2008-05-18 [colin] 3.4.0cvs51
[claws.git] / src / etpan / imap-thread.c
index 2828425a0c0b67bf1894770ceb9ff3ce3d44c93d..6c8651344941dcdeda3946b40f95d9ec307577cb 100644 (file)
@@ -287,6 +287,7 @@ void imap_main_set_timeout(int sec)
 
 void imap_main_done(void)
 {
+       imap_disconnect_all();
        etpan_thread_manager_stop(thread_manager);
 #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__)
        return;
@@ -2375,11 +2376,13 @@ static void fetch_content_run(struct etpan_thread_op * op)
                
                r = fwrite(content, 1, content_size, f);
                if (r < content_size) {
+                       result->error = MAILIMAP_ERROR_FETCH;
                        goto fclose;
                }
                
                r = fclose(f);
                if (r == EOF) {
+                       result->error = MAILIMAP_ERROR_FETCH;
                        goto unlink;
                }
                goto free;
@@ -2390,7 +2393,7 @@ static void fetch_content_run(struct etpan_thread_op * op)
        close:
                close(fd);
        unlink:
-               g_unlink(param->filename);
+               claws_unlink(param->filename);
        
        free:
                /* mmap_string_unref is a simple free in libetpan
@@ -2399,7 +2402,7 @@ static void fetch_content_run(struct etpan_thread_op * op)
                        free(content);
        }
        
-       debug_print("imap fetch_content run - end %i\n", r);
+       debug_print("imap fetch_content run - end %i\n", result->error);
 }
 
 int imap_threaded_fetch_content(Folder * folder, uint32_t msg_index,
@@ -3103,37 +3106,20 @@ static void do_exec_command(int fd, const char * command,
                exit(0);
        }
   
-#ifdef SOLARIS
-       if (servername)
-               snprintf(env_buffer, ENV_BUFFER_SIZE,
-                        "ETPANSERVER=%s", servername);
-       else
-               snprintf(env_buffer, ENV_BUFFER_SIZE, "ETPANSERVER=");
-       putenv(env_buffer);
-#else
        if (servername)
-               setenv("ETPANSERVER", servername, 1);
+               g_setenv("ETPANSERVER", servername, TRUE);
        else
-               unsetenv("ETPANSERVER");
-#endif
+               g_unsetenv("ETPANSERVER");
   
-#ifdef SOLARIS
-       if (port)
-               snprintf(env_buffer, ENV_BUFFER_SIZE, "ETPANPORT=%d", port);
-       else
-               snprintf(env_buffer, ENV_BUFFER_SIZE, "ETPANPORT=");
-       putenv(env_buffer);
-#else
        if (port) {
                char porttext[20];
                
                snprintf(porttext, sizeof(porttext), "%d", port);
-               setenv("ETPANPORT", porttext, 1);
+               g_setenv("ETPANPORT", porttext, TRUE);
        }
        else {
-               unsetenv("ETPANPORT");
+               g_unsetenv("ETPANPORT");
        }
-#endif
                
        /* Not a lot we can do if there's an error other than bail. */
        if (dup2(fd, 0) == -1)