Mercurial > pidgin.yaz
comparison libgaim/protocols/qq/file_trans.c @ 14242:85f3808ca472
[gaim-migrate @ 16924]
Got rid of a bunch of warnings.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Huetsch <markhuetsch> |
---|---|
date | Sun, 20 Aug 2006 23:16:44 +0000 |
parents | 60b1bc8dbf37 |
children | 6b8bc59414f0 |
comparison
equal
deleted
inserted
replaced
14241:c54ea2572de9 | 14242:85f3808ca472 |
---|---|
36 #include "im.h" | 36 #include "im.h" |
37 #include "packet_parse.h" | 37 #include "packet_parse.h" |
38 #include "proxy.h" | 38 #include "proxy.h" |
39 #include "send_core.h" | 39 #include "send_core.h" |
40 #include "send_file.h" | 40 #include "send_file.h" |
41 | 41 #include "utils.h" |
42 extern gchar *hex_dump_to_str (const guint8 *buffer, gint bytes); | |
43 | 42 |
44 struct _qq_file_header { | 43 struct _qq_file_header { |
45 guint8 tag; | 44 guint8 tag; |
46 guint16 client_ver; | 45 guint16 client_ver; |
47 guint8 file_key; | 46 guint8 file_key; |
74 static guint32 _encrypt_qq_uid(guint32 uid, guint32 key) | 73 static guint32 _encrypt_qq_uid(guint32 uid, guint32 key) |
75 { | 74 { |
76 return (~uid) ^ key; | 75 return (~uid) ^ key; |
77 } | 76 } |
78 | 77 |
79 static void _fill_filename_md5(const gchar *filename, gchar *md5) | 78 static void _fill_filename_md5(const gchar *filename, guint8 *md5) |
80 { | 79 { |
81 GaimCipher *cipher; | 80 GaimCipher *cipher; |
82 GaimCipherContext *context; | 81 GaimCipherContext *context; |
83 | 82 |
84 g_return_if_fail(filename != NULL && md5 != NULL); | 83 g_return_if_fail(filename != NULL && md5 != NULL); |
88 gaim_cipher_context_append(context, (guint8 *) filename, strlen(filename)); | 87 gaim_cipher_context_append(context, (guint8 *) filename, strlen(filename)); |
89 gaim_cipher_context_digest(context, 16, md5, NULL); | 88 gaim_cipher_context_digest(context, 16, md5, NULL); |
90 gaim_cipher_context_destroy(context); | 89 gaim_cipher_context_destroy(context); |
91 } | 90 } |
92 | 91 |
93 static void _fill_file_md5(const gchar *filename, gint filelen, gchar *md5) | 92 static void _fill_file_md5(const gchar *filename, gint filelen, guint8 *md5) |
94 { | 93 { |
95 FILE *fp; | 94 FILE *fp; |
96 guint8 *buffer; | 95 guint8 *buffer; |
97 GaimCipher *cipher; | 96 GaimCipher *cipher; |
98 GaimCipherContext *context; | 97 GaimCipherContext *context; |
272 bytes += create_packet_b(buf, &cursor, file_key & 0xff); | 271 bytes += create_packet_b(buf, &cursor, file_key & 0xff); |
273 bytes += create_packet_dw(buf, &cursor, _encrypt_qq_uid(qd->uid, file_key)); | 272 bytes += create_packet_dw(buf, &cursor, _encrypt_qq_uid(qd->uid, file_key)); |
274 bytes += create_packet_dw(buf, &cursor, _encrypt_qq_uid(to_uid, file_key)); | 273 bytes += create_packet_dw(buf, &cursor, _encrypt_qq_uid(to_uid, file_key)); |
275 bytes += create_packet_data(buf, &cursor, data, len); | 274 bytes += create_packet_data(buf, &cursor, data, len); |
276 | 275 |
277 ssize_t _qq_xfer_write(const char *buf, size_t len, GaimXfer *xfer); | |
278 if (bytes == len + 12) { | 276 if (bytes == len + 12) { |
279 _qq_xfer_write(buf, bytes, qd->xfer); | 277 _qq_xfer_write(buf, bytes, qd->xfer); |
280 } else | 278 } else |
281 gaim_debug(GAIM_DEBUG_INFO, "QQ", "send_file: want %d but got %d\n", len + 12, bytes); | 279 gaim_debug(GAIM_DEBUG_INFO, "QQ", "send_file: want %d but got %d\n", len + 12, bytes); |
282 return bytes; | 280 return bytes; |
283 } | 281 } |
284 | 282 |
285 extern gchar *_gen_session_md5(gint uid, guint8 *session_key); | |
286 | |
287 /* send a file to udp channel with QQ_FILE_CONTROL_PACKET_TAG */ | 283 /* send a file to udp channel with QQ_FILE_CONTROL_PACKET_TAG */ |
288 void qq_send_file_ctl_packet(GaimConnection *gc, guint16 packet_type, guint32 to_uid, guint8 hellobyte) | 284 void qq_send_file_ctl_packet(GaimConnection *gc, guint16 packet_type, guint32 to_uid, guint8 hellobyte) |
289 { | 285 { |
290 qq_data *qd; | 286 qq_data *qd; |
291 gint bytes, bytes_expected, encrypted_len; | 287 gint bytes, bytes_expected, encrypted_len; |
292 guint8 *raw_data, *cursor, *encrypted_data; | 288 guint8 *raw_data, *cursor, *encrypted_data, *md5; |
293 gchar *md5; | |
294 time_t now; | 289 time_t now; |
295 ft_info *info; | 290 ft_info *info; |
296 | 291 |
297 g_return_if_fail(gc != NULL && gc->proto_data != NULL); | 292 g_return_if_fail(gc != NULL && gc->proto_data != NULL); |
298 qd = (qq_data *) gc->proto_data; | 293 qd = (qq_data *) gc->proto_data; |
391 /* send a file to udp channel with QQ_FILE_DATA_PACKET_TAG */ | 386 /* send a file to udp channel with QQ_FILE_DATA_PACKET_TAG */ |
392 static void _qq_send_file_data_packet(GaimConnection *gc, guint16 packet_type, guint8 sub_type, | 387 static void _qq_send_file_data_packet(GaimConnection *gc, guint16 packet_type, guint8 sub_type, |
393 guint32 fragment_index, guint16 seq, guint8 *data, gint len) | 388 guint32 fragment_index, guint16 seq, guint8 *data, gint len) |
394 { | 389 { |
395 gint bytes; | 390 gint bytes; |
396 guint8 *raw_data, *cursor; | 391 guint8 *raw_data, *cursor, filename_md5[QQ_KEY_LENGTH], file_md5[QQ_KEY_LENGTH]; |
397 guint32 fragment_size = 1000; | 392 guint32 fragment_size = 1000; |
398 gchar file_md5[16], filename_md5[16], *filename; | 393 gchar *filename; |
399 gint filename_len, filesize; | 394 gint filename_len, filesize; |
400 qq_data *qd; | 395 qq_data *qd; |
401 ft_info *info; | 396 ft_info *info; |
402 | 397 |
403 g_return_if_fail(gc != NULL && gc->proto_data != NULL); | 398 g_return_if_fail(gc != NULL && gc->proto_data != NULL); |
527 gint decrypted_len; | 522 gint decrypted_len; |
528 qq_data *qd = (qq_data *) gc->proto_data; | 523 qq_data *qd = (qq_data *) gc->proto_data; |
529 guint16 packet_type; | 524 guint16 packet_type; |
530 guint16 seq; | 525 guint16 seq; |
531 guint8 hellobyte; | 526 guint8 hellobyte; |
532 gchar *md5; | 527 guint8 *md5; |
533 ft_info *info = (ft_info *) qd->xfer->data; | 528 ft_info *info = (ft_info *) qd->xfer->data; |
534 | 529 |
535 decrypted_data = g_newa(guint8, len); | 530 decrypted_data = g_newa(guint8, len); |
536 decrypted_len = len; | 531 decrypted_len = len; |
537 | 532 |