summaryrefslogtreecommitdiff
path: root/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter
diff options
context:
space:
mode:
Diffstat (limited to 'SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter')
-rw-r--r--SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/CMakeLists.txt116
-rw-r--r--SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.cc89
-rw-r--r--SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.h64
-rw-r--r--SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.cc93
-rw-r--r--SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.h68
-rw-r--r--SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.cc46
-rw-r--r--SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.h64
-rw-r--r--SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/metatype.h61
-rw-r--r--SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/optional_argument.h83
-rw-r--r--SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/qml_dbus_common.h232
-rw-r--r--SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/qmldir3
-rw-r--r--SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/qt_version.h47
-rw-r--r--SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/sdl_proxy.cc110
-rw-r--r--SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/sdl_proxy.h76
-rw-r--r--SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.cc68
-rw-r--r--SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.h42
16 files changed, 1262 insertions, 0 deletions
diff --git a/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/CMakeLists.txt b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/CMakeLists.txt
new file mode 100644
index 000000000..2d970bbb7
--- /dev/null
+++ b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/CMakeLists.txt
@@ -0,0 +1,116 @@
+# 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(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} ..."
+)
+
+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
+ sdl_proxy.cc
+ hmi_proxy.cc
+ stream_qvariant.cc
+ moc_qml_dbus.cpp
+ dbus_controller.cc
+)
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_BINARY_DIR}/src/components
+)
+
+add_library(${target} SHARED ${SOURCES})
+
+if (${qt_version} MATCHES "4.8.5")
+ qt4_generate_moc(${CMAKE_CURRENT_BINARY_DIR}/qml_dbus.h moc_qml_dbus.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}/qml_dbus.h moc_qml_dbus.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} apr-1 aprutil-1 log4cxx)
+
+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/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.cc b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.cc
new file mode 100644
index 000000000..7882cfc6d
--- /dev/null
+++ b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.cc
@@ -0,0 +1,89 @@
+/**
+ * \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 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.createErrorReply(QDBusError::InternalError,
+ data.toString());
+ QDBusConnection::sessionBus().send(msg);
+ replies_.erase(it);
+ }
+}
diff --git a/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.h b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.h
new file mode 100644
index 000000000..9fd1252b5
--- /dev/null
+++ b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.h
@@ -0,0 +1,64 @@
+/**
+ * \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 data);
+ 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/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.cc b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.cc
new file mode 100644
index 000000000..0ea0d9eca
--- /dev/null
+++ b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.cc
@@ -0,0 +1,93 @@
+/**
+ * \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 <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, "HMIProxy");
+ qmlRegisterType<SdlProxy>(uri, 1, 0, "SDLProxy");
+
+ 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();
+ HmiProxy::api_adaptors_.SetDBusController(dbusController_);
+}
+
+void DbusPlugin::initializeEngine(Engine *engine, const char *uri) {
+ engine->rootContext()->setContextProperty("DBus", dbusController_);
+}
+
+#if QT_4
+Q_EXPORT_PLUGIN2(DbusAdapter, DbusPlugin)
+#endif // QT_4
diff --git a/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.h b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.h
new file mode 100644
index 000000000..fb3deb5ce
--- /dev/null
+++ b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.h
@@ -0,0 +1,68 @@
+/**
+ * \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 DbusPlugin : public ExtensionPlugin, public QDBusContext {
+ Q_OBJECT
+
+#if QT_5
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
+#endif // QT_5
+
+ DBusController *dbusController_;
+
+ 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/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.cc b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.cc
new file mode 100644
index 000000000..bd9e6efea
--- /dev/null
+++ b/SDL_Core/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/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.h b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.h
new file mode 100644
index 000000000..7fa0e49bf
--- /dev/null
+++ b/SDL_Core/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/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/metatype.h b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/metatype.h
new file mode 100644
index 000000000..6f2b54fc5
--- /dev/null
+++ b/SDL_Core/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/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/optional_argument.h b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/optional_argument.h
new file mode 100644
index 000000000..61ed1c0b6
--- /dev/null
+++ b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/optional_argument.h
@@ -0,0 +1,83 @@
+/**
+ * \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;
+}
+
+#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/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/qml_dbus_common.h b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/qml_dbus_common.h
new file mode 100644
index 000000000..76e181882
--- /dev/null
+++ b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/qml_dbus_common.h
@@ -0,0 +1,232 @@
+/**
+ * \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) {
+ QDBusContext* context = dynamic_cast<QDBusContext*>(adaptor->parent());
+ if (context) {
+ context->sendErrorReply(QDBusError::InternalError,
+ QString::number(static_cast<int>(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/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/qmldir b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/qmldir
new file mode 100644
index 000000000..5f426d357
--- /dev/null
+++ b/SDL_Core/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/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/qt_version.h b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/qt_version.h
new file mode 100644
index 000000000..cbad38ed5
--- /dev/null
+++ b/SDL_Core/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/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/sdl_proxy.cc b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/sdl_proxy.cc
new file mode 100644
index 000000000..c0b0a3d7f
--- /dev/null
+++ b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/sdl_proxy.cc
@@ -0,0 +1,110 @@
+/**
+ * \file sdlproxy.cpp
+ * \brief SdlProxy 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 "sdl_proxy.h"
+
+SdlProxy::SdlProxy(Item *parent)
+ : Item(parent) {
+
+ QDBusConnection::sessionBus().connect(
+ "com.ford.sdl.core", "/", "com.ford.sdl.core.BasicCommunication",
+ "OnAppRegistered", this, SLOT(OnAppRegistered(Common_HMIApplication)));
+ QDBusConnection::sessionBus().connect(
+ "com.ford.sdl.core", "/", "com.ford.sdl.core.BasicCommunication",
+ "OnAppUnregistered", this, SLOT(OnAppUnregistered(int, OptionalArgument<bool>)));
+ QDBusConnection::sessionBus().connect(
+ "com.ford.sdl.core", "/", "com.ford.sdl.core.BasicCommunication",
+ "PlayTone", this, SIGNAL(playTone()));
+ QDBusConnection::sessionBus().connect(
+ "com.ford.sdl.core", "/", "com.ford.sdl.core.UI", "ShowNotification",
+ this, SLOT(OnShowNotification(Common_TextFieldStruct,
+ OptionalArgument<Common_Image>, int)));
+}
+
+void SdlProxy::OnAppRegistered(Common_HMIApplication app) {
+ QVariantMap appMap;
+ appMap["appId"] = QVariant::fromValue(app.appID);
+ appMap["appName"] = QVariant::fromValue(app.appName);
+ appMap["deviceName"] = QVariant::fromValue(app.deviceName);
+ appMap["hmiDisplayLanguageDesired"] = QVariant::fromValue(app.hmiDisplayLanguageDesired);
+ appMap["isMediaApplication"] = QVariant::fromValue(app.isMediaApplication);
+
+ if (app.appType.presence) {
+ QList<QVariant> appType;
+ for (QList<int>::const_iterator it = app.appType.val.begin();
+ it != app.appType.val.end(); ++it) {
+ appType.append(QVariant::fromValue(*it));
+ }
+ appMap["appType"] = appType;
+ }
+
+ if (app.ngnMediaScreenAppName.presence) {
+ appMap["ngnMediaScreenAppName"] = QVariant::fromValue(app.ngnMediaScreenAppName.val);
+ }
+
+ if (app.icon.presence) {
+ appMap["icon"] = QVariant::fromValue(app.icon.val);
+ }
+
+ emit appRegistered(QVariant(appMap));
+}
+
+void SdlProxy::OnShowNotification(Common_TextFieldStruct text,
+ OptionalArgument<Common_Image> image,
+ int timeout) {
+ QVariantMap txtMap;
+ QVariant img;
+
+ txtMap["fieldName"] = text.fieldName;
+ txtMap["fieldText"] = text.fieldText;
+
+ if (image.presence) {
+ QVariantMap imgMap;
+ imgMap["imageType"] = image.val.imageType;
+ imgMap["value"] = image.val.value;
+ img = QVariant(imgMap);
+ }
+
+ emit showNotification(QVariant(txtMap), img, timeout);
+}
+
+void SdlProxy::OnAppUnregistered(int appId, OptionalArgument<bool> resume) {
+ QVariant resume_arg;
+
+ if (resume.presence) {
+ resume_arg = QVariant::fromValue(resume.val);
+ }
+
+ emit appUnregistered(appId, resume_arg);
+}
diff --git a/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/sdl_proxy.h b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/sdl_proxy.h
new file mode 100644
index 000000000..81c1ee986
--- /dev/null
+++ b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/sdl_proxy.h
@@ -0,0 +1,76 @@
+/**
+ * \file sdlproxy.h
+ * \brief SdlProxy 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_SDL_PROXY_H_
+#define SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_SDL_PROXY_H_
+
+#include "qml_dbus.h"
+#include "qt_version.h"
+
+#include <QtDBus/QDBusInterface>
+#if QT_4
+# include <QtDeclarative/QDeclarativeItem>
+typedef QDeclarativeItem Item;
+#elif QT_5
+# include <QtQuick/QQuickItem>
+typedef QQuickItem Item;
+#endif // QT_VERSION
+
+class SdlProxy: public Item {
+ Q_OBJECT
+ Q_DISABLE_COPY(SdlProxy)
+
+ public:
+ explicit SdlProxy(Item* parent = 0);
+
+ private:
+ QDBusInterface *sdlBasicCommunicationInterface;
+
+ signals:
+ void appRegistered(QVariant application);
+ void appUnregistered(int appId, QVariant resume);
+ void playTone();
+ void showNotification(QVariant text, QVariant icon, int timeout);
+
+ private slots:
+ void OnAppRegistered(Common_HMIApplication);
+ void OnAppUnregistered(int appId, OptionalArgument<bool> resume);
+ void OnShowNotification(Common_TextFieldStruct text,
+ OptionalArgument<Common_Image> image,
+ int timeout);
+};
+
+QML_DECLARE_TYPE(SdlProxy)
+
+#endif // SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_SDL_PROXY_H_
diff --git a/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.cc b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.cc
new file mode 100644
index 000000000..a1ae3402c
--- /dev/null
+++ b/SDL_Core/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/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.h b/SDL_Core/src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.h
new file mode 100644
index 000000000..675b6d069
--- /dev/null
+++ b/SDL_Core/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_