pidgin.mxit: 3d58b1f8: Start on Gaming & Table markup.

andrew.victor at mxit.com andrew.victor at mxit.com
Mon Apr 18 17:25:43 EDT 2011


----------------------------------------------------------------------
Revision: 3d58b1f843fc2aebf9411756956d07ae96951623
Parent:   c4f92259c46aa8d657f99694e71e2376d4794b44
Author:   andrew.victor at mxit.com
Date:     04/18/11 17:20:33
Branch:   im.pidgin.pidgin.mxit
URL: http://d.pidgin.im/viewmtn/revision/info/3d58b1f843fc2aebf9411756956d07ae96951623

Changelog: 

Start on Gaming & Table markup.


Changes against parent c4f92259c46aa8d657f99694e71e2376d4794b44

  patched  libpurple/protocols/mxit/formcmds.c

-------------- next part --------------
============================================================
--- libpurple/protocols/mxit/formcmds.c	910876c4564aefed160a3c9368425d06c16131d7
+++ libpurple/protocols/mxit/formcmds.c	3ed8fdfef2a7c1cfa22acd84350ad7e708ed919d
@@ -54,7 +54,16 @@ typedef enum
 	MXIT_CMD_TABLE				/* Table (tbl) */
 } MXitCommandType;
 
+/* Chat-screen behaviours (bhvr) */
+#define SCREEN_NO_HEADINGS		0x01
+#define SCREEN_FULLSCREEN		0x02
+#define SCREEN_AUTOCLEAR		0x04
+#define SCREEN_NO_AUDIO			0x08
+#define SCREEN_NO_MSGPREFIX		0x10
+#define SCREEN_NOTIFY			0x20
+#define SCREEN_PROGRESSBAR		0x40
 
+
 /*
  * object for an inline image request with an URL
  */
