aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--calendar/importers/icalendar-importer.c6
-rw-r--r--e-util/e-import.c275
-rw-r--r--e-util/e-import.h81
-rw-r--r--mail/importers/elm-importer.c9
-rw-r--r--mail/importers/mail-importer.c64
-rw-r--r--mail/importers/mail-importer.h23
-rw-r--r--mail/importers/pine-importer.c4
-rw-r--r--plugins/pst-import/pst-importer.c1
-rw-r--r--plugins/startup-wizard/startup-wizard.c2
-rw-r--r--shell/e-shell-importer.c2
-rw-r--r--shell/main.c2
11 files changed, 23 insertions, 446 deletions
diff --git a/calendar/importers/icalendar-importer.c b/calendar/importers/icalendar-importer.c
index caa7a8a87c..6a09c36e03 100644
--- a/calendar/importers/icalendar-importer.c
+++ b/calendar/importers/icalendar-importer.c
@@ -593,12 +593,11 @@ gnome_calendar_supported(EImport *ei, EImportTarget *target, EImportImporter *im
{
gchar *filename;
gboolean res;
- EImportTargetHome *s = (EImportTargetHome *)target;
if (target->type != E_IMPORT_TARGET_HOME)
return FALSE;
- filename = g_build_filename(s->homedir, "user-cal.vcf", NULL);
+ filename = g_build_filename(g_get_home_dir (), "user-cal.vcf", NULL);
res = g_file_test(filename, G_FILE_TEST_IS_REGULAR);
g_free (filename);
@@ -614,7 +613,6 @@ gnome_calendar_import(EImport *ei, EImportTarget *target, EImportImporter *im)
ECal *calendar_client = NULL, *tasks_client = NULL;
gint t;
gint do_calendar, do_tasks;
- EImportTargetHome *s = (EImportTargetHome *)target;
ICalIntelligentImporter *ici;
/* This is pretty shitty, everything runs in the gui thread and can block
@@ -643,7 +641,7 @@ gnome_calendar_import(EImport *ei, EImportTarget *target, EImportImporter *im)
}
/* Load the Gnome Calendar file and convert to iCalendar. */
- filename = g_build_filename(s->homedir, "user-cal.vcf", NULL);
+ filename = g_build_filename(g_get_home_dir (), "user-cal.vcf", NULL);
icalcomp = load_vcalendar_file (filename);
g_free (filename);
diff --git a/e-util/e-import.c b/e-util/e-import.c
index 0c10715ce3..08747cd551 100644
--- a/e-util/e-import.c
+++ b/e-util/e-import.c
@@ -79,11 +79,8 @@ ec_target_free(EImport *ep, EImportTarget *t)
g_free(s->uri_src);
g_free(s->uri_dest);
break; }
- case E_IMPORT_TARGET_HOME: {
- EImportTargetHome *s = (EImportTargetHome *)t;
-
- g_free(s->homedir);
- break; }
+ default:
+ break;
}
g_datalist_clear(&t->data);
@@ -289,6 +286,7 @@ e_import_class_add_importer(EImportClass *klass, EImportImporter *importer, EImp
node->importer = importer;
node->free = freefunc;
node->data = data;
+
ei = (struct _EImportImporters *)klass->importers.head;
en = ei->next;
while (en && ei->importer->pri < importer->pri) {
@@ -306,24 +304,6 @@ e_import_class_add_importer(EImportClass *klass, EImportImporter *importer, EImp
}
}
-void e_import_class_remove_importer(EImportClass *klass, EImportImporter *f)
-{
- struct _EImportImporters *ei, *en;
-
- ei = (struct _EImportImporters *)klass->importers.head;
- en = ei->next;
- while (en) {
- if (ei->importer == f) {
- e_dlist_remove((EDListNode *)ei);
- if (ei->free)
- ei->free(f, ei->data);
- g_free(ei);
- }
- ei = en;
- en = en->next;
- }
-}
-
/**
* e_import_target_new:
* @ep: Parent EImport object.
@@ -377,250 +357,9 @@ EImportTargetURI *e_import_target_new_uri(EImport *ei, const gchar *suri, const
return t;
}
-EImportTargetHome *e_import_target_new_home(EImport *ei, const gchar *home)
-{
- EImportTargetHome *t = e_import_target_new(ei, E_IMPORT_TARGET_HOME, sizeof(*t));
-
- t->homedir = g_strdup(home);
-
- return t;
-}
-
-/* ********************************************************************** */
-
-/* Import menu plugin handler */
-
-/*
-<e-plugin
- class="org.gnome.mail.plugin.import:1.0"
- id="org.gnome.mail.plugin.import.item:1.0"
- type="shlib"
- location="/opt/gnome2/lib/camel/1.0/libcamelimap.so"
- name="imap"
- description="IMAP4 and IMAP4v1 mail store">
- <hook class="org.gnome.mail.importMenu:1.0"
- handler="HandleImport">
- <menu id="any" target="select">
- <item
- type="item|toggle|radio|image|submenu|bar"
- active
- path="foo/bar"
- label="label"
- icon="foo"
- activate="ep_view_emacs"/>
- </menu>
- </extension>
-
-*/
-
-static gpointer emph_parent_class;
-#define emph ((EImportHook *)eph)
-
-static const EImportHookTargetMask eih_no_masks[] = {
- { NULL }
-};
-
-static const EImportHookTargetMap eih_targets[] = {
- { "uri", E_IMPORT_TARGET_URI, eih_no_masks },
- { "home", E_IMPORT_TARGET_HOME, eih_no_masks },
- { NULL }
-};
-
-static gboolean eih_supported(EImport *ei, EImportTarget *target, EImportImporter *im)
-{
- struct _EImportHookImporter *ihook = (EImportHookImporter *)im;
- EImportHook *hook = im->user_data;
-
- return e_plugin_invoke(hook->hook.plugin, ihook->supported, target) != NULL;
-}
-
-static GtkWidget *eih_get_widget(EImport *ei, EImportTarget *target, EImportImporter *im)
-{
- struct _EImportHookImporter *ihook = (EImportHookImporter *)im;
- EImportHook *hook = im->user_data;
-
- return e_plugin_invoke(hook->hook.plugin, ihook->get_widget, target);
-}
-
-static void eih_import(EImport *ei, EImportTarget *target, EImportImporter *im)
-{
- struct _EImportHookImporter *ihook = (EImportHookImporter *)im;
- EImportHook *hook = im->user_data;
-
- e_plugin_invoke(hook->hook.plugin, ihook->import, target);
-}
-
-static void eih_cancel(EImport *ei, EImportTarget *target, EImportImporter *im)
-{
- struct _EImportHookImporter *ihook = (EImportHookImporter *)im;
- EImportHook *hook = im->user_data;
-
- e_plugin_invoke(hook->hook.plugin, ihook->cancel, target);
-}
-
-static void
-eih_free_importer(EImportImporter *im, gpointer data)
-{
- EImportHookImporter *ihook = (EImportHookImporter *)im;
-
- g_free(ihook->supported);
- g_free(ihook->get_widget);
- g_free(ihook->import);
- g_free(ihook);
-}
-
-static struct _EImportHookImporter *
-emph_construct_importer(EPluginHook *eph, xmlNodePtr root)
-{
- struct _EImportHookImporter *item;
- EImportHookTargetMap *map;
- EImportHookClass *klass = (EImportHookClass *)G_OBJECT_GET_CLASS(eph);
- gchar *tmp;
-
- d(printf(" loading import item\n"));
- item = g_malloc0(sizeof(*item));
-
- tmp = (gchar *)xmlGetProp(root, (const guchar *)"target");
- if (tmp == NULL)
- goto error;
- map = g_hash_table_lookup(klass->target_map, tmp);
- xmlFree(tmp);
- if (map == NULL)
- goto error;
-
- item->importer.type = map->id;
- item->supported = e_plugin_xml_prop(root, "supported");
- item->get_widget = e_plugin_xml_prop(root, "get-widget");
- item->import = e_plugin_xml_prop(root, "import");
- item->cancel = e_plugin_xml_prop(root, "cancel");
-
- item->importer.name = e_plugin_xml_prop(root, "name");
- item->importer.description = e_plugin_xml_prop(root, "description");
-
- item->importer.user_data = eph;
-
- if (item->import == NULL || item->supported == NULL)
- goto error;
-
- item->importer.supported = eih_supported;
- item->importer.import = eih_import;
- if (item->get_widget)
- item->importer.get_widget = eih_get_widget;
- if (item->cancel)
- item->importer.cancel = eih_cancel;
-
- return item;
-error:
- d(printf("error!\n"));
- eih_free_importer((EImportImporter *)item, NULL);
- return NULL;
-}
-
-static gint
-emph_construct(EPluginHook *eph, EPlugin *ep, xmlNodePtr root)
-{
- xmlNodePtr node;
- EImportClass *klass;
-
- d(printf("loading import hook\n"));
-
- if (((EPluginHookClass *)emph_parent_class)->construct(eph, ep, root) == -1)
- return -1;
-
- klass = ((EImportHookClass *)G_OBJECT_GET_CLASS(eph))->import_class;
-
- node = root->children;
- while (node) {
- if (strcmp((gchar *)node->name, "importer") == 0) {
- struct _EImportHookImporter *ihook;
-
- ihook = emph_construct_importer(eph, node);
- if (ihook) {
- e_import_class_add_importer(klass, &ihook->importer, eih_free_importer, eph);
- emph->importers = g_slist_append(emph->importers, ihook);
- }
- }
- node = node->next;
- }
-
- eph->plugin = ep;
-
- return 0;
-}
-
-static void
-emph_finalise(GObject *o)
-{
- /*EPluginHook *eph = (EPluginHook *)o;*/
-
- /* free importers? */
-
- ((GObjectClass *)emph_parent_class)->finalize(o);
-}
-
-static void
-emph_class_init(EPluginHookClass *klass)
-{
- gint i;
-
- ((GObjectClass *)klass)->finalize = emph_finalise;
- klass->construct = emph_construct;
-
- /** @HookClass: Evolution Importers
- * @Id: org.gnome.evolution.import:1.0
- * @Target: EImportTarget
- *
- * A hook for data importers.
- **/
-
- klass->id = "org.gnome.evolution.import:1.0";
-
- d(printf("EImportHook: init class %p '%s'\n", klass, g_type_name(((GObjectClass *)klass)->g_type_class.g_type)));
-
- ((EImportHookClass *)klass)->target_map = g_hash_table_new(g_str_hash, g_str_equal);
- ((EImportHookClass *)klass)->import_class = g_type_class_ref(e_import_get_type());
-
- for (i=0;eih_targets[i].type;i++)
- e_import_hook_class_add_target_map((EImportHookClass *)klass, &eih_targets[i]);
-}
-
-/**
- * e_import_hook_get_type:
- *
- * Standard GObject function to get the object type.
- *
- * Return value: The EImportHook class type.
- **/
-GType
-e_import_hook_get_type(void)
-{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo info = {
- sizeof(EImportHookClass), NULL, NULL, (GClassInitFunc) emph_class_init, NULL, NULL,
- sizeof(EImportHook), 0, (GInstanceInitFunc) NULL,
- };
-
- emph_parent_class = g_type_class_ref(e_plugin_hook_get_type());
- type = g_type_register_static(e_plugin_hook_get_type(), "EImportHook", &info, 0);
- }
-
- return type;
-}
-
-/**
- * e_import_hook_class_add_target_map:
- *
- * @klass: The dervied EimportHook class.
- * @map: A map used to describe a single EImportTarget type for this
- * class.
- *
- * Add a targe tmap to a concrete derived class of EImport. The
- * target map enumates the target types available for the implenting
- * class.
- **/
-void e_import_hook_class_add_target_map(EImportHookClass *klass, const EImportHookTargetMap *map)
+EImportTargetHome *
+e_import_target_new_home (EImport *ei)
{
- g_hash_table_insert(klass->target_map, (gpointer)map->type, (gpointer)map);
+ return e_import_target_new (
+ ei, E_IMPORT_TARGET_HOME, sizeof (EImportTargetHome));
}
diff --git a/e-util/e-import.h b/e-util/e-import.h
index 9e409a30fb..8215604c69 100644
--- a/e-util/e-import.h
+++ b/e-util/e-import.h
@@ -96,7 +96,7 @@ struct _EImportImporter {
* import context for a given importer.
**/
struct _EImportTarget {
- struct _EImport *import;
+ EImport *import;
guint32 type;
@@ -109,16 +109,14 @@ typedef struct _EImportTargetURI EImportTargetURI;
typedef struct _EImportTargetHome EImportTargetHome;
struct _EImportTargetURI {
- struct _EImportTarget target;
+ EImportTarget target;
gchar *uri_src;
gchar *uri_dest;
};
struct _EImportTargetHome {
- struct _EImportTarget target;
-
- gchar *homedir;
+ EImportTarget target;
};
/**
@@ -168,7 +166,6 @@ EImport *e_import_new(const gchar *id);
/* Static class methods */
void e_import_class_add_importer(EImportClass *klass, EImportImporter *importer, EImportImporterFunc freefunc, gpointer data);
-void e_import_class_remove_importer(EImportClass *klass, EImportImporter *f);
GSList *e_import_get_importers(EImport *emp, EImportTarget *target);
@@ -186,77 +183,7 @@ gpointer e_import_target_new(EImport *ep, gint type, gsize size);
void e_import_target_free(EImport *ep, gpointer o);
EImportTargetURI *e_import_target_new_uri(EImport *ei, const gchar *suri, const gchar *duri);
-EImportTargetHome *e_import_target_new_home(EImport *ei, const gchar *home);
-
-/* ********************************************************************** */
-
-/* import plugin target, they are closely integrated */
-
-/* To implement a basic import plugin, you just need to subclass
- this and initialise the class target type tables */
-
-#include "e-util/e-plugin.h"
-
-typedef struct _EPluginHookTargetMap EImportHookTargetMap;
-typedef struct _EPluginHookTargetKey EImportHookTargetMask;
-
-typedef struct _EImportHook EImportHook;
-typedef struct _EImportHookClass EImportHookClass;
-
-typedef struct _EImportHookImporter EImportHookImporter;
-
-struct _EImportHookImporter {
- EImportImporter importer;
-
- /* user_data == EImportHook */
-
- gchar *supported;
- gchar *get_widget;
- gchar *import;
- gchar *cancel;
-};
-
-/**
- * struct _EImportHook - Plugin hook for importuration windows.
- *
- * @hook: Superclass.
- * @groups: A list of EImportHookGroup's of all importuration windows
- * this plugin hooks into.
- *
- **/
-struct _EImportHook {
- EPluginHook hook;
-
- GSList *importers;
-};
-
-/**
- * struct _EImportHookClass - Abstract class for importuration window
- * plugin hooks.
- *
- * @hook_class: Superclass.
- * @target_map: A table of EImportHookTargetMap structures describing
- * the possible target types supported by this class.
- * @import_class: The EImport derived class that this hook
- * implementation drives.
- *
- * This is an abstract class defining the plugin hook point for
- * importuration windows.
- *
- **/
-struct _EImportHookClass {
- EPluginHookClass hook_class;
-
- /* EImportHookTargetMap by .type */
- GHashTable *target_map;
- /* the import class these imports's belong to */
- EImportClass *import_class;
-};
-
-GType e_import_hook_get_type(void);
-
-/* for implementors */
-void e_import_hook_class_add_target_map(EImportHookClass *klass, const EImportHookTargetMap *);
+EImportTargetHome *e_import_target_new_home(EImport *ei);
G_END_DECLS
diff --git a/mail/importers/elm-importer.c b/mail/importers/elm-importer.c
index 1c28e2d82d..e6cfa6a862 100644
--- a/mail/importers/elm-importer.c
+++ b/mail/importers/elm-importer.c
@@ -145,7 +145,6 @@ elm_get_rc(EImport *ei, const gchar *name)
static gboolean
elm_supported(EImport *ei, EImportTarget *target, EImportImporter *im)
{
- EImportTargetHome *s;
const gchar *maildir;
gchar *elmdir;
gboolean mailexists, exists;
@@ -153,9 +152,7 @@ elm_supported(EImport *ei, EImportTarget *target, EImportImporter *im)
if (target->type != E_IMPORT_TARGET_HOME)
return FALSE;
- s = (EImportTargetHome *)target;
-
- elmdir = g_build_filename(s->homedir, ".elm", NULL);
+ elmdir = g_build_filename(g_get_home_dir (), ".elm", NULL);
exists = g_file_test(elmdir, G_FILE_TEST_IS_DIR);
g_free(elmdir);
if (!exists)
@@ -166,7 +163,7 @@ elm_supported(EImport *ei, EImportTarget *target, EImportImporter *im)
maildir = "Mail";
if (!g_path_is_absolute(maildir))
- elmdir = g_build_filename(s->homedir, maildir, NULL);
+ elmdir = g_build_filename(g_get_home_dir (), maildir, NULL);
else
elmdir = g_strdup (maildir);
@@ -198,7 +195,7 @@ elm_import_exec (struct _elm_import_msg *m)
maildir = "Mail";
if (!g_path_is_absolute(maildir))
- elmdir = g_build_filename(m->target->homedir, maildir, NULL);
+ elmdir = g_build_filename(g_get_home_dir (), maildir, NULL);
else
elmdir = g_strdup(maildir);
diff --git a/mail/importers/mail-importer.c b/mail/importers/mail-importer.c
index 61726dd37f..6e4573487f 100644
--- a/mail/importers/mail-importer.c
+++ b/mail/importers/mail-importer.c
@@ -54,66 +54,6 @@
#include "mail-importer.h"
-/**
- * mail_importer_make_local_folder:
- * @folderpath:
- *
- * Check a local folder exists at path @folderpath, and if not, create it.
- *
- * Return value: The physical uri of the folder, or NULL if the folder did
- * not exist and could not be created.
- **/
-gchar *
-mail_importer_make_local_folder(const gchar *folderpath)
-{
- return g_strdup_printf("mbox:/home/notzed/.evolution/mail/local/%s", folderpath);
-}
-
-/**
- * mail_importer_add_line:
- * importer: A MailImporter structure.
- * str: Next line of the mbox.
- * finished: TRUE if @str is the last line of the message.
- *
- * Adds lines to the message until it is finished, and then adds
- * the complete message to the folder.
- */
-void
-mail_importer_add_line (MailImporter *importer,
- const gchar *str,
- gboolean finished)
-{
- CamelMimeMessage *msg;
- CamelMessageInfo *info;
- CamelException *ex;
-
- if (importer->mstream == NULL)
- importer->mstream = CAMEL_STREAM_MEM (camel_stream_mem_new ());
-
- camel_stream_write (CAMEL_STREAM (importer->mstream), str, strlen (str));
-
- if (finished == FALSE)
- return;
-
- camel_stream_reset (CAMEL_STREAM (importer->mstream));
- info = camel_message_info_new(NULL);
- camel_message_info_set_flags(info, CAMEL_MESSAGE_SEEN, ~0);
-
- msg = camel_mime_message_new ();
- camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg),
- CAMEL_STREAM (importer->mstream));
-
- camel_object_unref (importer->mstream);
- importer->mstream = NULL;
-
- ex = camel_exception_new ();
- camel_folder_append_message (importer->folder, msg, info, NULL, ex);
- camel_object_unref (msg);
-
- camel_exception_free (ex);
- camel_message_info_free(info);
-}
-
struct _import_mbox_msg {
MailMsg base;
@@ -151,7 +91,7 @@ decode_status(const gchar *status)
p = status;
while ((*p++)) {
- for (i=0;i<sizeof(status_flags)/sizeof(status_flags[0]);i++)
+ for (i = 0; i < G_N_ELEMENTS (status_flags); i++)
if (status_flags[i].tag == *p)
flags |= status_flags[i].flag;
}
@@ -166,7 +106,7 @@ decode_mozilla_status(const gchar *tmp)
guint32 flags = 0;
gint i;
- for (i=0;i<sizeof(status_flags)/sizeof(status_flags[0]);i++)
+ for (i = 0; i < G_N_ELEMENTS (status_flags); i++)
if (status_flags[i].mozflag & status)
flags |= status_flags[i].flag;
return flags;
diff --git a/mail/importers/mail-importer.h b/mail/importers/mail-importer.h
index d751547827..7758c0e563 100644
--- a/mail/importers/mail-importer.h
+++ b/mail/importers/mail-importer.h
@@ -27,29 +27,6 @@
#include <e-util/e-import.h>
#include <camel/camel-folder.h>
-typedef struct _MailImporter MailImporter;
-struct _MailImporter {
- CamelFolder *folder;
- CamelStreamMem *mstream;
-
- gboolean frozen; /* Is folder frozen? */
-};
-
-struct _MailComponent;
-
-void mail_importer_init (struct _MailComponent *mc);
-void mail_importer_uninit (void);
-
-void mail_importer_add_line (MailImporter *importer,
- const gchar *str,
- gboolean finished);
-void mail_importer_create_folder (const gchar *parent_path,
- const gchar *name,
- const gchar *description);
-
-/* creates a folder at folderpath on the local storage */
-gchar *mail_importer_make_local_folder(const gchar *folderpath);
-
EImportImporter *mbox_importer_peek(void);
EImportImporter *elm_importer_peek(void);
diff --git a/mail/importers/pine-importer.c b/mail/importers/pine-importer.c
index 84c29b24c5..d00394fa75 100644
--- a/mail/importers/pine-importer.c
+++ b/mail/importers/pine-importer.c
@@ -76,11 +76,11 @@ pine_supported(EImport *ei, EImportTarget *target, EImportImporter *im)
s = (EImportTargetHome *)target;
- maildir = g_build_filename(s->homedir, "mail", NULL);
+ maildir = g_build_filename(g_get_home_dir (), "mail", NULL);
md_exists = g_file_test(maildir, G_FILE_TEST_IS_DIR);
g_free(maildir);
- addrfile = g_build_filename(s->homedir, ".addressbook", NULL);
+ addrfile = g_build_filename(g_get_home_dir (), ".addressbook", NULL);
addr_exists = g_file_test(addrfile, G_FILE_TEST_IS_REGULAR);
g_free (addrfile);
diff --git a/plugins/pst-import/pst-importer.c b/plugins/pst-import/pst-importer.c
index 8009d563f7..a720236c5a 100644
--- a/plugins/pst-import/pst-importer.c
+++ b/plugins/pst-import/pst-importer.c
@@ -41,6 +41,7 @@
#include <gtk/gtk.h>
#include <e-util/e-import.h>
+#include <e-util/e-plugin.h>
#include <libebook/e-contact.h>
#include <libebook/e-book.h>
diff --git a/plugins/startup-wizard/startup-wizard.c b/plugins/startup-wizard/startup-wizard.c
index 15660dfc47..e04a005206 100644
--- a/plugins/startup-wizard/startup-wizard.c
+++ b/plugins/startup-wizard/startup-wizard.c
@@ -122,7 +122,7 @@ startup_wizard_importer_page (EPlugin *ep, EConfigHookItemFactoryData *hook_data
if (import == NULL) {
import = e_import_new("org.gnome.evolution.shell.importer");
- import_target = e_import_target_new_home(import, g_get_home_dir());
+ import_target = e_import_target_new_home(import);
import_importers = e_import_get_importers(import, (EImportTarget *)import_target);
}
diff --git a/shell/e-shell-importer.c b/shell/e-shell-importer.c
index fbc1b306f5..5d062126e0 100644
--- a/shell/e-shell-importer.c
+++ b/shell/e-shell-importer.c
@@ -372,7 +372,7 @@ prepare_intelligent_page (GtkAssistant *assistant, GtkWidget *apage, ImportData
return;
}
- page->target = e_import_target_new_home(data->import, g_get_home_dir());
+ page->target = e_import_target_new_home(data->import);
if (data->importerpage->importers)
g_slist_free(data->importerpage->importers);
diff --git a/shell/main.c b/shell/main.c
index 7ce930f6c2..0f52366aa8 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -69,7 +69,6 @@
#include <misc/e-cursors.h>
#include "e-util/e-error.h"
-#include "e-util/e-import.h"
#include <fcntl.h>
#include <signal.h>
@@ -610,7 +609,6 @@ main (gint argc, gchar **argv)
#ifdef ENABLE_PROFILING
e_profile_event_hook_get_type ();
#endif
- e_import_hook_get_type ();
e_plugin_ui_hook_get_type ();
/* All EPlugin and EPluginHook subclasses should be