Make the mbox importer check for Mozilla status headers and act on them.
svn path=/trunk/; revision=15265
This commit is contained in:
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
29
mail/importers/mozilla-status-headers.h
Normal file
29
mail/importers/mozilla-status-headers.h
Normal file
@ -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
|
Reference in New Issue
Block a user