diff options
author | Travis Reitter <travis.reitter@collabora.co.uk> | 2011-06-28 05:31:25 +0800 |
---|---|---|
committer | Jonny Lamb <jonnylamb@gnome.org> | 2011-08-22 17:36:33 +0800 |
commit | d1d3a49fc919ed734b77a6e94afb2d49109182f2 (patch) | |
tree | 8c329ef17d60f70dba7f6695378142e229ab44e2 /libempathy | |
parent | 358fab1eb85cecb34ca45f492be2e623ab443a5e (diff) | |
download | gsoc2013-empathy-d1d3a49fc919ed734b77a6e94afb2d49109182f2.tar gsoc2013-empathy-d1d3a49fc919ed734b77a6e94afb2d49109182f2.tar.gz gsoc2013-empathy-d1d3a49fc919ed734b77a6e94afb2d49109182f2.tar.bz2 gsoc2013-empathy-d1d3a49fc919ed734b77a6e94afb2d49109182f2.tar.lz gsoc2013-empathy-d1d3a49fc919ed734b77a6e94afb2d49109182f2.tar.xz gsoc2013-empathy-d1d3a49fc919ed734b77a6e94afb2d49109182f2.tar.zst gsoc2013-empathy-d1d3a49fc919ed734b77a6e94afb2d49109182f2.zip |
Don't assume that all TpfPersonas contain valid TpContacts
Helps: bgo#653599 - Empathy shouldn't assume all TpfPersonas contain a
valid TpContact
Signed-off-by: Jonny Lamb <jonnylamb@gnome.org>
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/empathy-contact.c | 3 | ||||
-rw-r--r-- | libempathy/empathy-individual-manager.c | 52 | ||||
-rw-r--r-- | libempathy/empathy-utils.c | 7 |
3 files changed, 40 insertions, 22 deletions
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c index d5764894b..eac5a8b84 100644 --- a/libempathy/empathy-contact.c +++ b/libempathy/empathy-contact.c @@ -2032,6 +2032,9 @@ empathy_contact_dup_best_for_action (FolksIndividual *individual, goto while_finish; tp_contact = tpf_persona_get_contact (TPF_PERSONA (persona)); + if (tp_contact == NULL) + goto while_finish; + contact = empathy_contact_dup_from_tp_contact (tp_contact); empathy_contact_set_persona (contact, FOLKS_PERSONA (persona)); diff --git a/libempathy/empathy-individual-manager.c b/libempathy/empathy-individual-manager.c index f6aa49184..47a01cb8d 100644 --- a/libempathy/empathy-individual-manager.c +++ b/libempathy/empathy-individual-manager.c @@ -531,14 +531,21 @@ empathy_individual_manager_supports_blocking (EmpathyIndividualManager *self, if (TPF_IS_PERSONA (persona)) { - conn = tp_contact_get_connection (tpf_persona_get_contact (persona)); - manager = empathy_contact_manager_dup_singleton (); + TpContact *tp_contact; - if (empathy_contact_manager_get_flags_for_connection (manager, conn) & - EMPATHY_CONTACT_LIST_CAN_BLOCK) - retval = TRUE; + tp_contact = tpf_persona_get_contact (persona); + if (tp_contact != NULL) + { + conn = tp_contact_get_connection (tp_contact); + manager = empathy_contact_manager_dup_singleton (); - g_object_unref (manager); + if (empathy_contact_manager_get_flags_for_connection ( + manager, conn) & + EMPATHY_CONTACT_LIST_CAN_BLOCK) + retval = TRUE; + + g_object_unref (manager); + } } g_clear_object (&persona); } @@ -569,20 +576,25 @@ empathy_individual_manager_set_blocked (EmpathyIndividualManager *self, if (TPF_IS_PERSONA (persona)) { - contact = empathy_contact_dup_from_tp_contact ( - tpf_persona_get_contact (persona)); - empathy_contact_set_persona (contact, FOLKS_PERSONA (persona)); - manager = empathy_contact_manager_dup_singleton (); - flags = empathy_contact_manager_get_flags_for_connection (manager, - empathy_contact_get_connection (contact)); - - if (flags & EMPATHY_CONTACT_LIST_CAN_BLOCK) - empathy_contact_list_set_blocked ( - EMPATHY_CONTACT_LIST (manager), - contact, blocked, abusive); - - g_object_unref (manager); - g_object_unref (contact); + TpContact *tp_contact; + + tp_contact = tpf_persona_get_contact (persona); + if (tp_contact != NULL) + { + contact = empathy_contact_dup_from_tp_contact (tp_contact); + empathy_contact_set_persona (contact, FOLKS_PERSONA (persona)); + manager = empathy_contact_manager_dup_singleton (); + flags = empathy_contact_manager_get_flags_for_connection (manager, + empathy_contact_get_connection (contact)); + + if (flags & EMPATHY_CONTACT_LIST_CAN_BLOCK) + empathy_contact_list_set_blocked ( + EMPATHY_CONTACT_LIST (manager), + contact, blocked, abusive); + + g_object_unref (manager); + g_object_unref (contact); + } } g_clear_object (&persona); } diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c index 04a6c7836..9a0d16707 100644 --- a/libempathy/empathy-utils.c +++ b/libempathy/empathy-utils.c @@ -715,8 +715,11 @@ empathy_contact_dup_from_folks_individual (FolksIndividual *individual) TpContact *tp_contact; tp_contact = tpf_persona_get_contact (persona); - contact = empathy_contact_dup_from_tp_contact (tp_contact); - empathy_contact_set_persona (contact, FOLKS_PERSONA (persona)); + if (tp_contact != NULL) + { + contact = empathy_contact_dup_from_tp_contact (tp_contact); + empathy_contact_set_persona (contact, FOLKS_PERSONA (persona)); + } } g_clear_object (&persona); } |