]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
API changes: Don't keep variables in mailbox class.
authorTimo Sirainen <tss@iki.fi>
Sat, 26 Jul 2003 16:55:11 +0000 (19:55 +0300)
committerTimo Sirainen <tss@iki.fi>
Sat, 26 Jul 2003 16:55:11 +0000 (19:55 +0300)
--HG--
branch : HEAD

16 files changed:
src/imap/cmd-close.c
src/imap/cmd-select.c
src/imap/commands-util.c
src/imap/imap-fetch.c
src/lib-storage/index/index-expunge.c
src/lib-storage/index/index-storage.c
src/lib-storage/index/index-storage.h
src/lib-storage/index/index-update-flags.c
src/lib-storage/index/maildir/maildir-copy.c
src/lib-storage/index/maildir/maildir-expunge.c
src/lib-storage/index/maildir/maildir-save.c
src/lib-storage/index/maildir/maildir-storage.c
src/lib-storage/index/mbox/mbox-save.c
src/lib-storage/index/mbox/mbox-storage.c
src/lib-storage/mail-storage.c
src/lib-storage/mail-storage.h

index 50a541b9f9dbd9790b4db17322b145b5262a30d8..cbbdab859abc7b310f1cc7f153eed91679bd00b1 100644 (file)
@@ -13,7 +13,7 @@ int cmd_close(struct client *client)
 
        client->mailbox = NULL;
 
-       if (!mailbox->readonly) {
+       if (!mailbox->is_readonly(mailbox)) {
                if (!imap_expunge(mailbox, FALSE))
                        client_send_untagged_storage_error(client);
        }
index 634e3260daf4a254c32e309ea4b4a9de0d382466..0134578bb56ae7c1b3e57cd5a2e18109d78c5e42 100644 (file)
@@ -73,7 +73,7 @@ int _cmd_select_full(struct client *client, int readonly)
                                 "Disk space is full, delete some messages.");
        }
 
-       client_send_tagline(client, box->readonly ?
+       client_send_tagline(client, box->is_readonly(box) ?
                            "OK [READ-ONLY] Select completed." :
                            "OK [READ-WRITE] Select completed.");
 
index 4da8155d44551d7c63d965589aea98ff8bec3c7d..d56ee4ecc203d90d9dff47368a3baa3942598f5b 100644 (file)
@@ -288,14 +288,14 @@ void client_send_mailbox_flags(struct client *client, struct mailbox *box,
        client_send_line(client,
                t_strconcat("* FLAGS ("SYSTEM_FLAGS, str, ")", NULL));
 
-       if (box->readonly) {
+       if (box->is_readonly(box)) {
                client_send_line(client, "* OK [PERMANENTFLAGS ()] "
                                 "Read-only mailbox.");
        } else {
                client_send_line(client,
                        t_strconcat("* OK [PERMANENTFLAGS ("SYSTEM_FLAGS, str,
-                                   box->allow_custom_flags ? " \\*" : "",
-                                   ")] Flags permitted.", NULL));
+                                   box->allow_new_custom_flags(box) ?
+                                   " \\*" : "", ")] Flags permitted.", NULL));
        }
 }
 
