FILE(GLOB HEADERS include/*.h)
INSTALL(FILES ${HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME})
-FILE(GLOB SCHEMA schema/*.xsd)
-INSTALL(FILES ${SCHEMA} DESTINATION ${MODES_XSD_DEFAULT_DIR})
+INSTALL(DIRECTORY schema DESTINATION ${MODES_DEFAULT_RO_DIR})
IF(STDOUT_LOG)
ADD_DEFINITIONS("-DMDS_STDOUT")
ENDIF(NOT DEFINED MODES_PLUGIN_DEFAULT_DIR)
ADD_DEFINITIONS("-DMODES_PLUGIN_DEFAULT_DIR=\"${MODES_PLUGIN_DEFAULT_DIR}\"")
-IF(NOT DEFINED MODES_MODE_DEFAULT_DIR)
- MESSAGE("No MODES_MODE_DEFAULT_DIR. Check build system")
- SET(MODES_MODE_DEFAULT_DIR "/usr/share/modes/mode")
-ENDIF(NOT DEFINED MODES_MODE_DEFAULT_DIR)
-ADD_DEFINITIONS("-DMODES_MODE_DEFAULT_DIR=\"${MODES_MODE_DEFAULT_DIR}\"")
+IF(NOT DEFINED MODES_DEFAULT_RO_DIR)
+ MESSAGE("No MODES_DEFAULT_RO_DIR. Check build system")
+ SET(MODES_DEFAULT_RO_DIR "/usr/share/modes")
+ENDIF(NOT DEFINED MODES_DEFAULT_RO_DIR)
+ADD_DEFINITIONS("-DMODES_DEFAULT_RO_DIR=\"${MODES_DEFAULT_RO_DIR}\"")
-IF(NOT DEFINED MODES_CUSTOM_MODE_DEFAULT_DIR)
- MESSAGE("No MODES_CUSTOM_MODE_DEFAULT_DIR. Check build system")
- SET(MODES_CUSTOM_MODE_DEFAULT_DIR "/var/lib/modes/custom-mode")
-ENDIF(NOT DEFINED MODES_CUSTOM_MODE_DEFAULT_DIR)
+IF(NOT DEFINED MODES_DEFAULT_RW_DIR)
+ MESSAGE("No MODES_DEFAULT_RW_DIR. Check build system")
+ SET(MODES_DEFAULT_RW_DIR "/var/lib/modes")
+ENDIF(NOT DEFINED MODES_DEFAULT_RW_DIR)
+SET(MODES_CUSTOM_MODE_DEFAULT_DIR ${MODES_DEFAULT_RW_DIR}/custom-mode)
ADD_DEFINITIONS("-DMODES_CUSTOM_MODE_DEFAULT_DIR=\"${MODES_CUSTOM_MODE_DEFAULT_DIR}\"")
-
-IF(NOT DEFINED MODES_ACTIONRULE_DEFAULT_DIR)
- MESSAGE("No MODES_ACTIONRULE_DEFAULT_DIR. Check build system")
- SET(MODES_ACTIONRULE_DEFAULT_DIR "/usr/share/modes/rule")
-ENDIF(NOT DEFINED MODES_ACTIONRULE_DEFAULT_DIR)
-ADD_DEFINITIONS("-DMODES_ACTIONRULE_DEFAULT_DIR=\"${MODES_ACTIONRULE_DEFAULT_DIR}\"")
-
-IF(NOT DEFINED MODES_XSD_DEFAULT_DIR)
- MESSAGE("No MODES_XSD_DEFAULT_DIR. Check build system")
- SET(MODES_XSD_DEFAULT_DIR "/usr/share/modes/schema")
-ENDIF(NOT DEFINED MODES_XSD_DEFAULT_DIR)
-ADD_DEFINITIONS("-DMODES_XSD_DEFAULT_DIR=\"${MODES_XSD_DEFAULT_DIR}\"")
-
-IF(NOT DEFINED MODES_UNDO_INFO_DEFAULT_DIR)
- MESSAGE("No MODES_UNDO_INFO_DEFAULT_DIR. Check build system")
- SET(MODES_UNDO_INFO_DEFAULT_DIR "/var/lib/modes/undo-info")
-ENDIF(NOT DEFINED MODES_UNDO_INFO_DEFAULT_DIR)
+SET(MODES_UNDO_INFO_DEFAULT_DIR ${MODES_DEFAULT_RW_DIR}/undo-info)
ADD_DEFINITIONS("-DMODES_UNDO_INFO_DEFAULT_DIR=\"${MODES_UNDO_INFO_DEFAULT_DIR}\"")
#define MODES_NAMESPACE_END }
#define MODES_NAMESPACE_USE using namespace ModeSupervisorNamespace
-#ifndef MODES_MODE_DEFAULT_DIR
-#define MODES_MODE_DEFAULT_DIR "/usr/share/modes/mode"
-#warning "MODES_MODE_DEFAULT_DIR is redefined"
+#ifndef MODES_PLUGIN_DEFAULT_DIR
+#define MODES_PLUGIN_DEFAULT_DIR "/usr/lib/modes-plugins/"
+#warning "MODES_PLUGIN_DEFAULT_DIR is redefined"
#endif
+#define MODES_PLUGIN_LIB_PREFIX "libmodes-plugin"
-#ifndef MODES_CUSTOM_MODE_DEFAULT_DIR
-#define MODES_CUSTOM_MODE_DEFAULT_DIR "/var/lib/modes/custom-mode"
-#warning "MODES_CUSTOM_MODE_DEFAULT_DIR is redefined"
+#ifndef MODES_DEFAULT_RO_DIR
+#define MODES_DEFAULT_RO_DIR "/usr/share/modes"
+#warning "MODES_DEFAULT_RO_DIR is redefined"
#endif
-#ifndef MODES_ACTIONRULE_DEFAULT_DIR
-#define MODES_ACTIONRULE_DEFAULT_DIR "/usr/share/modes/rule"
-#warning "MODES_ACTIONRULE_DEFAULT_DIR is redefined"
-#endif
+#define MODES_MODE_DEFAULT_DIR MODES_DEFAULT_RO_DIR "/mode"
+#define MODES_MODE_FILE_SUFFIX "_mode.xml"
-#ifndef MODES_PLUGIN_DEFAULT_DIR
-#define MODES_PLUGIN_DEFAULT_DIR "/usr/lib/modes-plugins/"
-#warning "MODES_PLUGIN_DEFAULT_DIR is redefined"
-#endif
+#define MODES_ACTIONRULE_DEFAULT_DIR MODES_DEFAULT_RO_DIR "/rule"
+#define MODES_ACTIONRULE_FILE_SUFFIX "_rule.xml"
+
+#define MODES_XSD_DEFAULT_DIR MODES_DEFAULT_RO_DIR "/schema"
+#define MODES_MODE_DEFAULT_XSD_FILE "tizen_mode.xsd"
+#define MODES_MODE_DEFAULT_XSD_PATH MODES_XSD_DEFAULT_DIR "/" MODES_MODE_DEFAULT_XSD_FILE
+#define MODES_RULE_DEFAULT_XSD_FILE "tizen_action_rule.xsd"
+#define MODES_RULE_DEFAULT_XSD_PATH MODES_XSD_DEFAULT_DIR "/" MODES_RULE_DEFAULT_XSD_FILE
-#ifndef MODES_XSD_DEFAULT_DIR
-#define MODES_XSD_DEFAULT_DIR "/usr/share/modes/schema"
-#warning "MODES_XSD_DEFAULT_DIR is redefined"
+#ifndef MODES_CUSTOM_MODE_DEFAULT_DIR
+#define MODES_CUSTOM_MODE_DEFAULT_DIR "/var/lib/modes/custom-mode"
+#warning "MODES_CUSTOM_MODE_DEFAULT_DIR is redefined"
#endif
#ifndef MODES_UNDO_INFO_DEFAULT_DIR
#define MODES_UNDO_INFO_DEFAULT_DIR "/var/lib/modes/undo-info"
#warning "MODES_UNDO_INFO_DEFAULT_DIR is redefined"
#endif
-
-#define MODES_MODE_DEFAULT_XSD_FILE "tizen_mode.xsd"
-#define MODES_ACTIONRULE_DEFAULT_XSD_FILE "tizen_action_rule.xsd"
-#define MODES_MODE_DEFAULT_XSD MODES_XSD_DEFAULT_DIR "/" MODES_MODE_DEFAULT_XSD_FILE
-#define MODES_ACTIONRULE_DEFAULT_XSD MODES_XSD_DEFAULT_DIR "/" MODES_ACTIONRULE_DEFAULT_XSD_FILE
-
-#define MODES_PLUGIN_LIB_PREFIX "libmodes-plugin"
-#define MODES_ACTIONRULE_FILE_SUFFIX "_rule.xml"
-#define MODES_MODE_FILE_SUFFIX "_mode.xml"
-
#define MODES_UNDO_FILE_SUFFIX "_undo.xml"
%cmake . -DMAJORVER=${MAJORVER} -DFULLVER=%{version} \
-DCMAKE_VERBOSE_MAKEFILE=OFF \
-DBIN_INSTALL_DIR:PATH=%{_bindir} \
- -DTEST_INSTALL_DIR:PATH=%{modes_test_dir} \
-DSYSTEMD_DIR:PATH=%{_unitdir} \
-DSYSCONF_DIR:PATH=%{_sysconfdir} \
- -DMODES_MODE_DEFAULT_DIR:PATH=%{modes_ro_dir}/mode \
- -DMODES_UNDO_INFO_DEFAULT_DIR:PATH=%{modes_rw_dir}/undo-info \
- -DMODES_CUSTOM_MODE_DEFAULT_DIR:PATH=%{modes_rw_dir}/custom-mode \
- -DMODES_ACTIONRULE_DEFAULT_DIR:PATH=%{modes_ro_dir}/rule \
- -DMODES_XSD_DEFAULT_DIR:PATH=%{modes_ro_dir}/schema \
+ -DMODES_DEFAULT_RO_DIR:PATH=%{modes_ro_dir} \
+ -DMODES_DEFAULT_RW_DIR:PATH=%{modes_rw_dir} \
-DMODES_PLUGIN_DEFAULT_DIR:PATH=%{modes_plugin_dir} \
+ -DTEST_INSTALL_DIR:PATH=%{modes_test_dir} \
-DDBUS_INTERFACE=%{_dbus_interface} \
-DBUILD_GCOV=%{?gcov:1}%{!?gcov:0} \
-DSTDOUT_LOG=%{?stdlog:1}%{!?stdlog:0}
TARGET_LINK_LIBRARIES(${LIB_NAME} ${plugin_pkgs_LIBRARIES})
SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES NO_SONAME 1 )
INSTALL(TARGETS ${LIB_NAME} DESTINATION ${MODES_PLUGIN_DEFAULT_DIR})
-INSTALL(FILES tizen_test_rule.xml DESTINATION ${MODES_ACTIONRULE_DEFAULT_DIR})
+INSTALL(FILES tizen_test_rule.xml DESTINATION ${MODES_DEFAULT_RO_DIR}/rule)
"Tizen: <http://www.tizen.org>";
char ArgumentParser::args_doc[] =
- "modeXMLDirPath1 [modeXMLDirPath2] [--pluginDir=../plugin]"
- " [--modeXsdFilePath=..example/tizen_mode.xsd] [--ruleXsdFilePath=..example/tizen_rule.xsd]"
- " [--ruleDir=../example] [--undoInfoDir=../example] [--[--help]";
+ "[extraModeDir1] [extraModeDir...] [--pluginDir=../plugin]"
+ " [--ruleDir=../example] [--[--help]";
struct argp_option ArgumentParser::options[] = {
{"pluginDir", 'p', "pluginDirPath", OPTION_ARG_OPTIONAL, "Set directory of plugin"},
- {"modeXsdFilePath", 'm', "modeXsdFilePath", OPTION_ARG_OPTIONAL, "Set mode xsd(schema) file path"},
- {"ruleXsdFilePath", 'a', "actionRuleXsdFilePath", OPTION_ARG_OPTIONAL, "Set action rule xsd(schema) file path"},
- {"ruleDir", 's', "actionRuleDirPath", OPTION_ARG_OPTIONAL, "Set directory of Action Rule file"},
- {"undoInfoDir", 'u', "UndoInfoDirPath", OPTION_ARG_OPTIONAL, "Set directory of Undo Information file"},
+ {"ruleDir", 'r', "actionRuleDirPath", OPTION_ARG_OPTIONAL, "Set directory of Action Rule file"},
{ 0 }
};
state->next++;
}
break;
- case 'm':
+ case 'r':
nextArg = state->argv[state->next];
if (nextArg && *nextArg != '-') {
- parser->modeXsdFile = nextArg;
- state->next++;
- }
- break;
- case 'a':
- nextArg = state->argv[state->next];
- if (nextArg && *nextArg != '-') {
- parser->actionRuleXsdFile = nextArg;
- state->next++;
- }
- break;
- case 's':
- nextArg = state->argv[state->next];
- if (nextArg && *nextArg != '-') {
- parser->actionRuleDir = nextArg;
- state->next++;
- }
- break;
- case 'u':
- nextArg = state->argv[state->next];
- if (nextArg && *nextArg != '-') {
- parser->undoInfoDir = nextArg;
+ parser->ruleDir = nextArg;
state->next++;
}
break;
case ARGP_KEY_NO_ARGS:
- if (parser->modeDirCount == 0)
- argp_usage(state);
break;
case ARGP_KEY_ARG:
parser->modeDirCount = (state->argc - state->next) + 1;
struct argp ArgumentParser::argp_input = {options, parse_opt, args_doc, argp_doc};
ArgumentParser::ArgumentParser()
- :modeDirCount(0), modeXMLDirList(NULL), modeXsdFile(NULL),
- actionRuleDir(NULL), actionRuleXsdFile(NULL), pluginDir(NULL), undoInfoDir(NULL)
+ :modeDirCount(0), modeXMLDirList(NULL), ruleDir(NULL), pluginDir(NULL)
{
}
DBG("mode xml dir path list[%d] %s", i, this->modeXMLDirList[i]);
config.modeXMLDirs = std::set<std::string>(modeXMLDirList, modeXMLDirList + modeDirCount);
- } else {
- config.modeXMLDirs.insert(MODES_MODE_DEFAULT_DIR);
}
+ auto found = config.modeXMLDirs.find(MODES_MODE_DEFAULT_DIR);
+ if (config.modeXMLDirs.end() == found)
+ config.modeXMLDirs.insert(MODES_MODE_DEFAULT_DIR);
- if (this->actionRuleDir) {
- DBG("Action Rule dir path: %s", this->actionRuleDir);
- config.actionRuleDir = this->actionRuleDir;
+ if (this->ruleDir) {
+ DBG("Action Rule dir path: %s", this->ruleDir);
+ config.actionRuleDir = this->ruleDir;
} else {
config.actionRuleDir = MODES_ACTIONRULE_DEFAULT_DIR;
}
- if (this->modeXsdFile) {
- DBG("mode xsd file path: %s", this->modeXsdFile);
- config.modeXsdFile = this->modeXsdFile;
- } else {
- config.modeXsdFile = MODES_MODE_DEFAULT_XSD;
- }
-
- if (this->actionRuleXsdFile) {
- DBG("Action Rule xsd file path: %s", this->actionRuleXsdFile);
- config.actionRuleXsdFile = this->actionRuleXsdFile;
- } else {
- config.actionRuleXsdFile = MODES_ACTIONRULE_DEFAULT_XSD;
- }
-
if (this->pluginDir) {
DBG("plugin dir path : %s", this->pluginDir);
config.pluginDir = this->pluginDir;
config.pluginDir = MODES_PLUGIN_DEFAULT_DIR;
}
- if (this->undoInfoDir) {
- DBG("undoInfo dir path : %s", this->undoInfoDir);
- config.undoInfoDir = this->undoInfoDir;
- } else {
- config.undoInfoDir = MODES_UNDO_INFO_DEFAULT_DIR;
- }
-
return config;
}
private:
int modeDirCount;
char **modeXMLDirList;
- char *modeXsdFile;
- char *actionRuleDir;
- char *actionRuleXsdFile;
+ char *ruleDir;
char *pluginDir;
- char *undoInfoDir;
static char argp_doc[];
static char args_doc[];
MODES_NAMESPACE_USE;
-ModeCareTaker::ModeCareTaker()
- : undoDir(MODES_UNDO_INFO_DEFAULT_DIR)
+ModeCareTaker::ModeCareTaker(const std::string &undoInfoDir)
+ : undoDir(undoInfoDir)
{
}
-void ModeCareTaker::setOptions(const std::string &undoInfoDir)
+std::string ModeCareTaker::getUndoInfoDir()
{
- undoDir = undoInfoDir;
+ return undoDir;
}
void ModeCareTaker::restoreMode(const Mode &mode)
class ModeCareTaker : public ActionObserver {
public:
- ModeCareTaker();
+ ModeCareTaker(const std::string &undoInfoDir);
~ModeCareTaker() = default;
- void setOptions(const std::string &undoInfoDir);
+ std::string getUndoInfoDir();
void restoreMode(const Mode &mode);
void pushMode(const Mode &mode);
int popMode(const std::string &name, Mode &mode);
using std::string;
MODES_NAMESPACE_USE;
-ModeManager::ModeManager(RuleManager &rMgr)
- : ruleMgr(rMgr)
+ModeManager::ModeManager(const std::set<string> &modeDirs, const string &xsdFile, RuleManager &rMgr)
+ : modeDirList(modeDirs), modeSyntaxFile(xsdFile),
+ ruleMgr(rMgr), careTaker(MODES_UNDO_INFO_DEFAULT_DIR)
{
+ modeDirList.insert(MODES_CUSTOM_MODE_DEFAULT_DIR);
}
-//it should be called before init()
-void ModeManager::setOptions(const std::set<string> &modeDirs, const string &xsdFile, const string &undoInfoDir)
-{
- modeDirList = modeDirs;
- modeSyntaxFile = xsdFile;
- undoDir = undoInfoDir;
- careTaker.setOptions(undoDir);
-}
-
-//it should be called after setOption()
void ModeManager::init()
{
modeMap.clear();
makeModeMap(*it);
DBG("Mode Directory(%s) added", it->c_str());
}
- restoreUndoInfo(undoDir);
+ restoreUndoInfo(careTaker.getUndoInfoDir());
}
// TODO: apply better polymorphism
string filename;
XMLGenerator xmlWriter;
+ auto element = std::make_pair(mode.getName(), std::make_tuple(filename, mode.getModeType(), false));
+ auto result = modeMap.insert(element);
+ if (false == result.second) {
+ ERR("Invalid mode(%s), already exists", mode.getName().c_str());
+ return MODES_ERROR_INVALID_PARAMETER;
+ }
+
try {
- filename = MODES_CUSTOM_MODE_DEFAULT_DIR"/tizen_" + mode.getName() + "_mode.xml";
+ filename = MODES_CUSTOM_MODE_DEFAULT_DIR "/tizen_" + mode.getName() + "_mode.xml";
xmlWriter.makeModeXML(filename, mode);
} catch (ModesEx &e) {
ERR("XML generator Fail(%s)", e.what());
+ modeMap.erase(result.first);
return MODES_ERROR_INVALID_PARAMETER;
}
- modeMap.insert(std::make_pair(mode.getName(), std::make_tuple(filename, mode.getModeType(), false)));
DBG("[%zu] Register modeName : %s, modePath : %s, type : %d, hidden : false", modeMap.size(), mode.getName().c_str(), filename.c_str(), mode.getModeType());
return MODES_ERROR_NONE;
#include "ModeObserver.h"
#include "ClientPrivilege.h"
-
-#ifndef MODES_MODE_DEFAULT_DIR
-#define MODES_MODE_DEFAULT_DIR "/usr/share/modes/mode"
-#warning "MODES_MODE_DEFAULT_DIR is redefined"
-#endif
-
MODES_NAMESPACE_BEGIN
class ModeManager {
public:
- ModeManager(RuleManager &rMgr);
+ ModeManager(const std::set<std::string> &modeDirs, const std::string &xsdFile, RuleManager &rMgr);
- void setOptions(const std::set<std::string> &modeDirs, const std::string &xsdFile, const std::string &undoInfoDir);
void init();
void addModeDirectory(const std::string &dirPath);
int applyMode(const std::string &modeName, ClientPrivilege &priv, bool isTest);
void attachObserver(ModeObserver *obs);
void detachObserver(ModeObserver *obs);
private:
- bool handleEssentialAction(const Mode &mode);
void notifyObservers(const std::string &modeName, ModeObserver::ModeState state);
bool makeModeMap(const std::string &dirPath);
bool restoreUndoInfo(const std::string &dirPath);
std::map<std::string, std::tuple<std::string, int, bool>> modeMap;
std::set<std::string> modeDirList;
- std::string undoDir;
std::string modeSyntaxFile;
RuleManager &ruleMgr;
ModeCareTaker careTaker;
struct ModesConfig {
std::string pluginDir;
std::set<std::string> modeXMLDirs;
- std::string modeXsdFile;
- std::string actionRuleXsdFile;
std::string actionRuleDir;
- std::string undoInfoDir;
};
MODES_NAMESPACE_END
#define EMPTY_PLUGIN_PAIR std::make_pair(nullptr, nullptr)
-void PluginMapper::setPluginDir(const std::string &dir)
+PluginMapper::PluginMapper(const std::string &dirPath)
+ : pluginDir(dirPath)
{
- pluginDir = dir;
}
int PluginMapper::loadPlugins()
class PluginMapper {
public:
- void setPluginDir(const std::string &dir_path);
+ PluginMapper(const std::string &dirPath);
+
int loadPlugins();
int unloadPlugins();
(xmlChar*)"privilege",
};
+RuleManager::RuleManager(const std::string & actionRuleDir, const std::string &actionRuleXsd, const std::string &pluginDir)
+ : ruleDir(actionRuleDir), ruleXsd(actionRuleXsd), piMapper(pluginDir)
+{
+}
+
void RuleManager::start()
{
piMapper.loadPlugins();
}
}
-void RuleManager::setOptions(const string &actionRuleDir, const string &actionRuleXsd, const std::string &pluginDir)
-{
- ruleDir = actionRuleDir;
- ruleXsd = actionRuleXsd;
- piMapper.setPluginDir(pluginDir);
-}
-
void RuleManager::addBoolAlias(ActionRule *actionRule)
{
actionRule->addAlias("true", "1");
void RuleManager::parseActionRule(const string &xmlFile)
{
- if (ruleXsd.empty()) {
- ERR("No ruleXsd");
- ruleXsd = MODES_ACTIONRULE_DEFAULT_XSD;
- }
-
try {
XMLParser parser(xmlFile);
parser.validate(ruleXsd);
TagMax
};
+ RuleManager(const std::string &actionRuleDir, const std::string &actionRuleXsd, const std::string &pluginDir);
+
void start();
void stop();
- void setOptions(const std::string &actionRuleDir, const std::string &actionRuleXsd, const std::string &pluginDir);
Action* createAction(const std::string &actionName);
private:
static const xmlChar* const ACTION_RULE_TAG;
MODES_NAMESPACE_USE;
-Supervisor::Supervisor()
- : modeMgr(ruleMgr)
+Supervisor::Supervisor(const ModesConfig &config)
+ : ruleMgr(config.actionRuleDir, MODES_RULE_DEFAULT_XSD_PATH, config.pluginDir),
+ modeMgr(config.modeXMLDirs, MODES_MODE_DEFAULT_XSD_PATH, ruleMgr)
{
}
RequestHandler::setRuleManager(NULL);
}
-void Supervisor::setOptions(const ModesConfig &config)
-{
- modeMgr.setOptions(config.modeXMLDirs, config.modeXsdFile, config.undoInfoDir);
- ruleMgr.setOptions(config.actionRuleDir, config.actionRuleXsdFile, config.pluginDir);
-}
-
void Supervisor::registerHandler()
{
clientConn.addRequestHandler("handle-can-apply", (GCallback)&RequestHandler::canApplyModeHandler);
class Supervisor {
public:
- Supervisor();
+ Supervisor(const ModesConfig &config);
void init();
void deInit();
- void setOptions(const ModesConfig &config);
void registerHandler();
private:
ClientConnection clientConn;
int main(int argc, char **argv)
{
GMainLoop *loop = g_main_loop_new(NULL, FALSE);
- Supervisor supervisor;
try {
ArgumentParser argParser;
ModesConfig config = argParser.parse(argc, argv);
- supervisor.setOptions(config);
+
+ Supervisor supervisor(config);
supervisor.init();
+ supervisor.registerHandler();
+
+ g_main_loop_run(loop);
+
+ supervisor.deInit();
}
catch (...) {
ERR("Initialization Fail");
return -1;
}
- supervisor.registerHandler();
-
- g_main_loop_run(loop);
-
- supervisor.deInit();
g_main_loop_unref(loop);
return 0;
User=system_fw
Group=system_fw
SmackProcessLabel=System
-ExecStart=@BIN_INSTALL_DIR@/@DAEMON@ @MODES_MODE_DEFAULT_DIR@ @MODES_CUSTOM_MODE_DEFAULT_DIR@
+ExecStart=@BIN_INSTALL_DIR@/@DAEMON@
*/
#include <gtest/gtest.h>
#include "common/definitions.h"
-#include "supervisor/ModesConfig.h"
#include "supervisor/ModeXMLParser.h"
#include "supervisor/ConflictManager.h"
};
ConflictTest::ConflictTest()
+ : ruleMgr(".", "./" MODES_RULE_DEFAULT_XSD_FILE, "../../.." MODES_PLUGIN_DEFAULT_DIR), careTaker(".")
{
- ModesConfig config;
- config.actionRuleDir = ".";
- config.actionRuleXsdFile = "./" MODES_ACTIONRULE_DEFAULT_XSD_FILE;
- config.undoInfoDir = ".";
- config.undoInfoDir = ".";
- config.pluginDir = "../../.." MODES_PLUGIN_DEFAULT_DIR;
-
- ruleMgr.setOptions(config.actionRuleDir, config.actionRuleXsdFile, config.pluginDir);
ruleMgr.start();
- careTaker.setOptions(config.undoInfoDir);
}
#include "supervisor/Mode.h"
#include "supervisor/ModesEx.h"
#include "supervisor/RuleManager.h"
-#include "supervisor/ModesConfig.h"
#include "supervisor/XMLGenerator.h"
#include "supervisor/ModeXMLParser.h"
MODES_NAMESPACE_END
GeneratorTest::GeneratorTest()
+ : ruleMgr(".", "./" MODES_RULE_DEFAULT_XSD_FILE, "../../.." MODES_PLUGIN_DEFAULT_DIR)
{
- ModesConfig config;
- config.actionRuleDir = ".";
- config.actionRuleXsdFile = "./" MODES_ACTIONRULE_DEFAULT_XSD_FILE;
- config.pluginDir = "../../.." MODES_PLUGIN_DEFAULT_DIR;
-
- ruleMgr.setOptions(config.actionRuleDir, config.actionRuleXsdFile, config.pluginDir);
ruleMgr.start();
}
#include <iostream>
#include <exception>
#include <gtest/gtest.h>
-#include "supervisor/ModesConfig.h"
#include "supervisor/ModeManager.h"
using namespace std;
public:
ModeManagerTest();
RuleManager rMgr;
- PluginMapper pMgr;
ModeManager mdMgr;
set<string> getDirectories();
MODES_NAMESPACE_END
ModeManagerTest::ModeManagerTest()
- : mdMgr(rMgr)
+ : rMgr(string(), string(), string()),
+ mdMgr(set<string>(), "./" MODES_MODE_DEFAULT_XSD_FILE, rMgr)
{
- ModesConfig config;
- config.modeXMLDirs.insert(".");
- config.modeXsdFile = "./" MODES_MODE_DEFAULT_XSD_FILE;
- config.undoInfoDir = "./";
-
- mdMgr.setOptions(config.modeXMLDirs, config.modeXsdFile, config.undoInfoDir);
+ mdMgr.modeDirList.insert(".");
mdMgr.init();
}
#include <gtest/gtest.h>
#include "supervisor/Mode.h"
#include "supervisor/ModesEx.h"
-#include "supervisor/ModesConfig.h"
#include "supervisor/RuleManager.h"
#include "supervisor/ModeXMLParser.h"
MODES_NAMESPACE_END
ParserTest::ParserTest()
+ : ruleMgr(".", "./" MODES_RULE_DEFAULT_XSD_FILE, "../../.." MODES_PLUGIN_DEFAULT_DIR)
{
- ModesConfig config;
- config.actionRuleDir = ".";
- config.actionRuleXsdFile = "./" MODES_ACTIONRULE_DEFAULT_XSD_FILE;
- config.pluginDir = "../../.." MODES_PLUGIN_DEFAULT_DIR;
-
- ruleMgr.setOptions(config.actionRuleDir, config.actionRuleXsdFile, config.pluginDir);
ruleMgr.start();
}
MODES_NAMESPACE_BEGIN
class TestPluginBroker {
public:
+ TestPluginBroker();
+
bool emptyPluginMap();
string getpluginDir();
MODES_NAMESPACE_USE;
+TestPluginBroker::TestPluginBroker()
+ : piMapper("../../.." MODES_PLUGIN_DEFAULT_DIR)
+{
+}
+
bool TestPluginBroker::emptyPluginMap()
{
return piMapper.pluginMap.empty();
{
TestPluginBroker broker;
- broker.piMapper.setPluginDir(MODES_PLUGIN_DEFAULT_DIR);
- try {
- broker.piMapper.loadPlugins();
- }
- catch (ModesEx &e) {
- broker.piMapper.setPluginDir("../../.." MODES_PLUGIN_DEFAULT_DIR);
- EXPECT_NO_THROW(broker.piMapper.loadPlugins());
- }
-
+ EXPECT_NO_THROW(broker.piMapper.loadPlugins());
EXPECT_FALSE(broker.emptyPluginMap());
list<string> pluginList = broker.piMapper.getPluginList();
}
}
-TEST(PluginMapper, setPluginDir)
-{
- TestPluginBroker broker;
-
- string path = "../plugin";
- broker.piMapper.setPluginDir(path);
-
- EXPECT_EQ(path, broker.getpluginDir());
-}
-
TEST(PluginMapper, unloadClassMap)
{
TestPluginBroker broker;
int ret;
TestPluginBroker broker;
- broker.piMapper.setPluginDir(MODES_PLUGIN_DEFAULT_DIR);
- try {
- broker.piMapper.loadPlugins();
- }
- catch (ModesEx &e) {
- broker.piMapper.setPluginDir("../../.." MODES_PLUGIN_DEFAULT_DIR);
- EXPECT_NO_THROW(broker.piMapper.loadPlugins());
- }
-
+ EXPECT_NO_THROW(broker.piMapper.loadPlugins());
EXPECT_FALSE(broker.emptyPluginMap());
Plugin *plugin = broker.piMapper.getPlugin("test");
*/
#include <gtest/gtest.h>
#include "supervisor/ModesEx.h"
-#include "supervisor/ModesConfig.h"
#include "supervisor/RuleManager.h"
using namespace std;
MODES_NAMESPACE_USE;
RuleManagerTest::RuleManagerTest()
+ : rMgr(".", "./" MODES_RULE_DEFAULT_XSD_FILE, "../../.." MODES_PLUGIN_DEFAULT_DIR)
{
- ModesConfig config;
- config.actionRuleDir = ".";
- config.actionRuleXsdFile = "./" MODES_ACTIONRULE_DEFAULT_XSD_FILE;
- config.pluginDir = "../../.." MODES_PLUGIN_DEFAULT_DIR;
-
- rMgr.setOptions(config.actionRuleDir, config.actionRuleXsdFile, config.pluginDir);
rMgr.piMapper.loadPlugins();
}