[evolution-data-server] Fix undefined references and fiddling with imapx



commit 0e943121c10e27af12dccd4154d0d2a74f452de7
Author: Chenthill Palanisamy <pchenthill novell com>
Date:   Wed Sep 30 15:24:51 2009 +0530

    Fix undefined references and fiddling with imapx
    exception handling.

 camel/camel-file-utils.c                          |   35 ++++++++++++++
 camel/camel-file-utils.h                          |    1 +
 camel/providers/imapx/Makefile.am                 |   10 ++++
 camel/providers/imapx/camel-imapx-server.c        |   43 ++++++++++++-----
 camel/providers/imapx/camel-imapx-store-summary.h |    6 +-
 camel/providers/imapx/camel-imapx-store.c         |   51 +++++++++++++++++++++
 camel/providers/imapx/camel-imapx-utils.c         |    5 +-
 camel/providers/imapx/test-imapx.c                |   29 ++++++++++++
 8 files changed, 162 insertions(+), 18 deletions(-)
---
diff --git a/camel/camel-file-utils.c b/camel/camel-file-utils.c
index d903619..4af03c6 100644
--- a/camel/camel-file-utils.c
+++ b/camel/camel-file-utils.c
@@ -752,3 +752,38 @@ camel_file_util_savename(const gchar *filename)
 
 	return retval;
 }
+
+/**
+ * camel_mkdir:
+ * @path: directory path to create
+ * @mode: permissions
+ *
+ * Creates the directory path described in @path, creating any parent
+ * directories as necessary.
+ *
+ * Returns 0 on success or -1 on fail. In the case of failure, errno
+ * will be set appropriately.
+ **/
+int
+camel_mkdir (const char *path, mode_t mode)
+{
+	char *copy, *p;
+	
+	g_assert(path && path[0] == '/');
+	
+	p = copy = g_alloca (strlen (path) + 1);
+	strcpy(copy, path);
+	do {
+		p = strchr(p + 1, '/');
+		if (p)
+			*p = '\0';
+		if (access(copy, F_OK) == -1) {
+			if (mkdir(copy, mode) == -1)
+				return -1;
+		}
+		if (p)
+			*p = '/';
+	} while (p);
+	
+	return 0;
+}
diff --git a/camel/camel-file-utils.h b/camel/camel-file-utils.h
index 5c8ac4b..3db63e6 100644
--- a/camel/camel-file-utils.h
+++ b/camel/camel-file-utils.h
@@ -69,6 +69,7 @@ gssize camel_read_socket (gint fd, gchar *buf, gsize n);
 gssize camel_write_socket (gint fd, const gchar *buf, gsize n);
 
 gchar *camel_file_util_savename(const gchar *filename);
+int camel_mkdir (const char *path, mode_t mode);
 
 G_END_DECLS
 
diff --git a/camel/providers/imapx/Makefile.am b/camel/providers/imapx/Makefile.am
index a95f896..c9ff9df 100644
--- a/camel/providers/imapx/Makefile.am
+++ b/camel/providers/imapx/Makefile.am
@@ -20,6 +20,7 @@ libcamelimapx_la_SOURCES =			\
 	camel-imapx-store.c			\
 	camel-imapx-folder.c			\
 	camel-imapx-server.c			\
+	camel-imapx-utils.c			\
 	camel-imapx-stream.c			
 
 noinst_HEADERS =				\
@@ -37,4 +38,13 @@ camel-imapx-tokenise.h: camel-imapx-tokens.txt
 
 libcamelimapx_la_LDFLAGS = -avoid-version -module
 
+noinst_PROGRAMS = test-imapx
+
+test_imapx_SOURCES = test-imapx.c
+test_imapx_LDADD =							\ 
+	$(top_builddir)/camel/libcamel-1.2.la				\
+	$(top_builddir)/camel/libcamel-provider-1.2.la			\
+	$(top_builddir)/camel/providers/imapx/libcamelimapx.la
+
+
 EXTRA_DIST = libcamelimapx.urls
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 33c94d2..0f07680 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -1471,7 +1471,7 @@ imapx_connect(CamelIMAPXServer *is, int ssl_mode, int try_starttls)
 	CamelStream * volatile tcp_stream = NULL;
 	int ret;
 
