changeset 10485:58ab47ed31bf

[gaim-migrate @ 11775] i think this is something like what we want committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Sat, 08 Jan 2005 18:53:49 +0000
parents ec82cbb21fe8
children 84bc372a621e
files src/gtkstatusselector.c src/protocols/oscar/oscar.c
diffstat 2 files changed, 49 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkstatusselector.c	Sat Jan 08 07:40:31 2005 +0000
+++ b/src/gtkstatusselector.c	Sat Jan 08 18:53:49 2005 +0000
@@ -508,7 +508,7 @@
 	gboolean enabled = FALSE;
 	GaimAccount *first_account = NULL;
 	const char *first_prpl_type = NULL;
-	GList *l;
+	const GList *l;
 
 	g_return_if_fail(selector != NULL);
 	g_return_if_fail(GAIM_GTK_IS_STATUS_SELECTOR(selector));
@@ -578,8 +578,6 @@
 
 	if (single_prpl)
 	{
-		const GList *l;
-
 		for (l = gaim_account_get_status_types(first_account);
 			 l != NULL;
 			 l = l->next)
@@ -605,10 +603,50 @@
 	}
 	else
 	{
-		/* TODO: Add "online" and "offline" here? */
-		add_item(selector, "available", _("Available"),
-				 load_icon("online.png"));
-		add_item(selector, "away", _("Away"), load_icon("away.png"));
+		/* what follows is either really ugly, or brilliant depending on
+		 * how you look at it, and how much you've had to drink */
+		int i;
+		int num_accounts = 0;
+		int options[GAIM_STATUS_NUM_PRIMITIVES];
+		GaimAccount *acct_options[GAIM_STATUS_NUM_PRIMITIVES];
+
+		for(i=0; i<GAIM_STATUS_NUM_PRIMITIVES; i++) {
+			options[i] = 0;
+			acct_options[i] = NULL;
+		}
+
+		for(accounts = gaim_accounts_get_all(); accounts != NULL; accounts = accounts->next) {
+			GaimAccount *account = accounts->data;
+
+			if (!gaim_account_get_enabled(account, GAIM_GTK_UI))
+				continue;
+
+			num_accounts++;
+
+			for(l = gaim_account_get_status_types(account); l != NULL; l = l->next) {
+				GaimStatusType *status_type = l->data;
+
+				if (!gaim_status_type_is_user_settable(status_type))
+					continue;
+
+				acct_options[gaim_status_type_get_primitive(status_type)] = account;
+			}
+
+			for(i=0; i<GAIM_STATUS_NUM_PRIMITIVES; i++) {
+				gaim_debug_misc("gtkstatusselector", "account=%p, acct_options[%d]=%p\n", account, i, acct_options[i]);
+				if(acct_options[i] == account)
+					options[i]++;
+			}
+		}
+
+		for(i=0; i<GAIM_STATUS_NUM_PRIMITIVES; i++) {
+			gaim_debug_misc("gtkstatusselector", "%s has %d accounts\n", gaim_primitive_get_name_from_type(i), options[i]);
+			if(options[i] == num_accounts) {
+				char *filename = g_strdup_printf("%s.png", gaim_primitive_get_id_from_type(i));
+				add_item(selector, gaim_primitive_get_id_from_type(i), gaim_primitive_get_name_from_type(i), load_icon(filename));
+				g_free(filename);
+			}
+		}
 	}
 
 	/* TODO: Add saved statuses here? */
--- a/src/protocols/oscar/oscar.c	Sat Jan 08 07:40:31 2005 +0000
+++ b/src/protocols/oscar/oscar.c	Sat Jan 08 18:53:49 2005 +0000
@@ -16,7 +16,7 @@
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
@@ -5797,6 +5797,9 @@
 	GaimStatusType *type = gaim_status_get_type(status);
 	int primitive = gaim_status_type_get_primitive(type);
 
+	if(!gaim_status_is_active(status))
+		return;
+
 	if (primitive == !GAIM_STATUS_OFFLINE && !gc) {
 		gaim_account_connect(account, status);
 	} else if (primitive == GAIM_STATUS_OFFLINE && gc) {