aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-03-28 12:25:31 +0800
committerDan Winship <danw@src.gnome.org>2000-03-28 12:25:31 +0800
commit9d0c0def4a16839bca1c688317b29718f5128e84 (patch)
treed3b1363f96f579568b8962d6620fb4016f009d06
parent7301e78bde90188847bc5348e19ac565622a765a (diff)
downloadgsoc2013-evolution-9d0c0def4a16839bca1c688317b29718f5128e84.tar
gsoc2013-evolution-9d0c0def4a16839bca1c688317b29718f5128e84.tar.gz
gsoc2013-evolution-9d0c0def4a16839bca1c688317b29718f5128e84.tar.bz2
gsoc2013-evolution-9d0c0def4a16839bca1c688317b29718f5128e84.tar.lz
gsoc2013-evolution-9d0c0def4a16839bca1c688317b29718f5128e84.tar.xz
gsoc2013-evolution-9d0c0def4a16839bca1c688317b29718f5128e84.tar.zst
gsoc2013-evolution-9d0c0def4a16839bca1c688317b29718f5128e84.zip
new test program. Can be used to copy POP mail into your evolution inbox.
* tests/test-movemail.c: new test program. Can be used to copy POP mail into your evolution inbox. svn path=/trunk/; revision=2208
-rw-r--r--ChangeLog5
-rw-r--r--tests/Makefile.am10
-rw-r--r--tests/test-movemail.c150
3 files changed, 164 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 212776f6ff..3cbb0d22e7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2000-03-27 Dan Winship <danw@helixcode.com>
+
+ * tests/test-movemail.c: new test program. Can be used to copy POP
+ mail into your evolution inbox.
+
2000-03-27 Chris Toshok <toshok@laptoph.xtoph.org>
* addressbook/backend/pas/pas-backend-file.c
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3291d6035c..d91c0cb660 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) -I$(top_srcdir)/camel \
- -I$(includedir) -I$(top_srcdir)/camel/providers/MH \
+ -I$(includedir) -I$(top_srcdir)/camel/providers/pop3 \
-I$(top_srcdir)/camel/providers/mbox
LDADD = \
$(top_builddir)/camel/libcamel.la \
@@ -31,6 +31,13 @@ test9_LDADD = \
$(GNOME_LIBDIR) \
$(GNOMEUI_LIBS) $(INTLLIBS) $(EXTRA_GNOME_LIBS)
+test_movemail_LDADD = \
+ $(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/camel/libcamel.la \
+ $(top_builddir)/libibex/libibex.la \
+ $(GNOME_LIBDIR) \
+ $(GNOMEUI_LIBS) $(INTLLIBS) $(EXTRA_GNOME_LIBS)
+
if ENABLE_THREADS
THREAD_RELATED_TESTS=test8
else
@@ -47,4 +54,5 @@ noinst_PROGRAMS = \
test10 \
test11 \
test-formatter \
+ test-movemail \
$(THREAD_RELATED_TESTS)
diff --git a/tests/test-movemail.c b/tests/test-movemail.c
new file mode 100644
index 0000000000..553f7a3f5f
--- /dev/null
+++ b/tests/test-movemail.c
@@ -0,0 +1,150 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include <camel.h>
+#include "camel-pop3-store.h"
+#include "camel-pop3-folder.h"
+
+static char *
+auth_callback (char *prompt, gboolean secret, CamelService *service,
+ char *item, CamelException *ex)
+{
+ char buf[80];
+
+ printf ("%s\n", prompt);
+ if (secret)
+ printf ("(Warning: your input will be displayed)\n");
+ if (fgets (buf, sizeof (buf), stdin) == NULL) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
+ "User cancelled input.");
+ return NULL;
+ }
+ return g_strdup (buf);
+}
+
+int main (int argc, char **argv)
+{
+ CamelSession *session;
+ CamelException *ex;
+ CamelStore *store, *outstore;
+ CamelFolder *folder, *outfolder;
+ int nmsgs, i;
+ CamelMimeMessage *msg;
+
+ gtk_init (&argc, &argv);
+ camel_init ();
+
+ if (argc != 2) {
+ fprintf (stderr, "Usage: test-movemail url\n");
+ exit (1);
+ }
+ camel_provider_scan ();
+ session = camel_session_new (auth_callback);
+
+ ex = camel_exception_new ();
+ store = camel_session_get_store (session, argv[1], ex);
+ if (!store) {
+ fprintf(stderr, "Could not open store %s:\n%s\n", argv[1],
+ camel_exception_get_description (ex));
+ exit (1);
+ }
+ camel_service_connect_with_url (CAMEL_SERVICE (store), argv[1], ex);
+ if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) {
+ printf ("Couldn't connect to %s:\n%s\n", argv[1],
+ camel_exception_get_description (ex));
+ exit (1);
+ }
+
+ folder = camel_store_get_folder (store, "inbox", ex);
+ if (!folder) {
+ fprintf(stderr, "Could not get inbox:\n%s\n",
+ camel_exception_get_description (ex));
+ exit (1);
+ }
+ camel_folder_open (folder, FOLDER_OPEN_READ, ex);
+ if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) {
+ printf ("Couldn't open folder: %s\n",
+ camel_exception_get_description (ex));
+ exit (1);
+ }
+
+ nmsgs = camel_folder_get_message_count (folder, ex);
+ if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) {
+ printf ("Couldn't get message count: %s\n",
+ camel_exception_get_description (ex));
+ exit (1);
+ }
+ printf ("Inbox contains %d messages.\n", nmsgs);
+
+#ifdef DISPLAY_ONLY
+ stdout_stream = camel_stream_fs_new_with_fd (1);
+#else
+ outstore = camel_session_get_store (session, "mbox:///home/danw/evolution/folders", ex);
+ if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) {
+ printf ("Couldn't open output store: %s\n",
+ camel_exception_get_description (ex));
+ exit (1);
+ }
+ outfolder = camel_store_get_folder (outstore, "inbox", ex);
+ if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) {
+ printf ("Couldn't make output folder: %s\n",
+ camel_exception_get_description (ex));
+ exit (1);
+ }
+ camel_folder_open (outfolder, FOLDER_OPEN_WRITE, ex);
+ if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) {
+ printf ("Couldn't open output folder: %s\n",
+ camel_exception_get_description (ex));
+ exit (1);
+ }
+#endif
+
+ for (i = 1; i <= nmsgs; i++) {
+ msg = camel_folder_get_message_by_number (folder, i, ex);
+ if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) {
+ printf ("Couldn't get message: %s\n",
+ camel_exception_get_description (ex));
+ exit (1);
+ }
+
+#ifdef DISPLAY_ONLY
+ camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (msg),
+ stdout_stream);
+#else
+ camel_folder_append_message (outfolder, msg, ex);
+ if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) {
+ printf ("Couldn't write message: %s\n",
+ camel_exception_get_description (ex));
+ exit (1);
+ }
+#if 0
+ camel_folder_delete_message_by_number (folder, i, ex);
+ if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) {
+ printf ("Couldn't delete message: %s\n",
+ camel_exception_get_description (ex));
+ exit (1);
+ }
+#endif
+#endif
+ }
+
+#ifndef DISPLAY_ONLY
+ camel_folder_close (outfolder, FALSE, ex);
+#endif
+ camel_folder_close (folder, TRUE, ex);
+
+ camel_service_disconnect (CAMEL_SERVICE (store), ex);
+ if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) {
+ printf ("Couldn't disconnect: %s\n",
+ camel_exception_get_description (ex));
+ exit (1);
+ }
+
+ return 0;
+}
+
+void
+gratuitous_dependency_generator()
+{
+ xmlSetProp();
+ e_sexp_add_function();
+}