Mercurial > pidgin
comparison src/protocols/qq/group_im.c @ 14021:ef8490f9e823
[gaim-migrate @ 16618]
Replaced all C++-style comments with C-style ones.
Cleaned up some comments and implemented a more consistent formatting scheme.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Huetsch <markhuetsch> |
---|---|
date | Wed, 02 Aug 2006 15:35:36 +0000 |
parents | 983fd420e86b |
children | 6342ffdeb3ac |
comparison
equal
deleted
inserted
replaced
14020:13e7ba964993 | 14021:ef8490f9e823 |
---|---|
18 * You should have received a copy of the GNU General Public License | 18 * You should have received a copy of the GNU General Public License |
19 * along with this program; if not, write to the Free Software | 19 * along with this program; if not, write to the Free Software |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 */ | 21 */ |
22 | 22 |
23 // START OF FILE | 23 #include "conversation.h" |
24 /*****************************************************************************/ | |
25 #include "debug.h" | 24 #include "debug.h" |
26 #include "conversation.h" // GaimConversation | 25 #include "notify.h" |
27 #include "notify.h" // gaim_notify_warning | 26 #include "prefs.h" |
28 #include "prefs.h" // gaim_prefs_get_bool | 27 #include "request.h" |
29 #include "request.h" // gaim_request_action | |
30 #include "util.h" | 28 #include "util.h" |
31 | 29 |
32 #include "utils.h" // uid_to_gaim_name | 30 #include "char_conv.h" |
33 #include "packet_parse.h" // create_packet_xx | 31 #include "group_find.h" |
34 #include "char_conv.h" // qq_smiley_to_gaim | 32 #include "group_hash.h" |
35 #include "group_find.h" // qq_group_find_by_external_group_id | 33 #include "group_info.h" |
36 #include "group_hash.h" // qq_group_refresh | |
37 #include "group_info.h" // qq_send_cmd_group_get_group_info | |
38 #include "group_im.h" | 34 #include "group_im.h" |
39 #include "group_network.h" // qq_send_group_cmd | 35 #include "group_network.h" |
40 #include "group_opt.h" // add_group_member | 36 #include "group_opt.h" |
41 #include "im.h" // QQ_SEND_IM_AFTER_MSG_LEN | 37 #include "im.h" |
38 #include "packet_parse.h" | |
39 #include "utils.h" | |
42 | 40 |
43 typedef struct _qq_recv_group_im { | 41 typedef struct _qq_recv_group_im { |
44 guint32 external_group_id; | 42 guint32 external_group_id; |
45 guint8 group_type; | 43 guint8 group_type; |
46 guint32 member_uid; | 44 guint32 member_uid; |
50 guint8 *msg; | 48 guint8 *msg; |
51 guint8 *font_attr; | 49 guint8 *font_attr; |
52 gint font_attr_len; | 50 gint font_attr_len; |
53 } qq_recv_group_im; | 51 } qq_recv_group_im; |
54 | 52 |
55 /*****************************************************************************/ | 53 /* send IM to a group */ |
56 // send IM to a group | 54 void qq_send_packet_group_im(GaimConnection *gc, qq_group *group, const gchar *msg) |
57 void qq_send_packet_group_im(GaimConnection * gc, qq_group * group, const gchar * msg) { | 55 { |
58 gint data_len, bytes; | 56 gint data_len, bytes; |
59 guint8 *raw_data, *cursor; | 57 guint8 *raw_data, *cursor; |
60 guint16 msg_len; | 58 guint16 msg_len; |
61 gchar *msg_filtered; | 59 gchar *msg_filtered; |
62 | 60 |
78 QQ_SEND_IM_AFTER_MSG_LEN); | 76 QQ_SEND_IM_AFTER_MSG_LEN); |
79 bytes += create_packet_data(raw_data, &cursor, (gchar *) send_im_tail, QQ_SEND_IM_AFTER_MSG_LEN); | 77 bytes += create_packet_data(raw_data, &cursor, (gchar *) send_im_tail, QQ_SEND_IM_AFTER_MSG_LEN); |
80 g_free(send_im_tail); | 78 g_free(send_im_tail); |
81 g_free(msg_filtered); | 79 g_free(msg_filtered); |
82 | 80 |
83 if (bytes == data_len) // create OK | 81 if (bytes == data_len) /* create OK */ |
84 qq_send_group_cmd(gc, group, raw_data, data_len); | 82 qq_send_group_cmd(gc, group, raw_data, data_len); |
85 else | 83 else |
86 gaim_debug(GAIM_DEBUG_ERROR, "QQ", | 84 gaim_debug(GAIM_DEBUG_ERROR, "QQ", |
87 "Fail creating group_im packet, expect %d bytes, build %d bytes\n", data_len, bytes); | 85 "Fail creating group_im packet, expect %d bytes, build %d bytes\n", data_len, bytes); |
88 | 86 } |
89 } // qq_send_packet_group_im | 87 |
90 | 88 /* this is the ACK */ |
91 /*****************************************************************************/ | 89 void qq_process_group_cmd_im(guint8 *data, guint8 **cursor, gint len, GaimConnection *gc) |
92 // this is the ACK | 90 { |
93 void qq_process_group_cmd_im(guint8 * data, guint8 ** cursor, gint len, GaimConnection * gc) { | 91 /* return should be the internal group id |
94 // return should be the internal group id | 92 * but we have nothing to do with it */ |
95 // but we have nothing to do with it | |
96 return; | 93 return; |
97 } // qq_process_group_cmd_im | 94 } |
98 | 95 |
99 /*****************************************************************************/ | 96 /* receive an application to join the group */ |
100 // receive an application to join the group | |
101 void qq_process_recv_group_im_apply_join | 97 void qq_process_recv_group_im_apply_join |
102 (guint8 * data, guint8 ** cursor, gint len, guint32 internal_group_id, GaimConnection * gc) { | 98 (guint8 *data, guint8 **cursor, gint len, guint32 internal_group_id, GaimConnection *gc) |
99 { | |
103 guint32 external_group_id, user_uid; | 100 guint32 external_group_id, user_uid; |
104 guint8 group_type; | 101 guint8 group_type; |
105 gchar *reason_utf8, *msg, *reason; | 102 gchar *reason_utf8, *msg, *reason; |
106 group_member_opt *g; | 103 group_member_opt *g; |
107 | 104 |
108 g_return_if_fail(gc != NULL && internal_group_id > 0 && data != NULL && len > 0); | 105 g_return_if_fail(gc != NULL && internal_group_id > 0 && data != NULL && len > 0); |
109 | 106 |
110 if (*cursor >= (data + len - 1)) { | 107 if (*cursor >= (data + len - 1)) { |
111 gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Received group msg apply_join is empty\n"); | 108 gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Received group msg apply_join is empty\n"); |
112 return; | 109 return; |
113 } // if | 110 } |
114 | 111 |
115 read_packet_dw(data, cursor, len, &external_group_id); | 112 read_packet_dw(data, cursor, len, &external_group_id); |
116 read_packet_b(data, cursor, len, &group_type); | 113 read_packet_b(data, cursor, len, &group_type); |
117 read_packet_dw(data, cursor, len, &user_uid); | 114 read_packet_dw(data, cursor, len, &user_uid); |
118 | 115 |
140 _("Search"), G_CALLBACK(qq_group_search_application_with_struct)); | 137 _("Search"), G_CALLBACK(qq_group_search_application_with_struct)); |
141 | 138 |
142 g_free(reason); | 139 g_free(reason); |
143 g_free(msg); | 140 g_free(msg); |
144 g_free(reason_utf8); | 141 g_free(reason_utf8); |
145 | 142 } |
146 } // qq_process_recv_group_im_apply_join | 143 |
147 | 144 /* the request to join a group is rejected */ |
148 /*****************************************************************************/ | |
149 // the request to join a group is rejected | |
150 void qq_process_recv_group_im_been_rejected | 145 void qq_process_recv_group_im_been_rejected |
151 (guint8 * data, guint8 ** cursor, gint len, guint32 internal_group_id, GaimConnection * gc) { | 146 (guint8 *data, guint8 **cursor, gint len, guint32 internal_group_id, GaimConnection *gc) |
147 { | |
152 guint32 external_group_id, admin_uid; | 148 guint32 external_group_id, admin_uid; |
153 guint8 group_type; | 149 guint8 group_type; |
154 gchar *reason_utf8, *msg, *reason; | 150 gchar *reason_utf8, *msg, *reason; |
155 qq_group *group; | 151 qq_group *group; |
156 | 152 |
157 g_return_if_fail(gc != NULL && data != NULL && len > 0); | 153 g_return_if_fail(gc != NULL && data != NULL && len > 0); |
158 | 154 |
159 if (*cursor >= (data + len - 1)) { | 155 if (*cursor >= (data + len - 1)) { |
160 gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Received group msg been_rejected is empty\n"); | 156 gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Received group msg been_rejected is empty\n"); |
161 return; | 157 return; |
162 } // if | 158 } |
163 | 159 |
164 read_packet_dw(data, cursor, len, &external_group_id); | 160 read_packet_dw(data, cursor, len, &external_group_id); |
165 read_packet_b(data, cursor, len, &group_type); | 161 read_packet_b(data, cursor, len, &group_type); |
166 read_packet_dw(data, cursor, len, &admin_uid); | 162 read_packet_dw(data, cursor, len, &admin_uid); |
167 | 163 |
177 | 173 |
178 group = qq_group_find_by_internal_group_id(gc, internal_group_id); | 174 group = qq_group_find_by_internal_group_id(gc, internal_group_id); |
179 if (group != NULL) { | 175 if (group != NULL) { |
180 group->my_status = QQ_GROUP_MEMBER_STATUS_NOT_MEMBER; | 176 group->my_status = QQ_GROUP_MEMBER_STATUS_NOT_MEMBER; |
181 qq_group_refresh(gc, group); | 177 qq_group_refresh(gc, group); |
182 } // if group | 178 } |
183 | 179 |
184 g_free(reason); | 180 g_free(reason); |
185 g_free(msg); | 181 g_free(msg); |
186 g_free(reason_utf8); | 182 g_free(reason_utf8); |
187 | 183 } |
188 } // qq_process_group_im_being_rejected | 184 |
189 | 185 /* the request to join a group is approved */ |
190 /*****************************************************************************/ | |
191 // the request to join a group is approved | |
192 void qq_process_recv_group_im_been_approved | 186 void qq_process_recv_group_im_been_approved |
193 (guint8 * data, guint8 ** cursor, gint len, guint32 internal_group_id, GaimConnection * gc) { | 187 (guint8 *data, guint8 **cursor, gint len, guint32 internal_group_id, GaimConnection *gc) |
188 { | |
194 guint32 external_group_id, admin_uid; | 189 guint32 external_group_id, admin_uid; |
195 guint8 group_type; | 190 guint8 group_type; |
196 gchar *reason_utf8, *msg; | 191 gchar *reason_utf8, *msg; |
197 qq_group *group; | 192 qq_group *group; |
198 | 193 |
199 g_return_if_fail(gc != NULL && data != NULL && len > 0); | 194 g_return_if_fail(gc != NULL && data != NULL && len > 0); |
200 | 195 |
201 if (*cursor >= (data + len - 1)) { | 196 if (*cursor >= (data + len - 1)) { |
202 gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Received group msg been_approved is empty\n"); | 197 gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Received group msg been_approved is empty\n"); |
203 return; | 198 return; |
204 } // if | 199 } |
205 | 200 |
206 read_packet_dw(data, cursor, len, &external_group_id); | 201 read_packet_dw(data, cursor, len, &external_group_id); |
207 read_packet_b(data, cursor, len, &group_type); | 202 read_packet_b(data, cursor, len, &group_type); |
208 read_packet_dw(data, cursor, len, &admin_uid); | 203 read_packet_dw(data, cursor, len, &admin_uid); |
209 | 204 |
210 g_return_if_fail(external_group_id > 0 && admin_uid > 0); | 205 g_return_if_fail(external_group_id > 0 && admin_uid > 0); |
211 // it is also a "无" here, so do not display | 206 /* it is also a "无" here, so do not display */ |
212 convert_as_pascal_string(*cursor, &reason_utf8, QQ_CHARSET_DEFAULT); | 207 convert_as_pascal_string(*cursor, &reason_utf8, QQ_CHARSET_DEFAULT); |
213 | 208 |
214 msg = g_strdup_printf | 209 msg = g_strdup_printf |
215 (_("You request to join group %d has been approved by admin %d"), external_group_id, admin_uid); | 210 (_("You request to join group %d has been approved by admin %d"), external_group_id, admin_uid); |
216 | 211 |
218 | 213 |
219 group = qq_group_find_by_internal_group_id(gc, internal_group_id); | 214 group = qq_group_find_by_internal_group_id(gc, internal_group_id); |
220 if (group != NULL) { | 215 if (group != NULL) { |
221 group->my_status = QQ_GROUP_MEMBER_STATUS_IS_MEMBER; | 216 group->my_status = QQ_GROUP_MEMBER_STATUS_IS_MEMBER; |
222 qq_group_refresh(gc, group); | 217 qq_group_refresh(gc, group); |
223 } // if group | 218 } |
224 | 219 |
225 g_free(msg); | 220 g_free(msg); |
226 g_free(reason_utf8); | 221 g_free(reason_utf8); |
227 } // qq_process_group_im_being_approved | 222 } |
228 | 223 |
229 /*****************************************************************************/ | 224 /* process the packet when removed from a group */ |
230 // process the packet when reomved from a group | |
231 void qq_process_recv_group_im_been_removed | 225 void qq_process_recv_group_im_been_removed |
232 (guint8 * data, guint8 ** cursor, gint len, guint32 internal_group_id, GaimConnection * gc) { | 226 (guint8 *data, guint8 **cursor, gint len, guint32 internal_group_id, GaimConnection *gc) |
227 { | |
233 guint32 external_group_id, uid; | 228 guint32 external_group_id, uid; |
234 guint8 group_type; | 229 guint8 group_type; |
235 gchar *msg; | 230 gchar *msg; |
236 qq_group *group; | 231 qq_group *group; |
237 | 232 |
238 g_return_if_fail(gc != NULL && data != NULL && len > 0); | 233 g_return_if_fail(gc != NULL && data != NULL && len > 0); |
239 | 234 |
240 if (*cursor >= (data + len - 1)) { | 235 if (*cursor >= (data + len - 1)) { |
241 gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Received group msg been_removed is empty\n"); | 236 gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Received group msg been_removed is empty\n"); |
242 return; | 237 return; |
243 } // if | 238 } |
244 | 239 |
245 read_packet_dw(data, cursor, len, &external_group_id); | 240 read_packet_dw(data, cursor, len, &external_group_id); |
246 read_packet_b(data, cursor, len, &group_type); | 241 read_packet_b(data, cursor, len, &group_type); |
247 read_packet_dw(data, cursor, len, &uid); | 242 read_packet_dw(data, cursor, len, &uid); |
248 | 243 |
253 | 248 |
254 group = qq_group_find_by_internal_group_id(gc, internal_group_id); | 249 group = qq_group_find_by_internal_group_id(gc, internal_group_id); |
255 if (group != NULL) { | 250 if (group != NULL) { |
256 group->my_status = QQ_GROUP_MEMBER_STATUS_NOT_MEMBER; | 251 group->my_status = QQ_GROUP_MEMBER_STATUS_NOT_MEMBER; |
257 qq_group_refresh(gc, group); | 252 qq_group_refresh(gc, group); |
258 } // if group | 253 } |
259 | 254 |
260 g_free(msg); | 255 g_free(msg); |
261 } // qq_process_recv_group_im_been_removed | 256 } |
262 | 257 |
263 /*****************************************************************************/ | 258 /* process the packet when added to a group */ |
264 // process the packet when added to a group | |
265 void qq_process_recv_group_im_been_added | 259 void qq_process_recv_group_im_been_added |
266 (guint8 * data, guint8 ** cursor, gint len, guint32 internal_group_id, GaimConnection * gc) { | 260 (guint8 *data, guint8 **cursor, gint len, guint32 internal_group_id, GaimConnection *gc) |
261 { | |
267 guint32 external_group_id, uid; | 262 guint32 external_group_id, uid; |
268 guint8 group_type; | 263 guint8 group_type; |
269 qq_group *group; | 264 qq_group *group; |
270 gchar *msg; | 265 gchar *msg; |
271 | 266 |
272 g_return_if_fail(gc != NULL && data != NULL && len > 0); | 267 g_return_if_fail(gc != NULL && data != NULL && len > 0); |
273 | 268 |
274 if (*cursor >= (data + len - 1)) { | 269 if (*cursor >= (data + len - 1)) { |
275 gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Received group msg been_added is empty\n"); | 270 gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Received group msg been_added is empty\n"); |
276 return; | 271 return; |
277 } // if | 272 } |
278 | 273 |
279 read_packet_dw(data, cursor, len, &external_group_id); | 274 read_packet_dw(data, cursor, len, &external_group_id); |
280 read_packet_b(data, cursor, len, &group_type); | 275 read_packet_b(data, cursor, len, &group_type); |
281 read_packet_dw(data, cursor, len, &uid); | 276 read_packet_dw(data, cursor, len, &uid); |
282 | 277 |
287 | 282 |
288 group = qq_group_find_by_internal_group_id(gc, internal_group_id); | 283 group = qq_group_find_by_internal_group_id(gc, internal_group_id); |
289 if (group != NULL) { | 284 if (group != NULL) { |
290 group->my_status = QQ_GROUP_MEMBER_STATUS_IS_MEMBER; | 285 group->my_status = QQ_GROUP_MEMBER_STATUS_IS_MEMBER; |
291 qq_group_refresh(gc, group); | 286 qq_group_refresh(gc, group); |
292 } else { // no such group, try to create a dummy first, and then update | 287 } else { /* no such group, try to create a dummy first, and then update */ |
293 group = qq_group_create_by_id(gc, internal_group_id, external_group_id); | 288 group = qq_group_create_by_id(gc, internal_group_id, external_group_id); |
294 group->my_status = QQ_GROUP_MEMBER_STATUS_IS_MEMBER; | 289 group->my_status = QQ_GROUP_MEMBER_STATUS_IS_MEMBER; |
295 qq_group_refresh(gc, group); | 290 qq_group_refresh(gc, group); |
296 qq_send_cmd_group_get_group_info(gc, group); | 291 qq_send_cmd_group_get_group_info(gc, group); |
297 // the return of this cmd will automatically update the group in blist | 292 /* the return of this cmd will automatically update the group in blist */ |
298 } // if group; | 293 } |
299 | 294 |
300 g_free(msg); | 295 g_free(msg); |
301 | 296 } |
302 } // qq_process_recv_group_im_been_added | 297 |
303 | 298 /* recv an IM from a group chat */ |
304 /*****************************************************************************/ | |
305 // recv an IM from a group chat | |
306 void qq_process_recv_group_im | 299 void qq_process_recv_group_im |
307 (guint8 * data, guint8 ** cursor, gint data_len, guint32 internal_group_id, GaimConnection * gc, guint16 im_type /* gfhuang */) | 300 (guint8 *data, guint8 **cursor, gint data_len, guint32 internal_group_id, GaimConnection *gc, guint16 im_type) |
308 { | 301 { |
309 gchar *msg_with_gaim_smiley, *msg_utf8_encoded, *im_src_name; | 302 gchar *msg_with_gaim_smiley, *msg_utf8_encoded, *im_src_name; |
310 guint16 unknown; | 303 guint16 unknown; |
311 guint32 unknown4; | 304 guint32 unknown4; |
312 GaimConversation *conv; | 305 GaimConversation *conv; |
317 gint skip_len; | 310 gint skip_len; |
318 | 311 |
319 g_return_if_fail(gc != NULL && gc->proto_data != NULL && data != NULL && data_len > 0); | 312 g_return_if_fail(gc != NULL && gc->proto_data != NULL && data != NULL && data_len > 0); |
320 qd = (qq_data *) gc->proto_data; | 313 qd = (qq_data *) gc->proto_data; |
321 | 314 |
322 gaim_debug(GAIM_DEBUG_INFO, "QQ", //by gfhuang | 315 gaim_debug(GAIM_DEBUG_INFO, "QQ", |
323 "group im hex dump\n%s\n", hex_dump_to_str(*cursor, data_len - (*cursor - data))); | 316 "group im hex dump\n%s\n", hex_dump_to_str(*cursor, data_len - (*cursor - data))); |
324 | 317 |
325 if (*cursor >= (data + data_len - 1)) { | 318 if (*cursor >= (data + data_len - 1)) { |
326 gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Received group im_group is empty\n"); | 319 gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Received group im_group is empty\n"); |
327 return; | 320 return; |
330 im_group = g_newa(qq_recv_group_im, 1); | 323 im_group = g_newa(qq_recv_group_im, 1); |
331 | 324 |
332 read_packet_dw(data, cursor, data_len, &(im_group->external_group_id)); | 325 read_packet_dw(data, cursor, data_len, &(im_group->external_group_id)); |
333 read_packet_b(data, cursor, data_len, &(im_group->group_type)); | 326 read_packet_b(data, cursor, data_len, &(im_group->group_type)); |
334 | 327 |
335 if(QQ_RECV_IM_TEMP_QUN_IM == im_type) { //by gfhuang, protocal changed | 328 if(QQ_RECV_IM_TEMP_QUN_IM == im_type) { |
336 read_packet_dw(data, cursor, data_len, &(internal_group_id)); | 329 read_packet_dw(data, cursor, data_len, &(internal_group_id)); |
337 } | 330 } |
338 | 331 |
339 read_packet_dw(data, cursor, data_len, &(im_group->member_uid)); | 332 read_packet_dw(data, cursor, data_len, &(im_group->member_uid)); |
340 read_packet_w(data, cursor, data_len, &unknown); // 0x0001? | 333 read_packet_w(data, cursor, data_len, &unknown); /* 0x0001? */ |
341 read_packet_w(data, cursor, data_len, &(im_group->msg_seq)); | 334 read_packet_w(data, cursor, data_len, &(im_group->msg_seq)); |
342 read_packet_dw(data, cursor, data_len, (guint32 *) & (im_group->send_time)); | 335 read_packet_dw(data, cursor, data_len, (guint32 *) & (im_group->send_time)); |
343 read_packet_dw(data, cursor, data_len, &unknown4); // versionID, gfhuang | 336 read_packet_dw(data, cursor, data_len, &unknown4); /* versionID */ |
344 // length includes font_attr | 337 /* |
345 // this msg_len includes msg and font_attr | 338 * length includes font_attr |
346 ////////////////// the format is | 339 * this msg_len includes msg and font_attr |
347 // length of all | 340 **** the format is **** |
348 // 1. unknown 10 bytes | 341 * length of all |
349 // 2. 0-ended string | 342 * 1. unknown 10 bytes |
350 // 3. font_attr | 343 * 2. 0-ended string |
344 * 3. font_attr | |
345 */ | |
351 | 346 |
352 read_packet_w(data, cursor, data_len, &(im_group->msg_len)); | 347 read_packet_w(data, cursor, data_len, &(im_group->msg_len)); |
353 g_return_if_fail(im_group->msg_len > 0); | 348 g_return_if_fail(im_group->msg_len > 0); |
354 | 349 |
355 // 10 bytes from lumaqq | 350 /* |
356 // contentType = buf.getChar(); | 351 * 10 bytes from lumaqq |
357 // totalFragments = buf.get() & 255; | 352 * contentType = buf.getChar(); |
358 // fragmentSequence = buf.get() & 255; | 353 * totalFragments = buf.get() & 255; |
359 // messageId = buf.getChar(); | 354 * fragmentSequence = buf.get() & 255; |
360 // buf.getInt(); | 355 * messageId = buf.getChar(); |
361 | 356 * buf.getInt(); |
362 if(im_type != QQ_RECV_IM_UNKNOWN_QUN_IM) // gfhuang, protocal changed | 357 */ |
358 | |
359 if(im_type != QQ_RECV_IM_UNKNOWN_QUN_IM) | |
363 skip_len = 10; | 360 skip_len = 10; |
364 else | 361 else |
365 skip_len = 0; | 362 skip_len = 0; |
366 *cursor += skip_len; | 363 *cursor += skip_len; |
367 | 364 |
368 im_group->msg = g_strdup(*cursor); | 365 im_group->msg = g_strdup(*cursor); |
369 *cursor += strlen(im_group->msg) + 1; | 366 *cursor += strlen(im_group->msg) + 1; |
370 // there might not be any font_attr, check it | 367 /* there might not be any font_attr, check it */ |
371 im_group->font_attr_len = im_group->msg_len - strlen(im_group->msg) - 1 - skip_len /* gfhuang */; | 368 im_group->font_attr_len = im_group->msg_len - strlen(im_group->msg) - 1 - skip_len; |
372 if (im_group->font_attr_len > 0) | 369 if (im_group->font_attr_len > 0) |
373 im_group->font_attr = g_memdup(*cursor, im_group->font_attr_len); | 370 im_group->font_attr = g_memdup(*cursor, im_group->font_attr_len); |
374 else | 371 else |
375 im_group->font_attr = NULL; | 372 im_group->font_attr = NULL; |
376 | 373 |
377 // group im_group has no flag to indicate whether it has font_attr or not | 374 /* group im_group has no flag to indicate whether it has font_attr or not */ |
378 msg_with_gaim_smiley = qq_smiley_to_gaim(im_group->msg); | 375 msg_with_gaim_smiley = qq_smiley_to_gaim(im_group->msg); |
379 if (im_group->font_attr_len > 0) | 376 if (im_group->font_attr_len > 0) |
380 msg_utf8_encoded = qq_encode_to_gaim(im_group->font_attr, | 377 msg_utf8_encoded = qq_encode_to_gaim(im_group->font_attr, |
381 im_group->font_attr_len, msg_with_gaim_smiley); | 378 im_group->font_attr_len, msg_with_gaim_smiley); |
382 else | 379 else |
383 msg_utf8_encoded = qq_to_utf8(msg_with_gaim_smiley, QQ_CHARSET_DEFAULT); | 380 msg_utf8_encoded = qq_to_utf8(msg_with_gaim_smiley, QQ_CHARSET_DEFAULT); |
384 | 381 |
385 group = qq_group_find_by_internal_group_id(gc, internal_group_id); | 382 group = qq_group_find_by_internal_group_id(gc, internal_group_id); |
386 g_return_if_fail(group != NULL); | 383 g_return_if_fail(group != NULL); |
387 | 384 |
388 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, /*gfhuang*/group->group_name_utf8, gaim_connection_get_account(gc)); | 385 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, group->group_name_utf8, gaim_connection_get_account(gc)); |
389 if (conv == NULL && gaim_prefs_get_bool("/plugins/prpl/qq/prompt_group_msg_on_recv")) { | 386 if (conv == NULL && gaim_prefs_get_bool("/plugins/prpl/qq/prompt_group_msg_on_recv")) { |
390 serv_got_joined_chat(gc, qd->channel++, group->group_name_utf8); | 387 serv_got_joined_chat(gc, qd->channel++, group->group_name_utf8); |
391 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, /*gfhuang*/group->group_name_utf8, gaim_connection_get_account(gc)); | 388 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, group->group_name_utf8, gaim_connection_get_account(gc)); |
392 } // if conv | 389 } |
393 | 390 |
394 if (conv != NULL) { | 391 if (conv != NULL) { |
395 member = qq_group_find_member_by_uid(group, im_group->member_uid); | 392 member = qq_group_find_member_by_uid(group, im_group->member_uid); |
396 if (member == NULL || member->nickname == NULL) | 393 if (member == NULL || member->nickname == NULL) |
397 im_src_name = uid_to_gaim_name(im_group->member_uid); | 394 im_src_name = uid_to_gaim_name(im_group->member_uid); |
399 im_src_name = g_strdup(member->nickname); | 396 im_src_name = g_strdup(member->nickname); |
400 serv_got_chat_in(gc, | 397 serv_got_chat_in(gc, |
401 gaim_conv_chat_get_id(GAIM_CONV_CHAT | 398 gaim_conv_chat_get_id(GAIM_CONV_CHAT |
402 (conv)), im_src_name, 0, msg_utf8_encoded, im_group->send_time); | 399 (conv)), im_src_name, 0, msg_utf8_encoded, im_group->send_time); |
403 g_free(im_src_name); | 400 g_free(im_src_name); |
404 } // if conv | 401 } |
405 g_free(msg_with_gaim_smiley); | 402 g_free(msg_with_gaim_smiley); |
406 g_free(msg_utf8_encoded); | 403 g_free(msg_utf8_encoded); |
407 g_free(im_group->msg); | 404 g_free(im_group->msg); |
408 g_free(im_group->font_attr); | 405 g_free(im_group->font_attr); |
409 } // _qq_process_recv_group_im | 406 } |
410 | |
411 | |
412 /*****************************************************************************/ | |
413 // END OF FILE |