[JDEV] AIM transport as ICQ transport replacement, away status diff

David Sutton dsutton at legend.co.uk
Wed Nov 14 08:27:05 CST 2001


Hello,

  I've made a quick change to your hack so it also understands 'Free for
Chat' mode as 'Chat' and not as 'xa'

David

--- buddies.c	2001/05/16 21:21:04	1.39
+++ buddies.c	2001/11/13 07:39:48
@@ -232,6 +232,7 @@
     char *msg;
     struct aim_userinfo_s *userinfo;
     int was_away;
+    int is_icq_user;
 
     va_list ap;
     va_start(ap, command);
@@ -265,14 +266,27 @@
     buddy->idle_time = userinfo->idletime;
 
     was_away = buddy->is_away;
-    if(userinfo->flags&AIM_FLAG_AWAY) 
-        buddy->is_away = 1;
+    if((userinfo->flags == 80)&&(userinfo->icqinfo.status != 0))
+    {
+        is_icq_user = 1;
+        buddy->is_away = userinfo->icqinfo.status;
+    }
     else
-        buddy->is_away = 0;
+    {
+        is_icq_user = 0;
+        if(userinfo->flags&AIM_FLAG_AWAY) 
+            buddy->is_away = 1;
+        else
+            buddy->is_away = 0;
+    }
+
+//    log_warn(ZONE, "[AT] userinfo-flags %d for %s", userinfo->flags, userinfo->sn);
+//    log_warn(ZONE, "[AT] userinfo-status %d, is_icq %d", userinfo->icqinfo.status, is_icq_user);
 
-    if(buddy->is_away == 0 && (buddy->is_away != was_away))
+    if(((buddy->is_away == 0) || is_icq_user) && (buddy->is_away != was_away))
     {
         char *status_msg;
+        char *show;
 
         x = xmlnode_new_tag("presence");
 	    xmlnode_put_attrib(x, "to", jid_full(s->cur));
@@ -280,9 +294,39 @@
 	    jp = jpacket_new(x);
     	jid_set(jp->from, at_normalize(userinfo->sn), JID_USER);
 	    xmlnode_put_attrib(jp->x, "from", jid_full(jp->from));
-        status = xmlnode_insert_tag(x, "status");
-        status_msg = pmalloco(xmlnode_pool(x), 30);
-        sprintf(status_msg, "Online (Idle %d Seconds)", buddy->idle_time);
+        if((!is_icq_user) || (is_icq_user && (buddy->is_away == 0)))
+        {
+            status = xmlnode_insert_tag(x, "status");
+            status_msg = pmalloco(xmlnode_pool(x), 30);
+            if(!is_icq_user)
+                sprintf(status_msg, "Online (Idle %d Seconds)", buddy->idle_time);
+            else
+                sprintf(status_msg, "Online");
+        }
+        else
+        {
+            status = xmlnode_insert_tag(x, "show");
+            show = pmalloco(xmlnode_pool(x), 30);
+            if(buddy->is_away&32)
+                sprintf(show, "chat");
+            else if(buddy->is_away&16)
+                sprintf(show, "dnd");
+            else if(buddy->is_away&4)
+                sprintf(show, "xa"); /* na really */
+            else if(buddy->is_away&2)
+                sprintf(show, "dnd");
+            else if(buddy->is_away&1)
+                sprintf(show, "away");
+            else
+                sprintf(show, "xa");
+            xmlnode_insert_cdata(status, show, -1);
+            status = xmlnode_insert_tag(x, "status");
+            status_msg = pmalloco(xmlnode_pool(x), 30);
+            if(buddy->is_away&4)
+                sprintf(status_msg, "not available");
+            else
+                sprintf(status_msg, "%s", show);
+        }
         xmlnode_insert_cdata(status, status_msg, -1);
         deliver(dpacket_new(jp->x), ti->i);
     } 






More information about the JDev mailing list