I’‘m trying to get a better understanding of the difference between these two interfaces and when it is better to use which. My scenario is that I have a wildfire plugin that attaches some information to each user’‘s Presence on the server. What I want to do is have a spark client plugin that is able to handle the modified Presence object being sent to the spark clients and have my code update each of the contacts’’ presence info displayed in the client.
Based on the API docs, both these interfaces seem to capture when a user’'s presence changes. My question is “which should I use to be able to examine the custom presence object sent from the server?”
It would seem to me that using PresenceListener is a better choice.
A ContactItem is represented more of an Item in your ContactList.
A ContactItemListener would be more towards keeping track of a Presence on a specific user.
Like say you want a special alert when a contact becomes available.
PresenceListener grabs a Presence object and has better lower access.
A ContactItem is a subclass of JPanel. So it is more of an UI type Object.
This is just my thoughts on this matter.
Hope this helps at all.
I did some more searching of the APIs and found the correct way to get this done. I actually did not need the PresenceListener or the ContactItemHandler. Turns out the correct approach was having my plugin implement the PacketListener interface from the smack library. This interface allows you to intercept packets sent from the server to the client. In particular, the PacketExtensionFilter came in handy because on the server the custom Presence object I send to clients is actuall a PacketExtension.
The PresenceListener and ContactItemHandler interfaces seem to be geared more toward presence changes originating from the IM client and being sent to the server.