Mercurial > pidgin
changeset 20943:e0d7429cfd8a
merge of '4d5bbc54236419e777e3df044678b798605409bf'
and 'cca81a1b623d3a31f3a7d03158eddb36ecf4bfbc'
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Mon, 15 Oct 2007 02:11:13 +0000 |
parents | d1695d02c498 (current diff) 1d8969748cd9 (diff) |
children | 91ce973a950b |
files | |
diffstat | 7 files changed, 144 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/prefs.c Mon Oct 15 00:47:48 2007 +0000 +++ b/libpurple/prefs.c Mon Oct 15 02:11:13 2007 +0000 @@ -297,6 +297,7 @@ g_filename_from_utf8(pref_value, -1, NULL, NULL, NULL)); } } + g_string_free(pref_name_full, TRUE); } else { char *decoded;
--- a/libpurple/protocols/msn/httpconn.c Mon Oct 15 00:47:48 2007 +0000 +++ b/libpurple/protocols/msn/httpconn.c Mon Oct 15 02:11:13 2007 +0000 @@ -169,7 +169,7 @@ /* Now we should be able to process the data. */ if ((s = purple_strcasestr(header, "X-MSN-Messenger: ")) != NULL) { - char *full_session_id, *gw_ip, *session_action; + gchar *full_session_id = NULL, *gw_ip = NULL, *session_action = NULL; char *t, *session_id; char **elems, **cur, **tokens; @@ -196,13 +196,16 @@ { tokens = g_strsplit(*cur, "=", 2); - if (strcmp(tokens[0], "SessionID") == 0) + if (strcmp(tokens[0], "SessionID") == 0) { + g_free(full_session_id); full_session_id = tokens[1]; - else if (strcmp(tokens[0], "GW-IP") == 0) + } else if (strcmp(tokens[0], "GW-IP") == 0) { + g_free(gw_ip); gw_ip = tokens[1]; - else if (strcmp(tokens[0], "Session") == 0) + } else if (strcmp(tokens[0], "Session") == 0) { + g_free(session_action); session_action = tokens[1]; - else + } else g_free(tokens[1]); g_free(tokens[0]);
--- a/libpurple/protocols/msn/msg.c Mon Oct 15 00:47:48 2007 +0000 +++ b/libpurple/protocols/msn/msg.c Mon Oct 15 02:11:13 2007 +0000 @@ -664,10 +664,11 @@ tokens = g_strsplit(*cur, ": ", 2); - if (tokens[0] != NULL && tokens[1] != NULL) + if (tokens[0] != NULL && tokens[1] != NULL) { g_hash_table_insert(table, tokens[0], tokens[1]); - - g_free(tokens); + g_free(tokens); + } else + g_strfreev(tokens); } g_strfreev(elems);
--- a/libpurple/protocols/msn/notification.c Mon Oct 15 00:47:48 2007 +0000 +++ b/libpurple/protocols/msn/notification.c Mon Oct 15 02:11:13 2007 +0000 @@ -262,14 +262,15 @@ for (cur = elems; *cur != NULL; cur++) { tokens = g_strsplit(*cur, "=", 2); - if(tokens[0]&&tokens[1]) + if(tokens[0] && tokens[1]) { purple_debug_info("MSNP14","challenge %p,key:%s,value:%s\n", session->nexus->challenge_data,tokens[0],tokens[1]); g_hash_table_insert(session->nexus->challenge_data, tokens[0], tokens[1]); - } - /* Don't free each of the tokens, only the array. */ - g_free(tokens); + /* Don't free each of the tokens, only the array. */ + g_free(tokens); + } else + g_strfreev(tokens); } g_strfreev(elems); @@ -735,7 +736,7 @@ msn_cmdproc_send_trans(cmdproc, trans); g_free(payload); - g_free(tokens); + g_strfreev(tokens); } static void
--- a/libpurple/protocols/oscar/oscar.c Mon Oct 15 00:47:48 2007 +0000 +++ b/libpurple/protocols/oscar/oscar.c Mon Oct 15 02:11:13 2007 +0000 @@ -5006,6 +5006,7 @@ g = purple_group_new(gname_utf8); purple_blist_add_group(g, NULL); } + g_free(gname_utf8); } break; case 0x0002: { /* Permit buddy */
--- a/pidgin/gtkdocklet.c Mon Oct 15 00:47:48 2007 +0000 +++ b/pidgin/gtkdocklet.c Mon Oct 15 02:11:13 2007 +0000 @@ -38,6 +38,7 @@ #include "gtkprefs.h" #include "gtksavedstatuses.h" #include "gtksound.h" +#include "gtkstatusbox.h" #include "gtkutils.h" #include "pidginstock.h" #include "gtkdocklet.h" @@ -356,6 +357,10 @@ } #endif +/* There is a lot of code here for handling the status submenu, much of + * which is duplicated from the gtkstatusbox. It'd be nice to add API + * somewhere to simplify this (either in the statusbox, or in libpurple). + */ static void show_custom_status_editor_cb(GtkMenuItem *menuitem, gpointer user_data) { @@ -369,6 +374,70 @@ purple_savedstatus_is_transient(saved_status) ? saved_status : NULL); } +static PurpleSavedStatus * +create_transient_status(PurpleStatusPrimitive primitive, PurpleStatusType *status_type) +{ + PurpleSavedStatus *saved_status = purple_savedstatus_new(NULL, primitive); + + if(status_type != NULL) { + GList *tmp, *active_accts = purple_accounts_get_all_active(); + for (tmp = active_accts; tmp != NULL; tmp = tmp->next) { + purple_savedstatus_set_substatus(saved_status, + (PurpleAccount*) tmp->data, status_type, NULL); + } + g_list_free(active_accts); + } + + return saved_status; +} + +static void +activate_status_account_cb(GtkMenuItem *menuitem, gpointer user_data) +{ + PurpleStatusType *status_type; + PurpleStatusPrimitive primitive; + PurpleSavedStatus *saved_status = NULL; + GList *iter = purple_savedstatuses_get_all(); + GList *tmp, *active_accts = purple_accounts_get_all_active(); + + status_type = (PurpleStatusType *)user_data; + primitive = purple_status_type_get_primitive(status_type); + + for (; iter != NULL; iter = iter->next) { + PurpleSavedStatus *ss = iter->data; + if ((purple_savedstatus_get_type(ss) == primitive) && purple_savedstatus_is_transient(ss) && + purple_savedstatus_has_substatuses(ss)) + { + gboolean found = FALSE; + /* The currently enabled accounts must have substatuses for all the active accts */ + for(tmp = active_accts; tmp != NULL; tmp = tmp->next) { + PurpleAccount *acct = tmp->data; + PurpleSavedStatusSub *sub = purple_savedstatus_get_substatus(ss, acct); + if (sub) { + const PurpleStatusType *sub_type = purple_savedstatus_substatus_get_type(sub); + const char *subtype_status_id = purple_status_type_get_id(sub_type); + if (subtype_status_id && !strcmp(subtype_status_id, + purple_status_type_get_id(status_type))) + found = TRUE; + } + } + if (!found) + continue; + saved_status = ss; + break; + } + } + + g_list_free(active_accts); + + /* Create a new transient saved status if we weren't able to find one */ + if (saved_status == NULL) + saved_status = create_transient_status(primitive, status_type); + + /* Set the status for each account */ + purple_savedstatus_activate(saved_status); +} + static void activate_status_primitive_cb(GtkMenuItem *menuitem, gpointer user_data) { @@ -382,7 +451,7 @@ /* Create a new transient saved status if we weren't able to find one */ if (saved_status == NULL) - saved_status = purple_savedstatus_new(NULL, primitive); + saved_status = create_transient_status(primitive, NULL); /* Set the status for each account */ purple_savedstatus_activate(saved_status); @@ -425,31 +494,67 @@ return menuitem; } +static void +add_account_statuses(GtkWidget *menu, PurpleAccount *account) +{ + GList *l; + + for (l = purple_account_get_status_types(account); l != NULL; l = l->next) { + PurpleStatusType *status_type = (PurpleStatusType *)l->data; + PurpleStatusPrimitive prim; + + if (!purple_status_type_is_user_settable(status_type)) + continue; + + prim = purple_status_type_get_primitive(status_type); + + new_menu_item_with_status_icon(menu, + purple_status_type_get_name(status_type), + prim, G_CALLBACK(activate_status_account_cb), + status_type, 0, 0, NULL); + } +} + static GtkWidget * docklet_status_submenu() { GtkWidget *submenu, *menuitem; GList *popular_statuses, *cur; + PidginStatusBox *statusbox = NULL; submenu = gtk_menu_new(); menuitem = gtk_menu_item_new_with_label(_("Change Status")); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); - new_menu_item_with_status_icon(submenu, _("Available"), - PURPLE_STATUS_AVAILABLE, G_CALLBACK(activate_status_primitive_cb), - GINT_TO_POINTER(PURPLE_STATUS_AVAILABLE), 0, 0, NULL); + if(pidgin_blist_get_default_gtk_blist() != NULL) { + statusbox = PIDGIN_STATUS_BOX(pidgin_blist_get_default_gtk_blist()->statusbox); + } - new_menu_item_with_status_icon(submenu, _("Away"), - PURPLE_STATUS_AWAY, G_CALLBACK(activate_status_primitive_cb), - GINT_TO_POINTER(PURPLE_STATUS_AWAY), 0, 0, NULL); + if(statusbox && statusbox->account != NULL) { + add_account_statuses(submenu, statusbox->account); + } else if(statusbox && statusbox->token_status_account != NULL) { + add_account_statuses(submenu, statusbox->token_status_account); + } else { + new_menu_item_with_status_icon(submenu, _("Available"), + PURPLE_STATUS_AVAILABLE, G_CALLBACK(activate_status_primitive_cb), + GINT_TO_POINTER(PURPLE_STATUS_AVAILABLE), 0, 0, NULL); - new_menu_item_with_status_icon(submenu, _("Invisible"), - PURPLE_STATUS_INVISIBLE, G_CALLBACK(activate_status_primitive_cb), - GINT_TO_POINTER(PURPLE_STATUS_INVISIBLE), 0, 0, NULL); + new_menu_item_with_status_icon(submenu, _("Away"), + PURPLE_STATUS_AWAY, G_CALLBACK(activate_status_primitive_cb), + GINT_TO_POINTER(PURPLE_STATUS_AWAY), 0, 0, NULL); + + new_menu_item_with_status_icon(submenu, _("Do not disturb"), + PURPLE_STATUS_UNAVAILABLE, G_CALLBACK(activate_status_primitive_cb), + GINT_TO_POINTER(PURPLE_STATUS_UNAVAILABLE), 0, 0, NULL); - new_menu_item_with_status_icon(submenu, _("Offline"), - PURPLE_STATUS_OFFLINE, G_CALLBACK(activate_status_primitive_cb), - GINT_TO_POINTER(PURPLE_STATUS_OFFLINE), 0, 0, NULL); + new_menu_item_with_status_icon(submenu, _("Invisible"), + PURPLE_STATUS_INVISIBLE, G_CALLBACK(activate_status_primitive_cb), + GINT_TO_POINTER(PURPLE_STATUS_INVISIBLE), 0, 0, NULL); + + new_menu_item_with_status_icon(submenu, _("Offline"), + PURPLE_STATUS_OFFLINE, G_CALLBACK(activate_status_primitive_cb), + GINT_TO_POINTER(PURPLE_STATUS_OFFLINE), 0, 0, NULL); + } popular_statuses = purple_savedstatuses_get_popular(6); if (popular_statuses != NULL)
--- a/pidgin/gtkutils.c Mon Oct 15 00:47:48 2007 +0000 +++ b/pidgin/gtkutils.c Mon Oct 15 02:11:13 2007 +0000 @@ -850,16 +850,14 @@ gboolean pidgin_check_if_dir(const char *path, GtkFileSelection *filesel) { - char *dirname; + char *dirname = NULL; if (g_file_test(path, G_FILE_TEST_IS_DIR)) { /* append a / if needed */ if (path[strlen(path) - 1] != G_DIR_SEPARATOR) { dirname = g_strconcat(path, G_DIR_SEPARATOR_S, NULL); - } else { - dirname = g_strdup(path); } - gtk_file_selection_set_filename(filesel, dirname); + gtk_file_selection_set_filename(filesel, (dirname != NULL) ? dirname : path); g_free(dirname); return TRUE; } @@ -1178,14 +1176,15 @@ label = gtk_widget_get_accessible (l); /* Make sure mnemonics work */ - gtk_label_set_mnemonic_widget(GTK_LABEL(l), w); - + gtk_label_set_mnemonic_widget(GTK_LABEL(l), w); + /* Create the labeled-by relation */ set = atk_object_ref_relation_set (acc); rel_obj[0] = label; relation = atk_relation_new (rel_obj, 1, ATK_RELATION_LABELLED_BY); atk_relation_set_add (set, relation); g_object_unref (relation); + g_object_unref(set); /* Create the label-for relation */ set = atk_object_ref_relation_set (label); @@ -1193,6 +1192,7 @@ relation = atk_relation_new (rel_obj, 1, ATK_RELATION_LABEL_FOR); atk_relation_set_add (set, relation); g_object_unref (relation); + g_object_unref(set); } void