#include <stdint.h>
#include "lib.h"
#include "hcache/lib.h"
Go to the source code of this file.
|
void | nntp_acache_free (struct NntpMboxData *mdata) |
| Remove all temporarily cache files. More...
|
|
int | nntp_active_save_cache (struct NntpAccountData *adata) |
| Save list of all newsgroups to cache. More...
|
|
int | nntp_add_group (char *line, void *data) |
| Parse newsgroup. More...
|
|
void | nntp_article_status (struct Mailbox *m, struct Email *e, char *group, anum_t anum) |
| Get status of articles from .newsrc. More...
|
|
void | nntp_bcache_update (struct NntpMboxData *mdata) |
| Remove stale cached messages. More...
|
|
int | nntp_check_new_groups (struct Mailbox *m, struct NntpAccountData *adata) |
| Check for new groups/articles in subscribed groups. More...
|
|
void | nntp_delete_group_cache (struct NntpMboxData *mdata) |
| Remove hcache and bcache of newsgroup. More...
|
|
void | nntp_group_unread_stat (struct NntpMboxData *mdata) |
| Count number of unread articles using .newsrc data. More...
|
|
void | nntp_hash_destructor_t (int type, void *obj, intptr_t data) |
|
void | nntp_hashelem_free (int type, void *obj, intptr_t data) |
| Free our hash table data - Implements hash_hdata_free_t. More...
|
|
struct HeaderCache * | nntp_hcache_open (struct NntpMboxData *mdata) |
| Open newsgroup hcache. More...
|
|
void | nntp_hcache_update (struct NntpMboxData *mdata, struct HeaderCache *hc) |
| Remove stale cached headers. More...
|
|
void | nntp_newsrc_gen_entries (struct Mailbox *m) |
| Generate array of .newsrc entries. More...
|
|
int | nntp_open_connection (struct NntpAccountData *adata) |
| Connect to server, authenticate and get capabilities. More...
|
|
Usenet network mailbox type; talk to an NNTP server
- Authors
-
- 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/.
Definition in file private.h.
◆ NNTP_PORT
◆ NNTP_SSL_PORT
#define NNTP_SSL_PORT 563 |
◆ NntpStatus
NNTP server return values.
Enumerator |
---|
NNTP_NONE | No connection to server.
|
NNTP_OK | Connected to server.
|
NNTP_BYE | Disconnected from server.
|
Definition at line 40 of file private.h.
◆ nntp_acache_free()
Remove all temporarily cache files.
- Parameters
-
Definition at line 104 of file newsrc.c.
◆ nntp_active_save_cache()
Save list of all newsgroups to cache.
- Parameters
-
- Return values
-
Definition at line 651 of file newsrc.c.
656 size_t buflen = 10240;
658 snprintf(buf, buflen,
"%lu\n", (
unsigned long) adata->
newgroups_time);
659 size_t off = strlen(buf);
661 for (
unsigned int i = 0; i < adata->
groups_num; i++)
668 if ((off + strlen(
mdata->group) + (
mdata->desc ? strlen(
mdata->desc) : 0) + 50) > buflen)
673 snprintf(buf + off, buflen - off,
"%s %u %u %c%s%s\n",
mdata->group,
676 off += strlen(buf + off);
◆ nntp_add_group()
int nntp_add_group |
( |
char * |
line, |
|
|
void * |
data |
|
) |
| |
Parse newsgroup.
- Parameters
-
line | String to parse |
data | NNTP data |
- Return values
-
Definition at line 576 of file newsrc.c.
580 char group[1024] = { 0 };
581 char desc[8192] = { 0 };
589 if (sscanf(line,
"%1023s " ANUM " " ANUM " %c %8191[^\n]",
group, &last,
590 &first, &mod,
desc) < 4)
597 mdata->deleted =
false;
598 mdata->first_message = first;
599 mdata->last_message = last;
600 mdata->allowed = (mod ==
'y') || (mod ==
'm');
602 if (
mdata->newsrc_ent || (
mdata->last_cached != 0))
604 else if (
mdata->last_message && (
mdata->first_message <=
mdata->last_message))
◆ nntp_article_status()
void nntp_article_status |
( |
struct Mailbox * |
m, |
|
|
struct Email * |
e, |
|
|
char * |
group, |
|
|
anum_t |
anum |
|
) |
| |
Get status of articles from .newsrc.
- Parameters
-
Full status flags are not supported by nntp, but we can fake some of them: Read = a read message number is in the .newsrc New = not read and not cached Old = not read but cached
Definition at line 1211 of file newsrc.c.
1221 for (
unsigned int i = 0; i <
mdata->newsrc_len; i++)
1232 if (anum >
mdata->last_cached)
◆ nntp_bcache_update()
Remove stale cached messages.
- Parameters
-
Definition at line 800 of file newsrc.c.
◆ nntp_check_new_groups()
Check for new groups/articles in subscribed groups.
- Parameters
-
- Return values
-
1 | New groups found |
0 | No new groups |
-1 | Error |
Definition at line 2015 of file nntp.c.
2020 char *msg =
_(
"Checking for new newsgroups...");
2022 int rc, update_active =
false;
2041 update_active =
true;
2056 tmp_mdata.
group = NULL;
2059 snprintf(buf,
sizeof(buf),
"NEWGROUPS %02d%02d%02d %02d%02d%02d GMT\r\n",
2060 tm.tm_year % 100, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
2081 mdata->has_new_mail =
true;
2087 unsigned int count = 0;
2092 for (i = groups_num; i < adata->
groups_num; i++)
2101 update_active =
true;
◆ nntp_delete_group_cache()
Remove hcache and bcache of newsgroup.
- Parameters
-
Definition at line 809 of file newsrc.c.
◆ nntp_group_unread_stat()
Count number of unread articles using .newsrc data.
- Parameters
-
Definition at line 134 of file newsrc.c.
144 for (
unsigned int i = 0; i < mdata->
newsrc_len; i++)
147 if (first < mdata->first_message)
153 mdata->
unread -= last - first + 1;
◆ nntp_hash_destructor_t()
void nntp_hash_destructor_t |
( |
int |
type, |
|
|
void * |
obj, |
|
|
intptr_t |
data |
|
) |
| |
◆ nntp_hashelem_free()
void nntp_hashelem_free |
( |
int |
type, |
|
|
void * |
obj, |
|
|
intptr_t |
data |
|
) |
| |
◆ nntp_hcache_open()
Open newsgroup hcache.
- Parameters
-
- Return values
-
ptr | Header cache |
NULL | Error |
Definition at line 710 of file newsrc.c.
712 struct Url url = { 0 };
◆ nntp_hcache_update()
Remove stale cached headers.
- Parameters
-
mdata | NNTP Mailbox data |
hc | Header cache |
Definition at line 732 of file newsrc.c.
739 anum_t first = 0, last = 0;
747 if (sscanf(hdata,
ANUM " " ANUM, &first, &last) == 2)
753 for (
anum_t current = first; current <= last; current++)
755 if ((current >= mdata->
first_message) && (current <= mdata->last_message))
758 snprintf(buf,
sizeof(buf),
"%u", current);
◆ nntp_newsrc_gen_entries()
void nntp_newsrc_gen_entries |
( |
struct Mailbox * |
m | ) |
|
Generate array of .newsrc entries.
- Parameters
-
Definition at line 298 of file newsrc.c.
304 anum_t last = 0, first = 1;
307 unsigned int entries;
316 entries =
mdata->newsrc_len;
325 mdata->newsrc_len = 0;
365 if (series && (first <= mdata->last_loaded))
◆ nntp_open_connection()
Connect to server, authenticate and get capabilities.
- Parameters
-
- Return values
-
Definition at line 1702 of file nntp.c.
1707 bool posting =
false, auth =
true;
1767 posting ?
_(
"Posting is ok") :
_(
"Posting is NOT ok"));
1779 _(
"Secure connection with TLS?")) ==
MUTT_YES) ?
1802 mutt_error(
_(
"Could not negotiate TLS connection"));
◆ C_NewsCacheDir
Config: (nntp) Directory for cached news articles.
Definition at line 40 of file config.c.
◆ C_Newsrc
Config: (nntp) File containing list of subscribed newsgroups.
Definition at line 43 of file config.c.
◆ C_NntpAuthenticators
char* C_NntpAuthenticators |
Config: (nntp) Allowed authentication methods.
Definition at line 44 of file config.c.
◆ C_NntpContext
Config: (nntp) Maximum number of articles to list (0 for all articles)
Definition at line 45 of file config.c.
◆ C_NntpListgroup
Config: (nntp) Check all articles when opening a newsgroup.
Definition at line 46 of file config.c.
◆ C_NntpLoadDescription
bool C_NntpLoadDescription |
Config: (nntp) Load descriptions for newsgroups when adding to the list.
Definition at line 47 of file config.c.
◆ C_NntpPass
Config: (nntp) Password for the news server.
Definition at line 48 of file config.c.
◆ C_NntpPoll
Config: (nntp) Interval between checks for new posts.
Definition at line 49 of file config.c.
◆ C_NntpUser
Config: (nntp) Username for the news server.
Definition at line 50 of file config.c.
◆ C_SaveUnsubscribed
Config: (nntp) Save a list of unsubscribed newsgroups to the 'newsrc'.
Definition at line 52 of file config.c.
◆ C_ShowNewNews
Config: (nntp) Check for new newsgroups when entering the browser.
Definition at line 53 of file config.c.
bool C_SslForceTls
Config: (ssl) Require TLS encryption for all connections.
struct HeaderCache * mutt_hcache_open(const char *path, const char *folder, hcache_namer_t namer)
Multiplexor for StoreOps::open.
An open network connection (socket)
struct BodyCache * mutt_bcache_open(struct ConnAccount *account, const char *mailbox)
Open an Email-Body Cache.
static int nntp_connect_error(struct NntpAccountData *adata)
Signal a failed connection.
char host[128]
Server to login to.
static struct NntpMboxData * mdata_find(struct NntpAccountData *adata, const char *group)
Find NntpMboxData for given newsgroup or add it.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
int nntp_add_group(char *line, void *data)
Parse newsgroup.
struct Email ** emails
Array of Emails.
int mutt_hcache_store_raw(struct HeaderCache *hc, const char *key, size_t keylen, void *data, size_t dlen)
store a key / data pair
String manipulation buffer.
struct ConnAccount account
Account details: username, password, etc.
void mutt_socket_empty(struct Connection *conn)
Clear out any queued data.
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
static int nntp_capabilities(struct NntpAccountData *adata)
Get capabilities.
unsigned char C_SslStarttls
Config: (ssl) Use STARTTLS on servers advertising the capability.
static void cache_expand(char *dst, size_t dstlen, struct ConnAccount *cac, const char *src)
Make fully qualified cache file name.
struct NntpEmailData * nntp_edata_get(struct Email *e)
Get the private data for this Email.
void mutt_account_tourl(struct ConnAccount *cac, struct Url *url)
Fill URL with info from account.
struct BodyCache * bcache
SortType
Methods for sorting.
static int update_file(char *filename, char *buf)
Update file with new contents.
int mutt_socket_close(struct Connection *conn)
Close a socket.
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
@ LL_DEBUG1
Log at debug level 1.
bool C_ShowNewNews
Config: (nntp) Check for new newsgroups when entering the browser.
static int get_description(struct NntpMboxData *mdata, const char *wildmat, const char *msg)
Fetch newsgroups descriptions.
#define mutt_socket_readln(buf, buflen, conn)
size_t dsize
Length of data.
void mutt_sleep(short s)
Sleep for a while.
static int nntp_group_poll(struct NntpMboxData *mdata, bool update_stat)
Check newsgroup for new articles.
struct NntpAccountData * adata
void * mutt_hash_find(const struct HashTable *table, const char *strkey)
Find the HashElem data in a Hash Table element using a key.
bool old
Email is seen, but unread.
void mutt_progress_init(struct Progress *progress, const char *msg, enum ProgressType type, size_t size)
Set up a progress bar.
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
@ NNTP_NONE
No connection to server.
void * mdata
Driver specific data.
int url_tostring(struct Url *url, char *dest, size_t len, uint8_t flags)
Output the URL string for a given Url object.
A parsed URL proto://user:password@host:port/path?a=1&b=2
int msg_count
Total number of messages.
static int nntp_bcache_delete(const char *id, struct BodyCache *bcache, void *data)
Remove bcache file - Implements bcache_list_t.
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
static int nntp_attempt_features(struct NntpAccountData *adata)
Detect supported commands.
void mutt_hcache_free_raw(struct HeaderCache *hc, void **data)
Multiplexor for StoreOps::free.
bool C_SaveUnsubscribed
Config: (nntp) Save a list of unsubscribed newsgroups to the 'newsrc'.
struct NewsrcEntry * newsrc_ent
#define mutt_socket_send(conn, buf)
@ MUTT_PROGRESS_READ
Progress tracks elements, according to $read_inc
static int nntp_fetch_lines(struct NntpMboxData *mdata, char *query, size_t qlen, const char *msg, int(*func)(char *, void *), void *data)
Read lines, calling a callback function for each.
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
#define mutt_debug(LEVEL,...)
void mutt_bcache_close(struct BodyCache **bcache)
Close an Email-Body Cache.
int mutt_bcache_list(struct BodyCache *bcache, bcache_list_t want_id, void *data)
Find matching entries in the Body Cache.
An entry in a .newsrc (subscribed newsgroups)
#define MUTT_ACCT_USER
User field has been set.
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
void nntp_mdata_free(void **ptr)
Free the private Mailbox data - Implements Mailbox::mdata_free()
MuttAccountFlags flags
Which fields are initialised, e.g. MUTT_ACCT_USER.
@ SORT_ORDER
Sort by the order the messages appear in the mailbox.
void nntp_group_unread_stat(struct NntpMboxData *mdata)
Count number of unread articles using .newsrc data.
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
@ NNTP_BYE
Disconnected from server.
struct NntpAcache acache[NNTP_ACACHE_LEN]
bool deleted
Email is deleted.
NNTP-specific Account data -.
int mutt_socket_open(struct Connection *conn)
Simple wrapper.
WHERE short C_Sort
Config: Sort method for the index.
bool C_NntpLoadDescription
Config: (nntp) Load descriptions for newsgroups when adding to the list.
void mutt_str_remove_trailing_ws(char *s)
Trim trailing whitespace from a string.
char * C_NewsCacheDir
Config: (nntp) Directory for cached news articles.
int mutt_hcache_delete_record(struct HeaderCache *hc, const char *key, size_t keylen)
Multiplexor for StoreOps::delete_record.
struct tm mutt_date_gmtime(time_t t)
Converts calendar time to a broken-down time structure expressed in UTC timezone.
void mailbox_changed(struct Mailbox *m, enum NotifyMailbox action)
Notify observers of a change to a Mailbox.
void * adata
Private data (for Mailbox backends)
bool C_MarkOld
Config: Mark new emails as old when leaving the mailbox.
void mutt_progress_update(struct Progress *progress, size_t pos, int percent)
Update the state of the progress bar.
void * mutt_hcache_fetch_raw(struct HeaderCache *hc, const char *key, size_t keylen, size_t *dlen)
Fetch a message's header from the cache.
char * data
Pointer to data.
The envelope/body of an email.
int mutt_ssl_starttls(struct Connection *conn)
Negotiate TLS over an already opened connection.
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
#define mutt_message(...)
@ NNTP_OK
Connected to server.
static int nntp_date(struct NntpAccountData *adata, time_t *now)
Get date and time from server.
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
@ NT_MAILBOX_RESORT
Email list needs resorting.
int nntp_active_save_cache(struct NntpAccountData *adata)
Save list of all newsgroups to cache.
static int nntp_auth(struct NntpAccountData *adata)
Get login, password and authenticate.
static void nntp_hcache_namer(const char *path, struct Buffer *dest)
Compose hcache file names - Implements hcache_namer_t.
@ LL_DEBUG2
Log at debug level 2.
NNTP-specific Mailbox data -.