OSDN Git Service

win and mac leftovers removal from network component mostly
authorIvailo Monev <xakepa10@laimg.moc>
Fri, 16 Sep 2016 00:16:22 +0000 (00:16 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Fri, 16 Sep 2016 00:16:22 +0000 (00:16 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
18 files changed:
src/core/global/qglobal.cpp
src/core/io/qsettings.cpp
src/core/io/qtemporaryfile.cpp
src/network/access/qnetworkaccessfilebackend.cpp
src/network/access/qnetworkdiskcache.cpp
src/network/access/qnetworkreplyfileimpl.cpp
src/network/bearer/qnetworkconfiguration.h
src/network/bearer/qnetworksession.h
src/network/kernel/qhostaddress.cpp
src/network/kernel/qnetworkinterface.cpp
src/network/socket/qabstractsocket.cpp
src/network/socket/qnativesocketengine.cpp
src/network/socket/qnativesocketengine_p.h
src/network/socket/qsocks5socketengine.cpp
src/network/socket/qudpsocket.cpp
src/network/ssl/qsslsocket_openssl.cpp
src/network/ssl/qsslsocket_openssl_p.h
src/network/ssl/qsslsocket_p.h

index 7fab74e..f926b2f 100644 (file)
@@ -1446,235 +1446,6 @@ bool qSharedBuild()
  */
 
 
-#if !defined(QWS) && defined(Q_OS_MAC)
-
-QT_BEGIN_INCLUDE_NAMESPACE
-#include "qcore_mac_p.h"
-#include "qnamespace.h"
-QT_END_INCLUDE_NAMESPACE
-
-static QSysInfo::MacVersion macVersion()
-{
-#if !defined(Q_OS_IOS)
-    SInt32 gestalt_version;
-    if (Gestalt(gestaltSystemVersionMinor, &gestalt_version) == noErr) {
-        // add 2 because OS X 10.0 is 0x02 in the enum
-        return QSysInfo::MacVersion(gestalt_version + 2);
-    }
-#endif
-    return QSysInfo::MV_Unknown;
-}
-const QSysInfo::MacVersion QSysInfo::MacintoshVersion = macVersion();
-
-#elif defined(Q_OS_WIN32) || defined(Q_OS_CYGWIN) || defined(Q_OS_WINCE)
-
-QT_BEGIN_INCLUDE_NAMESPACE
-#include "qt_windows.h"
-QT_END_INCLUDE_NAMESPACE
-
-#  ifndef Q_OS_WINCE
-
-// Determine Windows versions >= 8 by querying the version of kernel32.dll.
-static inline bool determineWinOsVersionPost8(OSVERSIONINFO *result)
-{
-    typedef WORD (WINAPI* PtrGetFileVersionInfoSizeW)(LPCWSTR, LPDWORD);
-    typedef BOOL (WINAPI* PtrVerQueryValueW)(LPCVOID, LPCWSTR, LPVOID, PUINT);
-    typedef BOOL (WINAPI* PtrGetFileVersionInfoW)(LPCWSTR, DWORD, DWORD, LPVOID);
-
-    QSystemLibrary versionLib(QLatin1String("version"));
-    if (!versionLib.load())
-        return false;
-    PtrGetFileVersionInfoSizeW getFileVersionInfoSizeW = (PtrGetFileVersionInfoSizeW)versionLib.resolve("GetFileVersionInfoSizeW");
-    PtrVerQueryValueW verQueryValueW = (PtrVerQueryValueW)versionLib.resolve("VerQueryValueW");
-    PtrGetFileVersionInfoW getFileVersionInfoW = (PtrGetFileVersionInfoW)versionLib.resolve("GetFileVersionInfoW");
-    if (!getFileVersionInfoSizeW || !verQueryValueW || !getFileVersionInfoW)
-        return false;
-
-    const wchar_t kernel32Dll[] = L"kernel32.dll";
-    DWORD handle;
-    const DWORD size = getFileVersionInfoSizeW(kernel32Dll, &handle);
-    if (!size)
-        return false;
-    QScopedArrayPointer<BYTE> versionInfo(new BYTE[size]);
-    if (!getFileVersionInfoW(kernel32Dll, handle, size, versionInfo.data()))
-        return false;
-    UINT uLen;
-    VS_FIXEDFILEINFO *fileInfo = 0;
-    if (!verQueryValueW(versionInfo.data(), L"\\", (LPVOID *)&fileInfo, &uLen))
-        return false;
-    const DWORD fileVersionMS = fileInfo->dwFileVersionMS;
-    const DWORD fileVersionLS = fileInfo->dwFileVersionLS;
-    result->dwMajorVersion = HIWORD(fileVersionMS);
-    result->dwMinorVersion = LOWORD(fileVersionMS);
-    result->dwBuildNumber = HIWORD(fileVersionLS);
-    return true;
-}
-
-#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600
-// Fallback for determining Windows versions >= 8 by looping using the
-// version check macros. Note that it will return build number=0 to avoid
-// inefficient looping.
-static inline void determineWinOsVersionFallbackPost8(OSVERSIONINFO *result)
-{
-    result->dwBuildNumber = 0;
-    DWORDLONG conditionMask = 0;
-    VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
-    VER_SET_CONDITION(conditionMask, VER_PLATFORMID, VER_EQUAL);
-    OSVERSIONINFOEX checkVersion = { sizeof(OSVERSIONINFOEX), result->dwMajorVersion, 0,
-                                     result->dwBuildNumber, result->dwPlatformId, {'\0'}, 0, 0, 0, 0, 0 };
-    for ( ; VerifyVersionInfo(&checkVersion, VER_MAJORVERSION | VER_PLATFORMID, conditionMask); ++checkVersion.dwMajorVersion)
-        result->dwMajorVersion = checkVersion.dwMajorVersion;
-    conditionMask = 0;
-    checkVersion.dwMajorVersion = result->dwMajorVersion;
-    checkVersion.dwMinorVersion = 0;
-    VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_EQUAL);
-    VER_SET_CONDITION(conditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
-    VER_SET_CONDITION(conditionMask, VER_PLATFORMID, VER_EQUAL);
-    for ( ; VerifyVersionInfo(&checkVersion, VER_MAJORVERSION | VER_MINORVERSION | VER_PLATFORMID, conditionMask); ++checkVersion.dwMinorVersion)
-        result->dwMinorVersion = checkVersion.dwMinorVersion;
-}
-
-#endif // defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600
-#  endif // !Q_OS_WINCE
-
-static inline OSVERSIONINFO winOsVersion()
-{
-    OSVERSIONINFO result = { sizeof(OSVERSIONINFO), 0, 0, 0, 0, {'\0'}};
-    // GetVersionEx() has been deprecated in Windows 8.1 and will return
-    // only Windows 8 from that version on.
-#  if defined(_MSC_VER) && _MSC_VER >= 1800
-#    pragma warning( push )
-#    pragma warning( disable : 4996 )
-#  endif
-    GetVersionEx(&result);
-#  if defined(_MSC_VER) && _MSC_VER >= 1800
-#    pragma warning( pop )
-#  endif
-#  ifndef Q_OS_WINCE
-    if (result.dwMajorVersion == 6 && result.dwMinorVersion == 2) {
-               if (!determineWinOsVersionPost8(&result)) {
-#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600
-            determineWinOsVersionFallbackPost8(&result);
-#endif
-        }
-    }
-#  endif // !Q_OS_WINCE
-    return result;
-}
-
-QSysInfo::WinVersion QSysInfo::windowsVersion()
-{
-#ifndef VER_PLATFORM_WIN32s
-#define VER_PLATFORM_WIN32s            0
-#endif
-#ifndef VER_PLATFORM_WIN32_WINDOWS
-#define VER_PLATFORM_WIN32_WINDOWS  1
-#endif
-#ifndef VER_PLATFORM_WIN32_NT
-#define VER_PLATFORM_WIN32_NT            2
-#endif
-#ifndef VER_PLATFORM_WIN32_CE
-#define VER_PLATFORM_WIN32_CE            3
-#endif
-
-    static QSysInfo::WinVersion winver;
-    if (winver)
-        return winver;
-    winver = QSysInfo::WV_NT;
-    const OSVERSIONINFO osver = winOsVersion();
-#ifdef Q_OS_WINCE
-    DWORD qt_cever = 0;
-    qt_cever = osver.dwMajorVersion * 100;
-    qt_cever += osver.dwMinorVersion * 10;
-#endif
-    switch (osver.dwPlatformId) {
-    case VER_PLATFORM_WIN32s:
-        winver = QSysInfo::WV_32s;
-        break;
-    case VER_PLATFORM_WIN32_WINDOWS:
-        // We treat Windows Me (minor 90) the same as Windows 98
-        if (osver.dwMinorVersion == 90)
-            winver = QSysInfo::WV_Me;
-        else if (osver.dwMinorVersion == 10)
-            winver = QSysInfo::WV_98;
-        else
-            winver = QSysInfo::WV_95;
-        break;
-#ifdef Q_OS_WINCE
-    case VER_PLATFORM_WIN32_CE:
-        if (qt_cever >= 600)
-            winver = QSysInfo::WV_CE_6;
-        if (qt_cever >= 500)
-            winver = QSysInfo::WV_CE_5;
-        else if (qt_cever >= 400)
-            winver = QSysInfo::WV_CENET;
-        else
-            winver = QSysInfo::WV_CE;
-        break;
-#endif
-    default: // VER_PLATFORM_WIN32_NT
-        if (osver.dwMajorVersion < 5) {
-            winver = QSysInfo::WV_NT;
-        } else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 0) {
-            winver = QSysInfo::WV_2000;
-        } else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 1) {
-            winver = QSysInfo::WV_XP;
-        } else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 2) {
-            winver = QSysInfo::WV_2003;
-        } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 0) {
-            winver = QSysInfo::WV_VISTA;
-        } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 1) {
-            winver = QSysInfo::WV_WINDOWS7;
-        } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 2) {
-            winver = QSysInfo::WV_WINDOWS8;
-        } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 3) {
-            winver = QSysInfo::WV_WINDOWS8_1;
-        } else if (osver.dwMajorVersion == 10 && osver.dwMinorVersion == 0) {
-            winver = QSysInfo::WV_WINDOWS10;
-        } else {
-            qWarning("Qt: Untested Windows version %d.%d detected!",
-                     int(osver.dwMajorVersion), int(osver.dwMinorVersion));
-            winver = QSysInfo::WV_NT_based;
-        }
-    }
-
-#ifdef QT_DEBUG
-    {
-        QByteArray winver_override = qgetenv("QT_WINVER_OVERRIDE");
-        if (winver_override.isEmpty())
-            return winver;
-
-        if (winver_override == "Me")
-            winver = QSysInfo::WV_Me;
-        if (winver_override == "95")
-            winver = QSysInfo::WV_95;
-        else if (winver_override == "98")
-            winver = QSysInfo::WV_98;
-        else if (winver_override == "NT")
-            winver = QSysInfo::WV_NT;
-        else if (winver_override == "2000")
-            winver = QSysInfo::WV_2000;
-        else if (winver_override == "2003")
-            winver = QSysInfo::WV_2003;
-        else if (winver_override == "XP")
-            winver = QSysInfo::WV_XP;
-        else if (winver_override == "VISTA")
-            winver = QSysInfo::WV_VISTA;
-        else if (winver_override == "WINDOWS7")
-            winver = QSysInfo::WV_WINDOWS7;
-        else if (winver_override == "WINDOWS8")
-            winver = QSysInfo::WV_WINDOWS8;
-    }
-#endif
-
-    return winver;
-}
-
-const QSysInfo::WinVersion QSysInfo::WindowsVersion = QSysInfo::windowsVersion();
-
-#endif
-
-
 /*!
     \macro void Q_ASSERT(bool test)
     \relates <QtGlobal>
@@ -1850,13 +1621,9 @@ QString qt_error_string(int errorCode)
 {
     const char *s = 0;
     QString ret;
-    if (errorCode == -1) {
-#if defined(Q_OS_WIN)
-        errorCode = GetLastError();
-#else
+    if (errorCode == -1)
         errorCode = errno;
-#endif
-    }
+
     switch (errorCode) {
     case 0:
         break;
@@ -1873,21 +1640,7 @@ QString qt_error_string(int errorCode)
         s = QT_TRANSLATE_NOOP("QIODevice", "No space left on device");
         break;
     default: {
-#ifdef Q_OS_WIN
-        wchar_t *string = 0;
-        FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
-                      NULL,
-                      errorCode,
-                      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-                      (LPWSTR)&string,
-                      0,
-                      NULL);
-        ret = QString::fromWCharArray(string);
-        LocalFree((HLOCAL)string);
-
-        if (ret.isEmpty() && errorCode == ERROR_MOD_NOT_FOUND)
-            ret = QString::fromLatin1("The specified module could not be found.");
-#elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX)
+#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L
         QByteArray buf(1024, '\0');
         ret = fromstrerror_helper(strerror_r(errorCode, buf.data(), buf.size()), buf);
 #else
@@ -1936,19 +1689,11 @@ QString qt_error_string(int errorCode)
     \sa qDebug(), qWarning(), qCritical(), qFatal(), QtMsgType,
     {Debugging Techniques}
 */
