21 #include <QCoreApplication>
24 #include <QTextStream>
29 const QString ProvisioningInfo::intermediateOutDir = QString(CMAKE_INTDIR);
31 const QString ProvisioningInfo::intermediateOutDir = QString();
38 void ProvisioningInfo::readProvisioningFile(
const QString &filePath)
41 file.open(QFile::ReadOnly);
42 QTextStream fileStream(&file);
48 line = fileStream.readLine().trimmed();
49 if (!line.isEmpty() && !line.startsWith(
'#'))
51 QString keyword = line.section(sep, 0, 0);
52 QString value = line.mid(keyword.size()).trimmed();
53 value = substituteKeywords(value);
55 if (keyword.isEmpty())
57 MITK_WARN <<
"Keyword missing in line " << count <<
" of provisioning file " << filePath.toStdString();
61 Keyword key = UNKNOWN;
62 if (keyword.compare(
"READ", Qt::CaseInsensitive) == 0)
66 else if (keyword.compare(
"INSTALL", Qt::CaseInsensitive) == 0)
70 else if (keyword.compare(
"START", Qt::CaseInsensitive) == 0)
74 else if (keyword.compare(
"STOP", Qt::CaseInsensitive) == 0)
81 MITK_WARN <<
"Keyword " << keyword.toStdString() <<
" in line " << count <<
" of provisioning file "
82 << filePath.toStdString() <<
" unknown";
88 MITK_WARN <<
"Value after keyword " << keyword.toStdString() <<
" missing in line " << count
89 <<
" of provisioning file " << filePath.toStdString();
97 QUrl readFileUrl(value);
98 if (!readFileUrl.isValid())
100 MITK_WARN <<
"The READ URL " << value.toStdString()
101 <<
"is invalid: " << readFileUrl.errorString().toStdString();
104 this->readProvisioningFile(readFileUrl.toLocalFile());
109 this->addPluginToInstall(value);
114 this->addPluginToStart(value);
128 }
while (!line.isNull());
131 QUrl ProvisioningInfo::addPluginToInstall(
const QString &file)
133 QUrl pluginUrl(file);
134 if (!pluginUrl.isValid())
136 MITK_WARN <<
"The plugin URL " << file.toStdString() <<
" is invalid:" << pluginUrl.errorString().toStdString();
140 QFileInfo fileInfo(pluginUrl.toLocalFile());
141 if (!fileInfo.exists())
143 QString fileName = fileInfo.fileName();
144 QString filePath = fileInfo.absolutePath();
145 if (!intermediateOutDir.isEmpty())
148 QString filePath2 = filePath +
"/" + intermediateOutDir;
149 fileInfo = QFileInfo(filePath2 +
"/" + fileName);
150 if (!fileInfo.exists())
152 MITK_WARN <<
"The plugin " << fileName.toStdString() <<
" was not found in " << filePath.toStdString()
153 <<
" or " << filePath2.toStdString();
156 pluginUrl = QUrl::fromLocalFile(fileInfo.canonicalFilePath());
157 pluginDirs.insert(fileInfo.canonicalPath());
161 MITK_WARN <<
"The plugin " << fileName.toStdString() <<
" was not found in " << filePath.toStdString();
167 pluginDirs.insert(fileInfo.canonicalPath());
170 pluginsToInstall.append(pluginUrl);
174 void ProvisioningInfo::addPluginToStart(
const QString &file)
176 QUrl pluginUrl = this->addPluginToInstall(file);
177 if (!pluginUrl.isEmpty())
179 pluginsToStart.append(pluginUrl);
183 QString ProvisioningInfo::substituteKeywords(
const QString &value)
const
185 QString appPath = QCoreApplication::applicationDirPath();
186 if (appPath.endsWith(
'/'))
193 QString intDir(CMAKE_INTDIR);
194 if (appPath.endsWith(intDir))
196 appPath.chop(intDir.size() + 1);
201 if (value.contains(
"@EXECUTABLE_DIR") && value.contains(
"blueberry_osgi"))
204 return QString(value).replace(
"@EXECUTABLE_DIR", appPath, Qt::CaseInsensitive).replace(
"plugins/",
"");
208 return QString(value).replace(
"@EXECUTABLE_DIR", appPath, Qt::CaseInsensitive);
DataCollection - Class to facilitate loading/accessing structured data.
QStringList getPluginDirs() const
QList< QUrl > getPluginsToInstall() const
ProvisioningInfo(const QString &file)
QList< QUrl > getPluginsToStart() const