pidgin/android/libpurple2

368feedc80cf
Merge latest changes from release-2.x.y to default.
--- a/libpurple/protocols/mxit/actions.c Tue Apr 02 09:20:41 2013 -0400
+++ b/libpurple/protocols/mxit/actions.c Wed Apr 03 23:15:20 2013 +0200
@@ -23,8 +23,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
-#include "internal.h"
-#include "purple.h"
+#include "internal.h"
+#include "debug.h"
+#include "request.h"
#include "protocol.h"
#include "mxit.h"
--- a/libpurple/protocols/mxit/chunk.c Tue Apr 02 09:20:41 2013 -0400
+++ b/libpurple/protocols/mxit/chunk.c Wed Apr 03 23:15:20 2013 +0200
@@ -23,8 +23,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
-#include "internal.h"
-#include "purple.h"
+#include "internal.h"
+#include "debug.h"
+
#include "protocol.h"
#include "mxit.h"
#include "chunk.h"
--- a/libpurple/protocols/mxit/cipher.c Tue Apr 02 09:20:41 2013 -0400
+++ b/libpurple/protocols/mxit/cipher.c Wed Apr 03 23:15:20 2013 +0200
@@ -23,8 +23,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
-#include "internal.h"
-#include "purple.h"
+#include "internal.h"
+#include "debug.h"
#include "mxit.h"
#include "cipher.h"
@@ -107,12 +107,12 @@
*/
char* mxit_encrypt_password( struct MXitSession* session )
{
- char key[16 + 1];
- char exkey[512];
- GString* pass = NULL;
- GString* encrypted = NULL;
- char* base64;
- int i;
+ char key[16 + 1];
+ char exkey[512];
+ GString* pass = NULL;
+ GString* encrypted = NULL;
+ char* base64;
+ unsigned int i;
purple_debug_info( MXIT_PLUGIN_ID, "mxit_encrypt_password\n" );
@@ -154,11 +154,11 @@
*/
char* mxit_decrypt_message( struct MXitSession* session, char* message )
{
- guchar* raw_message;
- gsize raw_len;
- char exkey[512];
- GString* decoded = NULL;
- int i;
+ guchar* raw_message;
+ gsize raw_len;
+ char exkey[512];
+ GString* decoded = NULL;
+ unsigned int i;
/* remove optional header: <mxitencrypted ver="5.2"/> */
if ( strncmp( message, ENCRYPT_HEADER, strlen( ENCRYPT_HEADER ) ) == 0 )
@@ -209,11 +209,11 @@
*/
char* mxit_encrypt_message( struct MXitSession* session, char* message )
{
- GString* raw_message = NULL;
- char exkey[512];
- GString* encoded = NULL;
- gchar* base64;
- int i;
+ GString* raw_message = NULL;
+ char exkey[512];
+ GString* encoded = NULL;
+ gchar* base64;
+ unsigned int i;
purple_debug_info( MXIT_PLUGIN_ID, "encrypt message: '%s'\n", message );
--- a/libpurple/protocols/mxit/filexfer.c Tue Apr 02 09:20:41 2013 -0400
+++ b/libpurple/protocols/mxit/filexfer.c Wed Apr 03 23:15:20 2013 +0200
@@ -23,8 +23,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
-#include "internal.h"
-#include "purple.h"
+#include "internal.h"
+#include "debug.h"
+
#include "protocol.h"
#include "mxit.h"
#include "chunk.h"
@@ -124,7 +125,7 @@
if ( purple_xfer_get_type( xfer ) == PURPLE_XFER_SEND ) {
/* we are trying to send a file to MXit */
- if ( purple_xfer_get_size( xfer ) > ( CP_MAX_PACKET - 1000 ) ) { /* need to reserve some space for packet headers */
+ if ( purple_xfer_get_size( xfer ) > CP_MAX_FILESIZE ) {
/* the file is too big */
purple_xfer_error( purple_xfer_get_type( xfer ), purple_xfer_get_account( xfer ), purple_xfer_get_remote_user( xfer ), _( "The file you are trying to send is too large!" ) );
purple_xfer_cancel_local( xfer );
@@ -165,6 +166,7 @@
*/
filesize = purple_xfer_get_bytes_remaining( xfer );
buffer = g_malloc( filesize );
+
if ( fread( buffer, filesize, 1, xfer->dest_fp ) > 0 ) {
/* send data */
wrote = purple_xfer_write( xfer, buffer, filesize );
--- a/libpurple/protocols/mxit/formcmds.c Tue Apr 02 09:20:41 2013 -0400
+++ b/libpurple/protocols/mxit/formcmds.c Wed Apr 03 23:15:20 2013 +0200
@@ -25,9 +25,7 @@
#include "internal.h"
-#include <glib.h>
-
-#include "purple.h"
+#include "debug.h"
#include "obsolete.h"
#include "protocol.h"
--- a/libpurple/protocols/mxit/formcmds.h Tue Apr 02 09:20:41 2013 -0400
+++ b/libpurple/protocols/mxit/formcmds.h Wed Apr 03 23:15:20 2013 +0200
@@ -26,10 +26,8 @@
#ifndef _MXIT_FORMCMDS_H_
#define _MXIT_FORMCMDS_H_
-#include "mxit.h"
-
+#include "protocol.h"
int mxit_parse_command(struct RXMsgData* mx, char* message);
-
#endif /* _MXIT_FORMCMDS_H_ */
--- a/libpurple/protocols/mxit/http.c Tue Apr 02 09:20:41 2013 -0400
+++ b/libpurple/protocols/mxit/http.c Wed Apr 03 23:15:20 2013 +0200
@@ -23,8 +23,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
-#include "internal.h"
-#include "purple.h"
+#include "internal.h"
+#include "debug.h"
#include "mxit.h"
#include "protocol.h"
--- a/libpurple/protocols/mxit/login.c Tue Apr 02 09:20:41 2013 -0400
+++ b/libpurple/protocols/mxit/login.c Wed Apr 03 23:15:20 2013 +0200
@@ -23,8 +23,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
-#include "internal.h"
-#include "purple.h"
+#include "internal.h"
+#include "debug.h"
+#include "request.h"
+#include "version.h"
#include "obsolete.h"
#include "protocol.h"
--- a/libpurple/protocols/mxit/markup.c Tue Apr 02 09:20:41 2013 -0400
+++ b/libpurple/protocols/mxit/markup.c Wed Apr 03 23:15:20 2013 +0200
@@ -23,8 +23,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
-#include "internal.h"
-#include "purple.h"
+#include "internal.h"
+#include "debug.h"
#include "obsolete.h"
#include "protocol.h"
@@ -203,7 +203,7 @@
* @param utf8 The extracted string. Must be deallocated by caller.
* @return The number of bytes extracted
*/
-static int asn_getUtf8( const char* data, char type, char** utf8 )
+static int asn_getUtf8( const char* data, unsigned char type, char** utf8 )
{
int len;
@@ -250,12 +250,12 @@
{
GString* msg = NULL;
char* ch = NULL;
- int pos = 0;
- int start = 0;
- int l_nl = 0;
- int l_sp = 0;
- int l_gt = 0;
- int stop = 0;
+ unsigned int pos = 0;
+ unsigned int start = 0;
+ unsigned int l_nl = 0;
+ unsigned int l_sp = 0;
+ unsigned int l_gt = 0;
+ unsigned int stop = 0;
int tags = 0;
gboolean intag = FALSE;
@@ -654,7 +654,7 @@
*/
static int mxit_parse_vibe( struct RXMsgData* mx, const char* message )
{
- int vibeid;
+ unsigned int vibeid;
vibeid = message[2] - '0';
--- a/libpurple/protocols/mxit/multimx.c Tue Apr 02 09:20:41 2013 -0400
+++ b/libpurple/protocols/mxit/multimx.c Wed Apr 03 23:15:20 2013 +0200
@@ -24,8 +24,7 @@
*/
#include "internal.h"
-#include "purple.h"
-#include "prpl.h"
+#include "debug.h"
#include "protocol.h"
#include "mxit.h"
--- a/libpurple/protocols/mxit/mxit.c Tue Apr 02 09:20:41 2013 -0400
+++ b/libpurple/protocols/mxit/mxit.c Wed Apr 03 23:15:20 2013 +0200
@@ -23,10 +23,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
-#include "internal.h"
-#include "purple.h"
-#include "notify.h"
-#include "plugin.h"
+#include "internal.h"
+#include "debug.h"
+#include "accountopt.h"
#include "version.h"
#include "mxit.h"
@@ -563,7 +562,7 @@
struct MXitSession* session = purple_connection_get_protocol_data( gc );
const char* profilelist[] = { CP_PROFILE_BIRTHDATE, CP_PROFILE_GENDER, CP_PROFILE_FULLNAME,
CP_PROFILE_FIRSTNAME, CP_PROFILE_LASTNAME, CP_PROFILE_REGCOUNTRY, CP_PROFILE_LASTSEEN,
- CP_PROFILE_STATUS, CP_PROFILE_AVATAR, CP_PROFILE_WHEREAMI, CP_PROFILE_ABOUTME };
+ CP_PROFILE_STATUS, CP_PROFILE_AVATAR, CP_PROFILE_WHEREAMI, CP_PROFILE_ABOUTME, CP_PROFILE_RELATIONSHIP };
purple_debug_info( MXIT_PLUGIN_ID, "mxit_get_info: '%s'\n", who );
@@ -665,6 +664,58 @@
}
+/*------------------------------------------------------------------------
+ * Send a typing indicator event.
+ *
+ * @param gc The connection object
+ * @param name The username of the contact
+ * @param state The typing state to be reported.
+ */
+static unsigned int mxit_send_typing( PurpleConnection *gc, const char *name, PurpleTypingState state )
+{
+ PurpleAccount* account = purple_connection_get_account( gc );
+ struct MXitSession* session = purple_connection_get_protocol_data( gc );
+ PurpleBuddy* buddy;
+ struct contact* contact;
+ gchar* messageId = NULL;
+
+ /* 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;
+
+ messageId = purple_uuid_random(); /* generate a unique message id */
+
+ switch ( state ) {
+ case PURPLE_TYPING : /* currently typing */
+ mxit_send_msgevent( session, name, messageId, CP_MSGEVENT_TYPING );
+ break;
+
+ case PURPLE_TYPED : /* stopped typing */
+ case PURPLE_NOT_TYPING : /* not typing / erased all text */
+ mxit_send_msgevent( session, name, messageId, CP_MSGEVENT_STOPPED );
+ break;
+
+ default:
+ break;
+ }
+
+ g_free( messageId );
+
+ return 0;
+}
+
+
/*========================================================================================================================*/
static PurplePluginProtocolInfo proto_info = {
@@ -691,7 +742,7 @@
mxit_close, /* close */
mxit_send_im, /* send_im */
NULL, /* set_info */
- NULL, /* send_typing */
+ mxit_send_typing, /* send_typing */
mxit_get_info, /* get_info */
mxit_set_status, /* set_status */
NULL, /* set_idle */
--- a/libpurple/protocols/mxit/profile.c Tue Apr 02 09:20:41 2013 -0400
+++ b/libpurple/protocols/mxit/profile.c Wed Apr 03 23:15:20 2013 +0200
@@ -26,8 +26,7 @@
#define _XOPEN_SOURCE
#include <time.h>
-#include "internal.h"
-#include "purple.h"
+#include "internal.h"
#include "mxit.h"
#include "profile.h"
--- a/libpurple/protocols/mxit/profile.h Tue Apr 02 09:20:41 2013 -0400
+++ b/libpurple/protocols/mxit/profile.h Wed Apr 03 23:15:20 2013 +0200
@@ -26,8 +26,6 @@
#ifndef _MXIT_PROFILE_H_
#define _MXIT_PROFILE_H_
-#include <glib.h>
-
/* MXit relationship status types */
#define MXIT_RELATIONSHIP_UNKNOWN 0
--- a/libpurple/protocols/mxit/protocol.c Tue Apr 02 09:20:41 2013 -0400
+++ b/libpurple/protocols/mxit/protocol.c Wed Apr 03 23:15:20 2013 +0200
@@ -23,8 +23,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
-#include "internal.h"
-#include "purple.h"
+#include "internal.h"
+#include "debug.h"
+#include "version.h"
#include "obsolete.h"
#include "protocol.h"
@@ -100,26 +101,27 @@
*/
void dump_bytes( struct MXitSession* session, const char* buf, int len )
{
- char msg[( len * 3 ) + 1];
- int i;
-
- memset( msg, 0x00, sizeof( msg ) );
+ char* msg = g_malloc0( len + 1 );
+ int i;
for ( i = 0; i < len; i++ ) {
- if ( buf[i] == CP_REC_TERM ) /* record terminator */
+ char ch = buf[i];
+
+ if ( ch == CP_REC_TERM ) /* record terminator */
msg[i] = '!';
- else if ( buf[i] == CP_FLD_TERM ) /* field terminator */
+ else if ( ch == CP_FLD_TERM ) /* field terminator */
msg[i] = '^';
- else if ( buf[i] == CP_PKT_TERM ) /* packet terminator */
+ else if ( ch == CP_PKT_TERM ) /* packet terminator */
msg[i] = '@';
- else if ( buf[i] < 0x20 )
+ else if ( ( ch < 0x20 ) || ( ch > 0x7E ) ) /* non-printable character */
msg[i] = '_';
else
- msg[i] = buf[i];
-
+ msg[i] = ch;
}
purple_debug_info( MXIT_PLUGIN_ID, "DUMP: '%s'\n", msg );
+
+ g_free( msg );
}
@@ -721,7 +723,7 @@
"%s%c%i%c%s%c%s%c" /* dateOfBirth\1gender\1location\1capabilities\1 */
"%s%c%i%c%s%c%s" /* dc\1features\1dialingcode\1locale */
"%c%i%c%i", /* \1protocolVer\1lastRosterUpdate */
- session->encpwd, CP_FLD_TERM, clientVersion, CP_FLD_TERM, CP_MAX_PACKET, CP_FLD_TERM, profile->nickname, CP_FLD_TERM,
+ session->encpwd, CP_FLD_TERM, clientVersion, 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, features, CP_FLD_TERM, session->dialcode, CP_FLD_TERM, locale,
CP_FLD_TERM, MXIT_CP_PROTO_VESION, CP_FLD_TERM, 0
@@ -768,7 +770,7 @@
session->encpwd, CP_FLD_TERM, clientVersion, CP_FLD_TERM, 1, 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_PACKET, CP_FLD_TERM, MXIT_CP_PROTO_VESION, CP_FLD_TERM, 0
+ CP_MAX_FILESIZE, CP_FLD_TERM, MXIT_CP_PROTO_VESION, CP_FLD_TERM, 0
);
/* include "custom resource" information */
--- a/libpurple/protocols/mxit/roster.c Tue Apr 02 09:20:41 2013 -0400
+++ b/libpurple/protocols/mxit/roster.c Wed Apr 03 23:15:20 2013 +0200
@@ -23,8 +23,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
-#include "internal.h"
-#include "purple.h"
+#include "internal.h"
+#include "debug.h"
#include "protocol.h"
#include "mxit.h"
@@ -672,7 +672,7 @@
{
struct contact* con = NULL;
struct contact* match = NULL;
- int i;
+ unsigned int i;
/* run through all the invites and try and find the match */
for ( i = 0; i < g_list_length( session->invites ); i++ ) {
--- a/libpurple/protocols/mxit/splashscreen.c Tue Apr 02 09:20:41 2013 -0400
+++ b/libpurple/protocols/mxit/splashscreen.c Wed Apr 03 23:15:20 2013 +0200
@@ -24,9 +24,9 @@
*/
#include "internal.h"
-
-#include "purple.h"
+#include "debug.h"
#include "imgstore.h"
+#include "request.h"
#include "protocol.h"
#include "mxit.h"
@@ -121,7 +121,7 @@
splash_remove(session);
/* Save the new splash image */
- dir = g_strdup_printf("%s" G_DIR_SEPARATOR_S "mxit", purple_user_dir());
+ dir = g_strdup_printf("%s" G_DIR_SEPARATOR_S "mxit", purple_user_dir());
purple_build_dir(dir, S_IRUSR | S_IWUSR | S_IXUSR); /* ensure directory exists */
filename = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s.png", dir, purple_escape_filename(splashId));
--- a/libpurple/protocols/mxit/voicevideo.c Tue Apr 02 09:20:41 2013 -0400
+++ b/libpurple/protocols/mxit/voicevideo.c Wed Apr 03 23:15:20 2013 +0200
@@ -23,7 +23,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
-#include "purple.h"
+#include "internal.h"
+
#include "mxit.h"
#include "roster.h"
#include "voicevideo.h"
--- a/libpurple/protocols/mxit/voicevideo.h Tue Apr 02 09:20:41 2013 -0400
+++ b/libpurple/protocols/mxit/voicevideo.h Wed Apr 03 23:15:20 2013 +0200
@@ -26,16 +26,11 @@
#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_ */