From 1dc4c5de39970316494ab17e2b50ae1a7ca6170e Mon Sep 17 00:00:00 2001 From: Not Zed Date: Thu, 20 Mar 2003 10:17:25 +0000 Subject: ** for mail part of bug #38461. 2003-03-21 Not Zed ** for mail part of bug #38461. * importers/evolution-outlook-importer.c (load_file_fn): dont pass in create flag to uri_to_folder, the folder must already exist. * importers/evolution-mbox-importer.c (folder_created_cb): Removed, we now force the caller to create the destination folder first. (load_file_fn): Dont try and create a folder if it doesn't exist. Also, use the uri directly as the destination uri, so we can import into any folder. (process_item_fn): If we dont have a folder, thats just an error, return BAD_FILE. * importers/netscape-importer.c (netscape_import_file): As below for elm_import_file. (import_next): similarly as for pine import_next. (importer_cb): just record result. (importer_timeout_fn): removed. * importers/pine-importer.c (import_next): Similar to below for the elm import_next. (pine_import_file): As below for elm_import_file. (importer_timeout_fn): removed. (importer_cb): just record the result, and exit. (import_next): change around to behave more like the elm importer, cleaning up when we're done. * importers/elm-importer.c (elm_import_file): Create the destination folder ourselves, dont pass it onto the mbox importer. Simplify logic, just do the import within a while loop, polling the g main loop as necessary, remove need for idle callbacks and other crap. (import_next): If elm_import_file fails, then just go straight to the next folder, stops it falling in a heap. (import_item_idle): removed. (importer_cb): just record result/exit. * mail-importer.c (mail_importer_create_folder): removed. (mail_importer_make_local_folder): new function to create a local-only folder from a path. It runs synchronously by using a recursive main loop. (folder_created_cb): callback for make_local_folder. svn path=/trunk/; revision=20379 --- mail/importers/evolution-mbox-importer.c | 105 +++---------------------------- 1 file changed, 8 insertions(+), 97 deletions(-) (limited to 'mail/importers/evolution-mbox-importer.c') diff --git a/mail/importers/evolution-mbox-importer.c b/mail/importers/evolution-mbox-importer.c index 31d3d4c6a2..9cbcdeb9de 100644 --- a/mail/importers/evolution-mbox-importer.c +++ b/mail/importers/evolution-mbox-importer.c @@ -120,19 +120,9 @@ process_item_fn (EvolutionImporter *eimporter, const char *mozilla_status; if (importer->folder == NULL) { - /* if it failed, need to say it failed ... */ - /* the create_folder callback needs to store the create result */ - /* here we need to pass FALSE for more items */ - printf("not ready\n"); - if (mbi->create_result == GNOME_Evolution_Storage_OK) - GNOME_Evolution_ImporterListener_notifyResult (listener, - GNOME_Evolution_ImporterListener_NOT_READY, - TRUE, ev); - else - GNOME_Evolution_ImporterListener_notifyResult (listener, - GNOME_Evolution_ImporterListener_BAD_FILE, - FALSE, ev); - return; + GNOME_Evolution_ImporterListener_notifyResult (listener, + GNOME_Evolution_ImporterListener_BAD_FILE, + FALSE, ev); } if (mbi->is_folder == TRUE) { @@ -247,59 +237,14 @@ importer_destroy_cb (void *data, GObject *object) g_free (mbi); } -static void -folder_created_cb (BonoboListener *listener, - const char *event_name, - const BonoboArg *event_data, - CORBA_Environment *ev, - MailImporter *importer) -{ - char *fullpath; - GNOME_Evolution_Storage_FolderResult *result; - CamelException *ex; - - if (strcmp (event_name, "evolution-shell:folder_created") != 0) { - return; /* Unknown event */ - } - - result = event_data->_value; - - printf("folder created cb, result = %d\n", result->result); - ((MboxImporter *)importer)->create_result = result->result; - - if (result->result != GNOME_Evolution_Storage_OK) - return; - - fullpath = g_strconcat ("file://", result->path, NULL); - - ex = camel_exception_new (); - importer->folder = mail_tool_uri_to_folder (fullpath, CAMEL_STORE_FOLDER_CREATE, ex); - if (camel_exception_is_set (ex)) { - g_warning ("Error opening %s", fullpath); - camel_exception_free (ex); - - g_free (fullpath); - ((MboxImporter *)importer)->create_result = GNOME_Evolution_Storage_GENERIC_ERROR; - - return; - } - - camel_folder_freeze (importer->folder); - importer->frozen = TRUE; - - g_free (fullpath); - bonobo_object_unref (BONOBO_OBJECT (listener)); -} - static gboolean load_file_fn (EvolutionImporter *eimporter, const char *filename, - const char *folderpath, + const char *uri, void *closure) { MboxImporter *mbi; MailImporter *importer; - gboolean delayed = FALSE; struct stat buf; int fd; @@ -328,46 +273,12 @@ load_file_fn (EvolutionImporter *eimporter, } importer->mstream = NULL; - if (folderpath == NULL || *folderpath == '\0') { + if (uri == NULL || *uri == '\0') importer->folder = mail_tool_get_local_inbox (NULL); - } else { - char *parent, *fullpath, *homedir; - const char *name; - BonoboListener *listener; - CamelException *ex; - - homedir = g_strdup_printf("file://%s/evolution/local", g_get_home_dir()); + else + importer->folder = mail_tool_uri_to_folder(uri, 0, NULL); - fullpath = e_path_to_physical (homedir, folderpath); - ex = camel_exception_new (); - importer->folder = mail_tool_uri_to_folder (fullpath, 0, ex); - g_free (homedir); - - if (camel_exception_is_set (ex) || importer->folder == NULL) { - /* Make a new directory */ - name = strrchr (folderpath, '/'); - if (name == NULL) { - parent = g_strdup ("/"); - name = folderpath; - } else { - name += 1; - parent = g_path_get_dirname (folderpath); - } - - listener = bonobo_listener_new (NULL, NULL); - g_signal_connect((listener), "event-notify", - G_CALLBACK (folder_created_cb), - importer); - mbi->create_result = GNOME_Evolution_Storage_OK; - mail_importer_create_folder (parent, name, NULL, listener); - delayed = importer->folder == NULL; - g_free (parent); - } - camel_exception_free (ex); - g_free (fullpath); - } - - if (importer->folder == NULL && delayed == FALSE){ + if (importer->folder == NULL) { g_warning ("Bad folder\n"); goto fail; } -- cgit v1.2.3