-	CAMEL_TRY {
+	{
 #ifdef HAVE_SSL
 		const char *mode;
 #endif
@@ -1540,18 +1540,21 @@ imapx_connect(CamelIMAPXServer *is, int ssl_mode, int try_starttls)
 		ic = camel_imapx_command_new("CAPABILITY", NULL, "CAPABILITY");
 		imapx_command_run(is, ic);
 		camel_imapx_command_free(ic);
-	} CAMEL_CATCH(e) {
+	} 
+	
+	
+/*	CAMEL_CATCH(e) {
 		if (tcp_stream)
 			camel_object_unref(tcp_stream);
 		camel_exception_throw_ex(e);
-	} CAMEL_DONE;
+	} CAMEL_DONE; */
 }
 
 static void
 imapx_reconnect(CamelIMAPXServer *is)
 {
 retry:
-	CAMEL_TRY {
+	{
 		CamelSasl *sasl;
 		CamelIMAPXCommand *ic;
 
@@ -1592,15 +1595,26 @@ retry:
 		imapx_command_run(is, ic);
 		camel_imapx_command_free(ic);
 		is->state = IMAPX_AUTHENTICATED;
-	} CAMEL_CATCH(e) {
-		/* Shrug, either way this re-loops back ... */
-		if (TRUE /*e->ex != CAMEL_EXCEPTION_USER_CANCEL*/) {
+	} 
+
+/*	if (camel_exception_is_set (e)) {
+		if (*e->ex  CAMEL_EXCEPTION_USER_CANCEL) {
 			printf("Re Connection failed: %s\n", e->desc);
 			sleep(5);
 			// camelexception_done?
 			goto retry;
 		}
-	} CAMEL_DONE;
+	} */
+	
+/*	CAMEL_CATCH(e) {
+		/* Shrug, either way this re-loops back ... 
+		if (TRUE /*e->ex != CAMEL_EXCEPTION_USER_CANCEL) {
+			printf("Re Connection failed: %s\n", e->desc);
+			sleep(5);
+			// camelexception_done?
+			goto retry;
+		}
+	} CAMEL_DONE; */
 }
 
 /* ********************************************************************** */
@@ -2183,7 +2197,8 @@ imapx_server_loop(void *d)
 
 	// FIXME: handle exceptions
 	while (1) {
-		CAMEL_TRY {
+		{
+			printf ("Inside try catch loop \n");
 			if (!is->stream)
 				imapx_reconnect(is);
 
@@ -2265,10 +2280,12 @@ imapx_server_loop(void *d)
 			}
 #endif
 #endif
-		} CAMEL_CATCH(e) {
-			printf("######### Got main loop exception: %s\n", e->desc);
-			sleep(1);
-		} CAMEL_DONE;
+		} 
+		
+//		CAMEL_CATCH(e) {
+//			printf("######### Got main loop exception: %s\n", e->desc);
+//			sleep(1);
+//		} CAMEL_DONE;
 	}
 
 	return NULL;
diff --git a/camel/providers/imapx/camel-imapx-store-summary.h b/camel/providers/imapx/camel-imapx-store-summary.h
index 7cc60db..aa6015f 100644
--- a/camel/providers/imapx/camel-imapx-store-summary.h
+++ b/camel/providers/imapx/camel-imapx-store-summary.h
@@ -25,9 +25,9 @@
 #include <camel/camel-object.h>
 #include <camel/camel-store-summary.h>
 
-#define CAMEL_IMAPX_STORE_SUMMARY(obj)         CAMEL_CHECK_CAST (obj, camel_iMAPX_store_summary_get_type (), CamelIMAPXStoreSummary)
-#define CAMEL_IMAPX_STORE_SUMMARY_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_iMAPX_store_summary_get_type (), CamelIMAPXStoreSummaryClass)
-#define CAMEL_IS_IMAPX_STORE_SUMMARY(obj)      CAMEL_CHECK_TYPE (obj, camel_iMAPX_store_summary_get_type ())
+#define CAMEL_IMAPX_STORE_SUMMARY(obj)         CAMEL_CHECK_CAST (obj, camel_imapx_store_summary_get_type (), CamelIMAPXStoreSummary)
+#define CAMEL_IMAPX_STORE_SUMMARY_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_imapx_store_summary_get_type (), CamelIMAPXStoreSummaryClass)
+#define CAMEL_IS_IMAPX_STORE_SUMMARY(obj)      CAMEL_CHECK_TYPE (obj, camel_imapx_store_summary_get_type ())
 
 G_BEGIN_DECLS
 
diff --git a/camel/providers/imapx/camel-imapx-store.c b/camel/providers/imapx/camel-imapx-store.c
index b412192..592a1c6 100644
--- a/camel/providers/imapx/camel-imapx-store.c
+++ b/camel/providers/imapx/camel-imapx-store.c
@@ -55,6 +55,7 @@
 #include "camel-imapx-exception.h"
 #include "camel-imapx-utils.h"
 #include "camel-imapx-server.h"
+#include "camel-imapx-summary.h"
 #include "camel-net-utils.h"
 
 /* Specified in RFC 2060 section 2.1 */
@@ -462,6 +463,56 @@ imapx_build_folder_info (CamelIMAPXStore *imap_store, const gchar *folder_name)
 	return fi;
 }
 
