aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarja Hassinen <ext-marja.2.hassinen@nokia.com>2009-12-16 16:55:15 +0200
committerMarja Hassinen <ext-marja.2.hassinen@nokia.com>2009-12-16 16:55:15 +0200
commita9c09956f728d6469ad86f2388acb5a28b6c0a3c (patch)
tree97ab671ba3020f554b37faf6d7451b734c2a6ea1
parentd44af91c8a78de5c27e33d08d89dba6b087b87bc (diff)
Emit warnings if the key names have illegal characters.
Key names with - (and other non-A-Za-z0-9_/.-characters) have never worked even though we tried. Removing the trying and printing warnings instead, both in the subscriber and provider side.
-rw-r--r--libcontextprovider/src/property.cpp8
-rw-r--r--libcontextprovider/src/propertyadaptor.cpp4
-rw-r--r--libcontextsubscriber/src/contextkitplugin.cpp2
-rw-r--r--libcontextsubscriber/src/contextproperty.cpp5
4 files changed, 14 insertions, 5 deletions
diff --git a/libcontextprovider/src/property.cpp b/libcontextprovider/src/property.cpp
index 02181fdd..a3718738 100644
--- a/libcontextprovider/src/property.cpp
+++ b/libcontextprovider/src/property.cpp
@@ -44,7 +44,7 @@ namespace ContextProvider {
/// Create a Property object on \a service for the key \a k.
Property::Property(Service &service, const QString &k, QObject* parent)
- : QObject(parent)
+ : QObject(parent), priv(NULL)
{
init(service.backend, k);
}
@@ -52,7 +52,7 @@ Property::Property(Service &service, const QString &k, QObject* parent)
/// Create a Property object on the default service for the key \a k.
/// The default service can be set with Service::setAsDefault().
Property::Property(const QString &k, QObject* parent)
- : QObject(parent)
+ : QObject(parent), priv(NULL)
{
if (ServiceBackend::defaultServiceBackend == NULL) {
contextCritical() << "No default service set.";
@@ -68,6 +68,10 @@ Property::Property(const QString &k, QObject* parent)
void Property::init(ServiceBackend *serviceBackend, const QString &key)
{
contextDebug() << F_PROPERTY << "Creating new Property for key:" << key;
+ if (!QRegExp("[A-Za-z0-9_/.]+").exactMatch(key)) {
+ contextCritical() << "Invalid key name:" << key << ". Should match [A-Za-z0-9_/.]+";
+ abort();
+ }
QPair<ServiceBackend*, QString> lookup(serviceBackend, key);
diff --git a/libcontextprovider/src/propertyadaptor.cpp b/libcontextprovider/src/propertyadaptor.cpp
index a61a8e5b..bd38f0d1 100644
--- a/libcontextprovider/src/propertyadaptor.cpp
+++ b/libcontextprovider/src/propertyadaptor.cpp
@@ -150,10 +150,10 @@ void PropertyAdaptor::onServiceOwnerChanged(const QString &name, const QString &
QString PropertyAdaptor::objectPath() const
{
if (propertyPrivate->key.startsWith("/"))
- return QString(propertyPrivate->key);
+ return propertyPrivate->key;
return QString("/org/maemo/contextkit/") +
- QString(propertyPrivate->key).replace(".", "/").replace(QRegExp("[^A-Za-z0-9_/]"), "_");
+ QString(propertyPrivate->key).replace(".", "/");
}
diff --git a/libcontextsubscriber/src/contextkitplugin.cpp b/libcontextsubscriber/src/contextkitplugin.cpp
index 7419117f..23e0d0c8 100644
--- a/libcontextsubscriber/src/contextkitplugin.cpp
+++ b/libcontextsubscriber/src/contextkitplugin.cpp
@@ -75,7 +75,7 @@ QString ContextKitPlugin::keyToPath(QString key)
if (key.startsWith("/"))
return key;
- return corePrefix + key.replace('.', '/').replace(QRegExp("[^A-Za-z0-9_/]"), "_");
+ return corePrefix + key.replace('.', '/');
}
/// Inverse of \c keyToPath.
diff --git a/libcontextsubscriber/src/contextproperty.cpp b/libcontextsubscriber/src/contextproperty.cpp
index 30f29b45..3891cf81 100644
--- a/libcontextsubscriber/src/contextproperty.cpp
+++ b/libcontextsubscriber/src/contextproperty.cpp
@@ -261,6 +261,11 @@ void ContextProperty::subscribe() const
if (priv->subscribed)
return;
+ if (!QRegExp("[A-Za-z0-9_/.]+").exactMatch(key())) {
+ contextCritical() << "Invalid key name:" << key() << ". Should match [A-Za-z0-9_/.]+";
+ return;
+ }
+
// We create a queued connection, because otherwise we run
// the users' valueChanged() handlers with locks and if they do
// something fancy (for example unsubscribe) it can cause a