index 2b5dff5d7ea4f73e6cc9034fc1905aac0a9b6604..483207627077c895b5d3d1a55c3e07c9a88554d6 100644 (file)
@@ -275,7 +275,7 @@ int imap_fetch(struct client *client,
        ctx.select_counter = client->select_counter;
        ctx.seen_flag.flags = MAIL_SEEN;
 
-       if (!box->readonly) {
+       if (!box->is_readonly(box)) {
                /* If we have any BODY[..] sections, \Seen flag is added for
                   all messages */
                struct imap_fetch_body_data *body;
index da9c0d2cc7415d3c1336ce89fc8b1843d7f8e893..37e227314232bf505df877d04bed2b8535fe5b9e 100644 (file)
@@ -53,7 +53,7 @@ index_storage_expunge_init(struct mailbox *box,
        struct index_mailbox *ibox = (struct index_mailbox *) box;
        struct mail_expunge_context *ctx;
 
-       if (box->readonly) {
+       if (box->is_readonly(box)) {
                box->storage->callbacks->
                        notify_no(box, "Mailbox is read-only, ignoring expunge",
                                  box->storage->callback_context);
index 0bd23fe9fae8446becdea6a12babca4738da6758..f5d31b81d770422a41ce907e816ab78cadb80865 100644 (file)
@@ -271,7 +271,7 @@ static void lock_notify(enum mail_lock_notify_type notify_type,
 void index_storage_init_lock_notify(struct index_mailbox *ibox)
 {
        if (ibox->index->mailbox_readonly)
-               ibox->box.readonly = TRUE;
+               ibox->readonly = TRUE;
 
        ibox->next_lock_notify = time(NULL) + LOCK_NOTIFY_INTERVAL;
        ibox->last_notify_type = (enum mail_lock_notify_type)-1;
@@ -328,7 +328,7 @@ index_storage_mailbox_init(struct mail_storage *storage, struct mailbox *box,
 
                ibox->box.storage = storage;
                ibox->box.name = i_strdup(name);
-               ibox->box.readonly = (flags & MAILBOX_OPEN_READONLY) != 0;
+               ibox->readonly = (flags & MAILBOX_OPEN_READONLY) != 0;
 
                ibox->index = index;
 
@@ -356,8 +356,6 @@ index_storage_mailbox_init(struct mail_storage *storage, struct mailbox *box,
                if (!ibox->index->set_lock(ibox->index, MAIL_LOCK_SHARED))
                        break;
 
-               ibox->box.allow_custom_flags =
-                       ibox->index->allow_new_custom_flags;
                ibox->synced_messages_count =
                        mail_index_get_header(index)->messages_count;
 
@@ -391,6 +389,27 @@ int index_storage_mailbox_free(struct mailbox *box)
        return TRUE;
 }
 
+int index_storage_is_readonly(struct mailbox *box)
+{
+       struct index_mailbox *ibox = (struct index_mailbox *) box;
+
+       return ibox->readonly;
+}
+
+int index_storage_allow_new_custom_flags(struct mailbox *box)
+{
+       struct index_mailbox *ibox = (struct index_mailbox *) box;
+
+       return ibox->index->allow_new_custom_flags;
+}
+
+int index_storage_is_inconsistency_error(struct mailbox *box)
+{
+       struct index_mailbox *ibox = (struct index_mailbox *) box;
+
+       return ibox->inconsistent;
+}
+
 void index_storage_set_callbacks(struct mail_storage *storage,
                                 struct mail_storage_callbacks *callbacks,
                                 void *context)
@@ -408,7 +427,7 @@ int mail_storage_set_index_error(struct index_mailbox *ibox)
                mail_storage_set_internal_error(ibox->box.storage);
                break;
        case MAIL_INDEX_ERROR_INCONSISTENT:
-               ibox->box.inconsistent = TRUE;
+               ibox->inconsistent = TRUE;
                break;
        case MAIL_INDEX_ERROR_DISKSPACE:
                mail_storage_set_error(ibox->box.storage, "Out of disk space");
index be044734ee9c48ccdd1c3ef6937d1c2a4ac8a178..8fa90e39e6fb26a21faead9e2bf2a666ea86e8a5 100644 (file)
@@ -34,6 +34,8 @@ struct index_mailbox {
        time_t next_lock_notify; /* temporary */
        enum mail_lock_notify_type last_notify_type;
 
+       unsigned int readonly:1;
+       unsigned int inconsistent:1;
        unsigned int sent_diskspace_warning:1;
        unsigned int sent_readonly_flags_warning:1;
 };
@@ -57,6 +59,10 @@ index_storage_mailbox_init(struct mail_storage *storage, struct mailbox *box,
                           enum mailbox_open_flags flags);
 int index_storage_mailbox_free(struct mailbox *box);
 
+int index_storage_is_readonly(struct mailbox *box);
+int index_storage_allow_new_custom_flags(struct mailbox *box);
+int index_storage_is_inconsistency_error(struct mailbox *box);
+
 int index_storage_sync_and_lock(struct index_mailbox *ibox,
                                int sync_size, int minimal_sync,
                                enum mail_lock_type data_lock_type);
index 87aacc1ab44459540c83d10497772d3e64997712..80a7d6e9bec92eb8b1b283c3cb05ecde207f57cb 100644 (file)
@@ -14,7 +14,7 @@ int index_storage_update_flags(struct mail *mail,
        struct mail_storage *storage = mail->box->storage;
        enum mail_flags modify_flags, new_flags;
 
-       if (mail->box->readonly) {
+       if (mail->box->is_readonly(mail->box)) {
                if (ibox->sent_readonly_flags_warning)
                        return TRUE;
                 ibox->sent_readonly_flags_warning = TRUE;
index bfb8b9f321d93c31b6261a592e6e28980589eef5..c9f5d9346b27a50146fa1e9d019f77e98b93c7d5 100644 (file)
@@ -133,7 +133,7 @@ struct mail_copy_context *maildir_storage_copy_init(struct mailbox *box)
        struct index_mailbox *ibox = (struct index_mailbox *) box;
        struct maildir_copy_context *ctx;
 
-       if (box->readonly) {
+       if (box->is_readonly(box)) {
                mail_storage_set_error(box->storage,
                                       "Destination mailbox is read-only");
                return NULL;
index f9a8699a28a727bfc404c44c606859999a3be20e..eb329edadcb78bf81d96db1d608af5ddb7f94836 100644 (file)
@@ -56,7 +56,7 @@ int maildir_storage_expunge(struct mail *mail,
        struct index_mail *imail = (struct index_mail *) mail;
        int ret;
 
-       if (mail->box->readonly) {
+       if (mail->box->is_readonly(mail->box)) {
                /* send warning */
                return index_storage_expunge(mail, ctx->ctx, seq_r, notify);
        }
index 584094db60eee3c2f7bc35675ee56df8da1adaf7..921b3548ed6f4141dda8de7f6105deb01857fed8 100644 (file)
@@ -172,7 +172,7 @@ maildir_storage_save_init(struct mailbox *box, int transaction)
        struct mail_save_context *ctx;
        pool_t pool;
 
-       if (box->readonly) {
+       if (box->is_readonly(box)) {
                mail_storage_set_error(box->storage, "Mailbox is read-only");
                return NULL;
        }
index 054b654c885a7d9cac336b972b3e4abe86c1f0e7..7cf0796184dc04e952efba10ca2b0aecdf3ac9d7 100644 (file)
@@ -764,6 +764,8 @@ struct mailbox maildir_mailbox = {
        NULL, /* name */
        NULL, /* storage */
 
+       index_storage_is_readonly,
+        index_storage_allow_new_custom_flags,
        maildir_storage_close,
        maildir_storage_lock,
        index_storage_get_status,
@@ -786,9 +788,5 @@ struct mailbox maildir_mailbox = {
        maildir_storage_expunge_init,
        maildir_storage_expunge_deinit,
        maildir_storage_expunge_fetch_next,
-       mail_storage_is_inconsistency_error,
-
-       FALSE,
-       FALSE,
-       FALSE
+       index_storage_is_inconsistency_error
 };
index e8815469e3693b663c55614d428a0a2c9cf9eff8..6c0dadc3bc7d28c90c8b0d48221171386f812259 100644 (file)
@@ -320,7 +320,7 @@ mbox_storage_save_init(struct mailbox *box, int transaction)
        struct index_mailbox *ibox = (struct index_mailbox *) box;
        struct mail_save_context *ctx;
 
-       if (box->readonly) {
+       if (box->is_readonly(box)) {
                mail_storage_set_error(box->storage, "Mailbox is read-only");
                return NULL;
        }
index c540857ae6ae0a559b1ef15bbbb5464a44165a8a..db4e117b95105c723a777e34b509d97bec638abb 100644 (file)
@@ -780,6 +780,8 @@ struct mailbox mbox_mailbox = {
        NULL, /* name */
        NULL, /* storage */
 
+       index_storage_is_readonly,
+        index_storage_allow_new_custom_flags,
        mbox_storage_close,
        mbox_storage_lock,
        index_storage_get_status,
@@ -802,9 +804,5 @@ struct mailbox mbox_mailbox = {
        mbox_storage_expunge_init,
        mbox_storage_expunge_deinit,
        mbox_storage_expunge_fetch_next,
-       mail_storage_is_inconsistency_error,
-
-       FALSE,
-       FALSE,
-       FALSE
+       index_storage_is_inconsistency_error
 };
index 25da04fa10799e5be45a92884f5d061afb1463be..c5b70b2f6521ae5050b28e8f6b2cb438bf9d2aa2 100644 (file)
@@ -256,8 +256,3 @@ const char *mail_storage_get_last_error(struct mail_storage *storage,
                *syntax = storage->syntax_error;
        return storage->error;
 }
-
-int mail_storage_is_inconsistency_error(struct mailbox *box)
-{
-       return box->inconsistent;
-}
index 9d442f87d8235b95dbfa6e632766a403a44af0d8..d1ca820d19faa2c830604c10770be8619ba89a0e 100644 (file)
@@ -229,6 +229,12 @@ struct mailbox {
 
        struct mail_storage *storage;
 
+       /* Returns TRUE if mailbox is read-only. */
+       int (*is_readonly)(struct mailbox *box);
+
+       /* Returns TRUE if mailbox supports adding custom flags. */
+       int (*allow_new_custom_flags)(struct mailbox *box);
+
        /* Close the box. Returns FALSE if some cleanup errors occured, but
           the mailbox was closed anyway. */
        int (*close)(struct mailbox *box);
@@ -342,12 +348,6 @@ struct mailbox {
           connection this would mean a forced disconnection since we can't
           do forced CLOSE. */
        int (*is_inconsistency_error)(struct mailbox *box);
-
-/* public: */
-       unsigned int readonly:1;
-       unsigned int allow_custom_flags:1;
-/* private: */
-       unsigned int inconsistent:1;
 };
 
 struct mail {
@@ -508,6 +508,5 @@ void mail_storage_set_internal_error(struct mail_storage *storage);
 
 const char *mail_storage_get_last_error(struct mail_storage *storage,
                                        int *syntax);
-int mail_storage_is_inconsistency_error(struct mailbox *box);
 
 #endif