sync with 0.9.5cvs2
authorPaul Mangan <paul@claws-mail.org>
Thu, 11 Sep 2003 07:48:09 +0000 (07:48 +0000)
committerPaul Mangan <paul@claws-mail.org>
Thu, 11 Sep 2003 07:48:09 +0000 (07:48 +0000)
ChangeLog.claws
configure.ac
src/common/utils.c
src/folder.h
src/imap.c
src/imap.h
src/mh.c
src/summaryview.c

index b3293c5..ffe0463 100644 (file)
@@ -1,3 +1,8 @@
+2003-09-11 [paul]      0.9.5claws2
+
+       * sync with 0.9.5cvs2
+               see ChangeLog 2003-09-05
+
 2003-09-11 [paul]      0.9.5claws1
 
        * sync with 0.9.5cvs3
index 07bf0aa..257511d 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=1
+EXTRA_VERSION=2
 if test $EXTRA_VERSION -eq 0; then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
 else
index d5e861f..1b71726 100644 (file)
@@ -2687,6 +2687,55 @@ gchar *get_outgoing_rfc2822_str(FILE *fp)
        return ret;
 }
 
+/*
+ * Create a new boundary in a way that it is very unlikely that this
+ * will occur in the following text.  It would be easy to ensure
+ * uniqueness if everything is either quoted-printable or base64
+ * encoded (note that conversion is allowed), but because MIME bodies
+ * may be nested, it may happen that the same boundary has already
+ * been used. We avoid scanning the message for conflicts and hope the
+ * best.
+ *
+ *   boundary := 0*69<bchars> bcharsnospace
+ *   bchars := bcharsnospace / " "
+ *   bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" /
+ *                    "+" / "_" / "," / "-" / "." /
+ *                    "/" / ":" / "=" / "?"
+ *
+ * some special characters removed because of buggy MTAs
+ */
+
+gchar *generate_mime_boundary(const gchar *prefix)
+{
+       static gchar tbl[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                            "abcdefghijklmnopqrstuvwxyz"
+                            "1234567890+_./=";
+       gchar buf_uniq[17];
+       gchar buf_date[64];
+       gint i;
+       gint pid;
+
+       pid = getpid();
+
+       /* We make the boundary depend on the pid, so that all running
+        * processes generate different values even when they have been
+        * started within the same second and srandom(time(NULL)) has been
+        * used.  I can't see whether this is really an advantage but it
+        * doesn't do any harm.
+        */
+       for (i = 0; i < sizeof(buf_uniq) - 1; i++)
+               buf_uniq[i] = tbl[(random() ^ pid) % (sizeof(tbl) - 1)];
+       buf_uniq[i] = '\0';
+
+       get_rfc822_date(buf_date, sizeof(buf_date));
+       subst_char(buf_date, ' ', '_');
+       subst_char(buf_date, ',', '_');
+       subst_char(buf_date, ':', '_');
+
+       return g_strdup_printf("%s=_%s_%s", prefix ? prefix : "Multipart",
+                              buf_date, buf_uniq);
+}
+
 gint change_file_mode_rw(FILE *fp, const gchar *file)
 {
 #if HAVE_FCHMOD
@@ -3594,65 +3643,3 @@ gchar *generate_msgid(const gchar *address, gchar *buf, gint len)
        g_free(addr);
        return buf;
 }
-
-/**
- * Create a new boundary in a way that it is very unlikely that this
- * will occur in the following text.  It would be easy to ensure
- * uniqueness if everything is either quoted-printable or base64
- * encoded (note that conversion is allowed), but because MIME bodies
- * may be nested, it may happen that the same boundary has already
- * been used. We avoid scanning the message for conflicts and hope the
- * best.
- *
- *   boundary := 0*69<bchars> bcharsnospace
- *   bchars := bcharsnospace / " "
- *   bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" /
- *                    "+" / "_" / "," / "-" / "." /
- *                    "/" / ":" / "=" / "?"  
- *
- * ":" and "," removed because of buggy MTAs
- */
-
-gchar *generate_mime_boundary(void)
-{
-       static gchar tbl[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-                            "abcdefghijklmnopqrstuvwxyz" 
-                            "1234567890'()+_./=?";
-       gchar bufuniq[17];
-       gchar bufdate[BUFFSIZE];
-       int i, equal;
-       int pid;
-
-       pid = getpid();
-
-       /* We make the boundary depend on the pid, so that all running
-        * processed generate different values even when they have been
-        * started within the same second and srand48(time(NULL)) has been
-        * used.  I can't see whether this is really an advantage but it
-        * doesn't do any harm.
-        */
-       equal = -1;
-       for (i = 0; i < sizeof(bufuniq) - 1; i++) {
-               bufuniq[i] = tbl[(lrand48() ^ pid) % (sizeof(tbl) - 1)];        /* fill with random */
-               if (bufuniq[i] == '=' && equal == -1)
-                       equal = i;
-       }
-       bufuniq[i] = 0;
-
-       /* now make sure that we do have the sequence "=." in it which cannot
-        * be matched by quoted-printable or base64 encoding */
-       if (equal != -1 && (equal + 1) < i)
-               bufuniq[equal + 1] = '.';
-       else {
-               bufuniq[0] = '=';
-               bufuniq[1] = '.';
-       }
-
-       get_rfc822_date(bufdate, sizeof(bufdate));
-       subst_char(bufdate, ' ', '_');
-       subst_char(bufdate, ',', '_');
-       subst_char(bufdate, ':', '_');
-
-       return g_strdup_printf("Multipart_%s_%s",
-                              bufdate, bufuniq);
-}
index c352228..357d499 100644 (file)
@@ -171,7 +171,7 @@ struct _FolderClass
        Folder          *(*new_folder)          (const gchar    *name,
                                                 const gchar    *path);
        void            (*destroy_folder)       (Folder         *folder);
-       void            (*scan_tree)            (Folder         *folder);
+       gint            (*scan_tree)            (Folder         *folder);
 
        gint            (*create_tree)          (Folder         *folder);
 
index ea63ce5..be3fc8a 100644 (file)
@@ -187,7 +187,7 @@ static gboolean imap_is_msg_changed(Folder * folder,
 
 static gint imap_close(Folder * folder, FolderItem * item);
 
-static void imap_scan_tree(Folder * folder);
+static gint imap_scan_tree(Folder * folder);
 
 static gint imap_create_tree(Folder * folder);
 
@@ -1142,8 +1142,7 @@ gint imap_close(Folder *folder, FolderItem *item)
        if (!session) return -1;
 
        if (session->mbox) {
-               if (strcmp(item->path, session->mbox))
-                       return -1;
+               if (strcmp2(session->mbox, item->path) != 0) return -1;
 
                ok = imap_cmd_close(session);
                if (ok != IMAP_SUCCESS)
@@ -1158,14 +1157,14 @@ gint imap_close(Folder *folder, FolderItem *item)
        return 0;
 }
 
-void imap_scan_tree(Folder *folder)
+gint imap_scan_tree(Folder *folder)
 {
        FolderItem *item = NULL;
        IMAPSession *session;
        gchar *root_folder = NULL;
 
-       g_return_if_fail(folder != NULL);
-       g_return_if_fail(folder->account != NULL);
+       g_return_val_if_fail(folder != NULL, -1);
+       g_return_val_if_fail(folder->account != NULL, -1);
 
        session = imap_session_get(folder);
        if (!session) {
@@ -1175,13 +1174,30 @@ void imap_scan_tree(Folder *folder)
                        item->folder = folder;
                        folder->node = item->node = g_node_new(item);
                }
-               return;
+               return -1;
        }
 
        if (folder->account->imap_dir && *folder->account->imap_dir) {
-               Xstrdup_a(root_folder, folder->account->imap_dir, return);
+               gchar *real_path;
+
+               Xstrdup_a(root_folder, folder->account->imap_dir, return -1);
                strtailchomp(root_folder, '/');
-               debug_print("IMAP root directory: %s\n", root_folder);
+               extract_quote(root_folder, '"');
+               real_path = imap_get_real_path
+                       (IMAP_FOLDER(folder), root_folder);
+               debug_print("IMAP root directory: %s\n", real_path);
+               if (imap_status(session, IMAP_FOLDER(folder), root_folder,
+                                   NULL, NULL, NULL, NULL, NULL)
+                   != IMAP_SUCCESS) {
+                       if (imap_cmd_create(session, real_path)
+                           != IMAP_SUCCESS) {
+                               log_warning(_("can't create root folder %s\n"),
+                                           real_path);
+                               g_free(real_path);
+                               return -1;
+                       }
+               }
+               g_free(real_path);
        }
 
        if (folder->node)
@@ -1196,6 +1212,8 @@ void imap_scan_tree(Folder *folder)
 
        imap_scan_tree_recursive(session, FOLDER_ITEM(folder->node->data));
        imap_create_missing_folders(folder);
+
+       return 0;
 }
 
 static gint imap_scan_tree_recursive(IMAPSession *session, FolderItem *item)
@@ -1352,6 +1370,10 @@ static GSList *imap_parse_list(IMAPFolder *folder, IMAPSession *session,
                strretchomp(buf);
                if (buf[0] != '*' || buf[1] != ' ') {
                        log_print("IMAP4< %s\n", buf);
+                       if (sscanf(buf, "%*d %16s", buf) < 1 ||
+                           strcmp(buf, "OK") != 0)
+                               log_warning(_("error occurred while getting LIST.\n"));
+                               
                        break;
                }
                debug_print("IMAP4< %s\n", buf);
@@ -2027,14 +2049,15 @@ static IMAPNameSpace *imap_find_namespace_from_list(GList *ns_list,
 
        if (!path) path = "";
 
-       Xstrcat_a(tmp_path, path, "/", return NULL);
-
        for (; ns_list != NULL; ns_list = ns_list->next) {
                IMAPNameSpace *tmp_ns = ns_list->data;
 
+               Xstrcat_a(tmp_path, path, "/", return namespace);
                Xstrdup_a(name, tmp_ns->name, return namespace);
-               if (tmp_ns->separator && tmp_ns->separator != '/')
+               if (tmp_ns->separator && tmp_ns->separator != '/') {
+                       subst_char(tmp_path, tmp_ns->separator, '/');
                        subst_char(name, tmp_ns->separator, '/');
+               }
                if (strncmp(tmp_path, name, strlen(name)) == 0)
                        namespace = tmp_ns;
        }
@@ -2426,15 +2449,13 @@ static gint imap_status(IMAPSession *session, IMAPFolder *folder,
        gchar *real_path;
        gchar *real_path_;
        gint ok;
-       GPtrArray *argbuf;
+       GPtrArray *argbuf = NULL;
        gchar *str;
 
-       *messages = *recent = *uid_next = *uid_validity = *unseen = 0;
-
-       if (path == NULL)
-               return -1;
-
-       argbuf = g_ptr_array_new();
+       if (messages && recent && uid_next && uid_validity && unseen) {
+               *messages = *recent = *uid_next = *uid_validity = *unseen = 0;
+               argbuf = g_ptr_array_new();
+       }
 
        real_path = imap_get_real_path(folder, path);
        QUOTE_IF_REQUIRED(real_path_, real_path);
@@ -2443,7 +2464,7 @@ static gint imap_status(IMAPSession *session, IMAPFolder *folder,
                      real_path_);
 
        ok = imap_cmd_ok(session, argbuf);
-       if (ok != IMAP_SUCCESS) THROW(ok);
+       if (ok != IMAP_SUCCESS || !argbuf) THROW(ok);
 
        str = search_array_str(argbuf, "STATUS");
        if (!str) THROW(IMAP_ERROR);
@@ -2477,8 +2498,10 @@ static gint imap_status(IMAPSession *session, IMAPFolder *folder,
 
 catch:
        g_free(real_path);
-       ptr_array_free_strings(argbuf);
-       g_ptr_array_free(argbuf, TRUE);
+       if (argbuf) {
+               ptr_array_free_strings(argbuf);
+               g_ptr_array_free(argbuf, TRUE);
+       }
 
        return ok;
 }
index 3a287de..a897ea9 100644 (file)
@@ -25,7 +25,7 @@
 typedef enum
 {
        IMAP_AUTH_LOGIN         = 1 << 0,
-       IMAP_AUTH_CRAM_MD5      = 1 << 1,
+       IMAP_AUTH_CRAM_MD5      = 1 << 1
 } IMAPAuthType;
 
 FolderClass *imap_get_class            (void);
index e0bc447..59500c4 100644 (file)
--- a/src/mh.c
+++ b/src/mh.c
@@ -66,7 +66,7 @@ static gboolean mh_is_msg_changed(Folder * folder,
 
 static gint mh_get_num_list(Folder * folder,
                            FolderItem * item, GSList ** list, gboolean *old_uids_valid);
-static void mh_scan_tree(Folder * folder);
+static gint mh_scan_tree(Folder * folder);
 
 static gint mh_create_tree(Folder * folder);
 static FolderItem *mh_create_folder(Folder * folder,
@@ -466,12 +466,12 @@ gboolean mh_is_msg_changed(Folder *folder, FolderItem *item, MsgInfo *msginfo)
        return FALSE;
 }
 
-void mh_scan_tree(Folder *folder)
+gint mh_scan_tree(Folder *folder)
 {
        FolderItem *item;
        gchar *rootpath;
 
-       g_return_if_fail(folder != NULL);
+       g_return_val_if_fail(folder != NULL, -1);
 
        if (!folder->node) {
                item = folder_item_new(folder, folder->name, NULL);
@@ -483,13 +483,15 @@ void mh_scan_tree(Folder *folder)
        rootpath = folder_item_get_path(item);
        if (change_dir(rootpath) < 0) {
                g_free(rootpath);
-               return;
+               return -1;
        }
        g_free(rootpath);
 
        mh_create_tree(folder);
        mh_remove_missing_folder_items(folder);
        mh_scan_tree_recursive(item);
+
+       return 0;
 }
 
 #define MAKE_DIR_IF_NOT_EXIST(dir) \
index c3cef2a..3dcb701 100644 (file)
@@ -933,16 +933,12 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
 
        summary_clear_list(summaryview);
        summary_set_column_titles(summaryview);
-       if (!is_refresh)
-               messageview_clear(summaryview->messageview);
 
        buf = NULL;
        if (!item || !item->path || !item->parent || item->no_select) {
                g_free(buf);
                debug_print("empty folder\n\n");
                summary_set_hide_read_msgs_menu(summaryview, FALSE);
-               if (is_refresh)
-                       messageview_clear(summaryview->messageview);
                summary_clear_all(summaryview);
                summaryview->folder_item = item;
                gtk_clist_thaw(GTK_CLIST(ctree));
@@ -952,6 +948,9 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
        }
        g_free(buf);
 
+       if (!is_refresh)
+               messageview_clear(summaryview->messageview);
+
        summaryview->folder_item = item;
        item->opened = TRUE;
 
@@ -1211,6 +1210,7 @@ void summary_clear_list(SummaryView *summaryview)
 
 void summary_clear_all(SummaryView *summaryview)
 {
+       messageview_clear(summaryview->messageview);
        summary_clear_list(summaryview);
        summary_set_menu_sensitive(summaryview);
        toolbar_main_set_sensitive(summaryview->mainwin);