PATCH: Basic IMAPS support
- From: Manuel McLure <manuel mclure org>
- To: balsa-list gnome org
- Subject: PATCH: Basic IMAPS support
- Date: Fri, 17 Aug 2001 22:50:22 -0700
The following patch adds basic IMAPS support to Balsa. I call it "basic"
because there is no certificate checking going on - however the connection
is encrypted.
At the moment you need to manually set the "Port" field to 993 *and* check
the "Use secure IMAP" checkbox on the mailbox or folder definition page for
this to work. I am planning to have the checkbox put the default port
setting (993 or 143) in the "Port" field when it is set/unset but I have to
study the GUI aspects a bit longer before I would feel comfortable doing
this (on the other hand, if someone more GUI-savvy wants to do this for me,
go ahead!).
Enjoy!
--
Manuel A. McLure KE6TAW | ...for in Ulthar, according to an ancient
<manuel@mclure.org> | and significant law, no man may kill a cat.
<http://www.mclure.org> | -- H.P. Lovecraft
diff -cr --exclude CVS --exclude ChangeLog* balsa.orig/libbalsa/folder-scanners.c balsa/libbalsa/folder-scanners.c
*** balsa.orig/libbalsa/folder-scanners.c Wed Aug 1 06:11:52 2001
--- balsa/libbalsa/folder-scanners.c Thu Aug 16 21:43:43 2001
***************
*** 184,193 ****
printf("Deph: %i -------------------------------------------\n", i);
for(el= g_list_first(list); el; el = g_list_next(el)) {
if(*(char*)el->data)
! imap_path = g_strdup_printf("imap://%s:%i/%s/", server->host,
server->port, (char*)el->data);
else
! imap_path = g_strdup_printf("imap://%s:%i/", server->host,
server->port);
FREE(&state.folder);
imap_browse ((char*)imap_path, &state);
--- 184,197 ----
printf("Deph: %i -------------------------------------------\n", i);
for(el= g_list_first(list); el; el = g_list_next(el)) {
if(*(char*)el->data)
! imap_path = g_strdup_printf("imap%s://%s:%i/%s/",
! server->secure ? "s" : "",
! server->host,
server->port, (char*)el->data);
else
! imap_path = g_strdup_printf("imap%s://%s:%i/",
! server->secure ? "s" : "",
! server->host,
server->port);
FREE(&state.folder);
imap_browse ((char*)imap_path, &state);
diff -cr --exclude CVS --exclude ChangeLog* balsa.orig/libbalsa/mailbox_imap.c balsa/libbalsa/mailbox_imap.c
*** balsa.orig/libbalsa/mailbox_imap.c Mon Aug 6 06:07:34 2001
--- balsa/libbalsa/mailbox_imap.c Fri Aug 17 17:36:42 2001
***************
*** 63,68 ****
--- 63,69 ----
LibBalsaMailbox * mailbox);
static void server_host_settings_changed_cb(LibBalsaServer * server,
gchar * host, gint port,
+ gint secure,
LibBalsaMailbox * mailbox);
GtkType libbalsa_mailbox_imap_get_type(void)
***************
*** 186,192 ****
LibBalsaServer* s = LIBBALSA_MAILBOX_REMOTE_SERVER(mailbox);
g_free(LIBBALSA_MAILBOX(mailbox)->url);
LIBBALSA_MAILBOX(mailbox)->url =
! g_strdup_printf("imap://%s:%i/%s", s->host, s->port, mailbox->path);
}
/* Unregister an old notification and add a current one */
--- 187,194 ----
LibBalsaServer* s = LIBBALSA_MAILBOX_REMOTE_SERVER(mailbox);
g_free(LIBBALSA_MAILBOX(mailbox)->url);
LIBBALSA_MAILBOX(mailbox)->url =
! g_strdup_printf("imap%s://%s:%i/%s", s->secure ? "s" : "",
! s->host, s->port, mailbox->path);
}
/* Unregister an old notification and add a current one */
***************
*** 223,229 ****
static void
server_host_settings_changed_cb(LibBalsaServer * server, gchar * host,
! gint port, LibBalsaMailbox * mailbox)
{
server_settings_changed(server, mailbox);
libbalsa_mailbox_imap_update_url(LIBBALSA_MAILBOX_IMAP(mailbox));
--- 225,232 ----
static void
server_host_settings_changed_cb(LibBalsaServer * server, gchar * host,
! gint port, gint secure,
! LibBalsaMailbox * mailbox)
{
server_settings_changed(server, mailbox);
libbalsa_mailbox_imap_update_url(LIBBALSA_MAILBOX_IMAP(mailbox));
***************
*** 477,483 ****
const gchar *folder, gboolean subscribe,
LibBalsaServer *server)
{
! gchar *imap_prefix = g_strdup_printf("imap://%s:%i/", server->host,
server->port);
imap_mailbox_rename(imap_prefix, dir, parent, folder, subscribe);
g_free(imap_prefix);
--- 480,488 ----
const gchar *folder, gboolean subscribe,
LibBalsaServer *server)
{
! gchar *imap_prefix = g_strdup_printf("imap%s://%s:%i/",
! server->secure ? "s" : "",
! server->host,
server->port);
imap_mailbox_rename(imap_prefix, dir, parent, folder, subscribe);
g_free(imap_prefix);
***************
*** 487,493 ****
libbalsa_imap_new_subfolder(const gchar *parent, const gchar *folder,
gboolean subscribe, LibBalsaServer *server)
{
! gchar *imap_path = g_strdup_printf("imap://%s:%i/%s", server->host,
server->port, parent);
imap_mailbox_create(imap_path, folder, subscribe);
g_free(imap_path);
--- 492,500 ----
libbalsa_imap_new_subfolder(const gchar *parent, const gchar *folder,
gboolean subscribe, LibBalsaServer *server)
{
! gchar *imap_path = g_strdup_printf("imap%s://%s:%i/%s",
! server->secure ? "s" : "",
! server->host,
server->port, parent);
imap_mailbox_create(imap_path, folder, subscribe);
g_free(imap_path);
diff -cr --exclude CVS --exclude ChangeLog* balsa.orig/libbalsa/server.c balsa/libbalsa/server.c
*** balsa.orig/libbalsa/server.c Mon Apr 16 15:48:35 2001
--- balsa/libbalsa/server.c Fri Aug 17 18:29:23 2001
***************
*** 36,42 ****
static void libbalsa_server_real_set_password(LibBalsaServer * server,
const gchar * passwd);
static void libbalsa_server_real_set_host(LibBalsaServer * server,
! const gchar * host, gint port);
/* static gchar* libbalsa_server_real_get_password(LibBalsaServer *server); */
enum {
--- 36,43 ----
static void libbalsa_server_real_set_password(LibBalsaServer * server,
const gchar * passwd);
static void libbalsa_server_real_set_host(LibBalsaServer * server,
! const gchar * host, gint port,
! gint secure);
/* static gchar* libbalsa_server_real_get_password(LibBalsaServer *server); */
enum {
***************
*** 99,106 ****
libbalsa_server_signals[SET_HOST] =
gtk_signal_new("set-host", GTK_RUN_FIRST, object_class->type,
GTK_SIGNAL_OFFSET(LibBalsaServerClass, set_host),
! gtk_marshal_NONE__POINTER_INT, GTK_TYPE_NONE, 2,
! GTK_TYPE_STRING, GTK_TYPE_INT);
libbalsa_server_signals[GET_PASSWORD] =
gtk_signal_new("get-password",
--- 100,107 ----
libbalsa_server_signals[SET_HOST] =
gtk_signal_new("set-host", GTK_RUN_FIRST, object_class->type,
GTK_SIGNAL_OFFSET(LibBalsaServerClass, set_host),
! gtk_marshal_NONE__POINTER_INT_INT, GTK_TYPE_NONE, 3,
! GTK_TYPE_STRING, GTK_TYPE_INT, GTK_TYPE_INT);
libbalsa_server_signals[GET_PASSWORD] =
gtk_signal_new("get-password",
***************
*** 127,132 ****
--- 128,134 ----
server->port = 0;
server->user = NULL;
server->passwd = NULL;
+ server->secure = FALSE;
}
/* leave object in sane state (NULLified fields) */
***************
*** 180,192 ****
void
libbalsa_server_set_host(LibBalsaServer * server, const gchar * host,
! gint port)
{
g_return_if_fail(server != NULL);
g_return_if_fail(LIBBALSA_IS_SERVER(server));
gtk_signal_emit(GTK_OBJECT(server), libbalsa_server_signals[SET_HOST],
! host, port);
}
gchar *
--- 182,194 ----
void
libbalsa_server_set_host(LibBalsaServer * server, const gchar * host,
! gint port, gint secure)
{
g_return_if_fail(server != NULL);
g_return_if_fail(LIBBALSA_IS_SERVER(server));
gtk_signal_emit(GTK_OBJECT(server), libbalsa_server_signals[SET_HOST],
! host, port, secure);
}
gchar *
***************
*** 227,239 ****
static void
libbalsa_server_real_set_host(LibBalsaServer * server, const gchar * host,
! gint port)
{
g_return_if_fail(LIBBALSA_IS_SERVER(server));
g_free(server->host);
server->host = g_strdup(host);
server->port = port;
}
#if 0
--- 229,242 ----
static void
libbalsa_server_real_set_host(LibBalsaServer * server, const gchar * host,
! gint port, gint secure)
{
g_return_if_fail(LIBBALSA_IS_SERVER(server));
g_free(server->host);
server->host = g_strdup(host);
server->port = port;
+ server->secure = (gboolean)secure;
}
#if 0
***************
*** 281,286 ****
--- 284,292 ----
server->port = gnome_config_get_int_with_default("Port", &d);
if (d)
server->port = default_port;
+ server->secure = gnome_config_get_int_with_default("Secure", &d);
+ if (d)
+ server->secure = FALSE;
server->user = gnome_config_private_get_string("Username");
server->passwd = gnome_config_private_get_string("Password");
if(server->passwd && server->passwd[0] == '\0') {
***************
*** 304,309 ****
--- 310,316 ----
{
gnome_config_set_string("Server", server->host);
gnome_config_set_int("Port", server->port);
+ gnome_config_set_int("Secure", server->secure);
gnome_config_private_set_string("Username", server->user);
if (server->passwd != NULL) {
diff -cr --exclude CVS --exclude ChangeLog* balsa.orig/libbalsa/server.h balsa/libbalsa/server.h
*** balsa.orig/libbalsa/server.h Fri Oct 6 08:50:51 2000
--- balsa/libbalsa/server.h Thu Aug 16 22:59:23 2001
***************
*** 51,56 ****
--- 51,58 ----
gchar *user;
gchar *passwd;
+
+ gint secure;
};
struct _LibBalsaServerClass {
***************
*** 59,65 ****
void (*set_username) (LibBalsaServer * server, const gchar * name);
void (*set_password) (LibBalsaServer * server, const gchar * passwd);
void (*set_host) (LibBalsaServer * server,
! const gchar * host, gint port);
gchar *(*get_password) (LibBalsaServer * server);
};
--- 61,67 ----
void (*set_username) (LibBalsaServer * server, const gchar * name);
void (*set_password) (LibBalsaServer * server, const gchar * passwd);
void (*set_host) (LibBalsaServer * server,
! const gchar * host, gint port, gint secure);
gchar *(*get_password) (LibBalsaServer * server);
};
***************
*** 70,76 ****
void libbalsa_server_set_password(LibBalsaServer * server,
const gchar * passwd);
void libbalsa_server_set_host(LibBalsaServer * server, const gchar * host,
! gint port);
gchar *libbalsa_server_get_password(LibBalsaServer * server,
LibBalsaMailbox * mbox);
--- 72,78 ----
void libbalsa_server_set_password(LibBalsaServer * server,
const gchar * passwd);
void libbalsa_server_set_host(LibBalsaServer * server, const gchar * host,
! gint port, gboolean secure);
gchar *libbalsa_server_get_password(LibBalsaServer * server,
LibBalsaMailbox * mbox);
diff -cr --exclude CVS --exclude ChangeLog* balsa.orig/libmutt/mutt_ssl.c balsa/libmutt/mutt_ssl.c
*** balsa.orig/libmutt/mutt_ssl.c Wed Jul 18 11:59:28 2001
--- balsa/libmutt/mutt_ssl.c Fri Aug 17 22:37:43 2001
***************
*** 267,272 ****
--- 267,273 ----
data->ctx = SSL_CTX_new (SSLv23_client_method ());
+ #if 0
/* disable SSL protocols as needed */
if (!option(OPTTLSV1))
{
***************
*** 280,285 ****
--- 281,287 ----
{
SSL_CTX_set_options(data->ctx, SSL_OP_NO_SSLv3);
}
+ #endif
data->ssl = SSL_new (data->ctx);
SSL_set_fd (data->ssl, conn->fd);
***************
*** 329,334 ****
--- 331,337 ----
return -1;
}
+ #if 0
ssldata->cert = SSL_get_peer_certificate (ssldata->ssl);
if (!ssldata->cert)
{
***************
*** 339,345 ****
if (!ssl_check_certificate (ssldata))
return -1;
!
mutt_message (_("SSL connection using %s (%s)"),
SSL_get_cipher_version (ssldata->ssl), SSL_get_cipher_name (ssldata->ssl));
mutt_sleep (0);
--- 342,348 ----
if (!ssl_check_certificate (ssldata))
return -1;
! #endif
mutt_message (_("SSL connection using %s (%s)"),
SSL_get_cipher_version (ssldata->ssl), SSL_get_cipher_name (ssldata->ssl));
mutt_sleep (0);
diff -cr --exclude CVS --exclude ChangeLog* balsa.orig/src/folder-conf.c balsa/src/folder-conf.c
*** balsa.orig/src/folder-conf.c Sun Aug 12 11:39:43 2001
--- balsa/src/folder-conf.c Fri Aug 17 18:29:54 2001
***************
*** 31,37 ****
typedef struct {
GnomeDialog *dialog;
GtkWidget * folder_name, *server, *port, *username, *password,
! *subscribed, *prefix;
} FolderDialogData;
/* folder_conf_imap_node:
--- 31,37 ----
typedef struct {
GnomeDialog *dialog;
GtkWidget * folder_name, *server, *port, *username, *password,
! *subscribed, *prefix, *secure;
} FolderDialogData;
/* folder_conf_imap_node:
***************
*** 120,125 ****
--- 120,129 ----
fcw.prefix = create_entry(fcw.dialog, table, NULL, NULL, 6,
mn ? mn->dir : NULL, keyval);
+ fcw.secure = create_check(fcw.dialog,
+ _("Use secure IMAP (IMAPS)"),
+ table, 7, s->secure);
+
gtk_widget_show_all(GTK_WIDGET(fcw.dialog));
gnome_dialog_close_hides(fcw.dialog, TRUE);
***************
*** 142,148 ****
port_no = atoi(gtk_entry_get_text(GTK_ENTRY(fcw.port)));
libbalsa_server_set_host(s, gtk_entry_get_text(GTK_ENTRY(fcw.server)),
! port_no);
libbalsa_server_set_username
(s, gtk_entry_get_text(GTK_ENTRY(fcw.username)));
libbalsa_server_set_password
--- 146,154 ----
port_no = atoi(gtk_entry_get_text(GTK_ENTRY(fcw.port)));
libbalsa_server_set_host(s, gtk_entry_get_text(GTK_ENTRY(fcw.server)),
! port_no,
! gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
! (fcw.secure)));
libbalsa_server_set_username
(s, gtk_entry_get_text(GTK_ENTRY(fcw.username)));
libbalsa_server_set_password
diff -cr --exclude CVS --exclude ChangeLog* balsa.orig/src/mailbox-conf.c balsa/src/mailbox-conf.c
*** balsa.orig/src/mailbox-conf.c Wed Aug 15 21:29:16 2001
--- balsa/src/mailbox-conf.c Fri Aug 17 18:28:32 2001
***************
*** 55,60 ****
--- 55,61 ----
GtkWidget *username;
GtkWidget *password;
GtkWidget *folderpath;
+ GtkWidget *secure;
} imap;
/* for pop3 mailboxes */
***************
*** 419,424 ****
--- 420,430 ----
if (imap->path)
gtk_entry_set_text(GTK_ENTRY(mcw->mb_data.imap.folderpath),
imap->path);
+
+ gtk_toggle_button_set_active
+ (GTK_TOGGLE_BUTTON(mcw->mb_data.imap.secure),
+ server->secure);
+
g_free(port);
}
}
***************
*** 509,515 ****
gtk_entry_get_text(GTK_ENTRY
(mcw->mb_data.pop3.server)),
atoi(gtk_entry_get_text
! (GTK_ENTRY(mcw->mb_data.pop3.port))));
mailbox->check =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mcw->mb_data.pop3.check));
mailbox->use_apop =
--- 515,522 ----
gtk_entry_get_text(GTK_ENTRY
(mcw->mb_data.pop3.server)),
atoi(gtk_entry_get_text
! (GTK_ENTRY(mcw->mb_data.pop3.port))),
! FALSE); /* TODO - add POPS */
mailbox->check =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mcw->mb_data.pop3.check));
mailbox->use_apop =
***************
*** 544,550 ****
gtk_entry_get_text(GTK_ENTRY
(mcw->mb_data.imap.server)),
atoi(gtk_entry_get_text
! (GTK_ENTRY(mcw->mb_data.imap.port))));
gtk_signal_connect(GTK_OBJECT(LIBBALSA_MAILBOX_REMOTE_SERVER(mailbox)),
"get-password", GTK_SIGNAL_FUNC(ask_password),
mailbox);
--- 551,559 ----
gtk_entry_get_text(GTK_ENTRY
(mcw->mb_data.imap.server)),
atoi(gtk_entry_get_text
! (GTK_ENTRY(mcw->mb_data.imap.port))),
! gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
! (mcw->mb_data.imap.secure)));
gtk_signal_connect(GTK_OBJECT(LIBBALSA_MAILBOX_REMOTE_SERVER(mailbox)),
"get-password", GTK_SIGNAL_FUNC(ask_password),
mailbox);
***************
*** 876,881 ****
--- 885,896 ----
"INBOX.Draft");
gnome_entry_append_history(GNOME_ENTRY(entry), 1,
"INBOX.outbox");
+
+ /* toggle for secure IMAP */
+ mcw->mb_data.imap.secure =
+ create_check(mcw->window,
+ _("Use secure IMAP (IMAPS)"),
+ table, 6, FALSE);
gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 5, 6,
GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 10);
diff -cr --exclude CVS --exclude ChangeLog* balsa.orig/src/mailbox-node.c balsa/src/mailbox-node.c
*** balsa.orig/src/mailbox-node.c Mon Aug 6 07:56:30 2001
--- balsa/src/mailbox-node.c Thu Aug 16 21:42:03 2001
***************
*** 842,848 ****
g_return_val_if_fail(parent, NULL);
! url = g_strdup_printf("imap://%s:%i/%s",
BALSA_MAILBOX_NODE(root->data)->server->host,
BALSA_MAILBOX_NODE(root->data)->server->port,
fn);
--- 842,850 ----
g_return_val_if_fail(parent, NULL);
! url = g_strdup_printf("imap%s://%s:%i/%s",
! BALSA_MAILBOX_NODE(root->data)->server->secure ?
! "s" : "",
BALSA_MAILBOX_NODE(root->data)->server->host,
BALSA_MAILBOX_NODE(root->data)->server->port,
fn);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]