From 08d493a056aa2bc326f8d1f5f3c0dfa61511ceb1 Mon Sep 17 00:00:00 2001 From: hiro Date: Tue, 24 Jan 2006 07:45:31 +0000 Subject: save temporary IMAP4 password. Don't try to connect to IMAP4 server when closing folder. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@921 ee746299-78ed-0310-b773-934348b2243d --- ChangeLog | 8 ++++++++ ChangeLog.ja | 8 ++++++++ libsylph/account.c | 7 ++++--- libsylph/imap.c | 18 ++++++++++++++---- libsylph/prefs_account.c | 4 ++++ src/prefs_account_dialog.c | 2 +- 6 files changed, 39 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index f4b8fb2a..4414a73f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-01-24 + + * libsylph/account.c + libsylph/prefs_account.c + src/prefs_account_dialog.c: fixed memory leaks. + * libsylph/imap.c: imap_session_connect(): save temporary password. + imap_close(): don't try to connect to server when closing. + 2006-01-24 * libsylph/procsg.c: procmsg_remove_all_cached_messages(): skip diff --git a/ChangeLog.ja b/ChangeLog.ja index 009d3635..61551e3a 100644 --- a/ChangeLog.ja +++ b/ChangeLog.ja @@ -1,3 +1,11 @@ +2006-01-24 + + * libsylph/account.c + libsylph/prefs_account.c + src/prefs_account_dialog.c: メモリリークを修正。 + * libsylph/imap.c: imap_session_connect(): 一時パスワードを保存。 + imap_close(): クローズ時にサーバへの接続を試みないようにした。 + 2006-01-24 * libsylph/procsg.c: procmsg_remove_all_cached_messages(): 仮想 diff --git a/libsylph/account.c b/libsylph/account.c index f9997ced..514825dd 100644 --- a/libsylph/account.c +++ b/libsylph/account.c @@ -1,6 +1,6 @@ /* * LibSylph -- E-Mail client library - * Copyright (C) 1999-2005 Hiroyuki Yamamoto + * Copyright (C) 1999-2006 Hiroyuki Yamamoto * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -431,10 +431,11 @@ void account_destroy(PrefsAccount *ac_prefs) folder_unref_account_all(ac_prefs); - prefs_account_free(ac_prefs); account_list = g_list_remove(account_list, ac_prefs); + if (cur_account == ac_prefs) + cur_account = NULL; + prefs_account_free(ac_prefs); - if (cur_account == ac_prefs) cur_account = NULL; if (!cur_account && account_list) { cur_account = account_get_default(); if (!cur_account) { diff --git a/libsylph/imap.c b/libsylph/imap.c index ac0cd1b2..ceffb2c0 100644 --- a/libsylph/imap.c +++ b/libsylph/imap.c @@ -588,7 +588,7 @@ static gint imap_session_connect(IMAPSession *session) { SockInfo *sock; PrefsAccount *account; - gchar *pass; + const gchar *pass; g_return_val_if_fail(session != NULL, IMAP_ERROR); @@ -598,15 +598,18 @@ static gint imap_session_connect(IMAPSession *session) SESSION(session)->server, SESSION(session)->port); pass = account->passwd; + if (!pass) + pass = account->tmp_pass; if (!pass) { gchar *tmp_pass; + tmp_pass = input_query_password(account->recv_server, account->userid); if (!tmp_pass) return IMAP_ERROR; - Xstrdup_a(pass, tmp_pass, - {g_free(tmp_pass); return IMAP_ERROR;}); - g_free(tmp_pass); + + account->tmp_pass = tmp_pass; + pass = account->tmp_pass; } #if USE_SSL @@ -650,6 +653,10 @@ static gint imap_session_connect(IMAPSession *session) if (!session->authenticated && imap_auth(session, account->userid, pass, account->imap_auth_type) != IMAP_SUCCESS) { + if (account->tmp_pass) { + g_free(account->tmp_pass); + account->tmp_pass = NULL; + } imap_cmd_logout(session); return IMAP_AUTHFAIL; } @@ -1599,6 +1606,9 @@ static gint imap_close(Folder *folder, FolderItem *item) if (!item->path) return 0; + if (!REMOTE_FOLDER(folder)->session) + return 0; + session = imap_session_get(folder); if (!session) return -1; diff --git a/libsylph/prefs_account.c b/libsylph/prefs_account.c index a6c229dd..20f07eb3 100644 --- a/libsylph/prefs_account.c +++ b/libsylph/prefs_account.c @@ -237,6 +237,10 @@ void prefs_account_free(PrefsAccount *ac_prefs) tmp_ac_prefs = *ac_prefs; prefs_free(param); + + if (ac_prefs->tmp_pass) + g_free(ac_prefs->tmp_pass); + g_free(ac_prefs); } static gint prefs_account_get_new_id(void) diff --git a/src/prefs_account_dialog.c b/src/prefs_account_dialog.c index b18ee2f4..c8946bb2 100644 --- a/src/prefs_account_dialog.c +++ b/src/prefs_account_dialog.c @@ -491,7 +491,7 @@ PrefsAccount *prefs_account_open(PrefsAccount *ac_prefs) inc_unlock(); if (cancelled && new_account) { - g_free(ac_prefs); + prefs_account_free(ac_prefs); return NULL; } else { prefs_account_apply_tmp_prefs(ac_prefs); -- cgit v1.2.3