diff libpurple/protocols/yahoo/util.c @ 22018:118046227581

This patch from Thanumalayan S. implements Yahoo protocol version 15 file transfer support. Currently sending multiple files from an official Yahoo client is treated as multiple individual transfers that must be accepted separately. This also changes things so that we identify as Yahoo Messenger version 8.0 (previously we were identifying as 6.0 or not at all). committer: John Bailey <rekkanoryo@rekkanoryo.org>
author Thanumalayan <madthanu@gmail.com>
date Sun, 06 Jan 2008 19:45:03 +0000
parents 543306932d15
children 4ab154a14e55
line wrap: on
line diff
--- a/libpurple/protocols/yahoo/util.c	Sun Jan 06 19:28:49 2008 +0000
+++ b/libpurple/protocols/yahoo/util.c	Sun Jan 06 19:45:03 2008 +0000
@@ -31,6 +31,70 @@
 #include "yahoo.h"
 
 #include <string.h>
+/*
+ * Returns cookies formatted as a null terminated string for the given connection.
+ * Must g_free return value.
+ * 
+ * TODO:will work, but must test for strict correctness
+ */
+gchar* yahoo_get_cookies(PurpleConnection *gc)
+{
+	gchar *ans = NULL;
+	gchar *cur;
+	char firstflag = 1;
+	gchar *t1,*t2,*t3;
+	GSList *tmp;
+	GSList *cookies;
+	cookies = ((struct yahoo_data*)(gc->proto_data))->cookies;
+	tmp = cookies;
+	while(tmp)
+	{
+		cur = tmp->data;
+		t1 = ans;
+		t2 = g_strrstr(cur, ";expires=");
+		if(t2 == NULL)
+			t2 = g_strrstr(cur, "; expires=");
+		if(t2 == NULL)
+		{
+			if(firstflag)
+				ans = g_strdup_printf("%c=%s", cur[0], cur+2);
+			else
+				ans = g_strdup_printf("%s; %c=%s", t1, cur[0], cur+2);
+		}
+		else
+		{
+			t3 = strstr(t2+1, ";");
+			if(t3 != NULL)
+			{
+				t2[0] = '\0';
+
+				if(firstflag)
+					ans = g_strdup_printf("%c=%s%s", cur[0], cur+2, t3);
+				else
+					ans = g_strdup_printf("%s; %c=%s%s", t1, cur[0], cur+2, t3);
+
+				t2[0] = ';';
+			}
+			else
+			{
+				t2[0] = '\0';
+
+				if(firstflag)
+					ans = g_strdup_printf("%c=%s", cur[0], cur+2);
+				else
+					ans = g_strdup_printf("%s; %c=%s", t1, cur[0], cur+2);
+
+				t2[0] = ';';
+			}
+		}
+		if(firstflag)
+			firstflag = 0;
+		else
+			g_free(t1);
+		tmp = g_slist_next(tmp);
+	}
+	return ans;
+}
 
 /**
  * Encode some text to send to the yahoo server.