diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2010-08-27 22:41:50 +0800 |
---|---|---|
committer | Philip Withnall <philip.withnall@collabora.co.uk> | 2010-08-30 22:54:59 +0800 |
commit | 5ea7f6cfbc591afac428bffbff513ccb77db3d63 (patch) | |
tree | 356544b2f2c53b7ccd4aff4b7234bd089e2776ed /libempathy-gtk/empathy-individual-view.c | |
parent | eaa8c0029aa90c33d415a000342354bb2fe771d4 (diff) | |
download | gsoc2013-empathy-5ea7f6cfbc591afac428bffbff513ccb77db3d63.tar gsoc2013-empathy-5ea7f6cfbc591afac428bffbff513ccb77db3d63.tar.gz gsoc2013-empathy-5ea7f6cfbc591afac428bffbff513ccb77db3d63.tar.bz2 gsoc2013-empathy-5ea7f6cfbc591afac428bffbff513ccb77db3d63.tar.lz gsoc2013-empathy-5ea7f6cfbc591afac428bffbff513ccb77db3d63.tar.xz gsoc2013-empathy-5ea7f6cfbc591afac428bffbff513ccb77db3d63.tar.zst gsoc2013-empathy-5ea7f6cfbc591afac428bffbff513ccb77db3d63.zip |
Bug 628121 — Should pick an online persona when starting a chat
Change the EmpathyIndividualMenu and EmpathyIndividualView code for starting
chats with Individuals to choose the most available Persona to chat to, rather
than just the first available one. Helps: bgo#628121
Diffstat (limited to 'libempathy-gtk/empathy-individual-view.c')
-rw-r--r-- | libempathy-gtk/empathy-individual-view.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/libempathy-gtk/empathy-individual-view.c b/libempathy-gtk/empathy-individual-view.c index 1c8dd21cf..f8822bc81 100644 --- a/libempathy-gtk/empathy-individual-view.c +++ b/libempathy-gtk/empathy-individual-view.c @@ -903,8 +903,10 @@ individual_view_row_activated (GtkTreeView *view, EmpathyIndividualViewPriv *priv = GET_PRIV (view); FolksIndividual *individual; EmpathyContact *contact = NULL; + FolksPresenceType best_presence = FOLKS_PRESENCE_TYPE_UNSET; GtkTreeModel *model; GtkTreeIter iter; + GList *personas, *l; if (!(priv->individual_features & EMPATHY_INDIVIDUAL_FEATURE_CHAT)) return; @@ -917,7 +919,31 @@ individual_view_row_activated (GtkTreeView *view, if (individual == NULL) return; - contact = empathy_contact_dup_from_folks_individual (individual); + /* Determine which Persona to chat to, by choosing the most available one. */ + personas = folks_individual_get_personas (individual); + for (l = personas; l != NULL; l = l->next) + { + FolksPresenceType presence; + + if (!TPF_IS_PERSONA (l->data)) + continue; + + /* Only choose the contact if it has a higher presence than our current + * best choice of contact. */ + presence = folks_presence_get_presence_type (FOLKS_PRESENCE (l->data)); + if (folks_presence_typecmp (presence, best_presence) > 0) + { + TpContact *tp_contact; + + tp_clear_object (&contact); + tp_contact = tpf_persona_get_contact (TPF_PERSONA (l->data)); + contact = empathy_contact_dup_from_tp_contact (tp_contact); + empathy_contact_set_persona (contact, FOLKS_PERSONA (l->data)); + + best_presence = presence; + } + } + if (contact != NULL) { DEBUG ("Starting a chat"); |