172
172
QDir installationDir = QDir(webAppInstallLocation.absoluteFilePath());
174
//TODO search only for manifest.json
175
// Search for manifest & userscript
176
QFileInfoList manifest =
177
installationDir.entryInfoList(QStringList("*.json"), QDir::Files);
178
if (manifest.count() != 1) {
179
qDebug() << "Folder not being considered for webapp (no manifest file found): "
180
<< installationDir.absolutePath();
181
return WebappFileInfoOption();
184
QFileInfoList script =
185
installationDir.entryInfoList(QStringList("*.user.js"), QDir::Files);
186
if (script.count() != 1) {
187
qDebug() << "Folder not being considered for webapp (no userscript found): "
188
<< installationDir.absolutePath();
189
return WebappFileInfoOption();
192
return WebappFileInfoOption (WebappFileInfo (manifest[0].absoluteFilePath(), script[0].absoluteFilePath()));
174
// Search for manifest files & userscript
176
// The order here is important, the preferred filename is manifest.json
177
// which is still used in the desktop for regulat webapps, but in order
178
// to avoid name clashes w/ the click package manifest.json, the
179
// webapp-properties.json filename is searches first as a valid name
180
// and the regular manifest.json file used as a standard fallback.
181
QStringList manifestFileNames =
182
QStringList() << QString("webapp-properties.json")
183
<< QString("manifest.json");
187
Q_FOREACH(QString manifestFileName, manifestFileNames)
189
QFileInfo manifestFileInfo =
190
installationDir.absolutePath() + QDir::separator() + manifestFileName;
191
if ( ! manifestFileInfo.isFile()) {
192
qDebug() << "Skipping" << manifestFileName << "as a webapp definition search: "
193
<< manifestFileInfo.absoluteFilePath();
197
QString userScriptFilename;
198
QFileInfoList script =
199
installationDir.entryInfoList(QStringList("*.user.js"), QDir::Files);
200
if (script.count() >= 1) {
201
// Arbitrarily considering the "first" one
202
userScriptFilename = script[0].absoluteFilePath();
205
webappCandidateInfo = WebappFileInfoOption (WebappFileInfo (manifestFileInfo.absoluteFilePath(),
206
userScriptFilename));
211
return webappCandidateInfo;
196
215
UnityWebappsAppModel::getCandidateInstalledWebappsFolders (const QString& installationSearchPath)
217
// If the search path was overriden (not the default system one), we add the local
218
// path to the list of searched paths. The idea is to remove some of the potentially
219
// overloaded cruft (notably on UbuntuTouch or for simple installs/tests) the needed
220
// webapp file setup.
221
// We still do some possibly unecessary work of looking up in any unity-webapp-* subdir
222
// but in the general case that shouldn't be too much of a hassle.
198
224
QDir webappsDir(installationSearchPath);
199
return webappsDir.entryInfoList (QStringList(_webappDirPrefix + "*"), QDir::Dirs);
226
candidateWebappsFolders = webappsDir.entryInfoList (QStringList(_webappDirPrefix + "*")
228
if (installationSearchPath != getDefaultWebappsInstallationSearchPath())
230
QFileInfo localSearchPath(installationSearchPath);
231
if (localSearchPath.isDir())
233
candidateWebappsFolders.append(localSearchPath);
236
return candidateWebappsFolders;
202
239
void UnityWebappsAppModel::cleanup()