Mercurial > pidgin.yaz
changeset 4759:1762496d502a
[gaim-migrate @ 5076]
This caches ICQ remote nicks in your local blist.xml file. It's really
not a great thing to do, but it's better than what we do currently.
I want to make Gaim request the remote nick every now and then to see
if it's changed.
Anyhow, like all things I've done recently, it's slightly ugly.
And I can't test the get-alias-when-adding-icq-buddy thing until
Sean commits his buddy list editing stuff later tonight, but it should
work like a charm.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 14 Mar 2003 03:09:54 +0000 |
parents | 2202f056a1c9 |
children | a979ce8ec806 |
files | src/protocols/oscar/aim.h src/protocols/oscar/aim_cbtypes.h src/protocols/oscar/icq.c src/protocols/oscar/oscar.c |
diffstat | 4 files changed, 109 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/oscar/aim.h Fri Mar 14 02:28:49 2003 +0000 +++ b/src/protocols/oscar/aim.h Fri Mar 14 03:09:54 2003 +0000 @@ -1306,6 +1306,7 @@ faim_export int aim_icq_hideip(aim_session_t *sess); faim_export int aim_icq_changepasswd(aim_session_t *sess, const char *passwd); faim_export int aim_icq_getsimpleinfo(aim_session_t *sess, const char *uin); +faim_export int aim_icq_getalias(aim_session_t *sess, const char *uin); faim_export int aim_icq_getallinfo(aim_session_t *sess, const char *uin);
--- a/src/protocols/oscar/aim_cbtypes.h Fri Mar 14 02:28:49 2003 +0000 +++ b/src/protocols/oscar/aim_cbtypes.h Fri Mar 14 03:09:54 2003 +0000 @@ -195,6 +195,7 @@ #define AIM_CB_ICQ_OFFLINEMSG 0x00f0 #define AIM_CB_ICQ_OFFLINEMSGCOMPLETE 0x00f1 #define AIM_CB_ICQ_INFO 0x00f2 +#define AIM_CB_ICQ_ALIAS 0x00f3 #define AIM_CB_ICQ_DEFAULT 0xffff /*
--- a/src/protocols/oscar/icq.c Fri Mar 14 02:28:49 2003 +0000 +++ b/src/protocols/oscar/icq.c Fri Mar 14 03:09:54 2003 +0000 @@ -189,6 +189,43 @@ return 0; } +faim_export int aim_icq_getalias(aim_session_t *sess, const char *uin) +{ + aim_conn_t *conn; + aim_frame_t *fr; + aim_snacid_t snacid; + int bslen; + + if (!uin || uin[0] < '0' || uin[0] > '9') + return -EINVAL; + + if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) + return -EINVAL; + + bslen = 2 + 4 + 2 + 2 + 2 + 4; + + if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) + return -ENOMEM; + + snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0); + aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid); + + /* For simplicity, don't bother using a tlvlist */ + aimbs_put16(&fr->data, 0x0001); + aimbs_put16(&fr->data, bslen); + + aimbs_putle16(&fr->data, bslen - 2); + aimbs_putle32(&fr->data, atoi(sess->sn)); + aimbs_putle16(&fr->data, 0x07d0); /* I command thee. */ + aimbs_putle16(&fr->data, snacid); /* eh. */ + aimbs_putle16(&fr->data, 0x04ba); /* shrug. */ + aimbs_putle32(&fr->data, atoi(uin)); + + aim_tx_enqueue(sess, fr); + + return 0; +} + faim_export int aim_icq_getsimpleinfo(aim_session_t *sess, const char *uin) { aim_conn_t *conn; @@ -448,6 +485,14 @@ case 0x00fa: { /* past background and current organizations */ } break; + case 0x0104: { /* alias info */ + info->nick = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); + info->first = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); + info->last = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); + aim_bstream_advance(&qbs, aimbs_getle16(&qbs)); /* email address? */ + /* Then 0x00 02 00 */ + } break; + case 0x010e: { /* unknown */ /* 0x00 00 */ } break; @@ -464,8 +509,13 @@ } /* End switch statement */ if (!(snac->flags & 0x0001)) { - if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO))) - ret = userfunc(sess, rx, info); + if (cmd != 0x104) + if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO))) + ret = userfunc(sess, rx, info); + + if (info->uin && info->nick) + if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS))) + ret = userfunc(sess, rx, info); if (sess->icq_info == info) { sess->icq_info = info->next;
--- a/src/protocols/oscar/oscar.c Fri Mar 14 02:28:49 2003 +0000 +++ b/src/protocols/oscar/oscar.c Fri Mar 14 03:09:54 2003 +0000 @@ -313,6 +313,7 @@ static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); +static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); static int gaim_popup (aim_session_t *, aim_frame_t *, ...); #ifndef NOSSI @@ -1069,6 +1070,7 @@ aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSG, gaim_offlinemsg, 0); aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSGCOMPLETE, gaim_offlinemsgdone, 0); aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); + aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); #ifndef NOSSI aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); @@ -3555,7 +3557,6 @@ buf = g_strdup_printf("<b>UIN:</b> %s", who); if (info->nick && info->nick[0]) { tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Nick:</b> ", info->nick, NULL); g_free(tmp); - serv_got_alias(gc, who, info->nick); } if (info->first && info->first[0]) { tmp = buf; buf = g_strconcat(tmp, "\n<br><b>First Name:</b> ", info->first, NULL); g_free(tmp); @@ -3656,6 +3657,30 @@ return 1; } +static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) +{ + struct gaim_connection *gc = sess->aux_data; + gchar who[16]; + struct buddy *b; + va_list ap; + struct aim_icq_info *info; + + va_start(ap, fr); + info = va_arg(ap, struct aim_icq_info *); + va_end(ap); + + if (info->uin && info->nick && info->nick[0]) { + g_snprintf(who, sizeof(who), "%lu", info->uin); + serv_got_alias(gc, who, info->nick); + if ((b = gaim_find_buddy(gc->account, who))) { + gaim_buddy_set_setting(b, "servernick", info->nick); + gaim_blist_save(); + } + } + + return 1; +} + static int gaim_popup(aim_session_t *sess, aim_frame_t *fr, ...) { char *msg, *url; @@ -4175,6 +4200,8 @@ } } #endif + if (od->icq) + aim_icq_getalias(od->sess, name); } static void oscar_add_buddies(struct gaim_connection *gc, GList *buddies) { @@ -4437,30 +4464,38 @@ if (tmp) gaim_blist_save(); - /* Add from local list to server list */ - if (gc) { + { /* Add from local list to server list */ + GaimBlistNode *gnode, *bnode; + struct group *group; + struct buddy *buddy; + struct gaim_buddy_list *blist; GSList *cur; /* Buddies */ - for (cur=groups; cur; cur=g_slist_next(cur)) { - GSList *curb; - struct group *group = cur->data; - for (curb=group->members; curb; curb=curb->next) { - struct buddy *buddy = curb->data; - if(buddy->account == gc->account) { - if (aim_ssi_itemlist_exists(sess->ssi.local, buddy->name)) { - /* Store local alias on server */ - char *alias = aim_ssi_getalias(sess->ssi.local, group->name, buddy->name); - if (!alias && buddy->alias[0]) - aim_ssi_aliasbuddy(sess, od->conn, group->name, buddy->name, buddy->alias); - free(alias); - } else { - debug_printf("ssi: adding buddy %s from local list to server list\n", buddy->name); - aim_ssi_addbuddy(sess, od->conn, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 0); + if ((blist = gaim_get_blist())) + for (gnode = blist->root; gnode; gnode = gnode->next) { + group = (struct group *)gnode; + for (bnode = gnode->child; bnode; bnode = bnode->next) { + buddy = (struct buddy *)bnode; + if (buddy->account == gc->account) { + gchar *servernick = gaim_buddy_get_setting(buddy, "servernick"); + if (servernick) { + serv_got_alias(gc, buddy->name, servernick); + g_free(servernick); + } + if (aim_ssi_itemlist_exists(sess->ssi.local, buddy->name)) { + /* Store local alias on server */ + char *alias = aim_ssi_getalias(sess->ssi.local, group->name, buddy->name); + if (!alias && buddy->alias) + aim_ssi_aliasbuddy(sess, od->conn, group->name, buddy->name, buddy->alias); + free(alias); + } else { + debug_printf("ssi: adding buddy %s from local list to server list\n", buddy->name); + aim_ssi_addbuddy(sess, od->conn, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 0); + } } } } - } /* Permit list */ if (gc->account->permit) { @@ -4504,7 +4539,7 @@ g_free(dialog_msg); } - } /* end if (gc) */ + } /* end adding buddies from local list to server list */ /* Activate SSI */ /* Sending the enable causes other people to be able to see you, and you to see them */