pidgin.openq: 9c0f04cf: 2009.02.09 - Chengming Wang <tiger200753...
csyfek at gmail.com
csyfek at gmail.com
Mon Feb 9 10:50:30 EST 2009
-----------------------------------------------------------------
Revision: 9c0f04cfe244cbeb2a13a89213c33fb46064da76
Ancestor: 03a157b94d471daba5c03a25ea316392a4b2001b
Author: csyfek at gmail.com
Date: 2009-02-09T15:52:13
Branch: im.pidgin.pidgin.openq
URL: http://d.pidgin.im/viewmtn/revision/info/9c0f04cfe244cbeb2a13a89213c33fb46064da76
Modified files:
libpurple/protocols/qq/ChangeLog
libpurple/protocols/qq/buddy_memo.c
ChangeLog:
2009.02.09 - Chengming Wang <tiger2007532246(at)gmail.com>
* Rewrite buddy_memo using qq_put/qq_get series functions
-------------- next part --------------
============================================================
--- libpurple/protocols/qq/ChangeLog ef78d43e7fc75be50b081e13234b0f10c44959d4
+++ libpurple/protocols/qq/ChangeLog be773bbbdc53504d9fd0b57c1d9e5a8df61ac907
@@ -1,4 +1,7 @@ 2009.02.09 - Chengming Wang <tiger200753
2009.02.09 - Chengming Wang <tiger2007532246(at)gmail.com>
+ * Rewrite buddy_memo using qq_put/qq_get series functions
+
+2009.02.09 - Chengming Wang <tiger2007532246(at)gmail.com>
* Added buddy 'get memo', 'remove memo', 'upload memo' functions
2009.02.08 - flos <lonicerae(at)gmail.com>
============================================================
--- libpurple/protocols/qq/buddy_memo.c e05317c103cea4d29edb5d6e4ef0fc1a2a63fa96
+++ libpurple/protocols/qq/buddy_memo.c e228922db73c6cc5fabb1b3c51b5fd2f86d05002
@@ -21,7 +21,8 @@
#include<stdlib.h>
#include<stdio.h>
-
+#include <stdlib.h>
+#include <stdio.h>
static const gchar* buddy_memo_txt[] = {
"Name",
"Mobile",
@@ -127,7 +128,7 @@ void qq_request_buddy_memo_upload( Purpl
PurpleConnection* gc;
qq_buddy_data* buddy_data;
guint8* rawData;
- guint8* pos;
+ gint bytes;
int rawDataSize;
int index;
int memoItemSize[QQ_BUDDY_MEMO_SIZE];
@@ -143,16 +144,14 @@ void qq_request_buddy_memo_upload( Purpl
rawDataSize += memoItemSize[index]+1;
}
rawData = g_new0( guint8,rawDataSize );
- pos = rawData;
- (*pos) = QQ_BUDDY_MEMO_UPLOAD;
- pos += 2;
- (*(guint32*)pos) = htonl( buddy_data->uid );
- pos += 5;
+ bytes = 0;
+ bytes += qq_put8( rawData+bytes,QQ_BUDDY_MEMO_UPLOAD );
+ bytes += qq_put8( rawData+bytes,0 );
+ bytes += qq_put32( rawData+bytes, buddy_data->uid );
+ bytes += qq_put8( rawData+bytes,0 );
for( index=0; index<QQ_BUDDY_MEMO_SIZE; index++ ){
- (*pos) = 0xff&memoItemSize[index];
- pos++;
- memcpy( pos, qqCharSetTxt[index], memoItemSize[index] );
- pos += memoItemSize[index];
+ bytes += qq_put8( rawData+bytes,0xff&memoItemSize[index] ); //TODO: 0xff?
+ bytes += qq_putdata( rawData+bytes, (const guint8 *)qqCharSetTxt[index], memoItemSize[index] );
}
qq_send_cmd( gc, QQ_CMD_BUDDY_MEMO, rawData, rawDataSize );
@@ -165,37 +164,40 @@ void qq_request_buddy_memo_download(Purp
void qq_request_buddy_memo_download(PurpleConnection *gc, guint32 uid)
{
- gchar raw_data[16] = {0};
- unsigned int tmp;
+ guint8 raw_data[16] = {0};
+ //unsigned int tmp;
+ gint bytes;
+
purple_debug_info("QQ", "Call qq_request_buddy_memo_download! qq number =%u\n", uid);
g_return_if_fail(uid != 0);
- raw_data[0] = QQ_BUDDY_MEMO_GET;
-
- tmp = htonl((unsigned int)uid);
- memcpy(raw_data+1, &tmp, 4);
+ bytes = 0;
+ bytes += qq_put8( raw_data+bytes, QQ_BUDDY_MEMO_GET );
+ bytes += qq_put32( raw_data+bytes, uid );
- qq_send_cmd(gc, QQ_CMD_BUDDY_MEMO, (guint8*)raw_data, 5);
+ qq_send_cmd(gc, QQ_CMD_BUDDY_MEMO, (guint8*)raw_data, bytes);
}
void qq_process_get_buddy_memo( PurpleConnection *gc, guint8* data, gint len )
{
qq_data *qd;
- //_buddy_memo memo;
PurpleBuddy *buddy;
gchar *who;
qq_buddy_data* bd;
- guint8* pos;
- gint lenth;
+ gint bytes;
+ guint8 lenth;
guint32 qq_number;
+ guint8 receive_cmd;
+ guint8 receive_data;
int k;
- pos = data;
- switch( *pos ){
+ bytes = 0;
+ bytes += qq_get8( &receive_cmd, data+bytes );
+ switch( receive_cmd ){
case QQ_BUDDY_MEMO_UPLOAD :
case QQ_BUDDY_MEMO_REMOVE :
- if( data[1] == QQ_BUDDY_MEMO_REQUEST_SUCCESS ){//????????????
- //TODO:
+ bytes += qq_get8( &receive_data, data+bytes );
+ if( receive_data == QQ_BUDDY_MEMO_REQUEST_SUCCESS ){//????????????
purple_debug_info( "QQ","????????\n" );
purple_notify_message( gc,
PURPLE_NOTIFY_MSG_INFO,
@@ -205,12 +207,21 @@ void qq_process_get_buddy_memo( PurpleCo
NULL,
NULL);
}
+ else{
+ purple_debug_info( "QQ","????????\n" );
+ purple_notify_message( gc,
+ PURPLE_NOTIFY_MSG_INFO,
+ _( "Your request was rejected" ),
+ _( "Your request was rejected" ),
+ _( "Your request was rejected" ),
+ NULL,
+ NULL);
+ }
break;
case QQ_BUDDY_MEMO_GET:
qd = (qq_data *) gc->proto_data;
- pos++;
- qq_number = ntohl( *(uint32_t*)pos );
- pos += 5;//qq???????????????
+ bytes += qq_get32( &qq_number, data+bytes );
+ bytes ++;//qq???????????????
who = uid_to_purple_name( qq_number );
buddy = purple_find_buddy( gc->account, who );
if (buddy == NULL || buddy->proto_data == NULL) {
@@ -224,19 +235,18 @@ void qq_process_get_buddy_memo( PurpleCo
bd->memo = g_new0( gchar*,QQ_BUDDY_MEMO_SIZE );
}
for( k=0; k<QQ_BUDDY_MEMO_SIZE; k++ ){
- lenth = pos[0];
- pos++;
+ bytes += qq_get8( &lenth, data+bytes );
if( bd->memo[k] != NULL )
g_free( bd->memo[k] );
- bd->memo[k] = qq_to_utf8_len( (gchar*)pos, lenth, QQ_CHARSET_DEFAULT );
- pos += lenth;
+ bd->memo[k] = qq_to_utf8_len( (gchar*)(data+bytes), lenth, QQ_CHARSET_DEFAULT );
+ bytes += lenth;
}
buddy_memo_debug( bd->memo );
purple_blist_alias_buddy( buddy,
(const char*)bd->memo[QQ_BUDDY_MEMO_NAME] );//??
break;
default:
- purple_debug_info( "QQ","error: unknown memo cmd\n" );
+ purple_debug_info( "QQ","error: unknown memo cmd \n" );
break;
}
@@ -305,7 +315,7 @@ void qq_on_show_memo(PurpleBlistNode *no
}
-static gchar** buddy_memo_init_data( )
+gchar** buddy_memo_init_data( )
{
gchar** pmemo;
int index;
More information about the Commits
mailing list