/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Sylpheed-Claws team
+ * Copyright (C) 1999-2006 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
#include "log.h"
#include "remotefolder.h"
#include "alertpanel.h"
-#include "sylpheed.h"
+#include "claws.h"
#include "statusbar.h"
#include "msgcache.h"
#include "imap-thread.h"
static gint imap_cmd_copy (IMAPSession *session,
struct mailimap_set * set,
const gchar *destfolder,
- GRelation *uid_mapping);
+ GRelation *uid_mapping,
+ struct mailimap_set ** source,
+ struct mailimap_set ** dest);
static gint imap_cmd_store (IMAPSession *session,
struct mailimap_set * set,
IMAPFlags flags,
static MsgInfo *imap_parse_msg(const gchar *file, FolderItem *item);
-/* data types conversion libetpan <-> sylpheed */
+/* data types conversion libetpan <-> claws */
static GSList * imap_list_from_lep(IMAPFolder * folder,
clist * list, const gchar * real_path, gboolean all);
static GSList * imap_get_lep_set_from_numlist(MsgNumberList *numlist);
case IMAP_AUTH_LOGIN:
ok = imap_cmd_login(session, user, pass, "LOGIN");
break;
+ case IMAP_AUTH_GSSAPI:
+ ok = imap_cmd_login(session, user, pass, "GSSAPI");
+ break;
default:
debug_print("capabilities:\n"
"\t ANONYMOUS %d\n"
"\t CRAM-MD5 %d\n"
- "\t LOGIN %d\n",
+ "\t LOGIN %d\n"
+ "\t GSSAPI %d\n",
imap_has_capability(session, "ANONYMOUS"),
imap_has_capability(session, "CRAM-MD5"),
- imap_has_capability(session, "LOGIN"));
+ imap_has_capability(session, "LOGIN"),
+ imap_has_capability(session, "GSSAPI"));
if (imap_has_capability(session, "CRAM-MD5"))
ok = imap_cmd_login(session, user, pass, "CRAM-MD5");
+ if (ok == IMAP_ERROR && imap_has_capability(session, "GSSAPI"))
+ ok = imap_cmd_login(session, user, pass, "GSSAPI");
if (ok == IMAP_ERROR) /* we always try LOGIN before giving up */
ok = imap_cmd_login(session, user, pass, "LOGIN");
}
if (prefs_common.work_offline &&
!inc_offline_should_override(
- _("Sylpheed-Claws needs network access in order "
+ _("Claws Mail needs network access in order "
"to access the IMAP server."))) {
return NULL;
}
if (alertpanel_full(_("Insecure connection"),
_("This connection is configured to be secured "
"using SSL, but SSL is not available in this "
- "build of Sylpheed-Claws. \n\n"
+ "build of Claws Mail. \n\n"
"Do you want to continue connecting to this "
"server? The communication would not be "
"secure."),
authenticated = FALSE;
}
else {
+#if (LIBETPAN_VERSION_MAJOR > 0 || LIBETPAN_VERSION_MINOR > 48)
+#ifdef USE_OPENSSL
+ if (r == MAILIMAP_ERROR_SSL)
+ log_error(_("SSL handshake failed\n"));
+#endif
+#endif
if(!prefs_common.no_recv_err_panel) {
- alertpanel_error(_("Can't connect to IMAP4 server: %s:%d"),
+ alertpanel_error_log(_("Can't connect to IMAP4 server: %s:%d"),
account->recv_server, port);
} else {
log_error(_("Can't connect to IMAP4 server: %s:%d\n"),
procmsg_msginfo_free(msginfo);
file_strip_crs(filename);
return filename;
- } else if (!cached) {
- debug_print("message not cached, considering file complete\n");
+ } else if (!cached && time(NULL) - get_file_mtime(filename) < 60) {
+ debug_print("message not cached and file recent, considering file complete\n");
procmsg_msginfo_free(msginfo);
file_strip_crs(filename);
return filename;
gint ok = IMAP_SUCCESS;
GRelation *uid_mapping;
gint last_num = 0;
+ gboolean single = FALSE;
g_return_val_if_fail(folder != NULL, -1);
g_return_val_if_fail(dest != NULL, -1);
}
lock_session();
msginfo = (MsgInfo *)msglist->data;
-
+ if (msglist->next == NULL)
+ single = TRUE;
src = msginfo->folder;
if (src == dest) {
g_warning("the src folder is identical to the dest.\n");
statusbar_print_all(_("Copying messages..."));
for (cur = seq_list; cur != NULL; cur = g_slist_next(cur)) {
struct mailimap_set * seq_set;
+ struct mailimap_set * source = NULL;
+ struct mailimap_set * dest = NULL;
seq_set = cur->data;
debug_print("Copying messages from %s to %s ...\n",
src->path, destdir);
- ok = imap_cmd_copy(session, seq_set, destdir, uid_mapping);
+ ok = imap_cmd_copy(session, seq_set, destdir, uid_mapping,
+ &source, &dest);
+
+ if (ok == IMAP_SUCCESS) {
+ if (single && relation && source && dest) {
+ clistiter *l = clist_begin(source->set_list);
+ struct mailimap_set_item *i = (struct mailimap_set_item *)clist_content(l);
+ int snum = i->set_first;
+ int dnum = 0;
+ l = clist_begin(dest->set_list);
+ i = (struct mailimap_set_item *)clist_content(l);
+ dnum = i->set_first;
+ g_relation_insert(uid_mapping, GINT_TO_POINTER(snum),
+ GINT_TO_POINTER(dnum));
+ }
+ }
+
+
+ if (source)
+ mailimap_set_free(source);
+ if (dest)
+ mailimap_set_free(dest);
+
if (ok != IMAP_SUCCESS) {
g_relation_destroy(uid_mapping);
imap_lep_set_free(seq_list);
if (tuples->len > 0) {
gint num = GPOINTER_TO_INT(g_tuples_index(tuples, 0, 1));
g_relation_insert(relation, msginfo,
- GPOINTER_TO_INT(num));
+ GINT_TO_POINTER(num));
if (num > last_num)
last_num = num;
+ debug_print("copied new message as %d\n", num);
+ /* put the local file in the imapcache, so that we don't
+ * have to fetch it back later. */
+ if (num > 0) {
+ gchar *cache_path = folder_item_get_path(msginfo->folder);
+ gchar *real_file = g_strconcat(
+ cache_path, G_DIR_SEPARATOR_S,
+ itos(msginfo->msgnum), NULL);
+ gchar *cache_file = NULL;
+ g_free(cache_path);
+ cache_path = folder_item_get_path(dest);
+ cache_file = g_strconcat(
+ cache_path, G_DIR_SEPARATOR_S,
+ itos(num), NULL);
+ if (!is_dir_exist(cache_path))
+ make_dir_hier(cache_path);
+ if (is_file_exist(real_file) && is_dir_exist(cache_path)) {
+ copy_file(real_file, cache_file, TRUE);
+ debug_print("copied to cache: %s\n", cache_file);
+ }
+ g_free(real_file);
+ g_free(cache_file);
+ g_free(cache_path);
+ }
} else
g_relation_insert(relation, msginfo,
- GPOINTER_TO_INT(0));
+ GINT_TO_POINTER(0));
g_tuples_destroy(tuples);
}
statusbar_pop_all();
if (prefs_common.work_offline &&
!inc_offline_should_override(
- _("Sylpheed-Claws needs network access in order "
+ _("Claws Mail needs network access in order "
"to access the IMAP server."))) {
g_free(data);
return NULL;
return imap_get_path_separator(imap_folder, item->path);
}
+static gchar imap_refresh_path_separator(IMAPFolder *folder, const gchar *subfolder)
+{
+ IMAPSession *session = imap_session_get(FOLDER(folder));
+ clist * lep_list;
+ int r;
+ gchar separator = '\0';
+
+ g_return_val_if_fail(session != NULL, '/');
+ r = imap_threaded_list((Folder *)folder, "", subfolder, &lep_list);
+
+ if (r != MAILIMAP_NO_ERROR) {
+ log_warning(_("LIST failed\n"));
+ return '\0';
+ }
+
+ if (clist_count(lep_list) > 0) {
+ clistiter * iter = clist_begin(lep_list);
+ struct mailimap_mailbox_list * mb;
+ mb = clist_content(iter);
+
+ separator = mb->mb_delimiter;
+ debug_print("got separator: %c\n", folder->last_seen_separator);
+ }
+ mailimap_list_result_free(lep_list);
+ return separator;
+}
+
static gchar imap_get_path_separator(IMAPFolder *folder, const gchar *path)
{
IMAPNameSpace *namespace;
g_return_val_if_fail(session != NULL, '/');
if (folder->last_seen_separator == 0) {
- clist * lep_list;
- int r = imap_threaded_list((Folder *)folder, "", "", &lep_list);
- if (r != MAILIMAP_NO_ERROR) {
- log_warning(_("LIST failed\n"));
- return '/';
- }
-
- if (clist_count(lep_list) > 0) {
- clistiter * iter = clist_begin(lep_list);
- struct mailimap_mailbox_list * mb;
- mb = clist_content(iter);
-
- folder->last_seen_separator = mb->mb_delimiter;
- debug_print("got separator: %c\n", folder->last_seen_separator);
- }
- mailimap_list_result_free(lep_list);
+ folder->last_seen_separator = imap_refresh_path_separator(folder, "");
+ }
+
+ if (folder->last_seen_separator == 0) {
+ folder->last_seen_separator = imap_refresh_path_separator(folder, "INBOX");
}
if (folder->last_seen_separator != 0) {
return folder->last_seen_separator;
}
- namespace = imap_find_namespace(folder, path);
- if (namespace && namespace->separator)
- separator = namespace->separator;
-
return separator;
}
}
#else
log_error(_("Connection to %s failed: "
- "server requires TLS, but Sylpheed-Claws "
+ "server requires TLS, but Claws Mail "
"has been compiled without OpenSSL "
"support.\n"),
SESSION(session)->server);
if (prefs_common.work_offline &&
!inc_offline_should_override(
- _("Sylpheed-Claws needs network access in order "
+ _("Claws Mail needs network access in order "
"to access the IMAP server."))) {
g_free(data);
return -1;
}
static gint imap_cmd_copy(IMAPSession *session, struct mailimap_set * set,
- const gchar *destfolder, GRelation *uid_mapping)
+ const gchar *destfolder, GRelation *uid_mapping,
+ struct mailimap_set **source, struct mailimap_set **dest)
{
int r;
g_return_val_if_fail(set != NULL, IMAP_ERROR);
g_return_val_if_fail(destfolder != NULL, IMAP_ERROR);
- r = imap_threaded_copy(session->folder, set, destfolder);
+ r = imap_threaded_copy(session->folder, set, destfolder, source, dest);
if (r != MAILIMAP_NO_ERROR) {
return IMAP_ERROR;
if (prefs_common.work_offline &&
!inc_offline_should_override(
- _("Sylpheed-Claws needs network access in order "
+ _("Claws Mail needs network access in order "
"to access the IMAP server."))) {
return -1;
}
data->session = session;
if (prefs_common.work_offline &&
!inc_offline_should_override(
- _("Sylpheed-Claws needs network access in order "
+ _("Claws Mail needs network access in order "
"to access the IMAP server."))) {
g_free(data);
return -1;
if (prefs_common.work_offline &&
!inc_offline_should_override(
- _("Sylpheed-Claws needs network access in order "
+ _("Claws Mail needs network access in order "
"to access the IMAP server."))) {
g_free(data);
return -1;
-/* data types conversion libetpan <-> sylpheed */
+/* data types conversion libetpan <-> claws */
static Folder *imap_folder_new (const gchar *name,
const gchar *path)
{
+ static gboolean missing_imap_warning = TRUE;
+ if (missing_imap_warning) {
+ missing_imap_warning = FALSE;
+ alertpanel_error(
+ _("You have one or more IMAP accounts "
+ "defined. However this version of "
+ "Claws Mail has been built without "
+ "IMAP support; your IMAP account(s) are "
+ "disabled.\n\n"
+ "You probably need to "
+ "install libetpan and recompile "
+ "Claws Mail."));
+ }
return NULL;
}
static gint imap_create_tree (Folder *folder)