# HG changeset patch # User Paul Aurich # Date 1243827242 0 # Node ID 5ff1d66e6aefd6facb7484dded9aa1b74c6d4c2d # Parent a9f5afce8f399cb179cde4225df25a3494b0f76d Convert zephyr to use purple_find_buddies. This code had no hope of compiling previously on win32, but might be able to now. diff -r a9f5afce8f39 -r 5ff1d66e6aef libpurple/protocols/zephyr/zephyr.c --- a/libpurple/protocols/zephyr/zephyr.c Mon Jun 01 02:28:39 2009 +0000 +++ b/libpurple/protocols/zephyr/zephyr.c Mon Jun 01 03:34:02 2009 +0000 @@ -1254,45 +1254,32 @@ #ifdef WIN32 -static gint check_loc(gpointer_data) +static gint check_loc(gpointer data) { - PurpleBlistNode *gnode, *cnode, *bnode; + GSList *buddies; ZLocations_t locations; + PurpleConnection *gc = data; + zephyr_account *zephyr = gc->proto_data; + PurpleAccount *account = purple_connection_get_account(gc); int numlocs; int one = 1; - 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 = 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 = 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 (purple_buddy_get_account(b)->gc == zgc) { - char *chk; - const char *bname = purple_buddy_get_name(b); - chk = local_zephyr_normalize(bname); - ZLocateUser(chk,&numlocs, ZAUTH); - if (numlocs) { - int i; - for(i=0;idata; + char *chk; + 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; @@ -1312,65 +1299,49 @@ ald.version = NULL; } - 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 = 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 = purple_blist_node_get_first_child(cnode); - bnode; - bnode = purple_blist_node_get_sibling_next(bnode)) { - PurpleBuddy *b = (PurpleBuddy *) bnode; + for (buddies = purple_find_buddies(account, NULL); buddies; + buddies = g_slist_delete_link(buddies, buddies)) { + PurpleBuddy *b = buddies->data; - if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) - continue; - if (purple_buddy_get_account(b) == account) { - const char *chk; - const char *name = purple_buddy_get_name(b); + const char *chk; + const char *name = purple_buddy_get_name(b); - 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)) { + 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)) { #ifdef WIN32 - int numlocs; - int one=1; - ZLocateUser(chk,&numlocs,ZAUTH); - if (numlocs) { - int i; - for(i=0;i0) - purple_prpl_got_user_status(account,name,"available",NULL); - else - purple_prpl_got_user_status(account,name,"offline",NULL); - } - } -#else - ZRequestLocations(chk, &ald, UNACKED, ZAUTH); - g_free(ald.user); - g_free(ald.version); -#endif /* WIN32 */ - } else - if (use_tzc(zephyr)) { - gchar *zlocstr = g_strdup_printf("((tzcfodder . zlocate) \"%s\")\n",chk); - size_t len = strlen(zlocstr); - size_t result = write(zephyr->totzc[ZEPHYR_FD_WRITE],zlocstr,len); - if (result != len) { - purple_debug_error("zephyr", "Unable to write a message: %s\n", g_strerror(errno)); - } - g_free(zlocstr); - } + int numlocs; + int one=1; + ZLocateUser(chk,&numlocs,ZAUTH); + if (numlocs) { + int i; + for(i=0;i0) + purple_prpl_got_user_status(account,name,"available",NULL); + else + purple_prpl_got_user_status(account,name,"offline",NULL); } } - } +#else + ZRequestLocations(chk, &ald, UNACKED, ZAUTH); + g_free(ald.user); + g_free(ald.version); +#endif /* WIN32 */ + } else + if (use_tzc(zephyr)) { + gchar *zlocstr = g_strdup_printf("((tzcfodder . zlocate) \"%s\")\n",chk); + size_t len = strlen(zlocstr); + size_t result = write(zephyr->totzc[ZEPHYR_FD_WRITE],zlocstr,len); + if (result != len) { + purple_debug_error("zephyr", "Unable to write a message: %s\n", g_strerror(errno)); + } + g_free(zlocstr); + } } - + return TRUE; }