From: Travis Reitter Date: Wed, 25 Jan 2012 02:00:29 +0000 (-0800) Subject: Don't assume every Tpf.Persona has a contact X-Git-Tag: FOLKS_0_6_7~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=50171f5392901dca6eb1af48cc76a7b0c7ad7b5b;p=platform%2Fupstream%2Ffolks.git Don't assume every Tpf.Persona has a contact --- diff --git a/backends/telepathy/lib/tpf-persona-store.vala b/backends/telepathy/lib/tpf-persona-store.vala index d5f76e9..b79577b 100644 --- a/backends/telepathy/lib/tpf-persona-store.vala +++ b/backends/telepathy/lib/tpf-persona-store.vala @@ -1234,7 +1234,10 @@ public class Tpf.PersonaStore : Folks.PersonaStore /* Translators: the parameter is a persona identifier and * the second parameter is a group name. */ warning (_("Failed to add Telepathy contact ‘%s’ to group ‘%s’."), - persona.contact.identifier, group); + persona.contact != null ? + persona.contact.identifier : + "(nil)", + group); } else { @@ -1242,7 +1245,11 @@ public class Tpf.PersonaStore : Folks.PersonaStore /* Translators: the parameter is a persona identifier * and the second parameter is a group name. */ _("Failed to remove Telepathy contact ‘%s’ from group ‘%s’."), - persona.contact.identifier, group); + + persona.contact != null ? + persona.contact.identifier : + "(nil)", + group); } } } @@ -1606,6 +1613,13 @@ public class Tpf.PersonaStore : Folks.PersonaStore _("Telepathy contacts representing the local user may not be removed.")); } + if (tp_persona.contact == null) + { + warning ("Skipping server-side removal of Tpf.Persona %p because " + + "it has no attached TpContact", tp_persona); + return; + } + try { FolksTpLowlevel.channel_group_change_membership (this._stored, @@ -1798,6 +1812,13 @@ public class Tpf.PersonaStore : Folks.PersonaStore { var tp_persona = (Tpf.Persona) persona; + if (tp_persona.contact == null) + { + warning ("Skipping Tpf.Persona %p contact list change because it " + + "has no attached TpContact", tp_persona); + return; + } + try { FolksTpLowlevel.channel_group_change_membership (channel, @@ -2263,6 +2284,12 @@ public class Tpf.PersonaStore : Folks.PersonaStore _("Failed to change favorite without a connection to the telepathy-logger service.")); } + if (((Tpf.Persona) persona).contact == null) + { + throw new PropertyError.INVALID_VALUE ( + _("Failed to change favorite status of Telepathy Persona because it has no attached TpContact.")); + } + try { /* Add or remove the persona to the list of favourites as @@ -2291,6 +2318,13 @@ public class Tpf.PersonaStore : Folks.PersonaStore alias = ""; } + if (persona.contact == null) + { + warning ("Skipping Tpf.Persona %p alias change to '%s' because it " + + "has no attached TpContact", persona, alias); + return; + } + debug ("Changing alias of persona %u to '%s'.", persona.contact.handle, alias); FolksTpLowlevel.connection_set_contact_alias (this._conn,