Swap return value and argument of imap_threaded_capability()
[claws.git] / src / imap.c
index 00c1763d69f8143bb7266557003e6b0a15545a58..35fb47f78e02d3495f58717a715ff3beb17b3d42 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2012 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2014 Hiroyuki Yamamoto and the Claws Mail team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -59,7 +59,6 @@
 #include "prefs_account.h"
 #include "codeconv.h"
 #include "md5.h"
-#include "base64.h"
 #include "utils.h"
 #include "prefs_common.h"
 #include "inputdialog.h"
@@ -836,12 +835,12 @@ static int imap_get_capabilities(IMAPSession *session)
 {
        struct mailimap_capability_data *capabilities = NULL;
        clistiter *cur;
-       int result = -1;
+       int result;
 
        if (session->capability != NULL)
                return MAILIMAP_NO_ERROR;
 
-       capabilities = imap_threaded_capability(session->folder, &result);
+       result = imap_threaded_capability(session->folder, &capabilities);
 
        if (result != MAILIMAP_NO_ERROR) {
                return result;
@@ -2098,6 +2097,7 @@ static IMAPSearchKey* search_make_key(MatcherProp* match, gboolean* is_all)
                case MATCHCRITERIA_NOT_HEADER: invert = TRUE; matchertype = MATCHCRITERIA_HEADER; break;
                case MATCHCRITERIA_NOT_TAG: invert = TRUE; matchertype = MATCHCRITERIA_TAG; break;
                case MATCHCRITERIA_NOT_HEADERS_PART: invert = TRUE; matchertype = MATCHCRITERIA_HEADERS_PART; break;
+               case MATCHCRITERIA_NOT_HEADERS_CONT: invert = TRUE; matchertype = MATCHCRITERIA_HEADERS_CONT; break;
                case MATCHCRITERIA_NOT_MESSAGE: invert = TRUE; matchertype = MATCHCRITERIA_MESSAGE; break;
                case MATCHCRITERIA_NOT_BODY_PART: invert = TRUE; matchertype = MATCHCRITERIA_BODY_PART; break;
                case MATCHCRITERIA_NOT_TO_AND_NOT_CC: invert = TRUE; matchertype = MATCHCRITERIA_TO_OR_CC; break;
@@ -2143,6 +2143,7 @@ static IMAPSearchKey* search_make_key(MatcherProp* match, gboolean* is_all)
                        break;
 
                case MATCHCRITERIA_HEADERS_PART:
+               case MATCHCRITERIA_HEADERS_CONT:
                        result = imap_search_and(
                                        imap_search_not(imap_search_new(IMAP_SEARCH_CRITERIA_BODY, NULL, match->expr, 0)),
                                        imap_search_new(IMAP_SEARCH_CRITERIA_MESSAGE, NULL, match->expr, 0)
@@ -2731,7 +2732,7 @@ static gint imap_scan_tree_recursive(IMAPSession *session, FolderItem *item, gbo
                        }
                }
                if (!new_item) {
-                       if (old_item && old_item->path && !strcmp(old_item->path, "INBOX")) {
+                       if (old_item && old_item->path && !strcasecmp(old_item->path, "INBOX")) {
                                debug_print("not removing INBOX\n");
                        } else {
                                debug_print("folder '%s' not found. removing...\n",
@@ -2772,7 +2773,7 @@ static gint imap_scan_tree_recursive(IMAPSession *session, FolderItem *item, gbo
                        folder_item_append(item, new_item);
                }
 
-               if (!strcmp(new_item->path, "INBOX")) {
+               if (!strcasecmp(new_item->path, "INBOX")) {
                        new_item->stype = F_INBOX;
                        folder->inbox = new_item;
                } else if (!folder_item_parent(item) || item->stype == F_INBOX) {
@@ -2783,7 +2784,7 @@ static gint imap_scan_tree_recursive(IMAPSession *session, FolderItem *item, gbo
                        if (!folder->outbox && !g_ascii_strcasecmp(base, "Sent")) {
                                new_item->stype = F_OUTBOX;
                                folder->outbox = new_item;
-                       } else if (!folder->draft && !g_ascii_strcasecmp(base, "Drafts")) {
+                       } else if (!folder->draft && (!g_ascii_strcasecmp(base, "Drafts") || !g_ascii_strcasecmp(base, "Draft"))) {
                                new_item->stype = F_DRAFT;
                                folder->draft = new_item;
                        } else if (!folder->queue && !g_ascii_strcasecmp(base, "Queue")) {
@@ -3109,7 +3110,7 @@ static FolderItem *imap_create_folder(Folder *folder, FolderItem *parent,
                return NULL;
        }
 
-       if (!folder_item_parent(parent) && strcmp(name, "INBOX") == 0) {
+       if (!folder_item_parent(parent) && strcasecmp(name, "INBOX") == 0) {
                dirpath = g_strdup(name);
        }else if (parent->path)
                dirpath = g_strconcat(parent->path, "/", name, NULL);
@@ -3145,7 +3146,7 @@ static FolderItem *imap_create_folder(Folder *folder, FolderItem *parent,
        /* remove trailing / for display */
        strtailchomp(new_name, '/');
 
-       if (strcmp(dirpath, "INBOX") != 0) {
+       if (strcasecmp(dirpath, "INBOX") != 0) {
                GPtrArray *argbuf;
                int r;
                clist * lep_list;
@@ -3352,7 +3353,7 @@ gint imap_subscribe(Folder *folder, FolderItem *item, gchar *rpath, gboolean sub
                        g_free(path);
                        return -1;
                }
-               if (!strcmp(path, "INBOX") && sub == FALSE) {
+               if (!strcasecmp(path, "INBOX") && sub == FALSE) {
                        g_free(path);
                        return -1;
                }
@@ -4810,8 +4811,12 @@ gboolean imap_scan_required(Folder *folder, FolderItem *_item)
                        return FALSE;
                }
                
-               debug_print("exists %d, item->item.total_msgs %d\n", 
-                       exists, item->item.total_msgs);
+               debug_print("exists %d, item->item.total_msgs %d\n"
+                           "\tunseen %d, item->item.unread_msgs %d\n"
+                           "\tuid_next %d, item->uid_next %d\n"
+                           "\tuid_val %d, item->item.mtime %d\n", 
+                           exists, item->item.total_msgs,unseen, item->item.unread_msgs,
+                           uid_next, item->uid_next,uid_val, item->item.mtime);
                if (exists != item->item.total_msgs
                    || unseen != item->item.unread_msgs 
                    || uid_next != item->uid_next
@@ -5635,7 +5640,7 @@ static GSList * imap_list_from_lep(IMAPFolder * folder,
                        new_item = folder_item_new(FOLDER(folder), loc_name, loc_path);
                        if ((flags & ETPAN_IMAP_MB_NOINFERIORS) != 0)
                                new_item->no_sub = TRUE;
-                       if (strcmp(dup_name, "INBOX") != 0 &&
+                       if (strcasecmp(dup_name, "INBOX") != 0 &&
                            ((flags & ETPAN_IMAP_MB_NOSELECT) != 0))
                                new_item->no_select = TRUE;