if(bluemonkey_plugin)
-
find_package(Qt5Core REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5Script REQUIRED)
if(Qt5Core_FOUND)
- message(STATUS "using Qt5")
+ message(STATUS "using Qt5")
- set(QT_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS} ${Qt5Script_INCLUDE_DIRS})
- set(QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Script_LIBRARIES})
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
- message(STATUS "size of void_p: ${CMAKE_SIZEOF_VOID_P}")
- if(CMAKE_SIZEOF_VOID_P MATCHES "8")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcmodel=large")
- endif(CMAKE_SIZEOF_VOID_P MATCHES "8")
- add_definitions(${Qt5Core_DEFINITIONS})
+ set(QT_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS} ${Qt5Script_INCLUDE_DIRS})
+ set(QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Script_LIBRARIES})
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
+ message(STATUS "size of void_p: ${CMAKE_SIZEOF_VOID_P}")
+ if(CMAKE_SIZEOF_VOID_P MATCHES "8")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcmodel=large")
+ endif(CMAKE_SIZEOF_VOID_P MATCHES "8")
+ add_definitions(${Qt5Core_DEFINITIONS})
endif(Qt5Core_FOUND)
set(communi_LIBRARIES -lCommuni)
add_definitions(-DCOMMUNI_SHARED)
-include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs} ${communi_INCLUDE_DIRS} ${QT_INCLUDE_DIRS})
+include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs} ${communi_INCLUDE_DIRS} ${QT_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/plugins/common)
set(bluemonkeyplugin_headers bluemonkey.h irccoms.h authenticate.h agent.h)
set(bluemonkeyplugin_sources bluemonkey.cpp irccoms.cpp authenticate.cpp agent.cpp)
add_library(bluemonkeyplugin MODULE ${bluemonkeyplugin_sources})
set_target_properties(bluemonkeyplugin PROPERTIES PREFIX "")
-target_link_libraries(bluemonkeyplugin amb -L${CMAKE_CURRENT_BINARY_DIR}/lib ${link_libraries} ${QT_LIBRARIES} ${communi_LIBRARIES})
+target_link_libraries(bluemonkeyplugin amb -L${CMAKE_CURRENT_BINARY_DIR}/lib ${link_libraries} ${QT_LIBRARIES} ${communi_LIBRARIES} amb-plugins-common -L${CMAKE_CURRENT_BINARY_DIR}/plugins/common)
set(config_files ${CMAKE_CURRENT_SOURCE_DIR}/ircSettings.js
${CMAKE_CURRENT_SOURCE_DIR}/authSettings.js
${CMAKE_CURRENT_SOURCE_DIR}/config.js)
-install(TARGETS bluemonkeyplugin LIBRARY DESTINATION lib/automotive-message-broker)
-install (FILES ${config_files} DESTINATION /etc/ambd)
+install(TARGETS bluemonkeyplugin LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH})
+install (FILES ${config_files} DESTINATION /etc/ambd/bluemonkey)
endif(bluemonkey_plugin)
/*
- Copyright (C) 2012 Intel Corporation
+ Copyright (C) 2012 Intel Corporation
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "bluemonkey.h"
#include "abstractroutingengine.h"
+#include "ambplugin.h"
#include "debugout.h"
#include "irccoms.h"
#define foreach Q_FOREACH
-extern "C" AbstractSinkManager * create(AbstractRoutingEngine* routingengine, map<string, string> config)
+extern "C" AbstractSource * create(AbstractRoutingEngine* routingengine, map<string, string> config)
{
- return new BluemonkeySinkManager(routingengine, config);
+ auto plugin = new AmbPlugin<BluemonkeySink>(routingengine, config);
+ plugin->init();
+
+ return plugin;
}
QVariant gvariantToQVariant(GVariant *value)
}
-BluemonkeySink::BluemonkeySink(AbstractRoutingEngine* e, map<string, string> config): QObject(0), AbstractSource(e, config), agent(nullptr), engine(nullptr), mSilentMode(false)
+BluemonkeySink::BluemonkeySink(AbstractRoutingEngine* e, map<string, string> config, AbstractSource &parent): QObject(0), AmbPluginImpl(e, config, parent), agent(nullptr), engine(nullptr), mSilentMode(false)
{
irc = new IrcCommunication(config, this);
}
-void BluemonkeySink::supportedChanged(const PropertyList &supportedProperties)
+void BluemonkeySink::supportedChanged(const PropertyList & supportedProperties)
{
DebugOut()<<"supported changed"<<endl;
}
-void BluemonkeySink::propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, std::string uuid)
+void BluemonkeySink::propertyChanged(AbstractPropertyType * value)
{
}
-const string BluemonkeySink::uuid()
+const string BluemonkeySink::uuid() const
{
return "bluemonkey";
}
-void BluemonkeySink::getPropertyAsync(AsyncPropertyReply *reply)
-{
-}
-
-void BluemonkeySink::getRangePropertyAsync(AsyncRangePropertyReply *reply)
-{
-}
-
-AsyncPropertyReply *BluemonkeySink::setProperty(AsyncSetPropertyRequest request)
-{
-}
-
-void BluemonkeySink::subscribeToPropertyChanges(VehicleProperty::Property property)
-{
-}
-
-void BluemonkeySink::unsubscribeToPropertyChanges(VehicleProperty::Property property)
-{
-}
-
-PropertyList BluemonkeySink::supported()
-{
- return mSupported;
-}
-
int BluemonkeySink::supportedOperations()
{
return AbstractSource::Get | AbstractSource::Set;
return strList;
}
+QStringList BluemonkeySink::supportedProperties()
+{
+ PropertyList props = routingEngine->supported();
+ QStringList strList;
+ for(auto p : props)
+ {
+ strList<<p.c_str();
+ }
+
+ return strList;
+}
+
bool BluemonkeySink::authenticate(QString pass)
{
return nullptr;
if(var.type() == QVariant::UInt)
- return new BasicPropertyType<uint>(name.toStdString(),var.toUInt());
+ return new BasicPropertyType<uint>(name.toStdString(), var.toUInt());
else if(var.type() == QVariant::Double)
return new BasicPropertyType<double>(name.toStdString(), var.toDouble());
else if(var.type() == QVariant::Bool)
return new BasicPropertyType<bool>(name.toStdString(), var.toBool());
else if(var.type() == QVariant::Int)
- return new BasicPropertyType<int>(name.toStdString(),var.toInt());
+ return new BasicPropertyType<int>(name.toStdString(), var.toInt());
else if(var.type() == QVariant::String)
- return new StringPropertyType(name.toStdString(),var.toString().toStdString());
+ return new StringPropertyType(name.toStdString(), var.toString().toStdString());
return nullptr;
};
- VehicleProperty::registerProperty(name.toStdString(),create);
- mSupported.push_back(name.toStdString());
+ addPropertySupport(Zone::None, create);
+
+ routingEngine->updateSupported(supported(), PropertyList(), &source);
}
{
if(reply->success)
{
- propertyChanged(reply->property,reply->value,reply->value->sourceUuid);
+ propertyChanged(reply->property, reply->value, reply->value->sourceUuid);
}
delete reply;
};
/*
- Copyright (C) 2012 Intel Corporation
+ Copyright (C) 2012 Intel Corporation
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define BluemonkeySink_H
#include "abstractsource.h"
+#include "ambpluginimpl.h"
+
#include <QObject>
#include <QVariant>
#include <QJsonDocument>
};
-class BluemonkeySink : public QObject, public AbstractSource
+class BluemonkeySink : public QObject, public AmbPluginImpl
{
Q_OBJECT
public:
- BluemonkeySink(AbstractRoutingEngine* e, map<string, string> config);
+ BluemonkeySink(AbstractRoutingEngine* e, map<string, string> config, AbstractSource& parent);
virtual PropertyList subscriptions();
virtual void supportedChanged(const PropertyList & supportedProperties);
- virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, std::string uuid);
- virtual const std::string uuid();
+ virtual void propertyChanged(AbstractPropertyType* value);
+ virtual const std::string uuid() const;
QScriptEngine* engine;
- /// source methods:
- virtual void getPropertyAsync(AsyncPropertyReply *reply);
- virtual void getRangePropertyAsync(AsyncRangePropertyReply *reply);
- virtual AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request);
- virtual void subscribeToPropertyChanges(VehicleProperty::Property property);
- virtual void unsubscribeToPropertyChanges(VehicleProperty::Property property);
- virtual PropertyList supported();
-
virtual int supportedOperations();
private: //source privates
QStringList sourcesForProperty(QString property);
+ QStringList supportedProperties();
+
bool authenticate(QString pass);
void loadConfig(QString str);
bool mSilentMode;
};
-class BluemonkeySinkManager: public AbstractSinkManager
-{
-public:
- BluemonkeySinkManager(AbstractRoutingEngine* engine, map<string, string> config)
- :AbstractSinkManager(engine, config)
- {
- new BluemonkeySink(routingEngine, config);
- }
-};
#endif // BluemonkeySink_H