FolderItem *dest,
MsgInfoList *msglist,
GRelation *relation);
+static gint imap_expunge (Folder *folder,
+ FolderItem *dest);
static gint imap_remove_all_msg (Folder *folder,
FolderItem *item);
IMAPFlags flags,
GSList *tags,
int do_add);
-static gint imap_cmd_expunge (IMAPSession *session);
+static gint imap_cmd_expunge (IMAPSession *session, gboolean force);
static void imap_path_separator_subst (gchar *str,
gchar separator);
imap_class.copy_msgs = imap_copy_msgs;
imap_class.remove_msg = imap_remove_msg;
imap_class.remove_msgs = imap_remove_msgs;
+ imap_class.expunge = imap_expunge;
imap_class.remove_all_msg = imap_remove_all_msg;
imap_class.is_msg_changed = imap_is_msg_changed;
imap_class.change_flags = imap_change_flags;
acc_pass = account->passwd;
try_again:
pass = acc_pass;
- if (!pass && account->imap_auth_type != IMAP_AUTH_ANON) {
+ if (!pass && account->imap_auth_type != IMAP_AUTH_ANON && account->imap_auth_type != IMAP_AUTH_GSSAPI) {
gchar *tmp_pass;
tmp_pass = input_dialog_query_password_keep(account->recv_server,
account->userid,
return MAILIMAP_NO_ERROR;
Xstrdup_a(pass, tmp_pass, {g_free(tmp_pass); return MAILIMAP_NO_ERROR;});
g_free(tmp_pass);
- } else if (account->imap_auth_type == IMAP_AUTH_ANON) {
+ } else if (account->imap_auth_type == IMAP_AUTH_ANON || account->imap_auth_type == IMAP_AUTH_GSSAPI) {
pass = "";
}
statuswindow_print_all(_("Connecting to IMAP4 server %s...\n"),
return ok;
}
} /* else we just need to expunge */
- ok = imap_cmd_expunge(session);
+ ok = imap_cmd_expunge(session, folder->account->imap_use_trash);
if (ok != MAILIMAP_NO_ERROR) {
log_warning(LOG_PROTOCOL, _("can't expunge\n"));
g_free(destdir);
if (folder->account->imap_dir && *folder->account->imap_dir) {
gchar *real_path;
- int r;
+ int r = MAILIMAP_NO_ERROR;
clist * lep_list;
Xstrdup_a(root_folder, folder->account->imap_dir, {return -1;});
gchar separator;
gchar wildcard[3];
clist * lep_list;
- int r;
+ int r = MAILIMAP_NO_ERROR;
g_return_val_if_fail(item != NULL, -1);
g_return_val_if_fail(item->folder != NULL, -1);
GSList *item_list = NULL, *cur;
GList *child_list = NULL, *tmplist = NULL;
GSList *sub_list = NULL;
- int r;
+ int r = MAILIMAP_NO_ERROR;
if (!session)
return NULL;
gchar separator;
gchar *new_name;
const gchar *p;
- gint ok;
+ gint ok = MAILIMAP_NO_ERROR;
gboolean no_select = FALSE, no_sub = FALSE;
gboolean exist = FALSE;
gchar *new_cache_dir;
IMAPSession *session;
gchar separator;
- gint ok;
+ gint ok = MAILIMAP_NO_ERROR;
gint exists, recent, unseen;
guint32 uid_validity;
gint imap_subscribe(Folder *folder, FolderItem *item, gchar *rpath, gboolean sub)
{
gchar *path;
- gint r = -1;
+ gint r = MAILIMAP_NO_ERROR;
IMAPSession *session;
debug_print("getting session...\n");
static gint imap_remove_folder_real(Folder *folder, FolderItem *item)
{
- gint ok;
+ gint ok = MAILIMAP_NO_ERROR;
IMAPSession *session;
gchar *path;
gchar *cache_dir;
}
ok = imap_cmd_delete(session, path);
if (ok != MAILIMAP_NO_ERROR && !is_fatal(ok)) {
- gchar *tmp = g_strdup_printf("%s%c", path,
+ gchar *tmp = NULL;
+
+ ok = MAILIMAP_NO_ERROR;
+ tmp = g_strdup_printf("%s%c", path,
imap_get_path_separator(session, IMAP_FOLDER(folder), path, &ok));
g_free(path);
path = tmp;
g_slist_free(tags);
continue;
}
- if (tags != NULL) {
- g_slist_free(msginfo->tags);
- msginfo->tags = NULL;
- }
+ g_slist_free(msginfo->tags);
+ msginfo->tags = NULL;
+
for (cur = tags; cur; cur = cur->next) {
gchar *real_tag = imap_modified_utf7_to_utf8(cur->data, TRUE);
gint id = 0;
got_alien_tags = TRUE;
}
if (!g_slist_find(msginfo->tags, GINT_TO_POINTER(id))) {
- msginfo->tags = g_slist_append(
+ msginfo->tags = g_slist_prepend(
msginfo->tags,
GINT_TO_POINTER(id));
}
g_free(real_tag);
}
+ if (msginfo->tags)
+ msginfo->tags = g_slist_reverse(msginfo->tags);
slist_free_strings(tags);
g_slist_free(tags);
msginfo->folder = item;
IMAPFolder *imap_folder = NULL;
IMAPSession *session = NULL;
gchar result = '/';
- gint ok;
+ gint ok = MAILIMAP_NO_ERROR;
if (!item)
return '/';
folder = item->folder;
static gchar imap_get_path_separator(IMAPSession *session, IMAPFolder *folder, const gchar *path, gint *ok)
{
gchar separator = '/';
-
+ *ok = MAILIMAP_NO_ERROR;
if (folder->last_seen_separator == 0) {
folder->last_seen_separator = imap_refresh_path_separator(session, folder, "", ok);
}
{
gchar *real_path = NULL;
gchar separator;
-
+
g_return_val_if_fail(folder != NULL, NULL);
g_return_val_if_fail(path != NULL, NULL);
+ *ok = MAILIMAP_NO_ERROR;
+
real_path = imap_utf8_to_modified_utf7(path, FALSE);
separator = imap_get_path_separator(session, folder, path, ok);
if (*ok == MAILIMAP_NO_ERROR)
gboolean block)
{
gchar *real_path;
- gint ok;
+ gint ok = MAILIMAP_NO_ERROR;
gint exists_, recent_, unseen_;
guint32 uid_validity_;
gint can_create_flags_;
guint32 *uid_next, guint32 *uid_validity,
gint *unseen, gboolean block)
{
- int r;
+ int r = MAILIMAP_NO_ERROR;
clistiter * iter;
struct mailimap_mailbox_data_status * data_status;
int got_values;
struct mailimap_flag_list * flag_list;
int r;
- g_return_val_if_fail(file != NULL, MAILIMAP_ERROR_BAD_STATE);
+ cm_return_val_if_fail(file != NULL, MAILIMAP_ERROR_BAD_STATE);
flag_list = imap_flag_to_lep(item, flags, NULL);
lock_session(session);
return MAILIMAP_NO_ERROR;
}
-static gint imap_cmd_expunge(IMAPSession *session)
+static gint imap_cmd_expunge(IMAPSession *session, gboolean do_expunge)
{
int r;
+ if (!do_expunge)
+ return MAILIMAP_NO_ERROR;
+
if (prefs_common.work_offline &&
!inc_offline_should_override(FALSE,
_("Claws Mail needs network access in order "
return MAILIMAP_NO_ERROR;
}
+gint imap_expunge(Folder *folder, FolderItem *item)
+{
+ IMAPSession *session = imap_session_get(folder);
+ if (session == NULL)
+ return -1;
+
+ return imap_cmd_expunge(session, TRUE);
+}
+
static void imap_path_separator_subst(gchar *str, gchar separator)
{
gchar *p;
gchar *new_itempath;
gint oldpathlen;
IMAPSession *session = imap_session_get(item->folder);
- gint ok;
+ gint ok = MAILIMAP_NO_ERROR;
oldpathlen = strlen(oldpath);
if (strncmp(oldpath, item->path, oldpathlen) != 0) {
g_warning("path doesn't match: %s, %s\n", oldpath, item->path);
return ok;
}
- if (!session->uidplus) {
- ok = imap_cmd_expunge(session);
- } else {
- gchar *uidstr;
+ ok = imap_cmd_expunge(session, folder->account->imap_use_trash);
- uidstr = g_strdup_printf("%u", uid);
- ok = imap_cmd_expunge(session);
- g_free(uidstr);
- }
if (ok != MAILIMAP_NO_ERROR) {
log_warning(LOG_PROTOCOL, _("can't expunge\n"));
return ok;
unsigned long ucs4 = 0, bitbuf = 0;
/* initialize hex lookup table */
- char *dst, *res = malloc(2*strlen(src)+1);
+ char *dst, *res;
+
+ if (!src) return NULL;
+
+ res = malloc(2*strlen(src)+1);
dst = res;
if(!dst) return NULL;