-#if defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB)
-extern bool usingWinMain;
-extern Q_CORE_EXPORT void qWinMsgHandler(QtMsgType t, const char* str);
-#endif
 
 QtMsgHandler qInstallMsgHandler(QtMsgHandler h)
 {
     QtMsgHandler old = handler;
     handler = h;
-#if defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB)
-    if (!handler && usingWinMain)
-        handler = qWinMsgHandler;
-#endif
     return old;
 }
 
@@ -1960,28 +1705,12 @@ void qt_message_output(QtMsgType msgType, const char *buf)
     if (handler) {
         (*handler)(msgType, buf);
     } else {
-#if defined(Q_CC_MWERKS) && defined(Q_OS_MACX)
-        mac_default_handler(buf);
-#elif defined(Q_OS_WINCE)
-        QString fstr = QString::fromLatin1(buf);
-        fstr += QLatin1Char('\n');
-        OutputDebugString(reinterpret_cast<const wchar_t *> (fstr.utf16()));
-#else
         fprintf(stderr, "%s\n", buf);
         fflush(stderr);
-#endif
     }
 
-    if (msgType == QtFatalMsg
-        || (msgType == QtWarningMsg
-            && (!qgetenv("QT_FATAL_WARNINGS").isNull())) ) {
-
-#if   (defined(Q_OS_UNIX) || defined(Q_CC_MINGW))
+    if (msgType == QtFatalMsg || (msgType == QtWarningMsg && (!qgetenv("QT_FATAL_WARNINGS").isNull())))
         abort(); // trap; generates core dump
-#else
-        exit(1); // goodbye cruel world
-#endif
-    }
 }
 
 #if !defined(QT_NO_EXCEPTIONS)
