aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog16
-rw-r--r--camel/camel-mime-parser.c3
-rw-r--r--camel/providers/nntp/camel-nntp-folder.c69
-rw-r--r--camel/providers/nntp/camel-nntp-utils.c9
4 files changed, 56 insertions, 41 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index e1918ca7be..dba02a52a5 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,19 @@
+2000-07-12 Chris Toshok <toshok@helixcode.com>
+
+ * providers/nntp/camel-nntp-folder.c
+ (nntp_folder_set_message_flags): get the article num out of our
+ uid and mark it read in the newsrc.
+ (nntp_folder_get_message): get the message id out of the uid to
+ fetch the article.
+
+ * providers/nntp/camel-nntp-utils.c (get_XOVER_headers): the uid
+ is now <article-num>,<messageid>
+ (get_HEAD_headers): same.
+
+ * camel-mime-parser.c (folder_scan_step): go to HSCAN_MESSAGE
+ state when ct->subtype is "news" as well as "rfc822". this makes
+ attachments of type "message/news" display properly.
+
2000-07-12 Dan Winship <danw@helixcode.com>
* camel-folder.c (camel_folder_free_deep,
diff --git a/camel/camel-mime-parser.c b/camel/camel-mime-parser.c
index c8dc4fb61c..9e49effa6c 100644
--- a/camel/camel-mime-parser.c
+++ b/camel/camel-mime-parser.c
@@ -288,7 +288,7 @@ static char *states[] = {
"HSCAN_HEADER", /* toplevel header */
"HSCAN_BODY", /* scanning body of message */
"HSCAN_MULTIPART", /* got multipart header */
- "HSCAN_MESSAGE", /* rfc822 message */
+ "HSCAN_MESSAGE", /* rfc822/news message */
"HSCAN_PART", /* part of a multipart */
"<invalid>",
@@ -1557,6 +1557,7 @@ tail_recurse:
}
} else if (!strcasecmp(ct->type, "message")) {
if (!strcasecmp(ct->subtype, "rfc822")
+ || !strcasecmp(ct->subtype, "news")
/*|| !strcasecmp(ct->subtype, "partial")*/) {
type = HSCAN_MESSAGE;
}
diff --git a/camel/providers/nntp/camel-nntp-folder.c b/camel/providers/nntp/camel-nntp-folder.c
index 2b41768d36..677af03878 100644
--- a/camel/providers/nntp/camel-nntp-folder.c
+++ b/camel/providers/nntp/camel-nntp-folder.c
@@ -126,27 +126,13 @@ static void
nntp_folder_sync (CamelFolder *folder, gboolean expunge,
CamelException *ex)
{
- camel_folder_summary_save (CAMEL_NNTP_FOLDER(folder)->summary);
-
- /* XXX
-
- loop through the messages in the summary and store out the .newsrc,
- using something similar to this bit snipped from _set_message_flags:
+ CamelNNTPStore *store;
+ camel_folder_summary_save (CAMEL_NNTP_FOLDER(folder)->summary);
- if (set & CAMEL_MESSAGE_SEEN) {
- CamelNNTPStore *store;
- CamelException *ex;
-
- ex = camel_exception_new ();
- store = CAMEL_NNTP_STORE (camel_folder_get_parent_store (folder, ex));
- camel_exception_free (ex);
-
- camel_nntp_newsrc_mark_article_read (store->newsrc,
- nntp_folder->group_name,
- XXX);
- }
- */
+ store = CAMEL_NNTP_STORE (camel_folder_get_parent_store (folder, ex));
+ if (!camel_exception_is_set (ex))
+ camel_nntp_newsrc_write (store->newsrc);
}
static const gchar *
@@ -202,6 +188,20 @@ nntp_folder_set_message_flags (CamelFolder *folder, const char *uid,
info->flags = set;
+ if (set & CAMEL_MESSAGE_SEEN) {
+ CamelNNTPStore *store;
+ int article_num;
+ CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (camel_folder_get_parent_store (folder, ex));
+
+ if (!camel_exception_is_set (ex)) {
+ sscanf (uid, "%d", &article_num);
+
+ camel_nntp_newsrc_mark_article_read (nntp_store->newsrc,
+ nntp_folder->group_name,
+ article_num);
+ }
+ }
+
camel_folder_summary_touch (nntp_folder->summary);
}
@@ -226,6 +226,7 @@ nntp_folder_get_message (CamelFolder *folder, const gchar *uid, CamelException *
int buf_alloc;
int status;
gboolean done;
+ char *message_id;
/* get the parent store */
parent_store = camel_folder_get_parent_store (folder, ex);
@@ -233,16 +234,17 @@ nntp_folder_get_message (CamelFolder *folder, const gchar *uid, CamelException *
return NULL;
}
- status = camel_nntp_command (CAMEL_NNTP_STORE( parent_store ), NULL, "ARTICLE %s", uid);
+ message_id = strchr (uid, ',') + 1;
+ status = camel_nntp_command (CAMEL_NNTP_STORE( parent_store ), NULL, "ARTICLE %s", message_id);
nntp_istream = CAMEL_NNTP_STORE (parent_store)->istream;
- /* if the uid was not found, raise an exception and return */
+ /* if the message_id was not found, raise an exception and return */
if (status != CAMEL_NNTP_OK) {
camel_exception_setv (ex,
CAMEL_EXCEPTION_FOLDER_INVALID_UID,
"message %s not found.",
- uid);
+ message_id);
return NULL;
}
@@ -288,7 +290,7 @@ nntp_folder_get_message (CamelFolder *folder, const gchar *uid, CamelException *
gtk_object_unref (GTK_OBJECT (message_stream));
camel_exception_setv (ex,
CAMEL_EXCEPTION_FOLDER_INVALID_UID, /* XXX */
- "Could not create message for uid %s.", uid);
+ "Could not create message for message_id %s.", message_id);
return NULL;
}
@@ -317,17 +319,16 @@ nntp_folder_get_uids (CamelFolder *folder,
CamelException *ex)
{
CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder);
- GPtrArray *infoarray, *out;
+ GPtrArray *out;
CamelMessageInfo *message_info;
int i;
-
- infoarray = nntp_folder->summary->messages;
+ int count = camel_folder_summary_count (nntp_folder->summary);
out = g_ptr_array_new ();
- g_ptr_array_set_size (out, infoarray->len);
+ g_ptr_array_set_size (out, count);
- for (i=0; i<infoarray->len; i++) {
- message_info = (CamelMessageInfo *) g_ptr_array_index (infoarray, i);
+ for (i = 0; i < count; i++) {
+ message_info = camel_folder_summary_index (nntp_folder->summary, i);
out->pdata[i] = g_strdup (message_info->uid);
}
@@ -378,16 +379,8 @@ static const CamelMessageInfo*
nntp_folder_get_message_info (CamelFolder *folder, const char *uid)
{
CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder);
- CamelMessageInfo *info = NULL;
- int i;
- for (i = 0; i < nntp_folder->summary->messages->len; i++) {
- info = g_ptr_array_index (nntp_folder->summary->messages, i);
- if (!strcmp (info->uid, uid))
- return info;
- }
-
- return NULL;
+ return camel_folder_summary_uid (nntp_folder->summary, uid);
}
static void
diff --git a/camel/providers/nntp/camel-nntp-utils.c b/camel/providers/nntp/camel-nntp-utils.c
index 864271cd2c..e0a331f2a7 100644
--- a/camel/providers/nntp/camel-nntp-utils.c
+++ b/camel/providers/nntp/camel-nntp-utils.c
@@ -69,10 +69,15 @@ get_XOVER_headers(CamelNNTPStore *nntp_store, CamelFolder *folder,
new_info->headers.date_received = g_strdup(split_line[3]);
#endif
new_info->size = atoi(split_line[5]);
- new_info->uid = g_strdup(split_line[4]);
+ 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);
+ if (camel_nntp_newsrc_article_is_read (nntp_store->newsrc,
+ nntp_folder->group_name,
+ atoi (split_line[0])))
+ new_info->flags |= CAMEL_MESSAGE_SEEN;
+
camel_folder_summary_add (nntp_folder->summary, new_info);
}
g_free (line);
@@ -153,7 +158,7 @@ get_HEAD_headers(CamelNNTPStore *nntp_store, CamelFolder *folder,
else if (!g_strcasecmp(header->name, "Subject"))
new_info->subject = g_strdup(header->value);
else if (!g_strcasecmp(header->name, "Message-ID")) {
- new_info->uid = g_strdup(header->value);
+ new_info->uid = g_strdup_printf("%d,%s", i, header->value);
new_info->message_id = g_strdup(header->value);
}
else if (!g_strcasecmp(header->name, "Date")) {