diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-09-12 02:56:28 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-09-13 20:28:58 +0800 |
commit | cd53ba990035bdb4861d9660917d457533d4ecb2 (patch) | |
tree | d9c9da2208f4a921c514497ea92d27e3d88481d1 /mail/importers | |
parent | b2b27cfa1bfcd6efdac30d2745a6e8cd4e6de134 (diff) | |
download | gsoc2013-evolution-cd53ba990035bdb4861d9660917d457533d4ecb2.tar gsoc2013-evolution-cd53ba990035bdb4861d9660917d457533d4ecb2.tar.gz gsoc2013-evolution-cd53ba990035bdb4861d9660917d457533d4ecb2.tar.bz2 gsoc2013-evolution-cd53ba990035bdb4861d9660917d457533d4ecb2.tar.lz gsoc2013-evolution-cd53ba990035bdb4861d9660917d457533d4ecb2.tar.xz gsoc2013-evolution-cd53ba990035bdb4861d9660917d457533d4ecb2.tar.zst gsoc2013-evolution-cd53ba990035bdb4861d9660917d457533d4ecb2.zip |
Coding style cleanups.
Diffstat (limited to 'mail/importers')
-rw-r--r-- | mail/importers/elm-importer.c | 110 | ||||
-rw-r--r-- | mail/importers/evolution-mbox-importer.c | 90 | ||||
-rw-r--r-- | mail/importers/mail-importer.c | 138 | ||||
-rw-r--r-- | mail/importers/mail-importer.h | 12 | ||||
-rw-r--r-- | mail/importers/pine-importer.c | 156 |
5 files changed, 253 insertions, 253 deletions
diff --git a/mail/importers/elm-importer.c b/mail/importers/elm-importer.c index 87c94ff524..80d4c474bc 100644 --- a/mail/importers/elm-importer.c +++ b/mail/importers/elm-importer.c @@ -59,7 +59,7 @@ struct _elm_import_msg { }; static GHashTable * -parse_elm_rc(const gchar *elmrc) +parse_elm_rc (const gchar *elmrc) { gchar line[4096]; FILE *handle; @@ -70,7 +70,7 @@ parse_elm_rc(const gchar *elmrc) (GDestroyNotify) g_free, (GDestroyNotify) g_free); - if (!g_file_test(elmrc, G_FILE_TEST_IS_REGULAR)) + if (!g_file_test (elmrc, G_FILE_TEST_IS_REGULAR)) return prefs; handle = fopen (elmrc, "r"); @@ -111,7 +111,7 @@ parse_elm_rc(const gchar *elmrc) *end = 0; value = g_strdup (linestart); - g_hash_table_insert(prefs, key, value); + g_hash_table_insert (prefs, key, value); } fclose (handle); @@ -120,7 +120,7 @@ parse_elm_rc(const gchar *elmrc) } static gchar * -elm_get_rc(EImport *ei, const gchar *name) +elm_get_rc (EImport *ei, const gchar *name) { GHashTable *prefs; gchar *elmrc; @@ -128,19 +128,19 @@ elm_get_rc(EImport *ei, const gchar *name) prefs = g_object_get_data((GObject *)ei, "elm-rc"); if (prefs == NULL) { elmrc = g_build_filename(g_get_home_dir(), ".elm/elmrc", NULL); - prefs = parse_elm_rc(elmrc); - g_free(elmrc); + prefs = parse_elm_rc (elmrc); + g_free (elmrc); g_object_set_data((GObject *)ei, "elm-rc", prefs); } if (prefs == NULL) return NULL; else - return g_hash_table_lookup(prefs, name); + return g_hash_table_lookup (prefs, name); } static gboolean -elm_supported(EImport *ei, EImportTarget *target, EImportImporter *im) +elm_supported (EImport *ei, EImportTarget *target, EImportImporter *im) { const gchar *maildir; gchar *elmdir; @@ -150,8 +150,8 @@ elm_supported(EImport *ei, EImportTarget *target, EImportImporter *im) return FALSE; elmdir = g_build_filename(g_get_home_dir (), ".elm", NULL); - exists = g_file_test(elmdir, G_FILE_TEST_IS_DIR); - g_free(elmdir); + exists = g_file_test (elmdir, G_FILE_TEST_IS_DIR); + g_free (elmdir); if (!exists) return FALSE; @@ -159,12 +159,12 @@ elm_supported(EImport *ei, EImportTarget *target, EImportImporter *im) if (maildir == NULL) maildir = "Mail"; - if (!g_path_is_absolute(maildir)) - elmdir = g_build_filename(g_get_home_dir (), maildir, NULL); + if (!g_path_is_absolute (maildir)) + elmdir = g_build_filename (g_get_home_dir (), maildir, NULL); else elmdir = g_strdup (maildir); - mailexists = g_file_test(elmdir, G_FILE_TEST_IS_DIR); + mailexists = g_file_test (elmdir, G_FILE_TEST_IS_DIR); g_free (elmdir); return mailexists; @@ -191,47 +191,47 @@ elm_import_exec (struct _elm_import_msg *m) if (maildir == NULL) maildir = "Mail"; - if (!g_path_is_absolute(maildir)) - elmdir = g_build_filename(g_get_home_dir (), maildir, NULL); + if (!g_path_is_absolute (maildir)) + elmdir = g_build_filename (g_get_home_dir (), maildir, NULL); else - elmdir = g_strdup(maildir); + elmdir = g_strdup (maildir); - mail_importer_import_folders_sync(elmdir, elm_special_folders, 0, m->status); - g_free(elmdir); + mail_importer_import_folders_sync (elmdir, elm_special_folders, 0, m->status); + g_free (elmdir); } static void -elm_import_done(struct _elm_import_msg *m) +elm_import_done (struct _elm_import_msg *m) { printf("importing complete\n"); if (m->base.error == NULL) { GConfClient *gconf; - gconf = gconf_client_get_default(); + gconf = gconf_client_get_default (); gconf_client_set_bool(gconf, "/apps/evolution/importer/elm/mail", TRUE, NULL); - g_object_unref(gconf); + g_object_unref (gconf); } - e_import_complete(m->import, (EImportTarget *)m->target); + e_import_complete (m->import, (EImportTarget *)m->target); } static void -elm_import_free(struct _elm_import_msg *m) +elm_import_free (struct _elm_import_msg *m) { - camel_operation_unref(m->status); + camel_operation_unref (m->status); - g_free(m->status_what); - g_mutex_free(m->status_lock); + g_free (m->status_what); + g_mutex_free (m->status_lock); - g_source_remove(m->status_timeout_id); + g_source_remove (m->status_timeout_id); m->status_timeout_id = 0; - g_object_unref(m->import); + g_object_unref (m->import); } static void -elm_status(CamelOperation *op, const gchar *what, gint pc, gpointer data) +elm_status (CamelOperation *op, const gchar *what, gint pc, gpointer data) { struct _elm_import_msg *importer = data; @@ -240,28 +240,28 @@ elm_status(CamelOperation *op, const gchar *what, gint pc, gpointer data) else if (pc == CAMEL_OPERATION_END) pc = 100; - g_mutex_lock(importer->status_lock); - g_free(importer->status_what); - importer->status_what = g_strdup(what); + g_mutex_lock (importer->status_lock); + g_free (importer->status_what); + importer->status_what = g_strdup (what); importer->status_pc = pc; - g_mutex_unlock(importer->status_lock); + g_mutex_unlock (importer->status_lock); } static gboolean -elm_status_timeout(gpointer data) +elm_status_timeout (gpointer data) { struct _elm_import_msg *importer = data; gint pc; gchar *what; if (importer->status_what) { - g_mutex_lock(importer->status_lock); + g_mutex_lock (importer->status_lock); what = importer->status_what; importer->status_what = NULL; pc = importer->status_pc; - g_mutex_unlock(importer->status_lock); + g_mutex_unlock (importer->status_lock); - e_import_status(importer->import, (EImportTarget *)importer->target, what, pc); + e_import_status (importer->import, (EImportTarget *)importer->target, what, pc); } return TRUE; @@ -276,19 +276,19 @@ static MailMsgInfo elm_import_info = { }; static gint -mail_importer_elm_import(EImport *ei, EImportTarget *target) +mail_importer_elm_import (EImport *ei, EImportTarget *target) { struct _elm_import_msg *m; gint id; - m = mail_msg_new(&elm_import_info); + m = mail_msg_new (&elm_import_info); g_datalist_set_data(&target->data, "elm-msg", m); m->import = ei; - g_object_ref(m->import); + g_object_ref (m->import); m->target = (EImportTargetHome *)target; - m->status_timeout_id = g_timeout_add(100, elm_status_timeout, m); - m->status_lock = g_mutex_new(); - m->status = camel_operation_new(elm_status, m); + m->status_timeout_id = g_timeout_add (100, elm_status_timeout, m); + m->status_lock = g_mutex_new (); + m->status = camel_operation_new (elm_status, m); id = m->base.seq; @@ -306,7 +306,7 @@ checkbox_toggle_cb (GtkToggleButton *tb, EImportTarget *target) } static GtkWidget * -elm_getwidget(EImport *ei, EImportTarget *target, EImportImporter *im) +elm_getwidget (EImport *ei, EImportTarget *target, EImportImporter *im) { GtkWidget *box, *w; GConfClient *gconf; @@ -315,39 +315,39 @@ elm_getwidget(EImport *ei, EImportTarget *target, EImportImporter *im) gconf = gconf_client_get_default (); done_mail = gconf_client_get_bool ( gconf, "/apps/evolution/importer/elm/mail", NULL); - g_object_unref(gconf); + g_object_unref (gconf); g_datalist_set_data ( &target->data, "elm-do-mail", GINT_TO_POINTER(!done_mail)); - box = gtk_vbox_new(FALSE, 2); + box = gtk_vbox_new (FALSE, 2); w = gtk_check_button_new_with_label(_("Mail")); - gtk_toggle_button_set_active((GtkToggleButton *)w, !done_mail); + gtk_toggle_button_set_active ((GtkToggleButton *)w, !done_mail); g_signal_connect(w, "toggled", G_CALLBACK(checkbox_toggle_cb), target); - gtk_box_pack_start((GtkBox *)box, w, FALSE, FALSE, 0); - gtk_widget_show_all(box); + gtk_box_pack_start ((GtkBox *)box, w, FALSE, FALSE, 0); + gtk_widget_show_all (box); return box; } static void -elm_import(EImport *ei, EImportTarget *target, EImportImporter *im) +elm_import (EImport *ei, EImportTarget *target, EImportImporter *im) { if (GPOINTER_TO_INT(g_datalist_get_data(&target->data, "elm-do-mail"))) - mail_importer_elm_import(ei, target); + mail_importer_elm_import (ei, target); else - e_import_complete(ei, target); + e_import_complete (ei, target); } static void -elm_cancel(EImport *ei, EImportTarget *target, EImportImporter *im) +elm_cancel (EImport *ei, EImportTarget *target, EImportImporter *im) { struct _elm_import_msg *m = g_datalist_get_data(&target->data, "elm-msg"); if (m) - camel_operation_cancel(m->status); + camel_operation_cancel (m->status); } static EImportImporter elm_importer = { @@ -361,7 +361,7 @@ static EImportImporter elm_importer = { }; EImportImporter * -elm_importer_peek(void) +elm_importer_peek (void) { elm_importer.name = _("Evolution Elm importer"); elm_importer.description = _("Import mail from Elm."); diff --git a/mail/importers/evolution-mbox-importer.c b/mail/importers/evolution-mbox-importer.c index 2d18bf62db..affebd74b6 100644 --- a/mail/importers/evolution-mbox-importer.c +++ b/mail/importers/evolution-mbox-importer.c @@ -70,14 +70,14 @@ typedef struct { } MboxImporter; static void -folder_selected(EMFolderSelectionButton *button, EImportTargetURI *target) +folder_selected (EMFolderSelectionButton *button, EImportTargetURI *target) { - g_free(target->uri_dest); - target->uri_dest = g_strdup(em_folder_selection_button_get_selection(button)); + g_free (target->uri_dest); + target->uri_dest = g_strdup (em_folder_selection_button_get_selection (button)); } static GtkWidget * -mbox_getwidget(EImport *ei, EImportTarget *target, EImportImporter *im) +mbox_getwidget (EImport *ei, EImportTarget *target, EImportImporter *im) { GtkWindow *window; GtkWidget *hbox, *w; @@ -111,24 +111,24 @@ mbox_getwidget(EImport *ei, EImportTarget *target, EImportImporter *im) if (!select_uri) select_uri = g_strdup (e_mail_local_get_folder_uri (E_MAIL_FOLDER_INBOX)); - hbox = gtk_hbox_new(FALSE, 0); + hbox = gtk_hbox_new (FALSE, 0); w = gtk_label_new_with_mnemonic (_("_Destination folder:")); - gtk_box_pack_start((GtkBox *)hbox, w, FALSE, TRUE, 6); + gtk_box_pack_start ((GtkBox *)hbox, w, FALSE, TRUE, 6); label = GTK_LABEL (w); - w = em_folder_selection_button_new( + w = em_folder_selection_button_new ( _("Select folder"), _("Select folder to import into")); gtk_label_set_mnemonic_widget (label, w); em_folder_selection_button_set_selection ((EMFolderSelectionButton *)w, select_uri); folder_selected (EM_FOLDER_SELECTION_BUTTON (w), (EImportTargetURI *)target); g_signal_connect (w, "selected", G_CALLBACK(folder_selected), target); - gtk_box_pack_start((GtkBox *)hbox, w, FALSE, TRUE, 6); + gtk_box_pack_start ((GtkBox *)hbox, w, FALSE, TRUE, 6); - w = gtk_vbox_new(FALSE, 0); - gtk_box_pack_start((GtkBox *)w, hbox, FALSE, FALSE, 0); - gtk_widget_show_all(w); + w = gtk_vbox_new (FALSE, 0); + gtk_box_pack_start ((GtkBox *)w, hbox, FALSE, FALSE, 0); + gtk_widget_show_all (w); g_free (select_uri); @@ -136,7 +136,7 @@ mbox_getwidget(EImport *ei, EImportTarget *target, EImportImporter *im) } static gboolean -mbox_supported(EImport *ei, EImportTarget *target, EImportImporter *im) +mbox_supported (EImport *ei, EImportTarget *target, EImportImporter *im) { gchar signature[6]; gboolean ret = FALSE; @@ -154,20 +154,20 @@ mbox_supported(EImport *ei, EImportTarget *target, EImportImporter *im) if (strncmp(s->uri_src, "file:///", strlen("file:///")) != 0) return FALSE; - filename = g_filename_from_uri(s->uri_src, NULL, NULL); - fd = g_open(filename, O_RDONLY, 0); - g_free(filename); + filename = g_filename_from_uri (s->uri_src, NULL, NULL); + fd = g_open (filename, O_RDONLY, 0); + g_free (filename); if (fd != -1) { - n = read(fd, signature, 5); + n = read (fd, signature, 5); ret = n == 5 && memcmp(signature, "From ", 5) == 0; - close(fd); + close (fd); } return ret; } static void -mbox_status(CamelOperation *op, const gchar *what, gint pc, gpointer data) +mbox_status (CamelOperation *op, const gchar *what, gint pc, gpointer data) { MboxImporter *importer = data; @@ -176,77 +176,77 @@ mbox_status(CamelOperation *op, const gchar *what, gint pc, gpointer data) else if (pc == CAMEL_OPERATION_END) pc = 100; - g_mutex_lock(importer->status_lock); - g_free(importer->status_what); - importer->status_what = g_strdup(what); + g_mutex_lock (importer->status_lock); + g_free (importer->status_what); + importer->status_what = g_strdup (what); importer->status_pc = pc; - g_mutex_unlock(importer->status_lock); + g_mutex_unlock (importer->status_lock); } static gboolean -mbox_status_timeout(gpointer data) +mbox_status_timeout (gpointer data) { MboxImporter *importer = data; gint pc; gchar *what; if (importer->status_what) { - g_mutex_lock(importer->status_lock); + g_mutex_lock (importer->status_lock); what = importer->status_what; importer->status_what = NULL; pc = importer->status_pc; - g_mutex_unlock(importer->status_lock); + g_mutex_unlock (importer->status_lock); - e_import_status(importer->import, (EImportTarget *)importer->target, what, pc); + e_import_status (importer->import, (EImportTarget *)importer->target, what, pc); } return TRUE; } static void -mbox_import_done(gpointer data, GError **error) +mbox_import_done (gpointer data, GError **error) { MboxImporter *importer = data; - g_source_remove(importer->status_timeout_id); - g_free(importer->status_what); - g_mutex_free(importer->status_lock); - camel_operation_unref(importer->cancel); + g_source_remove (importer->status_timeout_id); + g_free (importer->status_what); + g_mutex_free (importer->status_lock); + camel_operation_unref (importer->cancel); - e_import_complete(importer->import, importer->target); - g_free(importer); + e_import_complete (importer->import, importer->target); + g_free (importer); } static void -mbox_import(EImport *ei, EImportTarget *target, EImportImporter *im) +mbox_import (EImport *ei, EImportTarget *target, EImportImporter *im) { MboxImporter *importer; gchar *filename; /* TODO: do we validate target? */ - importer = g_malloc0(sizeof(*importer)); + importer = g_malloc0 (sizeof (*importer)); g_datalist_set_data(&target->data, "mbox-data", importer); importer->import = ei; importer->target = target; - importer->status_lock = g_mutex_new(); - importer->status_timeout_id = g_timeout_add(100, mbox_status_timeout, importer); - importer->cancel = camel_operation_new(mbox_status, importer); + importer->status_lock = g_mutex_new (); + importer->status_timeout_id = g_timeout_add (100, mbox_status_timeout, importer); + importer->cancel = camel_operation_new (mbox_status, importer); - filename = g_filename_from_uri(((EImportTargetURI *)target)->uri_src, NULL, NULL); + filename = g_filename_from_uri (((EImportTargetURI *)target)->uri_src, NULL, NULL); mail_importer_import_mbox ( filename, ((EImportTargetURI *)target)->uri_dest, importer->cancel, mbox_import_done, importer); - g_free(filename); + g_free (filename); } static void -mbox_cancel(EImport *ei, EImportTarget *target, EImportImporter *im) +mbox_cancel (EImport *ei, EImportTarget *target, EImportImporter *im) { MboxImporter *importer = g_datalist_get_data(&target->data, "mbox-data"); if (importer) - camel_operation_cancel(importer->cancel); + camel_operation_cancel (importer->cancel); } static MboxImporterCreatePreviewFunc create_preview_func = NULL; @@ -321,7 +321,7 @@ mbox_get_preview (EImport *ei, EImportTarget *target, EImportImporter *im) g_free (filename); - mp = camel_mime_parser_new(); + mp = camel_mime_parser_new (); camel_mime_parser_scan_from (mp, TRUE); if (camel_mime_parser_init_with_fd (mp, fd) == -1) { g_object_unref (mp); @@ -332,7 +332,7 @@ mbox_get_preview (EImport *ei, EImportTarget *target, EImportImporter *im) CamelMimeMessage *msg; gchar *from; - msg = camel_mime_message_new(); + msg = camel_mime_message_new (); if (camel_mime_part_construct_from_parser ( (CamelMimePart *)msg, mp, NULL) == -1) { g_object_unref (msg); @@ -426,7 +426,7 @@ static EImportImporter mbox_importer = { }; EImportImporter * -mbox_importer_peek(void) +mbox_importer_peek (void) { mbox_importer.name = _("Berkeley Mailbox (mbox)"); mbox_importer.description = _("Importer Berkeley Mailbox format folders"); diff --git a/mail/importers/mail-importer.c b/mail/importers/mail-importer.c index 7c497108b1..d00725533a 100644 --- a/mail/importers/mail-importer.c +++ b/mail/importers/mail-importer.c @@ -76,7 +76,7 @@ static struct { }; static guint32 -decode_status(const gchar *status) +decode_status (const gchar *status) { const gchar *p; guint32 flags = 0; @@ -93,9 +93,9 @@ decode_status(const gchar *status) } static guint32 -decode_mozilla_status(const gchar *tmp) +decode_mozilla_status (const gchar *tmp) { - unsigned long status = strtoul(tmp, NULL, 16); + unsigned long status = strtoul (tmp, NULL, 16); guint32 flags = 0; gint i; @@ -114,7 +114,7 @@ import_mbox_exec (struct _import_mbox_msg *m) gint fd; CamelMessageInfo *info; - if (g_stat(m->path, &st) == -1) { + if (g_stat (m->path, &st) == -1) { g_warning("cannot find source file to import '%s': %s", m->path, g_strerror(errno)); return; } @@ -128,79 +128,79 @@ import_mbox_exec (struct _import_mbox_msg *m) if (folder == NULL) return; - if (S_ISREG(st.st_mode)) { + if (S_ISREG (st.st_mode)) { CamelOperation *oldcancel = NULL; - fd = g_open(m->path, O_RDONLY|O_BINARY, 0); + fd = g_open (m->path, O_RDONLY|O_BINARY, 0); if (fd == -1) { g_warning("cannot find source file to import '%s': %s", m->path, g_strerror(errno)); goto fail1; } - mp = camel_mime_parser_new(); - camel_mime_parser_scan_from(mp, TRUE); - if (camel_mime_parser_init_with_fd(mp, fd) == -1) { /* will never happen - 0 is unconditionally returned */ + mp = camel_mime_parser_new (); + camel_mime_parser_scan_from (mp, TRUE); + if (camel_mime_parser_init_with_fd (mp, fd) == -1) { /* will never happen - 0 is unconditionally returned */ goto fail2; } if (m->cancel) - oldcancel = camel_operation_register(m->cancel); + oldcancel = camel_operation_register (m->cancel); camel_operation_start ( NULL, _("Importing '%s'"), camel_folder_get_full_name (folder)); - camel_folder_freeze(folder); - while (camel_mime_parser_step(mp, NULL, NULL) == CAMEL_MIME_PARSER_STATE_FROM) { + camel_folder_freeze (folder); + while (camel_mime_parser_step (mp, NULL, NULL) == CAMEL_MIME_PARSER_STATE_FROM) { CamelMimeMessage *msg; const gchar *tmp; gint pc = 0; guint32 flags = 0; if (st.st_size > 0) - pc = (gint)(100.0 * ((double)camel_mime_parser_tell(mp) / (double)st.st_size)); - camel_operation_progress(NULL, pc); + pc = (gint)(100.0 * ((double)camel_mime_parser_tell (mp) / (double)st.st_size)); + camel_operation_progress (NULL, pc); - msg = camel_mime_message_new(); - if (camel_mime_part_construct_from_parser((CamelMimePart *)msg, mp, NULL) == -1) { + msg = camel_mime_message_new (); + if (camel_mime_part_construct_from_parser ((CamelMimePart *)msg, mp, NULL) == -1) { /* set exception? */ g_object_unref (msg); break; } - info = camel_message_info_new(NULL); + info = camel_message_info_new (NULL); tmp = camel_medium_get_header((CamelMedium *)msg, "X-Mozilla-Status"); if (tmp) - flags |= decode_mozilla_status(tmp); + flags |= decode_mozilla_status (tmp); tmp = camel_medium_get_header((CamelMedium *)msg, "Status"); if (tmp) - flags |= decode_status(tmp); + flags |= decode_status (tmp); tmp = camel_medium_get_header((CamelMedium *)msg, "X-Status"); if (tmp) - flags |= decode_status(tmp); + flags |= decode_status (tmp); - camel_message_info_set_flags(info, flags, ~0); + camel_message_info_set_flags (info, flags, ~0); camel_folder_append_message ( folder, msg, info, NULL, &m->base.error); - camel_message_info_free(info); + camel_message_info_free (info); g_object_unref (msg); if (m->base.error != NULL) break; - camel_mime_parser_step(mp, NULL, NULL); + camel_mime_parser_step (mp, NULL, NULL); } - camel_folder_sync(folder, FALSE, NULL); - camel_folder_thaw(folder); - camel_operation_end(NULL); + camel_folder_sync (folder, FALSE, NULL); + camel_folder_thaw (folder); + camel_operation_end (NULL); /* TODO: these api's are a bit weird, registering the old is the same as deregistering */ if (m->cancel) - camel_operation_register(oldcancel); + camel_operation_register (oldcancel); fail2: g_object_unref (mp); } fail1: - camel_folder_sync(folder, FALSE, NULL); + camel_folder_sync (folder, FALSE, NULL); g_object_unref (folder); } @@ -208,16 +208,16 @@ static void import_mbox_done (struct _import_mbox_msg *m) { if (m->done) - m->done(m->done_data, &m->base.error); + m->done (m->done_data, &m->base.error); } static void import_mbox_free (struct _import_mbox_msg *m) { if (m->cancel) - camel_operation_unref(m->cancel); - g_free(m->uri); - g_free(m->path); + camel_operation_unref (m->cancel); + g_free (m->uri); + g_free (m->path); } static MailMsgInfo import_mbox_info = { @@ -229,19 +229,19 @@ static MailMsgInfo import_mbox_info = { }; gint -mail_importer_import_mbox(const gchar *path, const gchar *folderuri, CamelOperation *cancel, void (*done)(gpointer data, GError **), gpointer data) +mail_importer_import_mbox (const gchar *path, const gchar *folderuri, CamelOperation *cancel, void (*done)(gpointer data, GError **), gpointer data) { struct _import_mbox_msg *m; gint id; - m = mail_msg_new(&import_mbox_info); - m->path = g_strdup(path); - m->uri = g_strdup(folderuri); + m = mail_msg_new (&import_mbox_info); + m->path = g_strdup (path); + m->uri = g_strdup (folderuri); m->done = done; m->done_data = data; if (cancel) { m->cancel = cancel; - camel_operation_ref(cancel); + camel_operation_ref (cancel); } id = m->base.seq; @@ -251,21 +251,21 @@ mail_importer_import_mbox(const gchar *path, const gchar *folderuri, CamelOperat } void -mail_importer_import_mbox_sync(const gchar *path, const gchar *folderuri, CamelOperation *cancel) +mail_importer_import_mbox_sync (const gchar *path, const gchar *folderuri, CamelOperation *cancel) { struct _import_mbox_msg *m; - m = mail_msg_new(&import_mbox_info); - m->path = g_strdup(path); - m->uri = g_strdup(folderuri); + m = mail_msg_new (&import_mbox_info); + m->path = g_strdup (path); + m->uri = g_strdup (folderuri); if (cancel) { m->cancel = cancel; - camel_operation_ref(cancel); + camel_operation_ref (cancel); } - import_mbox_exec(m); - import_mbox_done(m); - mail_msg_unref(m); + import_mbox_exec (m); + import_mbox_done (m); + mail_msg_unref (m); } struct _import_folders_data { @@ -276,7 +276,7 @@ struct _import_folders_data { }; static void -import_folders_rec(struct _import_folders_data *m, const gchar *filepath, const gchar *folderparent) +import_folders_rec (struct _import_folders_data *m, const gchar *filepath, const gchar *folderparent) { GDir *dir; const gchar *d; @@ -285,7 +285,7 @@ import_folders_rec(struct _import_folders_data *m, const gchar *filepath, const gchar *filefull, *foldersub, *uri, *utf8_filename; const gchar *folder; - dir = g_dir_open(filepath, 0, NULL); + dir = g_dir_open (filepath, 0, NULL); if (dir == NULL) return; @@ -295,17 +295,17 @@ import_folders_rec(struct _import_folders_data *m, const gchar *filepath, const camel_operation_start(NULL, _("Scanning %s"), utf8_filename); g_free (utf8_filename); - while ( (d=g_dir_read_name(dir))) { + while ( (d=g_dir_read_name (dir))) { if (d[0] == '.') continue; - filefull = g_build_filename(filepath, d, NULL); + filefull = g_build_filename (filepath, d, NULL); /* skip non files and directories, and skip directories in mozilla mode */ - if (g_stat(filefull, &st) == -1 - || !(S_ISREG(st.st_mode) - || (m->elmfmt && S_ISDIR(st.st_mode)))) { - g_free(filefull); + if (g_stat (filefull, &st) == -1 + || !(S_ISREG (st.st_mode) + || (m->elmfmt && S_ISDIR (st.st_mode)))) { + g_free (filefull); continue; } @@ -314,7 +314,7 @@ import_folders_rec(struct _import_folders_data *m, const gchar *filepath, const gint i; for (i=0;m->special_folders[i].orig;i++) - if (strcmp(m->special_folders[i].orig, folder) == 0) { + if (strcmp (m->special_folders[i].orig, folder) == 0) { folder = m->special_folders[i].new; break; } @@ -325,32 +325,32 @@ import_folders_rec(struct _import_folders_data *m, const gchar *filepath, const } printf("importing to uri %s\n", uri); - mail_importer_import_mbox_sync(filefull, uri, m->cancel); - g_free(uri); + mail_importer_import_mbox_sync (filefull, uri, m->cancel); + g_free (uri); /* This little gem re-uses the stat buffer and filefull to automagically scan mozilla-format folders */ if (!m->elmfmt) { gchar *tmp = g_strdup_printf("%s.sbd", filefull); - g_free(filefull); + g_free (filefull); filefull = tmp; - if (g_stat(filefull, &st) == -1) { - g_free(filefull); + if (g_stat (filefull, &st) == -1) { + g_free (filefull); continue; } } - if (S_ISDIR(st.st_mode)) { + if (S_ISDIR (st.st_mode)) { foldersub = folderparent?g_strdup_printf("%s/%s", folderparent, folder):g_strdup(folder); - import_folders_rec(m, filefull, foldersub); - g_free(foldersub); + import_folders_rec (m, filefull, foldersub); + g_free (foldersub); } - g_free(filefull); + g_free (filefull); } - g_dir_close(dir); + g_dir_close (dir); - camel_operation_end(NULL); + camel_operation_end (NULL); } /** @@ -369,7 +369,7 @@ import_folders_rec(struct _import_folders_data *m, const gchar *filepath, const * standard unix directories. **/ void -mail_importer_import_folders_sync(const gchar *filepath, MailImporterSpecial special_folders[], gint flags, CamelOperation *cancel) +mail_importer_import_folders_sync (const gchar *filepath, MailImporterSpecial special_folders[], gint flags, CamelOperation *cancel) { struct _import_folders_data m; CamelOperation *oldcancel = NULL; @@ -379,10 +379,10 @@ mail_importer_import_folders_sync(const gchar *filepath, MailImporterSpecial spe m.cancel = cancel; if (cancel) - oldcancel = camel_operation_register(cancel); + oldcancel = camel_operation_register (cancel); - import_folders_rec(&m, filepath, NULL); + import_folders_rec (&m, filepath, NULL); if (cancel) - camel_operation_register(oldcancel); + camel_operation_register (oldcancel); } diff --git a/mail/importers/mail-importer.h b/mail/importers/mail-importer.h index 01a69c981d..9c8c531226 100644 --- a/mail/importers/mail-importer.h +++ b/mail/importers/mail-importer.h @@ -27,7 +27,7 @@ #include <e-util/e-import.h> #include <camel/camel.h> -EImportImporter *mbox_importer_peek(void); +EImportImporter *mbox_importer_peek (void); typedef void (*MboxImporterCreatePreviewFunc)(GObject *preview, GtkWidget **preview_widget); typedef void (*MboxImporterFillPreviewFunc)(GObject *preview, CamelMimeMessage *msg); @@ -36,8 +36,8 @@ typedef void (*MboxImporterFillPreviewFunc)(GObject *preview, CamelMimeMessage * (mail importer cannot link to em-format-html-display directly) */ void mbox_importer_set_preview_funcs (MboxImporterCreatePreviewFunc create_func, MboxImporterFillPreviewFunc fill_func); -EImportImporter *elm_importer_peek(void); -EImportImporter *pine_importer_peek(void); +EImportImporter *elm_importer_peek (void); +EImportImporter *pine_importer_peek (void); /* Defines copied from nsMsgMessageFlags.h in Mozilla source. */ /* Evolution only cares about these headers I think */ @@ -46,8 +46,8 @@ EImportImporter *pine_importer_peek(void); #define MSG_FLAG_MARKED 0x0004 #define MSG_FLAG_EXPUNGED 0x0008 -gint mail_importer_import_mbox(const gchar *path, const gchar *folderuri, CamelOperation *cancel, void (*done)(gpointer data, GError **), gpointer data); -void mail_importer_import_mbox_sync(const gchar *path, const gchar *folderuri, CamelOperation *cancel); +gint mail_importer_import_mbox (const gchar *path, const gchar *folderuri, CamelOperation *cancel, void (*done)(gpointer data, GError **), gpointer data); +void mail_importer_import_mbox_sync (const gchar *path, const gchar *folderuri, CamelOperation *cancel); struct _MailImporterSpecial { const gchar *orig, *new; @@ -58,6 +58,6 @@ typedef struct _MailImporterSpecial MailImporterSpecial; #define MAIL_IMPORTER_MOZFMT (1<<0) /* api in flux */ -void mail_importer_import_folders_sync(const gchar *filepath, MailImporterSpecial special_folders[], gint flags, CamelOperation *cancel); +void mail_importer_import_folders_sync (const gchar *filepath, MailImporterSpecial special_folders[], gint flags, CamelOperation *cancel); #endif diff --git a/mail/importers/pine-importer.c b/mail/importers/pine-importer.c index 354d53d377..c2c0ec22d7 100644 --- a/mail/importers/pine-importer.c +++ b/mail/importers/pine-importer.c @@ -62,7 +62,7 @@ struct _pine_import_msg { }; static gboolean -pine_supported(EImport *ei, EImportTarget *target, EImportImporter *im) +pine_supported (EImport *ei, EImportTarget *target, EImportImporter *im) { gchar *maildir, *addrfile; gboolean md_exists, addr_exists; @@ -71,11 +71,11 @@ pine_supported(EImport *ei, EImportTarget *target, EImportImporter *im) return FALSE; maildir = g_build_filename(g_get_home_dir (), "mail", NULL); - md_exists = g_file_test(maildir, G_FILE_TEST_IS_DIR); - g_free(maildir); + md_exists = g_file_test (maildir, G_FILE_TEST_IS_DIR); + g_free (maildir); addrfile = g_build_filename(g_get_home_dir (), ".addressbook", NULL); - addr_exists = g_file_test(addrfile, G_FILE_TEST_IS_REGULAR); + addr_exists = g_file_test (addrfile, G_FILE_TEST_IS_REGULAR); g_free (addrfile); return md_exists || addr_exists; @@ -96,7 +96,7 @@ FIXME: we dont handle aliases in lists. */ static void -import_contact(EBook *book, gchar *line) +import_contact (EBook *book, gchar *line) { gchar **strings, *addr, **addrs; gint i; @@ -105,14 +105,14 @@ import_contact(EBook *book, gchar *line) EContact *card; gsize len; - card = e_contact_new(); + card = e_contact_new (); strings = g_strsplit(line, "\t", 5); if (strings[0] && strings[1] && strings[2]) { - e_contact_set(card, E_CONTACT_NICKNAME, strings[0]); - e_contact_set(card, E_CONTACT_FULL_NAME, strings[1]); + e_contact_set (card, E_CONTACT_NICKNAME, strings[0]); + e_contact_set (card, E_CONTACT_FULL_NAME, strings[1]); addr = strings[2]; - len = strlen(addr); + len = strlen (addr); if (addr[0] == '(' && addr[len-1] == ')') { addr[0] = 0; addr[len-1] = 0; @@ -126,37 +126,37 @@ import_contact(EBook *book, gchar *line) EDestination *d; EVCardAttribute *attr; - d = e_destination_new(); - e_destination_set_email(d, addrs[i]); + d = e_destination_new (); + e_destination_set_email (d, addrs[i]); attr = e_vcard_attribute_new (NULL, EVC_EMAIL); e_destination_export_to_vcard_attribute (d, attr); - list = g_list_append(list, attr); - g_object_unref(d); + list = g_list_append (list, attr); + g_object_unref (d); } - e_contact_set_attributes(card, E_CONTACT_EMAIL, list); - g_list_foreach(list, (GFunc)e_vcard_attribute_free, NULL); - g_list_free(list); - g_strfreev(addrs); - e_contact_set(card, E_CONTACT_IS_LIST, GINT_TO_POINTER(TRUE)); + e_contact_set_attributes (card, E_CONTACT_EMAIL, list); + g_list_foreach (list, (GFunc)e_vcard_attribute_free, NULL); + g_list_free (list); + g_strfreev (addrs); + e_contact_set (card, E_CONTACT_IS_LIST, GINT_TO_POINTER (TRUE)); } else { - e_contact_set(card, E_CONTACT_EMAIL_1, strings[2]); + e_contact_set (card, E_CONTACT_EMAIL_1, strings[2]); } /*name = e_contact_name_from_string(strings[1]);*/ if (strings[3] && strings[4]) - e_contact_set(card, E_CONTACT_NOTE, strings[4]); + e_contact_set (card, E_CONTACT_NOTE, strings[4]); /* FIXME Error checking */ - e_book_add_contact(book, card, NULL); - g_object_unref(card); + e_book_add_contact (book, card, NULL); + g_object_unref (card); } g_strfreev (strings); } static void -import_contacts(void) +import_contacts (void) { ESource *primary; ESourceList *source_list; @@ -168,51 +168,51 @@ import_contacts(void) printf("importing pine addressbook\n"); - if (!e_book_get_addressbooks(&source_list, NULL)) + if (!e_book_get_addressbooks (&source_list, NULL)) return; name = g_build_filename(g_get_home_dir(), ".addressbook", NULL); fp = fopen(name, "r"); - g_free(name); + g_free (name); if (fp == NULL) return; - primary = e_source_list_peek_source_any(source_list); + primary = e_source_list_peek_source_any (source_list); /* FIXME Better error handling */ - if ((book = e_book_new(primary,NULL)) == NULL) { - fclose(fp); + if ((book = e_book_new (primary,NULL)) == NULL) { + fclose (fp); g_warning ("Could not create EBook."); return; } - e_book_open(book, TRUE, NULL); - g_object_unref(primary); - g_object_unref(source_list); + e_book_open (book, TRUE, NULL); + g_object_unref (primary); + g_object_unref (source_list); line = g_string_new(""); - g_string_set_size(line, 256); + g_string_set_size (line, 256); offset = 0; - while (fgets(line->str+offset, 256, fp)) { + while (fgets (line->str+offset, 256, fp)) { gsize len; - len = strlen(line->str+offset)+offset; + len = strlen (line->str+offset)+offset; if (line->str[len-1] == '\n') - g_string_truncate(line, len-1); - else if (!feof(fp)) { + g_string_truncate (line, len-1); + else if (!feof (fp)) { offset = len; - g_string_set_size(line, len+256); + g_string_set_size (line, len+256); continue; } else { - g_string_truncate(line, len); + g_string_truncate (line, len); } - import_contact(book, line->str); + import_contact (book, line->str); offset = 0; } - g_string_free(line, TRUE); - fclose(fp); - g_object_unref(book); + g_string_free (line, TRUE); + fclose (fp); + g_object_unref (book); } static gchar * @@ -228,17 +228,17 @@ static MailImporterSpecial pine_special_folders[] = { }; static void -pine_import_exec(struct _pine_import_msg *m) +pine_import_exec (struct _pine_import_msg *m) { if (GPOINTER_TO_INT(g_datalist_get_data(&m->target->data, "pine-do-addr"))) - import_contacts(); + import_contacts (); if (GPOINTER_TO_INT(g_datalist_get_data(&m->target->data, "pine-do-mail"))) { gchar *path; path = g_build_filename(g_get_home_dir(), "mail", NULL); - mail_importer_import_folders_sync(path, pine_special_folders, 0, m->status); - g_free(path); + mail_importer_import_folders_sync (path, pine_special_folders, 0, m->status); + g_free (path); } } @@ -250,29 +250,29 @@ pine_import_done (struct _pine_import_msg *m) if (m->base.error == NULL) { GConfClient *gconf; - gconf = gconf_client_get_default(); + gconf = gconf_client_get_default (); if (GPOINTER_TO_INT(g_datalist_get_data(&m->target->data, "pine-do-addr"))) gconf_client_set_bool(gconf, "/apps/evolution/importer/pine/addr", TRUE, NULL); if (GPOINTER_TO_INT(g_datalist_get_data(&m->target->data, "pine-do-mail"))) gconf_client_set_bool(gconf, "/apps/evolution/importer/pine/mail", TRUE, NULL); - g_object_unref(gconf); + g_object_unref (gconf); } - e_import_complete(m->import, (EImportTarget *)m->target); + e_import_complete (m->import, (EImportTarget *)m->target); } static void pine_import_free (struct _pine_import_msg *m) { - camel_operation_unref(m->status); + camel_operation_unref (m->status); - g_free(m->status_what); - g_mutex_free(m->status_lock); + g_free (m->status_what); + g_mutex_free (m->status_lock); - g_source_remove(m->status_timeout_id); + g_source_remove (m->status_timeout_id); m->status_timeout_id = 0; - g_object_unref(m->import); + g_object_unref (m->import); } static void @@ -288,11 +288,11 @@ pine_status (CamelOperation *op, else if (pc == CAMEL_OPERATION_END) pc = 100; - g_mutex_lock(importer->status_lock); - g_free(importer->status_what); - importer->status_what = g_strdup(what); + g_mutex_lock (importer->status_lock); + g_free (importer->status_what); + importer->status_what = g_strdup (what); importer->status_pc = pc; - g_mutex_unlock(importer->status_lock); + g_mutex_unlock (importer->status_lock); } static gboolean @@ -302,11 +302,11 @@ pine_status_timeout (struct _pine_import_msg *importer) gchar *what; if (importer->status_what) { - g_mutex_lock(importer->status_lock); + g_mutex_lock (importer->status_lock); what = importer->status_what; importer->status_what = NULL; pc = importer->status_pc; - g_mutex_unlock(importer->status_lock); + g_mutex_unlock (importer->status_lock); e_import_status ( importer->import, (EImportTarget *) @@ -331,15 +331,15 @@ mail_importer_pine_import (EImport *ei, struct _pine_import_msg *m; gint id; - m = mail_msg_new(&pine_import_info); + m = mail_msg_new (&pine_import_info); g_datalist_set_data(&target->data, "pine-msg", m); m->import = ei; - g_object_ref(m->import); + g_object_ref (m->import); m->target = target; m->status_timeout_id = g_timeout_add ( 100, (GSourceFunc) pine_status_timeout, m); - m->status_lock = g_mutex_new(); - m->status = camel_operation_new(pine_status, m); + m->status_lock = g_mutex_new (); + m->status = camel_operation_new (pine_status, m); id = m->base.seq; @@ -375,7 +375,7 @@ checkbox_addr_toggle_cb (GtkToggleButton *tb, } static GtkWidget * -pine_getwidget(EImport *ei, EImportTarget *target, EImportImporter *im) +pine_getwidget (EImport *ei, EImportTarget *target, EImportImporter *im) { GtkWidget *box, *w; GConfClient *gconf; @@ -386,7 +386,7 @@ pine_getwidget(EImport *ei, EImportTarget *target, EImportImporter *im) gconf, "/apps/evolution/importer/pine/mail", NULL); done_addr = gconf_client_get_bool ( gconf, "/apps/evolution/importer/pine/address", NULL); - g_object_unref(gconf); + g_object_unref (gconf); g_datalist_set_data ( &target->data, "pine-do-mail", @@ -395,40 +395,40 @@ pine_getwidget(EImport *ei, EImportTarget *target, EImportImporter *im) &target->data, "pine-do-addr", GINT_TO_POINTER (!done_addr)); - box = gtk_vbox_new(FALSE, 2); + box = gtk_vbox_new (FALSE, 2); w = gtk_check_button_new_with_label(_("Mail")); - gtk_toggle_button_set_active((GtkToggleButton *)w, !done_mail); + gtk_toggle_button_set_active ((GtkToggleButton *)w, !done_mail); g_signal_connect(w, "toggled", G_CALLBACK(checkbox_mail_toggle_cb), target); - gtk_box_pack_start((GtkBox *)box, w, FALSE, FALSE, 0); + gtk_box_pack_start ((GtkBox *)box, w, FALSE, FALSE, 0); w = gtk_check_button_new_with_label(_("Address Book")); - gtk_toggle_button_set_active((GtkToggleButton *)w, !done_addr); + gtk_toggle_button_set_active ((GtkToggleButton *)w, !done_addr); g_signal_connect(w, "toggled", G_CALLBACK(checkbox_addr_toggle_cb), target); - gtk_box_pack_start((GtkBox *)box, w, FALSE, FALSE, 0); + gtk_box_pack_start ((GtkBox *)box, w, FALSE, FALSE, 0); - gtk_widget_show_all(box); + gtk_widget_show_all (box); return box; } static void -pine_import(EImport *ei, EImportTarget *target, EImportImporter *im) +pine_import (EImport *ei, EImportTarget *target, EImportImporter *im) { if (GPOINTER_TO_INT(g_datalist_get_data(&target->data, "pine-do-mail")) || GPOINTER_TO_INT(g_datalist_get_data(&target->data, "pine-do-addr"))) - mail_importer_pine_import(ei, target); + mail_importer_pine_import (ei, target); else - e_import_complete(ei, target); + e_import_complete (ei, target); } static void -pine_cancel(EImport *ei, EImportTarget *target, EImportImporter *im) +pine_cancel (EImport *ei, EImportTarget *target, EImportImporter *im) { struct _pine_import_msg *m = g_datalist_get_data(&target->data, "pine-msg"); if (m) - camel_operation_cancel(m->status); + camel_operation_cancel (m->status); } static EImportImporter pine_importer = { @@ -442,7 +442,7 @@ static EImportImporter pine_importer = { }; EImportImporter * -pine_importer_peek(void) +pine_importer_peek (void) { pine_importer.name = _("Evolution Pine importer"); pine_importer.description = _("Import mail from Pine."); |