NeoMutt  2018-07-16 +2481-68dcde
Teaching an old dog new tricks
Go to the documentation of this file.
38 #ifndef MUTT_NNTP_NNTP_H
39 #define MUTT_NNTP_NNTP_H
41 #include <stdbool.h>
42 #include <stdint.h>
43 #include <stdio.h>
44 #include <sys/types.h>
45 #include <time.h>
46 #include "core/lib.h"
47 #include "format_flags.h"
48 #include "mx.h"
50 struct ConnAccount;
51 struct stat;
53 /* These Config Variables are only used in nntp/nntp.c */
54 extern char *C_NntpAuthenticators;
55 extern short C_NntpContext;
56 extern bool C_NntpListgroup;
57 extern bool C_NntpLoadDescription;
58 extern short C_NntpPoll;
59 extern bool C_ShowNewNews;
61 /* These Config Variables are only used in nntp/newsrc.c */
62 extern char *C_NewsCacheDir;
63 extern char *C_Newsrc;
65 extern struct NntpAccountData *CurrentNewsSrv;
66 extern struct MxOps MxNntpOps;
68 /* article number type and format */
69 #define anum_t uint32_t
70 #define ANUM "%u"
76 {
77  bool hasCAPABILITIES : 1;
78  bool hasSTARTTLS : 1;
79  bool hasDATE : 1;
81  bool hasXGTITLE : 1;
82  bool hasLISTGROUP : 1;
84  bool hasOVER : 1;
85  bool hasXOVER : 1;
86  unsigned int use_tls : 3;
87  unsigned int status : 3;
88  bool cacheable : 1;
89  bool newsrc_modified : 1;
90  FILE *fp_newsrc;
91  char *newsrc_file;
93  char *overview_fmt;
94  off_t size;
95  time_t mtime;
97  time_t check_time;
98  unsigned int groups_num;
99  unsigned int groups_max;
100  void **groups_list;
101  struct Hash *groups_hash;
102  struct Connection *conn;
103 };
109 {
111  bool parsed : 1;
112 };
118 {
119  unsigned int index;
120  char *path;
121 };
127 {
130 };
132 /* number of entries in article cache */
133 #define NNTP_ACACHE_LEN 10
139 {
140  char *group;
141  char *desc;
147  bool subscribed : 1;
148  bool has_new_mail : 1;
149  bool allowed : 1;
150  bool deleted : 1;
151  unsigned int newsrc_len;
154  struct NntpAcache acache[NNTP_ACACHE_LEN];
155  struct BodyCache *bcache;
156 };
158 struct NntpAccountData *nntp_select_server(struct Mailbox *m, char *server, bool leave_lock);
161 struct NntpMboxData *mutt_newsgroup_catchup(struct Mailbox *m, struct NntpAccountData *adata, char *group);
162 struct NntpMboxData *mutt_newsgroup_uncatchup(struct Mailbox *m, struct NntpAccountData *adata, char *group);
163 int nntp_active_fetch(struct NntpAccountData *adata, bool mark_new);
165 int nntp_post(struct Mailbox *m, const char *msg);
166 int nntp_check_msgid(struct Mailbox *m, const char *msgid);
167 int nntp_check_children(struct Mailbox *m, const char *msgid);
170 void nntp_mailbox(struct Mailbox *m, char *buf, size_t buflen);
171 void nntp_expand_path(char *buf, size_t buflen, struct ConnAccount *acct);
173 const char *nntp_format_str(char *buf, size_t buflen, size_t col, int cols, char op, const char *src, const char *prec, const char *if_str, const char *else_str, unsigned long data, MuttFormatFlags flags);
174 int nntp_compare_order(const void *a, const void *b);
175 enum MailboxType nntp_path_probe(const char *path, const struct stat *st);
176 const char *group_index_format_str(char *buf, size_t buflen, size_t col, int cols, char op, const char *src, const char *prec, const char *if_str, const char *else_str, unsigned long data, MuttFormatFlags flags);
177 int nntp_complete(char *buf, size_t buflen);
179 #endif /* MUTT_NNTP_NNTP_H */
bool has_new_mail
Definition: nntp.h:148
char * path
Definition: nntp.h:120
int nntp_newsrc_parse(struct NntpAccountData *adata)
Parse .newsrc file.
Definition: newsrc.c:161
uint8_t MuttFormatFlags
Flags for mutt_expando_format(), e.g. MUTT_FORMAT_FORCESUBJ.
Definition: format_flags.h:29
char * newsrc_file
Definition: nntp.h:91
void nntp_mailbox(struct Mailbox *m, char *buf, size_t buflen)
Get first newsgroup with new messages.
Definition: newsrc.c:1335
int nntp_compare_order(const void *a, const void *b)
Sort to mailbox order - Implements sort_t.
Definition: nntp.c:2363
A Hash Table.
Definition: hash.h:61
int nntp_post(struct Mailbox *m, const char *msg)
Post article.
Definition: nntp.c:1971
const char * group_index_format_str(char *buf, size_t buflen, size_t col, int cols, char op, const char *src, const char *prec, const char *if_str, const char *else_str, unsigned long data, MuttFormatFlags flags)
Format a string for the newsgroup menu - Implements format_t.
Definition: browse.c:51
unsigned int use_tls
Definition: nntp.h:86
bool newsrc_modified
Definition: nntp.h:89
struct NntpAccountData * adata
Definition: nntp.h:153
int nntp_complete(char *buf, size_t buflen)
Auto-complete NNTP newsgroups.
Definition: complete.c:45
Definition: nntp.h:133
time_t mtime
Definition: nntp.h:95
bool parsed
Definition: nntp.h:111
An open network connection (socket)
Definition: connection.h:34
anum_t article_num
Definition: nntp.h:110
bool C_ShowNewNews
Config: (nntp) Check for new newsgroups when entering the browser.
Definition: nntp.c:73
struct MxOps MxNntpOps
NNTP Mailbox - Implements MxOps.
Definition: nntp.c:2872
bool C_NntpListgroup
Config: (nntp) Check all articles when opening a newsgroup.
Definition: nntp.c:70
bool hasSTARTTLS
Definition: nntp.h:78
char * C_Newsrc
Config: (nntp) File containing list of subscribed newsgroups.
Definition: newsrc.c:63
const char * nntp_format_str(char *buf, size_t buflen, size_t col, int cols, char op, const char *src, const char *prec, const char *if_str, const char *else_str, unsigned long data, MuttFormatFlags flags)
Expand the newsrc filename - Implements format_t.
Definition: newsrc.c:909
struct NntpMboxData * mutt_newsgroup_uncatchup(struct Mailbox *m, struct NntpAccountData *adata, char *group)
Uncatchup newsgroup.
Definition: newsrc.c:1297
NNTP-specific Email data -.
Definition: nntp.h:108
Flags to control mutt_expando_format()
NNTP-specific Account data -.
Definition: nntp.h:75
anum_t last
Definition: nntp.h:129
bool subscribed
Definition: nntp.h:147
anum_t last_cached
Definition: nntp.h:145
struct NntpMboxData * mutt_newsgroup_subscribe(struct NntpAccountData *adata, char *group)
Subscribe newsgroup.
Definition: newsrc.c:1213
bool cacheable
Definition: nntp.h:88
struct NntpMboxData * mutt_newsgroup_unsubscribe(struct NntpAccountData *adata, char *group)
Unsubscribe newsgroup.
Definition: newsrc.c:1237
API for mailboxes.
time_t newgroups_time
Definition: nntp.h:96
An entry in a .newsrc (subscribed newsgroups)
Definition: nntp.h:126
anum_t last_loaded
Definition: nntp.h:144
char * C_NewsCacheDir
Config: (nntp) Directory for cached news articles.
Definition: newsrc.c:62
Definition: nntp.h:80
char * overview_fmt
Definition: nntp.h:93
Convenience wrapper for the core headers.
char * group
Definition: nntp.h:140
int flags
Definition: mailbox.h:145
off_t size
Definition: nntp.h:94
void nntp_clear_cache(struct NntpAccountData *adata)
Clear the NNTP cache.
Definition: newsrc.c:832
char * C_NntpAuthenticators
Config: (nntp) Allowed authentication methods.
Definition: nntp.c:68
#define anum_t
Definition: nntp.h:69
struct BodyCache * bcache
Definition: nntp.h:155
unsigned int status
Definition: nntp.h:87
A mailbox.
Definition: mailbox.h:92
bool hasXGTITLE
Definition: nntp.h:81
bool allowed
Definition: nntp.h:149
unsigned int groups_max
Definition: nntp.h:99
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
int nntp_newsrc_update(struct NntpAccountData *adata)
Update .newsrc file.
Definition: newsrc.c:436
Definition: nntp.h:82
unsigned int groups_num
Definition: nntp.h:98
int nntp_check_msgid(struct Mailbox *m, const char *msgid)
Fetch article by Message-ID.
Definition: nntp.c:2223
short C_NntpContext
Config: (nntp) Maximum number of articles to list (0 for all articles)
Definition: nntp.c:69
short C_NntpPoll
Config: (nntp) Interval between checks for new posts.
Definition: nntp.c:72
Login details for a remote server.
Definition: connaccount.h:31
struct NewsrcEntry * newsrc_ent
Definition: nntp.h:152
bool hasOVER
Definition: nntp.h:84
NNTP-specific Mailbox data -.
Definition: nntp.h:138
unsigned int newsrc_len
Definition: nntp.h:151
struct NntpMboxData * mutt_newsgroup_catchup(struct Mailbox *m, struct NntpAccountData *adata, char *group)
Catchup newsgroup.
Definition: newsrc.c:1263
unsigned int index
Definition: nntp.h:119
Local cache of email bodies.
Definition: bcache.c:50
struct Connection * conn
Definition: nntp.h:102
struct Hash * groups_hash
Definition: nntp.h:101
char * authenticators
Definition: nntp.h:92
time_t check_time
Definition: nntp.h:97
Supported mailbox formats.
Definition: mailbox.h:42
bool deleted
Definition: nntp.h:150
bool hasLISTGROUPrange
Definition: nntp.h:83
anum_t first_message
Definition: nntp.h:142
NNTP article cache.
Definition: nntp.h:117
anum_t unread
Definition: nntp.h:146
void ** groups_list
Definition: nntp.h:100
FILE * fp_newsrc
Definition: nntp.h:90
int nntp_check_children(struct Mailbox *m, const char *msgid)
Fetch children of article with the Message-ID.
Definition: nntp.c:2293
void nntp_expand_path(char *buf, size_t buflen, struct ConnAccount *acct)
Make fully qualified url from newsgroup name.
Definition: newsrc.c:549
int nntp_active_fetch(struct NntpAccountData *adata, bool mark_new)
Fetch list of all newsgroups from server.
Definition: nntp.c:2053
struct NntpAccountData * CurrentNewsSrv
Current NNTP news server.
Definition: nntp.c:75
bool hasXOVER
Definition: nntp.h:85
bool hasDATE
Definition: nntp.h:79
Definition: nntp.h:77
void nntp_newsrc_close(struct NntpAccountData *adata)
Unlock and close .newsrc file.
Definition: newsrc.c:120
enum MailboxType nntp_path_probe(const char *path, const struct stat *st)
Is this an NNTP Mailbox? - Implements MxOps::path_probe()
Definition: nntp.c:2825
struct NntpAccountData * nntp_select_server(struct Mailbox *m, char *server, bool leave_lock)
Open a connection to an NNTP server.
Definition: newsrc.c:982
anum_t first
Definition: nntp.h:128
The Mailbox API.
Definition: mx.h:103
char * desc
Definition: nntp.h:141
bool C_NntpLoadDescription
Config: (nntp) Load descriptions for newsgroups when adding to the list.
Definition: nntp.c:71
anum_t last_message
Definition: nntp.h:143