forked from neomutt/neomutt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nntp: refactor Account/Mailbox/Email private data
- Loading branch information
Showing
21 changed files
with
392 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/** | ||
* @file | ||
* Nntp-specific Account data | ||
* | ||
* @authors | ||
* Copyright (C) 2021 Richard Russon <[email protected]> | ||
* | ||
* @copyright | ||
* This program is free software: you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License as published by the Free Software | ||
* Foundation, either version 2 of the License, or (at your option) any later | ||
* version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/** | ||
* @page nntp_adata Nntp-specific Account data | ||
* | ||
* Nntp-specific Account data | ||
*/ | ||
|
||
#include "config.h" | ||
#include "private.h" | ||
#include "mutt/lib.h" | ||
#include "adata.h" | ||
|
||
/** | ||
* nntp_adata_free - Free the private Account data - Implements Account::adata_free() | ||
* | ||
* The NntpAccountData struct stores global NNTP data, such as the connection to | ||
* the database. This function will close the database, free the resources and | ||
* the struct itself. | ||
*/ | ||
void nntp_adata_free(void **ptr) | ||
{ | ||
if (!ptr || !*ptr) | ||
return; | ||
|
||
struct NntpAccountData *adata = *ptr; | ||
|
||
mutt_file_fclose(&adata->fp_newsrc); | ||
FREE(&adata->newsrc_file); | ||
FREE(&adata->authenticators); | ||
FREE(&adata->overview_fmt); | ||
FREE(&adata->conn); | ||
FREE(&adata->groups_list); | ||
mutt_hash_free(&adata->groups_hash); | ||
FREE(ptr); | ||
} | ||
|
||
/** | ||
* nntp_adata_new - Allocate and initialise a new NntpAccountData structure | ||
* @param conn Network connection | ||
* @retval ptr New NntpAccountData | ||
*/ | ||
struct NntpAccountData *nntp_adata_new(struct Connection *conn) | ||
{ | ||
struct NntpAccountData *adata = mutt_mem_calloc(1, sizeof(struct NntpAccountData)); | ||
adata->conn = conn; | ||
adata->groups_hash = mutt_hash_new(1009, MUTT_HASH_NO_FLAGS); | ||
mutt_hash_set_destructor(adata->groups_hash, nntp_hashelem_free, 0); | ||
adata->groups_max = 16; | ||
adata->groups_list = | ||
mutt_mem_malloc(adata->groups_max * sizeof(struct NntpMboxData *)); | ||
return adata; | ||
} | ||
|
||
#if 0 | ||
/** | ||
* nntp_adata_get - Get the Account data for this mailbox | ||
* @retval ptr Private Account data | ||
*/ | ||
struct NntpAccountData *nntp_adata_get(struct Mailbox *m) | ||
{ | ||
if (!m || (m->type != MUTT_NNTP)) | ||
return NULL; | ||
struct Account *a = m->account; | ||
if (!a) | ||
return NULL; | ||
return a->adata; | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/** | ||
* @file | ||
* Nntp-specific Account data | ||
* | ||
* @authors | ||
* Copyright (C) 2021 Richard Russon <[email protected]> | ||
* | ||
* @copyright | ||
* This program is free software: you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License as published by the Free Software | ||
* Foundation, either version 2 of the License, or (at your option) any later | ||
* version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef MUTT_NNTP_ADATA_H | ||
#define MUTT_NNTP_ADATA_H | ||
|
||
#include <stdbool.h> | ||
|
||
struct Mailbox; | ||
|
||
/** | ||
* struct NntpAccountData - NNTP-specific Account data - @extends Account | ||
*/ | ||
struct NntpAccountData | ||
{ | ||
bool hasCAPABILITIES : 1; | ||
bool hasSTARTTLS : 1; | ||
bool hasDATE : 1; | ||
bool hasLIST_NEWSGROUPS : 1; | ||
bool hasXGTITLE : 1; | ||
bool hasLISTGROUP : 1; | ||
bool hasLISTGROUPrange : 1; | ||
bool hasOVER : 1; | ||
bool hasXOVER : 1; | ||
unsigned int use_tls : 3; | ||
unsigned int status : 3; | ||
bool cacheable : 1; | ||
bool newsrc_modified : 1; | ||
FILE *fp_newsrc; | ||
char *newsrc_file; | ||
char *authenticators; | ||
char *overview_fmt; | ||
off_t size; | ||
time_t mtime; | ||
time_t newgroups_time; | ||
time_t check_time; | ||
unsigned int groups_num; | ||
unsigned int groups_max; | ||
void **groups_list; | ||
struct HashTable *groups_hash; | ||
struct Connection *conn; | ||
}; | ||
|
||
void nntp_adata_free(void **ptr); | ||
struct NntpAccountData *nntp_adata_get (struct Mailbox *m); | ||
struct NntpAccountData *nntp_adata_new (struct Connection *conn); | ||
|
||
#endif /* MUTT_NNTP_ADATA_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* @file | ||
* Nntp-specific Email data | ||
* | ||
* @authors | ||
* Copyright (C) 2021 Richard Russon <[email protected]> | ||
* | ||
* @copyright | ||
* This program is free software: you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License as published by the Free Software | ||
* Foundation, either version 2 of the License, or (at your option) any later | ||
* version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/** | ||
* @page nntp_edata Nntp-specific Email data | ||
* | ||
* Nntp-specific Email data | ||
*/ | ||
|
||
#include "config.h" | ||
#include "mutt/lib.h" | ||
#include "email/lib.h" | ||
#include "edata.h" | ||
|
||
/** | ||
* nntp_edata_free - Free the private Email data - Implements Email::edata_free() | ||
*/ | ||
void nntp_edata_free(void **ptr) | ||
{ | ||
// struct NntpEmailData *edata = *ptr; | ||
FREE(ptr); | ||
} | ||
|
||
/** | ||
* nntp_edata_new - Create a new NntpEmailData for an Email | ||
* @retval ptr New NntpEmailData struct | ||
*/ | ||
struct NntpEmailData *nntp_edata_new(void) | ||
{ | ||
return mutt_mem_calloc(1, sizeof(struct NntpEmailData)); | ||
} | ||
|
||
/** | ||
* nntp_edata_get - Get the private data for this Email | ||
* @param e Email | ||
* @retval ptr Private Email data | ||
*/ | ||
struct NntpEmailData *nntp_edata_get(struct Email *e) | ||
{ | ||
if (!e) | ||
return NULL; | ||
return e->edata; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* @file | ||
* Nntp-specific Email data | ||
* | ||
* @authors | ||
* Copyright (C) 2021 Richard Russon <[email protected]> | ||
* | ||
* @copyright | ||
* This program is free software: you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License as published by the Free Software | ||
* Foundation, either version 2 of the License, or (at your option) any later | ||
* version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef MUTT_NNTP_EDATA_H | ||
#define MUTT_NNTP_EDATA_H | ||
|
||
#include "lib.h" | ||
|
||
/** | ||
* struct NntpEmailData - NNTP-specific Email data - @extends Email | ||
*/ | ||
struct NntpEmailData | ||
{ | ||
anum_t article_num; | ||
bool parsed : 1; | ||
}; | ||
|
||
void nntp_edata_free(void **ptr); | ||
struct NntpEmailData *nntp_edata_new (void); | ||
struct NntpEmailData *nntp_edata_get (struct Email *e); | ||
|
||
#endif /* MUTT_NNTP_EDATA_H */ |
Oops, something went wrong.