[folks] Remove the exception from Tpf.Persona's constructor
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] Remove the exception from Tpf.Persona's constructor
- Date: Sat, 13 Nov 2010 13:13:42 +0000 (UTC)
commit 9a47fc5816ecf71d7d3ac45030a7e776384e2caf
Author: Philip Withnall <philip withnall collabora co uk>
Date: Fri Sep 17 12:00:19 2010 +0100
Remove the exception from Tpf.Persona's constructor
It was not possible for it to ever be thrown (since TpContact.get_identifier()
is guaranteed to always return a valid ID, and having *_new() methods throw
exceptions is never a good idea. (GInitable should be used instead.)
This breaks both the Vala and C APIs.
Helps: bgo#629078
NEWS | 2 +
backends/telepathy/lib/tpf-persona-store.vala | 59 +++++--------------------
backends/telepathy/lib/tpf-persona.vala | 16 +------
3 files changed, 14 insertions(+), 63 deletions(-)
---
diff --git a/NEWS b/NEWS
index 067732e..029a02d 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,8 @@ API changes:
PersonaStore.display_name, PersonaStore.id, Backend.name,
Backend.persona_stores and Persona.linkable_properties. This removes the
corresponding C setter methods which should never have been exposed
+* Remove Tpf.PersonaError
+* Remove the exception from the Tpf.Persona constructor
Bugs fixed:
* Bug 629081 â?? Add API to allow specific backends to be disabled
diff --git a/backends/telepathy/lib/tpf-persona-store.vala b/backends/telepathy/lib/tpf-persona-store.vala
index 8b2e7f3..0b5f536 100644
--- a/backends/telepathy/lib/tpf-persona-store.vala
+++ b/backends/telepathy/lib/tpf-persona-store.vala
@@ -594,25 +594,13 @@ public class Tpf.PersonaStore : Folks.PersonaStore
/* Add the local user */
Contact contact = contacts[0];
- try
- {
- Persona persona = this.add_persona_from_contact (contact);
+ Persona persona = this.add_persona_from_contact (contact);
- GLib.List<Persona> personas = new GLib.List<Persona> ();
- personas.prepend (persona);
+ GLib.List<Persona> personas = new GLib.List<Persona> ();
+ personas.prepend (persona);
- this.self_contact = contact;
- this.personas_changed (personas, null, null, null, 0);
- }
- catch (Tpf.PersonaError e)
- {
- warning (
- /* Translators: the first parameter is the contact's
- * alias, and the second is the location of the contact's
- * data in memory (for debugging). */
- _("Failed to create self persona from contact '%s' (%p)"),
- contact.alias, contact);
- }
+ this.self_contact = contact;
+ this.personas_changed (personas, null, null, null, 0);
},
this);
}
@@ -1261,23 +1249,9 @@ public class Tpf.PersonaStore : Folks.PersonaStore
debug ("Creating persona from contact '%s'", contact.identifier);
- try
- {
- var persona = this.add_persona_from_contact (contact);
- if (persona != null)
- personas.prepend (persona);
- }
- catch (Tpf.PersonaError e)
- {
- err_string = "%s\n%s".printf (err_string,
- /* Translators: format for lines in the error string below
- * "Failed to create %u personas:". The first parameter is
- * a contact alias, the second is a pointer address and
- * the third is an error message. */
- _("'%s' (%p): %s").printf (contact.alias, contact,
- e.message));
- err_count++;
- }
+ var persona = this.add_persona_from_contact (contact);
+ if (persona != null)
+ personas.prepend (persona);
}
if (err_count > 0)
@@ -1302,7 +1276,6 @@ public class Tpf.PersonaStore : Folks.PersonaStore
}
private Tpf.Persona? add_persona_from_contact (Contact contact)
- throws Tpf.PersonaError
{
var h = contact.get_handle ();
@@ -1332,19 +1305,9 @@ public class Tpf.PersonaStore : Folks.PersonaStore
GLib.List<Persona> personas = new GLib.List<Persona> ();
foreach (Contact contact in contacts)
{
- try
- {
- var persona = this.add_persona_from_contact (contact);
- if (persona != null)
- personas.prepend (persona);
- }
- catch (Tpf.PersonaError e)
- {
- /* Translators: the first parameter is a contact alias and the
- * second is a pointer address. */
- warning (_("Failed to create persona from contact '%s' (%p)."),
- contact.alias, contact);
- }
+ var persona = this.add_persona_from_contact (contact);
+ if (persona != null)
+ personas.prepend (persona);
}
this.channel_groups_add_new_personas ();
diff --git a/backends/telepathy/lib/tpf-persona.vala b/backends/telepathy/lib/tpf-persona.vala
index 6b8498b..01ba60d 100644
--- a/backends/telepathy/lib/tpf-persona.vala
+++ b/backends/telepathy/lib/tpf-persona.vala
@@ -23,11 +23,6 @@ using GLib;
using TelepathyGLib;
using Folks;
-public errordomain Tpf.PersonaError
-{
- INVALID_ARGUMENT
-}
-
/**
* A persona subclass which represents a single instant messaging contact from
* Telepathy.
@@ -212,18 +207,9 @@ public class Tpf.Persona : Folks.Persona,
* Create a new persona for the { link PersonaStore} `store`, representing
* the Telepathy contact given by `contact`.
*/
- public Persona (Contact contact, PersonaStore store) throws Tpf.PersonaError
+ public Persona (Contact contact, PersonaStore store)
{
- /* FIXME: There is the possibility of a crash in the error condition below
- * due to bgo#604299, where the C self variable isn't initialised until we
- * chain up to the Object constructor, below. */
unowned string id = contact.get_identifier ();
- if (id == null || id == "")
- {
- throw new Tpf.PersonaError.INVALID_ARGUMENT (
- _("Contact has an invalid ID."));
- }
-
unowned Connection connection = contact.connection;
var account = account_for_connection (connection);
string uid = this.build_uid ("telepathy", account.get_protocol (), id);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]