changeset 30048:b491612862dc

Try and reduce some code duplication.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Wed, 05 May 2010 07:29:24 +0000
parents 6936ffd13cb9
children b0a7b31dcc5d
files libpurple/protocols/msn/directconn.c
diffstat 1 files changed, 15 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/directconn.c	Wed May 05 07:26:57 2010 +0000
+++ b/libpurple/protocols/msn/directconn.c	Wed May 05 07:29:24 2010 +0000
@@ -610,10 +610,22 @@
 }
 
 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 @@
 	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