pidgin: 84ccc7a4: Allow UIs to specify their own AOL clien...

markdoliner at pidgin.im markdoliner at pidgin.im
Wed Jul 8 15:20:34 EDT 2009


-----------------------------------------------------------------
Revision: 84ccc7a4a13b683bb091e40e212d7db1dbf78485
Ancestor: 715e0c80b3edebfaea1d18534006de8e95ae453e
Author: markdoliner at pidgin.im
Date: 2009-07-08T19:02:40
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/84ccc7a4a13b683bb091e40e212d7db1dbf78485

Modified files:
        libpurple/protocols/oscar/clientlogin.c

ChangeLog: 

Allow UIs to specify their own AOL client key

-------------- next part --------------
============================================================
--- libpurple/protocols/oscar/clientlogin.c	c008e2fc3bd58b7491e126a1c4b04157dc817d0e
+++ libpurple/protocols/oscar/clientlogin.c	e4794a1bd753f0278ae0c677bfcfa3a8d772c626
@@ -45,11 +45,30 @@
 #define URL_START_OSCAR_SESSION "http://api.oscar.aol.com/aim/startOSCARSession"
 
 /*
- * Using clientLogin requires a developer ID.  This dev ID is owned by
- * the AIM account "markdoliner"
+ * Using clientLogin requires a developer ID.  This key is for libpurple.
+ * It is the default key for all libpurple-based clients.  AOL encourages
+ * UIs (especially ones with lots of users) to override this with their
+ * own key.  This key is owned by the AIM account "markdoliner"
+ *
+ * Keys can be managed at http://developer.aim.com/manageKeys.jsp
  */
-#define CLIENT_KEY "ma15d7JTxbmVG-RP"
+#define DEFAULT_CLIENT_KEY "ma15d7JTxbmVG-RP"
 
+static const char *get_client_key(OscarData *od)
+{
+	GHashTable *ui_info;
+	const char *client_key = NULL;
+
+	ui_info = purple_core_get_ui_info();
+	if (ui_info != NULL)
+		client_key = g_hash_table_lookup(ui_info,
+				od->icq ? "prpl-icq-clientkey" : "prpl-aim-clientkey");
+	if (client_key == NULL)
+		client_key = DEFAULT_CLIENT_KEY;
+
+	return client_key;
+}
+
 /**
  * This is similar to purple_url_encode() except that it follows
  * RFC3986 a little more closely by not encoding - . _ and ~
@@ -276,10 +295,10 @@ static void send_start_oscar_session(Osc
 	/* Construct the GET parameters */
 	query_string = g_strdup_printf("a=%s"
 			"&f=xml"
-			"&k=" CLIENT_KEY
+			"&k=%s"
 			"&ts=%zu"
 			"&useTLS=0",
-			oscar_auth_url_encode(token), hosttime);
+			oscar_auth_url_encode(token), get_client_key(od), hosttime);
 	signature = generate_signature("GET", URL_START_OSCAR_SESSION,
 			query_string, session_key);
 	url = g_strdup_printf(URL_START_OSCAR_SESSION "?%s&sig_sha256=%s",
@@ -505,7 +524,7 @@ void send_client_login(OscarData *od, co
 
 	/* Construct the body of the HTTP POST request */
 	body = g_string_new("");
-	g_string_append_printf(body, "devId=" CLIENT_KEY);
+	g_string_append_printf(body, "devId=%s", get_client_key(od));
 	g_string_append_printf(body, "&f=xml");
 	g_string_append_printf(body, "&pwd=%s", oscar_auth_url_encode(password));
 	g_string_append_printf(body, "&s=%s", oscar_auth_url_encode(username));


More information about the Commits mailing list