Re: gloox 0.7 final
From: Jakob Schroeter <js@xxxxxxxxxx>
Date: Sat, 05 Nov 2005 22:08:03 +0100
Hi Lou,

On Saturday November 5 2005 20:09, you wrote:
> I am implementing RosterListener.  When a user goes "away", I get an
> itemChanged event.  When that user comes back, I get an itemAvailable
> event.  Is that the way it is supposed to work?  I would have expected
> to get another itemChanged event when they come back.

Well, sort of. On XML level both events are identical. An app has to track on 
its own whether a user was away or offline when an 'available' presence 
arrives. The RosterManager currently just forwards the event.
There is certainly room for improvement here.


> I am trying to work around that behaviour, and it is certainly doable,
> but, from my POV, it doesn't seem quite right.

How about the attached patch, does it achieve what you expect?

cheers,
Jakob
Index: rostermanager.cpp
===================================================================
--- rostermanager.cpp   (Revision 879)
+++ rostermanager.cpp   (Arbeitskopie)
@@ -111,13 +111,20 @@
     RosterListener::Roster::iterator it = m_roster.find( stanza->from().bare() 
);
     if( it != m_roster.end() )
     {
+      PresenceStatus oldStat = (*it).second->status();
+
       (*it).second->setStatus( stanza->show() );
       (*it).second->setStatusMsg( stanza->status() );
 
       if( m_rosterListener )
       {
         if( stanza->show() == PRESENCE_AVAILABLE )
-          m_rosterListener->itemAvailable( (*(*it).second), stanza->status() );
+        {
+          if( oldStat == PRESENCE_UNAVAILABLE )
+            m_rosterListener->itemAvailable( (*(*it).second), stanza->status() 
);
+          else
+            m_rosterListener->itemChanged( (*(*it).second), stanza->show(), 
stanza->status() );
+        }
         else if( stanza->show() == PRESENCE_UNAVAILABLE )
           m_rosterListener->itemUnavailable( (*(*it).second), stanza->status() 
);
         else

Attachment: pgpZMcKe4aWGz.pgp
Description: PGP signature

-- 
gloox-dev mailing list
to unsubscribe:
send a message with subject 'unsubscribe gloox-dev' to minimalist@xxxxxxxxxx