Changeset 846 for trunk/tools/shared/symbian
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 2 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/tools/shared/symbian/epocroot.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 40 40 ****************************************************************************/ 41 41 42 #include <iostream>43 44 42 #include <QtCore/qdir.h> 45 43 #include <QtCore/qxmlstream.h> 46 44 47 #include "epocroot.h" 48 #include "../windows/registry.h" 45 #include "epocroot_p.h" 46 #include "../windows/registry_p.h" 47 48 QT_BEGIN_NAMESPACE 49 49 50 50 // Registry key under which the location of the Symbian devices.xml file is … … 65 65 static QString epocRootValue; 66 66 67 #ifdef QT_BUILD_QMAKE 68 std::ostream &operator<<(std::ostream &s, const QString &val) { 69 s << val.toLocal8Bit().data(); 70 return s; 71 } 72 #else 73 // Operator implemented in configureapp.cpp 74 std::ostream &operator<<(std::ostream &s, const QString &val); 75 #endif 76 77 QString getDevicesXmlPath() 67 static QString getDevicesXmlPath() 78 68 { 79 69 // Note that the following call will return a null string on platforms other … … 81 71 // an alternative mechanism for retrieving the location of this file will 82 72 // be required. 83 return readRegistryKey(SYMBIAN_SDKS_REG_HANDLE, SYMBIAN_SDKS_REG_SUBKEY);73 return qt_readRegistryKey(SYMBIAN_SDKS_REG_HANDLE, QLatin1String(SYMBIAN_SDKS_REG_SUBKEY)); 84 74 } 85 75 … … 88 78 * If not, epocRootValue is set to an empty string and an error message is printed. 89 79 */ 90 void checkEpocRootExists(const QString &source)80 static void checkEpocRootExists(const QString &source) 91 81 { 92 82 if (!epocRootValue.isEmpty()) { 93 83 QDir dir(epocRootValue); 94 84 if (!dir.exists()) { 95 std::cerr << "Warning: " << source << " is set to an invalid path: " << epocRootValue << std::endl; 85 qWarning("Warning: %s is set to an invalid path: '%s'", qPrintable(source), 86 qPrintable(epocRootValue)); 96 87 epocRootValue = QString(); 97 88 } … … 104 95 static void fixEpocRoot(QString &path) 105 96 { 106 path.replace("\\", "/"); 107 108 if (path.size() > 1 && path[1] == QChar(':')) { 109 path = path.mid(2); 110 } 111 112 if (!path.size() || path[path.size()-1] != QChar('/')) { 113 path += QChar('/'); 97 path.replace(QLatin1Char('\\'), QLatin1Char('/')); 98 99 if (!path.size() || path[path.size()-1] != QLatin1Char('/')) { 100 path += QLatin1Char('/'); 114 101 } 115 102 } … … 118 105 * Determine the epoc root for the currently active SDK. 119 106 */ 120 QString epocRoot()107 QString qt_epocRoot() 121 108 { 122 109 if (epocRootValue.isEmpty()) { 123 110 // 1. If environment variable EPOCROOT is set and points to an existent 124 111 // directory, this is returned. 125 epocRootValue = qgetenv("EPOCROOT");126 checkEpocRootExists( "EPOCROOT");112 epocRootValue = QString::fromLocal8Bit(qgetenv("EPOCROOT").constData()); 113 checkEpocRootExists(QLatin1String("EPOCROOT environment variable")); 127 114 128 115 if (epocRootValue.isEmpty()) { … … 130 117 // file exists, it is parsed. 131 118 QString devicesXmlPath = getDevicesXmlPath(); 132 if (devicesXmlPath.isEmpty()) { 133 std::cerr << "Error: Symbian SDK registry key not found" << std::endl; 134 } else { 135 devicesXmlPath += "/devices.xml"; 119 if (!devicesXmlPath.isEmpty()) { 120 devicesXmlPath += QLatin1String("/devices.xml"); 136 121 QFile devicesFile(devicesXmlPath); 137 122 if (devicesFile.open(QIODevice::ReadOnly)) { … … 143 128 // epocroot value points to an existent directory, this is returned. 144 129 145 const QString epocDeviceValue = qgetenv("EPOCDEVICE");130 const QString epocDeviceValue = QString::fromLocal8Bit(qgetenv("EPOCDEVICE").constData()); 146 131 bool epocDeviceFound = false; 147 132 … … 149 134 while (!xml.atEnd()) { 150 135 xml.readNext(); 151 if (xml.isStartElement() && xml.name() == "devices") {152 if (xml.attributes().value( "version") == "1.0") {153 while (!(xml.isEndElement() && xml.name() == "devices") && !xml.atEnd()) {136 if (xml.isStartElement() && xml.name() == QLatin1String("devices")) { 137 if (xml.attributes().value(QLatin1String("version")) == QLatin1String("1.0")) { 138 while (!(xml.isEndElement() && xml.name() == QLatin1String("devices")) && !xml.atEnd()) { 154 139 xml.readNext(); 155 if (xml.isStartElement() && xml.name() == "device") { 156 const bool isDefault = xml.attributes().value("default") == "yes"; 157 const QString id = xml.attributes().value("id").toString(); 158 const QString name = xml.attributes().value("name").toString(); 159 const bool epocDeviceMatch = (id + ":" + name) == epocDeviceValue; 140 if (xml.isStartElement() && xml.name() == QLatin1String("device")) { 141 const bool isDefault = xml.attributes().value(QLatin1String("default")) == QLatin1String("yes"); 142 const QString id = xml.attributes().value(QLatin1String("id")).toString(); 143 const QString name = xml.attributes().value(QLatin1String("name")).toString(); 144 const QString alias = xml.attributes().value(QLatin1String("alias")).toString(); 145 bool epocDeviceMatch = QString(id + QLatin1String(":") + name) == epocDeviceValue; 146 if (!alias.isEmpty()) 147 epocDeviceMatch |= alias == epocDeviceValue; 160 148 epocDeviceFound |= epocDeviceMatch; 161 149 162 150 if((epocDeviceValue.isEmpty() && isDefault) || epocDeviceMatch) { 163 151 // Found a matching device 164 while (!(xml.isEndElement() && xml.name() == "device") && !xml.atEnd()) {152 while (!(xml.isEndElement() && xml.name() == QLatin1String("device")) && !xml.atEnd()) { 165 153 xml.readNext(); 166 if (xml.isStartElement() && xml.name() == "epocroot") {154 if (xml.isStartElement() && xml.name() == QLatin1String("epocroot")) { 167 155 epocRootValue = xml.readElementText(); 168 156 const QString deviceSource = epocDeviceValue.isEmpty() 169 ? "default device"170 : "EPOCDEVICE (" + epocDeviceValue + ")";157 ? QLatin1String("default device") 158 : QString(QLatin1String("EPOCDEVICE (") + epocDeviceValue + QLatin1String(")")); 171 159 checkEpocRootExists(deviceSource); 172 160 } … … 174 162 175 163 if (epocRootValue.isEmpty()) 176 xml.raiseError( "No epocroot element found");164 xml.raiseError(QLatin1String("No epocroot element found")); 177 165 } 178 166 } 179 167 } 180 168 } else { 181 xml.raiseError( "Invalid 'devices' element version");169 xml.raiseError(QLatin1String("Invalid 'devices' element version")); 182 170 } 183 171 } 184 172 } 185 173 if (xml.hasError()) { 186 std::cerr << "Error: \"" << xml.errorString() << "\" when parsing devices.xml" << std::endl; 174 qWarning("Warning: Error \"%s\" when parsing devices.xml", 175 qPrintable(xml.errorString())); 187 176 } else { 188 177 if (epocRootValue.isEmpty()) { 189 178 if (!epocDeviceValue.isEmpty()) { 190 179 if (epocDeviceFound) { 191 std::cerr << "Error: missing or invalid epocroot attribute "192 << "in device '" << epocDeviceValue << "'";180 qWarning("Warning: Missing or invalid epocroot attribute in device '%s' in devices.xml.", 181 qPrintable(epocDeviceValue)); 193 182 } else { 194 std::cerr << "Error: no device matching EPOCDEVICE ("195 << epocDeviceValue << ")";183 qWarning("Warning: No device matching EPOCDEVICE (%s) in devices.xml.", 184 qPrintable(epocDeviceValue)); 196 185 } 197 186 } else { 198 187 if (epocDeviceFound) { 199 std::cerr << "Error: missing or invalid epocroot attribute " 200 << "in default device"; 188 qWarning("Warning: Missing or invalid epocroot attribute in default device in devices.xml."); 201 189 } else { 202 std::cerr << "Error: no default device";190 qWarning("Warning: No default device set in devices.xml."); 203 191 } 204 192 } 205 std::cerr << " found in devices.xml file." << std::endl;206 193 } 207 194 } 208 195 } else { 209 std::cerr << "Error: could not open file " << devicesXmlPath << std::endl;196 qWarning("Warning: Could not open file: '%s'.", qPrintable(devicesXmlPath)); 210 197 } 211 198 } … … 214 201 if (epocRootValue.isEmpty()) { 215 202 // 5. An empty string is returned. 216 std::cerr << "Error: failed to find epoc root" << std::endl 217 << "Either" << std::endl 218 << " 1. Set EPOCROOT environment variable to a valid value" << std::endl 219 << " or 2. Ensure that the HKEY_LOCAL_MACHINE\\" SYMBIAN_SDKS_REG_SUBKEY 220 " registry key is set, and then" << std::endl 221 << " a. Set EPOCDEVICE environment variable to a valid device" << std::endl 222 << " or b. Specify a default device in the devices.xml file." << std::endl; 203 qWarning("Warning: failed to resolve epocroot." 204 #ifdef Q_OS_WIN32 205 "\nEither\n" 206 " 1. Set EPOCROOT environment variable to a valid value.\n" 207 " or 2. Ensure that the HKEY_LOCAL_MACHINE\\" SYMBIAN_SDKS_REG_SUBKEY 208 " registry key is set, and then\n" 209 " a. Set EPOCDEVICE environment variable to a valid device\n" 210 " or b. Specify a default device in the devices.xml file."); 211 #else 212 " Set EPOCROOT environment variable to a valid value."); 213 #endif 223 214 } else { 224 215 fixEpocRoot(epocRootValue); … … 229 220 } 230 221 222 QT_END_NAMESPACE
Note:
See TracChangeset
for help on using the changeset viewer.