/pidgin/main: c591cb78552a: Only sent Typing Notification to con...

Andrew Victor andrew.victor at mxit.com
Sat Sep 1 17:11:19 EDT 2012


Changeset: c591cb78552ac52fda8bb614888ee4f95522bf9c
Author:	 Andrew Victor <andrew.victor at mxit.com>
Date:	 2012-09-01 23:10 +0200
Branch:	 mxit-2.x.y
URL: http://hg.pidgin.im/pidgin/main/rev/c591cb78552a

Description:

Only sent Typing Notification to contacts that support and want it.

diffstat:

 libpurple/protocols/mxit/mxit.c     |  26 ++++++++++++++++++++++----
 libpurple/protocols/mxit/protocol.h |   6 +++++-
 libpurple/protocols/mxit/roster.h   |   1 +
 3 files changed, 28 insertions(+), 5 deletions(-)

diffs (73 lines):

diff --git a/libpurple/protocols/mxit/mxit.c b/libpurple/protocols/mxit/mxit.c
--- a/libpurple/protocols/mxit/mxit.c
+++ b/libpurple/protocols/mxit/mxit.c
@@ -671,8 +671,26 @@ static GHashTable *mxit_chat_info_defaul
  */
 static unsigned int mxit_send_typing( PurpleConnection *gc, const char *name, PurpleTypingState state )
 {
-	struct MXitSession*	session	= purple_connection_get_protocol_data( gc );
-	gchar* messageId = purple_uuid_random();		/* generate a unique message id */
+	PurpleAccount*		account		= purple_connection_get_account( gc );
+	struct MXitSession*	session		= purple_connection_get_protocol_data( gc );
+	PurpleBuddy*		buddy;
+	struct contact*		contact;
+	gchar*				messageId	= purple_uuid_random();		/* generate a unique message id */
+
+	/* find the buddy information for this contact (reference: "libpurple/blist.h") */
+	buddy = purple_find_buddy( account, name );
+	if ( !buddy ) {
+		purple_debug_warning( MXIT_PLUGIN_ID, "mxit_send_typing: unable to find the buddy '%s'\n", name );
+		return 0;
+	}
+
+	contact = purple_buddy_get_protocol_data( buddy );
+	if ( !contact )
+		return 0;
+
+	/* does this contact support and want typing notification? */
+	if ( ! ( contact->capabilities & MXIT_PFLAG_TYPING ) )
+		return 0;
 
 	switch ( state ) {
 		case PURPLE_TYPING :		/* currently typing */
@@ -690,9 +708,9 @@ static unsigned int mxit_send_typing( Pu
 
 	g_free( messageId );
 
-	return 0;            
+	return 0;
 }
- 
+
 
 /*========================================================================================================================*/
 
diff --git a/libpurple/protocols/mxit/protocol.h b/libpurple/protocols/mxit/protocol.h
--- a/libpurple/protocols/mxit/protocol.h
+++ b/libpurple/protocols/mxit/protocol.h
@@ -77,9 +77,13 @@
 #define		MXIT_CF_GAMING_UPDATE	0x800000
 #define		MXIT_CF_VOICE			0x1000000
 #define		MXIT_CF_VIDEO			0x2000000
+#define		MXIT_CF_TOUCHSCREEN		0x4000000
+#define		MXIT_CF_SVC_CONNECTION	0x8000000
+#define		MXIT_CF_MXML			0x10000000
+#define		MXIT_CF_TYPING_NOTIFY	0x20000000
 
 /* 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 )
+#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 | MXIT_CF_TYPING_NOTIFY )
 
 
 #define		MXIT_PING_INTERVAL		( 5 * 60 )				/* ping the server after X seconds of being idle (5 minutes) */
diff --git a/libpurple/protocols/mxit/roster.h b/libpurple/protocols/mxit/roster.h
--- a/libpurple/protocols/mxit/roster.h
+++ b/libpurple/protocols/mxit/roster.h
@@ -82,6 +82,7 @@
 /* MXit presence flags */
 #define		MXIT_PFLAG_VOICE			0x1
 #define		MXIT_PFLAG_VIDEO			0x2
+#define		MXIT_PFLAG_TYPING			0x4
 
 
 /* Subscription types */



More information about the Commits mailing list