comparison pidgin/gtkblist.c @ 30511:9623db527d1e

merged from im.pidgin.pidgin
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Tue, 25 May 2010 22:21:47 +0900
parents 2a19f7385ba5 8e060965d69f
children 9c24dd1f1c1a
comparison
equal deleted inserted replaced
30383:2a19f7385ba5 30511:9623db527d1e
3490 int i = 0; 3490 int i = 0;
3491 int num_accounts = 0; 3491 int num_accounts = 0;
3492 3492
3493 for (; accounts ; accounts = g_list_delete_link(accounts, accounts)) { 3493 for (; accounts ; accounts = g_list_delete_link(accounts, accounts)) {
3494 PurpleAccount *account = (PurpleAccount *) accounts->data; 3494 PurpleAccount *account = (PurpleAccount *) accounts->data;
3495 PurpleConnection *gc = purple_account_get_connection(account); 3495 if (purple_account_is_connected(account)) {
3496 3496 PurpleConnection *gc = purple_account_get_connection(account);
3497 if (gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS) { 3497
3498 PurplePluginProtocolInfo *prpl_info = 3498 if (gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS) {
3499 PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); 3499 PurplePluginProtocolInfo *prpl_info =
3500 PurpleMood *mood = NULL; 3500 PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
3501 3501 PurpleMood *mood = NULL;
3502 /* PURPLE_CONNECTION_SUPPORT_MOODS would not be set if the prpl doesn't 3502
3503 * have get_moods, so using PURPLE_PROTOCOL_PLUGIN_HAS_FUNC isn't necessary 3503 /* PURPLE_CONNECTION_SUPPORT_MOODS would not be set if the prpl doesn't
3504 * here */ 3504 * have get_moods, so using PURPLE_PROTOCOL_PLUGIN_HAS_FUNC isn't necessary
3505 for (mood = prpl_info->get_moods(account) ; 3505 * here */
3506 mood->mood != NULL ; mood++) { 3506 for (mood = prpl_info->get_moods(account) ;
3507 int mood_count = 3507 mood->mood != NULL ; mood++) {
3508 GPOINTER_TO_INT(g_hash_table_lookup(mood_counts, mood->mood)); 3508 int mood_count =
3509 3509 GPOINTER_TO_INT(g_hash_table_lookup(mood_counts, mood->mood));
3510 if (!g_hash_table_lookup(global_moods, mood->mood)) { 3510
3511 g_hash_table_insert(global_moods, (gpointer)mood->mood, mood); 3511 if (!g_hash_table_lookup(global_moods, mood->mood)) {
3512 g_hash_table_insert(global_moods, (gpointer)mood->mood, mood);
3513 }
3514 g_hash_table_insert(mood_counts, (gpointer)mood->mood,
3515 GINT_TO_POINTER(mood_count + 1));
3512 } 3516 }
3513 g_hash_table_insert(mood_counts, (gpointer)mood->mood, 3517
3514 GINT_TO_POINTER(mood_count + 1)); 3518 num_accounts++;
3515 } 3519 }
3516
3517 num_accounts++;
3518 } 3520 }
3519 } 3521 }
3520 3522
3521 g_hash_table_foreach(global_moods, global_moods_for_each, &out_moods); 3523 g_hash_table_foreach(global_moods, global_moods_for_each, &out_moods);
3522 result = g_new0(PurpleMood, g_hash_table_size(global_moods) + 1); 3524 result = g_new0(PurpleMood, g_hash_table_size(global_moods) + 1);
3550 const gchar *found_mood = NULL; 3552 const gchar *found_mood = NULL;
3551 3553
3552 for (; accounts ; accounts = g_list_delete_link(accounts, accounts)) { 3554 for (; accounts ; accounts = g_list_delete_link(accounts, accounts)) {
3553 PurpleAccount *account = (PurpleAccount *) accounts->data; 3555 PurpleAccount *account = (PurpleAccount *) accounts->data;
3554 3556
3555 if (purple_account_get_connection(account)->flags & 3557 if (purple_account_is_connected(account) &&
3556 PURPLE_CONNECTION_SUPPORT_MOODS) { 3558 (purple_account_get_connection(account)->flags &
3559 PURPLE_CONNECTION_SUPPORT_MOODS)) {
3557 PurplePresence *presence = purple_account_get_presence(account); 3560 PurplePresence *presence = purple_account_get_presence(account);
3558 PurpleStatus *status = purple_presence_get_status(presence, "mood"); 3561 PurpleStatus *status = purple_presence_get_status(presence, "mood");
3559 const gchar *curr_mood = purple_status_get_attr_string(status, PURPLE_MOOD_NAME); 3562 const gchar *curr_mood = purple_status_get_attr_string(status, PURPLE_MOOD_NAME);
3560 3563
3561 if (found_mood != NULL && !purple_strequal(curr_mood, found_mood)) { 3564 if (found_mood != NULL && !purple_strequal(curr_mood, found_mood)) {