client->mailbox = NULL;
- if (!mailbox->readonly) {
+ if (!mailbox->is_readonly(mailbox)) {
if (!imap_expunge(mailbox, FALSE))
client_send_untagged_storage_error(client);
}
"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.");
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));
}
}
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;
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);
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;
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;
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;
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)
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");
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;
};
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);
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;
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;
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);
}
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;
}
NULL, /* name */
NULL, /* storage */
+ index_storage_is_readonly,
+ index_storage_allow_new_custom_flags,
maildir_storage_close,
maildir_storage_lock,
index_storage_get_status,
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
};
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;
}
NULL, /* name */
NULL, /* storage */
+ index_storage_is_readonly,
+ index_storage_allow_new_custom_flags,
mbox_storage_close,
mbox_storage_lock,
index_storage_get_status,
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
};
*syntax = storage->syntax_error;
return storage->error;
}
-
-int mail_storage_is_inconsistency_error(struct mailbox *box)
-{
- return box->inconsistent;
-}
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);
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 {
const char *mail_storage_get_last_error(struct mail_storage *storage,
int *syntax);
-int mail_storage_is_inconsistency_error(struct mailbox *box);
#endif