pidgin: 34e3e539: Convert zephyr to use purple_find_buddie...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Mon Jun 1 00:25:29 EDT 2009
-----------------------------------------------------------------
Revision: 34e3e539a3dc505eed92c20b192370ed1651b96e
Ancestor: 1e3787263d0d1f22b698aa4b57f1d5605eac9934
Author: darkrain42 at pidgin.im
Date: 2009-06-01T03:34:02
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/34e3e539a3dc505eed92c20b192370ed1651b96e
Modified files:
libpurple/protocols/zephyr/zephyr.c
ChangeLog:
Convert zephyr to use purple_find_buddies.
This code had no hope of compiling previously on win32, but might be able to now.
-------------- next part --------------
============================================================
--- libpurple/protocols/zephyr/zephyr.c 17fe34c8f7d39f913d89d48fe11b6ecde7dd8fe8
+++ libpurple/protocols/zephyr/zephyr.c da7c4d206d99812dfe4c97059e8b2f68cf85d501
@@ -1254,45 +1254,32 @@ static gint check_notify_zeph02(gpointer
#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;i<numlocs;i++) {
- ZGetLocations(&locations,&one);
- serv_got_update(zgc,bname,1,0,0,0,0);
- }
- }
- }
+ for (buddies = purple_find_buddies(account, NULL); buddies;
+ buddies = g_slist_delete_link(buddies, buddies)) {
+ PurpleBuddy *b = buddies->data;
+ 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;i<numlocs;i++) {
+ ZGetLocations(&locations,&one);
+ serv_got_update(zgc,bname,1,0,0,0,0);
}
}
}
+
return TRUE;
}
@@ -1300,7 +1287,7 @@ static gint check_loc(gpointer data)
static gint check_loc(gpointer data)
{
- PurpleBlistNode *gnode, *cnode, *bnode;
+ GSList *buddies;
ZAsyncLocateData_t ald;
PurpleConnection *gc = (PurpleConnection *)data;
zephyr_account *zephyr = gc->proto_data;
@@ -1312,65 +1299,49 @@ static gint check_loc(gpointer data)
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;i<numlocs;i++) {
- ZGetLocations(&locations,&one);
- if (nlocs>0)
- purple_prpl_got_user_status(account,name,"available",NULL);
- else
- purple_prpl_got_user_status(account,name,"offline",NULL);
- }
- }
+ int numlocs;
+ int one=1;
+ ZLocateUser(chk,&numlocs,ZAUTH);
+ if (numlocs) {
+ int i;
+ for(i=0;i<numlocs;i++) {
+ ZGetLocations(&locations,&one);
+ if (nlocs>0)
+ 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);
+ 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);
- }
+ } 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;
}
More information about the Commits
mailing list