BlackBerry: Changed QSettings file access
On the BlackBerry platform, applications run in a sandbox. They are not allowed to read or write outside of this sandbox. Hence in QSettings there is no use for the system scope and differentiating between organization and application. This change will also improve performance. Change-Id: I79fee0140595385f3d33bd89fe5daa36b04836bc Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com> Reviewed-by: Fabian Bumberger <fbumberger@rim.com> Reviewed-by: Alan Alpert (RIM) <aalpert@rim.com>bb10
parent
131b863473
commit
146f63bea4
|
|
@ -1156,6 +1156,7 @@ QConfFileSettingsPrivate::QConfFileSettingsPrivate(QSettings::Format format,
|
|||
org = QLatin1String("Unknown Organization");
|
||||
}
|
||||
|
||||
#if !defined(Q_OS_BLACKBERRY)
|
||||
QString appFile = org + QDir::separator() + application + extension;
|
||||
QString orgFile = org + extension;
|
||||
|
||||
|
|
@ -1170,6 +1171,13 @@ QConfFileSettingsPrivate::QConfFileSettingsPrivate(QSettings::Format format,
|
|||
if (!application.isEmpty())
|
||||
confFiles[F_System | F_Application].reset(QConfFile::fromName(systemPath + appFile, false));
|
||||
confFiles[F_System | F_Organization].reset(QConfFile::fromName(systemPath + orgFile, false));
|
||||
#else
|
||||
QString confName = getPath(format, QSettings::UserScope) + org;
|
||||
if (!application.isEmpty())
|
||||
confName += QDir::separator() + application;
|
||||
confName += extension;
|
||||
confFiles[SandboxConfFile].reset(QConfFile::fromName(confName, true));
|
||||
#endif
|
||||
|
||||
for (i = 0; i < NumConfFiles; ++i) {
|
||||
if (confFiles[i]) {
|
||||
|
|
@ -2430,6 +2438,16 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
|
|||
running. Also, the locking isn't performed when accessing \c .plist
|
||||
files.
|
||||
|
||||
\o On the BlackBerry platform, applications run in a sandbox. They are not
|
||||
allowed to read or write outside of this sandbox. This involves the
|
||||
following limitations:
|
||||
\list
|
||||
\o As there is only a single scope the scope is simply ignored.
|
||||
\o The \l{Fallback Mechanism} is not applied, i.e. only a single
|
||||
location is considered.
|
||||
\o It is advised against setting and using custom file paths.
|
||||
\endlist
|
||||
|
||||
\endlist
|
||||
|
||||
\sa QVariant, QSessionManager, {Settings Editor Example}, {Application Example}
|
||||
|
|
|
|||
|
|
@ -239,11 +239,16 @@ public:
|
|||
because their values are respectively 1 and 2.
|
||||
*/
|
||||
enum {
|
||||
F_Application = 0x0,
|
||||
F_Organization = 0x1,
|
||||
F_User = 0x0,
|
||||
F_System = 0x2,
|
||||
NumConfFiles = 4
|
||||
#if !defined(Q_OS_BLACKBERRY)
|
||||
F_Application = 0x0,
|
||||
F_Organization = 0x1,
|
||||
F_User = 0x0,
|
||||
F_System = 0x2,
|
||||
NumConfFiles = 4
|
||||
#else
|
||||
SandboxConfFile = 0,
|
||||
NumConfFiles = 1
|
||||
#endif
|
||||
};
|
||||
|
||||
QSettings::Format format;
|
||||
|
|
|
|||
|
|
@ -368,11 +368,11 @@ void tst_QSettings::ctor()
|
|||
QVERIFY(settings3.applicationName() == "KillerAPP");
|
||||
QVERIFY(settings4.applicationName().isEmpty());
|
||||
|
||||
#if !defined(Q_OS_BLACKBERRY)
|
||||
/*
|
||||
Go forwards.
|
||||
*/
|
||||
settings4.setValue("key 1", QString("doodah"));
|
||||
|
||||
QCOMPARE(settings1.value("key 1").toString(), QString("doodah"));
|
||||
QCOMPARE(settings2.value("key 1").toString(), QString("doodah"));
|
||||
QCOMPARE(settings3.value("key 1").toString(), QString("doodah"));
|
||||
|
|
@ -425,6 +425,22 @@ void tst_QSettings::ctor()
|
|||
QCOMPARE(settings2.value("key 1").toString(), QString("bilboh"));
|
||||
QCOMPARE(settings3.value("key 1").toString(), QString("catha"));
|
||||
QCOMPARE(settings4.value("key 1").toString(), QString("quirko"));
|
||||
#else
|
||||
/*
|
||||
No fallback mechanism and a single scope on Blackberry OS
|
||||
*/
|
||||
settings2.setValue("key 1", QString("whoa"));
|
||||
QCOMPARE(settings2.value("key 1").toString(), QString("whoa"));
|
||||
QCOMPARE(settings4.value("key 1").toString(), QString("whoa"));
|
||||
QVERIFY(!settings1.contains("key 1"));
|
||||
QVERIFY(!settings3.contains("key 1"));
|
||||
|
||||
settings1.setValue("key 1", QString("blah"));
|
||||
QCOMPARE(settings1.value("key 1").toString(), QString("blah"));
|
||||
QCOMPARE(settings2.value("key 1").toString(), QString("whoa"));
|
||||
QCOMPARE(settings3.value("key 1").toString(), QString("blah"));
|
||||
QCOMPARE(settings4.value("key 1").toString(), QString("whoa"));
|
||||
#endif
|
||||
|
||||
/*
|
||||
Test the copies again.
|
||||
|
|
@ -461,10 +477,17 @@ void tst_QSettings::ctor()
|
|||
QSettings settings3(format, QSettings::SystemScope, "software.org", "KillerAPP");
|
||||
QSettings settings4(format, QSettings::SystemScope, "software.org");
|
||||
|
||||
#if !defined(Q_OS_BLACKBERRY)
|
||||
QCOMPARE(settings1.value("key 1").toString(), QString("gurgle"));
|
||||
QCOMPARE(settings2.value("key 1").toString(), QString("bilboh"));
|
||||
QCOMPARE(settings3.value("key 1").toString(), QString("catha"));
|
||||
QCOMPARE(settings4.value("key 1").toString(), QString("quirko"));
|
||||
#else
|
||||
QCOMPARE(settings1.value("key 1").toString(), QString("blah"));
|
||||
QCOMPARE(settings2.value("key 1").toString(), QString("whoa"));
|
||||
QCOMPARE(settings3.value("key 1").toString(), QString("blah"));
|
||||
QCOMPARE(settings4.value("key 1").toString(), QString("whoa"));
|
||||
#endif
|
||||
|
||||
/*
|
||||
Test problem keys.
|
||||
|
|
@ -1246,6 +1269,8 @@ void tst_QSettings::remove()
|
|||
settings1.setValue("key 1", "gurgle");
|
||||
QCOMPARE(settings1.value("key 1").toString(), QString("gurgle"));
|
||||
QCOMPARE(settings2.value("key 1").toString(), QString("whoa"));
|
||||
|
||||
#if !defined(Q_OS_BLACKBERRY)
|
||||
QCOMPARE(settings3.value("key 1").toString(), QString("blah"));
|
||||
QCOMPARE(settings4.value("key 1").toString(), QString("doodah"));
|
||||
|
||||
|
|
@ -1272,6 +1297,14 @@ void tst_QSettings::remove()
|
|||
QVERIFY(!settings2.contains("key 1"));
|
||||
QVERIFY(!settings3.contains("key 1"));
|
||||
QVERIFY(!settings4.contains("key 1"));
|
||||
#else
|
||||
settings1.remove("key 1");
|
||||
QCOMPARE(settings2.value("key 1").toString(), QString("whoa"));
|
||||
|
||||
settings2.remove("key 1");
|
||||
QVERIFY(!settings1.contains("key 1"));
|
||||
QVERIFY(!settings2.contains("key 1"));
|
||||
#endif
|
||||
|
||||
/*
|
||||
Get ready for the next part of the test.
|
||||
|
|
@ -1566,6 +1599,7 @@ void tst_QSettings::setFallbacksEnabled()
|
|||
main associated file when fallbacks are turned off.
|
||||
*/
|
||||
|
||||
#if !defined(Q_OS_BLACKBERRY)
|
||||
QCOMPARE(settings1.value("key 1").toString(), QString("alpha"));
|
||||
QCOMPARE(settings2.value("key 1").toString(), QString("beta"));
|
||||
QCOMPARE(settings3.value("key 1").toString(), QString("gamma"));
|
||||
|
|
@ -1595,6 +1629,22 @@ void tst_QSettings::setFallbacksEnabled()
|
|||
QCOMPARE(settings1.value("key 5").toString(), QString(""));
|
||||
QVERIFY(settings1.contains("key 1"));
|
||||
QVERIFY(!settings1.contains("key 5"));
|
||||
#else
|
||||
QCOMPARE(settings1.value("key 1").toString(), QString("gamma"));
|
||||
QCOMPARE(settings2.value("key 1").toString(), QString("delta"));
|
||||
QCOMPARE(settings3.value("key 1").toString(), QString("gamma"));
|
||||
QCOMPARE(settings4.value("key 1").toString(), QString("delta"));
|
||||
|
||||
QCOMPARE(settings1.value("key 2").toString(), QString("gamma"));
|
||||
QCOMPARE(settings2.value("key 2").toString(), QString("beta"));
|
||||
QCOMPARE(settings3.value("key 2").toString(), QString("gamma"));
|
||||
QCOMPARE(settings4.value("key 2").toString(), QString("beta"));
|
||||
|
||||
QCOMPARE(settings1.value("key 3").toString(), QString("gamma"));
|
||||
QCOMPARE(settings2.value("key 3").toString(), QString("delta"));
|
||||
QCOMPARE(settings3.value("key 3").toString(), QString("gamma"));
|
||||
QCOMPARE(settings4.value("key 3").toString(), QString("delta"));
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QSettings::testChildKeysAndGroups_data()
|
||||
|
|
@ -2288,6 +2338,7 @@ void tst_QSettings::testArrays()
|
|||
}
|
||||
settings2.endArray();
|
||||
|
||||
#if !defined (Q_OS_BLACKBERRY)
|
||||
size1 = settings1.beginReadArray("strings");
|
||||
QCOMPARE(size1, 3);
|
||||
|
||||
|
|
@ -2298,6 +2349,7 @@ void tst_QSettings::testArrays()
|
|||
QCOMPARE(str, fiveStrings.at(i));
|
||||
}
|
||||
settings1.endArray();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef QT_BUILD_INTERNAL
|
||||
|
|
@ -2970,6 +3022,7 @@ void tst_QSettings::setPath()
|
|||
path checks that it has no bad side effects.
|
||||
*/
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
#if !defined(Q_OS_BLACKBERRY)
|
||||
#if !defined(Q_OS_WIN) && !defined(Q_OS_MAC)
|
||||
TEST_PATH(i == 0, "conf", NativeFormat, UserScope, "alpha")
|
||||
TEST_PATH(i == 0, "conf", NativeFormat, SystemScope, "beta")
|
||||
|
|
@ -2980,6 +3033,12 @@ void tst_QSettings::setPath()
|
|||
TEST_PATH(i == 0, "custom1", CustomFormat1, SystemScope, "zeta")
|
||||
TEST_PATH(i == 0, "custom2", CustomFormat2, UserScope, "eta")
|
||||
TEST_PATH(i == 0, "custom2", CustomFormat2, SystemScope, "iota")
|
||||
#else // Q_OS_BLACKBERRY: no system scope
|
||||
TEST_PATH(i == 0, "conf", NativeFormat, UserScope, "alpha")
|
||||
TEST_PATH(i == 0, "ini", IniFormat, UserScope, "gamma")
|
||||
TEST_PATH(i == 0, "custom1", CustomFormat1, UserScope, "epsilon")
|
||||
TEST_PATH(i == 0, "custom2", CustomFormat2, UserScope, "eta")
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue