changeset 27506:74e487f82f39

Oh, we don't need a special ui_info field for the AIM clientstring because we can just concat the name and version. And set the distids for libpurple, Pidgin and Finch AOL would like Adium to use 1551 (0x060f)
author Mark Doliner <mark@kingant.net>
date Wed, 08 Jul 2009 20:44:16 +0000
parents 5048054d319a
children 1c61906755fe
files finch/finch.c libpurple/protocols/oscar/family_auth.c libpurple/protocols/oscar/flap_connection.c libpurple/protocols/oscar/oscar.h libpurple/protocols/oscar/util.c pidgin/gtkmain.c
diffstat 6 files changed, 53 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/finch/finch.c	Wed Jul 08 20:11:07 2009 +0000
+++ b/finch/finch.c	Wed Jul 08 20:44:16 2009 +0000
@@ -77,6 +77,14 @@
 		 */
 		g_hash_table_insert(ui_info, "prpl-aim-clientkey", "ma19sqWV9ymU6UYc");
 		g_hash_table_insert(ui_info, "prpl-icq-clientkey", "ma19sqWV9ymU6UYc");
+
+		/*
+		 * This is the distid for Finch, given to us by AOL.  Please
+		 * don't use this for other applications.  You can just not
+		 * specify a distid and libpurple will use a default.
+		 */
+		g_hash_table_insert(ui_info, "prpl-aim-distid", GINT_TO_POINTER(1552));
+		g_hash_table_insert(ui_info, "prpl-icq-distid", GINT_TO_POINTER(1552));
 	}
 
 	return ui_info;
--- a/libpurple/protocols/oscar/family_auth.c	Wed Jul 08 20:11:07 2009 +0000
+++ b/libpurple/protocols/oscar/family_auth.c	Wed Jul 08 20:44:16 2009 +0000
@@ -129,7 +129,6 @@
 	GSList *tlvlist = NULL;
 	int passwdlen;
 	guint8 *password_encoded;
-	const char *clientstring;
 	guint32 distrib;
 
 	passwdlen = strlen(password);
@@ -141,9 +140,6 @@
 
 	aim_encode_password(password, password_encoded);
 
-	clientstring = oscar_get_ui_info_string(
-			od->icq ? "prpl-icq-clientstring" : "prpl-aim-clientstring",
-			ci->clientstring);
 	distrib = oscar_get_ui_info_int(
 			od->icq ? "prpl-icq-distid" : "prpl-aim-distid",
 			ci->distrib);
@@ -152,8 +148,13 @@
 	aim_tlvlist_add_str(&tlvlist, 0x0001, sn);
 	aim_tlvlist_add_raw(&tlvlist, 0x0002, passwdlen, password_encoded);
 
-	if (clientstring)
+	if (ci->clientstring != NULL)
+		aim_tlvlist_add_str(&tlvlist, 0x0003, ci->clientstring);
+	else {
+		gchar *clientstring = oscar_get_clientstring();
 		aim_tlvlist_add_str(&tlvlist, 0x0003, clientstring);
+		g_free(clientstring);
+	}
 	aim_tlvlist_add_16(&tlvlist, 0x0016, (guint16)ci->clientid);
 	aim_tlvlist_add_16(&tlvlist, 0x0017, (guint16)ci->major);
 	aim_tlvlist_add_16(&tlvlist, 0x0018, (guint16)ci->minor);
@@ -219,7 +220,6 @@
 	guint8 digest[16];
 	aim_snacid_t snacid;
 	size_t password_len;
-	const char *clientstring;
 	guint32 distrib;
 
 	if (!ci || !sn || !password)
@@ -247,9 +247,6 @@
 
 	aim_encode_password_md5(password, password_len, key, digest);
 
-	clientstring = oscar_get_ui_info_string(
-			od->icq ? "prpl-icq-clientstring" : "prpl-aim-clientstring",
-			ci->clientstring);
 	distrib = oscar_get_ui_info_int(
 			od->icq ? "prpl-icq-distid" : "prpl-aim-distid",
 			ci->distrib);
@@ -260,8 +257,13 @@
 	aim_tlvlist_add_noval(&tlvlist, 0x004c);
 #endif
 
-	if (clientstring)
+	if (ci->clientstring != NULL)
+		aim_tlvlist_add_str(&tlvlist, 0x0003, ci->clientstring);
+	else {
+		gchar *clientstring = oscar_get_clientstring();
 		aim_tlvlist_add_str(&tlvlist, 0x0003, clientstring);
+		g_free(clientstring);
+	}
 	aim_tlvlist_add_16(&tlvlist, 0x0016, (guint16)ci->clientid);
 	aim_tlvlist_add_16(&tlvlist, 0x0017, (guint16)ci->major);
 	aim_tlvlist_add_16(&tlvlist, 0x0018, (guint16)ci->minor);
