Mercurial > pidgin
changeset 31040:1029e81fe8e5
merge of '0c09db333f3ff80093510065d37e0e275499b9f1'
and '2b77d04bbc598fa43216d1cfbc953a5891d1eda1'
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Thu, 16 Dec 2010 07:20:13 +0000 |
parents | 7d980d6b40e1 (diff) 36855fcbd278 (current diff) |
children | e358c09cd765 |
files | |
diffstat | 19 files changed, 40 insertions(+), 178 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/msn/cmdproc.c Thu Dec 16 06:13:54 2010 +0000 +++ b/libpurple/protocols/msn/cmdproc.c Thu Dec 16 07:20:13 2010 +0000 @@ -58,7 +58,7 @@ msn_history_destroy(cmdproc->history); if (cmdproc->last_cmd != NULL) - msn_command_destroy(cmdproc->last_cmd); + msn_command_unref(cmdproc->last_cmd); g_hash_table_destroy(cmdproc->multiparts); @@ -329,7 +329,7 @@ show_debug_cmd(cmdproc, TRUE, command); if (cmdproc->last_cmd != NULL) - msn_command_destroy(cmdproc->last_cmd); + msn_command_unref(cmdproc->last_cmd); cmdproc->last_cmd = msn_command_from_string(command);
--- a/libpurple/protocols/msn/command.c Thu Dec 16 06:13:54 2010 +0000 +++ b/libpurple/protocols/msn/command.c Thu Dec 16 07:20:13 2010 +0000 @@ -79,20 +79,10 @@ return cmd; } -void +static void msn_command_destroy(MsnCommand *cmd) { - g_return_if_fail(cmd != NULL); - - if (cmd->ref_count > 0) - { - msn_command_unref(cmd); - return; - } - - if (cmd->payload != NULL) - g_free(cmd->payload); - + g_free(cmd->payload); g_free(cmd->command); g_strfreev(cmd->params); g_free(cmd); @@ -107,19 +97,17 @@ return cmd; } -MsnCommand * +void msn_command_unref(MsnCommand *cmd) { - g_return_val_if_fail(cmd != NULL, NULL); - g_return_val_if_fail(cmd->ref_count > 0, NULL); + g_return_if_fail(cmd != NULL); + g_return_if_fail(cmd->ref_count > 0); cmd->ref_count--; if (cmd->ref_count == 0) { msn_command_destroy(cmd); - return NULL; } +} - return cmd; -}
--- a/libpurple/protocols/msn/command.h Thu Dec 16 06:13:54 2010 +0000 +++ b/libpurple/protocols/msn/command.h Thu Dec 16 07:20:13 2010 +0000 @@ -43,7 +43,7 @@ char **params; int param_count; - int ref_count; + guint ref_count; MsnTransaction *trans; @@ -64,14 +64,6 @@ MsnCommand *msn_command_from_string(const char *string); /** - * Destroy a MsnCommand object if its ref count is zero, otherwise - * just unref it. - * - * @param cmd The MsnCommand to be destroyed. - */ -void msn_command_destroy(MsnCommand *cmd); - -/** * Increment the ref count. * * @param cmd The MsnCommand to be ref. @@ -85,8 +77,8 @@ * * @param cmd The MsnCommand to be unref. * - * @return The ref command. */ -MsnCommand *msn_command_unref(MsnCommand *cmd); +void msn_command_unref(MsnCommand *cmd); #endif /* MSN_COMMAND_H */ +
--- a/libpurple/protocols/msn/contact.c Thu Dec 16 06:13:54 2010 +0000 +++ b/libpurple/protocols/msn/contact.c Thu Dec 16 07:20:13 2010 +0000 @@ -1093,18 +1093,6 @@ gchar *body = NULL; gchar *contact_xml = NULL; -#if 0 - gchar *escaped_displayname; - - - if (displayname != NULL) { - escaped_displayname = g_markup_decode_text(displayname, -1); - } else { - escaped_displayname = passport; - } - contact_xml = g_strdup_printf(MSN_XML_ADD_CONTACT, escaped_displayname, passport); -#endif - purple_debug_info("msn", "Adding contact %s to contact list\n", passport); user = msn_userlist_find_user(session->userlist, passport);
--- a/libpurple/protocols/msn/contact.h Thu Dec 16 06:13:54 2010 +0000 +++ b/libpurple/protocols/msn/contact.h Thu Dec 16 07:20:13 2010 +0000 @@ -708,7 +708,6 @@ void msn_callback_state_set_action(MsnCallbackState *state, MsnCallbackAction action); -void msn_contact_connect(MsnSession *session); void msn_get_contact_list(MsnSession *session, const MsnSoapPartnerScenario partner_scenario, const char *update);
--- a/libpurple/protocols/msn/directconn.c Thu Dec 16 06:13:54 2010 +0000 +++ b/libpurple/protocols/msn/directconn.c Thu Dec 16 07:20:13 2010 +0000 @@ -111,10 +111,6 @@ { g_free(p->data); -#if 0 - if (p->msg) - msn_message_unref(p->msg); -#endif if (p->part) msn_slpmsgpart_unref(p->part); @@ -543,33 +539,6 @@ p->part->ack_cb(p->part, p->part->ack_data); } -#if 0 -static void -msn_dc_send_packet_cb(MsnDirectConnPacket *p) -{ - if (p->msg != NULL && p->msg->ack_cb != NULL) - p->msg->ack_cb(p->msg, p->msg->ack_data); -} - -void -msn_dc_enqueue_msg(MsnDirectConn *dc, MsnMessage *msg) -{ - MsnDirectConnPacket *p; - guint32 length; - - length = msg->body_len + P2P_PACKET_HEADER_SIZE; - p = msn_dc_new_packet(length); - - memcpy(p->data, msg->slpmsg->header, P2P_PACKET_HEADER_SIZE); - memcpy(p->data + P2P_PACKET_HEADER_SIZE, msg->body, msg->body_len); - - p->sent_cb = msn_dc_send_packet_cb; - p->msg = msn_message_ref(msg); - - msn_dc_enqueue_packet(dc, p); -} -#endif - void msn_dc_enqueue_part(MsnDirectConn *dc, MsnSlpMessagePart *part) { @@ -583,7 +552,7 @@ memcpy(p->data + P2P_PACKET_HEADER_SIZE, part->buffer, part->size); p->sent_cb = msn_dc_send_packet_cb; - p->part = part; + p->part = msn_slpmsgpart_ref(part); msn_dc_enqueue_packet(dc, p); } @@ -633,7 +602,7 @@ if (dc->header.length) { part = msn_slpmsgpart_new_from_data(dc->in_buffer + 4, dc->header.length); msn_slplink_process_msg(dc->slplink, part); - msn_slpmsgpart_destroy(part); + msn_slpmsgpart_unref(part); } /*
--- a/libpurple/protocols/msn/directconn.h Thu Dec 16 06:13:54 2010 +0000 +++ b/libpurple/protocols/msn/directconn.h Thu Dec 16 07:20:13 2010 +0000 @@ -127,10 +127,6 @@ /* * Queues an MSN message to be sent via direct connection. */ -#if 0 -void -msn_dc_enqueue_msg(MsnDirectConn *dc, MsnMessage *msg); -#endif void msn_dc_enqueue_part(MsnDirectConn *dc, MsnSlpMessagePart *part);
--- a/libpurple/protocols/msn/msg.c Thu Dec 16 06:13:54 2010 +0000 +++ b/libpurple/protocols/msn/msg.c Thu Dec 16 07:20:13 2010 +0000 @@ -70,7 +70,8 @@ g_hash_table_destroy(msg->header_table); g_list_free(msg->header_list); - msn_slpmsgpart_destroy(msg->part); + if (msg->part) + msn_slpmsgpart_unref(msg->part); g_free(msg); } @@ -83,7 +84,7 @@ msg->ref_count++; if (purple_debug_is_verbose()) - purple_debug_info("msn", "message ref (%p)[%" G_GSIZE_FORMAT "]\n", msg, msg->ref_count); + purple_debug_info("msn", "message ref (%p)[%u]\n", msg, msg->ref_count); return msg; } @@ -97,7 +98,7 @@ msg->ref_count--; if (purple_debug_is_verbose()) - purple_debug_info("msn", "message unref (%p)[%" G_GSIZE_FORMAT "]\n", msg, msg->ref_count); + purple_debug_info("msn", "message unref (%p)[%u]\n", msg, msg->ref_count); if (msg->ref_count == 0) msn_message_destroy(msg); @@ -293,15 +294,6 @@ } char * -msn_message_gen_slp_body(MsnMessage *msg, size_t *ret_size) -{ - char *tmp; - - tmp = msn_slpmsgpart_serialize(msg->part, ret_size); - return tmp; -} - -char * msn_message_gen_payload(MsnMessage *msg, size_t *ret_size) { GList *l; @@ -648,7 +640,7 @@ int i; int bin_len; - if (msg->part->footer->value == P2P_APPID_SESION) + if (msg->part->footer->value == P2P_APPID_SESSION) bin_len = P2P_PACKET_HEADER_SIZE; else bin_len = body_len;
--- a/libpurple/protocols/msn/msg.h Thu Dec 16 06:13:54 2010 +0000 +++ b/libpurple/protocols/msn/msg.h Thu Dec 16 07:20:13 2010 +0000 @@ -74,7 +74,7 @@ */ struct _MsnMessage { - size_t ref_count; /**< The reference count. */ + guint ref_count; /**< The reference count. */ MsnMsgType type; @@ -89,8 +89,8 @@ char *charset; char *body; gsize body_len; - guint total_chunks; /**< How many chunks in this multi-part message */ - guint received_chunks; /**< How many chunks we've received so far */ + guint total_chunks; /**< How many chunks in this multi-part message */ + guint received_chunks; /**< How many chunks we've received so far */ GHashTable *header_table; GList *header_list; @@ -302,8 +302,6 @@ void msn_message_show_readable(MsnMessage *msg, const char *info, gboolean text_body); -char *msn_message_gen_slp_body(MsnMessage *msg, size_t *ret_size); - char *msn_message_to_string(MsnMessage *msg); void msn_plain_msg(MsnCmdProc *cmdproc, MsnMessage *msg);
--- a/libpurple/protocols/msn/notification.c Thu Dec 16 06:13:54 2010 +0000 +++ b/libpurple/protocols/msn/notification.c Thu Dec 16 07:20:13 2010 +0000 @@ -1990,9 +1990,6 @@ /* always get the full list? */ msn_get_contact_list(session, MSN_PS_INITIAL, NULL); #endif -#if 0 - msn_contact_connect(session); -#endif } static void
--- a/libpurple/protocols/msn/oim.c Thu Dec 16 06:13:54 2010 +0000 +++ b/libpurple/protocols/msn/oim.c Thu Dec 16 07:20:13 2010 +0000 @@ -166,14 +166,10 @@ xmlnode *fault = NULL; xmlnode *faultcode = NULL; - if (response == NULL) - return; + if (response != NULL) + fault = xmlnode_get_child(response->xml, "Body/Fault"); - fault = xmlnode_get_child(response->xml, "Body/Fault"); - if (fault) - faultcode = xmlnode_get_child(fault, "faultcode"); - - if (faultcode) { + if (fault && (faultcode = xmlnode_get_child(fault, "faultcode"))) { gchar *faultcode_str = xmlnode_get_data(faultcode); gboolean need_token_update = FALSE;
--- a/libpurple/protocols/msn/p2p.h Thu Dec 16 06:13:54 2010 +0000 +++ b/libpurple/protocols/msn/p2p.h Thu Dec 16 07:20:13 2010 +0000 @@ -84,7 +84,7 @@ typedef enum { - P2P_APPID_SESION = 0x0, /**< Negotiating session */ + P2P_APPID_SESSION = 0x0, /**< Negotiating session */ P2P_APPID_OBJ = 0x1, /**< MsnObject (Display or Emoticon) */ P2P_APPID_FILE = 0x2, /**< File transfer */ P2P_APPID_EMOTE = 0xB, /**< CustomEmoticon */
--- a/libpurple/protocols/msn/slplink.c Thu Dec 16 06:13:54 2010 +0000 +++ b/libpurple/protocols/msn/slplink.c Thu Dec 16 07:20:13 2010 +0000 @@ -49,7 +49,7 @@ dir = send ? "send" : "recv"; c = send ? m_sc++ : m_rc++; - tmp = g_strdup_printf("%s/msntest/%s/%03d", g_get_home_dir(), dir, c); + tmp = g_strdup_printf("%s/msntest/%s/%03d", purple_user_dir(), dir, c); data = msn_slpmsg_serialize(msg, &data_size); if (!purple_util_write_data_to_file_absolute(tmp, data, data_size)) { @@ -96,18 +96,11 @@ if (purple_debug_is_verbose()) purple_debug_info("msn", "slplink_destroy: slplink(%p)\n", slplink); - g_return_if_fail(slplink != NULL); - if (slplink->swboard != NULL) { slplink->swboard->slplinks = g_list_remove(slplink->swboard->slplinks, slplink); slplink->swboard = NULL; } - if (slplink->refs > 1) { - slplink->refs--; - return; - } - session = slplink->session; if (slplink->dc != NULL) {
--- a/libpurple/protocols/msn/slplink.h Thu Dec 16 06:13:54 2010 +0000 +++ b/libpurple/protocols/msn/slplink.h Thu Dec 16 07:20:13 2010 +0000 @@ -42,7 +42,7 @@ MsnSwitchBoard *swboard; MsnDirectConn *dc; - int refs; + guint refs; char *remote_user;
--- a/libpurple/protocols/msn/slpmsg.c Thu Dec 16 06:13:54 2010 +0000 +++ b/libpurple/protocols/msn/slpmsg.c Thu Dec 16 07:20:13 2010 +0000 @@ -85,7 +85,7 @@ part->ack_cb = NULL; part->nak_cb = NULL; part->ack_data = NULL; - msn_slpmsgpart_destroy(part); + msn_slpmsgpart_unref(part); } slplink->slp_msgs = g_list_remove(slplink->slp_msgs, slpmsg);
--- a/libpurple/protocols/msn/slpmsg_part.c Thu Dec 16 06:13:54 2010 +0000 +++ b/libpurple/protocols/msn/slpmsg_part.c Thu Dec 16 07:20:13 2010 +0000 @@ -81,17 +81,8 @@ return part; } -void msn_slpmsgpart_destroy(MsnSlpMessagePart *part) +static void msn_slpmsgpart_destroy(MsnSlpMessagePart *part) { - if (!part) - return; - - if (part->ref_count > 0) { - msn_slpmsgpart_unref(part); - - return; - } - g_free(part->header); g_free(part->footer); @@ -102,31 +93,27 @@ MsnSlpMessagePart *msn_slpmsgpart_ref(MsnSlpMessagePart *part) { g_return_val_if_fail(part != NULL, NULL); - part->ref_count ++; + part->ref_count++; if (purple_debug_is_verbose()) - purple_debug_info("msn", "part ref (%p)[%d]\n", part, part->ref_count); + purple_debug_info("msn", "part ref (%p)[%u]\n", part, part->ref_count); return part; } -MsnSlpMessagePart *msn_slpmsgpart_unref(MsnSlpMessagePart *part) +void msn_slpmsgpart_unref(MsnSlpMessagePart *part) { - g_return_val_if_fail(part != NULL, NULL); - g_return_val_if_fail(part->ref_count > 0, NULL); + g_return_if_fail(part != NULL); + g_return_if_fail(part->ref_count > 0); part->ref_count--; if (purple_debug_is_verbose()) - purple_debug_info("msn", "part unref (%p)[%d]\n", part, part->ref_count); + purple_debug_info("msn", "part unref (%p)[%u]\n", part, part->ref_count); if (part->ref_count == 0) { msn_slpmsgpart_destroy(part); - - return NULL; } - - return part; } void msn_slpmsgpart_set_bin_data(MsnSlpMessagePart *part, const void *data, size_t len) @@ -196,6 +183,7 @@ slpmsg->header->offset += part->header->length; slpmsg->parts = g_list_remove(slpmsg->parts, part); + msn_slpmsgpart_unref(part); if (slpmsg->header->offset < real_size) { @@ -233,4 +221,6 @@ msn_slplink_send_msgpart(slpmsg->slplink, slpmsg); slpmsg->parts = g_list_remove(slpmsg->parts, part); + msn_slpmsgpart_unref(part); } +
--- a/libpurple/protocols/msn/slpmsg_part.h Thu Dec 16 06:13:54 2010 +0000 +++ b/libpurple/protocols/msn/slpmsg_part.h Thu Dec 16 07:20:13 2010 +0000 @@ -32,7 +32,7 @@ struct _MsnSlpMessagePart { - int ref_count; + guint ref_count; MsnP2PHeader *header; MsnP2PFooter *footer; @@ -49,11 +49,9 @@ MsnSlpMessagePart *msn_slpmsgpart_new_from_data(const char *data, size_t data_len); -void msn_slpmsgpart_destroy(MsnSlpMessagePart *part); - MsnSlpMessagePart *msn_slpmsgpart_ref(MsnSlpMessagePart *part); -MsnSlpMessagePart *msn_slpmsgpart_unref(MsnSlpMessagePart *part); +void msn_slpmsgpart_unref(MsnSlpMessagePart *part); void msn_slpmsgpart_set_bin_data(MsnSlpMessagePart *part, const void *data, size_t len);
--- a/libpurple/protocols/msn/switchboard.c Thu Dec 16 06:13:54 2010 +0000 +++ b/libpurple/protocols/msn/switchboard.c Thu Dec 16 07:20:13 2010 +0000 @@ -577,33 +577,6 @@ msg_error_helper(cmdproc, trans->data, MSN_MSG_ERROR_UNKNOWN); } -#if 0 -/** Called when we receive an ack of a special message. */ -static void -msg_ack(MsnCmdProc *cmdproc, MsnCommand *cmd) -{ - MsnMessage *msg; - - msg = cmd->trans->data; - - if (msg->ack_cb != NULL) - msg->ack_cb(msg->ack_data); - - msn_message_unref(msg); -} - -/** Called when we receive a nak of a special message. */ -static void -msg_nak(MsnCmdProc *cmdproc, MsnCommand *cmd) -{ - MsnMessage *msg; - - msg = cmd->trans->data; - - msn_message_unref(msg); -} -#endif - gboolean msn_switchboard_can_send(MsnSwitchBoard *swboard) {
--- a/libpurple/protocols/msn/user.c Thu Dec 16 06:13:54 2010 +0000 +++ b/libpurple/protocols/msn/user.c Thu Dec 16 07:20:13 2010 +0000 @@ -57,13 +57,6 @@ static void msn_user_destroy(MsnUser *user) { - g_return_if_fail(user != NULL); - - if (user->refcount > 1) { - msn_user_unref(user); - return; - } - while (user->endpoints != NULL) { free_user_endpoint(user->endpoints->data); user->endpoints = g_slist_delete_link(user->endpoints, user->endpoints);