aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/nntp/camel-nntp-utils.c
diff options
context:
space:
mode:
authorChris Toshok <toshok@helixcode.com>2000-09-01 08:57:20 +0800
committerChris Toshok <toshok@src.gnome.org>2000-09-01 08:57:20 +0800
commit3cf4f0d243e0c84b519fe027a3299a925e7075fb (patch)
tree666af08cf25c07ea8c2da1235c4ab512f30193ce /camel/providers/nntp/camel-nntp-utils.c
parent65d4250703d68534210c57f4ed413f95b24390d3 (diff)
downloadgsoc2013-evolution-3cf4f0d243e0c84b519fe027a3299a925e7075fb.tar.gz
gsoc2013-evolution-3cf4f0d243e0c84b519fe027a3299a925e7075fb.tar.zst
gsoc2013-evolution-3cf4f0d243e0c84b519fe027a3299a925e7075fb.zip
make this a bit more robust. try to create an empty .newsrc file for the
2000-08-31 Chris Toshok <toshok@helixcode.com> * providers/nntp/camel-nntp-newsrc.c (camel_nntp_newsrc_read_for_server): make this a bit more robust. try to create an empty .newsrc file for the server if we can't open it for reading. also, don't allocate everything until we've opened the file. * providers/nntp/camel-nntp-utils.c (get_OVER_headers): make use of our overview field indices. (camel_nntp_get_headers): only call get_OVER_headers if the extension is present. warn if it's not - since get_HEAD_headers needs work before it works. * providers/nntp/camel-nntp-store.c (camel_nntp_store_get_extensions): new function - query the server for it's extensions. (camel_nntp_store_get_overview_fmt): new function - query the server for the overview format and build our table of the indices we care about. support the "full" suffix on fields. (nntp_store_connect): call camel_nntp_store_get_extensions and camel_nntp_store_get_overview_fmt. * providers/nntp/camel-nntp-store.h: add codes for extensions found on news.mozilla.org. only one that we care about is OVER. also, add CamelNNTPOverField and an enum of the overview fields that we care about. svn path=/trunk/; revision=5152
Diffstat (limited to 'camel/providers/nntp/camel-nntp-utils.c')
-rw-r--r--camel/providers/nntp/camel-nntp-utils.c56
1 files changed, 38 insertions, 18 deletions
diff --git a/camel/providers/nntp/camel-nntp-utils.c b/camel/providers/nntp/camel-nntp-utils.c
index e0a331f2a7..01b7876134 100644
--- a/camel/providers/nntp/camel-nntp-utils.c
+++ b/camel/providers/nntp/camel-nntp-utils.c
@@ -33,7 +33,7 @@
#include <string.h>
static void
-get_XOVER_headers(CamelNNTPStore *nntp_store, CamelFolder *folder,
+get_OVER_headers(CamelNNTPStore *nntp_store, CamelFolder *folder,
int first_message, int last_message, CamelException *ex)
{
int status;
@@ -43,7 +43,7 @@ get_XOVER_headers(CamelNNTPStore *nntp_store, CamelFolder *folder,
"XOVER %d-%d",
first_message,
last_message);
-
+
if (status == CAMEL_NNTP_OK) {
CamelStream *nntp_istream = nntp_store->istream;
gboolean done = FALSE;
@@ -55,23 +55,44 @@ get_XOVER_headers(CamelNNTPStore *nntp_store, CamelFolder *folder,
if (*line == '.') {
done = TRUE;
+ g_print ("done\n");
}
else {
CamelMessageInfo *new_info = g_new0(CamelMessageInfo, 1);
char **split_line = g_strsplit (line, "\t", 7);
-
- new_info->subject = g_strdup(split_line[1]);
- new_info->from = g_strdup(split_line[2]);
+ char *subject, *from, *date, *message_id, *bytes;
+
+ subject = split_line [nntp_store->overview_field [CAMEL_NNTP_OVER_SUBJECT].index];
+ from = split_line [nntp_store->overview_field [CAMEL_NNTP_OVER_FROM].index];
+ 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 */
+ if (nntp_store->overview_field [ CAMEL_NNTP_OVER_SUBJECT ].full)
+ subject += strlen ("Subject:");
+ if (nntp_store->overview_field [ CAMEL_NNTP_OVER_FROM ].full)
+ from += strlen ("From:");
+ if (nntp_store->overview_field [ CAMEL_NNTP_OVER_DATE ].full)
+ date += strlen ("Date:");
+ if (nntp_store->overview_field [ CAMEL_NNTP_OVER_MESSAGE_ID ].full)
+ message_id += strlen ("Message-ID:");
+ if (nntp_store->overview_field [ CAMEL_NNTP_OVER_BYTES ].full)
+ bytes += strlen ("Bytes:");
+
+ new_info->subject = g_strdup(subject);
+ new_info->from = g_strdup(from);
new_info->to = g_strdup(nntp_folder->group_name);
- new_info->date_sent = header_decode_date(split_line[3], NULL);
+ new_info->date_sent = header_decode_date(date, NULL);
#if 0
/* XXX do we need to fill in both dates? */
- new_info->headers.date_received = g_strdup(split_line[3]);
+ new_info->headers.date_received = g_strdup(date);
#endif
- new_info->size = atoi(split_line[5]);
- new_info->uid = g_strdup_printf ("%s,%s", split_line[0], split_line[4]);
- new_info->message_id = g_strdup(split_line[4]);
- g_strfreev (split_line);
+ new_info->size = atoi(bytes);
+ new_info->uid = g_strdup_printf ("%s,%s", split_line[0], message_id);
+ new_info->message_id = g_strdup(message_id);
if (camel_nntp_newsrc_article_is_read (nntp_store->newsrc,
nntp_folder->group_name,
@@ -79,6 +100,7 @@ get_XOVER_headers(CamelNNTPStore *nntp_store, CamelFolder *folder,
new_info->flags |= CAMEL_MESSAGE_SEEN;
camel_folder_summary_add (nntp_folder->summary, new_info);
+ g_strfreev (split_line);
}
g_free (line);
}
@@ -204,15 +226,13 @@ camel_nntp_get_headers (CamelStore *store,
return;
}
-#if 0
- if (nntp_store->extensions & CAMEL_NNTP_EXT_XOVER) {
-#endif
- get_XOVER_headers (nntp_store, folder, first_message, last_message, ex);
-#if 0
+ if (nntp_store->extensions & CAMEL_NNTP_EXT_OVER) {
+ get_OVER_headers (nntp_store, folder, first_message, last_message, ex);
}
else {
+ g_warning ("need to fix get_HEAD_headers\n");
+#if 0
get_HEAD_headers (nntp_store, folder, first_message, last_message, ex);
- }
#endif
+ }
}
-