Fix printf formats for size_t and goffset arguments.
[claws.git] / src / imap.c
index 23232f8079549818bfca36df50eb4bc2c6b109ec..db6770af0c243afdcbaf76d018477b93d7801156 100644 (file)
@@ -71,6 +71,7 @@
 #include "tags.h"
 #include "main.h"
 #include "passwordstore.h"
+#include "file-utils.h"
 
 typedef struct _IMAPFolder     IMAPFolder;
 typedef struct _IMAPSession    IMAPSession;
@@ -1153,9 +1154,8 @@ static IMAPSession *imap_session_new(Folder * folder,
                          "Do you want to continue connecting to this "
                          "server? The communication would not be "
                          "secure."),
-                         GTK_STOCK_CANCEL, _("Con_tinue connecting"), 
-                         NULL, FALSE, NULL, ALERT_WARNING,
-                         G_ALERTDEFAULT) != G_ALERTALTERNATE)
+                         GTK_STOCK_CANCEL, _("Con_tinue connecting"), NULL,
+                               ALERTFOCUS_FIRST, FALSE, NULL, ALERT_WARNING) != G_ALERTALTERNATE)
                        return NULL;
        }
        port = account->set_imapport ? account->imapport
@@ -1276,7 +1276,9 @@ static IMAPSession *imap_session_new(Folder * folder,
                session->uidplus = FALSE;
                session->cmd_count = 1;
        }
+       SESSION(session)->use_tls_sni = account->use_tls_sni;
 #endif
+
        log_message(LOG_PROTOCOL, "IMAP connection is %s-authenticated\n",
                    (session->authenticated) ? "pre" : "un");
        
@@ -1377,17 +1379,17 @@ static guint get_file_size_with_crs(const gchar *filename)
        if (filename == NULL)
                return -1;
        
-       fp = g_fopen(filename, "rb");
+       fp = claws_fopen(filename, "rb");
        if (!fp)
                return -1;
        
-       while (fgets(buf, sizeof (buf), fp) != NULL) {
+       while (claws_fgets(buf, sizeof (buf), fp) != NULL) {
                cnt += strlen(buf);
                if (!strstr(buf, "\r\n") && strstr(buf, "\n"))
                        cnt++;
        }
        
-       fclose(fp);
+       claws_fclose(fp);
        return cnt;
 }
 
@@ -1585,7 +1587,7 @@ static gchar *imap_fetch_msg_full(Folder *folder, FolderItem *item, gint uid,
                                ok = file_strip_crs(filename);
                                if (ok == 0 && cached && cached->size <= have_size) {
                                        /* we have it all and stripped */
-                                       debug_print("...fully cached in fact (%u/%zd); setting flag.\n",
+                                       debug_print("...fully cached in fact (%u/%"G_GOFFSET_FORMAT"); setting flag.\n",
                                                        have_size, cached->size);
                                        procmsg_msginfo_set_flags(cached, MSG_FULLY_CACHED, 0);
                                }
@@ -1689,7 +1691,7 @@ static gboolean imap_is_msg_fully_cached(Folder *folder, FolderItem *item, gint
                size = get_file_size_with_crs(filename);
        }
        g_free(filename);
-       debug_print("msg %d cached, has size %d, full should be %zd.\n", uid, size, cached->size);
+       debug_print("msg %d cached, has size %d, full should be %"G_GOFFSET_FORMAT".\n", uid, size, cached->size);
        if (cached && size >= cached->size) {
                cached->total_size = cached->size;
                procmsg_msginfo_set_flags(cached, MSG_FULLY_CACHED, 0);
@@ -2708,7 +2710,7 @@ static gint imap_scan_tree_real(Folder *folder, gboolean subs_only)
        }
 
        if (!item || ((item->path || root_folder) &&
-                     strcmp2(item->path, root_folder) != 0)) {
+                     g_strcmp0(item->path, root_folder) != 0)) {
                folder_tree_destroy(folder);
                item = folder_item_new(folder, folder->name, root_folder);
                item->folder = folder;
@@ -2805,7 +2807,7 @@ static gint imap_scan_tree_recursive(IMAPSession *session, FolderItem *item, gbo
                new_item = NULL;
                for (cur = item_list; cur != NULL; cur = cur->next) {
                        FolderItem *cur_item = FOLDER_ITEM(cur->data);
-                       if (!strcmp2(old_item->path, cur_item->path)) {
+                       if (!g_strcmp0(old_item->path, cur_item->path)) {
                                new_item = cur_item;
                                break;
                        }
@@ -2838,7 +2840,7 @@ static gint imap_scan_tree_recursive(IMAPSession *session, FolderItem *item, gbo
 
                for (node = item->node->children; node != NULL;
                     node = node->next) {
-                       if (!strcmp2(FOLDER_ITEM(node->data)->path,
+                       if (!g_strcmp0(FOLDER_ITEM(node->data)->path,
                                     cur_item->path)) {
                                new_item = FOLDER_ITEM(node->data);
                                folder_item_destroy(cur_item);
@@ -2986,7 +2988,7 @@ GList *imap_scan_subtree(Folder *folder, FolderItem *item, gboolean unsubs_only,
                        }
                        folder_item_destroy(cur_item);
                        oldlitem = g_list_find_custom(
-                                       child_list, tmp, (GCompareFunc)strcmp2);
+                                       child_list, tmp, (GCompareFunc)g_strcmp0);
                        if (oldlitem) {
                                child_list = g_list_remove_link(child_list, oldlitem);
                                g_free(oldlitem->data);
@@ -3210,19 +3212,15 @@ static FolderItem *imap_create_folder(Folder *folder, FolderItem *parent,
        strtailchomp(new_name, '/');
 
        if (strcasecmp(dirpath, "INBOX") != 0) {
-               GPtrArray *argbuf;
                int r;
                clist * lep_list;
                
-               argbuf = g_ptr_array_new();
                r = imap_threaded_list(folder, "", imap_path, &lep_list);
                if (r != MAILIMAP_NO_ERROR) {
                        imap_handle_error(SESSION(session), NULL, r);
                        log_warning(LOG_PROTOCOL, _("can't create mailbox: LIST failed\n"));
                        g_free(imap_path);
                        g_free(dirpath);
-                       ptr_array_free_strings(argbuf);
-                       g_ptr_array_free(argbuf, TRUE);
                        return NULL;
                }
                
@@ -4093,7 +4091,7 @@ static gint imap_cmd_login(IMAPSession *session,
        gint ok;
 
        if (!strcmp(type, "plaintext") && imap_has_capability(session, "LOGINDISABLED")) {
-               gint ok = MAILIMAP_ERROR_BAD_STATE;
+               ok = MAILIMAP_ERROR_BAD_STATE;
                if (imap_has_capability(session, "STARTTLS")) {
 #ifdef USE_GNUTLS
                        log_warning(LOG_PROTOCOL, _("Server requires STARTTLS to log in.\n"));