aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Vollmer <marius.vollmer@nokia.com>2010-01-21 13:40:09 +0200
committerMarius Vollmer <marius.vollmer@nokia.com>2010-01-21 13:40:09 +0200
commit49d9c5640e4e48b696a5f659a7e87bccbdb88103 (patch)
tree59165d28940786cb25bfe3e0fd3bd2d247a3cf0d
parentbebe762456d426a1013a4929ea7eb1d4cc1a3e98 (diff)
Parse deprecated flag in XML backend.
-rw-r--r--libcontextsubscriber/src/infokeydata.h1
-rw-r--r--libcontextsubscriber/src/infoxmlbackend.cpp7
-rw-r--r--libcontextsubscriber/unit-tests/infoxmlbackend/infoxmlbackendunittest.cpp13
-rw-r--r--libcontextsubscriber/unit-tests/infoxmlbackend/providers1.src3
4 files changed, 21 insertions, 3 deletions
diff --git a/libcontextsubscriber/src/infokeydata.h b/libcontextsubscriber/src/infokeydata.h
index 0be577c1..efbcecf0 100644
--- a/libcontextsubscriber/src/infokeydata.h
+++ b/libcontextsubscriber/src/infokeydata.h
@@ -39,6 +39,7 @@ struct InfoKeyData
QString name; ///< Name of the we're storing data for.
ContextTypeInfo typeInfo; ///< Type information of the key.
QString doc; ///< Doc for the key.
+ bool deprecated; ///< Whether the key is deprecated.
};
#endif // INFOKEYDATA_H
diff --git a/libcontextsubscriber/src/infoxmlbackend.cpp b/libcontextsubscriber/src/infoxmlbackend.cpp
index 910c48f3..70f4135e 100644
--- a/libcontextsubscriber/src/infoxmlbackend.cpp
+++ b/libcontextsubscriber/src/infoxmlbackend.cpp
@@ -103,7 +103,10 @@ bool InfoXmlBackend::keyDeclared(QString key) const
bool InfoXmlBackend::keyDeprecated(QString key) const
{
- return false;
+ if (! keyDataHash.contains(key))
+ return false;
+
+ return keyDataHash.value(key).deprecated;
}
/// Returns the full path to the registry directory. Takes the
@@ -250,6 +253,7 @@ void InfoXmlBackend::parseKey(const AssocTree &keyTree, const AssocTree &provide
QString plugin = providerTree.value("plugin").toString();
QString constructionString = providerTree.value("constructionString").toString();
QString doc = keyTree.value("doc").toString();
+ QVariant deprecated_node = keyTree.node("deprecated");
ContextTypeInfo typeInfo = keyTree.value("type");
typeInfo = typeInfo.ensureNewTypes(); // Make sure to get rid of old names (INTEGER...)
@@ -263,6 +267,7 @@ void InfoXmlBackend::parseKey(const AssocTree &keyTree, const AssocTree &provide
keyData.name = key;
keyData.typeInfo = typeInfo;
keyData.doc = doc;
+ keyData.deprecated = deprecated_node.isValid();
contextDebug() << F_XML << "Adding new key" << key << "with type:" << keyData.typeInfo.name();
keyDataHash.insert(key, keyData);
diff --git a/libcontextsubscriber/unit-tests/infoxmlbackend/infoxmlbackendunittest.cpp b/libcontextsubscriber/unit-tests/infoxmlbackend/infoxmlbackendunittest.cpp
index 2a70b616..85a0b456 100644
--- a/libcontextsubscriber/unit-tests/infoxmlbackend/infoxmlbackendunittest.cpp
+++ b/libcontextsubscriber/unit-tests/infoxmlbackend/infoxmlbackendunittest.cpp
@@ -59,6 +59,7 @@ private Q_SLOTS:
void typeInfoForKey();
void docForKey();
void keyDeclared();
+ void keyDeprecated();
void providersForKey();
void dynamics();
void cleanupTestCase();
@@ -96,7 +97,7 @@ void InfoXmlBackendUnitTest::listKeys()
QVERIFY(! keys.contains("System.ProcessingData"));
- QCOMPARE(keys.count(), 10);
+ QCOMPARE(keys.count(), 11);
QVERIFY(keys.contains("Battery.ChargePercentage"));
QVERIFY(keys.contains("Battery.LowBattery"));
QVERIFY(keys.contains("Key.With.Attribute"));
@@ -105,6 +106,7 @@ void InfoXmlBackendUnitTest::listKeys()
QVERIFY(keys.contains("Key.With.string"));
QVERIFY(keys.contains("Key.With.double"));
QVERIFY(keys.contains("Key.With.complex"));
+ QVERIFY(keys.contains("Key.Deprecated"));
QVERIFY(keys.contains("Battery.Charging"));
QVERIFY(keys.contains("Battery.Voltage"));
}
@@ -155,6 +157,13 @@ void InfoXmlBackendUnitTest::keyDeclared()
QCOMPARE(backend->keyDeclared("Battery.Charging"), true);
}
+void InfoXmlBackendUnitTest::keyDeprecated()
+{
+ QCOMPARE(backend->keyDeprecated("Key.With.bool"), false);
+ QCOMPARE(backend->keyDeprecated("Key.does.not.exist"), false);
+ QCOMPARE(backend->keyDeprecated("Key.Deprecated"), true);
+}
+
void InfoXmlBackendUnitTest::paths()
{
QVERIFY(InfoXmlBackend::registryPath() == QString("./") ||
@@ -177,7 +186,7 @@ void InfoXmlBackendUnitTest::dynamics()
{
// Sanity check
QStringList keys = backend->listKeys();
- QCOMPARE(keys.count(), 10);
+ QCOMPARE(keys.count(), 11);
QVERIFY(keys.contains("Battery.Charging"));
QCOMPARE(backend->keyDeclared("System.Active"), false);
diff --git a/libcontextsubscriber/unit-tests/infoxmlbackend/providers1.src b/libcontextsubscriber/unit-tests/infoxmlbackend/providers1.src
index e55c94b1..11e95001 100644
--- a/libcontextsubscriber/unit-tests/infoxmlbackend/providers1.src
+++ b/libcontextsubscriber/unit-tests/infoxmlbackend/providers1.src
@@ -17,4 +17,7 @@
<double min="0" max="10"/>
</type>
</key>
+ <key name="Key.Deprecated" type="string">
+ <deprecated/>
+ </key>
</provider>