diff options
author | Sam Creasey <sammy@oh.verio.com> | 2001-07-03 10:54:06 +0800 |
---|---|---|
committer | Sam Creasy <sammy@src.gnome.org> | 2001-07-03 10:54:06 +0800 |
commit | 7cd517dc60d56c2203d82faffaf40dc5cc7aed5a (patch) | |
tree | b44e82ecd9cba6608dfffbe36c9d974858218a05 /camel/providers/nntp/camel-nntp-utils.c | |
parent | 29700d38aeb9a90caaed499ac010f7632e9587dc (diff) | |
download | gsoc2013-evolution-7cd517dc60d56c2203d82faffaf40dc5cc7aed5a.tar.gz gsoc2013-evolution-7cd517dc60d56c2203d82faffaf40dc5cc7aed5a.tar.zst gsoc2013-evolution-7cd517dc60d56c2203d82faffaf40dc5cc7aed5a.zip |
Implemented nntp_folder_search_by_expression and nntp_folder_search_free.
2001-07-02 Sam Creasey <sammy@oh.verio.com>
* providers/nntp/camel-nntp-folder.c: Implemented
nntp_folder_search_by_expression and
nntp_folder_search_free. Basic search functionality e.g. unread
marking now works for NNTP folders.
* camel_filter_search.c (get_size): Added get-size sexp directive
to get the size of a message for filters.
* providers/nntp/camel-nntp-folder.c (camel_nntp_folder_new):
Always check with the NNTP server after summary load -- this
function now always expires old summary entries and syncs with
the news server.
* providers/nntp/camel-nntp-utils.c (camel_nntp_get_headers):
Only fetch headers for articles not already logged in
the summary file.
* providers/nntp/camel-nntp-grouplist.c
(camel_nntp_get_grouplist_from_*): change from g_list_append()
to g_list_prepend() + g_list_reverse. Traversing 40,000
element linked lists sucks.
* providers/nntp/camel-nntp-store.c (camel_nntp_command):
Should the NNTP connection die with
CAMEL_EXCEPTION_SERVICE_NOT_CONNECTED, make a single retry
attempt. Timing out the NNTP link is less painful this way.
svn path=/trunk/; revision=10716
Diffstat (limited to 'camel/providers/nntp/camel-nntp-utils.c')
-rw-r--r-- | camel/providers/nntp/camel-nntp-utils.c | 55 |
1 files changed, 50 insertions, 5 deletions
diff --git a/camel/providers/nntp/camel-nntp-utils.c b/camel/providers/nntp/camel-nntp-utils.c index 3bff5bfb58..ed0482a109 100644 --- a/camel/providers/nntp/camel-nntp-utils.c +++ b/camel/providers/nntp/camel-nntp-utils.c @@ -64,7 +64,7 @@ get_XOVER_headers(CamelNNTPStore *nntp_store, CamelFolder *folder, g_print ("done\n"); } else { - CamelMessageInfo *new_info = camel_folder_summary_info_new(nntp_folder->summary); + CamelMessageInfo *new_info = camel_folder_summary_info_new(folder->summary); char **split_line = g_strsplit (line, "\t", 7); char *subject, *from, *date, *message_id, *bytes; char *uid; @@ -74,7 +74,7 @@ get_XOVER_headers(CamelNNTPStore *nntp_store, CamelFolder *folder, date = split_line [nntp_store->overview_field [CAMEL_NNTP_OVER_DATE].index]; message_id = split_line [nntp_store->overview_field [CAMEL_NNTP_OVER_MESSAGE_ID].index]; bytes = split_line [nntp_store->overview_field [CAMEL_NNTP_OVER_BYTES].index]; - + /* if the overview format flagged this field as "full", skip over the preceding field name and colon */ @@ -109,7 +109,7 @@ get_XOVER_headers(CamelNNTPStore *nntp_store, CamelFolder *folder, atoi (split_line[0]))) new_info->flags |= CAMEL_MESSAGE_SEEN; - camel_folder_summary_add (nntp_folder->summary, new_info); + camel_folder_summary_add (folder->summary, new_info); g_strfreev (split_line); } g_free (line); @@ -217,6 +217,33 @@ get_HEAD_headers(CamelNNTPStore *nntp_store, CamelFolder *folder, } #endif +static inline int +uid_num (CamelFolderSummary *summary, int index) +{ + char *tmp; + char *brk; + CamelMessageInfo *minfo; + int ret; + + minfo = camel_folder_summary_index(summary, index); + if(minfo == NULL) + return 0; + + tmp = g_strdup(camel_message_info_uid(minfo)); + camel_message_info_free(minfo); + + if((brk = strchr(tmp, ',')) == NULL) + ret = 0; + else { + *brk = 0; + ret = atoi(tmp); + } + + g_free(tmp); + + return ret; +} + void camel_nntp_get_headers (CamelStore *store, CamelNNTPFolder *nntp_folder, @@ -225,15 +252,32 @@ camel_nntp_get_headers (CamelStore *store, CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (store); CamelFolder *folder = CAMEL_FOLDER (nntp_folder); char *ret; - int first_message, nb_message, last_message; + int first_message, nb_message, last_message, last_summary; int status; + int i; status = camel_nntp_command (nntp_store, ex, &ret, "GROUP %s", folder->name); - sscanf (ret, "%d %d %d", &nb_message, &first_message, &last_message); g_free (ret); + i = camel_folder_summary_count(folder->summary); + if(i != 0) { + last_summary = uid_num(folder->summary, i-1); + + if(last_summary < first_message) + camel_folder_summary_clear(folder->summary); + else { + while(uid_num(folder->summary, 0) < first_message) + camel_folder_summary_remove_index(folder->summary, 0); + + if(last_summary >= last_message) + return; + + first_message = last_summary; + } + } + if (status == NNTP_NO_SUCH_GROUP) { /* XXX throw invalid group exception */ camel_exception_setv (ex, @@ -253,4 +297,5 @@ camel_nntp_get_headers (CamelStore *store, get_HEAD_headers (nntp_store, folder, first_message, last_message, ex); #endif } + } |