diff -r 009f3ea55124 -r 7c494d2bc5e4 libpurple/protocols/zephyr/zephyr.c --- a/libpurple/protocols/zephyr/zephyr.c Fri Dec 12 17:18:59 2008 +0000 +++ b/libpurple/protocols/zephyr/zephyr.c Fri Dec 12 20:03:58 2008 +0000 @@ -732,7 +732,7 @@ return ret; } -static gboolean pending_zloc(zephyr_account *zephyr,char *who) +static gboolean pending_zloc(zephyr_account *zephyr, const char *who) { GList *curr; @@ -771,6 +771,8 @@ int nlocs; char *user; PurpleBuddy *b; + const char *bname; + /* XXX add real error reporting */ if (ZParseLocations(¬ice, NULL, &nlocs, &user) != ZERR_NONE) return; @@ -780,15 +782,19 @@ b = purple_find_buddy(gc->account,stripped_user); g_free(stripped_user); } - if ((b && pending_zloc(zephyr,b->name)) || pending_zloc(zephyr,user)) { + + bname = b ? purple_buddy_get_name(b) : NULL; + if ((b && pending_zloc(zephyr,bname)) || pending_zloc(zephyr,user)) { ZLocations_t locs; int one = 1; PurpleNotifyUserInfo *user_info = purple_notify_user_info_new(); char *tmp; + const char *balias; - purple_notify_user_info_add_pair(user_info, _("User"), (b ? b->name : user)); - if (b && b->alias) - purple_notify_user_info_add_pair(user_info, _("Alias"), b->alias); + purple_notify_user_info_add_pair(user_info, _("User"), (b ? bname : user)); + balias = purple_buddy_get_local_buddy_alias(b); + if (b && balias) + purple_notify_user_info_add_pair(user_info, _("Alias"), balias); if (!nlocs) { purple_notify_user_info_add_pair(user_info, NULL, _("Hidden or not logged-in")); @@ -801,14 +807,14 @@ purple_notify_user_info_add_pair(user_info, _("Location"), tmp); g_free(tmp); } - purple_notify_userinfo(gc, (b ? b->name : user), + purple_notify_userinfo(gc, (b ? bname : user), user_info, NULL, NULL); purple_notify_user_info_destroy(user_info); } else { if (nlocs>0) - purple_prpl_got_user_status(gc->account, b ? b->name : user, "available", NULL); + purple_prpl_got_user_status(gc->account, b ? bname : user, "available", NULL); else - purple_prpl_got_user_status(gc->account, b ? b->name : user, "offline", NULL); + purple_prpl_got_user_status(gc->account, b ? bname : user, "offline", NULL); } g_free(user); @@ -1141,6 +1147,7 @@ /* XXX fix */ char *user; PurpleBuddy *b; + const char *bname; int nlocs = 0; parse_tree *locations; gchar *locval; @@ -1160,15 +1167,18 @@ nlocs = 1; } - if ((b && pending_zloc(zephyr,b->name)) || pending_zloc(zephyr,user) || pending_zloc(zephyr,local_zephyr_normalize(zephyr,user))){ + bname = b ? purple_buddy_get_name(b) : NULL; + if ((b && pending_zloc(zephyr,bname)) || pending_zloc(zephyr,user) || pending_zloc(zephyr,local_zephyr_normalize(zephyr,user))){ PurpleNotifyUserInfo *user_info = purple_notify_user_info_new(); char *tmp; + const char *balias; - purple_notify_user_info_add_pair(user_info, _("User"), (b ? b->name : user)); + purple_notify_user_info_add_pair(user_info, _("User"), (b ? bname : user)); - if (b && b->alias) - purple_notify_user_info_add_pair(user_info, _("Alias"), b->alias); - + balias = b ? purple_buddy_get_local_buddy_alias(b) : NULL; + if (balias) + purple_notify_user_info_add_pair(user_info, _("Alias"), balias); + if (!nlocs) { purple_notify_user_info_add_pair(user_info, NULL, _("Hidden or not logged-in")); } else { @@ -1179,14 +1189,14 @@ g_free(tmp); } - purple_notify_userinfo(gc, b ? b->name : user, + purple_notify_userinfo(gc, b ? bname : user, user_info, NULL, NULL); purple_notify_user_info_destroy(user_info); } else { if (nlocs>0) - purple_prpl_got_user_status(gc->account, b ? b->name : user, "available", NULL); + purple_prpl_got_user_status(gc->account, b ? bname : user, "available", NULL); else - purple_prpl_got_user_status(gc->account, b ? b->name : user, "offline", NULL); + purple_prpl_got_user_status(gc->account, b ? bname : user, "offline", NULL); } } else if (!g_ascii_strncasecmp(spewtype,"subscribed",10)) { @@ -1246,38 +1256,44 @@ static gint check_loc(gpointer_data) { - PurpleBlistNode *gnode, *cnode, *bnode; - ZLocations_t locations; - int numlocs; - int one = 1; + PurpleBlistNode *gnode, *cnode, *bnode; + ZLocations_t locations; + int numlocs; + int one = 1; - for (gnode = purple_get_blist()->root; gnode; gnode = gnode->next) { + for (gnode = purple_blist_get_root(); gnode; + gnode = purple_blist_node_get_sibling_next(gnode)) { if (!PURPLE_BLIST_NODE_IS_GROUP(gnode)) continue; - for (cnode = gnode->child; cnode; cnode = cnode->next) { + for (cnode = purple_blist_node_get_first_child(gnode); + cnode; + cnode = purple_blist_node_get_sibling_next(cnode)) { if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) continue; - for (bnode = cnode->child; bnode; bnode = bnode->next) { + for (bnode = purple_blist_node_get_first_child(cnode); + bnode; + bnode = purple_blist_node_get_sibling_next(bnode)) { PurpleBuddy *b = (PurpleBuddy *) bnode; if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) continue; - if (b->account->gc == zgc) { + if (purple_buddy_get_account(b)->gc == zgc) { char *chk; - chk = local_zephyr_normalize(b->name); - ZLocateUser(chk,&numlocs, ZAUTH); - if (numlocs) { - int i; - for(i=0;iname,1,0,0,0,0); - } - } - } - } - } - } - return TRUE; + const char *bname = purple_buddy_get_name(b); + chk = local_zephyr_normalize(bname); + ZLocateUser(chk,&numlocs, ZAUTH); + if (numlocs) { + int i; + for(i=0;iproto_data; + PurpleAccount *account = purple_connection_get_account(gc); if (use_zeph02(zephyr)) { ald.user = NULL; @@ -1295,22 +1312,28 @@ ald.version = NULL; } - for (gnode = purple_get_blist()->root; gnode; gnode = gnode->next) { + for (gnode = purple_blist_get_root(); gnode; + gnode = purple_blist_node_get_sibling_next(gnode)) { if (!PURPLE_BLIST_NODE_IS_GROUP(gnode)) continue; - for (cnode = gnode->child; cnode; cnode = cnode->next) { + for (cnode = purple_blist_node_get_first_child(gnode); + cnode; + cnode = purple_blist_node_get_sibling_next(cnode)) { if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) continue; - for (bnode = cnode->child; bnode; bnode = bnode->next) { + for (bnode = purple_blist_node_get_first_child(cnode); + bnode; + bnode = purple_blist_node_get_sibling_next(bnode)) { PurpleBuddy *b = (PurpleBuddy *) bnode; if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) continue; - if (b->account->gc == gc) { + if (purple_buddy_get_account(b) == account) { const char *chk; + const char *name = purple_buddy_get_name(b); - chk = local_zephyr_normalize(zephyr,b->name); - purple_debug_info("zephyr","chk: %s b->name %s\n",chk,b->name); + chk = local_zephyr_normalize(zephyr,name); + purple_debug_info("zephyr","chk: %s b->name %s\n",chk,name); /* XXX add real error reporting */ /* doesn't matter if this fails or not; we'll just move on to the next one */ if (use_zeph02(zephyr)) { @@ -1323,9 +1346,9 @@ for(i=0;i0) - purple_prpl_got_user_status(gc->account,b->name,"available",NULL); + purple_prpl_got_user_status(account,name,"available",NULL); else - purple_prpl_got_user_status(gc->account,b->name,"offline",NULL); + purple_prpl_got_user_status(account,name,"offline",NULL); } } #else @@ -1936,6 +1959,7 @@ PurpleBuddy *b; char *fname; FILE *fd; + PurpleAccount *account; zephyr_account* zephyr = gc->proto_data; fname = g_strdup_printf("%s/.anyone", purple_home_dir()); fd = g_fopen(fname, "w"); @@ -1944,18 +1968,25 @@ return; } - for (gnode = purple_get_blist()->root; gnode; gnode = gnode->next) { + account = purple_connection_get_account(gc); + for (gnode = purple_blist_get_root(); + gnode; + gnode = purple_blist_node_get_sibling_next(gnode)) { if (!PURPLE_BLIST_NODE_IS_GROUP(gnode)) continue; - for (cnode = gnode->child; cnode; cnode = cnode->next) { + for (cnode = purple_blist_node_get_first_child(gnode); + cnode; + cnode = purple_blist_node_get_sibling_next(cnode)) { if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) continue; - for (bnode = cnode->child; bnode; bnode = bnode->next) { + for (bnode = purple_blist_node_get_first_child(cnode); + bnode; + bnode = purple_blist_node_get_sibling_next(bnode)) { if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) continue; b = (PurpleBuddy *) bnode; - if (b->account == gc->account) { - gchar *stripped_user = zephyr_strip_local_realm(zephyr,b->name); + if (purple_buddy_get_account(b) == account) { + gchar *stripped_user = zephyr_strip_local_realm(zephyr, purple_buddy_get_name(b)); fprintf(fd, "%s\n", stripped_user); g_free(stripped_user); } @@ -2498,26 +2529,31 @@ PurpleBlistNode *gnode, *cnode; /* XXX needs to be %host%,%canon%, and %me% clean */ - for(gnode = purple_get_blist()->root; gnode; gnode = gnode->next) { - for(cnode = gnode->child; cnode; cnode = cnode->next) { + for(gnode = purple_blist_get_root(); gnode; + gnode = purple_blist_node_get_sibling_next(gnode)) { + for(cnode = purple_blist_node_get_first_child(gnode); + cnode; + cnode = purple_blist_node_get_sibling_next(cnode)) { PurpleChat *chat = (PurpleChat*)cnode; char *zclass, *inst, *recip; char** triple; + GHashTable *components; if(!PURPLE_BLIST_NODE_IS_CHAT(cnode)) continue; - if(chat->account !=account) - continue; - if(!(zclass = g_hash_table_lookup(chat->components, "class"))) + if(purple_chat_get_account(chat) != account) continue; - if(!(inst = g_hash_table_lookup(chat->components, "instance"))) + components = purple_chat_get_components(chat); + if(!(zclass = g_hash_table_lookup(components, "class"))) + continue; + if(!(inst = g_hash_table_lookup(components, "instance"))) inst = g_strdup(""); - if(!(recip = g_hash_table_lookup(chat->components, "recipient"))) + if(!(recip = g_hash_table_lookup(components, "recipient"))) recip = g_strdup(""); /* purple_debug_info("zephyr","in zephyr_find_blist_chat name: %s\n",name?name:""); */ triple = g_strsplit(name,",",3); if (!g_ascii_strcasecmp(triple[0],zclass) && !g_ascii_strcasecmp(triple[1],inst) && !g_ascii_strcasecmp(triple[2],recip)) return chat; - + } } return NULL;