pidgin: fe00f978: * Don't include ourselves in the list of...

markdoliner at pidgin.im markdoliner at pidgin.im
Mon Nov 22 02:38:09 EST 2010


----------------------------------------------------------------------
Revision: fe00f9786c65219ca9a113663801eb1df2bf3b15
Parent:   f3e5e3ff81060137ebde7cf6d19ee15f5b8822b1
Author:   markdoliner at pidgin.im
Date:     11/22/10 02:32:57
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/fe00f9786c65219ca9a113663801eb1df2bf3b15

Changelog: 

* Don't include ourselves in the list of other endpoints that can be
  disconnected
* Show a different message if there are no other endpoints.  Unfortunately
  this message has a colon after it, because our request API adds a colon
  to all labels.  There's a note in the code listing possible options for
  fixing that.  For now, I think this is an improvement

Changes against parent f3e5e3ff81060137ebde7cf6d19ee15f5b8822b1

  patched  libpurple/protocols/msn/msn.c

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/msn.c	f24c090aec062384522ee9131cad12e16d13e832
+++ libpurple/protocols/msn/msn.c	7df4ff74aa4d42f65b5596f4dcb57c521de35396
@@ -528,6 +528,7 @@ msn_show_locations(PurplePluginAction *a
 	PurpleRequestFields *fields;
 	PurpleRequestFieldGroup *group;
 	PurpleRequestField *field;
+	gboolean have_other_endpoints;
 	GSList *l;
 	MsnLocationData *data;
 
@@ -550,19 +551,37 @@ msn_show_locations(PurplePluginAction *a
 
 	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);
 
+	have_other_endpoints = FALSE;
 	for (l = session->user->endpoints; l; l = l->next) {
 		MsnUserEndpoint *ep = l->data;
 
-		if (g_str_equal(ep->id, session->guid))
+		if (ep->id[0] != '\0' && strncasecmp(ep->id + 1, session->guid, 36) == 0)
 			/* Don't add myself to the list */
 			continue;
 
+		if (!have_other_endpoints) {
+			/* We do in fact have an endpoint other than ourselves... let's
+			   add a label */
+			field = purple_request_field_label_new("others-label",
+					_("You can sign out from other locations here"));
+			purple_request_field_group_add_field(group, field);
+		}
+
+		have_other_endpoints = TRUE;
 		field = purple_request_field_bool_new(ep->id, ep->name, FALSE);
 		purple_request_field_group_add_field(group, field);
 	}
+	if (!have_other_endpoints) {
+		/* TODO: Due to limitations in our current request field API, the
+		   following string will show up with a trailing colon.  This should
+		   be fixed either by adding an "include_colon" boolean, or creating
+		   a separate purple_request_field_label_new_without_colon function,
+		   or by never automatically adding the colon and requiring that
+		   callers add the colon themselves. */
+		field = purple_request_field_label_new("others-label", _("You are not signed in from any other locations."));
+		purple_request_field_group_add_field(group, field);
+	}
 
 	data = g_new0(MsnLocationData, 1);
 	data->account = account;


More information about the Commits mailing list