Update AMB with amb-qt(qml) plugins to latest 37/4337/2
authorTadao Tanikawa <tanikawa.tadao@jp.panasonic.com>
Fri, 13 Nov 2015 07:11:35 +0000 (16:11 +0900)
committerGerrit Code Review <gerrit@172.30.200.200>
Fri, 13 Nov 2015 20:17:58 +0000 (20:17 +0000)
To use CogentEmbedded fixes to amb-qt(qml) plugins of AMB, the
recipes for AMB has been updated:
 - Pulling CogentEmbeeded's repository as upstream
 - Apply some patches to fix some issue around amb-qt plugins
   (these are from branch 'dev_0.14_2')

Change-Id: I81bf63d26446ec720343c4730fdc41d65ecf2e68
Signed-off-by: Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com>
meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0001-Improve-backward-compatibility-with-old-linaro-gcc.patch [new file with mode: 0644]
meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0002-Fix-library-versioning.patch [new file with mode: 0644]
meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0003-AmbSignalMapper-fix-can-interface-specification.patch [new file with mode: 0644]
meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0004-cansocketbcm-Fix-reading-of-frames-in-case-of-RX_TIM.patch [new file with mode: 0644]
meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0005-ambctl-remove-unnecessary-dependency-on-glib-introsp.patch [new file with mode: 0644]
meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0006-cangen-Implement-basic-handling-of-RX_TIMEOUT.patch [new file with mode: 0644]
meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0007-WORKAROUND-Allow-amb-qt-binding-to-work-in-case-of-m.patch [new file with mode: 0644]
meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0008-Add-simple-Qt-QML-example.patch [new file with mode: 0644]
meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0009-Add-Pressure-property-to-BrakeOperation.patch [new file with mode: 0644]
meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker_git.bb

