Update AMB with amb-qt(qml) plugins to latest
[AGL/meta-agl.git] / meta-ivi-common / recipes-automotive / automotive-message-broker / automotive-message-broker / 0007-WORKAROUND-Allow-amb-qt-binding-to-work-in-case-of-m.patch
1 From 5de4c1f8e0d5fb22a6d2927d3526498de2b21cbe Mon Sep 17 00:00:00 2001
2 From: Petr Nechaev <petr.nechaev@cogentembedded.com>
3 Date: Fri, 31 Jul 2015 20:22:36 +0300
4 Subject: [PATCH 7/9] [WORKAROUND] Allow amb-qt binding to work in case of
5  multiple properties
6
7 ---
8  docs/amb.in.fidl                   |  21 ++++
9  plugins/dbus/amb-qt/CMakeLists.txt |   2 +-
10  plugins/dbus/amb-qt/ambqt.cpp      | 237 ++++++++++++++++++++++++++-----------
11  plugins/dbus/amb-qt/ambqt.h        |  59 ++++-----
12  plugins/dbus/amb-qt/ambqtquick.cpp |  22 +++-
13  plugins/dbus/amb-qt/ambqtquick.h   |  22 +++-
14  plugins/dbus/amb-qt/qmldir         |   1 +
15  plugins/dbus/amb-qt/test.cpp       |  26 +++-
16  plugins/dbus/automotivemanager.cpp |  65 ++++++++++
17  9 files changed, 350 insertions(+), 105 deletions(-)
18
19 diff --git a/docs/amb.in.fidl b/docs/amb.in.fidl
20 index 398a33d..27d2827 100644
21 --- a/docs/amb.in.fidl
22 +++ b/docs/amb.in.fidl
23 @@ -220,6 +220,27 @@ interface org.automotive.Manager  {
24    }
25  
26    /*!
27 +   * FindObjectsForZone
28 +   *  \brief find the DBus object path which matches "objectName" and "zone".  This has the same behavior as FindObject
29 +   * except that it takes an addition zone argument and only return the path for that zone.
30 +   *  \arg String property is the requested property to be retrieved.
31 +   *  \arg Zone zone is the zone which the object
32 +   *  \return list of object paths that provide the given object Name.
33 +   *  Possible errors:
34 +   * "org.automotive.Manager.InvalidZone"
35 +   * "org.automotive.Manager.ObjectNotFound"
36 +  */
37 +  method FindObjectsForZone {
38 +        in {
39 +          String objectName
40 +          Zone zone
41 +        }
42 +        out {
43 +          array of String objectPath
44 +        }
45 +  }
46 +
47 +  /*!
48     * ZonesForObjectName
49     *  \brief get a list of zones for a given objectName.
50     *  \arg String objectName object name.
51 diff --git a/plugins/dbus/amb-qt/CMakeLists.txt b/plugins/dbus/amb-qt/CMakeLists.txt
52 index 2f2a2a8..42b7fb4 100644
53 --- a/plugins/dbus/amb-qt/CMakeLists.txt
54 +++ b/plugins/dbus/amb-qt/CMakeLists.txt
55 @@ -16,7 +16,7 @@ endif(Qt5Core_FOUND)
56  
57  set(ambqt_headers ambqt.h amb-qt_global.h)
58  set(ambqt_sources ambqt.cpp)
59 -set(ambqtquick_sources ambqtquick.cpp)
60 +set(ambqtquick_sources ambqtquick.cpp qmldir)
61  set(ambqtquick_headers ambqtquick.h)
62  
63  include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs} ${QT_INCLUDE_DIRS})
64 diff --git a/plugins/dbus/amb-qt/ambqt.cpp b/plugins/dbus/amb-qt/ambqt.cpp
65 index 6a3faeb..c8f1faf 100644
66 --- a/plugins/dbus/amb-qt/ambqt.cpp
67 +++ b/plugins/dbus/amb-qt/ambqt.cpp
68 @@ -1,92 +1,189 @@
69 +/*
70 +Copyright (C) 2012 Intel Corporation
71 +Copyright (C) 2015 Cogent Embedded Inc.
72 +
73 +This library is free software; you can redistribute it and/or
74 +modify it under the terms of the GNU Lesser General Public
75 +License as published by the Free Software Foundation; either
76 +version 2.1 of the License, or (at your option) any later version.
77 +
78 +This library is distributed in the hope that it will be useful,
79 +but WITHOUT ANY WARRANTY; without even the implied warranty of
80 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
81 +Lesser General Public License for more details.
82 +
83 +You should have received a copy of the GNU Lesser General Public
84 +License along with this library; if not, write to the Free Software
85 +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
86 +*/
87  #include "ambqt.h"
88  #include <QDBusConnection>
89  #include <QDBusInterface>
90  #include <QtDebug>
91  #include <QDBusReply>
92  
93 -AmbProperty::AmbProperty(QString op, QString iface, QString propName)
94 -       :QObject(), mPropertyName(propName),mInterfaceName(iface), mObjectPath(op),mDBusInterface(NULL),mZone(0)
95 +AmbProperty::AmbProperty(QString objectName, QString propName)
96 +    :QObject(), mObjectName(objectName), mPropertyName(propName), mZone(0), managerIface(NULL)
97  {
98 -       connect();
99 +    // Automatically connect when all properties have been set
100 +    connect();
101  }
102  
103  
104 -void AmbProperty::propertyChangedSlot(QString, QVariantMap values, QVariantMap )
105 +void AmbProperty::propertyChangedSlot(QString, QVariantMap values, QStringList )
106  {
107 -       valueChanged(values);
108 +    // try to get value
109 +    mValue = values[mPropertyName];
110 +
111 +    // try to parse time
112 +    QVariant timeVariant = values["Time"];
113 +    bool ok = false;
114 +    double NewTime = 0;
115 +    if (timeVariant.isValid())
116 +        NewTime = timeVariant.toDouble(&ok);
117 +    if (ok)
118 +        mTime = NewTime;
119 +
120 +    // emit the signal
121 +    valueChanged(mValue);
122  }
123  
124 -void AmbProperty::propertyChanged1(QDBusVariant val, double t)
125 +void AmbProperty::connect()
126  {
127 -       mTime = t;
128 -       mValue = val.variant();
129 -
130 -       signalChanged(mValue);
131 +    if (managerIface)
132 +        disconnect();
133 +
134 +    managerIface = new QDBusInterface("org.automotive.message.broker","/","org.automotive.Manager", QDBusConnection::systemBus(), this);
135 +
136 +    if(!managerIface->isValid())
137 +    {
138 +        qWarning()<<"Failed to create manager interface";
139 +        delete managerIface;
140 +        return;
141 +    }
142 +
143 +    QDBusReply<QList<QDBusObjectPath>> reply = managerIface->call("FindObjectsForZone", mObjectName, mZone);
144 +
145 +    if(reply.isValid())
146 +    {
147 +        for (int i=0; i < reply.value().size(); ++i)
148 +        {
149 +            QDBusInterface* mDBusInterface = new QDBusInterface("org.automotive.message.broker",
150 +                                                                reply.value().at(i).path(),
151 +                                                                "org.freedesktop.DBus.Properties",
152 +                                                                QDBusConnection::systemBus(),
153 +                                                                this);
154 +
155 +            if(!mDBusInterface->isValid())
156 +            {
157 +                qDebug()<<"Failed to create dbus interface for property "<<propertyName();
158 +                qDebug()<<"path: "<< reply.value().at(i).path();
159 +                qDebug()<<"object: "<< objectName();
160 +                qDebug()<<"property: "<< propertyName();
161 +                qDebug()<<"Error: "<<QDBusConnection::systemBus().lastError().message();
162 +            }
163 +
164 +            // store object interface for future use
165 +            ServerProperties.append(mDBusInterface);
166 +
167 +            if(!QDBusConnection::systemBus().connect("org.automotive.message.broker",
168 +                                                     reply.value().at(i).path(),
169 +                                                     "org.freedesktop.DBus.Properties",
170 +                                                     "PropertiesChanged",
171 +                                                     this,
172 +                                                     SLOT(propertyChangedSlot(QString,QVariantMap,QStringList))))
173 +            {
174 +                qDebug()<<"Failed to connect to signal";
175 +                qDebug()<<"path: "<< reply.value().at(i).path();
176 +                qDebug()<<"object: "<< objectName();
177 +                qDebug()<<"property: "<< propertyName();
178 +                qDebug()<<"Error: "<< QDBusConnection::systemBus().lastError().message();
179 +            }
180 +        }
181 +    }
182 +
183 +    //    if(mInterfaceName.isEmpty())
184 +    //        mInterfaceName = "org.automotive."+mPropertyName;
185 +
186 +    //    mDBusInterface = new QDBusInterface("org.automotive.message.broker",objectPath(), interfaceName(), QDBusConnection::systemBus(),this);
187 +
188 +    //    if(!mDBusInterface->isValid())
189 +    //    {
190 +    //        qDebug()<<"Failed to create dbus interface for property "<<propertyName();
191 +    //        qDebug()<<"Path: "<<objectPath();
192 +    //        qDebug()<<"Interface: "<<interfaceName();
193 +    //        qDebug()<<"Error: "<<QDBusConnection::systemBus().lastError().message();
194 +    //    }
195 +
196 +    //    QString signalName = propertyName() + "Changed";
197 +
198 +
199 +
200 +    //    ///TODO: only use PropertiesChanged...  treat AmbProperty like an object rather than a representation of just a single property in the object
201 +
202 +    //    if(!QDBusConnection::systemBus().connect("org.automotive.message.broker", objectPath(), mInterfaceName,
203 +    //                                             signalName, this, SLOT(propertyChanged1(QDBusVariant,double))))
204 +    //    {
205 +    //        qDebug()<<"Failed to connect to signal";
206 +    //        qDebug()<<"path: "<<objectPath();
207 +    //        qDebug()<<"interface: "<<interfaceName();
208 +    //        qDebug()<<"signal: "<<propertyName();
209 +    //        qDebug()<<"Error: "<<QDBusConnection::systemBus().lastError().message();
210 +    //    }
211  }
212  
213 -void AmbProperty::connect()
214 +void AmbProperty::disconnect()
215  {
216 -       if(mDBusInterface)
217 -       {
218 -               delete mDBusInterface;
219 -       }
220 -
221 -       if(mObjectPath.isEmpty())
222 -               getObjectPath();
223 -
224 -       if(mInterfaceName.isEmpty())
225 -               mInterfaceName = "org.automotive."+mPropertyName;
226 -
227 -       mDBusInterface = new QDBusInterface("org.automotive.message.broker",objectPath(), interfaceName(), QDBusConnection::systemBus(),this);
228 -
229 -       if(!mDBusInterface->isValid())
230 -       {
231 -               qDebug()<<"Failed to create dbus interface for property "<<propertyName();
232 -               qDebug()<<"Path: "<<objectPath();
233 -               qDebug()<<"Interface: "<<interfaceName();
234 -               qDebug()<<"Error: "<<QDBusConnection::systemBus().lastError().message();
235 -       }
236 -
237 -       QString signalName = propertyName() + "Changed";
238 -
239 -
240 -       if(!QDBusConnection::systemBus().connect("org.automotive.message.broker", objectPath(), "org.freedesktop.DBus.Properties",
241 -                                                                                        "PropertiesChanged", this, SLOT(propertyChangedSlot(QString,QVariantMap,QVariantMap))))
242 -       {
243 -               qDebug()<<"Failed to connect to signal";
244 -               qDebug()<<"path: "<<objectPath();
245 -               qDebug()<<"interface: "<<interfaceName();
246 -               qDebug()<<"signal: "<<propertyName();
247 -               qDebug()<<"Error: "<<QDBusConnection::systemBus().lastError().message();
248 -       }
249 -
250 -       ///TODO: only use PropertiesChanged...  treat AmbProperty like an object rather than a representation of just a single property in the object
251 -
252 -       if(!QDBusConnection::systemBus().connect("org.automotive.message.broker", objectPath(), mInterfaceName,
253 -                                                                                        signalName, this, SLOT(propertyChanged1(QDBusVariant,double))))
254 -       {
255 -               qDebug()<<"Failed to connect to signal";
256 -               qDebug()<<"path: "<<objectPath();
257 -               qDebug()<<"interface: "<<interfaceName();
258 -               qDebug()<<"signal: "<<propertyName();
259 -               qDebug()<<"Error: "<<QDBusConnection::systemBus().lastError().message();
260 -       }
261 +    delete managerIface;
262 +    managerIface = NULL;
263 +
264 +    QDBusReply<QList<QDBusObjectPath>> reply = managerIface->call("FindObjectsForZone", mObjectName, mZone);
265 +
266 +    if(reply.isValid())
267 +    {
268 +        for (int i=0; i < reply.value().size(); ++i)
269 +        {
270 +            QDBusConnection::systemBus().disconnect("org.automotive.message.broker",
271 +                                                    reply.value().at(i).path(),
272 +                                                    "org.freedesktop.DBus.Properties",
273 +                                                    "PropertiesChanged",
274 +                                                    this,
275 +                                                    SLOT(propertyChangedSlot(QString,QVariantMap,QStringList)));
276 +        }
277 +    }
278 +
279 +    for (int i = 0; i < ServerProperties.size(); ++i)
280 +        delete ServerProperties[i];
281 +
282 +    ServerProperties.clear();
283  }
284  
285 -void AmbProperty::getObjectPath()
286 +QVariant AmbProperty::updateValue()
287  {
288 -       QDBusInterface managerIface("org.automotive.message.broker","/","org.automotive.Manager", QDBusConnection::systemBus(), this);
289 -
290 -       if(!managerIface.isValid())
291 -       {
292 -               qDebug()<<"Failed to create manager interface";
293 -               return;
294 -       }
295 -
296 -       QDBusReply<QDBusObjectPath> reply = managerIface.call("FindObjectForZone", mPropertyName, mZone);
297 +    for (int i = 0; i < ServerProperties.size(); ++i)
298 +    {
299 +        if (!ServerProperties[i]->isValid())
300 +        {
301 +            qDebug()<<"error Interface is not valid "<<ServerProperties[i]->objectName();
302 +        }
303 +
304 +        QVariant v = ServerProperties[i]->property(propertyName().toUtf8());
305 +
306 +        if (v.isValid())
307 +            return v;
308 +    }
309 +}
310  
311 -       if(reply.isValid())
312 -       {
313 -               mObjectPath = reply.value().path();
314 -       }
315 +void AmbProperty::setValue(QVariant v)
316 +{
317 +    for (int i = 0; i < ServerProperties.size(); ++i)
318 +    {
319 +        if (!ServerProperties[i]->isValid())
320 +        {
321 +            qDebug()<<"error Interface is not valid "<<ServerProperties[i]->objectName();
322 +        }
323 +
324 +        ServerProperties[i]->setProperty(propertyName().toUtf8(), v);
325 +    }
326  }
327 +
328 diff --git a/plugins/dbus/amb-qt/ambqt.h b/plugins/dbus/amb-qt/ambqt.h
329 index 3d7e793..6510daa 100644
330 --- a/plugins/dbus/amb-qt/ambqt.h
331 +++ b/plugins/dbus/amb-qt/ambqt.h
332 @@ -1,3 +1,21 @@
333 +/*
334 +Copyright (C) 2012 Intel Corporation
335 +Copyright (C) 2015 Cogent Embedded Inc.
336 +
337 +This library is free software; you can redistribute it and/or
338 +modify it under the terms of the GNU Lesser General Public
339 +License as published by the Free Software Foundation; either
340 +version 2.1 of the License, or (at your option) any later version.
341 +
342 +This library is distributed in the hope that it will be useful,
343 +but WITHOUT ANY WARRANTY; without even the implied warranty of
344 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
345 +Lesser General Public License for more details.
346 +
347 +You should have received a copy of the GNU Lesser General Public
348 +License along with this library; if not, write to the Free Software
349 +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
350 +*/
351  #ifndef AMBQT_H
352  #define AMBQT_H
353  
354 @@ -17,57 +35,44 @@ class QDBusInterface;
355  class AmbProperty: public QObject
356  {
357         Q_OBJECT
358 -       Q_PROPERTY(QString propertyName READ propertyName WRITE setPropertyName)
359 +    Q_PROPERTY(QString objectName READ objectName WRITE setObjectName)
360 +    AUTOPROPERTY(QString, objectName, ObjectName)
361 +    Q_PROPERTY(QString propertyName READ propertyName WRITE setPropertyName)
362         AUTOPROPERTY(QString, propertyName, PropertyName)
363 -       Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
364 -       Q_PROPERTY(QString interfaceName READ interfaceName WRITE setInterfaceName)
365 -       AUTOPROPERTY(QString, interfaceName, InterfaceName)
366 -       Q_PROPERTY(QString objectPath READ objectPath WRITE setObjectPath)
367 -       AUTOPROPERTY(QString, objectPath, ObjectPath)
368 +    Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
369         Q_PROPERTY(int zone READ zone WRITE setZone)
370         AUTOPROPERTY(int, zone, Zone)
371         Q_PROPERTY(double time READ time)
372  
373  
374 -       public:
375 +public:
376 +    AmbProperty(): mPropertyName("Value"), mZone(0), mTime(0), managerIface(NULL) { }
377  
378 -               AmbProperty():mDBusInterface(NULL),mZone(0),mTime(0) { }
379 -
380 -       AmbProperty(QString op, QString iface, QString propName);
381 +    AmbProperty(QString objectName, QString propName);
382  
383         QVariant value()
384         {
385                 return mValue;
386         }
387  
388 -       void setValue(QVariant v)
389 -       {
390 -               if(!mDBusInterface || !mDBusInterface->isValid())
391 -               {
392 -                       qDebug()<<"error Interface is not valid "<<interfaceName();
393 -               }
394 -
395 -               mDBusInterface->setProperty(propertyName().toUtf8(), v);
396 -       }
397 +    void setValue(QVariant v);
398  
399         double time(){ return mTime; }
400  
401 -Q_SIGNALS:     
402 +signals:
403         void valueChanged(QVariant val);
404  
405 -       ///TODO: remove
406 -       void signalChanged(QVariant val);
407 -
408  public Q_SLOTS:
409         void connect();
410 +    QVariant updateValue();
411 +    void disconnect();
412  
413  private Q_SLOTS:
414 -       void propertyChangedSlot(QString, QVariantMap values, QVariantMap);
415 -       void propertyChanged1(QDBusVariant, double);
416 +    void propertyChangedSlot(QString, QVariantMap values, QStringList);
417  
418  private:
419 -       void getObjectPath();
420 -       QDBusInterface* mDBusInterface;
421 +    QList<QDBusInterface*> ServerProperties;
422 +    QDBusInterface* managerIface;
423         double mTime;
424         QVariant mValue;
425  };
426 diff --git a/plugins/dbus/amb-qt/ambqtquick.cpp b/plugins/dbus/amb-qt/ambqtquick.cpp
427 index c5102a9..4362297 100644
428 --- a/plugins/dbus/amb-qt/ambqtquick.cpp
429 +++ b/plugins/dbus/amb-qt/ambqtquick.cpp
430 @@ -1,10 +1,28 @@
431 +/*
432 +Copyright (C) 2012 Intel Corporation
433 +Copyright (C) 2015 Cogent Embedded Inc.
434 +
435 +This library is free software; you can redistribute it and/or
436 +modify it under the terms of the GNU Lesser General Public
437 +License as published by the Free Software Foundation; either
438 +version 2.1 of the License, or (at your option) any later version.
439 +
440 +This library is distributed in the hope that it will be useful,
441 +but WITHOUT ANY WARRANTY; without even the implied warranty of
442 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
443 +Lesser General Public License for more details.
444 +
445 +You should have received a copy of the GNU Lesser General Public
446 +License along with this library; if not, write to the Free Software
447 +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
448 +*/
449  #include "ambqtquick.h"
450  #include <QtQml/qqml.h>
451  
452  void Components::registerTypes(const char *uri)
453  {
454 -       qmlRegisterType<AmbProperty>(uri,0,1,"AutomotivePropertyItem");
455 -
456 + Q_ASSERT(uri == QLatin1String("amb"));
457 + int ret = qmlRegisterType<AmbProperty>(uri, 0, 1,"AutomotivePropertyItem");
458  }
459  
460  void Components::initializeEngine(QQmlEngine *, const char *)
461 diff --git a/plugins/dbus/amb-qt/ambqtquick.h b/plugins/dbus/amb-qt/ambqtquick.h
462 index a48104a..74b3d6d 100644
463 --- a/plugins/dbus/amb-qt/ambqtquick.h
464 +++ b/plugins/dbus/amb-qt/ambqtquick.h
465 @@ -1,3 +1,21 @@
466 +/*
467 +Copyright (C) 2012 Intel Corporation
468 +Copyright (C) 2015 Cogent Embedded Inc.
469 +
470 +This library is free software; you can redistribute it and/or
471 +modify it under the terms of the GNU Lesser General Public
472 +License as published by the Free Software Foundation; either
473 +version 2.1 of the License, or (at your option) any later version.
474 +
475 +This library is distributed in the hope that it will be useful,
476 +but WITHOUT ANY WARRANTY; without even the implied warranty of
477 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
478 +Lesser General Public License for more details.
479 +
480 +You should have received a copy of the GNU Lesser General Public
481 +License along with this library; if not, write to the Free Software
482 +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
483 +*/
484  #include <QQmlExtensionPlugin>
485  #include "ambqt.h"
486  
487 @@ -7,8 +25,6 @@ class Components : public QQmlExtensionPlugin
488         Q_PLUGIN_METADATA(IID "org.automotive.qmlplugin")
489  public:
490  
491 -
492         void registerTypes(const char *uri);
493 -       void initializeEngine(QQmlEngine *engine, const char *uri);
494 -
495 +    void initializeEngine(QQmlEngine *engine, const char *uri);
496  };
497 diff --git a/plugins/dbus/amb-qt/qmldir b/plugins/dbus/amb-qt/qmldir
498 index a2d986c..49557ae 100644
499 --- a/plugins/dbus/amb-qt/qmldir
500 +++ b/plugins/dbus/amb-qt/qmldir
501 @@ -1 +1,2 @@
502 +module amb
503  plugin ambqtquick
504 diff --git a/plugins/dbus/amb-qt/test.cpp b/plugins/dbus/amb-qt/test.cpp
505 index 6eb88eb..a11f5e4 100644
506 --- a/plugins/dbus/amb-qt/test.cpp
507 +++ b/plugins/dbus/amb-qt/test.cpp
508 @@ -1,3 +1,21 @@
509 +/*
510 +Copyright (C) 2012 Intel Corporation
511 +Copyright (C) 2015 Cogent Embedded Inc.
512 +
513 +This library is free software; you can redistribute it and/or
514 +modify it under the terms of the GNU Lesser General Public
515 +License as published by the Free Software Foundation; either
516 +version 2.1 of the License, or (at your option) any later version.
517 +
518 +This library is distributed in the hope that it will be useful,
519 +but WITHOUT ANY WARRANTY; without even the implied warranty of
520 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
521 +Lesser General Public License for more details.
522 +
523 +You should have received a copy of the GNU Lesser General Public
524 +License along with this library; if not, write to the Free Software
525 +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
526 +*/
527  #include "ambqt.h"
528  #include "timestamp.h"
529  
530 @@ -15,7 +33,7 @@ int main(int argc, char** argv)
531         double totalLatency=0;
532         int numSamples=0;
533  
534 -       QObject::connect(&speed, &AmbProperty::signalChanged,[&](QVariant val)
535 +       QObject::connect(&speed, &AmbProperty::valueChanged,[&](QVariant val)
536         {
537                 double t1 = speed.time();
538                 double t2 = amb::currentTime();
539 @@ -26,10 +44,14 @@ int main(int argc, char** argv)
540                 totalLatency+=latency;
541                 numSamples++;
542                 DebugOut(0)<<"Average: "<<totalLatency / numSamples<<std::endl;
543 +               qDebug()<<"Value: "<<val;
544         });
545  
546 -       speed.setPropertyName("VehicleSpeed");
547 +       speed.setObjectName("VehicleSpeed");
548 +       speed.setPropertyName("Speed");
549         speed.connect();
550  
551 +       qDebug() << "Updated="<< speed.updateValue();
552 +
553         return app.exec();
554  }
555 diff --git a/plugins/dbus/automotivemanager.cpp b/plugins/dbus/automotivemanager.cpp
556 index 64919e0..a164d11 100644
557 --- a/plugins/dbus/automotivemanager.cpp
558 +++ b/plugins/dbus/automotivemanager.cpp
559 @@ -14,6 +14,11 @@ static const gchar introspection_xml[] =
560    "      <arg type='i' name='zone' direction='in'/>"
561    "      <arg type='o' name='response' direction='out'/>"
562    "    </method>"
563 +  "    <method name='FindObjectsForZone'>"
564 +  "      <arg type='s' name='searchstring' direction='in'/>"
565 +  "      <arg type='i' name='zone' direction='in'/>"
566 +  "      <arg type='ao' name='response' direction='out'/>"
567 +  "    </method>"
568    "    <method name='FindObjectForSourceZone'>"
569    "      <arg type='s' name='searchstring' direction='in'/>"
570    "      <arg type='s' name='source' direction='in'/>"
571 @@ -168,6 +173,66 @@ static void handleMethodCall(GDBusConnection       *connection,
572                 g_dbus_method_invocation_return_dbus_error(invocation,"org.automotive.Manager.InvalidZone", "zone not found");
573         }
574  
575 +       else if(method == "FindObjectsForZone")
576 +       {
577 +               gchar* arg;
578 +               int zone;
579 +
580 +               g_variant_get(parameters,"(si)", &arg, &zone);
581 +
582 +               std::string propertyToFind = arg;
583 +
584 +               if(propertyToFind == "")
585 +               {
586 +                       g_dbus_method_invocation_return_error(invocation,G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "Invalid argument.");
587 +                       return;
588 +               }
589 +
590 +               std::list<AbstractDBusInterface*> interfaces = AbstractDBusInterface::getObjectsForProperty(propertyToFind);
591 +
592 +               if(!interfaces.size())
593 +               {
594 +                       g_dbus_method_invocation_return_dbus_error(invocation, "org.automotive.Manager.ObjectNotFound", "Property not found");
595 +                       return;
596 +               }
597 +
598 +               GVariantBuilder params;
599 +               g_variant_builder_init(&params, G_VARIANT_TYPE_ARRAY);
600 +
601 +               bool hasItems = false;
602 +
603 +               for(auto itr = interfaces.begin(); itr != interfaces.end(); itr++)
604 +               {
605 +                       AbstractDBusInterface* t = *itr;
606 +                       if(!t->isSupported())
607 +                               continue;
608 +
609 +                       if(t->zone() == (Zone::Type)zone)
610 +                       {
611 +                               hasItems = true;
612 +
613 +                               if(!t->isRegistered())
614 +                                       t->registerObject();
615 +
616 +                               std::list<std::string> processes = manager->subscribedProcesses[t];
617 +
618 +                               if(!contains(processes,sender))
619 +                               {
620 +                                       DebugOut()<<"Referencing "<<t->objectPath()<<" with sender: "<<sender<<endl;
621 +                                       manager->subscribedProcesses[t].push_back(sender);
622 +                               }
623 +
624 +                               GVariant *newvar = g_variant_new("o",t->objectPath().c_str());
625 +                               g_variant_builder_add_value(&params, newvar);
626 +                       }
627 +               }
628 +
629 +               if(hasItems)
630 +                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ao)",&params));
631 +               else
632 +                       g_dbus_method_invocation_return_dbus_error(invocation,"org.automotive.Manager.ObjectNotFound", "Property not found");
633 +       }
634 +
635         else if (method == "ZonesForObjectName")
636         {
637                 gchar* arg;
638 -- 
639 1.9.1
640