changeset 10714:ad57a8b5495e

[gaim-migrate @ 12308] Some minor status changes. * Using the "enable?" checkbox in the account window will now sign on an account if it was offline. I'm starting to get a feel for how some of this stuff should work... * Signing on an account that doesn't support available messages no longer shows some warnings. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 21 Mar 2005 05:22:09 +0000
parents 7d4ca0d36f25
children c6bf026fcab9
files src/account.c src/gtkaccount.c src/status.c
diffstat 3 files changed, 35 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/account.c	Mon Mar 21 04:17:21 2005 +0000
+++ b/src/account.c	Mon Mar 21 05:22:09 2005 +0000
@@ -991,6 +991,7 @@
 						gboolean active, ...)
 {
 	GaimStatus *status;
+	GaimStatusType *status_type;
 	va_list args;
 
 	g_return_if_fail(account   != NULL);
@@ -1010,6 +1011,17 @@
 	va_start(args, active);
 	gaim_status_set_active_with_attrs(status, active, args);
 	va_end(args);
+
+	/*
+	 * If this account should be connected, but is not, then connect.
+	 */
+	status_type = gaim_status_get_type(status);
+	if (active &&
+		(gaim_status_type_get_primitive(status_type) != GAIM_STATUS_OFFLINE) &&
+		!gaim_account_is_connected(account))
+	{
+		gaim_account_connect(account, status);
+	}
 }
 
 void
--- a/src/gtkaccount.c	Mon Mar 21 04:17:21 2005 +0000
+++ b/src/gtkaccount.c	Mon Mar 21 05:22:09 2005 +0000
@@ -2044,10 +2044,26 @@
 	if (enabled) {
 		gaim_account_disconnect(account);
 	} else {
-		GaimGtkBuddyList *gtkblist = gaim_gtk_blist_get_default_gtk_blist();
-		const char *type = gtk_gaim_status_box_get_active_type(GTK_GAIM_STATUS_BOX(gtkblist->statusbox));
-		const char *message = gtk_gaim_status_box_get_message(GTK_GAIM_STATUS_BOX(gtkblist->statusbox));
-		gaim_account_set_status(account, type, TRUE, "message", message, NULL);
+		GaimGtkBuddyList *gtkblist;
+		const char *type;
+		GaimStatus *status;
+		GaimStatusType *status_type;
+
+		gtkblist = gaim_gtk_blist_get_default_gtk_blist();
+		type = gtk_gaim_status_box_get_active_type(GTK_GAIM_STATUS_BOX(gtkblist->statusbox));
+		status = gaim_account_get_status(account, type);
+		status_type = gaim_status_get_type(status);
+
+		if (gaim_status_type_get_attr(status_type, "message") != NULL)
+		{
+			const char *message;
+			message = gtk_gaim_status_box_get_message(GTK_GAIM_STATUS_BOX(gtkblist->statusbox));
+			gaim_account_set_status(account, type, TRUE, "message", message, NULL);
+		}
+		else
+		{
+			gaim_account_set_status(account, type, TRUE, NULL);
+		}
 	}
 
 	gaim_account_set_enabled(account, GAIM_GTK_UI, !enabled);
--- a/src/status.c	Mon Mar 21 04:17:21 2005 +0000
+++ b/src/status.c	Mon Mar 21 05:22:09 2005 +0000
@@ -775,6 +775,8 @@
 	gboolean changed = FALSE;
 	const gchar *id;
 
+	g_return_if_fail(status != NULL);
+
 	if (!active && gaim_status_is_exclusive(status))
 	{
 		gaim_debug_error("status",
@@ -783,8 +785,6 @@
 		return;
 	}
 
-	g_return_if_fail(status != NULL);
-
 	if (status->active != active)
 		changed = TRUE;
 
@@ -798,7 +798,7 @@
 		if (value == NULL)
 		{
 			gaim_debug_warning("status", "The attribute \"%s\" on the status \"%s\" is "
-							   "not supported.\n", id, status->title);
+							   "not supported.\n", id, status->type->name);
 			/* Skip over the data and move on to the next attribute */
 			va_arg(args, void *);
 			continue;