@@ -281,6 +290,7 @@ static void command_reply(struct RXMsgDa
 
 /*------------------------------------------------------------------------
  * Process a PlatformRequest MXit command.
+ *  [::op=cmd|type=platreq|selmsg=Upgrade MXit|dest=http%3a//m.mxit.com|id=12345:]
  *
  *  @param hash			The MXit command <key,value> map
  *  @param msg			The message to display (as generated so far)
@@ -369,6 +379,173 @@ static void command_image(struct RXMsgDa
 
 
 /*------------------------------------------------------------------------
+ * Process an Imagestrip MXit command.
+ *  [::op=is|nm=status|dat=iVBORw0KGgoAAAA%3d%3d|v=63398792426788|fw=8|fh=8|layer=0:]
+ *
+ *  @param from			The sender of the message.
+ *  @param hash			The MXit command <key,value> map
+ */
+static void command_imagestrip(struct MXitSession* session, const char* from, GHashTable* hash)
+{
+	const char* name;
+	const char* validator;
+	const char* tmp;
+	int width, height, layer;
+
+	purple_debug_info(MXIT_PLUGIN_ID, "ImageStrip received from %s\n", from);
+
+	/* image strip name */
+	name = g_hash_table_lookup(hash, "nm");
+
+	/* validator */
+	validator = g_hash_table_lookup(hash, "v");
+
+	/* image data */
+	tmp = g_hash_table_lookup(hash, "dat");
+	if (tmp) {
+		guchar*		rawimg;
+		gsize		rawimglen;
+		char*		dir;
+		char*		filename;
+
+		/* base64 decode the image data */
+		rawimg = purple_base64_decode(tmp, &rawimglen);
+
+		/* save it to a file */
+		dir = g_strdup_printf("%s/mxit/imagestrips", purple_user_dir());
+		purple_build_dir(dir, S_IRUSR | S_IWUSR | S_IXUSR);		/* ensure directory exists */
+
+		filename = g_strdup_printf("%s/%s-%s-%s.png", dir, from, name, validator);
+		purple_util_write_data_to_file_absolute(filename, (char*) rawimg, rawimglen);
+
+		g_free(dir);
+		g_free(filename);
+	}
+
+	tmp = g_hash_table_lookup(hash, "fw");
+	width = atoi(tmp);
+
+	tmp = g_hash_table_lookup(hash, "fh");
+	height = atoi(tmp);
+
+	tmp = g_hash_table_lookup(hash, "layer");
+	layer = atoi(tmp);
+
+	purple_debug_info(MXIT_PLUGIN_ID, "ImageStrip %s from %s: [w=%i h=%i l=%i validator=%s]\n", name, from, width, height, layer, validator);
+}
+
+
+/*------------------------------------------------------------------------
+ * Process a Chat-Screen-Info MXit command.
+ *  [::op=csi:]
+ *
+ *  @param session		The MXit session object
+ *  @param from			The sender of the message.
+ */
+static void command_screeninfo(struct MXitSession* session, const char* from)
+{
+	char* response;
+
+	purple_debug_info(MXIT_PLUGIN_ID, "Chat Screen Info received from %s\n", from);
+
+	// TODO: Determine width, height, colors of chat-screen.
+
+	response = g_strdup_printf("::type=csi|res=bhvr,0;w,%i;h,%i;col,0.ffffffff,29.ff000000:", 300, 400);
+
+	/* send response back to MXit */
+    mxit_send_message( session, from, response, FALSE, TRUE );
+
+	g_free(response);
+}
+
+
+/*------------------------------------------------------------------------
+ * Process a Chat-Screen-Configure MXit command.
+ *  [::op=csc|bhvr=|menu=<menu>|col=<colors>:]
+ *  where:
+ *   menu ::= <menuitem> { ";" <menuitem> }
+ *     menuitem ::= { type "," <text> "," <name> "," <meta> }
+ *   colors ::= <color> { ";" <color> }
+ *     color ::= <colorid> "," <ARGB hex color>   
+ *
+ *  @param session		The MXit session object
+ *  @param from			The sender of the message.
+ *  @param hash			The MXit command <key,value> map
+ */
+static void command_screenconfig(struct MXitSession* session, const char* from, GHashTable* hash)
+{
+	const char* tmp;
+
+	purple_debug_info(MXIT_PLUGIN_ID, "Chat Screen Configure received from %s\n", from);
+
+	/* Behaviour */
+	tmp = g_hash_table_lookup(hash, "bhvr");
+	if (tmp) {
+		purple_debug_info(MXIT_PLUGIN_ID, "  behaviour = %s\n", tmp);
+		// TODO: Re-configure conversation screen.
+	}
+
+	/* Menu */
+	tmp = g_hash_table_lookup(hash, "menu");
+	if (tmp) {
+		purple_debug_info(MXIT_PLUGIN_ID, "  menu = %s\n", tmp);
+		// TODO: Implement conversation-specific sub-menu.
+	}
+
+	/* Colours */
+	tmp = g_hash_table_lookup(hash, "col");
+	if (tmp) {
+		purple_debug_info(MXIT_PLUGIN_ID, "  colours = %s\n", tmp);
+		// TODO: Re-configuration conversation colors.
+	}
+}
+
+
+/*------------------------------------------------------------------------
+ * Process a Table Markup MXit command.
+ *
+ *  @param mx			The received message data object
+ *  @param hash			The MXit command <key,value> map
+ */
+static void command_table(struct RXMsgData* mx, GHashTable* hash)
+{
+	const char* tmp;
+	const char* name;
+	int mode;
+	int nr_columns = 0, nr_rows = 0;
+	gchar** coldata;
+	int i, j;
+
+	/* table name */
+	name = g_hash_table_lookup(hash, "nm");
+
+	/* number of columns */
+	tmp = g_hash_table_lookup(hash, "col");
+	nr_columns = atoi(tmp);	
+
+	/* number of rows */
+	tmp = g_hash_table_lookup(hash, "row");
+	nr_rows = atoi(tmp);
+
+	/* mode */
+	tmp = g_hash_table_lookup(hash, "mode");
+	mode = atoi(tmp);
+
+	/* table data */
+	tmp = g_hash_table_lookup(hash, "d");
+	coldata = g_strsplit(tmp, "~", 0);			/* split into entries for each row & column */
+
+	purple_debug_info(MXIT_PLUGIN_ID, "Table %s from %s: [cols=%i rows=%i mode=%i]\n", name, mx->from, nr_columns, nr_rows, mode);
+
+	for (i = 0; i < nr_rows; i++) {
+		for (j = 0; j < nr_columns; j++) {
+			purple_debug_info(MXIT_PLUGIN_ID, " Row %i Column %i = %s\n", i, j, coldata[i*nr_columns + j]);
+		}
+	}
+}
+
+
+/*------------------------------------------------------------------------
  * Process a received MXit Command message.
  *
  *  @param mx				The received message data object
@@ -410,6 +587,18 @@ int mxit_parse_command(struct RXMsgData*
 				case MXIT_CMD_IMAGE :
 					command_image(mx, hash, mx->msg);
 					break;
+				case MXIT_CMD_SCREENCONFIG :
+					command_screenconfig(mx->session, mx->from, hash);
+					break;
+				case MXIT_CMD_SCREENINFO :
+					command_screeninfo(mx->session, mx->from);
+					break;
+				case MXIT_CMD_IMAGESTRIP :
+					command_imagestrip(mx->session, mx->from, hash);
+					break;
+				case MXIT_CMD_TABLE :
+					command_table(mx, hash);
+					break;
 				default :
 					/* command unknown, or not currently supported */
 					break;


More information about the Commits mailing list