[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdepim/runtime
From:       Casey Link <unnamedrambler () gmail ! com>
Date:       2010-05-31 23:51:19
Message-ID: 20100531235119.33168AC8C8 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1133037 by link:

Make the IMAP resource store its encryption setting as a string, rather
then an integer representation of an enum.

THIS WILL BREAK YOUR CURRENT IMAP SETUPS!

Short rationale: "SSL" is more understandable than "1"
Longer rationale:  There are two enums used to
represent encryption settings in kdepim, each with different values and
orders. The result was hell whenever you had to reference the enum by
integer value (like in javascript). Storing it as a String makes it
easier and removes all ambiguity as to what the value represents.

CCMAIL: kde-pim@kde.org

 M  +3 -3      migration/kmail/kmailmigrator.cpp  
 M  +7 -1      resources/imap/imapaccount.cpp  
 M  +2 -2      resources/imap/imapresource.kcfg  
 M  +24 -2     resources/imap/setupserver.cpp  
 M  +7 -5      resources/imap/wizard/imapwizard.js  


--- trunk/KDE/kdepim/runtime/migration/kmail/kmailmigrator.cpp #1133036:1133037
@@ -353,11 +353,11 @@
   iface->setImapPort( config.readEntry( "port", 143 ) );
   iface->setUserName( config.readEntry( "login" ) );
   if ( config.readEntry( "use-ssl" ).toLower() == "true" )
-    iface->setSafety( KIMAP::LoginJob::AnySslVersion );
+    iface->setSafety( "SSL" );
   else if ( config.readEntry( "use-tls" ).toLower() == "true" )
-    iface->setSafety( KIMAP::LoginJob::TlsV1 );
+    iface->setSafety( "STARTTLS" );
   else
-    iface->setSafety( KIMAP::LoginJob::Unencrypted );
+    iface->setSafety( "NONE" );
   const QString &authentication = config.readEntry( "auth" ).toUpper();
   if ( authentication == "LOGIN" )
     iface->setAuthentication( KIMAP::LoginJob::Login );
--- trunk/KDE/kdepim/runtime/resources/imap/imapaccount.cpp #1133036:1133037
@@ -67,7 +67,13 @@
   m_userName = settings->userName();
   m_subscriptionEnabled = settings->subscriptionEnabled();
 
-  m_encryption = (KIMAP::LoginJob::EncryptionMode) settings->safety();
+  QString safety = settings->safety();
+  if( safety == "SSL" )
+    m_encryption = KIMAP::LoginJob::AnySslVersion;
+  else if ( safety == "STARTTLS" )
+    m_encryption = KIMAP::LoginJob::TlsV1;
+  else
+    m_encryption = KIMAP::LoginJob::Unencrypted;
   m_authentication = (KIMAP::LoginJob::AuthenticationMode) settings->authentication();
 }
 
--- trunk/KDE/kdepim/runtime/resources/imap/imapresource.kcfg #1133036:1133037
@@ -16,9 +16,9 @@
     <entry name="UserName" type="String">
       <label>Username</label>
     </entry>
-    <entry name="Safety" type="Int">
+    <entry name="Safety" type="String">
       <label>Defines the encryption type to use</label>
-      <default>1</default>
+      <default>SSL</default>
     </entry>
     <entry name="Authentication" type="Int">
       <label>Defines the authentication type to use</label>
--- trunk/KDE/kdepim/runtime/resources/imap/setupserver.cpp #1133036:1133037
@@ -236,7 +236,21 @@
   Settings::self()->setImapServer( m_ui->imapServer->text() );
   Settings::self()->setImapPort( m_ui->portSpin->value() );
   Settings::self()->setUserName( m_ui->userName->text() );
-  Settings::self()->setSafety( m_ui->safeImapGroup->checkedId() );
+  QString encryption = "";
+  switch ( m_ui->safeImapGroup->checkedId() ) {
+  case KIMAP::LoginJob::Unencrypted :
+    encryption = "None";
+    break;
+  case KIMAP::LoginJob::AnySslVersion:
+    encryption = "SSL";
+    break;
+  case KIMAP::LoginJob::TlsV1:
+    encryption = "STARTTLS";
+    break;
+  default:
+    kFatal() << "Shouldn't happen";
+  }
+  Settings::self()->setSafety( encryption );
   KIMAP::LoginJob::AuthenticationMode authtype = getCurrentAuthMode( m_ui->authenticationCombo );
   kDebug() << "saving IMAP auth mode: " << authenticationModeString( authtype );
   Settings::self()->setAuthentication( authtype );
@@ -293,7 +307,15 @@
     !Settings::self()->userName().isEmpty() ? Settings::self()->userName() :
     currentUser->loginName() );
 
-  int i = Settings::self()->safety();
+  QString safety = Settings::self()->safety();
+  int i = 0;
+  if( safety == "SSL" )
+    i = KIMAP::LoginJob::AnySslVersion;
+  else if ( safety == "STARTTLS" )
+    i = KIMAP::LoginJob::TlsV1;
+  else
+    i = KIMAP::LoginJob::Unencrypted;
+
   QAbstractButton* safetyButton = m_ui->safeImapGroup->button( i );
   if ( safetyButton )
       safetyButton->setChecked( true );
--- trunk/KDE/kdepim/runtime/resources/imap/wizard/imapwizard.js #1133036:1133037
@@ -72,12 +72,14 @@
     imapRes.setOption( "UseDefaultIdentity", false );
     imapRes.setOption( "AccountIdentity", identity.uoid() );
     if ( arg == "ssl" ) { 
-      imapRes.setOption( "Safety", 0);
-      imapRes.setOption( "Authentication", 0);
+      // The ENUM used for authentication (in the imap resource only)
+      // is KIMAP::LoginJob::AuthenticationMode
+      imapRes.setOption( "Safety", "SSL"); // SSL/TLS
+      imapRes.setOption( "Authentication", 0); // ClearText
       imapRes.setOption( "ImapPort", 993 );
-    } else if ( arg == "tls" ) {
-      imapRes.setOption( "Safety", 1);
-      imapRes.setOption( "Authentication", 0);
+    } else if ( arg == "tls" ) { // tls is really STARTTLS
+      imapRes.setOption( "Safety", "STARTTLS");  // STARTTLS
+      imapRes.setOption( "Authentication", 0); // ClearText
       imapRes.setOption( "ImapPort", 143 );
     }
     stage = 2;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic