Mercurial > pidgin.yaz
comparison libpurple/protocols/qq/file_trans.c @ 31639:4deef745de87
2010.01.23 - flos <lonicerae(at)gmail.com>
* added an option to force incoming message in chat room to use a default font instead of the font in message itself
2010.01.18 - flos <lonicerae(at)gmail.com>
* added type 'UPDCLS' and 'UID' for implementing business logic layer
2010.01.13 - ccpaging <ccpaging(at)gmail.com>
* qq2009-1 patch from ccpaging
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Sun, 06 Feb 2011 05:23:22 +0000 |
parents | de168bbf1e43 |
children | 1bf763879b96 |
comparison
equal
deleted
inserted
replaced
31638:f0e6aaf942f8 | 31639:4deef745de87 |
---|---|
39 #include "utils.h" | 39 #include "utils.h" |
40 | 40 |
41 struct _qq_file_header { | 41 struct _qq_file_header { |
42 guint16 client_ver; | 42 guint16 client_ver; |
43 guint8 file_key; | 43 guint8 file_key; |
44 guint32 sender_uid; | 44 UID sender_uid; |
45 guint32 receiver_uid; | 45 UID receiver_uid; |
46 }; | 46 }; |
47 | 47 |
48 typedef struct _qq_file_header qq_file_header; | 48 typedef struct _qq_file_header qq_file_header; |
49 | 49 |
50 static guint32 _get_file_key(guint8 seed) | 50 static guint32 _get_file_key(guint8 seed) |
60 | 60 |
61 seed = rand() & 0xFF; | 61 seed = rand() & 0xFF; |
62 return _get_file_key(seed); | 62 return _get_file_key(seed); |
63 } | 63 } |
64 | 64 |
65 static guint32 _decrypt_qq_uid(guint32 uid, guint32 key) | 65 static guint32 _decrypt_qq_uid(UID uid, guint32 key) |
66 { | 66 { |
67 return ~(uid ^ key); | 67 return ~(uid ^ key); |
68 } | 68 } |
69 | 69 |
70 static guint32 _encrypt_qq_uid(guint32 uid, guint32 key) | 70 static guint32 _encrypt_qq_uid(UID uid, guint32 key) |
71 { | 71 { |
72 return (~uid) ^ key; | 72 return (~uid) ^ key; |
73 } | 73 } |
74 | 74 |
75 static void _fill_file_md5(const gchar *filename, gint filelen, guint8 *md5) | 75 static void _fill_file_md5(const gchar *filename, gint filelen, guint8 *md5) |
230 | 230 |
231 if (info->dest_fp) fclose(info->dest_fp); | 231 if (info->dest_fp) fclose(info->dest_fp); |
232 } | 232 } |
233 #endif | 233 #endif |
234 | 234 |
235 static gint _qq_send_file(PurpleConnection *gc, guint8 *data, gint len, guint16 packet_type, guint32 to_uid) | 235 static gint _qq_send_file(PurpleConnection *gc, guint8 *data, gint len, guint16 packet_type, UID to_uid) |
236 { | 236 { |
237 guint8 *raw_data; | 237 guint8 *raw_data; |
238 gint bytes = 0; | 238 gint bytes = 0; |
239 guint32 file_key; | 239 guint32 file_key; |
240 qq_data *qd; | 240 qq_data *qd; |
257 purple_debug_info("QQ", "send_file: want %d but got %d\n", len + 12, bytes); | 257 purple_debug_info("QQ", "send_file: want %d but got %d\n", len + 12, bytes); |
258 return bytes; | 258 return bytes; |
259 } | 259 } |
260 | 260 |
261 /* send a file to udp channel with QQ_FILE_CONTROL_PACKET_TAG */ | 261 /* send a file to udp channel with QQ_FILE_CONTROL_PACKET_TAG */ |
262 void qq_send_file_ctl_packet(PurpleConnection *gc, guint16 packet_type, guint32 to_uid, guint8 hellobyte) | 262 void qq_send_file_ctl_packet(PurpleConnection *gc, guint16 packet_type, UID to_uid, guint8 hellobyte) |
263 { | 263 { |
264 qq_data *qd; | 264 qq_data *qd; |
265 gint bytes, bytes_expected, encrypted_len; | 265 gint bytes, bytes_expected, encrypted_len; |
266 guint8 *raw_data, *encrypted; | 266 guint8 *raw_data, *encrypted; |
267 time_t now; | 267 time_t now; |