changeset 30951:a328691c761a

* 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
author Mark Doliner <mark@kingant.net>
date Mon, 22 Nov 2010 07:32:57 +0000
parents e946cb06faec
children b4285ea42b6e
files libpurple/protocols/msn/msn.c
diffstat 1 files changed, 23 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/msn.c	Mon Nov 22 03:04:17 2010 +0000
+++ b/libpurple/protocols/msn/msn.c	Mon Nov 22 07:32:57 2010 +0000
@@ -528,6 +528,7 @@
 	PurpleRequestFields *fields;
 	PurpleRequestFieldGroup *group;
 	PurpleRequestField *field;
+	gboolean have_other_endpoints;
 	GSList *l;
 	MsnLocationData *data;
 
@@ -550,19 +551,37 @@
 
 	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;