pidgin: 360d1dbc: Try and reduce some code duplication.

qulogic at pidgin.im qulogic at pidgin.im
Fri May 21 18:03:04 EDT 2010


-----------------------------------------------------------------
Revision: 360d1dbc4ebd3fa3d39f0ac5674cfe72076b45d9
Ancestor: 8ae64977f9f373b826ea4c74134742ade5fac8a4
Author: qulogic at pidgin.im
Date: 2010-05-05T07:29:24
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/360d1dbc4ebd3fa3d39f0ac5674cfe72076b45d9

Modified files:
        libpurple/protocols/msn/directconn.c

ChangeLog: 

Try and reduce some code duplication.

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/directconn.c	b36736e9e052e5baea1f0274133703968267c4a7
+++ libpurple/protocols/msn/directconn.c	dc63df3cb37477192eea7d01161bca67f576c2e8
@@ -610,10 +610,22 @@ static void
 }
 
 static void
+msn_dc_send_handshake_with_nonce(MsnDirectConn *dc, MsnDirectConnPacket *p)
+{
+	const gchar *h;
+
+	h = msn_dc_serialize_binary_header(dc);
+	memcpy(p->data, h, DC_PACKET_HEADER_SIZE);
+
+	memcpy(p->data + offsetof(MsnDcContext, ack_id), dc->nonce, 16);
+
+	msn_dc_enqueue_packet(dc, p);
+}
+
+static void
 msn_dc_send_handshake(MsnDirectConn *dc)
 {
 	MsnDirectConnPacket *p;
-	const gchar *h;
 
 	p = msn_dc_new_packet(DC_PACKET_HEADER_SIZE);
 
@@ -624,29 +636,20 @@ msn_dc_send_handshake(MsnDirectConn *dc)
 	dc->header.length = 0;
 	dc->header.flags = 0x100;
 
-	h = msn_dc_serialize_binary_header(dc);
-	memcpy(p->data, h, DC_PACKET_HEADER_SIZE);
-	memcpy(p->data + offsetof(MsnDcContext, ack_id), dc->nonce, 16);
-
-	msn_dc_enqueue_packet(dc, p);
+	msn_dc_send_handshake_with_nonce(dc, p);
 }
 
 static void
 msn_dc_send_handshake_reply(MsnDirectConn *dc)
 {
 	MsnDirectConnPacket *p;
-	const gchar *h;
 
 	p = msn_dc_new_packet(DC_PACKET_HEADER_SIZE);
 
 	dc->header.id = dc->slpcall->slplink->slp_seq_id++;
 	dc->header.length = 0;
 
-	h = msn_dc_serialize_binary_header(dc);
-	memcpy(p->data, h, DC_PACKET_HEADER_SIZE);
-	memcpy(p->data + offsetof(MsnDcContext, ack_id), dc->nonce, 16);
-
-	msn_dc_enqueue_packet(dc, p);
+	msn_dc_send_handshake_with_nonce(dc, p);
 }
 
 static gboolean


More information about the Commits mailing list