comparison libgaim/protocols/qq/im.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 584cbd1628d0
comparison
equal deleted inserted replaced
14241:c54ea2572de9 14242:85f3808ca472
21 */ 21 */
22 22
23 #include "conversation.h" 23 #include "conversation.h"
24 #include "debug.h" 24 #include "debug.h"
25 #include "internal.h" 25 #include "internal.h"
26 #include "cipher.h"
27 #include "notify.h" 26 #include "notify.h"
28 #include "server.h" 27 #include "server.h"
29 #include "util.h" 28 #include "util.h"
30 29
31 #include "buddy_info.h" 30 #include "buddy_info.h"
205 case QQ_RECV_IM_QUN_IM: 204 case QQ_RECV_IM_QUN_IM:
206 return "QQ_RECV_IM_QUN_IM"; 205 return "QQ_RECV_IM_QUN_IM";
207 default: 206 default:
208 return "QQ_RECV_IM_UNKNOWN"; 207 return "QQ_RECV_IM_UNKNOWN";
209 } 208 }
210 }
211
212 /* generate a md5 key using uid and session_key */
213 gchar *_gen_session_md5(gint uid, guint8 *session_key)
214 {
215 guint8 *src, md5_str[QQ_KEY_LENGTH], *cursor;
216 GaimCipher *cipher;
217 GaimCipherContext *context;
218
219 src = g_newa(guint8, 20);
220 cursor = src;
221 create_packet_dw(src, &cursor, uid);
222 create_packet_data(src, &cursor, session_key, QQ_KEY_LENGTH);
223
224 cipher = gaim_ciphers_find_cipher("md5");
225 context = gaim_cipher_context_new(cipher, NULL);
226 gaim_cipher_context_append(context, src, 20);
227 gaim_cipher_context_digest(context, sizeof(md5_str), md5_str, NULL);
228 gaim_cipher_context_destroy(context);
229
230 return g_memdup(md5_str, QQ_KEY_LENGTH);
231 } 209 }
232 210
233 /* when we receive a message, 211 /* when we receive a message,
234 * we send an ACK which is the first 16 bytes of incoming packet */ 212 * we send an ACK which is the first 16 bytes of incoming packet */
235 static void _qq_send_packet_recv_im_ack(GaimConnection *gc, guint16 seq, guint8 *data) 213 static void _qq_send_packet_recv_im_ack(GaimConnection *gc, guint16 seq, guint8 *data)
447 425
448 /* send an IM to to_uid */ 426 /* send an IM to to_uid */
449 void qq_send_packet_im(GaimConnection *gc, guint32 to_uid, gchar *msg, gint type) 427 void qq_send_packet_im(GaimConnection *gc, guint32 to_uid, gchar *msg, gint type)
450 { 428 {
451 qq_data *qd; 429 qq_data *qd;
452 guint8 *cursor, *raw_data, *send_im_tail; 430 guint8 *cursor, *raw_data, *send_im_tail, *md5;
453 guint16 client_tag, normal_im_type; 431 guint16 client_tag, normal_im_type;
454 gint msg_len, raw_len, font_name_len, tail_len, bytes; 432 gint msg_len, raw_len, font_name_len, tail_len, bytes;
455 time_t now; 433 time_t now;
456 gchar *md5, *msg_filtered; 434 gchar *msg_filtered;
457 GData *attribs; 435 GData *attribs;
458 gchar *font_size = NULL, *font_color = NULL, *font_name = NULL, *tmp; 436 gchar *font_size = NULL, *font_color = NULL, *font_name = NULL, *tmp;
459 gboolean is_bold = FALSE, is_italic = FALSE, is_underline = FALSE; 437 gboolean is_bold = FALSE, is_italic = FALSE, is_underline = FALSE;
460 const gchar *start, *end, *last; 438 const gchar *start, *end, *last;
461 439