pidgin: 0def6190: Gadu-Gadu: Allow showing your status onl...
rekkanoryo at pidgin.im
rekkanoryo at pidgin.im
Sun Mar 13 12:50:47 EDT 2011
----------------------------------------------------------------------
Revision: 0def6190f1792037a4b56d7e6c76bbd7ba704eba
Parent: e769b06f8be8ec74e181a6044fe02bc65902dd8b
Author: mateuszpiekos at gmail.com
Date: 03/13/11 12:10:16
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/0def6190f1792037a4b56d7e6c76bbd7ba704eba
Changelog:
Gadu-Gadu: Allow showing your status only to people on your buddy list.
Fixes #13358.
Changes against parent e769b06f8be8ec74e181a6044fe02bc65902dd8b
patched libpurple/protocols/gg/gg.c
patched libpurple/protocols/gg/gg.h
-------------- next part --------------
============================================================
--- libpurple/protocols/gg/gg.c 7f0250c8f719abd7922cac75d0eb20da58b5a991
+++ libpurple/protocols/gg/gg.c 68116fb0561c92ab8beb86a07f8af19aa0a89459
@@ -49,6 +49,10 @@ static PurplePlugin *my_protocol = NULL;
static PurplePlugin *my_protocol = NULL;
+/* Prototypes */
+static void ggp_set_status(PurpleAccount *account, PurpleStatus *status);
+static int ggp_to_gg_status(PurpleStatus *status, char **msg);
+
/* ---------------------------------------------------------------------- */
/* ----- EXTERNAL CALLBACKS --------------------------------------------- */
/* ---------------------------------------------------------------------- */
@@ -755,6 +759,61 @@ static void ggp_change_passwd(PurplePlug
ggp_token_request(gc, ggp_change_passwd_dialog);
}
+/* ----- CHANGE STATUS BROADCASTING ------------------------------------------------ */
+
+static void ggp_action_change_status_broadcasting_ok(PurpleConnection *gc, PurpleRequestFields *fields)
+{
+ GGPInfo *info = gc->proto_data;
+ int selected_field;
+ PurpleAccount *account = purple_connection_get_account(gc);
+ PurpleStatus *status;
+
+ selected_field = purple_request_fields_get_choice(fields, "status_broadcasting");
+
+ if (selected_field == 0)
+ info->status_broadcasting = TRUE;
+ else
+ info->status_broadcasting = FALSE;
+
+ status = purple_account_get_active_status(account);
+
+ ggp_set_status(account, status);
+}
+
+static void ggp_action_change_status_broadcasting(PurplePluginAction *action)
+{
+ PurpleConnection *gc = (PurpleConnection *)action->context;
+ GGPInfo *info = gc->proto_data;
+
+ PurpleRequestFields *fields;
+ PurpleRequestFieldGroup *group;
+ PurpleRequestField *field;
+
+ fields = purple_request_fields_new();
+ group = purple_request_field_group_new(NULL);
+ purple_request_fields_add_group(fields, group);
+
+ field = purple_request_field_choice_new("status_broadcasting", _("Show status to:"), 0);
+ purple_request_field_choice_add(field, _("All people"));
+ purple_request_field_choice_add(field, _("Only friends"));
+ purple_request_field_group_add_field(group, field);
+
+ if (info->status_broadcasting)
+ purple_request_field_choice_set_default_value(field, 0);
+ else
+ purple_request_field_choice_set_default_value(field, 1);
+
+ purple_request_fields(gc,
+ _("Change status broadcasting"),
+ _("Change status broadcasting"),
+ _("Please, select who can see your status"),
+ fields,
+ _("OK"), G_CALLBACK(ggp_action_change_status_broadcasting_ok),
+ _("Cancel"), NULL,
+ purple_connection_get_account(gc), NULL, NULL,
+ gc);
+}
+
/* ----- CONFERENCES ---------------------------------------------------- */
static void ggp_callback_add_to_chat_ok(PurpleBuddy *buddy, PurpleRequestFields *fields)
@@ -856,10 +915,6 @@ static void ggp_bmenu_block(PurpleBlistN
/* ----- INTERNAL CALLBACKS --------------------------------------------- */
/* ---------------------------------------------------------------------- */
-/* Prototypes */
-static void ggp_set_status(PurpleAccount *account, PurpleStatus *status);
-static int ggp_to_gg_status(PurpleStatus *status, char **msg);
-
struct gg_fetch_avatar_data
{
PurpleConnection *gc;
@@ -1948,7 +2003,8 @@ static void ggp_login(PurpleAccount *acc
info->searches = ggp_search_new();
info->pending_richtext_messages = NULL;
info->pending_images = g_hash_table_new(g_int_hash, g_int_equal);
-
+ info->status_broadcasting = purple_account_get_bool(account, "status_broadcasting", TRUE);
+
gc->proto_data = info;
glp->uin = ggp_get_uin(account);
@@ -1965,6 +2021,9 @@ static void ggp_login(PurpleAccount *acc
glp->status = ggp_to_gg_status(status, &glp->status_descr);
glp->tls = 0;
+ if (!info->status_broadcasting)
+ glp->status = glp->status|GG_STATUS_FRIENDS_MASK;
+
address = purple_account_get_string(account, "gg_server", "");
if (address && *address) {
/* TODO: Make this non-blocking */
@@ -2021,6 +2080,8 @@ static void ggp_close(PurpleConnection *
gg_free_session(info->session);
}
+ purple_account_set_bool(account, "status_broadcasting", info->status_broadcasting);
+
/* Immediately close any notifications on this handle since that process depends
* upon the contents of info->searches, which we are about to destroy.
*/
@@ -2243,6 +2304,9 @@ static void ggp_set_status(PurpleAccount
new_status = ggp_to_gg_status(status, &new_msg);
+ if (!info->status_broadcasting)
+ new_status = new_status|GG_STATUS_FRIENDS_MASK;
+
if (new_msg == NULL) {
gg_change_status(info->session, new_status);
} else {
@@ -2431,6 +2495,10 @@ static GList *ggp_actions(PurplePlugin *
ggp_action_buddylist_load);
m = g_list_append(m, act);
+ act = purple_plugin_action_new(_("Change status broadcasting"),
+ ggp_action_change_status_broadcasting);
+ m = g_list_append(m, act);
+
return m;
}
============================================================
--- libpurple/protocols/gg/gg.h e5ca05fc0e1945e7d729acc0a9bcb7c57682b6b5
+++ libpurple/protocols/gg/gg.h 174220d8802b40f910662633c10a5312f041bec6
@@ -64,6 +64,7 @@ typedef struct {
int chats_count;
GList *pending_richtext_messages;
GHashTable *pending_images;
+ gboolean status_broadcasting; //When TRUE status is visible to all, when FALSE status is visible only to friends.
} GGPInfo;
#endif /* _PURPLE_GG_H */
More information about the Commits
mailing list