soc.2010.msn-tlc: 2f8e4a25: Use p2p functions in directconn too.
masca at cpw.pidgin.im
masca at cpw.pidgin.im
Fri Jun 4 21:35:38 EDT 2010
-----------------------------------------------------------------
Revision: 2f8e4a25bf8df945806e65e13670d90305bde2d5
Ancestor: 391b9f6de2ac1a4197d7ce448dfa807a739641a1
Author: masca at cpw.pidgin.im
Date: 2010-06-05T01:27:07
Branch: im.pidgin.soc.2010.msn-tlc
URL: http://d.pidgin.im/viewmtn/revision/info/2f8e4a25bf8df945806e65e13670d90305bde2d5
Modified files:
libpurple/protocols/msn/directconn.c
ChangeLog:
Use p2p functions in directconn too.
-------------- next part --------------
============================================================
--- libpurple/protocols/msn/directconn.c 60f23f07985cc1fdb8e9cf34e5653582a69baadb
+++ libpurple/protocols/msn/directconn.c 797ab5df5ab7637632cc217273c6f28d1acaf201
@@ -338,51 +338,6 @@ static void
}
static void
-msn_dc_parse_binary_header(MsnDirectConn *dc)
-{
- MsnP2PHeader *h;
- MsnP2PHeader *context;
-
- g_return_if_fail(dc != NULL);
-
- h = &dc->header;
- /* Skip packet size */
- context = (MsnP2PHeader *)(dc->in_buffer + 4);
-
- h->session_id = GUINT32_FROM_LE(context->session_id);
- h->id = GUINT32_FROM_LE(context->id);
- h->offset = GUINT64_FROM_LE(context->offset);
- h->total_size = GUINT64_FROM_LE(context->total_size);
- h->length = GUINT32_FROM_LE(context->length);
- h->flags = GUINT32_FROM_LE(context->flags);
- h->ack_id = GUINT32_FROM_LE(context->ack_id);
- h->ack_sub_id = GUINT32_FROM_LE(context->ack_sub_id);
- h->ack_size = GUINT64_FROM_LE(context->ack_size);
-}
-
-static const gchar *
-msn_dc_serialize_binary_header(MsnDirectConn *dc) {
- MsnP2PHeader *h;
- static MsnP2PHeader bin_header;
-
- g_return_val_if_fail(dc != NULL, NULL);
-
- h = &dc->header;
-
- bin_header.session_id = GUINT32_TO_LE(h->session_id);
- bin_header.id = GUINT32_TO_LE(h->id);
- bin_header.offset = GUINT64_TO_LE(h->offset);
- bin_header.total_size = GUINT64_TO_LE(h->total_size);
- bin_header.length = GUINT32_TO_LE(h->length);
- bin_header.flags = GUINT32_TO_LE(h->flags);
- bin_header.ack_id = GUINT32_TO_LE(h->ack_id);
- bin_header.ack_sub_id = GUINT32_TO_LE(h->ack_sub_id);
- bin_header.ack_size = GUINT64_TO_LE(h->ack_size);
-
- return (const gchar *)&bin_header;
-}
-
-static void
msn_dc_send_cb(gpointer data, gint fd, PurpleInputCondition cond)
{
MsnDirectConn *dc = data;
@@ -477,7 +432,8 @@ msn_dc_send_handshake_with_nonce(MsnDire
{
const gchar *h;
- h = msn_dc_serialize_binary_header(dc);
+ h = (gchar*) msn_p2p_header_to_wire(&dc->header);
+
memcpy(p->data, h, P2P_PACKET_HEADER_SIZE);
memcpy(p->data + offsetof(MsnP2PHeader, ack_id), dc->nonce, 16);
@@ -702,7 +658,15 @@ msn_dc_recv_cb(gpointer data, gint fd, P
return;
if (dc->state != DC_STATE_FOO) {
- msn_dc_parse_binary_header(dc);
+ MsnP2PHeader *context;
+ MsnP2PHeader *h;
+
+ /* Skip packet size */
+ context = (MsnP2PHeader *)(dc->in_buffer + 4);
+
+ h = msn_p2p_header_from_wire(context);
+ memcpy(&dc->header, h, P2P_PACKET_HEADER_SIZE);
+ g_free(h);
}
switch (msn_dc_process_packet(dc, packet_length)) {
More information about the Commits
mailing list