[evolution-data-server/openismus-work-master: 1/7] Added e_book_client_view_set_flags()
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/openismus-work-master: 1/7] Added e_book_client_view_set_flags()
- Date: Fri, 22 Jul 2011 19:18:06 +0000 (UTC)
commit 906f7135e274aaac4038a4672f3bed5d39443718
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Fri Jun 24 18:25:24 2011 -0400
Added e_book_client_view_set_flags()
This commit adds a EBookClientViewFlags to EBookClientView with
an initial flag value E_BOOK_CLIENT_VIEW_NOTIFY_INITIAL to control
whether the initial contact notifications are sent. The default
is to send notifications, if the flag is unset then only future
notifications are issued.
addressbook/libebook/e-book-client-view.c | 32 ++++++++++++++++
addressbook/libebook/e-book-client-view.h | 24 ++++++++++++
addressbook/libedata-book/e-data-book-view.c | 51 ++++++++++++++++++++++++--
addressbook/libedata-book/e-data-book-view.h | 3 ++
addressbook/libegdbus/e-gdbus-book-view.c | 31 ++++++++++++++--
addressbook/libegdbus/e-gdbus-book-view.h | 15 ++++++++
6 files changed, 149 insertions(+), 7 deletions(-)
---
diff --git a/addressbook/libebook/e-book-client-view.c b/addressbook/libebook/e-book-client-view.c
index 394a2e8..6c09ccc 100644
--- a/addressbook/libebook/e-book-client-view.c
+++ b/addressbook/libebook/e-book-client-view.c
@@ -249,6 +249,38 @@ e_book_client_view_stop (EBookClientView *view, GError **error)
}
/**
+ * e_book_client_view_set_flags:
+ * @view: an #EBookClientView
+ * @flags: the #EBookClientViewFlags for @view.
+ * @error: a return location for a #GError, or %NULL.
+ *
+ * Sets the @flags which control the behaviour of @view.
+ */
+void
+e_book_client_view_set_flags (EBookClientView *view,
+ EBookClientViewFlags flags,
+ GError **error)
+{
+ EBookClientViewPrivate *priv;
+
+ g_return_if_fail (view != NULL);
+ g_return_if_fail (E_IS_BOOK_CLIENT_VIEW (view));
+
+ priv = view->priv;
+
+ if (priv->gdbus_bookview) {
+ GError *local_error = NULL;
+
+ e_gdbus_book_view_call_set_flags_sync (priv->gdbus_bookview, flags, NULL, &local_error);
+
+ e_client_unwrap_dbus_error (E_CLIENT (priv->client), local_error, error);
+ } else {
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR,
+ _("Cannot set flags on view, D-Bus proxy gone"));
+ }
+}
+
+/**
* e_book_client_view_set_fields_of_interest:
* @view: An #EBookClientView object
* @fields_of_interest: List of field names in which the client is interested
diff --git a/addressbook/libebook/e-book-client-view.h b/addressbook/libebook/e-book-client-view.h
index 60d58a6..24a91d9 100644
--- a/addressbook/libebook/e-book-client-view.h
+++ b/addressbook/libebook/e-book-client-view.h
@@ -38,6 +38,29 @@ typedef struct _EBookClientViewPrivate EBookClientViewPrivate;
struct _EBookClient; /* Forward reference */
+
+/**
+ * EBookClientViewFlags:
+ * @E_BOOK_CLIENT_VIEW_NOTIFY_INITIAL: If this flag is set then all contacts matching the
+ * view's query will be sent as notifications when starting
+ * the view, otherwise only future changes will be reported.
+ * The default for a #EBookClientView is %TRUE.
+ *
+ * Flags that control the behaviour of an #EBookClientView.
+ */
+typedef enum {
+ E_BOOK_CLIENT_VIEW_NOTIFY_INITIAL = (1 << 0),
+} EBookClientViewFlags;
+
+
+/**
+ * E_BOOK_CLIENT_VIEW_DEFAULT_FLAGS:
+ *
+ * The default values for a book view's #EBookClientViewFlags
+ */
+#define E_BOOK_CLIENT_VIEW_DEFAULT_FLAGS E_BOOK_CLIENT_VIEW_NOTIFY_INITIAL
+
+
struct _EBookClientView {
GObject parent;
/*< private >*/
@@ -64,6 +87,7 @@ gboolean e_book_client_view_is_running (EBookClientView *view);
void e_book_client_view_set_fields_of_interest (EBookClientView *view, const GSList *fields_of_interest, GError **error);
void e_book_client_view_start (EBookClientView *view, GError **error);
void e_book_client_view_stop (EBookClientView *view, GError **error);
+void e_book_client_view_set_flags (EBookClientView *view, EBookClientViewFlags flags, GError **error);
G_END_DECLS
diff --git a/addressbook/libedata-book/e-data-book-view.c b/addressbook/libedata-book/e-data-book-view.c
index 3d50d06..0db38f3 100644
--- a/addressbook/libedata-book/e-data-book-view.c
+++ b/addressbook/libedata-book/e-data-book-view.c
@@ -26,6 +26,7 @@
#include <string.h>
#include <libebook/e-contact.h>
+#include <libebook/e-book-view.h>
#include "libedataserver/e-data-server-util.h"
#include "e-data-book-view.h"
@@ -47,8 +48,10 @@ struct _EDataBookViewPrivate {
gchar * card_query;
EBookBackendSExp *card_sexp;
+ EBookClientViewFlags flags;
gboolean running;
+ gboolean complete;
GMutex *pending_mutex;
GArray *adds;
@@ -57,7 +60,6 @@ struct _EDataBookViewPrivate {
GHashTable *ids;
guint idle_id;
-
guint flush_id;
/* which fields is listener interested in */
@@ -145,6 +147,7 @@ book_destroyed_cb (gpointer data, GObject *dead)
if (priv->running) {
e_book_backend_stop_book_view (priv->backend, view);
priv->running = FALSE;
+ priv->complete = FALSE;
}
}
@@ -265,14 +268,19 @@ notify_remove (EDataBookView *view, const gchar *id)
static void
notify_add (EDataBookView *view, const gchar *id, const gchar *vcard)
{
+ EBookClientViewFlags flags;
EDataBookViewPrivate *priv = view->priv;
gchar *utf8_vcard;
send_pending_changes (view);
send_pending_removes (view);
- if (priv->adds->len == THRESHOLD_ITEMS) {
- send_pending_adds (view);
+ /* Do not send contact add notifications during initial stage */
+ flags = e_data_book_view_get_flags (view);
+ if (priv->complete || (flags & E_BOOK_CLIENT_VIEW_NOTIFY_INITIAL) != 0) {
+ if (priv->adds->len == THRESHOLD_ITEMS) {
+ send_pending_adds (view);
+ }
}
utf8_vcard = e_util_utf8_make_valid (vcard);
@@ -532,6 +540,8 @@ e_data_book_view_notify_complete (EDataBookView *book_view, const GError *error)
if (!priv->running)
return;
+ /* View is complete */
+ priv->complete = TRUE;
g_mutex_lock (priv->pending_mutex);
@@ -604,6 +614,7 @@ bookview_idle_start (gpointer data)
EDataBookView *book_view = data;
book_view->priv->running = TRUE;
+ book_view->priv->complete = FALSE;
book_view->priv->idle_id = 0;
e_book_backend_start_book_view (book_view->priv->backend, book_view);
@@ -629,6 +640,7 @@ bookview_idle_stop (gpointer data)
e_book_backend_stop_book_view (book_view->priv->backend, book_view);
book_view->priv->running = FALSE;
+ book_view->priv->complete = FALSE;
book_view->priv->idle_id = 0;
return FALSE;
@@ -648,6 +660,19 @@ impl_DataBookView_stop (EGdbusBookView *object, GDBusMethodInvocation *invocatio
}
static gboolean
+impl_DataBookView_setFlags (EGdbusBookView *object,
+ GDBusMethodInvocation *invocation,
+ EBookClientViewFlags flags,
+ EDataBookView *book_view)
+{
+ book_view->priv->flags = flags;
+
+ e_gdbus_book_view_complete_set_flags (object, invocation, NULL);
+
+ return TRUE;
+}
+
+static gboolean
impl_DataBookView_dispose (EGdbusBookView *object, GDBusMethodInvocation *invocation, EDataBookView *book_view)
{
e_gdbus_book_view_complete_dispose (object, invocation, NULL);
@@ -668,14 +693,18 @@ e_data_book_view_init (EDataBookView *book_view)
book_view->priv = priv;
+ priv->flags = E_BOOK_CLIENT_VIEW_DEFAULT_FLAGS;
+
priv->gdbus_object = e_gdbus_book_view_stub_new ();
g_signal_connect (priv->gdbus_object, "handle-start", G_CALLBACK (impl_DataBookView_start), book_view);
g_signal_connect (priv->gdbus_object, "handle-stop", G_CALLBACK (impl_DataBookView_stop), book_view);
+ g_signal_connect (priv->gdbus_object, "handle-set-flags", G_CALLBACK (impl_DataBookView_setFlags), book_view);
g_signal_connect (priv->gdbus_object, "handle-dispose", G_CALLBACK (impl_DataBookView_dispose), book_view);
g_signal_connect (priv->gdbus_object, "handle-set-fields-of-interest", G_CALLBACK (impl_DataBookView_set_fields_of_interest), book_view);
priv->fields_of_interest = NULL;
priv->running = FALSE;
+ priv->complete = FALSE;
priv->pending_mutex = g_mutex_new ();
priv->adds = g_array_sized_new (TRUE, TRUE, sizeof (gchar *), THRESHOLD_ITEMS);
@@ -802,6 +831,22 @@ e_data_book_view_get_backend (EDataBookView *book_view)
}
/**
+ * e_data_book_view_get_flags:
+ * @book_view: an #EDataBookView
+ *
+ * Gets the #EBookClientViewFlags that control the behaviour of @book_view.
+ *
+ * Returns: the flags for @book_view.
+ **/
+EBookClientViewFlags
+e_data_book_view_get_flags (EDataBookView *book_view)
+{
+ g_return_val_if_fail (E_IS_DATA_BOOK_VIEW (book_view), 0);
+
+ return book_view->priv->flags;
+}
+
+/**
* e_data_book_view_get_fields_of_interest:
* @view: A view object.
*
diff --git a/addressbook/libedata-book/e-data-book-view.h b/addressbook/libedata-book/e-data-book-view.h
index fc33d14..3e38cc5 100644
--- a/addressbook/libedata-book/e-data-book-view.h
+++ b/addressbook/libedata-book/e-data-book-view.h
@@ -26,6 +26,7 @@
#include <gio/gio.h>
#include <libebook/e-contact.h>
+#include <libebook/e-book-client-view.h>
#include <libedata-book/e-data-book-types.h>
#include <libedata-book/e-book-backend.h>
#include <libedata-book/e-book-backend-sexp.h>
@@ -57,6 +58,8 @@ guint e_data_book_view_register_gdbus_object (EDataBookView *query, GDBusConne
const gchar * e_data_book_view_get_card_query (EDataBookView *book_view);
EBookBackendSExp * e_data_book_view_get_card_sexp (EDataBookView *book_view);
EBookBackend * e_data_book_view_get_backend (EDataBookView *book_view);
+EBookClientViewFlags e_data_book_view_get_flags (EDataBookView *book_view);
+
void e_data_book_view_notify_update (EDataBookView *book_view, const EContact *contact);
void e_data_book_view_notify_update_vcard (EDataBookView *book_view, gchar *vcard);
diff --git a/addressbook/libegdbus/e-gdbus-book-view.c b/addressbook/libegdbus/e-gdbus-book-view.c
index c2b3609..4b6675f 100644
--- a/addressbook/libegdbus/e-gdbus-book-view.c
+++ b/addressbook/libegdbus/e-gdbus-book-view.c
@@ -42,6 +42,7 @@ enum
__COMPLETE_SIGNAL,
__START_METHOD,
__STOP_METHOD,
+ __SET_FLAGS_METHOD,
__DISPOSE_METHOD,
__SET_FIELDS_OF_INTEREST_METHOD,
__LAST_SIGNAL
@@ -107,10 +108,12 @@ e_gdbus_book_view_default_init (EGdbusBookViewIface *iface)
E_INIT_GDBUS_SIGNAL_STRV (EGdbusBookViewIface, "complete", complete, __COMPLETE_SIGNAL)
/* GObject signals definitions for D-Bus methods: */
- E_INIT_GDBUS_METHOD_VOID (EGdbusBookViewIface, "start", start, __START_METHOD)
- E_INIT_GDBUS_METHOD_VOID (EGdbusBookViewIface, "stop", stop, __STOP_METHOD)
- E_INIT_GDBUS_METHOD_VOID (EGdbusBookViewIface, "dispose", dispose, __DISPOSE_METHOD)
- E_INIT_GDBUS_METHOD_STRV (EGdbusBookViewIface, "set_fields_of_interest", set_fields_of_interest, __SET_FIELDS_OF_INTEREST_METHOD)
+ E_INIT_GDBUS_METHOD_VOID (EGdbusBookViewIface, "start", start, __START_METHOD)
+ E_INIT_GDBUS_METHOD_VOID (EGdbusBookViewIface, "stop", stop, __STOP_METHOD)
+ E_INIT_GDBUS_METHOD_UINT (EGdbusBookViewIface, "set_flags", set_flags, __SET_FLAGS_METHOD)
+ E_INIT_GDBUS_METHOD_VOID (EGdbusBookViewIface, "dispose", dispose, __DISPOSE_METHOD)
+ E_INIT_GDBUS_METHOD_STRV (EGdbusBookViewIface, "set_fields_of_interest", set_fields_of_interest,
+ __SET_FIELDS_OF_INTEREST_METHOD)
}
void
@@ -150,6 +153,24 @@ e_gdbus_book_view_call_stop_sync (GDBusProxy *proxy, GCancellable *cancellable,
}
void
+e_gdbus_book_view_call_set_flags (GDBusProxy *proxy, guint in_flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
+{
+ e_gdbus_proxy_method_call_uint ("set_flags", proxy, in_flags, cancellable, callback, user_data);
+}
+
+gboolean
+e_gdbus_book_view_call_set_flags_finish (GDBusProxy *proxy, GAsyncResult *result, GError **error)
+{
+ return e_gdbus_proxy_method_call_finish_void (proxy, result, error);
+}
+
+gboolean
+e_gdbus_book_view_call_set_flags_sync (GDBusProxy *proxy, guint in_flags, GCancellable *cancellable, GError **error)
+{
+ return e_gdbus_proxy_method_call_sync_uint__void ("set_flags", proxy, in_flags, cancellable, error);
+}
+
+void
e_gdbus_book_view_call_dispose (GDBusProxy *proxy, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
{
e_gdbus_proxy_method_call_void ("dispose", proxy, cancellable, callback, user_data);
@@ -223,6 +244,7 @@ E_DECLARE_GDBUS_NOTIFY_SIGNAL_1 (book_view, complete, error, "as")
E_DECLARE_GDBUS_SYNC_METHOD_0 (book_view, start)
E_DECLARE_GDBUS_SYNC_METHOD_0 (book_view, stop)
+E_DECLARE_GDBUS_SYNC_METHOD_1 (book_view, set_flags, flags, "u")
E_DECLARE_GDBUS_SYNC_METHOD_0 (book_view, dispose)
E_DECLARE_GDBUS_SYNC_METHOD_1 (book_view, set_fields_of_interest, fields_of_interest, "as")
@@ -230,6 +252,7 @@ static const GDBusMethodInfo * const e_gdbus_book_view_method_info_pointers[] =
{
&E_DECLARED_GDBUS_METHOD_INFO_NAME (book_view, start),
&E_DECLARED_GDBUS_METHOD_INFO_NAME (book_view, stop),
+ &E_DECLARED_GDBUS_METHOD_INFO_NAME (book_view, set_flags),
&E_DECLARED_GDBUS_METHOD_INFO_NAME (book_view, dispose),
&E_DECLARED_GDBUS_METHOD_INFO_NAME (book_view, set_fields_of_interest),
NULL
diff --git a/addressbook/libegdbus/e-gdbus-book-view.h b/addressbook/libegdbus/e-gdbus-book-view.h
index a271eea..56e8965 100644
--- a/addressbook/libegdbus/e-gdbus-book-view.h
+++ b/addressbook/libegdbus/e-gdbus-book-view.h
@@ -114,6 +114,7 @@ struct _EGdbusBookViewIface
/* Signal handlers for handling D-Bus method calls: */
gboolean (*handle_start) (EGdbusBookView *object, GDBusMethodInvocation *invocation);
gboolean (*handle_stop) (EGdbusBookView *object, GDBusMethodInvocation *invocation);
+ gboolean (*handle_set_flags) (EGdbusBookView *object, GDBusMethodInvocation *invocation, guint in_flags);
gboolean (*handle_dispose) (EGdbusBookView *object, GDBusMethodInvocation *invocation);
gboolean (*handle_set_fields_of_interest)(EGdbusBookView *object, GDBusMethodInvocation *invocation, const gchar * const *in_only_fields);
};
@@ -127,6 +128,19 @@ void e_gdbus_book_view_call_stop (GDBusProxy *proxy, GCancellable *cancellable
gboolean e_gdbus_book_view_call_stop_finish (GDBusProxy *proxy, GAsyncResult *result, GError **error);
gboolean e_gdbus_book_view_call_stop_sync (GDBusProxy *proxy, GCancellable *cancellable, GError **error);
+void e_gdbus_book_view_call_set_flags (GDBusProxy *proxy,
+ guint in_flags,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean e_gdbus_book_view_call_set_flags_finish (GDBusProxy *proxy,
+ GAsyncResult *res,
+ GError **error);
+gboolean e_gdbus_book_view_call_set_flags_sync (GDBusProxy *proxy,
+ guint in_flags,
+ GCancellable *cancellable,
+ GError **error);
+
void e_gdbus_book_view_call_dispose (GDBusProxy *proxy, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data);
gboolean e_gdbus_book_view_call_dispose_finish (GDBusProxy *proxy, GAsyncResult *result, GError **error);
gboolean e_gdbus_book_view_call_dispose_sync (GDBusProxy *proxy, GCancellable *cancellable, GError **error);
@@ -138,6 +152,7 @@ gboolean e_gdbus_book_view_call_set_fields_of_interest_sync (GDBusProxy *proxy,
/* D-Bus Methods Completion Helpers */
#define e_gdbus_book_view_complete_start e_gdbus_complete_sync_method_void
#define e_gdbus_book_view_complete_stop e_gdbus_complete_sync_method_void
+#define e_gdbus_book_view_complete_set_flags e_gdbus_complete_sync_method_void
#define e_gdbus_book_view_complete_dispose e_gdbus_complete_sync_method_void
#define e_gdbus_book_view_complete_set_fields_of_interest e_gdbus_complete_sync_method_void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]