Index: camel/camel-mime-filter-tohtml.c
===================================================================
--- camel/camel-mime-filter-tohtml.c (revision 444)
+++ camel/camel-mime-filter-tohtml.c (working copy)
@@ -47,12 +47,13 @@
#define CONVERT_WEB_URLS CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS
#define CONVERT_ADDRSPEC CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES
-static const struct {
- const unsigned int mask;
- const urlpattern_t pattern;
+static struct {
+ unsigned int mask;
+ urlpattern_t pattern;
} patterns[] = {
{ CONVERT_WEB_URLS, { "file://", "", camel_url_file_start, camel_url_file_end } },
{ CONVERT_WEB_URLS, { "ftp://", "", camel_url_web_start, camel_url_web_end } },
+ { CONVERT_WEB_URLS, { "sftp://", "", camel_url_web_start, camel_url_web_end } },
{ CONVERT_WEB_URLS, { "http://", "", camel_url_web_start, camel_url_web_end } },
{ CONVERT_WEB_URLS, { "https://", "", camel_url_web_start, camel_url_web_end } },
{ CONVERT_WEB_URLS, { "news://", "", camel_url_web_start, camel_url_web_end } },
@@ -164,13 +165,13 @@
{
CamelMimeFilterToHTML *html = (CamelMimeFilterToHTML *) filter;
const char *inptr = in;
-
+
while (inptr < inend) {
guint32 u;
-
+
outptr = check_size (filter, outptr, outend, 16);
-
- u = camel_utf8_getc_limit ((const unsigned char **) &inptr, inend);
+
+ u = camel_utf8_getc_limit ((const unsigned char **) &inptr, (const unsigned char *) inend);
switch (u) {
case 0xffff:
g_warning("Truncated utf8 buffer");
Index: camel/camel-filter-search.c
===================================================================
--- camel/camel-filter-search.c (revision 444)
+++ camel/camel-filter-search.c (working copy)
@@ -22,9 +22,7 @@
*
*/
-#ifdef HAVE_CONFIG_H
#include
-#endif
/* (from glibc headers:
POSIX says that must be included (by the caller) before . */
@@ -39,23 +37,26 @@
#include
#include
-#include
+#include
+
+#ifndef G_OS_WIN32
#include
+#endif
-#include
-#include
+#include "libedataserver/e-sexp.h"
+#include "libedataserver/e-iconv.h"
#include "camel-debug.h"
+#include "camel-exception.h"
+#include "camel-filter-search.h"
+#include "camel-i18n.h"
#include "camel-mime-message.h"
+#include "camel-multipart.h"
#include "camel-provider.h"
+#include "camel-search-private.h"
#include "camel-session.h"
-#include "camel-filter-search.h"
-#include "camel-exception.h"
-#include "camel-multipart.h"
+#include "camel-stream-fs.h"
#include "camel-stream-mem.h"
-#include "camel-stream-fs.h"
-#include "camel-search-private.h"
-#include "camel-i18n.h"
#include "camel-url.h"
#define d(x)
@@ -155,11 +156,12 @@
if (g_ascii_strcasecmp(name, "x-camel-mlist") == 0) {
const char *list = camel_message_info_mlist(fms->info);
- if (list)
+ if (list) {
for (i=1; itype == ESEXP_RES_STRING)
matched = camel_search_header_match(list, argv[i]->value.string, how, CAMEL_SEARCH_TYPE_MLIST, NULL);
}
+ }
} else {
CamelMimeMessage *message = camel_filter_search_get_message (fms, f);
struct _camel_header_raw *header;
@@ -506,90 +508,106 @@
return r;
}
+#ifndef G_OS_WIN32
+static void
+child_setup_func (gpointer user_data)
+{
+ setsid ();
+}
+#else
+#define child_setup_func NULL
+#endif
+
+typedef struct {
+ gint child_status;
+ GMainLoop *loop;
+} child_watch_data_t;
+
+static void
+child_watch (GPid pid,
+ gint status,
+ gpointer data)
+{
+ child_watch_data_t *child_watch_data = data;
+
+ g_spawn_close_pid (pid);
+
+ child_watch_data->child_status = status;
+
+ g_main_loop_quit (child_watch_data->loop);
+}
+
static int
run_command (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessageSearch *fms)
{
CamelMimeMessage *message;
CamelStream *stream;
- int result, status;
- int in_fds[2];
- pid_t pid;
+ int i;
+ int pipe_to_child;
+ GPid child_pid;
+ GError *error = NULL;
+ GPtrArray *args;
+ child_watch_data_t child_watch_data;
+ GSource *source;
if (argc < 1 || argv[0]->value.string[0] == '\0')
return 0;
- if (pipe (in_fds) == -1) {
- camel_exception_setv (fms->ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to create pipe to '%s': %s"),
- argv[0]->value.string, g_strerror (errno));
- return -1;
- }
+ args = g_ptr_array_new ();
+ for (i = 0; i < argc; i++)
+ g_ptr_array_add (args, argv[i]->value.string);
+ g_ptr_array_add (args, NULL);
- if (!(pid = fork ())) {
- /* child process */
- GPtrArray *args;
- int maxfd, fd, i;
-
- fd = open ("/dev/null", O_WRONLY);
-
- if (dup2 (in_fds[0], STDIN_FILENO) < 0 ||
- dup2 (fd, STDOUT_FILENO) < 0 ||
- dup2 (fd, STDERR_FILENO) < 0)
- _exit (255);
-
- setsid ();
-
- maxfd = sysconf (_SC_OPEN_MAX);
- for (fd = 3; fd < maxfd; fd++)
- fcntl (fd, F_SETFD, FD_CLOEXEC);
-
- args = g_ptr_array_new ();
- for (i = 0; i < argc; i++)
- g_ptr_array_add (args, argv[i]->value.string);
- g_ptr_array_add (args, NULL);
-
- execvp (argv[0]->value.string, (char **) args->pdata);
-
+ if (!g_spawn_async_with_pipes (NULL,
+ (gchar **) args->pdata,
+ NULL,
+ G_SPAWN_DO_NOT_REAP_CHILD |
+ G_SPAWN_SEARCH_PATH |
+ G_SPAWN_STDOUT_TO_DEV_NULL |
+ G_SPAWN_STDERR_TO_DEV_NULL,
+ child_setup_func,
+ NULL,
+ &child_pid,
+ &pipe_to_child,
+ NULL,
+ NULL,
+ &error)) {
g_ptr_array_free (args, TRUE);
-
- d(printf ("Could not execute %s: %s\n", argv[0]->value.string, g_strerror (errno)));
- _exit (255);
- } else if (pid < 0) {
+
camel_exception_setv (fms->ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to create create child process '%s': %s"),
- argv[0]->value.string, g_strerror (errno));
+ argv[0]->value.string, error->message);
+ g_error_free (error);
return -1;
}
- /* parent process */
- close (in_fds[0]);
+ g_ptr_array_free (args, TRUE);
message = camel_filter_search_get_message (fms, f);
- stream = camel_stream_fs_new_with_fd (in_fds[1]);
+ stream = camel_stream_fs_new_with_fd (pipe_to_child);
camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), stream);
camel_stream_flush (stream);
camel_object_unref (stream);
- result = waitpid (pid, &status, 0);
-
- if (result == -1 && errno == EINTR) {
- /* child process is hanging... */
- kill (pid, SIGTERM);
- sleep (1);
- result = waitpid (pid, &status, WNOHANG);
- if (result == 0) {
- /* ...still hanging, set phasers to KILL */
- kill (pid, SIGKILL);
- sleep (1);
- result = waitpid (pid, &status, WNOHANG);
- }
- }
-
- if (result != -1 && WIFEXITED (status))
- return WEXITSTATUS (status);
+ child_watch_data.loop = g_main_loop_new (g_main_context_new (), FALSE);
+
+ source = g_child_watch_source_new (child_pid);
+ g_source_set_callback (source, (GSourceFunc) child_watch, &child_watch_data, NULL);
+ g_source_attach (source, g_main_loop_get_context (child_watch_data.loop));
+ g_source_unref (source);
+
+ g_main_loop_run (child_watch_data.loop);
+ g_main_loop_unref (child_watch_data.loop);
+
+#ifndef G_OS_WIN32
+ if (WIFEXITED (child_watch_data.child_status))
+ return WEXITSTATUS (child_watch_data.child_status);
else
return -1;
+#else
+ return child_watch_data.child_status;
+#endif
}
static ESExpResult *
Index: camel/camel-stream.c
===================================================================
--- camel/camel-stream.c (revision 444)
+++ camel/camel-stream.c (working copy)
@@ -28,6 +28,7 @@
#endif
#include
+
#include "camel-stream.h"
static CamelObjectClass *parent_class = NULL;
Index: camel/camel-store.c
===================================================================
--- camel/camel-store.c (revision 444)
+++ camel/camel-store.c (working copy)
@@ -32,14 +32,13 @@
#include
#include "camel-debug.h"
-
+#include "camel-exception.h"
+#include "camel-folder.h"
+#include "camel-i18n.h"
+#include "camel-private.h"
#include "camel-session.h"
#include "camel-store.h"
-#include "camel-folder.h"
#include "camel-vtrash-folder.h"
-#include "camel-exception.h"
-#include "camel-private.h"
-#include "camel-i18n.h"
#define d(x)
#define w(x)
@@ -290,7 +289,7 @@
if (camel_debug_start(":store")) {
char *u = camel_url_to_string(((CamelService *)store)->url, CAMEL_URL_HIDE_PASSWORD);
- printf("CamelStore('%s'):get_folder('%s', %d) = %p\n", u, folder_name, flags, folder);
+ printf("CamelStore('%s'):get_folder('%s', %u) = %p\n", u, folder_name, flags, folder);
if (ex && ex->id)
printf(" failed: '%s'\n", ex->desc);
g_free(u);
Index: camel/camel-transport.c
===================================================================
--- camel/camel-transport.c (revision 444)
+++ camel/camel-transport.c (working copy)
@@ -27,10 +27,10 @@
#include
#endif
-#include "camel-transport.h"
#include "camel-address.h"
#include "camel-mime-message.h"
#include "camel-private.h"
+#include "camel-transport.h"
static CamelServiceClass *parent_class = NULL;
Index: camel/camel-mime-filter-pgp.c
===================================================================
--- camel/camel-mime-filter-pgp.c (revision 444)
+++ camel/camel-mime-filter-pgp.c (working copy)
@@ -3,6 +3,7 @@
* Copyright (C) 2005 Matt Brown.
*
* Authors: Matt Brown
+ * Jeffrey Stedfast
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU Lesser General Public
@@ -39,9 +40,10 @@
static void reset (CamelMimeFilter *f);
enum {
- PGPF_HEADER,
- PGPF_MESSAGE,
- PGPF_FOOTER,
+ PGP_PREFACE,
+ PGP_HEADER,
+ PGP_MESSAGE,
+ PGP_FOOTER,
};
static void
@@ -60,7 +62,8 @@
static CamelType type = CAMEL_INVALID_TYPE;
if (type == CAMEL_INVALID_TYPE) {
- type = camel_type_register (camel_mime_filter_get_type(), "CamelMimeFilterPgp",
+ type = camel_type_register (camel_mime_filter_get_type (),
+ "CamelMimeFilterPgp",
sizeof (CamelMimeFilterPgp),
sizeof (CamelMimeFilterPgpClass),
(CamelObjectClassInitFunc) camel_mime_filter_pgp_class_init,
@@ -72,94 +75,103 @@
return type;
}
+#define BEGIN_PGP_SIGNED_MESSAGE "-----BEGIN PGP SIGNED MESSAGE-----"
+#define BEGIN_PGP_SIGNATURE "-----BEGIN PGP SIGNATURE-----"
+#define END_PGP_SIGNATURE "-----END PGP SIGNATURE-----"
+
static void
filter_run(CamelMimeFilter *f, char *in, size_t len, size_t prespace, char **out, size_t *outlen, size_t *outprespace, int last)
{
- CamelMimeFilterPgp *pgpfilter = (CamelMimeFilterPgp *)f;
- char *inptr, *inend;
+ CamelMimeFilterPgp *pgp = (CamelMimeFilterPgp *) f;
+ const char *start, *inend = in + len;
+ register const char *inptr = in;
register char *o;
- char *start = in;
- int tmplen;
/* only need as much space as the input, we're stripping chars */
- camel_mime_filter_set_size(f, len, FALSE);
-
+ camel_mime_filter_set_size (f, len, FALSE);
+
o = f->outbuf;
- inptr = in;
- inend = in+len;
+
while (inptr < inend) {
start = inptr;
-
+
while (inptr < inend && *inptr != '\n')
inptr++;
-
+
if (inptr == inend) {
if (!last) {
- camel_mime_filter_backup(f, start, inend-start);
+ camel_mime_filter_backup (f, start, inend - start);
inend = start;
}
break;
}
-
- *inptr++ = 0;
- switch (pgpfilter->state) {
- case PGPF_HEADER:
- /* Wait for a blank line */
- if (strlen(start)==0)
- pgpfilter->state = PGPF_MESSAGE;
+ inptr++;
+
+ switch (pgp->state) {
+ case PGP_PREFACE:
+ /* check for the beginning of the pgp block */
+ if (!strncmp (start, BEGIN_PGP_SIGNED_MESSAGE, sizeof (BEGIN_PGP_SIGNED_MESSAGE) - 1)) {
+ pgp->state++;
+ break;
+ }
+
+ memcpy (o, start, inptr - start);
+ o += (inptr - start);
break;
- case PGPF_MESSAGE:
- /* In the message body, check for end of body */
- if (strncmp(start, "-----", 5)==0) {
- pgpfilter->state = PGPF_FOOTER;
+ case PGP_HEADER:
+ /* pgp headers (Hash: SHA1, etc) end with a blank line */
+ if ((inptr - start) == 1)
+ pgp->state++;
+ break;
+ case PGP_MESSAGE:
+ /* check for beginning of the pgp signature block */
+ if (!strncmp (start, BEGIN_PGP_SIGNATURE, sizeof (BEGIN_PGP_SIGNATURE) - 1)) {
+ pgp->state++;
break;
- }
+ }
+
/* do dash decoding */
- if (strncmp(start, "- ", 2)==0) {
+ if (!strncmp (start, "- ", 2)) {
/* Dash encoded line found, skip encoding */
- start+=2;
+ start += 2;
}
- tmplen=strlen(start)+1;
- inptr[-1] = '\n';
- strncpy(o, start, tmplen);
- o+=tmplen;
+
+ memcpy (o, start, inptr - start);
+ o += (inptr - start);
break;
- case PGPF_FOOTER:
- /* After end of message, (ie signature or something) skip it */
+ case PGP_FOOTER:
+ if (!strncmp (start, END_PGP_SIGNATURE, sizeof (END_PGP_SIGNATURE) - 1))
+ pgp->state = PGP_PREFACE;
break;
}
- inptr[-1] = '\n';
}
*out = f->outbuf;
*outlen = o - f->outbuf;
*outprespace = f->outpre;
-
}
static void
-filter(CamelMimeFilter *f, char *in, size_t len, size_t prespace, char **out, size_t *outlen, size_t *outprespace)
+filter (CamelMimeFilter *f, char *in, size_t len, size_t prespace, char **out, size_t *outlen, size_t *outprespace)
{
- filter_run(f, in, len, prespace, out, outlen, outprespace, FALSE);
+ filter_run (f, in, len, prespace, out, outlen, outprespace, FALSE);
}
static void
-complete(CamelMimeFilter *f, char *in, size_t len, size_t prespace, char **out, size_t *outlen, size_t *outprespace)
+complete (CamelMimeFilter *f, char *in, size_t len, size_t prespace, char **out, size_t *outlen, size_t *outprespace)
{
- filter_run(f, in, len, prespace, out, outlen, outprespace, TRUE);
+ filter_run (f, in, len, prespace, out, outlen, outprespace, TRUE);
}
static void
reset (CamelMimeFilter *f)
{
- /* no-op */
+ ((CamelMimeFilterPgp *) f)->state = PGP_PREFACE;
}
CamelMimeFilter *
camel_mime_filter_pgp_new(void)
{
- CamelMimeFilterPgp *pgpfilter = (CamelMimeFilterPgp *)camel_object_new (camel_mime_filter_pgp_get_type());
-
- return (CamelMimeFilter *) pgpfilter;
+ return (CamelMimeFilter *) camel_object_new (camel_mime_filter_pgp_get_type ());
}
Index: camel/camel-index.c
===================================================================
--- camel/camel-index.c (revision 444)
+++ camel/camel-index.c (working copy)
@@ -31,7 +31,7 @@
#include
#include "camel-index.h"
-#include "camel/camel-object.h"
+#include "camel-object.h"
#define w(x)
#define io(x)
Index: camel/camel-stream-process.c
===================================================================
--- camel/camel-stream-process.c (revision 444)
+++ camel/camel-stream-process.c (working copy)
@@ -39,8 +39,8 @@
#include
#include
+#include "camel-file-utils.h"
#include "camel-stream-process.h"
-#include "camel-file-utils.h"
extern int camel_verbose_debug;
Index: camel/providers/nntp/ChangeLog
===================================================================
--- camel/providers/nntp/ChangeLog (revision 444)
+++ camel/providers/nntp/ChangeLog (working copy)
@@ -1,3 +1,43 @@
+2006-06-15 Andre Klapper
+
+ * camel-nntp-store.c:
+ * camel-nntp-folder.c:
+ changing "cancelled" to "canceled" in user-visible strings.
+ Fixes bug #342163.
+
+2006-06-15 Andre Klapper
+
+ * addressbook/libebook/e-book.c:
+ * camel/camel-folder.c:
+ * camel/providers/nntp/camel-nntp-folder.c:
+ * camel/providers/pop3/camel-pop3-folder.c:
+ changing "uri" to "URI" in user-visible strings.
+ Fixes bug #342161.
+
+2006-06-09 Chris Heath
+
+ * camel-nntp-summary.c (message_info_new_from_header): Fix memory leak.
+ Fixes bug #335423.
+
+2005-12-13 Tor Lillqvist
+
+ * camel-nntp-grouplist.c
+ * camel-nntp-newsrc.c: Use gstdio wrappers.
+
+2005-11-30 Tor Lillqvist
+
+ * camel-nntp-folder.c
+ * camel-nntp-store.c: Remove some unneeded headers.
+
+2005-09-16 Tor Lillqvist
+
+ * camel-nntp-stream.c: If no ECONNRESET (Win32), use EIO instead.
+
+ * camel-nntp-utils.c: Use g_ascii_strcasecmp() instead of the
+ deprecated g_strcasecmp(). The strings we are comparing are just
+ ASCII anyway, so spell it out that we really do need ASCII
+ casefolding only.
+
2005-08-22 Not Zed
* camel-nntp-stream.c (stream_read): cast print args to int.
Index: camel/providers/nntp/camel-nntp-folder.c
===================================================================
--- camel/providers/nntp/camel-nntp-folder.c (revision 444)
+++ camel/providers/nntp/camel-nntp-folder.c (working copy)
@@ -28,12 +28,10 @@
#include
#include
#include
-#include
-#include
#include
-#include
#include
+#include
#include "camel/camel-file-utils.h"
#include "camel/camel-stream-mem.h"
#include "camel/camel-data-wrapper.h"
@@ -154,7 +152,7 @@
fail:
if (errno == EINTR)
- camel_exception_setv (ex, CAMEL_EXCEPTION_USER_CANCEL, _("User cancelled"));
+ camel_exception_setv (ex, CAMEL_EXCEPTION_USER_CANCEL, _("User canceled"));
else
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot get message %s: %s"), msgid, g_strerror (errno));
@@ -174,7 +172,7 @@
msgid = strchr(article, ',');
if (!msgid) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Internal error: uid in invalid format: %s"), uid);
+ _("Internal error: UID in invalid format: %s"), uid);
return;
}
*msgid++ = 0;
@@ -206,7 +204,7 @@
msgid = strchr (article, ',');
if (msgid == NULL) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Internal error: uid in invalid format: %s"), uid);
+ _("Internal error: UID in invalid format: %s"), uid);
return NULL;
}
*msgid++ = 0;
@@ -230,7 +228,7 @@
message = camel_mime_message_new ();
if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) message, stream) == -1) {
if (errno == EINTR)
- camel_exception_setv (ex, CAMEL_EXCEPTION_USER_CANCEL, _("User cancelled"));
+ camel_exception_setv (ex, CAMEL_EXCEPTION_USER_CANCEL, _("User canceled"));
else
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot get message %s: %s"), uid, g_strerror (errno));
camel_object_unref(message);
@@ -369,7 +367,7 @@
|| camel_stream_write (stream, "\r\n.\r\n", 5) == -1
|| (ret = camel_nntp_stream_line (nntp_store->stream, (unsigned char **)&line, &u)) == -1) {
if (errno == EINTR)
- camel_exception_setv (ex, CAMEL_EXCEPTION_USER_CANCEL, _("User cancelled"));
+ camel_exception_setv (ex, CAMEL_EXCEPTION_USER_CANCEL, _("User canceled"));
else
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Posting failed: %s"), g_strerror (errno));
} else if (atoi(line) != 240) {
@@ -494,7 +492,7 @@
return NULL;
/* If this doesn't work, stuff wont save, but let it continue anyway */
- camel_mkdir (root, 0777);
+ e_util_mkdir_hier (root, 0777);
folder = (CamelFolder *) camel_object_new (CAMEL_NNTP_FOLDER_TYPE);
nntp_folder = (CamelNNTPFolder *)folder;
Index: camel/providers/nntp/camel-nntp-store-summary.c
===================================================================
--- camel/providers/nntp/camel-nntp-store-summary.c (revision 444)
+++ camel/providers/nntp/camel-nntp-store-summary.c (working copy)
@@ -209,7 +209,7 @@
char *
camel_nntp_store_summary_path_to_full (CamelNNTPStoreSummary *s, const char *path, char dir_sep)
{
- unsigned char *full, *f;
+ char *full, *f;
guint32 c, v = 0;
const char *p;
int state=0;
Index: camel/providers/nntp/camel-nntp-grouplist.c
===================================================================
--- camel/providers/nntp/camel-nntp-grouplist.c (revision 444)
+++ camel/providers/nntp/camel-nntp-grouplist.c (working copy)
@@ -25,7 +25,11 @@
#include
#include
-#include "camel-exception.h"
+#include
+#include
+
+#include "camel/camel-exception.h"
+
#include "camel-nntp-grouplist.h"
#include "camel-nntp-resp-codes.h"
@@ -89,7 +93,7 @@
unsigned long time;
g_free (root_dir);
- fp = fopen (grouplist_file, "r");
+ fp = g_fopen (grouplist_file, "r");
g_free (grouplist_file);
if (fp == NULL) {
@@ -149,7 +153,7 @@
gchar *grouplist_file = g_strdup_printf ("%s/grouplist", root_dir);
g_free (root_dir);
- fp = fopen (grouplist_file, "w");
+ fp = g_fopen (grouplist_file, "w");
g_free (grouplist_file);
if (fp == NULL) {
Index: camel/providers/nntp/camel-nntp-provider.c
===================================================================
--- camel/providers/nntp/camel-nntp-provider.c (revision 444)
+++ camel/providers/nntp/camel-nntp-provider.c (working copy)
@@ -37,7 +37,7 @@
static gint check_equal (char *s1, char *s2);
static gint nntp_url_equal (gconstpointer a, gconstpointer b);
-CamelProviderConfEntry nntp_conf_entries[] = {
+static CamelProviderConfEntry nntp_conf_entries[] = {
{ CAMEL_PROVIDER_CONF_SECTION_START, "folders", NULL,
N_("Folders") },
{ CAMEL_PROVIDER_CONF_CHECKBOX, "show_short_notation", NULL,
Index: camel/providers/nntp/camel-nntp-stream.c
===================================================================
--- camel/providers/nntp/camel-nntp-stream.c (revision 444)
+++ camel/providers/nntp/camel-nntp-stream.c (working copy)
@@ -36,6 +36,10 @@
#define dd(x) (camel_debug("nntp:stream")?(x):0)
+#ifndef ECONNRESET
+#define ECONNRESET EIO
+#endif
+
static CamelObjectClass *parent_class = NULL;
/* Returns the class for a CamelStream */
Index: camel/providers/nntp/camel-nntp-store.c
===================================================================
--- camel/providers/nntp/camel-nntp-store.c (revision 444)
+++ camel/providers/nntp/camel-nntp-store.c (working copy)
@@ -30,7 +30,6 @@
#include
#include
#include
-#include
#include
#include
@@ -169,7 +168,6 @@
gboolean retval = FALSE;
unsigned char *buf;
unsigned int len;
- int ret;
char *path;
CAMEL_SERVICE_LOCK(store, connect_lock);
@@ -192,10 +190,10 @@
tcp_stream = camel_tcp_stream_raw_new ();
}
- if ((ret = camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai)) == -1) {
+ if (camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai) == -1) {
if (errno == EINTR)
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("Connection cancelled"));
+ _("Connection canceled"));
else
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("Could not connect to %s: %s"),
@@ -214,7 +212,7 @@
if (camel_nntp_stream_line (store->stream, &buf, &len) == -1) {
if (errno == EINTR)
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("Connection cancelled"));
+ _("Connection canceled"));
else
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("Could not read greeting from %s: %s"),
@@ -562,7 +560,7 @@
}
}
- printf("store info update '%s' first '%d' last '%d'\n", line, first, last);
+ printf("store info update '%s' first '%u' last '%u'\n", line, first, last);
if (si->last) {
if (last > si->last)
@@ -1270,7 +1268,7 @@
ioerror:
if (errno == EINTR)
- camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("Cancelled."));
+ camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("Canceled."));
else
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, _("NNTP Command failed: %s"), g_strerror(errno));
return -1;
Index: camel/providers/nntp/camel-nntp-summary.c
===================================================================
--- camel/providers/nntp/camel-nntp-summary.c (revision 444)
+++ camel/providers/nntp/camel-nntp-summary.c (working copy)
@@ -150,7 +150,8 @@
mi = (CamelMessageInfoBase *)((CamelFolderSummaryClass *)camel_nntp_summary_parent)->message_info_new_from_header(s, h);
if (mi) {
- mi->uid = g_strdup(cns->priv->uid);
+ g_free(mi->uid);
+ mi->uid = cns->priv->uid;
cns->priv->uid = NULL;
}
@@ -161,18 +162,23 @@
summary_header_load(CamelFolderSummary *s, FILE *in)
{
CamelNNTPSummary *cns = CAMEL_NNTP_SUMMARY(s);
+ gint32 *ptr32 = s->filepos;
+ unsigned char *ptrchr = s->filepos;
if (((CamelFolderSummaryClass *)camel_nntp_summary_parent)->summary_header_load(s, in) == -1)
return -1;
/* Legacy version */
if (s->version == 0x20c) {
- camel_file_util_decode_fixed_int32(in, &cns->high);
- return camel_file_util_decode_fixed_int32(in, &cns->low);
+ cns->high = g_ntohl (*ptr32); ptr32++;
+ cns->low = g_ntohl (*ptr32); ptr32++;
+ s->filepos = ptr32;
+
+ return 0;
}
- if (camel_file_util_decode_fixed_int32(in, &cns->version) == -1)
- return -1;
+ cns->version = g_ntohl (*ptr32); ptr32++;
+ s->filepos = ptr32;
if (cns->version > CAMEL_NNTP_SUMMARY_VERSION) {
g_warning("Unknown NNTP summary version");
@@ -180,10 +186,11 @@
return -1;
}
- if (camel_file_util_decode_fixed_int32(in, &cns->high) == -1
- || camel_file_util_decode_fixed_int32(in, &cns->low) == -1)
- return -1;
+ cns->high = g_ntohl (*ptr32); ptr32++;
+ cns->low = g_ntohl (*ptr32); ptr32++;
+ s->filepos = ptr32;
+
return 0;
}
@@ -303,9 +310,9 @@
add_range_head(CamelNNTPSummary *cns, CamelNNTPStore *store, unsigned int high, unsigned int low, CamelFolderChangeInfo *changes, CamelException *ex)
{
CamelFolderSummary *s;
- int i, ret = -1;
+ int ret = -1;
char *line, *msgid;
- unsigned int n, count, total;
+ unsigned int i, n, count, total;
CamelMessageInfo *mi;
CamelMimeParser *mp;
@@ -333,7 +340,7 @@
line += 3;
n = strtoul(line, &line, 10);
if (n != i)
- g_warning("retrieved message '%d' when i expected '%d'?\n", n, i);
+ g_warning("retrieved message '%u' when i expected '%u'?\n", n, i);
/* FIXME: use camel-mime-utils.c function for parsing msgid? */
if ((msgid = strchr(line, '<')) && (line = strchr(msgid+1, '>'))){
Index: camel/providers/nntp/camel-nntp-utils.c
===================================================================
--- camel/providers/nntp/camel-nntp-utils.c (revision 444)
+++ camel/providers/nntp/camel-nntp-utils.c (working copy)
@@ -185,17 +185,17 @@
for (h = 0; h < header_array->len; h ++) {
Rfc822Header *header = &((Rfc822Header*)header_array->data)[h];
- if (!g_strcasecmp(header->name, "From"))
+ if (!g_ascii_strcasecmp(header->name, "From"))
new_info->from = g_strdup(header->value);
- else if (!g_strcasecmp(header->name, "To"))
+ else if (!g_ascii_strcasecmp(header->name, "To"))
new_info->to = g_strdup(header->value);
- else if (!g_strcasecmp(header->name, "Subject"))
+ else if (!g_ascii_strcasecmp(header->name, "Subject"))
new_info->subject = g_strdup(header->value);
- else if (!g_strcasecmp(header->name, "Message-ID")) {
+ else if (!g_ascii_strcasecmp(header->name, "Message-ID")) {
new_info->uid = g_strdup_printf("%d,%s", i, header->value);
new_info->message_id = g_strdup(header->value);
}
- else if (!g_strcasecmp(header->name, "Date")) {
+ else if (!g_ascii_strcasecmp(header->name, "Date")) {
new_info->date_sent = camel_header_decode_date (header->value);
#if 0
new_info->date_sent = g_strdup(header->value);
Index: camel/providers/nntp/camel-nntp-newsrc.c
===================================================================
--- camel/providers/nntp/camel-nntp-newsrc.c (revision 444)
+++ camel/providers/nntp/camel-nntp-newsrc.c (working copy)
@@ -20,13 +20,8 @@
*
*/
-
-#ifdef HAVE_CONFIG_H
#include
-#endif
-#include
-
#include
#include
#include
@@ -35,8 +30,12 @@
#include
#include
+#include
+#include
+
+#include "camel/camel-folder-summary.h"
+
#include "camel-nntp-newsrc.h"
-#include
#define NEWSRC_LOCK(f, l) (g_mutex_lock(((CamelNNTPNewsrc *)f)->l))
#define NEWSRC_UNLOCK(f, l) (g_mutex_unlock(((CamelNNTPNewsrc *)f)->l))
@@ -485,7 +484,7 @@
return;
}
- if ((fp = fopen(newsrc->filename, "w")) == NULL) {
+ if ((fp = g_fopen(newsrc->filename, "w")) == NULL) {
g_warning ("Couldn't open newsrc file '%s'.\n", newsrc->filename);
NEWSRC_UNLOCK(newsrc, lock);
return;
@@ -614,7 +613,7 @@
newsrc->groups = g_hash_table_new (g_str_hash, g_str_equal);
newsrc->lock = g_mutex_new();
- if ((fd = open(filename, O_RDONLY)) == -1) {
+ if ((fd = g_open(filename, O_RDONLY, 0)) == -1) {
g_warning ("~/.newsrc-%s not present.\n", server);
return newsrc;
}
Index: camel/providers/pop3/camel-pop3-engine.c
===================================================================
--- camel/providers/pop3/camel-pop3-engine.c (revision 444)
+++ camel/providers/pop3/camel-pop3-engine.c (working copy)
@@ -74,6 +74,10 @@
if (pe->stream)
camel_object_unref(pe->stream);
+
+ g_list_free(pe->auth);
+ if (pe->apop)
+ g_free(pe->apop);
}
CamelType
@@ -170,7 +174,7 @@
/* TODO: read implementation too?
etc? */
-struct {
+static struct {
char *cap;
guint32 flag;
} capa[] = {
Index: camel/providers/pop3/ChangeLog
===================================================================
--- camel/providers/pop3/ChangeLog (revision 444)
+++ camel/providers/pop3/ChangeLog (working copy)
@@ -1,3 +1,41 @@
+2006-06-15 Andre Klapper
+
+ * camel-pop3-store.c:
+ * camel-pop3-folder.c:
+ changing "cancelled" to "canceled" in user-visible strings.
+ Fixes bug #342163.
+
+2006-06-15 Andre Klapper
+
+ * addressbook/libebook/e-book.c:
+ * camel/camel-folder.c:
+ * camel/providers/nntp/camel-nntp-folder.c:
+ * camel/providers/pop3/camel-pop3-folder.c:
+ changing "uri" to "URI" in user-visible strings.
+ Fixes bug #342161.
+
+2006-06-09 Chris Heath
+
+ * camel-pop3-engine.c (camel_pop3_engine_finalise): Fix memory leak.
+ Fixes bug #335423.
+
+2006-05-31 Jeffrey Stedfast
+
+ * camel-pop3-store.c (connect_to_server): Fix a few of the TLS
+ error strings to be more informative. Fixes the confusion in bug
+ #342001.
+
+2006-04-21 Jeffrey Stedfast
+
+ * camel-pop3-store.c (connect_to_server_wrapper): Don't do
+ fallback for SSL/TLS. Fixes bug #321797.
+
+2005-09-16 Tor Lillqvist
+
+ * camel-pop3-folder.c: Use g_ascii_strcasecmp() instead of
+ strcasecmp(). The strings we are comparing are just ASCII anyway,
+ so spell it out that we really do need ASCII casefolding only.
+
2005-08-22 Not Zed
* camel-pop3-stream.c: fix some debug printfs to use
Index: camel/providers/pop3/camel-pop3-provider.c
===================================================================
--- camel/providers/pop3/camel-pop3-provider.c (revision 444)
+++ camel/providers/pop3/camel-pop3-provider.c (working copy)
@@ -34,7 +34,8 @@
#include "camel-sasl.h"
#include "camel-i18n.h"
-CamelProviderConfEntry pop3_conf_entries[] = {
+
+static CamelProviderConfEntry pop3_conf_entries[] = {
{ CAMEL_PROVIDER_CONF_SECTION_START, "storage", NULL,
N_("Message storage") },
{ CAMEL_PROVIDER_CONF_CHECKBOX, "keep_on_server", NULL,
Index: camel/providers/pop3/camel-pop3-folder.c
===================================================================
--- camel/providers/pop3/camel-pop3-folder.c (revision 444)
+++ camel/providers/pop3/camel-pop3-folder.c (working copy)
@@ -162,8 +162,8 @@
case CAMEL_MIME_PARSER_STATE_MULTIPART:
h = camel_mime_parser_headers_raw(mp);
while (h) {
- if (strcasecmp(h->name, "status") != 0
- && strcasecmp(h->name, "x-status") != 0) {
+ if (g_ascii_strcasecmp(h->name, "status") != 0
+ && g_ascii_strcasecmp(h->name, "x-status") != 0) {
md5_update(&md5, h->name, strlen(h->name));
md5_update(&md5, h->value, strlen(h->value));
}
@@ -260,7 +260,7 @@
if (i == -1) {
if (errno == EINTR)
- camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("User cancelled"));
+ camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("User canceled"));
else
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot get POP summary: %s"),
@@ -396,13 +396,13 @@
CamelPOP3Command *pcr;
CamelPOP3FolderInfo *fi;
char buffer[1];
- int ok, i, last;
+ int i, last;
CamelStream *stream = NULL;
fi = g_hash_table_lookup(pop3_folder->uids_uid, uid);
if (fi == NULL) {
camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- _("No message with uid %s"), uid);
+ _("No message with UID %s"), uid);
return NULL;
}
@@ -422,13 +422,13 @@
fi->err = errno;
/* getting error code? */
- ok = fi->cmd->state == CAMEL_POP3_COMMAND_DATA;
+ /*g_assert (fi->cmd->state == CAMEL_POP3_COMMAND_DATA);*/
camel_pop3_engine_command_free(pop3_store->engine, fi->cmd);
fi->cmd = NULL;
if (fi->err != 0) {
if (fi->err == EINTR)
- camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("User cancelled"));
+ camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("User canceled"));
else
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot get message %s: %s"),
@@ -482,14 +482,14 @@
fi->err = errno;
/* getting error code? */
- ok = pcr->state == CAMEL_POP3_COMMAND_DATA;
+ /*g_assert (pcr->state == CAMEL_POP3_COMMAND_DATA);*/
camel_pop3_engine_command_free(pop3_store->engine, pcr);
camel_stream_reset(stream);
/* Check to see we have safely written flag set */
if (fi->err != 0) {
if (fi->err == EINTR)
- camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("User cancelled"));
+ camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("User canceled"));
else
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot get message %s: %s"),
@@ -507,7 +507,7 @@
message = camel_mime_message_new ();
if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)message, stream) == -1) {
if (errno == EINTR)
- camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("User cancelled"));
+ camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("User canceled"));
else
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot get message %s: %s"),
Index: camel/providers/pop3/camel-pop3-store.c
===================================================================
--- camel/providers/pop3/camel-pop3-store.c (revision 444)
+++ camel/providers/pop3/camel-pop3-store.c (working copy)
@@ -176,7 +176,7 @@
if ((ret = camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai)) == -1) {
if (errno == EINTR)
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("Connection cancelled"));
+ _("Connection canceled"));
else
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("Could not connect to %s: %s"),
@@ -214,7 +214,7 @@
if (!(store->engine->capa & CAMEL_POP3_CAP_STLS)) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to connect to POP server %s in secure mode: %s"),
- service->url->host, _("STLS not supported"));
+ service->url->host, _("STLS not supported by server"));
goto stls_exception;
}
@@ -241,13 +241,13 @@
if (ret == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to connect to POP server %s in secure mode: %s"),
- service->url->host, _("SSL negotiations failed"));
+ service->url->host, _("TLS negotiations failed"));
goto stls_exception;
}
#else
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to connect to POP server %s in secure mode: %s"),
- service->url->host, _("SSL is not available in this build"));
+ service->url->host, _("TLS is not available in this build"));
goto stls_exception;
#endif /* HAVE_SSL */
@@ -324,16 +324,11 @@
camel_exception_clear (ex);
ai = camel_getaddrinfo(service->url->host, port, &hints, ex);
}
+
if (ai == NULL)
return FALSE;
- if (!(ret = connect_to_server (service, ai, mode, ex)) && mode == MODE_SSL) {
- camel_exception_clear (ex);
- ret = connect_to_server (service, ai, MODE_TLS, ex);
- } else if (!ret && mode == MODE_TLS) {
- camel_exception_clear (ex);
- ret = connect_to_server (service, ai, MODE_CLEAR, ex);
- }
+ ret = connect_to_server (service, ai, mode, ex);
camel_freeaddrinfo (ai);
@@ -443,7 +438,7 @@
ioerror:
if (errno == EINTR) {
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Cancelled"));
+ camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Canceled"));
} else {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to authenticate on POP server %s: %s"),
@@ -524,7 +519,7 @@
if (status == -1) {
if (errno == EINTR) {
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Cancelled"));
+ camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Canceled"));
} else {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Unable to connect to POP server %s.\n"
Index: camel/providers/smtp/ChangeLog
===================================================================
--- camel/providers/smtp/ChangeLog (revision 444)
+++ camel/providers/smtp/ChangeLog (working copy)
@@ -1,3 +1,29 @@
+2006-06-15 Andre Klapper
+
+ * camel-smtp-transport.c:
+ changing "cancelled" to "canceled" in user-visible strings.
+ Fixes bug #342163.
+
+2006-05-10 Jeffrey Stedfast
+
+ * camel-smtp-transport.c (smtp_helo): Implement the correct fix.
+
+2006-05-09 Jeffrey Stedfast
+
+ * camel-smtp-transport.c (smtp_helo): Reverted. David Woodhouse
+ can fix his own damn server since he configured it to be broken.
+
+2006-04-21 Jeffrey Stedfast
+
+ * camel-smtp-transport.c (connect_to_server_wrapper): Don't do
+ fallback for SSL/TLS. Fixes bug #321797.
+
+2006-04-18 Jeffrey Stedfast
+
+ * camel-smtp-transport.c (smtp_helo): If the hostname isn't valid
+ (contains invalid chars, etc), then fallback to numeric host
+ address. Fixes bug #336035. Based on a patch by David Woodhouse.
+
2005-08-12 Tor Lillqvist
* Makefile.am: Use NO_UNDEFINED. Link with libcamel-provider,
Index: camel/providers/smtp/camel-smtp-transport.c
===================================================================
--- camel/providers/smtp/camel-smtp-transport.c (revision 444)
+++ camel/providers/smtp/camel-smtp-transport.c (working copy)
@@ -263,7 +263,7 @@
if ((ret = camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai)) == -1) {
if (errno == EINTR)
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("Connection cancelled"));
+ _("Connection canceled"));
else
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("Could not connect to %s: %s"),
@@ -431,16 +431,11 @@
camel_exception_clear (ex);
ai = camel_getaddrinfo(service->url->host, port, &hints, ex);
}
+
if (ai == NULL)
return FALSE;
- if (!(ret = connect_to_server (service, ai, mode, ex)) && mode == MODE_SSL) {
- camel_exception_clear (ex);
- ret = connect_to_server (service, ai, MODE_TLS, ex);
- } else if (!ret && mode == MODE_TLS) {
- camel_exception_clear (ex);
- ret = connect_to_server (service, ai, MODE_CLEAR, ex);
- }
+ ret = connect_to_server (service, ai, mode, ex);
camel_freeaddrinfo (ai);
@@ -875,9 +870,10 @@
static gboolean
smtp_helo (CamelSmtpTransport *transport, CamelException *ex)
{
- /* say hello to the server */
char *name = NULL, *cmdbuf = NULL, *respbuf = NULL;
const char *token, *numeric = NULL;
+ struct sockaddr *addr;
+ socklen_t addrlen;
/* these are flags that we set, so unset them in case we
are being called a second time (ie, after a STARTTLS) */
@@ -892,20 +888,19 @@
}
camel_operation_start_transient (NULL, _("SMTP Greeting"));
-
- /* force name resolution first, fallback to numerical, we need to know when it falls back */
- if (camel_getnameinfo(transport->localaddr, transport->localaddrlen, &name, NULL, NI_NAMEREQD, NULL) != 0) {
- if (camel_getnameinfo(transport->localaddr, transport->localaddrlen, &name, NULL, NI_NUMERICHOST, NULL) != 0)
- name = g_strdup("localhost.localdomain");
- else {
- if (transport->localaddr->sa_family == AF_INET6)
- numeric = "IPv6:";
- else
- numeric = "";
- }
+
+ addr = transport->localaddr;
+ addrlen = transport->localaddrlen;
+
+ if (camel_getnameinfo (addr, addrlen, &name, NULL, NI_NUMERICHOST, NULL) != 0) {
+ name = g_strdup ("localhost.localdomain");
+ } else {
+ if (addr->sa_family == AF_INET6)
+ numeric = "IPv6:";
+ else
+ numeric = "";
}
- /* hiya server! how are you today? */
token = (transport->flags & CAMEL_SMTP_TRANSPORT_IS_ESMTP) ? "EHLO" : "HELO";
if (numeric)
cmdbuf = g_strdup_printf("%s [%s%s]\r\n", token, numeric, name);
Index: camel/providers/groupwise/camel-groupwise-summary.c
===================================================================
--- camel/providers/groupwise/camel-groupwise-summary.c (revision 444)
+++ camel/providers/groupwise/camel-groupwise-summary.c (working copy)
@@ -34,8 +34,10 @@
#include
#include "camel-groupwise-summary.h"
+#include "camel-groupwise-folder.h"
#include "camel-file-utils.h"
#include
+#include
#define CAMEL_GW_SUMMARY_VERSION (1)
@@ -154,16 +156,23 @@
gw_summary_header_load (CamelFolderSummary *s, FILE *in)
{
CamelGroupwiseSummary *ims = CAMEL_GROUPWISE_SUMMARY (s);
+ gint32 *ptr32 = s->filepos;
+ unsigned char *ptrchr;
+ gint len;
if (camel_groupwise_summary_parent->summary_header_load (s, in) == -1)
return -1 ;
- if (camel_file_util_decode_fixed_int32(in, &ims->version) == -1
- || camel_file_util_decode_fixed_int32(in, &ims->validity) == -1)
- return -1;
-
- if (camel_file_util_decode_string (in, &ims->time_string) == -1)
- return -1;
+ ims->version = g_ntohl (*ptr32); ptr32++;
+ ims->validity = g_ntohl (*ptr32); ptr32++;
+ ptrchr = (unsigned char*)ptr32;
+
+ ptrchr = camel_file_util_mmap_decode_uint32 (ptrchr, &len, TRUE);
+ if (len) ims->time_string = (const char*)ptrchr;
+ ptrchr += len;
+
+ s->filepos = ptrchr;
+
return 0 ;
}
@@ -189,18 +198,16 @@
CamelMessageInfo *info ;
CamelGroupwiseMessageInfo *gw_info ;
-
info = camel_groupwise_summary_parent->message_info_load(s,in) ;
if (info) {
+ unsigned char *ptrchr = s->filepos;
gw_info = (CamelGroupwiseMessageInfo*) info ;
- if (camel_file_util_decode_uint32 (in, &gw_info->server_flags) == -1)
- goto error ;
+
+ ptrchr = camel_file_util_mmap_decode_uint32 (ptrchr, &gw_info->server_flags, FALSE);
+ s->filepos = ptrchr;
}
return info ;
-error:
- camel_message_info_free (info) ;
- return NULL ;
}
@@ -307,6 +314,7 @@
mi->info.size = camel_message_info_size(info);
mi->info.uid = g_strdup (uid);
+ mi->info.uid_needs_free = TRUE;
camel_folder_summary_add (summary, (CamelMessageInfo *)mi);
@@ -319,6 +327,39 @@
mi = camel_message_info_clone(info);
mi->info.uid = g_strdup(uid);
+ mi->info.uid_needs_free = TRUE;
+
camel_folder_summary_add (summary, (CamelMessageInfo *)mi);
}
+void
+groupwise_summary_clear (CamelFolderSummary *summary, gboolean uncache)
+{
+ CamelFolderChangeInfo *changes;
+ CamelMessageInfo *info;
+ int i, count;
+ const char *uid;
+
+ changes = camel_folder_change_info_new ();
+ count = camel_folder_summary_count (summary);
+ for (i = 0; i < count; i++) {
+ if (!(info = camel_folder_summary_index (summary, i)))
+ continue;
+
+ uid = camel_message_info_uid (info);
+ camel_folder_change_info_remove_uid (changes, uid);
+ camel_folder_summary_remove_uid (summary, uid);
+ camel_message_info_free(info);
+ }
+
+ camel_folder_summary_clear (summary);
+ camel_folder_summary_save (summary);
+
+ if (uncache)
+ camel_data_cache_clear (((CamelGroupwiseFolder *) summary->folder)->cache, "cache", NULL);
+
+ if (camel_folder_change_info_changed (changes))
+ camel_object_trigger_event (summary->folder, "folder_changed", changes);
+ camel_folder_change_info_free (changes);
+}
+
Index: camel/providers/groupwise/camel-groupwise-utils.c
===================================================================
--- camel/providers/groupwise/camel-groupwise-utils.c (revision 444)
+++ camel/providers/groupwise/camel-groupwise-utils.c (working copy)
@@ -21,24 +21,30 @@
#include
#include
-#include
#include
#include
#include
+
#include
+#include
+
#include
+
+#include "camel/camel-address.h"
+#include "camel/camel-mime-message.h"
+#include "camel/camel-multipart.h"
+#include "camel/camel-service.h"
+#include "camel/camel-stream-mem.h"
+#include "camel/camel-stream-filter.h"
+#include "camel/camel-mime-filter-charset.h"
+
#include "camel-groupwise-utils.h"
-#include
-#include
-#include
-#include
-#include
-
#define SUBFOLDER_DIR_NAME "subfolders"
#define SUBFOLDER_DIR_NAME_LEN 10
#define RFC_822 "message/rfc822"
+static void do_multipart (EGwConnection *cnc, EGwItem *item, CamelMultipart *mp, GSList **attach_list);
/**
* e_path_to_physical:
* @prefix: a prefix to prepend to the path, or %NULL
@@ -134,7 +140,7 @@
find_folders_recursive (const char *physical_path, const char *path,
EPathFindFoldersCallback callback, gpointer data)
{
- DIR *dir;
+ GDir *dir;
char *subfolder_directory_path;
gboolean ok;
@@ -152,7 +158,7 @@
}
/* Now scan the subfolders and load them. */
- dir = opendir (subfolder_directory_path);
+ dir = g_dir_open (subfolder_directory_path, 0, NULL);
if (dir == NULL) {
g_free (subfolder_directory_path);
return TRUE;
@@ -161,27 +167,23 @@
ok = TRUE;
while (ok) {
struct stat file_stat;
- struct dirent *dirent;
+ const char *dirent;
char *file_path;
char *new_path;
- dirent = readdir (dir);
+ dirent = g_dir_read_name (dir);
if (dirent == NULL)
break;
- if (strcmp (dirent->d_name, ".") == 0 || strcmp (dirent->d_name, "..") == 0)
- continue;
+ file_path = g_strdup_printf ("%s/%s", subfolder_directory_path, dirent);
- file_path = g_strdup_printf ("%s/%s", subfolder_directory_path,
- dirent->d_name);
-
- if (stat (file_path, &file_stat) < 0 ||
+ if (g_stat (file_path, &file_stat) < 0 ||
! S_ISDIR (file_stat.st_mode)) {
g_free (file_path);
continue;
}
- new_path = g_strdup_printf ("%s/%s", path, dirent->d_name);
+ new_path = g_strdup_printf ("%s/%s", path, dirent);
ok = find_folders_recursive (file_path, new_path, callback, data);
@@ -189,7 +191,7 @@
g_free (new_path);
}
- closedir (dir);
+ g_dir_close (dir);
g_free (subfolder_directory_path);
return ok;
@@ -235,7 +237,7 @@
/* Remove the directory itself */
physical_path = e_path_to_physical (prefix, vpath);
- if (rmdir (physical_path) == -1) {
+ if (g_rmdir (physical_path) == -1) {
g_free (physical_path);
return -1;
}
@@ -256,12 +258,12 @@
return 0;
}
- rmdir (physical_path);
+ g_rmdir (physical_path);
g_free (physical_path);
return 0;
}
-GSList *
+static GSList *
add_recipients(GSList *recipient_list, CamelAddress *recipients, int recipient_type)
{
int total_add,i;
@@ -278,31 +280,31 @@
recipient->display_name = g_strdup (name);
recipient->type = recipient_type;
recipient->status = E_GW_ITEM_STAT_NONE;
- recipient_list= g_slist_append (recipient_list, recipient);
+ recipient_list = g_slist_prepend (recipient_list, recipient);
}
}
return recipient_list;
}
static void
-send_as_attachment (EGwConnection *cnc, EGwItem *item, CamelStreamMem *content, char *buffer, CamelContentType *type, CamelDataWrapper *dw, const char *filename, GSList **attach_list)
+send_as_attachment (EGwConnection *cnc, EGwItem *item, CamelStreamMem *content, CamelContentType *type, CamelDataWrapper *dw, const char *filename, const char *cid, GSList **attach_list)
{
EGwItemLinkInfo *info = NULL;
EGwConnectionStatus status;
EGwItemAttachment *attachment;
EGwItem *temp_item;
-
- int len;
- len = content->buffer->len;
-
+
attachment = g_new0 (EGwItemAttachment, 1);
- attachment->contentType = g_strdup_printf ("%s/%s", type->type, type->subtype);
-
+ attachment->contentType = camel_content_type_simple (type);
+
+ if (cid)
+ attachment->contentid = camel_header_contentid_decode (cid);
+
if (filename) {
- if (!strcmp (attachment->contentType, "application/pgp-signature")) {
+ if (camel_content_type_is (type, "application", "pgp-signature")) {
char *temp_str;
int temp_len;
- temp_str = soup_base64_encode (buffer, len);
+ temp_str = soup_base64_encode (content->buffer->data, content->buffer->len);
temp_len = strlen (temp_str);
attachment->data = g_strdup (temp_str);
attachment->size = temp_len;
@@ -310,45 +312,59 @@
temp_str = NULL;
temp_len = 0;
} else {
- attachment->data = g_malloc0 (content->buffer->len+1);
- attachment->data = memcpy (attachment->data,
- content->buffer->data,
- content->buffer->len);
- attachment->size = content->buffer->len;
+ attachment->data = soup_base64_encode(content->buffer->data, content->buffer->len);
+ attachment->size = strlen (attachment->data);
}
} else {
char *temp_str;
int temp_len;
- temp_str = soup_base64_encode (buffer, len);
- temp_len = strlen (temp_str);
- attachment->data = g_strdup (temp_str);
- attachment->size = temp_len;
- g_free (temp_str);
- temp_str = NULL;
- temp_len = 0;
+ if (!strcmp (attachment->contentType, "multipart/digest")) {
+ /* FIXME? */
+ } else {
+ temp_str = soup_base64_encode (content->buffer->data, content->buffer->len);
+ temp_len = strlen (temp_str);
+ attachment->data = g_strdup (temp_str);
+ attachment->size = temp_len;
+ g_free (temp_str);
+ temp_str = NULL;
+ temp_len = 0;
+ }
}
- if (!strcmp (attachment->contentType, "text/html") || !(strcmp (attachment->contentType, "multipart/alternative"))) {
- filename = "text.htm";
- if (!(strcmp (attachment->contentType, "multipart/alternative"))) {
+ if (camel_content_type_is (type, "text", "html") || camel_content_type_is (type, "multipart", "alternative")) {
+ if (!filename)
+ filename = "text.htm";
+ if (camel_content_type_is (type, "multipart", "alternative")) {
+ /* FIXME: this just feels so wrong... */
g_free (attachment->contentType);
attachment->contentType = g_strdup ("text/html");
}
}
attachment->name = g_strdup (filename ? filename : "");
- if (!g_ascii_strncasecmp (attachment->contentType, RFC_822, strlen (RFC_822))) {
- char *temp_id = NULL, *id = NULL;
- temp_id = (char *)camel_medium_get_header (CAMEL_MEDIUM ((CamelMimeMessage *)dw), "Message-Id");
- int len = strlen (temp_id);
+ if (camel_content_type_is (type, "message", "rfc822")) {
+ const char *message_id;
+ char *msgid;
+ int len;
+
+ message_id = camel_medium_get_header (CAMEL_MEDIUM (dw), "Message-Id");
+ /*
+ * XXX: The following code piece is a screwed up way of doing stuff.
+ * But we dont have much choice. Do not use 'camel_header_msgid_decode'
+ * since it removes the container id portion from the id and which the
+ * groupwise server needs.
+ */
+
+ len = strlen (message_id);
+ msgid = (char *)g_malloc0 (len-1);
+ msgid = memcpy(msgid, message_id+2, len-3);
- id = (char *)g_malloc0 (len-1);
- id = memcpy(id, temp_id+2, len-3);
-
- status = e_gw_connection_forward_item (cnc, id, "message", TRUE, &temp_item);
- if (status != E_GW_CONNECTION_STATUS_OK)
+ status = e_gw_connection_forward_item (cnc, msgid, NULL, TRUE, &temp_item);
+ g_free (msgid);
+
+ if (status != E_GW_CONNECTION_STATUS_OK) {
g_warning ("Could not send a forwardRequest...continuing without!!\n");
- else {
+ } else {
GSList *attach_list = e_gw_item_get_attach_id_list (temp_item);
EGwItemAttachment *temp_attach = (EGwItemAttachment *)attach_list->data;
attachment->id = g_strdup (temp_attach->id);
@@ -363,41 +379,36 @@
info = e_gw_item_get_link_info (temp_item);
e_gw_item_set_link_info (item, info);
}
- g_free (id);
}
*attach_list = g_slist_append (*attach_list, attachment);
}
EGwItem *
-camel_groupwise_util_item_from_message (EGwConnection *cnc, CamelMimeMessage *message, CamelAddress *from, CamelAddress *recipients)
+camel_groupwise_util_item_from_message (EGwConnection *cnc, CamelMimeMessage *message, CamelAddress *from)
{
EGwItem *item;
EGwItemOrganizer *org = g_new0 (EGwItemOrganizer, 1);
-
const char *display_name = NULL, *email = NULL;
char *send_options = NULL;
CamelMultipart *mp;
- GSList *recipient_list = NULL, *attach_list = NULL;
- int i;
+ GSList *recipient_list = NULL, *attach_list = NULL;
+ CamelAddress *recipients;
/*Egroupwise item*/
item = e_gw_item_new_empty ();
/*populate recipient list*/
- camel_address_remove(recipients,-1);
- camel_address_cat (recipients, CAMEL_ADDRESS (camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO)));
+ recipients = CAMEL_ADDRESS (camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO));
recipient_list=add_recipients(recipient_list,recipients,E_GW_ITEM_RECIPIENT_TO);
-
- camel_address_remove(recipients,-1);
- camel_address_cat (recipients, CAMEL_ADDRESS (camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC)));
+
+ recipients = CAMEL_ADDRESS (camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC));
recipient_list=add_recipients(recipient_list,recipients,E_GW_ITEM_RECIPIENT_CC);
- camel_address_remove(recipients,-1);
- camel_address_cat (recipients, CAMEL_ADDRESS (camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_BCC)));
+ recipients = CAMEL_ADDRESS (camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_BCC));
recipient_list=add_recipients(recipient_list,recipients,E_GW_ITEM_RECIPIENT_BC);
-
-
+ recipient_list = g_slist_reverse (recipient_list);
+
/** Get the mime parts from CamelMimemessge **/
mp = (CamelMultipart *)camel_medium_get_content_object (CAMEL_MEDIUM (message));
if(!mp) {
@@ -408,92 +419,49 @@
if (CAMEL_IS_MULTIPART (mp)) {
/*contains multiple parts*/
- guint part_count;
-
- part_count = camel_multipart_get_number (mp);
- for ( i=0 ; isubtype && !strcmp (type->subtype, "alternative")) {
- CamelMimePart *temp_part;
- CamelStreamMem *temp_content = (CamelStreamMem *)camel_stream_mem_new ();
- temp_part = camel_multipart_get_part ((CamelMultipart *)dw, 1);
- CamelDataWrapper *temp_dw = camel_data_wrapper_new ();
- if (temp_part) {
- is_alternative = TRUE;
- temp_dw = camel_medium_get_content_object (CAMEL_MEDIUM (temp_part));
- camel_data_wrapper_write_to_stream(temp_dw, (CamelStream *)temp_content);
- buffer = g_malloc0 (temp_content->buffer->len+1);
- buffer = memcpy (buffer, temp_content->buffer->data, temp_content->buffer->len);
- filename = camel_mime_part_get_filename (temp_part);
- disposition = camel_mime_part_get_disposition (temp_part);
- mime_type = camel_data_wrapper_get_mime_type (temp_dw);
- send_as_attachment (cnc, item, temp_content, buffer, type, temp_dw, filename, &attach_list);
- g_free (buffer);
- g_free (mime_type);
- }
- camel_object_unref (temp_content);
- camel_object_unref (temp_dw);
- camel_object_unref (dw);
- continue;
- }
-
- camel_data_wrapper_write_to_stream(dw, (CamelStream *)content);
- buffer = g_malloc0 (content->buffer->len+1);
- buffer = memcpy (buffer, content->buffer->data, content->buffer->len);
- filename = camel_mime_part_get_filename (part);
- disposition = camel_mime_part_get_disposition (part);
- mime_type = camel_data_wrapper_get_mime_type (dw);
-
- if (i == 0 && !strcmp (mime_type, "text/plain") ) {
- e_gw_item_set_content_type (item, mime_type);
- e_gw_item_set_message (item, buffer);
- } else
- send_as_attachment (cnc, item, content, buffer, type, dw, filename, &attach_list);
-
- g_free (buffer);
- g_free (mime_type);
- camel_object_unref (content);
- camel_object_unref (dw);
- } /*end of for*/
-
+ do_multipart (cnc, item, mp, &attach_list);
} else {
/*only message*/
CamelStreamMem *content = (CamelStreamMem *)camel_stream_mem_new ();
- CamelDataWrapper *dw = camel_data_wrapper_new ();
+ CamelDataWrapper *dw = NULL;
CamelContentType *type;
- char *buffer = NULL;
- char *content_type = NULL;
-
+
dw = camel_medium_get_content_object (CAMEL_MEDIUM (message));
type = camel_mime_part_get_content_type((CamelMimePart *)message);
- content_type = g_strdup_printf ("%s/%s", type->type, type->subtype);
- camel_data_wrapper_write_to_stream(dw, (CamelStream *)content);
- buffer = g_malloc0 (content->buffer->len+1);
- buffer = memcpy (buffer, content->buffer->data, content->buffer->len);
- if (!strcmp(content_type, "text/plain")) {
- e_gw_item_set_content_type (item, content_type);
- e_gw_item_set_message (item, buffer);
- } else
- send_as_attachment (cnc, item, content, buffer, type, dw, NULL, &attach_list);
-
- g_free (buffer);
- g_free (content_type);
+ if (camel_content_type_is (type, "text", "plain")) {
+ CamelStream *filtered_stream;
+ CamelMimeFilter *filter;
+ const char *charset;
+ char *content_type;
+
+ content_type = camel_content_type_simple (type);
+ e_gw_item_set_content_type (item, content_type);
+ g_free (content_type);
+
+ charset = camel_content_type_param (type, "charset");
+ if (charset && g_ascii_strcasecmp (charset, "US-ASCII") && g_ascii_strcasecmp (charset, "UTF-8")) {
+ filter = camel_mime_filter_charset_new_convert (charset, "UTF-8");
+ filtered_stream = camel_stream_filter_new_with_stream ((CamelStream *) content);
+ camel_stream_filter_add ((CamelStreamFilter *) filtered_stream, filter);
+ camel_object_unref (filter);
+ } else {
+ /* US-ASCII or UTF-8 */
+ filtered_stream = (CamelStream *) content;
+ camel_object_ref (content);
+ }
+
+ camel_data_wrapper_decode_to_stream (dw, filtered_stream);
+ camel_stream_flush (filtered_stream);
+ camel_object_unref (filtered_stream);
+
+ camel_stream_write ((CamelStream *) content, "", 1);
+ e_gw_item_set_message (item, (const char *)content->buffer->data);
+ } else {
+ camel_data_wrapper_decode_to_stream (dw, (CamelStream *) content);
+ send_as_attachment (cnc, item, content, type, dw, NULL, NULL, &attach_list);
+ }
+
camel_object_unref (content);
}
/*Populate EGwItem*/
@@ -602,3 +570,108 @@
return g_strdup_printf ("%s%c%s", prefix, '/', suffix);
}
+void
+strip_lt_gt (char **string, int s_offset, int e_offset)
+{
+ char *temp = NULL;
+ int len;
+
+ temp = g_strdup (*string);
+ len = strlen (*string);
+
+ *string = (char *)g_malloc0 (len-1);
+ *string = memcpy(*string, temp+s_offset, len-e_offset);
+ g_free (temp);
+}
+
+static void
+do_multipart (EGwConnection *cnc, EGwItem *item, CamelMultipart *mp, GSList **attach_list)
+{
+ /*contains multiple parts*/
+ guint part_count;
+ int i;
+
+ part_count = camel_multipart_get_number (mp);
+ for ( i=0 ; isubtype && !strcmp (type->subtype, "alternative")) {
+ /* eh... I don't think this code will ever get hit? */
+ CamelMimePart *temp_part;
+ const char *cid = NULL;
+ CamelStreamMem *temp_content = (CamelStreamMem *)camel_stream_mem_new ();
+ temp_part = camel_multipart_get_part ((CamelMultipart *)dw, 1);
+ CamelDataWrapper *temp_dw = NULL;
+
+ if (temp_part) {
+ is_alternative = TRUE;
+ temp_dw = camel_medium_get_content_object (CAMEL_MEDIUM (temp_part));
+ camel_data_wrapper_write_to_stream(temp_dw, (CamelStream *)temp_content);
+ filename = camel_mime_part_get_filename (temp_part);
+ disposition = camel_mime_part_get_disposition (temp_part);
+ cid = camel_mime_part_get_content_id (temp_part);
+ send_as_attachment (cnc, item, temp_content, type, temp_dw, filename, cid, attach_list);
+ }
+ camel_object_unref (temp_content);
+ continue;
+ }
+
+ if (i == 0 && camel_content_type_is (type, "text", "plain")) {
+ CamelStream *filtered_stream;
+ CamelMimeFilter *filter;
+ const char *charset;
+ char *content_type;
+
+ content_type = camel_content_type_simple (type);
+ e_gw_item_set_content_type (item, content_type);
+ g_free (content_type);
+
+ charset = camel_content_type_param (type, "charset");
+ if (charset && g_ascii_strcasecmp (charset, "US-ASCII") && g_ascii_strcasecmp (charset, "UTF-8")) {
+ filter = camel_mime_filter_charset_new_convert (charset, "UTF-8");
+ filtered_stream = camel_stream_filter_new_with_stream ((CamelStream *) content);
+ camel_stream_filter_add ((CamelStreamFilter *) filtered_stream, filter);
+ camel_object_unref (filter);
+ } else {
+ /* US-ASCII or UTF-8 */
+ filtered_stream = (CamelStream *) content;
+ camel_object_ref (content);
+ }
+
+ camel_data_wrapper_decode_to_stream (dw, filtered_stream);
+ camel_stream_flush (filtered_stream);
+ camel_object_unref (filtered_stream);
+
+ camel_stream_write ((CamelStream *) content, "", 1);
+ e_gw_item_set_message (item, (const char *)content->buffer->data);
+ } else {
+ filename = camel_mime_part_get_filename (part);
+ disposition = camel_mime_part_get_disposition (part);
+ content_id = camel_mime_part_get_content_id (part);
+
+ camel_data_wrapper_decode_to_stream (dw, (CamelStream *) content);
+ send_as_attachment (cnc, item, content, type, dw, filename, content_id, attach_list);
+ }
+
+ camel_object_unref (content);
+ } /*end of for*/
+}
Index: camel/providers/groupwise/camel-groupwise-store.h
===================================================================
--- camel/providers/groupwise/camel-groupwise-store.h (revision 444)
+++ camel/providers/groupwise/camel-groupwise-store.h (working copy)
@@ -61,7 +61,7 @@
/* the parameters field is not to be included not. probably for 2.6*/
/*guint32 parameters;*/
time_t refresh_stamp;
- guint list_loaded:1;
+ guint list_loaded;
};
@@ -82,6 +82,7 @@
const char *groupwise_base_url_lookup (CamelGroupwiseStorePrivate *priv);
CamelFolderInfo * create_junk_folder (CamelStore *store);
gboolean camel_groupwise_store_connected (CamelGroupwiseStore *store, CamelException *ex);
+void gw_store_reload_folder (CamelGroupwiseStore *store, CamelFolder *folder, guint32 flags, CamelException *ex);
#ifdef __cplusplus
}
Index: camel/providers/groupwise/camel-groupwise-summary.h
===================================================================
--- camel/providers/groupwise/camel-groupwise-summary.h (revision 444)
+++ camel/providers/groupwise/camel-groupwise-summary.h (working copy)
@@ -75,4 +75,5 @@
void camel_gw_summary_add_offline (CamelFolderSummary *summary, const char *uid, CamelMimeMessage *messgae, const CamelMessageInfo *info) ;
void camel_gw_summary_add_offline_uncached (CamelFolderSummary *summary, const char *uid, const CamelMessageInfo *info) ;
+void groupwise_summary_clear (CamelFolderSummary *summary, gboolean uncache);
#endif /*_CAMEL_GW_SUMMARY_H*/
Index: camel/providers/groupwise/camel-groupwise-utils.h
===================================================================
--- camel/providers/groupwise/camel-groupwise-utils.h (revision 444)
+++ camel/providers/groupwise/camel-groupwise-utils.h (working copy)
@@ -71,8 +71,9 @@
int e_path_rmdir (const char *prefix, const char *vpath);
-EGwItem *camel_groupwise_util_item_from_message (EGwConnection *cnc, CamelMimeMessage *message, CamelAddress *from, CamelAddress *recipients);
+EGwItem *camel_groupwise_util_item_from_message (EGwConnection *cnc, CamelMimeMessage *message, CamelAddress *from);
+
void do_flags_diff (flags_diff_t *diff, guint32 old, guint32 _new);
-GSList *add_recipients(GSList *recipient_list, CamelAddress *recipients, int recipient_type);
char *gw_concat ( const char *prefix, const char *suffix);
+void strip_lt_gt (char **string, int s_offset, int e_offset);
#endif
Index: camel/providers/groupwise/ChangeLog
===================================================================
--- camel/providers/groupwise/ChangeLog (revision 444)
+++ camel/providers/groupwise/ChangeLog (working copy)
@@ -1,19 +1,417 @@
+2006-07-06 Parthasarathi Susarla
+
+ * camel-groupwise-transport.c: (groupwise_send_to):
+ check if you have a valid transport. For those wierd times
+ when you have everything screwed up
+
+2006-07-05 Parthasarathi Susarla
+
+ * camel-groupwise-utils.c: (camel_groupwise_util_item_from_message):
+ fix compiler warnings
+
+2006-07-05 Parthasarathi Susarla
+
+ ** Fixes bug #165728 on novell bugzilla
+ * camel-groupwise-store.[ch]:
+ (groupwise_store_construct): initialize list loaded to 3
+ (groupwise_get_folder_info): update only once from the server
+ and from then on - just use the cache.
+
+2006-07-05 Parthasarathi Susarla
+
+ ** Fixes bug #165922 on novell bugzilla.
+ * camel-groupwise-folder.[ch]:
+ (groupwise_folder_item_to_msg): use Mime.822 whenever it is available
+
+
+2006-06-15 Andre Klapper
+
+ * camel-groupwise-folder.c:
+ changing "cancelled" to "canceled" in user-visible strings.
+ Fixes bug #342163.
+
+2006-06-13 Andre Klapper
+
+ * camel-groupwise-store.c:
+ changing "couldn't", "can't" and "didn't" to proper
+ English. Fixes bug #342160.
+
+2006-06-13 Parthasarathi Susarla
+
+ Fixes bug #167517 on bnc
+
+ * camel-groupwise-utils.c: (send_as_attachment):
+ revert a part of fejjs patch. We need the message id
+ with the container in it. We cant use the camel_header_msgid_decode
+ method since it would normalise anything after ':'.
+ Henceforth the forwardrequest would get the complete id of the message
+ and the link info is sent correctly.
+
+ * camel-groupwise-store.c:
+ * camel-groupwise-folder.c:
+ (gw_update_cache):
+ (gw_update_summary): use the hasAttachments element to
+ check if a mail has attachments or not.
+
+2006-06-12 Parthasarathi Susarla
+
+ Fixes bug #166265 on bnc
+
+ * camel-groupwise-folder.c: call purgeRequest when
+ deleting on Trash folder
+
+2006-06-09 Sankar P
+
+ * camel-groupwise-folder.c:
+ Fixes the problem of email id appearing twice
+
+2006-06-09 Chris Heath
+
+ * camel-groupwise-journal.c (update_cache): Fix memory leak.
+ Fixes bug #335423.
+
+2006-06-06 Jeffrey Stedfast
+
+ Fixes for Novell bug #173454
+
+ * camel-groupwise-utils.c (add_recipients): Changed to be an
+ internal function.
+ (send_as_attachment): No longer takes 'buffer' nor 'encoding'
+ arguments. Changed the code to use the camel content-id/message-id
+ parsers rather than home-brew blocks of code to do it. Instead of
+ strcmp'ing mime types, use the camel_content_type_is() function
+ which simplifies things a bit.
+ (camel_groupwise_util_item_from_message): No longer takes a
+ recipients list argument as this function extracted that info from
+ the CamelMimeMessage object anyway. Do charset conversion for
+ text/plain parts.
+
+ * camel-groupwise-folder.c (groupwise_append_message): Don't pass
+ to/cc/bcc recpients to camel_groupwise_util_item_from_message() as
+ it no longer takes those arguments.
+
+ * camel-groupwise-transport.c (groupwise_send_to): Same.
+
+2006-05-23 Sankar P
+
+ * camel-groupwise-folder.c: (groupwise_refresh_folder)
+ Uses readCursor on trash so that we get all items
+
+2006-05-17 Sankar P
+
+ * camel-groupwise-folder.c:
+ Notify the user if the Trash is overflowing
+
+2006-04-28 Sankar P
+
+ * camel-groupwise-folder.c:
+ Initialize a pointer to NULL so that we wont
+ have any dangling reference to be freed
+
+2006-04-24 Sankar P
+
+ * camel-groupwise-folder.c:
+ Removes multiple items by a single call instead
+ of deleting one-by-one.
+
+2006-04-22 Sankar P
+
+ * camel-groupwise-store.c: (convert_to_folder_info):
+ No need to get the unread count for Sent Items folder.
+ All will be read by default.
+
+2006-04-20 Parthasarathi Susarla
+
+ ** See bug 167640 on bnc
+ * camel-groupwise-store.c: Add space at the end of a string.
+
+2006-04-20 Sankar P
+
+ * camel-groupwise-summary.c : (groupwise_summary_clear):
+ Removes from summary based on uid instead of info.
+ This will avoid double-free crash of info.
+
+2006-04-18 Sankar P
+
+ * camel-groupwise-folder.c: (groupwise_sync):
+ Corrected an erroneous commit.
+
+2006-04-17 Sankar P
+
+ * camel-groupwise-folder.c: (groupwise_refresh_folder)
+ Sync up the flags before updating the changes.
+
+2006-04-06 Parthasarathi Susarla
+
+ * camel-groupwise-folder.c : (gw_update_cache)
+ Store the flags to the summary so that the markRead doesnot
+ get called every time
+
+2006-04-06 Parthasarathi Susarla
+
+ * camel-groupwise-store.c :
+ Sync up changes before gettting the folder-list
+
+2006-04-03 Sankar P
+
+ * camel-groupwise-folder.c: (update_junk_list)
+ (gw_update_summary)(gw_update_cache):
+ Stores the name as well as the email address so
+ that the (un)junk operations will work.
+
+2006-04-03 Sankar P
+
+ * camel-groupwise-folder.c: (groupwise_refresh_folder):
+ Added code for getting deltas for Proxy accounts,
+ instead of downloading everything everytime.
+
+2006-03-24 Parthasarathi Susarla
+
+ * camel-groupwise-folder.c: (groupwise_item_folder_to_msg):
+ Set content type, so that it does not crash
+
+2006-03-23 Sankar P
+
+ * camel-groupwise-folder.c:
+ (groupwise_refresh_folder):
+ Sync up externally deleted items only on arrival of New items
+
+2006-03-23 Parthasarathi Susarla
+
+ * camel-groupwise-folder.c:
+ (groupwise_sync): removed a double free and a crash
+ (gw_update_cache): Do not clone messageinfo. jus work on
+ the original message info
+ * camel-groupwise-store.c: (groupwise_folders_sync):
+ sync up the current folder whenever the folder list is
+ being refreshed.
+
+2006-03-21 Parthasarathi Susarla
+
+ * camel-groupwise-utils.c: (do_multipart):
+ Remove unrefs which are actually not needed for a Datawrapper got
+ from camel_medium_get_content_object()
+
+2006-03-20 Parthasarathi Susarla
+
+ * camel-groupwise-folder.c:(gw_udpate_cache):
+ Sync up changes made in the server with the local data, mainly
+ the read and unread data.
+
+2006-03-17 Parthasarathi Susarla
+
+ * camel-groupwise-folder.c:
+ (groupwise_folder_item_to_msg): If the message-body/attachment
+ is larger than 1MB, have to get it in chunks(streaming).
+
+2006-03-15 Sankar P
+
+ * camel-groupwise-folder.c:
+ (gw_update_cache) (update_update)
+ (groupwise_refresh_folder) (gw_update_all_items):
+ - Use read_cursor ALL for identifying new messages and
+ avoids getQM for getting new items.
+ - Altered the code which keeps Evolution stay in sync,
+ with the rest of the clients by deleting
+ externally deleted items
+
+2006-03-13 Parthasarathi Susarla
+
+ * Fixes bug 137357 & 156823
+
+ * camel-groupwise-store.c:
+ (groupwise_auth_loop):
+ (groupwise_connect):
+ Ignore Offline status when service status is
+ Disconnected.
+
+2006-03-13 Parthasarathi Susarla
+
+ * Fixes bug 152355
+
+ * camel-groupwise-folder.c:
+ (groupwise_refresh_info): If the summary is corrupt, or is not
+ present, rebuild the summary again.
+ * camel-groupwise-store.[ch]:
+ (gw_store_reload_folder): This method rebuilds the folder summary
+ it the summary is somehow corrupted.
+
+2006-03-11 Sankar P
+
+ * camel-groupwise-folder.c:
+ Changed the way in which UIDs are handled. Reduces a lot of
+ coslty String and List operations. Should make GroupWise provider
+ run fast and shutdown faster. Reduces CPU and memory usage too.
+
+2006-03-11 Parthasarathi Susarla
+
+ * camel-groupwise-folder.c: (groupwise_refresh_info):
+ reload folder if there is no content in it.
+
+ * camel-groupwise-store.c:
+ (groupwise_connect): Dont check for disconnected state while
+ connecting.
+ (groupwise_get_folder): set the correct total count so that
+ we get the actual progress on each folder when downloading
+ mail headers the first time.
+
+2006-03-09 parthasarathi susarla
+
+ * camel-groupwise-store.c:
+ (camel_groupwise_store_connected):
+ (check_for_connection):
+ check if the status is online before trying to connect
+ to server.
+
+ * camel-groupwise-folder.c: (gw_update_cache):
+ assert lock, before continuing further.
+
+2006-01-31 Parthasarathi Susarla
+
+ ** See bug 329214
+
+ * camel-groupwise-utils.c:
+ (send_as_attachment): use text.htm for text files only
+ if there is no file name.
+
+2006-01-24 Parthasarathi Susarla
+
+ * camel-groupwise-folder.c:
+ (groupwise_sync):
+ (groupwise_transfer_messages_to):
+ (groupwise_append_message):
+ lookup for CNC only if we are connected.
+
+ * camel-groupwise-store.c:
+ (groupwise_auth_loop):
+ (groupwise_connect):
+ lookup for CNC only if we are connected
+ (groupwise_disconnect_cleanup): cleanup the priv
+ structure whenever we disconnect
+
+2006-01-23 Parthasarathi Susarla
+
+ * camel-groupwise-folder.c:
+ (update_junk_list): do not contact the server each time we
+ add junk, just once, while marking not junk.
+ (groupwise_transfer_messages_to): fix a crash, have to use
+ destination->summary instead of destination.
+
+ ** See bug 327376
+ * camel-groupwise-transport.c: (groupwise_send_to):
+ set the link info to NULL. Fixes a crash.
+ * camel-groupwise-utils.c: (send_as_attachment):
+ Based on encoding, check if we are sending non base64 data
+ to the server, if we are, do a base64 encode first.
+
+2006-01-19 Andre Klapper
+
+ * camel-groupwise-transport.c: fixed a typo and improved an
+ error message. Fixes bug 325657.
+
+2006-01-12 Parthasarathi Susarla
+
+ * camel-groupwise-folder.c:
+ (groupwise_populate_details_from_item):
+ (gw_update_cache):
+ (gw_update_summary):
+ put the created date, in case of missing delivered date
+
+ ** See bug 314841
+ (gw_update_summary): dont bold trash folder with number of
+ messsages
+
+ * camel-groupwise-storec.:(groupwise_get_folder):
+ request for created date too
+
+ ** See bug 323570
+
+ * camel-groupwise-utils.c:
+ (do_multipart): a part can further be a multipart so have a
+ recurssive function
+
+2006-01-04 Parthasarathi Susarla
+
+ * camel-groupwise-folder.c:
+ (groupwise_sync_summary): saves the summary to the disk
+ (groupwise_sync): remove a lot of junk code
+ (groupwise_folder_item_to_msg): fixes the html with embedded
+ images issue. See bug 320898
+ * camel-groupwise-store.c: remove printfs everywhere
+ * camel-groupwise-utils.c:
+ (strip_lt_gt): strips the < and > characters based on the
+ given offsets
+
+
2005-12-14 Parthasarathi Susarla
+
+ ** See bug 317794
+ * camel-groupwise-store-summary.c:
+ (camel_groupwise_store_summary_full_to_path):
+ (camel_groupwise_store_summary_path_to_full):
+ Do not convert folder names here, there are already converted
- ** See bug 317794
- * camel-groupwise-store-summary.c:
- (camel_groupwise_store_summary_full_to_path):
- (camel_groupwise_store_summary_path_to_full):
- Do not convert folder names here, there are already converted
+2005-12-13 Tor Lillqvist
+ * camel-groupwise-store.c
+ * camel-groupwise-utils.c: Use gstdio wrappers. Use GDir instead
+ of dirent API.
+2005-12-09 Parthasarathi Susarla
+
+ ** See bug 321830
+
+ * camel-groupwise-folder.c: (gw_update_cache): Do not skip
+ caching sent items, they dont get displayed otherwise.
+
+2005-11-09 Parthasarathi Susarla
+
+ * camel-groupwise-folder.c:
+ (groupwise_sync): initialise mi and free some stuff
+ (groupwise_expunge): clear summary and cache and emptying trash
+ Fixes bug **320095
+
+ * camel-groupwise-store.c:
+ (groupwise_connect): do not attempt to connect when the service is
+ disconnected and the network is unavailable.
+ (groupwise_disconnect): check if priv is indeed available. Prevents
+ a violation
+ (groupwise_get_trash): fix up the state of the folder. Fixes the bug
+ **320095
+
+ * camel-groupwise-summary.[ch]:
+ (groupwise_summary_clear): clears the summary and cache of a groupwise
+ folder.
+
+2005-11-09 Sankar P
+
+ * camel-groupwise-transport.c (groupwise_send_to):
+ Changed the string so as to be consistent with Win32 client error messages.
+
+2005-11-09 Shreyas Srinivasan
+
+ * camel-groupwise-store.c (groupwise_connect): Uncomment
+ code which previously fixed offlining code.
+
+2005-11-09 Sankar P
+
+ * camel-groupwise-transport.c (groupwise_send_to):
+ Added code to handle the Quota errors.
+ Fixes #314476
+
2005-11-07 Parthasarathi Susarla
** See bug #320736
* camel-groupwise-folder.c: (groupwise_folder_item_to_msg):
- Check if the attachment is indeed a valid string. Prevents
- a crash.
+ Check if the attachment buffer is indeed valid. Prevents a possible
+ segment violation.
+2005-10-21 Shreyas Srinivasan
+
+ * camel-groupwise-store.c:(groupwise_connect): Connect if store->state
+ is CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL and not if
+ CAMEL_OFFLINE_STORE_NETWORK_AVAIL
+
2005-10-19 Vivek Jain
**See bug #319045
@@ -25,11 +423,7 @@
* camel-groupwise-folder.c: (transfer_messages_to):
set the flags correctly for GW_JUNK
-
-2005-10-03 Parthasarathi Susarla
- * reverting commits made for JUNK folder type
-
2005-10-03 Parthasarathi Susarla
** See bug 314751
@@ -42,7 +436,7 @@
2005-09-30 Vivek Jain
* camel-groupwise-store.c: (get_folder_info)
- remove env chceck GROUPWISE_SHARED_FOLDER
+ remove env check GROUPWISE_SHARED_FOLDER
to enable shared folder functionality
2005-09-28 Sankar P
@@ -51,13 +445,21 @@
Added peek to the view so that the unread status of mails doesnt get
changed during a proxy access.
Fixes #309993
-
+
+2005-09-26 Veerapuram Varadhan
+ * camel-groupwise-folder.c: (camel_gw_folder_new)
+ Memory leak fixes.
+
+ * camel-groupwise-store.c: (groupwise_store_construct)
+ (camel_groupwise_store_finalize): Memory leak fixes, use
+ g_hash_table_new_full instead of g_hash_table_new.
+
2005-09-26 Vivek Jain
-
+
* camel-groupwise-folder.c :(update_junk_list)
initialize variables email and from.
**Fixes #314942
-
+
2005-09-18 Parthasarathi Susarla
* camel-groupwise-folder.c: (groupwise_refresh_info):
Index: camel/providers/groupwise/camel-groupwise-journal.c
===================================================================
--- camel/providers/groupwise/camel-groupwise-journal.c (revision 444)
+++ camel/providers/groupwise/camel-groupwise-journal.c (working copy)
@@ -372,6 +372,7 @@
camel_object_unref (cache);
info = camel_folder_summary_info_new_from_message (folder->summary, message);
+ g_free(info->uid);
info->uid = g_strdup (uid);
gw_message_info_dup_to ((CamelMessageInfoBase *) info, (CamelMessageInfoBase *) mi);
Index: camel/providers/groupwise/camel-groupwise-folder.c
===================================================================
--- camel/providers/groupwise/camel-groupwise-folder.c (revision 444)
+++ camel/providers/groupwise/camel-groupwise-folder.c (working copy)
@@ -49,6 +49,8 @@
#include
#include
+#include
+
#include
#include
#include
@@ -58,6 +60,8 @@
#define REMOVE_JUNK_ENTRY -1
#define JUNK_FOLDER "Junk Mail"
#define READ_CURSOR_MAX_IDS 500
+#define MAX_ATTACHMENT_SIZE 1*1024*1024 /*In bytes*/
+#define GROUPWISE_BULK_DELETE_LIMIT 100
static CamelOfflineFolderClass *parent_class = NULL;
@@ -71,30 +75,22 @@
};
/*prototypes*/
-static void groupwise_transfer_messages_to (CamelFolder *source,
- GPtrArray *uids,
- CamelFolder *destination,
- GPtrArray **transferred_uids,
- gboolean delete_originals,
- CamelException *ex);
-
+static void groupwise_transfer_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *destination, GPtrArray **transferred_uids, gboolean delete_originals, CamelException *ex);
static int gw_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args);
void convert_to_calendar (EGwItem *item, char **str, int *len);
static void convert_to_task (EGwItem *item, char **str, int *len);
-static void gw_update_all_items ( CamelFolder *folder, GSList *item_list, CamelException *ex);
+static void gw_update_all_items ( CamelFolder *folder, GList *item_list, CamelException *ex);
static void groupwise_populate_details_from_item (CamelMimeMessage *msg, EGwItem *item);
static void groupwise_populate_msg_body_from_item (EGwConnection *cnc, CamelMultipart *multipart, EGwItem *item, char *body);
static void groupwise_msg_set_recipient_list (CamelMimeMessage *msg, EGwItem *item);
-static void gw_update_cache ( CamelFolder *folder, GList *item_list,CamelException *ex);
-static CamelMimeMessage *groupwise_folder_item_to_msg ( CamelFolder *folder, EGwItem *item, CamelException *ex );
+static void gw_update_cache ( CamelFolder *folder, GList *item_list, CamelException *ex, gboolean uid_flag);
+static CamelMimeMessage *groupwise_folder_item_to_msg ( CamelFolder *folder, EGwItem *item, CamelException *ex );
-#define d(x) x
+#define d(x)
static CamelMimeMessage *
-groupwise_folder_get_message( CamelFolder *folder,
- const char *uid,
- CamelException *ex )
+groupwise_folder_get_message( CamelFolder *folder, const char *uid, CamelException *ex )
{
CamelMimeMessage *msg = NULL;
CamelGroupwiseFolder *gw_folder = CAMEL_GROUPWISE_FOLDER(folder);
@@ -107,7 +103,7 @@
EGwItem *item;
CamelStream *stream, *cache_stream;
int errno;
-
+
/* see if it is there in cache */
mi = (CamelGroupwiseMessageInfo *) camel_folder_summary_uid (folder->summary, uid);
@@ -125,7 +121,7 @@
camel_stream_reset (stream);
if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) msg, stream) == -1) {
if (errno == EINTR) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_USER_CANCEL, _("User cancelled"));
+ camel_exception_setv (ex, CAMEL_EXCEPTION_USER_CANCEL, _("User canceled"));
camel_object_unref (msg);
camel_object_unref (cache_stream);
camel_object_unref (stream);
@@ -146,14 +142,14 @@
camel_message_info_free (&mi->info);
return msg;
}
-
+
if (((CamelOfflineStore *) gw_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("This message is not available in offline mode."));
camel_message_info_free (&mi->info);
return NULL;
}
-
+
/* Check if we are really offline */
if (!camel_groupwise_store_connected (gw_store, ex)) {
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
@@ -178,7 +174,7 @@
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Could not get message"));
g_free (container_id);
camel_message_info_free (&mi->info);
-
+
return NULL;
}
@@ -198,7 +194,7 @@
}
CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
-
+
end:
camel_message_info_free (&mi->info);
g_free (container_id);
@@ -214,16 +210,23 @@
temp_str = (char *)e_gw_item_get_subject(item);
if(temp_str)
camel_mime_message_set_subject (msg, temp_str);
- dtstring = e_gw_item_get_creation_date (item);
+ dtstring = e_gw_item_get_delivered_date (item);
if(dtstring) {
int offset = 0;
time_t time = e_gw_connection_get_date_from_string (dtstring);
time_t actual_time = camel_header_decode_date (ctime(&time), &offset);
camel_mime_message_set_date (msg, actual_time, offset);
+ } else {
+ time_t time;
+ time_t actual_time;
+ int offset = 0;
+ dtstring = e_gw_item_get_creation_date (item);
+ time = e_gw_connection_get_date_from_string (dtstring);
+ actual_time = camel_header_decode_date (ctime(&time), NULL);
+ camel_mime_message_set_date (msg, actual_time, offset);
}
}
-
static void
groupwise_populate_msg_body_from_item (EGwConnection *cnc, CamelMultipart *multipart, EGwItem *item, char *body)
{
@@ -267,19 +270,19 @@
case E_GW_ITEM_TYPE_NOTIFICATION:
case E_GW_ITEM_TYPE_MAIL:
case E_GW_ITEM_TYPE_NOTE:
- if (body)
- camel_mime_part_set_content(part, body, strlen(body), "text/html");
- else if (temp_body)
- camel_mime_part_set_content(part, temp_body, strlen(temp_body), e_gw_item_get_msg_content_type (item));
- else
- camel_mime_part_set_content(part, " ", strlen(" "), "text/html");
+ if (body)
+ camel_mime_part_set_content(part, body, strlen(body), "text/html");
+ else if (temp_body)
+ camel_mime_part_set_content(part, temp_body, strlen(temp_body), e_gw_item_get_msg_content_type (item));
+ else
+ camel_mime_part_set_content(part, " ", strlen(" "), "text/html");
break;
default:
break;
}
-
+
camel_multipart_set_boundary (multipart, NULL);
camel_multipart_add_part (multipart, part);
camel_object_unref (part);
@@ -301,7 +304,7 @@
GSList *rl;
char *status_opt = NULL;
gboolean enabled;
-
+
for (rl = recipient_list ; rl != NULL ; rl = rl->next) {
EGwItemRecipient *recp = (EGwItemRecipient *) rl->data;
enabled = recp->status_enabled;
@@ -311,7 +314,7 @@
} else {
ha=camel_header_address_new_name(recp->display_name,recp->email);
}
-
+
if (recp->type == E_GW_ITEM_RECIPIENT_TO) {
if (recp->status_enabled)
status_opt = g_strconcat (status_opt ? status_opt : "" , "TO", ";",NULL);
@@ -320,7 +323,7 @@
if (recp->status_enabled)
status_opt = g_strconcat (status_opt ? status_opt : "", "CC", ";",NULL);
camel_header_address_list_append(&cc_list,ha);
-
+
} else if (recp->type == E_GW_ITEM_RECIPIENT_BC) {
if (recp->status_enabled)
status_opt = g_strconcat (status_opt ? status_opt : "", "BCC", ";",NULL);
@@ -330,17 +333,17 @@
}
if (recp->status_enabled) {
status_opt = g_strconcat (status_opt,
- recp->display_name,";",
- recp->email,";",
- recp->delivered_date ? recp->delivered_date : "", ";",
- recp->opened_date ? recp->opened_date : "", ";",
- recp->accepted_date ? recp->accepted_date : "", ";",
- recp->deleted_date ? recp->deleted_date : "", ";",
- recp->declined_date ? recp->declined_date : "", ";",
- recp->completed_date ? recp->completed_date : "", ";",
- recp->undelivered_date ? recp->undelivered_date : "", ";",
- "::", NULL);
-
+ recp->display_name,";",
+ recp->email,";",
+ recp->delivered_date ? recp->delivered_date : "", ";",
+ recp->opened_date ? recp->opened_date : "", ";",
+ recp->accepted_date ? recp->accepted_date : "", ";",
+ recp->deleted_date ? recp->deleted_date : "", ";",
+ recp->declined_date ? recp->declined_date : "", ";",
+ recp->completed_date ? recp->completed_date : "", ";",
+ recp->undelivered_date ? recp->undelivered_date : "", ";",
+ "::", NULL);
+
}
}
if (enabled) {
@@ -371,11 +374,19 @@
}
if (org) {
- if (org->display_name && org->email) {
- ha=camel_header_address_new_name(org->display_name,org->email);
- } else {
+ if (org->display_name && org->display_name[0] && org->email != NULL && org->email[0] != '\0') {
+ int i;
+ for (i = 0; org->display_name[i] != '<' &&
+ org->display_name[i] != '\0';
+ i++);
+
+ org->display_name[i] = '\0';
+ }
+ if (org->display_name && org->email)
+ ha=camel_header_address_new_name(org->display_name, org->email);
+ else if (org->display_name)
ha=camel_header_address_new_group(org->display_name);
- }
+
subs_email=camel_header_address_list_encode(ha);
camel_medium_set_header( CAMEL_MEDIUM(msg), "From", subs_email);
camel_header_address_unref(ha);
@@ -383,7 +394,6 @@
}
}
-
static void
groupwise_folder_rename (CamelFolder *folder, const char *new)
{
@@ -421,12 +431,12 @@
{
CamelGroupwiseFolder *gw_folder = CAMEL_GROUPWISE_FOLDER(folder);
GPtrArray *matches;
-
+
CAMEL_GROUPWISE_FOLDER_LOCK(folder, search_lock);
camel_folder_search_set_folder (gw_folder->search, folder);
matches = camel_folder_search_search(gw_folder->search, expression, NULL, ex);
CAMEL_GROUPWISE_FOLDER_UNLOCK(gw_folder, search_lock);
-
+
return matches;
}
@@ -438,7 +448,7 @@
if (uids->len == 0)
return g_ptr_array_new();
-
+
CAMEL_GROUPWISE_FOLDER_LOCK(folder, search_lock);
camel_folder_search_set_folder(gw_folder->search, folder);
@@ -453,7 +463,7 @@
groupwise_folder_search_free (CamelFolder *folder, GPtrArray *uids)
{
CamelGroupwiseFolder *gw_folder = CAMEL_GROUPWISE_FOLDER(folder);
-
+
g_return_if_fail (gw_folder->search);
CAMEL_GROUPWISE_FOLDER_LOCK(folder, search_lock);
@@ -461,7 +471,7 @@
camel_folder_search_free_result (gw_folder->search, uids);
CAMEL_GROUPWISE_FOLDER_UNLOCK(gw_folder, search_lock);
-
+
}
/******************* functions specific to Junk Mail Handling**************/
@@ -481,8 +491,6 @@
static void
update_junk_list (CamelStore *store, CamelMessageInfo *info, int flag)
{
- GList *list = NULL;
- EGwJunkEntry *entry;
gchar **email = NULL, *from = NULL;
CamelGroupwiseStore *gw_store= CAMEL_GROUPWISE_STORE(store);
CamelGroupwiseStorePrivate *priv = gw_store->priv;
@@ -492,25 +500,25 @@
goto error;
email = g_strsplit_set (from, "<>", -1);
- if (!email[1])
+
+ if (!email || !email[1])
goto error;
- if (e_gw_connection_get_junk_entries (cnc, &list)== E_GW_CONNECTION_STATUS_OK){
- while (list) {
- entry = list->data;
- if (!g_ascii_strcasecmp (entry->match, email[1])) {
- if (flag == ADD_JUNK_ENTRY) /*if already there then don't add*/
- break;
- else if (flag == REMOVE_JUNK_ENTRY){
+ if (flag == ADD_JUNK_ENTRY)
+ e_gw_connection_create_junk_entry (cnc, email[1], "email", "junk");
+ else if (flag == REMOVE_JUNK_ENTRY) {
+ GList *list = NULL;
+ EGwJunkEntry *entry;
+ if (e_gw_connection_get_junk_entries (cnc, &list)== E_GW_CONNECTION_STATUS_OK){
+ while (list) {
+ entry = list->data;
+ if (!g_ascii_strcasecmp (entry->match, email[1])) {
e_gw_connection_remove_junk_entry (cnc, entry->id);
- break;
}
+ list = list->next;
}
- list = list->next;
+ g_list_foreach (list, (GFunc) free_node, NULL);
}
- if (!list && flag == ADD_JUNK_ENTRY) /*no entry found just create a new entry if asked to*/
- if (e_gw_connection_create_junk_entry (cnc, email[1], "email", "junk") == E_GW_CONNECTION_STATUS_OK);
- g_list_foreach (list, (GFunc) free_node, NULL);
}
error:
@@ -524,10 +532,10 @@
CamelFolder *dest;
GPtrArray *uids;
const char *uid = camel_message_info_uid (info);
-
+
uids = g_ptr_array_new ();
g_ptr_array_add (uids, (gpointer) uid);
-
+
dest = camel_store_get_folder (folder->parent_store, "Mailbox", 0, ex);
if (dest)
groupwise_transfer_messages_to (folder, uids, dest, NULL, TRUE, ex);
@@ -544,10 +552,10 @@
CamelFolderInfo *fi;
GPtrArray *uids;
const char *uid = camel_message_info_uid (info);
-
+
uids = g_ptr_array_new ();
g_ptr_array_add (uids, (gpointer) uid);
-
+
dest = camel_store_get_folder (folder->parent_store, JUNK_FOLDER, 0, ex);
if (dest)
groupwise_transfer_messages_to (folder, uids, dest, NULL, TRUE, ex);
@@ -559,31 +567,46 @@
else
groupwise_transfer_messages_to (folder, uids, dest, NULL, TRUE, ex);
}
-
+
update_junk_list (folder->parent_store, info, ADD_JUNK_ENTRY);
-
+
}
/********************* back to folder functions*************************/
+static void
+groupwise_sync_summary (CamelFolder *folder, CamelException *ex)
+{
+ camel_folder_summary_save (folder->summary);
+ camel_store_summary_save ((CamelStoreSummary *)((CamelGroupwiseStore *)folder->parent_store)->summary);
+}
+
static void
groupwise_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
{
CamelGroupwiseStore *gw_store = CAMEL_GROUPWISE_STORE (folder->parent_store);
CamelGroupwiseFolder *gw_folder = CAMEL_GROUPWISE_FOLDER (folder);
CamelGroupwiseStorePrivate *priv = gw_store->priv;
- CamelMessageInfo *info;
+ CamelMessageInfo *info = NULL;
CamelGroupwiseMessageInfo *gw_info;
- GList *read_items = NULL, *deleted_items = NULL;
+ GList *read_items = NULL;
flags_diff_t diff;
const char *container_id;
EGwConnectionStatus status;
- EGwConnection *cnc = cnc_lookup (priv);
+ EGwConnection *cnc;
int count, i;
- if (((CamelOfflineStore *) gw_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
+ GList *deleted_items, *deleted_head;
+
+ deleted_items = deleted_head = NULL;
+
+ if (((CamelOfflineStore *) gw_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL ||
+ ((CamelService *)gw_store)->status == CAMEL_SERVICE_DISCONNECTED) {
+ groupwise_sync_summary (folder, ex);
return;
-
+ }
+ cnc = cnc_lookup (priv);
+
container_id = camel_groupwise_store_container_id_lookup (gw_store, folder->full_name) ;
CAMEL_SERVICE_LOCK (gw_store, connect_lock);
@@ -596,11 +619,11 @@
count = camel_folder_summary_count (folder->summary);
CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
- for (i=0 ; i summary, i);
gw_info = (CamelGroupwiseMessageInfo *) info;
-
+
/**Junk Mail handling**/
if(!info)
continue;
@@ -608,6 +631,7 @@
if ((flags & CAMEL_MESSAGE_JUNK) && !(flags & CAMEL_GW_MESSAGE_JUNK)) /*marked a message junk*/
move_to_junk (folder, info, ex);
+
else if ((flags & CAMEL_MESSAGE_JUNK) && (flags & CAMEL_GW_MESSAGE_JUNK)) /*message was marked as junk, now unjunk*/
move_to_mailbox (folder, info, ex);
@@ -616,64 +640,91 @@
diff.changed &= folder->permanent_flags;
/* weed out flag changes that we can't sync to the server */
- if (!diff.changed)
+ if (!diff.changed) {
camel_message_info_free(info);
- else {
+ continue;
+ } else {
+ gw_info->server_flags = gw_info->info.flags;
const char *uid = camel_message_info_uid (info);
if (diff.changed & CAMEL_MESSAGE_SEEN)
read_items = g_list_append (read_items, (char *)uid);
if (diff.changed & CAMEL_MESSAGE_DELETED) {
- /*deleted_items = g_list_append (deleted_items, (char *)uid);*/
- CAMEL_SERVICE_LOCK (gw_store, connect_lock);
- status = e_gw_connection_remove_item (cnc, container_id, uid);
- if (status == E_GW_CONNECTION_STATUS_OK) {
- CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
- camel_folder_summary_remove (folder->summary, info);
- camel_data_cache_remove(gw_folder->cache, "cache", uid, ex);
- CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
- i--; count--;
+ if (deleted_items)
+ deleted_items = g_list_prepend (deleted_items, (char *)camel_message_info_uid (info));
+ else {
+ g_list_free (deleted_head);
+ deleted_head = NULL;
+ deleted_head = deleted_items = g_list_prepend (deleted_items, (char *)camel_message_info_uid (info));
}
- CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+
+ if (g_list_length (deleted_items) == GROUPWISE_BULK_DELETE_LIMIT ) {
+ CAMEL_SERVICE_LOCK (gw_store, connect_lock);
+ status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
+ CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+ if (status == E_GW_CONNECTION_STATUS_OK) {
+ char *uid;
+ while (deleted_items) {
+ uid = (char *)deleted_items->data;
+ CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
+ camel_folder_summary_remove_uid (folder->summary, uid);
+ camel_data_cache_remove(gw_folder->cache, "cache", uid, ex);
+ CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
+ deleted_items = g_list_next (deleted_items);
+ count -= GROUPWISE_BULK_DELETE_LIMIT;
+ i -= GROUPWISE_BULK_DELETE_LIMIT;
+ }
+ }
+ }
}
}
}
camel_message_info_free (info);
- info = NULL;
}
CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
+ if (deleted_items) {
+ CAMEL_SERVICE_LOCK (gw_store, connect_lock);
+ if (!strcmp (folder->full_name, "Trash")) {
+ status = e_gw_connection_purge_selected_items (cnc, deleted_items);
+ } else {
+ status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
+ }
+ CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+ if (status == E_GW_CONNECTION_STATUS_OK) {
+ char *uid;
+ while (deleted_items) {
+ uid = (char *)deleted_items->data;
+ CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
+ camel_folder_summary_remove_uid (folder->summary, uid);
+ camel_data_cache_remove(gw_folder->cache, "cache", uid, ex);
+ CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
+ deleted_items = g_list_next (deleted_items);
+ count -= GROUPWISE_BULK_DELETE_LIMIT;
+ i -= GROUPWISE_BULK_DELETE_LIMIT;
+ }
+ }
+ g_list_free (deleted_head);
+ }
if (read_items && g_list_length (read_items)) {
CAMEL_SERVICE_LOCK (gw_store, connect_lock);
e_gw_connection_mark_read (cnc, read_items);
CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
}
- if (deleted_items) {
- /* status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
- if (status == E_GW_CONNECTION_STATUS_OK) {
- GList *temp_list = deleted_items;
- int len = g_list_length (deleted_items);
- int i;
- for (i=0 ; isummary, (const char *)temp_list->data);
- camel_data_cache_remove (gw_folder->cache, "cache", (const char *)temp_list->data, ex);
- temp_list = g_list_next (deleted_items);
- }
- }*/
- }
if (expunge) {
CAMEL_SERVICE_LOCK (gw_store, connect_lock);
status = e_gw_connection_purge_deleted_items (cnc);
if (status == E_GW_CONNECTION_STATUS_OK) {
+ g_message ("Purged deleted items in %s", folder->name);
}
CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
}
-
- camel_folder_summary_save (folder->summary);
+
+ CAMEL_SERVICE_LOCK (gw_store, connect_lock);
+ groupwise_sync_summary (folder, ex);
+ CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
}
-
-
CamelFolder *
camel_gw_folder_new(CamelStore *store, const char *folder_name, const char *folder_dir, CamelException *ex)
{
@@ -699,11 +750,11 @@
if (!folder->summary) {
camel_object_unref (CAMEL_OBJECT (folder));
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not load summary for %s"),
- folder_name);
+ _("Could not load summary for %s"),
+ folder_name);
return NULL;
}
-
+
/* set/load persistent state */
state_file = g_strdup_printf ("%s/cmeta", folder_dir);
camel_object_set(folder, NULL, CAMEL_OBJECT_STATE_FILE, state_file, NULL);
@@ -718,6 +769,7 @@
journal_file = g_strdup_printf ("%s/journal",folder_dir);
gw_folder->journal = camel_groupwise_journal_new (gw_folder, journal_file);
+ g_free (journal_file);
if (!gw_folder->journal) {
camel_object_unref (folder);
return NULL;
@@ -727,13 +779,13 @@
if (camel_url_get_param (((CamelService *) store)->url, "filter"))
folder->folder_flags |= CAMEL_FOLDER_FILTER_RECENT;
}
-
+
gw_folder->search = camel_folder_search_new ();
if (!gw_folder->search) {
camel_object_unref (folder);
return NULL;
}
-
+
return folder;
}
@@ -747,7 +799,6 @@
GSList *slist;
};
-
static void
update_update (CamelSession *session, CamelSessionThreadMsg *msg)
{
@@ -755,7 +806,7 @@
EGwConnectionStatus status;
CamelException *ex = NULL;
- GList *item_list;
+ GList *item_list, *items_full_list = NULL, *last_element=NULL;
int cursor = 0;
const char *position = E_GW_CURSOR_POSITION_END;
gboolean done;
@@ -777,20 +828,48 @@
e_gw_connection_destroy_cursor (m->cnc, m->container_id, cursor);
return;
}
-
+
if (!item_list || g_list_length (item_list) == 0)
done = TRUE;
else {
- for (;item_list; item_list = g_list_next (item_list)) {
- m->slist = g_slist_prepend (m->slist, (char *)item_list->data);
+
+ /* item_list is prepended to items_full_list and not the other way
+ because when we have a large number of items say 50000,
+ for each iteration there will be more elements in items_full_list
+ and less elements in item_list */
+
+ last_element = g_list_last (item_list);
+ if (items_full_list) {
+ last_element->next = items_full_list;
+ items_full_list->prev = last_element;
}
+ items_full_list = item_list;
}
- g_list_free (item_list);
position = E_GW_CURSOR_POSITION_CURRENT;
}
e_gw_connection_destroy_cursor (m->cnc, m->container_id, cursor);
- gw_update_all_items (m->folder, m->slist, ex);
+ /* Take out only the first part in the list until the @ since it is guaranteed
+ to be unique only until that symbol */
+
+ /*if (items_full_list) {
+ int i;
+ item_list = items_full_list;
+
+ while (item_list->next) {
+ i = 0;
+ while (((const char *)item_list->data)[i++]!='@');
+ ((char *)item_list->data)[i-1] = '\0';
+ item_list = item_list->next;
+ }
+
+ i = 0;
+ while (((const char *)item_list->data)[i++]!='@');
+ ((char *)item_list->data)[i-1] = '\0';
+ }*/
+
+ g_print ("\nNumber of items in the folder: %d \n", g_list_length(items_full_list));
+ gw_update_all_items (m->folder, items_full_list, ex);
}
static void
@@ -818,6 +897,7 @@
CamelGroupwiseSummary *summary;
CamelStoreInfo *si;
summary = (CamelGroupwiseSummary *) folder->summary;
+ CamelGroupwiseStore *gw_store = CAMEL_GROUPWISE_STORE (folder->parent_store);
/*
* Checking for the summary->time_string here since the first the a
* user views a folder, the read cursor is in progress, and the getQM
@@ -838,6 +918,12 @@
}
camel_folder_summary_save (folder->summary);
camel_store_summary_save ((CamelStoreSummary *)((CamelGroupwiseStore *)folder->parent_store)->summary);
+ } else {
+ /* We probably could not get the messages the first time. (get_folder) failed???!
+ * so do a get_folder again. And hope that it works
+ */
+ g_print("Reloading folder...something wrong with the summary....\n");
+ gw_store_reload_folder (gw_store, folder, 0, ex);
}
}
@@ -858,7 +944,12 @@
char *container_id = NULL;
char *time_string = NULL, *t_str = NULL;
struct _folder_update_msg *msg;
+ gboolean check_all = FALSE;
+ /* Sync-up the (un)read changes before getting updates,
+ so that the getFolderList will reflect the most recent changes too */
+ groupwise_sync (folder, FALSE, ex);
+
if (((CamelOfflineStore *) gw_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
g_warning ("In offline mode. Cannot refresh!!!\n");
return;
@@ -871,20 +962,26 @@
return;
}
+ if (!cnc)
+ return;
+
if (camel_folder_is_frozen (folder) ) {
gw_folder->need_refresh = TRUE;
}
-
+
CAMEL_SERVICE_LOCK (gw_store, connect_lock);
if (!camel_groupwise_store_connected (gw_store, ex))
goto end1;
- if (!strcmp (folder->full_name, "Trash") || is_proxy) {
- status = e_gw_connection_get_items (cnc, container_id, "peek recipient distribution created attachments subject status size", NULL, &list);
+ if (!strcmp (folder->full_name, "Trash")) {
+#if 0
+ status = e_gw_connection_get_items (cnc, container_id, "peek recipient distribution created delivered attachments subject status size", NULL, &list);
if (status != E_GW_CONNECTION_STATUS_OK) {
if (status ==E_GW_CONNECTION_STATUS_OTHER) {
g_warning ("Trash full....Empty Trash!!!!\n");
+ camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Trash Folder Full. Please Empty."));
+ goto end1;
/*groupwise_expunge (folder, ex);*/
} else
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Authentication failed"));
@@ -898,62 +995,87 @@
list = NULL;
}
goto end1;
+#endif
+ is_proxy = TRUE;
}
time_string = g_strdup (((CamelGroupwiseSummary *) folder->summary)->time_string);
t_str = g_strdup (time_string);
+
/*Get the New Items*/
- status = e_gw_connection_get_quick_messages (cnc, container_id,
- "peek id",
- &t_str, "New", NULL, NULL, -1, &slist);
- if (status != E_GW_CONNECTION_STATUS_OK) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Authentication failed"));
- goto end2;
- }
+ if (!is_proxy) {
+ status = e_gw_connection_get_quick_messages (cnc, container_id,
+ "peek id",
+ &t_str, "New", NULL, NULL, -1, &slist);
+ if (status != E_GW_CONNECTION_STATUS_OK) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Authentication failed"));
+ goto end2;
+ }
- /*
- * The value in t_str is the one that has to be used for the next set of calls.
- * so store this value in the summary.
- */
- if (summary->time_string)
- g_free (summary->time_string);
- summary->time_string = g_strdup (t_str);
- g_free (t_str);
- t_str = NULL;
+ /*
+ * The value in t_str is the one that has to be used for the next set of calls.
+ * so store this value in the summary.
+ */
+ if (summary->time_string)
+ g_free (summary->time_string);
- for ( sl = slist ; sl != NULL; sl = sl->next)
- list = g_list_append (list, sl->data);
- g_slist_free (slist);
- slist = NULL;
+ //summary->time_string = g_strdup (t_str);
+ ((CamelGroupwiseSummary *) folder->summary)->time_string = g_strdup (t_str);
+ camel_folder_summary_touch (folder->summary);
+ groupwise_sync_summary (folder, ex);
+ g_free (t_str);
+ t_str = NULL;
- t_str = g_strdup (time_string);
+ /*
+ for ( sl = slist ; sl != NULL; sl = sl->next)
+ list = g_list_append (list, sl->data);*/
- /*Get those items which have been modifed*/
- status = e_gw_connection_get_quick_messages (cnc, container_id,
- "peek id",
- &t_str, "Modified", NULL, NULL, -1, &slist);
- g_free (t_str), t_str = NULL;
- if (status != E_GW_CONNECTION_STATUS_OK) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Authentication failed"));
- goto end3;
- }
-
- for ( sl = slist ; sl != NULL; sl = sl->next)
- list = g_list_append (list, sl->data);
+ if (slist && g_slist_length(slist) != 0)
+ check_all = TRUE;
- g_slist_free (slist);
- slist = NULL;
+ g_slist_free (slist);
+ slist = NULL;
- if (gw_store->current_folder != folder) {
- gw_store->current_folder = folder;
+ t_str = g_strdup (time_string);
+
+ /*Get those items which have been modifed*/
+
+ status = e_gw_connection_get_quick_messages (cnc, container_id,
+ "peek id",
+ &t_str, "Modified", NULL, NULL, -1, &slist);
+
+ if (status != E_GW_CONNECTION_STATUS_OK) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Authentication failed"));
+ goto end3;
+ }
+
+ /* The storing of time-stamp to summary code below should be commented if the
+ above commented code is uncommented */
+
+ /* if (summary->time_string)
+ g_free (summary->time_string);
+
+ summary->time_string = g_strdup (t_str);
+
+ g_free (t_str), t_str = NULL;*/
+
+ for ( sl = slist ; sl != NULL; sl = sl->next)
+ list = g_list_prepend (list, sl->data);
+
+ g_slist_free (slist);
+ slist = NULL;
+
+ if (gw_store->current_folder != folder) {
+ gw_store->current_folder = folder;
+ }
+
+ if (list) {
+ gw_update_cache (folder, list, ex, FALSE);
+ }
}
- if (list) {
- gw_update_cache (folder, list, ex);
- }
-
-
+
CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
is_locked = FALSE;
@@ -964,17 +1086,18 @@
* this folder, and update the summary.
*/
/*create a new session thread for the update all operation*/
- msg = camel_session_thread_msg_new (session, &update_ops, sizeof(*msg));
- msg->cnc = cnc;
- msg->t_str = g_strdup (time_string);
- msg->container_id = g_strdup (container_id);
- msg->folder = folder;
- camel_object_ref (folder);
- camel_folder_freeze (folder);
- camel_session_thread_queue (session, &msg->msg, 0);
- /*thread creation and queueing done*/
+ if (check_all || is_proxy) {
+ msg = camel_session_thread_msg_new (session, &update_ops, sizeof(*msg));
+ msg->cnc = cnc;
+ msg->t_str = g_strdup (time_string);
+ msg->container_id = g_strdup (container_id);
+ msg->folder = folder;
+ camel_object_ref (folder);
+ camel_folder_freeze (folder);
+ camel_session_thread_queue (session, &msg->msg, 0);
+ /*thread creation and queueing done*/
+ }
-
end3:
g_list_foreach (list, (GFunc) g_object_unref, NULL);
g_list_free (list);
@@ -989,10 +1112,11 @@
return;
}
-void
-gw_update_cache ( CamelFolder *folder, GList *list, CamelException *ex)
+static void
+gw_update_cache (CamelFolder *folder, GList *list, CamelException *ex, gboolean uid_flag)
{
CamelGroupwiseMessageInfo *mi = NULL;
+ CamelMessageInfo *pmi = NULL;
CamelGroupwiseStore *gw_store = CAMEL_GROUPWISE_STORE (folder->parent_store);
CamelGroupwiseFolder *gw_folder = CAMEL_GROUPWISE_FOLDER(folder);
CamelGroupwiseStorePrivate *priv = gw_store->priv;
@@ -1008,8 +1132,9 @@
EGwItemStatus status;
GList *item_list = list;
int total_items = g_list_length (item_list), i=0;
-
- /*Assert lock*/
+
+ CAMEL_SERVICE_ASSERT_LOCKED (gw_store, connect_lock);
+
changes = camel_folder_change_info_new ();
container_id = g_strdup (camel_groupwise_store_container_id_lookup (gw_store, folder->full_name));
if (!container_id) {
@@ -1017,15 +1142,15 @@
camel_folder_change_info_free (changes);
return;
}
-
+
if (!strcmp (folder->full_name, JUNK_FOLDER)) {
is_junk = TRUE;
}
- camel_operation_start (NULL, _("Fetching summary information for new messages"));
+ camel_operation_start (NULL, _("Fetching summary information for new messages in %s"), folder->name);
for ( ; item_list != NULL ; item_list = g_list_next (item_list) ) {
- EGwItem *temp_item = (EGwItem *)item_list->data;
+ EGwItem *temp_item ;
EGwItem *item;
EGwItemType type = E_GW_ITEM_TYPE_UNKNOWN;
EGwItemOrganizer *org;
@@ -1033,32 +1158,34 @@
const char *id;
GSList *recp_list = NULL;
status_flags = 0;
- CamelStream *cache_stream;
+ CamelStream *cache_stream, *t_cache_stream;
CamelMimeMessage *mail_msg = NULL;
+ gboolean is_sent_folder = FALSE;
- id = e_gw_item_get_id (temp_item);
+ exists = FALSE;
+ if (uid_flag == FALSE) {
+ temp_item = (EGwItem *)item_list->data;
+ id = e_gw_item_get_id (temp_item);
+ } else
+ id = (char *) item_list->data;
+
camel_operation_progress (NULL, (100*i)/total_items);
- cache_stream = camel_data_cache_get (gw_folder->cache, "cache", id, ex);
- if (cache_stream) {
- camel_object_unref (cache_stream);
- cache_stream = NULL;
- i++;
- //g_print ("*** Exists in cache, continuing....%s\n", id);
- continue;
- }
- status = e_gw_connection_get_item (cnc, container_id, id, "peek default distribution recipient message attachments subject notification created recipientStatus status", &item);
+ status = e_gw_connection_get_item (cnc, container_id, id, "peek default distribution recipient message attachments subject notification created recipientStatus status hasAttachment size", &item);
if (status != E_GW_CONNECTION_STATUS_OK) {
i++;
continue;
}
/************************ First populate summary *************************/
- mi = (CamelGroupwiseMessageInfo *)camel_folder_summary_uid (folder->summary, id);
- if (mi) {
+ mi = NULL;
+ pmi = NULL;
+ pmi = camel_folder_summary_uid (folder->summary, id);
+ if (pmi) {
exists = TRUE;
- camel_message_info_free (&mi->info);
+ camel_message_info_ref (pmi);
+ mi = (CamelGroupwiseMessageInfo *)pmi;
}
if (!exists) {
@@ -1068,7 +1195,7 @@
continue;
}
- mi = camel_message_info_new (folder->summary);
+ mi = (CamelGroupwiseMessageInfo *)camel_message_info_new (folder->summary);
if (mi->info.content == NULL) {
mi->info.content = camel_folder_summary_content_info_new (folder->summary);
mi->info.content->type = camel_content_type_new ("multipart", "mixed");
@@ -1082,35 +1209,47 @@
item_status = e_gw_item_get_item_status (item);
if (item_status & E_GW_ITEM_STAT_READ)
status_flags |= CAMEL_MESSAGE_SEEN;
- /*if (item_status & E_GW_ITEM_STAT_DELETED)
- status_flags |= CAMEL_MESSAGE_DELETED;*/
+ else
+ mi->info.flags &= ~CAMEL_MESSAGE_SEEN;
+
if (item_status & E_GW_ITEM_STAT_REPLIED)
status_flags |= CAMEL_MESSAGE_ANSWERED;
- mi->info.flags |= status_flags;
+ if (exists)
+ mi->info.flags |= status_flags;
+ else
+ mi->info.flags = status_flags;
priority = e_gw_item_get_priority (item);
if (priority && !(g_ascii_strcasecmp (priority,"High"))) {
mi->info.flags |= CAMEL_MESSAGE_FLAGGED;
}
- attach_list = e_gw_item_get_attach_id_list (item);
- if (attach_list) {
- GSList *al = attach_list;
- gboolean has_attachments = TRUE;
- EGwItemAttachment *attach = (EGwItemAttachment *)al->data;
+ mi->server_flags = mi->info.flags;
+
+ if (e_gw_item_has_attachment (item))
+ mi->info.flags |= CAMEL_MESSAGE_ATTACHMENTS;
- if (!g_ascii_strcasecmp (attach->name, "Mime.822") ||
- !g_ascii_strcasecmp (attach->name, "TEXT.htm"))
- has_attachments = FALSE;
-
- if (has_attachments)
- mi->info.flags |= CAMEL_MESSAGE_ATTACHMENTS;
- }
-
org = e_gw_item_get_organizer (item);
if (org) {
- g_string_append_printf (str, "%s <%s>",org->display_name, org->email);
+ GString *str;
+ int i;
+ str = g_string_new ("");
+ if (org->display_name && org->display_name[0] && org->email != NULL && org->email[0] != '\0') {
+ for (i = 0; org->display_name[i] != '<' &&
+ org->display_name[i] != '\0';
+ i++);
+
+ org->display_name[i] = '\0';
+ str = g_string_append (str, org->display_name);
+ str = g_string_append (str, " ");
+ }
+ if (org->email && org->email[0]) {
+ g_string_append (str, "<");
+ str = g_string_append (str, org->email);
+ g_string_append (str, ">");
+ }
mi->info.from = camel_pstring_strdup (str->str);
+ g_string_free (str, TRUE);
}
g_string_truncate (str, 0);
recp_list = e_gw_item_get_recipient_list (item);
@@ -1126,13 +1265,15 @@
i++;
}
}
+ if (exists)
+ camel_pstring_free(mi->info.to);
mi->info.to = camel_pstring_strdup (str->str);
g_string_truncate (str, 0);
}
-
+
if (type == E_GW_ITEM_TYPE_APPOINTMENT
- || type == E_GW_ITEM_TYPE_NOTE
- || type == E_GW_ITEM_TYPE_TASK ) {
+ || type == E_GW_ITEM_TYPE_NOTE
+ || type == E_GW_ITEM_TYPE_TASK ) {
temp_date = e_gw_item_get_start_date (item);
if (temp_date) {
time_t time = e_gw_connection_get_date_from_string (temp_date);
@@ -1140,38 +1281,52 @@
mi->info.date_sent = mi->info.date_received = actual_time;
}
} else {
- temp_date = e_gw_item_get_creation_date(item);
+ temp_date = e_gw_item_get_delivered_date(item);
if (temp_date) {
time_t time = e_gw_connection_get_date_from_string (temp_date);
time_t actual_time = camel_header_decode_date (ctime(&time), NULL);
mi->info.date_sent = mi->info.date_received = actual_time;
+ } else {
+ time_t time;
+ time_t actual_time;
+ temp_date = e_gw_item_get_creation_date (item);
+ time = e_gw_connection_get_date_from_string (temp_date);
+ actual_time = camel_header_decode_date (ctime(&time), NULL);
+ mi->info.date_sent = mi->info.date_received = actual_time;
}
}
- mi->info.uid = g_strdup(e_gw_item_get_id(item));
- if (!exists)
+ if (!exists) {
+ mi->info.uid = g_strdup (e_gw_item_get_id(item));
mi->info.size = e_gw_item_get_mail_size (item);
- mi->info.subject = camel_pstring_strdup(e_gw_item_get_subject(item));
-
- if (exists)
- camel_folder_change_info_change_uid (changes, e_gw_item_get_id (item));
- else {
+ mi->info.subject = camel_pstring_strdup(e_gw_item_get_subject(item));
+ }
+
+ if (exists) {
+ camel_folder_change_info_change_uid (changes, mi->info.uid);
+ camel_message_info_free (pmi);
+ } else {
camel_folder_summary_add (folder->summary,(CamelMessageInfo *)mi);
camel_folder_change_info_add_uid (changes, mi->info.uid);
camel_folder_change_info_recent_uid (changes, mi->info.uid);
}
- /********************* Summary Stuff ends *************************/
- exists = FALSE;
- if (!strcmp (folder->full_name, "Junk Mail")|| !strcmp (folder->full_name, "Sent Items"))
+ /********************* Summary ends *************************/
+ if (!strcmp (folder->full_name, "Junk Mail"))
continue;
+ if (!strcmp (folder->full_name, "Sent Items"))
+ is_sent_folder = TRUE;
/******************** Begine Caching ************************/
- mail_msg = groupwise_folder_item_to_msg (folder, item, ex);
- if (mail_msg)
- camel_medium_set_header (CAMEL_MEDIUM (mail_msg), "X-Evolution-Source", groupwise_base_url_lookup (priv));
/* add to cache if its a new message*/
- if (!exists) {
+ t_cache_stream = camel_data_cache_get (gw_folder->cache, "cache", id, ex);
+ if (t_cache_stream && !is_sent_folder) {
+ camel_object_unref (t_cache_stream);
+
+ mail_msg = groupwise_folder_item_to_msg (folder, item, ex);
+ if (mail_msg)
+ camel_medium_set_header (CAMEL_MEDIUM (mail_msg), "X-Evolution-Source", groupwise_base_url_lookup (priv));
+
CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
if ((cache_stream = camel_data_cache_add (gw_folder->cache, "cache", id, NULL))) {
if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *) mail_msg, cache_stream) == -1 || camel_stream_flush (cache_stream) == -1)
@@ -1207,7 +1362,7 @@
char *container_id = NULL;
gboolean is_junk = FALSE;
GList *item_list = list;
-
+
/*Assert lock???*/
changes = camel_folder_change_info_new ();
container_id = g_strdup (camel_groupwise_store_container_id_lookup (gw_store, folder->full_name));
@@ -1216,7 +1371,7 @@
camel_folder_change_info_free (changes);
return;
}
-
+
if (!strcmp (folder->full_name, JUNK_FOLDER)) {
is_junk = TRUE;
}
@@ -1231,12 +1386,10 @@
status_flags = 0;
id = e_gw_item_get_id (item);
-
+
mi = (CamelGroupwiseMessageInfo *)camel_folder_summary_uid (folder->summary, id);
- if (mi) {
+ if (mi)
exists = TRUE;
- camel_message_info_free (&mi->info);
- }
if (!exists) {
type = e_gw_item_get_item_type (item);
@@ -1259,35 +1412,44 @@
item_status = e_gw_item_get_item_status (item);
if (item_status & E_GW_ITEM_STAT_READ)
status_flags |= CAMEL_MESSAGE_SEEN;
- /*if (item_status & E_GW_ITEM_STAT_DELETED)
- status_flags |= CAMEL_MESSAGE_DELETED;*/
if (item_status & E_GW_ITEM_STAT_REPLIED)
status_flags |= CAMEL_MESSAGE_ANSWERED;
+
+ if (!strcmp (folder->full_name, "Trash"))
+ status_flags |= CAMEL_MESSAGE_SEEN;
+
mi->info.flags |= status_flags;
+
priority = e_gw_item_get_priority (item);
if (priority && !(g_ascii_strcasecmp (priority,"High"))) {
mi->info.flags |= CAMEL_MESSAGE_FLAGGED;
}
+
+ if (e_gw_item_has_attachment (item))
+ mi->info.flags |= CAMEL_MESSAGE_ATTACHMENTS;
- attach_list = e_gw_item_get_attach_id_list (item);
- if (attach_list) {
- GSList *al = attach_list;
- gboolean has_attachments = TRUE;
- EGwItemAttachment *attach = (EGwItemAttachment *)al->data;
-
- if (!g_ascii_strcasecmp (attach->name, "Mime.822") ||
- !g_ascii_strcasecmp (attach->name, "TEXT.htm"))
- has_attachments = FALSE;
-
- if (has_attachments)
- mi->info.flags |= CAMEL_MESSAGE_ATTACHMENTS;
- }
-
org = e_gw_item_get_organizer (item);
if (org) {
- g_string_append_printf (str, "%s <%s>",org->display_name, org->email);
+ GString *str;
+ int i;
+ str = g_string_new ("");
+ if (org->display_name && org->display_name[0] && org->email != NULL && org->email[0] != '\0') {
+ for (i = 0; org->display_name[i] != '<' &&
+ org->display_name[i] != '\0';
+ i++);
+
+ org->display_name[i] = '\0';
+ str = g_string_append (str, org->display_name);
+ str = g_string_append (str, " ");
+ }
+ if (org->email && org->email[0]) {
+ g_string_append (str, "<");
+ str = g_string_append (str, org->email);
+ g_string_append (str, ">");
+ }
mi->info.from = camel_pstring_strdup (str->str);
+ g_string_free (str, TRUE);
}
g_string_truncate (str, 0);
recp_list = e_gw_item_get_recipient_list (item);
@@ -1306,10 +1468,10 @@
mi->info.to = camel_pstring_strdup (str->str);
g_string_truncate (str, 0);
}
-
- if (type == E_GW_ITEM_TYPE_APPOINTMENT
- || type == E_GW_ITEM_TYPE_NOTE
- || type == E_GW_ITEM_TYPE_TASK ) {
+
+ if (type == E_GW_ITEM_TYPE_APPOINTMENT ||
+ type == E_GW_ITEM_TYPE_NOTE ||
+ type == E_GW_ITEM_TYPE_TASK ) {
temp_date = e_gw_item_get_start_date (item);
if (temp_date) {
time_t time = e_gw_connection_get_date_from_string (temp_date);
@@ -1317,11 +1479,18 @@
mi->info.date_sent = mi->info.date_received = actual_time;
}
} else {
- temp_date = e_gw_item_get_creation_date(item);
+ temp_date = e_gw_item_get_delivered_date(item);
if (temp_date) {
time_t time = e_gw_connection_get_date_from_string (temp_date);
time_t actual_time = camel_header_decode_date (ctime(&time), NULL);
mi->info.date_sent = mi->info.date_received = actual_time;
+ } else {
+ time_t time;
+ time_t actual_time;
+ temp_date = e_gw_item_get_creation_date (item);
+ time = e_gw_connection_get_date_from_string (temp_date);
+ actual_time = camel_header_decode_date (ctime(&time), NULL);
+ mi->info.date_sent = mi->info.date_received = actual_time;
}
}
@@ -1329,10 +1498,11 @@
if (!exists)
mi->info.size = e_gw_item_get_mail_size (item);
mi->info.subject = camel_pstring_strdup(e_gw_item_get_subject(item));
-
- if (exists)
+
+ if (exists) {
camel_folder_change_info_change_uid (changes, e_gw_item_get_id (item));
- else {
+ camel_message_info_free (&mi->info);
+ } else {
camel_folder_summary_add (folder->summary,(CamelMessageInfo *)mi);
camel_folder_change_info_add_uid (changes, mi->info.uid);
camel_folder_change_info_recent_uid (changes, mi->info.uid);
@@ -1363,8 +1533,13 @@
CamelMultipart *multipart;
int errno;
char *body = NULL;
+ int body_len = 0;
const char *uid = NULL;
-
+ gboolean is_text_html = FALSE;
+ gboolean has_mime_822 = FALSE;
+ gboolean is_text_html_embed = FALSE;
+ gboolean is_base64_encoded = FALSE;
+ CamelStream *temp_stream;
uid = e_gw_item_get_id(item);
cnc = cnc_lookup (priv);
@@ -1378,9 +1553,9 @@
char *attachment = NULL;
int len = 0;
- if (!g_ascii_strcasecmp (attach->name, "Mime.822") ||
- !g_ascii_strcasecmp (attach->name, "TEXT.htm")) {
-
+ if (!g_ascii_strcasecmp (attach->name, "Text.htm") ||
+ !g_ascii_strcasecmp (attach->name, "Header")) {
+
status = e_gw_connection_get_attachment (cnc,
attach->id, 0, -1,
(const char **)&attachment, &len);
@@ -1393,14 +1568,70 @@
if (!g_ascii_strcasecmp (attach->name, "TEXT.htm")) {
body = g_strdup (attachment);
g_free (attachment);
+ is_text_html = TRUE;
}
}//if attachment and len
} // if Mime.822 or TEXT.htm
+
+ for (al = attach_list ; al != NULL ; al = al->next) {
+ EGwItemAttachment *attach = (EGwItemAttachment *)al->data;
+ if (!g_ascii_strcasecmp (attach->name, "Mime.822")) {
+ if (attach->size > MAX_ATTACHMENT_SIZE) {
+ long count = 0;
+ int i, t_len=0, offset=0, t_offset=0;
+ char *t_attach = NULL;
+ GString *gstr = g_string_new (NULL);
+
+ count = (attach->size)/(1024*1024);
+ count++;
+ len = 0;
+ for (i = 0; iid, t_offset, MAX_ATTACHMENT_SIZE,
+ (const char **)&t_attach, &t_len, &offset);
+ if (status == E_GW_CONNECTION_STATUS_OK) {
+ gstr = g_string_append (gstr, t_attach);
+ t_offset = offset;
+ g_free (t_attach);
+ t_attach = NULL;
+ t_len = 0;
+ }
+ }
+ body = soup_base64_decode (gstr->str, &len);
+ body_len = len;
+ g_string_free (gstr, TRUE);
+ } else {
+ status = e_gw_connection_get_attachment (cnc,
+ attach->id, 0, -1,
+ (const char **)&attachment, &len);
+ if (status != E_GW_CONNECTION_STATUS_OK) {
+ g_warning ("Could not get attachment\n");
+ camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Could not get message"));
+ return NULL;
+ }
+ body = g_strdup (attachment);
+ body_len = len;
+ g_free (attachment);
+ }
+ has_mime_822 = TRUE;
+ }
+ }
+
}//if attach_list
msg = camel_mime_message_new ();
- multipart = camel_multipart_new ();
+ if (has_mime_822) {
+ temp_stream = camel_stream_mem_new_with_buffer (body, body_len);
+ if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) msg, temp_stream) == -1) {
+ camel_object_unref (msg);
+ camel_object_unref (temp_stream);
+ msg = NULL;
+ goto end;
+ }
+ } else {
+ multipart = camel_multipart_new ();
+ }
camel_mime_message_set_message_id (msg, uid);
type = e_gw_item_get_item_type (item);
@@ -1432,9 +1663,11 @@
g_free (value);
}
}
-
- groupwise_populate_msg_body_from_item (cnc, multipart, item, body);
+ if (has_mime_822)
+ goto end;
+ else
+ groupwise_populate_msg_body_from_item (cnc, multipart, item, body);
/*Set recipient details*/
groupwise_msg_set_recipient_list (msg, item);
groupwise_populate_details_from_item (msg, item);
@@ -1449,11 +1682,15 @@
int len = 0;
CamelMimePart *part;
EGwItem *temp_item;
+ is_base64_encoded = FALSE;
+ if (attach->contentid && (is_text_html_embed != TRUE))
+ is_text_html_embed = TRUE;
if ( !g_ascii_strcasecmp (attach->name, "TEXT.htm") ||
- !g_ascii_strcasecmp (attach->name, "Mime.822"))
+ !g_ascii_strcasecmp (attach->name, "Mime.822") ||
+ !g_ascii_strcasecmp (attach->name, "Header"))
continue;
-
+
if ( (attach->item_reference) && (!g_ascii_strcasecmp (attach->item_reference, "1")) ) {
CamelMimeMessage *temp_msg = NULL;
status = e_gw_connection_get_item (cnc, container_id, attach->id, "default distribution recipient message attachments subject notification created recipientStatus status startDate", &temp_item);
@@ -1468,129 +1705,152 @@
camel_data_wrapper_set_mime_type_field(CAMEL_DATA_WRAPPER (temp_msg), ct);
camel_content_type_unref(ct);
camel_medium_set_content_object ( CAMEL_MEDIUM (part),CAMEL_DATA_WRAPPER(temp_msg));
+
camel_multipart_add_part (multipart,part);
camel_object_unref (temp_msg);
camel_object_unref (part);
}
g_object_unref (temp_item);
} else {
- status = e_gw_connection_get_attachment (cnc,
- attach->id, 0, -1,
- (const char **)&attachment, &len);
+ if (attach->size > MAX_ATTACHMENT_SIZE) {
+ long count = 0;
+ int i, t_len=0, offset=0, t_offset=0;
+ char *t_attach = NULL;
+ GString *gstr = g_string_new (NULL);
+
+ count = (attach->size)/(1024*1024);
+ count++;
+ len = 0;
+ for (i = 0; iid, t_offset, MAX_ATTACHMENT_SIZE,
+ (const char **)&t_attach, &t_len, &offset);
+ if (status == E_GW_CONNECTION_STATUS_OK) {
+ gstr = g_string_append (gstr, t_attach);
+ t_offset = offset;
+ g_free (t_attach);
+ t_attach = NULL;
+ t_len = 0;
+ }
+ }
+ attachment = soup_base64_decode (gstr->str, &len);
+ g_string_free (gstr, TRUE);
+ is_base64_encoded = FALSE;
+ } else {
+ status = e_gw_connection_get_attachment (cnc,
+ attach->id, 0, -1,
+ (const char **)&attachment, &len);
+ }
if (status != E_GW_CONNECTION_STATUS_OK) {
g_warning ("Could not get attachment\n");
continue;
}
if (attachment && (len !=0) ) {
part = camel_mime_part_new ();
- if (attach->contentType) {
- if (!strcmp (attach->contentType, "application/pgp-signature")) {
- camel_mime_part_set_filename(part, g_strdup(attach->name));
- camel_data_wrapper_set_mime_type(CAMEL_DATA_WRAPPER (multipart), "multipart/signed");
- has_boundary = TRUE;
- camel_content_type_set_param(CAMEL_DATA_WRAPPER (multipart)->mime_type, "protocol", attach->contentType);
- } else if (!strcmp (attach->contentType, "application/pgp-encrypted")) {
- camel_data_wrapper_set_mime_type(CAMEL_DATA_WRAPPER (multipart), "multipart/encrypted");
- has_boundary = TRUE;
- camel_content_type_set_param(CAMEL_DATA_WRAPPER (multipart)->mime_type, "protocol", attach->contentType);
- } else if ( !strcmp (attach->name, "encrypted.asc") &&
- !strcmp (attach->contentType, "application/octet-stream")) {
- camel_mime_part_set_filename(part, g_strdup(attach->name));
- camel_data_wrapper_set_mime_type(CAMEL_DATA_WRAPPER (multipart), "multipart/encrypted");
- has_boundary = TRUE;
- camel_content_type_set_param(CAMEL_DATA_WRAPPER (multipart)->mime_type, "protocol", "application/pgp-encrypted");
- } else {
- camel_mime_part_set_filename(part, g_strdup(attach->name));
- camel_mime_part_set_content_id (part, attach->id);
- if (!has_boundary)
- camel_data_wrapper_set_mime_type(CAMEL_DATA_WRAPPER (multipart), "multipart/digest");
+ /*multiparts*/
+ if (is_text_html_embed) {
+ camel_mime_part_set_filename(part, g_strdup(attach->name));
+ camel_data_wrapper_set_mime_type(CAMEL_DATA_WRAPPER (multipart), "multipart/related");
+ has_boundary = TRUE;
+ camel_content_type_set_param(CAMEL_DATA_WRAPPER (multipart)->mime_type, "type", "multipart/alternative");
+ if (attach->contentid) {
+ gchar **t;
+ t= g_strsplit_set (attach->contentid, "<>", -1);
+ if (!t[1])
+ camel_mime_part_set_content_id (part, attach->contentid);
+ else
+ camel_mime_part_set_content_id (part, t[1]);
+ g_strfreev (t);
+ camel_mime_part_set_content_location (part, attach->name);
}
} else {
camel_mime_part_set_filename(part, g_strdup(attach->name));
- camel_mime_part_set_content_id (part, attach->id);
- if (!has_boundary)
- camel_data_wrapper_set_mime_type(CAMEL_DATA_WRAPPER (multipart), "multipart/digest");
+ camel_mime_part_set_content_id (part, attach->contentid);
}
- camel_multipart_set_boundary(multipart, NULL);
-
//camel_mime_part_set_filename(part, g_strdup(attach->name));
- camel_mime_part_set_content(part, attachment, len, attach->contentType);
+ if (attach->contentType) {
+ if (is_base64_encoded)
+ camel_mime_part_set_encoding (part, CAMEL_TRANSFER_ENCODING_BASE64);
+ camel_mime_part_set_content(part, attachment, len, attach->contentType);
+ camel_content_type_set_param (((CamelDataWrapper *) part)->mime_type, "name", attach->name);
+ } else {
+ camel_mime_part_set_content(part, attachment, len, "text/plain");
+ }
+ if (!has_boundary)
+ camel_data_wrapper_set_mime_type(CAMEL_DATA_WRAPPER (multipart),"multipart/digest");
+ camel_multipart_set_boundary(multipart, NULL);
camel_multipart_add_part (multipart, part);
camel_object_unref (part);
g_free (attachment);
- }
+ } /* if attachment */
}
- }
+ } /* end of for*/
-
- }
+ }/* if attach_list */
/********************/
camel_medium_set_content_object(CAMEL_MEDIUM (msg), CAMEL_DATA_WRAPPER(multipart));
-
camel_object_unref (multipart);
+end:
if (body)
g_free (body);
return msg;
}
-static gint
-string_cmp(gconstpointer a, gconstpointer b)
-{
- int ret;
- char **tmp1, **tmp2;
-
- tmp1 = g_strsplit ((const char *)a, "@", -1);
- tmp2 = g_strsplit ((const char *)b, "@", -1);
-/* g_print ("************\n");
- g_print ("%s\n%s\n",tmp1[0], tmp2[0]);
- g_print ("************\n");*/
- ret = strcmp (tmp1[0], tmp2[0]);
- g_strfreev (tmp1);
- g_strfreev (tmp2);
- return ret;
-}
-
static void
-gw_update_all_items ( CamelFolder *folder, GSList *item_list, CamelException *ex)
+gw_update_all_items (CamelFolder *folder, GList *item_list, CamelException *ex)
{
CamelGroupwiseFolder *gw_folder = CAMEL_GROUPWISE_FOLDER (folder);
- GPtrArray *summary = camel_folder_get_summary (folder);
+ GPtrArray *summary = NULL;
int index = 0;
- GSList *item_ids = NULL, *l = NULL;
+ GList *temp;
CamelFolderChangeInfo *changes = NULL;
+ CamelMessageInfo *info;
+ changes = camel_folder_change_info_new ();
- changes = camel_folder_change_info_new ();
+ item_list = g_list_reverse (item_list);
+
+ summary = camel_folder_get_summary (folder);
/*item_ids : List of ids from the summary*/
while (index < summary->len) {
- CamelMessageInfo *info = g_ptr_array_index (summary, index);
- item_ids = g_slist_append (item_ids, info->uid);
- index ++;
- }
- l = item_ids;
+ info = g_ptr_array_index (summary, index);
+ temp = NULL;
- /*item_list : List of ids from the server*/
- for (; item_ids != NULL ; item_ids = g_slist_next (item_ids)) {
- GSList *temp = NULL;
- temp = g_slist_find_custom (item_list, (const char *)item_ids->data, (GCompareFunc) string_cmp);
+ if (item_list) {
+ temp = g_list_find_custom (item_list, (const char *)info->uid, (GCompareFunc) strcmp);
+ }
+
if (!temp) {
- //g_print ("Deleting:%s\n", (const char *)item_ids->data);
CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
- camel_folder_summary_remove_uid (folder->summary, (const char *)item_ids->data);
- camel_data_cache_remove(gw_folder->cache, "cache", (const char *)item_ids->data, ex);
- camel_folder_change_info_remove_uid(changes, (const char *)item_ids->data);
+ camel_folder_summary_remove_uid (folder->summary, info->uid);
+ camel_data_cache_remove (gw_folder->cache, "cache", info->uid, ex);
+ camel_folder_change_info_remove_uid (changes, info->uid);
CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
- }
+ } else {
+ item_list = g_list_delete_link (item_list, temp);
+ }
+ index ++;
}
+
camel_object_trigger_event (folder, "folder_changed", changes);
+ if (item_list) {
+ CamelGroupwiseStore *gw_store = CAMEL_GROUPWISE_STORE (folder->parent_store);
+
+ CAMEL_SERVICE_LOCK (gw_store, connect_lock);
+ gw_update_cache (folder, item_list, ex, TRUE);
+ CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+
+ g_list_foreach (item_list, (GFunc)g_free, NULL);
+ g_list_free (item_list);
+ }
+
camel_folder_free_summary (folder, summary);
- g_slist_free (l);
}
static void
@@ -1602,13 +1862,12 @@
CamelGroupwiseStore *gw_store= CAMEL_GROUPWISE_STORE(folder->parent_store);
CamelGroupwiseStorePrivate *priv = gw_store->priv;
CamelOfflineStore *offline = (CamelOfflineStore *) folder->parent_store;
- CamelAddress *recipients;
EGwConnectionStatus status;
- EGwConnection *cnc = cnc_lookup (priv);
+ EGwConnection *cnc;
EGwItem *item;
char *id;
gboolean is_ok = FALSE;
-
+
if (!strcmp (folder->name, RECEIVED))
is_ok = TRUE;
if(!strcmp (folder->name, SENT))
@@ -1624,33 +1883,29 @@
camel_groupwise_journal_append ((CamelGroupwiseJournal *) ((CamelGroupwiseFolder *)folder)->journal, message, info, appended_uid, ex);
return;
}
+ cnc = cnc_lookup (priv);
+
CAMEL_SERVICE_LOCK (folder->parent_store, connect_lock);
/*Get the container id*/
container_id = camel_groupwise_store_container_id_lookup (gw_store, folder->full_name) ;
-
- /* FIXME Separate To/CC/BCC? */
- recipients = CAMEL_ADDRESS (camel_internet_address_new ());
- camel_address_cat (recipients, CAMEL_ADDRESS (camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO)));
- camel_address_cat (recipients, CAMEL_ADDRESS (camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC)));
- camel_address_cat (recipients, CAMEL_ADDRESS (camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_BCC)));
-
- item = camel_groupwise_util_item_from_message (cnc, message, CAMEL_ADDRESS (message->from), recipients);
+
+ item = camel_groupwise_util_item_from_message (cnc, message, CAMEL_ADDRESS (message->from));
/*Set the source*/
if (!strcmp (folder->name, RECEIVED))
- e_gw_item_set_source (item, "received");
+ e_gw_item_set_source (item, "received");
if (!strcmp (folder->name, SENT))
- e_gw_item_set_source (item, "sent");
+ e_gw_item_set_source (item, "sent");
if (!strcmp (folder->name, DRAFT))
- e_gw_item_set_source (item, "draft");
+ e_gw_item_set_source (item, "draft");
if (!strcmp (folder->name, PERSONAL))
- e_gw_item_set_source (item, "personal");
+ e_gw_item_set_source (item, "personal");
/*set container id*/
e_gw_item_set_container_id (item, container_id);
status = e_gw_connection_create_item (cnc, item, &id);
if (status != E_GW_CONNECTION_STATUS_OK) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot create message: %s"),
- e_gw_connection_get_error_message (status));
+ e_gw_connection_get_error_message (status));
if (appended_uid)
*appended_uid = NULL;
@@ -1662,7 +1917,7 @@
g_message ("Adding %s to %s", id, container_id);
if (status != E_GW_CONNECTION_STATUS_OK) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot append message to folder `%s': %s"),
- folder->full_name, e_gw_connection_get_error_message (status));
+ folder->full_name, e_gw_connection_get_error_message (status));
if (appended_uid)
*appended_uid = NULL;
@@ -1695,8 +1950,8 @@
static void
groupwise_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
- CamelFolder *destination, GPtrArray **transferred_uids,
- gboolean delete_originals, CamelException *ex)
+ CamelFolder *destination, GPtrArray **transferred_uids,
+ gboolean delete_originals, CamelException *ex)
{
int count, index = 0;
GList *item_ids = NULL;
@@ -1705,10 +1960,10 @@
CamelOfflineStore *offline = (CamelOfflineStore *) destination->parent_store;
CamelGroupwiseStorePrivate *priv = gw_store->priv;
EGwConnectionStatus status;
- EGwConnection *cnc = cnc_lookup (priv);
+ EGwConnection *cnc;
- count = camel_folder_summary_count (destination->summary);
- qsort (uids->pdata, uids->len, sizeof (void *), uid_compar);
+ count = camel_folder_summary_count (destination->summary);
+ qsort (uids->pdata, uids->len, sizeof (void *), uid_compar);
while (index < uids->len) {
item_ids = g_list_append (item_ids, g_ptr_array_index (uids, index));
@@ -1723,7 +1978,7 @@
else
source_container_id = NULL;
dest_container_id = camel_groupwise_store_container_id_lookup (gw_store, destination->full_name) ;
-
+
CAMEL_SERVICE_LOCK (source->parent_store, connect_lock);
/* check for offline operation */
if (offline->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
@@ -1731,33 +1986,37 @@
CamelMimeMessage *message;
GList *l;
int i;
-
+
for (l = item_ids, i = 0; l; l = l->next, i++) {
CamelMessageInfo *info;
if (!(info = camel_folder_summary_uid (source->summary, uids->pdata[i])))
continue;
-
+
if (!(message = groupwise_folder_get_message (source, camel_message_info_uid (info), ex)))
break;
-
+
camel_groupwise_journal_transfer (journal, (CamelGroupwiseFolder *)source, message, info, uids->pdata[i], NULL, ex);
camel_object_unref (message);
-
+
if (camel_exception_is_set (ex))
break;
-
+
if (delete_originals)
- camel_folder_set_message_flags (source, camel_message_info_uid (info),
- CAMEL_MESSAGE_DELETED, CAMEL_MESSAGE_DELETED);
+ camel_folder_delete_message(source, camel_message_info_uid (info));
}
CAMEL_SERVICE_UNLOCK (source->parent_store, connect_lock);
return;
}
-
+
+ cnc = cnc_lookup (priv);
+
index = 0;
while (index < uids->len) {
+ int count;
+ count = camel_folder_summary_count (destination->summary);
+
if (delete_originals)
status = e_gw_connection_move_item (cnc, (const char *)uids->pdata[index],
dest_container_id, source_container_id);
@@ -1765,35 +2024,18 @@
status = e_gw_connection_move_item (cnc, (const char *)uids->pdata[index],
dest_container_id, NULL);
if (status == E_GW_CONNECTION_STATUS_OK) {
- const char *old_uid = (const char*)uids->pdata[index];
- char **tmp;
- guint32 temp_flags = 0;
- CamelGroupwiseMessageInfo *src_info = (CamelGroupwiseMessageInfo *)camel_folder_summary_uid (source->summary, (const char*)uids->pdata[index]);
-
- /* we don't want to blindly copy the info: reset some flags not suitable for destination*/
- if (!strcmp(source->full_name, JUNK_FOLDER))
- camel_folder_set_message_flags (source, old_uid, CAMEL_GW_MESSAGE_JUNK|CAMEL_MESSAGE_JUNK|CAMEL_MESSAGE_JUNK_LEARN, 0);
- else if (!strcmp(destination->full_name, JUNK_FOLDER))
- camel_folder_set_message_flags (source, old_uid, CAMEL_MESSAGE_JUNK|CAMEL_GW_MESSAGE_JUNK, CAMEL_GW_MESSAGE_JUNK);
-
- CamelGroupwiseMessageInfo *dest_info = (CamelGroupwiseMessageInfo *)camel_message_info_clone((CamelMessageInfo *)src_info);
- tmp = g_strsplit (old_uid, ":", -1);
- dest_info->info.uid = g_strdup_printf ("%s:%s",tmp[0], dest_container_id);
- temp_flags = camel_folder_get_message_flags (source, (const char *)uids->pdata[index]);
- camel_folder_set_message_flags (destination, (const char *)dest_info->info.uid, temp_flags, temp_flags);
- camel_folder_summary_add (destination->summary, (CamelMessageInfo *)dest_info);
- //camel_message_info_free(dest_info);
- g_strfreev (tmp);
- if (delete_originals) {
- camel_folder_set_message_flags (source, (const char *)uids->pdata[index],
- CAMEL_MESSAGE_DELETED, CAMEL_MESSAGE_DELETED);
-
- }
+ if (delete_originals)
+ camel_folder_delete_message(source, uids->pdata[index]);
} else {
g_warning ("Warning!! Could not move item : %s\n", (char *)uids->pdata[index]);
}
index ++;
}
+ /* Refresh the destination folder, if its not refreshed already */
+ if (gw_store->current_folder != destination ||
+ camel_folder_summary_count (destination->summary) == count)
+ camel_folder_refresh_info (destination, ex);
+
camel_folder_summary_touch (source->summary);
camel_folder_summary_touch (destination->summary);
@@ -1816,8 +2058,10 @@
CamelFolderChangeInfo *changes;
int i, max;
gboolean delete = FALSE;
+ GList *deleted_items, *deleted_head;
-
+
+ deleted_items = deleted_head = NULL;
cnc = cnc_lookup (priv);
if (!cnc)
return;
@@ -1826,16 +2070,17 @@
CAMEL_SERVICE_LOCK (groupwise_store, connect_lock);
status = e_gw_connection_purge_deleted_items (cnc);
if (status == E_GW_CONNECTION_STATUS_OK) {
- camel_folder_summary_clear (folder->summary);
- camel_folder_summary_save (folder->summary);
+ camel_folder_freeze (folder);
+ groupwise_summary_clear (folder->summary, TRUE);
+ camel_folder_thaw (folder);
} else
g_warning ("Could not Empty Trash\n");
CAMEL_SERVICE_UNLOCK (groupwise_store, connect_lock);
return;
}
-
+
changes = camel_folder_change_info_new ();
-
+
container_id = g_strdup (camel_groupwise_store_container_id_lookup (groupwise_store, folder->full_name)) ;
max = camel_folder_summary_count (folder->summary);
@@ -1843,39 +2088,74 @@
info = camel_folder_summary_index (folder->summary, i);
ginfo = (CamelGroupwiseMessageInfo *) info;
if (ginfo && (ginfo->info.flags & CAMEL_MESSAGE_DELETED)) {
- const char *uid = camel_message_info_uid (info);
- CAMEL_SERVICE_LOCK (groupwise_store, connect_lock);
- status = e_gw_connection_remove_item (cnc, container_id, uid);
- if (status == E_GW_CONNECTION_STATUS_OK) {
+
+ if (deleted_items)
+ deleted_items = g_list_prepend (deleted_items, (char *)camel_message_info_uid (info));
+ else {
+ g_list_free (deleted_head);
+ deleted_head = NULL;
+ deleted_head = deleted_items = g_list_prepend (deleted_items, (char *)camel_message_info_uid (info));
+ }
+ if (g_list_length (deleted_items) == GROUPWISE_BULK_DELETE_LIMIT ) {
+ /* Read the FIXME below */
+ CAMEL_SERVICE_LOCK (groupwise_store, connect_lock);
+ status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
+ CAMEL_SERVICE_UNLOCK (groupwise_store, connect_lock);
+ if (status == E_GW_CONNECTION_STATUS_OK) {
+ char *uid;
+ while (deleted_items) {
+ uid = (char *)deleted_items->data;
+ CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
+ camel_folder_change_info_remove_uid (changes, uid);
+ camel_folder_summary_remove_uid (folder->summary, uid);
+ camel_data_cache_remove(gw_folder->cache, "cache", uid, ex);
+ CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
+ deleted_items = g_list_next (deleted_items);
+ max -= GROUPWISE_BULK_DELETE_LIMIT;
+ i -= GROUPWISE_BULK_DELETE_LIMIT;
+ }
+ }
+ delete = TRUE;
+ }
+ }
+ camel_message_info_free (info);
+ }
+
+ if (deleted_items) {
+ /* FIXME: Put these in a function and reuse it inside the above loop, here and in groupwise_sync*/
+ CAMEL_SERVICE_LOCK (groupwise_store, connect_lock);
+ status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
+ CAMEL_SERVICE_UNLOCK (groupwise_store, connect_lock);
+ if (status == E_GW_CONNECTION_STATUS_OK) {
+ char *uid;
+ while (deleted_items) {
+ uid = (char *)deleted_items->data;
CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
- camel_folder_change_info_remove_uid (changes, (char *) uid);
- camel_folder_summary_remove (folder->summary, info);
+ camel_folder_change_info_remove_uid (changes, uid);
+ camel_folder_summary_remove_uid (folder->summary, uid);
camel_data_cache_remove(gw_folder->cache, "cache", uid, ex);
CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
- delete = TRUE;
- i--; max--;
+ deleted_items = g_list_next (deleted_items);
}
- CAMEL_SERVICE_UNLOCK (groupwise_store, connect_lock);
}
- camel_message_info_free (info);
+ delete = TRUE;
+ g_list_free (deleted_head);
}
if (delete)
camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", changes);
-
-
+
g_free (container_id);
camel_folder_change_info_free (changes);
}
-
static void
camel_groupwise_folder_class_init (CamelGroupwiseFolderClass *camel_groupwise_folder_class)
{
CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS (camel_groupwise_folder_class);
-
+
parent_class = CAMEL_OFFLINE_FOLDER_CLASS (camel_type_get_global_classfuncs (camel_offline_folder_get_type ()));
-
+
((CamelObjectClass *) camel_groupwise_folder_class)->getv = gw_getv;
camel_folder_class->get_message = groupwise_folder_get_message;
@@ -1901,9 +2181,9 @@
CAMEL_MESSAGE_DRAFT | CAMEL_MESSAGE_FLAGGED | CAMEL_MESSAGE_SEEN;
folder->folder_flags = CAMEL_FOLDER_HAS_SUMMARY_CAPABILITY | CAMEL_FOLDER_HAS_SEARCH_CAPABILITY;
-
- gw_folder->priv = g_malloc0(sizeof(*gw_folder->priv));
+ gw_folder->priv = g_malloc0 (sizeof(*gw_folder->priv));
+
#ifdef ENABLE_THREADS
gw_folder->priv->search_lock = e_mutex_new(E_MUTEX_SIMPLE);
gw_folder->priv->cache_lock = e_mutex_new(E_MUTEX_REC);
@@ -1929,20 +2209,20 @@
camel_groupwise_folder_get_type (void)
{
static CamelType camel_groupwise_folder_type = CAMEL_INVALID_TYPE;
-
-
+
+
if (camel_groupwise_folder_type == CAMEL_INVALID_TYPE) {
camel_groupwise_folder_type =
camel_type_register (camel_offline_folder_get_type (),
- "CamelGroupwiseFolder",
- sizeof (CamelGroupwiseFolder),
- sizeof (CamelGroupwiseFolderClass),
- (CamelObjectClassInitFunc) camel_groupwise_folder_class_init,
- NULL,
- (CamelObjectInitFunc) camel_groupwise_folder_init,
- (CamelObjectFinalizeFunc) camel_groupwise_folder_finalize);
+ "CamelGroupwiseFolder",
+ sizeof (CamelGroupwiseFolder),
+ sizeof (CamelGroupwiseFolderClass),
+ (CamelObjectClassInitFunc) camel_groupwise_folder_class_init,
+ NULL,
+ (CamelObjectInitFunc) camel_groupwise_folder_init,
+ (CamelObjectFinalizeFunc) camel_groupwise_folder_finalize);
}
-
+
return camel_groupwise_folder_type;
}
@@ -1952,7 +2232,7 @@
CamelFolder *folder = (CamelFolder *)object;
int i, count = 0;
guint32 tag;
-
+
for (i=0 ; iargc ; i++) {
CamelArgGet *arg = &args->argv[i];
@@ -1980,7 +2260,7 @@
return ((CamelObjectClass *)parent_class)->getv(object, ex, args);
return 0;
-
+
}
void
@@ -1999,7 +2279,7 @@
gstr = g_string_append (gstr, "BEGIN:VCALENDAR\n");
gstr = g_string_append (gstr, "METHOD:REQUEST\n");
gstr = g_string_append (gstr, "BEGIN:VEVENT\n");
-
+
if ((recur_key = e_gw_item_get_recurrence_key (item)) != 0) {
char *recur_k = g_strdup_printf ("%d", recur_key);
@@ -2013,7 +2293,7 @@
g_string_append_printf (gstr, "X-GWITEM-TYPE:APPOINTMENT\n");
g_string_append_printf (gstr, "DTSTART:%s\n",e_gw_item_get_start_date (item));
g_string_append_printf (gstr, "SUMMARY:%s\n", e_gw_item_get_subject (item));
-
+
temp = e_gw_item_get_message (item);
if (temp) {
g_string_append(gstr, "DESCRIPTION:");
@@ -2035,8 +2315,8 @@
org = e_gw_item_get_organizer (item);
if (org)
g_string_append_printf (gstr, "ORGANIZER;CN= %s;ROLE= CHAIR;\n MAILTO:%s\n",
- org->display_name, org->email);
-
+ org->display_name, org->email);
+
recp_list = e_gw_item_get_recipient_list (item);
if (recp_list) {
GSList *rl ;
@@ -2048,14 +2328,14 @@
recp->display_name, recp->email);
}
}
-
+
g_string_append_printf (gstr, "DTEND:%s\n", e_gw_item_get_end_date (item));
temp = NULL;
temp = e_gw_item_get_place (item);
if (temp)
g_string_append_printf (gstr, "LOCATION:%s\n", temp);
-
+
temp = NULL;
temp = e_gw_item_get_task_priority (item);
if (temp)
@@ -2073,10 +2353,10 @@
}
gstr = g_string_append (gstr, "END:VEVENT\n");
gstr = g_string_append (gstr, "END:VCALENDAR\n");
-
+
*str = gstr->str;
*len = gstr->len;
-
+
g_string_free (gstr, FALSE);
g_strfreev (tmp);
}
@@ -2089,7 +2369,7 @@
GString *gstr = g_string_new (NULL);
char **tmp = NULL;
const char *temp = NULL;
-
+
tmp = g_strsplit (e_gw_item_get_id (item), "@", -1);
gstr = g_string_append (gstr, "BEGIN:VCALENDAR\n");
@@ -2107,8 +2387,8 @@
org = e_gw_item_get_organizer (item);
if (org)
g_string_append_printf (gstr, "ORGANIZER;CN= %s;ROLE= CHAIR;\n MAILTO:%s\n",
- org->display_name, org->email);
-
+ org->display_name, org->email);
+
recp_list = e_gw_item_get_recipient_list (item);
if (recp_list) {
GSList *rl;
@@ -2120,13 +2400,13 @@
recp->display_name, recp->email);
}
}
-
+
g_string_append_printf (gstr, "DTEND:%s\n", e_gw_item_get_end_date (item));
temp = e_gw_item_get_place (item);
if (temp)
g_string_append_printf (gstr, "LOCATION:%s\n", temp);
-
+
temp = NULL;
temp = e_gw_item_get_task_priority (item);
if (temp)
@@ -2138,13 +2418,13 @@
g_string_append_printf (gstr, "DUE:%s\n", temp);
gstr = g_string_append (gstr, "END:VTODO\n");
gstr = g_string_append (gstr, "END:VCALENDAR\n");
-
+
*str = g_strdup (gstr->str);
*len = gstr->len;
-
+
g_string_free (gstr, TRUE);
g_strfreev (tmp);
}
-
+/** End **/
Index: camel/providers/groupwise/camel-groupwise-folder.h
===================================================================
--- camel/providers/groupwise/camel-groupwise-folder.h (revision 444)
+++ camel/providers/groupwise/camel-groupwise-folder.h (working copy)
@@ -40,6 +40,8 @@
#include
#include
#include
+#include
+#include
#include
#include "camel-groupwise-summary.h"
Index: camel/providers/groupwise/Makefile.am
===================================================================
--- camel/providers/groupwise/Makefile.am (revision 444)
+++ camel/providers/groupwise/Makefile.am (working copy)
@@ -38,8 +38,8 @@
libcamelgroupwise_la_LDFLAGS = -avoid-version -module $(NO_UNDEFINED)
libcamelgroupwise_la_LIBADD = \
- $(top_builddir)/servers/groupwise/libegroupwise-$(API_VERSION).la \
- $(top_builddir)/libedataserver/libedataserver-$(API_VERSION).la \
+ $(top_builddir)/servers/groupwise/libegroupwise-1.2.la \
+ $(top_builddir)/libedataserver/libedataserver-1.2.la \
$(top_builddir)/camel/libcamel-provider-1.2.la \
$(top_builddir)/camel/libcamel-1.2.la \
$(CAMEL_LIBS) \
Index: camel/providers/groupwise/camel-groupwise-transport.c
===================================================================
--- camel/providers/groupwise/camel-groupwise-transport.c (revision 444)
+++ camel/providers/groupwise/camel-groupwise-transport.c (working copy)
@@ -141,18 +141,24 @@
CamelAddress *recipients,
CamelException *ex)
{
- CamelService *service = CAMEL_SERVICE(transport);
+ CamelService *service;
CamelStore *store = NULL;
CamelGroupwiseStore *groupwise_store = NULL;
CamelGroupwiseStorePrivate *priv = NULL;
EGwItem *item ,*temp_item=NULL;
EGwConnection *cnc = NULL;
- EGwConnectionStatus status;
+ EGwConnectionStatus status = 0;
GSList *sent_item_list = NULL;
char *url = NULL;
const char *reply_request = NULL;
EGwItemLinkInfo *info = NULL;
+ if (!transport) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, _("Authentication failed"));
+ return FALSE;
+ }
+
+ service = CAMEL_SERVICE(transport);
url = camel_url_to_string (service->url,
(CAMEL_URL_HIDE_PASSWORD |
CAMEL_URL_HIDE_PARAMS |
@@ -178,10 +184,9 @@
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, _("Authentication failed"));
return FALSE;
}
-
-
- item = camel_groupwise_util_item_from_message (cnc, message, from, recipients);
+ item = camel_groupwise_util_item_from_message (cnc, message, from);
+
reply_request = (char *)camel_medium_get_header (CAMEL_MEDIUM (message), "In-Reply-To");
if (reply_request) {
char *id;
@@ -206,11 +211,17 @@
if (status != E_GW_CONNECTION_STATUS_OK) {
g_warning (" Error Sending mail");
camel_operation_end (NULL);
+ e_gw_item_set_link_info (item, NULL);
g_object_unref (item);
if (temp_item)
g_object_unref (temp_item);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,_("Could not send message: %s"),_("Unknown error"));
+ /* FIXME: 58652 should be changed with an enum.*/
+ if (status == 58652)
+ camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, _("You have exceeded this account's storage limit. Your messages are queued in your Outbox. Resend by pressing Send/Receive after deleting/archiving some of your mail.\n"));
+ else
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,_("Could not send message: %s"),_("Unknown error"));
+ status = 0;
return FALSE;
}
e_gw_item_set_link_info (item, NULL);
Index: camel/providers/groupwise/camel-groupwise-store.c
===================================================================
--- camel/providers/groupwise/camel-groupwise-store.c (revision 444)
+++ camel/providers/groupwise/camel-groupwise-store.c (working copy)
@@ -24,34 +24,33 @@
*
*/
-
-#ifdef HAVE_CONFIG_H
#include
-#endif
#include
#include
#include
#include
-#include
#include
#include
#include
+#include
+#include
+
+#include "camel/camel-session.h"
+#include "camel/camel-debug.h"
+#include "camel/camel-i18n.h"
+#include "camel/camel-types.h"
+#include "camel/camel-folder.h"
+#include "camel/camel-private.h"
+#include "camel/camel-net-utils.h"
+
#include "camel-groupwise-store.h"
#include "camel-groupwise-summary.h"
#include "camel-groupwise-store-summary.h"
#include "camel-groupwise-folder.h"
#include "camel-groupwise-utils.h"
-#include "camel-session.h"
-#include "camel-debug.h"
-#include "camel-i18n.h"
-#include "camel-types.h"
-#include "camel-folder.h"
-#include "camel-private.h"
-#include "camel-net-utils.h"
-
#define d(x)
#define CURSOR_ITEM_LIMIT 100
#define JUNK_ENABLE 1
@@ -104,8 +103,12 @@
_("Host or user not available in url"));
}
- //store->flags = 0;
- groupwise_store->list_loaded = FALSE;
+ /*XXX: The number 3 assigned to the list_loaded variable denotes
+ * the number of times the get_folder_info is called during startup.
+ * We are just trying to minimize the call.
+ * This is a dirty hack. But it *WORKS*
+ */
+ groupwise_store->list_loaded = 3;
/*storage path*/
priv->storage_path = camel_session_get_storage_path (session, service, ex);
@@ -124,9 +127,6 @@
priv->server_name = g_strdup (url->host);
priv->user = g_strdup (url->user);
- /*remove the sync option*/
-/* if (camel_url_get_param ((service->url, "sync_offline") != NULL)
- camel_url_set_param (service->url, "sync_offline", NULL);*/
/*base url*/
priv->base_url = camel_url_to_string (service->url, (CAMEL_URL_HIDE_PASSWORD |
CAMEL_URL_HIDE_PARAMS |
@@ -146,9 +146,9 @@
store->flags |= CAMEL_STORE_FILTER_INBOX;
/*Hash Table*/
- priv->id_hash = g_hash_table_new (g_str_hash, g_str_equal);
- priv->name_hash = g_hash_table_new (g_str_hash, g_str_equal);
- priv->parent_hash = g_hash_table_new (g_str_hash, g_str_equal);
+ priv->id_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+ priv->name_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+ priv->parent_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
/*ssl*/
priv->use_ssl = g_strdup (camel_url_get_param (url, "use_ssl"));
@@ -174,9 +174,9 @@
static gboolean
groupwise_auth_loop (CamelService *service, CamelException *ex)
{
- CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (service);
CamelSession *session = camel_service_get_session (service);
CamelStore *store = CAMEL_STORE (service);
+ CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (store);
CamelGroupwiseStorePrivate *priv = groupwise_store->priv;
char *errbuf = NULL;
gboolean authenticated = FALSE;
@@ -188,6 +188,7 @@
else
uri = g_strconcat ("http://", priv->server_name, ":", priv->port, "/soap", NULL);
service->url->passwd = NULL;
+
while (!authenticated) {
if (errbuf) {
@@ -197,6 +198,7 @@
service->url->passwd = NULL;
}
+
if (!service->url->passwd && !(store->flags & CAMEL_STORE_PROXY)) {
char *prompt;
@@ -214,13 +216,11 @@
if (!service->url->passwd) {
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("You didn't enter a password."));
+ _("You did not enter a password."));
return FALSE;
}
}
-
-
priv->cnc = e_gw_connection_new (uri, priv->user, service->url->passwd);
if (!E_IS_GW_CONNECTION(priv->cnc) && priv->use_ssl && g_str_equal (priv->use_ssl, "when-possible")) {
char *http_uri = g_strconcat ("http://", uri + 8, NULL);
@@ -229,7 +229,7 @@
}
if (!E_IS_GW_CONNECTION(priv->cnc)) {
errbuf = g_strdup_printf (_("Unable to authenticate "
- "to GroupWise server."));
+ "to GroupWise server. "));
camel_exception_clear (ex);
} else
@@ -263,6 +263,7 @@
return TRUE;
}
+
static gboolean
groupwise_connect (CamelService *service, CamelException *ex)
{
@@ -273,9 +274,18 @@
d("in groupwise store connect\n");
- if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
- return TRUE;
-
+/* if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL ||
+ (service->status == CAMEL_SERVICE_DISCONNECTED))
+ return FALSE; */
+ if (service->status == CAMEL_SERVICE_DISCONNECTED)
+ return FALSE;
+
+ if (!priv) {
+ store->priv = g_new0 (CamelGroupwiseStorePrivate, 1);
+ priv = store->priv;
+ camel_service_construct (service, service->session, service->provider, service->url, ex);
+ }
+
CAMEL_SERVICE_LOCK (service, connect_lock);
if (priv->cnc) {
@@ -289,7 +299,9 @@
return FALSE;
}
+
service->status = CAMEL_SERVICE_CONNECTED;
+ ((CamelOfflineStore *) store)->state = CAMEL_OFFLINE_STORE_NETWORK_AVAIL;
if (!e_gw_connection_get_version (priv->cnc)) {
camel_session_alert_user(session,
@@ -299,19 +311,10 @@
}
-
ns = camel_groupwise_store_summary_namespace_new (store->summary, priv->storage_path, '/');
camel_groupwise_store_summary_namespace_set (store->summary, ns);
if (camel_store_summary_count ((CamelStoreSummary *)store->summary) == 0) {
- /*XXX: Have to sync up folders here*/
- groupwise_folders_sync (store, ex);
- if (camel_exception_is_set (ex)) {
- camel_store_summary_save ((CamelStoreSummary *) store->summary);
- CAMEL_SERVICE_UNLOCK (service, connect_lock);
- camel_service_disconnect (service, TRUE, NULL);
- return FALSE;
- }
/*Settting the refresh stamp to the current time*/
store->refresh_stamp = time (0);
}
@@ -326,19 +329,75 @@
return FALSE;
}
+static void
+groupwise_disconnect_cleanup (CamelService *service, gboolean clean, CamelException *ex)
+{
+ CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (service);
+ CamelGroupwiseStorePrivate *priv = groupwise_store->priv;
+
+ g_print ("camel_groupwise_store_finalize\n");
+ if (groupwise_store->summary) {
+ camel_store_summary_save ((CamelStoreSummary *)groupwise_store->summary);
+ camel_object_unref (groupwise_store->summary);
+ }
+
+ if (priv) {
+ if (priv->user) {
+ g_free (priv->user);
+ priv->user = NULL;
+ }
+ if (priv->server_name) {
+ g_free (priv->server_name);
+ priv->server_name = NULL;
+ }
+ if (priv->port) {
+ g_free (priv->port);
+ priv->port = NULL;
+ }
+ if (priv->use_ssl) {
+ g_free (priv->use_ssl);
+ priv->use_ssl = NULL;
+ }
+ if (priv->base_url) {
+ g_free (priv->base_url);
+ priv->base_url = NULL;
+ }
+
+ if (priv->storage_path)
+ g_free(priv->storage_path);
+ if(groupwise_store->root_container)
+ g_free (groupwise_store->root_container);
+
+ if (priv->id_hash)
+ g_hash_table_destroy (priv->id_hash);
+
+ if (priv->name_hash)
+ g_hash_table_destroy (priv->name_hash);
+
+ if (priv->parent_hash)
+ g_hash_table_destroy (priv->parent_hash);
+
+ g_free (groupwise_store->priv);
+ groupwise_store->priv = NULL;
+ }
+}
+
static gboolean
groupwise_disconnect (CamelService *service, gboolean clean, CamelException *ex)
{
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (service);
- CAMEL_SERVICE_LOCK (groupwise_store, connect_lock);
- if (groupwise_store->priv->cnc) {
- g_object_unref (groupwise_store->priv->cnc);
- groupwise_store->priv->cnc = NULL;
+ if (clean) {
+ CAMEL_SERVICE_LOCK (groupwise_store, connect_lock);
+ if (groupwise_store->priv && groupwise_store->priv->cnc) {
+ g_object_unref (groupwise_store->priv->cnc);
+ groupwise_store->priv->cnc = NULL;
+ }
+ CAMEL_SERVICE_UNLOCK (groupwise_store, connect_lock);
}
- CAMEL_SERVICE_UNLOCK (groupwise_store, connect_lock);
+ //groupwise_disconnect_cleanup (service, clean, ex);
return TRUE;
}
@@ -399,7 +458,15 @@
name = fi->full_name;
else
name++;
-
+ if (!strcmp (folder_name, "Sent Items"))
+ fi->flags |= CAMEL_FOLDER_TYPE_SENT;
+ else if (!strcmp (folder_name, "Mailbox"))
+ fi->flags |= CAMEL_FOLDER_TYPE_INBOX;
+ else if (!strcmp (folder_name, "Trash"))
+ fi->flags |= CAMEL_FOLDER_TYPE_TRASH;
+ else if (!strcmp (folder_name, "Junk Mail"))
+ fi->flags |= CAMEL_FOLDER_TYPE_JUNK;
+
fi->name = g_strdup(name);
return fi;
}
@@ -420,7 +487,7 @@
storage_path = g_strdup_printf ("%s/folders", priv->storage_path);
folder_dir = g_strdup(e_path_to_physical (storage_path,folder_name));
- if (access(folder_dir, F_OK) != 0) {
+ if (g_access(folder_dir, F_OK) != 0) {
g_free(folder_dir);
return;
}
@@ -434,15 +501,15 @@
}
camel_object_unref (summary);
- unlink (summary_file);
+ g_unlink (summary_file);
g_free (summary_file);
state_file = g_strdup_printf ("%s/cmeta", folder_dir);
- unlink (state_file);
+ g_unlink (state_file);
g_free (state_file);
- rmdir (folder_dir);
+ g_rmdir (folder_dir);
g_free (folder_dir);
camel_store_summary_remove_path ( (CamelStoreSummary *)gw_store->summary, folder_name);
@@ -464,7 +531,7 @@
storage_path = g_strdup_printf("%s/folders", priv->storage_path);
folder_dir = e_path_to_physical (storage_path, folder_name);
g_free(storage_path);
- if (!folder_dir || access (folder_dir, F_OK) != 0) {
+ if (!folder_dir || g_access (folder_dir, F_OK) != 0) {
g_free (folder_dir);
camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
_("No such folder %s"), folder_name);
@@ -487,7 +554,7 @@
char *container_id, *folder_dir, *storage_path;
EGwConnectionStatus status;
GList *list = NULL;
- gboolean done = FALSE;
+ gboolean done = FALSE, all_ok = TRUE;
const char *position = E_GW_CURSOR_POSITION_END;
int count = 0, cursor, summary_count = 0;
CamelStoreInfo *si = NULL;
@@ -536,22 +603,21 @@
return NULL;
}
g_free (folder_dir);
-
+
si = camel_store_summary_path ((CamelStoreSummary *)gw_store->summary, folder_name);
if (si) {
- camel_object_get (folder, NULL, CAMEL_FOLDER_TOTAL, &total, NULL);
+ total = si->total;
camel_store_summary_info_free ((CamelStoreSummary *)(gw_store)->summary, si);
- g_print ("TOTAL:%d\n\n", total);
}
summary = (CamelGroupwiseSummary *) folder->summary;
summary_count = camel_folder_summary_count (folder->summary);
if(!summary_count || !summary->time_string) {
- g_print ("\n\n** %s **: No summary as yet : using get cursor request\n\n", folder->name);
+ d(g_print ("\n\n** %s **: No summary as yet : using get cursor request\n\n", folder->name);)
status = e_gw_connection_create_cursor (priv->cnc, container_id,
- "peek id recipient attachments distribution subject status options priority startDate created",
+ "peek id recipient attachments distribution subject status options priority startDate created delivered size hasAttachment",
NULL,
&cursor);
if (status != E_GW_CONNECTION_STATUS_OK) {
@@ -560,7 +626,7 @@
return NULL;
}
- camel_operation_start (NULL, _("Fetching summary information for new messages"));
+ camel_operation_start (NULL, _("Fetching summary information for new messages in %s"), folder->name);
camel_folder_summary_clear (folder->summary);
while (!done) {
@@ -568,14 +634,18 @@
cursor, FALSE,
CURSOR_ITEM_LIMIT, position, &list);
if (status != E_GW_CONNECTION_STATUS_OK) {
+ all_ok = FALSE;
+ break;
+ /*
CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
e_gw_connection_destroy_cursor (priv->cnc, container_id, cursor);
- camel_folder_summary_clear (folder->summary);
+ //camel_folder_summary_clear (folder->summary);
camel_folder_summary_save (folder->summary);
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Authentication failed"));
camel_operation_end (NULL);
+ camel_object_unref (folder);
g_free (container_id);
- return NULL;
+ return NULL;*/
}
count += g_list_length (list);
@@ -596,8 +666,7 @@
camel_operation_end (NULL);
}
-
- if (done) {
+ if (done && all_ok) {
if (summary->time_string)
g_free (summary->time_string);
summary->time_string = g_strdup (e_gw_connection_get_server_time (priv->cnc));
@@ -614,21 +683,111 @@
return folder;
}
-static gboolean
-get_one_folder_offline (const char *physical_path, const char *path, gpointer data)
+void
+gw_store_reload_folder (CamelGroupwiseStore *gw_store, CamelFolder *folder, guint32 flags, CamelException *ex)
{
- GPtrArray *folders = data;
- CamelGroupwiseStore *groupwise_store = folders->pdata[0];
- CamelFolderInfo *fi;
+ CamelGroupwiseStorePrivate *priv = gw_store->priv;
+ CamelGroupwiseSummary *summary;
+ char *container_id;
+ EGwConnectionStatus status;
+ GList *list = NULL;
+ gboolean done = FALSE;
+ const char *position = E_GW_CURSOR_POSITION_END;
+ int count = 0, cursor, summary_count = 0;
+ CamelStoreInfo *si = NULL;
+ guint total;
+
+ camel_exception_clear (ex);
+
+ CAMEL_SERVICE_LOCK (gw_store, connect_lock);
+
+ if (!camel_groupwise_store_connected (gw_store, ex)) {
+ CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+ return;
+ }
+
+ if (!E_IS_GW_CONNECTION( priv->cnc)) {
+ if (!groupwise_connect (CAMEL_SERVICE((CamelStore*)gw_store), ex)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, _("Authentication failed"));
+ CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+ return;
+ }
+ }
+
+ container_id = g_strdup (g_hash_table_lookup (priv->name_hash, folder->full_name));
+
+ si = camel_store_summary_path ((CamelStoreSummary *)gw_store->summary, folder->name);
+ if (si) {
+ total = si->total;
+ camel_store_summary_info_free ((CamelStoreSummary *)(gw_store)->summary, si);
+ }
+
+ summary = (CamelGroupwiseSummary *) folder->summary;
+ camel_folder_summary_clear (folder->summary);
+ camel_folder_summary_save (folder->summary);
+
+ summary_count = camel_folder_summary_count (folder->summary);
+ if(!summary_count || !summary->time_string) {
+ d(g_print ("\n\n** %s **: Summary missing???? Reloading summary....\n\n", folder->name);)
+
+ status = e_gw_connection_create_cursor (priv->cnc, container_id,
+ "peek id recipient attachments distribution subject status options priority startDate created delivered size",
+ NULL,
+ &cursor);
+ if (status != E_GW_CONNECTION_STATUS_OK) {
+ CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+ g_free (container_id);
+ return;
+ }
+
+ camel_operation_start (NULL, _("Fetching summary information for new messages in %s"), folder->name);
+
+ while (!done) {
+ status = e_gw_connection_read_cursor (priv->cnc, container_id,
+ cursor, FALSE,
+ CURSOR_ITEM_LIMIT, position, &list);
+ if (status != E_GW_CONNECTION_STATUS_OK) {
+ CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+ e_gw_connection_destroy_cursor (priv->cnc, container_id, cursor);
+ camel_folder_summary_save (folder->summary);
+ camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Authentication failed"));
+ camel_operation_end (NULL);
+ g_free (container_id);
+ return;
+ }
+
+ count += g_list_length (list);
- if (*path != '/')
- return TRUE;
+ if (total > 0)
+ camel_operation_progress (NULL, (100*count)/total);
+ gw_update_summary (folder, list, ex);
+
+ if (!list)
+ done = TRUE;
+ g_list_foreach (list, (GFunc)g_object_unref, NULL);
+ g_list_free (list);
+ list = NULL;
+ position = E_GW_CURSOR_POSITION_CURRENT;
+ }
+
+ e_gw_connection_destroy_cursor (priv->cnc, container_id, cursor);
+
+ camel_operation_end (NULL);
+ }
+
+ if (done) {
+ if (summary->time_string)
+ g_free (summary->time_string);
+ summary->time_string = g_strdup (e_gw_connection_get_server_time (priv->cnc));
+ }
+
+ camel_folder_summary_save (folder->summary);
+
+ gw_store->current_folder = folder;
- fi = groupwise_build_folder_info(groupwise_store, NULL, path+1);
- if (!strcmp (fi->full_name, "Mailbox"))
- fi->flags |= CAMEL_FOLDER_TYPE_INBOX;
- g_ptr_array_add (folders, fi);
- return TRUE;
+ g_free (container_id);
+ CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+ return;
}
CamelFolderInfo *
@@ -715,13 +874,16 @@
if (e_gw_container_get_is_shared_by_me (container))
fi->flags |= CAMEL_FOLDER_SHARED_BY_ME;
- if (type == E_GW_CONTAINER_TYPE_INBOX) {
+ /*if (type == E_GW_CONTAINER_TYPE_INBOX) {
fi->total = -1;
fi->unread = -1;
- } else if (type == E_GW_CONTAINER_TYPE_TRASH) {
+ } else if (type == E_GW_CONTAINER_TYPE_TRASH) {*/
+
+ if (type == E_GW_CONTAINER_TYPE_TRASH || type == E_GW_CONTAINER_TYPE_SENT) {
fi->total = e_gw_container_get_total_count (container);
- fi->unread = 0;
- }else {
+ fi->unread = 0;
+ /* Done with a belief that user wont mark something as unread in Trash and Sent Items */
+ } else {
fi->total = e_gw_container_get_total_count (container);
fi->unread = e_gw_container_get_unread_count (container);
}
@@ -756,6 +918,13 @@
CamelStoreInfo *si = NULL;
int count, i;
+ if (!priv->cnc && ((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL) {
+ if (((CamelService *)store)->status == CAMEL_SERVICE_DISCONNECTED){
+ ((CamelService *)store)->status = CAMEL_SERVICE_CONNECTING;
+ groupwise_connect ((CamelService *)store, ex);
+ }
+ }
+
status = e_gw_connection_get_container_list (priv->cnc, "folders", &folder_list);
if (status != E_GW_CONNECTION_STATUS_OK) {
g_warning ("Could not get folder list..\n");
@@ -807,7 +976,6 @@
if ( (type == E_GW_CONTAINER_TYPE_CALENDAR) || (type == E_GW_CONTAINER_TYPE_CONTACTS) )
continue;
- //convert_to_folder_info (store, E_GW_CONTAINER (folder_list->data), (const char *)url, ex);
info = convert_to_folder_info (store, E_GW_CONTAINER (folder_list->data), (const char *)url, ex);
if (info) {
hfi = g_hash_table_lookup (present, info->full_name);
@@ -958,47 +1126,57 @@
if (top && groupwise_is_system_folder (top))
return groupwise_build_folder_info (groupwise_store, NULL, top );
+
/*
* Thanks to Michael, for his cached folders implementation in IMAP
* is used as is here.
*/
- if ((groupwise_store->list_loaded == TRUE) && camel_store_summary_count((CamelStoreSummary *)groupwise_store->summary) > 0) {
- /*Load from cache*/
- time_t now;
- int ref;
-
- now = time (0);
- ref = now > groupwise_store->refresh_stamp+60*60*1;
- if (ref) {
- CAMEL_SERVICE_LOCK (store, connect_lock);
- ref = now > groupwise_store->refresh_stamp+60*60*1;
- if (ref) {
- struct _store_refresh_msg *m;
- groupwise_store->refresh_stamp = now;
- m = camel_session_thread_msg_new (((CamelService *)store)->session, &store_refresh_ops, sizeof(*m));
- m->store = store;
- camel_object_ref (store);
- camel_exception_init (&m->ex);
- camel_session_thread_queue (((CamelService *)store)->session, &m->msg, 0);
- }
- CAMEL_SERVICE_UNLOCK (store, connect_lock);
+ if (camel_store_summary_count ((CamelStoreSummary *)groupwise_store->summary) == 0) {
+ CAMEL_SERVICE_LOCK (store, connect_lock);
+ if (groupwise_store->list_loaded == 3) {
+ groupwise_folders_sync (groupwise_store, ex);
+ groupwise_store->list_loaded -= 1;
}
- }
-
- CAMEL_SERVICE_LOCK (store, connect_lock);
- if ((groupwise_store->list_loaded == FALSE) && camel_groupwise_store_connected ((CamelGroupwiseStore *)store, ex)) {
- groupwise_store->list_loaded = TRUE;
- groupwise_folders_sync (groupwise_store, ex);
if (camel_exception_is_set (ex)) {
+ camel_store_summary_save ((CamelStoreSummary *) groupwise_store->summary);
CAMEL_SERVICE_UNLOCK (store, connect_lock);
return NULL;
}
- camel_store_summary_touch ((CamelStoreSummary *)groupwise_store->summary);
+ CAMEL_SERVICE_UNLOCK (store, connect_lock);
camel_store_summary_save ((CamelStoreSummary *)groupwise_store->summary);
+ goto end_r;
}
+
+ if ((camel_store_summary_count((CamelStoreSummary *)groupwise_store->summary) > 0) && (groupwise_store->list_loaded > 1)) {
+ /*Load from cache*/
+ groupwise_store->list_loaded -= 1;
+ goto end_r;
+ }
+
+ CAMEL_SERVICE_LOCK (store, connect_lock);
+ if ((groupwise_store->list_loaded == 1) && check_for_connection((CamelService *)store, ex)) {
+ if (!priv->cnc) {
+ if (groupwise_connect ((CamelService *)store, ex)) {
+ g_warning ("Could connect!!!\n");
+ } else
+ g_warning ("Could not connect..failure connecting\n");
+ }
+ if (camel_groupwise_store_connected ((CamelGroupwiseStore *)store, ex)) {
+ if (groupwise_store->current_folder)
+ CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS (groupwise_store->current_folder))->sync(groupwise_store->current_folder, FALSE, ex);
+ groupwise_folders_sync (groupwise_store, ex);
+ if (camel_exception_is_set (ex)) {
+ CAMEL_SERVICE_UNLOCK (store, connect_lock);
+ return NULL;
+ }
+ camel_store_summary_touch ((CamelStoreSummary *)groupwise_store->summary);
+ camel_store_summary_save ((CamelStoreSummary *)groupwise_store->summary);
+ }
+ }
CAMEL_SERVICE_UNLOCK (store, connect_lock);
- //camel_exception_clear (ex);
+ /*camel_exception_clear (ex);*/
+end_r:
info = groupwise_get_folder_info_offline (store, top, flags, ex);
return info;
}
@@ -1181,7 +1359,7 @@
g_free (storepath);
/*XXX: make sure the summary is also renamed*/
- if (rename (oldpath, newpath) == -1) {
+ if (g_rename (oldpath, newpath) == -1) {
g_warning ("Could not rename message cache '%s' to '%s': %s: cache reset",
oldpath, newpath, strerror (errno));
}
@@ -1236,26 +1414,20 @@
return priv->base_url;
}
-static void
-free_hash (gpointer key, gpointer value, gpointer data)
-{
- if (value)
- g_free (value);
- if (key)
- g_free (key);
-}
-
static CamelFolder *
groupwise_get_trash (CamelStore *store, CamelException *ex)
{
- CamelFolder *folder = groupwise_get_folder (store, "Trash", 0, ex);
+ CamelFolder *folder = camel_store_get_folder(store, "Trash", 0, ex);
if (folder) {
- g_print ("Trash Folder exists\n");
+ char *state = g_build_filename(((CamelGroupwiseStore *)store)->priv->storage_path, "folders", "Trash", "cmeta", NULL);
+
+ camel_object_set(folder, NULL, CAMEL_OBJECT_STATE_FILE, state, NULL);
+ g_free(state);
+ camel_object_state_read(folder);
+
return folder;
- } else {
- g_print ("Trash Folder does not\n");
+ } else
return NULL;
- }
}
/*
@@ -1266,14 +1438,10 @@
camel_groupwise_store_connected (CamelGroupwiseStore *store, CamelException *ex)
{
if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL
- && camel_service_connect ((CamelService *)store, ex)
- && store->priv->cnc != NULL )
+ && camel_service_connect ((CamelService *)store, ex)) {
return TRUE;
-
- if (!camel_exception_is_set (ex))
- camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("You must be working online to complete this operation"));
-
+ }
+ /*Not online, so return FALSE*/
return FALSE;
}
@@ -1378,18 +1546,15 @@
if(groupwise_store->root_container)
g_free (groupwise_store->root_container);
- if (priv->id_hash) {
- g_hash_table_foreach (priv->id_hash, free_hash, NULL);
+ if (priv->id_hash)
g_hash_table_destroy (priv->id_hash);
- }
- if (priv->name_hash) {
- g_hash_table_foreach (priv->name_hash, free_hash, NULL);
+
+ if (priv->name_hash)
g_hash_table_destroy (priv->name_hash);
- }
- if (priv->parent_hash) {
- g_hash_table_foreach (priv->parent_hash, free_hash, NULL);
+
+ if (priv->parent_hash)
g_hash_table_destroy (priv->parent_hash);
- }
+
g_free (groupwise_store->priv);
groupwise_store->priv = NULL;
}
Index: camel/providers/imapp/camel-imapp-folder.c
===================================================================
--- camel/providers/imapp/camel-imapp-folder.c (revision 444)
+++ camel/providers/imapp/camel-imapp-folder.c (working copy)
@@ -42,6 +42,7 @@
#include "camel-imapp-exception.h"
#include
+#include
#include
#include
@@ -134,7 +135,7 @@
char *base = g_build_filename(root, path, NULL);
char *file = g_build_filename(base, ".ev-summary", NULL);
- camel_mkdir(base, 0777);
+ e_util_mkdir_hier(base, 0777);
g_free(base);
camel_folder_summary_set_filename(folder->summary, file);
Index: camel/providers/imapp/ChangeLog
===================================================================
--- camel/providers/imapp/ChangeLog (revision 444)
+++ camel/providers/imapp/ChangeLog (working copy)
@@ -1,3 +1,9 @@
+2006-06-15 Andre Klapper
+
+ * camel-imapp-store.c:
+ changing "cancelled" to "canceled" in user-visible strings.
+ Fixes bug #342163.
+
2005-04-17 Changwoo Ryu
** See bug #300891
Index: camel/providers/imapp/camel-imapp-store.c
===================================================================
--- camel/providers/imapp/camel-imapp-store.c (revision 444)
+++ camel/providers/imapp/camel-imapp-store.c (working copy)
@@ -245,7 +245,7 @@
camel_freeaddrinfo(ai);
if (ret == -1) {
if (errno == EINTR)
- camel_exception_throw(CAMEL_EXCEPTION_USER_CANCEL, _("Connection cancelled"));
+ camel_exception_throw(CAMEL_EXCEPTION_USER_CANCEL, _("Connection canceled"));
else
camel_exception_throw(CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("Could not connect to %s (port %s): %s"),
Index: camel/providers/imapp/camel-imapp-summary.c
===================================================================
--- camel/providers/imapp/camel-imapp-summary.c (revision 444)
+++ camel/providers/imapp/camel-imapp-summary.c (working copy)
@@ -115,18 +115,28 @@
summary_header_load(CamelFolderSummary *s, FILE *in)
{
CamelIMAPPSummary *ims = CAMEL_IMAPP_SUMMARY(s);
+ unsigned char *ptrchr = s->filepos;
+ gint32 *ptr32;
if (camel_imapp_summary_parent->summary_header_load(s, in) == -1)
return -1;
/* Legacy version */
if (s->version == 0x100c)
- return camel_file_util_decode_uint32(in, &ims->uidvalidity);
+ {
+ ptrchr = camel_file_util_mmap_decode_uint32 (ptrchr, &ims->uidvalidity, FALSE);
+ s->filepos = ptrchr;
- if (camel_file_util_decode_fixed_int32(in, &ims->version) == -1
- || camel_file_util_decode_fixed_int32(in, &ims->uidvalidity) == -1)
- return -1;
+ return 0;
+ }
+ ptr32 = s->filepos;
+
+ ims->version = g_ntohl (*ptr32); ptr32++;
+ ims->uidvalidity = g_ntohl (*ptr32); ptr32++;
+
+ s->filepos = ptr32;
+
if (ims->version > CAMEL_IMAPP_SUMMARY_VERSION) {
g_warning("Unkown summary version\n");
errno = EINVAL;
@@ -160,16 +170,14 @@
info = camel_imapp_summary_parent->message_info_load(s, in);
if (info) {
+ unsigned char *ptrchr = s->filepos;
iinfo =(CamelIMAPPMessageInfo *)info;
- if (camel_file_util_decode_uint32(in, &iinfo->server_flags) == -1)
- goto error;
+ ptrchr = camel_file_util_mmap_decode_uint32 (ptrchr, &iinfo->server_flags, FALSE);
+ s->filepos = ptrchr;
}
return info;
-error:
- camel_message_info_free(info);
- return NULL;
}
static int
Index: camel/providers/imap/camel-imap-store.c
===================================================================
--- camel/providers/imap/camel-imap-store.c (revision 444)
+++ camel/providers/imap/camel-imap-store.c (working copy)
@@ -24,9 +24,7 @@
*
*/
-#ifdef HAVE_CONFIG_H
#include
-#endif
#include
#include
@@ -34,40 +32,55 @@
#include
#include
+#include
+#include
+
+#include "camel/camel-debug.h"
+#include "camel/camel-disco-diary.h"
+#include "camel/camel-exception.h"
+#include "camel/camel-file-utils.h"
+#include "camel/camel-folder.h"
+#include "camel/camel-i18n.h"
+#include "camel/camel-net-utils.h"
+#include "camel/camel-private.h"
+#include "camel/camel-sasl.h"
+#include "camel/camel-session.h"
+#include "camel/camel-stream-buffer.h"
+#include "camel/camel-stream-fs.h"
+#include "camel/camel-stream-process.h"
+#include "camel/camel-stream.h"
+#include "camel/camel-string-utils.h"
+#include "camel/camel-tcp-stream-raw.h"
+#include "camel/camel-tcp-stream-ssl.h"
+#include "camel/camel-url.h"
+#include "camel/camel-utf8.h"
+
+#include "camel-imap-command.h"
+#include "camel-imap-folder.h"
+#include "camel-imap-message-cache.h"
+#include "camel-imap-store-summary.h"
#include "camel-imap-store.h"
-#include "camel-imap-store-summary.h"
-#include "camel-imap-folder.h"
+#include "camel-imap-summary.h"
#include "camel-imap-utils.h"
-#include "camel-imap-command.h"
-#include "camel-imap-summary.h"
-#include "camel-imap-message-cache.h"
-#include "camel-disco-diary.h"
-#include "camel-file-utils.h"
-#include "camel-folder.h"
-#include "camel-exception.h"
-#include "camel-session.h"
-#include "camel-stream.h"
-#include "camel-stream-buffer.h"
-#include "camel-stream-fs.h"
-#include "camel-stream-process.h"
-#include "camel-tcp-stream-raw.h"
-#include "camel-tcp-stream-ssl.h"
-#include "camel-url.h"
-#include "camel-sasl.h"
-#include "camel-utf8.h"
-#include "camel-string-utils.h"
-#include "camel-imap-private.h"
-#include "camel-private.h"
-#include "camel-debug.h"
-#include "camel-i18n.h"
-#include "camel-net-utils.h"
+#if !GLIB_CHECK_VERSION (2, 8, 0)
+#define g_access access
+#endif
+
#define d(x)
/* Specified in RFC 2060 */
#define IMAP_PORT "143"
#define IMAPS_PORT "993"
+#ifdef G_OS_WIN32
+/* The strtok() in Microsoft's C library is MT-safe (but still uses
+ * only one buffer pointer per thread, but for the use of strtok_r()
+ * here that's enough).
+ */
+#define strtok_r(s,sep,lasts) (*(lasts)=strtok((s),(sep)))
+#endif
+
static CamelDiscoStoreClass *parent_class = NULL;
static char imap_tag_prefix = 'A';
@@ -245,8 +258,8 @@
CamelException *ex)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (service);
+ CamelStore *store = CAMEL_STORE (service);
CamelDiscoStore *disco_store = CAMEL_DISCO_STORE (service);
- CamelStore *store = CAMEL_STORE (service);
char *tmp, *path;
CamelURL *summary_url;
@@ -266,7 +279,7 @@
imap_store->parameters = 0;
if (camel_url_get_param (url, "use_lsub"))
imap_store->parameters |= IMAP_PARAM_SUBSCRIPTIONS;
- if (camel_url_get_param (url, "namespace")) {
+ if (camel_url_get_param (url, "override_namespace") && camel_url_get_param (url, "namespace")) {
imap_store->parameters |= IMAP_PARAM_OVERRIDE_NAMESPACE;
g_free(imap_store->namespace);
imap_store->namespace = g_strdup (camel_url_get_param (url, "namespace"));
@@ -550,7 +563,7 @@
CamelStream *tcp_stream;
CamelSockOptData sockopt;
gboolean force_imap4 = FALSE;
- int clean_quit = TRUE, ret;
+ gboolean clean_quit = TRUE;
char *buf;
if (ssl_mode != MODE_CLEAR) {
@@ -571,7 +584,7 @@
tcp_stream = camel_tcp_stream_raw_new ();
}
- if ((ret = camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai)) == -1) {
+ if (camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai) == -1) {
if (errno == EINTR)
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
_("Connection cancelled"));
@@ -759,6 +772,10 @@
return FALSE;
}
+#ifndef G_OS_WIN32
+
+/* Using custom commands to connect to IMAP servers is not supported on Win32 */
+
static gboolean
connect_to_server_process (CamelService *service, const char *cmd, CamelException *ex)
{
@@ -902,6 +919,8 @@
}
+#endif
+
static struct {
char *value;
char *serv;
@@ -918,16 +937,19 @@
static gboolean
connect_to_server_wrapper (CamelService *service, CamelException *ex)
{
- const char *command, *ssl_mode;
+ const char *ssl_mode;
struct addrinfo hints, *ai;
int mode, ret, i;
char *serv;
const char *port;
+#ifndef G_OS_WIN32
+ const char *command;
+
if (camel_url_get_param(service->url, "use_command")
&& (command = camel_url_get_param(service->url, "command")))
return connect_to_server_process(service, command, ex);
-
+#endif
if ((ssl_mode = camel_url_get_param (service->url, "use_ssl"))) {
for (i = 0; ssl_options[i].value; i++)
if (!strcmp (ssl_options[i].value, ssl_mode))
@@ -955,16 +977,11 @@
camel_exception_clear (ex);
ai = camel_getaddrinfo(service->url->host, port, &hints, ex);
}
+
if (ai == NULL)
return FALSE;
- if (!(ret = connect_to_server (service, ai, mode, ex)) && mode == MODE_SSL) {
- camel_exception_clear (ex);
- ret = connect_to_server (service, ai, MODE_TLS, ex);
- } else if (!ret && mode == MODE_TLS) {
- camel_exception_clear (ex);
- ret = connect_to_server (service, ai, MODE_CLEAR, ex);
- }
+ ret = connect_to_server (service, ai, mode, ex);
camel_freeaddrinfo (ai);
@@ -1088,7 +1105,7 @@
storage_path = g_strdup_printf ("%s/folders", imap_store->storage_path);
folder_dir = imap_path_to_physical (storage_path, folder_name);
g_free (storage_path);
- if (access (folder_dir, F_OK) != 0) {
+ if (g_access (folder_dir, F_OK) != 0) {
g_free (folder_dir);
goto event;
}
@@ -1108,22 +1125,22 @@
camel_object_unref (cache);
camel_object_unref (summary);
- unlink (summary_file);
+ g_unlink (summary_file);
g_free (summary_file);
journal_file = g_strdup_printf ("%s/journal", folder_dir);
- unlink (journal_file);
+ g_unlink (journal_file);
g_free (journal_file);
state_file = g_strdup_printf ("%s/cmeta", folder_dir);
- unlink (state_file);
+ g_unlink (state_file);
g_free (state_file);
state_file = g_strdup_printf("%s/subfolders", folder_dir);
- rmdir(state_file);
+ g_rmdir(state_file);
g_free(state_file);
- rmdir (folder_dir);
+ g_rmdir (folder_dir);
g_free (folder_dir);
event:
@@ -1158,6 +1175,7 @@
return TRUE;
}
+#if 0
/* This is a little 'hack' to avoid the deadlock conditions that would otherwise
ensue when calling camel_folder_refresh_info from inside a lock */
/* NB: on second thougts this is probably not entirely safe, but it'll do for now */
@@ -1204,7 +1222,8 @@
}
g_ptr_array_free (folders, TRUE);
-}
+}
+#endif
static gboolean
try_auth (CamelImapStore *store, const char *mech, CamelException *ex)
@@ -1338,7 +1357,7 @@
if (!service->url->passwd) {
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- _("You didn't enter a password."));
+ _("You did not enter a password."));
return FALSE;
}
}
@@ -1389,10 +1408,9 @@
imap_connect_online (CamelService *service, CamelException *ex)
{
CamelImapStore *store = CAMEL_IMAP_STORE (service);
- CamelDiscoStore *disco_store = CAMEL_DISCO_STORE (service);
CamelImapResponse *response;
/*struct _namespaces *namespaces;*/
- char *result, *name, *path;
+ char *result, *name;
size_t len;
CamelImapStoreNamespace *ns;
@@ -1515,6 +1533,7 @@
store->refresh_stamp = time(0);
}
+
done:
/* save any changes we had */
camel_store_summary_save((CamelStoreSummary *)store->summary);
@@ -1618,13 +1637,12 @@
imap_noop (CamelStore *store, CamelException *ex)
{
CamelImapStore *imap_store = (CamelImapStore *) store;
- CamelDiscoStore *disco = (CamelDiscoStore *) store;
CamelImapResponse *response;
CamelFolder *current_folder;
CAMEL_SERVICE_LOCK (imap_store, connect_lock);
- if (!camel_imap_store_connected(imap_store, ex))
+ if (!camel_imap_store_connected(imap_store, ex))
goto done;
current_folder = imap_store->current_folder;
@@ -1636,7 +1654,6 @@
if (response)
camel_imap_response_free (imap_store, response);
}
-
done:
CAMEL_SERVICE_UNLOCK (imap_store, connect_lock);
}
@@ -2195,7 +2212,7 @@
g_free(storage_path);
/* So do we care if this didn't work? Its just a cache? */
- if (rename (oldpath, newpath) == -1) {
+ if (g_rename (oldpath, newpath) == -1) {
g_warning ("Could not rename message cache '%s' to '%s': %s: cache reset",
oldpath, newpath, strerror (errno));
}
@@ -2600,7 +2617,10 @@
if (store->namespace && store->namespace[0]) {
char *pattern;
-
+
+ get_folders_sync(store, "INBOX", &m->ex);
+ if (camel_exception_is_set(&m->ex))
+ goto done;
get_folders_sync(store, store->namespace, &m->ex);
if (camel_exception_is_set(&m->ex))
goto done;
@@ -2679,6 +2699,10 @@
if (top[0] == 0) {
if (imap_store->namespace && imap_store->namespace[0]) {
+ get_folders_sync(imap_store, "INBOX", ex);
+ if (camel_exception_is_set(ex))
+ goto fail;
+
i = strlen(imap_store->namespace)-1;
pattern = g_alloca(i+5);
strcpy(pattern, imap_store->namespace);
@@ -2693,7 +2717,7 @@
}
} else {
char *name;
-
+
name = camel_imap_store_summary_full_from_path(imap_store->summary, top);
if (name == NULL)
name = camel_imap_store_summary_path_to_full(imap_store->summary, top, imap_store->dir_sep);
@@ -2730,6 +2754,7 @@
guint32 flags, CamelException *ex)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
+ gboolean include_inbox = FALSE;
CamelFolderInfo *fi;
GPtrArray *folders;
char *pattern, *name;
@@ -2742,12 +2767,14 @@
folders = g_ptr_array_new ();
- if (top == NULL)
+ if (top == NULL || top[0] == '\0') {
+ include_inbox = TRUE;
top = "";
+ }
/* get starting point */
if (top[0] == 0) {
- if (imap_store->namespace) {
+ if (imap_store->namespace && imap_store->namespace[0]) {
name = g_strdup(imap_store->summary->namespace->full_name);
top = imap_store->summary->namespace->path;
} else
@@ -2771,9 +2798,10 @@
if (si == NULL)
continue;
-
+
if ((!strcmp(name, camel_imap_store_info_full_name(imap_store->summary, si))
- || imap_match_pattern(imap_store->dir_sep, pattern, camel_imap_store_info_full_name(imap_store->summary, si)))
+ || imap_match_pattern(imap_store->dir_sep, pattern, camel_imap_store_info_full_name(imap_store->summary, si))
+ || (include_inbox && !g_ascii_strcasecmp (camel_imap_store_info_full_name(imap_store->summary, si), "INBOX")))
&& ((imap_store->parameters & IMAP_PARAM_SUBSCRIPTIONS) == 0
|| (flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED) == 0
|| (si->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED))) {
@@ -2786,11 +2814,11 @@
it. See create folder */
if (fi->flags & CAMEL_FOLDER_NOINFERIORS)
fi->flags = (fi->flags & ~CAMEL_FOLDER_NOINFERIORS) | CAMEL_FOLDER_NOCHILDREN;
-
+
/* blah, this gets lost somewhere, i can't be bothered finding out why */
if (!g_ascii_strcasecmp(fi->full_name, "inbox"))
fi->flags = (fi->flags & ~CAMEL_FOLDER_TYPE_MASK) | CAMEL_FOLDER_TYPE_INBOX;
-
+
if (si->flags & CAMEL_FOLDER_NOSELECT) {
CamelURL *url = camel_url_new(fi->uri, NULL);
@@ -2840,15 +2868,15 @@
CamelFolderInfo *fi;
CamelStoreInfo *si;
- if (!camel_disco_store_check_online (CAMEL_DISCO_STORE (store), ex))
- return;
+ CAMEL_SERVICE_LOCK(store, connect_lock);
+
if (!camel_imap_store_connected (imap_store, ex))
- return;
+ goto done;
response = camel_imap_command (imap_store, NULL, ex,
"SUBSCRIBE %F", folder_name);
if (!response)
- return;
+ goto done;
camel_imap_response_free (imap_store, response);
si = camel_store_summary_path((CamelStoreSummary *)imap_store->summary, folder_name);
@@ -2865,7 +2893,7 @@
/* we don't need to emit a "folder_subscribed" signal
if we are in the process of renaming folders, so we
are done here... */
- return;
+ goto done;
}
fi = imap_build_folder_info(imap_store, folder_name);
@@ -2873,6 +2901,8 @@
camel_object_trigger_event (CAMEL_OBJECT (store), "folder_subscribed", fi);
camel_folder_info_free (fi);
+done:
+ CAMEL_SERVICE_UNLOCK(store, connect_lock);
}
static void
@@ -2881,19 +2911,21 @@
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
CamelImapResponse *response;
+
+ CAMEL_SERVICE_LOCK(store, connect_lock);
- if (!camel_disco_store_check_online (CAMEL_DISCO_STORE (store), ex))
- return;
if (!camel_imap_store_connected (imap_store, ex))
- return;
+ goto done;
response = camel_imap_command (imap_store, NULL, ex,
"UNSUBSCRIBE %F", folder_name);
if (!response)
- return;
+ goto done;
camel_imap_response_free (imap_store, response);
imap_folder_effectively_unsubscribed (imap_store, folder_name, ex);
+done:
+ CAMEL_SERVICE_UNLOCK(store, connect_lock);
}
#if 0
Index: camel/providers/imap/camel-imap-summary.c
===================================================================
--- camel/providers/imap/camel-imap-summary.c (revision 444)
+++ camel/providers/imap/camel-imap-summary.c (working copy)
@@ -154,23 +154,24 @@
/* Legacy version */
if (s->version == 0x30c)
- return camel_file_util_decode_uint32(in, &ims->validity);
+ {
+ unsigned char* ptrchr = s->filepos;
+ ptrchr = camel_file_util_mmap_decode_uint32 (ptrchr, &ims->validity, FALSE);
+ s->filepos = ptrchr;
+ return 0;
+ }
/* Version 1 */
- if (camel_file_util_decode_fixed_int32(in, &ims->version) == -1)
- return -1;
+ ims->version = g_ntohl(get_unaligned_u32(s->filepos)); s->filepos += 4;
if (ims->version == 2) {
/* Version 2: for compat with version 2 of the imap4 summary files */
int have_mlist;
-
- if (camel_file_util_decode_fixed_int32 (in, &have_mlist) == -1)
- return -1;
+ have_mlist = g_ntohl(get_unaligned_u32(s->filepos)); s->filepos += 4;
}
+
+ ims->validity = g_ntohl(get_unaligned_u32(s->filepos)); s->filepos += 4;
- if (camel_file_util_decode_fixed_int32(in, &ims->validity) == -1)
- return -1;
-
if (ims->version > CAMEL_IMAP_SUMMARY_VERSION) {
g_warning("Unkown summary version\n");
errno = EINVAL;
@@ -212,19 +213,16 @@
CamelImapMessageInfo *iinfo;
info = camel_imap_summary_parent->message_info_load (s, in);
+ iinfo = info;
+
if (info) {
- iinfo = (CamelImapMessageInfo *)info;
-
- if (camel_file_util_decode_uint32 (in, &iinfo->server_flags) == -1)
- goto error;
-
+ unsigned char* ptrchr = s->filepos;
+ ptrchr = camel_file_util_mmap_decode_uint32 (ptrchr, &iinfo->server_flags, FALSE);
+ s->filepos = ptrchr;
label_to_flags(iinfo);
}
return info;
-error:
- camel_message_info_free(info);
- return NULL;
}
static int
@@ -254,10 +252,20 @@
static CamelMessageContentInfo *
content_info_load (CamelFolderSummary *s, FILE *in)
{
- if (fgetc (in))
- return camel_imap_summary_parent->content_info_load (s, in);
- else
- return camel_folder_summary_content_info_new (s);
+ CamelMessageContentInfo *retval;
+ guint32 doit;
+ unsigned char* ptrchr = s->filepos;
+
+ ptrchr = camel_file_util_mmap_decode_uint32 (ptrchr, &doit, FALSE);
+ s->filepos = ptrchr;
+
+ if (doit == 1) {
+ retval = camel_imap_summary_parent->content_info_load (s, in);
+ } else {
+ retval = camel_folder_summary_content_info_new (s);
+ }
+
+ return retval;
}
static int
@@ -265,10 +273,12 @@
CamelMessageContentInfo *info)
{
if (info->type) {
- fputc (1, out);
+
+ camel_file_util_encode_uint32 (out, 1);
return camel_imap_summary_parent->content_info_save (s, out, info);
} else
- return fputc (0, out);
+ return camel_file_util_encode_uint32 (out, 0);
+
}
void
@@ -298,6 +308,8 @@
}
mi->info.size = camel_message_info_size(info);
+
+ mi->info.uid_needs_free = TRUE;
mi->info.uid = g_strdup (uid);
label_to_flags(mi);
@@ -312,7 +324,9 @@
CamelImapMessageInfo *mi;
mi = camel_message_info_clone(info);
+
mi->info.uid = g_strdup(uid);
+ mi->info.uid_needs_free = TRUE;
label_to_flags(mi);
Index: camel/providers/imap/camel-imap-utils.c
===================================================================
--- camel/providers/imap/camel-imap-utils.c (revision 444)
+++ camel/providers/imap/camel-imap-utils.c (working copy)
@@ -31,7 +31,6 @@
#include
#include
#include
-#include
#include
#include
@@ -42,6 +41,8 @@
#include "camel-string-utils.h"
#include "camel-utf8.h"
+#include
+
#define d(x)
#define SUBFOLDER_DIR_NAME "subfolders"
@@ -404,6 +405,7 @@
*flags &= ~CAMEL_FOLDER_NOSELECT;
*folder = mailbox;
+
}
return TRUE;
@@ -1348,7 +1350,7 @@
find_folders_recursive (const char *physical_path, const char *path,
IMAPPathFindFoldersCallback callback, gpointer data)
{
- DIR *dir;
+ GDir *dir;
char *subfolder_directory_path;
gboolean ok;
@@ -1366,7 +1368,7 @@
}
/* Now scan the subfolders and load them. */
- dir = opendir (subfolder_directory_path);
+ dir = g_dir_open (subfolder_directory_path, 0, NULL);
if (dir == NULL) {
g_free (subfolder_directory_path);
return TRUE;
@@ -1375,27 +1377,24 @@
ok = TRUE;
while (ok) {
struct stat file_stat;
- struct dirent *dirent;
+ const char *dirent;
char *file_path;
char *new_path;
- dirent = readdir (dir);
+ dirent = g_dir_read_name (dir);
if (dirent == NULL)
break;
- if (strcmp (dirent->d_name, ".") == 0 || strcmp (dirent->d_name, "..") == 0)
- continue;
-
file_path = g_strdup_printf ("%s/%s", subfolder_directory_path,
- dirent->d_name);
+ dirent);
- if (stat (file_path, &file_stat) < 0 ||
+ if (g_stat (file_path, &file_stat) < 0 ||
! S_ISDIR (file_stat.st_mode)) {
g_free (file_path);
continue;
}
- new_path = g_strdup_printf ("%s/%s", path, dirent->d_name);
+ new_path = g_strdup_printf ("%s/%s", path, dirent);
ok = find_folders_recursive (file_path, new_path, callback, data);
@@ -1403,7 +1402,7 @@
g_free (new_path);
}
- closedir (dir);
+ g_dir_close (dir);
g_free (subfolder_directory_path);
return ok;
Index: camel/providers/imap/ChangeLog
===================================================================
--- camel/providers/imap/ChangeLog (revision 444)
+++ camel/providers/imap/ChangeLog (working copy)
@@ -1,7 +1,67 @@
+2006-07-12 Andre Klapper
+
+ * camel-imap-provider.c:
+ adding trailing colon to string. Fixes bug #331858.
+
+2006-06-13 Andre Klapper
+
+ * camel-imap-store.c:
+ changing "couldn't", "can't" and "didn't" to proper
+ English. Fixes bug #342160.
+
+2006-05-22 Jeffrey Stedfast
+
+ * camel-imap-command.c (imap_read_untagged): Make sure the literal
+ length is non-negative (yes, some servers are sending negative
+ values here). Fixes Novell bug #177394.
+
+2006-05-19 Jeffrey Stedfast
+
+ * camel-imap-folder.c (imap_search_by_expression)
+ (imap_search_by_uids, imap_search_free): Get rid of the
+ search_lock and simply reuse the connect_lock.
+
+2006-05-18 Jeffrey Stedfast
+
+ * camel-imap-folder.c (camel_imap_folder_selected, imap_rename)
+ (imap_append_offline, imap_append_online, imap_append_resyncing)
+ (imap_transfer_offline, imap_transfer_online)
+ (imap_transfer_resyncing, camel_imap_folder_changed): Get rid of
+ the cache_lock and use the service connect_lock instead. Fixes
+ some possible deadlock conditions.
+
+2006-05-10 Parthasarathi Susarla
+
+ * camel-imap-folder.c: Add space at the end of
+ CAMEL_MESSAGE_INFO_HEADERS. The content-type header wont be
+ fetched otherwise(it mergers with the MESSAGE_LIST_HEADER). This
+ fix shows the attachment icon in the message list
+
+2006-05-01 Jeffrey Stedfast
+
+ Fix for bug #315976.
+
+ * camel-imap-store.c (construct): Only override the namespace if
+ the URL param override_namespace is also set.
+ (get_folder_info_offline): Always include INBOX if we are being
+ asked for the toplevel folder-info tree.
+ (refresh_refresh): Make sure to always query the server for INBOX.
+ (get_folder_info_online): Same.
+
+2006-04-21 Jeffrey Stedfast
+
+ * camel-imap-store.c (connect_to_server_wrapper): Don't do
+ fallback for SSL/TLS. Fixes bug #321797.
+
+2006-04-19 Sankar P
+
+ * camel-imap-folder.c (imap_update_summary): Instead of
+ downloading HEADERS try to download the specific HEADER FIELDS so
+ that the initial loading time is considerably reduced.
+
2006-01-17 Parthasarathi Susarla
** See Bug #323106, #326385
-
* camel-imap-store.c:
(imap_connect_online):
(get_folder_online):
@@ -17,6 +77,14 @@
Committed on behalf of Ed Catmur - partha
+2006-01-12 Parthasarathi Susarla
+
+ * camel-imap-command.c:
+ (imap_command_start):
+ (imap_command_continuation):
+ User g_return_val_if_fail instead of g_assert. Do not crash.
+ Return gracefully.
+
2006-01-10 Shreyas Srinivasan
* camel-imap-store.c (camel_store_finalize): Fix #321812
@@ -25,22 +93,48 @@
2005-12-14 Tor Lillqvist
Fix #323106:
-
+
* camel-imap-store.c (camel_imap_store_summary_full_to_path,
camel_imap_store_summary_path_to_full): Remove extraneous
conversions from IMAP-UTF-7 to UTF-8 and back.
* camel-imap-command.c (imap_command_strdup_vprintf): Do the
- conversion from UTF-8 to IMAP-UTF-7 only just before sending a
+ conversion from UTF-8 to IMAP-UTF-7 only just before sending a
request. Do it also for %S formats, as that is what the CREATE
command uses. But %S is used also for other commands (like LOGIN
and LIST), so maybe we really would need a new format that would
be used *only* for mailbox (folder) names, assuming it's only
mailbox names that use the IMAP-UTF-7 encoding. Or is that what %F
is intended for? But why then does CREATE use %S?
-
- Committed on behalf of Tor - partha
+2005-12-08 Tor Lillqvist
+
+ * camel-imap-folder.c: Drop unused .
+
+ * camel-imap-message-cache.c: Use gstdio wrappers. Open files in
+ binary mode.
+ (camel_imap_message_cache_new): Use GDir instead of dirent API.
+ (insert_setup, camel_imap_message_cache_get): Trailing periods in
+ file names are silently dropped on Win32, so on Win32, so if we
+ would want to create a file with a name ending with a perioud,
+ append a tilde (just a random choice).
+
+ * camel-imap-provider.c: No external command possibility on Win32,
+ drop that part of the UI.
+
+ * camel-imap-store.c: Use gstdio wrappers.
+
+ * camel-imap-utils.c (find_folders_recursive): Use GDir instead of
+ dirent API.
+
+2005-12-05 Parthasarathi Susarla
+
+ * camel-imap-store.c: (construct):
+ Setup disco journal during store construct. Previously,
+ it was dont in connect_offline and connect_online methods.
+ This makes sure that the diary is initialised even when evo
+ starts in offline mode.
+
2005-12-01 Jeff Cai
* camel-imap-command.c:(imap_command_strdup_vprintf):
@@ -53,6 +147,20 @@
Courier imap's LSUB response for INBOX when its not subscribed.
Fix #228929.
+2005-10-21 Vivek Jain
+
+ Committed NotZed's patch on #314833
+
+ ** See #314833.
+ * camel-imap-store.c (subscribe_folder, unsubscribe_folder):
+ add missing locking.
+ (imap_noop): re-arrange locking slightly.
+
+2005-10-10 Parthasarathi Susarla
+
+ * camel-imap-folder.c:(imap_update_summary): specify the
+ folder name of the folde being refreshed in the status mesage
+
2005-10-10 Björn Torkelsson
** See bug #317956.
@@ -60,10 +168,10 @@
* camel-imap-store.c:(try_auth): Null check sasl_resp
and bail out, otherwise evolution will crash when running strlen on
sasl_resp.
-
- ** Committed on behalf of Björn Torkelsson since he does not have
- commit rights. - partha
+ ** Committed on behalf of Björn Torkelsson since he does not
+ have commit rights - partha
+
2005-09-27 Vivek Jain
** See bug #315173.
@@ -72,6 +180,27 @@
info before using it
initialize flags as we '&' with old value.
+2005-09-15 Tor Lillqvist
+
+ * camel-imap-command.c
+ * camel-imap-folder.c: Use g_ascii_str(n)casecmp() instead of
+ str(n)casecmp(). The strings we are comparing in these cases
+ should be just ASCII anyway, so spell it out that we really do
+ need ASCII casefolding only.
+
+ * camel-imap-folder.c
+ * camel-imap-search.c
+ * camel-imap-store.c: No strtok_r() in Microsoft's C library, but
+ strtok() is MT-safe, which is enough for the way it's used in this
+ file, to tokenize only one string at a time.
+
+ * camel-imap-store.c (connect_to_server_process,
+ connect_to_server_wrapper): Using custom commands to connect to
+ IMAP servers is not supported on Win32 (at least for now), so
+ bypass that code.
+
+ * camel-imap-wrapper.c: If no ENETUNREACH (Win32), use EINVAL.
+
2005-08-23 Shreyas Srinivasan
** See #314199
Index: camel/providers/imap/camel-imap-search.c
===================================================================
--- camel/providers/imap/camel-imap-search.c (revision 444)
+++ camel/providers/imap/camel-imap-search.c (working copy)
@@ -34,7 +34,6 @@
#include "camel-imap-folder.h"
#include "camel-imap-store.h"
#include "camel-imap-search.h"
-#include "camel-imap-private.h"
#include "camel-imap-utils.h"
#include "camel-imap-summary.h"
@@ -46,6 +45,14 @@
#define d(x)
+#ifdef G_OS_WIN32
+/* The strtok() in Microsoft's C library is MT-safe (but still uses
+ * only one buffer pointer per thread, but for the use of strtok_r()
+ * here that's enough).
+ */
+#define strtok_r(s,sep,lasts) (*(lasts)=strtok((s),(sep)))
+#endif
+
/*
File is:
BODY (as in body search)
Index: camel/providers/imap/camel-imap-folder.c
===================================================================
--- camel/providers/imap/camel-imap-folder.c (revision 444)
+++ camel/providers/imap/camel-imap-folder.c (working copy)
@@ -23,13 +23,10 @@
* USA
*/
-#ifdef HAVE_CONFIG_H
#include
-#endif
#include
#include
-#include
#include
#include
#include
@@ -39,11 +36,12 @@
/*#include "libedataserver/e-path.h"*/
#include "libedataserver/e-time-utils.h"
+#include "libedataserver/e-data-server-util.h"
+#include "libedataserver/e-msgport.h"
#include "camel-imap-folder.h"
#include "camel-imap-command.h"
#include "camel-imap-message-cache.h"
-#include "camel-imap-private.h"
#include "camel-imap-search.h"
#include "camel-imap-store.h"
#include "camel-imap-summary.h"
@@ -72,6 +70,7 @@
#include "camel-i18n.h"
#include "camel/camel-store-summary.h"
+
#define d(x)
/* set to -1 for infinite size (suggested max command-line length is
@@ -134,6 +133,14 @@
static GData *parse_fetch_response (CamelImapFolder *imap_folder, char *msg_att);
+#ifdef G_OS_WIN32
+/* The strtok() in Microsoft's C library is MT-safe (but still uses
+ * only one buffer pointer per thread, but for the use of strtok_r()
+ * here that's enough).
+ */
+#define strtok_r(s,sep,lasts) (*(lasts)=strtok((s),(sep)))
+#endif
+
static void
camel_imap_folder_class_init (CamelImapFolderClass *camel_imap_folder_class)
{
@@ -183,12 +190,6 @@
folder->folder_flags |= (CAMEL_FOLDER_HAS_SUMMARY_CAPABILITY |
CAMEL_FOLDER_HAS_SEARCH_CAPABILITY);
- imap_folder->priv = g_malloc0(sizeof(*imap_folder->priv));
-#ifdef ENABLE_THREADS
- imap_folder->priv->search_lock = e_mutex_new(E_MUTEX_SIMPLE);
- imap_folder->priv->cache_lock = e_mutex_new(E_MUTEX_REC);
-#endif
-
imap_folder->need_rescan = TRUE;
}
@@ -222,7 +223,7 @@
const char *short_name;
char *summary_file, *state_file;
- if (camel_mkdir (folder_dir, S_IRWXU) != 0) {
+ if (e_util_mkdir_hier (folder_dir, S_IRWXU) != 0) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Could not create directory %s: %s"),
folder_dir, g_strerror (errno));
@@ -296,22 +297,22 @@
for (i = 0; i < response->untagged->len; i++) {
resp = response->untagged->pdata[i] + 2;
- if (!strncasecmp (resp, "FLAGS ", 6) && !perm_flags) {
+ if (!g_ascii_strncasecmp (resp, "FLAGS ", 6) && !perm_flags) {
resp += 6;
folder->permanent_flags = imap_parse_flag_list (&resp);
- } else if (!strncasecmp (resp, "OK [PERMANENTFLAGS ", 19)) {
+ } else if (!g_ascii_strncasecmp (resp, "OK [PERMANENTFLAGS ", 19)) {
resp += 19;
/* workaround for broken IMAP servers that send "* OK [PERMANENTFLAGS ()] Permanent flags"
* even tho they do allow storing flags. *Sigh* So many fucking broken IMAP servers out there. */
if ((perm_flags = imap_parse_flag_list (&resp)) != 0)
folder->permanent_flags = perm_flags;
- } else if (!strncasecmp (resp, "OK [UIDVALIDITY ", 16)) {
+ } else if (!g_ascii_strncasecmp (resp, "OK [UIDVALIDITY ", 16)) {
validity = strtoul (resp + 16, NULL, 10);
} else if (isdigit ((unsigned char)*resp)) {
unsigned long num = strtoul (resp, &resp, 10);
- if (!strncasecmp (resp, " EXISTS", 7)) {
+ if (!g_ascii_strncasecmp (resp, " EXISTS", 7)) {
exists = num;
/* Remove from the response so nothing
* else tries to interpret it.
@@ -341,9 +342,7 @@
else if (validity != imap_summary->validity) {
imap_summary->validity = validity;
camel_folder_summary_clear (folder->summary);
- CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock);
camel_imap_message_cache_clear (imap_folder->cache);
- CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock);
imap_folder->need_rescan = FALSE;
camel_imap_folder_changed (folder, exists, NULL, ex);
return;
@@ -377,7 +376,7 @@
exists = val;
continue;
}
- if (uid != 0 || val != count || strncasecmp (resp, " FETCH (", 8) != 0)
+ if (uid != 0 || val != count || g_ascii_strncasecmp (resp, " FETCH (", 8) != 0)
continue;
fetch_data = parse_fetch_response (imap_folder, resp + 7);
@@ -417,12 +416,6 @@
camel_object_unref (CAMEL_OBJECT (imap_folder->search));
if (imap_folder->cache)
camel_object_unref (CAMEL_OBJECT (imap_folder->cache));
-
-#ifdef ENABLE_THREADS
- e_mutex_destroy(imap_folder->priv->search_lock);
- e_mutex_destroy(imap_folder->priv->cache_lock);
-#endif
- g_free(imap_folder->priv);
}
static int
@@ -469,26 +462,28 @@
CamelImapStore *imap_store = (CamelImapStore *)folder->parent_store;
char *folder_dir, *summary_path, *state_file;
char *folders;
-
+
+ CAMEL_SERVICE_LOCK (imap_store, connect_lock);
+
folders = g_strconcat (imap_store->storage_path, "/folders", NULL);
folder_dir = imap_path_to_physical (folders, new);
g_free (folders);
summary_path = g_strdup_printf("%s/summary", folder_dir);
-
- CAMEL_IMAP_FOLDER_LOCK (folder, cache_lock);
+
camel_imap_message_cache_set_path(imap_folder->cache, folder_dir);
- CAMEL_IMAP_FOLDER_UNLOCK (folder, cache_lock);
-
+
camel_folder_summary_set_filename(folder->summary, summary_path);
-
+
state_file = g_strdup_printf ("%s/cmeta", folder_dir);
camel_object_set(folder, NULL, CAMEL_OBJECT_STATE_FILE, state_file, NULL);
g_free(state_file);
-
+
g_free(summary_path);
g_free(folder_dir);
-
+
((CamelFolderClass *)disco_folder_class)->rename(folder, new);
+
+ CAMEL_SERVICE_UNLOCK (imap_store, connect_lock);
}
static void
@@ -625,7 +620,7 @@
}
/* Check UIDs and flags of all messages we already know of. */
- camel_operation_start (NULL, _("Scanning for changed messages"));
+ camel_operation_start (NULL, _("Scanning for changed messages in %s"), folder->name);
info = camel_folder_summary_index (folder->summary, summary_len - 1);
ok = camel_imap_command_start (store, folder, ex,
"UID FETCH 1:%s (FLAGS)",
@@ -1196,21 +1191,23 @@
char *uid;
uid = get_temp_uid ();
-
+
+ CAMEL_SERVICE_LOCK (imap_store, connect_lock);
+
camel_imap_summary_add_offline (folder->summary, uid, message, info);
- CAMEL_IMAP_FOLDER_LOCK (folder, cache_lock);
camel_imap_message_cache_insert_wrapper (cache, uid, "",
CAMEL_DATA_WRAPPER (message), ex);
- CAMEL_IMAP_FOLDER_UNLOCK (folder, cache_lock);
-
+
changes = camel_folder_change_info_new ();
camel_folder_change_info_add_uid (changes, uid);
- camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed",
- changes);
+ camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", changes);
camel_folder_change_info_free (changes);
camel_disco_diary_log (CAMEL_DISCO_STORE (imap_store)->diary,
CAMEL_DISCO_DIARY_FOLDER_APPEND, folder, uid);
+
+ CAMEL_SERVICE_UNLOCK (imap_store, connect_lock);
+
if (appended_uid)
*appended_uid = uid;
else
@@ -1321,21 +1318,22 @@
CamelImapResponse *response;
char *uid;
int count;
-
+
+ CAMEL_SERVICE_LOCK (store, connect_lock);
+
count = camel_folder_summary_count (folder->summary);
- response = do_append (folder, message, info, &uid, ex);
- if (!response)
+ if (!(response = do_append (folder, message, info, &uid, ex))) {
+ CAMEL_SERVICE_UNLOCK (store, connect_lock);
return;
+ }
if (uid) {
/* Cache first, since freeing response may trigger a
* summary update that will want this information.
*/
- CAMEL_IMAP_FOLDER_LOCK (folder, cache_lock);
camel_imap_message_cache_insert_wrapper (
CAMEL_IMAP_FOLDER (folder)->cache, uid,
"", CAMEL_DATA_WRAPPER (message), ex);
- CAMEL_IMAP_FOLDER_UNLOCK (folder, cache_lock);
if (appended_uid)
*appended_uid = uid;
else
@@ -1346,10 +1344,10 @@
camel_imap_response_free (store, response);
/* Make sure a "folder_changed" is emitted. */
- CAMEL_SERVICE_LOCK (store, connect_lock);
if (store->current_folder != folder ||
camel_folder_summary_count (folder->summary) == count)
imap_refresh_info (folder, ex);
+
CAMEL_SERVICE_UNLOCK (store, connect_lock);
}
@@ -1362,19 +1360,20 @@
CamelImapResponse *response;
char *uid;
- response = do_append (folder, message, info, &uid, ex);
- if (!response)
+ CAMEL_SERVICE_LOCK (store, connect_lock);
+
+ if (!(response = do_append (folder, message, info, &uid, ex))) {
+ CAMEL_SERVICE_UNLOCK (store, connect_lock);
return;
+ }
if (uid) {
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
const char *olduid = camel_message_info_uid (info);
- CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock);
camel_imap_message_cache_copy (imap_folder->cache, olduid,
imap_folder->cache, uid, ex);
- CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock);
-
+
if (appended_uid)
*appended_uid = uid;
else
@@ -1383,6 +1382,8 @@
*appended_uid = NULL;
camel_imap_response_free (store, response);
+
+ CAMEL_SERVICE_UNLOCK (store, connect_lock);
}
@@ -1399,17 +1400,9 @@
CamelMessageInfo *mi;
char *uid, *destuid;
int i;
-
- /* We grab the store's command lock first, and then grab the
- * source and destination cache_locks. This way we can't
- * deadlock in the case where we're simultaneously also trying
- * to copy messages in the other direction from another thread.
- */
+
CAMEL_SERVICE_LOCK (store, connect_lock);
- CAMEL_IMAP_FOLDER_LOCK (source, cache_lock);
- CAMEL_IMAP_FOLDER_LOCK (dest, cache_lock);
- CAMEL_SERVICE_UNLOCK (store, connect_lock);
-
+
if (transferred_uids) {
*transferred_uids = g_ptr_array_new ();
g_ptr_array_set_size (*transferred_uids, uids->len);
@@ -1445,16 +1438,15 @@
if (delete_originals)
camel_folder_delete_message (source, uid);
}
-
- CAMEL_IMAP_FOLDER_UNLOCK (dest, cache_lock);
- CAMEL_IMAP_FOLDER_UNLOCK (source, cache_lock);
-
+
camel_object_trigger_event (CAMEL_OBJECT (dest), "folder_changed", changes);
camel_folder_change_info_free (changes);
camel_disco_diary_log (CAMEL_DISCO_STORE (store)->diary,
CAMEL_DISCO_DIARY_FOLDER_TRANSFER,
source, dest, uids, delete_originals);
+
+ CAMEL_SERVICE_UNLOCK (store, connect_lock);
}
static void
@@ -1484,22 +1476,14 @@
src = imap_uid_set_to_array (source->summary, srcset);
dest = imap_uid_set_to_array (destination->summary, destset);
-
+
if (src && dest && src->len == dest->len) {
- /* We don't have to worry about deadlocking on the
- * cache locks here, because we've got the store's
- * command lock too, so no one else could be here.
- */
- CAMEL_IMAP_FOLDER_LOCK (source, cache_lock);
- CAMEL_IMAP_FOLDER_LOCK (destination, cache_lock);
for (i = 0; i < src->len; i++) {
camel_imap_message_cache_copy (scache, src->pdata[i],
dcache, dest->pdata[i],
NULL);
}
- CAMEL_IMAP_FOLDER_UNLOCK (source, cache_lock);
- CAMEL_IMAP_FOLDER_UNLOCK (destination, cache_lock);
-
+
imap_uid_array_free (src);
imap_uid_array_free (dest);
return;
@@ -1561,7 +1545,9 @@
qsort (uids->pdata, uids->len, sizeof (void *), uid_compar);
/* Now copy the messages */
+ CAMEL_SERVICE_LOCK (store, connect_lock);
do_copy(source, uids, dest, delete_originals, ex);
+ CAMEL_SERVICE_UNLOCK (store, connect_lock);
if (camel_exception_is_set (ex))
return;
@@ -1581,12 +1567,15 @@
gboolean delete_originals, CamelException *ex)
{
CamelDiscoDiary *diary = CAMEL_DISCO_STORE (source->parent_store)->diary;
+ CamelStore *store = source->parent_store;
GPtrArray *realuids;
int first, i;
const char *uid;
CamelMimeMessage *message;
CamelMessageInfo *info;
+ CAMEL_SERVICE_LOCK (store, connect_lock);
+
qsort (uids->pdata, uids->len, sizeof (void *), uid_compar);
/* This is trickier than append_resyncing, because some of
@@ -1643,10 +1632,12 @@
}
g_ptr_array_free (realuids, FALSE);
-
+
/* FIXME */
if (transferred_uids)
*transferred_uids = NULL;
+
+ CAMEL_SERVICE_UNLOCK (store, connect_lock);
}
static GPtrArray *
@@ -1654,36 +1645,36 @@
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
GPtrArray *matches;
-
+
/* we could get around this by creating a new search object each time,
but i doubt its worth it since any long operation would lock the
command channel too */
- CAMEL_IMAP_FOLDER_LOCK(folder, search_lock);
-
+ CAMEL_SERVICE_LOCK (folder->parent_store, connect_lock);
+
camel_folder_search_set_folder (imap_folder->search, folder);
matches = camel_folder_search_search(imap_folder->search, expression, NULL, ex);
-
- CAMEL_IMAP_FOLDER_UNLOCK(folder, search_lock);
-
+
+ CAMEL_SERVICE_UNLOCK (folder->parent_store, connect_lock);
+
return matches;
}
static GPtrArray *
-imap_search_by_uids(CamelFolder *folder, const char *expression, GPtrArray *uids, CamelException *ex)
+imap_search_by_uids (CamelFolder *folder, const char *expression, GPtrArray *uids, CamelException *ex)
{
- CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER(folder);
+ CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
GPtrArray *matches;
-
+
if (uids->len == 0)
- return g_ptr_array_new();
-
- CAMEL_IMAP_FOLDER_LOCK(folder, search_lock);
-
+ return g_ptr_array_new ();
+
+ CAMEL_SERVICE_LOCK (folder->parent_store, connect_lock);
+
camel_folder_search_set_folder(imap_folder->search, folder);
matches = camel_folder_search_search(imap_folder->search, expression, uids, ex);
-
- CAMEL_IMAP_FOLDER_UNLOCK(folder, search_lock);
-
+
+ CAMEL_SERVICE_UNLOCK (folder->parent_store, connect_lock);
+
return matches;
}
@@ -1691,14 +1682,14 @@
imap_search_free (CamelFolder *folder, GPtrArray *uids)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
-
+
g_return_if_fail (imap_folder->search);
-
- CAMEL_IMAP_FOLDER_LOCK(folder, search_lock);
-
+
+ CAMEL_SERVICE_LOCK (folder->parent_store, connect_lock);
+
camel_folder_search_free_result (imap_folder->search, uids);
-
- CAMEL_IMAP_FOLDER_UNLOCK(folder, search_lock);
+
+ CAMEL_SERVICE_UNLOCK (folder->parent_store, connect_lock);
}
static CamelMimeMessage *get_message (CamelImapFolder *imap_folder,
@@ -2050,7 +2041,7 @@
CamelMimeMessage *msg = NULL;
CamelStream *stream = NULL;
int retry;
-
+
mi = (CamelImapMessageInfo *)camel_folder_summary_uid (folder->summary, uid);
if (mi == NULL) {
camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
@@ -2060,7 +2051,7 @@
/* If its cached in full, just get it as is, this is only a shortcut,
since we get stuff from the cache anyway. It affects a busted connection though. */
- if ( (stream = camel_imap_folder_fetch_data(imap_folder, uid, "", TRUE, NULL))
+ if ((stream = camel_imap_folder_fetch_data(imap_folder, uid, "", TRUE, NULL))
&& (msg = get_message_simple(imap_folder, uid, stream, ex)))
goto done;
@@ -2089,7 +2080,7 @@
char *body, *found_uid;
int i;
- CAMEL_SERVICE_LOCK(store, connect_lock);
+ CAMEL_SERVICE_LOCK (store, connect_lock);
if (!camel_imap_store_connected(store, ex)) {
CAMEL_SERVICE_UNLOCK(store, connect_lock);
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
@@ -2098,8 +2089,7 @@
}
response = camel_imap_command (store, folder, ex, "UID FETCH %s BODY", uid);
- CAMEL_SERVICE_UNLOCK(store, connect_lock);
-
+
if (response) {
for (i = 0, body = NULL; i < response->untagged->len; i++) {
fetch_data = parse_fetch_response (imap_folder, response->untagged->pdata[i]);
@@ -2119,7 +2109,7 @@
imap_parse_body ((const char **) &body, folder, mi->info.content);
camel_folder_summary_touch (folder->summary);
}
-
+
if (fetch_data)
g_datalist_clear (&fetch_data);
@@ -2127,6 +2117,8 @@
} else {
camel_exception_clear(ex);
}
+
+ CAMEL_SERVICE_UNLOCK (store, connect_lock);
}
if (camel_debug_start("imap:folder")) {
@@ -2240,7 +2232,7 @@
return (time_t) -1;
for (n = 0; n < 12; n++) {
- if (!strncasecmp (inptr, tm_months[n], 3))
+ if (!g_ascii_strncasecmp (inptr, tm_months[n], 3))
break;
}
@@ -2304,6 +2296,7 @@
}
mi = (CamelImapMessageInfo *)camel_folder_summary_info_new_from_message (folder->summary, msg);
+
camel_object_unref (CAMEL_OBJECT (msg));
if ((idate = g_datalist_get_data (&data, "INTERNALDATE")))
@@ -2316,7 +2309,7 @@
}
-#define CAMEL_MESSAGE_INFO_HEADERS "DATE FROM TO CC SUBJECT REFERENCES IN-REPLY-TO MESSAGE-ID MIME-VERSION CONTENT-TYPE"
+#define CAMEL_MESSAGE_INFO_HEADERS "DATE FROM TO CC SUBJECT REFERENCES IN-REPLY-TO MESSAGE-ID MIME-VERSION CONTENT-TYPE "
/* FIXME: this needs to be kept in sync with camel-mime-utils.c's list
of mailing-list headers and so might be best if this were
@@ -2342,7 +2335,7 @@
CAMEL_SERVICE_ASSERT_LOCKED (store, connect_lock);
if (store->server_level >= IMAP_LEVEL_IMAP4REV1)
- header_spec = "HEADER";
+ header_spec = "HEADER.FIELDS (" CAMEL_MESSAGE_INFO_HEADERS MAILING_LIST_HEADERS ")";
else
header_spec = "0";
@@ -2366,7 +2359,7 @@
"UID FETCH %d:* (FLAGS RFC822.SIZE INTERNALDATE BODY.PEEK[%s])",
uidval + 1, header_spec))
return;
- camel_operation_start (NULL, _("Fetching summary information for new messages"));
+ camel_operation_start (NULL, _("Fetching summary information for new messages in %s"), folder->name);
/* Parse the responses. We can't add a message to the summary
* until we've gotten its headers, and there's no guarantee
@@ -2436,7 +2429,7 @@
qsort (needheaders->pdata, needheaders->len,
sizeof (void *), uid_compar);
- camel_operation_start (NULL, _("Fetching summary information for new messages"));
+ camel_operation_start (NULL, _("Fetching summary information for new messages in %s"), folder->name);
while (uid < needheaders->len) {
uidset = imap_uid_array_to_set (folder->summary, needheaders, uid, UID_SET_LIMIT, &uid);
@@ -2519,8 +2512,11 @@
}
uid = g_datalist_get_data (&data, "UID");
+
+ /* This strdup() might not get freed since the mmap() patch! */
if (uid)
mi->info.uid = g_strdup (uid);
+
flags = GPOINTER_TO_INT (g_datalist_get_data (&data, "FLAGS"));
if (flags) {
((CamelImapMessageInfo *)mi)->server_flags = flags;
@@ -2578,7 +2574,7 @@
if ((mi->info.flags & CAMEL_IMAP_MESSAGE_RECENT))
camel_folder_change_info_recent_uid(changes, camel_message_info_uid (mi));
}
-
+
for ( ; i < messages->len; i++) {
if ((mi = messages->pdata[i]))
camel_message_info_free(&mi->info);
@@ -2631,9 +2627,7 @@
}
camel_folder_change_info_remove_uid (changes, camel_message_info_uid (info));
- CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock);
camel_imap_message_cache_remove (imap_folder->cache, camel_message_info_uid (info));
- CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock);
camel_folder_summary_remove (folder->summary, info);
camel_message_info_free(info);
}
@@ -2680,36 +2674,23 @@
char *found_uid;
int i;
- /* EXPUNGE responses have to modify the cache, which means
- * they have to grab the cache_lock while holding the
- * connect_lock.
-
- * Because getting the service lock may cause MUCH unecessary
- * delay when we already have the data locally, we do the
- * locking separately. This could cause a race
- * getting the same data from the cache, but that is only
- * an inefficiency, and bad luck.
- */
- CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock);
+ CAMEL_SERVICE_LOCK (store, connect_lock);
stream = camel_imap_message_cache_get (imap_folder->cache, uid, section_text, ex);
if (!stream && (!strcmp (section_text, "HEADER") || !strcmp (section_text, "0"))) {
camel_exception_clear (ex);
stream = camel_imap_message_cache_get (imap_folder->cache, uid, "", ex);
}
- CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock);
- if (stream || cache_only)
+ if (stream || cache_only) {
+ CAMEL_SERVICE_UNLOCK (store, connect_lock);
return stream;
-
+ }
+
camel_exception_clear(ex);
-
- CAMEL_SERVICE_LOCK (store, connect_lock);
- CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock);
-
+
if (!camel_imap_store_connected(store, ex)) {
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("This message is not currently available"));
- CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock);
CAMEL_SERVICE_UNLOCK (store, connect_lock);
return NULL;
}
@@ -2724,11 +2705,9 @@
"UID FETCH %s BODY.PEEK[%s]",
uid, section_text);
}
- /* We won't need the connect_lock again after this. */
- CAMEL_SERVICE_UNLOCK (store, connect_lock);
if (!response) {
- CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock);
+ CAMEL_SERVICE_UNLOCK (store, connect_lock);
return NULL;
}
@@ -2742,8 +2721,9 @@
g_datalist_clear (&fetch_data);
stream = NULL;
}
+
camel_imap_response_free (store, response);
- CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock);
+
if (!stream) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("Could not find message body in FETCH response."));
@@ -2752,6 +2732,8 @@
g_datalist_clear (&fetch_data);
}
+ CAMEL_SERVICE_UNLOCK (store, connect_lock);
+
return stream;
}
@@ -2763,6 +2745,8 @@
gboolean cache_header = TRUE, header = FALSE;
size_t body_len = 0;
+ CAMEL_SERVICE_ASSERT_LOCKED (((CamelFolder *) imap_folder)->parent_store, connect_lock);
+
if (*response != '(') {
long seq;
@@ -2771,7 +2755,7 @@
seq = strtol (response + 2, &response, 10);
if (seq == 0)
return NULL;
- if (strncasecmp (response, " FETCH (", 8) != 0)
+ if (g_ascii_strncasecmp (response, " FETCH (", 8) != 0)
return NULL;
response += 7;
@@ -2782,7 +2766,7 @@
/* Skip the initial '(' or the ' ' between elements */
response++;
- if (!strncasecmp (response, "FLAGS ", 6)) {
+ if (!g_ascii_strncasecmp (response, "FLAGS ", 6)) {
guint32 flags;
response += 6;
@@ -2790,25 +2774,25 @@
flags = imap_parse_flag_list (&response);
g_datalist_set_data (&data, "FLAGS", GUINT_TO_POINTER (flags));
- } else if (!strncasecmp (response, "RFC822.SIZE ", 12)) {
+ } else if (!g_ascii_strncasecmp (response, "RFC822.SIZE ", 12)) {
unsigned long size;
response += 12;
size = strtoul (response, &response, 10);
g_datalist_set_data (&data, "RFC822.SIZE", GUINT_TO_POINTER (size));
- } else if (!strncasecmp (response, "BODY[", 5) ||
- !strncasecmp (response, "RFC822 ", 7)) {
+ } else if (!g_ascii_strncasecmp (response, "BODY[", 5) ||
+ !g_ascii_strncasecmp (response, "RFC822 ", 7)) {
char *p;
if (*response == 'B') {
response += 5;
/* HEADER], HEADER.FIELDS (...)], or 0] */
- if (!strncasecmp (response, "HEADER", 6)) {
+ if (!g_ascii_strncasecmp (response, "HEADER", 6)) {
header = TRUE;
- if (!strncasecmp (response + 6, ".FIELDS", 7))
+ if (!g_ascii_strncasecmp (response + 6, ".FIELDS", 7))
cache_header = FALSE;
- } else if (!strncasecmp (response, "0]", 2))
+ } else if (!g_ascii_strncasecmp (response, "0]", 2))
header = TRUE;
p = strchr (response, ']');
@@ -2825,7 +2809,7 @@
part_spec = g_strdup ("");
response += 7;
- if (!strncasecmp (response, "HEADER", 6))
+ if (!g_ascii_strncasecmp (response, "HEADER", 6))
header = TRUE;
}
@@ -2840,20 +2824,20 @@
g_datalist_set_data_full (&data, "BODY_PART_SPEC", part_spec, g_free);
g_datalist_set_data_full (&data, "BODY_PART_DATA", body, g_free);
g_datalist_set_data (&data, "BODY_PART_LEN", GINT_TO_POINTER (body_len));
- } else if (!strncasecmp (response, "BODY ", 5) ||
- !strncasecmp (response, "BODYSTRUCTURE ", 14)) {
+ } else if (!g_ascii_strncasecmp (response, "BODY ", 5) ||
+ !g_ascii_strncasecmp (response, "BODYSTRUCTURE ", 14)) {
response = strchr (response, ' ') + 1;
start = response;
imap_skip_list ((const char **) &response);
g_datalist_set_data_full (&data, "BODY", g_strndup (start, response - start), g_free);
- } else if (!strncasecmp (response, "UID ", 4)) {
+ } else if (!g_ascii_strncasecmp (response, "UID ", 4)) {
int len;
len = strcspn (response + 4, " )");
uid = g_strndup (response + 4, len);
g_datalist_set_data_full (&data, "UID", uid, g_free);
response += 4 + len;
- } else if (!strncasecmp (response, "INTERNALDATE ", 13)) {
+ } else if (!g_ascii_strncasecmp (response, "INTERNALDATE ", 13)) {
int len;
response += 13;
@@ -2881,11 +2865,9 @@
if (header && !cache_header) {
stream = camel_stream_mem_new_with_buffer (body, body_len);
} else {
- CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock);
stream = camel_imap_message_cache_insert (imap_folder->cache,
uid, part_spec,
body, body_len, NULL);
- CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock);
if (stream == NULL)
stream = camel_stream_mem_new_with_buffer (body, body_len);
}
Index: camel/providers/imap/camel-imap-command.c
===================================================================
--- camel/providers/imap/camel-imap-command.c (revision 444)
+++ camel/providers/imap/camel-imap-command.c (working copy)
@@ -38,7 +38,6 @@
#include "camel-imap-folder.h"
#include "camel-imap-store.h"
#include "camel-imap-store-summary.h"
-#include "camel-imap-private.h"
#include
#include
#include
@@ -50,8 +49,8 @@
static gboolean imap_command_start (CamelImapStore *store, CamelFolder *folder,
const char *cmd, CamelException *ex);
-CamelImapResponse *imap_read_response (CamelImapStore *store,
- CamelException *ex);
+static CamelImapResponse *imap_read_response (CamelImapStore *store,
+ CamelException *ex);
static char *imap_read_untagged (CamelImapStore *store, char *line,
CamelException *ex);
static char *imap_command_strdup_vprintf (CamelImapStore *store,
@@ -211,10 +210,10 @@
else
mask = cmd;
- fprintf (stderr, "sending : %c%.5d %s\r\n", store->tag_prefix, store->command, mask);
+ fprintf (stderr, "sending : %c%.5u %s\r\n", store->tag_prefix, store->command, mask);
}
- nwritten = camel_stream_printf (store->ostream, "%c%.5d %s\r\n",
+ nwritten = camel_stream_printf (store->ostream, "%c%.5u %s\r\n",
store->tag_prefix, store->command++, cmd);
if (nwritten == -1) {
@@ -439,10 +438,9 @@
fulllen += str->len;
g_ptr_array_add (data, str);
- p = strrchr (str->str, '{');
- if (!p)
+ if (!(p = strrchr (str->str, '{')) || p[1] == '-')
break;
-
+
/* HACK ALERT: We scan the non-literal part of the string, looking for possible s expression braces.
This assumes we're getting s-expressions, which we should be.
This is so if we get a blank line after a literal, in an s-expression, we can keep going, since
@@ -530,7 +528,7 @@
* don't want it to be shorter either, because then the
* GString's length would be off...
*/
- sprintf (p, "{%0*d}", ldigits, length);
+ sprintf (p, "{%0*u}", ldigits, length);
fulllen += str->len;
g_ptr_array_add (data, str);
Index: camel/providers/imap/camel-imap-folder.h
===================================================================
--- camel/providers/imap/camel-imap-folder.h (revision 444)
+++ camel/providers/imap/camel-imap-folder.h (working copy)
@@ -44,9 +44,7 @@
struct _CamelImapFolder {
CamelDiscoFolder parent_object;
-
- struct _CamelImapFolderPrivate *priv;
-
+
CamelFolderSearch *search;
CamelImapMessageCache *cache;
Index: camel/providers/imap/camel-imap-wrapper.c
===================================================================
--- camel/providers/imap/camel-imap-wrapper.c (revision 444)
+++ camel/providers/imap/camel-imap-wrapper.c (working copy)
@@ -30,7 +30,6 @@
#include "camel-imap-folder.h"
#include "camel-imap-wrapper.h"
-#include "camel-imap-private.h"
#include "camel-exception.h"
#include "camel-stream-filter.h"
#include "camel-mime-filter-basic.h"
@@ -38,6 +37,17 @@
#include "camel-mime-filter-charset.h"
#include "camel-mime-part.h"
+#include "libedataserver/e-msgport.h"
+
+
+struct _CamelImapWrapperPrivate {
+ GMutex *lock;
+};
+
+#define CAMEL_IMAP_WRAPPER_LOCK(f, l) (g_mutex_lock(((CamelImapWrapper *)f)->priv->l))
+#define CAMEL_IMAP_WRAPPER_UNLOCK(f, l) (g_mutex_unlock(((CamelImapWrapper *)f)->priv->l))
+
+
static CamelDataWrapperClass *parent_class = NULL;
/* Returns the class for a CamelDataWrapper */
@@ -68,10 +78,9 @@
g_free (imap_wrapper->uid);
if (imap_wrapper->part)
g_free (imap_wrapper->part_spec);
-
-#ifdef ENABLE_THREADS
+
g_mutex_free (imap_wrapper->priv->lock);
-#endif
+
g_free (imap_wrapper->priv);
}
@@ -81,9 +90,7 @@
CamelImapWrapper *imap_wrapper = CAMEL_IMAP_WRAPPER (object);
imap_wrapper->priv = g_new0 (struct _CamelImapWrapperPrivate, 1);
-#ifdef ENABLE_THREADS
imap_wrapper->priv->lock = g_mutex_new ();
-#endif
}
CamelType
@@ -139,7 +146,12 @@
imap_wrapper->part_spec, FALSE, NULL);
if (!datastream) {
CAMEL_IMAP_WRAPPER_UNLOCK (imap_wrapper, lock);
+#ifdef ENETUNREACH
errno = ENETUNREACH;
+#else
+#warning FIXME: what errno to use if no ENETUNREACH
+ errno = EINVAL;
+#endif
return -1;
}
Index: camel/providers/imap/camel-imap-message-cache.c
===================================================================
--- camel/providers/imap/camel-imap-message-cache.c (revision 444)
+++ camel/providers/imap/camel-imap-message-cache.c (working copy)
@@ -22,12 +22,9 @@
* USA
*/
-#ifdef HAVE_CONFIG_H
#include
-#endif
#include
-#include
#include
#include
#include
@@ -38,6 +35,12 @@
#include "camel-stream-fs.h"
#include "camel-i18n.h"
+#include
+
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
static void finalize (CamelImapMessageCache *cache);
static void stream_finalize (CamelObject *stream, gpointer event_data, gpointer user_data);
@@ -144,17 +147,19 @@
CamelException *ex)
{
CamelImapMessageCache *cache;
- DIR *dir;
- struct dirent *d;
+ GDir *dir;
+ const char *dname;
char *uid, *p;
GPtrArray *deletes;
CamelMessageInfo *info;
+ GError *error;
- dir = opendir (path);
+ dir = g_dir_open (path, 0, &error);
if (!dir) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Could not open cache directory: %s"),
- g_strerror (errno));
+ error->message);
+ g_error_free (error);
return NULL;
}
@@ -164,28 +169,27 @@
cache->parts = g_hash_table_new (g_str_hash, g_str_equal);
cache->cached = g_hash_table_new (NULL, NULL);
deletes = g_ptr_array_new ();
- while ((d = readdir (dir))) {
- if (!isdigit (d->d_name[0]))
+ while ((dname = g_dir_read_name (dir))) {
+ if (!isdigit (dname[0]))
continue;
-
- p = strchr (d->d_name, '.');
+ p = strchr (dname, '.');
if (p)
- uid = g_strndup (d->d_name, p - d->d_name);
+ uid = g_strndup (dname, p - dname);
else
- uid = g_strdup (d->d_name);
+ uid = g_strdup (dname);
info = camel_folder_summary_uid (summary, uid);
if (info) {
camel_message_info_free(info);
- cache_put (cache, uid, d->d_name, NULL);
+ cache_put (cache, uid, dname, NULL);
} else
- g_ptr_array_add (deletes, g_strdup_printf ("%s/%s", cache->path, d->d_name));
+ g_ptr_array_add (deletes, g_strdup_printf ("%s/%s", cache->path, dname));
g_free (uid);
}
- closedir (dir);
+ g_dir_close (dir);
while (deletes->len) {
- unlink (deletes->pdata[0]);
+ g_unlink (deletes->pdata[0]);
g_free (deletes->pdata[0]);
g_ptr_array_remove_index_fast (deletes, 0);
}
@@ -241,13 +245,22 @@
CamelStream *stream;
int fd;
+#ifdef G_OS_WIN32
+ /* Trailing periods in file names are silently dropped on
+ * Win32, argh. The code in this file requires the period to
+ * be there. So in case part_spec is empty, use a tilde (just
+ * a random choice) instead.
+ */
+ if (!*part_spec)
+ part_spec = "~";
+#endif
*path = g_strdup_printf ("%s/%s.%s", cache->path, uid, part_spec);
*key = strrchr (*path, '/') + 1;
stream = g_hash_table_lookup (cache->parts, *key);
if (stream)
camel_object_unref (CAMEL_OBJECT (stream));
- fd = open (*path, O_RDWR | O_CREAT | O_TRUNC, 0600);
+ fd = g_open (*path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0600);
if (fd == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to cache message %s: %s"),
@@ -262,7 +275,7 @@
static CamelStream *
insert_abort (char *path, CamelStream *stream)
{
- unlink (path);
+ g_unlink (path);
g_free (path);
camel_object_unref (CAMEL_OBJECT (stream));
return NULL;
@@ -400,6 +413,11 @@
if (uid[0] == 0)
return NULL;
+#ifdef G_OS_WIN32
+ /* See comment in insert_setup() */
+ if (!*part_spec)
+ part_spec = "~";
+#endif
path = g_strdup_printf ("%s/%s.%s", cache->path, uid, part_spec);
key = strrchr (path, '/') + 1;
stream = g_hash_table_lookup (cache->parts, key);
@@ -445,7 +463,7 @@
for (i = 0; i < subparts->len; i++) {
key = subparts->pdata[i];
path = g_strdup_printf ("%s/%s", cache->path, key);
- unlink (path);
+ g_unlink (path);
g_free (path);
stream = g_hash_table_lookup (cache->parts, key);
if (stream) {
@@ -519,7 +537,7 @@
part = strchr (subparts->pdata[i], '.');
if (!part++)
continue;
-
+
if ((stream = camel_imap_message_cache_get (source, source_uid, part, ex))) {
camel_imap_message_cache_insert_stream (dest, dest_uid, part, stream, ex);
camel_object_unref (CAMEL_OBJECT (stream));
Index: camel/providers/imap/Makefile.am
===================================================================
--- camel/providers/imap/Makefile.am (revision 444)
+++ camel/providers/imap/Makefile.am (working copy)
@@ -37,8 +37,7 @@
camel-imap-summary.h \
camel-imap-types.h \
camel-imap-utils.h \
- camel-imap-wrapper.h \
- camel-imap-private.h
+ camel-imap-wrapper.h
libcamelimap_la_LDFLAGS = -avoid-version -module $(NO_UNDEFINED)
Index: camel/providers/imap/camel-imap-store-summary.c
===================================================================
--- camel/providers/imap/camel-imap-store-summary.c (revision 444)
+++ camel/providers/imap/camel-imap-store-summary.c (working copy)
@@ -211,7 +211,7 @@
char *
camel_imap_store_summary_path_to_full(CamelImapStoreSummary *s, const char *path, char dir_sep)
{
- unsigned char *full, *f;
+ char *full, *f;
guint32 c, v = 0;
const char *p;
int state=0;
@@ -248,7 +248,7 @@
else
p = path;
- while ( (c = camel_utf8_getc((const unsigned char **)&p)) ) {
+ while ((c = camel_utf8_getc((const unsigned char **)&p))) {
switch(state) {
case 0:
if (c == '%')
@@ -469,27 +469,44 @@
guint32 sep = '/';
ns = g_malloc0(sizeof(*ns));
- if (camel_file_util_decode_string(in, &ns->path) == -1
- || camel_file_util_decode_string(in, &ns->full_name) == -1
- || camel_file_util_decode_uint32(in, &sep) == -1) {
- namespace_free(s, ns);
- ns = NULL;
- } else {
- ns->sep = sep;
- }
+ if (camel_file_util_decode_string(in, &ns->path) == -1)
+ goto nserror;
+
+ if (camel_file_util_decode_string(in, &ns->full_name) == -1)
+ goto nserror;
+
+ if (camel_file_util_decode_uint32(in, &sep) == -1)
+ goto nserror;
+
+ ns->sep = sep;
+
return ns;
+
+ nserror:
+
+ namespace_free(s, ns);
+ return NULL;
}
static int
namespace_save(CamelStoreSummary *s, FILE *in, CamelImapStoreNamespace *ns)
{
- if (camel_file_util_encode_string(in, ns->path) == -1
- || camel_file_util_encode_string(in, ns->full_name) == -1
- || camel_file_util_encode_uint32(in, (guint32)ns->sep) == -1)
- return -1;
+ if (camel_file_util_encode_string(in, ns->path) == -1)
+ goto serr;
+ if (camel_file_util_encode_string(in, ns->full_name) == -1)
+ goto serr;
+
+ if (camel_file_util_encode_uint32(in, (guint32)ns->sep) == -1)
+ goto serr;
+
return 0;
+
+ serr:
+ printf ("Error happend while writing\n");
+ return -1;
+
}
static int
Index: camel/providers/imap/camel-imap-provider.c
===================================================================
--- camel/providers/imap/camel-imap-provider.c (revision 444)
+++ camel/providers/imap/camel-imap-provider.c (working copy)
@@ -22,9 +22,7 @@
*
*/
-#ifdef HAVE_CONFIG_H
#include
-#endif
#include
#include "camel-imap-store.h"
@@ -45,6 +43,7 @@
{ CAMEL_PROVIDER_CONF_CHECKBOX, "check_all", NULL,
N_("C_heck for new messages in all folders"), "1" },
{ CAMEL_PROVIDER_CONF_SECTION_END },
+#ifndef G_OS_WIN32
{ CAMEL_PROVIDER_CONF_SECTION_START, "cmdsection", NULL,
N_("Connection to Server") },
{ CAMEL_PROVIDER_CONF_CHECKBOX, "use_command", NULL,
@@ -52,6 +51,7 @@
{ CAMEL_PROVIDER_CONF_ENTRY, "command", "use_command",
N_("Command:"), "ssh -C -l %u %h exec /usr/sbin/imapd" },
{ CAMEL_PROVIDER_CONF_SECTION_END },
+#endif
{ CAMEL_PROVIDER_CONF_SECTION_START, "folders", NULL,
N_("Folders") },
{ CAMEL_PROVIDER_CONF_CHECKBOX, "use_lsub", NULL,
@@ -59,7 +59,7 @@
{ CAMEL_PROVIDER_CONF_CHECKBOX, "override_namespace", NULL,
N_("O_verride server-supplied folder namespace"), "0" },
{ CAMEL_PROVIDER_CONF_ENTRY, "namespace", "override_namespace",
- N_("Namespace") },
+ N_("Namespace:") },
{ CAMEL_PROVIDER_CONF_SECTION_END },
{ CAMEL_PROVIDER_CONF_SECTION_START, "general", NULL, N_("Options") },
{ CAMEL_PROVIDER_CONF_CHECKBOX, "filter", NULL,
Index: camel/providers/Makefile.am
===================================================================
--- camel/providers/Makefile.am (revision 444)
+++ camel/providers/Makefile.am (working copy)
@@ -8,13 +8,11 @@
IMAPP_DIR=imapp
endif
-if WITH_SOUP
-GROUPWISE_DIR=groupwise
-endif
-
if OS_WIN32
else
SENDMAIL_DIR=sendmail
endif
-SUBDIRS = pop3 $(SENDMAIL_DIR) smtp imap imap4 $(NNTP_DIR) local $(IMAPP_DIR) $(GROUPWISE_DIR)
+SUBDIRS = pop3 $(SENDMAIL_DIR) smtp imap imap4 $(NNTP_DIR) local $(IMAPP_DIR)
+
+
Index: camel/providers/imap4/camel-imap4-specials.h
===================================================================
--- camel/providers/imap4/camel-imap4-specials.h (revision 444)
+++ camel/providers/imap4/camel-imap4-specials.h (working copy)
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* Camel
- * Copyright (C) 1999-2004 Jeffrey Stedfast
+ * Copyright (C) 1999-2006 Jeffrey Stedfast
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Index: camel/providers/imap4/camel-imap4-journal.c
===================================================================
--- camel/providers/imap4/camel-imap4-journal.c (revision 444)
+++ camel/providers/imap4/camel-imap4-journal.c (working copy)
@@ -351,6 +351,7 @@
e_dlist_addtail (&journal->queue, (EDListNode *) entry);
info = camel_folder_summary_info_new_from_message (folder->summary, message);
+ g_free(info->uid);
info->uid = g_strdup (uid);
imap4_message_info_dup_to ((CamelMessageInfoBase *) info, (CamelMessageInfoBase *) mi);
Index: camel/providers/imap4/camel-imap4-folder.c
===================================================================
--- camel/providers/imap4/camel-imap4-folder.c (revision 444)
+++ camel/providers/imap4/camel-imap4-folder.c (working copy)
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* Camel
- * Copyright (C) 1999-2004 Jeffrey Stedfast
+ * Copyright (C) 1999-2006 Jeffrey Stedfast
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -35,6 +35,7 @@
#include
#include
+#include
#include
#include
#include
@@ -345,7 +346,7 @@
folder->summary = camel_imap4_summary_new (folder);
imap4_folder->cachedir = imap4_store_build_filename (store, folder->full_name);
- camel_mkdir (imap4_folder->cachedir, 0777);
+ e_util_mkdir_hier (imap4_folder->cachedir, 0777);
imap4_folder->cache = camel_data_cache_new (imap4_folder->cachedir, 0, NULL);
@@ -784,7 +785,7 @@
if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) message, stream) == -1) {
if (errno == EINTR) {
CAMEL_SERVICE_UNLOCK (folder->parent_store, connect_lock);
- camel_exception_setv (ex, CAMEL_EXCEPTION_USER_CANCEL, _("User cancelled"));
+ camel_exception_setv (ex, CAMEL_EXCEPTION_USER_CANCEL, _("User canceled"));
camel_object_unref (message);
camel_object_unref (stream);
return NULL;
@@ -1012,6 +1013,7 @@
char *parent_name, *p;
parent_name = g_alloca (strlen (folder->full_name) + 1);
+ strcpy (parent_name, folder->full_name);
if (!(p = strrchr (parent_name, '/')))
*parent_name = '\0';
else
Index: camel/providers/imap4/camel-imap4-command.c
===================================================================
--- camel/providers/imap4/camel-imap4-command.c (revision 444)
+++ camel/providers/imap4/camel-imap4-command.c (working copy)
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* Camel
- * Copyright (C) 1999-2004 Jeffrey Stedfast
+ * Copyright (C) 1999-2006 Jeffrey Stedfast
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -507,7 +507,6 @@
CamelIMAP4Literal *literal;
camel_imap4_token_t token;
unsigned char *linebuf;
- ssize_t nwritten;
size_t len;
g_assert (ic->part != NULL);
@@ -545,7 +544,7 @@
linebuf = ic->part->buffer;
len = ic->part->buflen;
- if ((nwritten = camel_stream_write (engine->ostream, linebuf, len)) == -1) {
+ if (camel_stream_write (engine->ostream, linebuf, len) == -1) {
camel_exception_setv (&ic->ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed sending command to IMAP server %s: %s"),
engine->url->host, g_strerror (errno));
Index: camel/providers/imap4/ChangeLog
===================================================================
--- camel/providers/imap4/ChangeLog (revision 444)
+++ camel/providers/imap4/ChangeLog (working copy)
@@ -1,3 +1,68 @@
+2006-07-12 Andre Klapper
+
+ * camel-imap4-provider.c:
+ adding trailing colon to string. Fixes bug #331858.
+
+2006-06-15 Andre Klapper
+
+ * camel-imap4-folder.c:
+ * camel-imap4-store.c:
+ changing "cancelled" to "canceled" in user-visible strings.
+ Fixes bug #342163.
+
+2006-06-09 Chris Heath
+
+ * camel-imap4-journal.c (camel_imap4_journal_append): Fix memory leak.
+ Fixes bug #335423.
+
+2006-04-21 Jeffrey Stedfast
+
+ * camel-imap4-store.c (connect_to_server): Set some socket options
+ like keepalive and nodelay.
+ (connect_to_server_wrapper): Don't do fallback with SSL/TLS. Fixes
+ bug #321797.
+
+2006-04-12 Jeffrey Stedfast
+
+ * camel-imap4-folder.c (imap4_append_message): strcpy the
+ folder->full_name into the freshly alloca'd parent_name buffer
+ before using strrchr on it.
+
+2006-03-31 Jeffrey Stedfast
+
+ Fix for bug #272058
+
+ * camel-imap4-summary.c (untagged_fetch_all): Get the In-Reply-To
+ header too.
+ (decode_envelope): Only decode the ENVELOPE's In-Reply-To field if
+ we don't already have a list of references decoded (e.g. from a
+ header query). Decode the Message-Id value before getting the md5
+ digest so that the format matches the References/In-Reply-To
+ values.
+ (decode_references): Modified to take 2 string args - References
+ and In-Reply-To - so that we can merge the 2 references lists like
+ the default CamelFolderSummary implementation.
+
+2006-03-28 Jeffrey Stedfast
+
+ * camel-imap4-store.c (imap4_reconnect): Only try to authenticate
+ if the engine is not already in the authenticated state.
+
+2005-12-08 Tor Lillqvist
+
+ * camel-imap4-store.c: Bypass the external command stuff on Win32.
+
+ * camel-imap4-summary.c: Use g_ascii_strncasecmp() instead of
+ strncasecmp().
+
+2005-09-28 Jeffrey Stedfast
+
+ * camel-imap4-store.c (imap4_create_folder): Finally fixed to
+ handle recreating parent folders to allow subfolders.
+ (imap4_try_authenticate): Only request a password if no
+ authentication mechanism is to be used or if the mechanism
+ requires a password. Fixes bug #317301.
+
2005-08-22 Not Zed
* camel-imap4-utils.c (camel_imap4_utils_set_unexpected_token_error):
Index: camel/providers/imap4/camel-imap4-folder.h
===================================================================
--- camel/providers/imap4/camel-imap4-folder.h (revision 444)
+++ camel/providers/imap4/camel-imap4-folder.h (working copy)
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* Camel
- * Copyright (C) 1999-2004 Jeffrey Stedfast
+ * Copyright (C) 1999-2006 Jeffrey Stedfast
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Index: camel/providers/imap4/camel-imap4-command.h
===================================================================
--- camel/providers/imap4/camel-imap4-command.h (revision 444)
+++ camel/providers/imap4/camel-imap4-command.h (working copy)
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* Camel
- * Copyright (C) 1999-2004 Jeffrey Stedfast
+ * Copyright (C) 1999-2006 Jeffrey Stedfast
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Index: camel/providers/imap4/camel-imap4-store-summary.c
===================================================================
--- camel/providers/imap4/camel-imap4-store-summary.c (revision 444)
+++ camel/providers/imap4/camel-imap4-store-summary.c (working copy)
@@ -113,7 +113,7 @@
static CamelIMAP4NamespaceList *
load_namespaces (FILE *in)
{
- CamelIMAP4Namespace *ns, *tail;
+ CamelIMAP4Namespace *ns, *tail = NULL;
CamelIMAP4NamespaceList *nsl;
guint32 i, j, n;
@@ -200,7 +200,7 @@
static int
save_namespaces (FILE *out, CamelIMAP4NamespaceList *nsl)
{
- CamelIMAP4Namespace *cur, *ns;
+ CamelIMAP4Namespace *ns, *cur = NULL;
guint32 i, n;
for (i = 0; i < 3; i++) {
Index: camel/providers/imap4/camel-imap4-provider.c
===================================================================
--- camel/providers/imap4/camel-imap4-provider.c (revision 444)
+++ camel/providers/imap4/camel-imap4-provider.c (working copy)
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* Camel
- * Copyright (C) 1999-2004 Jeffrey Stedfast
+ * Copyright (C) 1999-2006 Jeffrey Stedfast
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -31,19 +31,12 @@
#include "camel-imap4-store.h"
-CamelProviderConfEntry imap4_conf_entries[] = {
+static CamelProviderConfEntry imap4_conf_entries[] = {
{ CAMEL_PROVIDER_CONF_SECTION_START, "mailcheck", NULL,
N_("Checking for new mail") },
{ CAMEL_PROVIDER_CONF_CHECKBOX, "check_all", NULL,
N_("C_heck for new messages in all folders"), "1" },
{ CAMEL_PROVIDER_CONF_SECTION_END },
- { CAMEL_PROVIDER_CONF_SECTION_START, "cmdsection", NULL,
- N_("Connection to Server") },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "use_command", NULL,
- N_("_Use custom command to connect to server"), "0" },
- { CAMEL_PROVIDER_CONF_ENTRY, "command", "use_command",
- N_("Command:"), "ssh -C -l %u %h exec /usr/sbin/imapd" },
- { CAMEL_PROVIDER_CONF_SECTION_END },
{ CAMEL_PROVIDER_CONF_SECTION_START, "folders", NULL,
N_("Folders") },
{ CAMEL_PROVIDER_CONF_CHECKBOX, "use_lsub", NULL,
@@ -51,7 +44,7 @@
{ CAMEL_PROVIDER_CONF_CHECKBOX, "override_namespace", NULL,
N_("O_verride server-supplied folder namespace"), "0" },
{ CAMEL_PROVIDER_CONF_ENTRY, "namespace", "override_namespace",
- N_("Namespace") },
+ N_("Namespace:") },
{ CAMEL_PROVIDER_CONF_SECTION_END },
{ CAMEL_PROVIDER_CONF_SECTION_START, "general", NULL, N_("Options") },
{ CAMEL_PROVIDER_CONF_CHECKBOX, "filter", NULL,
Index: camel/providers/imap4/camel-imap4-store.c
===================================================================
--- camel/providers/imap4/camel-imap4-store.c (revision 444)
+++ camel/providers/imap4/camel-imap4-store.c (working copy)
@@ -32,7 +32,6 @@
#include