summaryrefslogtreecommitdiffstats
path: root/tools/configure/environment.cpp
diff options
context:
space:
mode:
authorGareth Stockwell <ext-gareth.stockwell@nokia.com>2010-02-10 15:16:20 (GMT)
committerGareth Stockwell <ext-gareth.stockwell@nokia.com>2010-02-18 16:34:18 (GMT)
commitea34fbde76a0407dc4a9bb9f4a3140c4764ca6ba (patch)
tree82d438d523141fc88471c6bcaabefcbb7e4dbc1c /tools/configure/environment.cpp
parent13cb80be958c40077245cbc4b36448a661e30c64 (diff)
downloadQt-ea34fbde76a0407dc4a9bb9f4a3140c4764ca6ba.zip
Qt-ea34fbde76a0407dc4a9bb9f4a3140c4764ca6ba.tar.gz
Qt-ea34fbde76a0407dc4a9bb9f4a3140c4764ca6ba.tar.bz2
Removed duplicated implementation of readRegistryKeys from configure
Configure now shares - at the source level - a single implementation of this function with qmake. Reviewed-by: Miikka Heikkinen
Diffstat (limited to 'tools/configure/environment.cpp')
-rw-r--r--tools/configure/environment.cpp121
1 files changed, 1 insertions, 120 deletions
diff --git a/tools/configure/environment.cpp b/tools/configure/environment.cpp
index af6f9e5..da86f5d 100644
--- a/tools/configure/environment.cpp
+++ b/tools/configure/environment.cpp
@@ -60,6 +60,7 @@ using namespace std;
#include <qt_windows.h>
#endif
+#include <windows/registry.h> // from tools/shared
QT_BEGIN_NAMESPACE
@@ -97,126 +98,6 @@ CompilerInfo *Environment::compilerInfo(Compiler compiler)
}
/*!
- Returns the path part of a registry key.
- Ei.
- For a key
- "Software\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\ProductDir"
- it returns
- "Software\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\"
-*/
-QString Environment::keyPath(const QString &rKey)
-{
- int idx = rKey.lastIndexOf(QLatin1Char('\\'));
- if (idx == -1)
- return QString();
- return rKey.left(idx + 1);
-}
-
-/*!
- Returns the name part of a registry key.
- Ei.
- For a key
- "Software\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\ProductDir"
- it returns
- "ProductDir"
-*/
-QString Environment::keyName(const QString &rKey)
-{
- int idx = rKey.lastIndexOf(QLatin1Char('\\'));
- if (idx == -1)
- return rKey;
-
- QString res(rKey.mid(idx + 1));
- if (res == "Default" || res == ".")
- res = "";
- return res;
-}
-
-/*!
- Returns a registry keys value in string form.
- If the registry key does not exist, or cannot be accessed, a
- QString() is returned.
-*/
-QString Environment::readRegistryKey(HKEY parentHandle, const QString &rSubkey)
-{
-#ifndef Q_OS_WIN32
- return QString();
-#else
- QString rSubkeyName = keyName(rSubkey);
- QString rSubkeyPath = keyPath(rSubkey);
-
- HKEY handle = 0;
- LONG res = RegOpenKeyEx(parentHandle, (wchar_t*)rSubkeyPath.utf16(), 0, KEY_READ, &handle);
- if (res != ERROR_SUCCESS)
- return QString();
-
- // get the size and type of the value
- DWORD dataType;
- DWORD dataSize;
- res = RegQueryValueEx(handle, (wchar_t*)rSubkeyName.utf16(), 0, &dataType, 0, &dataSize);
- if (res != ERROR_SUCCESS) {
- RegCloseKey(handle);
- return QString();
- }
-
- // get the value
- QByteArray data(dataSize, 0);
- res = RegQueryValueEx(handle, (wchar_t*)rSubkeyName.utf16(), 0, 0,
- reinterpret_cast<unsigned char*>(data.data()), &dataSize);
- if (res != ERROR_SUCCESS) {
- RegCloseKey(handle);
- return QString();
- }
-
- QString result;
- switch (dataType) {
- case REG_EXPAND_SZ:
- case REG_SZ: {
- result = QString::fromWCharArray(((const wchar_t *)data.constData()));
- break;
- }
-
- case REG_MULTI_SZ: {
- QStringList l;
- int i = 0;
- for (;;) {
- QString s = QString::fromWCharArray((const wchar_t *)data.constData() + i);
- i += s.length() + 1;
-
- if (s.isEmpty())
- break;
- l.append(s);
- }
- result = l.join(", ");
- break;
- }
-
- case REG_NONE:
- case REG_BINARY: {
- result = QString::fromWCharArray((const wchar_t *)data.constData(), data.size() / 2);
- break;
- }
-
- case REG_DWORD_BIG_ENDIAN:
- case REG_DWORD: {
- Q_ASSERT(data.size() == sizeof(int));
- int i;
- memcpy((char*)&i, data.constData(), sizeof(int));
- result = QString::number(i);
- break;
- }
-
- default:
- qWarning("QSettings: unknown data %d type in windows registry", dataType);
- break;
- }
-
- RegCloseKey(handle);
- return result;
-#endif
-}
-
-/*!
Returns the qmakespec for the compiler detected on the system.
*/
QString Environment::detectQMakeSpec()