I wanted to add an XEP-0172 nickname (distinct from XEP-0144, such helpful naming eh ) to subscription requests. The method to sendSubscriptionRequest is in Smack Core however, and the Nick ExtensionElement in Smack-Extension, meaning I could not simply import it.
I got around this by creating a setter which could be called in the client code with knowledge of all of Smack to set a global setter for this method:
public interface RosterPresenceStanzaEnhancer {
void addNick(PresenceBuilder stanza, String nick);
}
public void setRosterPresenceStanzaEnhancer(RosterPresenceStanzaEnhancer stanzaEnhancer) {
rosterPresenceStanzaEnhancer = stanzaEnhancer;
}
where the enhancer is called within sendSubscriptionRequest like so:
if (rosterPresenceStanzaEnhancer != null) {
rosterPresenceStanzaEnhancer.addNick(presenceBuilder, nick);
}
Needless to say this is pretty ugly. Is there an existing paradigm for knowledge of non Smack-Core classes?
Yeh, keeping it general is cleaner than fudging knowledge of the Nick class specifically, and the calling code will have the global Smack knowledge. Great. I’ll look to get that changed in our fork and upstream.
I have 3 open PRs on Smack at the moment, do you need anything from me to progress?
I am sorry, but I am currently overloaded with work. I suggest you pick the PR of yours with the best effort/benefit ratio and we focus on this PR first. Then we pick we next one and handle one PR at a time this way.