From: Richard Russon Date: Sat, 20 Oct 2018 18:02:19 +0000 (+0100) Subject: Nntp: add Account X-Git-Tag: 2019-10-25~593^2~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0ae43f29b113de7787895ccbfe7ed393e8ed22d0;p=neomutt Nntp: add Account --- diff --git a/nntp/nntp.c b/nntp/nntp.c index c97776c5b..fa26fa3c5 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -6,6 +6,7 @@ * Copyright (C) 1998 Brandon Long * Copyright (C) 1999 Andrej Gritsenko * Copyright (C) 2000-2017 Vsevolod Volkov + * Copyright (C) 2018 Richard Russon * * @copyright * This program is free software: you can redistribute it and/or modify it under @@ -41,6 +42,7 @@ #include "conn/conn.h" #include "mutt.h" #include "nntp.h" +#include "account.h" #include "bcache.h" #include "context.h" #include "curs_lib.h" @@ -2276,6 +2278,54 @@ int nntp_compare_order(const void *a, const void *b) return SORTCODE(result); } +/** + * nntp_ac_find - Find a Account that matches a Mailbox path + */ +struct Account *nntp_ac_find(struct Account *a, const char *path) +{ +#if 0 + if (!a || (a->type != MUTT_NNTP) || !path) + return NULL; + + struct Url url; + char tmp[PATH_MAX]; + mutt_str_strfcpy(tmp, path, sizeof(tmp)); + url_parse(&url, tmp); + + struct ImapAccountData *adata = a->data; + 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; +#endif + return a; +} + +/** + * nntp_ac_add - Add a Mailbox to a Account + */ +int nntp_ac_add(struct Account *a, struct Mailbox *m) +{ + if (!a || !m) + return -1; + + if (m->magic != MUTT_NNTP) + return -1; + + m->account = a; + + struct MailboxNode *np = mutt_mem_calloc(1, sizeof(*np)); + np->m = m; + STAILQ_INSERT_TAIL(&a->mailboxes, np, entries); + return 0; +} + /** * nntp_mbox_open - Implements MxOps::mbox_open() */ @@ -2312,6 +2362,11 @@ static int nntp_mbox_open(struct Context *ctx) return -1; CurrentNewsSrv = adata; + ctx->mailbox->account->adata = adata; + + if (group[0] == '/') + group++; + /* find news group data structure */ mdata = mutt_hash_find(adata->groups_hash, group); if (!mdata) @@ -2723,6 +2778,8 @@ int nntp_path_parent(char *buf, size_t buflen) struct MxOps mx_nntp_ops = { .magic = MUTT_NNTP, .name = "nntp", + .ac_find = nntp_ac_find, + .ac_add = nntp_ac_add, .mbox_open = nntp_mbox_open, .mbox_open_append = NULL, .mbox_check = nntp_mbox_check,