cpw.qulogic.msnp16: 8dfea9e7: Add a dialog listing the other endpoints...
qulogic at pidgin.im
qulogic at pidgin.im
Tue Dec 15 04:02:02 EST 2009
-----------------------------------------------------------------
Revision: 8dfea9e767a0db884d1ab0346de6052890c0da55
Ancestor: 9fef6a1023cfc012f2c5dc46dfa21df2e0491547
Author: qulogic at pidgin.im
Date: 2009-12-15T08:57:37
Branch: im.pidgin.cpw.qulogic.msnp16
URL: http://d.pidgin.im/viewmtn/revision/info/8dfea9e767a0db884d1ab0346de6052890c0da55
Modified files:
libpurple/protocols/msn/msn.c
ChangeLog:
Add a dialog listing the other endpoints from which users can sign them out
-------------- next part --------------
============================================================
--- libpurple/protocols/msn/msn.c 2961e3952b40ef583797c16b5b814fa993e730a2
+++ libpurple/protocols/msn/msn.c 2a4c88d03824ddf8d78c2b7e1ddf2614e08e3ecb
@@ -358,40 +358,110 @@ msn_show_set_friendly_name(PurplePluginA
gc);
}
+typedef struct MsnLocationData {
+ PurpleAccount *account;
+ MsnSession *session;
+ PurpleRequestFieldGroup *group;
+} MsnLocationData;
+
static void
-set_endpoint_cb(PurpleConnection *pc, const char *entry)
+update_endpoint_cb(MsnLocationData *data, PurpleRequestFields *fields)
{
+ PurpleAccount *account;
MsnSession *session;
- PurpleAccount *account;
+ const char *old_name;
+ const char *name;
+ GList *others;
- session = purple_connection_get_protocol_data(pc);
- account = purple_connection_get_account(pc);
+ session = data->session;
+ account = data->account;
- /* Empty endpoint names are not allowed */
- if (!entry || !*entry)
+ /* Update the current location's name */
+ old_name = purple_account_get_string(account, "endpoint-name", NULL);
+ name = purple_request_fields_get_string(fields, "endpoint-name");
+ if (!g_str_equal(old_name, name)) {
+ purple_account_set_string(account, "endpoint-name", name);
+ msn_notification_send_uux_private_endpointdata(session);
+ }
+
+ /* Sign out other locations */
+ for (others = purple_request_field_group_get_fields(data->group);
+ others;
+ others = g_list_next(others)) {
+ if (!purple_request_field_bool_get_value(others->data)) {
+ const char *id = purple_request_field_get_id(others->data);
+ char *user;
+ purple_debug_info("msn", "Disconnecting Endpoint %s\n", id);
+
+ user = g_strdup_printf("%s;%s", purple_account_get_username(account), id);
+ msn_notification_send_uun(session, user, MSN_UNIFIED_NOTIFICATION_MPOP, "goawyplzthxbye");
+ g_free(user);
+ }
+ }
+
+ g_free(data);
+}
+
+static void
+create_endpoint_fields(gpointer key, gpointer value, gpointer user_data)
+{
+ const char *id = key;
+ MsnUserEndpoint *ep = value;
+ MsnLocationData *data = user_data;
+ PurpleRequestField *field;
+
+ if (g_str_equal(id, data->session->guid))
return;
- purple_account_set_string(account, "endpoint-name", entry);
- msn_notification_send_uux_private_endpointdata(session);
+ field = purple_request_field_bool_new(id, ep->name, TRUE);
+ purple_request_field_group_add_field(data->group, field);
}
static void
-msn_show_set_endpoint_name(PurplePluginAction *action)
+msn_show_locations(PurplePluginAction *action)
{
PurpleConnection *pc;
PurpleAccount *account;
+ MsnSession *session;
+ PurpleRequestFields *fields;
+ PurpleRequestFieldGroup *group;
+ PurpleRequestField *field;
+ MsnLocationData *data;
pc = (PurpleConnection *)action->context;
account = purple_connection_get_account(pc);
+ session = purple_connection_get_protocol_data(pc);
- purple_request_input(pc, NULL, _("Set your location name."),
- _("This is the name that identifies this location."),
- purple_account_get_string(account, "endpoint-name", NULL),
- FALSE, FALSE, NULL,
- _("OK"), G_CALLBACK(set_endpoint_cb),
- _("Cancel"), NULL,
- account, NULL, NULL,
- pc);
+ fields = purple_request_fields_new();
+
+ group = purple_request_field_group_new(_("This Location"));
+ purple_request_fields_add_group(fields, group);
+ field = purple_request_field_label_new("endpoint-label", _("This is the name that identifies this location"));
+ purple_request_field_group_add_field(group, field);
+ field = purple_request_field_string_new("endpoint-name",
+ _("Name"),
+ purple_account_get_string(account, "endpoint-name", NULL),
+ FALSE);
+ purple_request_field_set_required(field, TRUE);
+ purple_request_field_group_add_field(group, field);
+
+ group = purple_request_field_group_new(_("Other Locations"));
+ purple_request_fields_add_group(fields, group);
+ field = purple_request_field_label_new("others-label", _("You can sign out from other locations here"));
+ purple_request_field_group_add_field(group, field);
+
+ data = g_new0(MsnLocationData, 1);
+ data->account = account;
+ data->session = session;
+ data->group = group;
+ g_hash_table_foreach(session->user->endpoints, create_endpoint_fields, data);
+
+ purple_request_fields(pc, NULL, NULL, NULL,
+ fields,
+ _("OK"), G_CALLBACK(update_endpoint_cb),
+ _("Cancel"), G_CALLBACK(g_free),
+ account, NULL, NULL,
+ data);
}
static void
@@ -967,8 +1037,8 @@ msn_actions(PurplePlugin *plugin, gpoint
m = g_list_append(m, act);
m = g_list_append(m, NULL);
- act = purple_plugin_action_new(_("Set Location Name..."),
- msn_show_set_endpoint_name);
+ act = purple_plugin_action_new(_("View Locations..."),
+ msn_show_locations);
m = g_list_append(m, act);
m = g_list_append(m, NULL);
More information about the Commits
mailing list