diff src/savedstatuses.c @ 11724:a8ec0a291d14

[gaim-migrate @ 14015] If you're online, and sitting around, and la-di-da you enable one of your accounts, it will now use the status currently set in your gtkstatusbox instead of whatever the account was set to when it was disabled committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 22 Oct 2005 22:29:40 +0000
parents 723487d07aa0
children 8657ad65e257
line wrap: on
line diff
--- a/src/savedstatuses.c	Sat Oct 22 22:13:19 2005 +0000
+++ b/src/savedstatuses.c	Sat Oct 22 22:29:40 2005 +0000
@@ -498,6 +498,49 @@
 	return (saved_status->substatuses != NULL);
 }
 
+void
+gaim_savedstatus_activate(const GaimSavedStatus *saved_status)
+{
+	GList *accounts;
+
+	accounts = gaim_accounts_get_all_active();
+
+	while (accounts != NULL)
+	{
+		GaimAccount *account;
+
+		account = accounts->data;
+		gaim_savedstatus_activate_for_account(saved_status, account);
+		accounts = accounts->next;
+	}
+}
+
+void
+gaim_savedstatus_activate_for_account(const GaimSavedStatus *saved_status,
+									  GaimAccount *account)
+{
+	const GList *status_types;
+	GaimStatusType *status_type;
+
+	/* Find the status type that matches the given primitive */
+	status_types = gaim_account_get_status_types(account);
+	while (status_types != NULL)
+	{
+		status_type = status_types->data;
+		if (gaim_status_type_get_primitive(status_type) == saved_status->type)
+		{
+			if (saved_status->message != NULL)
+				gaim_account_set_status(account, gaim_status_type_get_id(status_type),
+										TRUE, "message", saved_status->message, NULL);
+			else
+				gaim_account_set_status(account, gaim_status_type_get_id(status_type),
+										TRUE, NULL);
+			return;
+		}
+		status_types = status_types->next;
+	}
+}
+
 void *
 gaim_savedstatuses_get_handle(void)
 {