From da570c66609a9baea34d4899c4ca7e1f8329d471 Mon Sep 17 00:00:00 2001 From: Peter Williams Date: Tue, 29 Aug 2000 21:28:46 +0000 Subject: CamelRemoteStore: a new generic store for stores that connect to servers. Prepare for the ability to cancel operations (much better exception handling). Clean up IMAP like nobody's business svn path=/trunk/; revision=5103 --- camel/providers/nntp/camel-nntp-folder.c | 15 +++++++++----- camel/providers/nntp/camel-nntp-store.c | 34 +++++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 14 deletions(-) (limited to 'camel/providers/nntp') diff --git a/camel/providers/nntp/camel-nntp-folder.c b/camel/providers/nntp/camel-nntp-folder.c index 091d35e591..371c4698e2 100644 --- a/camel/providers/nntp/camel-nntp-folder.c +++ b/camel/providers/nntp/camel-nntp-folder.c @@ -63,7 +63,6 @@ nntp_folder_init (CamelFolder *folder, CamelStore *parent_store, gchar *separator, gboolean path_begins_with_sep, CamelException *ex) { - const gchar *root_dir_path; CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder); /* call parent method */ @@ -93,12 +92,19 @@ nntp_folder_init (CamelFolder *folder, CamelStore *parent_store, if (!(nntp_load_uid_list (nntp_folder) > 0)) nntp_generate_uid_list (nntp_folder); #endif +} - root_dir_path = camel_nntp_store_get_toplevel_dir (CAMEL_NNTP_STORE(folder->parent_store)); - +static void +nntp_refresh_info (CamelFolder *folder, CamelException *ex) +{ + CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder); /* load the summary if we have that ability */ if (folder->has_summary_capability) { + const gchar *root_dir_path; + + root_dir_path = camel_nntp_store_get_toplevel_dir (CAMEL_NNTP_STORE(folder->parent_store)); + nntp_folder->summary_file_path = g_strdup_printf ("%s/%s-ev-summary", root_dir_path, nntp_folder->group_name); @@ -118,8 +124,6 @@ nntp_folder_init (CamelFolder *folder, CamelStore *parent_store, camel_folder_summary_save (nntp_folder->summary); } } - - } static void @@ -364,6 +368,7 @@ camel_nntp_folder_class_init (CamelNNTPFolderClass *camel_nntp_folder_class) /* virtual method overload */ camel_folder_class->init = nntp_folder_init; + camel_folder_class->refresh_info = nntp_refresh_info; camel_folder_class->sync = nntp_folder_sync; camel_folder_class->get_subfolder = nntp_folder_get_subfolder; camel_folder_class->get_message_count = nntp_folder_get_message_count; diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c index c412c0f6a3..5c9475ed14 100644 --- a/camel/providers/nntp/camel-nntp-store.c +++ b/camel/providers/nntp/camel-nntp-store.c @@ -176,6 +176,8 @@ nntp_store_get_folder (CamelStore *store, const gchar *folder_name, CF_CLASS (new_folder)->init (new_folder, store, NULL, folder_name, ".", FALSE, ex); + CF_CLASS (new_folder)->refresh_info (new_folder, ex); + return new_folder; } @@ -271,21 +273,22 @@ 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_store_connect (CAMEL_SERVICE (store), ex); - - if (camel_exception_get_id (ex)) { - camel_exception_free (ex); - return CAMEL_NNTP_FAIL; + if (store->ostream == NULL) { + CamelException ex; + + camel_exception_init (&ex); + nntp_store_connect (CAMEL_SERVICE (store), &ex); + if (camel_exception_get_id (&ex)) { + camel_exception_clear (&ex); + return CAMEL_NNTP_FAIL; + } + camel_exception_clear (&ex); } /* Send the command */ @@ -344,6 +347,19 @@ camel_nntp_command_get_additional_data (CamelNNTPStore *store) char *buf; int i, status = CAMEL_NNTP_OK; + /* make sure we're connected */ + if (store->ostream == NULL) { + CamelException ex; + + camel_exception_init (&ex); + nntp_store_connect (CAMEL_SERVICE (store), &ex); + if (camel_exception_get_id (&ex)) { + camel_exception_clear (&ex); + return NULL; + } + camel_exception_clear (&ex); + } + data = g_ptr_array_new (); while (1) { buf = camel_stream_buffer_read_line (stream); -- cgit