[folks] libsocialweb: check contacts capabilities and disconnect signals
- From: Alban Crequy <albanc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] libsocialweb: check contacts capabilities and disconnect signals
- Date: Tue, 5 Apr 2011 13:29:57 +0000 (UTC)
commit ea92ae0ac24d181cb64840df86b7c6c821105f79
Author: Alban Crequy <alban crequy collabora co uk>
Date: Mon Mar 28 15:43:57 2011 +0100
libsocialweb: check contacts capabilities and disconnect signals
backends/libsocialweb/lib/swf-persona-store.vala | 53 +++++++++++++++-------
1 files changed, 37 insertions(+), 16 deletions(-)
---
diff --git a/backends/libsocialweb/lib/swf-persona-store.vala b/backends/libsocialweb/lib/swf-persona-store.vala
index a4c6440..c03816e 100644
--- a/backends/libsocialweb/lib/swf-persona-store.vala
+++ b/backends/libsocialweb/lib/swf-persona-store.vala
@@ -131,6 +131,13 @@ public class Swf.PersonaStore : Folks.PersonaStore
this._personas = new HashTable<string, Persona> (str_hash, str_equal);
}
+ ~PersonaStore ()
+ {
+ this._contact_view.contacts_added.disconnect (this.contacts_added_cb);
+ this._contact_view.contacts_changed.disconnect (this.contacts_changed_cb);
+ this._contact_view.contacts_removed.disconnect (this.contacts_removed_cb);
+ }
+
/**
* Add a new { link Persona} to the PersonaStore.
*
@@ -166,25 +173,39 @@ public class Swf.PersonaStore : Folks.PersonaStore
{
if (!this._is_prepared)
{
- var parameters = new HashTable<weak string, weak string> (
- str_hash, str_equal);
- this._service.contacts_query_open_view("people", parameters,
- (query, contact_view) =>
+ this._service.get_static_capabilities (
+ (service, caps, error) =>
{
- /* The D-Bus call could return an error. In this case,
- * contact_view is null */
- if (contact_view == null)
+ if (caps == null)
return;
- contact_view.contacts_added.connect (this.contacts_added_cb);
- contact_view.contacts_changed.connect (this.contacts_changed_cb);
- contact_view.contacts_removed.connect (this.contacts_removed_cb);
-
- this._contact_view = contact_view;
- this._is_prepared = true;
- this.notify_property ("is-prepared");
-
- this._contact_view.start ();
+ bool has_contacts = ClientService.has_cap (caps,
+ "has-contacts-query-iface");
+ if (!has_contacts)
+ return;
+ var parameters = new HashTable<weak string, weak string>
+ (str_hash, str_equal);
+ this._service.contacts_query_open_view
+ ("people", parameters, (query, contact_view) =>
+ {
+ /* The D-Bus call could return an error. In this
+ * case, contact_view is null */
+ if (contact_view == null)
+ return;
+
+ contact_view.contacts_added.connect
+ (this.contacts_added_cb);
+ contact_view.contacts_changed.connect
+ (this.contacts_changed_cb);
+ contact_view.contacts_removed.connect
+ (this.contacts_removed_cb);
+
+ this._contact_view = contact_view;
+ this._is_prepared = true;
+ this.notify_property ("is-prepared");
+
+ this._contact_view.start ();
+ });
});
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]