char name[LONG_STRING];
short n;
- adata = imap_adata_find(path, name, sizeof(name));
+ adata = imap_adata_find(path, name, sizeof(name), false);
if (!adata)
{
mutt_debug(1, "Couldn't find open connection to %s\n", path);
char oldname[LONG_STRING];
char newname[PATH_MAX];
- adata = imap_adata_find(path, oldname, sizeof(oldname));
+ adata = imap_adata_find(path, oldname, sizeof(oldname), false);
if (!adata)
{
mutt_debug(1, "Couldn't find open connection to %s\n", path);
return 0;
}
-/**
- * get_mailbox - Split mailbox URI
- * @param path Mailbox URI
- * @param adata Imap Account data
- * @param buf Buffer to store mailbox name
- * @param buflen Length of buffer
- * @retval 0 Success
- * @retval -1 Failure
- *
- * Split up a mailbox URI. The connection info is stored in the ImapAccountData and
- * the mailbox name is stored in buf.
- * TODO(sileht): We should drop this method and pass a Context or Mailbox
- * object everywhere instead.
- */
-int get_mailbox(const char *path, struct ImapAccountData **adata, char *buf, size_t buflen)
-{
- char tmp[LONG_STRING];
-
- *adata = imap_adata_find(path, tmp, sizeof(tmp));
- if (!*adata)
- return -1;
-
- imap_fix_path(*adata, tmp, buf, buflen);
- if (!*buf)
- mutt_str_strfcpy(buf, "INBOX", buflen);
- return 0;
-}
-
/**
* do_search - Perform a search of messages
* @param search List of pattern to match
{
struct ImapAccountData *adata = NULL;
char mailbox[LONG_STRING];
- int rc;
- rc = get_mailbox(path, &adata, mailbox, sizeof(mailbox));
- if (rc < 0)
+ adata = imap_adata_find(path, mailbox, sizeof(mailbox), true);
+ if (!adata)
return -1;
- rc = imap_access2(adata, mailbox);
- return rc;
+ if (mailbox[0] == '\0')
+ mutt_str_strfcpy(mailbox, "INBOX", sizeof(mailbox));
+
+ return imap_access2(adata, mailbox);
}
/**
char mbox[LONG_STRING];
struct ImapStatus *status = NULL;
- if (get_mailbox(path, &adata, buf, sizeof(buf)) < 0)
+ adata = imap_adata_find(path, buf, sizeof(buf), true);
+ if (!adata)
return -1;
/* We are in the folder we're polling - just return the mailbox count.
char errstr[STRING];
struct Buffer err, token;
size_t len = 0;
- int rc;
- rc = get_mailbox(path, &adata, buf, sizeof(buf));
- if (rc < 0)
+ adata = imap_adata_find(path, buf, sizeof(buf), false);
+ if (!adata)
return -1;
if (ImapCheckSubscribed)
int completions = 0;
int rc;
- adata = imap_adata_find(path, mailbox, sizeof(mailbox));
+ adata = imap_adata_find(path, mailbox, sizeof(mailbox), false);
if (!adata)
{
mutt_str_strfcpy(buf, path, buflen);
void imap_logout(struct ImapAccountData **adata);
int imap_sync_message_for_copy(struct ImapAccountData *adata, struct Email *e, struct Buffer *cmd, int *err_continue);
bool imap_has_flag(struct ListHead *flag_list, const char *flag);
-struct ImapAccountData *imap_adata_find(const char *path, char *mailbox, size_t mailboxlen);
+struct ImapAccountData *imap_adata_find(const char *path, char *mailbox, size_t mailboxlen, bool fix_path);
/* auth.c */
int imap_authenticate(struct ImapAccountData *adata);
/**
* imap_adata_find - Find the Account data for this path
*/
-struct ImapAccountData *imap_adata_find(const char *path, char *mailbox, size_t mailboxlen)
+struct ImapAccountData *imap_adata_find(const char *path, char *mailbox,
+ size_t mailboxlen, bool fix_path)
{
// NOTE(sileht): Remove mx when we are able to pass Mailbox or Url there.
struct ImapMbox mx;
if (imap_account_match(&adata->conn_account, &mx.account))
{
if (mx.mbox)
- mutt_str_strfcpy(mailbox, mx.mbox, mailboxlen);
+ {
+ if (fix_path)
+ imap_fix_path(adata, mx.mbox, mailbox, mailboxlen);
+ else
+ mutt_str_strfcpy(mailbox, mx.mbox, mailboxlen);
+ }
return adata;
}
}
struct ImapAccountData *adata = NULL;
char mbox[LONG_STRING], tmp[LONG_STRING];
- adata = imap_adata_find(path, tmp, sizeof(tmp));
+ adata = imap_adata_find(path, tmp, sizeof(tmp), true);
if (!adata || tmp[0] == '\0')
{
mutt_str_strfcpy(buf, path, buflen);
return;
}
- /* Stores a fixed path in mbox */
- imap_fix_path(adata, tmp, mbox, sizeof(mbox));
-
/* Gets the parent mbox in mbox */
imap_get_parent(mbox, adata->delim, mbox, sizeof(mbox));
struct ImapAccountData *adata = NULL;
char mbox[LONG_STRING], tmp[LONG_STRING];
- adata = imap_adata_find(path, tmp, sizeof(tmp));
+ adata = imap_adata_find(path, tmp, sizeof(tmp), true);
if (!adata || tmp[0] == '\0')
return;
- /* Stores a fixed path in mbox */
- imap_fix_path(adata, tmp, mbox, sizeof(mbox));
-
/* Returns a fully qualified IMAP url */
imap_qualify_path2(path, plen, &adata->conn_account, mbox);
}