changeset 25953:cf29591fe78a

Only update the idle time on a buddy when getting info if the buddy already has an idle time set. This will avoid setting idle time on a resource that won't send an updated idle (going unidle) in a <presence/> later on (thus getting "stuck" idle).
author Marcus Lundblad <ml@update.uu.se>
date Thu, 25 Dec 2008 10:48:49 +0000
parents 6185767dc03c
children f2d533384535
files libpurple/protocols/jabber/buddy.c
diffstat 1 files changed, 17 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/buddy.c	Wed Dec 24 22:51:16 2008 +0000
+++ b/libpurple/protocols/jabber/buddy.c	Thu Dec 25 10:48:49 2008 +0000
@@ -1646,15 +1646,26 @@
                     if (jb) {
                         resource = jabber_get_resource(from);
                         buddy_name = jabber_get_bare_jid(from);
+                        /* if the resource already has an idle time set, we
+                         must have gotten it originally from a presence. In
+                         this case we update it. Otherwise don't update it, to
+                         avoid setting an idle and not getting informed about
+                         the resource getting unidle */
                         if (resource && buddy_name) {
                             jbr = jabber_buddy_find_resource(jb, resource);
-                            jbr->idle = time(NULL) - sec;
                             
-                            if (jbr == 
-                                jabber_buddy_find_resource(jb, NULL) &&
-                                jbr->idle) {
-                                purple_prpl_got_user_idle(js->gc->account, 
-                                    buddy_name, jbr->idle, jbr->idle);
+                            if (jbr->idle) {
+                                if (sec) {
+                                    jbr->idle = time(NULL) - sec;
+                                } else {
+                                    jbr->idle = 0;
+                                }
+                            
+                                if (jbr == 
+                                    jabber_buddy_find_resource(jb, NULL)) {
+                                    purple_prpl_got_user_idle(js->gc->account, 
+                                        buddy_name, jbr->idle, jbr->idle);
+                                }
                             }
                         }
                         g_free(resource);