[JDEV] AIM transport as ICQ transport replacement, away status diff
M.Kiesel
m.kiesel at iname.com
Tue Nov 13 01:39:15 CST 2001
Hi!
As you probably know the AIM transport can be used as an ICQ transport
replacement (just use your UIN as screen name when registering). In fact,
AIM transport is reliable in contrast to ICQ transport. Here, no messages
were dropped as long as my contacts use newer (= working) ICQ clients (or
Jabber :-).
One problem was that the away status of ICQ contacts did not show (Away,
DND, NA were displayed as "Online") as well as my status was "Online" all
the time.
This patch partly solves this issue. Own status still is "Online" but
the status of other ICQ contacts is shown properly. Also status updates
seem not to work properly.
Perhaps someone improves this further... just a quick hack and I'm no C
guru ;-).
Regards
M.Kiesel
--- 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,37 @@
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&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