annotate libpurple/protocols/qq/im.c @ 25363:cf6dfd38c7c1

Fix a botched line in the merge...
author Gary Kramlich <grim@reaperworld.com>
date Sat, 13 Dec 2008 05:49:20 +0000
parents 65cfc59858cf
children be87547aa431
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * @file im.c
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
4 * purple
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
6 * Purple is the legal property of its developers, whose names are too numerous
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * source distribution.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
19680
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18807
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24
18210
b8572b937c09 #include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents: 16208
diff changeset
25 #include "internal.h"
b8572b937c09 #include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents: 16208
diff changeset
26
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "conversation.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "debug.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "internal.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "notify.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "server.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include "util.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include "buddy_info.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 #include "buddy_list.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 #include "buddy_opt.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 #include "char_conv.h"
24065
bdfcfd71449c patch 20080922 from ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24048
diff changeset
38 #include "qq_define.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 #include "im.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 #include "packet_parse.h"
23052
51dbe83ebbd3 patch-04-tcp-pending
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
41 #include "qq_network.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 #include "send_file.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 #include "utils.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
45 #define QQ_MSG_IM_MAX 700 /* max length of IM */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
46
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
47 enum {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
48 QQ_IM_TEXT = 0x01,
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
49 QQ_IM_AUTO_REPLY = 0x02
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
50 };
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 enum
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 {
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
54 QQ_NORMAL_IM_TEXT = 0x000b,
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 QQ_NORMAL_IM_FILE_REQUEST_TCP = 0x0001,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 QQ_NORMAL_IM_FILE_APPROVE_TCP = 0x0003,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 QQ_NORMAL_IM_FILE_REJECT_TCP = 0x0005,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 QQ_NORMAL_IM_FILE_REQUEST_UDP = 0x0035,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 QQ_NORMAL_IM_FILE_APPROVE_UDP = 0x0037,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 QQ_NORMAL_IM_FILE_REJECT_UDP = 0x0039,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 QQ_NORMAL_IM_FILE_NOTIFY = 0x003b,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 QQ_NORMAL_IM_FILE_PASV = 0x003f, /* are you behind a firewall? */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 QQ_NORMAL_IM_FILE_CANCEL = 0x0049,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 QQ_NORMAL_IM_FILE_EX_REQUEST_UDP = 0x81,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 QQ_NORMAL_IM_FILE_EX_REQUEST_ACCEPT = 0x83,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 QQ_NORMAL_IM_FILE_EX_REQUEST_CANCEL = 0x85,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 QQ_NORMAL_IM_FILE_EX_NOTIFY_IP = 0x87
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
70 typedef struct _qq_im_header qq_im_header;
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
71 struct _qq_im_header {
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
72 /* this is the common part of normal_text */
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
73 guint16 version_from;
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
74 guint32 uid_from;
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
75 guint32 uid_to;
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
76 guint8 session_md5[QQ_KEY_LENGTH];
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 guint16 im_type;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 /* read the common parts of the normal_im,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 * returns the bytes read if succeed, or -1 if there is any error */
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
82 static gint get_im_header(qq_im_header *im_header, guint8 *data, gint len)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 gint bytes;
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
85 g_return_val_if_fail(data != NULL && len > 0, -1);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 bytes = 0;
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
88 bytes += qq_get16(&(im_header->version_from), data + bytes);
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
89 bytes += qq_get32(&(im_header->uid_from), data + bytes);
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
90 bytes += qq_get32(&(im_header->uid_to), data + bytes);
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
91 bytes += qq_getdata(im_header->session_md5, QQ_KEY_LENGTH, data + bytes);
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
92 bytes += qq_get16(&(im_header->im_type), data + bytes);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 return bytes;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
96 typedef struct _qq_emoticon qq_emoticon;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
97 struct _qq_emoticon {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
98 guint8 symbol;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
99 gchar *name;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
100 };
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
101
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
102 static gboolean emoticons_is_sorted = FALSE;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
103 /* Map for purple smiley convert to qq, need qsort */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
104 static qq_emoticon emoticons_std[] = {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
105 {0x4f, "/:)"}, {0x4f, "/wx"}, {0x4f, "/small_smile"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
106 {0x42, "/:~"}, {0x42, "/pz"}, {0x42, "/curl_lip"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
107 {0x43, "/:*"}, {0x43, "/se"}, {0x43, "/desire"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
108 {0x44, "/:|"}, {0x44, "/fd"}, {0x44, "/dazed"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
109 {0x45, "/8-)"}, {0x45, "/dy"}, {0x45, "/revel"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
110 {0x46, "/:<"}, {0x46, "/ll"}, {0x46, "/cry"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
111 {0x47, "/:$"}, {0x47, "/hx"}, {0x47, "/bashful"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
112 {0x48, "/:x"}, {0x48, "/bz"}, {0x48, "/shut_mouth"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
113 {0x8f, "/|-)"}, {0x8f, "/kun"}, {0x8f, "/sleepy"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
114 {0x49, "/:z"}, {0x49, "/shui"}, {0x49, "/sleep"}, /* after sleepy */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
115 {0x4a, "/:'"}, {0x4a, "/dk"}, {0x4a, "/weep"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
116 {0x4b, "/:-|"}, {0x4b, "/gg"}, {0x4b, "/embarassed"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
117 {0x4c, "/:@"}, {0x4c, "/fn"}, {0x4c, "/pissed_off"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
118 {0x4d, "/:P"}, {0x4d, "/tp"}, {0x4d, "/act_up"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
119 {0x4e, "/:D"}, {0x4e, "/cy"}, {0x4e, "/toothy_smile"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
120 {0x41, "/:O"}, {0x41, "/jy"}, {0x41, "/surprised"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
121 {0x73, "/:("}, {0x73, "/ng"}, {0x73, "/sad"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
122 {0x74, "/:+"}, {0x74, "/kuk"}, {0x74, "/cool"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
123 {0xa1, "/--b"}, {0xa1, "/lengh"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
124 {0x76, "/:Q"}, {0x76, "/zk"}, {0x76, "/crazy"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
125 {0x8a, "/;P"}, {0x8a, "/tx"}, {0x8a, "/titter"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
126 {0x8b, "/;-D"}, {0x8b, "/ka"}, {0x8b, "/cute"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
127 {0x8c, "/;d"}, {0x8c, "/by"}, {0x8c, "/disdain"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
128 {0x8d, "/;o"}, {0x8d, "/am"}, {0x8d, "/arrogant"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
129 {0x8e, "/:g"}, {0x8e, "/jie"}, {0x8e, "/starving"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
130 {0x78, "/:!"}, {0x78, "/jk"}, {0x78, "/terror"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
131 {0x79, "/:L"}, {0x79, "/lh"}, {0x79, "/sweat"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
132 {0x7a, "/:>"}, {0x7a, "/hanx"}, {0x7a, "/smirk"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
133 {0x7b, "/:;"}, {0x7b, "/db"}, {0x7b, "/soldier"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
134 {0x90, "/;f"}, {0x90, "/fendou"}, {0x90, "/struggle"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
135 {0x91, "/:-S"}, {0x91, "/zhm"}, {0x91, "/curse"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
136 {0x92, "/?"}, {0x92, "/yiw"}, {0x92, "/question"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
137 {0x93, "/;x"}, {0x93, "/xu"}, {0x93, "/shh"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
138 {0x94, "/;@"}, {0x94, "/yun"}, {0x94, "/dizzy"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
139 {0x95, "/:8"}, {0x95, "/zhem"}, {0x95, "/excrutiating"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
140 {0x96, "/;!"}, {0x96, "/shuai"}, {0x96, "/freaked_out"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
141 {0x97, "/!!!"}, {0x97, "/kl"}, {0x97, "/skeleton"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
142 {0x98, "/xx"}, {0x98, "/qiao"}, {0x98, "/hammer"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
143 {0x99, "/bye"}, {0x99, "/zj"}, {0x99, "/bye"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
144 {0xa2, "/wipe"}, {0xa2, "/ch"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
145 {0xa3, "/dig"}, {0xa3, "/kb"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
146 {0xa4, "/handclap"},{0xa4, "/gz"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
147 {0xa5, "/&-("}, {0xa5, "/qd"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
148 {0xa6, "/B-)"}, {0xa6, "/huaix"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
149 {0xa7, "/<@"}, {0xa7, "/zhh"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
150 {0xa8, "/@>"}, {0xa8, "/yhh"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
151 {0xa9, "/:-O"}, {0xa9, "/hq"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
152 {0xaa, "/>-|"}, {0xaa, "/bs"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
153 {0xab, "/P-("}, {0xab, "/wq"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
154 {0xac, "/:'|"}, {0xac, "/kk"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
155 {0xad, "/X-)"}, {0xad, "/yx"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
156 {0xae, "/:*"}, {0xae, "/qq"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
157 {0xaf, "/@x"}, {0xaf, "/xia"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
158 {0xb0, "/8*"}, {0xb0, "/kel"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
159 {0xb1, "/pd"}, {0xb1, "/cd"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
160 {0x61, "/<W>"}, {0x61, "/xig"}, {0x61, "/watermelon"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
161 {0xb2, "/beer"}, {0xb2, "/pj"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
162 {0xb3, "/basketb"}, {0xb3, "/lq"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
163 {0xb4, "/oo"}, {0xb4, "/pp"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
164 {0x80, "/coffee"}, {0x80, "/kf"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
165 {0x81, "/eat"}, {0x81, "/fan"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
166 {0x62, "/rose"}, {0x62, "/mg"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
167 {0x63, "/fade"}, {0x63, "/dx"}, {0x63, "/wilt"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
168 {0xb5, "/showlove"},{0xb5, "/sa"}, /* after sad */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
169 {0x65, "/heart"}, {0x65, "/xin"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
170 {0x66, "/break"}, {0x66, "/xs"}, {0x66, "/broken_heart"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
171 {0x67, "/cake"}, {0x67, "/dg"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
172 {0x9c, "/li"}, {0x9c, "/shd"}, {0x9c, "/lightning"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
173 {0x9d, "/bome"}, {0x9d, "/zhd"}, {0x9d, "/bomb"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
174 {0x9e, "/kn"}, {0x9e, "/dao"}, {0x9e, "/knife"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
175 {0x5e, "/footb"}, {0x5e, "/zq"}, {0x5e, "/soccer"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
176 {0xb6, "/ladybug"}, {0xb6, "/pc"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
177 {0x89, "/shit"}, {0x89, "/bb"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
178 {0x6e, "/moon"}, {0x6e, "/yl"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
179 {0x6b, "/sun"}, {0x6b, "/ty"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
180 {0x68, "/gift"}, {0x68, "/lw"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
181 {0x7f, "/hug"}, {0x7f, "/yb"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
182 {0x6f, "/strong"}, {0x6f, "/qiang"}, {0x6f, "/thumbs_up"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
183 {0x70, "/weak"}, {0x70, "/ruo"}, {0x70, "/thumbs_down"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
184 {0x88, "/share"}, {0x88, "/ws"}, {0x88, "/handshake"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
185 {0xb7, "/@)"}, {0xb7, "/bq"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
186 {0xb8, "/jj"}, {0xb8, "/gy"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
187 {0xb9, "/@@"}, {0xb9, "/qt"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
188 {0xba, "/bad"}, {0xba, "/cj"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
189 {0xbb, "/loveu"}, {0xbb, "/aini"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
190 {0xbc, "/no"}, {0xbc, "/bu"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
191 {0xbd, "/ok"}, {0xbd, "/hd"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
192 {0x5c, "/love"}, {0x5c, "/aiq"}, /* after loveu */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
193 {0x56, "/<L>"}, {0x56, "/fw"}, {0x56, "/blow_kiss"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
194 {0x58, "/jump"}, {0x58, "/tiao"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
195 {0x5a, "/shake"}, {0x5a, "/fad"}, /* after fade */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
196 {0x5b, "/<O>"}, {0x5b, "/oh"}, {0x5b, "/angry"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
197 {0xbe, "/circle"}, {0xbe, "/zhq"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
198 {0xbf, "/kotow"}, {0xbf, "/kt"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
199 {0xc0, "/turn"}, {0xc0, "/ht"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
200 {0x77, "/:t"}, {0x77, "/tu"}, {0x77, "/vomit"}, /* after turn */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
201 {0xa0, "/victory"}, {0xa0, "/shl"}, {0xa0, "/v"}, /* end of v */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
202 {0xc1, "/skip"}, {0xc1, "/tsh"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
203 {0xc2, "/oY"}, {0xc2, "/hsh"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
204 {0xc3, "/#-O"}, {0xc3, "/jd"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
205 {0xc4, "/hiphop"}, {0xc4, "/jw"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
206 {0xc5, "/kiss"}, {0xc5, "/xw"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
207 {0xc6, "/<&"}, {0xc6, "/ztj"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
208 {0x7c, "/pig"}, {0x7c, "/zt"}, /* after ztj */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
209 {0xc7, "/&>"}, {0xc7, "/ytj"}, /* must be end of "&" */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
210 {0x75, "/:#"}, {0x75, "/feid"}, {0x75, "/SARS"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
211 {0x59, "/go"}, {0x59, "/shan"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
212 {0x57, "/find"}, {0x57, "/zhao"}, {0x57, "/search"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
213 {0x55, "/&"}, {0x55, "/mm"}, {0x55, "/beautiful_eyebrows"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
214 {0x7d, "/cat"}, {0x7d, "/maom"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
215 {0x7e, "/dog"}, {0x7e, "/xg"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
216 {0x9a, "/$"}, {0x9a, "/qianc"}, {0x9a, "/money"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
217 {0x9b, "/(!)"}, {0x9b, "/dp"}, {0x9b, "/lightbulb"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
218 {0x60, "/cup"}, {0x60, "/bei"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
219 {0x9f, "/music"}, {0x9f, "/yy"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
220 {0x82, "/pill"}, {0x82, "/yw"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
221 {0x64, "/kiss"}, {0x64, "/wen"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
222 {0x83, "/meeting"}, {0x83, "/hy"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
223 {0x84, "/phone"}, {0x84, "/dh"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
224 {0x85, "/time"}, {0x85, "/sj"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
225 {0x86, "/email"}, {0x86, "/yj"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
226 {0x87, "/tv"}, {0x87, "/ds"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
227 {0x50, "/<D>"}, {0x50, "/dd"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
228 {0x51, "/<J>"}, {0x51, "/mn"}, {0x51, "/beauty"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
229 {0x52, "/<H>"}, {0x52, "/hl"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
230 {0x53, "/<M>"}, {0x53, "/mamao"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
231 {0x54, "/<QQ>"}, {0x54, "/qz"}, {0x54, "/qq"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
232 {0x5d, "/<B>"}, {0x5d, "/bj"}, {0x5d, "/baijiu"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
233 {0x5f, "/<U>"}, {0x5f, "/qsh"}, {0x5f, "/soda"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
234 {0x69, "/<!!>"}, {0x69, "/xy"}, {0x69, "/rain"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
235 {0x6a, "/<~>"}, {0x6a, "/duoy"}, {0x6a, "/cloudy"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
236 {0x6c, "/<Z>"}, {0x6c, "/xr"}, {0x6c, "/snowman"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
237 {0x6d, "/<*>"}, {0x6d, "/xixing"}, {0x6d, "/star"}, /* after starving */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
238 {0x71, "/<00>"}, {0x71, "/nv"}, {0x71, "/woman"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
239 {0x72, "/<11>"}, {0x72, "/nan"}, {0x72, "/man"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
240 {0, NULL}
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
241 };
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
242 gint emoticons_std_num = sizeof(emoticons_std) / sizeof(qq_emoticon) - 1;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
243
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
244 /* Map for purple smiley convert to qq, need qsort */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
245 static qq_emoticon emoticons_ext[] = {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
246 {0xc7, "/&>"}, {0xa5, "/&-("},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
247 {0xbb, "/loveu"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
248 {0x63, "/fade"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
249 {0x8f, "/sleepy"}, {0x73, "/sad"}, {0x8e, "/starving"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
250 {0xc0, "/turn"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
251 {0xa0, "/victory"}, {0x77, "/vomit"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
252 {0xc6, "/ztj"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
253 {0, NULL}
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
254 };
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
255 gint emoticons_ext_num = sizeof(emoticons_ext) / sizeof(qq_emoticon) - 1;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
256
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
257 /* Map for qq smiley convert to purple */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
258 static qq_emoticon emoticons_sym[] = {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
259 {0x41, "/jy"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
260 {0x42, "/pz"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
261 {0x43, "/se"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
262 {0x44, "/fd"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
263 {0x45, "/dy"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
264 {0x46, "/ll"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
265 {0x47, "/hx"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
266 {0x48, "/bz"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
267 {0x49, "/shui"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
268 {0x4a, "/dk"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
269 {0x4b, "/gg"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
270 {0x4c, "/fn"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
271 {0x4d, "/tp"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
272 {0x4e, "/cy"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
273 {0x4f, "/wx"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
274 {0x50, "/dd"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
275 {0x51, "/mn"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
276 {0x52, "/hl"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
277 {0x53, "/mamao"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
278 {0x54, "/qz"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
279 {0x55, "/mm"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
280 {0x56, "/fw"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
281 {0x57, "/zhao"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
282 {0x58, "/tiao"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
283 {0x59, "/shan"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
284 {0x5a, "/fad"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
285 {0x5b, "/oh"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
286 {0x5c, "/aiq"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
287 {0x5d, "/bj"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
288 {0x5e, "/zq"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
289 {0x5f, "/qsh"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
290 {0x60, "/bei"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
291 {0x61, "/xig"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
292 {0x62, "/mg"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
293 {0x63, "/dx"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
294 {0x64, "/wen"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
295 {0x65, "/xin"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
296 {0x66, "/xs"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
297 {0x67, "/dg"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
298 {0x68, "/lw"},
24577
8084892eb422 Fix smiley map
Hu Yong <ccpaging@gmail.com>
parents: 24566
diff changeset
299 {0x69, "/xy"},
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
300 {0x6a, "/duoy"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
301 {0x6b, "/ty"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
302 {0x6c, "/xr"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
303 {0x6d, "/xixing"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
304 {0x6e, "/yl"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
305 {0x6f, "/qiang"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
306 {0x70, "/ruo"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
307 {0x71, "/nv"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
308 {0x72, "/nan"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
309 {0x73, "/ng"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
310 {0x74, "/kuk"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
311 {0x75, "/feid"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
312 {0x76, "/zk"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
313 {0x77, "/tu"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
314 {0x78, "/jk"},
24600
0036025df58d Fix emoticon map
Hu Yong <ccpaging@gmail.com>
parents: 24590
diff changeset
315 {0x79, "/sweat"},
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
316 {0x7a, "/hanx"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
317 {0x7b, "/db"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
318 {0x7c, "/zt"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
319 {0x7d, "/maom"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
320 {0x7e, "/xg"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
321 {0x7f, "/yb"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
322 {0x80, "/coffee"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
323 {0x81, "/fan"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
324 {0x82, "/yw"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
325 {0x83, "/hy"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
326 {0x84, "/dh"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
327 {0x85, "/sj"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
328 {0x86, "/yj"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
329 {0x87, "/ds"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
330 {0x88, "/ws"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
331 {0x89, "/bb"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
332 {0x8a, "/tx"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
333 {0x8b, "/ka"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
334 {0x8c, "/by"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
335 {0x8d, "/am"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
336 {0x8e, "/jie"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
337 {0x8f, "/kun"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
338 {0x90, "/fendou"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
339 {0x91, "/zhm"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
340 {0x92, "/yiw"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
341 {0x93, "/xu"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
342 {0x94, "/yun"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
343 {0x95, "/zhem"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
344 {0x96, "/shuai"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
345 {0x97, "/kl"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
346 {0x98, "/qiao"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
347 {0x99, "/zj"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
348 {0x9a, "/qianc"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
349 {0x9b, "/dp"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
350 {0x9c, "/shd"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
351 {0x9d, "/zhd"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
352 {0x9e, "/dao"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
353 {0x9f, "/yy"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
354 {0xa0, "/shl"},
24600
0036025df58d Fix emoticon map
Hu Yong <ccpaging@gmail.com>
parents: 24590
diff changeset
355 {0xa1, "/lengh"},
24583
3327b1f20fa6 Fixed: Not set flag after qsort
Hu Yong <ccpaging@gmail.com>
parents: 24577
diff changeset
356 {0xa2, "/wipe"},
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
357 {0xa3, "/kb"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
358 {0xa4, "/gz"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
359 {0xa5, "/qd"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
360 {0xa6, "/huaix"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
361 {0xa7, "/zhh"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
362 {0xa8, "/yhh"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
363 {0xa9, "/hq"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
364 {0xaa, "/bs"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
365 {0xab, "/wq"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
366 {0xac, "/kk"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
367 {0xad, "/yx"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
368 {0xae, "/qq"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
369 {0xaf, "/xia"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
370 {0xb0, "/kel"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
371 {0xb1, "/cd"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
372 {0xb2, "/pj"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
373 {0xb3, "/lq"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
374 {0xb4, "/pp"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
375 {0xb5, "/sa"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
376 {0xb6, "/pc"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
377 {0xb7, "/bq"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
378 {0xb8, "/gy"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
379 {0xb9, "/qt"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
380 {0xba, "/cj"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
381 {0xbb, "/aini"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
382 {0xbc, "/bu"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
383 {0xbd, "/hd"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
384 {0xbe, "/zhq"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
385 {0xbf, "/kt"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
386 {0xc0, "/ht"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
387 {0xc1, "/tsh"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
388 {0xc2, "/hsh"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
389 {0xc3, "/jd"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
390 {0xc4, "/jw"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
391 {0xc5, "/xw"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
392 {0xc6, "/ztj"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
393 {0xc7, "/ytj"},
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
394 {0, NULL}
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
395 };
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
396 gint emoticons_sym_num = sizeof(emoticons_sym) / sizeof(qq_emoticon) - 1;;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
397
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
398 static int emoticon_cmp(const void *k1, const void *k2)
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
399 {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
400 const qq_emoticon *e1 = (const qq_emoticon *) k1;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
401 const qq_emoticon *e2 = (const qq_emoticon *) k2;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
402 if (e1->symbol == 0) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
403 /* purple_debug_info("QQ", "emoticon_cmp len %d\n", strlen(e2->name)); */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
404 return strncmp(e1->name, e2->name, strlen(e2->name));
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
405 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
406 if (e2->symbol == 0) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
407 /* purple_debug_info("QQ", "emoticon_cmp len %d\n", strlen(e1->name)); */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
408 return strncmp(e1->name, e2->name, strlen(e1->name));
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
409 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
410 return strcmp(e1->name, e2->name);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
411 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
412
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
413 static void emoticon_try_sort()
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
414 {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
415 if (emoticons_is_sorted)
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
416 return;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
417
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
418 purple_debug_info("QQ", "qsort stand emoticons\n");
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
419 qsort(emoticons_std, emoticons_std_num, sizeof(qq_emoticon), emoticon_cmp);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
420 purple_debug_info("QQ", "qsort extend emoticons\n");
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
421 qsort(emoticons_ext, emoticons_ext_num, sizeof(qq_emoticon), emoticon_cmp);
24583
3327b1f20fa6 Fixed: Not set flag after qsort
Hu Yong <ccpaging@gmail.com>
parents: 24577
diff changeset
422 emoticons_is_sorted = TRUE;
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
423 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
424
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
425 static qq_emoticon *emoticon_find(gchar *name)
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
426 {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
427 qq_emoticon *ret = NULL;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
428 qq_emoticon key;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
429
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
430 g_return_val_if_fail(name != NULL, NULL);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
431 emoticon_try_sort();
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
432
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
433 key.name = name;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
434 key.symbol = 0;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
435
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
436 /* purple_debug_info("QQ", "bsearch emoticon %.20s\n", name); */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
437 ret = (qq_emoticon *)bsearch(&key, emoticons_ext, emoticons_ext_num,
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
438 sizeof(qq_emoticon), emoticon_cmp);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
439 if (ret != NULL) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
440 return ret;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
441 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
442 ret = (qq_emoticon *)bsearch(&key, emoticons_std, emoticons_std_num,
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
443 sizeof(qq_emoticon), emoticon_cmp);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
444 return ret;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
445 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
446
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
447 static gchar *emoticon_get(guint8 symbol)
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
448 {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
449 g_return_val_if_fail(symbol >= emoticons_sym[0].symbol, NULL);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
450 g_return_val_if_fail(symbol <= emoticons_sym[emoticons_sym_num - 2].symbol, NULL);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
451
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
452 return emoticons_sym[symbol - emoticons_sym[0].symbol].name;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
453 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
454
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
455 /* convert qq emote icon to purple sytle
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
456 Notice: text is in qq charset, GB18030 or utf8 */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
457 gchar *qq_emoticon_to_purple(gchar *text)
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
458 {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
459 gchar *ret;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
460 GString *converted;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
461 gchar **segments;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
462 gboolean have_smiley;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
463 gchar *purple_smiley;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
464 gchar *cur;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
465 guint8 symbol;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
466
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
467 /* qq_show_packet("text", (guint8 *)text, strlen(text)); */
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
468 g_return_val_if_fail(text != NULL && strlen(text) != 0, g_strdup(""));
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
469
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
470 segments = g_strsplit_set(text, "\x14\x15", 0);
24601
fecedf6d9ee1 propagate from branch 'im.pidgin.pidgin' (head 97d295a04f3a9852a3b29cf0df43d56d1ddcc672)
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24293 24600
diff changeset
471 if(segments == NULL) {
fecedf6d9ee1 propagate from branch 'im.pidgin.pidgin' (head 97d295a04f3a9852a3b29cf0df43d56d1ddcc672)
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24293 24600
diff changeset
472 return g_strdup("");
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
473 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
474
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
475 converted = g_string_new("");
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
476 have_smiley = FALSE;
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
477 if (segments[0] != NULL) {
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
478 g_string_append(converted, segments[0]);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
479 } else {
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
480 purple_debug_info("QQ", "segments[0] is NULL\n");
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
481 }
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
482 while ((*(++segments)) != NULL) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
483 have_smiley = TRUE;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
484
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
485 cur = *segments;
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
486 if (cur == NULL) {
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
487 purple_debug_info("QQ", "current segment is NULL\n");
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
488 break;
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
489 }
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
490 if (strlen(cur) == 0) {
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
491 purple_debug_info("QQ", "current segment length is 0\n");
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
492 break;
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
493 }
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
494 symbol = (guint8)cur[0];
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
495
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
496 purple_smiley = emoticon_get(symbol);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
497 if (purple_smiley == NULL) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
498 purple_debug_info("QQ", "Not found smiley of 0x%02X\n", symbol);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
499 g_string_append(converted, "<IMG ID=\"0\">");
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
500 } else {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
501 purple_debug_info("QQ", "Found 0x%02X smiley is %s\n", symbol, purple_smiley);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
502 g_string_append(converted, purple_smiley);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
503 g_string_append(converted, cur + 1);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
504 }
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
505 /* purple_debug_info("QQ", "next segment\n"); */
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
506 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
507
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
508 /* purple_debug_info("QQ", "end of convert\n"); */
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
509 if (!have_smiley) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
510 g_string_prepend(converted, "<font sml=\"none\">");
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
511 g_string_append(converted, "</font>");
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
512 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
513 ret = converted->str;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
514 g_string_free(converted, FALSE);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
515 return ret;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
516 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
517
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
518 void qq_im_fmt_free(qq_im_format *fmt)
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
519 {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
520 g_return_if_fail(fmt != NULL);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
521 if (fmt->font) g_free(fmt->font);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
522 g_free(fmt);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
523 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
524
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
525 qq_im_format *qq_im_fmt_new(void)
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
526 {
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
527 qq_im_format *fmt;
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
528 const gchar simsun[] = { 0xcb, 0xce, 0xcc, 0xe5, 0}; /* simsun in Chinese */
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
529
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
530 fmt = g_new0(qq_im_format, 1);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
531 memset(fmt, 0, sizeof(qq_im_format));
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
532 fmt->font_len = strlen(simsun);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
533 fmt->font = g_strdup(simsun);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
534 fmt->attr = 10;
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
535 /* encoding, 0x8602=GB, 0x0000=EN, define BIG5 support here */
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
536 fmt->charset = 0x8602;
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
537
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
538 return fmt;
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
539 }
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
540
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
541 qq_im_format *qq_im_fmt_new_by_purple(const gchar *msg)
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
542 {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
543 qq_im_format *fmt;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
544 const gchar *start, *end, *last;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
545 GData *attribs;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
546 gchar *tmp;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
547 unsigned char *rgb;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
548
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
549 g_return_val_if_fail(msg != NULL, NULL);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
550
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
551 fmt = qq_im_fmt_new();
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
552
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
553 last = msg;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
554 while (purple_markup_find_tag("font", last, &start, &end, &attribs)) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
555 tmp = g_datalist_get_data(&attribs, "face");
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
556 if (tmp && strlen(tmp) > 0) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
557 if (fmt->font) g_free(fmt->font);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
558 fmt->font_len = strlen(tmp);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
559 fmt->font = g_strdup(tmp);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
560 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
561
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
562 tmp = g_datalist_get_data(&attribs, "size");
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
563 if (tmp) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
564 fmt->attr = atoi(tmp) * 3 + 1;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
565 fmt->attr &= 0x0f;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
566 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
567
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
568 tmp = g_datalist_get_data(&attribs, "color");
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
569 if (tmp && strlen(tmp) > 1) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
570 rgb = purple_base16_decode(tmp + 1, NULL);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
571 g_memmove(fmt->rgb, rgb, 3);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
572 g_free(rgb);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
573 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
574
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
575 g_datalist_clear(&attribs);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
576 last = end + 1;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
577 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
578
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
579 if (purple_markup_find_tag("b", msg, &start, &end, &attribs)) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
580 fmt->attr |= 0x20;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
581 g_datalist_clear(&attribs);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
582 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
583
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
584 if (purple_markup_find_tag("i", msg, &start, &end, &attribs)) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
585 fmt->attr |= 0x40;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
586 g_datalist_clear(&attribs);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
587 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
588
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
589 if (purple_markup_find_tag("u", msg, &start, &end, &attribs)) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
590 fmt->attr |= 0x80;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
591 g_datalist_clear(&attribs);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
592 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
593
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
594 return fmt;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
595 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
596
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
597 /* convert qq format to purple
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
598 Notice: text is in qq charset, GB18030 or utf8 */
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
599 gchar *qq_im_fmt_to_purple(qq_im_format *fmt, gchar *text)
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
600 {
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
601 GString *converted, *tmp;
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
602 gchar *ret;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
603 gint size;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
604
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
605 converted = g_string_new(text);
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
606 tmp = g_string_new("");
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
607 g_string_append_printf(tmp, "<font color=\"#%02x%02x%02x\">",
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
608 fmt->rgb[0], fmt->rgb[1], fmt->rgb[2]);
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
609 g_string_prepend(converted, tmp->str);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
610 g_string_set_size(tmp, 0);
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
611 g_string_append(converted, "</font>");
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
612
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
613 /* Fixme:
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
614 * check font face can be convert to utf8 or not?
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
615 * If failed, prepending font face cause msg display as "(NULL)" */
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
616 if (fmt->font != NULL) {
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
617 g_string_append_printf(tmp, "<font face=\"%s\">", fmt->font);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
618 g_string_prepend(converted, tmp->str);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
619 g_string_set_size(tmp, 0);
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
620 g_string_append(converted, "</font>");
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
621 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
622 size = (fmt->attr & 0x1f) / 3;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
623 if (size >= 0) {
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
624 g_string_append_printf(tmp, "<font size=\"%d\">", size);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
625 g_string_prepend(converted, tmp->str);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
626 g_string_set_size(tmp, 0);
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
627 g_string_append(converted, "</font>");
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
628 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
629 if (fmt->attr & 0x20) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
630 /* bold */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
631 g_string_prepend(converted, "<b>");
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
632 g_string_append(converted, "</b>");
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
633 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
634 if (fmt->attr & 0x40) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
635 /* italic */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
636 g_string_prepend(converted, "<i>");
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
637 g_string_append(converted, "</i>");
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
638 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
639 if (fmt->attr & 0x80) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
640 /* underline */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
641 g_string_prepend(converted, "<u>");
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
642 g_string_append(converted, "</u>");
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
643 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
644
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
645 g_string_free(tmp, TRUE);
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
646 ret = converted->str;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
647 g_string_free(converted, FALSE);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
648 return ret;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
649 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
650
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
651 gint qq_put_im_tail(guint8 *buf, qq_im_format *fmt)
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
652 {
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
653 gint bytes;
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
654
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
655 g_return_val_if_fail(buf != NULL && fmt != NULL, 0);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
656
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
657 bytes = 0;
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
658 bytes += qq_put8(buf + bytes, 0);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
659 bytes += qq_put8(buf + bytes, fmt->attr);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
660 bytes += qq_putdata(buf + bytes, fmt->rgb, sizeof(fmt->rgb));
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
661 bytes += qq_put8(buf + bytes, 0);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
662 bytes += qq_put16(buf + bytes, fmt->charset);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
663 if (fmt->font != NULL && fmt->font_len > 0) {
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
664 bytes += qq_putdata(buf + bytes, (guint8 *)fmt->font, fmt->font_len);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
665 } else {
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
666 purple_debug_warning("QQ", "Font name is empty\n");
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
667 }
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
668 bytes += qq_put8(buf + bytes, bytes + 1);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
669 /* qq_show_packet("IM tail", buf, bytes); */
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
670 return bytes;
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
671 }
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
672
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
673 /* data includes text msg and font attr*/
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
674 gint qq_get_im_tail(qq_im_format *fmt, guint8 *data, gint data_len)
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
675 {
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
676 gint bytes, text_len;
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
677 guint8 tail_len;
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
678 guint8 font_len;
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
679
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
680 g_return_val_if_fail(fmt != NULL && data != NULL, 0);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
681 g_return_val_if_fail(data_len > 1, 0);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
682 tail_len = data[data_len - 1];
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
683 g_return_val_if_fail(tail_len > 2, 0);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
684 text_len = data_len - tail_len;
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
685 g_return_val_if_fail(text_len >= 0, 0);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
686
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
687 bytes = text_len;
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
688 /* qq_show_packet("IM tail", data + bytes, tail_len); */
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
689 bytes += 1; /* skip 0x00 */
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
690 bytes += qq_get8(&fmt->attr, data + bytes);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
691 bytes += qq_getdata(fmt->rgb, sizeof(fmt->rgb), data + bytes); /* red,green,blue */
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
692 bytes += 1; /* skip 0x00 */
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
693 bytes += qq_get16(&fmt->charset, data + bytes);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
694
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
695 font_len = data_len - bytes - 1;
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
696 g_return_val_if_fail(font_len > 0, bytes + 1);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
697
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
698 fmt->font_len = font_len;
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
699 if (fmt->font != NULL) g_free(fmt->font);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
700 fmt->font = g_strndup((gchar *)data + bytes, fmt->font_len);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
701 return tail_len;
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
702 }
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
703
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
704 void qq_got_message(PurpleConnection *gc, const gchar *msg)
24066
dbc7a9742f8d 2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24065
diff changeset
705 {
dbc7a9742f8d 2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24065
diff changeset
706 qq_data *qd;
dbc7a9742f8d 2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24065
diff changeset
707 gchar *from;
dbc7a9742f8d 2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24065
diff changeset
708 time_t now = time(NULL);
dbc7a9742f8d 2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24065
diff changeset
709
24079
1bdf7b602684 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24077
diff changeset
710 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
1bdf7b602684 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24077
diff changeset
711 qd = gc->proto_data;
24066
dbc7a9742f8d 2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24065
diff changeset
712
dbc7a9742f8d 2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24065
diff changeset
713 g_return_if_fail(qd->uid > 0);
dbc7a9742f8d 2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24065
diff changeset
714
24079
1bdf7b602684 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24077
diff changeset
715 qq_buddy_find_or_new(gc, qd->uid);
1bdf7b602684 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24077
diff changeset
716
24069
dc112387190f 2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24066
diff changeset
717 from = uid_to_purple_name(qd->uid);
24066
dbc7a9742f8d 2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24065
diff changeset
718 serv_got_im(gc, from, msg, PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NOTIFY, now);
24069
dc112387190f 2008.09.29 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24066
diff changeset
719 g_free(from);
24066
dbc7a9742f8d 2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24065
diff changeset
720 }
dbc7a9742f8d 2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24065
diff changeset
721
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
722 /* process received normal text IM */
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
723 static void process_im_text(PurpleConnection *gc, guint8 *data, gint len, qq_im_header *im_header)
24074
c2253c485728 2008.10.04 - ccpaging <ccpagint(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24071
diff changeset
724 {
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
725 qq_data *qd;
24074
c2253c485728 2008.10.04 - ccpaging <ccpagint(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24071
diff changeset
726 guint16 purple_msg_type;
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
727 gchar *who;
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
728 gchar *msg_smiley, *msg_fmt, *msg_utf8;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
729 PurpleBuddy *buddy;
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
730 qq_buddy_data *bd;
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
731 gint bytes, tail_len;
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
732 qq_im_format *fmt = NULL;
24076
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24074
diff changeset
733
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
734 struct {
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
735 /* now comes the part for text only */
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
736 guint16 msg_seq;
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
737 guint32 send_time;
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
738 guint16 sender_icon;
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
739 guint8 unknown1[3];
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
740 guint8 has_font_attr;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
741 guint8 fragment_count;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
742 guint8 fragment_index;
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
743 guint8 msg_id;
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
744 guint8 unknown2;
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
745 guint8 msg_type;
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
746 gchar *msg; /* no fixed length, ends with 0x00 */
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
747 } im_text;
24074
c2253c485728 2008.10.04 - ccpaging <ccpagint(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24071
diff changeset
748
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
749 g_return_if_fail (data != NULL && len > 0);
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
750 g_return_if_fail(im_header != NULL);
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
751
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
752 qd = (qq_data *) gc->proto_data;
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
753 memset(&im_text, 0, sizeof(im_text));
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
754
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
755 /* qq_show_packet("IM text", data, len); */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
756 bytes = 0;
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
757 bytes += qq_get16(&(im_text.msg_seq), data + bytes);
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
758 bytes += qq_get32(&(im_text.send_time), data + bytes);
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
759 bytes += qq_get16(&(im_text.sender_icon), data + bytes);
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
760 bytes += qq_getdata(im_text.unknown1, sizeof(im_text.unknown1), data + bytes); /* 0x(00 00 00)*/
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
761 bytes += qq_get8(&(im_text.has_font_attr), data + bytes);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
762 bytes += qq_get8(&(im_text.fragment_count), data + bytes);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
763 bytes += qq_get8(&(im_text.fragment_index), data + bytes);
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
764 bytes += qq_get8(&(im_text.msg_id), data + bytes);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
765 bytes += 1; /* skip 0x00 */
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
766 bytes += qq_get8(&(im_text.msg_type), data + bytes);
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
767 purple_debug_info("QQ", "IM Seq %u, id %04X, fragment %d-%d, type %d, %s\n",
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
768 im_text.msg_seq, im_text.msg_id,
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
769 im_text.fragment_count, im_text.fragment_index,
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
770 im_text.msg_type,
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
771 im_text.has_font_attr ? "exist font atrr" : "");
24076
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24074
diff changeset
772
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
773 if (im_text.has_font_attr) {
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
774 fmt = qq_im_fmt_new();
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
775 tail_len = qq_get_im_tail(fmt, data + bytes, len - bytes);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
776 im_text.msg = g_strndup((gchar *)(data + bytes), len - tail_len);
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
777 } else {
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
778 im_text.msg = g_strndup((gchar *)(data + bytes), len - bytes);
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
779 }
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
780 /* qq_show_packet("IM text", (guint8 *)im_text.msg , strlen(im_text.msg) ); */
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
781
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
782 who = uid_to_purple_name(im_header->uid_from);
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
783 buddy = purple_find_buddy(gc->account, who);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
784 if (buddy == NULL) {
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
785 /* create no-auth buddy */
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
786 buddy = qq_buddy_new(gc, im_header->uid_from);
24076
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24074
diff changeset
787 }
25363
cf6dfd38c7c1 Fix a botched line in the merge...
Gary Kramlich <grim@reaperworld.com>
parents: 25362
diff changeset
788 bd = (buddy == NULL) ? NULL : purple_buddy_get_protocol_data(buddy);
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
789 if (bd != NULL) {
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
790 bd->client_tag = im_header->version_from;
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
791 bd->face = im_text.sender_icon;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
792 qq_update_buddy_icon(gc->account, who, bd->face);
24074
c2253c485728 2008.10.04 - ccpaging <ccpagint(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24071
diff changeset
793 }
c2253c485728 2008.10.04 - ccpaging <ccpagint(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24071
diff changeset
794
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
795 purple_msg_type = (im_text.msg_type == QQ_IM_AUTO_REPLY)
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
796 ? PURPLE_MESSAGE_AUTO_RESP : 0;
24074
c2253c485728 2008.10.04 - ccpaging <ccpagint(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24071
diff changeset
797
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
798 msg_smiley = qq_emoticon_to_purple(im_text.msg);
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
799 if (fmt != NULL) {
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
800 msg_fmt = qq_im_fmt_to_purple(fmt, msg_smiley);
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
801 msg_utf8 = qq_to_utf8(msg_fmt, QQ_CHARSET_DEFAULT);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
802 g_free(msg_fmt);
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
803 qq_im_fmt_free(fmt);
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
804 } else {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
805 msg_utf8 = qq_to_utf8(msg_smiley, QQ_CHARSET_DEFAULT);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
806 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
807 g_free(msg_smiley);
24074
c2253c485728 2008.10.04 - ccpaging <ccpagint(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24071
diff changeset
808
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
809 /* send encoded to purple, note that we use im_text.send_time,
24074
c2253c485728 2008.10.04 - ccpaging <ccpagint(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24071
diff changeset
810 * not the time we receive the message
c2253c485728 2008.10.04 - ccpaging <ccpagint(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24071
diff changeset
811 * as it may have been delayed when I am not online. */
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
812 purple_debug_info("QQ", "IM from %u: %s\n", im_header->uid_from,msg_utf8);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
813 serv_got_im(gc, who, msg_utf8, purple_msg_type, (time_t) im_text.send_time);
24074
c2253c485728 2008.10.04 - ccpaging <ccpagint(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24071
diff changeset
814
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
815 g_free(msg_utf8);
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
816 g_free(who);
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
817 g_free(im_text.msg);
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
818 }
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
819
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
820 /* process received extended (2007) text IM */
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
821 static void process_extend_im_text(PurpleConnection *gc, guint8 *data, gint len, qq_im_header *im_header)
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
822 {
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
823 qq_data *qd;
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
824 guint16 purple_msg_type;
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
825 gchar *who;
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
826 gchar *msg_smiley, *msg_fmt, *msg_utf8;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
827 PurpleBuddy *buddy;
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
828 qq_buddy_data *bd;
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
829 gint bytes, tail_len;
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
830 qq_im_format *fmt = NULL;
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
831
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
832 struct {
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
833 /* now comes the part for text only */
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
834 guint16 msg_seq;
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
835 guint32 send_time;
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
836 guint16 sender_icon;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
837 guint32 has_font_attr;
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
838 guint8 unknown1[8];
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
839 guint8 fragment_count;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
840 guint8 fragment_index;
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
841 guint8 msg_id;
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
842 guint8 unknown2;
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
843 guint8 msg_type;
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
844 gchar *msg; /* no fixed length, ends with 0x00 */
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
845 guint8 fromMobileQQ;
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
846 } im_text;
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
847
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
848 g_return_if_fail (data != NULL && len > 0);
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
849 g_return_if_fail(im_header != NULL);
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
850
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
851 qd = (qq_data *) gc->proto_data;
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
852 memset(&im_text, 0, sizeof(im_text));
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
853
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
854 /* qq_show_packet("Extend IM text", data, len); */
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
855 bytes = 0;
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
856 bytes += qq_get16(&(im_text.msg_seq), data + bytes);
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
857 bytes += qq_get32(&(im_text.send_time), data + bytes);
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
858 bytes += qq_get16(&(im_text.sender_icon), data + bytes);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
859 bytes += qq_get32(&(im_text.has_font_attr), data + bytes);
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
860 bytes += qq_getdata(im_text.unknown1, sizeof(im_text.unknown1), data + bytes);
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
861 bytes += qq_get8(&(im_text.fragment_count), data + bytes);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
862 bytes += qq_get8(&(im_text.fragment_index), data + bytes);
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
863 bytes += qq_get8(&(im_text.msg_id), data + bytes);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
864 bytes += 1; /* skip 0x00 */
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
865 bytes += qq_get8(&(im_text.msg_type), data + bytes);
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
866 purple_debug_info("QQ", "IM Seq %u, id %04X, fragment %d-%d, type %d, %s\n",
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
867 im_text.msg_seq, im_text.msg_id,
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
868 im_text.fragment_count, im_text.fragment_index,
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
869 im_text.msg_type,
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
870 im_text.has_font_attr ? "exist font atrr" : "");
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
871
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
872 if (im_text.has_font_attr) {
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
873 fmt = qq_im_fmt_new();
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
874 tail_len = qq_get_im_tail(fmt, data + bytes, len - bytes);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
875 im_text.msg = g_strndup((gchar *)(data + bytes), len - tail_len);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
876 } else {
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
877 im_text.msg = g_strndup((gchar *)(data + bytes), len - bytes);
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
878 }
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
879 /* qq_show_packet("IM text", (guint8 *)im_text.msg , strlen(im_text.msg)); */
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
880
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
881 if(im_text.fragment_count == 0) im_text.fragment_count = 1;
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
882
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
883 who = uid_to_purple_name(im_header->uid_from);
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
884 buddy = purple_find_buddy(gc->account, who);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
885 if (buddy == NULL) {
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
886 /* create no-auth buddy */
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
887 buddy = qq_buddy_new(gc, im_header->uid_from);
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
888 }
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
889 bd = (buddy == NULL) ? NULL : (qq_buddy_data *) buddy->proto_data;
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
890 if (bd != NULL) {
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
891 bd->client_tag = im_header->version_from;
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
892 bd->face = im_text.sender_icon;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
893 qq_update_buddy_icon(gc->account, who, bd->face);
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
894 }
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
895
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
896 purple_msg_type = 0;
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
897
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
898 msg_smiley = qq_emoticon_to_purple(im_text.msg);
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
899 if (fmt != NULL) {
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
900 msg_fmt = qq_im_fmt_to_purple(fmt, msg_smiley);
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
901 msg_utf8 = qq_to_utf8(msg_fmt, QQ_CHARSET_DEFAULT);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
902 g_free(msg_fmt);
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
903 qq_im_fmt_free(fmt);
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
904 } else {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
905 msg_utf8 = qq_to_utf8(msg_smiley, QQ_CHARSET_DEFAULT);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
906 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
907 g_free(msg_smiley);
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
908
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
909 /* send encoded to purple, note that we use im_text.send_time,
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
910 * not the time we receive the message
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
911 * as it may have been delayed when I am not online. */
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
912 serv_got_im(gc, who, msg_utf8, purple_msg_type, (time_t) im_text.send_time);
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
913
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
914 g_free(msg_utf8);
24080
818ab62006f5 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24079
diff changeset
915 g_free(who);
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
916 g_free(im_text.msg);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
917 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
918
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
919 /* it is a normal IM, maybe text or video request */
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
920 void qq_process_im(PurpleConnection *gc, guint8 *data, gint len)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
921 {
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
922 gint bytes = 0;
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
923 qq_im_header im_header;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
924
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
925 g_return_if_fail (data != NULL && len > 0);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
926
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
927 bytes = get_im_header(&im_header, data, len);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
928 if (bytes < 0) {
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
929 purple_debug_error("QQ", "Fail read im header, len %d\n", len);
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
930 qq_show_packet ("IM Header", data, len);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
931 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
932 }
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
933 purple_debug_info("QQ",
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
934 "Got IM to %u, type: %02X from: %u ver: %s (%04X)\n",
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
935 im_header.uid_to, im_header.im_type, im_header.uid_from,
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
936 qq_get_ver_desc(im_header.version_from), im_header.version_from);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
937
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
938 switch (im_header.im_type) {
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
939 case QQ_NORMAL_IM_TEXT:
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
940 if (bytes >= len - 1) {
24046
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24045
diff changeset
941 purple_debug_warning("QQ", "Received normal IM text is empty\n");
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
942 return;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
943 }
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
944 process_im_text(gc, data + bytes, len - bytes, &im_header);
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
945 break;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
946 case QQ_NORMAL_IM_FILE_REJECT_UDP:
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
947 qq_process_recv_file_reject(data + bytes, len - bytes, im_header.uid_from, gc);
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
948 break;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
949 case QQ_NORMAL_IM_FILE_APPROVE_UDP:
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
950 qq_process_recv_file_accept(data + bytes, len - bytes, im_header.uid_from, gc);
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
951 break;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
952 case QQ_NORMAL_IM_FILE_REQUEST_UDP:
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
953 qq_process_recv_file_request(data + bytes, len - bytes, im_header.uid_from, gc);
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
954 break;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
955 case QQ_NORMAL_IM_FILE_CANCEL:
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
956 qq_process_recv_file_cancel(data + bytes, len - bytes, im_header.uid_from, gc);
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
957 break;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
958 case QQ_NORMAL_IM_FILE_NOTIFY:
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
959 qq_process_recv_file_notify(data + bytes, len - bytes, im_header.uid_from, gc);
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
960 break;
24046
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24045
diff changeset
961 case QQ_NORMAL_IM_FILE_REQUEST_TCP:
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24045
diff changeset
962 /* Check ReceivedFileIM::parseContents in eva*/
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24045
diff changeset
963 /* some client use this function for detect invisable buddy*/
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24045
diff changeset
964 case QQ_NORMAL_IM_FILE_APPROVE_TCP:
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24045
diff changeset
965 case QQ_NORMAL_IM_FILE_REJECT_TCP:
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24045
diff changeset
966 case QQ_NORMAL_IM_FILE_PASV:
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24045
diff changeset
967 case QQ_NORMAL_IM_FILE_EX_REQUEST_UDP:
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24045
diff changeset
968 case QQ_NORMAL_IM_FILE_EX_REQUEST_ACCEPT:
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24045
diff changeset
969 case QQ_NORMAL_IM_FILE_EX_REQUEST_CANCEL:
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24045
diff changeset
970 case QQ_NORMAL_IM_FILE_EX_NOTIFY_IP:
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24045
diff changeset
971 qq_show_packet ("Not support", data, len);
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24045
diff changeset
972 break;
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
973 default:
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
974 /* a simple process here, maybe more later */
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
975 qq_show_packet ("Unknow", data + bytes, len - bytes);
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
976 return;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
977 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
978 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
979
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
980 /* it is a extended IM, maybe text or video request */
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
981 void qq_process_extend_im(PurpleConnection *gc, guint8 *data, gint len)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
982 {
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
983 gint bytes;
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
984 qq_im_header im_header;
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
985
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
986 g_return_if_fail (data != NULL && len > 0);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
987
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
988 bytes = get_im_header(&im_header, data, len);
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
989 if (bytes < 0) {
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
990 purple_debug_error("QQ", "Fail read im header, len %d\n", len);
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
991 qq_show_packet ("IM Header", data, len);
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
992 return;
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
993 }
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
994 purple_debug_info("QQ",
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
995 "Got Extend IM to %u, type: %02X from: %u ver: %s (%04X)\n",
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
996 im_header.uid_to, im_header.im_type, im_header.uid_from,
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
997 qq_get_ver_desc(im_header.version_from), im_header.version_from);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
998
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
999 switch (im_header.im_type) {
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1000 case QQ_NORMAL_IM_TEXT:
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1001 process_extend_im_text(gc, data + bytes, len - bytes, &im_header);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1002 break;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1003 case QQ_NORMAL_IM_FILE_REJECT_UDP:
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1004 qq_process_recv_file_reject (data + bytes, len - bytes, im_header.uid_from, gc);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1005 break;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1006 case QQ_NORMAL_IM_FILE_APPROVE_UDP:
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1007 qq_process_recv_file_accept (data + bytes, len - bytes, im_header.uid_from, gc);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1008 break;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1009 case QQ_NORMAL_IM_FILE_REQUEST_UDP:
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1010 qq_process_recv_file_request (data + bytes, len - bytes, im_header.uid_from, gc);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1011 break;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1012 case QQ_NORMAL_IM_FILE_CANCEL:
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1013 qq_process_recv_file_cancel (data + bytes, len - bytes, im_header.uid_from, gc);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1014 break;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1015 case QQ_NORMAL_IM_FILE_NOTIFY:
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1016 qq_process_recv_file_notify (data + bytes, len - bytes, im_header.uid_from, gc);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1017 break;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1018 case QQ_NORMAL_IM_FILE_REQUEST_TCP:
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1019 /* Check ReceivedFileIM::parseContents in eva*/
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1020 /* some client use this function for detect invisable buddy*/
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1021 case QQ_NORMAL_IM_FILE_APPROVE_TCP:
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1022 case QQ_NORMAL_IM_FILE_REJECT_TCP:
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1023 case QQ_NORMAL_IM_FILE_PASV:
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1024 case QQ_NORMAL_IM_FILE_EX_REQUEST_UDP:
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1025 case QQ_NORMAL_IM_FILE_EX_REQUEST_ACCEPT:
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1026 case QQ_NORMAL_IM_FILE_EX_REQUEST_CANCEL:
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1027 case QQ_NORMAL_IM_FILE_EX_NOTIFY_IP:
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1028 qq_show_packet ("Not support", data, len);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1029 break;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1030 default:
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1031 /* a simple process here, maybe more later */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1032 qq_show_packet ("Unknow", data + bytes, len - bytes);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1033 break;
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
1034 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1035 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1036
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
1037 /* send an IM to uid_to */
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1038 static void request_send_im(PurpleConnection *gc, guint32 uid_to, gint type,
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
1039 qq_im_format *fmt, gchar *msg, guint8 id, guint8 frag_count, guint8 frag_index)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1040 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1041 qq_data *qd;
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1042 guint8 raw_data[MAX_PACKET_SIZE - 16];
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
1043 guint16 im_type;
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1044 gint bytes;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1045 time_t now;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1046
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1047 qd = (qq_data *) gc->proto_data;
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
1048 im_type = QQ_NORMAL_IM_TEXT;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1049
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1050 /* purple_debug_info("QQ", "Send IM %d-%d\n", frag_count, frag_index); */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1051 bytes = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1052 /* 000-003: receiver uid */
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
1053 bytes += qq_put32(raw_data + bytes, qd->uid);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1054 /* 004-007: sender uid */
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
1055 bytes += qq_put32(raw_data + bytes, uid_to);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1056 /* 008-009: sender client version */
24066
dbc7a9742f8d 2008.09.26 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24065
diff changeset
1057 bytes += qq_put16(raw_data + bytes, qd->client_tag);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1058 /* 010-013: receiver uid */
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
1059 bytes += qq_put32(raw_data + bytes, qd->uid);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1060 /* 014-017: sender uid */
24077
ce94189f15ad Flos Lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24076
diff changeset
1061 bytes += qq_put32(raw_data + bytes, uid_to);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1062 /* 018-033: md5 of (uid+session_key) */
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
1063 bytes += qq_putdata(raw_data + bytes, qd->session_md5, 16);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1064 /* 034-035: message type */
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1065 bytes += qq_put16(raw_data + bytes, QQ_NORMAL_IM_TEXT);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1066 /* 036-037: sequence number */
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
1067 bytes += qq_put16(raw_data + bytes, qd->send_seq);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1068 /* 038-041: send time */
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1069 now = time(NULL);
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
1070 bytes += qq_put32(raw_data + bytes, (guint32) now);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1071 /* 042-043: sender icon */
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
1072 bytes += qq_put16(raw_data + bytes, qd->my_icon);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1073 /* 044-046: always 0x00 */
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
1074 bytes += qq_put16(raw_data + bytes, 0x0000);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
1075 bytes += qq_put8(raw_data + bytes, 0x00);
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1076 /* 047-047: always use font attr */
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
1077 bytes += qq_put8(raw_data + bytes, 0x01);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1078 /* 048-051: always 0x00 */
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1079 /* Fixme: frag_count, frag_index not working now */
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
1080 bytes += qq_put8(raw_data + bytes, frag_count);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
1081 bytes += qq_put8(raw_data + bytes, frag_index);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
1082 bytes += qq_put8(raw_data + bytes, id);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
1083 bytes += qq_put8(raw_data + bytes, 0);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1084 /* 052-052: text message type (normal/auto-reply) */
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 22527
diff changeset
1085 bytes += qq_put8(raw_data + bytes, type);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1086 /* 053- : msg ends with 0x00 */
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1087 bytes += qq_putdata(raw_data + bytes, (guint8 *)msg, strlen(msg));
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
1088 if (frag_count == frag_index + 1) {
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
1089 bytes += qq_put8(raw_data + bytes, 0x20); /* add extra SPACE */
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
1090 }
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1091 bytes += qq_put_im_tail(raw_data + bytes, fmt);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1092
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1093 /* qq_show_packet("QQ_CMD_SEND_IM", raw_data, bytes); */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1094 qq_send_cmd(gc, QQ_CMD_SEND_IM, raw_data, bytes);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1095 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1096
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1097 static void im_convert_and_merge(GString *dest, GString *append)
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1098 {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1099 gchar *converted;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1100 g_return_if_fail(dest != NULL && append != NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1101
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1102 if (append->str == NULL || append->len <= 0) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1103 return;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1104 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1105 /* purple_debug_info("QQ", "Append:\n%s\n", append->str); */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1106 converted = utf8_to_qq(append->str, QQ_CHARSET_DEFAULT);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1107 g_string_append(dest, converted);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1108 g_string_set_size(append, 0);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1109 g_free(converted);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1110 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1111
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1112 GSList *qq_im_get_segments(gchar *msg_stripped, gboolean is_smiley_none)
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1113 {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1114 GSList *string_list = NULL;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1115 GString *new_string;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1116 GString *append_utf8;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1117 gchar *start, *p;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1118 gint count, len;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1119 qq_emoticon *emoticon;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1120
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1121 g_return_val_if_fail(msg_stripped != NULL, NULL);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1122
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1123 start = msg_stripped;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1124 count = 0;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1125 new_string = g_string_new("");
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1126 append_utf8 = g_string_new("");
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1127 while (*start) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1128 p = start;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1129
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1130 /* Convert emoticon */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1131 if (!is_smiley_none && *p == '/') {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1132 if (new_string->len + append_utf8->len + 2 > QQ_MSG_IM_MAX) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1133 /* enough chars to send */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1134 im_convert_and_merge(new_string, append_utf8);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1135 string_list = g_slist_append(string_list, strdup(new_string->str));
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1136 g_string_set_size(new_string, 0);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1137 continue;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1138 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1139 emoticon = emoticon_find(p);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1140 if (emoticon != NULL) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1141 purple_debug_info("QQ", "found emoticon %s as 0x%02X\n",
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1142 emoticon->name, emoticon->symbol);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1143 /* QQ emoticon code prevent converting from utf8 to QQ charset
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1144 * convert append_utf8 to QQ charset
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1145 * merge the result to dest
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1146 * append qq QQ emoticon code to dest */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1147 im_convert_and_merge(new_string, append_utf8);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1148 g_string_append_c(new_string, 0x14);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1149 g_string_append_c(new_string, emoticon->symbol);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1150 start += strlen(emoticon->name);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1151 continue;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1152 } else {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1153 purple_debug_info("QQ", "Not found emoticon %.20s\n", p);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1154 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1155 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1156
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1157 /* Get next char */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1158 start = g_utf8_next_char(p);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1159 len = start - p;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1160 if (new_string->len + append_utf8->len + len > QQ_MSG_IM_MAX) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1161 /* enough chars to send */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1162 im_convert_and_merge(new_string, append_utf8);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1163 string_list = g_slist_append(string_list, strdup(new_string->str));
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1164 g_string_set_size(new_string, 0);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1165 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1166 g_string_append_len(append_utf8, p, len);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1167 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1168
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1169 if (new_string->len + append_utf8->len > 0) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1170 im_convert_and_merge(new_string, append_utf8);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1171 string_list = g_slist_append(string_list, strdup(new_string->str));
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1172 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1173 g_string_free(new_string, TRUE);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1174 g_string_free(append_utf8, TRUE);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1175 return string_list;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1176 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1177
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1178 gboolean qq_im_smiley_none(const gchar *msg)
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1179 {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1180 const gchar *start, *end, *last;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1181 GData *attribs;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1182 gchar *tmp;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1183 gboolean ret = FALSE;
24076
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24074
diff changeset
1184
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1185 g_return_val_if_fail(msg != NULL, TRUE);
24076
ec3f7d3e0445 2008.10.04 - lonicerae <lonicerae(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24074
diff changeset
1186
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1187 last = msg;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1188 while (purple_markup_find_tag("font", last, &start, &end, &attribs)) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1189 tmp = g_datalist_get_data(&attribs, "sml");
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1190 if (tmp && strlen(tmp) > 0) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1191 if (strcmp(tmp, "none") == 0) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1192 ret = TRUE;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1193 break;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1194 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1195 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1196 g_datalist_clear(&attribs);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1197 last = end + 1;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1198 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1199 return ret;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1200 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1201
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1202 /* Grab custom emote icons
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1203 static GSList* qq_grab_emoticons(const char *msg, const char*username)
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1204 {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1205 GSList *list;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1206 GList *smileys;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1207 PurpleSmiley *smiley;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1208 const char *smiley_shortcut;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1209 char *ptr;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1210 int length;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1211 PurpleStoredImage *img;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1212
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1213 smileys = purple_smileys_get_all();
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1214 length = strlen(msg);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1215
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1216 for (; smileys; smileys = g_list_delete_link(smileys, smileys)) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1217 smiley = smileys->data;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1218 smiley_shortcut = purple_smiley_get_shortcut(smiley);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1219 purple_debug_info("QQ", "Smiley shortcut [%s]\n", smiley_shortcut);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1220
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1221 ptr = g_strstr_len(msg, length, smiley_shortcut);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1222
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1223 if (!ptr)
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1224 continue;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1225
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1226 purple_debug_info("QQ", "Found Smiley shortcut [%s]\n", smiley_shortcut);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1227
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1228 img = purple_smiley_get_stored_image(smiley);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1229
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1230 emoticon = g_new0(MsnEmoticon, 1);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1231 emoticon->smile = g_strdup(purple_smiley_get_shortcut(smiley));
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1232 emoticon->obj = msn_object_new_from_image(img,
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1233 purple_imgstore_get_filename(img),
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1234 username, MSN_OBJECT_EMOTICON);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1235
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1236 purple_imgstore_unref(img);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1237 list = g_slist_prepend(list, emoticon);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1238 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1239 return list;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1240 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1241 */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1242
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1243 gint qq_send_im(PurpleConnection *gc, const gchar *who, const gchar *what, PurpleMessageFlags flags)
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1244 {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1245 qq_data *qd;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1246 guint32 uid_to;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1247 gint type;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1248 qq_im_format *fmt;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1249 gchar *msg_stripped, *tmp;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1250 GSList *segments, *it;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1251 gint msg_len;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1252 const gchar *start_invalid;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1253 gboolean is_smiley_none;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1254 guint8 frag_count, frag_index;
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
1255 guint8 msg_id;
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1256
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1257 g_return_val_if_fail(NULL != gc && NULL != gc->proto_data, -1);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1258 g_return_val_if_fail(who != NULL && what != NULL, -1);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1259
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1260 qd = (qq_data *) gc->proto_data;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1261 purple_debug_info("QQ", "Send IM to %s, len %d:\n%s\n", who, strlen(what), what);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1262
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1263 uid_to = purple_name_to_uid(who);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1264 if (uid_to == qd->uid) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1265 /* if msg is to myself, bypass the network */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1266 serv_got_im(gc, who, what, flags, time(NULL));
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1267 return 1;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1268 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1269
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1270 type = (flags == PURPLE_MESSAGE_AUTO_RESP ? QQ_IM_AUTO_REPLY : QQ_IM_TEXT);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1271 /* qq_show_packet("IM UTF8", (guint8 *)what, strlen(what)); */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1272
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1273 msg_stripped = purple_markup_strip_html(what);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1274 g_return_val_if_fail(msg_stripped != NULL, -1);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1275 /* qq_show_packet("IM Stripped", (guint8 *)what, strlen(what)); */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1276
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1277 /* Check and valid utf8 string */
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1278 msg_len = strlen(msg_stripped);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1279 g_return_val_if_fail(msg_len > 0, -1);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1280 if (!g_utf8_validate(msg_stripped, msg_len, &start_invalid)) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1281 if (start_invalid > msg_stripped) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1282 tmp = g_strndup(msg_stripped, start_invalid - msg_stripped);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1283 g_free(msg_stripped);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1284 msg_stripped = g_strconcat(tmp, _("(Invalid UTF-8 string)"), NULL);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1285 g_free(tmp);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1286 } else {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1287 g_free(msg_stripped);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1288 msg_stripped = g_strdup(_("(Invalid UTF-8 string)"));
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1289 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1290 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1291
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1292 is_smiley_none = qq_im_smiley_none(what);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1293 segments = qq_im_get_segments(msg_stripped, is_smiley_none);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1294 g_free(msg_stripped);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1295
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1296 if (segments == NULL) {
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1297 return -1;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1298 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1299
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
1300 qd->send_im_id++;
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
1301 msg_id = (guint8)(qd->send_im_id && 0xFF);
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1302 fmt = qq_im_fmt_new_by_purple(what);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1303 frag_count = g_slist_length(segments);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1304 frag_index = 0;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1305 for (it = segments; it; it = it->next) {
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
1306 /*
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1307 request_send_im(gc, uid_to, type, fmt, (gchar *)it->data,
24590
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
1308 msg_id, frag_count, frag_index);
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
1309 */
05fee0406365 Support sending long IM message
Hu Yong <ccpaging@gmail.com>
parents: 24583
diff changeset
1310 request_send_im(gc, uid_to, type, fmt, (gchar *)it->data, 0, 0, 0);
24566
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1311 g_free(it->data);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1312 frag_index++;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1313 }
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1314 g_slist_free(segments);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1315 qq_im_fmt_free(fmt);
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1316 return 1;
682eb95a6aa7 Rewrite smiley convert function
Hu Yong <ccpaging@gmail.com>
parents: 24089
diff changeset
1317 }