[evolution-ews] Bug 654939 - Show OAB download progress in UI
- From: Chenthill Palanisamy <pchen src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews] Bug 654939 - Show OAB download progress in UI
- Date: Wed, 3 Aug 2011 08:52:28 +0000 (UTC)
commit 6e2f623cf02425e3dd673306c440b6f6fba8e83d
Author: Punit Jain <jpunit novell com>
Date: Wed Aug 3 14:20:35 2011 +0530
Bug 654939 - Show OAB download progress in UI
src/addressbook/Makefile.am | 2 +
src/addressbook/e-book-backend-ews-gal.c | 9 +++-
src/addressbook/e-book-backend-ews-utils.c | 80 ++++++++++++++++++++++++++++
src/addressbook/e-book-backend-ews-utils.h | 25 +++++++++
src/addressbook/e-book-backend-ews.c | 11 ++++-
src/addressbook/ews-oab-decoder.c | 2 +-
6 files changed, 126 insertions(+), 3 deletions(-)
---
diff --git a/src/addressbook/Makefile.am b/src/addressbook/Makefile.am
index d67e709..b82b21f 100644
--- a/src/addressbook/Makefile.am
+++ b/src/addressbook/Makefile.am
@@ -23,6 +23,8 @@ 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-gal.c b/src/addressbook/e-book-backend-ews-gal.c
index 0d67dbf..6ee1c8a 100644
--- a/src/addressbook/e-book-backend-ews-gal.c
+++ b/src/addressbook/e-book-backend-ews-gal.c
@@ -47,6 +47,7 @@
#include "e-book-backend-ews-gal.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"
@@ -284,15 +285,20 @@ ews_gal_store_contact (EContact *contact, goffset offset, guint percent, gpointe
{
struct _db_data *data = (struct _db_data *) user_data;
EBookBackendEwsGalPrivate *priv = data->cbews->priv;
-
+
data->contact_collector = g_slist_prepend (data->contact_collector, g_object_ref (contact));
data->collected_length += 1;
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);
+ e_data_book_view_notify_status_message (book_view, status_message);
+
data->contact_collector = g_slist_reverse (data->contact_collector);
e_book_backend_sqlitedb_add_contacts (priv->ebsdb, priv->oal_id, data->contact_collector, FALSE, error);
@@ -300,6 +306,7 @@ ews_gal_store_contact (EContact *contact, goffset offset, guint percent, gpointe
e_book_backend_notify_update (E_BOOK_BACKEND (data->cbews), E_CONTACT (l->data));
/* reset data */
+ 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;
diff --git a/src/addressbook/e-book-backend-ews-utils.c b/src/addressbook/e-book-backend-ews-utils.c
new file mode 100644
index 0000000..e3aed40
--- /dev/null
+++ b/src/addressbook/e-book-backend-ews-utils.c
@@ -0,0 +1,80 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/* e-book-backend-ews-utils.c - Ews personal addressbook and GAL common funtions.
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <time.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <glib/gi18n-lib.h>
+
+#include "e-book-backend-ews-utils.h"
+#include "libedata-book/e-book-backend-sexp.h"
+#include "libedata-book/e-data-book.h"
+#include "libedata-book/e-data-book-view.h"
+
+
+/**
+ * e_book_backend_ews_utils_get_book_view:
+ * @backend: an #EBookBackend
+ *
+ * Gets the currrent (first) #EDataBookView from this backend.
+ *
+ * Returns: An #EDataBookView object.
+ **/
+EDataBookView *
+e_book_backend_ews_utils_get_book_view (EBookBackend *backend)
+{
+ EList *views = e_book_backend_get_book_views (backend);
+ EIterator *iter;
+ EDataBookView *rv = NULL;
+
+ if (!views)
+ return NULL;
+
+ iter = e_list_get_iterator (views);
+
+ if (!iter) {
+ g_object_unref (views);
+ return NULL;
+ }
+
+ if (e_iterator_is_valid (iter)) {
+ /* just always use the first book view */
+ EDataBookView *v = (EDataBookView*)e_iterator_get (iter);
+ if (v)
+ rv = v;
+ }
+
+ g_object_unref (iter);
+ g_object_unref (views);
+
+ return rv;
+}
diff --git a/src/addressbook/e-book-backend-ews-utils.h b/src/addressbook/e-book-backend-ews-utils.h
new file mode 100644
index 0000000..c5c93c0
--- /dev/null
+++ b/src/addressbook/e-book-backend-ews-utils.h
@@ -0,0 +1,25 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/* e-book-backend-ews-utils.h - Ews Personal addressbook and GAL common functions
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "libedata-book/e-data-book-view.h"
+
+EDataBookView* e_book_backend_ews_utils_get_book_view (EBookBackend *backend);
diff --git a/src/addressbook/e-book-backend-ews.c b/src/addressbook/e-book-backend-ews.c
index 603c1e1..3790917 100644
--- a/src/addressbook/e-book-backend-ews.c
+++ b/src/addressbook/e-book-backend-ews.c
@@ -46,6 +46,7 @@
#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 "e-ews-message.h"
#include "e-ews-connection.h"
@@ -1191,13 +1192,18 @@ ebews_start_sync (gpointer data)
{
EBookBackendEws *ebews;
EBookBackendEwsPrivate *priv;
- gchar *sync_state;
+ 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));
+
+ e_data_book_view_notify_status_message (book_view, status_message);
sync_state = e_book_backend_sqlitedb_get_sync_data (priv->ebsdb, priv->folder_id, NULL);
do
{
@@ -1238,10 +1244,13 @@ 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);
+ e_data_book_view_notify_complete (book_view, error);
+
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);
diff --git a/src/addressbook/ews-oab-decoder.c b/src/addressbook/ews-oab-decoder.c
index d74a698..77f855e 100644
--- a/src/addressbook/ews-oab-decoder.c
+++ b/src/addressbook/ews-oab-decoder.c
@@ -820,7 +820,7 @@ ews_decode_and_store_oab_records (EwsOabDecoder *eod, EwsOabContactAddedCb cb, g
uid = (gchar *) e_contact_get (contact, E_CONTACT_EMAIL_1);
e_contact_set (contact, E_CONTACT_UID, uid);
- cb (contact, offset, ((gfloat) i/priv->total_records)*100, user_data, error);
+ cb (contact, offset, ((gfloat) (i+1)/priv->total_records)*100, user_data, error);
d(g_print ("%s \n", e_vcard_to_string ((EVCard *) contact, EVC_FORMAT_VCARD_30));)
error:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]