author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Thu, 22 Apr 2010 16:15:11 +0300 | |
branch | RCL_3 |
changeset 14 | 8c4229025c0b |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the tools applications of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
#include "cesdkhandler.h" |
|
42 |
#include <QtCore/QFile> |
|
43 |
#include <QtCore/QDebug> |
|
44 |
#include <QtCore/QXmlStreamReader> |
|
45 |
||
46 |
CeSdkInfo::CeSdkInfo() : m_major(0) , m_minor(0) |
|
47 |
{ |
|
48 |
} |
|
49 |
||
50 |
QStringList CeSdkInfo::environment() |
|
51 |
{ |
|
52 |
QStringList result; |
|
53 |
QString argument = QLatin1String("PATH="); |
|
54 |
argument += m_bin; |
|
55 |
result.append(argument); |
|
56 |
argument = QLatin1String("INCLUDE="); |
|
57 |
argument += m_include; |
|
58 |
result.append(argument); |
|
59 |
argument = QLatin1String("LIB="); |
|
60 |
argument += m_lib; |
|
61 |
result.append(argument); |
|
62 |
return result; |
|
63 |
} |
|
64 |
||
65 |
CeSdkHandler::CeSdkHandler() |
|
66 |
{ |
|
67 |
} |
|
68 |
||
69 |
bool CeSdkHandler::parse() |
|
70 |
{ |
|
71 |
// look at the file at %VCInstallDir%/vcpackages/WCE.VCPlatform.config |
|
72 |
// and scan through all installed sdks... |
|
73 |
m_list.clear(); |
|
74 |
VCInstallDir = QString::fromLatin1(qgetenv("VCInstallDir")); |
|
75 |
VCInstallDir += QLatin1String("\\"); |
|
76 |
VSInstallDir = QString::fromLatin1(qgetenv("VSInstallDir")); |
|
77 |
VSInstallDir += QLatin1String("\\"); |
|
78 |
if (VCInstallDir.isEmpty() || VSInstallDir.isEmpty()) |
|
79 |
return false; |
|
80 |
||
81 |
QDir vStudioDir(VCInstallDir); |
|
82 |
if (!vStudioDir.cd(QLatin1String("vcpackages"))) |
|
83 |
return false; |
|
84 |
||
85 |
QFile configFile(vStudioDir.absoluteFilePath(QLatin1String("WCE.VCPlatform.config"))); |
|
86 |
if (!configFile.exists() || !configFile.open(QIODevice::ReadOnly)) |
|
87 |
return false; |
|
88 |
||
89 |
QString currentElement; |
|
90 |
CeSdkInfo currentItem; |
|
91 |
QXmlStreamReader xml(&configFile); |
|
92 |
while (!xml.atEnd()) { |
|
93 |
xml.readNext(); |
|
94 |
if (xml.isStartElement()) { |
|
95 |
currentElement = xml.name().toString(); |
|
96 |
if (currentElement == QLatin1String("Platform")) |
|
97 |
currentItem = CeSdkInfo(); |
|
98 |
else if (currentElement == QLatin1String("Directories")) { |
|
99 |
QXmlStreamAttributes attr = xml.attributes(); |
|
100 |
currentItem.m_include = fixPaths(attr.value(QLatin1String("Include")).toString()); |
|
101 |
currentItem.m_lib = fixPaths(attr.value(QLatin1String("Library")).toString()); |
|
102 |
currentItem.m_bin = fixPaths(attr.value(QLatin1String("Path")).toString()); |
|
103 |
} |
|
104 |
} else if (xml.isEndElement()) { |
|
105 |
if (xml.name().toString() == QLatin1String("Platform")) |
|
106 |
m_list.append(currentItem); |
|
107 |
} else if (xml.isCharacters() && !xml.isWhitespace()) { |
|
108 |
if (currentElement == QLatin1String("PlatformName")) |
|
109 |
currentItem.m_name = xml.text().toString(); |
|
110 |
else if (currentElement == QLatin1String("OSMajorVersion")) |
|
111 |
currentItem.m_major = xml.text().toString().toInt(); |
|
112 |
else if (currentElement == QLatin1String("OSMinorVersion")) |
|
113 |
currentItem.m_minor = xml.text().toString().toInt(); |
|
114 |
} |
|
115 |
} |
|
116 |
||
117 |
if (xml.error() && xml.error() != QXmlStreamReader::PrematureEndOfDocumentError) { |
|
118 |
qWarning() << "XML ERROR:" << xml.lineNumber() << ": " << xml.errorString(); |
|
119 |
return false; |
|
120 |
} |
|
121 |
||
122 |
return m_list.size() > 0 ? true : false; |
|
123 |
} |
|
124 |
||
125 |
CeSdkInfo CeSdkHandler::find(const QString &name) |
|
126 |
{ |
|
127 |
for (QList<CeSdkInfo>::iterator it = m_list.begin(); it != m_list.end(); ++it) { |
|
128 |
if (it->name() == name) |
|
129 |
return *it; |
|
130 |
} |
|
131 |
return CeSdkInfo(); |
|
132 |
} |