summaryrefslogtreecommitdiff
path: root/src/components/qt_hmi/qml_plugins/dbus_adapter
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/qt_hmi/qml_plugins/dbus_adapter')
-rw-r--r--src/components/qt_hmi/qml_plugins/dbus_adapter/CMakeLists.txt164
-rw-r--r--src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.cc93
-rw-r--r--src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.h65
-rw-r--r--src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.cc97
-rw-r--r--src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.h70
-rw-r--r--src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.cc46
-rw-r--r--src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.h64
-rw-r--r--src/components/qt_hmi/qml_plugins/dbus_adapter/metatype.h61
-rw-r--r--src/components/qt_hmi/qml_plugins/dbus_adapter/optional_argument.h94
-rw-r--r--src/components/qt_hmi/qml_plugins/dbus_adapter/qml_dbus_common.h236
-rw-r--r--src/components/qt_hmi/qml_plugins/dbus_adapter/qmldir3
-rw-r--r--src/components/qt_hmi/qml_plugins/dbus_adapter/qt_version.h47
-rw-r--r--src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.cc68
-rw-r--r--src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.h42
14 files changed, 1150 insertions, 0 deletions
diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/CMakeLists.txt b/src/components/qt_hmi/qml_plugins/dbus_adapter/CMakeLists.txt
new file mode 100644
index 0000000000..53d1144356
--- /dev/null
+++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/CMakeLists.txt
@@ -0,0 +1,164 @@
+# Copyright (c) 2013, Ford Motor Company
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+#
+# Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following
+# disclaimer in the documentation and/or other materials provided with the
+# distribution.
+#
+# Neither the name of the Ford Motor Company nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+cmake_minimum_required(VERSION 2.8.11)
+
+set(components_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
+set(dbus_dir ${components_dir}/dbus)
+set(codegen_dir ${dbus_dir}/codegen)
+set(codegen ${codegen_dir}/make_qml_dbus_cpp.py)
+set(codegen_request_to_sdl ${codegen_dir}/make_request_to_sdl.py)
+set(codegen_hmi_requests ${codegen_dir}/make_hmi_requests.py)
+set(codegen_notification_qml ${codegen_dir}/make_notifications_qml.py)
+set(parser ${codegen_dir}/ford_xml_parser.py)
+set(interfaces_dir ${components_dir}/interfaces)
+set(api_xml ${interfaces_dir}/QT_HMI_API.xml)
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qml_dbus.cc ${CMAKE_CURRENT_BINARY_DIR}/qml_dbus.h
+ COMMAND python ${codegen} --infile ${api_xml} --version ${qt_version} --outdir ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS ${api_xml} ${codegen} ${parser}
+ COMMENT "Generating files:
+ ${CMAKE_CURRENT_BINARY_DIR}/qml_dbus.cc
+ ${CMAKE_CURRENT_BINARY_DIR}/qml_dbus.h
+ from:
+ ${api_xml} ..."
+)
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/request_to_sdl.cc ${CMAKE_CURRENT_BINARY_DIR}/request_to_sdl.h
+ COMMAND python ${codegen_request_to_sdl} --infile ${api_xml} --version ${qt_version} --outdir ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS ${api_xml} ${codegen_request_to_sdl} ${parser}
+ COMMENT "Generating files:
+ ${CMAKE_CURRENT_BINARY_DIR}/request_to_sdl.cc
+ ${CMAKE_CURRENT_BINARY_DIR}/request_to_sdl.h
+ from:
+ ${api_xml} ..."
+)
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/hmi_requests.cc ${CMAKE_CURRENT_BINARY_DIR}/hmi_requests.h
+ COMMAND python ${codegen_hmi_requests} --infile ${api_xml} --version ${qt_version} --outdir ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS ${api_xml} ${codegen_hmi_requests} ${parser}
+ COMMENT "Generating files:
+ ${CMAKE_CURRENT_BINARY_DIR}/hmi_requests.cc
+ ${CMAKE_CURRENT_BINARY_DIR}/hmi_requests.h
+ from:
+ ${api_xml} ..."
+)
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sdl_proxy.cc ${CMAKE_CURRENT_BINARY_DIR}/sdl_proxy.h
+ COMMAND python ${codegen_notification_qml} --infile ${api_xml} --version ${qt_version} --outdir ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS ${api_xml} ${codegen_notification_qml} ${parser}
+ COMMENT "Generating files:
+ ${CMAKE_CURRENT_BINARY_DIR}/sdl_proxy.cc
+ ${CMAKE_CURRENT_BINARY_DIR}/sdl_proxy.h
+ from:
+ ${api_xml} ..."
+)
+
+set(target DbusAdapter)
+set(destination com/ford/sdl/hmi/dbus_adapter)
+set(install_destination bin/hmi/plugins/${destination})
+set(library_name ${CMAKE_SHARED_LIBRARY_PREFIX}${target}${CMAKE_SHARED_LIBRARY_SUFFIX})
+
+set(CMAKE_AUTOMOC ON)
+set(SOURCES
+ dbus_plugin.cc
+ ${CMAKE_CURRENT_BINARY_DIR}/qml_dbus.cc
+ moc_qml_dbus.cpp
+ sdl_proxy.cc
+ moc_sdl_proxy.cpp
+ hmi_proxy.cc
+ stream_qvariant.cc
+ moc_qml_dbus.cpp
+ dbus_controller.cc
+ request_to_sdl.cc
+ moc_request_to_sdl.cpp
+ hmi_requests.cc
+ moc_hmi_requests.cpp
+)
+include_directories(
+ ${LOG4CXX_INCLUDE_DIRECTORY}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_BINARY_DIR}/src/components
+ ${CMAKE_SOURCE_DIR}/src/components/utils/include/
+)
+
+add_library(${target} SHARED ${SOURCES})
+
+if (${qt_version} MATCHES "4.8.5")
+ qt4_generate_moc(${CMAKE_CURRENT_BINARY_DIR}/hmi_requests.h moc_hmi_requests.cpp)
+ qt4_generate_moc(${CMAKE_CURRENT_BINARY_DIR}/request_to_sdl.h moc_request_to_sdl.cpp)
+ qt4_generate_moc(${CMAKE_CURRENT_BINARY_DIR}/qml_dbus.h moc_qml_dbus.cpp)
+ qt4_generate_moc(${CMAKE_CURRENT_BINARY_DIR}/sdl_proxy.h moc_sdl_proxy.cpp)
+ qt4_use_modules(${target} Core DBus Declarative)
+ set(model_dir ${CMAKE_CURRENT_BINARY_DIR}/../../qml_model_qt4/)
+ set(copy_destination ${CMAKE_CURRENT_BINARY_DIR}/../../qml_model_qt4/${destination})
+elseif (${qt_version} MATCHES "5.1.0")
+ qt5_generate_moc(${CMAKE_CURRENT_BINARY_DIR}/hmi_requests.h moc_hmi_requests.cpp)
+ qt5_generate_moc(${CMAKE_CURRENT_BINARY_DIR}/request_to_sdl.h moc_request_to_sdl.cpp)
+ qt5_generate_moc(${CMAKE_CURRENT_BINARY_DIR}/qml_dbus.h moc_qml_dbus.cpp)
+ qt5_generate_moc(${CMAKE_CURRENT_BINARY_DIR}/sdl_proxy.h moc_sdl_proxy.cpp)
+ qt5_use_modules(${target} Core DBus Qml)
+ set(model_dir ${CMAKE_CURRENT_BINARY_DIR}/../../qml_model_qt5/)
+ set(copy_destination ${CMAKE_CURRENT_BINARY_DIR}/../../qml_model_qt5/${destination})
+endif ()
+
+target_link_libraries(${target} log4cxx -L${LOG4CXX_LIBS_DIRECTORY})
+target_link_libraries(${target} Utils)
+
+add_custom_target(copy_library_${target} ALL
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ ${CMAKE_CURRENT_BINARY_DIR}/${library_name}
+ ${copy_destination}
+ DEPENDS ${target}
+ COMMENT "Copying library ${library_name}")
+file(COPY qmldir DESTINATION ${copy_destination})
+
+install(TARGETS ${target}
+ DESTINATION ${install_destination}
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
+ GROUP_READ GROUP_EXECUTE
+ WORLD_READ WORLD_EXECUTE
+)
+install(FILES qmldir DESTINATION ${install_destination})
+
+if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ add_custom_target(qmltypes_${target} ALL
+ COMMAND ${qmlplugindump_binary} -nonrelocatable com.ford.sdl.hmi.dbus_adapter 1.0 ${model_dir} > ${CMAKE_CURRENT_BINARY_DIR}/plugins.qmltypes 2>/dev/null || true
+ DEPENDS copy_library_${target}
+ )
+ add_custom_target(copy_qmltypes_${target} ALL
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ ${CMAKE_CURRENT_BINARY_DIR}/plugins.qmltypes
+ ${copy_destination}
+ DEPENDS qmltypes_${target}
+ )
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/plugins.qmltypes DESTINATION ${install_destination})
+endif ()
diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.cc b/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.cc
new file mode 100644
index 0000000000..abfe712398
--- /dev/null
+++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.cc
@@ -0,0 +1,93 @@
+/**
+ * \file dbus_controller.cpp
+ * \brief DbusController class.
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "dbus_controller.h"
+#include "interfaces/QT_HMI_API.h"
+#include <QtDBus/QDBusConnection>
+
+DBusController::DBusController(QObject *parent)
+ : QObject(parent),
+ message(NULL) {}
+
+void DBusController::addMessage(const QDBusMessage& message, fillRoutine fill,
+ int async_uid) {
+ delayedReply reply;
+ reply.message = message;
+ reply.fill = fill;
+ replies_[async_uid] = reply;
+}
+
+void DBusController::sendReply(QVariant asyncObject, QVariant data) {
+ int uid = asyncObject.toMap()["__async_uid"].toInt();
+ std::map<int, delayedReply>::iterator it = replies_.find(uid);
+ if (it != replies_.end()) {
+ QDBusMessage msg = it->second.message.createReply();
+ if (!it->second.fill(msg, data.toMap())) {
+ QDBusConnection::sessionBus()
+ .send(it->second.message.createErrorReply(QDBusError::InternalError,
+ QString::number(hmi_apis::Common_Result::INVALID_DATA)));
+ } else {
+ QDBusConnection::sessionBus().send(msg);
+ }
+ replies_.erase(it);
+ }
+}
+
+void DBusController::sendReply(QVariant data) {
+ if (!message)
+ return;
+ QDBusMessage msg = message->createReply();
+ if (!fill(msg, data.toMap())) {
+ QDBusConnection::sessionBus()
+ .send(message->createErrorReply(QDBusError::InternalError,
+ QString::number(hmi_apis::Common_Result::INVALID_DATA)));
+ } else {
+ QDBusConnection::sessionBus().send(msg);
+ }
+}
+
+void DBusController::sendError(QVariant asyncObject, QVariant code, QVariant message) {
+ int uid = asyncObject.toMap()["__async_uid"].toInt();
+ std::map<int, delayedReply>::iterator it = replies_.find(uid);
+ if (it != replies_.end()) {
+ QDBusMessage msg = it->second.message.createErrorReply(code.toString(),
+ message.toString());
+ QDBusConnection::sessionBus().send(msg);
+ replies_.erase(it);
+ }
+}
+
+void DBusController::sendError(QVariant asyncObject, QVariant code) {
+ sendError(asyncObject, code, QVariant(""));
+}
diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.h b/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.h
new file mode 100644
index 0000000000..45b6a4e7fe
--- /dev/null
+++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.h
@@ -0,0 +1,65 @@
+/**
+ * \file dbus_controller.h
+ * \brief DbusController class header file.
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_DBUS_CONTROLLER_H_
+#define SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_DBUS_CONTROLLER_H_
+
+#include <QtDBus/QDBusMessage>
+#include <QtCore/QObject>
+#include <map>
+
+typedef bool (*fillRoutine)(QDBusMessage&, const QVariantMap&);
+
+class DBusController: public QObject {
+ struct delayedReply {
+ QDBusMessage message;
+ fillRoutine fill;
+ };
+ Q_OBJECT
+
+ public:
+ explicit DBusController(QObject *parent = 0);
+ void addMessage(const QDBusMessage& message, fillRoutine fill, int async_uid);
+ Q_INVOKABLE void sendReply(QVariant asyncObject, QVariant data);
+ Q_INVOKABLE void sendReply(QVariant data);
+ Q_INVOKABLE void sendError(QVariant asyncObject, QVariant code);
+ Q_INVOKABLE void sendError(QVariant asyncObject, QVariant code, QVariant message);
+ const QDBusMessage* message;
+ fillRoutine fill;
+
+ private:
+ std::map<int, delayedReply> replies_;
+};
+
+#endif // SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_DBUS_CONTROLLER_H_
diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.cc b/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.cc
new file mode 100644
index 0000000000..c264a42a8b
--- /dev/null
+++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.cc
@@ -0,0 +1,97 @@
+/**
+ * \file dbus_plugin.cpp
+ * \brief DbusPlugin class source file.
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "dbus_plugin.h"
+
+#include "hmi_proxy.h"
+#include "sdl_proxy.h"
+#include "optional_argument.h"
+#include "qml_dbus.h"
+#include "dbus_controller.h"
+#include "request_to_sdl.h"
+
+#include <log4cxx/logger.h>
+#include <log4cxx/propertyconfigurator.h>
+
+#include <QtCore/QString>
+#include <QtDBus/QDBusConnection>
+
+#if QT_4
+# include <QtDeclarative/QDeclarativeContext>
+# include <QtDeclarative/QDeclarativeListReference>
+# include <QtDeclarative/QDeclarativeEngine>
+#elif QT_5
+# include <QtQml/QQmlContext>
+# include <QtQml/QQmlListReference>
+# include <QtQml/QQmlEngine>
+#endif // QT_VERSION
+log4cxx::LoggerPtr logger_ = log4cxx::LoggerPtr(
+ log4cxx::Logger::getLogger("DBusPlugin"));
+
+void DbusPlugin::registerTypes(const char *uri) {
+ log4cxx::PropertyConfigurator::configure("log4cxx.properties");
+
+ // @uri sdl.core.api
+ qmlRegisterType<HmiProxy>(uri, 1, 0, "HMIAdapter");
+ qmlRegisterType<SdlProxy>(uri, 1, 0, "SDLAdapter");
+
+ RegisterDbusMetatypes();
+ qDBusRegisterMetaType<OptionalArgument<int> >();
+ qDBusRegisterMetaType<OptionalArgument<QList<int> > >();
+ qDBusRegisterMetaType<OptionalArgument<QString> >();
+ qDBusRegisterMetaType<OptionalArgument<QStringList> >();
+ qDBusRegisterMetaType<OptionalArgument<bool> >();
+ qDBusRegisterMetaType<OptionalArgument<QList<bool> > >();
+ qDBusRegisterMetaType<OptionalArgument<double> >();
+ qDBusRegisterMetaType<OptionalArgument<QList<double> > >();
+
+ HmiProxy::api_adaptors_.Init(this);
+
+ QDBusConnection::sessionBus().registerObject("/", this);
+ QDBusConnection::sessionBus().registerService("com.ford.sdl.hmi");
+
+ dbusController_ = new DBusController();
+ requestToSDL_ = new RequestToSDL();
+
+ HmiProxy::api_adaptors_.SetDBusController(dbusController_);
+}
+
+void DbusPlugin::initializeEngine(Engine *engine, const char *uri) {
+ engine->rootContext()->setContextProperty("DBus", dbusController_);
+ engine->rootContext()->setContextProperty("RequestToSDL", requestToSDL_);
+}
+
+#if QT_4
+Q_EXPORT_PLUGIN2(DbusAdapter, DbusPlugin)
+#endif // QT_4
diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.h b/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.h
new file mode 100644
index 0000000000..4d145d09b4
--- /dev/null
+++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.h
@@ -0,0 +1,70 @@
+/**
+ * \file dbus_plugin.h
+ * \brief DbusPlugin class header file.
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_DBUS_PLUGIN_H_
+#define SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_DBUS_PLUGIN_H_
+
+#include "qt_version.h"
+
+#if QT_4
+# include <QtDeclarative/QDeclarativeExtensionPlugin>
+typedef QDeclarativeExtensionPlugin ExtensionPlugin;
+typedef QDeclarativeEngine Engine;
+#elif QT_5
+# include <QtQml/QQmlExtensionPlugin>
+typedef QQmlExtensionPlugin ExtensionPlugin;
+typedef QQmlEngine Engine;
+#endif // QT_VERSION
+#include <QtDBus/QDBusContext>
+
+class DBusController;
+class RequestToSDL;
+
+class DbusPlugin : public ExtensionPlugin, public QDBusContext {
+ Q_OBJECT
+
+#if QT_5
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
+#endif // QT_5
+
+ DBusController *dbusController_;
+ RequestToSDL *requestToSDL_;
+
+ public:
+ void registerTypes(const char *uri);
+ void initializeEngine(Engine *engine, const char *uri);
+};
+
+#endif // SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_DBUS_PLUGIN_H_
+
diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.cc b/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.cc
new file mode 100644
index 0000000000..bd9e6efea9
--- /dev/null
+++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.cc
@@ -0,0 +1,46 @@
+/**
+ * \file hmiproxy.cpp
+ * \brief HmiProxy class source file.
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "hmi_proxy.h"
+#include <QtDBus/QDBusConnection>
+
+ApiAdaptors HmiProxy::api_adaptors_;
+
+HmiProxy::HmiProxy(Item *parent)
+ : Item(parent) {}
+
+void HmiProxy::componentComplete() {
+ Item::componentComplete();
+ api_adaptors_.SetApi(this);
+}
diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.h b/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.h
new file mode 100644
index 0000000000..7fa0e49bf8
--- /dev/null
+++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.h
@@ -0,0 +1,64 @@
+/**
+ * \file hmiproxy.h
+ * \brief HmiProxy class header file.
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_HMI_PROXY_H_
+#define SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_HMI_PROXY_H_
+
+#include "qt_version.h"
+#include "qml_dbus.h"
+
+#if QT_4
+# include <QtDeclarative/QDeclarativeItem>
+typedef QDeclarativeItem Item;
+#elif QT_5
+# include <QtQuick/QQuickItem>
+typedef QQuickItem Item;
+#endif // QT_VERSION
+
+class HmiProxy : public Item {
+ Q_OBJECT
+ Q_DISABLE_COPY(HmiProxy)
+
+ public:
+ explicit HmiProxy(Item *parent = 0);
+ static ApiAdaptors api_adaptors_;
+
+ protected:
+ virtual void componentComplete();
+};
+
+QML_DECLARE_TYPE(HmiProxy)
+
+#endif // SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_HMI_PROXY_H_
+
diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/metatype.h b/src/components/qt_hmi/qml_plugins/dbus_adapter/metatype.h
new file mode 100644
index 0000000000..6f2b54fc57
--- /dev/null
+++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/metatype.h
@@ -0,0 +1,61 @@
+/**
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_METATYPE_H_
+#define SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_METATYPE_H_
+
+#include <QMetaType>
+
+template<typename T>
+QMetaType::Type metatype();
+
+template<>
+inline QMetaType::Type metatype<int>() {
+ return QMetaType::Int;
+}
+
+template<>
+inline QMetaType::Type metatype<QString>() {
+ return QMetaType::QString;
+}
+
+template<>
+inline QMetaType::Type metatype<bool>() {
+ return QMetaType::Bool;
+}
+
+template<>
+inline QMetaType::Type metatype<double>() {
+ return QMetaType::Double;
+}
+
+#endif // SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_METATYPE_H_
diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/optional_argument.h b/src/components/qt_hmi/qml_plugins/dbus_adapter/optional_argument.h
new file mode 100644
index 0000000000..79dfdd1838
--- /dev/null
+++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/optional_argument.h
@@ -0,0 +1,94 @@
+/**
+ * \file optional_argument.h
+ * \brief OptionalArgument struct header file.
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_OPTIONAL_ARGUMENT_H_
+#define SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_OPTIONAL_ARGUMENT_H_
+
+#include "qt_version.h"
+#include <QtDBus/QDBusArgument>
+
+template<class T>
+struct OptionalArgument {
+ T val;
+ bool presence;
+ explicit OptionalArgument(const T& value)
+ : val(value),
+ presence(true) {}
+ OptionalArgument()
+ : presence(false) {}
+};
+
+template<class T>
+inline
+QDBusArgument& operator << (QDBusArgument& arg, const OptionalArgument<T>& o) {
+ arg.beginStructure();
+ arg << o.presence << o.val;
+ arg.endStructure();
+ return arg;
+}
+
+template<class T>
+inline
+const QDBusArgument& operator >> (const QDBusArgument& arg, OptionalArgument<T>& o) {
+ arg.beginStructure();
+ arg >> o.presence >> o.val;
+ arg.endStructure();
+ return arg;
+}
+
+template<class T>
+inline
+bool VariantToValue(const QVariant& variant, OptionalArgument<T>& o) {
+ if (variant.isNull()) {
+ o.presence = false;
+ return true;
+ }
+ o.presence = true;
+ return VariantToValue(variant, o.val);
+}
+
+#if QT_4
+Q_DECLARE_METATYPE(QList<int>)
+#endif // QT_4
+
+Q_DECLARE_METATYPE(OptionalArgument<int>)
+Q_DECLARE_METATYPE(OptionalArgument<QString>)
+Q_DECLARE_METATYPE(OptionalArgument<bool>)
+Q_DECLARE_METATYPE(OptionalArgument<double>)
+
+Q_DECLARE_METATYPE(OptionalArgument<QList<int> >)
+Q_DECLARE_METATYPE(OptionalArgument<QStringList>)
+Q_DECLARE_METATYPE(OptionalArgument<QList<bool> >)
+Q_DECLARE_METATYPE(OptionalArgument<QList<double> >)
+#endif // SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_OPTIONAL_ARGUMENT_H_
diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/qml_dbus_common.h b/src/components/qt_hmi/qml_plugins/dbus_adapter/qml_dbus_common.h
new file mode 100644
index 0000000000..6148da71f5
--- /dev/null
+++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/qml_dbus_common.h
@@ -0,0 +1,236 @@
+/**
+ * \file qml_dbus_common.h
+ * \brief Contain utilities for DBus plugin.
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_QML_DBUS_COMMON_H_
+#define SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_QML_DBUS_COMMON_H_
+
+#include <QtDBus/QDBusContext>
+#include "optional_argument.h"
+#include "stream_qvariant.h"
+#include "metatype.h"
+
+enum ErrorCode {
+ Success = 0,
+ UnsupportedRequest,
+ UnsupportedResource,
+ Disallowed,
+ Rejected,
+ Aborted,
+ Ignored,
+ Retry,
+ InUse,
+ DataNotAvailable,
+ TimedOut,
+ InvalidData,
+ CharLimitExceeded,
+ InvalidId,
+ DuplicateName,
+ ApplicationNotRegistered,
+ WrongLanguage,
+ OutOfMemory,
+ TooManyPendingRequests,
+ NoAppsRegistered,
+ NoDevicesConnected,
+ Warnings,
+ GenericError,
+ UserDisallowed
+};
+
+inline void RaiseDbusError(QObject* adaptor, int code, const QString& message) {
+ QDBusContext* context = dynamic_cast<QDBusContext*>(adaptor->parent());
+ if (context) {
+ context->sendErrorReply(QString::number(static_cast<int>(code)),
+ message);
+ }
+}
+
+inline void RaiseDbusError(QObject* adaptor, int code) {
+ RaiseDbusError(adaptor, code, "");
+}
+
+template<typename T>
+inline void PutArgToMap(QVariantMap& map, const char* name, const T& v) {
+ map.insert(name, QVariant::fromValue(v));
+}
+
+inline bool GetArgFromMap(const QVariantMap& map, const char* name, int& v) {
+ QVariantMap::const_iterator it = map.find(name);
+ if (map.end() == it) return false;
+ if (it->type() != QVariant::Int) return false;
+ v = it->toInt();
+ return true;
+}
+
+inline bool GetArgFromMap(const QVariantMap& map, const char* name, QString& v) {
+ QVariantMap::const_iterator it = map.find(name);
+ if (map.end() == it) return false;
+ if (it->type() != QVariant::String) return false;
+ v = it->toString();
+ return true;
+}
+
+inline bool GetArgFromMap(const QVariantMap& map, const char* name, bool& v) {
+ QVariantMap::const_iterator it = map.find(name);
+ if (map.end() == it) return false;
+ if (it->type() != QVariant::Bool) return false;
+ v = it->toBool();
+ return true;
+}
+
+inline bool isNumber(QVariant v) {
+ QVariant::Type t = v.type();
+ return (t == QVariant::Double) || (t == QVariant::Int) ||
+ (t == QVariant::UInt) || (t == QVariant::LongLong) ||
+ (t == QVariant::ULongLong);
+}
+
+inline bool GetArgFromMap(const QVariantMap& map, const char* name, double& v) {
+ QVariantMap::const_iterator it = map.find(name);
+ if (map.end() == it) return false;
+ if (!isNumber(*it)) return false;
+ v = it->toDouble();
+ return true;
+}
+
+inline bool VariantToValue(const QVariant& variant, int& v) {
+ if (variant.type() != QVariant::Int) return false;
+ v = variant.toInt();
+ return true;
+}
+
+inline bool VariantToValue(const QVariant& variant, QString& v) {
+ if (variant.type() != QVariant::String) return false;
+ v = variant.toString();
+ return true;
+}
+
+inline bool VariantToValue(const QVariant& variant, bool& v) {
+ if (variant.type() != QVariant::Bool) return false;
+ v = variant.toBool();
+ return true;
+}
+
+inline bool VariantToValue(const QVariant& variant, double& v) {
+ if (variant.type() != QVariant::Double) return false;
+ v = variant.toDouble();
+ return true;
+}
+
+inline bool VariantToValue(const QVariant& variant, QStringList& v) {
+ if (variant.type() != QVariant::List) return false;
+ QList<QVariant> list = variant.toList();
+ for (QList<QVariant>::const_iterator i = list.begin(); i != list.end(); ++i) {
+ if (i->type() != QVariant::String) return false;
+ v.append(i->toString());
+ }
+ return true;
+}
+
+template<typename T>
+bool VariantToValue(const QVariant& variant, QList<T>& v) {
+ if (variant.type() != QVariant::List) return false;
+ QList<T> spare;
+ QList<QVariant> list = variant.toList();
+ for (QList<QVariant>::const_iterator i = list.begin(); i != list.end(); ++i) {
+ QVariant::Type type = i->type();
+// Although this function is declared as returning QVariant::Type(obsolete),
+// the return value should be interpreted as QMetaType::Type.
+// (http://qt-project.org/doc/qt-5.0/qtcore/qvariant.html#type)
+ QMetaType::Type type_casted = static_cast<QMetaType::Type>(type);
+ if (type_casted != metatype<T>()) {
+ return false;
+ }
+ spare.append(i->value<T>());
+ }
+ v.swap(spare);
+ return true;
+}
+
+template<typename T>
+inline QVariant ValueToVariant(const T& v) {
+ return QVariant::fromValue(v);
+}
+
+template<typename T>
+inline QVariant ValueToVariant(const QList<T>& v) {
+ QList<QVariant> list;
+ for (typename QList<T>::const_iterator i = v.begin(); i != v.end(); ++i)
+ list.append(ValueToVariant(*i));
+ return QVariant::fromValue(list);
+}
+
+template<typename T>
+inline void PutArgToMap(QVariantMap& map, const char* name, const QList<T>& v) {
+ QList<QVariant> list;
+ for (typename QList<T>::const_iterator i = v.begin(); i != v.end(); ++i)
+ list.append(ValueToVariant(*i));
+ map.insert(name, QVariant::fromValue(list));
+}
+
+template<typename T>
+inline bool GetArgFromMap(const QVariantMap& map, const char* name, QList<T>& v) {
+ QVariantMap::const_iterator it = map.find(name);
+ if (map.end() == it) return false;
+ const QVariant& variant = *it;
+ if (variant.type() != QVariant::List) return false;
+ QList<QVariant> list = variant.toList();
+ for (QList<QVariant>::const_iterator i = list.begin(); i != list.end(); ++i) {
+ T t;
+ bool ok = VariantToValue(*i, t);
+ if (!ok) return false;
+ v.append(t);
+ }
+ return true;
+}
+
+template<typename T>
+inline void PutArgToMap(QVariantMap& map, const char* name,
+ const OptionalArgument<T>& v) {
+ if (v.presence)
+ map.insert(name, ValueToVariant(v.val));
+}
+
+template<typename T>
+inline bool GetArgFromMap(const QVariantMap& map, const char* name,
+ OptionalArgument<T>& v) {
+ QVariantMap::const_iterator it = map.find(name);
+ if (map.end() == it || !it->isValid()) {
+ v.presence = false;
+ return true;
+ }
+ v.presence = true;
+ return GetArgFromMap(map, name, v.val);
+}
+
+#endif // SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_QML_DBUS_COMMON_H_
diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/qmldir b/src/components/qt_hmi/qml_plugins/dbus_adapter/qmldir
new file mode 100644
index 0000000000..5f426d357d
--- /dev/null
+++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/qmldir
@@ -0,0 +1,3 @@
+module com.ford.sdl.hmi.dbus_adapter
+plugin DbusAdapter
+
diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/qt_version.h b/src/components/qt_hmi/qml_plugins/dbus_adapter/qt_version.h
new file mode 100644
index 0000000000..cbad38ed5e
--- /dev/null
+++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/qt_version.h
@@ -0,0 +1,47 @@
+/**
+ * @file qt_version.h
+ * @brief Defines for check Qt version.
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_QT_VERSION_H_
+#define SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_QT_VERSION_H_
+
+#include <qglobal.h>
+
+#define QT_4 ((QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)) && \
+ (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)))
+
+#define QT_5 ((QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) && \
+ (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)))
+
+#endif // SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_QT_VERSION_H_
+
diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.cc b/src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.cc
new file mode 100644
index 0000000000..a1ae3402c4
--- /dev/null
+++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.cc
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "stream_qvariant.h"
+
+std::basic_ostream<char>& operator<<(std::basic_ostream<char>& os,
+ const QVariant& value) {
+ switch (value.type()) {
+ case QVariant::Map: {
+ os << "{ ";
+ QVariantMap structure = value.toMap();
+ QMapIterator<QString, QVariant> i(structure);
+ while (i.hasNext()) {
+ i.next();
+ os << i.key() << ":" << i.value();
+ if (i.hasNext()) {
+ os << ", ";
+ }
+ }
+ os << " }";
+ } break;
+ case QVariant::List: {
+ os << "[ ";
+ QVariantList array = value.toList();
+ QListIterator<QVariant> i(array);
+ while (i.hasNext()) {
+ os << i.next();
+ if (i.hasNext()) {
+ os << ", ";
+ }
+ }
+ os << " ]";
+ } break;
+ default:
+ os << value.toString().toLatin1().data();
+ }
+
+ return os;
+}
diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.h b/src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.h
new file mode 100644
index 0000000000..675b6d069e
--- /dev/null
+++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.h
@@ -0,0 +1,42 @@
+/**
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_STREAM_QVARIANT_H_
+#define SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_STREAM_QVARIANT_H_
+
+#include <QtCore/QVariant>
+#include <sstream>
+
+std::basic_ostream<char>& operator<<(std::basic_ostream<char>& os,
+ const QVariant& value);
+
+#endif // SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_STREAM_QVARIANT_H_