changeset 10197:7369bf2bf593

[gaim-migrate @ 11314] More status fixes. Oscar kind of works... you can set yourself away, invisible and available, but you can't choose the message for away, can't choose an available message, and invisible only seems to work the first time. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 17 Nov 2004 01:32:06 +0000
parents 760e690a5f30
children 137a880153ba
files src/gtkstatusselector.c src/protocols/oscar/oscar.c src/status.c
diffstat 3 files changed, 23 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkstatusselector.c	Tue Nov 16 23:29:53 2004 +0000
+++ b/src/gtkstatusselector.c	Wed Nov 17 01:32:06 2004 +0000
@@ -226,13 +226,9 @@
 			/* TODO */
 		}
 	}
-	else if (!strcmp(status_type_id, "available"))
+	else
 	{
-		/* TODO */
-	}
-	else if (!strcmp(status_type_id, "away"))
-	{
-		const char *message = "";
+		const char *message = text;
 		GtkTextBuffer *buffer;
 		gboolean allow_message = FALSE;
 
@@ -256,7 +252,7 @@
 			if (gaim_status_type_get_attr(status_type, "message") != NULL)
 			{
 				gaim_account_set_status(account,
-										"away", TRUE,
+										status_type_id, TRUE,
 										"message", message,
 										NULL);
 
@@ -265,7 +261,7 @@
 			else
 			{
 				gaim_account_set_status(account,
-										"away", TRUE,
+										status_type_id, TRUE,
 										NULL);
 			}
 		}
--- a/src/protocols/oscar/oscar.c	Tue Nov 16 23:29:53 2004 +0000
+++ b/src/protocols/oscar/oscar.c	Wed Nov 17 01:32:06 2004 +0000
@@ -5560,11 +5560,6 @@
 
 	gaim_debug_info("oscar", "Setting status to %s\n", status_id);
 
-	if (primitive == GAIM_STATUS_HIDDEN)
-		aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE);
-	else
-		aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL);
-
 	if (od->rights.maxawaymsglen == 0)
 		gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."),
 							_("You have probably requested to set your "
@@ -5574,6 +5569,8 @@
 							  "fully connected."));
 
 	if (primitive == GAIM_STATUS_AVAILABLE) {
+		aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL);
+
 		aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0);
 #if 0
 		/* Set an available message */
@@ -5581,6 +5578,8 @@
 #endif
 
 	} else if (primitive == GAIM_STATUS_AWAY) {
+		aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL);
+
 		text_html = gaim_status_get_attr_string(status, "message");
 
 		if (text_html == NULL) {
@@ -5616,6 +5615,9 @@
 			g_free(errstr);
 		}
 
+	} else if (primitive == GAIM_STATUS_HIDDEN) {
+		aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE);
+
 	} else {
 		gaim_debug_info("oscar", "Don't know what to do for this status\n");
 
--- a/src/status.c	Tue Nov 16 23:29:53 2004 +0000
+++ b/src/status.c	Wed Nov 17 01:32:06 2004 +0000
@@ -269,7 +269,7 @@
 }
 
 void
-gaim_status_type_add_attr(GaimStatusType *status_type, const char *id,\
+gaim_status_type_add_attr(GaimStatusType *status_type, const char *id,
 		const char *name, GaimValue *value)
 {
 	GaimStatusAttr *attr;
@@ -515,7 +515,8 @@
 		GaimValue *new_value = gaim_value_dup(value);
 
 		g_hash_table_insert(status->attr_values,
-		g_strdup(gaim_status_attr_get_id(attr)), new_value);
+							g_strdup(gaim_status_attr_get_id(attr)),
+							new_value);
 	}
 
 	return status;
@@ -693,7 +694,6 @@
 		gboolean value)
 {
 	GaimStatusType *status_type;
-	GaimStatusAttr *attr;
 	GaimValue *attr_value;
 
 	g_return_if_fail(status != NULL);
@@ -701,11 +701,9 @@
 
 	status_type = gaim_status_get_type(status);
 
-	/* Make sure this attribute exists. */
-	attr = gaim_status_type_get_attr(status_type, id);
-	g_return_if_fail(attr != NULL);
-
-	attr_value = gaim_status_attr_get_value_type(attr);
+	/* Make sure this attribute exists and is the correct type. */
+	attr_value = gaim_status_get_attr_value(status, id);
+	g_return_if_fail(attr_value != NULL);
 	g_return_if_fail(gaim_value_get_type(attr_value) == GAIM_TYPE_BOOLEAN);
 
 	gaim_value_set_boolean(attr_value, value);
@@ -715,7 +713,6 @@
 gaim_status_set_attr_int(GaimStatus *status, const char *id, int value)
 {
 	GaimStatusType *status_type;
-	GaimStatusAttr *attr;
 	GaimValue *attr_value;
 
 	g_return_if_fail(status != NULL);
@@ -723,11 +720,9 @@
 
 	status_type = gaim_status_get_type(status);
 
-	/* Make sure this attribute exists. */
-	attr = gaim_status_type_get_attr(status_type, id);
-	g_return_if_fail(attr != NULL);
-
-	attr_value = gaim_status_attr_get_value_type(attr);
+	/* Make sure this attribute exists and is the correct type. */
+	attr_value = gaim_status_get_attr_value(status, id);
+	g_return_if_fail(attr_value != NULL);
 	g_return_if_fail(gaim_value_get_type(attr_value) == GAIM_TYPE_INT);
 
 	gaim_value_set_int(attr_value, value);
@@ -738,7 +733,6 @@
 		const char *value)
 {
 	GaimStatusType *status_type;
-	GaimStatusAttr *attr;
 	GaimValue *attr_value;
 
 	g_return_if_fail(status != NULL);
@@ -746,11 +740,9 @@
 
 	status_type = gaim_status_get_type(status);
 
-	/* Make sure this attribute exists. */
-	attr = gaim_status_type_get_attr(status_type, id);
-	g_return_if_fail(attr != NULL);
-
+	/* Make sure this attribute exists and is the correct type. */
 	attr_value = gaim_status_get_attr_value(status, id);
+	g_return_if_fail(attr_value != NULL);
 	g_return_if_fail(gaim_value_get_type(attr_value) == GAIM_TYPE_STRING);
 
 	gaim_value_set_string(attr_value, value);
@@ -833,12 +825,6 @@
 			primitive != GAIM_STATUS_OFFLINE);
 }
 
-/*
- * What's the difference between
- * gaim_status_get_attr_value(GaimStatus *status, const char *id)
- * gaim_status_attr_get_value_type(GaimStatusAttr *attr)
- * and I think there was another similar one...
- */
 GaimValue *
 gaim_status_get_attr_value(const GaimStatus *status, const char *id)
 {
@@ -868,7 +854,7 @@
 	if ((value = gaim_status_get_attr_value(status, id)) == NULL)
 		return FALSE;
 
-	g_return_val_if_fail(gaim_value_get_type(value) == GAIM_TYPE_STRING, FALSE);
+	g_return_val_if_fail(gaim_value_get_type(value) == GAIM_TYPE_BOOLEAN, FALSE);
 
 	return gaim_value_get_boolean(value);
 }