Skip to content

Commit

Permalink
Merge pull request rdkcentral#2616 from npoltorapavlo/remove_abstract…
Browse files Browse the repository at this point in the history
…plugin

DELIA-54683: Remove AbstractPlugin
  • Loading branch information
anand-ky authored and npoltorapavlo committed Jun 8, 2022
1 parent dd01233 commit 2d72b16
Show file tree
Hide file tree
Showing 61 changed files with 518 additions and 418 deletions.
10 changes: 5 additions & 5 deletions ActivityMonitor/ActivityMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,16 @@ namespace WPEFramework


ActivityMonitor::ActivityMonitor()
: AbstractPlugin()
: PluginHost::JSONRPC()
, m_monitorParams(NULL)
, m_stopMonitoring(false)
{
ActivityMonitor::_instance = this;

registerMethod(ACTIVITY_MONITOR_METHOD_GET_APPLICATION_MEMORY_USAGE, &ActivityMonitor::getApplicationMemoryUsage, this);
registerMethod(ACTIVITY_MONITOR_METHOD_GET_ALL_MEMORY_USAGE, &ActivityMonitor::getAllMemoryUsage, this);
registerMethod(ACTIVITY_MONITOR_METHOD_ENABLE_MONITORING, &ActivityMonitor::enableMonitoring, this);
registerMethod(ACTIVITY_MONITOR_METHOD_DISABLE_MONITORING, &ActivityMonitor::disableMonitoring, this);
Register(ACTIVITY_MONITOR_METHOD_GET_APPLICATION_MEMORY_USAGE, &ActivityMonitor::getApplicationMemoryUsage, this);
Register(ACTIVITY_MONITOR_METHOD_GET_ALL_MEMORY_USAGE, &ActivityMonitor::getAllMemoryUsage, this);
Register(ACTIVITY_MONITOR_METHOD_ENABLE_MONITORING, &ActivityMonitor::enableMonitoring, this);
Register(ACTIVITY_MONITOR_METHOD_DISABLE_MONITORING, &ActivityMonitor::disableMonitoring, this);
}

ActivityMonitor::~ActivityMonitor()
Expand Down
11 changes: 8 additions & 3 deletions ActivityMonitor/ActivityMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
#include "Module.h"
#include "utils.h"

#include "AbstractPlugin.h"

