[evolution-data-server/meego-eds] Fix "avoid initial notifications" functionality
- From: Christophe Dumez <cdumez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/meego-eds] Fix "avoid initial notifications" functionality
- Date: Tue, 21 Jun 2011 13:29:50 +0000 (UTC)
commit a66d6bcc8883fe0203d1117f3d0364244941fb68
Author: Christophe Dumez <christophe dumez intel com>
Date: Tue Jun 21 16:26:58 2011 +0300
Fix "avoid initial notifications" functionality
The file backend does need to notify the view so that it can
update its hash table of ids. The filtering needs to be done in
EDataBookView instead, AFTER the hash table is updated.
This way, the functionality does not require any change in the
backend and works for all backends.
Bug report:
https://bugzilla.gnome.org/show_bug.cgi?id=652171
addressbook/backends/file/e-book-backend-file.c | 17 ++++-------------
addressbook/libedata-book/e-data-book-view.c | 16 ++++++++++++++--
2 files changed, 18 insertions(+), 15 deletions(-)
---
diff --git a/addressbook/backends/file/e-book-backend-file.c b/addressbook/backends/file/e-book-backend-file.c
index efb7047..a65e126 100644
--- a/addressbook/backends/file/e-book-backend-file.c
+++ b/addressbook/backends/file/e-book-backend-file.c
@@ -803,21 +803,12 @@ static void
e_book_backend_file_start_book_view (EBookBackend *backend,
EDataBookView *book_view)
{
- FileBackendSearchClosure *closure;
- EBookViewFlags flags;
-
- /* Start a thread and send all the initial notifications if appropriate */
- flags = e_data_book_view_get_flags (book_view);
- if ((flags & E_BOOK_VIEW_NOTIFY_INITIAL) != 0) {
- d(printf ("starting book view thread\n"));
+ FileBackendSearchClosure *closure = init_closure (book_view, E_BOOK_BACKEND_FILE (backend));
- closure = init_closure (book_view, E_BOOK_BACKEND_FILE (backend));
- closure->thread = g_thread_create (book_view_thread, book_view, TRUE, NULL);
+ d(printf ("starting book view thread\n"));
+ closure->thread = g_thread_create (book_view_thread, book_view, TRUE, NULL);
- e_flag_wait (closure->running);
- }
- else
- e_data_book_view_notify_complete (book_view, NULL /* Success */);
+ e_flag_wait (closure->running);
/* at this point we know the book view thread is actually running */
d(printf ("returning from start_book_view\n"));
diff --git a/addressbook/libedata-book/e-data-book-view.c b/addressbook/libedata-book/e-data-book-view.c
index 24e124f..b011f0c 100644
--- a/addressbook/libedata-book/e-data-book-view.c
+++ b/addressbook/libedata-book/e-data-book-view.c
@@ -53,6 +53,7 @@ struct _EDataBookViewPrivate {
EBookViewFlags flags;
gboolean running;
+ gboolean complete;
GMutex *pending_mutex;
GArray *adds;
@@ -108,6 +109,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;
}
}
@@ -225,12 +227,17 @@ notify_remove (EDataBookView *view, gchar *id)
static void
notify_add (EDataBookView *view, const gchar *id, gchar *vcard)
{
+ EBookViewFlags flags;
EDataBookViewPrivate *priv = view->priv;
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_VIEW_NOTIFY_INITIAL) != 0) {
+ if (priv->adds->len == THRESHOLD_ITEMS) {
+ send_pending_adds (view);
+ }
}
g_array_append_val (priv->adds, vcard);
@@ -438,6 +445,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);
@@ -515,6 +524,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);
@@ -540,6 +550,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;
@@ -596,6 +607,7 @@ e_data_book_view_init (EDataBookView *book_view)
g_signal_connect (priv->gdbus_object, "handle-dispose", G_CALLBACK (impl_DataBookView_dispose), book_view);
priv->running = FALSE;
+ priv->complete = FALSE;
priv->pending_mutex = g_mutex_new ();
priv->adds = g_array_sized_new (TRUE, TRUE, sizeof (gchar *), THRESHOLD_ITEMS);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]