aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2003-08-28 03:50:25 +0800
committerMichael Zucci <zucchi@src.gnome.org>2003-08-28 03:50:25 +0800
commit7dea6c9dc22d7be2f2069bb2372d2df9df2abdd5 (patch)
treefe3c66020637a15c20a71b2ef0fbe71a73c2631d /camel/providers
parent6b615eaf55a664686b2513f0ae6701e338ace46b (diff)
downloadgsoc2013-evolution-7dea6c9dc22d7be2f2069bb2372d2df9df2abdd5.tar
gsoc2013-evolution-7dea6c9dc22d7be2f2069bb2372d2df9df2abdd5.tar.gz
gsoc2013-evolution-7dea6c9dc22d7be2f2069bb2372d2df9df2abdd5.tar.bz2
gsoc2013-evolution-7dea6c9dc22d7be2f2069bb2372d2df9df2abdd5.tar.lz
gsoc2013-evolution-7dea6c9dc22d7be2f2069bb2372d2df9df2abdd5.tar.xz
gsoc2013-evolution-7dea6c9dc22d7be2f2069bb2372d2df9df2abdd5.tar.zst
gsoc2013-evolution-7dea6c9dc22d7be2f2069bb2372d2df9df2abdd5.zip
implement PERSISTENT_PROPERTIES, for index mode.
2003-08-27 Not Zed <NotZed@Ximian.com> * providers/local/camel-local-folder.c (local_getv): implement PERSISTENT_PROPERTIES, for index mode. * camel-object.c (cobject_state_read): Also add property reading, and bump version to 1. (cobject_state_write): add persistent property writing. 2003-08-26 Not Zed <NotZed@Ximian.com> * camel-folder.c (folder_getv): chain up properly. * camel-file-utils.c (camel_file_util_savename): helper to create a .#filename filename. * providers/local/camel-local-folder.c (camel_local_folder_construct): init meta-data for local folders. (local_getv): chain up properly, if args are not processed, rather than don't if they aren't. 2003-08-23 Not Zed <NotZed@Ximian.com> * camel-object.c (cobject_class_init): added a new event, meta_changed. (camel_object_meta_set, camel_object_meta_get): meta-data api. (camel_object_free_hooks): Free meta-data if it is set on the object. * providers/local/camel-local-folder.c (camel_local_folder_get_type): setup a property list for local folders, just 'index_body' at present. svn path=/trunk/; revision=22388
Diffstat (limited to 'camel/providers')
-rw-r--r--camel/providers/local/camel-local-folder.c84
-rw-r--r--camel/providers/local/camel-local-folder.h10
2 files changed, 82 insertions, 12 deletions
diff --git a/camel/providers/local/camel-local-folder.c b/camel/providers/local/camel-local-folder.c
index 0945f92370..91d001ccfc 100644
--- a/camel/providers/local/camel-local-folder.c
+++ b/camel/providers/local/camel-local-folder.c
@@ -59,7 +59,8 @@
#define PATH_MAX _POSIX_PATH_MAX
#endif
-static CamelFolderClass *parent_class = NULL;
+static CamelFolderClass *parent_class;
+static GSList *local_folder_properties;
/* Returns the class for a CamelLocalFolder */
#define CLOCALF_CLASS(so) CAMEL_LOCAL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so))
@@ -67,6 +68,7 @@ static CamelFolderClass *parent_class = NULL;
#define CLOCALS_CLASS(so) CAMEL_STORE_CLASS (CAMEL_OBJECT_GET_CLASS(so))
static int local_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args);
+static int local_setv(CamelObject *object, CamelException *ex, CamelArgV *args);
static int local_lock(CamelLocalFolder *lf, CamelLockType type, CamelException *ex);
static void local_unlock(CamelLocalFolder *lf);
@@ -91,12 +93,11 @@ camel_local_folder_class_init(CamelLocalFolderClass * camel_local_folder_class)
CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS(camel_local_folder_class);
CamelObjectClass *oklass = (CamelObjectClass *)camel_local_folder_class;
- parent_class = CAMEL_FOLDER_CLASS(camel_type_get_global_classfuncs(camel_folder_get_type()));
-
/* virtual method definition */
/* virtual method overload */
oklass->getv = local_getv;
+ oklass->setv = local_setv;
camel_folder_class->refresh_info = local_refresh_info;
camel_folder_class->sync = local_sync;
@@ -168,19 +169,31 @@ local_finalize(CamelObject * object)
g_free(local_folder->priv);
}
+static CamelProperty local_property_list[] = {
+ { CAMEL_LOCAL_FOLDER_INDEX_BODY, "index_body", N_("Index message body data") },
+};
+
CamelType
camel_local_folder_get_type(void)
{
static CamelType camel_local_folder_type = CAMEL_INVALID_TYPE;
if (camel_local_folder_type == CAMEL_INVALID_TYPE) {
- camel_local_folder_type = camel_type_register(CAMEL_FOLDER_TYPE, "CamelLocalFolder",
+ int i;
+
+ parent_class = (CamelFolderClass *)camel_folder_get_type();
+ camel_local_folder_type = camel_type_register(camel_folder_get_type(), "CamelLocalFolder",
sizeof(CamelLocalFolder),
sizeof(CamelLocalFolderClass),
(CamelObjectClassInitFunc) camel_local_folder_class_init,
NULL,
(CamelObjectInitFunc) local_init,
(CamelObjectFinalizeFunc) local_finalize);
+
+ for (i=0;i<sizeof(local_property_list)/sizeof(local_property_list[0]);i++) {
+ local_property_list[i].description = _(local_property_list[i].description);
+ local_folder_properties = g_slist_prepend(local_folder_properties, &local_property_list[i]);
+ }
}
return camel_local_folder_type;
@@ -192,7 +205,7 @@ camel_local_folder_construct(CamelLocalFolder *lf, CamelStore *parent_store, con
CamelFolderInfo *fi;
CamelFolder *folder;
const char *root_dir_path, *name;
- char *tmp;
+ char *tmp, *statepath;
char folder_path[PATH_MAX];
struct stat st;
int forceindex, len;
@@ -223,12 +236,20 @@ camel_local_folder_construct(CamelLocalFolder *lf, CamelStore *parent_store, con
/* not really sure to do with these for now? */
lf->summary_path = g_strdup_printf("%s.ev-summary", tmp);
lf->index_path = g_strdup_printf("%s.ibex", tmp);
+ statepath = alloca(strlen(tmp)+7);
+ sprintf(statepath, "%s.cmeta", tmp);
} else {
lf->folder_path = g_strdup_printf("%s/%s", root_dir_path, full_name);
lf->summary_path = g_strdup_printf("%s/%s.ev-summary", root_dir_path, full_name);
lf->index_path = g_strdup_printf("%s/%s.ibex", root_dir_path, full_name);
+ statepath = alloca(strlen(full_name)+strlen(root_dir_path)+8);
+ sprintf(statepath, "%s/%s.cmeta", root_dir_path, full_name);
}
-
+ camel_object_set(lf, NULL, CAMEL_OBJECT_STATE_FILE, statepath, NULL);
+ if (camel_object_state_read(lf) == -1) {
+ /* FIXME: load defaults? */
+ }
+
/* follow any symlinks to the mailbox */
if (lstat (lf->folder_path, &st) != -1 && S_ISLNK (st.st_mode) &&
realpath (lf->folder_path, folder_path) != NULL) {
@@ -326,7 +347,7 @@ static int
local_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
{
CamelFolder *folder = (CamelFolder *)object;
- int i, count=args->argc;
+ int i;
guint32 tag;
for (i=0;i<args->argc;i++) {
@@ -335,7 +356,6 @@ local_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
tag = arg->tag;
switch (tag & CAMEL_ARG_TAG) {
- /* CamelObject args */
case CAMEL_OBJECT_ARG_DESCRIPTION:
if (folder->description == NULL) {
char *tmp, *path;
@@ -366,18 +386,58 @@ local_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
}
*arg->ca_str = folder->description;
break;
+
+ 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, local_folder_properties);
+
+ break; }
+
+ case CAMEL_LOCAL_FOLDER_INDEX_BODY:
+ /* FIXME: remove this from sotre flags */
+ *arg->ca_int = (((CamelLocalFolder *)folder)->flags & CAMEL_STORE_FOLDER_BODY_INDEX) != 0;
+ break;
+
default: skip:
- count--;
continue;
}
arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE;
}
- if (count)
- return ((CamelObjectClass *)parent_class)->getv(object, ex, args);
+ return ((CamelObjectClass *)parent_class)->getv(object, ex, args);
+}
- return 0;
+static int
+local_setv(CamelObject *object, CamelException *ex, CamelArgV *args)
+{
+ CamelFolder *folder = (CamelFolder *)object;
+ 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_LOCAL_FOLDER_INDEX_BODY:
+ /* FIXME: implement */
+ printf("setting folder indexing %s\n", arg->ca_int?"on":"off");
+ break;
+ default:
+ continue;
+ }
+
+ arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE;
+ }
+
+ return ((CamelObjectClass *)parent_class)->setv(object, ex, args);
}
static int
diff --git a/camel/providers/local/camel-local-folder.h b/camel/providers/local/camel-local-folder.h
index c958bde835..63a6870793 100644
--- a/camel/providers/local/camel-local-folder.h
+++ b/camel/providers/local/camel-local-folder.h
@@ -40,6 +40,16 @@ extern "C" {
#define CAMEL_LOCAL_FOLDER_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_LOCAL_FOLDER_TYPE, CamelLocalFolderClass))
#define CAMEL_IS_LOCAL_FOLDER(o) (CAMEL_CHECK_TYPE((o), CAMEL_LOCAL_FOLDER_TYPE))
+enum {
+ CAMEL_LOCAL_FOLDER_ARG_INDEX_BODY = CAMEL_FOLDER_ARG_LAST,
+
+ CAMEL_LOCAL_FOLDER_ARG_LAST = CAMEL_FOLDER_ARG_LAST + 0x100
+};
+
+enum {
+ CAMEL_LOCAL_FOLDER_INDEX_BODY = CAMEL_LOCAL_FOLDER_ARG_INDEX_BODY | CAMEL_ARG_INT,
+};
+
typedef struct {
CamelFolder parent_object;
struct _CamelLocalFolderPrivate *priv;