I wrote an application that uses Smack library for entegration with MSN and Gtalk communities. My application works successfully.
Hereby, i am giving thanks to all of the Smack developers and Smack fans.
I want to differentiate picture change from other presence actions. But all presence activities (including picture update) coming to presenceChanged handler.
I used CreateRosterListener for getting picture updates but all of the presence packet’s coming to presenceChanged method.
Here is my CreateRosterListener for getting picture changes :
...
...
... public void CreateRosterListener(Roster roster) {
roster.addRosterListener(new RosterListener() { public void entriesAdded(Collection addresses) { for (Iterator iterator = addresses.iterator(); iterator.hasNext();) {
String name = (String) iterator.next(); logger.debug("Entry added:" + name);
} } public void entriesDeleted(Collection addresses) { for (Iterator iterator = addresses.iterator(); iterator.hasNext();) {
String name = (String) iterator.next(); logger.debug("Entry deleted:" + name);
} } public void entriesUpdated(Collection addresses) { for (Iterator iterator = addresses.iterator(); iterator.hasNext();) {
String name = (String) iterator.next(); logger.debug("Entry updated:" + name);
} } public void presenceChanged(Presence presence) { logger.debug("connection.getUser:" + connection.getUser());
//Presence myPresence = connection.getRoster().getPresence(connection.getUser()); logger.debug("Presence changed: " + presence.getFrom() + " " + presence + "\n"); } });
}
..
..
..
Thanks for your cooperation. Unfortunately this solution doesn’t work for MSN community. Because Microsoft sends vcard-temp:x:update in every presence change. (online,offline,etc.) Anyway thank you so much.
Finally, they sent me this answer for this problem :
"Our Messenger XMPP service supports getting the display picture at the beginning of a session. However, any updates that happen during that session won’t cause notifications or broadcast of the change.
Alternatively, your app could do a periodic request for the display picture if the app wants to make sure it is recent within a given time period. For example, the app could make a periodic request for the picture, say every 12 hours. Then the picture would be relatively recent than if you checked for it, say once a week"
Conforming to XEP-0153, it is a normal behavior to send the “vacrd-temp:x:update” in every presence message. That is why, when receiving a presence message with the “vacrd-temp:x:update” extension, you have to compare:
the avatar image SHA-1 hash included in the data in the “photo” tag of this presence message.
with the SHA-1 hash of the current avatar image for the corresponding contact.
If they differ, then request the contact vCard which contains the new avatar image in the “binval” tag inside the “photo” tag.
For example, the “parseContactPhotoPresence(Packet packet)” function in "http://java.net/projects/jitsi/sources/svn/content/trunk/src/net/java/sip/commun icator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java?rev=94 71 " is responsible to check whether or not the avatar image has been updated (SHA-1 hash comparison and vCard photo retrieval). This function is called by the listener described in my previous post.