comparison src/plugins/acl/acl-mailbox.c @ 9434:e374a365521d HEAD

Initial commit for making mail_storage:mailbox_list to be from 1:1 to n:n. This will allow namespaces to share the same storage and a single namespace to have multiple storages (multiple mailbox formats). Neither works currently, and this commit probably breaks some things.
author Timo Sirainen <tss@iki.fi>
date Tue, 02 Jun 2009 22:30:28 -0400
parents 68db63cc32b3
children 653183a81b6c
comparison
equal deleted inserted replaced
9433:438491c166cb 9434:e374a365521d
28 }; 28 };
29 29
30 static MODULE_CONTEXT_DEFINE_INIT(acl_mail_module, &mail_module_register); 30 static MODULE_CONTEXT_DEFINE_INIT(acl_mail_module, &mail_module_register);
31 static struct acl_transaction_context acl_transaction_failure; 31 static struct acl_transaction_context acl_transaction_failure;
32 32
33 struct acl_backend *acl_storage_get_backend(struct mail_storage *storage)
34 {
35 struct acl_mail_storage *astorage = ACL_CONTEXT(storage);
36
37 return astorage->rights.backend;
38 }
39
40 struct acl_object *acl_storage_get_default_aclobj(struct mail_storage *storage)
41 {
42 struct acl_mail_storage *astorage = ACL_CONTEXT(storage);
43
44 return astorage->rights.backend->default_aclobj;
45 }
46
47 struct acl_object *acl_mailbox_get_aclobj(struct mailbox *box) 33 struct acl_object *acl_mailbox_get_aclobj(struct mailbox *box)
48 { 34 {
49 struct acl_mailbox *abox = ACL_CONTEXT(box); 35 struct acl_mailbox *abox = ACL_CONTEXT(box);
50 36
51 return abox->aclobj; 37 return abox->aclobj;
52 } 38 }
53 39
54 int acl_mailbox_right_lookup(struct mailbox *box, unsigned int right_idx) 40 int acl_mailbox_right_lookup(struct mailbox *box, unsigned int right_idx)
55 { 41 {
56 struct acl_mailbox *abox = ACL_CONTEXT(box); 42 struct acl_mailbox *abox = ACL_CONTEXT(box);
57 struct acl_mail_storage *astorage = ACL_CONTEXT(box->storage); 43 struct acl_mailbox_list *alist = ACL_LIST_CONTEXT(box->list);
58 int ret; 44 int ret;
59 45
60 ret = acl_object_have_right(abox->aclobj, 46 ret = acl_object_have_right(abox->aclobj,
61 astorage->rights.acl_storage_right_idx[right_idx]); 47 alist->rights.acl_storage_right_idx[right_idx]);
62 if (ret > 0) 48 if (ret > 0)
63 return 1; 49 return 1;
64 if (ret < 0) { 50 if (ret < 0) {
65 mail_storage_set_internal_error(box->storage); 51 mail_storage_set_internal_error(box->storage);
66 return -1; 52 return -1;
350 keywords_r, skip_invalid); 336 keywords_r, skip_invalid);
351 } 337 }
352 338
353 struct mailbox *acl_mailbox_open_box(struct mailbox *box) 339 struct mailbox *acl_mailbox_open_box(struct mailbox *box)
354 { 340 {
355 struct acl_mail_storage *astorage = ACL_CONTEXT(box->storage); 341 struct acl_mailbox_list *alist = ACL_LIST_CONTEXT(box->list);
356 struct acl_mailbox *abox; 342 struct acl_mailbox *abox;
357 343
358 abox = p_new(box->pool, struct acl_mailbox, 1); 344 abox = p_new(box->pool, struct acl_mailbox, 1);
359 abox->module_ctx.super = box->v; 345 abox->module_ctx.super = box->v;
360 abox->aclobj = acl_object_init_from_name(astorage->rights.backend, 346 abox->aclobj = acl_object_init_from_name(alist->rights.backend,
361 box->storage,
362 mailbox_get_name(box)); 347 mailbox_get_name(box));
363 348
364 if ((box->open_flags & MAILBOX_OPEN_IGNORE_ACLS) == 0) { 349 if ((box->open_flags & MAILBOX_OPEN_IGNORE_ACLS) == 0) {
365 box->v.is_readonly = acl_is_readonly; 350 box->v.is_readonly = acl_is_readonly;
366 box->v.allow_new_keywords = acl_allow_new_keywords; 351 box->v.allow_new_keywords = acl_allow_new_keywords;