commit d3eafd010e4ad038e0b8671a6a9bbba2c6c21957
Author: Chenthill Palanisamy <pchenthill@novell.com>
Date:   Tue Mar 20 18:27:29 2012 +0530

    Use e_book_backend_foreach_view for notifying status messages to all the views.

diff --git a/src/addressbook/Makefile.am b/src/addressbook/Makefile.am
index 89e9230..3e672c2 100644
--- a/src/addressbook/Makefile.am
+++ b/src/addressbook/Makefile.am
@@ -23,8 +23,6 @@ libebookbackendews_la_CPPFLAGS = \
 libebookbackendews_la_SOURCES =			\
 	e-book-backend-sqlitedb.c		\
 	e-book-backend-sqlitedb.h		\
-	e-book-backend-ews-utils.c		\
-	e-book-backend-ews-utils.h		\
 	ews-oab-props.h				\
 	ews-oab-decoder.c			\
 	ews-oab-decoder.h			\
diff --git a/src/addressbook/e-book-backend-ews.c b/src/addressbook/e-book-backend-ews.c
index 45410c7..8e7d09e 100644
--- a/src/addressbook/e-book-backend-ews.c
+++ b/src/addressbook/e-book-backend-ews.c
@@ -47,7 +47,6 @@
 #include "libedata-book/e-data-book-view.h"
 #include "e-book-backend-ews.h"
 #include "e-book-backend-sqlitedb.h"
-#include "e-book-backend-ews-utils.h"
 #include "lzx/ews-oal-decompress.h"
 #include "ews-oab-decoder.h"
 #include "e-ews-item-change.h"
@@ -153,6 +152,35 @@ ews_remove_attachments (const gchar *attachment_dir)
 	return TRUE;
 }
 
+static gboolean
+ews_book_view_each_notify_status (EBookBackend *backend,
+                         	  const gchar *status)
+{
+	EList *views = e_book_backend_get_book_views (backend);
+	EIterator *iter;
+
+	if (!views)
+		return FALSE;
+
+	iter = e_list_get_iterator (views);
+
+	if (!iter) {
+		g_object_unref (views);
+		return FALSE;
+	}
+
+	while (e_iterator_is_valid (iter)) {
+		EDataBookView *view = (EDataBookView*)e_iterator_get (iter);
+
+		if (view)
+			e_data_book_view_notify_progress (view, -1, status);
+
+		e_iterator_next (iter);
+	}
+
+	return TRUE;
+}
+
 static const struct phone_field_mapping {
 	EContactField field;
 	const gchar *element;
@@ -1567,13 +1595,12 @@ ews_gal_store_contact (EContact *contact, goffset offset, guint percent, gpointe
 	if (data->collected_length == 1000 || percent >= 100) {
 		GSList *l;
 		gchar *status_message=NULL;
-		EDataBookView *book_view = e_book_backend_ews_utils_get_book_view (E_BOOK_BACKEND (data->cbews));
 
 		d(g_print ("GAL adding contacts, percent complete : %d \n", percent);)
 
 		status_message = g_strdup_printf (_("Downloading contacts in %s %d%% completed... "), priv->folder_name, percent);
-		if (book_view)
-			e_data_book_view_notify_status_message (book_view, status_message);
+		ews_book_view_each_notify_status (E_BOOK_BACKEND (data->cbews), status_message);
+		g_free (status_message);
 
 		data->contact_collector = g_slist_reverse (data->contact_collector);
 		e_book_backend_sqlitedb_add_contacts (priv->ebsdb, priv->folder_id, data->contact_collector, FALSE, error);
@@ -1581,10 +1608,6 @@ ews_gal_store_contact (EContact *contact, goffset offset, guint percent, gpointe
 		for (l = data->contact_collector; l != NULL; l = g_slist_next (l))
 			e_book_backend_notify_update (E_BOOK_BACKEND (data->cbews), E_CONTACT (l->data));
 
-		/* reset data */
-		if (book_view)
-			e_data_book_view_unref (book_view);
-		g_free (status_message);
 		g_slist_foreach (data->contact_collector, (GFunc) g_object_unref, NULL);
 		g_slist_free (data->contact_collector);
 		data->contact_collector = NULL;
@@ -2043,15 +2066,13 @@ ebews_start_sync	(gpointer data)
 	gchar *sync_state, *status_message = NULL;
 	gboolean includes_last_item;
 	GError *error = NULL;
-	EDataBookView *book_view;
 
 	ebews = (EBookBackendEws *) data;
 	priv = ebews->priv;
 
 	status_message = g_strdup (_("Syncing contacts..."));
-	book_view = e_book_backend_ews_utils_get_book_view (E_BOOK_BACKEND (ebews));
-	if (book_view)
-		e_data_book_view_notify_status_message (book_view, status_message);
+	ews_book_view_each_notify_status (E_BOOK_BACKEND (ebews), status_message);
+	g_free (status_message);
 
 	sync_state = e_book_backend_sqlitedb_get_sync_data (priv->ebsdb, priv->folder_id, NULL);
 	do
@@ -2093,16 +2114,10 @@ ebews_start_sync	(gpointer data)
 		e_book_backend_sqlitedb_set_sync_data (priv->ebsdb, priv->folder_id, sync_state, &error);
 	} while (!error && !includes_last_item);
 
-	if (book_view) {
-		e_data_book_view_notify_complete (book_view, error ? EDB_ERROR (OtherError) : 0);
-		e_data_book_view_unref (book_view);
-	}
-
 	if (!error)
 		e_book_backend_sqlitedb_set_is_populated (priv->ebsdb, priv->folder_id, TRUE, &error);
 
 	g_free (sync_state);
-	g_free (status_message);
 
 	if (error) {
 		g_warning ("Error Syncing Contacts: Folder %s Error: %s", priv->folder_id, error->message);
