Bug 136670

Summary: Mailody cannot connect to Dovecot IMAP with SSL.
Product: mailody Reporter: Tadeusz Andrzej Kadłubowski <yess>
Component: generalAssignee: Tom Albers <toma>
Status: RESOLVED NOT A BUG    
Severity: normal    
Priority: NOR    
Version: 0.2.0-beta1   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:

Description Tadeusz Andrzej Kadłubowski 2006-11-01 21:21:57 UTC
Version:           0.2.0-beta1 (using KDE 3.5.5, compiled sources)
Compiler:          gcc version 3.3.6 (PLD Linux)
OS:                Linux (i686) release 2.6.18-swsusp2

I have Dovecot 1.0.alpha3 IMAP server which I can connect to using SSL.

When I run mailody (svn revision 601036, new as of Nov 1st 2006) it shows me a popup:

Creating the connection failed, the error:
Could not connect on port 1852404340

The port number is weird and doesn't make much sense. It is 7077993 when mailody tries to connect after startup and 1852404340 when mailody tries to connect after being reconfigured.

It prints the following on the console:
[yess@trumf src]$ ./mailody
mailody: DB CONSTRUCTOR called
mailody: TLS not supported!
mailody: Connecting to: :7077993
kio (KSycoca): Trying to open ksycoca from /var/tmp/kdecache-yess/ksycoca
khtml (part): KHTMLPart(0x81c7920)::openURL http://
mailody: WARNING: KXMLGUIClient::setXMLFile: cannot find .rc file mailodyui.rc
khtml (part): KHTMLPart::showError d->m_bParsing=false d->m_bComplete=true d->m_bCleared=false
khtml (part): KHTMLPart::htmlError errorCode=5 text=http://
[yess@trumf src]$ mailody: Socket error: 14 - operation is not supported

This bug is a show-stopper for me, as I cannot connect to my mailbox. :/

Feel free to ask for any additional information.
Comment 1 Tom Albers 2006-11-01 22:16:33 UTC
What was the end of the configure output? Did it find QCA? You seem to miss the tls plugin of qca. I'ld like to know if configure did not detect that properly.
Comment 2 Tadeusz Andrzej Kadłubowski 2006-11-02 19:19:18 UTC
I installed qca and its header files just before compiling mailody. Ldd shows that the runnable binary is linked with qca library.
Comment 3 Tom Albers 2006-11-03 00:11:52 UTC
can you see if your distro (which is?) carries a seperate package called QCA-TLS. Let me know.
Comment 4 Tadeusz Andrzej Kadłubowski 2006-11-04 10:50:49 UTC
Ok, I have two qt versions and not the one mailody linked to had qca tls plugin installed. Just close the bug as INVALID.

I'll keep in touch. Maybe mailody will crash within first hour from the moment I compilled it correctly.
Comment 5 Tom Albers 2006-11-04 14:16:40 UTC
ok, thanks.
Comment 6 Tom Albers 2006-11-05 18:09:44 UTC
SVN commit 602297 by toma:

Properly detect if SSL/TLS is possible and warn about it. Disable the settings if needed. CLosing the bugs which I think are related to this.
BUG:136391,136460
CCBUG: 136670


 M  +6 -0      global.cpp  
 M  +5 -0      global.h  
 M  +22 -4     setupaccount.cpp  
 M  +10 -6     socketsafe.cpp  


--- trunk/playground/pim/mailody/src/global.cpp #602296:602297
@@ -20,6 +20,7 @@
 #include <kabc/stdaddressbook.h>
 #include <kapplication.h>
 #include <krun.h>
+#include <qca.h>
 #include "../libkmime/kmime_headers.h"
 #include "global.h"
 
@@ -88,3 +89,8 @@
     }
     return address;
 }
