[Commits] [SCM] claws branch, master, updated. 3.9.2-17-gd3c722d
colin at claws-mail.org
colin at claws-mail.org
Fri Jun 14 10:25:26 CEST 2013
The branch master of project "claws" (Claws Mail) has been updated
via d3c722d3f45e2280384c78994a65bfb4e093eb0a (commit)
via 80b136e8b9436e79bfad49a053e2ae1d33521470 (commit)
from d74bd45f9a003128e049a42a5a06606944fc286c (commit)
- Log -----------------------------------------------------------------
commit d3c722d3f45e2280384c78994a65bfb4e093eb0a
Author: Colin Leroy <colin at colino.net>
Date: Thu May 30 15:50:12 2013 +0200
Add Michal to AUTHORS
diff --git a/AUTHORS b/AUTHORS
index e4ab791..27c6f8a 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -296,4 +296,4 @@ contributors (in addition to the above; based on Changelog)
Christian Hesse
Ben Deering
Henri Bauer
-
+ Michal Gorny
diff --git a/src/gtk/authors.h b/src/gtk/authors.h
index 29bc26a..7d2d2bd 100644
--- a/src/gtk/authors.h
+++ b/src/gtk/authors.h
@@ -129,6 +129,7 @@ static char *CONTRIBS_LIST[] = {
"Marius Glauser",
"Thierry Godefroy",
"Alex Gorbachenko",
+"Michał Górny",
"Bodo Graumann",
"Yang Guilong",
"Daniel Gustafson",
commit 80b136e8b9436e79bfad49a053e2ae1d33521470
Author: Colin Leroy <colin at colino.net>
Date: Thu May 30 15:26:00 2013 +0200
Implement a password get hooklist, allowing plugins to
provide passwords for various accounts. Patch by Michal
Gorki, bug #2252 "API for external password storage"
diff --git a/src/account.c b/src/account.c
index 303d9ec..3a898da 100644
--- a/src/account.c
+++ b/src/account.c
@@ -53,6 +53,7 @@
#include "manual.h"
#include "filtering.h"
#include "prefs_actions.h"
+#include "hooks.h"
enum {
ACCOUNT_IS_DEFAULT,
@@ -1849,3 +1850,29 @@ PrefsAccount *account_get_cur_account (void)
{
return cur_account;
}
+
+gboolean password_get(const gchar *user,
+ const gchar *server,
+ const gchar *protocol,
+ guint16 port,
+ gchar **password)
+{
+ PasswordRequest req;
+
+ /* all have to be set */
+ cm_return_val_if_fail(user != NULL, FALSE);
+ cm_return_val_if_fail(server != NULL, FALSE);
+ cm_return_val_if_fail(protocol != NULL, FALSE);
+ cm_return_val_if_fail(port != NULL, FALSE);
+
+ req.user = user;
+ req.server = server;
+ req.protocol = protocol;
+ req.port = port;
+
+ if (hooks_invoke(PASSWORD_GET_HOOKLIST, &req)) {
+ *password = req.password;
+ return TRUE;
+ }
+ return FALSE;
+}
diff --git a/src/account.h b/src/account.h
index 4bc44be..e7c7760 100644
--- a/src/account.h
+++ b/src/account.h
@@ -29,6 +29,17 @@
typedef gint (*AccountFunc) (PrefsAccount *ac_prefs,
gpointer user_data);
+typedef struct {
+ const gchar *user;
+ const gchar *server;
+ const gchar *protocol;
+ guint16 port;
+
+ gchar *password;
+} PasswordRequest;
+
+#define PASSWORD_GET_HOOKLIST "password_get_hooklist"
+
extern PrefsAccount *cur_account;
PrefsAccount *account_get_cur_account (void);
@@ -63,4 +74,10 @@ void account_rename_path (const gchar *old_id,
const gchar *new_id);
gchar *account_get_signature_str(PrefsAccount *account);
+gboolean password_get(const gchar *user,
+ const gchar *server,
+ const gchar *protocol,
+ guint16 port,
+ gchar **password);
+
#endif /* __ACCOUNT_H__ */
diff --git a/src/imap.c b/src/imap.c
index 94de747..ba4a480 100644
--- a/src/imap.c
+++ b/src/imap.c
@@ -1213,7 +1213,14 @@ static gint imap_session_authenticate(IMAPSession *session,
gboolean failed = FALSE;
gint ok = MAILIMAP_NO_ERROR;
g_return_val_if_fail(account->userid != NULL, MAILIMAP_ERROR_BAD_STATE);
- acc_pass = account->passwd;
+
+ if (password_get(account->userid, account->recv_server, "imap",
+ SESSION(session)->port, &pass)) {
+ Xstrdup_a(acc_pass, pass, {g_free(pass); return MAILIMAP_NO_ERROR;});
+ g_free(pass);
+ } else {
+ acc_pass = account->passwd;
+ }
try_again:
pass = acc_pass;
if (!pass && account->imap_auth_type != IMAP_AUTH_ANON && account->imap_auth_type != IMAP_AUTH_GSSAPI) {
diff --git a/src/inc.c b/src/inc.c
index 80ad90d..c9ce084 100644
--- a/src/inc.c
+++ b/src/inc.c
@@ -552,7 +552,12 @@ static gint inc_start(IncProgressDialog *inc_dialog)
session = qlist->data;
pop3_session = POP3_SESSION(session->session);
pop3_session->user = g_strdup(pop3_session->ac_prefs->userid);
- if (pop3_session->ac_prefs->passwd)
+ if (password_get(pop3_session->user,
+ pop3_session->ac_prefs->recv_server,
+ "pop3", SESSION(session)->port,
+ &(pop3_session->pass))) {
+ /* NOP */;
+ } else if (pop3_session->ac_prefs->passwd)
pop3_session->pass =
g_strdup(pop3_session->ac_prefs->passwd);
else {
diff --git a/src/news.c b/src/news.c
index 9c9080c..9df3090 100644
--- a/src/news.c
+++ b/src/news.c
@@ -376,15 +376,6 @@ static Session *news_session_new_for_folder(Folder *folder)
cm_return_val_if_fail(folder->account != NULL, NULL);
ac = folder->account;
- if (ac->use_nntp_auth && ac->userid && ac->userid[0]) {
- userid = ac->userid;
- if (ac->passwd && ac->passwd[0])
- passwd = g_strdup(ac->passwd);
- else
- passwd = input_dialog_query_password_keep(ac->nntp_server,
- userid,
- &(ac->session_passwd));
- }
#ifdef USE_GNUTLS
port = ac->set_nntpport ? ac->nntpport
@@ -409,6 +400,18 @@ static Session *news_session_new_for_folder(Folder *folder)
session = news_session_new(folder, ac->nntp_server, port, userid, passwd);
#endif
+ if (ac->use_nntp_auth && ac->userid && ac->userid[0]) {
+ userid = ac->userid;
+ if (password_get(userid, ac->nntp_server, "nntp", port, &passwd)) {
+ /* NOP */;
+ } else if (ac->passwd && ac->passwd[0])
+ passwd = g_strdup(ac->passwd);
+ else
+ passwd = input_dialog_query_password_keep(ac->nntp_server,
+ userid,
+ &(ac->session_passwd));
+ }
+
if (session != NULL)
r = nntp_threaded_mode_reader(folder);
else
diff --git a/src/send_message.c b/src/send_message.c
index 4e5f6e6..3cf8204 100644
--- a/src/send_message.c
+++ b/src/send_message.c
@@ -287,7 +287,11 @@ gint send_message_smtp_full(PrefsAccount *ac_prefs, GSList *to_list, FILE *fp, g
smtp_session->forced_auth_type = ac_prefs->smtp_auth_type;
if (ac_prefs->smtp_userid && strlen(ac_prefs->smtp_userid)) {
smtp_session->user = g_strdup(ac_prefs->smtp_userid);
- if (ac_prefs->smtp_passwd)
+ if (password_get(smtp_session->user,
+ ac_prefs->smtp_server, "smtp", port,
+ &(smtp_session->pass))) {
+ /* NOP */;
+ } else if (ac_prefs->smtp_passwd)
smtp_session->pass =
g_strdup(ac_prefs->smtp_passwd);
else {
@@ -303,7 +307,11 @@ gint send_message_smtp_full(PrefsAccount *ac_prefs, GSList *to_list, FILE *fp, g
}
} else {
smtp_session->user = g_strdup(ac_prefs->userid);
- if (ac_prefs->passwd)
+ if (password_get(smtp_session->user,
+ ac_prefs->smtp_server, "smtp", port,
+ &(smtp_session->pass))) {
+ /* NOP */;
+ } else if (ac_prefs->passwd)
smtp_session->pass = g_strdup(ac_prefs->passwd);
else {
smtp_session->pass =
-----------------------------------------------------------------------
Summary of changes:
AUTHORS | 2 +-
src/account.c | 27 +++++++++++++++++++++++++++
src/account.h | 17 +++++++++++++++++
src/gtk/authors.h | 1 +
src/imap.c | 9 ++++++++-
src/inc.c | 7 ++++++-
src/news.c | 21 ++++++++++++---------
src/send_message.c | 12 ++++++++++--
8 files changed, 82 insertions(+), 14 deletions(-)
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list