}
/**
+ * 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.
+ *
+ * Since: 3.4
+ */
+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: (element-type utf8): List of field names in which the client is interested
struct _EBookClient; /* Forward reference */
+
+/**
+ * EBookClientViewFlags:
+ * @E_BOOK_CLIENT_VIEW_FLAGS_NONE: Symbolic value for no flags
+ * @E_BOOK_CLIENT_VIEW_FLAGS_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.
+ *
+ * Since: 3.4
+ */
+typedef enum {
+ E_BOOK_CLIENT_VIEW_FLAGS_NONE = 0,
+ E_BOOK_CLIENT_VIEW_FLAGS_NOTIFY_INITIAL = (1 << 0),
+} EBookClientViewFlags;
+
+
struct _EBookClientView {
GObject parent;
/*< private >*/
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
gchar * card_query;
EBookBackendSExp *card_sexp;
+ EBookClientViewFlags flags;
gboolean running;
+ gboolean complete;
GMutex *pending_mutex;
GArray *adds;
if (priv->running) {
e_book_backend_stop_book_view (priv->backend, view);
priv->running = FALSE;
+ priv->complete = FALSE;
}
}
const gchar *id,
const gchar *vcard)
{
+ EBookClientViewFlags flags;
EDataBookViewPrivate *priv = view->priv;
gchar *utf8_vcard, *utf8_id;
send_pending_changes (view);
send_pending_removes (view);
- if (priv->adds->len == THRESHOLD_ITEMS * 2) {
- send_pending_adds (view);
- }
-
- utf8_vcard = e_util_utf8_make_valid (vcard);
utf8_id = e_util_utf8_make_valid (id);
- g_array_append_val (priv->adds, utf8_vcard);
- g_array_append_val (priv->adds, utf8_id);
- g_hash_table_insert (priv->ids, g_strdup (utf8_id),
- GUINT_TO_POINTER (1));
+ /* 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_FLAGS_NOTIFY_INITIAL) != 0) {
+ gchar *utf8_id_copy = g_strdup (utf8_id);
- ensure_pending_flush_timeout (view);
+ if (priv->adds->len == THRESHOLD_ITEMS) {
+ send_pending_adds (view);
+ }
+
+ utf8_vcard = e_util_utf8_make_valid (vcard);
+
+ g_array_append_val (priv->adds, utf8_vcard);
+ g_array_append_val (priv->adds, utf8_id_copy);
+
+ ensure_pending_flush_timeout (view);
+ }
+
+ g_hash_table_insert (priv->ids, utf8_id,
+ GUINT_TO_POINTER (1));
}
static gboolean
if (!priv->running)
return;
+ /* View is complete */
+ priv->complete = TRUE;
g_mutex_lock (priv->pending_mutex);
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);
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;
}
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)
book_view->priv = priv;
+ priv->flags = E_BOOK_CLIENT_VIEW_FLAGS_NOTIFY_INITIAL;
+
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 ();
/* THRESHOLD_ITEMS * 2 because we store UID and vcard */
}
/**
+ * 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.
+ *
+ * Since: 3.4
+ **/
+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.
*
#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>
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, const gchar *id, const gchar *vcard);
__COMPLETE_SIGNAL,
__START_METHOD,
__STOP_METHOD,
+ __SET_FLAGS_METHOD,
__DISPOSE_METHOD,
__SET_FIELDS_OF_INTEREST_METHOD,
__LAST_SIGNAL
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_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_UINT (EGdbusBookViewIface, "set_flags", set_flags, __SET_FLAGS_METHOD)
E_INIT_GDBUS_METHOD_STRV (EGdbusBookViewIface, "set_fields_of_interest", set_fields_of_interest, __SET_FIELDS_OF_INTEREST_METHOD)
}
}
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)
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
e_gdbus_proxy_method_call_void ("dispose", proxy, cancellable, callback, user_data);
}
stop)
E_DECLARE_GDBUS_SYNC_METHOD_0 (book_view,
dispose)
+E_DECLARE_GDBUS_SYNC_METHOD_1 (book_view, set_flags, flags, "u")
E_DECLARE_GDBUS_SYNC_METHOD_1 (book_view, set_fields_of_interest, fields_of_interest, "as")
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
/* 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);
};
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);
/* 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
dnl ******************************
dnl D-Bus versioning
dnl ******************************
-ADDRESS_BOOK_DBUS_SERVICE_NAME="org.gnome.evolution.dataserver.AddressBook2"
+ADDRESS_BOOK_DBUS_SERVICE_NAME="org.gnome.evolution.dataserver.AddressBook3"
CALENDAR_DBUS_SERVICE_NAME="org.gnome.evolution.dataserver.Calendar1"
AC_DEFINE_UNQUOTED(
LIBEDATACAL_REVISION=0
LIBEDATACAL_AGE=0
-LIBEDATABOOK_CURRENT=12
+LIBEDATABOOK_CURRENT=13
LIBEDATABOOK_REVISION=0
LIBEDATABOOK_AGE=0