| 769 } else if (!g_ascii_strcasecmp(notice.z_class, LOCATE_CLASS)) { |
769 } else if (!g_ascii_strcasecmp(notice.z_class, LOCATE_CLASS)) { |
| 770 if (!g_ascii_strcasecmp(notice.z_opcode, LOCATE_LOCATE)) { |
770 if (!g_ascii_strcasecmp(notice.z_opcode, LOCATE_LOCATE)) { |
| 771 int nlocs; |
771 int nlocs; |
| 772 char *user; |
772 char *user; |
| 773 PurpleBuddy *b; |
773 PurpleBuddy *b; |
| |
774 const char *bname; |
| |
775 |
| 774 /* XXX add real error reporting */ |
776 /* XXX add real error reporting */ |
| 775 if (ZParseLocations(¬ice, NULL, &nlocs, &user) != ZERR_NONE) |
777 if (ZParseLocations(¬ice, NULL, &nlocs, &user) != ZERR_NONE) |
| 776 return; |
778 return; |
| 777 |
779 |
| 778 if ((b = purple_find_buddy(gc->account, user)) == NULL) { |
780 if ((b = purple_find_buddy(gc->account, user)) == NULL) { |
| 779 char* stripped_user = zephyr_strip_local_realm(zephyr,user); |
781 char* stripped_user = zephyr_strip_local_realm(zephyr,user); |
| 780 b = purple_find_buddy(gc->account,stripped_user); |
782 b = purple_find_buddy(gc->account,stripped_user); |
| 781 g_free(stripped_user); |
783 g_free(stripped_user); |
| 782 } |
784 } |
| 783 if ((b && pending_zloc(zephyr,b->name)) || pending_zloc(zephyr,user)) { |
785 |
| |
786 bname = b ? purple_buddy_get_name(b) : NULL; |
| |
787 if ((b && pending_zloc(zephyr,bname)) || pending_zloc(zephyr,user)) { |
| 784 ZLocations_t locs; |
788 ZLocations_t locs; |
| 785 int one = 1; |
789 int one = 1; |
| 786 PurpleNotifyUserInfo *user_info = purple_notify_user_info_new(); |
790 PurpleNotifyUserInfo *user_info = purple_notify_user_info_new(); |
| 787 char *tmp; |
791 char *tmp; |
| 788 |
792 const char *balias; |
| 789 purple_notify_user_info_add_pair(user_info, _("User"), (b ? b->name : user)); |
793 |
| 790 if (b && b->alias) |
794 purple_notify_user_info_add_pair(user_info, _("User"), (b ? bname : user)); |
| 791 purple_notify_user_info_add_pair(user_info, _("Alias"), b->alias); |
795 balias = purple_buddy_get_local_buddy_alias(b); |
| |
796 if (b && balias) |
| |
797 purple_notify_user_info_add_pair(user_info, _("Alias"), balias); |
| 792 |
798 |
| 793 if (!nlocs) { |
799 if (!nlocs) { |
| 794 purple_notify_user_info_add_pair(user_info, NULL, _("Hidden or not logged-in")); |
800 purple_notify_user_info_add_pair(user_info, NULL, _("Hidden or not logged-in")); |
| 795 } |
801 } |
| 796 for (; nlocs > 0; nlocs--) { |
802 for (; nlocs > 0; nlocs--) { |
| 799 ZGetLocations(&locs, &one); |
805 ZGetLocations(&locs, &one); |
| 800 tmp = g_strdup_printf(_("<br>At %s since %s"), locs.host, locs.time); |
806 tmp = g_strdup_printf(_("<br>At %s since %s"), locs.host, locs.time); |
| 801 purple_notify_user_info_add_pair(user_info, _("Location"), tmp); |
807 purple_notify_user_info_add_pair(user_info, _("Location"), tmp); |
| 802 g_free(tmp); |
808 g_free(tmp); |
| 803 } |
809 } |
| 804 purple_notify_userinfo(gc, (b ? b->name : user), |
810 purple_notify_userinfo(gc, (b ? bname : user), |
| 805 user_info, NULL, NULL); |
811 user_info, NULL, NULL); |
| 806 purple_notify_user_info_destroy(user_info); |
812 purple_notify_user_info_destroy(user_info); |
| 807 } else { |
813 } else { |
| 808 if (nlocs>0) |
814 if (nlocs>0) |
| 809 purple_prpl_got_user_status(gc->account, b ? b->name : user, "available", NULL); |
815 purple_prpl_got_user_status(gc->account, b ? bname : user, "available", NULL); |
| 810 else |
816 else |
| 811 purple_prpl_got_user_status(gc->account, b ? b->name : user, "offline", NULL); |
817 purple_prpl_got_user_status(gc->account, b ? bname : user, "offline", NULL); |
| 812 } |
818 } |
| 813 |
819 |
| 814 g_free(user); |
820 g_free(user); |
| 815 } |
821 } |
| 816 } else { |
822 } else { |
| 1158 nlocs = 0; |
1165 nlocs = 0; |
| 1159 } else { |
1166 } else { |
| 1160 nlocs = 1; |
1167 nlocs = 1; |
| 1161 } |
1168 } |
| 1162 |
1169 |
| 1163 if ((b && pending_zloc(zephyr,b->name)) || pending_zloc(zephyr,user) || pending_zloc(zephyr,local_zephyr_normalize(zephyr,user))){ |
1170 bname = b ? purple_buddy_get_name(b) : NULL; |
| |
1171 if ((b && pending_zloc(zephyr,bname)) || pending_zloc(zephyr,user) || pending_zloc(zephyr,local_zephyr_normalize(zephyr,user))){ |
| 1164 PurpleNotifyUserInfo *user_info = purple_notify_user_info_new(); |
1172 PurpleNotifyUserInfo *user_info = purple_notify_user_info_new(); |
| 1165 char *tmp; |
1173 char *tmp; |
| 1166 |
1174 const char *balias; |
| 1167 purple_notify_user_info_add_pair(user_info, _("User"), (b ? b->name : user)); |
1175 |
| 1168 |
1176 purple_notify_user_info_add_pair(user_info, _("User"), (b ? bname : user)); |
| 1169 if (b && b->alias) |
1177 |
| 1170 purple_notify_user_info_add_pair(user_info, _("Alias"), b->alias); |
1178 balias = b ? purple_buddy_get_local_buddy_alias(b) : NULL; |
| 1171 |
1179 if (balias) |
| |
1180 purple_notify_user_info_add_pair(user_info, _("Alias"), balias); |
| |
1181 |
| 1172 if (!nlocs) { |
1182 if (!nlocs) { |
| 1173 purple_notify_user_info_add_pair(user_info, NULL, _("Hidden or not logged-in")); |
1183 purple_notify_user_info_add_pair(user_info, NULL, _("Hidden or not logged-in")); |
| 1174 } else { |
1184 } else { |
| 1175 tmp = g_strdup_printf(_("<br>At %s since %s"), |
1185 tmp = g_strdup_printf(_("<br>At %s since %s"), |
| 1176 tree_child(tree_child(tree_child(tree_child(locations,2),0),0),2)->contents, |
1186 tree_child(tree_child(tree_child(tree_child(locations,2),0),0),2)->contents, |
| 1177 tree_child(tree_child(tree_child(tree_child(locations,2),0),2),2)->contents); |
1187 tree_child(tree_child(tree_child(tree_child(locations,2),0),2),2)->contents); |
| 1178 purple_notify_user_info_add_pair(user_info, _("Location"), tmp); |
1188 purple_notify_user_info_add_pair(user_info, _("Location"), tmp); |
| 1179 g_free(tmp); |
1189 g_free(tmp); |
| 1180 } |
1190 } |
| 1181 |
1191 |
| 1182 purple_notify_userinfo(gc, b ? b->name : user, |
1192 purple_notify_userinfo(gc, b ? bname : user, |
| 1183 user_info, NULL, NULL); |
1193 user_info, NULL, NULL); |
| 1184 purple_notify_user_info_destroy(user_info); |
1194 purple_notify_user_info_destroy(user_info); |
| 1185 } else { |
1195 } else { |
| 1186 if (nlocs>0) |
1196 if (nlocs>0) |
| 1187 purple_prpl_got_user_status(gc->account, b ? b->name : user, "available", NULL); |
1197 purple_prpl_got_user_status(gc->account, b ? bname : user, "available", NULL); |
| 1188 else |
1198 else |
| 1189 purple_prpl_got_user_status(gc->account, b ? b->name : user, "offline", NULL); |
1199 purple_prpl_got_user_status(gc->account, b ? bname : user, "offline", NULL); |
| 1190 } |
1200 } |
| 1191 } |
1201 } |
| 1192 else if (!g_ascii_strncasecmp(spewtype,"subscribed",10)) { |
1202 else if (!g_ascii_strncasecmp(spewtype,"subscribed",10)) { |
| 1193 } |
1203 } |
| 1194 else if (!g_ascii_strncasecmp(spewtype,"start",5)) { |
1204 else if (!g_ascii_strncasecmp(spewtype,"start",5)) { |
| 1244 |
1254 |
| 1245 #ifdef WIN32 |
1255 #ifdef WIN32 |
| 1246 |
1256 |
| 1247 static gint check_loc(gpointer_data) |
1257 static gint check_loc(gpointer_data) |
| 1248 { |
1258 { |
| 1249 PurpleBlistNode *gnode, *cnode, *bnode; |
1259 PurpleBlistNode *gnode, *cnode, *bnode; |
| 1250 ZLocations_t locations; |
1260 ZLocations_t locations; |
| 1251 int numlocs; |
1261 int numlocs; |
| 1252 int one = 1; |
1262 int one = 1; |
| 1253 |
1263 |
| 1254 for (gnode = purple_get_blist()->root; gnode; gnode = gnode->next) { |
1264 for (gnode = purple_blist_get_root(); gnode; |
| |
1265 gnode = purple_blist_node_get_sibling_next(gnode)) { |
| 1255 if (!PURPLE_BLIST_NODE_IS_GROUP(gnode)) |
1266 if (!PURPLE_BLIST_NODE_IS_GROUP(gnode)) |
| 1256 continue; |
1267 continue; |
| 1257 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
1268 for (cnode = purple_blist_node_get_first_child(gnode); |
| |
1269 cnode; |
| |
1270 cnode = purple_blist_node_get_sibling_next(cnode)) { |
| 1258 if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) |
1271 if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) |
| 1259 continue; |
1272 continue; |
| 1260 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
1273 for (bnode = purple_blist_node_get_first_child(cnode); |
| |
1274 bnode; |
| |
1275 bnode = purple_blist_node_get_sibling_next(bnode)) { |
| 1261 PurpleBuddy *b = (PurpleBuddy *) bnode; |
1276 PurpleBuddy *b = (PurpleBuddy *) bnode; |
| 1262 |
1277 |
| 1263 if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) |
1278 if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) |
| 1264 continue; |
1279 continue; |
| 1265 if (b->account->gc == zgc) { |
1280 if (purple_buddy_get_account(b)->gc == zgc) { |
| 1266 char *chk; |
1281 char *chk; |
| 1267 chk = local_zephyr_normalize(b->name); |
1282 const char *bname = purple_buddy_get_name(b); |
| 1268 ZLocateUser(chk,&numlocs, ZAUTH); |
1283 chk = local_zephyr_normalize(bname); |
| 1269 if (numlocs) { |
1284 ZLocateUser(chk,&numlocs, ZAUTH); |
| 1270 int i; |
1285 if (numlocs) { |
| 1271 for(i=0;i<numlocs;i++) { |
1286 int i; |
| 1272 ZGetLocations(&locations,&one); |
1287 for(i=0;i<numlocs;i++) { |
| 1273 serv_got_update(zgc,b->name,1,0,0,0,0); |
1288 ZGetLocations(&locations,&one); |
| 1274 } |
1289 serv_got_update(zgc,bname,1,0,0,0,0); |
| 1275 } |
1290 } |
| 1276 } |
1291 } |
| 1277 } |
1292 } |
| 1278 } |
1293 } |
| 1279 } |
1294 } |
| 1280 return TRUE; |
1295 } |
| |
1296 return TRUE; |
| 1281 } |
1297 } |
| 1282 |
1298 |
| 1283 #else |
1299 #else |
| 1284 |
1300 |
| 1285 static gint check_loc(gpointer data) |
1301 static gint check_loc(gpointer data) |
| 1286 { |
1302 { |
| 1287 PurpleBlistNode *gnode, *cnode, *bnode; |
1303 PurpleBlistNode *gnode, *cnode, *bnode; |
| 1288 ZAsyncLocateData_t ald; |
1304 ZAsyncLocateData_t ald; |
| 1289 PurpleConnection *gc = (PurpleConnection *)data; |
1305 PurpleConnection *gc = (PurpleConnection *)data; |
| 1290 zephyr_account *zephyr = gc->proto_data; |
1306 zephyr_account *zephyr = gc->proto_data; |
| |
1307 PurpleAccount *account = purple_connection_get_account(gc); |
| 1291 |
1308 |
| 1292 if (use_zeph02(zephyr)) { |
1309 if (use_zeph02(zephyr)) { |
| 1293 ald.user = NULL; |
1310 ald.user = NULL; |
| 1294 memset(&(ald.uid), 0, sizeof(ZUnique_Id_t)); |
1311 memset(&(ald.uid), 0, sizeof(ZUnique_Id_t)); |
| 1295 ald.version = NULL; |
1312 ald.version = NULL; |
| 1296 } |
1313 } |
| 1297 |
1314 |
| 1298 for (gnode = purple_get_blist()->root; gnode; gnode = gnode->next) { |
1315 for (gnode = purple_blist_get_root(); gnode; |
| |
1316 gnode = purple_blist_node_get_sibling_next(gnode)) { |
| 1299 if (!PURPLE_BLIST_NODE_IS_GROUP(gnode)) |
1317 if (!PURPLE_BLIST_NODE_IS_GROUP(gnode)) |
| 1300 continue; |
1318 continue; |
| 1301 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
1319 for (cnode = purple_blist_node_get_first_child(gnode); |
| |
1320 cnode; |
| |
1321 cnode = purple_blist_node_get_sibling_next(cnode)) { |
| 1302 if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) |
1322 if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) |
| 1303 continue; |
1323 continue; |
| 1304 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
1324 for (bnode = purple_blist_node_get_first_child(cnode); |
| |
1325 bnode; |
| |
1326 bnode = purple_blist_node_get_sibling_next(bnode)) { |
| 1305 PurpleBuddy *b = (PurpleBuddy *) bnode; |
1327 PurpleBuddy *b = (PurpleBuddy *) bnode; |
| 1306 |
1328 |
| 1307 if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) |
1329 if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) |
| 1308 continue; |
1330 continue; |
| 1309 if (b->account->gc == gc) { |
1331 if (purple_buddy_get_account(b) == account) { |
| 1310 const char *chk; |
1332 const char *chk; |
| 1311 |
1333 const char *name = purple_buddy_get_name(b); |
| 1312 chk = local_zephyr_normalize(zephyr,b->name); |
1334 |
| 1313 purple_debug_info("zephyr","chk: %s b->name %s\n",chk,b->name); |
1335 chk = local_zephyr_normalize(zephyr,name); |
| |
1336 purple_debug_info("zephyr","chk: %s b->name %s\n",chk,name); |
| 1314 /* XXX add real error reporting */ |
1337 /* XXX add real error reporting */ |
| 1315 /* doesn't matter if this fails or not; we'll just move on to the next one */ |
1338 /* doesn't matter if this fails or not; we'll just move on to the next one */ |
| 1316 if (use_zeph02(zephyr)) { |
1339 if (use_zeph02(zephyr)) { |
| 1317 #ifdef WIN32 |
1340 #ifdef WIN32 |
| 1318 int numlocs; |
1341 int numlocs; |
| 1934 { |
1957 { |
| 1935 PurpleBlistNode *gnode, *cnode, *bnode; |
1958 PurpleBlistNode *gnode, *cnode, *bnode; |
| 1936 PurpleBuddy *b; |
1959 PurpleBuddy *b; |
| 1937 char *fname; |
1960 char *fname; |
| 1938 FILE *fd; |
1961 FILE *fd; |
| |
1962 PurpleAccount *account; |
| 1939 zephyr_account* zephyr = gc->proto_data; |
1963 zephyr_account* zephyr = gc->proto_data; |
| 1940 fname = g_strdup_printf("%s/.anyone", purple_home_dir()); |
1964 fname = g_strdup_printf("%s/.anyone", purple_home_dir()); |
| 1941 fd = g_fopen(fname, "w"); |
1965 fd = g_fopen(fname, "w"); |
| 1942 if (!fd) { |
1966 if (!fd) { |
| 1943 g_free(fname); |
1967 g_free(fname); |
| 1944 return; |
1968 return; |
| 1945 } |
1969 } |
| 1946 |
1970 |
| 1947 for (gnode = purple_get_blist()->root; gnode; gnode = gnode->next) { |
1971 account = purple_connection_get_account(gc); |
| |
1972 for (gnode = purple_blist_get_root(); |
| |
1973 gnode; |
| |
1974 gnode = purple_blist_node_get_sibling_next(gnode)) { |
| 1948 if (!PURPLE_BLIST_NODE_IS_GROUP(gnode)) |
1975 if (!PURPLE_BLIST_NODE_IS_GROUP(gnode)) |
| 1949 continue; |
1976 continue; |
| 1950 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
1977 for (cnode = purple_blist_node_get_first_child(gnode); |
| |
1978 cnode; |
| |
1979 cnode = purple_blist_node_get_sibling_next(cnode)) { |
| 1951 if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) |
1980 if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) |
| 1952 continue; |
1981 continue; |
| 1953 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
1982 for (bnode = purple_blist_node_get_first_child(cnode); |
| |
1983 bnode; |
| |
1984 bnode = purple_blist_node_get_sibling_next(bnode)) { |
| 1954 if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) |
1985 if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) |
| 1955 continue; |
1986 continue; |
| 1956 b = (PurpleBuddy *) bnode; |
1987 b = (PurpleBuddy *) bnode; |
| 1957 if (b->account == gc->account) { |
1988 if (purple_buddy_get_account(b) == account) { |
| 1958 gchar *stripped_user = zephyr_strip_local_realm(zephyr,b->name); |
1989 gchar *stripped_user = zephyr_strip_local_realm(zephyr, purple_buddy_get_name(b)); |
| 1959 fprintf(fd, "%s\n", stripped_user); |
1990 fprintf(fd, "%s\n", stripped_user); |
| 1960 g_free(stripped_user); |
1991 g_free(stripped_user); |
| 1961 } |
1992 } |
| 1962 } |
1993 } |
| 1963 } |
1994 } |
| 2496 static PurpleChat *zephyr_find_blist_chat(PurpleAccount *account, const char *name) |
2527 static PurpleChat *zephyr_find_blist_chat(PurpleAccount *account, const char *name) |
| 2497 { |
2528 { |
| 2498 PurpleBlistNode *gnode, *cnode; |
2529 PurpleBlistNode *gnode, *cnode; |
| 2499 |
2530 |
| 2500 /* XXX needs to be %host%,%canon%, and %me% clean */ |
2531 /* XXX needs to be %host%,%canon%, and %me% clean */ |
| 2501 for(gnode = purple_get_blist()->root; gnode; gnode = gnode->next) { |
2532 for(gnode = purple_blist_get_root(); gnode; |
| 2502 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
2533 gnode = purple_blist_node_get_sibling_next(gnode)) { |
| |
2534 for(cnode = purple_blist_node_get_first_child(gnode); |
| |
2535 cnode; |
| |
2536 cnode = purple_blist_node_get_sibling_next(cnode)) { |
| 2503 PurpleChat *chat = (PurpleChat*)cnode; |
2537 PurpleChat *chat = (PurpleChat*)cnode; |
| 2504 char *zclass, *inst, *recip; |
2538 char *zclass, *inst, *recip; |
| 2505 char** triple; |
2539 char** triple; |
| |
2540 GHashTable *components; |
| 2506 if(!PURPLE_BLIST_NODE_IS_CHAT(cnode)) |
2541 if(!PURPLE_BLIST_NODE_IS_CHAT(cnode)) |
| 2507 continue; |
2542 continue; |
| 2508 if(chat->account !=account) |
2543 if(purple_chat_get_account(chat) != account) |
| 2509 continue; |
2544 continue; |
| 2510 if(!(zclass = g_hash_table_lookup(chat->components, "class"))) |
2545 components = purple_chat_get_components(chat); |
| |
2546 if(!(zclass = g_hash_table_lookup(components, "class"))) |
| 2511 continue; |
2547 continue; |
| 2512 if(!(inst = g_hash_table_lookup(chat->components, "instance"))) |
2548 if(!(inst = g_hash_table_lookup(components, "instance"))) |
| 2513 inst = g_strdup(""); |
2549 inst = g_strdup(""); |
| 2514 if(!(recip = g_hash_table_lookup(chat->components, "recipient"))) |
2550 if(!(recip = g_hash_table_lookup(components, "recipient"))) |
| 2515 recip = g_strdup(""); |
2551 recip = g_strdup(""); |
| 2516 /* purple_debug_info("zephyr","in zephyr_find_blist_chat name: %s\n",name?name:""); */ |
2552 /* purple_debug_info("zephyr","in zephyr_find_blist_chat name: %s\n",name?name:""); */ |
| 2517 triple = g_strsplit(name,",",3); |
2553 triple = g_strsplit(name,",",3); |
| 2518 if (!g_ascii_strcasecmp(triple[0],zclass) && !g_ascii_strcasecmp(triple[1],inst) && !g_ascii_strcasecmp(triple[2],recip)) |
2554 if (!g_ascii_strcasecmp(triple[0],zclass) && !g_ascii_strcasecmp(triple[1],inst) && !g_ascii_strcasecmp(triple[2],recip)) |
| 2519 return chat; |
2555 return chat; |
| 2520 |
2556 |
| 2521 } |
2557 } |
| 2522 } |
2558 } |
| 2523 return NULL; |
2559 return NULL; |
| 2524 } |
2560 } |
| 2525 static const char *zephyr_list_icon(PurpleAccount * a, PurpleBuddy * b) |
2561 static const char *zephyr_list_icon(PurpleAccount * a, PurpleBuddy * b) |