Mercurial > pidgin.yaz
changeset 10012:a38881ec9c0f
[gaim-migrate @ 10929]
i'm fairly certain this is all better
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Sat, 11 Sep 2004 05:41:50 +0000 |
parents | 32467b63f55a |
children | f1f239fa8973 |
files | plugins/gaim-remote/remote.c src/account.c src/blist.h src/gtkblist.c src/prpl.c src/status.c |
diffstat | 6 files changed, 52 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/gaim-remote/remote.c Sat Sep 11 03:37:16 2004 +0000 +++ b/plugins/gaim-remote/remote.c Sat Sep 11 05:41:50 2004 +0000 @@ -498,7 +498,7 @@ const char *resp; char *send; GList *c = gaim_connections_get_all(); - GaimConnection *gc; + GaimConnection *gc = NULL; GaimAccount *account; switch (subtype) {
--- a/src/account.c Sat Sep 11 03:37:16 2004 +0000 +++ b/src/account.c Sat Sep 11 05:41:50 2004 +0000 @@ -126,6 +126,8 @@ gaim_account_new(const char *username, const char *protocol_id) { GaimAccount *account = NULL; + GaimPlugin *prpl = NULL; + GaimPluginProtocolInfo *prpl_info = NULL; g_return_val_if_fail(username != NULL, NULL); g_return_val_if_fail(protocol_id != NULL, NULL); @@ -149,6 +151,15 @@ account->presence = gaim_presence_new_for_account(account); + prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); + + if (prpl == NULL) + return account; + + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); + if ( prpl_info != NULL && prpl_info->status_types != NULL ) + gaim_account_set_status_types(account, prpl_info->status_types(account)); + return account; }
--- a/src/blist.h Sat Sep 11 03:37:16 2004 +0000 +++ b/src/blist.h Sat Sep 11 05:41:50 2004 +0000 @@ -191,7 +191,6 @@ void (*request_add_chat)(GaimAccount *account, GaimGroup *group, const char *alias, const char *name); void (*request_add_group)(void); - void (*status_changed)(GaimBuddy *buddy, GaimStatus *status); };
--- a/src/gtkblist.c Sat Sep 11 03:37:16 2004 +0000 +++ b/src/gtkblist.c Sat Sep 11 05:41:50 2004 +0000 @@ -2964,12 +2964,11 @@ for(cnode = gnode->child; cnode; cnode = cnode->next) { if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { GaimBuddy *buddy; - GaimPresence *presence; buddy = gaim_contact_get_priority_buddy((GaimContact*)cnode); - presence = gaim_buddy_get_presence(buddy); - - if (buddy && gaim_presence_is_idle(presence)) + + if (buddy && + gaim_presence_is_idle(gaim_buddy_get_presence(buddy))) gaim_gtk_blist_update(list, cnode); } } @@ -4601,19 +4600,6 @@ } } -void gaim_gtk_blist_status_changed(GaimBuddy *buddy, GaimStatus *status) -{ - g_return_if_fail(buddy != NULL); - - /* - * What do we do with status here? - * g_return_if_fail(status != NULL); - */ - - gaim_debug_info("gtkblist", "Updating buddy list\n"); - gaim_gtk_blist_update(gaim_get_blist(), (GaimBlistNode*)buddy); -} - static GaimBlistUiOps blist_ui_ops = { gaim_gtk_blist_new_list, @@ -4625,8 +4611,7 @@ gaim_gtk_blist_set_visible, gaim_gtk_blist_request_add_buddy, gaim_gtk_blist_request_add_chat, - gaim_gtk_blist_request_add_group, - gaim_gtk_blist_status_changed + gaim_gtk_blist_request_add_group };
--- a/src/prpl.c Sat Sep 11 03:37:16 2004 +0000 +++ b/src/prpl.c Sat Sep 11 05:41:50 2004 +0000 @@ -270,6 +270,7 @@ GaimBuddy *buddy; GaimPresence *presence; GaimStatus *status; + gboolean was_online = FALSE; g_return_if_fail(account != NULL); g_return_if_fail(name != NULL); @@ -301,6 +302,9 @@ } gaim_presence_set_status_active(presence, status_id, TRUE); + + gaim_blist_update_buddy_presence(buddy, GAIM_BUDDY_IS_ONLINE(buddy)); + gaim_contact_compute_priority_buddy(gaim_buddy_get_contact(buddy)); } void
--- a/src/status.c Sat Sep 11 03:37:16 2004 +0000 +++ b/src/status.c Sat Sep 11 05:41:50 2004 +0000 @@ -118,8 +118,6 @@ { GaimAccount *account; char *name; - guint id; - } GaimStatusBuddyKey; @@ -218,7 +216,7 @@ g_return_val_if_fail(primitive != GAIM_STATUS_UNSET, NULL); g_return_val_if_fail(id != NULL, NULL); g_return_val_if_fail(name != NULL, NULL); - g_return_val_if_fail(attr_id != NULL, NULL); + g_return_val_if_fail(attr_id != NULL, NULL); g_return_val_if_fail(attr_name != NULL, NULL); g_return_val_if_fail(attr_value != NULL, NULL); @@ -561,8 +559,10 @@ } } - if (ops != NULL && ops->status_changed != NULL) - ops->status_changed(buddy, new_status); + + + if (ops != NULL && ops->update != NULL) + ops->update(gaim_get_blist(), (GaimBlistNode*)buddy); } static void @@ -636,17 +636,20 @@ for (l = gaim_presence_get_statuses(presence); l != NULL; l = l->next) { - GaimStatus *temp_status = (GaimStatus *)l->data; - GaimStatusType *temp_type; + GaimStatusType *temp_type = l->data; + GaimStatus *temp_status = NULL; if (!gaim_status_compare(temp_status, status)) continue; - temp_type = gaim_status_get_type(temp_status); - if (gaim_status_type_is_independent(temp_type)) continue; + + temp_status = (GaimStatus *)g_hash_table_lookup( + presence->status_table, + gaim_status_type_get_id(temp_type)); + if (gaim_status_is_active(temp_status)) { /* @@ -915,8 +918,7 @@ GaimPresence * gaim_presence_new_for_account(GaimAccount *account) { - GaimPresence *presence; - + GaimPresence *presence = NULL; g_return_val_if_fail(account != NULL, NULL); presence = gaim_presence_new(GAIM_PRESENCE_CONTEXT_ACCOUNT); @@ -946,21 +948,15 @@ GaimPresence *presence; GaimStatusBuddyKey *key; GaimAccount *account; - gchar *hash_seed; g_return_val_if_fail(buddy != NULL, NULL); + account = buddy->account; account = buddy->account; - hash_seed = g_strdup_printf("%s:%s:%s", buddy->name, account->username, - account->protocol_id); key = g_new0(GaimStatusBuddyKey, 1); key->account = buddy->account; key->name = g_strdup(buddy->name); - key->id = g_str_hash(hash_seed); - - g_free(hash_seed); - hash_seed = NULL; presence = g_hash_table_lookup(buddy_presences, key); if (presence == NULL) @@ -1303,15 +1299,15 @@ g_return_val_if_fail(status_id != NULL, NULL); /* What's the purpose of this hash table? */ - status = (GaimStatus *)g_hash_table_lookup(presence->status_table, + status = (GaimStatus *)g_hash_table_lookup(presence->status_table, status_id); - + if (status == NULL) { - for (l = gaim_presence_get_statuses(presence); + for (l = gaim_presence_get_statuses(presence); l != NULL && status == NULL; l = l->next) { GaimStatus *temp_status = l->data; - + if (!strcmp(status_id, gaim_status_get_id(temp_status))) status = temp_status; } @@ -1319,7 +1315,7 @@ if (status != NULL) g_hash_table_insert(presence->status_table, g_strdup(gaim_status_get_id(status)), status); - } + } return status; } @@ -1493,19 +1489,28 @@ primitive_scores[index] = GPOINTER_TO_INT(value); } -guint +guint gaim_buddy_presences_hash(gconstpointer key) { - return ((GaimStatusBuddyKey *)key)->id; + const GaimStatusBuddyKey *me = key; + guint ret; + char *str; + + str = g_strdup_printf("%p%s", me->account, me->name); + ret = g_str_hash(str); + g_free(str); + + return ret; } -gboolean +gboolean gaim_buddy_presences_equal(gconstpointer a, gconstpointer b) { GaimStatusBuddyKey *key_a = (GaimStatusBuddyKey *)a; GaimStatusBuddyKey *key_b = (GaimStatusBuddyKey *)b; - if (key_a->id == key_b->id) + if(key_a->account == key_b->account && + !strcmp(key_a->name, key_b->name)) return TRUE; else return FALSE; @@ -1549,7 +1554,6 @@ score_pref_changed_cb, GINT_TO_POINTER(SCORE_IDLE)); - /* XXX - I don't think this is destroyed correctly. --Mark */ buddy_presences = g_hash_table_new(gaim_buddy_presences_hash, gaim_buddy_presences_equal); }