index 31b4c9a..0aef444 100644 (file)
@@ -120,7 +120,6 @@ Q_GLOBAL_STATIC(CustomFormatVector, customFormatVectorFunc)
 Q_GLOBAL_STATIC(QMutex, globalMutex)
 static QSettings::Format globalDefaultFormat = QSettings::NativeFormat;
 
-#ifndef Q_OS_WIN
 inline bool qt_isEvilFsTypeName(const char *name)
 {
     return (qstrncmp(name, "nfs", 3) == 0
@@ -213,7 +212,6 @@ static bool unixLock(int handle, int lockType)
     fl.l_type = lockType;
     return fcntl(handle, F_SETLKW, &fl) == 0;
 }
-#endif
 
 QConfFile::QConfFile(const QString &fileName, bool _userPerms)
     : name(fileName), size(0), ref(1), userPerms(_userPerms)
@@ -983,11 +981,7 @@ void QConfFileSettingsPrivate::initFormat()
     extension = (format == QSettings::NativeFormat) ? QLatin1String(".conf") : QLatin1String(".ini");
     readFunc = 0;
     writeFunc = 0;
-#if defined(Q_OS_MAC)
-    caseSensitivity = (format == QSettings::NativeFormat) ? Qt::CaseSensitive : IniCaseSensitivity;
-#else
     caseSensitivity = IniCaseSensitivity;
-#endif
 
     if (format > QSettings::IniFormat) {
         QMutexLocker locker(globalMutex());
@@ -1028,7 +1022,7 @@ static void initDefaultPaths(QMutexLocker *locker)
     QString systemPath;
 
     locker->unlock();
-       
+
     /*
        QLibraryInfo::location() uses QSettings, so in order to
        avoid a dead-lock, we can't hold the global mutex while
@@ -1436,37 +1430,30 @@ void QConfFileSettingsPrivate::syncConfFile(int confFileNo)
         ParsedSettingsMap mergedKeys = confFile->mergedKeyMap();
 
         if (file.isWritable()) {
-#ifdef Q_OS_MAC
-            if (format == QSettings::NativeFormat) {
-                ok = writePlistFile(confFile->name, mergedKeys);
-            } else
-#endif
-            {
-                file.seek(0);
-                file.resize(0);
-
-                if (format <= QSettings::IniFormat) {
-                    ok = writeIniFile(file, mergedKeys);
-                    if (!ok) {
-                        // try to restore old data; might work if the disk was full and the new data
-                        // was larger than the old data
-                        file.seek(0);
-                        file.resize(0);
-                        writeIniFile(file, confFile->originalKeys);
-                    }
-                } else {
-                    if (writeFunc) {
-                        QSettings::SettingsMap tempOriginalKeys;
+            file.seek(0);
+            file.resize(0);
 
-                        ParsedSettingsMap::const_iterator i = mergedKeys.constBegin();
-                        while (i != mergedKeys.constEnd()) {
-                            tempOriginalKeys.insert(i.key(), i.value());
-                            ++i;
-                        }
-                        ok = writeFunc(file, tempOriginalKeys);
-                    } else {
-                        ok = false;
+            if (format <= QSettings::IniFormat) {
+                ok = writeIniFile(file, mergedKeys);
+                if (!ok) {
+                    // try to restore old data; might work if the disk was full and the new data
+                    // was larger than the old data
+                    file.seek(0);
+                    file.resize(0);
+                    writeIniFile(file, confFile->originalKeys);
+                }
+            } else {
+                if (writeFunc) {
+                    QSettings::SettingsMap tempOriginalKeys;
+
+                    ParsedSettingsMap::const_iterator i = mergedKeys.constBegin();
+                    while (i != mergedKeys.constEnd()) {
+                        tempOriginalKeys.insert(i.key(), i.value());
+                        ++i;
                     }
+                    ok = writeFunc(file, tempOriginalKeys);
+                } else {
+                    ok = false;
                 }
             }
         } else {
@@ -2149,30 +2136,6 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
     \o \c{/etc/xdg/MySoft.conf}
     \endlist
 
-    On Mac OS X versions 10.2 and 10.3, these files are used by
-    default:
-
-    \list 1
-    \o \c{$HOME/Library/Preferences/com.MySoft.Star Runner.plist}
-    \o \c{$HOME/Library/Preferences/com.MySoft.plist}
-    \o \c{/Library/Preferences/com.MySoft.Star Runner.plist}
-    \o \c{/Library/Preferences/com.MySoft.plist}
-    \endlist
-
-    On Windows, NativeFormat settings are stored in the following
-    registry paths:
-
-    \list 1
-    \o \c{HKEY_CURRENT_USER\Software\MySoft\Star Runner}
-    \o \c{HKEY_CURRENT_USER\Software\MySoft}
-    \o \c{HKEY_LOCAL_MACHINE\Software\MySoft\Star Runner}
-    \o \c{HKEY_LOCAL_MACHINE\Software\MySoft}
-    \endlist
-
-    \note On Windows, for 32-bit programs running in WOW64 mode, settings are
-    stored in the following registry path:
-    \c{HKEY_LOCAL_MACHINE\Software\WOW6432node}.
-
     If the file format is IniFormat, the following files are
     used on Unix:
 
@@ -2192,9 +2155,8 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
     environments.
 
     The paths for the \c .ini and \c .conf files can be changed using
-    setPath(). On Unix and Mac OS X, the user can override them by
-    setting the \c XDG_CONFIG_HOME environment variable; see
-    setPath() for details.
+    setPath(). On Unix, the user can override them by setting the
+    \c XDG_CONFIG_HOME environment variable; see setPath() for details.
 
     \section2 Accessing INI and .plist Files Directly
 
@@ -2209,92 +2171,6 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
     You can then use the QSettings object to read and write settings
     in the file.
 
-    On Mac OS X, you can access XML-based \c .plist files by passing
-    QSettings::NativeFormat as second argument. For example:
-
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 3
-
-    \section2 Accessing the Windows Registry Directly
-
-    On Windows, QSettings lets you access settings that have been
-    written with QSettings (or settings in a supported format, e.g., string
-    data) in the system registry. This is done by constructing a QSettings
-    object with a path in the registry and QSettings::NativeFormat.
-
-    For example:
-
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 4
-
-    All the registry entries that appear under the specified path can
-    be read or written through the QSettings object as usual (using
-    forward slashes instead of backslashes). For example:
-
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 5
-
-    Note that the backslash character is, as mentioned, used by
-    QSettings to separate subkeys. As a result, you cannot read or
-    write windows registry entries that contain slashes or
-    backslashes; you should use a native windows API if you need to do
-    so.
-
-    \section2 Accessing Common Registry Settings on Windows
-
-    On Windows, it is possible for a key to have both a value and subkeys.
-    Its default value is accessed by using "Default" or "." in
-    place of a subkey:
-
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 6
-
-    On other platforms than Windows, "Default" and "." would be
-    treated as regular subkeys.
-
-    \section2 Securing application settings in Symbian
-
-    UserScope settings in Symbian are writable by any application by
-    default. To protect the application settings from access and tampering
-    by other applications, the settings need to be placed in the private
-    secure area of the application. This can be done by specifying the
-    settings storage path directly to the private area. The following
-    snippet changes the UserScope to \c{c:/private/ecb00931/MySoft.conf}
-    (provided the application is installed on the \c{c-drive} and its
-    Secure ID is \c{0xECB00931}:
-
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 30
-
-    Framework libraries (like Qt itself) may store configuration and cache
-    settings using UserScope, which is accessible and writable by other
-    applications. If the application is very security sensitive or uses
-    high platform security capabilities, it may be prudent to also force
-    framework settings to be stored in the private directory of the
-    application. This can be done by changing the default path of UserScope
-    before QApplication is created:
-
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 31
-
-    Note that this may affect framework libraries' functionality if they expect
-    the settings to be shared between applications.
-
-    \section2 Changing the location of global Qt settings on Mac OS X
-
-    On Mac OS X, the global Qt settings (stored in \c com.trolltech.plist)
-    are stored in the application settings file in two situations:
-
-    \list 1
-    \o If the application runs in a Mac OS X sandbox (on Mac OS X 10.7 or later) or
-    \o If the \c Info.plist file of the application contains the key \c "ForAppStore" with the value \c "yes"
-    \endlist
-
-    In these situations, the application settings file is named using
-    the bundle identifier of the application, which must consequently
-    be set in the application's \c Info.plist file.
-
-    This feature is provided to ease the acceptance of Qt applications into
-    the Mac App Store, as the default behaviour of storing global Qt
-    settings in the \c com.trolltech.plist file does not conform with Mac
-    App Store file system usage requirements. For more information
-    about submitting Qt applications to the Mac App Store, see
-    \l{mac-differences.html#Preparing a Qt application for Mac App Store submission}{Preparing a Qt application for Mac App Store submission}.
-
     \section2 Platform Limitations
 
     While QSettings attempts to smooth over the differences between
@@ -2303,36 +2179,6 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
     application:
 
     \list
-    \o  The Windows system registry has the following limitations: A
-        subkey may not exceed 255 characters, an entry's value may
-        not exceed 16,383 characters, and all the values of a key may
-        not exceed 65,535 characters. One way to work around these
-        limitations is to store the settings using the IniFormat
-        instead of the NativeFormat.
-
-    \o  On Mac OS X, allKeys() will return some extra keys for global
-        settings that apply to all applications. These keys can be
-        read using value() but cannot be changed, only shadowed.
-        Calling setFallbacksEnabled(false) will hide these global
-        settings.
-
-    \o  On Mac OS X, the CFPreferences API used by QSettings expects
-        Internet domain names rather than organization names. To
-        provide a uniform API, QSettings derives a fake domain name
-        from the organization name (unless the organization name
-        already is a domain name, e.g. OpenOffice.org). The algorithm
-        appends ".com" to the company name and replaces spaces and
-        other illegal characters with hyphens. If you want to specify
-        a different domain name, call
-        QCoreApplication::setOrganizationDomain(),
-        QCoreApplication::setOrganizationName(), and
-        QCoreApplication::setApplicationName() in your \c main()
-        function and then use the default QSettings constructor.
-        Another solution is to use preprocessor directives, for
-        example:
-
-        \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 7
-
     \o On Unix systems, the advisory file locking is disabled if NFS (or AutoFS
        or CacheFS) is detected to work around a bug in the NFS fcntl()
        implementation, which hangs forever if statd or lockd aren't running.
@@ -2578,10 +2424,6 @@ QSettings::QSettings(const QString &fileName, Format format, QObject *parent)
     called, the QSettings object will not be able to read or write
     any settings, and status() will return AccessError.
 
-    On Mac OS X, if both a name and an Internet domain are specified
-    for the organization, the domain is preferred over the name. On
-    other platforms, the name is preferred over the domain.
-
     \sa QCoreApplication::setOrganizationName(),
         QCoreApplication::setOrganizationDomain(),
         QCoreApplication::setApplicationName(),
@@ -2589,15 +2431,9 @@ QSettings::QSettings(const QString &fileName, Format format, QObject *parent)
 */
 QSettings::QSettings(QObject *parent)
     : QObject(*QSettingsPrivate::create(globalDefaultFormat, UserScope,
-#ifdef Q_OS_MAC
-                                        QCoreApplication::organizationDomain().isEmpty()
-                                            ? QCoreApplication::organizationName()
-                                            : QCoreApplication::organizationDomain()
-#else
                                         QCoreApplication::organizationName().isEmpty()
                                             ? QCoreApplication::organizationDomain()
                                             : QCoreApplication::organizationName()
-#endif
                                         , QCoreApplication::applicationName()),
               parent)
 {
@@ -3093,11 +2929,6 @@ bool QSettings::isWritable() const
   Sets the value of setting \a key to \a value. If the \a key already
   exists, the previous value is overwritten.
 
-  Note that the Windows registry and INI files use case-insensitive
-  keys, whereas the Carbon Preferences API on Mac OS X uses
-  case-sensitive keys. To avoid portability problems, see the
-  \l{Section and Key Syntax} rules.
-
   Example:
 
   \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 23
@@ -3128,11 +2959,6 @@ void QSettings::setValue(const QString &key, const QVariant &value)
 
     \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 25
 
-    Note that the Windows registry and INI files use case-insensitive
-    keys, whereas the Carbon Preferences API on Mac OS X uses
-    case-sensitive keys. To avoid portability problems, see the
-    \l{Section and Key Syntax} rules.
-
     \sa setValue(), value(), contains()
 */
 void QSettings::remove(const QString &key)
@@ -3163,11 +2989,6 @@ void QSettings::remove(const QString &key)
     If a group is set using beginGroup(), \a key is taken to be
     relative to that group.
 
-    Note that the Windows registry and INI files use case-insensitive
-    keys, whereas the Carbon Preferences API on Mac OS X uses
-    case-sensitive keys. To avoid portability problems, see the
-    \l{Section and Key Syntax} rules.
-
     \sa value(), setValue()
 */
 bool QSettings::contains(const QString &key) const
@@ -3225,11 +3046,6 @@ bool QSettings::event(QEvent *event)
     If no default value is specified, a default QVariant is
     returned.
 
-    Note that the Windows registry and INI files use case-insensitive
-    keys, whereas the Carbon Preferences API on Mac OS X uses
-    case-sensitive keys. To avoid portability problems, see the
-    \l{Section and Key Syntax} rules.
-
     Example:
 
     \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 26
@@ -3315,16 +3131,8 @@ void QSettings::setUserIniPath(const QString &dir)
 
     \table
     \header \o Platform         \o Format                       \o Scope       \o Path
-    \row    \o{1,2} Windows     \o{1,2} IniFormat               \o UserScope   \o \c %APPDATA%
-    \row                                                        \o SystemScope \o \c %COMMON_APPDATA%
     \row    \o{1,2} Unix        \o{1,2} NativeFormat, IniFormat \o UserScope   \o \c $HOME/.config
     \row                                                        \o SystemScope \o \c /etc/xdg
-    \row    \o{1,2} Qt for Embedded Linux \o{1,2} NativeFormat, IniFormat \o UserScope   \o \c $HOME/Settings
-    \row                                                        \o SystemScope \o \c /etc/xdg
-    \row    \o{1,2} Mac OS X    \o{1,2} IniFormat               \o UserScope   \o \c $HOME/.config
-    \row                                                        \o SystemScope \o \c /etc/xdg
-    \row    \o{1,2} Symbian     \o{1,2} NativeFormat, IniFormat \o UserScope   \o \c c:/data/.config
-    \row                                                        \o SystemScope \o \c <drive>/private/<uid>
     \endtable
 
     The default UserScope paths on Unix and Mac OS X (\c
index 94943f3..1ed189b 100644 (file)
 #include "qfsfileengine_p.h"
 #include "qsystemerror_p.h"
 #include "qfilesystemengine_p.h"
-
-
-#if !defined(Q_OS_WIN)
 #include "qcore_unix_p.h"       // overrides QT_OPEN
+
 #include <errno.h>
-#endif
 
 #if defined(QT_BUILD_CORE_LIB)
 #include "qcoreapplication.h"
 
 QT_BEGIN_NAMESPACE
 
-#if defined(Q_OS_WIN)
-typedef ushort Char;
-
-static inline Char Latin1Char(char ch)
-{
-    return ushort(uchar(ch));
-}
 
-# ifdef Q_OS_WIN
-typedef HANDLE NativeFileHandle;
-# else // Q_OS_SYMBIAN
-#  ifdef  SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
-typedef RFile64 NativeFileHandle;
-#  else
-typedef RFile NativeFileHandle;
-#  endif
-# endif
-
-#else // POSIX
 typedef char Char;
 typedef char Latin1Char;
 typedef int NativeFileHandle;
-#endif
 
 /*
  * Copyright (c) 1987, 1993
@@ -158,73 +136,54 @@ static bool createFileFromTemplate(NativeFileHandle &file,
         }
     }
 
+    // Atomically create file and obtain handle
+    file = QT_OPEN(path.constData(),
+            QT_OPEN_CREAT | O_EXCL | QT_OPEN_RDWR | QT_OPEN_LARGEFILE,
+            0600);
 
-    for (;;) {
-        // Atomically create file and obtain handle
-#if defined(Q_OS_WIN)
-        file = CreateFile((const wchar_t *)path.constData(),
-                GENERIC_READ | GENERIC_WRITE,
-                FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_NEW,
-                FILE_ATTRIBUTE_NORMAL, NULL);
-
-        if (file != INVALID_HANDLE_VALUE)
-            return true;
+    if (file != -1)
+        return true;
 
-        DWORD err = GetLastError();
-        if (err != ERROR_FILE_EXISTS) {
-            error = QSystemError(err, QSystemError::NativeError);
-            return false;
-        }
-#else // POSIX
-        file = QT_OPEN(path.constData(),
-                QT_OPEN_CREAT | O_EXCL | QT_OPEN_RDWR | QT_OPEN_LARGEFILE,
-                0600);
+    int err = errno;
+    if (err != EEXIST) {
+        error = QSystemError(err, QSystemError::NativeError);
+        return false;
+    }
 
-        if (file != -1)
-            return true;
+    /* tricky little algorithm for backward compatibility */
+    for (Char *iter = placeholderStart;;) {
+        // Character progression: [0-9] => 'a' ... 'z' => 'A' .. 'Z'
+        // String progression: "ZZaiC" => "aabiC"
+        switch (char(*iter)) {
+            case 'Z':
+                // Rollover, advance next character
+                *iter = Latin1Char('a');
+                if (++iter == placeholderEnd) {
+                    // Out of alternatives. Return file exists error, previously set.
+                    error = QSystemError(err, QSystemError::NativeError);
+                    return false;
+                }
+
+                continue;
+
+            case '0': case '1': case '2': case '3': case '4':
+            case '5': case '6': case '7': case '8': case '9':
+                *iter = Latin1Char('a');
+                break;
 
-        int err = errno;
-        if (err != EEXIST) {
-            error = QSystemError(err, QSystemError::NativeError);
-            return false;
-        }
-#endif
+            case 'z':
+                // increment 'z' to 'A'
+                *iter = Latin1Char('A');
+                break;
 
-        /* tricky little algorwwithm for backward compatibility */
-        for (Char *iter = placeholderStart;;) {
-            // Character progression: [0-9] => 'a' ... 'z' => 'A' .. 'Z'
-            // String progression: "ZZaiC" => "aabiC"
-            switch (char(*iter)) {
-                case 'Z':
-                    // Rollover, advance next character
-                    *iter = Latin1Char('a');
-                    if (++iter == placeholderEnd) {
-                        // Out of alternatives. Return file exists error, previously set.
-                        error = QSystemError(err, QSystemError::NativeError);
-                        return false;
-                    }
-
-                    continue;
-
-                case '0': case '1': case '2': case '3': case '4':
-                case '5': case '6': case '7': case '8': case '9':
-                    *iter = Latin1Char('a');
-                    break;
-
-                case 'z':
-                    // increment 'z' to 'A'
-                    *iter = Latin1Char('A');
-                    break;
-
-                default:
-                    ++*iter;
-                    break;
-            }
-            break;
+            default:
+                ++*iter;
+                break;
         }
+        break;
     }
 
-    Q_ASSERT(false);
+    Q_UNREACHABLE();
 }
 
 //************* QTemporaryFileEngine
@@ -265,11 +224,7 @@ bool QTemporaryFileEngine::isReallyOpen()
 {
     Q_D(QFSFileEngine);
 
-    if (!((0 == d->fh) && (-1 == d->fd)
-#if defined Q_OS_WIN
-                && (INVALID_HANDLE_VALUE == d->fileHandle)
-#endif
-            ))
+    if (!((0 == d->fh) && (-1 == d->fd)))
         return true;
 
     return false;
@@ -355,11 +310,7 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode)
     Q_ASSERT(phLength >= 6);
 
     QSystemError error;
-#if defined(Q_OS_WIN)
-    NativeFileHandle &file = d->fileHandle;
-#else // POSIX
     NativeFileHandle &file = d->fd;
-#endif
 
     if (!createFileFromTemplate(file, filename, phPos, phLength, error)) {
         setError(QFile::OpenError, error.toString());
@@ -368,9 +319,7 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode)
 
     d->fileEntry = QFileSystemEntry(filename, QFileSystemEntry::FromNativePath());
 
-#if !defined(Q_OS_WIN)
     d->closeFileHandle = true;
-#endif
 
     filePathIsTemplate = false;
 
index 7cd5fbe..6907740 100644 (file)
@@ -100,7 +100,6 @@ void QNetworkAccessFileBackend::open()
 
     if (url.host() == QLatin1String("localhost"))
         url.setHost(QString());
-#if !defined(Q_OS_WIN)
     // do not allow UNC paths on Unix
     if (!url.host().isEmpty()) {
         // we handle only local files
@@ -109,7 +108,6 @@ void QNetworkAccessFileBackend::open()
         finished();
         return;
     }
-#endif // !defined(Q_OS_WIN)
     if (url.path().isEmpty())
         url.setPath(QLatin1String("/"));
     setUrl(url);
index 8994841..11adbf7 100644 (file)
@@ -428,10 +428,7 @@ QIODevice *QNetworkDiskCache::data(const QUrl &url)
             buffer.reset(new QBuffer);
             // ### verify that QFile uses the fd size and not the file name
             qint64 size = file->size() - file->pos();
-            const uchar *p = 0;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_INTEGRITY)
-            p = file->map(file->pos(), size);
-#endif
+            const uchar *p = file->map(file->pos(), size);
             if (p) {
                 buffer->setData((const char *)p, size);
                 file.take()->setParent(buffer.data());
index 835cb6b..0c8d61e 100644 (file)
@@ -72,7 +72,6 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QObject *parent, const QNetworkRequ
     if (url.host() == QLatin1String("localhost"))
         url.setHost(QString());
 
-#if !defined(Q_OS_WIN)
     // do not allow UNC paths on Unix
     if (!url.host().isEmpty()) {
         // we handle only local files
@@ -83,7 +82,6 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QObject *parent, const QNetworkRequ
         QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
         return;
     }
-#endif
     if (url.path().isEmpty())
         url.setPath(QLatin1String("/"));
     setUrl(url);
index 6331050..c7f2262 100644 (file)
 #include <QtCore/qstring.h>
 #include <QtCore/qlist.h>
 
-#if defined(Q_OS_WIN) && defined(interface)
-#undef interface
-#endif
-
 QT_BEGIN_HEADER
 
 QT_BEGIN_NAMESPACE
index 4ce04c5..81b6507 100644 (file)
 
 #ifndef QT_NO_BEARERMANAGEMENT
 
-#if defined(Q_OS_WIN) && defined(interface)
-#undef interface
-#endif
-
 QT_BEGIN_HEADER
 
 QT_BEGIN_NAMESPACE
index 0828c5b..657a45f 100644 (file)
@@ -49,9 +49,6 @@
 #ifndef QT_NO_DATASTREAM
 #include <qdatastream.h>
 #endif
-#if defined(Q_OS_WINCE)
-#include <winsock.h>
-#endif
 
 #ifdef QT_LINUXBASE
 #  include <arpa/inet.h>
index c85df1f..98eb4d7 100644 (file)
@@ -126,15 +126,10 @@ QString QNetworkInterfacePrivate::makeHwAddress(int len, uchar *data)
 {
     QString result;
     for (int i = 0; i < len; ++i) {
-        if (i)
-            result += QLatin1Char(':');
+        result += QLatin1Char(':');
 
         char buf[3];
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && defined(_MSC_VER) && _MSC_VER >= 1400
-        sprintf_s(buf, 3, "%02hX", ushort(data[i]));
-#else
         sprintf(buf, "%02hX", ushort(data[i]));
-#endif
         result += QLatin1String(buf);
     }
     return result;
index 5b7968b..b073c97 100644 (file)
@@ -683,26 +683,14 @@ bool QAbstractSocketPrivate::canReadNotification()
 */
 bool QAbstractSocketPrivate::canWriteNotification()
 {
-#if defined (Q_OS_WIN)
-    if (socketEngine && socketEngine->isWriteNotificationEnabled())
-        socketEngine->setWriteNotificationEnabled(false);
-#endif
-
 #if defined (QABSTRACTSOCKET_DEBUG)
     qDebug("QAbstractSocketPrivate::canWriteNotification() flushing");
 #endif
     int tmp = writeBuffer.size();
     flush();
 
-    if (socketEngine) {
-#if defined (Q_OS_WIN)
-        if (!writeBuffer.isEmpty())
-            socketEngine->setWriteNotificationEnabled(true);
-#else
-        if (writeBuffer.isEmpty() && socketEngine->bytesToWrite() == 0)
-            socketEngine->setWriteNotificationEnabled(false);
-#endif
-    }
+    if (socketEngine && writeBuffer.isEmpty() && socketEngine->bytesToWrite() == 0)
+        socketEngine->setWriteNotificationEnabled(false);
 
     return (writeBuffer.size() < tmp);
 }
index eb67c87..3b7f856 100644 (file)
@@ -944,36 +944,7 @@ bool QNativeSocketEngine::waitForWrite(int msecs, bool *timedOut)
     if (timedOut)
         *timedOut = false;
 
-    int ret = d->nativeSelect(msecs, false);
-    // On Windows, the socket is in connected state if a call to
-    // select(writable) is successful. In this case we should not
-    // issue a second call to WSAConnect()
-#if defined (Q_WS_WIN)
-    if (ret > 0) {
-        setState(QAbstractSocket::ConnectedState);
-        d_func()->fetchConnectionParameters();
-        return true;
-    } else {
-        int value = 0;
-        int valueSize = sizeof(value);
-        if (::getsockopt(d->socketDescriptor, SOL_SOCKET, SO_ERROR, (char *) &value, &valueSize) == 0) {
-            if (value == WSAECONNREFUSED) {
-                d->setError(QAbstractSocket::ConnectionRefusedError, QNativeSocketEnginePrivate::ConnectionRefusedErrorString);
-                d->socketState = QAbstractSocket::UnconnectedState;
-                return false;
-            } else if (value == WSAETIMEDOUT) {
-                d->setError(QAbstractSocket::NetworkError, QNativeSocketEnginePrivate::ConnectionTimeOutErrorString);
-                d->socketState = QAbstractSocket::UnconnectedState;
-                return false;
-            } else if (value == WSAEHOSTUNREACH) {
-                d->setError(QAbstractSocket::NetworkError, QNativeSocketEnginePrivate::HostUnreachableErrorString);
-                d->socketState = QAbstractSocket::UnconnectedState;
-                return false;
-            }
-        }
-    }
-#endif
-
+    const int ret = d->nativeSelect(msecs, false);
     if (ret == 0) {
         if (timedOut)
             *timedOut = true;
@@ -997,35 +968,7 @@ bool QNativeSocketEngine::waitForReadOrWrite(bool *readyToRead, bool *readyToWri
     Q_CHECK_NOT_STATE(QNativeSocketEngine::waitForReadOrWrite(),
                       QAbstractSocket::UnconnectedState, false);
 
-    int ret = d->nativeSelect(msecs, checkRead, checkWrite, readyToRead, readyToWrite);
-    // On Windows, the socket is in connected state if a call to
-    // select(writable) is successful. In this case we should not
-    // issue a second call to WSAConnect()
-#if defined (Q_WS_WIN)
-    if (checkWrite && ((readyToWrite && *readyToWrite) || !readyToWrite) && ret > 0) {
-        setState(QAbstractSocket::ConnectedState);
-        d_func()->fetchConnectionParameters();
-        return true;
-    } else {
-        int value = 0;
-        int valueSize = sizeof(value);
-        if (::getsockopt(d->socketDescriptor, SOL_SOCKET, SO_ERROR, (char *) &value, &valueSize) == 0) {
-            if (value == WSAECONNREFUSED) {
-                d->setError(QAbstractSocket::ConnectionRefusedError, QNativeSocketEnginePrivate::ConnectionRefusedErrorString);
-                d->socketState = QAbstractSocket::UnconnectedState;
-                return false;
-            } else if (value == WSAETIMEDOUT) {
-                d->setError(QAbstractSocket::NetworkError, QNativeSocketEnginePrivate::ConnectionTimeOutErrorString);
-                d->socketState = QAbstractSocket::UnconnectedState;
-                return false;
-            } else if (value == WSAEHOSTUNREACH) {
-                d->setError(QAbstractSocket::NetworkError, QNativeSocketEnginePrivate::HostUnreachableErrorString);
-                d->socketState = QAbstractSocket::UnconnectedState;
-                return false;
-            }
-        }
-    }
-#endif
+    const int ret = d->nativeSelect(msecs, checkRead, checkWrite, readyToRead, readyToWrite);
     if (ret == 0) {
         if (timedOut)
             *timedOut = true;
index 5274d8d..cf4139d 100644 (file)
 //
 #include "QtNetwork/qhostaddress.h"
 #include "qabstractsocketengine_p.h"
-#ifndef Q_OS_WIN
-#  include "qplatformdefs.h"
-#else
-#  include <winsock2.h>
-#endif
+#include "qplatformdefs.h"
 
 QT_BEGIN_NAMESPACE
 
@@ -175,16 +171,6 @@ private:
     Q_DISABLE_COPY(QNativeSocketEngine)
 };
 
-#ifdef Q_OS_WIN
-class QWindowsSockInit
-{
-public:
-    QWindowsSockInit();
-    ~QWindowsSockInit();
-    int version;
-};
-#endif
-
 class QSocketNotifier;
 
 class QNativeSocketEnginePrivate : public QAbstractSocketEnginePrivate
@@ -198,10 +184,6 @@ public:
 
     QSocketNotifier *readNotifier, *writeNotifier, *exceptNotifier;
 
-#ifdef Q_OS_WIN
-    QWindowsSockInit winSock;
-#endif
-
     enum ErrorString {
         NonBlockingInitFailedErrorString,
         BroadcastingInitFailedErrorString,
index 9b24a6b..112014e 100644 (file)
@@ -66,11 +66,7 @@ static const int MaxWriteBufferSize = 128*1024;
 //#define QSOCKS5SOCKETLAYER_DEBUG
 
 #define MAX_DATA_DUMP 256
-#if !defined(Q_OS_WINCE)
 #define SOCKS5_BLOCKING_BIND_TIMEOUT 5000
-#else
-#define SOCKS5_BLOCKING_BIND_TIMEOUT 10000
-#endif
 
 #define Q_INIT_CHECK(returnValue) do { \
     if (!d->data) { \
index 61e4da9..c012f06 100644 (file)
@@ -252,23 +252,11 @@ bool QUdpSocket::bind(const QHostAddress &address, quint16 port, BindMode mode)
     if (!d->ensureInitialized(address, port))
         return false;
 
-#ifdef Q_OS_UNIX
     if ((mode & ShareAddress) || (mode & ReuseAddressHint))
         d->socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 1);
     else
         d->socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 0);
-#endif
-#ifdef Q_OS_WIN
-    if (mode & ReuseAddressHint)
-        d->socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 1);
-    else
-        d->socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 0);
-    if (mode & DontShareAddress)
-        d->socketEngine->setOption(QAbstractSocketEngine::BindExclusively, 1);
-    else
-        d->socketEngine->setOption(QAbstractSocketEngine::BindExclusively, 0);
-#endif
-    bool result = d_func()->socketEngine->bind(address, port);
+    const bool result = d_func()->socketEngine->bind(address, port);
     d->cachedSocketDescriptor = d->socketEngine->socketDescriptor();
 
     if (!result) {
index c48c9e5..9170592 100644 (file)
 #endif
 QT_BEGIN_NAMESPACE
 
-#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
-#define kSecTrustSettingsDomainSystem 2 // so we do not need to include the header file
-    PtrSecCertificateGetData QSslSocketPrivate::ptrSecCertificateGetData = 0;
-    PtrSecTrustSettingsCopyCertificates QSslSocketPrivate::ptrSecTrustSettingsCopyCertificates = 0;
-    PtrSecTrustCopyAnchorCertificates QSslSocketPrivate::ptrSecTrustCopyAnchorCertificates = 0;
-#elif defined(Q_OS_WIN)
-    PtrCertOpenSystemStoreW QSslSocketPrivate::ptrCertOpenSystemStoreW = 0;
-    PtrCertFindCertificateInStore QSslSocketPrivate::ptrCertFindCertificateInStore = 0;
-    PtrCertCloseStore QSslSocketPrivate::ptrCertCloseStore = 0;
-#endif
-
 bool QSslSocketPrivate::s_libraryLoaded = false;
 bool QSslSocketPrivate::s_loadedCiphersAndCerts = false;
 bool QSslSocketPrivate::s_loadRootCertsOnDemand = false;
@@ -573,47 +562,9 @@ void QSslSocketPrivate::ensureCiphersAndCertsLoaded()
 
     resetDefaultCiphers();
 
-    //load symbols needed to receive certificates from system store
-#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
-    QLibrary securityLib("/System/Library/Frameworks/Security.framework/Versions/Current/Security");
-    if (securityLib.load()) {
-        ptrSecCertificateGetData = (PtrSecCertificateGetData) securityLib.resolve("SecCertificateGetData");
-        if (!ptrSecCertificateGetData)
-            qWarning("could not resolve symbols in security library"); // should never happen
-
-        ptrSecTrustSettingsCopyCertificates = (PtrSecTrustSettingsCopyCertificates) securityLib.resolve("SecTrustSettingsCopyCertificates");
-        if (!ptrSecTrustSettingsCopyCertificates) { // method was introduced in Leopard, use legacy method if it's not there
-            ptrSecTrustCopyAnchorCertificates = (PtrSecTrustCopyAnchorCertificates) securityLib.resolve("SecTrustCopyAnchorCertificates");
-            if (!ptrSecTrustCopyAnchorCertificates)
-                qWarning("could not resolve symbols in security library"); // should never happen
-        }
-    } else {
-        qWarning("could not load security library");
-    }
-#elif defined(Q_OS_WIN)
-    HINSTANCE hLib = LoadLibraryW(L"Crypt32");
-    if (hLib) {
-#if defined(Q_OS_WINCE)
-        ptrCertOpenSystemStoreW = (PtrCertOpenSystemStoreW)GetProcAddress(hLib, L"CertOpenStore");
-        ptrCertFindCertificateInStore = (PtrCertFindCertificateInStore)GetProcAddress(hLib, L"CertFindCertificateInStore");
-        ptrCertCloseStore = (PtrCertCloseStore)GetProcAddress(hLib, L"CertCloseStore");
-#else
-        ptrCertOpenSystemStoreW = (PtrCertOpenSystemStoreW)GetProcAddress(hLib, "CertOpenSystemStoreW");
-        ptrCertFindCertificateInStore = (PtrCertFindCertificateInStore)GetProcAddress(hLib, "CertFindCertificateInStore");
-        ptrCertCloseStore = (PtrCertCloseStore)GetProcAddress(hLib, "CertCloseStore");
-#endif
-        if (!ptrCertOpenSystemStoreW || !ptrCertFindCertificateInStore || !ptrCertCloseStore)
-            qWarning("could not resolve symbols in crypt32 library"); // should never happen
-    } else {
-        qWarning("could not load crypt32 library"); // should never happen
-    }
-#elif defined(Q_OS_QNX)
-    s_loadRootCertsOnDemand = true;
-#elif defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
     // check whether we can enable on-demand root-cert loading (i.e. check whether the sym links are there)
-    QList<QByteArray> dirs = unixRootCertDirectories();
-    QStringList symLinkFilter;
-    symLinkFilter << QLatin1String("[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f].[0-9]");
+    const QList<QByteArray> dirs = unixRootCertDirectories();
+    const QStringList symLinkFilter = QStringList() << QLatin1String("[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f].[0-9]");
     for (int a = 0; a < dirs.count(); ++a) {
         QDirIterator iterator(QLatin1String(dirs.at(a)), symLinkFilter, QDir::Files);
         if (iterator.hasNext()) {
@@ -621,7 +572,6 @@ void QSslSocketPrivate::ensureCiphersAndCertsLoaded()
             break;
         }
     }
-#endif
     // if on-demand loading was not enabled, load the certs now
     if (!s_loadRootCertsOnDemand)
         setDefaultCaCertificates(systemCaCertificates());
@@ -684,68 +634,7 @@ QList<QSslCertificate> QSslSocketPrivate::systemCaCertificates()
     timer.start();
 #endif
     QList<QSslCertificate> systemCerts;
-#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
-    CFArrayRef cfCerts;
-    OSStatus status = 1;
-
-    OSStatus SecCertificateGetData (
-       SecCertificateRef certificate,
-       CSSM_DATA_PTR data
-    );
-
-    if (ptrSecCertificateGetData) {
-        if (ptrSecTrustSettingsCopyCertificates)
-            status = ptrSecTrustSettingsCopyCertificates(kSecTrustSettingsDomainSystem, &cfCerts);
-        else if (ptrSecTrustCopyAnchorCertificates)
-            status = ptrSecTrustCopyAnchorCertificates(&cfCerts);
-        if (!status) {
-            CFIndex size = CFArrayGetCount(cfCerts);
-            for (CFIndex i = 0; i < size; ++i) {
-                SecCertificateRef cfCert = (SecCertificateRef)CFArrayGetValueAtIndex(cfCerts, i);
-                CSSM_DATA data;
-                CSSM_DATA_PTR dataPtr = &data;
-                if (ptrSecCertificateGetData(cfCert, dataPtr)) {
-                    qWarning("error retrieving a CA certificate from the system store");
-                } else {
-                    int len = data.Length;
-                    char *rawData = reinterpret_cast<char *>(data.Data);
-                    QByteArray rawCert(rawData, len);
-                    systemCerts.append(QSslCertificate::fromData(rawCert, QSsl::Der));
-                }
-            }
-            CFRelease(cfCerts);
-        }
-        else {
-           // no detailed error handling here
-           qWarning("could not retrieve system CA certificates");
-        }
-    }
-#elif defined(Q_OS_WIN)
-    if (ptrCertOpenSystemStoreW && ptrCertFindCertificateInStore && ptrCertCloseStore) {
-        HCERTSTORE hSystemStore;
-#if defined(Q_OS_WINCE)
-        hSystemStore = ptrCertOpenSystemStoreW(CERT_STORE_PROV_SYSTEM_W,
-                                               0,
-                                               0,
-                                               CERT_STORE_NO_CRYPT_RELEASE_FLAG|CERT_SYSTEM_STORE_CURRENT_USER,
-                                               L"ROOT");
-#else
-        hSystemStore = ptrCertOpenSystemStoreW(0, L"ROOT");
-#endif
-        if(hSystemStore) {
-            PCCERT_CONTEXT pc = NULL;
-            while(1) {
-                pc = ptrCertFindCertificateInStore( hSystemStore, X509_ASN_ENCODING, 0, CERT_FIND_ANY, NULL, pc);
-                if(!pc)
-                    break;
-                QByteArray der((const char *)(pc->pbCertEncoded), static_cast<int>(pc->cbCertEncoded));
-                QSslCertificate cert(der, QSsl::Der);
-                systemCerts.append(cert);
-            }
-            ptrCertCloseStore(hSystemStore, 0);
-        }
-    }
-#elif defined(Q_OS_UNIX)
+
     QSet<QString> certFiles;
     QList<QByteArray> directories = unixRootCertDirectories();
     QDir currentDir;
@@ -768,7 +657,6 @@ QList<QSslCertificate> QSslSocketPrivate::systemCaCertificates()
     systemCerts.append(QSslCertificate::fromPath(QLatin1String("/etc/pki/tls/certs/ca-bundle.crt"), QSsl::Pem)); // Fedora, Mandriva
     systemCerts.append(QSslCertificate::fromPath(QLatin1String("/usr/local/share/certs/ca-root-nss.crt"), QSsl::Pem)); // FreeBSD's ca_root_nss
 
-#endif
 #ifdef QSSLSOCKET_DEBUG
     qDebug() << "systemCaCertificates retrieval time " << timer.elapsed() << "ms";
     qDebug() << "imported " << systemCerts.count() << " certificates";
index f1a8623..5fd5402 100644 (file)
 
 #include "qsslsocket_p.h"
 
-#ifdef Q_OS_WIN
-#include <qt_windows.h>
-#if defined(OCSP_RESPONSE)
-#undef OCSP_RESPONSE
-#endif
-#endif
-
 #include <openssl/asn1.h>
 #include <openssl/bio.h>
 #include <openssl/bn.h>
index 650a6a1..2bb3ff4 100644 (file)
 // We mean it.
 //
 
-#include <qtcpsocket_p.h>
+#include "qtcpsocket_p.h"
 #include "qsslkey.h"
 #include "qsslconfiguration_p.h"
-
-#include <QtCore/qstringlist.h>
-
-#include <qringbuffer_p.h>
-
-#if defined(Q_OS_MAC)
-#include <Security/SecCertificate.h>
-#include <CoreFoundation/CFArray.h>
-#elif defined(Q_OS_WIN)
-#include <windows.h>
-#include <wincrypt.h>
-#ifndef HCRYPTPROV_LEGACY
-#define HCRYPTPROV_LEGACY HCRYPTPROV
-#endif
-#endif
+#include "qringbuffer_p.h"
+#include "qstringlist.h"
 
 QT_BEGIN_NAMESPACE
 
-#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
-    typedef OSStatus (*PtrSecCertificateGetData)(SecCertificateRef, CSSM_DATA_PTR);
-    typedef OSStatus (*PtrSecTrustSettingsCopyCertificates)(int, CFArrayRef*);
-    typedef OSStatus (*PtrSecTrustCopyAnchorCertificates)(CFArrayRef*);
-#endif
-
-#if defined(Q_OS_WIN)
-#if defined(Q_OS_WINCE)
-    typedef HCERTSTORE (WINAPI *PtrCertOpenSystemStoreW)(LPCSTR, DWORD, HCRYPTPROV_LEGACY, DWORD, const void*);
-#else
-    typedef HCERTSTORE (WINAPI *PtrCertOpenSystemStoreW)(HCRYPTPROV_LEGACY, LPCWSTR);
-#endif
-    typedef PCCERT_CONTEXT (WINAPI *PtrCertFindCertificateInStore)(HCERTSTORE, DWORD, DWORD, DWORD, const void*, PCCERT_CONTEXT);
-    typedef BOOL (WINAPI *PtrCertCloseStore)(HCERTSTORE, DWORD);
-#endif
-
-
-
 class QSslSocketPrivate : public QTcpSocketPrivate
 {
     Q_DECLARE_PUBLIC(QSslSocket)
@@ -139,16 +108,6 @@ public:
     static void addDefaultCaCertificate(const QSslCertificate &cert);
     static void addDefaultCaCertificates(const QList<QSslCertificate> &certs);
 
-#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
-    static PtrSecCertificateGetData ptrSecCertificateGetData;
-    static PtrSecTrustSettingsCopyCertificates ptrSecTrustSettingsCopyCertificates;
-    static PtrSecTrustCopyAnchorCertificates ptrSecTrustCopyAnchorCertificates;
-#elif defined(Q_OS_WIN)
-    static PtrCertOpenSystemStoreW ptrCertOpenSystemStoreW;
-    static PtrCertFindCertificateInStore ptrCertFindCertificateInStore;
-    static PtrCertCloseStore ptrCertCloseStore;
-#endif
-
     // The socket itself, including private slots.
     QTcpSocket *plainSocket;
     void createPlainSocket(QIODevice::OpenMode openMode);