diff --git a/meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0001-Improve-backward-compatibility-with-old-linaro-gcc.patch b/meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0001-Improve-backward-compatibility-with-old-linaro-gcc.patch
new file mode 100644 (file)
index 0000000..11726aa
--- /dev/null
@@ -0,0 +1,82 @@
+From fb401094c3d88da14e1b909d786a86c3a68d2199 Mon Sep 17 00:00:00 2001
+From: Petr Nechaev <petr.nechaev@cogentembedded.com>
+Date: Mon, 27 Jul 2015 20:34:47 +0300
+Subject: [PATCH 1/9] Improve backward compatibility with old linaro gcc
+
+---
+ lib/listplusplus.h                | 8 ++++++--
+ plugins/common/jsonprotocol.cpp   | 6 +++---
+ plugins/testplugin/testplugin.cpp | 2 +-
+ 3 files changed, 10 insertions(+), 6 deletions(-)
+
+diff --git a/lib/listplusplus.h b/lib/listplusplus.h
+index 433d34c..e653615 100644
+--- a/lib/listplusplus.h
++++ b/lib/listplusplus.h
+@@ -27,13 +27,17 @@
+ template <class T, class V, class Predicate>
+ bool contains(const T & iteratable, V value, Predicate comparator )
+ {
+-      return std::any_of(iteratable.begin(), iteratable.end(), [value, &comparator](auto i) { return comparator(value, i); });
++    for(auto i : iteratable)
++      {
++              if(comparator(value, i))
++                      return true;
++      }
+ }
+ template <class T, class V>
+ bool contains(const T & iteratable, V value)
+ {
+-      return contains(iteratable, value, [](auto a, auto b) { return a == b; });
++      return iteratable.size() > 0 && (std::find(iteratable.begin(), iteratable.end(), value) != iteratable.end());
+ }
+diff --git a/plugins/common/jsonprotocol.cpp b/plugins/common/jsonprotocol.cpp
+index a534900..43ef8cf 100644
+--- a/plugins/common/jsonprotocol.cpp
++++ b/plugins/common/jsonprotocol.cpp
+@@ -149,7 +149,7 @@ void amb::AmbRemoteClient::hasJsonMessage(const picojson::value &json)
+                       const ListMethodCall::Ptr listMethod = listMethodReply.method();
+-                      auto itr = std::find_if(mListCalls.begin(), mListCalls.end(),[&listMethod](auto o)
++                      auto itr = std::find_if(mListCalls.begin(), mListCalls.end(),[&listMethod](ListMethodCall::Ptr o)
+                       {
+                               return o->messageId == listMethod->messageId;
+                       });
+@@ -176,7 +176,7 @@ void amb::AmbRemoteClient::hasJsonMessage(const picojson::value &json)
+                       reply.fromJson(json);
+                       GetMethodCall::Ptr getCall = reply.method();
+-                      auto itr = std::find_if(mGetMethodCalls.begin(), mGetMethodCalls.end(),[&getCall](auto o)
++                      auto itr = std::find_if(mGetMethodCalls.begin(), mGetMethodCalls.end(),[&getCall](GetMethodCall::Ptr o)
+                       {
+                               return o->messageId == getCall->messageId;
+                       });
+@@ -205,7 +205,7 @@ void amb::AmbRemoteClient::hasJsonMessage(const picojson::value &json)
+                       auto call = reply.method();
+-                      auto itr = std::find_if(mSetMethodCalls.begin(), mSetMethodCalls.end(),[&call](auto o)
++                      auto itr = std::find_if(mSetMethodCalls.begin(), mSetMethodCalls.end(),[&call](SetMethodCall::Ptr o)
+                       {
+                               return o->messageId == call->messageId;
+                       });
+diff --git a/plugins/testplugin/testplugin.cpp b/plugins/testplugin/testplugin.cpp
+index d854d5f..a96cf19 100644
+--- a/plugins/testplugin/testplugin.cpp
++++ b/plugins/testplugin/testplugin.cpp
+@@ -268,7 +268,7 @@ bool testListPlusPlus()
+       complexList.push_back(complex1);
+       complexList.push_back(complex2);
+-      TEST(contains(complexList, complex1, [](auto a, auto b) { return a.foo == b.foo && a.bar == b.bar; }));
++      TEST(contains(complexList, complex1, [](Complex a, Complex b) { return a.foo == b.foo && a.bar == b.bar; }));
+       return true;
+ }
+-- 
+1.9.1
+
diff --git a/meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0002-Fix-library-versioning.patch b/meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0002-Fix-library-versioning.patch
new file mode 100644 (file)
index 0000000..92a1198
--- /dev/null
@@ -0,0 +1,46 @@
+From 38c2869f16356ac723712020903ddf27cbf5890d Mon Sep 17 00:00:00 2001
+From: Petr Nechaev <petr.nechaev@cogentembedded.com>
+Date: Tue, 28 Jul 2015 17:05:10 +0300
+Subject: [PATCH 2/9] Fix library versioning
+
+Preferred for Yocto builds
+---
+ plugins/common/CMakeLists.txt      | 2 ++
+ plugins/dbus/amb-qt/CMakeLists.txt | 1 +
+ 2 files changed, 3 insertions(+)
+
+diff --git a/plugins/common/CMakeLists.txt b/plugins/common/CMakeLists.txt
+index 407b281..b760671 100644
+--- a/plugins/common/CMakeLists.txt
++++ b/plugins/common/CMakeLists.txt
+@@ -6,6 +6,7 @@ set(plugins_common_headers_install abstractio.hpp serialport.hpp bluetooth.hpp b
+               canobserver.h logger.h mutex.h thread.h dbusexport.h dbusplugin.h abstractdbusinterface.h dbussignaller.h varianttype.h)
+ add_library(amb-plugins-common SHARED ${plugins_common_sources})
++set_target_properties(amb-plugins-common PROPERTIES SOVERSION ${PROJECT_VERSION})
+ pkg_check_modules(gio-unix REQUIRED gio-unix-2.0)
+@@ -25,6 +26,7 @@ set(amb_json_protocol_sources jsonprotocol.cpp)
+ set(amb_json_protocol_headers jsonprotocol.cpp)
+ add_library(amb-json-protocol SHARED ${amb_json_protocol_sources})
++set_target_properties(amb-json-protocol PROPERTIES SOVERSION ${PROJECT_VERSION})
+ target_link_libraries(amb-json-protocol amb -L${CMAKE_BINARY_DIR}/lib ${link_libraries} -L${CMAKE_CURRENT_BINARY_DIR} amb-plugins-common)
+diff --git a/plugins/dbus/amb-qt/CMakeLists.txt b/plugins/dbus/amb-qt/CMakeLists.txt
+index a1ae739..2f2a2a8 100644
+--- a/plugins/dbus/amb-qt/CMakeLists.txt
++++ b/plugins/dbus/amb-qt/CMakeLists.txt
+@@ -22,6 +22,7 @@ set(ambqtquick_headers ambqtquick.h)
+ include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs} ${QT_INCLUDE_DIRS})
+ add_library(amb-qt SHARED ${ambqt_sources} ${ambqt_headers_moc})
++set_target_properties(amb-qt PROPERTIES SOVERSION ${PROJECT_VERSION})
+ add_library(ambqtquick MODULE ${ambqtquick_sources} ${ambqtquick_headers_moc})
+ target_link_libraries(amb-qt amb ${QT_LIBRARIES} -L${CMAKE_CURRENT_BINARY_DIR}/lib ${link_libraries} ${gio_LIBRARIES})
+-- 
+1.9.1
+
diff --git a/meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0003-AmbSignalMapper-fix-can-interface-specification.patch b/meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0003-AmbSignalMapper-fix-can-interface-specification.patch
new file mode 100644 (file)
index 0000000..3b37fbc
--- /dev/null
@@ -0,0 +1,28 @@
+From 14743846b201bec6607fcbe7727d8c71024cf920 Mon Sep 17 00:00:00 2001
+From: Petr Nechaev <petr.nechaev@cogentembedded.com>
+Date: Tue, 28 Jul 2015 18:39:11 +0300
+Subject: [PATCH 3/9] AmbSignalMapper: fix can interface specification
+
+---
+ tools/AmbSignalMapper/lib/Intel/IviPoc/templates/CMakeLists.txt | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/tools/AmbSignalMapper/lib/Intel/IviPoc/templates/CMakeLists.txt b/tools/AmbSignalMapper/lib/Intel/IviPoc/templates/CMakeLists.txt
+index f5bfee9..4d1dd05 100644
+--- a/tools/AmbSignalMapper/lib/Intel/IviPoc/templates/CMakeLists.txt
++++ b/tools/AmbSignalMapper/lib/Intel/IviPoc/templates/CMakeLists.txt
+@@ -10,9 +10,9 @@ set(PLUGIN_INSTALL_PATH "${LIB_INSTALL_DIR}/automotive-message-broker")
+ set (CMAKE_INSTALL_PREFIX /usr)
+ # check that CAN interface is specified and use vcan0 by default
+-if(NOT DEFINED ${DEFAULT_CAN_INTERFACE})
++if(NOT DEFINED DEFAULT_CAN_INTERFACE)
+     set(DEFAULT_CAN_INTERFACE "vcan0")
+-endif(NOT DEFINED ${DEFAULT_CAN_INTERFACE})
++endif(NOT DEFINED DEFAULT_CAN_INTERFACE)
+ if(CMAKE_BUILD_TYPE MATCHES DEBUG)
+     message("debug mode") 
+-- 
+1.9.1
+
diff --git a/meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0004-cansocketbcm-Fix-reading-of-frames-in-case-of-RX_TIM.patch b/meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0004-cansocketbcm-Fix-reading-of-frames-in-case-of-RX_TIM.patch
new file mode 100644 (file)
index 0000000..fda7292
--- /dev/null
@@ -0,0 +1,65 @@
+From 10327a700491ba7412ce1296cb709b4d3303326f Mon Sep 17 00:00:00 2001
+From: Petr Nechaev <petr.nechaev@cogentembedded.com>
+Date: Wed, 29 Jul 2015 17:58:49 +0300
+Subject: [PATCH 4/9] cansocketbcm: Fix reading of frames in case of RX_TIMEOUT
+
+If bcms.hdr.nframes==0 we must not read any frames.
+Also, frame size can vary with the number of messages.
+---
+ plugins/common/cansocketbcm.cpp | 26 ++++++++++++++++++++------
+ 1 file changed, 20 insertions(+), 6 deletions(-)
+
+diff --git a/plugins/common/cansocketbcm.cpp b/plugins/common/cansocketbcm.cpp
+index d923ce3..7ee663c 100644
+--- a/plugins/common/cansocketbcm.cpp
++++ b/plugins/common/cansocketbcm.cpp
+@@ -145,7 +145,7 @@ int CANSocketBCM::waitData(unsigned int timeout)
+ /**
+  * BCM header with one message.
+- * @note hdr.nframes must always be 0 or 1.
++ * @note As a result, hdr.nframes must always be 0 or 1.
+  */
+ struct __attribute__ ((__packed__)) bcm_msg_one{
+     struct bcm_msg_head hdr;
+@@ -190,7 +190,7 @@ CANSocket::CANSocketReadSuccess CANSocketBCM::readMessage(CANFrameInfo& message)
+     switch (bcms.hdr.opcode)
+     {
+     case RX_CHANGED:
+-        if (bcms.hdr.nframes >= 1 && nbytes == sizeof(bcms))
++        if (bcms.hdr.nframes >= 1 && nbytes == sizeof(bcm_msg_head) + bcms.hdr.nframes*sizeof(can_frame))
+         {
+             if (bcms.hdr.nframes > 1)
+             {
+@@ -211,10 +211,24 @@ CANSocket::CANSocketReadSuccess CANSocketBCM::readMessage(CANFrameInfo& message)
+             return CANSocket::CANSocketReadSuccess::READING_FAILED;
+         }
+     case RX_TIMEOUT:
+-        memcpy(&message.frame, &bcms.frames[0], sizeof(bcms.frames[0]));
+-        message.frame.can_id = bcms.hdr.can_id; //doubtful. Do we need to override this?
+-        message.status = CANFrameInfo::CANMessageStatus::TIMEOUT;
+-        return CANSocket::CANSocketReadSuccess::READING_SUCCEEDED;
++        if (bcms.hdr.nframes >= 0 && nbytes == sizeof(bcm_msg_head) + bcms.hdr.nframes*sizeof(can_frame))
++        {
++            if (bcms.hdr.nframes > 0)
++            {
++                memcpy(&message.frame, &bcms.frames[0], sizeof(bcms.frames[0]));
++            }
++            message.frame.can_id = bcms.hdr.can_id; //doubtful. Do we need to override this?
++            message.status = CANFrameInfo::CANMessageStatus::TIMEOUT;
++            return CANSocket::CANSocketReadSuccess::READING_SUCCEEDED;
++        }
++        else
++        {
++            LOG_ERROR("Unexpected data from the socket"
++                      << " " << bcms.hdr.opcode
++                      << " " << bcms.hdr.nframes
++                      << " " << nbytes);
++            return CANSocket::CANSocketReadSuccess::READING_FAILED;
++        }
+     case TX_EXPIRED:
+         // do nothing
+-- 
+1.9.1
+
diff --git a/meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0005-ambctl-remove-unnecessary-dependency-on-glib-introsp.patch b/meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0005-ambctl-remove-unnecessary-dependency-on-glib-introsp.patch
new file mode 100644 (file)
index 0000000..a6bedce
--- /dev/null
@@ -0,0 +1,46 @@
+From 261e0d119463c648baaf6c3d4be989ca710f9c05 Mon Sep 17 00:00:00 2001
+From: Petr Nechaev <petr.nechaev@cogentembedded.com>
+Date: Wed, 29 Jul 2015 18:00:08 +0300
+Subject: [PATCH 5/9] ambctl: remove unnecessary dependency on glib
+ introspection Python binding
+
+"gobject" from pygobject is enough for the task.
+---
+ tools/ambctl.py | 9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+diff --git a/tools/ambctl.py b/tools/ambctl.py
+index cb091a7..b0b9fd4 100644
+--- a/tools/ambctl.py
++++ b/tools/ambctl.py
+@@ -8,7 +8,8 @@ import fileinput
+ import termios, fcntl, os
+ import curses.ascii
+ import traceback
+-from gi.repository import GObject, GLib
++import gobject
++import glib
+ from dbus.mainloop.glib import DBusGMainLoop
+@@ -545,14 +546,14 @@ if args.command == "stdin":
+               oldflags = fcntl.fcntl(fd, fcntl.F_GETFL)
+               fcntl.fcntl(fd, fcntl.F_SETFL, oldflags | os.O_NONBLOCK)
+-              io_stdin = GLib.IOChannel(fd)
+-              io_stdin.add_watch(GLib.IO_IN, handle_keyboard, data)
++              io_stdin = glib.IOChannel(fd)
++              io_stdin.add_watch(glib.IO_IN, handle_keyboard, data)
+               try:
+                       erase_line()
+                       display_prompt()
+                       sys.stdout.flush()
+-                      main_loop = GObject.MainLoop()
++                      main_loop = gobject.MainLoop()
+                       main_loop.run()
+               except KeyboardInterrupt:
+                       sys.exit()
+-- 
+1.9.1
+
diff --git a/meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0006-cangen-Implement-basic-handling-of-RX_TIMEOUT.patch b/meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0006-cangen-Implement-basic-handling-of-RX_TIMEOUT.patch
new file mode 100644 (file)
index 0000000..b07fa0d
--- /dev/null
@@ -0,0 +1,33 @@
+From 569467d31ef46781ae84b992772aa0897d573a09 Mon Sep 17 00:00:00 2001
+From: Petr Nechaev <petr.nechaev@cogentembedded.com>
+Date: Wed, 29 Jul 2015 18:00:36 +0300
+Subject: [PATCH 6/9] cangen: Implement basic handling of RX_TIMEOUT
+
+---
+ .../lib/Intel/IviPoc/templates/ambtmpl_cansignal.cpp               | 7 +++----
+ 1 file changed, 3 insertions(+), 4 deletions(-)
+
+diff --git a/tools/AmbSignalMapper/lib/Intel/IviPoc/templates/ambtmpl_cansignal.cpp b/tools/AmbSignalMapper/lib/Intel/IviPoc/templates/ambtmpl_cansignal.cpp
+index cd4b6d3..0222bed 100644
+--- a/tools/AmbSignalMapper/lib/Intel/IviPoc/templates/ambtmpl_cansignal.cpp
++++ b/tools/AmbSignalMapper/lib/Intel/IviPoc/templates/ambtmpl_cansignal.cpp
+@@ -86,13 +86,12 @@ void CANSignal::onMessage(const can_frame& frame, std::function<void (AbstractPr
+ void CANSignal::onTimeout(const can_frame& frame, std::function<void (AbstractPropertyType*)> changeCallback)
+ {
+-    //TODO: implement <no-value> handling
+-/*    if (ambProperty->toString() != "none") {
+-        ambProperty->setValue("none");
++    if (ambProperty->valueQuality != amb::Quality::ValueQuality::BadTimeout)
++    {
++        ambProperty->valueQuality = amb::Quality::ValueQuality::BadTimeout;
+         if(changeCallback)
+             changeCallback(ambProperty.get());
+     }
+-*/
+ }
+-- 
+1.9.1
+
diff --git a/meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0007-WORKAROUND-Allow-amb-qt-binding-to-work-in-case-of-m.patch b/meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0007-WORKAROUND-Allow-amb-qt-binding-to-work-in-case-of-m.patch
new file mode 100644 (file)
index 0000000..14717a9
--- /dev/null
@@ -0,0 +1,640 @@
+From 5de4c1f8e0d5fb22a6d2927d3526498de2b21cbe Mon Sep 17 00:00:00 2001
+From: Petr Nechaev <petr.nechaev@cogentembedded.com>
+Date: Fri, 31 Jul 2015 20:22:36 +0300
+Subject: [PATCH 7/9] [WORKAROUND] Allow amb-qt binding to work in case of
+ multiple properties
+
+---
+ docs/amb.in.fidl                   |  21 ++++
+ plugins/dbus/amb-qt/CMakeLists.txt |   2 +-
+ plugins/dbus/amb-qt/ambqt.cpp      | 237 ++++++++++++++++++++++++++-----------
+ plugins/dbus/amb-qt/ambqt.h        |  59 ++++-----
+ plugins/dbus/amb-qt/ambqtquick.cpp |  22 +++-
+ plugins/dbus/amb-qt/ambqtquick.h   |  22 +++-
+ plugins/dbus/amb-qt/qmldir         |   1 +
+ plugins/dbus/amb-qt/test.cpp       |  26 +++-
+ plugins/dbus/automotivemanager.cpp |  65 ++++++++++
+ 9 files changed, 350 insertions(+), 105 deletions(-)
+
+diff --git a/docs/amb.in.fidl b/docs/amb.in.fidl
+index 398a33d..27d2827 100644
+--- a/docs/amb.in.fidl
++++ b/docs/amb.in.fidl
+@@ -220,6 +220,27 @@ interface org.automotive.Manager  {
+   }
+   /*!
++   * FindObjectsForZone
++   *  \brief find the DBus object path which matches "objectName" and "zone".  This has the same behavior as FindObject
++   * except that it takes an addition zone argument and only return the path for that zone.
++   *  \arg String property is the requested property to be retrieved.
++   *  \arg Zone zone is the zone which the object
++   *  \return list of object paths that provide the given object Name.
++   *  Possible errors:
++   * "org.automotive.Manager.InvalidZone"
++   * "org.automotive.Manager.ObjectNotFound"
++  */
++  method FindObjectsForZone {
++        in {
++          String objectName
++          Zone zone
++        }
++        out {
++          array of String objectPath
++        }
++  }
++
++  /*!
+    * ZonesForObjectName
+    *  \brief get a list of zones for a given objectName.
+    *  \arg String objectName object name.
+diff --git a/plugins/dbus/amb-qt/CMakeLists.txt b/plugins/dbus/amb-qt/CMakeLists.txt
+index 2f2a2a8..42b7fb4 100644
+--- a/plugins/dbus/amb-qt/CMakeLists.txt
++++ b/plugins/dbus/amb-qt/CMakeLists.txt
+@@ -16,7 +16,7 @@ endif(Qt5Core_FOUND)
+ set(ambqt_headers ambqt.h amb-qt_global.h)
+ set(ambqt_sources ambqt.cpp)
+-set(ambqtquick_sources ambqtquick.cpp)
++set(ambqtquick_sources ambqtquick.cpp qmldir)
+ set(ambqtquick_headers ambqtquick.h)
+ include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs} ${QT_INCLUDE_DIRS})
+diff --git a/plugins/dbus/amb-qt/ambqt.cpp b/plugins/dbus/amb-qt/ambqt.cpp
+index 6a3faeb..c8f1faf 100644
+--- a/plugins/dbus/amb-qt/ambqt.cpp
++++ b/plugins/dbus/amb-qt/ambqt.cpp
+@@ -1,92 +1,189 @@
++/*
++Copyright (C) 2012 Intel Corporation
++Copyright (C) 2015 Cogent Embedded Inc.
++
++This library is free software; you can redistribute it and/or
++modify it under the terms of the GNU Lesser General Public
++License as published by the Free Software Foundation; either
++version 2.1 of the License, or (at your option) any later version.
++
++This library is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++Lesser General Public License for more details.
++
++You should have received a copy of the GNU Lesser General Public
++License along with this library; if not, write to the Free Software
++Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
++*/
+ #include "ambqt.h"
+ #include <QDBusConnection>
+ #include <QDBusInterface>
+ #include <QtDebug>
+ #include <QDBusReply>
+-AmbProperty::AmbProperty(QString op, QString iface, QString propName)
+-      :QObject(), mPropertyName(propName),mInterfaceName(iface), mObjectPath(op),mDBusInterface(NULL),mZone(0)
++AmbProperty::AmbProperty(QString objectName, QString propName)
++    :QObject(), mObjectName(objectName), mPropertyName(propName), mZone(0), managerIface(NULL)
+ {
+-      connect();
++    // Automatically connect when all properties have been set
++    connect();
+ }
+-void AmbProperty::propertyChangedSlot(QString, QVariantMap values, QVariantMap )
++void AmbProperty::propertyChangedSlot(QString, QVariantMap values, QStringList )
+ {
+-      valueChanged(values);
++    // try to get value
++    mValue = values[mPropertyName];
++
++    // try to parse time
++    QVariant timeVariant = values["Time"];
++    bool ok = false;
++    double NewTime = 0;
++    if (timeVariant.isValid())
++        NewTime = timeVariant.toDouble(&ok);
++    if (ok)
++        mTime = NewTime;
++
++    // emit the signal
++    valueChanged(mValue);
+ }
+-void AmbProperty::propertyChanged1(QDBusVariant val, double t)
++void AmbProperty::connect()
+ {
+-      mTime = t;
+-      mValue = val.variant();
+-
+-      signalChanged(mValue);
++    if (managerIface)
++        disconnect();
++
++    managerIface = new QDBusInterface("org.automotive.message.broker","/","org.automotive.Manager", QDBusConnection::systemBus(), this);
++
++    if(!managerIface->isValid())
++    {
++        qWarning()<<"Failed to create manager interface";
++        delete managerIface;
++        return;
++    }
++
++    QDBusReply<QList<QDBusObjectPath>> reply = managerIface->call("FindObjectsForZone", mObjectName, mZone);
++
++    if(reply.isValid())
++    {
++        for (int i=0; i < reply.value().size(); ++i)
++        {
++            QDBusInterface* mDBusInterface = new QDBusInterface("org.automotive.message.broker",
++                                                                reply.value().at(i).path(),
++                                                                "org.freedesktop.DBus.Properties",
++                                                                QDBusConnection::systemBus(),
++                                                                this);
++
++            if(!mDBusInterface->isValid())
++            {
++                qDebug()<<"Failed to create dbus interface for property "<<propertyName();
++                qDebug()<<"path: "<< reply.value().at(i).path();
++                qDebug()<<"object: "<< objectName();
++                qDebug()<<"property: "<< propertyName();
++                qDebug()<<"Error: "<<QDBusConnection::systemBus().lastError().message();
++            }
++
++            // store object interface for future use
++            ServerProperties.append(mDBusInterface);
++
++            if(!QDBusConnection::systemBus().connect("org.automotive.message.broker",
++                                                     reply.value().at(i).path(),
++                                                     "org.freedesktop.DBus.Properties",
++                                                     "PropertiesChanged",
++                                                     this,
++                                                     SLOT(propertyChangedSlot(QString,QVariantMap,QStringList))))
++            {
++                qDebug()<<"Failed to connect to signal";
++                qDebug()<<"path: "<< reply.value().at(i).path();
++                qDebug()<<"object: "<< objectName();
++                qDebug()<<"property: "<< propertyName();
++                qDebug()<<"Error: "<< QDBusConnection::systemBus().lastError().message();
++            }
++        }
++    }
++
++    //    if(mInterfaceName.isEmpty())
++    //        mInterfaceName = "org.automotive."+mPropertyName;
++
++    //    mDBusInterface = new QDBusInterface("org.automotive.message.broker",objectPath(), interfaceName(), QDBusConnection::systemBus(),this);
++
++    //    if(!mDBusInterface->isValid())
++    //    {
++    //        qDebug()<<"Failed to create dbus interface for property "<<propertyName();
++    //        qDebug()<<"Path: "<<objectPath();
++    //        qDebug()<<"Interface: "<<interfaceName();
++    //        qDebug()<<"Error: "<<QDBusConnection::systemBus().lastError().message();
++    //    }
++
++    //    QString signalName = propertyName() + "Changed";
++
++
++
++    //    ///TODO: only use PropertiesChanged...  treat AmbProperty like an object rather than a representation of just a single property in the object
++
++    //    if(!QDBusConnection::systemBus().connect("org.automotive.message.broker", objectPath(), mInterfaceName,
++    //                                             signalName, this, SLOT(propertyChanged1(QDBusVariant,double))))
++    //    {
++    //        qDebug()<<"Failed to connect to signal";
++    //        qDebug()<<"path: "<<objectPath();
++    //        qDebug()<<"interface: "<<interfaceName();
++    //        qDebug()<<"signal: "<<propertyName();
++    //        qDebug()<<"Error: "<<QDBusConnection::systemBus().lastError().message();
++    //    }
+ }
+-void AmbProperty::connect()
++void AmbProperty::disconnect()
+ {
+-      if(mDBusInterface)
+-      {
+-              delete mDBusInterface;
+-      }
+-
+-      if(mObjectPath.isEmpty())
+-              getObjectPath();
+-
+-      if(mInterfaceName.isEmpty())
+-              mInterfaceName = "org.automotive."+mPropertyName;
+-
+-      mDBusInterface = new QDBusInterface("org.automotive.message.broker",objectPath(), interfaceName(), QDBusConnection::systemBus(),this);
+-
+-      if(!mDBusInterface->isValid())
+-      {
+-              qDebug()<<"Failed to create dbus interface for property "<<propertyName();
+-              qDebug()<<"Path: "<<objectPath();
+-              qDebug()<<"Interface: "<<interfaceName();
+-              qDebug()<<"Error: "<<QDBusConnection::systemBus().lastError().message();
+-      }
+-
+-      QString signalName = propertyName() + "Changed";
+-
+-
+-      if(!QDBusConnection::systemBus().connect("org.automotive.message.broker", objectPath(), "org.freedesktop.DBus.Properties",
+-                                                                                       "PropertiesChanged", this, SLOT(propertyChangedSlot(QString,QVariantMap,QVariantMap))))
+-      {
+-              qDebug()<<"Failed to connect to signal";
+-              qDebug()<<"path: "<<objectPath();
+-              qDebug()<<"interface: "<<interfaceName();
+-              qDebug()<<"signal: "<<propertyName();
+-              qDebug()<<"Error: "<<QDBusConnection::systemBus().lastError().message();
+-      }
+-
+-      ///TODO: only use PropertiesChanged...  treat AmbProperty like an object rather than a representation of just a single property in the object
+-
+-      if(!QDBusConnection::systemBus().connect("org.automotive.message.broker", objectPath(), mInterfaceName,
+-                                                                                       signalName, this, SLOT(propertyChanged1(QDBusVariant,double))))
+-      {
+-              qDebug()<<"Failed to connect to signal";
+-              qDebug()<<"path: "<<objectPath();
+-              qDebug()<<"interface: "<<interfaceName();
+-              qDebug()<<"signal: "<<propertyName();
+-              qDebug()<<"Error: "<<QDBusConnection::systemBus().lastError().message();
+-      }
++    delete managerIface;
++    managerIface = NULL;
++
++    QDBusReply<QList<QDBusObjectPath>> reply = managerIface->call("FindObjectsForZone", mObjectName, mZone);
++
++    if(reply.isValid())
++    {
++        for (int i=0; i < reply.value().size(); ++i)
++        {
++            QDBusConnection::systemBus().disconnect("org.automotive.message.broker",
++                                                    reply.value().at(i).path(),
++                                                    "org.freedesktop.DBus.Properties",
++                                                    "PropertiesChanged",
++                                                    this,
++                                                    SLOT(propertyChangedSlot(QString,QVariantMap,QStringList)));
++        }
++    }
++
++    for (int i = 0; i < ServerProperties.size(); ++i)
++        delete ServerProperties[i];
++
++    ServerProperties.clear();
+ }
+-void AmbProperty::getObjectPath()
++QVariant AmbProperty::updateValue()
+ {
+-      QDBusInterface managerIface("org.automotive.message.broker","/","org.automotive.Manager", QDBusConnection::systemBus(), this);
+-
+-      if(!managerIface.isValid())
+-      {
+-              qDebug()<<"Failed to create manager interface";
+-              return;
+-      }
+-
+-      QDBusReply<QDBusObjectPath> reply = managerIface.call("FindObjectForZone", mPropertyName, mZone);
++    for (int i = 0; i < ServerProperties.size(); ++i)
++    {
++        if (!ServerProperties[i]->isValid())
++        {
++            qDebug()<<"error Interface is not valid "<<ServerProperties[i]->objectName();
++        }
++
++        QVariant v = ServerProperties[i]->property(propertyName().toUtf8());
++
++        if (v.isValid())
++            return v;
++    }
++}
+-      if(reply.isValid())
+-      {
+-              mObjectPath = reply.value().path();
+-      }
++void AmbProperty::setValue(QVariant v)
++{
++    for (int i = 0; i < ServerProperties.size(); ++i)
++    {
++        if (!ServerProperties[i]->isValid())
++        {
++            qDebug()<<"error Interface is not valid "<<ServerProperties[i]->objectName();
++        }
++
++        ServerProperties[i]->setProperty(propertyName().toUtf8(), v);
++    }
+ }
++
+diff --git a/plugins/dbus/amb-qt/ambqt.h b/plugins/dbus/amb-qt/ambqt.h
+index 3d7e793..6510daa 100644
+--- a/plugins/dbus/amb-qt/ambqt.h
++++ b/plugins/dbus/amb-qt/ambqt.h
+@@ -1,3 +1,21 @@
++/*
++Copyright (C) 2012 Intel Corporation
++Copyright (C) 2015 Cogent Embedded Inc.
++
++This library is free software; you can redistribute it and/or
++modify it under the terms of the GNU Lesser General Public
++License as published by the Free Software Foundation; either
++version 2.1 of the License, or (at your option) any later version.
++
++This library is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++Lesser General Public License for more details.
++
++You should have received a copy of the GNU Lesser General Public
++License along with this library; if not, write to the Free Software
++Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
++*/
+ #ifndef AMBQT_H
+ #define AMBQT_H
+@@ -17,57 +35,44 @@ class QDBusInterface;
+ class AmbProperty: public QObject
+ {
+       Q_OBJECT
+-      Q_PROPERTY(QString propertyName READ propertyName WRITE setPropertyName)
++    Q_PROPERTY(QString objectName READ objectName WRITE setObjectName)
++    AUTOPROPERTY(QString, objectName, ObjectName)
++    Q_PROPERTY(QString propertyName READ propertyName WRITE setPropertyName)
+       AUTOPROPERTY(QString, propertyName, PropertyName)
+-      Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
+-      Q_PROPERTY(QString interfaceName READ interfaceName WRITE setInterfaceName)
+-      AUTOPROPERTY(QString, interfaceName, InterfaceName)
+-      Q_PROPERTY(QString objectPath READ objectPath WRITE setObjectPath)
+-      AUTOPROPERTY(QString, objectPath, ObjectPath)
++    Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
+       Q_PROPERTY(int zone READ zone WRITE setZone)
+       AUTOPROPERTY(int, zone, Zone)
+       Q_PROPERTY(double time READ time)
+-      public:
++public:
++    AmbProperty(): mPropertyName("Value"), mZone(0), mTime(0), managerIface(NULL) { }
+-              AmbProperty():mDBusInterface(NULL),mZone(0),mTime(0) { }
+-
+-      AmbProperty(QString op, QString iface, QString propName);
++    AmbProperty(QString objectName, QString propName);
+       QVariant value()
+       {
+               return mValue;
+       }
+-      void setValue(QVariant v)
+-      {
+-              if(!mDBusInterface || !mDBusInterface->isValid())
+-              {
+-                      qDebug()<<"error Interface is not valid "<<interfaceName();
+-              }
+-
+-              mDBusInterface->setProperty(propertyName().toUtf8(), v);
+-      }
++    void setValue(QVariant v);
+       double time(){ return mTime; }
+-Q_SIGNALS:    
++signals:
+       void valueChanged(QVariant val);
+-      ///TODO: remove
+-      void signalChanged(QVariant val);
+-
+ public Q_SLOTS:
+       void connect();
++    QVariant updateValue();
++    void disconnect();
+ private Q_SLOTS:
+-      void propertyChangedSlot(QString, QVariantMap values, QVariantMap);
+-      void propertyChanged1(QDBusVariant, double);
++    void propertyChangedSlot(QString, QVariantMap values, QStringList);
+ private:
+-      void getObjectPath();
+-      QDBusInterface* mDBusInterface;
++    QList<QDBusInterface*> ServerProperties;
++    QDBusInterface* managerIface;
+       double mTime;
+       QVariant mValue;
+ };
+diff --git a/plugins/dbus/amb-qt/ambqtquick.cpp b/plugins/dbus/amb-qt/ambqtquick.cpp
+index c5102a9..4362297 100644
+--- a/plugins/dbus/amb-qt/ambqtquick.cpp
++++ b/plugins/dbus/amb-qt/ambqtquick.cpp
+@@ -1,10 +1,28 @@
++/*
++Copyright (C) 2012 Intel Corporation
++Copyright (C) 2015 Cogent Embedded Inc.
++
++This library is free software; you can redistribute it and/or
++modify it under the terms of the GNU Lesser General Public
++License as published by the Free Software Foundation; either
++version 2.1 of the License, or (at your option) any later version.
++
++This library is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++Lesser General Public License for more details.
++
++You should have received a copy of the GNU Lesser General Public
++License along with this library; if not, write to the Free Software
++Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
++*/
+ #include "ambqtquick.h"
+ #include <QtQml/qqml.h>
+ void Components::registerTypes(const char *uri)
+ {
+-      qmlRegisterType<AmbProperty>(uri,0,1,"AutomotivePropertyItem");
+-
++ Q_ASSERT(uri == QLatin1String("amb"));
++ int ret = qmlRegisterType<AmbProperty>(uri, 0, 1,"AutomotivePropertyItem");
+ }
+ void Components::initializeEngine(QQmlEngine *, const char *)
+diff --git a/plugins/dbus/amb-qt/ambqtquick.h b/plugins/dbus/amb-qt/ambqtquick.h
+index a48104a..74b3d6d 100644
+--- a/plugins/dbus/amb-qt/ambqtquick.h
++++ b/plugins/dbus/amb-qt/ambqtquick.h
+@@ -1,3 +1,21 @@
++/*
++Copyright (C) 2012 Intel Corporation
++Copyright (C) 2015 Cogent Embedded Inc.
++
++This library is free software; you can redistribute it and/or
++modify it under the terms of the GNU Lesser General Public
++License as published by the Free Software Foundation; either
++version 2.1 of the License, or (at your option) any later version.
++
++This library is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++Lesser General Public License for more details.
++
++You should have received a copy of the GNU Lesser General Public
++License along with this library; if not, write to the Free Software
++Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
++*/
+ #include <QQmlExtensionPlugin>
+ #include "ambqt.h"
+@@ -7,8 +25,6 @@ class Components : public QQmlExtensionPlugin
+       Q_PLUGIN_METADATA(IID "org.automotive.qmlplugin")
+ public:
+-
+       void registerTypes(const char *uri);
+-      void initializeEngine(QQmlEngine *engine, const char *uri);
+-
++    void initializeEngine(QQmlEngine *engine, const char *uri);
+ };
+diff --git a/plugins/dbus/amb-qt/qmldir b/plugins/dbus/amb-qt/qmldir
+index a2d986c..49557ae 100644
+--- a/plugins/dbus/amb-qt/qmldir
++++ b/plugins/dbus/amb-qt/qmldir
+@@ -1 +1,2 @@
++module amb
+ plugin ambqtquick
+diff --git a/plugins/dbus/amb-qt/test.cpp b/plugins/dbus/amb-qt/test.cpp
+index 6eb88eb..a11f5e4 100644
+--- a/plugins/dbus/amb-qt/test.cpp
++++ b/plugins/dbus/amb-qt/test.cpp
+@@ -1,3 +1,21 @@
++/*
++Copyright (C) 2012 Intel Corporation
++Copyright (C) 2015 Cogent Embedded Inc.
++
++This library is free software; you can redistribute it and/or
++modify it under the terms of the GNU Lesser General Public
++License as published by the Free Software Foundation; either
++version 2.1 of the License, or (at your option) any later version.
++
++This library is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++Lesser General Public License for more details.
++
++You should have received a copy of the GNU Lesser General Public
++License along with this library; if not, write to the Free Software
++Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
++*/
+ #include "ambqt.h"
+ #include "timestamp.h"
+@@ -15,7 +33,7 @@ int main(int argc, char** argv)
+       double totalLatency=0;
+       int numSamples=0;
+-      QObject::connect(&speed, &AmbProperty::signalChanged,[&](QVariant val)
++      QObject::connect(&speed, &AmbProperty::valueChanged,[&](QVariant val)
+       {
+               double t1 = speed.time();
+               double t2 = amb::currentTime();
+@@ -26,10 +44,14 @@ int main(int argc, char** argv)
+               totalLatency+=latency;
+               numSamples++;
+               DebugOut(0)<<"Average: "<<totalLatency / numSamples<<std::endl;
++              qDebug()<<"Value: "<<val;
+       });
+-      speed.setPropertyName("VehicleSpeed");
++      speed.setObjectName("VehicleSpeed");
++      speed.setPropertyName("Speed");
+       speed.connect();
++      qDebug() << "Updated="<< speed.updateValue();
++
+       return app.exec();
+ }
+diff --git a/plugins/dbus/automotivemanager.cpp b/plugins/dbus/automotivemanager.cpp
+index 64919e0..a164d11 100644
+--- a/plugins/dbus/automotivemanager.cpp
++++ b/plugins/dbus/automotivemanager.cpp
+@@ -14,6 +14,11 @@ static const gchar introspection_xml[] =
+   "      <arg type='i' name='zone' direction='in'/>"
+   "      <arg type='o' name='response' direction='out'/>"
+   "    </method>"
++  "    <method name='FindObjectsForZone'>"
++  "      <arg type='s' name='searchstring' direction='in'/>"
++  "      <arg type='i' name='zone' direction='in'/>"
++  "      <arg type='ao' name='response' direction='out'/>"
++  "    </method>"
+   "    <method name='FindObjectForSourceZone'>"
+   "      <arg type='s' name='searchstring' direction='in'/>"
+   "      <arg type='s' name='source' direction='in'/>"
+@@ -168,6 +173,66 @@ static void handleMethodCall(GDBusConnection       *connection,
+               g_dbus_method_invocation_return_dbus_error(invocation,"org.automotive.Manager.InvalidZone", "zone not found");
+       }
++      else if(method == "FindObjectsForZone")
++      {
++              gchar* arg;
++              int zone;
++
++              g_variant_get(parameters,"(si)", &arg, &zone);
++
++              std::string propertyToFind = arg;
++
++              if(propertyToFind == "")
++              {
++                      g_dbus_method_invocation_return_error(invocation,G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "Invalid argument.");
++                      return;
++              }
++
++              std::list<AbstractDBusInterface*> interfaces = AbstractDBusInterface::getObjectsForProperty(propertyToFind);
++
++              if(!interfaces.size())
++              {
++                      g_dbus_method_invocation_return_dbus_error(invocation, "org.automotive.Manager.ObjectNotFound", "Property not found");
++                      return;
++              }
++
++              GVariantBuilder params;
++              g_variant_builder_init(&params, G_VARIANT_TYPE_ARRAY);
++
++              bool hasItems = false;
++
++              for(auto itr = interfaces.begin(); itr != interfaces.end(); itr++)
++              {
++                      AbstractDBusInterface* t = *itr;
++                      if(!t->isSupported())
++                              continue;
++
++                      if(t->zone() == (Zone::Type)zone)
++                      {
++                              hasItems = true;
++
++                              if(!t->isRegistered())
++                                      t->registerObject();
++
++                              std::list<std::string> processes = manager->subscribedProcesses[t];
++
++                              if(!contains(processes,sender))
++                              {
++                                      DebugOut()<<"Referencing "<<t->objectPath()<<" with sender: "<<sender<<endl;
++                                      manager->subscribedProcesses[t].push_back(sender);
++                              }
++
++                              GVariant *newvar = g_variant_new("o",t->objectPath().c_str());
++                              g_variant_builder_add_value(&params, newvar);
++                      }
++              }
++
++              if(hasItems)
++                      g_dbus_method_invocation_return_value(invocation, g_variant_new("(ao)",&params));
++              else
++                      g_dbus_method_invocation_return_dbus_error(invocation,"org.automotive.Manager.ObjectNotFound", "Property not found");
++      }
++
+       else if (method == "ZonesForObjectName")
+       {
+               gchar* arg;
+-- 
+1.9.1
+
diff --git a/meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0008-Add-simple-Qt-QML-example.patch b/meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0008-Add-simple-Qt-QML-example.patch
new file mode 100644 (file)
index 0000000..36f9d7b
--- /dev/null
@@ -0,0 +1,166 @@
+From 7c452ae1228b01a3db697b5a74c9dee60dcfe352 Mon Sep 17 00:00:00 2001
+From: Petr Nechaev <petr.nechaev@cogentembedded.com>
+Date: Mon, 3 Aug 2015 14:17:40 +0300
+Subject: [PATCH 8/9] Add simple Qt-QML example
+
+The example requires qtdeclarative. It outputs values of basic vehicle
+properties.
+---
+ plugins/dbus/amb-qt/CMakeLists.txt  |  6 +++++
+ plugins/dbus/amb-qt/Meter.qml       | 46 +++++++++++++++++++++++++++++++++++++
+ plugins/dbus/amb-qt/qtquicktest.cpp | 12 ++++++++++
+ plugins/dbus/amb-qt/qtquicktest.qml | 35 ++++++++++++++++++++++++++++
+ plugins/dbus/amb-qt/qtquicktest.qrc |  6 +++++
+ 5 files changed, 105 insertions(+)
+ create mode 100644 plugins/dbus/amb-qt/Meter.qml
+ create mode 100644 plugins/dbus/amb-qt/qtquicktest.cpp
+ create mode 100644 plugins/dbus/amb-qt/qtquicktest.qml
+ create mode 100644 plugins/dbus/amb-qt/qtquicktest.qrc
+
+diff --git a/plugins/dbus/amb-qt/CMakeLists.txt b/plugins/dbus/amb-qt/CMakeLists.txt
+index 42b7fb4..99f691b 100644
+--- a/plugins/dbus/amb-qt/CMakeLists.txt
++++ b/plugins/dbus/amb-qt/CMakeLists.txt
+@@ -31,10 +31,16 @@ target_link_libraries(ambqtquick amb-qt ${QT_LIBRARIES} -L${CMAKE_CURRENT_BINARY
+ add_executable(ambtestclient test.cpp)
+ target_link_libraries(ambtestclient amb amb-qt ${QT_LIBRARIES} -L${CMAKE_CURRENT_BINARY_DIR}/lib ${link_libraries} ${gio_LIBRARIES})
++qt5_add_resources(ambqtquicktest_RESOURCES qtquicktest.qrc)
++add_executable(ambqtquicktest qtquicktest.cpp ${ambqtquicktest_RESOURCES})
++target_link_libraries(ambqtquicktest amb amb-qt ${QT_LIBRARIES} -L${CMAKE_CURRENT_BINARY_DIR}/lib ${link_libraries})
++qt5_use_modules(ambqtquicktest Quick Core)
++
+ install (TARGETS amb-qt LIBRARY DESTINATION lib${LIB_SUFFIX})
+ install (FILES ${ambqt_headers} DESTINATION ${INCLUDE_INSTALL_DIR}/ COMPONENT Devel)
+ install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/qmldir DESTINATION ${LIB_INSTALL_DIR}/qt5/qml/amb COMPONENT Devel)
+ install (TARGETS ambqtquick DESTINATION ${LIB_INSTALL_DIR}/qt5/qml/amb)
+ install (TARGETS ambtestclient RUNTIME DESTINATION bin)
++install (TARGETS ambqtquicktest RUNTIME DESTINATION bin)
+ endif(qt_bindings)
+diff --git a/plugins/dbus/amb-qt/Meter.qml b/plugins/dbus/amb-qt/Meter.qml
+new file mode 100644
+index 0000000..370e4da
+--- /dev/null
++++ b/plugins/dbus/amb-qt/Meter.qml
+@@ -0,0 +1,46 @@
++/*
++Copyright (C) 2015 Cogent Embedded Inc.
++
++This library is free software; you can redistribute it and/or
++modify it under the terms of the GNU Lesser General Public
++License as published by the Free Software Foundation; either
++version 2.1 of the License, or (at your option) any later version.
++
++This library is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++Lesser General Public License for more details.
++
++You should have received a copy of the GNU Lesser General Public
++License along with this library; if not, write to the Free Software
++Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
++*/
++import QtQuick 2.0
++import amb 0.1
++
++Row {
++
++    property string name
++    onNameChanged: {
++        // we use objectName.propertyName format
++        var parts = name.split(".");
++        prop.objectName = parts[0];
++        prop.propertyName = parts.length >= 2 ? parts[1] : "Value";
++        prop.connect();
++    }
++
++    spacing: 10
++    Text {
++        text: parent.name
++        font.pointSize: 14
++        width: 300 // this is a guess
++    }
++    Text {
++        text: qsTr("%1").arg(prop.value)
++        font.pointSize: 14
++    }
++
++    AutomotivePropertyItem {
++        id: prop
++    }
++}
+diff --git a/plugins/dbus/amb-qt/qtquicktest.cpp b/plugins/dbus/amb-qt/qtquicktest.cpp
+new file mode 100644
+index 0000000..4735d57
+--- /dev/null
++++ b/plugins/dbus/amb-qt/qtquicktest.cpp
+@@ -0,0 +1,12 @@
++#include <QGuiApplication>
++#include <QQmlApplicationEngine>
++
++int main(int argc, char *argv[])
++{
++      QGuiApplication app(argc, argv);
++
++      QQmlApplicationEngine engine;
++      engine.load(QUrl(QStringLiteral("qrc:/qtquicktest.qml")));
++
++      return app.exec();
++}
+diff --git a/plugins/dbus/amb-qt/qtquicktest.qml b/plugins/dbus/amb-qt/qtquicktest.qml
+new file mode 100644
+index 0000000..70cd846
+--- /dev/null
++++ b/plugins/dbus/amb-qt/qtquicktest.qml
+@@ -0,0 +1,35 @@
++/*
++Copyright (C) 2015 Cogent Embedded Inc.
++
++This library is free software; you can redistribute it and/or
++modify it under the terms of the GNU Lesser General Public
++License as published by the Free Software Foundation; either
++version 2.1 of the License, or (at your option) any later version.
++
++This library is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++Lesser General Public License for more details.
++
++You should have received a copy of the GNU Lesser General Public
++License along with this library; if not, write to the Free Software
++Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
++*/
++import QtQuick 2.0
++import QtQuick.Window 2.0
++
++Window {
++    visible: true
++    width: 500
++    height: 400
++
++    Column {
++        anchors.fill: parent;
++
++        Meter { name: "VehicleSpeed.Speed"}
++        Meter { name: "EngineSpeed.Speed"}
++        Meter { name: "SteeringWheel.Angle"}
++        Meter { name: "ThrottlePosition.Value"}
++        Meter { name: "BrakeOperation.BrakePressure"}
++    }
++}
+diff --git a/plugins/dbus/amb-qt/qtquicktest.qrc b/plugins/dbus/amb-qt/qtquicktest.qrc
+new file mode 100644
+index 0000000..998ec70
+--- /dev/null
++++ b/plugins/dbus/amb-qt/qtquicktest.qrc
+@@ -0,0 +1,6 @@
++<RCC>
++    <qresource prefix="/">
++        <file>qtquicktest.qml</file>
++        <file>Meter.qml</file>
++    </qresource>
++</RCC>
+-- 
+1.9.1
+
diff --git a/meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0009-Add-Pressure-property-to-BrakeOperation.patch b/meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0009-Add-Pressure-property-to-BrakeOperation.patch
new file mode 100644 (file)
index 0000000..11b44f5
--- /dev/null
@@ -0,0 +1,24 @@
+From 8f761e02172544212915c82b7e8dd8d4dd1281a6 Mon Sep 17 00:00:00 2001
+From: Petr Nechaev <petr.nechaev@cogentembedded.com>
+Date: Mon, 3 Aug 2015 14:18:34 +0300
+Subject: [PATCH 9/9] Add 'Pressure' property to 'BrakeOperation'
+
+---
+ plugins/dbus/runningstatus.h | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/plugins/dbus/runningstatus.h b/plugins/dbus/runningstatus.h
+index 16321cb..a706528 100644
+--- a/plugins/dbus/runningstatus.h
++++ b/plugins/dbus/runningstatus.h
+@@ -115,6 +115,7 @@ public:
+               :DBusSink("BrakeOperation", re, connection, map<string, string>())
+       {
+               wantPropertyVariant(VehicleProperty::WheelBrake, "BrakePedalDepressed", VariantType::Read);
++              wantPropertyVariant(VehicleProperty::WheelBrakePressure, "BrakePressure", VariantType::Read);
+       }
+ };
+-- 
+1.9.1
+
index 7c49e6c..ce4b127 100644 (file)
@@ -9,8 +9,6 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=b42382de5d854b9bb598acf2e8827de3"
 
 inherit cmake systemd
 
-PV = "0.12+git${SRCPV}"
-
 # The 'gpsd' leads to a conflict between bluez4 and bluez5 because
 # meta-openembedded/meta-oe/recipes-navigation/gpsd/gpsd_3.10.bb is able to
 # select  bluez4 only instead AGL Distro choose bluez5 at changeset 4141.
@@ -22,19 +20,33 @@ PV = "0.12+git${SRCPV}"
 DEPENDS = "glib-2.0 util-linux sqlite3 boost json-c libtool"
 RDEPENDS_${PN} = "python-misc python-json"
 
-SRC_URI = "git://github.com/otcshare/automotive-message-broker.git"
-SRCREV = "ac3fe53327a13afc571efe079a31a0472ea285a3"
-
-SRC_URI += "file://amb_allow_sessionbus.patch \
-            file://ambd.service \
-            "
+PV = "0.14+git${SRCPV}"
+
+SRC_URI = "git://github.com/CogentEmbedded/automotive-message-broker.git;protocol=https;branch=master"
+SRCREV = "58569fac42bb8b6e1ad208caef5db8a51befc87f"
+
+# The paches from 0001 to 0009 are from difference between 
+# hash:58569fac42bb8b6e1ad208caef5db8a51befc87f(main branch) and
+# hash:8f761e02172544212915c82b7e8dd8d4dd1281a6(dev_0.14_2)
+SRC_URI += " \
+    file://0001-Improve-backward-compatibility-with-old-linaro-gcc.patch \
+    file://0002-Fix-library-versioning.patch \
+    file://0003-AmbSignalMapper-fix-can-interface-specification.patch \
+    file://0004-cansocketbcm-Fix-reading-of-frames-in-case-of-RX_TIM.patch \
+    file://0005-ambctl-remove-unnecessary-dependency-on-glib-introsp.patch \
+    file://0006-cangen-Implement-basic-handling-of-RX_TIMEOUT.patch \
+    file://0007-WORKAROUND-Allow-amb-qt-binding-to-work-in-case-of-m.patch \
+    file://0008-Add-simple-Qt-QML-example.patch \
+    file://0009-Add-Pressure-property-to-BrakeOperation.patch \
+    file://ambd.service \
+    "
 
 SYSTEMD_PACKAGES = "${PN}"
 SYSTEMD_SERVICE_${PN} = "ambd.service"
 
 S = "${WORKDIR}/git"
 
-# amb detects icecc in cmake and would override the 
+# amb detects icecc in cmake and would override the
 # compiler selection of yocto. This breaks the build
 # if icecc is installed on the host.
 # -> Disable the detection in cmake.