aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbertrand <Bertrand.Guiheneuf@aful.org>1999-08-06 05:25:53 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>1999-08-06 05:25:53 +0800
commit7e8e444982ca1b454a8d7fb7e6462f6d1ced44d2 (patch)
tree936e1d536aa5ac9c2a5c88c91fbb0ad134972b5d
parent5de5ccdbae6e7a1a12d8ad3579cfa599eaaa903b (diff)
downloadgsoc2013-evolution-7e8e444982ca1b454a8d7fb7e6462f6d1ced44d2.tar.gz
gsoc2013-evolution-7e8e444982ca1b454a8d7fb7e6462f6d1ced44d2.tar.zst
gsoc2013-evolution-7e8e444982ca1b454a8d7fb7e6462f6d1ced44d2.zip
test mh provider.
1999-08-05 bertrand <Bertrand.Guiheneuf@aful.org> * tests/test4.c: test mh provider. * camel/providers/MH/camel-mh-folder.c (_get_message): implemented svn path=/trunk/; revision=1083
-rw-r--r--ChangeLog12
-rw-r--r--camel/camel-folder.c13
-rw-r--r--camel/camel-folder.h2
-rw-r--r--camel/gmime-rfc2047.c2
-rw-r--r--camel/providers/MH/camel-mh-folder.c47
-rw-r--r--tests/Makefile.am16
6 files changed, 78 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 4801528896..f584241e77 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,14 +1,17 @@
-1999-08-05 root <guiheneu@linoleum.inria.fr>
-
-
1999-08-05 bertrand <Bertrand.Guiheneuf@aful.org>
+ * tests/test4.c:
+ test mh provider.
+
+ * camel/providers/MH/camel-mh-folder.c (_get_message):
+ implemented
+
* camel/camel-folder.c (_get_message):
new method.
(camel_folder_get_message):
corresponding public call
-* camel/README.HACKING:
+ * camel/README.HACKING:
Some notes.
* camel/CODING.STYLE:
@@ -20,6 +23,7 @@
* camel/providers/MH/camel-mh-folder.c (_list_subfolders):
minor typo fixes.
+
1999-08-04 bertrand <Bertrand.Guiheneuf@aful.org>
* camel/gmime-rfc2047.c:
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index 6753789bd6..f8c5f34ee3 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -316,6 +316,13 @@ _can_hold_messages (CamelFolder *folder)
+static gboolean
+_exists (CamelFolder *folder)
+{
+ return FALSE;
+}
+
+
/**
* _exists: tests if the folder object exists in its parent store.
* @folder: folder object
@@ -326,10 +333,10 @@ _can_hold_messages (CamelFolder *folder)
*
* Return value: true if the folder exists on the store false otherwise
**/
-static gboolean
-_exists (CamelFolder *folder)
+gboolean
+camel_folder_exists (CamelFolder *folder)
{
- return FALSE;
+ return (CF_CLASS(folder)->exists (folder));
}
diff --git a/camel/camel-folder.h b/camel/camel-folder.h
index eea6bcd36e..fd9c94761e 100644
--- a/camel/camel-folder.h
+++ b/camel/camel-folder.h
@@ -122,7 +122,7 @@ const gchar *camel_folder_get_name (CamelFolder *folder);
/* void camel_folder_set_full_name (CamelFolder *folder, const gchar *name); */
const gchar *camel_folder_get_full_name (CamelFolder *folder);
CamelMimeMessage *camel_folder_get_message (CamelFolder *folder, gint number);
-
+gboolean camel_folder_exists (CamelFolder *folder);
diff --git a/camel/gmime-rfc2047.c b/camel/gmime-rfc2047.c
index 780a866006..7266cb1159 100644
--- a/camel/gmime-rfc2047.c
+++ b/camel/gmime-rfc2047.c
@@ -131,7 +131,7 @@ gchar
gchar *charset, *encoding, *text, *end;
gchar dc[4096];
charset = data+1;
- encoding = strchr(charset, '?');
+ encoding = strchr (charset, '?');
if (!encoding) break;
encoding++;
diff --git a/camel/providers/MH/camel-mh-folder.c b/camel/providers/MH/camel-mh-folder.c
index 6f7b419841..50c0ad34d4 100644
--- a/camel/providers/MH/camel-mh-folder.c
+++ b/camel/providers/MH/camel-mh-folder.c
@@ -32,6 +32,7 @@
#include "camel-mh-store.h"
#include "gstring-util.h"
#include "camel-log.h"
+#include "camel-stream-fs.h"
static CamelFolderClass *parent_class=NULL;
@@ -48,6 +49,7 @@ static gboolean _create(CamelFolder *folder);
static gboolean _delete (CamelFolder *folder, gboolean recurse);
static gboolean _delete_messages (CamelFolder *folder);
static GList *_list_subfolders (CamelFolder *folder);
+static CamelMimeMessage *_get_message (CamelFolder *folder, gint number);
static void
camel_mh_folder_class_init (CamelMhFolderClass *camel_mh_folder_class)
@@ -64,6 +66,7 @@ camel_mh_folder_class_init (CamelMhFolderClass *camel_mh_folder_class)
camel_folder_class->delete = _delete;
camel_folder_class->delete_messages = _delete_messages;
camel_folder_class->list_subfolders = _list_subfolders;
+ camel_folder_class->get_message = _get_message;
}
@@ -216,7 +219,7 @@ _delete (CamelFolder *folder, gboolean recurse)
CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::delete removing directory %s\n", directory_path);
rmdir_error = rmdir (directory_path);
if (rmdir_error == -1) {
- CAMEL_LOG_FULL_WARNING ("CamelMhFolder::delete Error when removing directory %s\n", directory_path);
+ CAMEL_LOG_WARNING ("CamelMhFolder::delete Error when removing directory %s\n", directory_path);
CAMEL_LOG_FULL_DEBUG ( " Full error text is : %s\n", strerror(errno));
}
@@ -265,7 +268,7 @@ _delete_messages (CamelFolder *folder)
unlink_error = unlink(entry_name);
if (unlink_error == -1) {
- CAMEL_LOG_FULL_WARNING ("CamelMhFolder::delete_messages Error when deleting file %s\n", entry_name);
+ CAMEL_LOG_WARNING ("CamelMhFolder::delete_messages Error when deleting file %s\n", entry_name);
CAMEL_LOG_FULL_DEBUG ( " Full error text is : %s\n", strerror(errno));
}
}
@@ -335,3 +338,43 @@ _list_subfolders(CamelFolder *folder)
+static CamelMimeMessage *
+_get_message (CamelFolder *folder, gint number)
+{
+ CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder);
+ gchar *directory_path;
+ gchar *message_file_name;
+ struct stat stat_buf;
+ gint stat_error = 0;
+ CamelStream *input_stream;
+ CamelMimeMessage *message;
+
+ g_assert(folder);
+
+ /* call default implementation */
+ parent_class->delete_messages (folder);
+
+ directory_path = mh_folder->directory_path;
+ if (!directory_path) return NULL;
+
+ if (!camel_folder_exists (folder)) return NULL;
+
+ message_file_name = g_strdup_printf ("%s/%d", directory_path, number);
+ stat_error = stat (message_file_name, &stat_buf);
+
+ if ((stat_error == -1) || (!S_ISREG (stat_buf.st_mode))) {
+ g_free (message_file_name);
+ return NULL;
+ } else {
+ input_stream = camel_stream_fs_new_with_name (message_file_name, CAMEL_STREAM_FS_READ);
+ g_free (message_file_name);
+ if (!input_stream) return NULL;
+#warning use session field here
+ message = camel_mime_message_new_with_session ( (CamelSession *)NULL);
+ camel_data_wrapper_construct_from_stream ( CAMEL_DATA_WRAPPER (message), input_stream);
+ gtk_object_unref (GTK_OBJECT (input_stream));
+
+ }
+
+ return message;
+}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ac29a88a93..3e8f4de850 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,7 +1,7 @@
# process this file with automake to create Makefile.in
INCLUDES = -I$(top_srcdir)/intl -I$(top_srcdir)/camel \
- -I$(includedir)
+ -I$(includedir) -I$(top_srcdir)/camel/providers/MH
LDADD = \
$(top_builddir)/camel/libcamel.la \
@@ -9,8 +9,18 @@ LDADD = \
$(GNOMEUI_LIBS) $(INTLLIBS)
# $(BONOBO_LIBS)
+
+
+
+test4_LDADD = \
+ $(top_builddir)/camel/libcamel.la \
+ $(top_builddir)/camel/providers/MH/libcamelmh.la \
+ $(GNOME_LIBDIR) \
+ $(GNOMEUI_LIBS) $(INTLLIBS)
+
+
noinst_PROGRAMS = \
test1 \
test2 \
- test3
-
+ test3 \
+ test4