pidgin: 4e44d4e1: Some fixes related to setting moods.
sadrul at pidgin.im
sadrul at pidgin.im
Thu Mar 25 16:30:40 EDT 2010
-----------------------------------------------------------------
Revision: 4e44d4e14490f87e50db97f26831389044635024
Ancestor: 79658787f31e562af9d263154475e79d718e2558
Author: sadrul at pidgin.im
Date: 2010-03-25T15:24:42
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/4e44d4e14490f87e50db97f26831389044635024
Modified files:
pidgin/gtkblist.c
ChangeLog:
Some fixes related to setting moods.
* Avoid run-time warnings when setting a mood without a message.
* Fix a typo to not try setting a mood on an account that doesn't support
them.
* Avoid unnecessary strdup and strequal calls.
-------------- next part --------------
============================================================
--- pidgin/gtkblist.c 5533f76c13a5b3c84d328b3eeaba6424de9377fe
+++ pidgin/gtkblist.c 663383224e45ab63e93b3930c50937589decdc8c
@@ -118,7 +118,6 @@ typedef struct
PidginMiniDialog *signed_on_elsewhere;
PidginBlistTheme *current_theme;
-
} PidginBuddyListPrivate;
#define PIDGIN_BUDDY_LIST_GET_PRIVATE(list) \
@@ -3405,7 +3404,7 @@ update_status_with_mood(PurpleAccount *a
update_status_with_mood(PurpleAccount *account, const gchar *mood,
const gchar *text)
{
- if (mood != NULL && !purple_strequal(mood, "")) {
+ if (mood && *mood) {
if (text) {
purple_account_set_status(account, "mood", TRUE,
PURPLE_MOOD_NAME, mood,
@@ -3424,20 +3423,27 @@ edit_mood_cb(PurpleConnection *gc, Purpl
static void
edit_mood_cb(PurpleConnection *gc, PurpleRequestFields *fields)
{
- PurpleRequestField *mood_field, *text_field;
+ PurpleRequestField *mood_field;
GList *l;
mood_field = purple_request_fields_get_field(fields, "mood");
- text_field = purple_request_fields_get_field(fields, "text");
l = purple_request_field_list_get_selected(mood_field);
if (l) {
const char *mood = purple_request_field_list_get_data(mood_field, l->data);
- const char *text = purple_request_field_string_get_value(text_field);
if (gc) {
+ const char *text;
PurpleAccount *account = purple_connection_get_account(gc);
+ if (gc->flags & PURPLE_CONNECTION_SUPPORT_MOOD_MESSAGES) {
+ PurpleRequestField *text_field;
+ text_field = purple_request_fields_get_field(fields, "text");
+ text = purple_request_field_string_get_value(text_field);
+ } else {
+ text = NULL;
+ }
+
update_status_with_mood(account, mood, text);
} else {
GList *accounts = purple_accounts_get_all_active();
@@ -3446,8 +3452,8 @@ edit_mood_cb(PurpleConnection *gc, Purpl
PurpleAccount *account = (PurpleAccount *) accounts->data;
PurpleConnection *gc = purple_account_get_connection(account);
- if (gc->flags && PURPLE_CONNECTION_SUPPORT_MOODS) {
- update_status_with_mood(account, mood, text);
+ if (gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS) {
+ update_status_with_mood(account, mood, NULL);
}
}
}
@@ -3467,9 +3473,9 @@ get_global_moods(void)
get_global_moods(void)
{
GHashTable *global_moods =
- g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
+ g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
GHashTable *mood_counts =
- g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
+ g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
GList *accounts = purple_accounts_get_all_active();
PurpleMood *result = NULL;
GList *out_moods = NULL;
@@ -3491,9 +3497,9 @@ get_global_moods(void)
GPOINTER_TO_INT(g_hash_table_lookup(mood_counts, mood->mood));
if (!g_hash_table_lookup(global_moods, mood->mood)) {
- g_hash_table_insert(global_moods, g_strdup(mood->mood), mood);
+ g_hash_table_insert(global_moods, (gpointer)mood->mood, mood);
}
- g_hash_table_insert(mood_counts, g_strdup(mood->mood),
+ g_hash_table_insert(mood_counts, (gpointer)mood->mood,
GINT_TO_POINTER(mood_count + 1));
}
More information about the Commits
mailing list