aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-01-09 14:26:58 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-01-09 14:26:58 +0800
commit2481120809ca40d8675f85851214272a527e6298 (patch)
treeb15379767c6b1e2515b3861bf341186e40bd5e00 /camel
parentefa0b9c96b5b3283dae60c8045ada5a89f817f4f (diff)
downloadgsoc2013-evolution-2481120809ca40d8675f85851214272a527e6298.tar.gz
gsoc2013-evolution-2481120809ca40d8675f85851214272a527e6298.tar.zst
gsoc2013-evolution-2481120809ca40d8675f85851214272a527e6298.zip
fix removal of journal file, and remove the cmeta state file too.
2004-01-09 Not Zed <NotZed@Ximian.com> * providers/imap/camel-imap-store.c (imap_forget_folder): fix removal of journal file, and remove the cmeta state file too. * providers/imap/camel-imap-folder.c (imap_getv): count up so we call parent class if we missed any, rather than only if we didn't miss any. (imap_rename): rename the object state file. (camel_imap_folder_new): set the object state file for persistent properties. * camel-disco-folder.c (disco_getv): support (PERSISTENT_)PROPERTIES & OFFLINE_SYNC. (disco_setv): implement OFFLINE_SYNC. (camel_disco_folder_get_type): setup disco properties list. (cdf_folder_changed): honour the offline_sync setting on the current folder. (disco_sync): save object state. (disco_setv): save object state if it changed. svn path=/trunk/; revision=24126
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog19
-rw-r--r--camel/camel-disco-folder.c92
-rw-r--r--camel/camel-disco-folder.h11
-rw-r--r--camel/providers/imap/camel-imap-folder.c18
-rw-r--r--camel/providers/imap/camel-imap-folder.h5
-rw-r--r--camel/providers/imap/camel-imap-store.c8
6 files changed, 144 insertions, 9 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index bf5999c080..e06f499175 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,24 @@
2004-01-09 Not Zed <NotZed@Ximian.com>
+ * providers/imap/camel-imap-store.c (imap_forget_folder): fix
+ removal of journal file, and remove the cmeta state file too.
+
+ * providers/imap/camel-imap-folder.c (imap_getv): count up so we
+ call parent class if we missed any, rather than only if we didn't
+ miss any.
+ (imap_rename): rename the object state file.
+ (camel_imap_folder_new): set the object state file for persistent
+ properties.
+
+ * camel-disco-folder.c (disco_getv): support
+ (PERSISTENT_)PROPERTIES & OFFLINE_SYNC.
+ (disco_setv): implement OFFLINE_SYNC.
+ (camel_disco_folder_get_type): setup disco properties list.
+ (cdf_folder_changed): honour the offline_sync setting on the
+ current folder.
+ (disco_sync): save object state.
+ (disco_setv): save object state if it changed.
+
* camel-data-wrapper.c (camel_data_wrapper_set_mime_type_field):
move assertions here.
(set_mime_type_field): change order slightly to properly handle
diff --git a/camel/camel-disco-folder.c b/camel/camel-disco-folder.c
index 61e825020c..33148251f2 100644
--- a/camel/camel-disco-folder.c
+++ b/camel/camel-disco-folder.c
@@ -35,6 +35,14 @@
#define CDF_CLASS(o) (CAMEL_DISCO_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS (o)))
static CamelFolderClass *parent_class = NULL;
+static GSList *disco_folder_properties;
+
+static CamelProperty disco_property_list[] = {
+ { CAMEL_DISCO_FOLDER_OFFLINE_SYNC, "offline_sync", N_("Copy folder content locally for offline operation") },
+};
+
+static int disco_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args);
+static int disco_setv(CamelObject *object, CamelException *ex, CamelArgV *args);
static void disco_refresh_info (CamelFolder *folder, CamelException *ex);
static void disco_sync (CamelFolder *folder, gboolean expunge, CamelException *ex);
@@ -61,6 +69,9 @@ camel_disco_folder_class_init (CamelDiscoFolderClass *camel_disco_folder_class)
parent_class = CAMEL_FOLDER_CLASS (camel_type_get_global_classfuncs (camel_folder_get_type ()));
+ ((CamelObjectClass *)camel_folder_class)->getv = disco_getv;
+ ((CamelObjectClass *)camel_folder_class)->setv = disco_setv;
+
/* virtual method definition */
camel_disco_folder_class->cache_message = disco_cache_message;
camel_disco_folder_class->prepare_for_offline = disco_prepare_for_offline;
@@ -126,7 +137,8 @@ static void
cdf_folder_changed(CamelFolder *folder, CamelFolderChangeInfo *changes, void *dummy)
{
if (changes->uid_added->len > 0
- && camel_url_get_param(((CamelService *)folder->parent_store)->url, "offline_sync")) {
+ && (((CamelDiscoFolder *)folder)->offline_sync
+ || camel_url_get_param(((CamelService *)folder->parent_store)->url, "offline_sync"))) {
CamelSession *session = ((CamelService *)folder->parent_store)->session;
struct _cdf_sync_msg *m;
@@ -149,6 +161,7 @@ CamelType
camel_disco_folder_get_type (void)
{
static CamelType camel_disco_folder_type = CAMEL_INVALID_TYPE;
+ int i;
if (camel_disco_folder_type == CAMEL_INVALID_TYPE) {
camel_disco_folder_type = camel_type_register (
@@ -157,11 +170,86 @@ camel_disco_folder_get_type (void)
sizeof (CamelDiscoFolderClass),
(CamelObjectClassInitFunc)camel_disco_folder_class_init, NULL,
(CamelObjectInitFunc)camel_disco_folder_init, NULL);
+
+ for (i=0;i<sizeof(disco_property_list)/sizeof(disco_property_list[0]);i++) {
+ disco_property_list[i].description = _(disco_property_list[i].description);
+ disco_folder_properties = g_slist_prepend(disco_folder_properties, &disco_property_list[i]);
+ }
}
return camel_disco_folder_type;
}
+static int
+disco_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
+{
+ int i, count=0;
+ guint32 tag;
+
+ for (i=0;i<args->argc;i++) {
+ CamelArgGet *arg = &args->argv[i];
+
+ tag = arg->tag;
+
+ switch (tag & CAMEL_ARG_TAG) {
+ case CAMEL_OBJECT_ARG_PERSISTENT_PROPERTIES:
+ case CAMEL_FOLDER_ARG_PROPERTIES: {
+ CamelArgGetV props;
+
+ props.argc = 1;
+ props.argv[0] = *arg;
+ ((CamelObjectClass *)parent_class)->getv(object, ex, &props);
+ *arg->ca_ptr = g_slist_concat(*arg->ca_ptr, g_slist_copy(disco_folder_properties));
+ break; }
+ /* disco args */
+ case CAMEL_DISCO_FOLDER_ARG_OFFLINE_SYNC:
+ *arg->ca_int = ((CamelDiscoFolder *)object)->offline_sync;
+ break;
+ default:
+ count++;
+ continue;
+ }
+
+ arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE;
+ }
+
+ if (count)
+ return ((CamelObjectClass *)parent_class)->getv(object, ex, args);
+
+ return 0;
+}
+
+static int
+disco_setv(CamelObject *object, CamelException *ex, CamelArgV *args)
+{
+ int save = 0;
+ int i;
+ guint32 tag;
+
+ for (i=0;i<args->argc;i++) {
+ CamelArg *arg = &args->argv[i];
+
+ tag = arg->tag;
+
+ switch (tag & CAMEL_ARG_TAG) {
+ case CAMEL_DISCO_FOLDER_ARG_OFFLINE_SYNC:
+ if (((CamelDiscoFolder *)object)->offline_sync != arg->ca_int) {
+ ((CamelDiscoFolder *)object)->offline_sync = arg->ca_int;
+ save = 1;
+ }
+ break;
+ default:
+ continue;
+ }
+
+ arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE;
+ }
+
+ if (save)
+ camel_object_state_write(object);
+
+ return ((CamelObjectClass *)parent_class)->setv(object, ex, args);
+}
static void
disco_refresh_info (CamelFolder *folder, CamelException *ex)
@@ -180,6 +268,8 @@ disco_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
return;
}
+ camel_object_state_write(folder);
+
switch (camel_disco_store_status (CAMEL_DISCO_STORE (folder->parent_store))) {
case CAMEL_DISCO_STORE_ONLINE:
CDF_CLASS (folder)->sync_online (folder, ex);
diff --git a/camel/camel-disco-folder.h b/camel/camel-disco-folder.h
index 0d857c0b9b..a877b22be3 100644
--- a/camel/camel-disco-folder.h
+++ b/camel/camel-disco-folder.h
@@ -36,9 +36,20 @@ extern "C" {
#define CAMEL_DISCO_FOLDER_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_DISCO_FOLDER_TYPE, CamelDiscoFolderClass))
#define CAMEL_IS_DISCO_FOLDER(o) (CAMEL_CHECK_TYPE((o), CAMEL_DISCO_FOLDER_TYPE))
+enum {
+ CAMEL_DISCO_FOLDER_ARG_OFFLINE_SYNC = CAMEL_FOLDER_ARG_LAST,
+
+ CAMEL_DISCO_FOLDER_ARG_LAST = CAMEL_FOLDER_ARG_LAST + 0x100
+};
+
+enum {
+ CAMEL_DISCO_FOLDER_OFFLINE_SYNC = CAMEL_DISCO_FOLDER_ARG_OFFLINE_SYNC | CAMEL_ARG_BOO,
+};
+
struct _CamelDiscoFolder {
CamelFolder parent_object;
+ unsigned int offline_sync:1;
};
typedef struct {
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index 4db0c7a43f..a4c40c6635 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -216,7 +216,7 @@ camel_imap_folder_new (CamelStore *parent, const char *folder_name,
CamelFolder *folder;
CamelImapFolder *imap_folder;
const char *short_name;
- char *summary_file;
+ char *summary_file, *state_file;
if (camel_mkdir (folder_dir, S_IRWXU) != 0) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
@@ -244,6 +244,12 @@ camel_imap_folder_new (CamelStore *parent, const char *folder_name,
return NULL;
}
+ /* set/load persistent state */
+ state_file = g_strdup_printf ("%s/cmeta", folder_dir);
+ camel_object_set(folder, NULL, CAMEL_OBJECT_STATE_FILE, state_file, NULL);
+ g_free(state_file);
+ camel_object_state_read(folder);
+
imap_folder = CAMEL_IMAP_FOLDER (folder);
imap_folder->cache = camel_imap_message_cache_new (folder_dir, folder->summary, ex);
if (!imap_folder->cache) {
@@ -406,7 +412,7 @@ static int
imap_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
{
CamelFolder *folder = (CamelFolder *)object;
- int i, count=args->argc;
+ int i, count=0;
guint32 tag;
for (i=0;i<args->argc;i++) {
@@ -426,7 +432,7 @@ imap_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
*arg->ca_str = folder->description;
break;
default:
- count--;
+ count++;
continue;
}
@@ -444,7 +450,7 @@ imap_rename (CamelFolder *folder, const char *new)
{
CamelImapFolder *imap_folder = (CamelImapFolder *)folder;
CamelImapStore *imap_store = (CamelImapStore *)folder->parent_store;
- char *folder_dir, *summary_path;
+ char *folder_dir, *summary_path, *state_file;
char *folders;
folders = g_strconcat (imap_store->storage_path, "/folders", NULL);
@@ -458,6 +464,10 @@ imap_rename (CamelFolder *folder, const char *new)
camel_folder_summary_set_filename(folder->summary, summary_path);
+ state_file = g_strdup_printf ("%s/cmeta", folder_dir);
+ camel_object_set(folder, NULL, CAMEL_OBJECT_STATE_FILE, state_file, NULL);
+ g_free(state_file);
+
g_free(summary_path);
g_free(folder_dir);
diff --git a/camel/providers/imap/camel-imap-folder.h b/camel/providers/imap/camel-imap-folder.h
index a49f7bd497..4cadebc65b 100644
--- a/camel/providers/imap/camel-imap-folder.h
+++ b/camel/providers/imap/camel-imap-folder.h
@@ -47,11 +47,12 @@ struct _CamelImapFolder {
struct _CamelImapFolderPrivate *priv;
- gboolean need_rescan, need_refresh;
CamelFolderSearch *search;
CamelImapMessageCache *cache;
-};
+ unsigned int need_rescan:1;
+ unsigned int need_refresh:1;
+};
typedef struct {
CamelDiscoFolderClass parent_class;
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index 4b4250da18..d8ff6e0ec7 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -1042,7 +1042,7 @@ imap_forget_folder (CamelImapStore *imap_store, const char *folder_name, CamelEx
{
CamelFolderSummary *summary;
CamelImapMessageCache *cache;
- char *summary_file;
+ char *summary_file, *state_file;
char *journal_file;
char *folder_dir, *storage_path;
CamelFolderInfo *fi;
@@ -1080,9 +1080,13 @@ imap_forget_folder (CamelImapStore *imap_store, const char *folder_name, CamelEx
unlink (summary_file);
g_free (summary_file);
- journal_file = g_strdup_printf ("%s/summary", folder_dir);
+ journal_file = g_strdup_printf ("%s/journal", folder_dir);
unlink (journal_file);
g_free (journal_file);
+
+ state_file = g_strdup_printf ("%s/cmeta", folder_dir);
+ unlink (state_file);
+ g_free (state_file);
rmdir (folder_dir);
g_free (folder_dir);