Mercurial > pidgin
comparison src/protocols/gg/gg.c @ 12220:64254fbabc7b
[gaim-migrate @ 14522]
SF Patch #1363787 from Bartosz Oler
"This is a fix to the 'Find buddies' command in which,
after the search results window was closed, prpl's
internal state was not cleared. A minor modification in
the notify API was required.
This patch also adds a few more notifications for the
user."
There also appears to be a few unrelated GG prpl updates in here. I noticed that more strings are marked for translation now.
I made several changes to this patch. I also found out that we're not honoring the callbacks passed in to the notify API. That's a bug since we document them. I'm not in the mood to fix it. I changed GCallback to GHookFunc as it has the right type (whereas GCallback did not). The name isn't too bad either. I didn't really want to create a new callback function typedef.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Fri, 25 Nov 2005 01:33:10 +0000 |
parents | 4d3119205a33 |
children | ca27de274225 |
comparison
equal
deleted
inserted
replaced
12219:f23ebb7b2dfd | 12220:64254fbabc7b |
---|---|
498 { | 498 { |
499 GGPInfo *info = gc->proto_data; | 499 GGPInfo *info = gc->proto_data; |
500 GGPSearchForm *form; | 500 GGPSearchForm *form; |
501 | 501 |
502 form = ggp_search_form_new(); | 502 form = ggp_search_form_new(); |
503 /* | |
504 * TODO: Fail if we have already a form attached. Only one search | |
505 * at a time will be allowed for now. | |
506 */ | |
507 info->search_form = form; | 503 info->search_form = form; |
508 | 504 |
509 form->lastname = charset_convert( | 505 form->lastname = charset_convert( |
510 gaim_request_fields_get_string(fields, "lastname"), | 506 gaim_request_fields_get_string(fields, "lastname"), |
511 "UTF-8", "CP1250"); | 507 "UTF-8", "CP1250"); |
547 */ | 543 */ |
548 /* static void ggp_find_buddies(GaimPluginAction *action) {{{ */ | 544 /* static void ggp_find_buddies(GaimPluginAction *action) {{{ */ |
549 static void ggp_find_buddies(GaimPluginAction *action) | 545 static void ggp_find_buddies(GaimPluginAction *action) |
550 { | 546 { |
551 GaimConnection *gc = (GaimConnection *)action->context; | 547 GaimConnection *gc = (GaimConnection *)action->context; |
548 GGPInfo *info = gc->proto_data; | |
552 | 549 |
553 GaimRequestFields *fields; | 550 GaimRequestFields *fields; |
554 GaimRequestFieldGroup *group; | 551 GaimRequestFieldGroup *group; |
555 GaimRequestField *field; | 552 GaimRequestField *field; |
553 | |
554 if (info->search_form != NULL) { | |
555 gaim_notify_error(gc, NULL, | |
556 _("Unable to initiate a new search"), | |
557 _("You have a pending search. Please wait for it to finish.")); | |
558 return; | |
559 } | |
556 | 560 |
557 fields = gaim_request_fields_new(); | 561 fields = gaim_request_fields_new(); |
558 group = gaim_request_field_group_new(NULL); | 562 group = gaim_request_field_group_new(NULL); |
559 gaim_request_fields_add_group(fields, group); | 563 gaim_request_fields_add_group(fields, group); |
560 | 564 |
915 } | 919 } |
916 /* }}} */ | 920 /* }}} */ |
917 | 921 |
918 /* | 922 /* |
919 */ | 923 */ |
924 /* static void ggp_sr_close_cb(GaimAccount *account) {{{ */ | |
925 static void ggp_sr_close_cb(GaimAccount *account) | |
926 { | |
927 GaimConnection *gc = gaim_account_get_connection(account); | |
928 GGPInfo *info = gc->proto_data; | |
929 GGPSearchForm *f; | |
930 | |
931 info->searchresults_window = NULL; | |
932 | |
933 f = info->search_form; | |
934 g_free(f->uin); | |
935 g_free(f->lastname); | |
936 g_free(f->firstname); | |
937 g_free(f->nickname); | |
938 g_free(f->city); | |
939 g_free(f->birthyear); | |
940 g_free(f->gender); | |
941 g_free(f->active); | |
942 g_free(f->offset); | |
943 g_free(f->last_uin); | |
944 g_free(f); | |
945 | |
946 info->search_form = NULL; | |
947 } | |
948 /* }}} */ | |
949 | |
950 /* | |
951 */ | |
920 /* static void ggp_pubdir_reply_handler(GaimConnection *gc, gg_pubdir50_t req) {{{ */ | 952 /* static void ggp_pubdir_reply_handler(GaimConnection *gc, gg_pubdir50_t req) {{{ */ |
921 static void ggp_pubdir_reply_handler(GaimConnection *gc, gg_pubdir50_t req) | 953 static void ggp_pubdir_reply_handler(GaimConnection *gc, gg_pubdir50_t req) |
922 { | 954 { |
923 GGPInfo *info = gc->proto_data; | 955 GGPInfo *info = gc->proto_data; |
924 GaimNotifySearchResults *results; | 956 GaimNotifySearchResults *results; |
928 int i; | 960 int i; |
929 | 961 |
930 res_count = gg_pubdir50_count(req); | 962 res_count = gg_pubdir50_count(req); |
931 if (res_count < 1) { | 963 if (res_count < 1) { |
932 gaim_debug_info("gg", "GG_EVENT_PUBDIR50_SEARCH_REPLY: Nothing found\n"); | 964 gaim_debug_info("gg", "GG_EVENT_PUBDIR50_SEARCH_REPLY: Nothing found\n"); |
965 gaim_notify_error(gc, NULL, | |
966 _("No matching users found"), | |
967 _("There are no users matching your search criteria.")); | |
933 return; | 968 return; |
934 } | 969 } |
935 res_count = (res_count > 20) ? 20 : res_count; | 970 res_count = (res_count > 20) ? 20 : res_count; |
936 | 971 |
937 results = gaim_notify_searchresults_new(); | 972 results = gaim_notify_searchresults_new(); |
938 | 973 |
939 column = gaim_notify_searchresults_column_new("UIN"); | 974 column = gaim_notify_searchresults_column_new(_("UIN")); |
940 gaim_notify_searchresults_column_add(results, column); | 975 gaim_notify_searchresults_column_add(results, column); |
941 | 976 |
942 column = gaim_notify_searchresults_column_new("First name"); | 977 column = gaim_notify_searchresults_column_new(_("First name")); |
943 gaim_notify_searchresults_column_add(results, column); | 978 gaim_notify_searchresults_column_add(results, column); |
944 | 979 |
945 column = gaim_notify_searchresults_column_new("Nick name"); | 980 column = gaim_notify_searchresults_column_new(_("Nick name")); |
946 gaim_notify_searchresults_column_add(results, column); | 981 gaim_notify_searchresults_column_add(results, column); |
947 | 982 |
948 column = gaim_notify_searchresults_column_new("City"); | 983 column = gaim_notify_searchresults_column_new(_("City")); |
949 gaim_notify_searchresults_column_add(results, column); | 984 gaim_notify_searchresults_column_add(results, column); |
950 | 985 |
951 column = gaim_notify_searchresults_column_new("Birth year"); | 986 column = gaim_notify_searchresults_column_new(_("Birth year")); |
952 gaim_notify_searchresults_column_add(results, column); | 987 gaim_notify_searchresults_column_add(results, column); |
953 | 988 |
954 gaim_debug_info("gg", "Going with %d entries\n", res_count); | 989 gaim_debug_info("gg", "Going with %d entries\n", res_count); |
955 | 990 |
956 start = (int)ggp_str_to_uin(gg_pubdir50_get(req, 0, GG_PUBDIR50_START)); | 991 start = (int)ggp_str_to_uin(gg_pubdir50_get(req, 0, GG_PUBDIR50_START)); |
987 gaim_notify_searchresults_button_add(results, GAIM_NOTIFY_BUTTON_ADD_BUDDY, | 1022 gaim_notify_searchresults_button_add(results, GAIM_NOTIFY_BUTTON_ADD_BUDDY, |
988 ggp_callback_add_buddy); | 1023 ggp_callback_add_buddy); |
989 if (info->searchresults_window == NULL) { | 1024 if (info->searchresults_window == NULL) { |
990 void *h = gaim_notify_searchresults(gc, | 1025 void *h = gaim_notify_searchresults(gc, |
991 _("Gadu-Gadu Public Directory"), | 1026 _("Gadu-Gadu Public Directory"), |
992 _("Search results"), NULL, results, NULL, NULL); | 1027 _("Search results"), NULL, results, |
1028 (GHookFunc)ggp_sr_close_cb, | |
1029 gaim_connection_get_account(gc)); | |
993 info->searchresults_window = h; | 1030 info->searchresults_window = h; |
994 } else { | 1031 } else { |
995 gaim_notify_searchresults_new_rows(gc, results, | 1032 gaim_notify_searchresults_new_rows(gc, results, |
996 info->searchresults_window, NULL); | 1033 info->searchresults_window, NULL); |
997 } | 1034 } |
1148 ev->event.status60.status, ev->event.status60.descr); | 1185 ev->event.status60.status, ev->event.status60.descr); |
1149 break; | 1186 break; |
1150 case GG_EVENT_USERLIST: | 1187 case GG_EVENT_USERLIST: |
1151 if (ev->event.userlist.type == GG_USERLIST_GET_REPLY) { | 1188 if (ev->event.userlist.type == GG_USERLIST_GET_REPLY) { |
1152 gaim_debug_info("gg", "GG_USERLIST_GET_REPLY\n"); | 1189 gaim_debug_info("gg", "GG_USERLIST_GET_REPLY\n"); |
1190 gaim_notify_info(gc, NULL, | |
1191 _("Buddy list downloaded"), | |
1192 _("Your buddy list was downloaded from the server.")); | |
1153 if (ev->event.userlist.reply != NULL) { | 1193 if (ev->event.userlist.reply != NULL) { |
1154 ggp_buddylist_load(gc, ev->event.userlist.reply); | 1194 ggp_buddylist_load(gc, ev->event.userlist.reply); |
1155 } | 1195 } |
1156 } else { | 1196 } else { |
1157 gaim_debug_info("gg", | 1197 gaim_debug_info("gg", "GG_USERLIST_PUT_REPLY\n"); |
1158 "GG_USERLIST_PUT_REPLY. Userlist stored on the server.\n"); | 1198 gaim_notify_info(gc, NULL, |
1199 _("Buddy list uploaded"), | |
1200 _("Your buddy list was stored on the server.")); | |
1159 } | 1201 } |
1160 break; | 1202 break; |
1161 case GG_EVENT_PUBDIR50_SEARCH_REPLY: | 1203 case GG_EVENT_PUBDIR50_SEARCH_REPLY: |
1162 ggp_pubdir_reply_handler(gc, ev->event.pubdir50); | 1204 ggp_pubdir_reply_handler(gc, ev->event.pubdir50); |
1163 break; | 1205 break; |
1531 /* static void ggp_get_info(GaimConnection *gc, const char *name) { {{{ */ | 1573 /* static void ggp_get_info(GaimConnection *gc, const char *name) { {{{ */ |
1532 static void ggp_get_info(GaimConnection *gc, const char *name) | 1574 static void ggp_get_info(GaimConnection *gc, const char *name) |
1533 { | 1575 { |
1534 GGPInfo *info = gc->proto_data; | 1576 GGPInfo *info = gc->proto_data; |
1535 GGPSearchForm *form; | 1577 GGPSearchForm *form; |
1578 | |
1579 if (info->search_form != NULL) { | |
1580 gaim_notify_error(gc, NULL, | |
1581 _("Unable to initiate a new search"), | |
1582 _("You have a pending search. Please wait for it to finish.")); | |
1583 return; | |
1584 } | |
1536 | 1585 |
1537 form = ggp_search_form_new(); | 1586 form = ggp_search_form_new(); |
1538 info->search_form = form; | 1587 info->search_form = form; |
1539 | 1588 |
1540 form->uin = g_strdup(name); | 1589 form->uin = g_strdup(name); |
1744 static GList *ggp_actions(GaimPlugin *plugin, gpointer context) | 1793 static GList *ggp_actions(GaimPlugin *plugin, gpointer context) |
1745 { | 1794 { |
1746 GList *m = NULL; | 1795 GList *m = NULL; |
1747 GaimPluginAction *act; | 1796 GaimPluginAction *act; |
1748 | 1797 |
1749 act = gaim_plugin_action_new(_("Find buddies"), | 1798 act = gaim_plugin_action_new(_("Find buddies..."), |
1750 ggp_find_buddies); | 1799 ggp_find_buddies); |
1751 m = g_list_append(m, act); | 1800 m = g_list_append(m, act); |
1752 | 1801 |
1753 m = g_list_append(m, NULL); | 1802 m = g_list_append(m, NULL); |
1754 | 1803 |
1755 act = gaim_plugin_action_new(_("Change password"), | 1804 act = gaim_plugin_action_new(_("Change password..."), |
1756 ggp_change_passwd); | 1805 ggp_change_passwd); |
1757 m = g_list_append(m, act); | 1806 m = g_list_append(m, act); |
1758 | 1807 |
1759 m = g_list_append(m, NULL); | 1808 m = g_list_append(m, NULL); |
1760 | 1809 |
1768 | 1817 |
1769 act = gaim_plugin_action_new(_("Delete buddylist from Server"), | 1818 act = gaim_plugin_action_new(_("Delete buddylist from Server"), |
1770 ggp_action_buddylist_delete); | 1819 ggp_action_buddylist_delete); |
1771 m = g_list_append(m, act); | 1820 m = g_list_append(m, act); |
1772 | 1821 |
1773 act = gaim_plugin_action_new(_("Save buddylist to file"), | 1822 act = gaim_plugin_action_new(_("Save buddylist to file..."), |
1774 ggp_action_buddylist_save); | 1823 ggp_action_buddylist_save); |
1775 m = g_list_append(m, act); | 1824 m = g_list_append(m, act); |
1776 | 1825 |
1777 act = gaim_plugin_action_new(_("Load buddylist from file"), | 1826 act = gaim_plugin_action_new(_("Load buddylist from file..."), |
1778 ggp_action_buddylist_load); | 1827 ggp_action_buddylist_load); |
1779 m = g_list_append(m, act); | 1828 m = g_list_append(m, act); |
1780 | 1829 |
1781 return m; | 1830 return m; |
1782 } | 1831 } |