Mercurial > pidgin
comparison src/protocols/msn/msg.c @ 10345:2e01c503aa4f
[gaim-migrate @ 11556]
Patch 1078151 from Felipe Contreras to fix some more MSN bugs:
"User Dislpay messages, and other less used, did not set
an slpcall, so the callback that should not be called,
was called (in some very special cases)."
...
"Here it goes the real real one, as far as I can tell.
Cleaning + organizing + documentation + hard bug fix = big
patch." -- Felipe Contreras
I also fixed drag-and-drop to conversation window file transfers (which
I had broken when I fixed some other dnd thing), made the debug output
of the autoreconnect plugin more useful, and stopped the message
notification plugin notifying you for messages sent by ignored users.
committer: Tailor Script <tailor@pidgin.im>
| author | Stu Tomlinson <stu@nosnilmot.com> |
|---|---|
| date | Sat, 11 Dec 2004 20:01:58 +0000 |
| parents | f776e117c17b |
| children | bcfea6c3d5c9 |
comparison
equal
deleted
inserted
replaced
| 10344:5976491e07a7 | 10345:2e01c503aa4f |
|---|---|
| 30 MsnMessage *msg; | 30 MsnMessage *msg; |
| 31 | 31 |
| 32 msg = g_new0(MsnMessage, 1); | 32 msg = g_new0(MsnMessage, 1); |
| 33 msg->type = type; | 33 msg->type = type; |
| 34 | 34 |
| 35 #ifdef MSN_DEBUG_MSG | |
| 36 gaim_debug_info("msn", "message new (%p)(%d)\n", msg, type); | |
| 37 #endif | |
| 38 | |
| 35 msg->attr_table = g_hash_table_new_full(g_str_hash, g_str_equal, | 39 msg->attr_table = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 36 g_free, g_free); | 40 g_free, g_free); |
| 37 | 41 |
| 38 msn_message_ref(msg); | 42 msn_message_ref(msg); |
| 43 | |
| 44 return msg; | |
| 45 } | |
| 46 | |
| 47 void | |
| 48 msn_message_destroy(MsnMessage *msg) | |
| 49 { | |
| 50 g_return_if_fail(msg != NULL); | |
| 51 | |
| 52 if (msg->ref_count > 0) | |
| 53 { | |
| 54 msn_message_unref(msg); | |
| 55 | |
| 56 return; | |
| 57 } | |
| 58 | |
| 59 #ifdef MSN_DEBUG_MSG | |
| 60 gaim_debug_info("msn", "message destroy (%p)\n", msg); | |
| 61 #endif | |
| 62 | |
| 63 if (msg->remote_user != NULL) | |
| 64 g_free(msg->remote_user); | |
| 65 | |
| 66 if (msg->body != NULL) | |
| 67 g_free(msg->body); | |
| 68 | |
| 69 if (msg->content_type != NULL) | |
| 70 g_free(msg->content_type); | |
| 71 | |
| 72 if (msg->charset != NULL) | |
| 73 g_free(msg->charset); | |
| 74 | |
| 75 g_hash_table_destroy(msg->attr_table); | |
| 76 g_list_free(msg->attr_list); | |
| 77 | |
| 78 g_free(msg); | |
| 79 } | |
| 80 | |
| 81 MsnMessage * | |
| 82 msn_message_ref(MsnMessage *msg) | |
| 83 { | |
| 84 g_return_val_if_fail(msg != NULL, NULL); | |
| 85 | |
| 86 msg->ref_count++; | |
| 87 | |
| 88 #ifdef MSN_DEBUG_MSG | |
| 89 gaim_debug_info("msn", "message ref (%p)[%d]\n", msg, msg->ref_count); | |
| 90 #endif | |
| 91 | |
| 92 return msg; | |
| 93 } | |
| 94 | |
| 95 MsnMessage * | |
| 96 msn_message_unref(MsnMessage *msg) | |
| 97 { | |
| 98 g_return_val_if_fail(msg != NULL, NULL); | |
| 99 | |
| 100 if (msg->ref_count <= 0) | |
| 101 return NULL; | |
| 102 | |
| 103 msg->ref_count--; | |
| 104 | |
| 105 #ifdef MSN_DEBUG_MSG | |
| 106 gaim_debug_info("msn", "message unref (%p)[%d]\n", msg, msg->ref_count); | |
| 107 #endif | |
| 108 | |
| 109 if (msg->ref_count == 0) | |
| 110 { | |
| 111 msn_message_destroy(msg); | |
| 112 | |
| 113 return NULL; | |
| 114 } | |
| 39 | 115 |
| 40 return msg; | 116 return msg; |
| 41 } | 117 } |
| 42 | 118 |
| 43 MsnMessage * | 119 MsnMessage * |
| 239 msg->cmd = cmd; | 315 msg->cmd = cmd; |
| 240 | 316 |
| 241 return msg; | 317 return msg; |
| 242 } | 318 } |
| 243 | 319 |
| 244 void | |
| 245 msn_message_destroy(MsnMessage *msg) | |
| 246 { | |
| 247 g_return_if_fail(msg != NULL); | |
| 248 | |
| 249 if (msg->ref_count > 0) | |
| 250 { | |
| 251 msn_message_unref(msg); | |
| 252 | |
| 253 return; | |
| 254 } | |
| 255 | |
| 256 if (msg->remote_user != NULL) | |
| 257 g_free(msg->remote_user); | |
| 258 | |
| 259 if (msg->body != NULL) | |
| 260 g_free(msg->body); | |
| 261 | |
| 262 if (msg->content_type != NULL) | |
| 263 g_free(msg->content_type); | |
| 264 | |
| 265 if (msg->charset != NULL) | |
| 266 g_free(msg->charset); | |
| 267 | |
| 268 g_hash_table_destroy(msg->attr_table); | |
| 269 g_list_free(msg->attr_list); | |
| 270 | |
| 271 g_free(msg); | |
| 272 } | |
| 273 | |
| 274 MsnMessage * | |
| 275 msn_message_ref(MsnMessage *msg) | |
| 276 { | |
| 277 g_return_val_if_fail(msg != NULL, NULL); | |
| 278 | |
| 279 msg->ref_count++; | |
| 280 | |
| 281 return msg; | |
| 282 } | |
| 283 | |
| 284 MsnMessage * | |
| 285 msn_message_unref(MsnMessage *msg) | |
| 286 { | |
| 287 g_return_val_if_fail(msg != NULL, NULL); | |
| 288 | |
| 289 if (msg->ref_count <= 0) | |
| 290 return NULL; | |
| 291 | |
| 292 msg->ref_count--; | |
| 293 | |
| 294 if (msg->ref_count == 0) | |
| 295 { | |
| 296 msn_message_destroy(msg); | |
| 297 | |
| 298 return NULL; | |
| 299 } | |
| 300 | |
| 301 return msg; | |
| 302 } | |
| 303 | |
| 304 char * | 320 char * |
| 305 msn_message_gen_slp_body(MsnMessage *msg, size_t *ret_size) | 321 msn_message_gen_slp_body(MsnMessage *msg, size_t *ret_size) |
| 306 { | 322 { |
| 307 MsnSlpHeader header; | 323 MsnSlpHeader header; |
| 308 | 324 |
| 689 g_string_append_printf(str, "Flags: 0x%x\r\n", msg->msnslp_header.flags); | 705 g_string_append_printf(str, "Flags: 0x%x\r\n", msg->msnslp_header.flags); |
| 690 g_string_append_printf(str, "ACK ID: %u\r\n", msg->msnslp_header.ack_id); | 706 g_string_append_printf(str, "ACK ID: %u\r\n", msg->msnslp_header.ack_id); |
| 691 g_string_append_printf(str, "SUB ID: %u\r\n", msg->msnslp_header.ack_sub_id); | 707 g_string_append_printf(str, "SUB ID: %u\r\n", msg->msnslp_header.ack_sub_id); |
| 692 g_string_append_printf(str, "ACK Size: %" G_GUINT64_FORMAT "\r\n", msg->msnslp_header.ack_size); | 708 g_string_append_printf(str, "ACK Size: %" G_GUINT64_FORMAT "\r\n", msg->msnslp_header.ack_size); |
| 693 | 709 |
| 694 #ifdef DEBUG_SLP_VERBOSE | 710 #ifdef MSN_DEBUG_SLP_VERBOSE |
| 695 if (body != NULL) | 711 if (body != NULL) |
| 696 { | 712 { |
| 697 if (text_body) | 713 if (text_body) |
| 698 { | 714 { |
| 699 g_string_append_len(str, body, body_len); | 715 g_string_append_len(str, body, body_len); |
