Is there a way to differentiate picture change from other presence actions?

Hello all,

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");             }         });
    }
..
..
..
1 Like

I wonder the same issue. Any comment?

1 Like

Hello again,

Are anybody to help me with this problem ? Any suggestions ?

I debuged presence traffic with the help of Smack Debug Window. And i release that there is a photo attribute in the incoming presence xml.

So i thought that I can make an assumption, if i compare old value with new incoming value.

<presence to="testxxx@gmail.com" from="qbeedickTEST@gmail.com/gmail.08CA655D">
  <status/>
  <priority>24</priority>
  <c xmlns="http://jabber.org/protocol/caps"/>
  <x xmlns="vcard-temp:x:update">
    <photo>7f5ce7d3c3d6976342d9c54e2a4b83711493d952</photo>
  </x>
</presence>

Do you have better solutions ?

Alper

Above solution doesn’t work for MSN community. Because they are sending null photo tag value in their presence packet.

I need help. Anybody there ???

I wonder whether Patch proposed to able VCard class to removes current avatar can help.

1 Like

Thank you. Good news for all but it is not related with differentiating picture change from other presence change activities.

My requirement is straight forward, so interesting that nobody else dealing with the same presence problem.

Hi,

Jitsi (http://jitsi.org) simply adds a packet listener with the following filters:


// Registers the listener to the Connection.

connection.addPacketListener(

new PacketListener()

{

public void processPacket(Packet packet)

{

// Calls a parser to manages this photo update presence packet.

parseContactPhotoPresence(packet);

}

},

// Creates a filter to only listen to presence packet with the

// element name “x” and the namespace “vcard-temp:x:update”.

new AndFilter(

new PacketTypeFilter(Presence.class),

new PacketExtensionFilter(“x”,“vcard-temp:x:update”)

)

);


Hope this helps.

Regards,

Vincent


Vincent Lucas, Ph.D. Jitsi developer

chenzo@jitsi.org http://jitsi.org

Hello Vincent,

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.

I’m talking Microsoft guys through this forum :

http://social.msdn.microsoft.com/Forums/en-US/messengerconnect/thread/da27af42-a 97c-4245-9e41-71180c82bde6

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"

Hello Alper,

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.

Regards,

Vincent


Vincent Lucas, Ph.D. Jitsi developer

chenzo@jitsi.org http://jitsi.org