Merge lp:~zeller-benjamin/qtcreator-plugin-ubuntu/bug-1387302 into lp:qtcreator-plugin-ubuntu
- bug-1387302
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Zoltan Balogh | ||||
Approved revision: | 292 | ||||
Merged at revision: | 291 | ||||
Proposed branch: | lp:~zeller-benjamin/qtcreator-plugin-ubuntu/bug-1387302 | ||||
Merge into: | lp:qtcreator-plugin-ubuntu | ||||
Diff against target: |
862 lines (+420/-227) 9 files modified
src/ubuntu/click-framework.json (+1/-0) src/ubuntu/resources.qrc (+1/-0) src/ubuntu/ubuntuclickmanifest.cpp (+2/-2) src/ubuntu/ubuntuclicktool.cpp (+322/-182) src/ubuntu/ubuntuclicktool.h (+43/-2) src/ubuntu/ubuntuconstants.h (+3/-3) src/ubuntu/ubuntumanifesteditorwidget.cpp (+43/-37) src/ubuntu/ubuntumanifesteditorwidget.h (+2/-1) src/ubuntu/ubuntuplugin.cpp (+3/-0) |
||||
To merge this branch: | bzr merge lp:~zeller-benjamin/qtcreator-plugin-ubuntu/bug-1387302 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Zoltan Balogh | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email: mp+240309@code.launchpad.net |
Commit message
- Fix bug lp:1387302
"Support selection of the 14.10 final framework version"
- Dynamically query frameworks from the server to make sure the list
is up2date. Fall back to resource files or last query if no network
is available.
- Fix update problem in the manifest editor
Description of the change
- Fix bug lp:1387302
"Support selection of the 14.10 final framework version"
- Dynamically query frameworks from the server to make sure the list
is up2date. Fall back to resource files or last query if no network
is available.
- Fix update problem in the manifest editor
PS Jenkins bot (ps-jenkins) wrote : | # |
- 291. By Benjamin Zeller
-
More easy sorting function for the frameworks
- 292. By Benjamin Zeller
-
sort frameworks by base version, and not by base string:
ubuntu-sdk-14.10 vs ubuntu-core-15.04
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:292
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 293. By Benjamin Zeller
-
Make sure the request returns valid data, and in case it does not fall
back to the default values (if the frameworkCache is empty)
Preview Diff
1 | === added file 'src/ubuntu/click-framework.json' |
2 | --- src/ubuntu/click-framework.json 1970-01-01 00:00:00 +0000 |
3 | +++ src/ubuntu/click-framework.json 2014-11-03 14:19:38 +0000 |
4 | @@ -0,0 +1,1 @@ |
5 | +{"ubuntu-sdk-14.04-html": "available", "ubuntu-sdk-14.04-papi-dev1": "deprecated", "ubuntu-sdk-14.10-papi": "available", "ubuntu-sdk-14.10-qml": "available", "ubuntu-sdk-14.04-dev1": "deprecated", "ubuntu-sdk-14.04-html-dev1": "deprecated", "ubuntu-sdk-14.04": "available", "ubuntu-sdk-14.10-html": "available", "ubuntu-sdk-14.04-papi": "available", "ubuntu-sdk-13.10": "deprecated", "ubuntu-sdk-14.10-qml-dev3": "available", "ubuntu-sdk-14.10-qml-dev2": "available", "ubuntu-sdk-14.10-qml-dev1": "obsolete", "ubuntu-sdk-14.04-qml-dev1": "deprecated", "ubuntu-sdk-14.10-papi-dev2": "available", "ubuntu-sdk-14.10-papi-dev3": "available", "ubuntu-sdk-14.10-papi-dev1": "obsolete", "ubuntu-sdk-14.10": "available", "ubuntu-sdk-14.04-qml": "available", "ubuntu-sdk-14.10-dev1": "obsolete", "ubuntu-sdk-14.10-dev2": "available", "ubuntu-sdk-14.10-dev3": "available", "ubuntu-sdk-14.10-html-dev3": "available", "ubuntu-sdk-14.10-html-dev2": "available", "ubuntu-sdk-14.10-html-dev1": "obsolete"} |
6 | |
7 | === modified file 'src/ubuntu/resources.qrc' |
8 | --- src/ubuntu/resources.qrc 2014-10-10 07:46:06 +0000 |
9 | +++ src/ubuntu/resources.qrc 2014-11-03 14:19:38 +0000 |
10 | @@ -22,5 +22,6 @@ |
11 | <file>images/security-alert.svg</file> |
12 | <file>images/view-expand.svg</file> |
13 | <file>images/view-collapse.svg</file> |
14 | + <file>click-framework.json</file> |
15 | </qresource> |
16 | </RCC> |
17 | |
18 | === modified file 'src/ubuntu/ubuntuclickmanifest.cpp' |
19 | --- src/ubuntu/ubuntuclickmanifest.cpp 2014-08-21 16:56:53 +0000 |
20 | +++ src/ubuntu/ubuntuclickmanifest.cpp 2014-11-03 14:19:38 +0000 |
21 | @@ -315,12 +315,12 @@ |
22 | |
23 | QString defFramework; |
24 | if(isUbuntuProject && isUbuntuHtmlProject) { |
25 | - defFramework = UbuntuClickTool::getMostRecentFramework(QLatin1String("html"),UbuntuClickTool::clickTargetFromTarget(proj->activeTarget())); |
26 | + defFramework = UbuntuClickFrameworkProvider::getMostRecentFramework(QLatin1String("html")); |
27 | |
28 | if(defFramework.isEmpty()) |
29 | defFramework = QLatin1String(Constants::UBUNTU_DEFAULT_HTML_FRAMEWORK); |
30 | } else { |
31 | - defFramework = UbuntuClickTool::getMostRecentFramework(QLatin1String("qml"),UbuntuClickTool::clickTargetFromTarget(proj->activeTarget())); |
32 | + defFramework = UbuntuClickFrameworkProvider::getMostRecentFramework(QLatin1String("qml")); |
33 | |
34 | if(defFramework.isEmpty()) |
35 | defFramework = QLatin1String(Constants::UBUNTU_DEFAULT_QML_FRAMEWORK); |
36 | |
37 | === modified file 'src/ubuntu/ubuntuclicktool.cpp' |
38 | --- src/ubuntu/ubuntuclicktool.cpp 2014-09-28 16:47:39 +0000 |
39 | +++ src/ubuntu/ubuntuclicktool.cpp 2014-11-03 14:19:38 +0000 |
40 | @@ -24,24 +24,19 @@ |
41 | |
42 | #include <QRegularExpression> |
43 | #include <QDir> |
44 | -#include <QPlainTextEdit> |
45 | -#include <QTextCursor> |
46 | -#include <QFont> |
47 | -#include <QFormLayout> |
48 | -#include <QLabel> |
49 | -#include <QDialogButtonBox> |
50 | -#include <QComboBox> |
51 | #include <QMessageBox> |
52 | -#include <QAction> |
53 | #include <QInputDialog> |
54 | -#include <QPushButton> |
55 | #include <QProcess> |
56 | +#include <QNetworkAccessManager> |
57 | +#include <QNetworkReply> |
58 | +#include <QTimer> |
59 | +#include <QFile> |
60 | +#include <QStandardPaths> |
61 | +#include <QJsonDocument> |
62 | +#include <QJsonObject> |
63 | +#include <QJsonParseError> |
64 | |
65 | #include <coreplugin/icore.h> |
66 | -#include <coreplugin/actionmanager/actioncontainer.h> |
67 | -#include <coreplugin/actionmanager/actionmanager.h> |
68 | -#include <coreplugin/progressmanager/futureprogress.h> |
69 | -#include <coreplugin/progressmanager/progressmanager.h> |
70 | #include <projectexplorer/projectexplorer.h> |
71 | #include <projectexplorer/target.h> |
72 | #include <projectexplorer/project.h> |
73 | @@ -209,133 +204,6 @@ |
74 | } |
75 | |
76 | /*! |
77 | - * \brief UbuntuClickTool::getSupportedFrameworks |
78 | - * returns all available frameworks on the host system |
79 | - */ |
80 | -QStringList UbuntuClickTool::getSupportedFrameworks(const UbuntuClickTool::Target *target) |
81 | -{ |
82 | -#if 0 |
83 | - QProcess proc; |
84 | - proc.setProgram(QStringLiteral("click")); |
85 | - |
86 | - QStringList args; |
87 | - if (target) { |
88 | - args << QStringLiteral("chroot") |
89 | - << QStringLiteral("-a") |
90 | - << target->architecture |
91 | - << QStringLiteral("-f") |
92 | - << target->framework |
93 | - << QStringLiteral("run") |
94 | - << QStringLiteral("click"); |
95 | - } |
96 | - args << QStringLiteral("framework") |
97 | - << QStringLiteral("list"); |
98 | - |
99 | - if(debug) qDebug()<<"click"<<Utils::QtcProcess::joinArgs(args); |
100 | - proc.setArguments(args); |
101 | - proc.start(); |
102 | - if (!proc.waitForFinished()) { |
103 | - proc.kill(); |
104 | - return QStringList(); |
105 | - } |
106 | - |
107 | - if(proc.exitCode() != 0 || proc.exitStatus() != QProcess::NormalExit) |
108 | - return QStringList(); |
109 | - |
110 | - QStringList allFws = QString::fromLocal8Bit(proc.readAllStandardOutput()).split(QStringLiteral("\n"),QString::SkipEmptyParts); |
111 | - |
112 | - //reverse the list |
113 | - QStringList result; |
114 | - result.reserve( allFws.size() ); |
115 | - std::reverse_copy( allFws.begin(), allFws.end(), std::back_inserter( result ) ); |
116 | - |
117 | - return result; |
118 | -#endif |
119 | - |
120 | -#if 0 |
121 | - if (!target) { |
122 | - QStringList items; |
123 | - QDir frameworksDir(QLatin1String(Constants::UBUNTU_CLICK_FRAMEWORKS_BASEPATH)); |
124 | - |
125 | - if(!frameworksDir.exists()) |
126 | - return items; |
127 | - |
128 | - QStringList availableFrameworkFiles = frameworksDir.entryList(QStringList()<<QLatin1String("*.framework"), |
129 | - QDir::Files | QDir::NoDotAndDotDot, |
130 | - QDir::Name | QDir::Reversed); |
131 | - |
132 | - QStringList availableFrameworks; |
133 | - foreach(QString fw, availableFrameworkFiles) { |
134 | - fw.replace(QLatin1String(".framework"),QString()); |
135 | - availableFrameworks.append(fw); |
136 | - } |
137 | - |
138 | - if(debug) qDebug()<<"Available Frameworks on the host"<<availableFrameworks; |
139 | - return availableFrameworks; |
140 | - } else { |
141 | - //hardcode for now, click chroots are broken, click is not installed and even if its installed |
142 | - //it does not show any valid informations |
143 | - if(target->majorVersion == 14 && target->minorVersion == 10) { |
144 | - return QStringList() << QStringLiteral("ubuntu-sdk-14.10-qml-dev3") |
145 | - << QStringLiteral("ubuntu-sdk-14.10-qml-dev2") |
146 | - << QStringLiteral("ubuntu-sdk-14.10-qml-dev1") |
147 | - << QStringLiteral("ubuntu-sdk-14.10-papi-dev2") |
148 | - << QStringLiteral("ubuntu-sdk-14.10-papi-dev1") |
149 | - << QStringLiteral("ubuntu-sdk-14.10-html-dev2") |
150 | - << QStringLiteral("ubuntu-sdk-14.10-html-dev1") |
151 | - << QStringLiteral("ubuntu-sdk-14.10-dev2") |
152 | - << QStringLiteral("ubuntu-sdk-14.10-dev1") |
153 | - << QStringLiteral("ubuntu-sdk-14.04") |
154 | - << QStringLiteral("ubuntu-sdk-14.04-qml") |
155 | - << QStringLiteral("ubuntu-sdk-14.04-qml-dev1") |
156 | - << QStringLiteral("ubuntu-sdk-14.04-papi") |
157 | - << QStringLiteral("ubuntu-sdk-14.04-papi-dev1") |
158 | - << QStringLiteral("ubuntu-sdk-14.04-html") |
159 | - << QStringLiteral("ubuntu-sdk-14.04-html-dev1") |
160 | - << QStringLiteral("ubuntu-sdk-14.04-dev1") |
161 | - << QStringLiteral("ubuntu-sdk-13.10"); |
162 | - } else if (target->majorVersion == 14 && target->minorVersion == 4){ |
163 | - return QStringList() << QStringLiteral("ubuntu-sdk-14.04") |
164 | - << QStringLiteral("ubuntu-sdk-14.04-qml") |
165 | - << QStringLiteral("ubuntu-sdk-14.04-qml-dev1") |
166 | - << QStringLiteral("ubuntu-sdk-14.04-papi") |
167 | - << QStringLiteral("ubuntu-sdk-14.04-papi-dev1") |
168 | - << QStringLiteral("ubuntu-sdk-14.04-html") |
169 | - << QStringLiteral("ubuntu-sdk-14.04-html-dev1") |
170 | - << QStringLiteral("ubuntu-sdk-14.04-dev1") |
171 | - << QStringLiteral("ubuntu-sdk-13.10"); |
172 | - } else { |
173 | - return QStringList() << QStringLiteral("ubuntu-sdk-13.10"); |
174 | - } |
175 | - } |
176 | -#endif |
177 | - |
178 | - //quick and dirty fix for trusty dev env |
179 | - Q_UNUSED(target); |
180 | - static QStringList frameworks { |
181 | - QStringLiteral("ubuntu-sdk-14.10-qml-dev3"), |
182 | - QStringLiteral("ubuntu-sdk-14.10-qml-dev2"), |
183 | - QStringLiteral("ubuntu-sdk-14.10-qml-dev1"), |
184 | - QStringLiteral("ubuntu-sdk-14.10-papi-dev2"), |
185 | - QStringLiteral("ubuntu-sdk-14.10-papi-dev1"), |
186 | - QStringLiteral("ubuntu-sdk-14.10-html-dev2"), |
187 | - QStringLiteral("ubuntu-sdk-14.10-html-dev1"), |
188 | - QStringLiteral("ubuntu-sdk-14.10-dev2"), |
189 | - QStringLiteral("ubuntu-sdk-14.10-dev1"), |
190 | - QStringLiteral("ubuntu-sdk-14.04"), |
191 | - QStringLiteral("ubuntu-sdk-14.04-qml"), |
192 | - QStringLiteral("ubuntu-sdk-14.04-qml-dev1"), |
193 | - QStringLiteral("ubuntu-sdk-14.04-papi"), |
194 | - QStringLiteral("ubuntu-sdk-14.04-papi-dev1"), |
195 | - QStringLiteral("ubuntu-sdk-14.04-html"), |
196 | - QStringLiteral("ubuntu-sdk-14.04-html-dev1"), |
197 | - QStringLiteral("ubuntu-sdk-14.04-dev1"), |
198 | - QStringLiteral("ubuntu-sdk-13.10") |
199 | - }; |
200 | - return frameworks; |
201 | -} |
202 | - |
203 | -/*! |
204 | * \brief UbuntuClickTool::targetExists |
205 | * checks if the target is still available |
206 | */ |
207 | @@ -348,48 +216,6 @@ |
208 | return true; |
209 | } |
210 | |
211 | -/*! |
212 | - * \brief UbuntuClickTool::getMostRecentFramework |
213 | - * returns the framework with the highest number supporting the subFramework |
214 | - * or a empty string of no framework with the given \a subFramework was found |
215 | - */ |
216 | -QString UbuntuClickTool::getMostRecentFramework(const QString &subFramework, const Target *target) |
217 | -{ |
218 | - //returned list is ordered from newest -> oldest framework |
219 | - QStringList allFws = getSupportedFrameworks(target); |
220 | - QString currFw; |
221 | - foreach(const QString &framework, allFws) { |
222 | - QString basename; |
223 | - QStringList extensions; |
224 | - QRegularExpression expr(QLatin1String(Constants::UBUNTU_CLICK_BASE_FRAMEWORK_REGEX)); |
225 | - QRegularExpressionMatch match = expr.match(framework); |
226 | - if(match.hasMatch()) { |
227 | - basename = match.captured(1); |
228 | - extensions = QString(framework).replace(basename, |
229 | - QString()).split(QChar::fromLatin1('-'), |
230 | - QString::SkipEmptyParts); |
231 | - } else { |
232 | - continue; |
233 | - } |
234 | - //this is a multi purpose framework |
235 | - if (extensions.size() == 0 |
236 | - || (extensions.size() == 1 && extensions[0].startsWith(QLatin1String("dev")) )) { |
237 | - if (currFw.isEmpty()) { |
238 | - currFw = framework; |
239 | - } |
240 | - //if the subframework is empty we return |
241 | - //the first baseframework we can find |
242 | - if(subFramework.isEmpty()) |
243 | - return currFw; |
244 | - continue; |
245 | - } |
246 | - |
247 | - if(extensions.contains(subFramework)) |
248 | - return framework; |
249 | - } |
250 | - return currFw; |
251 | -} |
252 | - |
253 | /** |
254 | * @brief UbuntuClickTool::listAvailableTargets |
255 | * @return all currently existing chroot targets in the system |
256 | @@ -577,6 +403,320 @@ |
257 | return dbg.space(); |
258 | } |
259 | |
260 | + |
261 | +/*! |
262 | + * \class UbuntuClickFrameworkProvider::UbuntuClickFrameworkProvider |
263 | + * |
264 | + * The UbuntuClickFrameworkProvider makes sure the IDE knows the most recent |
265 | + * framework list. It queries the Ubuntu servers for the list and fires frameworksUpdated() |
266 | + * if a new list is available. Widgets showing the frameworks should update accordingly |
267 | + * |
268 | + * The framework -> policy mapping is still hardcoded because there is no current API to query |
269 | + * it |
270 | + * |
271 | + * \note If no network connection is available the cache falls back to the last successful query or |
272 | + * the shipped framework list in the resource file |
273 | + */ |
274 | + |
275 | + |
276 | +struct FrameworkDesc{ |
277 | + FrameworkDesc() : develVersion(INT_MAX) {} |
278 | + QString base; |
279 | + QString baseVersion; |
280 | + QString sub; |
281 | + int develVersion; |
282 | +}; |
283 | + |
284 | +//this is a horrible complicated sorting function, it should be replaced with something more trivial |
285 | +static FrameworkDesc fwDescFromString (const QString &fw) |
286 | +{ |
287 | + FrameworkDesc fwDesc; |
288 | + |
289 | + QStringList ext; |
290 | + fwDesc.base = UbuntuClickFrameworkProvider::getBaseFramework(fw,&ext); |
291 | + |
292 | + int lastDash = fwDesc.base.lastIndexOf(QStringLiteral("-")); |
293 | + if(lastDash > 0) { |
294 | + fwDesc.baseVersion = fwDesc.base.mid(lastDash+1); |
295 | + fwDesc.base = fwDesc.base.mid(0,lastDash); |
296 | + } |
297 | + |
298 | + QString sub; |
299 | + while(ext.size()) { |
300 | + sub = ext.takeFirst(); |
301 | + if(sub.startsWith(QStringLiteral("dev"))) { |
302 | + fwDesc.develVersion = sub.remove(QStringLiteral("dev")).toInt(); |
303 | + } else { |
304 | + fwDesc.sub = sub; |
305 | + } |
306 | + } |
307 | + return fwDesc; |
308 | +} |
309 | + |
310 | + |
311 | +static bool caseInsensitiveFWLessThan(const QString &s1, const QString &s2) |
312 | +{ |
313 | + |
314 | + FrameworkDesc fwDesc1 = fwDescFromString(s1); |
315 | + FrameworkDesc fwDesc2 = fwDescFromString(s2); |
316 | + |
317 | + int comp = QString::compare(fwDesc1.baseVersion,fwDesc2.baseVersion,Qt::CaseInsensitive); |
318 | + if(comp < 0) |
319 | + return false; |
320 | + else if(comp > 0) |
321 | + return true; |
322 | + else { |
323 | + //from here on we deal only with the same base framework |
324 | + if(fwDesc1.sub.isEmpty() && !fwDesc2.sub.isEmpty()) |
325 | + return true; |
326 | + else if(!fwDesc1.sub.isEmpty() && fwDesc2.sub.isEmpty()) |
327 | + return false; |
328 | + else if(fwDesc1.sub == fwDesc2.sub) |
329 | + return fwDesc1.develVersion > fwDesc2.develVersion; |
330 | + else |
331 | + return fwDesc1.sub > fwDesc2.sub; |
332 | + } |
333 | + |
334 | + //this should never be reached |
335 | + return s1 > s2; |
336 | +} |
337 | + |
338 | +UbuntuClickFrameworkProvider *UbuntuClickFrameworkProvider::m_instance = nullptr; |
339 | + |
340 | +UbuntuClickFrameworkProvider::UbuntuClickFrameworkProvider() |
341 | + : QObject(0), |
342 | + m_policyCache { |
343 | + {QStringLiteral("ubuntu-sdk-13.10"),QStringLiteral("1.0")}, |
344 | + {QStringLiteral("ubuntu-sdk-14.04"),QStringLiteral("1.1")}, |
345 | + {QStringLiteral("ubuntu-sdk-14.10"),QStringLiteral("1.2")} |
346 | + }, |
347 | + m_manager(nullptr), |
348 | + m_currentRequest(nullptr), |
349 | + m_cacheUpdateTimer(nullptr) |
350 | +{ |
351 | + Q_ASSERT_X(m_instance == nullptr,Q_FUNC_INFO,"UbuntuClickFrameworkProvider can only be instantiated once"); |
352 | + m_instance = this; |
353 | + |
354 | + m_cacheFilePath = QStringLiteral("%1/ubuntu-sdk/framework-cache.json") |
355 | + .arg(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)); |
356 | + |
357 | + m_manager = new QNetworkAccessManager(this); |
358 | + m_cacheUpdateTimer = new QTimer(this); |
359 | + m_cacheUpdateTimer->setInterval( 60 * 60 * 1000); //fire every hour |
360 | + m_cacheUpdateTimer->start(); |
361 | + |
362 | + connect(m_cacheUpdateTimer,SIGNAL(timeout()),this,SLOT(updateFrameworks())); |
363 | + |
364 | + //read the current state |
365 | + readCache(); |
366 | + |
367 | + //fire a update |
368 | + updateFrameworks(true); |
369 | +} |
370 | + |
371 | +UbuntuClickFrameworkProvider *UbuntuClickFrameworkProvider::instance() |
372 | +{ |
373 | + return m_instance; |
374 | +} |
375 | + |
376 | +QStringList UbuntuClickFrameworkProvider::supportedFrameworks() const |
377 | +{ |
378 | + return m_frameworkCache; |
379 | +} |
380 | + |
381 | +/*! |
382 | + * \brief UbuntuClickTool::getMostRecentFramework |
383 | + * returns the framework with the highest number supporting the subFramework |
384 | + * or a empty string of no framework with the given \a subFramework was found |
385 | + */ |
386 | +QString UbuntuClickFrameworkProvider::mostRecentFramework(const QString &subFramework) |
387 | +{ |
388 | + //cache is ordered from newest -> oldest framework |
389 | + QString currFw; |
390 | + foreach(const QString &framework, m_frameworkCache) { |
391 | + QString basename; |
392 | + QStringList extensions; |
393 | + |
394 | + basename = getBaseFramework(framework,&extensions); |
395 | + if(basename.isEmpty()) |
396 | + continue; |
397 | + |
398 | + //this is a multi purpose framework |
399 | + if (extensions.size() == 0 |
400 | + || (extensions.size() == 1 && extensions[0].startsWith(QLatin1String("dev")) )) { |
401 | + if (currFw.isEmpty()) { |
402 | + currFw = framework; |
403 | + } |
404 | + //if the subframework is empty we return |
405 | + //the first baseframework we can find |
406 | + if(subFramework.isEmpty()) |
407 | + return currFw; |
408 | + continue; |
409 | + } |
410 | + |
411 | + if(extensions.contains(subFramework)) |
412 | + return framework; |
413 | + } |
414 | + return currFw; |
415 | +} |
416 | + |
417 | +QString UbuntuClickFrameworkProvider::frameworkPolicy(const QString &fw) const |
418 | +{ |
419 | + QString base = getBaseFramework(fw); |
420 | + if(m_policyCache.contains(base)) |
421 | + return m_policyCache[base]; |
422 | + return QString(); |
423 | +} |
424 | + |
425 | +QStringList UbuntuClickFrameworkProvider::getSupportedFrameworks() |
426 | +{ |
427 | + return instance()->supportedFrameworks(); |
428 | +} |
429 | + |
430 | +/*! |
431 | + * \brief UbuntuClickTool::getMostRecentFramework |
432 | + * \sa UbuntuClickFrameworkProvider::mostRecentFramework |
433 | + */ |
434 | +QString UbuntuClickFrameworkProvider::getMostRecentFramework(const QString &subFramework) |
435 | +{ |
436 | + return instance()->mostRecentFramework(subFramework); |
437 | +} |
438 | + |
439 | +QString UbuntuClickFrameworkProvider::getBaseFramework(const QString &framework, QStringList *extensions) |
440 | +{ |
441 | + QRegularExpression expr(QLatin1String(Constants::UBUNTU_CLICK_BASE_FRAMEWORK_REGEX)); |
442 | + QRegularExpressionMatch match = expr.match(framework); |
443 | + if(match.hasMatch()) { |
444 | + QString basename = match.captured(1); |
445 | + if(extensions) { |
446 | + *extensions = QString(framework).replace(basename, |
447 | + QString()).split(QChar::fromLatin1('-'), |
448 | + QString::SkipEmptyParts); |
449 | + } |
450 | + return basename; |
451 | + } |
452 | + return QString(); |
453 | +} |
454 | + |
455 | +void UbuntuClickFrameworkProvider::requestFinished() |
456 | +{ |
457 | + //if the current request is not set anymore we already called deleteLater |
458 | + if(!m_currentRequest) |
459 | + return; |
460 | + |
461 | + QByteArray data = m_currentRequest->readAll(); |
462 | + |
463 | + //make sure everything is cleaned up |
464 | + m_currentRequest->deleteLater(); |
465 | + m_currentRequest = nullptr; |
466 | + |
467 | + //if we received nothing, stop |
468 | + if(data.isEmpty()) |
469 | + return; |
470 | + |
471 | + //make sure we got valid data |
472 | + QStringList newData = parseData(data); |
473 | + if(newData.isEmpty()) |
474 | + return; |
475 | + |
476 | + bool cacheIsUp2Date = (newData == m_frameworkCache); |
477 | + if(!cacheIsUp2Date) { |
478 | + QFile cache(m_cacheFilePath); |
479 | + if(cache.open(QIODevice::WriteOnly | QIODevice::Truncate)) { |
480 | + cache.write(data); |
481 | + cache.close(); |
482 | + } else { |
483 | + qWarning()<<"Could not create framework cache file, falling back to default values"; |
484 | + } |
485 | + m_frameworkCache = newData; |
486 | + emit frameworksUpdated(); |
487 | + } |
488 | +} |
489 | + |
490 | +void UbuntuClickFrameworkProvider::requestError() |
491 | +{ |
492 | + //if the current request is not set anymore we already called deleteLater |
493 | + if(!m_currentRequest) |
494 | + return; |
495 | + |
496 | + qWarning()<<"Could not update the framework cache file. Probably there is no network connection."; |
497 | + |
498 | + m_currentRequest->deleteLater(); |
499 | + m_currentRequest = nullptr; |
500 | +} |
501 | + |
502 | +void UbuntuClickFrameworkProvider::updateFrameworks(bool force) |
503 | +{ |
504 | + if(m_currentRequest) |
505 | + return; |
506 | + |
507 | + if(!force) { |
508 | + //update every 12 hours |
509 | + QFileInfo info(m_cacheFilePath); |
510 | + if(info.exists() && info.lastModified().secsTo(QDateTime::currentDateTime()) < (12*60*60)) |
511 | + return; |
512 | + } |
513 | + |
514 | + //fire the request |
515 | + m_currentRequest = m_manager->get(QNetworkRequest(QUrl(QStringLiteral("https://myapps.developer.ubuntu.com/dev/api/click-framework/")))); |
516 | + connect(m_currentRequest,SIGNAL(finished()),this,SLOT(requestFinished())); |
517 | + connect(m_currentRequest,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(requestError())); |
518 | +} |
519 | + |
520 | +void UbuntuClickFrameworkProvider::readCache() |
521 | +{ |
522 | + QFile cache(m_cacheFilePath); |
523 | + if(!cache.exists() || !cache.open(QIODevice::ReadOnly)) { |
524 | + readDefaultValues(); |
525 | + return; |
526 | + } |
527 | + |
528 | + QStringList data = parseData(cache.readAll()); |
529 | + if(!data.isEmpty()) { |
530 | + m_frameworkCache = data; |
531 | + emit frameworksUpdated(); |
532 | + } else { |
533 | + //if the cache is empty fall back to the default values |
534 | + if(m_frameworkCache.isEmpty()) |
535 | + readDefaultValues(); |
536 | + } |
537 | +} |
538 | + |
539 | +void UbuntuClickFrameworkProvider::readDefaultValues() |
540 | +{ |
541 | + QFile cache(QStringLiteral(":/ubuntu/click-framework.json")); |
542 | + if(Q_UNLIKELY(cache.open(QIODevice::ReadOnly) == false)) { |
543 | + //This codepath is very unlikely, but lets still make sure there is a message to the user |
544 | + qWarning()<<"Could not read cache file OR default values. No frameworks are available to select from"; |
545 | + return; |
546 | + } |
547 | + |
548 | + QStringList data = parseData(cache.readAll()); |
549 | + if(!data.isEmpty()) { |
550 | + m_frameworkCache = data; |
551 | + emit frameworksUpdated(); |
552 | + } |
553 | +} |
554 | + |
555 | +QStringList UbuntuClickFrameworkProvider::parseData(const QByteArray &data) const |
556 | +{ |
557 | + QJsonParseError parseError; |
558 | + parseError.error = QJsonParseError::NoError; |
559 | + |
560 | + QJsonDocument doc = QJsonDocument::fromJson(data,&parseError); |
561 | + if(parseError.error != QJsonParseError::NoError) { |
562 | + qWarning()<< "Could not parse the framework cache: " |
563 | + << parseError.errorString(); |
564 | + return QStringList(); |
565 | + } |
566 | + |
567 | + QJsonObject obj = doc.object(); |
568 | + QStringList result = obj.keys(); |
569 | + qSort(result.begin(),result.end(),caseInsensitiveFWLessThan); |
570 | + |
571 | + return result; |
572 | +} |
573 | + |
574 | } // namespace Internal |
575 | } // namespace Ubuntu |
576 | |
577 | |
578 | === modified file 'src/ubuntu/ubuntuclicktool.h' |
579 | --- src/ubuntu/ubuntuclicktool.h 2014-09-28 09:15:53 +0000 |
580 | +++ src/ubuntu/ubuntuclicktool.h 2014-11-03 14:19:38 +0000 |
581 | @@ -33,6 +33,9 @@ |
582 | class QPlainTextEdit; |
583 | class QLabel; |
584 | class QAction; |
585 | +class QTimer; |
586 | +class QNetworkAccessManager; |
587 | +class QNetworkReply; |
588 | |
589 | namespace ProjectExplorer { |
590 | class Project; |
591 | @@ -71,8 +74,6 @@ |
592 | |
593 | static QString targetBasePath (const Target& target); |
594 | static bool getTargetFromUser (Target* target, const QString &framework=QString()); |
595 | - static QStringList getSupportedFrameworks (const Target *target); |
596 | - static QString getMostRecentFramework ( const QString &subFramework, const Target *target ); |
597 | |
598 | static bool targetExists (const Target& target); |
599 | static QList<Target> listAvailableTargets (const QString &framework=QString()); |
600 | @@ -85,6 +86,46 @@ |
601 | |
602 | QDebug operator<<(QDebug dbg, const UbuntuClickTool::Target& t); |
603 | |
604 | +class UbuntuClickFrameworkProvider : public QObject |
605 | +{ |
606 | + Q_OBJECT |
607 | + |
608 | +public: |
609 | + UbuntuClickFrameworkProvider(); |
610 | + static UbuntuClickFrameworkProvider *instance(); |
611 | + |
612 | + QStringList supportedFrameworks() const; |
613 | + QString mostRecentFramework ( const QString &subFramework); |
614 | + QString frameworkPolicy (const QString &fw) const; |
615 | + |
616 | + static QStringList getSupportedFrameworks (); |
617 | + static QString getMostRecentFramework ( const QString &subFramework); |
618 | + static QString getBaseFramework (const QString &framework, QStringList *extensions = 0); |
619 | + |
620 | +signals: |
621 | + void frameworksUpdated(); |
622 | + |
623 | +private slots: |
624 | + void requestFinished (); |
625 | + void requestError (); |
626 | + void updateFrameworks (bool force = false); |
627 | + |
628 | +private: |
629 | + void readCache (); |
630 | + void readDefaultValues (); |
631 | + QStringList parseData ( const QByteArray &data) const; |
632 | + |
633 | +private: |
634 | + QStringList m_frameworkCache; |
635 | + QString m_cacheFilePath; |
636 | + QMap<QString,QString> m_policyCache; |
637 | + |
638 | + QNetworkAccessManager *m_manager; |
639 | + QNetworkReply *m_currentRequest; |
640 | + QTimer *m_cacheUpdateTimer; |
641 | + static UbuntuClickFrameworkProvider *m_instance; |
642 | +}; |
643 | + |
644 | } // namespace Internal |
645 | } // namespace Ubuntu |
646 | |
647 | |
648 | === modified file 'src/ubuntu/ubuntuconstants.h' |
649 | --- src/ubuntu/ubuntuconstants.h 2014-10-13 15:33:46 +0000 |
650 | +++ src/ubuntu/ubuntuconstants.h 2014-11-03 14:19:38 +0000 |
651 | @@ -460,7 +460,7 @@ |
652 | const char UBUNTU_CLICK_OPEN_TERMINAL_ERROR[] = "Error when starting terminal"; |
653 | const char UBUNTU_CLICK_TARGETS_REGEX[] = "^%1-(.*)-([A-Za-z0-9]+)$"; |
654 | const char UBUNTU_CLICK_TARGETS_FRAMEWORK_REGEX[] = "^%1-(%2)-([A-Za-z0-9]+)$"; |
655 | -const char UBUNTU_CLICK_BASE_FRAMEWORK_REGEX[] = "(ubuntu-sdk-[0-9]{1,2}.[0-9]{1,2})"; |
656 | +const char UBUNTU_CLICK_BASE_FRAMEWORK_REGEX[] = "(ubuntu-(.*)-[0-9]{1,2}.[0-9]{1,2})"; |
657 | const char UBUNTU_CLICK_VERSION_REGEX[] = "^DISTRIB_RELEASE=([0-9]+)\\.([0-9]+)$"; |
658 | const char UBUNTU_CLICK_SERIES_REGEX[] = "^DISTRIB_CODENAME=([A-Za-z]+)$"; |
659 | |
660 | @@ -540,8 +540,8 @@ |
661 | const char UBUNTU_FRAMEWORK_14_10_BASENAME[] = "ubuntu-sdk-14.10"; |
662 | const char UBUNTU_FRAMEWORK_14_04_BASENAME[] = "ubuntu-sdk-14.04"; |
663 | const char UBUNTU_FRAMEWORK_13_10_BASENAME[] = "ubuntu-sdk-13.10"; |
664 | -const char UBUNTU_DEFAULT_QML_FRAMEWORK[] = "ubuntu-sdk-14.04-qml-dev1"; |
665 | -const char UBUNTU_DEFAULT_HTML_FRAMEWORK[] = "ubuntu-sdk-14.04-html"; |
666 | +const char UBUNTU_DEFAULT_QML_FRAMEWORK[] = "ubuntu-sdk-14.10-qml"; |
667 | +const char UBUNTU_DEFAULT_HTML_FRAMEWORK[] = "ubuntu-sdk-14.10-html"; |
668 | const char UBUNTU_UNKNOWN_FRAMEWORK_NAME[] = "Unknown framework"; |
669 | const int UBUNTU_UNKNOWN_FRAMEWORK_DATA = 0xdeadbeef; |
670 | |
671 | |
672 | === modified file 'src/ubuntu/ubuntumanifesteditorwidget.cpp' |
673 | --- src/ubuntu/ubuntumanifesteditorwidget.cpp 2014-08-19 06:15:32 +0000 |
674 | +++ src/ubuntu/ubuntumanifesteditorwidget.cpp 2014-11-03 14:19:38 +0000 |
675 | @@ -76,6 +76,9 @@ |
676 | connect(m_ui->lineEdit_name,SIGNAL(textChanged(QString)),this,SLOT(setDirty())); |
677 | connect(m_ui->lineEdit_title,SIGNAL(textChanged(QString)),this,SLOT(setDirty())); |
678 | connect(m_ui->lineEdit_version,SIGNAL(textChanged(QString)),this,SLOT(setDirty())); |
679 | + connect(UbuntuClickFrameworkProvider::instance(),SIGNAL(frameworksUpdated()),this,SLOT(updateFrameworkList())); |
680 | + |
681 | + updateFrameworkList(); |
682 | |
683 | return w; |
684 | } |
685 | @@ -148,31 +151,17 @@ |
686 | if(data != m_ui->lineEdit_description->text()) |
687 | m_ui->lineEdit_description->setText(data); |
688 | |
689 | - updateFrameworkList(); |
690 | - int idx = m_ui->comboBoxFramework->findText(m_manifest->frameworkName()); |
691 | - |
692 | //disable the currentIndexChanged signal, we need to check outselves if |
693 | //the data has changed |
694 | m_ui->comboBoxFramework->blockSignals(true); |
695 | - QVariant fwData = m_ui->comboBoxFramework->currentData(); |
696 | - |
697 | - //if the framework name is not valid set to empty item |
698 | - //just some data to easily find the unknown framework item without |
699 | - //using string compare |
700 | - if(idx < 0) { |
701 | - if(m_ui->comboBoxFramework->findData(Constants::UBUNTU_UNKNOWN_FRAMEWORK_DATA) < 0) |
702 | - m_ui->comboBoxFramework->addItem(tr(Constants::UBUNTU_UNKNOWN_FRAMEWORK_NAME),Constants::UBUNTU_UNKNOWN_FRAMEWORK_DATA); |
703 | - |
704 | - m_ui->comboBoxFramework->setCurrentIndex(m_ui->comboBoxFramework->count()-1); |
705 | - } else { |
706 | - m_ui->comboBoxFramework->setCurrentIndex(idx); |
707 | - m_ui->comboBoxFramework->removeItem(m_ui->comboBoxFramework->findData(Constants::UBUNTU_UNKNOWN_FRAMEWORK_DATA)); |
708 | - } |
709 | + |
710 | + QString fwText = m_ui->comboBoxFramework->currentText(); |
711 | + selectFramework(source->frameworkName()); |
712 | |
713 | m_ui->comboBoxFramework->blockSignals(false); |
714 | |
715 | //set the dirty flag manually in case something has changed |
716 | - if(m_ui->comboBoxFramework->currentData() != fwData) |
717 | + if(m_ui->comboBoxFramework->currentText() != fwText) |
718 | setDirty(); |
719 | |
720 | QSet<int> idxToKeep; |
721 | @@ -241,7 +230,7 @@ |
722 | m_manifest->setTitle(m_ui->lineEdit_title->text()); |
723 | m_manifest->setDescription(m_ui->lineEdit_description->text()); |
724 | |
725 | - if(m_ui->comboBoxFramework->currentText() != tr(Constants::UBUNTU_UNKNOWN_FRAMEWORK_NAME)) |
726 | + if(m_ui->comboBoxFramework->currentData() != Constants::UBUNTU_UNKNOWN_FRAMEWORK_DATA) |
727 | m_manifest->setFrameworkName(m_ui->comboBoxFramework->currentText()); |
728 | |
729 | for(int idx = 0; idx < m_ui->comboBoxHook->count(); idx++) { |
730 | @@ -266,7 +255,6 @@ |
731 | m_manifest->setHook(hook); |
732 | } |
733 | |
734 | - |
735 | QString result = m_manifest->raw()+QStringLiteral("\n"); |
736 | QString src = m_sourceEditor->toPlainText(); |
737 | if (result == src) |
738 | @@ -281,19 +269,36 @@ |
739 | |
740 | void UbuntuManifestEditorWidget::updateFrameworkList() |
741 | { |
742 | - const QString docPath(m_sourceEditor->baseTextDocument()->filePath()); |
743 | - |
744 | - const UbuntuClickTool::Target *t = 0; |
745 | - ProjectExplorer::Project* myProject = ubuntuProject(docPath); |
746 | - if (myProject) |
747 | - t = UbuntuClickTool::clickTargetFromTarget(myProject->activeTarget()); |
748 | - |
749 | m_ui->comboBoxFramework->blockSignals(true); |
750 | + |
751 | + //the current selected fw |
752 | + QString fwText = m_ui->comboBoxFramework->currentText(); |
753 | + |
754 | m_ui->comboBoxFramework->clear(); |
755 | - m_ui->comboBoxFramework->addItems(UbuntuClickTool::getSupportedFrameworks(t)); |
756 | + m_ui->comboBoxFramework->addItems(UbuntuClickFrameworkProvider::getSupportedFrameworks()); |
757 | + selectFramework(fwText); |
758 | m_ui->comboBoxFramework->blockSignals(false); |
759 | } |
760 | |
761 | +void UbuntuManifestEditorWidget::selectFramework (const QString &fw) |
762 | +{ |
763 | + // get the new Index for our new fw |
764 | + int idx = m_ui->comboBoxFramework->findText(fw); |
765 | + |
766 | + //if the framework name is not valid set to empty item |
767 | + //just some data to easily find the unknown framework item without |
768 | + //using string compare |
769 | + if(idx < 0) { |
770 | + if(m_ui->comboBoxFramework->findData(Constants::UBUNTU_UNKNOWN_FRAMEWORK_DATA) < 0) |
771 | + m_ui->comboBoxFramework->addItem(tr(Constants::UBUNTU_UNKNOWN_FRAMEWORK_NAME),Constants::UBUNTU_UNKNOWN_FRAMEWORK_DATA); |
772 | + |
773 | + m_ui->comboBoxFramework->setCurrentIndex(m_ui->comboBoxFramework->count()-1); |
774 | + } else { |
775 | + m_ui->comboBoxFramework->setCurrentIndex(idx); |
776 | + m_ui->comboBoxFramework->removeItem(m_ui->comboBoxFramework->findData(Constants::UBUNTU_UNKNOWN_FRAMEWORK_DATA)); |
777 | + } |
778 | +} |
779 | + |
780 | void UbuntuManifestEditorWidget::bzrChanged() |
781 | { |
782 | UbuntuBzr *bzr = UbuntuBzr::instance(); |
783 | @@ -314,13 +319,19 @@ |
784 | { |
785 | Core::DocumentModel *model = Core::EditorManager::documentModel(); |
786 | |
787 | + //make sure all changes are in the manifest instance |
788 | + syncToSource(); |
789 | + |
790 | + if(m_ui->comboBoxFramework->currentData() != Constants::UBUNTU_UNKNOWN_FRAMEWORK_DATA) { |
791 | + int idx = m_ui->comboBoxFramework->findData(Constants::UBUNTU_UNKNOWN_FRAMEWORK_DATA); |
792 | + if(idx >= 0) |
793 | + m_ui->comboBoxFramework->removeItem(idx); |
794 | + } |
795 | + |
796 | QString v = policyForFramework(m_ui->comboBoxFramework->currentText()); |
797 | if(v.isEmpty()) |
798 | return; |
799 | |
800 | - //make sure all changes are in the manifest instance |
801 | - syncToSource(); |
802 | - |
803 | QList<UbuntuClickManifest::Hook> hooks = m_manifest->hooks(); |
804 | foreach(const UbuntuClickManifest::Hook &hook, hooks){ |
805 | QFileInfo mFile(textEditorWidget()->baseTextDocument()->filePath()); |
806 | @@ -464,12 +475,7 @@ |
807 | |
808 | if(debug) qDebug()<<"Setting to "<<bzr->whoami(); |
809 | } else if (i.key() == QStringLiteral("framework")) { |
810 | - const UbuntuClickTool::Target *t = 0; |
811 | - ProjectExplorer::Project *p = ProjectExplorer::SessionManager::startupProject(); |
812 | - if (p) |
813 | - t = UbuntuClickTool::clickTargetFromTarget(p->activeTarget()); |
814 | - |
815 | - targetObject.insert(i.key(),UbuntuClickTool::getMostRecentFramework( QString(), t)); |
816 | + targetObject.insert(i.key(),UbuntuClickFrameworkProvider::getMostRecentFramework( QString())); |
817 | } else { |
818 | targetObject.insert(i.key(),i.value()); |
819 | |
820 | |
821 | === modified file 'src/ubuntu/ubuntumanifesteditorwidget.h' |
822 | --- src/ubuntu/ubuntumanifesteditorwidget.h 2014-08-19 06:15:32 +0000 |
823 | +++ src/ubuntu/ubuntumanifesteditorwidget.h 2014-11-03 14:19:38 +0000 |
824 | @@ -55,16 +55,17 @@ |
825 | bool syncToWidgets (UbuntuClickManifest *source); |
826 | void syncToSource (); |
827 | QWidget *createMainWidget(); |
828 | - void updateFrameworkList (); |
829 | void addMissingFieldsToManifest(QString fileName); |
830 | QString policyForFramework(const QString &fw); |
831 | |
832 | protected slots: |
833 | void bzrChanged (); |
834 | void onFrameworkChanged (); |
835 | + void updateFrameworkList (); |
836 | |
837 | private: |
838 | QWidget *createHookWidget (const UbuntuClickManifest::Hook &hook); |
839 | + void selectFramework(const QString &fw); |
840 | |
841 | private: |
842 | Ui::UbuntuManifestEditor *m_ui; |
843 | |
844 | === modified file 'src/ubuntu/ubuntuplugin.cpp' |
845 | --- src/ubuntu/ubuntuplugin.cpp 2014-10-20 19:24:50 +0000 |
846 | +++ src/ubuntu/ubuntuplugin.cpp 2014-11-03 14:19:38 +0000 |
847 | @@ -57,6 +57,7 @@ |
848 | #include <QtQml> |
849 | #include <QFile> |
850 | #include <coreplugin/icore.h> |
851 | +#include <stdint.h> |
852 | |
853 | using namespace Ubuntu; |
854 | using namespace Ubuntu::Internal; |
855 | @@ -95,6 +96,8 @@ |
856 | if (!Core::MimeDatabase::addMimeTypes(mimetypesXml, errorString)) |
857 | return false; |
858 | |
859 | + addAutoReleasedObject(new UbuntuClickFrameworkProvider); |
860 | + |
861 | m_ubuntuDeviceMode = new UbuntuDeviceMode(); |
862 | addAutoReleasedObject(m_ubuntuDeviceMode); |
863 |
PASSED: Continuous integration, rev:290 jenkins. qa.ubuntu. com/job/ qtcreator- plugin- ubuntu- ci/464/ jenkins. qa.ubuntu. com/job/ qtcreator- plugin- ubuntu- utopic- amd64-ci/ 232 jenkins. qa.ubuntu. com/job/ qtcreator- plugin- ubuntu- utopic- armhf-ci/ 232
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/qtcreator- plugin- ubuntu- ci/464/ rebuild
http://