aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-disco-store.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2001-05-10 05:57:32 +0800
committerDan Winship <danw@src.gnome.org>2001-05-10 05:57:32 +0800
commit630241d74b1a6dede97380c8ed70c74641399e0f (patch)
tree2a5642e69cf0bf563cd6c26176ac80633c9c82e0 /camel/camel-disco-store.c
parentc76080568db894f538f5b4d89293295b29fcc214 (diff)
downloadgsoc2013-evolution-630241d74b1a6dede97380c8ed70c74641399e0f.tar
gsoc2013-evolution-630241d74b1a6dede97380c8ed70c74641399e0f.tar.gz
gsoc2013-evolution-630241d74b1a6dede97380c8ed70c74641399e0f.tar.bz2
gsoc2013-evolution-630241d74b1a6dede97380c8ed70c74641399e0f.tar.lz
gsoc2013-evolution-630241d74b1a6dede97380c8ed70c74641399e0f.tar.xz
gsoc2013-evolution-630241d74b1a6dede97380c8ed70c74641399e0f.tar.zst
gsoc2013-evolution-630241d74b1a6dede97380c8ed70c74641399e0f.zip
Set the disconnected status. (camel_disco_store_can_work_offline): Return
* camel-disco-store.c (camel_disco_set_status): Set the disconnected status. (camel_disco_store_can_work_offline): Return whether or not a given CamelDiscoStore can work offline or not. * camel-disco-folder.c (camel_disco_folder_cache_message): Explicitly tell a folder to cache a message. (Better than using get_message, because for IMAP that doesn't guarantee you'll get all the message parts.) (camel_disco_folder_prepare_for_offline): Prepare a folder for offline use by caching all messages meeting given search criteria (and doing anything else the particular folder implementation needs). * camel-session.c (camel_session_set_online, camel_session_is_online): A session-wide online/offline toggle. (camel_session_init): Set online to TRUE. * providers/imap/camel-imap-store.c (can_work_offline): Implementation of CamelDiscoStore::can_work_offline. (Checks that the store has been used online at least once.) (imap_get_folder_online, imap_get_folder_offline): Deal with request for "inbox" properly. ("Don't you mean... 'INBOX'?"). * providers/imap/camel-imap-folder.c (imap_cache_message): Implementation of CamelDiscoFolder::cache_message. * camel.h: Add camel-disco-store.h and camel-disco-folder.h svn path=/trunk/; revision=9738
Diffstat (limited to 'camel/camel-disco-store.c')
-rw-r--r--camel/camel-disco-store.c83
1 files changed, 83 insertions, 0 deletions
diff --git a/camel/camel-disco-store.c b/camel/camel-disco-store.c
index 10d3ae78b3..ae51b54f0f 100644
--- a/camel/camel-disco-store.c
+++ b/camel/camel-disco-store.c
@@ -40,6 +40,10 @@ static CamelFolder *disco_get_folder (CamelStore *store, const char *name,
static CamelFolderInfo *disco_get_folder_info (CamelStore *store,
const char *top, guint32 flags,
CamelException *ex);
+static void set_status (CamelDiscoStore *disco_store,
+ CamelDiscoStoreStatus status,
+ CamelException *ex);
+static gboolean can_work_offline (CamelDiscoStore *disco_store);
static void
camel_disco_store_class_init (CamelDiscoStoreClass *camel_disco_store_class)
@@ -51,6 +55,10 @@ camel_disco_store_class_init (CamelDiscoStoreClass *camel_disco_store_class)
remote_store_class = CAMEL_REMOTE_STORE_CLASS (camel_type_get_global_classfuncs (camel_remote_store_get_type ()));
+ /* virtual method definition */
+ camel_disco_store_class->set_status = set_status;
+ camel_disco_store_class->can_work_offline = can_work_offline;
+
/* virtual method overload */
camel_service_class->connect = disco_connect;
camel_service_class->disconnect = disco_disconnect;
@@ -172,6 +180,12 @@ disco_get_folder_info (CamelStore *store, const char *top,
}
+/**
+ * camel_disco_store_status:
+ * @store: a disconnectable store
+ *
+ * Return value: the current online/offline status of @store.
+ **/
CamelDiscoStoreStatus
camel_disco_store_status (CamelDiscoStore *store)
{
@@ -180,6 +194,75 @@ camel_disco_store_status (CamelDiscoStore *store)
return store->status;
}
+
+static void
+set_status (CamelDiscoStore *disco_store, CamelDiscoStoreStatus status,
+ CamelException *ex)
+{
+ if (disco_store->status == status)
+ return;
+
+ camel_store_sync (CAMEL_STORE (disco_store), ex);
+ if (camel_exception_is_set (ex))
+ return;
+ if (!camel_service_disconnect (CAMEL_SERVICE (disco_store), TRUE, ex))
+ return;
+
+ disco_store->status = status;
+ camel_service_connect (CAMEL_SERVICE (disco_store), ex);
+}
+
+/**
+ * camel_disco_store_set_status:
+ * @store: a disconnectable store
+ * @status: the new status
+ * @ex: a CamelException
+ *
+ * Sets @store to @status. If an error occurrs and the status cannot
+ * be set to @status, @ex will be set.
+ **/
+void
+camel_disco_store_set_status (CamelDiscoStore *store,
+ CamelDiscoStoreStatus status,
+ CamelException *ex)
+{
+ CDS_CLASS (store)->set_status (store, status, ex);
+}
+
+
+static gboolean
+can_work_offline (CamelDiscoStore *disco_store)
+{
+ g_warning ("CamelDiscoStore::can_work_offline not implemented for `%s'",
+ camel_type_to_name (CAMEL_OBJECT_GET_TYPE (disco_store)));
+ return FALSE;
+}
+
+/**
+ * camel_disco_store_can_work_offline:
+ * @store: a disconnectable store
+ *
+ * Return value: whether or not @store can be used offline. (Will be
+ * %FALSE if the store is not caching data to local disk, for example.)
+ **/
+gboolean
+camel_disco_store_can_work_offline (CamelDiscoStore *store)
+{
+ return CDS_CLASS (store)->can_work_offline (store);
+}
+
+
+/**
+ * camel_disco_store_check_online:
+ * @store: a disconnectable store
+ * @ex: a CamelException
+ *
+ * This checks that @store is online, and sets @ex if it is not. This
+ * can be used as a simple way to set a generic error message in @ex
+ * for operations that won't work offline.
+ *
+ * Return value: whether or not @store is online.
+ **/
gboolean
camel_disco_store_check_online (CamelDiscoStore *store, CamelException *ex)
{