Mercurial > pidgin.yaz
changeset 27504:4f24d5da4cb3
Create a oscar_get_ui_info_string() function that looks up a value in the
ui_info hash table, and use this function in clientlogin.c and oscar.c
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 08 Jul 2009 19:46:50 +0000 |
parents | 88ef8c38a639 |
children | 5048054d319a |
files | libpurple/protocols/oscar/clientlogin.c libpurple/protocols/oscar/oscar.c libpurple/protocols/oscar/oscar.h libpurple/protocols/oscar/util.c |
diffstat | 4 files changed, 29 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/oscar/clientlogin.c Wed Jul 08 19:15:31 2009 +0000 +++ b/libpurple/protocols/oscar/clientlogin.c Wed Jul 08 19:46:50 2009 +0000 @@ -56,17 +56,9 @@ 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; + return oscar_get_ui_info_string( + od->icq ? "prpl-icq-clientkey" : "prpl-aim-clientkey", + DEFAULT_CLIENT_KEY); } /**
--- a/libpurple/protocols/oscar/oscar.c Wed Jul 08 19:15:31 2009 +0000 +++ b/libpurple/protocols/oscar/oscar.c Wed Jul 08 19:46:50 2009 +0000 @@ -1673,10 +1673,9 @@ } if (in != '\n') { char buf[256]; - GHashTable *ui_info = purple_core_get_ui_info(); g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. " "If so, check %s for updates."), - ((ui_info && g_hash_table_lookup(ui_info, "website")) ? (char *)g_hash_table_lookup(ui_info, "website") : PURPLE_WEBSITE)); + oscar_get_ui_info_string("website", PURPLE_WEBSITE)); purple_notify_warning(pos->gc, NULL, _("Unable to get a valid AIM login hash."), buf); @@ -1715,10 +1714,9 @@ pos->fd = source; if (source < 0) { - GHashTable *ui_info = purple_core_get_ui_info(); buf = g_strdup_printf(_("You may be disconnected shortly. " "If so, check %s for updates."), - ((ui_info && g_hash_table_lookup(ui_info, "website")) ? (char *)g_hash_table_lookup(ui_info, "website") : PURPLE_WEBSITE)); + oscar_get_ui_info_string("website", PURPLE_WEBSITE)); purple_notify_warning(pos->gc, NULL, _("Unable to get a valid AIM login hash."), buf); @@ -1814,13 +1812,12 @@ straight_to_hell, pos) == NULL) { char buf[256]; - GHashTable *ui_info = purple_core_get_ui_info(); g_free(pos->modname); g_free(pos); g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. " "If so, check %s for updates."), - ((ui_info && g_hash_table_lookup(ui_info, "website")) ? (char *)g_hash_table_lookup(ui_info, "website") : PURPLE_WEBSITE)); + oscar_get_ui_info_string("website", PURPLE_WEBSITE)); purple_notify_warning(pos->gc, NULL, _("Unable to get a valid login hash."), buf); @@ -1905,9 +1902,8 @@ case 0x1c: { /* client too old */ - GHashTable *ui_info = purple_core_get_ui_info(); g_snprintf(buf, sizeof(buf), _("The client version you are using is too old. Please upgrade at %s"), - ((ui_info && g_hash_table_lookup(ui_info, "website")) ? (char *)g_hash_table_lookup(ui_info, "website") : PURPLE_WEBSITE)); + oscar_get_ui_info_string("website", PURPLE_WEBSITE)); purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, buf); break; } @@ -7111,6 +7107,9 @@ * use them to override these two version fields which are sent to the * server when logging in. AOL requested this change to allow clients to * use custom values. + * + * TODO: It would be more appropriate for UIs to put these in the hash + * table returned by purple_core_get_ui_info(). */ purple_prefs_add_string("/plugins/prpl/oscar/clientstring", NULL); purple_prefs_add_int("/plugins/prpl/oscar/distid", -1);
--- a/libpurple/protocols/oscar/oscar.h Wed Jul 08 19:15:31 2009 +0000 +++ b/libpurple/protocols/oscar/oscar.h Wed Jul 08 19:46:50 2009 +0000 @@ -1527,6 +1527,8 @@ (((*((buf)+2)) << 16) & 0x00ff0000) + \ (((*((buf)+3)) << 24) & 0xff000000)) +const char *oscar_get_ui_info_string(const char *str, const char *default_value); + guint16 aimutil_iconsum(const guint8 *buf, int buflen); int aimutil_tokslen(char *toSearch, int theindex, char dl); int aimutil_itemcnt(char *toSearch, char dl);
--- a/libpurple/protocols/oscar/util.c Wed Jul 08 19:15:31 2009 +0000 +++ b/libpurple/protocols/oscar/util.c Wed Jul 08 19:46:50 2009 +0000 @@ -26,12 +26,29 @@ */ #include "oscar.h" + +#include "core.h" + #include <ctype.h> #ifdef _WIN32 #include "win32dep.h" #endif +const char *oscar_get_ui_info_string(const char *str, const char *default_value) +{ + GHashTable *ui_info; + const char *value = NULL; + + ui_info = purple_core_get_ui_info(); + if (ui_info != NULL) + value = g_hash_table_lookup(ui_info, str); + if (value == NULL) + value = default_value; + + return value; +} + /* * Tokenizing functions. Used to portably replace strtok/sep. * -- DMP.