Mercurial > pidgin.yaz
comparison libpurple/protocols/sametime/sametime.c @ 25373:f8dbd57cf635
explicit merge of '448583a763dcf343f1a4392bdcdcc4c4f01f3aed'
and 'df350a99631d730a3d67255d916ee24e97f0f621'
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Fri, 02 Jan 2009 21:48:12 +0000 |
parents | 508e57943440 65cfc59858cf |
children | 43b721aa4b76 |
comparison
equal
deleted
inserted
replaced
24730:ce108a92fa4e | 25373:f8dbd57cf635 |
---|---|
661 - iterate through the buddy list | 661 - iterate through the buddy list |
662 - add each buddy matching this account to the stlist | 662 - add each buddy matching this account to the stlist |
663 */ | 663 */ |
664 | 664 |
665 PurpleAccount *acct; | 665 PurpleAccount *acct; |
666 PurpleBuddyList *blist; | |
667 PurpleBlistNode *gn, *cn, *bn; | 666 PurpleBlistNode *gn, *cn, *bn; |
668 PurpleGroup *grp; | 667 PurpleGroup *grp; |
669 PurpleBuddy *bdy; | 668 PurpleBuddy *bdy; |
670 | 669 |
671 struct mwSametimeGroup *stg = NULL; | 670 struct mwSametimeGroup *stg = NULL; |
672 struct mwIdBlock idb = { NULL, NULL }; | 671 struct mwIdBlock idb = { NULL, NULL }; |
673 | 672 |
674 acct = purple_connection_get_account(gc); | 673 acct = purple_connection_get_account(gc); |
675 g_return_if_fail(acct != NULL); | 674 g_return_if_fail(acct != NULL); |
676 | 675 |
677 blist = purple_get_blist(); | 676 for(gn = purple_blist_get_root(); gn; |
678 g_return_if_fail(blist != NULL); | 677 gn = purple_blist_node_get_sibling_next(gn)) { |
679 | |
680 for(gn = blist->root; gn; gn = gn->next) { | |
681 const char *owner; | 678 const char *owner; |
682 const char *gname; | 679 const char *gname; |
683 enum mwSametimeGroupType gtype; | 680 enum mwSametimeGroupType gtype; |
684 gboolean gopen; | 681 gboolean gopen; |
685 | 682 |
700 continue; | 697 continue; |
701 | 698 |
702 /* the group's actual name may be different from the purple group's | 699 /* the group's actual name may be different from the purple group's |
703 name. Find whichever is there */ | 700 name. Find whichever is there */ |
704 gname = purple_blist_node_get_string(gn, GROUP_KEY_NAME); | 701 gname = purple_blist_node_get_string(gn, GROUP_KEY_NAME); |
705 if(! gname) gname = grp->name; | 702 if(! gname) gname = purple_group_get_name(grp); |
706 | 703 |
707 /* we save this, but never actually honor it */ | 704 /* we save this, but never actually honor it */ |
708 gopen = ! purple_blist_node_get_bool(gn, GROUP_KEY_COLLAPSED); | 705 gopen = ! purple_blist_node_get_bool(gn, GROUP_KEY_COLLAPSED); |
709 | 706 |
710 stg = mwSametimeGroup_new(stlist, gtype, gname); | 707 stg = mwSametimeGroup_new(stlist, gtype, gname); |
711 mwSametimeGroup_setAlias(stg, grp->name); | 708 mwSametimeGroup_setAlias(stg, purple_group_get_name(grp)); |
712 mwSametimeGroup_setOpen(stg, gopen); | 709 mwSametimeGroup_setOpen(stg, gopen); |
713 | 710 |
714 /* don't attempt to put buddies in a dynamic group, it breaks | 711 /* don't attempt to put buddies in a dynamic group, it breaks |
715 other clients */ | 712 other clients */ |
716 if(gtype == mwSametimeGroup_DYNAMIC) | 713 if(gtype == mwSametimeGroup_DYNAMIC) |
717 continue; | 714 continue; |
718 | 715 |
719 for(cn = gn->child; cn; cn = cn->next) { | 716 for(cn = purple_blist_node_get_first_child(gn); |
717 cn; | |
718 cn = purple_blist_node_get_sibling_next(cn)) { | |
720 if(! PURPLE_BLIST_NODE_IS_CONTACT(cn)) continue; | 719 if(! PURPLE_BLIST_NODE_IS_CONTACT(cn)) continue; |
721 | 720 |
722 for(bn = cn->child; bn; bn = bn->next) { | 721 for(bn = purple_blist_node_get_first_child(cn); |
722 bn; | |
723 bn = purple_blist_node_get_sibling_next(bn)) { | |
723 if(! PURPLE_BLIST_NODE_IS_BUDDY(bn)) continue; | 724 if(! PURPLE_BLIST_NODE_IS_BUDDY(bn)) continue; |
724 if(! PURPLE_BLIST_NODE_SHOULD_SAVE(bn)) continue; | 725 if(! PURPLE_BLIST_NODE_SHOULD_SAVE(bn)) continue; |
725 | 726 |
726 bdy = (PurpleBuddy *) bn; | 727 bdy = (PurpleBuddy *) bn; |
727 | 728 |
728 if(bdy->account == acct) { | 729 if(purple_buddy_get_account(bdy) == acct) { |
729 struct mwSametimeUser *stu; | 730 struct mwSametimeUser *stu; |
730 enum mwSametimeUserType utype; | 731 enum mwSametimeUserType utype; |
731 | 732 |
732 idb.user = bdy->name; | 733 idb.user = (char *)purple_buddy_get_name(bdy); |
733 | 734 |
734 utype = purple_blist_node_get_int(bn, BUDDY_KEY_TYPE); | 735 utype = purple_blist_node_get_int(bn, BUDDY_KEY_TYPE); |
735 if(! utype) utype = mwSametimeUser_NORMAL; | 736 if(! utype) utype = mwSametimeUser_NORMAL; |
736 | 737 |
737 stu = mwSametimeUser_new(stg, utype, &idb); | 738 stu = mwSametimeUser_new(stg, utype, &idb); |
738 mwSametimeUser_setShortName(stu, bdy->server_alias); | 739 mwSametimeUser_setShortName(stu, purple_buddy_get_server_alias(bdy)); |
739 mwSametimeUser_setAlias(stu, bdy->alias); | 740 mwSametimeUser_setAlias(stu, purple_buddy_get_local_buddy_alias(bdy)); |
740 } | 741 } |
741 } | 742 } |
742 } | 743 } |
743 } | 744 } |
744 } | 745 } |
814 } | 815 } |
815 | 816 |
816 | 817 |
817 static gboolean buddy_is_external(PurpleBuddy *b) { | 818 static gboolean buddy_is_external(PurpleBuddy *b) { |
818 g_return_val_if_fail(b != NULL, FALSE); | 819 g_return_val_if_fail(b != NULL, FALSE); |
819 return purple_str_has_prefix(b->name, "@E "); | 820 return purple_str_has_prefix(purple_buddy_get_name(b), "@E "); |
820 } | 821 } |
821 | 822 |
822 | 823 |
823 /** Actually add a buddy to the aware service, and schedule the buddy | 824 /** Actually add a buddy to the aware service, and schedule the buddy |
824 list to be saved to the server */ | 825 list to be saved to the server */ |
825 static void buddy_add(struct mwPurplePluginData *pd, | 826 static void buddy_add(struct mwPurplePluginData *pd, |
826 PurpleBuddy *buddy) { | 827 PurpleBuddy *buddy) { |
827 | 828 |
828 struct mwAwareIdBlock idb = { mwAware_USER, (char *) buddy->name, NULL }; | 829 struct mwAwareIdBlock idb = { mwAware_USER, (char *) purple_buddy_get_name(buddy), NULL }; |
829 struct mwAwareList *list; | 830 struct mwAwareList *list; |
830 | 831 |
831 PurpleGroup *group; | 832 PurpleGroup *group; |
832 GList *add; | 833 GList *add; |
833 | 834 |
888 struct mwAwareList *list; | 889 struct mwAwareList *list; |
889 const char *n; | 890 const char *n; |
890 GList *add; | 891 GList *add; |
891 | 892 |
892 n = purple_blist_node_get_string((PurpleBlistNode *) group, GROUP_KEY_NAME); | 893 n = purple_blist_node_get_string((PurpleBlistNode *) group, GROUP_KEY_NAME); |
893 if(! n) n = group->name; | 894 if(! n) n = purple_group_get_name(group); |
894 | 895 |
895 idb.user = (char *) n; | 896 idb.user = (char *) n; |
896 add = g_list_prepend(NULL, &idb); | 897 add = g_list_prepend(NULL, &idb); |
897 | 898 |
898 list = list_ensure(pd, group); | 899 list = list_ensure(pd, group); |
924 | 925 |
925 DEBUG_INFO("attempting to ensure group %s, called %s\n", | 926 DEBUG_INFO("attempting to ensure group %s, called %s\n", |
926 NSTR(name), NSTR(alias)); | 927 NSTR(name), NSTR(alias)); |
927 | 928 |
928 /* first attempt at finding the group, by the name key */ | 929 /* first attempt at finding the group, by the name key */ |
929 for(gn = blist->root; gn; gn = gn->next) { | 930 for(gn = purple_blist_get_root(); gn; |
931 gn = purple_blist_node_get_sibling_next(gn)) { | |
930 const char *n, *o; | 932 const char *n, *o; |
931 if(! PURPLE_BLIST_NODE_IS_GROUP(gn)) continue; | 933 if(! PURPLE_BLIST_NODE_IS_GROUP(gn)) continue; |
932 n = purple_blist_node_get_string(gn, GROUP_KEY_NAME); | 934 n = purple_blist_node_get_string(gn, GROUP_KEY_NAME); |
933 o = purple_blist_node_get_string(gn, GROUP_KEY_OWNER); | 935 o = purple_blist_node_get_string(gn, GROUP_KEY_OWNER); |
934 | 936 |
1004 GList *prune = NULL; | 1006 GList *prune = NULL; |
1005 PurpleBlistNode *gn, *cn, *bn; | 1007 PurpleBlistNode *gn, *cn, *bn; |
1006 | 1008 |
1007 g_return_if_fail(group != NULL); | 1009 g_return_if_fail(group != NULL); |
1008 | 1010 |
1009 DEBUG_INFO("clearing members from pruned group %s\n", NSTR(group->name)); | 1011 DEBUG_INFO("clearing members from pruned group %s\n", NSTR(purple_group_get_name(group))); |
1010 | 1012 |
1011 gc = purple_account_get_connection(acct); | 1013 gc = purple_account_get_connection(acct); |
1012 g_return_if_fail(gc != NULL); | 1014 g_return_if_fail(gc != NULL); |
1013 | 1015 |
1014 gn = (PurpleBlistNode *) group; | 1016 gn = (PurpleBlistNode *) group; |
1015 | 1017 |
1016 for(cn = gn->child; cn; cn = cn->next) { | 1018 for(cn = purple_blist_node_get_first_child(gn); |
1019 cn; | |
1020 cn = purple_blist_node_get_sibling_next(cn)) { | |
1017 if(! PURPLE_BLIST_NODE_IS_CONTACT(cn)) continue; | 1021 if(! PURPLE_BLIST_NODE_IS_CONTACT(cn)) continue; |
1018 | 1022 |
1019 for(bn = cn->child; bn; bn = bn->next) { | 1023 for(bn = purple_blist_node_get_first_child(cn); |
1024 bn; | |
1025 bn = purple_blist_node_get_sibling_next(bn)) { | |
1020 PurpleBuddy *gb = (PurpleBuddy *) bn; | 1026 PurpleBuddy *gb = (PurpleBuddy *) bn; |
1021 | 1027 |
1022 if(! PURPLE_BLIST_NODE_IS_BUDDY(bn)) continue; | 1028 if(! PURPLE_BLIST_NODE_IS_BUDDY(bn)) continue; |
1023 | 1029 |
1024 if(gb->account == acct) { | 1030 if(purple_buddy_get_account(gb) == acct) { |
1025 DEBUG_INFO("clearing %s from group\n", NSTR(gb->name)); | 1031 DEBUG_INFO("clearing %s from group\n", NSTR(purple_buddy_get_name(gb))); |
1026 prune = g_list_prepend(prune, gb); | 1032 prune = g_list_prepend(prune, gb); |
1027 } | 1033 } |
1028 } | 1034 } |
1029 } | 1035 } |
1030 | 1036 |
1057 GList *prune = NULL; | 1063 GList *prune = NULL; |
1058 GList *ul, *utl; | 1064 GList *ul, *utl; |
1059 | 1065 |
1060 g_return_if_fail(group != NULL); | 1066 g_return_if_fail(group != NULL); |
1061 | 1067 |
1062 DEBUG_INFO("pruning membership of group %s\n", NSTR(group->name)); | 1068 DEBUG_INFO("pruning membership of group %s\n", NSTR(purple_group_get_name(group))); |
1063 | 1069 |
1064 acct = purple_connection_get_account(gc); | 1070 acct = purple_connection_get_account(gc); |
1065 g_return_if_fail(acct != NULL); | 1071 g_return_if_fail(acct != NULL); |
1066 | 1072 |
1067 stusers = g_hash_table_new(g_str_hash, g_str_equal); | 1073 stusers = g_hash_table_new(g_str_hash, g_str_equal); |
1076 } | 1082 } |
1077 g_list_free(utl); | 1083 g_list_free(utl); |
1078 | 1084 |
1079 gn = (PurpleBlistNode *) group; | 1085 gn = (PurpleBlistNode *) group; |
1080 | 1086 |
1081 for(cn = gn->child; cn; cn = cn->next) { | 1087 for(cn = purple_blist_node_get_first_child(gn); |
1088 cn; | |
1089 cn = purple_blist_node_get_sibling_next(cn)) { | |
1082 if(! PURPLE_BLIST_NODE_IS_CONTACT(cn)) continue; | 1090 if(! PURPLE_BLIST_NODE_IS_CONTACT(cn)) continue; |
1083 | 1091 |
1084 for(bn = cn->child; bn; bn = bn->next) { | 1092 for(bn = purple_blist_node_get_first_child(cn); |
1093 bn; | |
1094 bn = purple_blist_node_get_sibling_next(bn)) { | |
1085 PurpleBuddy *gb = (PurpleBuddy *) bn; | 1095 PurpleBuddy *gb = (PurpleBuddy *) bn; |
1086 | 1096 |
1087 if(! PURPLE_BLIST_NODE_IS_BUDDY(bn)) continue; | 1097 if(! PURPLE_BLIST_NODE_IS_BUDDY(bn)) continue; |
1088 | 1098 |
1089 /* if the account is correct and they're not in our table, mark | 1099 /* if the account is correct and they're not in our table, mark |
1090 them for pruning */ | 1100 them for pruning */ |
1091 if(gb->account == acct && !g_hash_table_lookup(stusers, gb->name)) { | 1101 if(purple_buddy_get_account(gb) == acct && !g_hash_table_lookup(stusers, purple_buddy_get_name(gb))) { |
1092 DEBUG_INFO("marking %s for pruning\n", NSTR(gb->name)); | 1102 DEBUG_INFO("marking %s for pruning\n", NSTR(purple_buddy_get_name(gb))); |
1093 prune = g_list_prepend(prune, gb); | 1103 prune = g_list_prepend(prune, gb); |
1094 } | 1104 } |
1095 } | 1105 } |
1096 } | 1106 } |
1097 DEBUG_INFO("done marking\n"); | 1107 DEBUG_INFO("done marking\n"); |
1143 g_hash_table_insert(stgroups, (char *) name, gl->data); | 1153 g_hash_table_insert(stgroups, (char *) name, gl->data); |
1144 } | 1154 } |
1145 g_list_free(gtl); | 1155 g_list_free(gtl); |
1146 | 1156 |
1147 /* find all groups which should be pruned from the local list */ | 1157 /* find all groups which should be pruned from the local list */ |
1148 for(gn = blist->root; gn; gn = gn->next) { | 1158 for(gn = purple_blist_get_root(); gn; |
1159 gn = purple_blist_node_get_sibling_next(gn)) { | |
1149 PurpleGroup *grp = (PurpleGroup *) gn; | 1160 PurpleGroup *grp = (PurpleGroup *) gn; |
1150 const char *gname, *owner; | 1161 const char *gname, *owner; |
1151 struct mwSametimeGroup *stgrp; | 1162 struct mwSametimeGroup *stgrp; |
1152 | 1163 |
1153 if(! PURPLE_BLIST_NODE_IS_GROUP(gn)) continue; | 1164 if(! PURPLE_BLIST_NODE_IS_GROUP(gn)) continue; |
1162 continue; | 1173 continue; |
1163 | 1174 |
1164 /* we actually are synching by this key as opposed to the group | 1175 /* we actually are synching by this key as opposed to the group |
1165 title, which can be different things in the st list */ | 1176 title, which can be different things in the st list */ |
1166 gname = purple_blist_node_get_string(gn, GROUP_KEY_NAME); | 1177 gname = purple_blist_node_get_string(gn, GROUP_KEY_NAME); |
1167 if(! gname) gname = grp->name; | 1178 if(! gname) gname = purple_group_get_name(grp); |
1168 | 1179 |
1169 stgrp = g_hash_table_lookup(stgroups, gname); | 1180 stgrp = g_hash_table_lookup(stgroups, gname); |
1170 if(! stgrp) { | 1181 if(! stgrp) { |
1171 /* remove the whole group */ | 1182 /* remove the whole group */ |
1172 DEBUG_INFO("marking group %s for pruning\n", grp->name); | 1183 DEBUG_INFO("marking group %s for pruning\n", purple_group_get_name(grp)); |
1173 g_prune = g_list_prepend(g_prune, grp); | 1184 g_prune = g_list_prepend(g_prune, grp); |
1174 | 1185 |
1175 } else { | 1186 } else { |
1176 /* synch the group contents */ | 1187 /* synch the group contents */ |
1177 group_prune(gc, grp, stgrp); | 1188 group_prune(gc, grp, stgrp); |
1282 | 1293 |
1283 PurpleGroup *group = (PurpleGroup *) node; | 1294 PurpleGroup *group = (PurpleGroup *) node; |
1284 | 1295 |
1285 GString *str; | 1296 GString *str; |
1286 char *tmp; | 1297 char *tmp; |
1298 const char *gname; | |
1287 | 1299 |
1288 g_return_if_fail(pd != NULL); | 1300 g_return_if_fail(pd != NULL); |
1289 | 1301 |
1290 gc = pd->gc; | 1302 gc = pd->gc; |
1291 g_return_if_fail(gc != NULL); | 1303 g_return_if_fail(gc != NULL); |
1293 g_return_if_fail(PURPLE_BLIST_NODE_IS_GROUP(node)); | 1305 g_return_if_fail(PURPLE_BLIST_NODE_IS_GROUP(node)); |
1294 | 1306 |
1295 str = g_string_new(NULL); | 1307 str = g_string_new(NULL); |
1296 | 1308 |
1297 tmp = (char *) purple_blist_node_get_string(node, GROUP_KEY_NAME); | 1309 tmp = (char *) purple_blist_node_get_string(node, GROUP_KEY_NAME); |
1298 | 1310 gname = purple_group_get_name(group); |
1299 g_string_append_printf(str, _("<b>Group Title:</b> %s<br>"), group->name); | 1311 |
1312 g_string_append_printf(str, _("<b>Group Title:</b> %s<br>"), gname); | |
1300 g_string_append_printf(str, _("<b>Notes Group ID:</b> %s<br>"), tmp); | 1313 g_string_append_printf(str, _("<b>Notes Group ID:</b> %s<br>"), tmp); |
1301 | 1314 |
1302 tmp = g_strdup_printf(_("Info for Group %s"), group->name); | 1315 tmp = g_strdup_printf(_("Info for Group %s"), gname); |
1303 | 1316 |
1304 purple_notify_formatted(gc, tmp, _("Notes Address Book Information"), | 1317 purple_notify_formatted(gc, tmp, _("Notes Address Book Information"), |
1305 NULL, str->str, NULL, NULL); | 1318 NULL, str->str, NULL, NULL); |
1306 | 1319 |
1307 g_free(tmp); | 1320 g_free(tmp); |
1354 anymore. */ | 1367 anymore. */ |
1355 static void blist_init(PurpleAccount *acct) { | 1368 static void blist_init(PurpleAccount *acct) { |
1356 PurpleBlistNode *gnode, *cnode, *bnode; | 1369 PurpleBlistNode *gnode, *cnode, *bnode; |
1357 GList *add_buds = NULL; | 1370 GList *add_buds = NULL; |
1358 | 1371 |
1359 for(gnode = purple_get_blist()->root; gnode; gnode = gnode->next) { | 1372 for(gnode = purple_blist_get_root(); gnode; |
1373 gnode = purple_blist_node_get_sibling_next(gnode)) { | |
1360 if(! PURPLE_BLIST_NODE_IS_GROUP(gnode)) continue; | 1374 if(! PURPLE_BLIST_NODE_IS_GROUP(gnode)) continue; |
1361 | 1375 |
1362 for(cnode = gnode->child; cnode; cnode = cnode->next) { | 1376 for(cnode = purple_blist_node_get_first_child(gnode); |
1377 cnode; | |
1378 cnode = purple_blist_node_get_sibling_next(cnode)) { | |
1363 if(! PURPLE_BLIST_NODE_IS_CONTACT(cnode)) | 1379 if(! PURPLE_BLIST_NODE_IS_CONTACT(cnode)) |
1364 continue; | 1380 continue; |
1365 for(bnode = cnode->child; bnode; bnode = bnode->next) { | 1381 for(bnode = purple_blist_node_get_first_child(cnode); |
1382 bnode; | |
1383 bnode = purple_blist_node_get_sibling_next(bnode)) { | |
1366 PurpleBuddy *b; | 1384 PurpleBuddy *b; |
1367 if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) | 1385 if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) |
1368 continue; | 1386 continue; |
1369 | 1387 |
1370 b = (PurpleBuddy *)bnode; | 1388 b = (PurpleBuddy *)bnode; |
1371 if(b->account == acct) { | 1389 if(purple_buddy_get_account(b) == acct) { |
1372 add_buds = g_list_append(add_buds, b); | 1390 add_buds = g_list_append(add_buds, b); |
1373 } | 1391 } |
1374 } | 1392 } |
1375 } | 1393 } |
1376 } | 1394 } |
1386 static void services_starting(struct mwPurplePluginData *pd) { | 1404 static void services_starting(struct mwPurplePluginData *pd) { |
1387 | 1405 |
1388 PurpleConnection *gc; | 1406 PurpleConnection *gc; |
1389 PurpleAccount *acct; | 1407 PurpleAccount *acct; |
1390 struct mwStorageUnit *unit; | 1408 struct mwStorageUnit *unit; |
1391 PurpleBuddyList *blist; | |
1392 PurpleBlistNode *l; | 1409 PurpleBlistNode *l; |
1393 | 1410 |
1394 gc = pd->gc; | 1411 gc = pd->gc; |
1395 acct = purple_connection_get_account(gc); | 1412 acct = purple_connection_get_account(gc); |
1396 | 1413 |
1397 /* grab the buddy list from the server */ | 1414 /* grab the buddy list from the server */ |
1398 unit = mwStorageUnit_new(mwStore_AWARE_LIST); | 1415 unit = mwStorageUnit_new(mwStore_AWARE_LIST); |
1399 mwServiceStorage_load(pd->srvc_store, unit, fetch_blist_cb, pd, NULL); | 1416 mwServiceStorage_load(pd->srvc_store, unit, fetch_blist_cb, pd, NULL); |
1400 | 1417 |
1401 /* find all the NAB groups and subscribe to them */ | 1418 /* find all the NAB groups and subscribe to them */ |
1402 blist = purple_get_blist(); | 1419 for(l = purple_blist_get_root(); l; |
1403 for(l = blist->root; l; l = l->next) { | 1420 l = purple_blist_node_get_sibling_next(l)) { |
1404 PurpleGroup *group = (PurpleGroup *) l; | 1421 PurpleGroup *group = (PurpleGroup *) l; |
1405 enum mwSametimeGroupType gt; | 1422 enum mwSametimeGroupType gt; |
1406 const char *owner; | 1423 const char *owner; |
1407 | 1424 |
1408 if(! PURPLE_BLIST_NODE_IS_GROUP(l)) continue; | 1425 if(! PURPLE_BLIST_NODE_IS_GROUP(l)) continue; |
3237 | 3254 |
3238 | 3255 |
3239 static char *mw_prpl_status_text(PurpleBuddy *b) { | 3256 static char *mw_prpl_status_text(PurpleBuddy *b) { |
3240 PurpleConnection *gc; | 3257 PurpleConnection *gc; |
3241 struct mwPurplePluginData *pd; | 3258 struct mwPurplePluginData *pd; |
3242 struct mwAwareIdBlock t = { mwAware_USER, b->name, NULL }; | 3259 struct mwAwareIdBlock t = { mwAware_USER, (char *)purple_buddy_get_name(b), NULL }; |
3243 const char *ret = NULL; | 3260 const char *ret = NULL; |
3244 | 3261 |
3245 if ((gc = purple_account_get_connection(b->account)) | 3262 if ((gc = purple_account_get_connection(purple_buddy_get_account(b))) |
3246 && (pd = gc->proto_data)) | 3263 && (pd = gc->proto_data)) |
3247 ret = mwServiceAware_getText(pd->srvc_aware, &t); | 3264 ret = mwServiceAware_getText(pd->srvc_aware, &t); |
3248 | 3265 |
3249 return (ret && g_utf8_validate(ret, -1, NULL)) ? g_markup_escape_text(ret, -1): NULL; | 3266 return (ret && g_utf8_validate(ret, -1, NULL)) ? g_markup_escape_text(ret, -1): NULL; |
3250 } | 3267 } |
3297 | 3314 |
3298 | 3315 |
3299 static void mw_prpl_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) { | 3316 static void mw_prpl_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) { |
3300 PurpleConnection *gc; | 3317 PurpleConnection *gc; |
3301 struct mwPurplePluginData *pd = NULL; | 3318 struct mwPurplePluginData *pd = NULL; |
3302 struct mwAwareIdBlock idb = { mwAware_USER, b->name, NULL }; | 3319 struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(b), NULL }; |
3303 | 3320 |
3304 const char *message = NULL; | 3321 const char *message = NULL; |
3305 const char *status; | 3322 const char *status; |
3306 char *tmp; | 3323 char *tmp; |
3307 | 3324 |
3308 if ((gc = purple_account_get_connection(b->account)) | 3325 if ((gc = purple_account_get_connection(purple_buddy_get_account(b))) |
3309 && (pd = gc->proto_data)) | 3326 && (pd = gc->proto_data)) |
3310 message = mwServiceAware_getText(pd->srvc_aware, &idb); | 3327 message = mwServiceAware_getText(pd->srvc_aware, &idb); |
3311 | 3328 |
3312 status = status_text(b); | 3329 status = status_text(b); |
3313 | 3330 |
3319 } else { | 3336 } else { |
3320 purple_notify_user_info_add_pair(user_info, _("Status"), status); | 3337 purple_notify_user_info_add_pair(user_info, _("Status"), status); |
3321 } | 3338 } |
3322 | 3339 |
3323 if(full && pd != NULL) { | 3340 if(full && pd != NULL) { |
3324 tmp = user_supports_text(pd->srvc_aware, b->name); | 3341 tmp = user_supports_text(pd->srvc_aware, purple_buddy_get_name(b)); |
3325 if(tmp) { | 3342 if(tmp) { |
3326 purple_notify_user_info_add_pair(user_info, _("Supports"), tmp); | 3343 purple_notify_user_info_add_pair(user_info, _("Supports"), tmp); |
3327 g_free(tmp); | 3344 g_free(tmp); |
3328 } | 3345 } |
3329 | 3346 |
3381 | 3398 |
3382 const char *topic, *invite; | 3399 const char *topic, *invite; |
3383 struct mwConference *conf; | 3400 struct mwConference *conf; |
3384 struct mwIdBlock idb = { NULL, NULL }; | 3401 struct mwIdBlock idb = { NULL, NULL }; |
3385 | 3402 |
3386 acct = buddy->account; | 3403 acct = purple_buddy_get_account(buddy); |
3387 gc = purple_account_get_connection(acct); | 3404 gc = purple_account_get_connection(acct); |
3388 pd = gc->proto_data; | 3405 pd = gc->proto_data; |
3389 srvc = pd->srvc_conf; | 3406 srvc = pd->srvc_conf; |
3390 | 3407 |
3391 f = purple_request_fields_get_field(fields, CHAT_KEY_TOPIC); | 3408 f = purple_request_fields_get_field(fields, CHAT_KEY_TOPIC); |
3395 invite = purple_request_field_string_get_value(f); | 3412 invite = purple_request_field_string_get_value(f); |
3396 | 3413 |
3397 conf = mwConference_new(srvc, topic); | 3414 conf = mwConference_new(srvc, topic); |
3398 mwConference_open(conf); | 3415 mwConference_open(conf); |
3399 | 3416 |
3400 idb.user = buddy->name; | 3417 idb.user = (char *)purple_buddy_get_name(buddy); |
3401 mwConference_invite(conf, &idb, invite); | 3418 mwConference_invite(conf, &idb, invite); |
3402 } | 3419 } |
3403 | 3420 |
3404 | 3421 |
3405 static void blist_menu_conf_create(PurpleBuddy *buddy, const char *msg) { | 3422 static void blist_menu_conf_create(PurpleBuddy *buddy, const char *msg) { |
3415 const char *msgB; | 3432 const char *msgB; |
3416 char *msg1; | 3433 char *msg1; |
3417 | 3434 |
3418 g_return_if_fail(buddy != NULL); | 3435 g_return_if_fail(buddy != NULL); |
3419 | 3436 |
3420 acct = buddy->account; | 3437 acct = purple_buddy_get_account(buddy); |
3421 g_return_if_fail(acct != NULL); | 3438 g_return_if_fail(acct != NULL); |
3422 | 3439 |
3423 gc = purple_account_get_connection(acct); | 3440 gc = purple_account_get_connection(acct); |
3424 g_return_if_fail(gc != NULL); | 3441 g_return_if_fail(gc != NULL); |
3425 | 3442 |
3435 purple_request_field_group_add_field(g, f); | 3452 purple_request_field_group_add_field(g, f); |
3436 | 3453 |
3437 msgA = _("Create conference with user"); | 3454 msgA = _("Create conference with user"); |
3438 msgB = _("Please enter a topic for the new conference, and an invitation" | 3455 msgB = _("Please enter a topic for the new conference, and an invitation" |
3439 " message to be sent to %s"); | 3456 " message to be sent to %s"); |
3440 msg1 = g_strdup_printf(msgB, buddy->name); | 3457 msg1 = g_strdup_printf(msgB, purple_buddy_get_name(buddy)); |
3441 | 3458 |
3442 purple_request_fields(gc, _("New Conference"), | 3459 purple_request_fields(gc, _("New Conference"), |
3443 msgA, msg1, fields, | 3460 msgA, msg1, fields, |
3444 _("Create"), G_CALLBACK(conf_create_prompt_join), | 3461 _("Create"), G_CALLBACK(conf_create_prompt_join), |
3445 _("Cancel"), G_CALLBACK(conf_create_prompt_cancel), | 3462 _("Cancel"), G_CALLBACK(conf_create_prompt_cancel), |
3472 | 3489 |
3473 if(GPOINTER_TO_INT(d) == 0x01) { | 3490 if(GPOINTER_TO_INT(d) == 0x01) { |
3474 blist_menu_conf_create(buddy, msg); | 3491 blist_menu_conf_create(buddy, msg); |
3475 | 3492 |
3476 } else { | 3493 } else { |
3477 struct mwIdBlock idb = { buddy->name, NULL }; | 3494 struct mwIdBlock idb = { (char *)purple_buddy_get_name(buddy), NULL }; |
3478 mwConference_invite(d, &idb, msg); | 3495 mwConference_invite(d, &idb, msg); |
3479 } | 3496 } |
3480 } | 3497 } |
3481 } | 3498 } |
3482 | 3499 |
3493 | 3510 |
3494 const char *msgA; | 3511 const char *msgA; |
3495 const char *msgB; | 3512 const char *msgB; |
3496 char *msg; | 3513 char *msg; |
3497 | 3514 |
3498 acct = buddy->account; | 3515 acct = purple_buddy_get_account(buddy); |
3499 g_return_if_fail(acct != NULL); | 3516 g_return_if_fail(acct != NULL); |
3500 | 3517 |
3501 gc = purple_account_get_connection(acct); | 3518 gc = purple_account_get_connection(acct); |
3502 g_return_if_fail(gc != NULL); | 3519 g_return_if_fail(gc != NULL); |
3503 | 3520 |
3521 | 3538 |
3522 msgA = _("Invite user to a conference"); | 3539 msgA = _("Invite user to a conference"); |
3523 msgB = _("Select a conference from the list below to send an invite to" | 3540 msgB = _("Select a conference from the list below to send an invite to" |
3524 " user %s. Select \"Create New Conference\" if you'd like to" | 3541 " user %s. Select \"Create New Conference\" if you'd like to" |
3525 " create a new conference to invite this user to."); | 3542 " create a new conference to invite this user to."); |
3526 msg = g_strdup_printf(msgB, buddy->name); | 3543 msg = g_strdup_printf(msgB, purple_buddy_get_name(buddy)); |
3527 | 3544 |
3528 purple_request_fields(gc, _("Invite to Conference"), | 3545 purple_request_fields(gc, _("Invite to Conference"), |
3529 msgA, msg, fields, | 3546 msgA, msg, fields, |
3530 _("Invite"), G_CALLBACK(conf_select_prompt_invite), | 3547 _("Invite"), G_CALLBACK(conf_select_prompt_invite), |
3531 _("Cancel"), G_CALLBACK(conf_select_prompt_cancel), | 3548 _("Cancel"), G_CALLBACK(conf_select_prompt_cancel), |
3543 GList *l; | 3560 GList *l; |
3544 | 3561 |
3545 g_return_if_fail(node != NULL); | 3562 g_return_if_fail(node != NULL); |
3546 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); | 3563 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
3547 | 3564 |
3548 acct = buddy->account; | 3565 acct = purple_buddy_get_account(buddy); |
3549 g_return_if_fail(acct != NULL); | 3566 g_return_if_fail(acct != NULL); |
3550 | 3567 |
3551 gc = purple_account_get_connection(acct); | 3568 gc = purple_account_get_connection(acct); |
3552 g_return_if_fail(gc != NULL); | 3569 g_return_if_fail(gc != NULL); |
3553 | 3570 |
4183 purple_notify_user_info_add_pair(user_info, _("User ID"), who); | 4200 purple_notify_user_info_add_pair(user_info, _("User ID"), who); |
4184 | 4201 |
4185 if(b) { | 4202 if(b) { |
4186 guint32 type; | 4203 guint32 type; |
4187 | 4204 |
4188 if(b->server_alias) { | 4205 if(purple_buddy_get_server_alias(b)) { |
4189 purple_notify_user_info_add_pair(user_info, _("Full Name"), b->server_alias); | 4206 purple_notify_user_info_add_pair(user_info, _("Full Name"), purple_buddy_get_server_alias(b)); |
4190 } | 4207 } |
4191 | 4208 |
4192 type = purple_blist_node_get_int((PurpleBlistNode *) b, BUDDY_KEY_CLIENT); | 4209 type = purple_blist_node_get_int((PurpleBlistNode *) b, BUDDY_KEY_CLIENT); |
4193 if(type) { | 4210 if(type) { |
4194 tmp = g_strdup(mw_client_name(type)); | 4211 tmp = g_strdup(mw_client_name(type)); |
4326 } | 4343 } |
4327 | 4344 |
4328 | 4345 |
4329 static void notify_add(PurpleConnection *gc, GList *row, void *user_data) { | 4346 static void notify_add(PurpleConnection *gc, GList *row, void *user_data) { |
4330 BuddyAddData *data = user_data; | 4347 BuddyAddData *data = user_data; |
4331 char *group_name = NULL; | 4348 const char *group_name = NULL; |
4332 | 4349 |
4333 if (data && data->group) { | 4350 if (data && data->group) { |
4334 group_name = data->group->name; | 4351 group_name = purple_group_get_name(data->group); |
4335 } | 4352 } |
4336 | 4353 |
4337 purple_blist_request_add_buddy(purple_connection_get_account(gc), | 4354 purple_blist_request_add_buddy(purple_connection_get_account(gc), |
4338 g_list_nth_data(row, 1), group_name, | 4355 g_list_nth_data(row, 1), group_name, |
4339 g_list_nth_data(row, 0)); | 4356 g_list_nth_data(row, 0)); |
4411 | 4428 |
4412 g_return_if_fail(data != NULL); | 4429 g_return_if_fail(data != NULL); |
4413 | 4430 |
4414 buddy = data->buddy; | 4431 buddy = data->buddy; |
4415 | 4432 |
4416 gc = purple_account_get_connection(buddy->account); | 4433 gc = purple_account_get_connection(purple_buddy_get_account(buddy)); |
4417 pd = gc->proto_data; | 4434 pd = gc->proto_data; |
4418 | 4435 |
4419 if(results) | 4436 if(results) |
4420 res = results->data; | 4437 res = results->data; |
4421 | 4438 |
4512 data->buddy = buddy; | 4529 data->buddy = buddy; |
4513 data->group = group; | 4530 data->group = group; |
4514 | 4531 |
4515 srvc = pd->srvc_resolve; | 4532 srvc = pd->srvc_resolve; |
4516 | 4533 |
4517 query = g_list_prepend(NULL, buddy->name); | 4534 query = g_list_prepend(NULL, (char *)purple_buddy_get_name(buddy)); |
4518 flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; | 4535 flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
4519 | 4536 |
4520 req = mwServiceResolve_resolve(srvc, query, flags, add_buddy_resolved, | 4537 req = mwServiceResolve_resolve(srvc, query, flags, add_buddy_resolved, |
4521 data, NULL); | 4538 data, NULL); |
4522 g_list_free(query); | 4539 g_list_free(query); |
4565 fn = purple_blist_node_get_string((PurpleBlistNode *) b, BUDDY_KEY_NAME); | 4582 fn = purple_blist_node_get_string((PurpleBlistNode *) b, BUDDY_KEY_NAME); |
4566 purple_blist_server_alias_buddy(b, fn); | 4583 purple_blist_server_alias_buddy(b, fn); |
4567 | 4584 |
4568 /* convert PurpleBuddy into a mwAwareIdBlock */ | 4585 /* convert PurpleBuddy into a mwAwareIdBlock */ |
4569 idb->type = mwAware_USER; | 4586 idb->type = mwAware_USER; |
4570 idb->user = (char *) b->name; | 4587 idb->user = (char *) purple_buddy_get_name(b); |
4571 idb->community = NULL; | 4588 idb->community = NULL; |
4572 | 4589 |
4573 /* put idb into the list associated with the buddy's group */ | 4590 /* put idb into the list associated with the buddy's group */ |
4574 g = purple_buddy_get_group(b); | 4591 g = purple_buddy_get_group(b); |
4575 l = g_hash_table_lookup(group_sets, g); | 4592 l = g_hash_table_lookup(group_sets, g); |
4590 | 4607 |
4591 static void mw_prpl_remove_buddy(PurpleConnection *gc, | 4608 static void mw_prpl_remove_buddy(PurpleConnection *gc, |
4592 PurpleBuddy *buddy, PurpleGroup *group) { | 4609 PurpleBuddy *buddy, PurpleGroup *group) { |
4593 | 4610 |
4594 struct mwPurplePluginData *pd; | 4611 struct mwPurplePluginData *pd; |
4595 struct mwAwareIdBlock idb = { mwAware_USER, buddy->name, NULL }; | 4612 struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(buddy), NULL }; |
4596 struct mwAwareList *list; | 4613 struct mwAwareList *list; |
4597 | 4614 |
4598 GList *rem = g_list_prepend(NULL, &idb); | 4615 GList *rem = g_list_prepend(NULL, &idb); |
4599 | 4616 |
4600 pd = gc->proto_data; | 4617 pd = gc->proto_data; |