| 69 |
69 |
| 70 typedef struct _qq_im_header qq_im_header; |
70 typedef struct _qq_im_header qq_im_header; |
| 71 struct _qq_im_header { |
71 struct _qq_im_header { |
| 72 /* this is the common part of normal_text */ |
72 /* this is the common part of normal_text */ |
| 73 guint16 version_from; |
73 guint16 version_from; |
| 74 guint32 uid_from; |
74 UID uid_from; |
| 75 guint32 uid_to; |
75 UID uid_to; |
| 76 guint8 session_md5[QQ_KEY_LENGTH]; |
76 guint8 session_md5[QQ_KEY_LENGTH]; |
| 77 guint16 im_type; |
77 guint16 im_type; |
| 78 }; |
78 }; |
| 79 |
79 |
| 80 /* read the common parts of the normal_im, |
80 /* read the common parts of the normal_im, |
| 526 } |
526 } |
| 527 |
527 |
| 528 qq_im_format *qq_im_fmt_new(void) |
528 qq_im_format *qq_im_fmt_new(void) |
| 529 { |
529 { |
| 530 qq_im_format *fmt; |
530 qq_im_format *fmt; |
| 531 const gchar simsun[] = { 0xcb, 0xce, 0xcc, 0xe5, 0}; /* simsun in Chinese */ |
531 /* '0xcb, 0xce, 0xcc, 0xe5' means Chinese '宋体' in utf8 */ |
| |
532 const gchar simsun[] = { 0xcb, 0xce, 0xcc, 0xe5, 0}; |
| 532 |
533 |
| 533 fmt = g_new0(qq_im_format, 1); |
534 fmt = g_new0(qq_im_format, 1); |
| 534 memset(fmt, 0, sizeof(qq_im_format)); |
535 memset(fmt, 0, sizeof(qq_im_format)); |
| 535 fmt->font_len = strlen(simsun); |
536 fmt->font_len = strlen(simsun); |
| 536 fmt->font = g_strdup(simsun); |
537 fmt->font = g_strdup(simsun); |
| 537 fmt->attr = 10; |
538 fmt->attr = 10; |
| 538 /* encoding, 0x8602=GB, 0x0000=EN, define BIG5 support here */ |
539 /* encoding, 0x8602=GB, 0x0000=EN, define BIG5 support here */ |
| 539 fmt->charset = 0x8602; |
540 fmt->charset = 0x8602; |
| 540 |
541 |
| 541 return fmt; |
542 return fmt; |
| |
543 } |
| |
544 |
| |
545 void qq_im_fmt_reset_font(qq_im_format *fmt) |
| |
546 { |
| |
547 const gchar simsun[] = {0xcb, 0xce, 0xcc, 0xe5, 0x00}; |
| |
548 g_return_if_fail(NULL != fmt); |
| |
549 |
| |
550 if (NULL != fmt->font) { |
| |
551 g_free(fmt->font); |
| |
552 fmt->font = g_strdup(simsun); |
| |
553 } |
| 542 } |
554 } |
| 543 |
555 |
| 544 qq_im_format *qq_im_fmt_new_by_purple(const gchar *msg) |
556 qq_im_format *qq_im_fmt_new_by_purple(const gchar *msg) |
| 545 { |
557 { |
| 546 qq_im_format *fmt; |
558 qq_im_format *fmt; |
| 1034 break; |
1046 break; |
| 1035 } |
1047 } |
| 1036 } |
1048 } |
| 1037 |
1049 |
| 1038 /* send an IM to uid_to */ |
1050 /* send an IM to uid_to */ |
| 1039 static void request_send_im(PurpleConnection *gc, guint32 uid_to, gint type, |
1051 static void request_send_im(PurpleConnection *gc, UID uid_to, gint type, |
| 1040 qq_im_format *fmt, gchar *msg, guint8 id, guint8 frag_count, guint8 frag_index) |
1052 qq_im_format *fmt, gchar *msg, guint8 id, guint8 frag_count, guint8 frag_index) |
| 1041 { |
1053 { |
| 1042 qq_data *qd; |
1054 qq_data *qd; |
| 1043 guint8 raw_data[MAX_PACKET_SIZE - 16]; |
1055 guint8 raw_data[MAX_PACKET_SIZE - 16]; |
| 1044 gint bytes; |
1056 gint bytes; |
| 1239 */ |
1251 */ |
| 1240 |
1252 |
| 1241 gint qq_send_im(PurpleConnection *gc, const gchar *who, const gchar *what, PurpleMessageFlags flags) |
1253 gint qq_send_im(PurpleConnection *gc, const gchar *who, const gchar *what, PurpleMessageFlags flags) |
| 1242 { |
1254 { |
| 1243 qq_data *qd; |
1255 qq_data *qd; |
| 1244 guint32 uid_to; |
1256 UID uid_to; |
| 1245 gint type; |
1257 gint type; |
| 1246 qq_im_format *fmt; |
1258 qq_im_format *fmt; |
| 1247 gchar *msg_stripped, *tmp; |
1259 gchar *msg_stripped, *tmp; |
| 1248 GSList *segments, *it; |
1260 GSList *segments, *it; |
| 1249 gint msg_len; |
1261 gint msg_len; |