Re: IMAPS support
- From: Manuel McLure <manuel mclure org>
- To: Balsa List <balsa-list gnome org>
- Subject: Re: IMAPS support
- Date: Fri, 17 Aug 2001 18:49:07 -0700
On 2001.08.16 01:50 Carlos Morgado wrote:
>
> On 2001.08.16 03:32:34 +0100 Manuel McLure wrote:
> > How difficult would it be to implement IMAPS support in Balsa? I can
> see
> > that libmutt seems to have support for it, but I haven't gone deeply
> enough
> > into the API to see how easy it would be to get Balsa to use IMAPS. If
> > someone can give me some pointers, I may look into implementing this.
> >
>
> i believe now is just a question of grunt work. the balsa func that
> encodes
> mutt mailbox names must be changed to accomodate imaps syntax but that's
> about it (apart from the eventual GUI stuff). of course, there can be an
> ugly piece of code hidding somewhere ;)
Well, I've made a patch that adds the capability for us to generate
"imaps://" URLs for mailboxes (including the GUI part) and everything seems
to be working exept that the connection does not work. It connects to the
server on the right port, and seems to attempt to start an SSL connection,
but then it seems to die. The imapd on the server prints out
Aug 17 18:30:20 leng imapd[25555]: imaps alternative service init from
10.1.1.2
Aug 17 18:30:20 leng imapd[25555]: Command stream end of file, while
reading line user=??? host=ulthar.internal.mclure.org [10.1.1.2]
A successful IMAPS connection (from Outlook Express) shows the following:
Aug 17 11:56:42 leng imapd[24786]: imaps alternative service init from
204.163.170.33
Aug 17 11:56:42 leng imapd[24786]: Login user=manuel host=host33.unify.com
[204.163.170.33]
Aug 17 11:56:42 leng imapd[24786]: Command stream end of file, while
reading line user=manuel host=host33.unify.com [204.163.170.33]
so it seems like the user name is not being transferred?
If anyone wants to try to debug this in parallel with me, I have attached
my patch (against today's CVS) to this email. Help! :-)
--
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 -ur --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,10 +184,14 @@
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,
+ 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:%i/", server->host,
+ 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 -ur --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,6 +63,7 @@
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,7 +187,8 @@
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);
+ 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,7 +225,8 @@
static void
server_host_settings_changed_cb(LibBalsaServer * server, gchar * host,
- gint port, LibBalsaMailbox * mailbox)
+ gint port, gint secure,
+ LibBalsaMailbox * mailbox)
{
server_settings_changed(server, mailbox);
libbalsa_mailbox_imap_update_url(LIBBALSA_MAILBOX_IMAP(mailbox));
@@ -477,7 +480,9 @@
const gchar *folder, gboolean subscribe,
LibBalsaServer *server)
{
- gchar *imap_prefix = g_strdup_printf("imap://%s:%i/", server->host,
+ 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,7 +492,9 @@
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,
+ 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 -ur --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,7 +36,8 @@
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);
+ const gchar * host, gint port,
+ gint secure);
/* static gchar* libbalsa_server_real_get_password(LibBalsaServer *server); */
enum {
@@ -99,8 +100,8 @@
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);
+ 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,6 +128,7 @@
server->port = 0;
server->user = NULL;
server->passwd = NULL;
+ server->secure = FALSE;
}
/* leave object in sane state (NULLified fields) */
@@ -180,13 +182,13 @@
void
libbalsa_server_set_host(LibBalsaServer * server, const gchar * host,
- gint port)
+ 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);
+ host, port, secure);
}
gchar *
@@ -227,13 +229,14 @@
static void
libbalsa_server_real_set_host(LibBalsaServer * server, const gchar * host,
- gint port)
+ 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,6 +284,9 @@
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,6 +310,7 @@
{
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 -ur --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,6 +51,8 @@
gchar *user;
gchar *passwd;
+
+ gint secure;
};
struct _LibBalsaServerClass {
@@ -59,7 +61,7 @@
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);
+ const gchar * host, gint port, gint secure);
gchar *(*get_password) (LibBalsaServer * server);
};
@@ -70,7 +72,7 @@
void libbalsa_server_set_password(LibBalsaServer * server,
const gchar * passwd);
void libbalsa_server_set_host(LibBalsaServer * server, const gchar * host,
- gint port);
+ gint port, gboolean secure);
gchar *libbalsa_server_get_password(LibBalsaServer * server,
LibBalsaMailbox * mbox);
diff -ur --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,7 +31,7 @@
typedef struct {
GnomeDialog *dialog;
GtkWidget * folder_name, *server, *port, *username, *password,
- *subscribed, *prefix;
+ *subscribed, *prefix, *secure;
} FolderDialogData;
/* folder_conf_imap_node:
@@ -120,6 +120,10 @@
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,7 +146,9 @@
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);
+ 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 -ur --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,6 +55,7 @@
GtkWidget *username;
GtkWidget *password;
GtkWidget *folderpath;
+ GtkWidget *secure;
} imap;
/* for pop3 mailboxes */
@@ -419,6 +420,11 @@
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,7 +515,8 @@
gtk_entry_get_text(GTK_ENTRY
(mcw->mb_data.pop3.server)),
atoi(gtk_entry_get_text
- (GTK_ENTRY(mcw->mb_data.pop3.port))));
+ (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,7 +551,9 @@
gtk_entry_get_text(GTK_ENTRY
(mcw->mb_data.imap.server)),
atoi(gtk_entry_get_text
- (GTK_ENTRY(mcw->mb_data.imap.port))));
+ (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,6 +885,12 @@
"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 -ur --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,7 +842,9 @@
g_return_val_if_fail(parent, NULL);
- url = g_strdup_printf("imap://%s:%i/%s",
+ 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]