Mercurial > pidgin
comparison libpurple/protocols/gg/gg.c @ 31350:64b362d1c49e
Gadu-Gadu: Allow showing your status only to people on your buddy list.
Fixes #13358.
committer: John Bailey <rekkanoryo@rekkanoryo.org>
author | mateuszpiekos@gmail.com |
---|---|
date | Sun, 13 Mar 2011 16:10:16 +0000 |
parents | 1607b413a139 |
children | e31163acae07 |
comparison
equal
deleted
inserted
replaced
31348:c9244d8303ce | 31350:64b362d1c49e |
---|---|
47 #include "buddylist.h" | 47 #include "buddylist.h" |
48 #include "gg-utils.h" | 48 #include "gg-utils.h" |
49 | 49 |
50 static PurplePlugin *my_protocol = NULL; | 50 static PurplePlugin *my_protocol = NULL; |
51 | 51 |
52 /* Prototypes */ | |
53 static void ggp_set_status(PurpleAccount *account, PurpleStatus *status); | |
54 static int ggp_to_gg_status(PurpleStatus *status, char **msg); | |
55 | |
52 /* ---------------------------------------------------------------------- */ | 56 /* ---------------------------------------------------------------------- */ |
53 /* ----- EXTERNAL CALLBACKS --------------------------------------------- */ | 57 /* ----- EXTERNAL CALLBACKS --------------------------------------------- */ |
54 /* ---------------------------------------------------------------------- */ | 58 /* ---------------------------------------------------------------------- */ |
55 | 59 |
56 | 60 |
753 PurpleConnection *gc = (PurpleConnection *)action->context; | 757 PurpleConnection *gc = (PurpleConnection *)action->context; |
754 | 758 |
755 ggp_token_request(gc, ggp_change_passwd_dialog); | 759 ggp_token_request(gc, ggp_change_passwd_dialog); |
756 } | 760 } |
757 | 761 |
762 /* ----- CHANGE STATUS BROADCASTING ------------------------------------------------ */ | |
763 | |
764 static void ggp_action_change_status_broadcasting_ok(PurpleConnection *gc, PurpleRequestFields *fields) | |
765 { | |
766 GGPInfo *info = gc->proto_data; | |
767 int selected_field; | |
768 PurpleAccount *account = purple_connection_get_account(gc); | |
769 PurpleStatus *status; | |
770 | |
771 selected_field = purple_request_fields_get_choice(fields, "status_broadcasting"); | |
772 | |
773 if (selected_field == 0) | |
774 info->status_broadcasting = TRUE; | |
775 else | |
776 info->status_broadcasting = FALSE; | |
777 | |
778 status = purple_account_get_active_status(account); | |
779 | |
780 ggp_set_status(account, status); | |
781 } | |
782 | |
783 static void ggp_action_change_status_broadcasting(PurplePluginAction *action) | |
784 { | |
785 PurpleConnection *gc = (PurpleConnection *)action->context; | |
786 GGPInfo *info = gc->proto_data; | |
787 | |
788 PurpleRequestFields *fields; | |
789 PurpleRequestFieldGroup *group; | |
790 PurpleRequestField *field; | |
791 | |
792 fields = purple_request_fields_new(); | |
793 group = purple_request_field_group_new(NULL); | |
794 purple_request_fields_add_group(fields, group); | |
795 | |
796 field = purple_request_field_choice_new("status_broadcasting", _("Show status to:"), 0); | |
797 purple_request_field_choice_add(field, _("All people")); | |
798 purple_request_field_choice_add(field, _("Only friends")); | |
799 purple_request_field_group_add_field(group, field); | |
800 | |
801 if (info->status_broadcasting) | |
802 purple_request_field_choice_set_default_value(field, 0); | |
803 else | |
804 purple_request_field_choice_set_default_value(field, 1); | |
805 | |
806 purple_request_fields(gc, | |
807 _("Change status broadcasting"), | |
808 _("Change status broadcasting"), | |
809 _("Please, select who can see your status"), | |
810 fields, | |
811 _("OK"), G_CALLBACK(ggp_action_change_status_broadcasting_ok), | |
812 _("Cancel"), NULL, | |
813 purple_connection_get_account(gc), NULL, NULL, | |
814 gc); | |
815 } | |
816 | |
758 /* ----- CONFERENCES ---------------------------------------------------- */ | 817 /* ----- CONFERENCES ---------------------------------------------------- */ |
759 | 818 |
760 static void ggp_callback_add_to_chat_ok(PurpleBuddy *buddy, PurpleRequestFields *fields) | 819 static void ggp_callback_add_to_chat_ok(PurpleBuddy *buddy, PurpleRequestFields *fields) |
761 { | 820 { |
762 GGPInfo *info; | 821 GGPInfo *info; |
853 } | 912 } |
854 | 913 |
855 /* ---------------------------------------------------------------------- */ | 914 /* ---------------------------------------------------------------------- */ |
856 /* ----- INTERNAL CALLBACKS --------------------------------------------- */ | 915 /* ----- INTERNAL CALLBACKS --------------------------------------------- */ |
857 /* ---------------------------------------------------------------------- */ | 916 /* ---------------------------------------------------------------------- */ |
858 | |
859 /* Prototypes */ | |
860 static void ggp_set_status(PurpleAccount *account, PurpleStatus *status); | |
861 static int ggp_to_gg_status(PurpleStatus *status, char **msg); | |
862 | 917 |
863 struct gg_fetch_avatar_data | 918 struct gg_fetch_avatar_data |
864 { | 919 { |
865 PurpleConnection *gc; | 920 PurpleConnection *gc; |
866 gchar *uin; | 921 gchar *uin; |
1946 info->chats_count = 0; | 2001 info->chats_count = 0; |
1947 info->token = NULL; | 2002 info->token = NULL; |
1948 info->searches = ggp_search_new(); | 2003 info->searches = ggp_search_new(); |
1949 info->pending_richtext_messages = NULL; | 2004 info->pending_richtext_messages = NULL; |
1950 info->pending_images = g_hash_table_new(g_int_hash, g_int_equal); | 2005 info->pending_images = g_hash_table_new(g_int_hash, g_int_equal); |
1951 | 2006 info->status_broadcasting = purple_account_get_bool(account, "status_broadcasting", TRUE); |
2007 | |
1952 gc->proto_data = info; | 2008 gc->proto_data = info; |
1953 | 2009 |
1954 glp->uin = ggp_get_uin(account); | 2010 glp->uin = ggp_get_uin(account); |
1955 glp->password = (char *)purple_account_get_password(account); | 2011 glp->password = (char *)purple_account_get_password(account); |
1956 glp->image_size = 255; | 2012 glp->image_size = 255; |
1963 | 2019 |
1964 glp->async = 1; | 2020 glp->async = 1; |
1965 glp->status = ggp_to_gg_status(status, &glp->status_descr); | 2021 glp->status = ggp_to_gg_status(status, &glp->status_descr); |
1966 glp->tls = 0; | 2022 glp->tls = 0; |
1967 | 2023 |
2024 if (!info->status_broadcasting) | |
2025 glp->status = glp->status|GG_STATUS_FRIENDS_MASK; | |
2026 | |
1968 address = purple_account_get_string(account, "gg_server", ""); | 2027 address = purple_account_get_string(account, "gg_server", ""); |
1969 if (address && *address) { | 2028 if (address && *address) { |
1970 /* TODO: Make this non-blocking */ | 2029 /* TODO: Make this non-blocking */ |
1971 struct in_addr *addr = gg_gethostbyname(address); | 2030 struct in_addr *addr = gg_gethostbyname(address); |
1972 | 2031 |
2018 if (info->session != NULL) { | 2077 if (info->session != NULL) { |
2019 ggp_set_status(account, status); | 2078 ggp_set_status(account, status); |
2020 gg_logoff(info->session); | 2079 gg_logoff(info->session); |
2021 gg_free_session(info->session); | 2080 gg_free_session(info->session); |
2022 } | 2081 } |
2082 | |
2083 purple_account_set_bool(account, "status_broadcasting", info->status_broadcasting); | |
2023 | 2084 |
2024 /* Immediately close any notifications on this handle since that process depends | 2085 /* Immediately close any notifications on this handle since that process depends |
2025 * upon the contents of info->searches, which we are about to destroy. | 2086 * upon the contents of info->searches, which we are about to destroy. |
2026 */ | 2087 */ |
2027 purple_notify_close_with_handle(gc); | 2088 purple_notify_close_with_handle(gc); |
2241 gc = purple_account_get_connection(account); | 2302 gc = purple_account_get_connection(account); |
2242 info = gc->proto_data; | 2303 info = gc->proto_data; |
2243 | 2304 |
2244 new_status = ggp_to_gg_status(status, &new_msg); | 2305 new_status = ggp_to_gg_status(status, &new_msg); |
2245 | 2306 |
2307 if (!info->status_broadcasting) | |
2308 new_status = new_status|GG_STATUS_FRIENDS_MASK; | |
2309 | |
2246 if (new_msg == NULL) { | 2310 if (new_msg == NULL) { |
2247 gg_change_status(info->session, new_status); | 2311 gg_change_status(info->session, new_status); |
2248 } else { | 2312 } else { |
2249 gg_change_status_descr(info->session, new_status, new_msg); | 2313 gg_change_status_descr(info->session, new_status, new_msg); |
2250 g_free(new_msg); | 2314 g_free(new_msg); |
2429 | 2493 |
2430 act = purple_plugin_action_new(_("Load buddylist from file..."), | 2494 act = purple_plugin_action_new(_("Load buddylist from file..."), |
2431 ggp_action_buddylist_load); | 2495 ggp_action_buddylist_load); |
2432 m = g_list_append(m, act); | 2496 m = g_list_append(m, act); |
2433 | 2497 |
2498 act = purple_plugin_action_new(_("Change status broadcasting"), | |
2499 ggp_action_change_status_broadcasting); | |
2500 m = g_list_append(m, act); | |
2501 | |
2434 return m; | 2502 return m; |
2435 } | 2503 } |
2436 | 2504 |
2437 static gboolean ggp_offline_message(const PurpleBuddy *buddy) | 2505 static gboolean ggp_offline_message(const PurpleBuddy *buddy) |
2438 { | 2506 { |