+
+bool Global::cryptoConnectionSupported()
+{
+    return QCA::isSupported(QCA::CAP_TLS);
+}
--- trunk/playground/pim/mailody/src/global.h #602296:602297
@@ -60,6 +60,11 @@
          */
         static QString myEmail();
 
+        /**
+         * will return true when it is possible to use SSL or TLS
+         */
+        static bool cryptoConnectionSupported();
+
     private:
         static Global* m_instance;
 };
--- trunk/playground/pim/mailody/src/setupaccount.cpp #602296:602297
@@ -48,6 +48,7 @@
 using KWallet::Wallet;
 
 // Local includes.
+#include "global.h"
 #include "setupaccount.h"
 
 class SetupAccountPriv
@@ -110,8 +111,8 @@
     d->safeImap = new QButtonGroup(3, Qt::Horizontal, parent);
     d->safeImap->setExclusive(true);
     new QRadioButton(i18n("None"), d->safeImap);
-    new QRadioButton(i18n("SSL"), d->safeImap);
-    new QRadioButton(i18n("TLS"), d->safeImap);
+    QRadioButton* sslRadioI = new QRadioButton(i18n("SSL"), d->safeImap);
+    QRadioButton* tlsRadioI = new QRadioButton(i18n("TLS"), d->safeImap);
     m->addWidget(d->safeImap,3,1);
     l5->setBuddy(d->safeImap);
 
@@ -151,8 +152,8 @@
     d->safeSMTP = new QButtonGroup(3, Qt::Horizontal, parent);
     d->safeSMTP->setExclusive(true);
     new QRadioButton("None", d->safeSMTP);
-    new QRadioButton("SSL", d->safeSMTP);
-    new QRadioButton("TLS", d->safeSMTP);
+    QRadioButton* sslRadioS = new QRadioButton("SSL", d->safeSMTP);
+    QRadioButton* tlsRadioS = new QRadioButton("TLS", d->safeSMTP);
     m->addWidget(d->safeSMTP,7,1);
     l5->setBuddy(d->safeSMTP);
 
@@ -165,6 +166,23 @@
     l8->setBuddy(d->homePage);
 
     readSettings();
+
+    if(!Global::cryptoConnectionSupported())
+    {
+        tlsRadioI->setEnabled(false);
+        tlsRadioS->setEnabled(false);
+        sslRadioI->setEnabled(false);
+        sslRadioS->setEnabled(false);
+        d->safeSMTP->setButton(0);
+        d->safeImap->setButton(0);
+
+        KMessageBox::information(0,i18n("Your system does not seem to be "
+                                        "setup for TLS or SSL, these settings "
+                                        "are disabled. Install QCA and "
+                                        "recompile Mailody or contact your "
+                                        "distribution"),
+                                 QString::null, "TLS_SSL_DISABLED");
+    }
 }
 
 SetupAccount::~SetupAccount()
--- trunk/playground/pim/mailody/src/socketsafe.cpp #602296:602297
@@ -32,6 +32,7 @@
 #include <qca.h>
 
 #include "db.h"
+#include "global.h"
 #include "socketsafe.h"
 
 SocketSafe::SocketSafe(QObject* parent, const QString& server,
@@ -44,12 +45,6 @@
     , m_gather(false)
     , m_crypted(false)
 {
-    if(!QCA::isSupported(QCA::CAP_TLS))
-    {
-        kdDebug() << "TLS not supported!" << endl;
-        return;
-    }
-
     m_server = server;
     m_port = port;
     m_safe = safe;
@@ -68,6 +63,15 @@
             << "TLS: " <<  (m_safe == TLS) << endl;
 #endif
 
+    if(!Global::cryptoConnectionSupported())
+    {
+        kdDebug() << "Crypto not supported!" << endl;
+        if (m_safe == TLS || m_safe == SSL)
+            emit error(i18n("You requested TLS/SSL, but your "
+                    "system does not seem to be setup for that."));
+        return;
+    }
+
     m_crypted=false;
 
     if (!m_socket)