aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers
diff options
context:
space:
mode:
authorChris Toshok <toshok@src.gnome.org>2000-04-15 04:29:33 +0800
committerChris Toshok <toshok@src.gnome.org>2000-04-15 04:29:33 +0800
commit239523998456f6e7b5a5c516c5f40870d9960fb1 (patch)
tree618bf59bb2ea2479949421882a48c30ff0d9f5bf /camel/providers
parentd870ec752c2ae51843e5b8f07cef39ff619f75d7 (diff)
downloadgsoc2013-evolution-239523998456f6e7b5a5c516c5f40870d9960fb1.tar.gz
gsoc2013-evolution-239523998456f6e7b5a5c516c5f40870d9960fb1.tar.zst
gsoc2013-evolution-239523998456f6e7b5a5c516c5f40870d9960fb1.zip
okay. working now.
svn path=/trunk/; revision=2432
Diffstat (limited to 'camel/providers')
-rw-r--r--camel/providers/nntp/camel-nntp-folder.c57
-rw-r--r--camel/providers/nntp/camel-nntp-store.c14
-rw-r--r--camel/providers/nntp/camel-nntp-summary.c22
3 files changed, 77 insertions, 16 deletions
diff --git a/camel/providers/nntp/camel-nntp-folder.c b/camel/providers/nntp/camel-nntp-folder.c
index 17328bfd38..7c3e2063b1 100644
--- a/camel/providers/nntp/camel-nntp-folder.c
+++ b/camel/providers/nntp/camel-nntp-folder.c
@@ -79,8 +79,8 @@ static CamelMimeMessage *_get_message_by_uid (CamelFolder *folder, const gchar *
#if 0
static void _expunge (CamelFolder *folder, CamelException *ex);
static void _copy_message_to (CamelFolder *folder, CamelMimeMessage *message, CamelFolder *dest_folder, CamelException *ex);
-static const gchar *_get_message_uid (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex);
#endif
+static const gchar *_get_message_uid (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex);
static void _finalize (GtkObject *object);
@@ -106,13 +106,13 @@ camel_nntp_folder_class_init (CamelNNTPFolderClass *camel_nntp_folder_class)
camel_folder_class->list_subfolders = _list_subfolders;
camel_folder_class->get_message_by_number = _get_message_by_number;
camel_folder_class->get_message_count = _get_message_count;
+ camel_folder_class->get_uid_list = _get_uid_list;
+ camel_folder_class->get_message_by_uid = _get_message_by_uid;
#if 0
camel_folder_class->append_message = _append_message;
- camel_folder_class->get_uid_list = _get_uid_list;
camel_folder_class->expunge = _expunge;
camel_folder_class->copy_message_to = _copy_message_to;
camel_folder_class->get_message_uid = _get_message_uid;
- camel_folder_class->get_message_by_uid = _get_message_by_uid;
#endif
gtk_object_class->finalize = _finalize;
@@ -198,7 +198,7 @@ _init (CamelFolder *folder, CamelStore *parent_store,
folder->can_hold_folders = TRUE;
}
- folder->has_uid_capability = FALSE;
+ folder->has_uid_capability = TRUE;
folder->has_search_capability = FALSE;
folder->summary = NULL;
@@ -448,11 +448,9 @@ _get_message_count (CamelFolder *folder, CamelException *ex)
gint message_count = 0;
g_assert (folder);
-#if 0
g_assert (folder->summary);
message_count = CAMEL_NNTP_SUMMARY (folder->summary)->nb_message;
-#endif
CAMEL_LOG_FULL_DEBUG ("CamelNNTPFolder::get_message_count found %d messages\n", message_count);
return message_count;
@@ -588,7 +586,6 @@ _append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException
-#if 0
static GList *
_get_uid_list (CamelFolder *folder, CamelException *ex)
{
@@ -604,21 +601,43 @@ _get_uid_list (CamelFolder *folder, CamelException *ex)
for (i=0; i<message_info_array->len; i++) {
message_info = (CamelNNTPSummaryInformation *)(message_info_array->data) + i;
- uid_list = g_list_prepend (uid_list, g_strdup_printf ("%u", message_info->uid));
+ uid_list = g_list_prepend (uid_list, g_strdup (message_info->headers.uid));
}
CAMEL_LOG_FULL_DEBUG ("Leaving CamelNNTPFolder::get_uid_list\n");
return uid_list;
}
-#endif
static CamelMimeMessage *
_get_message_by_number (CamelFolder *folder, gint number, CamelException *ex)
{
-
+ GArray *message_info_array;
+ CamelNNTPSummaryInformation *message_info;
+
+ message_info_array =
+ CAMEL_NNTP_SUMMARY (folder->summary)->message_info;
+
+ if (number > message_info_array->len) {
+ camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID,
+ "No such message %d in folder `%s'.",
+ number, folder->name);
+ return NULL;
+ }
+
+ message_info =
+ (CamelNNTPSummaryInformation *)(message_info_array->data) +
+ (number - 1);
+
+ return _get_message_by_uid (folder, message_info->headers.uid, ex);
+}
+
+
+static CamelMimeMessage *
+_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex)
+{
CamelStream *nntp_istream;
CamelStream *message_stream;
CamelMimeMessage *message = NULL;
@@ -637,17 +656,17 @@ _get_message_by_number (CamelFolder *folder, gint number, CamelException *ex)
return NULL;
}
- nntp_istream = CAMEL_NNTP_STORE (parent_store)->istream;
+ status = camel_nntp_command (CAMEL_NNTP_STORE( parent_store ), NULL, "ARTICLE %s", uid);
- status = camel_nntp_command (CAMEL_NNTP_STORE( parent_store ), NULL, "ARTICLE %d", number);
+ nntp_istream = CAMEL_NNTP_STORE (parent_store)->istream;
/* if the uid was not found, raise an exception and return */
if (status != CAMEL_NNTP_OK) {
camel_exception_setv (ex,
CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- "message %d not found in the group",
- number);
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelNNTPFolder::get_message_by_number\n");
+ "message %s not found.",
+ uid);
+ CAMEL_LOG_FULL_DEBUG ("Leaving CamelNNTPFolder::get_message_by_uid\n");
return NULL;
}
@@ -658,6 +677,8 @@ _get_message_by_number (CamelFolder *folder, gint number, CamelException *ex)
buf = malloc(buf_alloc);
done = FALSE;
+ buf[0] = 0;
+
while (!done) {
char *line = camel_stream_buffer_read_line ( CAMEL_STREAM_BUFFER ( nntp_istream ));
int line_length = strlen ( line );
@@ -671,6 +692,10 @@ _get_message_by_number (CamelFolder *folder, gint number, CamelException *ex)
buf_alloc *= 2;
buf = realloc (buf, buf_alloc);
}
+ strcat(buf, line);
+ strcat(buf, "\n");
+ buf_len += strlen(line);
+ g_free (line);
}
}
@@ -682,6 +707,6 @@ _get_message_by_number (CamelFolder *folder, gint number, CamelException *ex)
message = camel_mime_message_new_with_session (camel_service_get_session (CAMEL_SERVICE (parent_store)));
camel_data_wrapper_set_input_stream (CAMEL_DATA_WRAPPER (message), message_stream);
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelNNTPFolder::get_message_by_number\n");
+ CAMEL_LOG_FULL_DEBUG ("Leaving CamelNNTPFolder::get_message_by_uid\n");
return message;
}
diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c
index 0c300be197..e64cc14099 100644
--- a/camel/providers/nntp/camel-nntp-store.c
+++ b/camel/providers/nntp/camel-nntp-store.c
@@ -115,6 +115,8 @@ _get_folder (CamelStore *store, const gchar *folder_name, CamelException *ex)
CamelNNTPFolder *new_nntp_folder;
CamelFolder *new_folder;
+ folder_name = "netscape.public.mozilla.announce";
+
/* check if folder has already been created */
/* call the standard routine for that when */
/* it is done ... */
@@ -271,11 +273,23 @@ camel_nntp_command (CamelNNTPStore *store, char **ret, char *fmt, ...)
va_list ap;
int status;
int resp_code;
+ CamelException *ex;
va_start (ap, fmt);
cmdbuf = g_strdup_vprintf (fmt, ap);
va_end (ap);
+ ex = camel_exception_new();
+
+ /* make sure we're connected */
+ if (store->ostream == NULL)
+ nntp_connect (CAMEL_SERVICE (store), ex);
+
+ if (camel_exception_get_id (ex)) {
+ camel_exception_free (ex);
+ return CAMEL_NNTP_FAIL;
+ }
+
/* Send the command */
camel_stream_write (store->ostream, cmdbuf, strlen (cmdbuf));
g_free (cmdbuf);
diff --git a/camel/providers/nntp/camel-nntp-summary.c b/camel/providers/nntp/camel-nntp-summary.c
index 079c1dddab..174cceb4cb 100644
--- a/camel/providers/nntp/camel-nntp-summary.c
+++ b/camel/providers/nntp/camel-nntp-summary.c
@@ -243,6 +243,17 @@ camel_nntp_summary_save (CamelNNTPSummary *summary, const gchar *filename,
write (fd, &data, sizeof (data));
if (msg_info->headers.received_date)
write (fd, msg_info->headers.received_date, field_length);
+
+ /* Write uid date. */
+ if (msg_info->headers.uid)
+ field_length = strlen (msg_info->headers.uid);
+ else
+ field_length = 0;
+ data = htonl (field_length);
+ write (fd, &data, sizeof (data));
+ if (msg_info->headers.uid)
+ write (fd, msg_info->headers.uid, field_length);
+
}
close (fd);
@@ -357,6 +368,17 @@ camel_nntp_summary_load (const gchar *newsgroup, const gchar *filename, CamelExc
field_length);
} else
msg_info->headers.received_date = NULL;
+
+ /* Read the uid field. */
+ read (fd, &field_length, sizeof (field_length));
+ field_length = ntohl (field_length);
+ if (field_length > 0) {
+ msg_info->headers.uid =
+ g_new0 (gchar, field_length + 1);
+ read (fd, msg_info->headers.uid,
+ field_length);
+ } else
+ msg_info->headers.uid = NULL;
}
close (fd);