pidgin.mxit: b8fb5cf3: Add support for message delivery notific...

andrew.victor at mxit.com andrew.victor at mxit.com
Thu May 13 05:06:04 EDT 2010


-----------------------------------------------------------------
Revision: b8fb5cf371a54215ac977bb4653740046091ab13
Ancestor: 9ac2d649d6fd13882e1793f67d2da5ed5c4d66b5
Author: andrew.victor at mxit.com
Date: 2010-05-13T09:02:58
Branch: im.pidgin.pidgin.mxit
URL: http://d.pidgin.im/viewmtn/revision/info/b8fb5cf371a54215ac977bb4653740046091ab13

Modified files:
        libpurple/protocols/mxit/protocol.c
        libpurple/protocols/mxit/protocol.h

ChangeLog: 

Add support for message delivery notification.


-------------- next part --------------
============================================================
--- libpurple/protocols/mxit/protocol.c	2efcc788cd6e2c6d04707b80e657bb010eb3d2eb
+++ libpurple/protocols/mxit/protocol.c	526588979b939331fb19fbd510c98296ae84e299
@@ -962,6 +962,31 @@ void mxit_send_splashclick( struct MXitS
 
 
 /*------------------------------------------------------------------------
+ * Send a message event packet.
+ *
+ *  @param session		The MXit session object
+ *  @param to           The username of the original sender (ie, recipient of the event)
+ *  @param id			The identifier of the event (received in message)
+ *  @param event		Identified the type of event
+ */
+void mxit_send_msgevent( struct MXitSession* session, const char* to, const char* id, int event)
+{
+	char		data[CP_MAX_PACKET];
+	int			datalen;
+
+	purple_debug_info( MXIT_PLUGIN_ID, "mxit_send_msgevent: to=%s id=%s event=%i\n", to, id, event );
+
+	/* convert the packet to a byte stream */
+	datalen = sprintf( data,	"ms=%s%c%s%c%i",		/* "ms"=contactAddress \1 id \1 event */
+								to, CP_FLD_TERM, id, CP_FLD_TERM, event
+	);
+
+	/* queue packet for transmission */
+	mxit_queue_packet( session, data, datalen, CP_CMD_MSGEVENT );
+}
+
+
+/*------------------------------------------------------------------------
  * Send packet to create a MultiMX room.
  *
  *  @param session		The MXit session object
@@ -1355,6 +1380,12 @@ static void mxit_parse_cmd_message( stru
 		return;
 	}
 
+	if ( msgflags & CP_MSG_NOTIFY_DELIVERY ) {
+		/* delivery notification is requested */
+		if ( records[0]->fcount >= 4 )
+			mxit_send_msgevent( session, records[0]->fields[0]->data, records[0]->fields[3]->data, CP_MSGEVENT_DELIVERED );
+	}
+
 	/* create and initialise new markup struct */
 	mx = g_new0( struct RXMsgData, 1 );
 	mx->msg = g_string_sized_new( msglen );
@@ -1917,6 +1948,8 @@ static int process_success_response( str
 				/* profile update */
 		case CP_CMD_SPLASHCLICK :
 				/* splash-screen clickthrough */
+		case CP_CMD_MSGEVENT :
+				/* event message */
 				break;
 
 		default :
@@ -2020,6 +2053,7 @@ static int process_error_response( struc
 				mxit_popup( PURPLE_NOTIFY_MSG_WARNING, _( "Profile Error" ), _( errdesc ) );
 				break;
 		case CP_CMD_SPLASHCLICK :
+		case CP_CMD_MSGEVENT :
 				/* ignore error */
 				break;
 		case CP_CMD_PING :
============================================================
--- libpurple/protocols/mxit/protocol.h	40e8ef662dd35d8cd127a9b3252d4ba036790d3e
+++ libpurple/protocols/mxit/protocol.h	8cc937df699b1e1f26b4aaeda9858d23272be710
@@ -72,6 +72,9 @@
 #define		MXIT_CF_EXT_MARKUP		0x040000
 #define		MXIT_CF_PLAIN_PWD		0x080000
 #define		MXIT_CF_NO_GATEWAYS		0x100000
+#define		MXIT_CF_NO_AVATARS		0x200000
+#define		MXIT_CF_GAMING			0x400000
+#define		MXIT_CF_GAMING_UPDATE	0x800000
 
 /* Client features supported by this implementation */
 #define		MXIT_CP_FEATURES		( MXIT_CF_FILE_TRANSFER | MXIT_CF_FILE_ACCESS | MXIT_CF_AUDIO | MXIT_CF_MARKUP | MXIT_CF_EXT_MARKUP | MXIT_CF_NO_GATEWAYS | MXIT_CF_IMAGES | MXIT_CF_COMMANDS | MXIT_CF_VIBES | MXIT_CF_MIDP2 )
@@ -126,6 +129,7 @@
 #define		CP_CMD_MEDIA			0x001B					/* (27) get multimedia message */
 #define		CP_CMD_SPLASHCLICK		0x001F					/* (31) splash-screen clickthrough */
 #define		CP_CMD_STATUS			0x0020					/* (32) set shown presence & status */
+#define		CP_CMD_MSGEVENT			0x0023					/* (35) Raise message event */ 
 #define		CP_CMD_MOOD				0x0029					/* (41) set mood */
 #define		CP_CMD_KICK				0x002B					/* (43) login kick */
 #define		CP_CMD_GRPCHAT_CREATE	0x002C					/* (44) create new groupchat */
@@ -147,6 +151,8 @@
 #define		RX_STATE_PROC			0x03					/* process read data */
 
 /* message flags */
+#define		CP_MSG_NOTIFY_DELIVERY	0x0002					/* request delivery notification */
+#define		CP_MSG_NOTIFY_READ		0x0004					/* request read notification */
 #define		CP_MSG_ENCRYPTED		0x0010					/* message is encrypted */
 #define		CP_MSG_MARKUP			0x0200					/* message may contain markup */
 #define		CP_MSG_EMOTICON			0x0400					/* message may contain custom emoticons */
@@ -164,6 +170,9 @@
 #define		CP_MSGTYPE_FORM			0x06					/* mxit custom form */
 #define		CP_MSGTYPE_COMMAND		0x07					/* mxit command */
 
+/* message event types */
+#define		CP_MSGEVENT_DELIVERED	0x02					/* message was delivered */
+#define		CP_MSGEVENT_DISPLAYED	0x04					/* message was viewed */
 
 /* extended profile attribute fields */
 #define		CP_PROFILE_BIRTHDATE	"birthdate"				/* Birthdate (String - ISO 8601 format) */
@@ -284,6 +293,7 @@ void mxit_send_splashclick( struct MXitS
 void mxit_send_deny_sub( struct MXitSession* session, const char* username );
 void mxit_send_update_contact( struct MXitSession* session, const char* username, const char* alias, const char* groupname );
 void mxit_send_splashclick( struct MXitSession* session, const char* splashid );
+void mxit_send_msgevent( struct MXitSession* session, const char* to, const char* id, int event);
 
 void mxit_send_file( struct MXitSession* session, const char* username, const char* filename, const unsigned char* buf, int buflen );
 void mxit_send_file_reject( struct MXitSession* session, const char* fileid );


More information about the Commits mailing list