Index: trunk/README.OS2
===================================================================
--- trunk/README.OS2	(revision 787)
+++ trunk/README.OS2	(revision 788)
@@ -69,4 +69,16 @@
 
       http://web.os2power.com/download/lib/pthread-20100217-os2.zip
+
+  - OpenSSL 0.9.8o or later to support OpenSSL in Qt. The OpenSSL libraries are
+    available at:
+
+      http://rpm.netlabs.org/experimental/00/i386/i386/openssl-devel-1.0.0a-1.i386.rpm
+      http://rpm.netlabs.org/experimental/00/i386/i386/openssl-1.0.0a-1.i386.rpm
+
+      or
+
+      http://bauxite.sakura.ne.jp/tmp/os2/openssl-1.0.0a-os2knix-20100706-dev.zip
+      http://bauxite.sakura.ne.jp/tmp/os2/openssl-1.0.0a-os2knix-20100706-runtime.zip
+
 
 
@@ -93,5 +105,5 @@
 for applications based on qmake project files which most of them are). If you
 go that way, you may skip the rest of this section and proceed directly to
-section called "USING OFFICIAL BINARY QT ARCHIVES" or further. 
+section "USING OFFICIAL BINARY QT ARCHIVES" below.
 
 If you use the full source code ZIP distribution of the Qt library or work
@@ -156,4 +168,16 @@
     You will also need to make sure that pthread.lib is placed somewhere in your
     system library path so that the compiler can find it.
+
+  - Unzip the OpenSSL libraries to some directory and set the following
+    environment variables to tell the Qt configure script its location:
+
+      set OPENSSL_INCLUDEPATH=X:\<path_to_OpenSSL>\include
+      set OPENSSL_LIBS=
+
+    Note that you will also need to place OpenSSL DLLs to BEGINLIBPATH (if they
+    are not already in your LIBPATH) so that Qt applications can find them at
+    runtime:
+
+      set BEGINLIBPATH=X:\<path_to_OpenSSL>\dll;%BEGINLIBPATH%
 
 
Index: trunk/configure.cmd
===================================================================
--- trunk/configure.cmd	(revision 787)
+++ trunk/configure.cmd	(revision 788)
@@ -288,5 +288,4 @@
     G.CFG_QGTKSTYLE = "auto"
     G.CFG_OPENSSL = "auto"
-    G.CFG_OPENSSL_LIBS = ""
     G.CFG_DBUS = "auto"
     G.CFG_LARGEFILE = "auto"
@@ -599,5 +598,4 @@
 
     /* detect the CUPS support */
-
     G.CUPS_INCLUDEPATH = GetEnv('CUPS_INCLUDEPATH')
     G.CUPS_LIBS = GetEnv('CUPS_LIBS')
@@ -618,11 +616,15 @@
         drop G.CUPS.
     end
-    if (G.CUPS_LIBS \== '')  then do
+    if (G.CUPS_INCLUDEPATH \== '' & G.CUPS_LIBS \== '') then do
         call SayVerbose 'CUPS include path : 'G.CUPS_INCLUDEPATH
         call SayVerbose 'CUPS libraries    : 'G.CUPS_LIBS
+        call SayVerbose
         G.CFG_CUPS = 'yes'
     end
     else do
-        call SayVerbose 'CUPS libraries are not specified, CUPS support is disabled.'
+        call SayVerbose 'WARNING: CUPS libraries are not specified, CUPS support is disabled.'
+        call SayVerbose 'Use CUPS_INCLUDEPATH and CUPS_LIBS environment variables to specify'
+        call SayVerbose 'the location of the libraries.'
+        call SayVerbose
         G.CFG_CUPS = 'no'
     end
@@ -632,5 +634,23 @@
         call SayLog 'WARNING: Printing support is completely disabled due to',
                     'disabled CUPS support.'
+        call SayLog
         G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_PRINTER")
+    end
+
+    /* detect OpenSSL libraries */
+    G.OPENSSL_INCLUDEPATH = GetEnv('OPENSSL_INCLUDEPATH')
+    G.OPENSSL_LIBS = GetEnv('OPENSSL_LIBS')
+    if (G.OPENSSL_INCLUDEPATH \== '')  then do
+        call SayVerbose 'OpenSSL include path : 'G.OPENSSL_INCLUDEPATH
+        call SayVerbose 'OpenSSL libraries    : 'G.OPENSSL_LIBS
+        call SayVerbose
+        G.CFG_OPENSSL = 'yes'
+    end
+    else do
+        call SayVerbose 'WARNING: OpenSSL libraries are not specified, OpenSSL support is disabled.'
+        call SayVerbose 'Use OPENSSL_INCLUDEPATH and OPENSSL_LIBS environment variables to specify'
+        call SayVerbose 'the location of the libraries.'
+        call SayVerbose
+        G.CFG_OPENSSL = 'no'
     end
 
