diff src/protocols/msn/slplink.c @ 10225:ecf3ce2e2ab1

[gaim-migrate @ 11357] This is mostly a patch from Felipe Contreras that eliminates MSN switchboard errors and fixes MSN buddy icon syncronization, with some tweaks by me. Thank Felipe if it works, blame me if something broke. I also fixed a couple of text markup escaping things, fixed a glib warning that was bugging me, fix a rare SILC crash, and make gtkstatusselector.c compile (but do nothing) with gtk < 2.4 committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Sun, 21 Nov 2004 17:48:09 +0000
parents 65e7df286076
children f776e117c17b
line wrap: on
line diff
--- a/src/protocols/msn/slplink.c	Sun Nov 21 06:16:23 2004 +0000
+++ b/src/protocols/msn/slplink.c	Sun Nov 21 17:48:09 2004 +0000
@@ -100,11 +100,12 @@
 MsnSlpLink *
 msn_session_find_slplink(MsnSession *session, const char *who)
 {
-	MsnSlpLink *slplink;
 	GList *l;
 
 	for (l = session->slplinks; l != NULL; l = l->next)
 	{
+		MsnSlpLink *slplink;
+
 		slplink = l->data;
 
 		if (!strcmp(slplink->remote_user, who))
@@ -192,7 +193,8 @@
 	{
 		MsnSwitchBoard *swboard;
 
-		swboard = msn_session_get_swboard(slplink->session, slplink->remote_user);
+		swboard = msn_session_get_swboard(slplink->session,
+										  slplink->remote_user);
 
 		if (swboard == NULL)
 			return;
@@ -209,13 +211,14 @@
 	}
 }
 
+/* We have received the message receive ack */
 static void
-t_ack(MsnCmdProc *cmdproc, MsnCommand *cmd)
+msg_ack(void *data)
 {
 	MsnSlpMessage *slpmsg;
 	long long real_size;
 
-	slpmsg = cmd->trans->data;
+	slpmsg = data;
 
 	real_size = (slpmsg->flags == 0x2) ? 0 : slpmsg->size;
 
@@ -283,10 +286,16 @@
 
 	msn_slplink_send_msg(slplink, msg);
 
-	if (slpmsg->flags == 0x20 || slpmsg->flags == 0x1000030)
+	if ((slpmsg->flags == 0x20 || slpmsg->flags == 0x1000030) && (slpmsg->slpcall != NULL))
 	{
-		if ((slpmsg->slpcall != NULL) &&
-			(slpmsg->slpcall->progress_cb != NULL))
+		if (slpmsg->slpcall->timer)
+		{
+			gaim_timeout_remove(slpmsg->slpcall->timer);
+			slpmsg->slpcall->timer = gaim_timeout_add(MSN_SLPCALL_TIMEOUT,
+													  msn_slp_call_timeout, slpmsg->slpcall);
+		}
+
+		if (slpmsg->slpcall->progress_cb != NULL)
 		{
 			slpmsg->slpcall->progress_cb(slpmsg->slpcall, slpmsg->size,
 										 len, slpmsg->offset);
@@ -338,7 +347,7 @@
 
 	msn_message_set_attr(msg, "P2P-Dest", slplink->remote_user);
 
-	msg->ack_cb = t_ack;
+	msg->ack_cb = msg_ack;
 	msg->ack_data = slpmsg;
 
 	msn_slplink_send_msgpart(slplink, slpmsg);
@@ -473,7 +482,7 @@
 				}
 			}
 		}
-		if (!slpmsg->fp)
+		if (!slpmsg->fp && slpmsg->size)
 		{
 			slpmsg->buffer = g_try_malloc(slpmsg->size);
 			if (slpmsg->buffer == NULL)
@@ -495,7 +504,7 @@
 			/* fseek(slpmsg->fp, offset, SEEK_SET); */
 			len = fwrite(data, 1, len, slpmsg->fp);
 		}
-		else
+		else if (slpmsg->size)
 		{
 			if ((offset + len) > slpmsg->size)
 			{
@@ -512,10 +521,16 @@
 		g_return_if_reached();
 	}
 
-	if (slpmsg->flags == 0x20 || slpmsg->flags == 0x1000030)
+	if ((slpmsg->flags == 0x20 || slpmsg->flags == 0x1000030) && (slpmsg->slpcall != NULL))
 	{
-		if ((slpmsg->slpcall != NULL) &&
-			(slpmsg->slpcall->progress_cb != NULL))
+		if (slpmsg->slpcall->timer)
+		{
+			gaim_timeout_remove(slpmsg->slpcall->timer);
+			slpmsg->slpcall->timer = gaim_timeout_add(MSN_SLPCALL_TIMEOUT,
+													  msn_slp_call_timeout, slpmsg->slpcall);
+		}
+
+		if (slpmsg->slpcall->progress_cb != NULL)
 		{
 			slpmsg->slpcall->progress_cb(slpmsg->slpcall, slpmsg->size,
 										 len, offset);
@@ -623,7 +638,7 @@
 	header.file_size = GUINT32_TO_LE(size);
 	header.unk2 = GUINT32_TO_LE(0);
 	header.unk3 = GUINT32_TO_LE(0);
-	
+
 	base = g_malloc(len + 1);
 	n = base;
 
@@ -638,7 +653,7 @@
 
 	memset(n, 0xFF, 4);
 	n += 4;
-	
+
 	g_free(uni);
 	return gaim_base64_encode(base, len);
 }
@@ -682,6 +697,7 @@
 msn_slplink_request_object(MsnSlpLink *slplink,
 						   const char *info,
 						   MsnSlpCb cb,
+						   MsnSlpEndCb end_cb,
 						   const MsnObject *obj)
 {
 	MsnSlpCall *slpcall;
@@ -700,6 +716,7 @@
 
 	slpcall->data_info = g_strdup(info);
 	slpcall->cb = cb;
+	slpcall->end_cb = end_cb;
 
 	msn_slp_call_invite(slpcall, "A4268EEC-FEC5-49E5-95C3-F126696BDBF6", 1,
 						msnobj_base64);