namespace WPEFramework {

namespace Plugin {
Expand All @@ -46,7 +44,7 @@ namespace WPEFramework {
// As the registration/unregistration of notifications is realized by the class PluginHost::JSONRPC,
// this class exposes a public method called, Notify(), using this methods, all subscribed clients
// will receive a JSONRPC message as a notification, in case this method is called.
class ActivityMonitor : public AbstractPlugin {
class ActivityMonitor : public PluginHost::IPlugin, public PluginHost::JSONRPC {
private:

// We do not allow this plugin to be copied !!
Expand All @@ -68,7 +66,14 @@ namespace WPEFramework {
public:
ActivityMonitor();
virtual ~ActivityMonitor();
virtual const string Initialize(PluginHost::IShell* shell) override { return {}; }
virtual void Deinitialize(PluginHost::IShell* service) override;
virtual string Information() const override { return {}; }

BEGIN_INTERFACE_MAP(ActivityMonitor)
INTERFACE_ENTRY(PluginHost::IPlugin)
INTERFACE_ENTRY(PluginHost::IDispatcher)
END_INTERFACE_MAP

public:
static ActivityMonitor* _instance;
Expand Down
48 changes: 24 additions & 24 deletions Bluetooth/Bluetooth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,35 +131,35 @@ namespace WPEFramework
}

Bluetooth::Bluetooth()
: AbstractPlugin()
: PluginHost::JSONRPC()
, m_apiVersionNumber(API_VERSION_NUMBER_MAJOR)
, m_discoveryRunning(false)
, m_discoveryTimer(this)
{
Bluetooth::_instance = this;
registerMethod(METHOD_GET_API_VERSION_NUMBER, &Bluetooth::getApiVersionNumber, this);
registerMethod(METHOD_START_SCAN, &Bluetooth::startScanWrapper, this);
registerMethod(METHOD_STOP_SCAN, &Bluetooth::stopScanWrapper, this);
registerMethod(METHOD_IS_DISCOVERABLE, &Bluetooth::isDiscoverableWrapper, this);
registerMethod(METHOD_GET_DISCOVERED_DEVICES, &Bluetooth::getDiscoveredDevicesWrapper, this);
registerMethod(METHOD_GET_PAIRED_DEVICES, &Bluetooth::getPairedDevicesWrapper, this);
registerMethod(METHOD_GET_CONNECTED_DEVICES, &Bluetooth::getConnectedDevicesWrapper, this);
registerMethod(METHOD_CONNECT, &Bluetooth::connectWrapper, this);
registerMethod(METHOD_DISCONNECT, &Bluetooth::disconnectWrapper, this);
registerMethod(METHOD_SET_AUDIO_STREAM, &Bluetooth::setAudioStreamWrapper, this);
registerMethod(METHOD_PAIR, &Bluetooth::pairWrapper, this);
registerMethod(METHOD_UNPAIR, &Bluetooth::unpairWrapper, this);
registerMethod(METHOD_ENABLE, &Bluetooth::enableWrapper, this);
registerMethod(METHOD_DISABLE, &Bluetooth::disableWrapper, this);
registerMethod(METHOD_SET_DISCOVERABLE, &Bluetooth::setDiscoverableWrapper, this);
registerMethod(METHOD_GET_NAME, &Bluetooth::getNameWrapper, this);
registerMethod(METHOD_SET_NAME, &Bluetooth::setNameWrapper, this);
registerMethod(METHOD_SET_AUDIO_PLAYBACK_COMMAND, &Bluetooth::sendAudioPlaybackCommandWrapper, this);
registerMethod(METHOD_SET_EVENT_RESPONSE, &Bluetooth::setEventResponseWrapper, this);
registerMethod(METHOD_GET_DEVICE_INFO, &Bluetooth::getDeviceInfoWrapper, this);
registerMethod(METHOD_GET_AUDIO_INFO, &Bluetooth::getMediaTrackInfoWrapper, this);
registerMethod(METHOD_GET_DEVICE_VOLUME_MUTE_INFO, &Bluetooth::getDeviceVolumeMuteInfoWrapper, this);
registerMethod(METHOD_SET_DEVICE_VOLUME_MUTE_INFO, &Bluetooth::setDeviceVolumeMuteInfoWrapper, this);
Register(METHOD_GET_API_VERSION_NUMBER, &Bluetooth::getApiVersionNumber, this);
Register(METHOD_START_SCAN, &Bluetooth::startScanWrapper, this);
Register(METHOD_STOP_SCAN, &Bluetooth::stopScanWrapper, this);
Register(METHOD_IS_DISCOVERABLE, &Bluetooth::isDiscoverableWrapper, this);
Register(METHOD_GET_DISCOVERED_DEVICES, &Bluetooth::getDiscoveredDevicesWrapper, this);
Register(METHOD_GET_PAIRED_DEVICES, &Bluetooth::getPairedDevicesWrapper, this);
Register(METHOD_GET_CONNECTED_DEVICES, &Bluetooth::getConnectedDevicesWrapper, this);
Register(METHOD_CONNECT, &Bluetooth::connectWrapper, this);
Register(METHOD_DISCONNECT, &Bluetooth::disconnectWrapper, this);
Register(METHOD_SET_AUDIO_STREAM, &Bluetooth::setAudioStreamWrapper, this);
Register(METHOD_PAIR, &Bluetooth::pairWrapper, this);
Register(METHOD_UNPAIR, &Bluetooth::unpairWrapper, this);
Register(METHOD_ENABLE, &Bluetooth::enableWrapper, this);
Register(METHOD_DISABLE, &Bluetooth::disableWrapper, this);
Register(METHOD_SET_DISCOVERABLE, &Bluetooth::setDiscoverableWrapper, this);
Register(METHOD_GET_NAME, &Bluetooth::getNameWrapper, this);
Register(METHOD_SET_NAME, &Bluetooth::setNameWrapper, this);
Register(METHOD_SET_AUDIO_PLAYBACK_COMMAND, &Bluetooth::sendAudioPlaybackCommandWrapper, this);
Register(METHOD_SET_EVENT_RESPONSE, &Bluetooth::setEventResponseWrapper, this);
Register(METHOD_GET_DEVICE_INFO, &Bluetooth::getDeviceInfoWrapper, this);
Register(METHOD_GET_AUDIO_INFO, &Bluetooth::getMediaTrackInfoWrapper, this);
Register(METHOD_GET_DEVICE_VOLUME_MUTE_INFO, &Bluetooth::getDeviceVolumeMuteInfoWrapper, this);
Register(METHOD_SET_DEVICE_VOLUME_MUTE_INFO, &Bluetooth::setDeviceVolumeMuteInfoWrapper, this);

Utils::IARM::init();

Expand Down
9 changes: 7 additions & 2 deletions Bluetooth/Bluetooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#include "Module.h"
#include "utils.h"
#include "AbstractPlugin.h"

#include "btmgr.h" //TODO: can we move it to the module? Required by notifyEventWrapper()

Expand Down Expand Up @@ -66,7 +65,7 @@ namespace WPEFramework {
Bluetooth* m_bt;
};

class Bluetooth : public AbstractPlugin {
class Bluetooth : public PluginHost::IPlugin, public PluginHost::JSONRPC {
private:

// We do not allow this plugin to be copied !!
Expand Down Expand Up @@ -174,9 +173,15 @@ namespace WPEFramework {

Bluetooth();
virtual ~Bluetooth();
virtual const string Initialize(PluginHost::IShell* shell) override { return {}; }
virtual void Deinitialize(PluginHost::IShell* service) override;
virtual string Information() const override;

BEGIN_INTERFACE_MAP(Bluetooth)
INTERFACE_ENTRY(PluginHost::IPlugin)
INTERFACE_ENTRY(PluginHost::IDispatcher)
END_INTERFACE_MAP

public:
static Bluetooth* _instance;
void notifyEventWrapper (BTRMGR_EventMessage_t eventMsg);
Expand Down
10 changes: 5 additions & 5 deletions CompositeInput/CompositeInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ namespace WPEFramework
CompositeInput* CompositeInput::_instance = nullptr;

CompositeInput::CompositeInput()
: AbstractPlugin()
: PluginHost::JSONRPC()
{
CompositeInput::_instance = this;

InitializeIARM();

registerMethod(COMPOSITEINPUT_METHOD_GET_COMPOSITE_INPUT_DEVICES, &CompositeInput::getCompositeInputDevicesWrapper, this);
registerMethod(COMPOSITEINPUT_METHOD_START_COMPOSITE_INPUT, &CompositeInput::startCompositeInput, this);
registerMethod(COMPOSITEINPUT_METHOD_STOP_COMPOSITE_INPUT, &CompositeInput::stopCompositeInput, this);
registerMethod(COMPOSITEINPUT_METHOD_SCALE_COMPOSITE_INPUT, &CompositeInput::setVideoRectangleWrapper, this);
Register(COMPOSITEINPUT_METHOD_GET_COMPOSITE_INPUT_DEVICES, &CompositeInput::getCompositeInputDevicesWrapper, this);
Register(COMPOSITEINPUT_METHOD_START_COMPOSITE_INPUT, &CompositeInput::startCompositeInput, this);
Register(COMPOSITEINPUT_METHOD_STOP_COMPOSITE_INPUT, &CompositeInput::stopCompositeInput, this);
Register(COMPOSITEINPUT_METHOD_SCALE_COMPOSITE_INPUT, &CompositeInput::setVideoRectangleWrapper, this);
}

CompositeInput::~CompositeInput()
Expand Down
10 changes: 8 additions & 2 deletions CompositeInput/CompositeInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#include "Module.h"
#include "utils.h"
#include "AbstractPlugin.h"

namespace WPEFramework {

Expand All @@ -41,7 +40,7 @@ namespace WPEFramework {
// As the registration/unregistration of notifications is realized by the class PluginHost::JSONRPC,
// this class exposes a public method called, Notify(), using this methods, all subscribed clients
// will receive a JSONRPC message as a notification, in case this method is called.
class CompositeInput : public AbstractPlugin {
class CompositeInput : public PluginHost::IPlugin, public PluginHost::JSONRPC {
private:

// We do not allow this plugin to be copied !!
Expand Down Expand Up @@ -75,10 +74,17 @@ namespace WPEFramework {
public:
CompositeInput();
virtual ~CompositeInput();
virtual const string Initialize(PluginHost::IShell* shell) override { return {}; }
virtual void Deinitialize(PluginHost::IShell* service) override;
virtual string Information() const override { return {}; }

void terminate();

BEGIN_INTERFACE_MAP(CompositeInput)
INTERFACE_ENTRY(PluginHost::IPlugin)
INTERFACE_ENTRY(PluginHost::IDispatcher)
END_INTERFACE_MAP

public:
static CompositeInput* _instance;
};
Expand Down
8 changes: 4 additions & 4 deletions ContinueWatching/ContinueWatching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ namespace WPEFramework {
ContinueWatching* ContinueWatching::_instance = nullptr;

ContinueWatching::ContinueWatching()
: AbstractPlugin()
: PluginHost::JSONRPC()
, m_apiVersionNumber((uint32_t)-1)
{
ContinueWatching::_instance = this;
//Register all the APIs
registerMethod("getApplicationToken", &ContinueWatching::getApplicationToken, this);
registerMethod("setApplicationToken", &ContinueWatching::setApplicationToken, this);
registerMethod("deleteApplicationToken", &ContinueWatching::deleteApplicationToken, this);
Register("getApplicationToken", &ContinueWatching::getApplicationToken, this);
Register("setApplicationToken", &ContinueWatching::setApplicationToken, this);
Register("deleteApplicationToken", &ContinueWatching::deleteApplicationToken, this);
setApiVersionNumber(1);
}

Expand Down
9 changes: 7 additions & 2 deletions ContinueWatching/ContinueWatching.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
#endif

#include "utils.h"
#include "AbstractPlugin.h"

#define CW_LOCAL_FILE "/opt/continuewatching.json"
#define NETFLIX_CONTINUEWATCHING_APP_NAME "netflix"
Expand All @@ -72,7 +71,7 @@ namespace WPEFramework {
// As the registration/unregistration of notifications is realized by the class PluginHost::JSONRPC,
// this class exposes a public method called, Notify(), using this methods, all subscribed clients
// will receive a JSONRPC message as a notification, in case this method is called.
class ContinueWatching : public AbstractPlugin {
class ContinueWatching : public PluginHost::IPlugin, public PluginHost::JSONRPC {
private:
// We do not allow this plugin to be copied !!
ContinueWatching(const ContinueWatching&) = delete;
Expand All @@ -88,7 +87,13 @@ namespace WPEFramework {
public:
ContinueWatching();
virtual ~ContinueWatching();
virtual const string Initialize(PluginHost::IShell* shell) override { return {}; }
virtual void Deinitialize(PluginHost::IShell* service) override;
virtual string Information() const override { return {}; }
BEGIN_INTERFACE_MAP(ContinueWatching)
INTERFACE_ENTRY(PluginHost::IPlugin)
INTERFACE_ENTRY(PluginHost::IDispatcher)
END_INTERFACE_MAP
private:
uint32_t getApiVersionNumber();
void setApiVersionNumber(uint32_t apiVersionNumber);
Expand Down
28 changes: 14 additions & 14 deletions ControlService/ControlService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,30 +65,30 @@ namespace WPEFramework {
ControlService* ControlService::_instance = nullptr;

ControlService::ControlService()
: AbstractPlugin()
: PluginHost::JSONRPC()
, m_apiVersionNumber((uint32_t)-1) /* default max uint32_t so everything gets enabled */ //TODO(MROLLINS) Can't we access this from jsonrpc interface?
{
LOGINFO("ctor");
ControlService::_instance = this;

registerMethod("getApiVersionNumber", &ControlService::getApiVersionNumber, this);
registerMethod("getQuirks", &ControlService::getQuirks, this);
Register("getApiVersionNumber", &ControlService::getApiVersionNumber, this);
Register("getQuirks", &ControlService::getQuirks, this);

registerMethod("getAllRemoteData", &ControlService::getAllRemoteDataWrapper, this);
registerMethod("getSingleRemoteData", &ControlService::getSingleRemoteDataWrapper, this);
registerMethod("getLastKeypressSource", &ControlService::getLastKeypressSourceWrapper, this);
registerMethod("getLastPairedRemoteData", &ControlService::getLastPairedRemoteDataWrapper, this);
Register("getAllRemoteData", &ControlService::getAllRemoteDataWrapper, this);
Register("getSingleRemoteData", &ControlService::getSingleRemoteDataWrapper, this);
Register("getLastKeypressSource", &ControlService::getLastKeypressSourceWrapper, this);
Register("getLastPairedRemoteData", &ControlService::getLastPairedRemoteDataWrapper, this);

registerMethod("setValues", &ControlService::setValuesWrapper, this);
registerMethod("getValues", &ControlService::getValuesWrapper, this);
Register("setValues", &ControlService::setValuesWrapper, this);
Register("getValues", &ControlService::getValuesWrapper, this);

registerMethod("startPairingMode", &ControlService::startPairingModeWrapper, this);
registerMethod("endPairingMode", &ControlService::endPairingModeWrapper, this);
Register("startPairingMode", &ControlService::startPairingModeWrapper, this);
Register("endPairingMode", &ControlService::endPairingModeWrapper, this);

registerMethod("canFindMyRemote", &ControlService::canFindMyRemoteWrapper, this);
registerMethod("findLastUsedRemote", &ControlService::findLastUsedRemoteWrapper, this);
Register("canFindMyRemote", &ControlService::canFindMyRemoteWrapper, this);
Register("findLastUsedRemote", &ControlService::findLastUsedRemoteWrapper, this);

registerMethod("checkRf4ceChipConnectivity", &ControlService::checkRf4ceChipConnectivityWrapper, this);
Register("checkRf4ceChipConnectivity", &ControlService::checkRf4ceChipConnectivityWrapper, this);

setApiVersionNumber(7);
}
Expand Down
22 changes: 7 additions & 15 deletions ControlService/ControlService.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include "Module.h"
#include "utils.h"
#include "AbstractPlugin.h"
#include "libIBus.h"

#include "ctrlm_ipc.h"
Expand Down Expand Up @@ -73,20 +72,7 @@ namespace WPEFramework {
int digit3;
};

// This is a server for a JSONRPC communication channel.
// For a plugin to be capable to handle JSONRPC, inherit from PluginHost::JSONRPC.
// By inheriting from this class, the plugin realizes the interface PluginHost::IDispatcher.
// This realization of this interface implements, by default, the following methods on this plugin
// - exists
// - register
// - unregister
// Any other method to be handled by this plugin can be added can be added by using the
// templated methods Register on the PluginHost::JSONRPC class.
// As the registration/unregistration of notifications is realized by the class PluginHost::JSONRPC,
// this class exposes a public method called, Notify(), using this methods, all subscribed clients
// will receive a JSONRPC message as a notification, in case this method is called.
// Note that most of the above is now inherited from the AbstractPlugin class.
class ControlService : public AbstractPlugin {
class ControlService : public PluginHost::IPlugin, public PluginHost::JSONRPC {
private:
typedef Core::JSON::String JString;
typedef Core::JSON::ArrayType<JString> JStringArray;
Expand Down Expand Up @@ -128,6 +114,12 @@ namespace WPEFramework {
//IPlugin methods
virtual const string Initialize(PluginHost::IShell* service) override;
virtual void Deinitialize(PluginHost::IShell* service) override;
virtual string Information() const override { return {}; }

BEGIN_INTERFACE_MAP(ControlService)
INTERFACE_ENTRY(PluginHost::IPlugin)
INTERFACE_ENTRY(PluginHost::IDispatcher)
END_INTERFACE_MAP
private:
void InitializeIARM();
void DeinitializeIARM();
Expand Down
Loading

0 comments on commit 2d72b16

Please sign in to comment.