@@ -651,5 +671,4 @@
     G.CFG_NIS = "no"
     G.CFG_DBUS = "no"
-    G.CFG_OPENSSL = "no"
     G.CFG_QGTKSTYLE = "no"
     G.CFG_LARGEFILE = "no"
@@ -1166,15 +1185,15 @@
     if (G.CFG_GSTREAMER == "yes") then
         G.QT_CONFIG = Join(G.QT_CONFIG, "gstreamer")
-    if (G.CFG_DBUS == "linked") then
-        G.QT_CONFIG = Join(G.QT_CONFIG dbus, "dbus-linked")
     if (G.CFG_NAS == "system") then
         G.QT_CONFIG = Join(G.QT_CONFIG, "nas")
-    if (G.CFG_OPENSSL == "linked") then
-        G.QT_CONFIG = Join(G.QT_CONFIG, "openssl-linked")
 */
     if (G.CFG_OPENSSL == "yes") then
         G.QT_CONFIG = Join(G.QT_CONFIG, "openssl")
+    if (G.CFG_OPENSSL == "linked") then
+        G.QT_CONFIG = Join(G.QT_CONFIG, "openssl-linked")
     if (G.CFG_DBUS == "yes") then
         G.QT_CONFIG = Join(G.QT_CONFIG, "dbus")
+    if (G.CFG_DBUS == "linked") then
+        G.QT_CONFIG = Join(G.QT_CONFIG, "dbus dbus-linked")
 
     if (G.D_FLAGS \== "") then
@@ -1461,4 +1480,6 @@
     if (G.CFG_OPENSSL \== "yes") then
         G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_OPENSSL")
+    if (G.CFG_OPENSSL == "linked") then
+        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_LINKED_OPENSSL")
     if (G.CFG_DBUS \== "yes") then
         G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_DBUS")
@@ -1496,6 +1517,4 @@
     if (G.CFG_NAS == "no") then
         G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_NO_NAS")
-    if (G.CFG_OPENSSL == "linked") then
-        G.QCONFIG_FLAGS = Join(G.QCONFIG_FLAGS, "QT_LINKED_OPENSSL")
 */
 
@@ -1734,11 +1753,4 @@
         call charout qmake_cache_new, 'DEFINES *= QT_EDITION=QT_EDITION_DESKTOP'
 
-    /* dump in the OPENSSL_LIBS info */
-    OPENSSL_LIBS = GetEnv("OPENSSL_LIBS")
-    if (OPENSSL_LIBS \== "") then
-        call lineout qmake_cache_new, 'OPENSSL_LIBS = 'OPENSSL_LIBS
-    else if (G.CFG_OPENSSL == "linked") then
-        call lineout qmake_cache_new, 'OPENSSL_LIBS = -lssl -lcrypto'
-
     /* dump CUPS_INCLUDEPATH and friends */
     if (G.CFG_CUPS == "yes") then do
@@ -1747,4 +1759,12 @@
         if (G.CUPS_LIBS \== "") then
             call lineout qmake_cache_new, 'CUPS_LIBS = 'G.CUPS_LIBS
+    end
+
+    /* dump in the OPENSSL_LIBS info */
+    if (G.CFG_OPENSSL == "yes") then do
+        if (G.OPENSSL_INCLUDEPATH \== "") then
+            call lineout qmake_cache_new, 'OPENSSL_INCLUDEPATH = 'G.OPENSSL_INCLUDEPATH
+        if (G.OPENSSL_LIBS \== "") then
+            call lineout qmake_cache_new, 'OPENSSL_LIBS = 'G.OPENSSL_LIBS
     end
 
@@ -1934,11 +1954,11 @@
 "or compile needed modules into the library."G.EOL||,
 G.EOL
-    if (G.CFG_OPENSSL == "linked" &  OPENSSL_LIBS == "") then
+
+    if (G.CFG_OPENSSL == "linked" & G.OPENSSL_LIBS == "") then
         call SayLog,,
 G.EOL||,
-"NOTE: When linking against OpenSSL, you can override the default"G.EOL||,
-"library names through OPENSSL_LIBS."G.EOL||,
-"For example:"G.EOL||,
-"    configure -openssl-linked OPENSSL_LIBS='-L/path/to/lib -lssl -lcrypto'"G.EOL||,
+"WARNING: You are linking against OpenSSL but didn't specify the OpenSSL library"G.EOL||,
+"names, so the build will most likely fail. You may fix this by setting the"G.EOL||,
+"OPENSSL_LIBS environment variable."G.EOL||,
 G.EOL
 
