This isn’‘t actually a question. It’‘s a feature request, except that I’'m planning to do it myself – at least minimally – so it may become a feature contribution (assuming I can get it to work).
But if I’‘m missing some obvious approach, please tell me. I’‘ve been staring at this all day, and I don’'t see any alternative except to start hacking the library code.
I want to send add extra information to all presence packets that I send out. (Both regular presence and MUC presence.) This is for JEP-0115 – but there are probably other situations where people want to do stuff like that.
Smack provides no way to do this. The calls to construct Presence packets are hardwired. My most extreme idea was to subclass XMPPConnection and MultiUserChat… but I can’'t even do that, because all the fields of those classes are private.
So my current plan is to change all the “new Presence()” lines in Smack to, say, “connection.callPresenceFactory”. And then add a way to set a presence factory function. The default factory churns out ordinary Presence packets; then I can customize it to create JEP-0115 packets.
Similarly, I want to put extension forms into disco#info replies. ServiceDiscoveryManager doesn’‘t let me do this – and I can’‘t replace ServiceDiscoveryManager, because it installs itself automatically and there’'s no way to uninstall it. So, again, I need to go in and put in a factory function.
The more general request is, this would be much easier if the Smack code didn’'t mark so much stuff as private. Classes like Roster and ServiceDiscoveryManager should be easily subclassable. (And then created from factories, so that you can do something useful with the subclasses.)
As I said, I plan to do this work. At least for disco and presence. I’‘m working off of Smack 1.5.1, though. (We’'ve already got a big application running with that version.)
I think this is a valuable feature, but – well, of course I think that. It’‘s a pretty invasive change, obviously. I hate to drop in and say “Please redesign your basic architecture for me,” even if I can offer a small part of the redesign as a patch. (Which I hope I can offer in a few days.) But, it’'s what I need for this project.
Comments? Am I going about this completely the wrong way? Is this proposal repugnant to the underlying intent of Smack?