[folks: 3/4] Make remove_persona() and remove_individual() async
- From: Travis Reitter <treitter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks: 3/4] Make remove_persona() and remove_individual() async
- Date: Mon, 26 Jul 2010 10:52:39 +0000 (UTC)
commit 3f860a202c8115de3279a5711a5d472b7ef55985
Author: Philip Withnall <philip withnall collabora co uk>
Date: Fri Jul 23 12:21:22 2010 +0100
Make remove_persona() and remove_individual() async
They could involve blocking operations, so should be async.
backends/telepathy/tp-backend-factory.vala | 10 +---------
backends/telepathy/tpf-persona-store.vala | 14 +++++++-------
folks/individual-aggregator.vala | 13 +++++--------
folks/persona-store.vala | 7 ++++++-
4 files changed, 19 insertions(+), 25 deletions(-)
---
diff --git a/backends/telepathy/tp-backend-factory.vala b/backends/telepathy/tp-backend-factory.vala
index a26592b..9390d39 100644
--- a/backends/telepathy/tp-backend-factory.vala
+++ b/backends/telepathy/tp-backend-factory.vala
@@ -53,14 +53,6 @@ public class Folks.Backends.Tp.BackendFactory : Object
*/
public BackendFactory (BackendStore backend_store)
{
- try
- {
- backend_store.add_backend (new Backend ());
- }
- catch (GLib.Error e)
- {
- warning ("Failed to add Telepathy backend to libfolks: %s",
- e.message);
- }
+ backend_store.add_backend (new Backend ());
}
}
diff --git a/backends/telepathy/tpf-persona-store.vala b/backends/telepathy/tpf-persona-store.vala
index bf1c58d..23e8f16 100644
--- a/backends/telepathy/tpf-persona-store.vala
+++ b/backends/telepathy/tpf-persona-store.vala
@@ -600,7 +600,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore
/**
* { inheritDoc}
*/
- public override void remove_persona (Folks.Persona persona)
+ public override async void remove_persona (Folks.Persona persona)
{
var tp_persona = (Tpf.Persona) persona;
@@ -609,10 +609,10 @@ public class Tpf.PersonaStore : Folks.PersonaStore
this.ll.channel_group_change_membership (this.stored,
(Handle) tp_persona.contact.handle, false);
}
- catch (GLib.Error e)
+ catch (GLib.Error e1)
{
warning ("failed to remove persona '%s' (%s) from stored list: %s",
- tp_persona.uid, tp_persona.alias, e.message);
+ tp_persona.uid, tp_persona.alias, e1.message);
}
try
@@ -620,10 +620,10 @@ public class Tpf.PersonaStore : Folks.PersonaStore
this.ll.channel_group_change_membership (this.subscribe,
(Handle) tp_persona.contact.handle, false);
}
- catch (GLib.Error e)
+ catch (GLib.Error e2)
{
warning ("failed to remove persona '%s' (%s) from subscribe list: %s",
- tp_persona.uid, tp_persona.alias, e.message);
+ tp_persona.uid, tp_persona.alias, e2.message);
}
try
@@ -631,10 +631,10 @@ public class Tpf.PersonaStore : Folks.PersonaStore
this.ll.channel_group_change_membership (this.publish,
(Handle) tp_persona.contact.handle, false);
}
- catch (GLib.Error e)
+ catch (GLib.Error e3)
{
warning ("failed to remove persona '%s' (%s) from publish list: %s",
- tp_persona.uid, tp_persona.alias, e.message);
+ tp_persona.uid, tp_persona.alias, e3.message);
}
/* the contact will be actually removed (and signaled) when we hear back
diff --git a/folks/individual-aggregator.vala b/folks/individual-aggregator.vala
index 12611f1..fead467 100644
--- a/folks/individual-aggregator.vala
+++ b/folks/individual-aggregator.vala
@@ -315,13 +315,10 @@ public class Folks.IndividualAggregator : Object
*
* @param individual the { link Individual} to remove
*/
- public void remove_individual (Individual individual)
+ public async void remove_individual (Individual individual)
{
- individual.personas.foreach ((p) =>
- {
- var persona = (Persona) p;
- persona.store.remove_persona (persona);
- });
+ foreach (unowned Persona persona in individual.personas)
+ yield persona.store.remove_persona (persona);
}
/**
@@ -331,8 +328,8 @@ public class Folks.IndividualAggregator : Object
*
* @param persona the { link Persona} to remove
*/
- public void remove_persona (Persona persona)
+ public async void remove_persona (Persona persona)
{
- persona.store.remove_persona (persona);
+ yield persona.store.remove_persona (persona);
}
}
diff --git a/folks/persona-store.vala b/folks/persona-store.vala
index 95350b4..814b7b1 100644
--- a/folks/persona-store.vala
+++ b/folks/persona-store.vala
@@ -136,7 +136,12 @@ public abstract class Folks.PersonaStore : Object
/**
* Remove a { link Persona} from the PersonaStore.
*
+ * It isn't guaranteed that the Persona will actually be removed by the time
+ * this asynchronous function finishes. The successful removal of the Persona
+ * will be signalled through emission of
+ * { link PersonaStore.personas_changed}.
+ *
* @param persona the { link Persona} to remove
*/
- public abstract void remove_persona (Persona persona);
+ public abstract async void remove_persona (Persona persona);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]