diff options
author | Thomas Roessler <roessler@does-not-exist.org> | 2001-02-19 11:05:23 +0000 |
---|---|---|
committer | Thomas Roessler <roessler@does-not-exist.org> | 2001-02-19 11:05:23 +0000 |
commit | 1af6293146bf5457d254a739536f1b7816a3429d (patch) | |
tree | fa8f327fbbedeec3dbb86c645e124bb1e16dee36 /imap | |
parent | 3b66b06963fe75d5e47db3b0c5f96b8ae37743cd (diff) |
Brendan Cully's generic access() wrapper which know about IMAP.
Diffstat (limited to 'imap')
-rw-r--r-- | imap/imap.c | 44 | ||||
-rw-r--r-- | imap/imap.h | 1 |
2 files changed, 45 insertions, 0 deletions
diff --git a/imap/imap.c b/imap/imap.c index 3d8437d1..80e4c73a 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -48,6 +48,50 @@ static int imap_check_capabilities (IMAP_DATA* idata); static void imap_set_flag (IMAP_DATA* idata, int aclbit, int flag, const char* str, char* flags, size_t flsize); +/* imap_access: Check permissions on an IMAP mailbox. */ +int imap_access (const char* path, int flags) +{ + IMAP_DATA* idata; + IMAP_MBOX mx; + char buf[LONG_STRING]; + char mailbox[LONG_STRING]; + char mbox[LONG_STRING]; + + if (imap_parse_path (path, &mx)) + return -1; + + if (!(idata = imap_conn_find (&mx.account, + option (OPTIMAPPASSIVE) ? M_IMAP_CONN_NONEW : 0))) + { + FREE (&mx.mbox); + return -1; + } + + + imap_fix_path (idata, mx.mbox, mailbox, sizeof (mailbox)); + FREE (&mx.mbox); + imap_munge_mbox_name (mbox, sizeof (mbox), mailbox); + + /* TODO: ACL checks. Right now we assume if it exists we can mess with it. */ + if (mutt_bit_isset (idata->capabilities, IMAP4REV1)) + snprintf (buf, sizeof (buf), "STATUS %s (UIDVALIDITY)", mbox); + else if (mutt_bit_isset (idata->capabilities, STATUS)) + snprintf (buf, sizeof (buf), "STATUS %s (UID-VALIDITY)", mbox); + else + { + dprint (2, (debugfile, "imap_access: STATUS not supported?\n")); + return -1; + } + + if (imap_exec (idata, buf, IMAP_CMD_FAIL_OK) < 0) + { + dprint (1, (debugfile, "imap_access: Can't check STATUS of %s\n", mbox)); + return -1; + } + + return 0; +} + int imap_create_mailbox (IMAP_DATA* idata, char* mailbox) { char buf[LONG_STRING], mbox[LONG_STRING]; diff --git a/imap/imap.h b/imap/imap.h index b05dc182..3cefa694 100644 --- a/imap/imap.h +++ b/imap/imap.h @@ -32,6 +32,7 @@ typedef struct } IMAP_MBOX; /* imap.c */ +int imap_access (const char*, int); int imap_check_mailbox (CONTEXT *ctx, int *index_hint); int imap_close_connection (CONTEXT *ctx); int imap_delete_mailbox (CONTEXT* idata, char* mailbox); |