[evolution-ews] Don't cache online state.



commit 918caf9774f8b875a7fe0299302eb3cbd5125ab0
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed May 23 06:41:35 2012 -0400

    Don't cache online state.
    
    The online flag is already built into EBackend so there's no need to
    cache it in subclasses.

 src/addressbook/e-book-backend-ews.c |   32 +++++++++++---------------------
 src/calendar/e-cal-backend-ews.c     |   30 ++++++++++--------------------
 2 files changed, 21 insertions(+), 41 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-ews.c b/src/addressbook/e-book-backend-ews.c
index 26eb6a4..7773f1d 100644
--- a/src/addressbook/e-book-backend-ews.c
+++ b/src/addressbook/e-book-backend-ews.c
@@ -87,7 +87,6 @@ struct _EBookBackendEwsPrivate {
 	gboolean marked_for_offline;
 	gboolean cache_ready;
 	gboolean is_gal;
-	gboolean is_online;
 
 	GHashTable *ops;
 
@@ -956,7 +955,7 @@ e_book_backend_ews_create_contacts (EBookBackend *backend,
 	ebews = E_BOOK_BACKEND_EWS (backend);
 	priv = ebews->priv;
 
-	if (!priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		if (!priv->is_writable) {
 			e_data_book_respond_create_contacts (book, opid, EDB_ERROR (PERMISSION_DENIED), NULL);
 			return;
@@ -1059,7 +1058,7 @@ e_book_backend_ews_remove_contacts (EBookBackend *backend,
 
 	priv = ebews->priv;
 
-	if (!priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		if (!priv->is_writable) {
 			e_data_book_respond_remove_contacts (book, opid, EDB_ERROR (PERMISSION_DENIED), NULL);
 			return;
@@ -1230,7 +1229,7 @@ e_book_backend_ews_modify_contacts (EBookBackend *backend,
 	ebews = E_BOOK_BACKEND_EWS (backend);
 	priv = ebews->priv;
 
-	if (!priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		if (!priv->is_writable) {
 			e_data_book_respond_modify_contacts (book, opid, EDB_ERROR (PERMISSION_DENIED), NULL);
 			return;
@@ -1300,7 +1299,7 @@ e_book_backend_ews_get_contact (EBookBackend *backend,
 
 	ebews =  E_BOOK_BACKEND_EWS (backend);
 
-	if (!ebews->priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		e_data_book_respond_get_contact (book, opid, EDB_ERROR (CONTACT_NOT_FOUND), "");
 		return;
 	}
@@ -1328,7 +1327,7 @@ e_book_backend_ews_get_contact_list (EBookBackend *backend,
 	ebews = E_BOOK_BACKEND_EWS (backend);
 	priv = ebews->priv;
 
-	if (!priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		if (e_book_backend_sqlitedb_get_is_populated (priv->ebsdb, priv->folder_id, NULL)) {
 			list = e_book_backend_sqlitedb_search (priv->ebsdb, priv->folder_id, query, NULL, NULL, NULL, &error);
 			l = list;
@@ -2358,7 +2357,8 @@ ebews_start_refreshing (EBookBackendEws *ebews)
 
 	PRIV_LOCK (priv);
 
-	if (priv->is_online && priv->cnc && priv->marked_for_offline)
+	if (e_backend_get_online (E_BACKEND (ebews)) &&
+	    priv->cnc != NULL&& priv->marked_for_offline)
 		fetch_deltas (ebews);
 
 	PRIV_UNLOCK (priv);
@@ -2421,7 +2421,7 @@ e_book_backend_ews_start_book_view (EBookBackend *backend,
 	e_data_book_view_ref (book_view);
 	e_data_book_view_notify_progress (book_view, -1, _("Searching..."));
 
-	if (!priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		if (priv->ebsdb && e_book_backend_sqlitedb_get_is_populated (priv->ebsdb, priv->folder_id, NULL)) {
 			fetch_from_offline (ebews, book_view, query, error);
 			return;
@@ -2610,10 +2610,8 @@ e_book_backend_ews_load_source (EBookBackend *backend,
 		}
 	}
 
-	if (priv->is_online) {
-		e_backend_set_online (E_BACKEND (backend), TRUE);
+	if (e_backend_get_online (E_BACKEND (backend)))
 		e_book_backend_notify_auth_required (backend, TRUE, NULL);
-	}
 }
 
 static void
@@ -2644,7 +2642,7 @@ e_book_backend_ews_authenticate_user (EBookBackend *backend,
 	ebews = E_BOOK_BACKEND_EWS (backend);
 	priv = ebews->priv;
 
-	if (!ebews->priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		e_book_backend_notify_opened (backend, EDB_ERROR (SUCCESS));
 		return;
 	}
@@ -2704,17 +2702,9 @@ e_book_backend_ews_notify_online_cb (EBookBackend *backend,
                                      GParamSpec *spec)
 {
 	EBookBackendEws *ebews;
-	gboolean is_online;
 
 	ebews = E_BOOK_BACKEND_EWS (backend);
 
-	is_online = e_backend_get_online (E_BACKEND (backend));
-
-	if ((ebews->priv->is_online ? 1 : 0) == (is_online ? 1 : 0))
-		return;
-
-	ebews->priv->is_online = is_online;
-
 	if (e_book_backend_is_opened (backend)) {
 		if (ebews->priv->cancellable) {
 			g_cancellable_cancel (ebews->priv->cancellable);
@@ -2722,7 +2712,7 @@ e_book_backend_ews_notify_online_cb (EBookBackend *backend,
 			ebews->priv->cancellable = NULL;
 		}
 
-		if (!is_online) {
+		if (!e_backend_get_online (E_BACKEND (backend))) {
 			e_book_backend_notify_readonly (backend, TRUE);
 			e_book_backend_notify_online (backend, FALSE);
 			if (ebews->priv->cnc) {
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index 8317ab7..c9d70a5 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -78,7 +78,6 @@ struct _ECalBackendEwsPrivate {
 	EDataCal *opening_cal;
 	guint32 opening_ctx;
 
-	gboolean is_online;
 	ECalBackendStore *store;
 	gboolean read_only;
 
@@ -552,7 +551,8 @@ connect_to_server (ECalBackendEws *cbews,
 
 	PRIV_LOCK (priv);
 
-	if (priv->is_online && !priv->cnc && password) {
+	if (e_backend_get_online (E_BACKEND (cbews)) &&
+	    priv->cnc == NULL && password != NULL) {
 		const gchar *host_url;
 		GSList *folders = NULL, *ids = NULL;
 		EwsFolderId *fid = NULL;
@@ -1699,7 +1699,7 @@ e_cal_backend_ews_create_objects (ECalBackend *backend,
 	kind = e_cal_backend_get_kind (E_CAL_BACKEND (backend));
 
 	/* make sure we're not offline */
-	if (!priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		g_propagate_error (&error, EDC_ERROR (RepositoryOffline));
 		goto exit;
 	}
@@ -2213,7 +2213,7 @@ e_cal_backend_ews_modify_object (ECalBackend *backend,
 	priv = cbews->priv;
 	kind = e_cal_backend_get_kind (E_CAL_BACKEND (backend));
 
-	if (!priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		g_propagate_error (&error, EDC_ERROR (RepositoryOffline));
 		goto exit;
 	}
@@ -2509,7 +2509,7 @@ e_cal_backend_ews_receive_objects (ECalBackend *backend,
 	priv = cbews->priv;
 
 	/* make sure we're not offline */
-	if (!priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		g_propagate_error (&error, EDC_ERROR (RepositoryOffline));
 		goto exit;
 	}
@@ -2766,7 +2766,7 @@ e_cal_backend_ews_send_objects (ECalBackend *backend,
 	priv = cbews->priv;
 
 	/* make sure we're not offline */
-	if (!priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		g_propagate_error (&error, EDC_ERROR (RepositoryOffline));
 		goto exit;
 	}
@@ -3599,7 +3599,7 @@ ews_cal_start_refreshing (ECalBackendEws *cbews)
 	PRIV_LOCK (priv);
 
 	if	(!priv->refresh_timeout &&
-		 priv->is_online &&
+		 e_backend_get_online (E_BACKEND (cbews)) &&
 		 priv->cnc) {
 			ews_start_sync (cbews);
 			priv->refresh_timeout = g_timeout_add_seconds
@@ -3678,7 +3678,7 @@ e_cal_backend_ews_refresh (ECalBackend *backend,
 	priv = cbews->priv;
 
 	/* make sure we're not offline */
-	if (!priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		g_propagate_error (&error, EDC_ERROR (RepositoryOffline));
 		goto exit;
 	}
@@ -3799,7 +3799,7 @@ e_cal_backend_ews_get_free_busy (ECalBackend *backend,
 	GSList *users_copy = NULL;
 
 	/* make sure we're not offline */
-	if (!priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		g_propagate_error (&error, EDC_ERROR (RepositoryOffline));
 		goto exit;
 	}
@@ -3912,23 +3912,13 @@ e_cal_backend_ews_notify_online_cb (ECalBackend *backend,
 {
 	ECalBackendEws *cbews;
 	ECalBackendEwsPrivate *priv;
-	gboolean is_online;
 
 	cbews = E_CAL_BACKEND_EWS (backend);
 	priv = cbews->priv;
 
-	is_online = e_backend_get_online (E_BACKEND (backend));
-
-	if ((is_online ? 1 : 0) == (priv->is_online ? 1 : 0)) {
-		e_cal_backend_notify_online (backend, is_online);
-		return;
-	}
-
 	PRIV_LOCK (priv);
 
-	priv->is_online = is_online;
-
-	if (is_online) {
+	if (e_backend_get_online (E_BACKEND (backend))) {
 		if (priv->cancellable) {
 			g_cancellable_cancel (priv->cancellable);
 			g_object_unref (priv->cancellable);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]