aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIain Holmes <iain@src.gnome.org>2002-01-09 00:42:55 +0800
committerIain Holmes <iain@src.gnome.org>2002-01-09 00:42:55 +0800
commita4db79a6d67be58e2922bc101e9db92b5a24d6cf (patch)
tree342f8a1d2af61b5deb4d60647e07f4d73661676a
parentd39b2d01d985e2e86857f1d632c8b821bdacb939 (diff)
downloadgsoc2013-evolution-a4db79a6d67be58e2922bc101e9db92b5a24d6cf.tar
gsoc2013-evolution-a4db79a6d67be58e2922bc101e9db92b5a24d6cf.tar.gz
gsoc2013-evolution-a4db79a6d67be58e2922bc101e9db92b5a24d6cf.tar.bz2
gsoc2013-evolution-a4db79a6d67be58e2922bc101e9db92b5a24d6cf.tar.lz
gsoc2013-evolution-a4db79a6d67be58e2922bc101e9db92b5a24d6cf.tar.xz
gsoc2013-evolution-a4db79a6d67be58e2922bc101e9db92b5a24d6cf.tar.zst
gsoc2013-evolution-a4db79a6d67be58e2922bc101e9db92b5a24d6cf.zip
Make the mbox importer check for Mozilla status headers and act on them.
svn path=/trunk/; revision=15265
-rw-r--r--mail/ChangeLog14
-rw-r--r--mail/importers/Makefile.am3
-rw-r--r--mail/importers/evolution-mbox-importer.c82
-rw-r--r--mail/importers/mozilla-status-headers.h29
4 files changed, 124 insertions, 4 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 962845a38b..18e9198358 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,17 @@
+2002-01-08 Iain Holmes <iain@ximian.com>
+
+ * importers/evolution-mbox-importer.c (string_to_int): Takes a hex
+ string and converts it to an int.
+ (get_info_from_mozilla): Creates a CamelMessageInfo structure from
+ the X-Mozilla-Status header.
+ (process_item_fn): Check for the X-Mozilla-Status header and if it
+ is present call get_info_from_mozilla. If get_info_from_mozilla
+ returns that the message was marked as deleted but never expunged
+ it isn't imported.
+
+ * importers/mozilla-status-headers.h: Stuff Evolution cares about
+ from the mozilla header.
+
2002-01-07 Jeffrey Stedfast <fejj@ximian.com>
* mail-config.c (mail_config_set_new_mail_notify_sound_file): Renamed.
diff --git a/mail/importers/Makefile.am b/mail/importers/Makefile.am
index 6767fde715..aa6049ca45 100644
--- a/mail/importers/Makefile.am
+++ b/mail/importers/Makefile.am
@@ -16,7 +16,8 @@ liboutlook_la_SOURCES = \
evolution-outlook-importer.c
liboutlook_la_LDFLAGS = -version-info 0:0:0
-libmbox_la_SOURCES = evolution-mbox-importer.c
+libmbox_la_SOURCES = evolution-mbox-importer.c \
+ mozilla-status-headers.h
libmbox_la_LDFLAGS = -version-info 0:0:0
oafdir = $(datadir)/oaf
diff --git a/mail/importers/evolution-mbox-importer.c b/mail/importers/evolution-mbox-importer.c
index b977ce6ac7..1dfeb93b40 100644
--- a/mail/importers/evolution-mbox-importer.c
+++ b/mail/importers/evolution-mbox-importer.c
@@ -25,6 +25,7 @@
#endif
#include <stdio.h>
+#include <ctype.h>
#include <bonobo/bonobo-object.h>
#include <bonobo/bonobo-generic-factory.h>
@@ -37,6 +38,8 @@
#include <importer/evolution-importer.h>
#include <importer/GNOME_Evolution_Importer.h>
+#include "mozilla-status-headers.h"
+
#include "mail/mail-importer.h"
#include "mail-tools.h"
@@ -66,6 +69,67 @@ void mail_importer_module_init (void);
/* EvolutionImporter methods */
+static int
+string_to_int (const char *str)
+{
+ int result = 0;
+ char *s;
+
+ for (s = (char *) str; *s; s++) {
+ char c = toupper (*s);
+
+ result *= 16;
+
+ if (c >= '0' && c <= '9') {
+ result += (c - '0');
+ } else if (c >= 'A' && c <= 'F') {
+ result += (c - 'A');
+ }
+ }
+
+ g_print ("%s became %d\n", str, result);
+
+ return result;
+}
+
+static CamelMessageInfo *
+get_info_from_mozilla (const char *mozilla_status,
+ gboolean *deleted)
+{
+ int status;
+ CamelMessageInfo *info;
+
+ info = g_new0 (CamelMessageInfo, 1);
+
+ *deleted = FALSE;
+
+ status = string_to_int (mozilla_status);
+ if (status == 0) {
+ return info;
+ }
+
+ if (status & MSG_FLAG_EXPUNGED) {
+ *deleted = TRUE;
+ g_free (info);
+
+ return NULL;
+ }
+
+ if (status & MSG_FLAG_READ) {
+ info->flags |= CAMEL_MESSAGE_SEEN;
+ }
+
+ if (status & MSG_FLAG_MARKED) {
+ info->flags |= CAMEL_MESSAGE_FLAGGED;
+ }
+
+ if (status & MSG_FLAG_REPLIED) {
+ info->flags |= CAMEL_MESSAGE_ANSWERED;
+ }
+
+ return info;
+}
+
static void
process_item_fn (EvolutionImporter *eimporter,
CORBA_Object listener,
@@ -76,6 +140,7 @@ process_item_fn (EvolutionImporter *eimporter,
MailImporter *importer = (MailImporter *) mbi;
gboolean done = FALSE;
CamelException *ex;
+ char *mozilla_status;
if (importer->folder == NULL) {
GNOME_Evolution_ImporterListener_notifyResult (listener,
@@ -96,6 +161,7 @@ process_item_fn (EvolutionImporter *eimporter,
/* Import the next message */
CamelMimeMessage *msg;
CamelMessageInfo *info;
+ gboolean deleted;
IN;
msg = camel_mime_message_new ();
@@ -106,10 +172,20 @@ process_item_fn (EvolutionImporter *eimporter,
done = TRUE;
}
+ mozilla_status = camel_medium_get_header (CAMEL_MEDIUM (msg), "X-Mozilla-Status");
+ if (mozilla_status != NULL) {
+ g_print ("Got Mozilla status header: %s\n", mozilla_status);
+ info = get_info_from_mozilla (mozilla_status, &deleted);
+ } else {
+ info = g_new0 (CamelMessageInfo, 1);
+ }
+
+ if (deleted == FALSE) {
/* write the mesg */
- info = g_new0 (CamelMessageInfo, 1);
- camel_folder_append_message (importer->folder, msg, info, ex);
- g_free (info);
+ camel_folder_append_message (importer->folder, msg, info, ex);
+ g_free (info);
+ }
+
camel_object_unref (CAMEL_OBJECT (msg));
if (camel_exception_is_set (ex)) {
g_warning ("Failed message %d", mbi->num);
diff --git a/mail/importers/mozilla-status-headers.h b/mail/importers/mozilla-status-headers.h
new file mode 100644
index 0000000000..f459d6ec8f
--- /dev/null
+++ b/mail/importers/mozilla-status-headers.h
@@ -0,0 +1,29 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* mozilla-status-headers.h
+ *
+ * Authors: Iain Holmes <iain@ximian.com>
+ *
+ * Copyright (C) 2001 Ximian, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/* Defines copied from nsMsgMessageFlags.h in Mozilla source. */
+
+/* Evolution only cares about these headers I think */
+#define MSG_FLAG_READ 0x0001
+#define MSG_FLAG_REPLIED 0x0002
+#define MSG_FLAG_MARKED 0x0004
+#define MSG_FLAG_EXPUNGED 0x0008