if (!new_account)
{
- struct Mailbox *old_m = mx_mbox_find(a, m);
+ struct Mailbox *old_m = mx_mbox_find(a, m->realpath);
if (old_m)
{
if (old_m->flags == MB_HIDDEN)
*/
struct Account *mbox_ac_find(struct Account *a, const char *path)
{
- return NULL;
+ if (!a || (a->magic != MUTT_MBOX) || !path)
+ return NULL;
+
+ struct MailboxNode *np = STAILQ_FIRST(&a->mailboxes);
+ if (!np)
+ return NULL;
+
+ if (mutt_str_strcmp(np->m->path, path) != 0)
+ return NULL;
+
+ return a;
}
/**
{
ctx->mailbox = mailbox_new();
ctx->mailbox->flags = MB_HIDDEN;
+ mutt_str_strfcpy(ctx->mailbox->path, path, sizeof(ctx->mailbox->path));
+ /* int rc = */ mx_path_canon2(ctx->mailbox, Folder);
}
#if 0
ctx->mailbox->magic = mx_path_probe(path, NULL);
ctx->mailbox->mx_ops = mx_get_ops(ctx->mailbox->magic);
- if (ctx->mailbox->path[0] == '\0')
- mutt_str_strfcpy(ctx->mailbox->path, path, sizeof(ctx->mailbox->path));
+ // if (ctx->mailbox->path[0] == '\0')
+ // mutt_str_strfcpy(ctx->mailbox->path, path, sizeof(ctx->mailbox->path));
if ((ctx->mailbox->magic == MUTT_UNKNOWN) ||
(ctx->mailbox->magic == MUTT_MAILBOX_ERROR) || !ctx->mailbox->mx_ops)
*
* find a mailbox on an account
*/
-struct Mailbox *mx_mbox_find(struct Account *a, struct Mailbox *m)
+struct Mailbox *mx_mbox_find(struct Account *a, const char *path)
{
- if (!a || !m)
+ if (!a || !path)
return NULL;
struct MailboxNode *np = NULL;
STAILQ_FOREACH(np, &a->mailboxes, entries)
{
- if (mutt_str_strcmp(np->m->realpath, m->realpath) == 0)
+ if (mutt_str_strcmp(np->m->realpath, path) == 0)
return np->m;
}
mutt_str_strfcpy(buf, path, sizeof(buf));
mx_path_canon(buf, sizeof(buf), Folder, NULL);
- struct MailboxNode *np = NULL;
- STAILQ_FOREACH(np, &AllMailboxes, entries)
+ struct Account *np = NULL;
+ TAILQ_FOREACH(np, &AllAccounts, entries)
{
- if (mutt_str_strcmp(np->m->realpath, buf) == 0)
- return np->m;
+ struct Mailbox *m = mx_mbox_find(np, buf);
+ if (m)
+ return m;
}
return NULL;
int mx_tags_edit (struct Context *ctx, const char *tags, char *buf, size_t buflen);
struct Account *mx_ac_find(struct Mailbox *m);
-struct Mailbox *mx_mbox_find(struct Account *a, struct Mailbox *m);
+struct Mailbox *mx_mbox_find(struct Account *a, const char *path);
struct Mailbox *mx_mbox_find2(const char *path);
int mx_ac_add(struct Account *a, struct Mailbox *m);
int mx_ac_remove(struct Account *a, struct Mailbox *m);
#include "bcache.h"
#include "context.h"
#include "globals.h"
+#include "hook.h"
#include "mailbox.h"
#include "mutt_account.h"
#include "mutt_header.h"
*/
struct Account *pop_ac_find(struct Account *a, const char *path)
{
- return NULL;
+ if (!a || (a->magic != MUTT_POP) || !path)
+ return NULL;
+
+ struct Url url;
+ char tmp[PATH_MAX];
+ mutt_str_strfcpy(tmp, path, sizeof(tmp));
+ url_parse(&url, tmp);
+
+ struct PopAccountData *adata = a->adata;
+ struct ConnAccount *ac = &adata->conn_account;
+
+ if (mutt_str_strcasecmp(url.host, ac->host) != 0)
+ return NULL;
+
+ if (mutt_str_strcasecmp(url.user, ac->user) != 0)
+ return NULL;
+
+ // if (mutt_str_strcmp(path, a->mailbox->realpath) == 0)
+ // return a;
+
+ return a;
}
/**
if (m->magic != MUTT_POP)
return -1;
+ if (!a->adata)
+ {
+ struct PopAccountData *adata = pop_adata_new();
+ a->magic = MUTT_POP;
+ a->adata = adata;
+ a->free_adata = pop_adata_free;
+
+ struct Url url;
+ char tmp[PATH_MAX];
+ mutt_str_strfcpy(tmp, m->path, sizeof(tmp));
+ url_parse(&url, tmp);
+
+ mutt_str_strfcpy(adata->conn_account.user, url.user,
+ sizeof(adata->conn_account.user));
+ mutt_str_strfcpy(adata->conn_account.pass, url.pass,
+ sizeof(adata->conn_account.pass));
+ mutt_str_strfcpy(adata->conn_account.host, url.host,
+ sizeof(adata->conn_account.host));
+ adata->conn_account.port = url.port;
+ adata->conn_account.type = MUTT_ACCT_TYPE_POP;
+
+ if (adata->conn_account.user[0] != '\0')
+ adata->conn_account.flags |= MUTT_ACCT_USER;
+ if (adata->conn_account.pass[0] != '\0')
+ adata->conn_account.flags |= MUTT_ACCT_PASS;
+ }
+
m->account = a;
struct MailboxNode *np = mutt_mem_calloc(1, sizeof(*np));
static int pop_mbox_open(struct Context *ctx)
{
char buf[PATH_MAX];
- struct Connection *conn = NULL;
struct ConnAccount acct;
struct Url url;
mutt_account_tourl(&acct, &url);
url.path = NULL;
url_tostring(&url, buf, sizeof(buf), 0);
- conn = mutt_conn_find(NULL, &acct);
- if (!conn)
- return -1;
mutt_str_strfcpy(ctx->mailbox->path, buf, sizeof(ctx->mailbox->path));
mutt_str_strfcpy(ctx->mailbox->realpath, ctx->mailbox->path,
sizeof(ctx->mailbox->realpath));
+ mutt_account_hook(ctx->mailbox->realpath);
+ struct Connection *conn = mutt_conn_new(&acct);
+ if (!conn)
+ return -1;
+
struct PopAccountData *adata = pop_adata_new();
adata->conn = conn;
if (pop_open_connection(adata) < 0)
return -1;
- conn->data = adata;
adata->bcache = mutt_bcache_open(&acct, NULL);
/* init (hard-coded) ACL rights */
#include <stdbool.h>
#include <time.h>
+#include "conn/conn.h"
struct ConnAccount;
struct Context;
struct PopAccountData
{
struct Connection *conn;
+ struct ConnAccount conn_account;
unsigned int status : 2;
bool capabilities : 1;
unsigned int use_stls : 2;