[gnome-contacts] Centralize calls to add_persona_from_details to one place
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Centralize calls to add_persona_from_details to one place
- Date: Thu, 16 Feb 2012 13:46:06 +0000 (UTC)
commit 67530e4d20017761230516735c7d34624cd57352
Author: Alexander Larsson <alexl redhat com>
Date: Thu Feb 16 14:32:02 2012 +0100
Centralize calls to add_persona_from_details to one place
This way we can add custom code there.
src/contacts-contact.vala | 5 +++++
src/contacts-linking.vala | 2 +-
src/contacts-new-contact-dialog.vala | 4 ++--
3 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index 182ff57..caf4279 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -1278,6 +1278,11 @@ public class Contacts.Contact : GLib.Object {
return null;
}
+ public static async Persona? create_primary_persona_for_details (HashTable<string, Value?> details) throws Folks.PersonaStoreError {
+ var primary_store = App.app.contacts_store.aggregator.primary_store;
+ return yield primary_store.add_persona_from_details (details);
+ }
+
internal static async void set_persona_property (Persona persona,
string property_name, Value new_value) throws PropertyError, IndividualAggregatorError, ContactError, PropertyError {
if (persona is FakePersona) {
diff --git a/src/contacts-linking.vala b/src/contacts-linking.vala
index bd60c5a..1b63ae0 100644
--- a/src/contacts-linking.vala
+++ b/src/contacts-linking.vala
@@ -583,7 +583,7 @@ namespace Contacts {
var v = Value (typeof (string));
v.set_string (main.display_name);
details.set ("full-name", v);
- write_persona = yield main.store.aggregator.primary_store.add_persona_from_details (details);
+ write_persona = yield Contact.create_primary_persona_for_details (details);
operation.added_persona (write_persona);
linkables = main_linkables;
if (other_linkables != null)
diff --git a/src/contacts-new-contact-dialog.vala b/src/contacts-new-contact-dialog.vala
index f0f0960..9e4ea09 100644
--- a/src/contacts-new-contact-dialog.vala
+++ b/src/contacts-new-contact-dialog.vala
@@ -324,13 +324,13 @@ public class Contacts.NewContactDialog : Dialog {
return;
}
- contacts_store.aggregator.primary_store.add_persona_from_details.begin (details, (obj, res) => {
+ Contact.create_primary_persona_for_details.begin (details, (obj, res) => {
var store = obj as PersonaStore;
Persona? persona = null;
Dialog dialog = null;
try {
- persona = store.add_persona_from_details.end (res);
+ persona = Contact.create_primary_persona_for_details.end (res);
} catch (Error e) {
dialog = new MessageDialog (this.get_toplevel () as Window,
DialogFlags.DESTROY_WITH_PARENT |
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]