diff options
author | Fabian Bumberger <fbumberger@rim.com> | 2012-10-12 13:38:31 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-18 00:58:15 (GMT) |
commit | 5e164f2bdd140860f98ade69fba0b7e4a11c94eb (patch) | |
tree | fbc9a24869835064ebf13f789487e3e3a211d3c6 /src/corelib | |
parent | 8869b3b30a29b1dd4218b3f5ac0bec9dd936b664 (diff) | |
download | Qt-5e164f2bdd140860f98ade69fba0b7e4a11c94eb.zip Qt-5e164f2bdd140860f98ade69fba0b7e4a11c94eb.tar.gz Qt-5e164f2bdd140860f98ade69fba0b7e4a11c94eb.tar.bz2 |
Blackberry: Populating the QCoreApplicationData
Backport of: 49f277482e86d21edf9a055229100486aaf8b4c0
Change-Id: I7549834efc86f834d549c9a4278f693a29b7ee11
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 4ee04da..3390438 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -376,6 +376,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(QLatin1String("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; @@ -2067,6 +2096,15 @@ QString QCoreApplication::applicationFilePath() #if defined(Q_WS_WIN) d->cachedApplicationFilePath = QFileInfo(qAppFileName()).filePath(); return d->cachedApplicationFilePath; +#elif defined(Q_OS_BLACKBERRY) + QDir dir(QLatin1String("./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_WS_MAC) QString qAppFileName_str = qAppFileName(); if(!qAppFileName_str.isEmpty()) { @@ -2301,6 +2339,9 @@ void QCoreApplication::setOrganizationName(const QString &orgName) QString QCoreApplication::organizationName() { +#ifdef Q_OS_BLACKBERRY + coreappdata()->loadManifest(); +#endif return coreappdata()->orgName; } @@ -2346,6 +2387,9 @@ void QCoreApplication::setApplicationName(const QString &application) QString QCoreApplication::applicationName() { +#ifdef Q_OS_BLACKBERRY + coreappdata()->loadManifest(); +#endif return coreappdata()->application; } @@ -2363,6 +2407,9 @@ void QCoreApplication::setApplicationVersion(const QString &version) QString QCoreApplication::applicationVersion() { +#ifdef Q_OS_BLACKBERRY + coreappdata()->loadManifest(); +#endif return coreappdata()->applicationVersion; } |