summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorFabian Bumberger <fbumberger@rim.com>2012-10-09 19:34:29 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-13 05:51:19 +0200
commit49f277482e86d21edf9a055229100486aaf8b4c0 (patch)
treef024bf5e91497166eb1118fa6bcf676594a73f77 /src/corelib/kernel
parenta1082dbc3f61f1747bd756f8fce2a54f558793ed (diff)
Blackberry: Populating the QCoreApplicationData
Change-Id: I7adb2e207cab89fbad9458cd0bcb856ecd2288f0 Reviewed-by: Peter Hartmann <phartmann@rim.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index fd423d4479..1e4a6f4c8c 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -264,6 +264,35 @@ struct QCoreApplicationData {
data->deref(); // deletes the data and the adopted thread
}
}
+
+#ifdef Q_OS_BLACKBERRY
+ //The QCoreApplicationData struct is only populated on demand, because it is rarely needed and would
+ //affect startup time
+ void loadManifest() {
+ static bool manifestLoadAttempt = false;
+ if (manifestLoadAttempt)
+ return;
+
+ manifestLoadAttempt = true;
+
+ QFile metafile(QStringLiteral("app/META-INF/MANIFEST.MF"));
+ if (!metafile.open(QIODevice::ReadOnly)) {
+ qWarning() << Q_FUNC_INFO << "Could not open application metafile for reading";
+ } else {
+ while (!metafile.atEnd() && (application.isEmpty() || applicationVersion.isEmpty() || orgName.isEmpty())) {
+ QByteArray line = metafile.readLine();
+ if (line.startsWith("Application-Name:"))
+ application = QString::fromUtf8(line.mid(18).trimmed());
+ else if (line.startsWith("Application-Version:"))
+ applicationVersion = QString::fromUtf8(line.mid(21).trimmed());
+ else if (line.startsWith("Package-Author:"))
+ orgName = QString::fromUtf8(line.mid(16).trimmed());
+ }
+ metafile.close();
+ }
+ }
+#endif
+
QString orgName, orgDomain, application;
QString applicationVersion;
@@ -1765,6 +1794,15 @@ QString QCoreApplication::applicationFilePath()
#if defined(Q_OS_WIN)
d->cachedApplicationFilePath = QFileInfo(qAppFileName()).filePath();
return d->cachedApplicationFilePath;
+#elif defined(Q_OS_BLACKBERRY)
+ QDir dir(QStringLiteral("./app/native/"));
+ QStringList executables = dir.entryList(QDir::Executable | QDir::Files);
+ if (!executables.empty()) {
+ //We assume that there is only one executable in the folder
+ return dir.absoluteFilePath(executables.first());
+ } else {
+ return QString();
+ }
#elif defined(Q_OS_MAC)
QString qAppFileName_str = qAppFileName();
if(!qAppFileName_str.isEmpty()) {
@@ -1930,6 +1968,9 @@ void QCoreApplication::setOrganizationName(const QString &orgName)
QString QCoreApplication::organizationName()
{
+#ifdef Q_OS_BLACKBERRY
+ coreappdata()->loadManifest();
+#endif
return coreappdata()->orgName;
}
@@ -1977,6 +2018,9 @@ void QCoreApplication::setApplicationName(const QString &application)
QString QCoreApplication::applicationName()
{
+#ifdef Q_OS_BLACKBERRY
+ coreappdata()->loadManifest();
+#endif
QString appname = coreappdata() ? coreappdata()->application : QString();
if (appname.isEmpty() && QCoreApplication::self)
appname = QCoreApplication::self->d_func()->appName();
@@ -2003,6 +2047,9 @@ void QCoreApplication::setApplicationVersion(const QString &version)
QString QCoreApplication::applicationVersion()
{
+#ifdef Q_OS_BLACKBERRY
+ coreappdata()->loadManifest();
+#endif
return coreappdata()->applicationVersion;
}