pidgin.mxit: f0aa6a6b: The initial protocol infrastructure for ...
andrew.victor at mxit.com
andrew.victor at mxit.com
Fri Jan 7 17:40:50 EST 2011
----------------------------------------------------------------------
Revision: f0aa6a6b3f0d66046ccee55030c8a8d5e3f9e067
Parent: 746f8b21ba720793649138345cf0b983c7d17c51
Author: andrew.victor at mxit.com
Date: 01/07/11 16:51:05
Branch: im.pidgin.pidgin.mxit
URL: http://d.pidgin.im/viewmtn/revision/info/f0aa6a6b3f0d66046ccee55030c8a8d5e3f9e067
Changelog:
The initial protocol infrastructure for MXit Voice/Video support.
(Currently disabled with compile-time flag)
Changes against parent 746f8b21ba720793649138345cf0b983c7d17c51
added libpurple/protocols/mxit/voicevideo.c
added libpurple/protocols/mxit/voicevideo.h
patched libpurple/protocols/mxit/Makefile.am
patched libpurple/protocols/mxit/Makefile.mingw
patched libpurple/protocols/mxit/mxit.c
patched libpurple/protocols/mxit/mxit.h
patched libpurple/protocols/mxit/protocol.c
patched libpurple/protocols/mxit/protocol.h
patched libpurple/protocols/mxit/roster.c
patched libpurple/protocols/mxit/roster.h
-------------- next part --------------
============================================================
--- libpurple/protocols/mxit/Makefile.am d5d7c82e5a7155e4171ccdbbca419160dd88b536
+++ libpurple/protocols/mxit/Makefile.am 7411e73602215679e6cb5c10662ec22067300e3c
@@ -33,7 +33,9 @@ MXITSOURCES = \
roster.c \
roster.h \
splashscreen.c \
- splashscreen.h
+ splashscreen.h \
+ voicevideo.c \
+ voicevideo.h
AM_CFLAGS = $(st)
============================================================
--- libpurple/protocols/mxit/Makefile.mingw d0e14c7f14ba527b84568484ec27a6da14f62011
+++ libpurple/protocols/mxit/Makefile.mingw 0f455fe48f78f7462ce058922f23b75f3bf430e6
@@ -51,7 +51,8 @@ C_SRC = actions.c \
profile.c \
protocol.c \
roster.c \
- splashscreen.c
+ splashscreen.c \
+ voicevideo.c
OBJECTS = $(C_SRC:%.c=%.o)
============================================================
--- libpurple/protocols/mxit/mxit.c 9ee6d69f7b630a4cfecf8ac63ce364edcf4aec13
+++ libpurple/protocols/mxit/mxit.c 171c3b31fc8d7e4a662b4d9645df2a35ba56cbde
@@ -37,6 +37,7 @@
#include "filexfer.h"
#include "actions.h"
#include "multimx.h"
+#include "voicevideo.h"
#ifdef MXIT_LINK_CLICK
@@ -719,8 +720,8 @@ static PurplePluginProtocolInfo proto_in
NULL, /* attention_types */
sizeof( PurplePluginProtocolInfo ), /* struct_size */
mxit_get_text_table, /* get_account_text_table */
- NULL, /* initiate_media */
- NULL, /* get_media_caps */
+ mxit_media_initiate, /* initiate_media */
+ mxit_media_caps, /* get_media_caps */
mxit_get_moods, /* get_moods */
NULL, /* set_public_alias */
NULL /* get_public_alias */
============================================================
--- libpurple/protocols/mxit/mxit.h c8cd01b98bd425b5874f50a858407c0d711aa2a3
+++ libpurple/protocols/mxit/mxit.h 3c60c130896c399418dcb384793bd6e1b0067ebb
@@ -111,7 +111,6 @@
/* define this to enable the link clicking support */
#define MXIT_LINK_CLICK
-
#ifdef MXIT_LINK_CLICK
#define MXIT_LINK_PREFIX "gopher://"
#define MXIT_LINK_KEY "MXIT"
@@ -141,6 +140,9 @@ struct MXitSession {
guint http_handler; /* HTTP connection handler */
void* http_out_req; /* HTTP outstanding request */
+ /* other servers */
+ char voip_server[HOST_NAME_MAX]; /* voice/video server */
+
/* client */
struct login_data* logindata;
char* encpwd; /* encrypted password */
============================================================
--- libpurple/protocols/mxit/protocol.c da5db4568c9908d4425f6adbf40798f71d318dfd
+++ libpurple/protocols/mxit/protocol.c 7cd5420f0f45e0a833fee08364f54c7c1c550dc9
@@ -37,6 +37,7 @@
#include "login.h"
#include "formcmds.h"
#include "http.h"
+#include "voicevideo.h"
#define MXIT_MS_OFFSET 3
@@ -638,9 +639,16 @@ void mxit_send_register( struct MXitSess
const char* locale;
char data[CP_MAX_PACKET];
int datalen;
+ unsigned int features = MXIT_CP_FEATURES;
locale = purple_account_get_string( session->acc, MXIT_CONFIG_LOCALE, MXIT_DEFAULT_LOCALE );
+ /* Voice and Video supported */
+ if (mxit_audio_enabled() && mxit_video_enabled())
+ features |= (MXIT_CF_VOICE | MXIT_CF_VIDEO);
+ else if (mxit_audio_enabled())
+ features |= MXIT_CF_VOICE;
+
/* convert the packet to a byte stream */
datalen = snprintf( data, sizeof( data ),
"ms=%s%c%s%c%i%c%s%c" /* "ms"=password\1version\1maxreplyLen\1name\1 */
@@ -648,7 +656,7 @@ void mxit_send_register( struct MXitSess
"%s%c%i%c%s%c%s", /* dc\1features\1dialingcode\1locale */
session->encpwd, CP_FLD_TERM, MXIT_CP_VERSION, CP_FLD_TERM, CP_MAX_FILESIZE, CP_FLD_TERM, profile->nickname, CP_FLD_TERM,
profile->birthday, CP_FLD_TERM, ( profile->male ) ? 1 : 0, CP_FLD_TERM, MXIT_DEFAULT_LOC, CP_FLD_TERM, MXIT_CP_CAP, CP_FLD_TERM,
- session->distcode, CP_FLD_TERM, MXIT_CP_FEATURES, CP_FLD_TERM, session->dialcode, CP_FLD_TERM, locale
+ session->distcode, CP_FLD_TERM, features, CP_FLD_TERM, session->dialcode, CP_FLD_TERM, locale
);
/* queue packet for transmission */
@@ -663,13 +671,20 @@ void mxit_send_login( struct MXitSession
*/
void mxit_send_login( struct MXitSession* session )
{
- const char* splashId;
- const char* locale;
- char data[CP_MAX_PACKET];
- int datalen;
+ const char* splashId;
+ const char* locale;
+ char data[CP_MAX_PACKET];
+ int datalen;
+ unsigned int features = MXIT_CP_FEATURES;
locale = purple_account_get_string( session->acc, MXIT_CONFIG_LOCALE, MXIT_DEFAULT_LOCALE );
+ /* Voice and Video supported */
+ if (mxit_audio_enabled() && mxit_video_enabled())
+ features |= (MXIT_CF_VOICE | MXIT_CF_VIDEO);
+ else if (mxit_audio_enabled())
+ features |= MXIT_CF_VOICE;
+
/* convert the packet to a byte stream */
datalen = snprintf( data, sizeof( data ),
"ms=%s%c%s%c%i%c" /* "ms"=password\1version\1getContacts\1 */
@@ -677,7 +692,7 @@ void mxit_send_login( struct MXitSession
"%s%c%s%c" /* dialingcode\1locale\1 */
"%i%c%i%c%i", /* maxReplyLen\1protocolVer\1lastRosterUpdate */
session->encpwd, CP_FLD_TERM, MXIT_CP_VERSION, CP_FLD_TERM, 1, CP_FLD_TERM,
- MXIT_CP_CAP, CP_FLD_TERM, session->distcode, CP_FLD_TERM, MXIT_CP_FEATURES, CP_FLD_TERM,
+ MXIT_CP_CAP, CP_FLD_TERM, session->distcode, CP_FLD_TERM, features, CP_FLD_TERM,
session->dialcode, CP_FLD_TERM, locale, CP_FLD_TERM,
CP_MAX_FILESIZE, CP_FLD_TERM, MXIT_CP_PROTO_VESION, CP_FLD_TERM, 0
);
@@ -1039,7 +1054,6 @@ void mxit_send_groupchat_create( struct
* @param nr_usernames Number of users being invited
* @param usernames The usernames of the users being invited
*/
-
void mxit_send_groupchat_invite( struct MXitSession* session, const char* roomid, int nr_usernames, const char* usernames[] )
{
char data[CP_MAX_PACKET];
@@ -1322,6 +1336,10 @@ static void mxit_parse_cmd_login( struct
if ( records[1]->fcount >= 9 )
session->uid = g_strdup( records[1]->fields[8]->data );
+ /* extract VoIP server (from protocol 6.2) */
+ if ( records[1]->fcount >= 11 )
+ g_strlcpy( session->voip_server, records[1]->fields[10]->data, sizeof( session->voip_server ) );
+
/* display the current splash-screen */
if ( splash_popup_enabled( session ) )
splash_display( session );
@@ -1567,13 +1585,13 @@ static void mxit_parse_cmd_presence( str
*/
static void mxit_parse_cmd_presence( struct MXitSession* session, struct record** records, int rcount )
{
- struct record* rec;
int i;
purple_debug_info( MXIT_PLUGIN_ID, "mxit_parse_cmd_presence (%i recs)\n", rcount );
for ( i = 0; i < rcount; i++ ) {
- rec = records[i];
+ struct record* rec = records[i];
+ int flags = 0;
if ( rec->fcount < 6 ) {
purple_debug_error( MXIT_PLUGIN_ID, "BAD PRESENCE RECORD! %i fields\n", rec->fcount );
@@ -1582,12 +1600,15 @@ static void mxit_parse_cmd_presence( str
/*
* The format of the record is:
- * contactAddressN\1presenceN\1moodN\1customMoodN\1statusMsgN\1avatarIdN
+ * contactAddressN \1 presenceN \1 moodN \1 customMoodN \1 statusMsgN \1 avatarIdN [ \1 flagsN ]
*/
mxit_strip_domain( rec->fields[0]->data ); /* contactAddress */
+ if ( rec->fcount >= 7 ) /* flags field is included */
+ flags = atoi( rec->fields[6]->data );
+
mxit_update_buddy_presence( session, rec->fields[0]->data, atoi( rec->fields[1]->data ), atoi( rec->fields[2]->data ),
- rec->fields[3]->data, rec->fields[4]->data );
+ rec->fields[3]->data, rec->fields[4]->data, flags );
mxit_update_buddy_avatar( session, rec->fields[0]->data, rec->fields[5]->data );
}
}
============================================================
--- libpurple/protocols/mxit/protocol.h 284c3da679dc86c843c0ab725b290e8f50bc371c
+++ libpurple/protocols/mxit/protocol.h 34a2e1a9cb9f285e9616e5d852c486f415c76027
@@ -75,6 +75,8 @@
#define MXIT_CF_NO_AVATARS 0x200000
#define MXIT_CF_GAMING 0x400000
#define MXIT_CF_GAMING_UPDATE 0x800000
+#define MXIT_CF_VOICE 0x1000000
+#define MXIT_CF_VIDEO 0x2000000
/* 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 )
============================================================
--- libpurple/protocols/mxit/roster.c 6ee78f678eeb6c8bab9407223eb68a26bc332e10
+++ libpurple/protocols/mxit/roster.c 875ace8019997d1dc51abbb29e646260b62e516b
@@ -443,8 +443,9 @@ void mxit_update_contact( struct MXitSes
* @param mood The new mood for the contact
* @param customMood The custom mood identifier
* @param statusMsg This is the contact's status message
+ * @param flags The contact's presence flags.
*/
-void mxit_update_buddy_presence( struct MXitSession* session, const char* username, short presence, short mood, const char* customMood, const char* statusMsg )
+void mxit_update_buddy_presence( struct MXitSession* session, const char* username, short presence, short mood, const char* customMood, const char* statusMsg, int flags )
{
PurpleBuddy* buddy = NULL;
struct contact* contact = NULL;
@@ -470,6 +471,7 @@ void mxit_update_buddy_presence( struct
contact->presence = presence;
contact->mood = mood;
+ contact->capabilities = flags;
/* validate mood */
if (( contact->mood < MXIT_MOOD_NONE ) || ( contact->mood > MXIT_MOOD_STRESSED ))
============================================================
--- libpurple/protocols/mxit/roster.h 8acc53e218f7f29b8f78703290411b5736e2995e
+++ libpurple/protocols/mxit/roster.h 11921a1739ca66da856e6184197248434899508d
@@ -79,6 +79,11 @@
#define MXIT_CFLAG_FOCUS_SEND_BLANK 0x20000
+/* MXit presence flags */
+#define MXIT_PFLAG_VOICE 0x1
+#define MXIT_PFLAG_VIDEO 0x2
+
+
/* Subscription types */
#define MXIT_SUBTYPE_BOTH 'B'
#define MXIT_SUBTYPE_PENDING 'P'
@@ -108,6 +113,7 @@ struct contact {
short mood; /* contact current mood */
int flags; /* contact flags */
short presence; /* presence state */
+ int capabilities; /* contact capabilities */
short subtype; /* subscription type */
char* msg; /* invite/rejection message */
@@ -129,7 +135,7 @@ void mxit_update_contact( struct MXitSes
/* MXit Protocol callbacks */
void mxit_update_contact( struct MXitSession* session, struct contact* contact );
-void mxit_update_buddy_presence( struct MXitSession* session, const char* username, short presence, short mood, const char* customMood, const char* statusMsg );
+void mxit_update_buddy_presence( struct MXitSession* session, const char* username, short presence, short mood, const char* customMood, const char* statusMsg, int flags );
void mxit_update_buddy_avatar( struct MXitSession* session, const char* username, const char* avatarId );
void mxit_new_subscription( struct MXitSession* session, struct contact* contact );
void mxit_update_blist( struct MXitSession* session );
============================================================
--- /dev/null
+++ libpurple/protocols/mxit/voicevideo.c 859c8c0f60dfdfbb3a2be5abd4dfde7ba279d7c7
@@ -0,0 +1,154 @@
+/*
+ * MXit Protocol libPurple Plugin
+ *
+ * -- voice & video --
+ *
+ * Andrew Victor <libpurple at mxit.com>
+ *
+ * (C) Copyright 2010 MXit Lifestyle (Pty) Ltd.
+ * <http://www.mxitlifestyle.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+ */
+
+#include "purple.h"
+#include "mxit.h"
+#include "roster.h"
+#include "voicevideo.h"
+
+#if defined(USE_VV) && defined(MXIT_DEV_VV)
+
+#warning "MXit VV support enabled."
+
+/*------------------------------------------------------------------------
+ * Does this client support Voice?
+ */
+gboolean mxit_audio_enabled(void)
+{
+ PurpleMediaManager *manager = purple_media_manager_get();
+ PurpleMediaCaps caps = purple_media_manager_get_ui_caps(manager);
+
+ return (caps & PURPLE_MEDIA_CAPS_AUDIO);
+}
+
+/*------------------------------------------------------------------------
+ * Does this client support Voice and Video?
+ */
+gboolean mxit_video_enabled(void)
+{
+ PurpleMediaManager *manager = purple_media_manager_get();
+ PurpleMediaCaps caps = purple_media_manager_get_ui_caps(manager);
+
+ return (caps & PURPLE_MEDIA_CAPS_VIDEO);
+}
+
+/*------------------------------------------------------------------------
+ * Return the list of media capabilities this contact supports.
+ *
+ * @param account The MXit account object
+ * @param who The username of the contact.
+ * @return The media capabilities supported
+ */
+PurpleMediaCaps mxit_media_caps(PurpleAccount *account, const char *who)
+{
+ struct MXitSession* session = purple_account_get_connection(account)->proto_data;
+ PurpleBuddy* buddy;
+ struct contact* contact;
+ PurpleMediaCaps capa = PURPLE_MEDIA_CAPS_NONE;
+
+ purple_debug_info(MXIT_PLUGIN_ID, "mxit_media_caps: buddy '%s'\n", who);
+
+ /* We need to have a voice/video server */
+ if (strlen(session->voip_server) == 0)
+ return PURPLE_MEDIA_CAPS_NONE;
+
+ /* find the buddy information for this contact (reference: "libpurple/blist.h") */
+ buddy = purple_find_buddy(account, who);
+ if (!buddy) {
+ purple_debug_warning(MXIT_PLUGIN_ID, "mxit_media_caps: unable to find the buddy '%s'\n", who);
+ return PURPLE_MEDIA_CAPS_NONE;
+ }
+
+ contact = purple_buddy_get_protocol_data(buddy);
+ if (!contact)
+ return PURPLE_MEDIA_CAPS_NONE;
+
+ /* can only communicate with MXit users */
+ if (contact->type != MXIT_TYPE_MXIT)
+ return PURPLE_MEDIA_CAPS_NONE;
+
+ /* and only with contacts in the 'Both' subscription state */
+ if (contact->subtype != MXIT_SUBTYPE_BOTH)
+ return PURPLE_MEDIA_CAPS_NONE;
+
+ /* and only when they're online */
+ if (contact->presence == MXIT_PRESENCE_OFFLINE)
+ return MXIT_PRESENCE_OFFLINE;
+
+ /* they support voice-only */
+ if (contact->capabilities & MXIT_PFLAG_VOICE)
+ capa |= PURPLE_MEDIA_CAPS_AUDIO;
+
+ /* they support voice-and-video */
+ if (contact->capabilities & MXIT_PFLAG_VIDEO)
+ capa |= (PURPLE_MEDIA_CAPS_AUDIO | PURPLE_MEDIA_CAPS_VIDEO | PURPLE_MEDIA_CAPS_AUDIO_VIDEO);
+
+ return capa;
+}
+
+
+/*------------------------------------------------------------------------
+ * Initiate a voice/video session with a contact.
+ *
+ * @param account The MXit account object
+ * @param who The username of the contact.
+ * @param type The type of media session to initiate
+ * @return TRUE if session was initiated
+ */
+gboolean mxit_media_initiate(PurpleAccount *account, const char *who, PurpleMediaSessionType type)
+{
+ purple_debug_info(MXIT_PLUGIN_ID, "mxit_media_initiate: buddy '%s'\n", who);
+
+ return FALSE;
+}
+
+#else
+
+/*
+ * Voice and Video not supported.
+ */
+
+gboolean mxit_audio_enabled(void)
+{
+ return FALSE;
+}
+
+gboolean mxit_video_enabled(void)
+{
+ return FALSE;
+}
+
+PurpleMediaCaps mxit_media_caps(PurpleAccount *account, const char *who)
+{
+ return PURPLE_MEDIA_CAPS_NONE;
+}
+
+gboolean mxit_media_initiate(PurpleAccount *account, const char *who, PurpleMediaSessionType type)
+{
+ return FALSE;
+}
+
+#endif
+
============================================================
--- /dev/null
+++ libpurple/protocols/mxit/voicevideo.h d615f658ac6e5f07f4de98f9148f599915ace7d7
@@ -0,0 +1,41 @@
+/*
+ * MXit Protocol libPurple Plugin
+ *
+ * -- voice & video --
+ *
+ * Andrew Victor <libpurple at mxit.com>
+ *
+ * (C) Copyright 2010 MXit Lifestyle (Pty) Ltd.
+ * <http://www.mxitlifestyle.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+ */
+
+#ifndef _MXIT_VOICEVICEO_H_
+#define _MXIT_VOICEVIDEO_H_
+
+#include "media.h"
+
+
+#undef MXIT_DEV_VV
+
+
+gboolean mxit_audio_enabled(void);
+gboolean mxit_video_enabled(void);
+PurpleMediaCaps mxit_media_caps(PurpleAccount* account, const char* who);
+gboolean mxit_media_initiate(PurpleAccount* account, const char* who, PurpleMediaSessionType type);
+
+
+#endif /* _MXIT_VOICEVIDEO_H_ */
More information about the Commits
mailing list