pidgin: a6fa365d: Create a oscar_get_ui_info_string() func...
markdoliner at pidgin.im
markdoliner at pidgin.im
Wed Jul 8 15:50:22 EDT 2009
-----------------------------------------------------------------
Revision: a6fa365dead8e84c4173c08c7450e8edaf1adcd3
Ancestor: f43aae9cec18c240f0d3c803f3c9136fe989d1c3
Author: markdoliner at pidgin.im
Date: 2009-07-08T19:46:50
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/a6fa365dead8e84c4173c08c7450e8edaf1adcd3
Modified files:
libpurple/protocols/oscar/clientlogin.c
libpurple/protocols/oscar/oscar.c
libpurple/protocols/oscar/oscar.h
libpurple/protocols/oscar/util.c
ChangeLog:
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
-------------- next part --------------
============================================================
--- libpurple/protocols/oscar/clientlogin.c e4794a1bd753f0278ae0c677bfcfa3a8d772c626
+++ libpurple/protocols/oscar/clientlogin.c 2ec57aff2d34686089de94ccb0a82548a3cd0b3c
@@ -56,17 +56,9 @@ static const char *get_client_key(OscarD
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);
}
/**
============================================================
--- libpurple/protocols/oscar/oscar.c d59497d11d676fb587c728c6bc4d6dfdc85a2d79
+++ libpurple/protocols/oscar/oscar.c cef8df6975a84f3ca838dde404b4ca047900a374
@@ -1673,10 +1673,9 @@ static void damn_you(gpointer data, gint
}
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 @@ straight_to_hell(gpointer data, gint sou
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 @@ static int purple_memrequest(OscarData *
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 @@ purple_parse_auth_resp(OscarData *od, Fl
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 @@ void oscar_init(PurplePluginProtocolInfo
* 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);
============================================================
--- libpurple/protocols/oscar/oscar.h a934b3d0cca07b79b7f11ee10dff506e53b95cb7
+++ libpurple/protocols/oscar/oscar.h 5a3e5c12cb9f4107cf5ded533b78fc6e77b662f9
@@ -1527,6 +1527,8 @@ void aim_tlvlist_remove(GSList **list, c
(((*((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);
============================================================
--- libpurple/protocols/oscar/util.c 3012570162a0277823637f3fe5f19ed45cafa784
+++ libpurple/protocols/oscar/util.c b1392178e8bd4b440d80a44a91f17a0f3acd0e0b
@@ -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.
More information about the Commits
mailing list