changeset 17679:608e4b47dfae

Allow setting status to away or online.
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Mon, 02 Jul 2007 07:07:48 +0000
parents 51f54868bbad
children d87916bd1d73
files libpurple/protocols/myspace/myspace.c libpurple/protocols/myspace/myspace.h
diffstat 2 files changed, 51 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/myspace/myspace.c	Mon Jul 02 05:13:11 2007 +0000
+++ b/libpurple/protocols/myspace/myspace.c	Mon Jul 02 07:07:48 2007 +0000
@@ -1285,6 +1285,53 @@
 	g_free(user_to_lookup); 
 }
 
+/* Set your status. */
+/* TODO: set status to online, when go online, if not invisible? */
+void
+msim_set_status(PurpleAccount *account, PurpleStatus *status)
+{
+	PurpleStatusType *type;
+	guint status_code;
+	MsimSession *session;
+
+	session = (MsimSession *)account->gc->proto_data;
+
+	type = purple_status_get_type(status);
+
+	switch (purple_status_type_get_primitive(type))
+	{
+		case PURPLE_STATUS_AVAILABLE:
+			status_code = MSIM_STATUS_CODE_ONLINE;
+			break;
+
+#if 0
+		case PURPLE_STATUS_INVISIBLE:
+			status_code = MSIM_STATUS_CODE_HIDDEN;
+			break;
+#endif
+
+		case PURPLE_STATUS_AWAY:
+			status_code = MSIM_STATUS_CODE_AWAY;
+			break;
+
+		default:
+			purple_debug_info("msim", "msim_set_status: unknown "
+					"status interpreting as online");
+			status_code = MSIM_STATUS_CODE_ONLINE;
+			break;
+	}
+
+	if (!msim_send(session,
+			"status", MSIM_TYPE_INTEGER, status_code,
+			"sesskey", MSIM_TYPE_INTEGER, session->sesskey,
+			"statstring", MSIM_TYPE_STRING, g_strdup(""),
+			"locstring", MSIM_TYPE_STRING, g_strdup("")))
+	{
+		purple_debug_info("msim", "msim_set_status: failed to set status");
+	}
+
+}
+
 /** After a uid is resolved to username, tag it with the username and submit for processing. 
  * 
  * @param session
@@ -2668,7 +2715,7 @@
     NULL,              /* set_info */
     msim_send_typing,  /* send_typing */
 	msim_get_info, 	   /* get_info */
-    NULL,              /* set_away */
+    msim_set_status,   /* set_status */
     NULL,              /* set_idle */
     NULL,              /* change_passwd */
     msim_add_buddy,    /* add_buddy */
--- a/libpurple/protocols/myspace/myspace.h	Mon Jul 02 05:13:11 2007 +0000
+++ b/libpurple/protocols/myspace/myspace.h	Mon Jul 02 07:07:48 2007 +0000
@@ -133,6 +133,7 @@
 #define MSIM_STATUS_CODE_OFFLINE		0	/* or hidden */
 #define MSIM_STATUS_CODE_ONLINE			1
 #define MSIM_STATUS_CODE_AWAY			5
+/* TODO: hidden */
 
 /* Random number in every MsimSession, to ensure it is valid. */
 #define MSIM_SESSION_STRUCT_MAGIC       0xe4a6752b
@@ -202,6 +203,8 @@
 void msim_get_info_cb(MsimSession *session, MsimMessage *userinfo, gpointer data);
 void msim_get_info(PurpleConnection *gc, const gchar *name);
 
+void msim_set_status(PurpleAccount *account, PurpleStatus *status);
+
 void msim_store_buddy_info_each(gpointer key, gpointer value, gpointer user_data);
 gboolean msim_store_buddy_info(MsimSession *session, MsimMessage *msg);
 gboolean msim_process_reply(MsimSession *session, MsimMessage *msg);