--- a/libpurple/protocols/oscar/flap_connection.c	Wed Jul 08 20:11:07 2009 +0000
+++ b/libpurple/protocols/oscar/flap_connection.c	Wed Jul 08 20:44:16 2009 +0000
@@ -77,19 +77,19 @@
 {
 	FlapFrame *frame;
 	GSList *tlvlist = NULL;
-	const char *clientstring;
 
 	frame = flap_frame_new(od, 0x01, 1152 + length);
 
 	byte_stream_put32(&frame->data, 0x00000001); /* FLAP Version */
 	aim_tlvlist_add_raw(&tlvlist, 0x0006, length, chipsahoy);
 
-	clientstring = oscar_get_ui_info_string(
-			od->icq ? "prpl-icq-clientstring" : "prpl-aim-clientstring",
-			ci->clientstring);
-
-	if (clientstring != NULL)
+	if (ci->clientstring != NULL)
+		aim_tlvlist_add_str(&tlvlist, 0x0003, ci->clientstring);
+	else {
+		gchar *clientstring = oscar_get_clientstring();
 		aim_tlvlist_add_str(&tlvlist, 0x0003, clientstring);
+		g_free(clientstring);
+	}
 	aim_tlvlist_add_16(&tlvlist, 0x0017, (guint16)ci->major);
 	aim_tlvlist_add_16(&tlvlist, 0x0018, (guint16)ci->minor);
 	aim_tlvlist_add_16(&tlvlist, 0x0019, (guint16)ci->point);
--- a/libpurple/protocols/oscar/oscar.h	Wed Jul 08 20:11:07 2009 +0000
+++ b/libpurple/protocols/oscar/oscar.h	Wed Jul 08 20:44:16 2009 +0000
@@ -307,23 +307,25 @@
 /*
  * We need to use the major-minor-micro versions from the official
  * AIM and ICQ programs here or AOL won't let us use certain features.
+ *
+ * 0x00000611 is the distid given to us by AOL for use as the default
+ * libpurple distid.
  */
-
 #define CLIENTINFO_PURPLE_AIM { \
-	"Purple/" VERSION, \
+	NULL, \
 	0x0109, \
 	0x0005, 0x0001, \
 	0x0000, 0x0bdc, \
-	0x000000d2, \
+	0x00000611, \
 	"us", "en", \
 }
 
 #define CLIENTINFO_PURPLE_ICQ { \
-	"Purple/" VERSION, \
+	NULL, \
 	0x010a, \
 	0x0014, 0x0034, \
 	0x0000, 0x0c18, \
-	0x0000043d, \
+	0x00000611, \
 	"us", "en", \
 }
 
@@ -1529,6 +1531,7 @@
 
 int oscar_get_ui_info_int(const char *str, int default_value);
 const char *oscar_get_ui_info_string(const char *str, const char *default_value);
+gchar *oscar_get_clientstring(void);
 
 guint16 aimutil_iconsum(const guint8 *buf, int buflen);
 int aimutil_tokslen(char *toSearch, int theindex, char dl);
--- a/libpurple/protocols/oscar/util.c	Wed Jul 08 20:11:07 2009 +0000
+++ b/libpurple/protocols/oscar/util.c	Wed Jul 08 20:44:16 2009 +0000
@@ -42,7 +42,7 @@
 	ui_info = purple_core_get_ui_info();
 	if (ui_info != NULL) {
 		gpointer value;
-		if (g_hash_table_lookup_extended(ui_info, str, NULL, value))
+		if (g_hash_table_lookup_extended(ui_info, str, NULL, &value))
 			return GPOINTER_TO_INT(value);
 	}
 
@@ -63,6 +63,16 @@
 	return value;
 }
 
+gchar *oscar_get_clientstring(void)
+{
+	const char *name, *version;
+
+	name = oscar_get_ui_info_string("name", "Purple");
+	version = oscar_get_ui_info_string("version", VERSION);
+
+	return g_strdup_printf("%s/%s", name, version);;
+}
+
 /*
  * Tokenizing functions.  Used to portably replace strtok/sep.
  *   -- DMP.
--- a/pidgin/gtkmain.c	Wed Jul 08 20:11:07 2009 +0000
+++ b/pidgin/gtkmain.c	Wed Jul 08 20:44:16 2009 +0000
@@ -367,6 +367,14 @@
 		 */
 		g_hash_table_insert(ui_info, "prpl-aim-clientkey", "ma1cSASNCKFtrdv9");
 		g_hash_table_insert(ui_info, "prpl-icq-clientkey", "ma1cSASNCKFtrdv9");
+
+		/*
+		 * This is the distid for Pidgin, given to us by AOL.  Please
+		 * don't use this for other applications.  You can just not
+		 * specify a distid and libpurple will use a default.
+		 */
+		g_hash_table_insert(ui_info, "prpl-aim-distid", GINT_TO_POINTER(1550));
+		g_hash_table_insert(ui_info, "prpl-icq-distid", GINT_TO_POINTER(1550));
 	}
 
 	return ui_info;