diff options
Diffstat (limited to 'mail/importers')
-rw-r--r-- | mail/importers/elm-importer.c | 36 | ||||
-rw-r--r-- | mail/importers/mail-importer.c | 50 | ||||
-rw-r--r-- | mail/importers/pine-importer.c | 37 |
3 files changed, 55 insertions, 68 deletions
diff --git a/mail/importers/elm-importer.c b/mail/importers/elm-importer.c index 1fafedc0a2..b65ffe420f 100644 --- a/mail/importers/elm-importer.c +++ b/mail/importers/elm-importer.c @@ -51,7 +51,7 @@ #define d(x) x struct _elm_import_msg { - struct _mail_msg msg; + MailMsg base; EImport *import; EImportTargetHome *target; @@ -178,8 +178,8 @@ elm_supported(EImport *ei, EImportTarget *target, EImportImporter *im) return mailexists; } -static char * -elm_import_describe (struct _mail_msg *mm, int complete) +static gchar * +elm_import_desc (struct _elm_import_msg *m) { return g_strdup (_("Importing Elm data")); } @@ -190,9 +190,8 @@ static MailImporterSpecial elm_special_folders[] = { }; static void -elm_import_import(struct _mail_msg *mm) +elm_import_exec (struct _elm_import_msg *m) { - struct _elm_import_msg *m = (struct _elm_import_msg *) mm; const char *maildir; char *elmdir; @@ -210,13 +209,11 @@ elm_import_import(struct _mail_msg *mm) } static void -elm_import_imported(struct _mail_msg *mm) +elm_import_done(struct _elm_import_msg *m) { - struct _elm_import_msg *m = (struct _elm_import_msg *)mm; - printf("importing complete\n"); - if (!camel_exception_is_set(&mm->ex)) { + if (!camel_exception_is_set(&m->base.ex)) { GConfClient *gconf; gconf = gconf_client_get_default(); @@ -228,10 +225,8 @@ elm_import_imported(struct _mail_msg *mm) } static void -elm_import_free(struct _mail_msg *mm) +elm_import_free(struct _elm_import_msg *m) { - struct _elm_import_msg *m = (struct _elm_import_msg *)mm; - camel_operation_unref(m->status); g_free(m->status_what); @@ -280,11 +275,12 @@ elm_status_timeout(void *data) return TRUE; } -static struct _mail_msg_op elm_import_op = { - elm_import_describe, - elm_import_import, - elm_import_imported, - elm_import_free, +static MailMsgInfo elm_import_info = { + sizeof (struct _elm_import_msg), + (MailMsgDescFunc) elm_import_desc, + (MailMsgExecFunc) elm_import_exec, + (MailMsgDoneFunc) elm_import_done, + (MailMsgFreeFunc) elm_import_free }; static int @@ -293,7 +289,7 @@ mail_importer_elm_import(EImport *ei, EImportTarget *target) struct _elm_import_msg *m; int id; - m = mail_msg_new(&elm_import_op, NULL, sizeof (*m)); + m = mail_msg_new(&elm_import_info); g_datalist_set_data(&target->data, "elm-msg", m); m->import = ei; g_object_ref(m->import); @@ -302,9 +298,9 @@ mail_importer_elm_import(EImport *ei, EImportTarget *target) m->status_lock = g_mutex_new(); m->status = camel_operation_new(elm_status, m); - id = m->msg.seq; + id = m->base.seq; - e_thread_put(mail_thread_queued, (EMsg *)m); + mail_msg_fast_ordered_push (m); return id; } diff --git a/mail/importers/mail-importer.c b/mail/importers/mail-importer.c index 5905080735..99241d8ddb 100644 --- a/mail/importers/mail-importer.c +++ b/mail/importers/mail-importer.c @@ -132,7 +132,7 @@ struct _BonoboObject *mail_importer_factory_cb(struct _BonoboGenericFactory *fac } struct _import_mbox_msg { - struct _mail_msg msg; + MailMsg base; char *path; char *uri; @@ -142,8 +142,8 @@ struct _import_mbox_msg { void *done_data; }; -static char * -import_mbox_describe(struct _mail_msg *mm, int complete) +static gchar * +import_mbox_desc (struct _import_mbox_msg *m) { return g_strdup (_("Importing mailbox")); } @@ -190,9 +190,8 @@ decode_mozilla_status(const char *tmp) } static void -import_mbox_import(struct _mail_msg *mm) +import_mbox_exec (struct _import_mbox_msg *m) { - struct _import_mbox_msg *m = (struct _import_mbox_msg *) mm; CamelFolder *folder; CamelMimeParser *mp = NULL; struct stat st; @@ -207,7 +206,7 @@ import_mbox_import(struct _mail_msg *mm) if (m->uri == NULL || m->uri[0] == 0) folder = mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_INBOX); else - folder = mail_tool_uri_to_folder(m->uri, CAMEL_STORE_FOLDER_CREATE, &mm->ex); + folder = mail_tool_uri_to_folder(m->uri, CAMEL_STORE_FOLDER_CREATE, &m->base.ex); if (folder == NULL) return; @@ -262,11 +261,11 @@ import_mbox_import(struct _mail_msg *mm) flags |= decode_status(tmp); camel_message_info_set_flags(info, flags, ~0); - camel_folder_append_message(folder, msg, info, NULL, &mm->ex); + camel_folder_append_message(folder, msg, info, NULL, &m->base.ex); camel_message_info_free(info); camel_object_unref(msg); - if (camel_exception_is_set(&mm->ex)) + if (camel_exception_is_set(&m->base.ex)) break; camel_mime_parser_step(mp, NULL, NULL); @@ -286,30 +285,27 @@ fail1: } static void -import_mbox_done(struct _mail_msg *mm) +import_mbox_done (struct _import_mbox_msg *m) { - struct _import_mbox_msg *m = (struct _import_mbox_msg *)mm; - if (m->done) - m->done(m->done_data, &mm->ex); + m->done(m->done_data, &m->base.ex); } static void -import_mbox_free (struct _mail_msg *mm) +import_mbox_free (struct _import_mbox_msg *m) { - struct _import_mbox_msg *m = (struct _import_mbox_msg *)mm; - if (m->cancel) camel_operation_unref(m->cancel); g_free(m->uri); g_free(m->path); } -static struct _mail_msg_op import_mbox_op = { - import_mbox_describe, - import_mbox_import, - import_mbox_done, - import_mbox_free, +static MailMsgInfo import_mbox_info = { + sizeof (struct _import_mbox_msg), + (MailMsgDescFunc) import_mbox_desc, + (MailMsgExecFunc) import_mbox_exec, + (MailMsgDoneFunc) import_mbox_done, + (MailMsgFreeFunc) import_mbox_free }; int @@ -318,7 +314,7 @@ mail_importer_import_mbox(const char *path, const char *folderuri, CamelOperatio struct _import_mbox_msg *m; int id; - m = mail_msg_new(&import_mbox_op, NULL, sizeof (*m)); + m = mail_msg_new(&import_mbox_info); m->path = g_strdup(path); m->uri = g_strdup(folderuri); m->done = done; @@ -328,8 +324,8 @@ mail_importer_import_mbox(const char *path, const char *folderuri, CamelOperatio camel_operation_ref(cancel); } - id = m->msg.seq; - e_thread_put(mail_thread_queued, (EMsg *)m); + id = m->base.seq; + mail_msg_fast_ordered_push (m); return id; } @@ -339,7 +335,7 @@ mail_importer_import_mbox_sync(const char *path, const char *folderuri, CamelOpe { struct _import_mbox_msg *m; - m = mail_msg_new(&import_mbox_op, NULL, sizeof (*m)); + m = mail_msg_new(&import_mbox_info); m->path = g_strdup(path); m->uri = g_strdup(folderuri); if (cancel) { @@ -347,9 +343,9 @@ mail_importer_import_mbox_sync(const char *path, const char *folderuri, CamelOpe camel_operation_ref(cancel); } - import_mbox_import(&m->msg); - import_mbox_done(&m->msg); - mail_msg_free(&m->msg); + import_mbox_exec(m); + import_mbox_done(m); + mail_msg_unref(m); } struct _import_folders_data { diff --git a/mail/importers/pine-importer.c b/mail/importers/pine-importer.c index 97f3349e66..afc7f7fb1c 100644 --- a/mail/importers/pine-importer.c +++ b/mail/importers/pine-importer.c @@ -56,7 +56,7 @@ #define d(x) x struct _pine_import_msg { - struct _mail_msg msg; + MailMsg base; EImport *import; EImportTarget *target; @@ -223,8 +223,8 @@ import_contacts(void) g_object_unref(book); } -static char * -pine_import_describe (struct _mail_msg *mm, int complete) +static gchar * +pine_import_desc (struct _pine_import_msg *m) { return g_strdup (_("Importing Pine data")); } @@ -236,10 +236,8 @@ static MailImporterSpecial pine_special_folders[] = { }; static void -pine_import_import(struct _mail_msg *mm) +pine_import_exec(struct _pine_import_msg *m) { - struct _pine_import_msg *m = (struct _pine_import_msg *) mm; - if (GPOINTER_TO_INT(g_datalist_get_data(&m->target->data, "pine-do-addr"))) import_contacts(); @@ -253,13 +251,11 @@ pine_import_import(struct _mail_msg *mm) } static void -pine_import_imported(struct _mail_msg *mm) +pine_import_done(struct _pine_import_msg *m) { - struct _pine_import_msg *m = (struct _pine_import_msg *)mm; - printf("importing complete\n"); - if (!camel_exception_is_set(&mm->ex)) { + if (!camel_exception_is_set(&m->base.ex)) { GConfClient *gconf; gconf = gconf_client_get_default(); @@ -274,10 +270,8 @@ pine_import_imported(struct _mail_msg *mm) } static void -pine_import_free(struct _mail_msg *mm) +pine_import_free(struct _pine_import_msg *m) { - struct _pine_import_msg *m = (struct _pine_import_msg *)mm; - camel_operation_unref(m->status); g_free(m->status_what); @@ -326,11 +320,12 @@ pine_status_timeout(void *data) return TRUE; } -static struct _mail_msg_op pine_import_op = { - pine_import_describe, - pine_import_import, - pine_import_imported, - pine_import_free, +static MailMsgInfo pine_import_info = { + sizeof (struct _pine_import_msg), + (MailMsgDescFunc) pine_import_desc, + (MailMsgExecFunc) pine_import_exec, + (MailMsgDoneFunc) pine_import_done, + (MailMsgFreeFunc) pine_import_free }; static int @@ -339,7 +334,7 @@ mail_importer_pine_import(EImport *ei, EImportTarget *target) struct _pine_import_msg *m; int id; - m = mail_msg_new(&pine_import_op, NULL, sizeof (*m)); + m = mail_msg_new(&pine_import_info); g_datalist_set_data(&target->data, "pine-msg", m); m->import = ei; g_object_ref(m->import); @@ -348,9 +343,9 @@ mail_importer_pine_import(EImport *ei, EImportTarget *target) m->status_lock = g_mutex_new(); m->status = camel_operation_new(pine_status, m); - id = m->msg.seq; + id = m->base.seq; - e_thread_put(mail_thread_queued, (EMsg *)m); + mail_msg_fast_ordered_push (m); return id; } |