+static void
+fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags)
+{
+	CamelFolder *folder;
+
+	folder = camel_object_bag_peek(store->folders, fi->full_name);
+	if (folder) {
+		CamelIMAPXSummary *ims;
+
+		if (folder->summary)
+			ims = (CamelIMAPXSummary *) folder->summary;
+		else
+			ims = (CamelIMAPXSummary *) camel_imapx_summary_new (folder, NULL);
+
+		fi->unread = ((CamelFolderSummary *)ims)->unread_count;
+		fi->total = ((CamelFolderSummary *)ims)->saved_count;
+
+		if (!folder->summary)
+			camel_object_unref (ims);
+		camel_object_unref(folder);
+	}
+}
+
+static gint 
+imap_match_pattern(gchar dir_sep, const gchar *pattern, const gchar *name)
+{
+	gchar p, n;
+
+	p = *pattern++;
+	n = *name++;
+	while (n && p) {
+		if (n == p) {
+			p = *pattern++;
+			n = *name++;
+		} else if (p == '%') {
+			if (n != dir_sep) {
+				n = *name++;
+			} else {
+				p = *pattern++;
+			}
+		} else if (p == '*') {
+			return TRUE;
+		} else
+			return FALSE;
+	}
+
+	return n == 0 && (p == '%' || p == 0);
+}
+
+
 static CamelFolderInfo *
 get_folder_info_offline (CamelStore *store, const gchar *top,
 			 guint32 flags, CamelException *ex)
diff --git a/camel/providers/imapx/camel-imapx-utils.c b/camel/providers/imapx/camel-imapx-utils.c
index 3772ad4..f296008 100644
--- a/camel/providers/imapx/camel-imapx-utils.c
+++ b/camel/providers/imapx/camel-imapx-utils.c
@@ -20,6 +20,7 @@
 #define d(x)
 
 #include "camel-imapx-tokenise.h"
+#define SUBFOLDER_DIR_NAME     "subfolders"
 
 #ifdef __GNUC__
 __inline
@@ -44,7 +45,7 @@ static struct {
 	{ "\\DRAFT", CAMEL_MESSAGE_DRAFT },
 	{ "\\FLAGGED", CAMEL_MESSAGE_FLAGGED },
 	{ "\\SEEN", CAMEL_MESSAGE_SEEN },
-	{ "\\RECENT", CAMEL_MESSAGE_RECENT },
+//	{ "\\RECENT", CAMEL_MESSAGE_RECENT },
 	{ "\\*", CAMEL_MESSAGE_USER },
 };
 
@@ -1407,7 +1408,7 @@ imapx_path_to_physical (const gchar *prefix, const gchar *vpath)
 }
 
 gchar *
-imapx_concat (CamelImapStore *imap_store, const gchar *prefix, const gchar *suffix)
+imapx_concat (CamelIMAPXStore *imap_store, const gchar *prefix, const gchar *suffix)
 {
 	gsize len;
 
diff --git a/camel/providers/imapx/test-imapx.c b/camel/providers/imapx/test-imapx.c
new file mode 100644
index 0000000..735432c
--- /dev/null
+++ b/camel/providers/imapx/test-imapx.c
@@ -0,0 +1,29 @@
+#include <glib.h>
+#include "camel-imapx-store.h"
+#include "camel-imapx-folder.h"
+#include <camel/camel-session.h>
+
+#define URL "imapx://pchenthill prv1-3 novell com/;check_lsub;basic_headers=1;imap_custom_headers;command=ssh%20-C%20-l%20%25u%20%25h%20exec%20/usr/sbin/imapd;use_ssl=always"
+
+int 
+main (int argc, char *argv [])
+{
+	CamelSession *session;
+	CamelException *ex;
+	gchar *uri = NULL;
+	CamelService *service;
+
+	g_thread_init (NULL);
+	system ("rm -rf /tmp/test-camel-imapx");
+	camel_init ("/tmp/test-camel-imapx");
+	camel_provider_init ();
+	ex = camel_exception_new ();
+	
+	session = CAMEL_SESSION (camel_object_new (CAMEL_SESSION_TYPE));
+	camel_session_construct (session, "/tmp/test-camel-imapx");
+
+	service = camel_session_get_service (session, URL, CAMEL_PROVIDER_STORE, ex);
+	camel_service_connect (service, ex);
+
+	exit (1);
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]