Index: trunk/src/network/ssl/qsslsocket_openssl.cpp
===================================================================
--- trunk/src/network/ssl/qsslsocket_openssl.cpp	(revision 787)
+++ trunk/src/network/ssl/qsslsocket_openssl.cpp	(revision 788)
@@ -188,5 +188,5 @@
         else if (protoString == QLatin1String("TLSv1"))
             ciph.d->protocol = QSsl::TlsV1;
-        
+
         if (descriptionList.at(2).startsWith(QLatin1String("Kx=")))
             ciph.d->keyExchangeMethod = descriptionList.at(2).mid(3);
@@ -341,5 +341,5 @@
     if (configuration.peerVerifyDepth != 0)
         q_SSL_CTX_set_verify_depth(ctx, configuration.peerVerifyDepth);
-    
+
     // Create and initialize SSL session
     if (!(ssl = q_SSL_new(ctx))) {
@@ -425,5 +425,5 @@
             do {
                 if (attempts < 500) {
-#ifdef Q_OS_UNIX
+#if defined(Q_OS_UNIX) || defined(Q_OS_OS2)
                     struct timespec ts = {0, 33333333};
                     nanosleep(&ts, 0);
@@ -534,5 +534,5 @@
     do {
         transmitting = false;
-        
+
         // If the connection is secure, we can transfer data from the write
         // buffer (in plain text) to the write BIO through SSL_write.
Index: trunk/src/network/ssl/qsslsocket_openssl_symbols.cpp
===================================================================
--- trunk/src/network/ssl/qsslsocket_openssl_symbols.cpp	(revision 787)
+++ trunk/src/network/ssl/qsslsocket_openssl_symbols.cpp	(revision 788)
@@ -262,4 +262,9 @@
     if (!(_q_##func = _q_PTR_##func(lib->resolve(#ordinal)))) \
         qWarning("QSslSocket: cannot resolve "#func);
+#elif defined(Q_OS_OS2)
+#define RESOLVEFUNC(func) \
+    if (!(_q_##func = _q_PTR_##func(libs.first->resolve("_"#func)))     \
+        && !(_q_##func = _q_PTR_##func(libs.second->resolve("_"#func)))) \
+        qWarning("QSslSocket: cannot resolve "#func);
 #else
 #define RESOLVEFUNC(func) \
@@ -462,5 +467,38 @@
     libssl = libcrypto = 0;
     return pair;
-
+# elif defined(Q_OS_OS2)
+    // note: the k* versions of libraries were in use once; support them for
+    // backward compatibility
+    static const char *ssl_dll[] = { "ssl10", "kssl10" };
+    static const char *crypto_dll[] = { "crypto10", "kcrypt10" };
+
+    QLibrary *libssl;
+    for (size_t i = 0; i < sizeof(ssl_dll)/sizeof(ssl_dll[0]); ++i) {
+        libssl = new QLibrary(QLatin1String(ssl_dll[i]));
+        if (libssl->load())
+            break;
+        delete libssl;
+        libssl = 0;
+    }
+    if (!libssl) {
+        return pair;
+    }
+
+    QLibrary *libcrypto;
+    for (size_t i = 0; i < sizeof(crypto_dll)/sizeof(crypto_dll[0]); ++i) {
+        libcrypto = new QLibrary(QLatin1String(crypto_dll[i]));
+        if (libcrypto->load())
+            break;
+        delete libcrypto;
+        libcrypto = 0;
+    }
+    if (!libcrypto) {
+        delete libssl;
+        return pair;
+    }
+
+    pair.first = libssl;
+    pair.second = libcrypto;
+    return pair;
 # else
     // not implemented for this platform yet
@@ -535,5 +573,5 @@
     RESOLVEFUNC(sk_free, 2571, libs.second )
     RESOLVEFUNC(sk_num, 2576, libs.second )
-    RESOLVEFUNC(sk_pop_free, 2578, libs.second )    
+    RESOLVEFUNC(sk_pop_free, 2578, libs.second )
     RESOLVEFUNC(sk_value, 2585, libs.second )
     RESOLVEFUNC(SSL_CIPHER_description, 11, libs.first )
Index: trunk/src/network/ssl/ssl.pri
===================================================================
--- trunk/src/network/ssl/ssl.pri	(revision 787)
+++ trunk/src/network/ssl/ssl.pri	(revision 788)
@@ -37,3 +37,8 @@
     # Add optional SSL libs
     LIBS_PRIVATE += $$OPENSSL_LIBS
+    
+    os2 {
+        # Add SSL include path
+        INCLUDEPATH *= $$OPENSSL_INCLUDEPATH
+    }
 }
