on xenial help sign in
Make Get/GetAll const
7e97f61Michael Terry
tests/plugins/AccountsService/PropertiesServer.cpp+3−3
@@ -32,9 +32,9 @@ PropertiesServer::PropertiesServer(QObject *parent)
32 Reset();
32 Reset();
33}
33}
34
34
35−QDBusVariant PropertiesServer::Get(const QString &interface, const QString &property)
35+QDBusVariant PropertiesServer::Get(const QString &interface, const QString &property) const
36{
36{
37− if (m_properties[interface].contains(property)) {
37+ if (m_properties.contains(interface) && m_properties[interface].contains(property)) {
38 return QDBusVariant(m_properties[interface][property]);
38 return QDBusVariant(m_properties[interface][property]);
39 } else {
39 } else {
40 sendErrorReply(QDBusError::InvalidArgs, "Bad interface or property");
40 sendErrorReply(QDBusError::InvalidArgs, "Bad interface or property");
@@ -42,7 +42,7 @@ QDBusVariant PropertiesServer::Get(const QString &interface, const QString &prop
42 }
42 }
43}
43}
44
44
45−QVariantMap PropertiesServer::GetAll(const QString &interface)
45+QVariantMap PropertiesServer::GetAll(const QString &interface) const
46{
46{
47 if (m_properties.contains(interface)) {
47 if (m_properties.contains(interface)) {
48 return m_properties[interface];
48 return m_properties[interface];
tests/plugins/AccountsService/PropertiesServer.h+2−2
@@ -34,8 +34,8 @@ public:
34 explicit PropertiesServer(QObject *parent = 0);
34 explicit PropertiesServer(QObject *parent = 0);
35
35
36public Q_SLOTS:
36public Q_SLOTS:
37− QDBusVariant Get(const QString &interface, const QString &property);
37+ QDBusVariant Get(const QString &interface, const QString &property) const;
38− QVariantMap GetAll(const QString &interface);
38+ QVariantMap GetAll(const QString &interface) const;
39 void Set(const QString &interface, const QString &property, const QDBusVariant &variant);
39 void Set(const QString &interface, const QString &property, const QDBusVariant &variant);
40
40
41 // mock only.
41 // mock only.