summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlban Crequy <alban.crequy@collabora.co.uk>2011-03-28 12:25:14 (GMT)
committerAlban Crequy <alban.crequy@collabora.co.uk>2011-03-31 15:07:31 (GMT)
commitbb13a0c9385263da428943e79d0d27a7c6cbe0eb (patch)
treed884b9434663115d66a46f2fb25e35d0166bfa2b
parente3a345ec08fffdfb456b8780ab5ad2aeb4e83b0f (diff)
downloadlibsocialweb-bb13a0c9385263da428943e79d0d27a7c6cbe0eb.tar.gz
libsocialweb-bb13a0c9385263da428943e79d0d27a7c6cbe0eb.tar.xz
lsw-client: Implements queries for contacts
-rw-r--r--libsocialweb-client/sw-client-service.c95
-rw-r--r--libsocialweb-client/sw-client-service.h15
2 files changed, 110 insertions, 0 deletions
diff --git a/libsocialweb-client/sw-client-service.c b/libsocialweb-client/sw-client-service.c
index 367911d..2d9d78d 100644
--- a/libsocialweb-client/sw-client-service.c
+++ b/libsocialweb-client/sw-client-service.c
@@ -24,6 +24,7 @@
#include <interfaces/sw-service-bindings.h>
#include <interfaces/sw-status-update-bindings.h>
+#include <interfaces/sw-contacts-query-bindings.h>
#include <interfaces/sw-query-bindings.h>
#include <interfaces/sw-avatar-bindings.h>
#include <interfaces/sw-banishable-bindings.h>
@@ -53,6 +54,7 @@ typedef enum
SERVICE_IFACE,
AVATAR_IFACE,
QUERY_IFACE,
+ CONTACTS_QUERY_IFACE,
STATUS_UPDATE_IFACE,
BANISHABLE_IFACE,
PHOTO_UPLOAD_IFACE,
@@ -72,6 +74,7 @@ static const gchar *interface_names[LAST_IFACE] = {
"com.meego.libsocialweb.Service",
"com.meego.libsocialweb.Avatar",
"com.meego.libsocialweb.Query",
+ "com.meego.libsocialweb.ContactsQuery",
"com.meego.libsocialweb.StatusUpdate",
"com.meego.libsocialweb.Banishable",
"com.meego.libsocialweb.PhotoUpload",
@@ -987,6 +990,98 @@ sw_client_service_query_open_view (SwClientService *service
g_hash_table_unref (tmp_params);
}
+static void
+_contacts_query_open_view_cb (DBusGProxy *proxy,
+ gchar *view_path,
+ GError *error,
+ gpointer userdata)
+{
+ SwClientContactView *contact_view = NULL;
+ SwClientServiceContactsQueryOpenViewCallback cb;
+ SwClientServiceCallClosure *closure = (SwClientServiceCallClosure *)userdata;
+
+ if (error)
+ {
+ SwClientServicePrivate *priv = GET_PRIVATE (closure->service);
+ g_warning (G_STRLOC ": Error calling OpenView on service %s: %s",
+ priv->name,
+ error->message);
+ g_error_free (error);
+ } else {
+ contact_view = _sw_client_contact_view_new_for_path (view_path);
+ g_free (view_path);
+ }
+
+ cb = (SwClientServiceContactsQueryOpenViewCallback)closure->cb;
+
+ cb (closure->service,
+ contact_view,
+ closure->userdata);
+
+ g_object_unref (closure->service);
+ g_slice_free (SwClientServiceCallClosure, closure);
+}
+
+/**
+ * SwClientServiceContactsQueryOpenViewCallback:
+ * @query:
+ * @contact_view: (allow-none):
+ * @userdata: (closure):
+ */
+
+/**
+ * sw_client_service_contacts_query_open_view:
+ * @service:
+ * @query:
+ * @params: (element-type gchar* gchar*):
+ * @cb: (scope async):
+ * @userdata: (closure):
+ */
+void
+sw_client_service_contacts_query_open_view (SwClientService *service,
+ const gchar *query,
+ GHashTable *params,
+ SwClientServiceContactsQueryOpenViewCallback cb,
+ gpointer userdata)
+{
+ SwClientServicePrivate *priv = GET_PRIVATE (service);
+ SwClientServiceCallClosure *closure;
+ GError *error = NULL;
+ GHashTable *tmp_params = NULL;
+
+ if (!_sw_client_service_setup_proxy_for_iface (service,
+ priv->name,
+ CONTACTS_QUERY_IFACE,
+ &error))
+ {
+ g_critical (G_STRLOC ": Unable to setup proxy on Query interface: %s",
+ error->message);
+ g_clear_error (&error);
+ return;
+ }
+
+ closure = g_slice_new0 (SwClientServiceCallClosure);
+ closure->service = g_object_ref (service);
+ closure->cb = (GCallback)cb;
+ closure->userdata = userdata;
+
+ if (!params)
+ {
+ tmp_params = g_hash_table_new (g_str_hash, g_str_equal);
+ params = tmp_params;
+ }
+
+ com_meego_libsocialweb_ContactsQuery_open_view_async
+ (priv->proxies [CONTACTS_QUERY_IFACE],
+ query,
+ params,
+ _contacts_query_open_view_cb,
+ closure);
+
+ if (tmp_params)
+ g_hash_table_unref (tmp_params);
+}
+
#define GROUP "LibSocialWebService"
static void
diff --git a/libsocialweb-client/sw-client-service.h b/libsocialweb-client/sw-client-service.h
index 6a6b292..f85df2e 100644
--- a/libsocialweb-client/sw-client-service.h
+++ b/libsocialweb-client/sw-client-service.h
@@ -23,6 +23,8 @@
#include <gio/gio.h>
#include <libsocialweb-client/sw-item.h>
#include <libsocialweb-client/sw-client-item-view.h>
+#include <libsocialweb-client/sw-contact.h>
+#include <libsocialweb-client/sw-client-contact-view.h>
G_BEGIN_DECLS
@@ -155,6 +157,19 @@ sw_client_service_query_open_view (SwClientService *service
SwClientServiceQueryOpenViewCallback cb,
gpointer userdata);
+typedef void (*SwClientServiceContactsQueryOpenViewCallback)
+ (SwClientService *query,
+ SwClientContactView *contact_view,
+ gpointer userdata);
+
+void
+sw_client_service_contacts_query_open_view
+ (SwClientService *service,
+ const gchar *query,
+ GHashTable *params,
+ SwClientServiceContactsQueryOpenViewCallback cb,
+ gpointer userdata);
+
void
sw_client_service_banishable_hide_item (SwClientService *service,
const gchar *uid);