aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-disco-store.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2001-05-30 01:08:53 +0800
committerDan Winship <danw@src.gnome.org>2001-05-30 01:08:53 +0800
commit11ea26d0e33405490795a766406d5e065b6b9234 (patch)
treebe249f7528c0a8b17cdd0890d40684f12eeb50e5 /camel/camel-disco-store.c
parentefabbb93c9f61e583d835d1735834cc5bd0ce63c (diff)
downloadgsoc2013-evolution-11ea26d0e33405490795a766406d5e065b6b9234.tar
gsoc2013-evolution-11ea26d0e33405490795a766406d5e065b6b9234.tar.gz
gsoc2013-evolution-11ea26d0e33405490795a766406d5e065b6b9234.tar.bz2
gsoc2013-evolution-11ea26d0e33405490795a766406d5e065b6b9234.tar.lz
gsoc2013-evolution-11ea26d0e33405490795a766406d5e065b6b9234.tar.xz
gsoc2013-evolution-11ea26d0e33405490795a766406d5e065b6b9234.tar.zst
gsoc2013-evolution-11ea26d0e33405490795a766406d5e065b6b9234.zip
Code for logging and replaying offline operations.
* camel-disco-diary.c: Code for logging and replaying offline operations. * camel-disco-store.c (disco_construct): Set disco->status here (where we can base it on the session's offline status) rather than at init time. (disco_connect): If we connect online and have a non-empty diary, switch to RESYNCING mode and replay the diary to the server. (disco_get_folder, disco_get_folder_info): Add _resyncing variants. * camel-disco-folder.c (disco_sync, disco_expunge_uids, disco_append_message, disco_copy_messages_to, disco_move_messages_to): Add _resyncing variants to switches. (disco_expunge_uids, disco_append_message, disco_copy_messages_to, disco_move_messages_to): Remove #ifdef'ed out diary code: let the provider do it. (disco_append_message): Redo the append methods to no longer return the UID, since we're no longer doing the logging from here. svn path=/trunk/; revision=10040
Diffstat (limited to 'camel/camel-disco-store.c')
-rw-r--r--camel/camel-disco-store.c66
1 files changed, 50 insertions, 16 deletions
diff --git a/camel/camel-disco-store.c b/camel/camel-disco-store.c
index ae51b54f0f..ebe26a1908 100644
--- a/camel/camel-disco-store.c
+++ b/camel/camel-disco-store.c
@@ -27,12 +27,17 @@
#endif
#include "camel-disco-store.h"
+#include "camel-disco-diary.h"
#include "camel-exception.h"
+#include "camel-session.h"
#define CDS_CLASS(o) (CAMEL_DISCO_STORE_CLASS (CAMEL_OBJECT_GET_CLASS (o)))
static CamelRemoteStoreClass *remote_store_class = NULL;
+static void disco_construct (CamelService *service, CamelSession *session,
+ CamelProvider *provider, CamelURL *url,
+ CamelException *ex);
static gboolean disco_connect (CamelService *service, CamelException *ex);
static gboolean disco_disconnect (CamelService *service, gboolean clean, CamelException *ex);
static CamelFolder *disco_get_folder (CamelStore *store, const char *name,
@@ -60,6 +65,7 @@ camel_disco_store_class_init (CamelDiscoStoreClass *camel_disco_store_class)
camel_disco_store_class->can_work_offline = can_work_offline;
/* virtual method overload */
+ camel_service_class->construct = disco_construct;
camel_service_class->connect = disco_connect;
camel_service_class->disconnect = disco_disconnect;
@@ -67,16 +73,6 @@ camel_disco_store_class_init (CamelDiscoStoreClass *camel_disco_store_class)
camel_store_class->get_folder_info = disco_get_folder_info;
}
-static void
-camel_disco_store_init (CamelDiscoStore *store)
-{
- /* Hack */
- if (getenv ("CAMEL_OFFLINE"))
- store->status = CAMEL_DISCO_STORE_OFFLINE;
- else
- store->status = CAMEL_DISCO_STORE_ONLINE;
-}
-
CamelType
camel_disco_store_get_type (void)
{
@@ -89,13 +85,28 @@ camel_disco_store_get_type (void)
sizeof (CamelDiscoStoreClass),
(CamelObjectClassInitFunc) camel_disco_store_class_init,
NULL,
- (CamelObjectInitFunc) camel_disco_store_init,
+ NULL,
NULL);
}
return camel_disco_store_type;
}
+static void
+disco_construct (CamelService *service, CamelSession *session,
+ CamelProvider *provider, CamelURL *url,
+ CamelException *ex)
+{
+ CamelDiscoStore *disco = CAMEL_DISCO_STORE (service);
+
+ CAMEL_SERVICE_CLASS (remote_store_class)->construct (service, session, provider, url, ex);
+ if (camel_exception_is_set (ex))
+ return;
+
+ disco->status = camel_session_is_online (session) ?
+ CAMEL_DISCO_STORE_ONLINE : CAMEL_DISCO_STORE_OFFLINE;
+}
+
static gboolean
disco_connect (CamelService *service, CamelException *ex)
{
@@ -106,14 +117,29 @@ disco_connect (CamelService *service, CamelException *ex)
switch (camel_disco_store_status (store)) {
case CAMEL_DISCO_STORE_ONLINE:
- return CDS_CLASS (service)->connect_online (service, ex);
+ case CAMEL_DISCO_STORE_RESYNCING:
+ if (!CDS_CLASS (service)->connect_online (service, ex))
+ return FALSE;
+ if (camel_disco_diary_empty (store->diary))
+ return TRUE;
+
+ /* Need to resync */
+ store->status = CAMEL_DISCO_STORE_RESYNCING;
+ camel_disco_diary_replay (store->diary, ex);
+ store->status = CAMEL_DISCO_STORE_ONLINE;
+ if (camel_exception_is_set (ex))
+ return FALSE;
+
+ if (!camel_service_disconnect (service, TRUE, ex))
+ return FALSE;
+ return camel_service_connect (service, ex);
case CAMEL_DISCO_STORE_OFFLINE:
return CDS_CLASS (service)->connect_offline (service, ex);
}
- /* Not reached */
- return TRUE;
+ g_assert_not_reached ();
+ return FALSE;
}
static gboolean
@@ -123,6 +149,7 @@ disco_disconnect (CamelService *service, gboolean clean, CamelException *ex)
switch (camel_disco_store_status (store)) {
case CAMEL_DISCO_STORE_ONLINE:
+ case CAMEL_DISCO_STORE_RESYNCING:
if (!CDS_CLASS (service)->disconnect_online (service, clean, ex))
return FALSE;
break;
@@ -131,6 +158,7 @@ disco_disconnect (CamelService *service, gboolean clean, CamelException *ex)
if (!CDS_CLASS (service)->disconnect_offline (service, clean, ex))
return FALSE;
break;
+
}
return CAMEL_SERVICE_CLASS (remote_store_class)->disconnect (service, clean, ex);
@@ -148,9 +176,12 @@ disco_get_folder (CamelStore *store, const char *name,
case CAMEL_DISCO_STORE_OFFLINE:
return CDS_CLASS (store)->get_folder_offline (store, name, flags, ex);
+
+ case CAMEL_DISCO_STORE_RESYNCING:
+ return CDS_CLASS (store)->get_folder_resyncing (store, name, flags, ex);
}
- /* Not reached */
+ g_assert_not_reached ();
return NULL;
}
@@ -173,9 +204,12 @@ disco_get_folder_info (CamelStore *store, const char *top,
}
return CDS_CLASS (store)->get_folder_info_offline (store, top, flags, ex);
+
+ case CAMEL_DISCO_STORE_RESYNCING:
+ return CDS_CLASS (store)->get_folder_info_resyncing (store, top, flags, ex);
}
- /* Not reached */
+ g_assert_not_reached ();
return NULL;
}