Commit 5f05f877 authored by Aline Gondim Santos's avatar Aline Gondim Santos Committed by Aline Gondim Santos

plugin: add preferences to API

exposes functions to read, edit or reset plugins preferences

Change-Id: I73e9d90373ef46945e4092f0d28afa7cb69389a5
parent 3c4d5d0f
/****************************************************************************
* Copyright (C) 2018-2020 Savoir-faire Linux Inc. *
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
/*!
* Copyright (C) 2018-2020 Savoir-faire Linux Inc.
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
// std
......@@ -93,31 +93,31 @@ public:
/**
* Install plugin
* @return plugin installed
* @return true if plugin was succesfully installed
*/
Q_INVOKABLE bool installPlugin(const QString& jplPath, bool force);
/**
* Uninstall plugin
* @return plugin uninstalled
* @return true if plugin was succesfully uninstalled
*/
Q_INVOKABLE bool uninstallPlugin(const QString& rootPath);
/**
* Load plugin
* @return plugin loaded
* @return true if plugin was succesfully loaded
*/
Q_INVOKABLE bool loadPlugin(const QString& path);
/**
* Unload plugin
* @return plugin unloaded
* @return true if plugin was succesfully unloaded
*/
Q_INVOKABLE bool unloadPlugin(const QString& path);
/**
* List available Media Handlers
* @return List of available Media Handlers
* List all plugins Media Handlers
* @return List of all plugins Media Handlers
*/
Q_INVOKABLE VectorString listCallMediaHandlers() const;
......@@ -133,10 +133,35 @@ public:
Q_INVOKABLE MapStringString getCallMediaHandlerStatus();
/**
* Get details of available media handler
* Get details of installed plugins media handlers
* @return Media Handler Details
*/
Q_INVOKABLE plugin::MediaHandlerDetails getCallMediaHandlerDetails(const QString& id);
/**
* Get preferences map of installed plugin
* @return Plugin preferences infos vector
*/
Q_INVOKABLE VectorMapStringString getPluginPreferences(const QString& path);
/**
* Modify preference of installed plugin
* @return true if preference was succesfully modified
*/
Q_INVOKABLE bool setPluginPreference(const QString& path, const QString& key, const QString& value);
/**
* Get preferences values of installed plugin
* @return Plugin preferences map
*/
Q_INVOKABLE MapStringString getPluginPreferencesValues(const QString& path);
/**
* Reste preferences values of installed plugin to default values
* @return true if preference was succesfully reset
*/
Q_INVOKABLE bool resetPluginPreferencesValues(const QString& path);
};
} // namespace api
......
......@@ -168,6 +168,30 @@ PluginModel::getCallMediaHandlerDetails(const QString& id)
return result;
}
VectorMapStringString
PluginModel::getPluginPreferences(const QString& path)
{
return PluginManager::instance().getPluginPreferences(path);
}
bool
PluginModel::setPluginPreference(const QString& path, const QString& key, const QString& value)
{
return PluginManager::instance().setPluginPreference(path, key, value);
}
MapStringString
PluginModel::getPluginPreferencesValues(const QString& path)
{
return PluginManager::instance().getPluginPreferencesValues(path);
}
bool
PluginModel::resetPluginPreferencesValues(const QString& path)
{
return PluginManager::instance().resetPluginPreferencesValues(path);
}
} // namespace lrc
#include "api/moc_pluginmodel.cpp"
......
......@@ -40,13 +40,21 @@ IF(NOT (${ENABLE_PLUGIN} MATCHES "true"))
SET(ENABLE_PLUGIN 0 CACHE BOOLEAN "Disable plugin")
ENDIF(NOT (${ENABLE_PLUGIN} MATCHES "true"))
IF(ENABLE_PLUGIN)
MESSAGE("Adding pluginmanager.cpp")
SET(plugin_SRC pluginmanager.cpp)
ELSE()
MESSAGE("Adding pluginmanagerMock.cpp")
SET(plugin_SRC pluginmanagerMock.cpp)
ENDIF()
INCLUDE_DIRECTORIES(SYSTEM ${Qt5Core_INCLUDE_DIRS} )
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE_DIRECTORIES(${ring_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../dbus)
ADD_LIBRARY( qtwrapper STATIC ${libqtwrapper_LIB_SRCS})
ADD_LIBRARY( qtwrapper STATIC ${libqtwrapper_LIB_SRCS} ${plugin_SRC})
IF(NOT ${ring_BIN} MATCHES "ring_BIN-NOTFOUND")
......
/******************************************************************************
* Copyright (C) 2014-2020 Savoir-faire Linux Inc. *
* Author : Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
#pragma once
#include "pluginmanager_wrap.h"
bool
PluginManagerInterface::loadPlugin(const QString& path)
{
return DRing::loadPlugin(path.toStdString());
}
bool
PluginManagerInterface::unloadPlugin(const QString& path)
{
return DRing::unloadPlugin(path.toStdString());
}
MapStringString
PluginManagerInterface::getPluginDetails(const QString& path)
{
return convertMap(DRing::getPluginDetails(path.toStdString()));
}
QStringList
PluginManagerInterface::listAvailablePlugins()
{
return convertStringList(DRing::listAvailablePlugins());
}
QStringList
PluginManagerInterface::listLoadedPlugins()
{
return convertStringList(DRing::listLoadedPlugins());
}
int
PluginManagerInterface::installPlugin(const QString& jplPath, bool force)
{
return DRing::installPlugin(jplPath.toStdString(), force);
}
int
PluginManagerInterface::uninstallPlugin(const QString& pluginRootPath)
{
return DRing::uninstallPlugin(pluginRootPath.toStdString());
}
QStringList
PluginManagerInterface::listCallMediaHandlers()
{
return convertStringList(DRing::listCallMediaHandlers());
}
void
PluginManagerInterface::toggleCallMediaHandler(const QString& id, bool toggle)
{
DRing::toggleCallMediaHandler(id.toStdString(), toggle);
}
MapStringString
PluginManagerInterface::getCallMediaHandlerStatus()
{
return convertMap(DRing::getCallMediaHandlerStatus());
}
MapStringString
PluginManagerInterface::getCallMediaHandlerDetails(const QString& id)
{
return convertMap(DRing::getCallMediaHandlerDetails(id.toStdString()));
}
void
PluginManagerInterface::setPluginsEnabled(bool enable)
{
DRing::setPluginsEnabled(enable);
}
bool
PluginManagerInterface::getPluginsEnabled()
{
return DRing::getPluginsEnabled();
}
VectorMapStringString
PluginManagerInterface::getPluginPreferences(const QString& path)
{
VectorMapStringString temp;
for (auto x : DRing::getPluginPreferences(path.toStdString())) {
temp.push_back(convertMap(x));
}
return temp;
}
bool
PluginManagerInterface::setPluginPreference(const QString& path, const QString& key, const QString& value)
{
return DRing::setPluginPreference(path.toStdString(), key.toStdString(), value.toStdString());
}
MapStringString
PluginManagerInterface::getPluginPreferencesValues(const QString& path)
{
return convertMap(DRing::getPluginPreferencesValues(path.toStdString()));
}
bool
PluginManagerInterface::resetPluginPreferencesValues(const QString& path)
{
return DRing::resetPluginPreferencesValues(path.toStdString());
}
/******************************************************************************
* Copyright (C) 2014-2020 Savoir-faire Linux Inc. *
* Author : Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
#pragma once
#include "pluginmanager_wrap.h"
bool
PluginManagerInterface::loadPlugin(const QString& path)
{
return false;
}
bool
PluginManagerInterface::unloadPlugin(const QString& path)
{
return false;
}
MapStringString
PluginManagerInterface::getPluginDetails(const QString& path)
{
return {};
}
QStringList
PluginManagerInterface::listAvailablePlugins()
{
return {};
}
QStringList
PluginManagerInterface::listLoadedPlugins()
{
return {};
}
int
PluginManagerInterface::installPlugin(const QString& jplPath, bool force)
{
return 0;
}
int
PluginManagerInterface::uninstallPlugin(const QString& pluginRootPath)
{
return 0;
}
QStringList
PluginManagerInterface::listCallMediaHandlers()
{
return {};
}
void
PluginManagerInterface::toggleCallMediaHandler(const QString& id, bool toggle)
{}
MapStringString
PluginManagerInterface::getCallMediaHandlerStatus()
{
return {};
}
MapStringString
PluginManagerInterface::getCallMediaHandlerDetails(const QString& id)
{
return {};
}
void
PluginManagerInterface::setPluginsEnabled(bool enable)
{}
bool
PluginManagerInterface::getPluginsEnabled()
{
return false;
}
VectorMapStringString
PluginManagerInterface::getPluginPreferences(const QString& path)
{
return {};
}
bool
PluginManagerInterface::setPluginPreference(const QString& path, const QString& key, const QString& value)
{
return false;
}
MapStringString
PluginManagerInterface::getPluginPreferencesValues(const QString& path)
{
return {};
}
bool
PluginManagerInterface::resetPluginPreferencesValues(const QString& path)
{
return false;
}
......@@ -46,125 +46,39 @@ public:
public Q_SLOTS: // METHODS
bool loadPlugin(const QString& path)
{
#ifdef ENABLE_PLUGIN
return DRing::loadPlugin(path.toStdString());
#else
return false;
#endif
}
bool loadPlugin(const QString& path);
bool unloadPlugin(const QString& path)
{
#ifdef ENABLE_PLUGIN
return DRing::unloadPlugin(path.toStdString());
#else
return false;
#endif
}
bool unloadPlugin(const QString& path);
MapStringString getPluginDetails(const QString& path)
{
#ifdef ENABLE_PLUGIN
return convertMap(DRing::getPluginDetails(path.toStdString()));
#else
MapStringString temp;
return temp;
#endif
}
MapStringString getPluginDetails(const QString& path);
QStringList listAvailablePlugins()
{
#ifdef ENABLE_PLUGIN
return convertStringList(DRing::listAvailablePlugins());
#else
QStringList temp;
return temp;
#endif
}
QStringList listAvailablePlugins();
QStringList listLoadedPlugins()
{
#ifdef ENABLE_PLUGIN
return convertStringList(DRing::listLoadedPlugins());
#else
QStringList temp;
return temp;
#endif
}
QStringList listLoadedPlugins();
int installPlugin(const QString& jplPath, bool force)
{
#ifdef ENABLE_PLUGIN
return DRing::installPlugin(jplPath.toStdString(), force);
#else
return 0;
#endif
}
int installPlugin(const QString& jplPath, bool force);
int uninstallPlugin(const QString& pluginRootPath)
{
#ifdef ENABLE_PLUGIN
return DRing::uninstallPlugin(pluginRootPath.toStdString());
#else
return 0;
#endif
}
int uninstallPlugin(const QString& pluginRootPath);
QStringList listCallMediaHandlers()
{
#ifdef ENABLE_PLUGIN
return convertStringList(DRing::listCallMediaHandlers());
#else
QStringList temp;
return temp;
#endif
}
QStringList listCallMediaHandlers();
void toggleCallMediaHandler(const QString& id, bool toggle)
{
#ifdef ENABLE_PLUGIN
DRing::toggleCallMediaHandler(id.toStdString(), toggle);
#endif
}
void toggleCallMediaHandler(const QString& id, bool toggle);
MapStringString getCallMediaHandlerStatus()
{
#ifdef ENABLE_PLUGIN
return convertMap(DRing::getCallMediaHandlerStatus());
#else
MapStringString temp;
return temp;
#endif
}
MapStringString getCallMediaHandlerStatus();
MapStringString getCallMediaHandlerDetails(const QString& id)
{
#ifdef ENABLE_PLUGIN
return convertMap(DRing::getCallMediaHandlerDetails(id.toStdString()));
#else
MapStringString temp;
return temp;
#endif
}
MapStringString getCallMediaHandlerDetails(const QString& id);
void setPluginsEnabled(bool enable)
{
#ifdef ENABLE_PLUGIN
DRing::setPluginsEnabled(enable);
#endif
}
void setPluginsEnabled(bool enable);
bool getPluginsEnabled()
{
#ifdef ENABLE_PLUGIN
return DRing::getPluginsEnabled();
#else
return false;
#endif
}
bool getPluginsEnabled();
VectorMapStringString getPluginPreferences(const QString& path);
bool setPluginPreference(const QString& path, const QString& key, const QString& value);
MapStringString getPluginPreferencesValues(const QString& path);
bool resetPluginPreferencesValues(const QString& path);
};
namespace org {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment