# HG changeset patch # User Mark Doliner # Date 1247079760 0 # Node ID 4813810ea7d44def16ade5d5a5c40966e61dd40c # Parent 8368e4fb7d3a219b9bd4343fbebb689d5df764ae Allow UIs to specify their own AOL client key diff -r 8368e4fb7d3a -r 4813810ea7d4 libpurple/protocols/oscar/clientlogin.c --- a/libpurple/protocols/oscar/clientlogin.c Wed Jul 08 17:20:00 2009 +0000 +++ b/libpurple/protocols/oscar/clientlogin.c Wed Jul 08 19:02:40 2009 +0000 @@ -45,10 +45,29 @@ #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 @@ -276,10 +295,10 @@ /* 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 @@ /* 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));