diff options
Diffstat (limited to 'camel/providers')
-rw-r--r-- | camel/providers/imap/camel-imap-store.c | 7 | ||||
-rw-r--r-- | camel/providers/mbox/camel-mbox-folder.c | 50 | ||||
-rw-r--r-- | camel/providers/mbox/camel-mbox-folder.h | 5 | ||||
-rw-r--r-- | camel/providers/mbox/camel-mbox-store.c | 69 | ||||
-rw-r--r-- | camel/providers/mbox/camel-mbox-summary.c | 10 | ||||
-rw-r--r-- | camel/providers/mh/camel-mh-folder.c | 21 | ||||
-rw-r--r-- | camel/providers/mh/camel-mh-folder.h | 2 | ||||
-rw-r--r-- | camel/providers/mh/camel-mh-store.c | 8 | ||||
-rw-r--r-- | camel/providers/mh/camel-mh-summary.c | 7 | ||||
-rw-r--r-- | camel/providers/nntp/camel-nntp-store.c | 2 | ||||
-rw-r--r-- | camel/providers/pop3/camel-pop3-store.c | 4 | ||||
-rw-r--r-- | camel/providers/vee/camel-vee-store.c | 4 |
12 files changed, 99 insertions, 90 deletions
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index ae4c13c150..80dc8dcd3c 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -57,8 +57,7 @@ static gboolean imap_connect (CamelService *service, CamelException *ex); static gboolean imap_disconnect (CamelService *service, CamelException *ex); static GList *query_auth_types_generic (CamelService *service, CamelException *ex); static GList *query_auth_types_connected (CamelService *service, CamelException *ex); -static CamelFolder *get_folder (CamelStore *store, const char *folder_name, gboolean create, - CamelException *ex); +static CamelFolder *get_folder (CamelStore *store, const char *folder_name, guint32 flags, CamelException *ex); static char *get_folder_name (CamelStore *store, const char *folder_name, CamelException *ex); static char *get_root_folder_name (CamelStore *store, CamelException *ex); @@ -420,7 +419,7 @@ imap_create (CamelImapStore *store, const char *folder_path, CamelException *ex) } static CamelFolder * -get_folder (CamelStore *store, const char *folder_name, gboolean create, CamelException *ex) +get_folder (CamelStore *store, const char *folder_name, guint32 flags, CamelException *ex) { CamelImapStore *imap_store = CAMEL_IMAP_STORE (store); CamelFolder *new_folder = NULL; @@ -429,7 +428,7 @@ get_folder (CamelStore *store, const char *folder_name, gboolean create, CamelEx folder_path = camel_imap_store_folder_path (imap_store, folder_name); if (!imap_folder_exists (imap_store, folder_path, &selectable, ex)) { - if (!create) { + if ((flags & CAMEL_STORE_FOLDER_CREATE) == 0) { g_free (folder_path); return NULL; } diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c index 163de6784f..55e2916ed4 100644 --- a/camel/providers/mbox/camel-mbox-folder.c +++ b/camel/providers/mbox/camel-mbox-folder.c @@ -171,11 +171,13 @@ CamelType camel_mbox_folder_get_type(void) } CamelFolder * -camel_mbox_folder_new(CamelStore *parent_store, const char *full_name, CamelException *ex) +camel_mbox_folder_new(CamelStore *parent_store, const char *full_name, guint32 flags, CamelException *ex) { CamelFolder *folder; CamelMboxFolder *mbox_folder; const char *root_dir_path, *name; + struct stat st; + int forceindex; folder = CAMEL_FOLDER (camel_object_new (CAMEL_MBOX_FOLDER_TYPE)); mbox_folder = (CamelMboxFolder *)folder; @@ -195,39 +197,41 @@ camel_mbox_folder_new(CamelStore *parent_store, const char *full_name, CamelExce mbox_folder->folder_dir_path = g_strdup_printf("%s/%s.sdb", root_dir_path, full_name); mbox_folder->index_file_path = g_strdup_printf("%s/%s.ibex", root_dir_path, full_name); - mbox_refresh_info (folder, ex); - if (camel_exception_is_set (ex)) { - camel_object_unref (CAMEL_OBJECT (folder)); - folder = NULL; - } - - return folder; -} - -static void -mbox_refresh_info (CamelFolder *folder, CamelException *ex) -{ - CamelMboxFolder *mbox_folder = (CamelMboxFolder *) folder; - struct stat st; - int forceindex; - /* if we have no index file, force it */ forceindex = stat(mbox_folder->index_file_path, &st) == -1; + if (flags & CAMEL_STORE_FOLDER_BODY_INDEX) { - mbox_folder->index = ibex_open(mbox_folder->index_file_path, O_CREAT | O_RDWR, 0600); - if (mbox_folder->index == NULL) { - /* yes, this isn't fatal at all */ - g_warning("Could not open/create index file: %s: indexing not performed", strerror(errno)); + mbox_folder->index = ibex_open(mbox_folder->index_file_path, O_CREAT | O_RDWR, 0600); + if (mbox_folder->index == NULL) { + /* yes, this isn't fatal at all */ + g_warning("Could not open/create index file: %s: indexing not performed", strerror(errno)); + forceindex = FALSE; + } + } else { + /* if we do have an index file, remove it */ + if (forceindex == FALSE) { + unlink(mbox_folder->index_file_path); + } + forceindex = FALSE; } - /* no summary (disk or memory), and we're proverbially screwed */ mbox_folder->summary = camel_mbox_summary_new(mbox_folder->summary_file_path, mbox_folder->folder_file_path, mbox_folder->index); if (mbox_folder->summary == NULL || camel_mbox_summary_load(mbox_folder->summary, forceindex) == -1) { camel_exception_set(ex, CAMEL_EXCEPTION_FOLDER_INVALID, /* FIXME: right error code */ "Could not create summary"); - return; + camel_object_unref (CAMEL_OBJECT (folder)); + return NULL; } + + return folder; +} + +static void +mbox_refresh_info (CamelFolder *folder, CamelException *ex) +{ + /* we are always in a consistent state, or fix it when we need to */ + return; } static void diff --git a/camel/providers/mbox/camel-mbox-folder.h b/camel/providers/mbox/camel-mbox-folder.h index 4cc91eda75..d6e8b0682c 100644 --- a/camel/providers/mbox/camel-mbox-folder.h +++ b/camel/providers/mbox/camel-mbox-folder.h @@ -69,10 +69,11 @@ typedef struct { /* public methods */ -CamelFolder *camel_mbox_folder_new (CamelStore *parent_store, const char *full_name, CamelException *ex); +/* flags are taken from CAMEL_STORE_FOLDER_* flags */ +CamelFolder *camel_mbox_folder_new(CamelStore *parent_store, const char *full_name, guint32 flags, CamelException *ex); /* Standard Camel function */ -CamelType camel_mbox_folder_get_type (void); +CamelType camel_mbox_folder_get_type(void); #ifdef __cplusplus } diff --git a/camel/providers/mbox/camel-mbox-store.c b/camel/providers/mbox/camel-mbox-store.c index 6ad729ce7d..2625722134 100644 --- a/camel/providers/mbox/camel-mbox-store.c +++ b/camel/providers/mbox/camel-mbox-store.c @@ -39,14 +39,11 @@ #define CF_CLASS(so) CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so)) #define CMBOXF_CLASS(so) CAMEL_MBOX_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so)) -static char *get_name (CamelService *service, gboolean brief); -static CamelFolder *get_folder (CamelStore *store, const char *folder_name, - gboolean create, CamelException *ex); -static void delete_folder (CamelStore *store, const char *folder_name, - CamelException *ex); +static char *get_name(CamelService *service, gboolean brief); +static CamelFolder *get_folder(CamelStore *store, const char *folder_name, guint32 flags, CamelException *ex); +static void delete_folder(CamelStore *store, const char *folder_name, CamelException *ex); static void rename_folder(CamelStore *store, const char *old_name, const char *new_name, CamelException *ex); -static char *get_folder_name (CamelStore *store, const char *folder_name, - CamelException *ex); +static char *get_folder_name(CamelStore *store, const char *folder_name, CamelException *ex); static CamelFolderInfo *get_folder_info (CamelStore *store, const char *top, gboolean fast, gboolean recursive, gboolean subscribed_only, @@ -109,55 +106,53 @@ camel_mbox_store_get_toplevel_dir (CamelMboxStore *store) } static CamelFolder * -get_folder (CamelStore *store, const char *folder_name, gboolean create, - CamelException *ex) +get_folder(CamelStore *store, const char *folder_name, guint32 flags, CamelException *ex) { char *name; struct stat st; - name = g_strdup_printf ("%s%s", CAMEL_SERVICE (store)->url->path, - folder_name); + name = g_strdup_printf("%s%s", CAMEL_SERVICE(store)->url->path, folder_name); - if (stat (name, &st) == -1) { + if (stat(name, &st) == -1) { int fd; if (errno != ENOENT) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "Could not open file `%s':" - "\n%s", name, - g_strerror (errno)); - g_free (name); + camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, + "Could not open file `%s':" + "\n%s", name, + g_strerror(errno)); + g_free(name); return NULL; } - if (!create) { - camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER, - "Folder `%s' does not exist.", - folder_name); - g_free (name); + if ((flags & CAMEL_STORE_FOLDER_CREATE) == 0) { + camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER, + "Folder `%s' does not exist.", + folder_name); + g_free(name); return NULL; } - fd = open (name, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR); + fd = open(name, O_WRONLY | O_CREAT | O_APPEND, 0600); if (fd == -1) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "Could not create file `%s':" - "\n%s", name, - g_strerror (errno)); - g_free (name); + camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, + "Could not create file `%s':" + "\n%s", name, + g_strerror(errno)); + g_free(name); return NULL; } - g_free (name); - close (fd); - } else if (!S_ISREG (st.st_mode)) { - camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER, - "`%s' is not a regular file.", - name); - g_free (name); + g_free(name); + close(fd); + } else if (!S_ISREG(st.st_mode)) { + camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER, + "`%s' is not a regular file.", + name); + g_free(name); return NULL; } else - g_free (name); + g_free(name); - return camel_mbox_folder_new (store, folder_name, ex); + return camel_mbox_folder_new(store, folder_name, flags, ex); } static void diff --git a/camel/providers/mbox/camel-mbox-summary.c b/camel/providers/mbox/camel-mbox-summary.c index 18d889ee84..c037b6000e 100644 --- a/camel/providers/mbox/camel-mbox-summary.c +++ b/camel/providers/mbox/camel-mbox-summary.c @@ -228,10 +228,10 @@ message_info_new_from_parser(CamelFolderSummary *s, CamelMimeParser *mp) mbi->frompos = camel_mime_parser_tell_start_from(mp); /* do we want to index this message as we add it, as well? */ - if (mbs->index_force - || (mi->flags & CAMEL_MESSAGE_FOLDER_FLAGGED) != 0 - || !ibex_contains_name(mbs->index, mi->uid)) { - + if (mbs->index + && (mbs->index_force + || (mi->flags & CAMEL_MESSAGE_FOLDER_FLAGGED) != 0 + || !ibex_contains_name(mbs->index, mi->uid))) { camel_folder_summary_set_index(s, mbs->index); } else { camel_folder_summary_set_index(s, NULL); @@ -387,7 +387,7 @@ camel_mbox_summary_load(CamelMboxSummary *mbs, int forceindex) for (i = 0; i < camel_folder_summary_count(s); i++) { CamelMessageInfo *mi = camel_folder_summary_index(s, i); - if (!ibex_contains_name(mbs->index, mi->uid)) { + if (mbs->index && !ibex_contains_name(mbs->index, mi->uid)) { minstart = ((CamelMboxMessageInfo *) mi)->frompos; printf("Found unindexed message: %s\n", mi->uid); break; diff --git a/camel/providers/mh/camel-mh-folder.c b/camel/providers/mh/camel-mh-folder.c index c8b0503e95..ccd9d717e9 100644 --- a/camel/providers/mh/camel-mh-folder.c +++ b/camel/providers/mh/camel-mh-folder.c @@ -158,7 +158,7 @@ CamelType camel_mh_folder_get_type(void) } CamelFolder * -camel_mh_folder_new(CamelStore *parent_store, const char *full_name, CamelException *ex) +camel_mh_folder_new(CamelStore *parent_store, const char *full_name, guint32 flags, CamelException *ex) { CamelFolder *folder; CamelMhFolder *mh_folder; @@ -185,11 +185,20 @@ camel_mh_folder_new(CamelStore *parent_store, const char *full_name, CamelExcept /* if we have no index file, force it */ forceindex = stat(mh_folder->index_file_path, &st) == -1; - - mh_folder->index = ibex_open(mh_folder->index_file_path, O_CREAT | O_RDWR, 0600); - if (mh_folder->index == NULL) { - /* yes, this isn't fatal at all */ - g_warning("Could not open/create index file: %s: indexing not performed", strerror(errno)); + /* check if we need to setup an index */ + if (flags & CAMEL_STORE_FOLDER_BODY_INDEX) { + mh_folder->index = ibex_open(mh_folder->index_file_path, O_CREAT | O_RDWR, 0600); + if (mh_folder->index == NULL) { + /* yes, this isn't fatal at all */ + g_warning("Could not open/create index file: %s: indexing not performed", strerror(errno)); + forceindex = FALSE; + } + } else { + /* if we do have an index file, remove it */ + if (forceindex == FALSE) { + unlink(mh_folder->index_file_path); + } + forceindex = FALSE; } /* no summary (disk or memory), and we're proverbially screwed */ diff --git a/camel/providers/mh/camel-mh-folder.h b/camel/providers/mh/camel-mh-folder.h index 90f2324d11..bdb1588811 100644 --- a/camel/providers/mh/camel-mh-folder.h +++ b/camel/providers/mh/camel-mh-folder.h @@ -62,7 +62,7 @@ typedef struct { } CamelMhFolderClass; /* public methods */ -CamelFolder *camel_mh_folder_new(CamelStore *parent_store, const char *full_name, CamelException *ex); +CamelFolder *camel_mh_folder_new(CamelStore *parent_store, const char *full_name, guint32 flags, CamelException *ex); /* Standard Camel function */ CamelType camel_mh_folder_get_type(void); diff --git a/camel/providers/mh/camel-mh-store.c b/camel/providers/mh/camel-mh-store.c index c169d878fd..ead6e4f340 100644 --- a/camel/providers/mh/camel-mh-store.c +++ b/camel/providers/mh/camel-mh-store.c @@ -41,7 +41,7 @@ #define CMHF_CLASS(so) CAMEL_MH_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so)) static char *get_name(CamelService * service, gboolean brief); -static CamelFolder *get_folder(CamelStore * store, const char *folder_name, gboolean create, CamelException * ex); +static CamelFolder *get_folder(CamelStore * store, const char *folder_name, guint32 flags, CamelException * ex); static void delete_folder(CamelStore * store, const char *folder_name, CamelException * ex); static void rename_folder(CamelStore *store, const char *old_name, const char *new_name, CamelException *ex); static char *get_folder_name(CamelStore * store, const char *folder_name, CamelException * ex); @@ -102,7 +102,7 @@ const gchar *camel_mh_store_get_toplevel_dir(CamelMhStore * store) return url->path; } -static CamelFolder *get_folder(CamelStore * store, const char *folder_name, gboolean create, CamelException * ex) +static CamelFolder *get_folder(CamelStore * store, const char *folder_name, guint32 flags, CamelException * ex) { char *name; struct stat st; @@ -118,7 +118,7 @@ static CamelFolder *get_folder(CamelStore * store, const char *folder_name, gboo g_free (name); return NULL; } - if (!create) { + if ((flags & CAMEL_STORE_FOLDER_CREATE) == 0) { camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER, "Folder `%s' does not exist.", folder_name); g_free (name); @@ -141,7 +141,7 @@ static CamelFolder *get_folder(CamelStore * store, const char *folder_name, gboo } g_free(name); - return camel_mh_folder_new (store, folder_name, ex); + return camel_mh_folder_new(store, folder_name, flags, ex); } static void delete_folder(CamelStore * store, const char *folder_name, CamelException * ex) diff --git a/camel/providers/mh/camel-mh-summary.c b/camel/providers/mh/camel-mh-summary.c index 5d304b4a42..ce1d597012 100644 --- a/camel/providers/mh/camel-mh-summary.c +++ b/camel/providers/mh/camel-mh-summary.c @@ -161,7 +161,7 @@ int camel_mh_summary_add(CamelMhSummary * mhs, const char *name, int forceindex mp = camel_mime_parser_new(); camel_mime_parser_scan_from(mp, FALSE); camel_mime_parser_init_with_fd(mp, fd); - if (forceindex || !ibex_contains_name(mhs->index, (char *)name)) { + if (mhs->index && (forceindex || !ibex_contains_name(mhs->index, (char *)name))) { d(printf("forcing indexing of message content\n")); camel_folder_summary_set_index((CamelFolderSummary *)mhs, mhs->index); } else { @@ -180,7 +180,8 @@ static void remove_summary(char *key, CamelMessageInfo *info, CamelMhSummary *mhs) { d(printf("removing message %s from summary\n", key)); - ibex_unindex(mhs->index, info->uid); + if (mhs->index) + ibex_unindex(mhs->index, info->uid); camel_folder_summary_remove((CamelFolderSummary *)mhs, info); } @@ -219,7 +220,7 @@ int camel_mh_summary_check(CamelMhSummary * mhs, int forceindex) } if (c==0) { info = camel_folder_summary_uid((CamelFolderSummary *)mhs, d->d_name); - if (info == NULL || (!ibex_contains_name(mhs->index, d->d_name))) { + if (info == NULL || (mhs->index && (!ibex_contains_name(mhs->index, d->d_name)))) { /* need to add this file to the summary */ if (info != NULL) { g_hash_table_remove(left, info->uid); diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c index 44b5fc102f..c75acbce44 100644 --- a/camel/providers/nntp/camel-nntp-store.c +++ b/camel/providers/nntp/camel-nntp-store.c @@ -315,7 +315,7 @@ nntp_store_query_auth_types_connected (CamelService *service, CamelException *ex static CamelFolder * nntp_store_get_folder (CamelStore *store, const gchar *folder_name, - gboolean get_folder, CamelException *ex) + guint32 flags, CamelException *ex) { CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (store); diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c index c5159eda1d..57af24b7f3 100644 --- a/camel/providers/pop3/camel-pop3-store.c +++ b/camel/providers/pop3/camel-pop3-store.c @@ -74,7 +74,7 @@ static GList *query_auth_types_connected (CamelService *service, CamelException static GList *query_auth_types_generic (CamelService *service, CamelException *ex); static CamelFolder *get_folder (CamelStore *store, const char *folder_name, - gboolean create, CamelException *ex); + guint32 flags, CamelException *ex); static char *get_folder_name (CamelStore *store, const char *folder_name, CamelException *ex); static char *get_root_folder_name (CamelStore *store, CamelException *ex); @@ -544,7 +544,7 @@ pop3_disconnect (CamelService *service, CamelException *ex) static CamelFolder * get_folder (CamelStore *store, const char *folder_name, - gboolean create, CamelException *ex) + guint32 flags, CamelException *ex) { return camel_pop3_folder_new (store, ex); } diff --git a/camel/providers/vee/camel-vee-store.c b/camel/providers/vee/camel-vee-store.c index 201c4b1fd8..7acc127542 100644 --- a/camel/providers/vee/camel-vee-store.c +++ b/camel/providers/vee/camel-vee-store.c @@ -22,7 +22,7 @@ #include "camel-vee-store.h" #include "camel-vee-folder.h" -static CamelFolder *vee_get_folder (CamelStore *store, const char *folder_name, gboolean create, CamelException *ex); +static CamelFolder *vee_get_folder (CamelStore *store, const char *folder_name, guint32 flags, CamelException *ex); static char *vee_get_folder_name (CamelStore *store, const char *folder_name, CamelException *ex); struct _CamelVeeStorePrivate { @@ -89,7 +89,7 @@ camel_vee_store_new (void) } static CamelFolder * -vee_get_folder (CamelStore *store, const char *folder_name, gboolean create, CamelException *ex) +vee_get_folder (CamelStore *store, const char *folder_name, guint32 flags, CamelException *ex) { return camel_vee_folder_new (store, folder_name, ex); } |