};
struct mds_mode_handle {
+ char *id;
char *name;
modes_type_mode_e type;
bool hidden;
}
GVariant *action = g_variant_new(MODES_DBUS_ACTION_LIST_SIG, action_builder);
- GVariant *mode_data = g_variant_new(MODES_DBUS_MODE_SIG, mode->name, mode->type, mode->hidden, action);
+ GVariant *mode_data = g_variant_new(MODES_DBUS_MODE_SIG, mode->id, mode->name, mode->type, mode->hidden, action);
g_variant_builder_unref(action_builder);
return mode_data;
}
-API modes_mode_h modes_create_mode(const char *name, modes_type_mode_e type)
+API modes_mode_h modes_create_mode(const char *id, const char *name, modes_type_mode_e type)
{
struct mds_mode_handle *mode;
- RETV_IF(NULL == name, NULL);
+ RETV_IF(NULL == id, NULL);
mode = malloc(sizeof(struct mds_mode_handle));
RETV_IF(NULL == mode, NULL);
+ mode->id = strdup(id);
mode->name = strdup(name);
mode->type = type;
mode->hidden = false;
return MODES_ERROR_NONE;
}
-API int modes_remove_mode(modes_h handle, const char *name)
+API int modes_remove_mode(modes_h handle, const char *id)
{
int ret;
RETV_IF(NULL == handle, MODES_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == name, MODES_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == id, MODES_ERROR_INVALID_PARAMETER);
- ret = _mdsc_dbus_remove_mode_sync(handle->conn, name);
+ ret = _mdsc_dbus_remove_mode_sync(handle->conn, id);
if (MODES_ERROR_NONE != ret) {
ERR("_mdsc_dbus_remove_mode_sync() Fail(%d)", ret);
return ret;
{
RET_IF(NULL == mode);
+ free(mode->id);
free(mode->name);
g_list_free_full(mode->action_list, _mdsc_free_action);
return result;
}
-API int modes_apply_mode(modes_h handle, const char *name)
+API int modes_apply_mode(modes_h handle, const char *id)
{
int ret;
RETV_IF(NULL == handle, MODES_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == name, MODES_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == id, MODES_ERROR_INVALID_PARAMETER);
- ret = _mdsc_dbus_apply_mode_sync(handle->conn, name);
+ ret = _mdsc_dbus_apply_mode_sync(handle->conn, id);
if (MODES_ERROR_NONE != ret) {
ERR("_mdsc_bus_client_change_mode_sync() Fail(%d)", ret);
return ret;
return result;
}
-API int modes_can_apply(modes_h handle, const char *name)
+API int modes_can_apply(modes_h handle, const char *id)
{
int ret;
RETV_IF(NULL == handle, MODES_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == name, MODES_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == id, MODES_ERROR_INVALID_PARAMETER);
- ret = _mdsc_dbus_can_apply_sync(handle->conn, name);
+ ret = _mdsc_dbus_can_apply_sync(handle->conn, id);
if (MODES_ERROR_NONE != ret) {
ERR("_mdsc_dbus_precheck_mode_sync() Fail(%d)", ret);
return ret;
#include "common/dbus_def.h"
struct mds_list_data_handle {
+ char *id;
char *name;
modes_type_mode_e type;
int state;
static GList* _get_mode_list(GVariant *in_data)
{
+ gchar *mode_id;
gchar *mode_name;
gint32 state;
gint32 type;
GList *mode_list = NULL;;
g_variant_get(in_data, MODES_DBUS_GET_MODES_SIG, &iter);
- while (g_variant_iter_loop(iter, MODES_DBUS_GET_MODES_MODE_SIG, &mode_name, &type, &state)) {
- DBG("mode(%s) : state(%d)", mode_name, state);
+ while (g_variant_iter_loop(iter, MODES_DBUS_GET_MODES_MODE_SIG, &mode_id, &mode_name, &type, &state)) {
+ DBG("mode(%s) : state(%d)", mode_id, state);
mode_list_data_h mode = malloc(sizeof(struct mds_list_data_handle));
if (NULL == mode) {
ERR("malloc() Fail");
return NULL;
}
+ mode->id = strdup(mode_id);
mode->name = strdup(mode_name);
mode->state = state;
mode->type = type;
static void _free_mode(gpointer data, gpointer user_data)
{
mode_list_data_h mode = data;
+ free(mode->id);
free(mode->name);
free(mode);
}
g_list_free(list);
}
+API const char* modes_get_mode_id(mode_list_data_h data)
+{
+ RETV_IF(NULL == data, NULL);
+ return data->id;
+}
+
API const char* modes_get_mode_name(mode_list_data_h data)
{
RETV_IF(NULL == data, NULL);
<arg type="i" name="ret" direction="out"/>
</method>
<method name="addMode">
- <arg type="(sibv)" name="modeData" direction="in"/>
+ <arg type="(ssibv)" name="modeData" direction="in"/>
<arg type="i" name="ret" direction="out"/>
</method>
<method name="removeMode">
<arg type="i" name="ret" direction="out"/>
</method>
<method name="getModes">
- <arg type="a(sii)" name="modeList" direction="out"/>
+ <arg type="a(ssii)" name="modeList" direction="out"/>
<arg type="i" name="ret" direction="out"/>
</method>
<signal name="changedMode">
#define MODES_DBUS_OBJPATH "/org/tizen/modes/dbus"
-#define MODES_DBUS_MODE_SIG "(sibv)"
+#define MODES_DBUS_MODE_SIG "(ssibv)"
#define MODES_DBUS_ACTION_SIG "(sss)"
#define MODES_DBUS_ACTION_LIST_SIG "a" MODES_DBUS_ACTION_SIG
-#define MODES_DBUS_GET_MODES_MODE_SIG "(sii)"
+#define MODES_DBUS_GET_MODES_MODE_SIG "(ssii)"
#define MODES_DBUS_GET_MODES_SIG "a" MODES_DBUS_GET_MODES_MODE_SIG
#define MODES_DBUS_SAFE_STR(x) x ? x : ""
#warning "MODES_UNDO_INFO_DEFAULT_DIR is redefined"
#endif
#define MODES_UNDO_FILE_SUFFIX "_undo.xml"
+#define MODES_ID_PREFIX "http://tizen.org/mode/"
<?xml version="1.0" encoding="utf-8"?>
<tizenModes xmlns="http://www.tizen.org" version="6.0">
- <mode name="asyncEx1" type="normal">
+ <mode ID="http://tizen.org/mode/example.asyncEx1" name="asyncEx1" type="normal">
<action ID="test_001" rule="test.sleep" type="async">5</action>
<action ID="test_002" rule="test.sleep" type="async">5</action>
<action ID="test_003" rule="test.sleepErrorReturn" type="async">5</action>
<?xml version="1.0" encoding="utf-8"?>
<tizenModes xmlns="http://www.tizen.org" version="6.0">
- <mode name="asyncEx2" type="oneshot">
+ <mode ID="http://tizen.org/mode/example.asyncEx2" name="asyncEx2" type="oneshot">
<action ID="test_001" rule="test.sleep" type="async">5</action>
<action ID="test_002" rule="test.sleep" type="async">5</action>
<action ID="test_003" rule="test.sleepErrorReturn" type="async">5</action>
<?xml version="1.0" encoding="utf-8"?>
<tizenModes xmlns="http://www.tizen.org" version="6.0">
- <mode name="asyncFail1" type="normal">
+ <mode ID="http://tizen.org/mode/example.asyncFail1" name="asyncFail1" type="normal">
<action rule="test.sleep" type="async">5</action>
<action rule="test.sleep" type="async">5</action>
<action rule="test.sleep" type="async">5</action>
<?xml version="1.0" encoding="utf-8"?>
<tizenModes xmlns="http://www.tizen.org" version="6.0">
- <mode name="asyncFail2" type="oneshot">
+ <mode ID="http://tizen.org/mode/example.asyncFail2" name="asyncFail2" type="oneshot">
<action rule="test.sleep" type="async">5</action>
<action rule="test.sleep" type="async">5</action>
<action rule="test.sleep" type="async">5</action>
<?xml version="1.0" encoding="utf-8"?>
<tizenModes xmlns="http://www.tizen.org" version="6.0">
- <mode name="async_valied" type="normal" hidden="true">
+ <mode ID="http://tizen.org/mode/example.async_valied" name="async_valied" type="normal" hidden="true">
<action rule="test.sleepErrorReturn" restrict="lock" stopOnErr="true" type="async">5</action>
</mode>
</tizenModes>
<?xml version="1.0" encoding="utf-8"?>
<tizenModes xmlns="http://www.tizen.org" version="6.0">
- <mode name="conflict1" type="normal">
+ <mode ID="http://tizen.org/mode/example.conflict1" name="conflict1" type="normal">
<action ID="test" rule="test.printInt" restrict="lock">1</action>
</mode>
</tizenModes>
<?xml version="1.0" encoding="utf-8"?>
<tizenModes xmlns="http://www.tizen.org" version="6.0">
- <mode name="conflict3" type="normal">
+ <mode ID="http://tizen.org/mode/example.conflict3" name="conflict3" type="normal">
<action ID="test" rule="test.printBool" restrict="lock">true</action>
</mode>
</tizenModes>
<?xml version="1.0" encoding="utf-8"?>
<tizenModes xmlns="http://www.tizen.org" version="6.0">
- <mode name="conflict1" type="normal">
+ <mode ID="http://tizen.org/mode/example.conflict1" name="conflict1" type="normal">
<action ID="test" rule="test.printInt" restrict="lock" stopOnErr="true">2</action>
</mode>
</tizenModes>
<?xml version="1.0" encoding="utf-8"?>
<tizenModes xmlns="http://www.tizen.org" version="6.0">
- <mode name="essential_ex" type="normal">
+ <mode ID="http://tizen.org/mode/example.essential_ex" name="essential_ex" type="normal">
<action rule="test.printBool">on</action>
<action rule="test.connect">Modes-JBL</action>
<action rule="test.changeTime" restrict="essential">3</action>
<?xml version="1.0" encoding="utf-8"?>
<tizenModes xmlns="http://www.tizen.org" version="6.0">
- <mode name="invalid1" type="normal">
+ <mode ID="http://tizen.org/mode/example.invalid1" name="invalid1" type="normal">
<action rule="test.printBool" restrict="lock">123</action>
</mode>
</tizenModes>
<?xml version="1.0" encoding="utf-8"?>
<tizenModes xmlns="http://www.tizen.org" version="6.0">
- <mode name="invalid2" type="normal">
+ <mode ID="http://tizen.org/mode/example.invalid2" name="invalid2" type="normal">
<action rule="test.printInt" restrict="lock">PRINT_TREE</action>
</mode>
</tizenModes>
<?xml version="1.0" encoding="utf-8"?>
<tizenModes xmlns="http://www.tizen.org" version="6.0">
- <mode name="ex1" type="normal">
+ <mode ID="http://tizen.org/mode/example.ex1" name="ex1" type="normal">
<action ID="wifiOn" rule="test.printBool" priority="-100">on</action>
<action rule="test.launch" before="GoPbsKids">com.vpn.usa123</action>
<action ID="GoPbsKids" rule="web.url" after="wifiOn">https://pbskids.org/</action>
<?xml version="1.0" encoding="utf-8"?>
<tizenModes xmlns="http://www.tizen.org" version="6.0">
- <mode name="ex2" type="normal" hidden="true">
+ <mode ID="http://tizen.org/mode/example.ex2" name="ex2" type="normal" hidden="true">
<action ID="1" rule="test.printInt" stopOnErr="true" restrict="lock">PRINT_FOUR</action>
<action ID="wifiOff" rule="test.printBool" restrict="lock">off</action>
<action rule="test.alwaySameValue">test</action>
void modes_disconnect(modes_h handle);
/**
- * @brief Apply mode with the given name.
+ * @brief Apply mode with the given mode id.
* @details Calls this function to change Modes.
* @since_tizen 6.0
* @privlevel public
- * @privilege according to privileges of the \p name Mode
+ * @privilege according to privileges of the mode id
* @param[in] Handle of modes server
- * @param[in] Mode name to change
+ * @param[in] Mode ID to change
* @return @c 0 on success,
* otherwise a negative error value
* @retval #MODES_ERROR_NONE Successful
* @retval #MODES_ERROR_PERMISSION_DENIED Permission denied
* @retval #MODES_ERROR_SYSTEM System errors
*/
-int modes_apply_mode(modes_h handle, const char *name);
+int modes_apply_mode(modes_h handle, const char *id);
/**
- * @brief Precheck to apply mode with the given name.
+ * @brief Precheck to apply mode with the given mode id.
* @details Calls this function to change Modes.
* @since_tizen 6.0
* @privlevel public
* @param[in] Handle of modes server
- * @param[in] Mode name to change
+ * @param[in] Mode ID to change
* @return @c 0 on success,
* otherwise a negative error value
* @retval #MODES_ERROR_NONE Successful
* @retval #MODES_ERROR_CONFLICT Conflict
* @retval #MODES_ERROR_SYSTEM System errors
*/
-int modes_can_apply(modes_h handle, const char *name);
+int modes_can_apply(modes_h handle, const char *id);
/**
- * @brief undo mode with the given name.
+ * @brief undo mode with the given mode id.
* @details If the mode is not applied bebore, it will be ingnored.
* @since_tizen 6.0
* @privlevel public
- * @privilege according to privileges of the \p name Mode
+ * @privilege according to privileges of the mode id
* @param[in] Handle of modes server
- * @param[in] Mode name to undo
+ * @param[in] Mode ID to undo
* @return @c 0 on success,
* otherwise a negative error value
* @retval #MODES_ERROR_NONE Successful
* @retval #MODES_ERROR_PERMISSION_DENIED Permission denied
* @retval #MODES_ERROR_SYSTEM System errors
*/
-int modes_undo_mode(modes_h handle, const char *name);
+int modes_undo_mode(modes_h handle, const char *id);
/**
* @since_tizen 6.0
* @privlevel public
* @param[in] Mode name
+ * @param[in] Mode ID
* @param[in] Mode type
* @return @c Mode handle pointer on success,
* otherwise NULL value
* @retval NULL Failed to create the mode handler
*/
-modes_mode_h modes_create_mode(const char *name, modes_type_mode_e type);
+modes_mode_h modes_create_mode(const char *id, const char *name, modes_type_mode_e type);
/**
* @brief Set Mode hidden.
* @retval #MODES_ERROR_CONFLICT Try to remove applied mode.
* @retval #MODES_ERROR_SYSTEM System errors
*/
-int modes_remove_mode(modes_h handle, const char *name);
+int modes_remove_mode(modes_h handle, const char *id);
/**
* @brief Adds callback for recognizing the changed of mode.
*/
void modes_free_modes(GList *list);
+/**
+ * @brief Get ID of mode from GList data
+ * @details Calls this function to get mode list
+ * @since_tizen 6.0
+ * @privlevel public
+ * @param[in] GList for mode list
+ * @return mode ID
+ */
+const char* modes_get_mode_id(mode_list_data_h data);
+
/**
* @brief Get name of mode from GList data
* @details Calls this function to get mode list
<xs:element maxOccurs="unbounded" name="action" type="o:actionT" />
<xs:element minOccurs="0" maxOccurs="unbounded" name="undo" type="o:actionT" />
</xs:sequence>
+ <xs:attribute name="ID" type="xs:string" use="required" />
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="type" type="o:modeTypeT" use="required" />
<xs:attribute name="hidden" type="xs:boolean" use="optional" />
g_signal_connect(dbusHandle, method.c_str(), cb, NULL);
}
-void ClientConnection::update(const std::string &name, ModeState state)
+void ClientConnection::update(const std::string &id, ModeState state)
{
- mds_dbus_emit_changed_mode(dbusHandle, name.c_str(), state);
+ mds_dbus_emit_changed_mode(dbusHandle, id.c_str(), state);
}
void ClientConnection::onBusAcquired(GDBusConnection *conn, const gchar *name, gpointer userData)
modeMgr = mgr;
}
-void EssentialHandler::undoHandler(const std::string &modeName)
+void EssentialHandler::undoHandler(const std::string &modeID)
{
- DBG("undo idler(%s) is added", modeName.c_str());
+ DBG("undo idler(%s) is added", modeID.c_str());
- g_idle_add(undoIdler, new std::string(modeName));
+ g_idle_add(undoIdler, new std::string(modeID));
}
gboolean EssentialHandler::undoIdler(gpointer data)
RETV_IF(NULL == data, G_SOURCE_REMOVE);
RETV_IF(nullptr == modeMgr, G_SOURCE_REMOVE);
- std::string &modeName = *(std::string*)data;
+ std::string &modeID = *(std::string*)data;
- int ret = modeMgr->undoMode(modeName);
+ int ret = modeMgr->undoMode(modeID);
if (MODES_ERROR_NONE != ret)
- ERR("undoMode(%s) Fail(%d)", modeName.c_str(), ret);
+ ERR("undoMode(%s) Fail(%d)", modeID.c_str(), ret);
- delete &modeName;
+ delete &modeID;
return G_SOURCE_REMOVE;
}
#include "Mode.h"
#include <thread>
+#include <algorithm>
#include "modes_constants.h"
#include "ModesEx.h"
return name;
}
+void Mode::setID(const std::string &data)
+{
+ id = data;
+}
+
+const std::string Mode::getID() const
+{
+ return id;
+}
+
void Mode::setModeType(Mode::ModeType val)
{
type = val;
{
return undoList;
}
+
+std::string Mode::getFileNameID() const
+{
+ std::string fileID = id.substr(sizeof(MODES_ID_PREFIX)-1);
+ std::replace(fileID.begin(), fileID.end(), '/', '_');
+ return fileID;
+}
void setName(const std::string &data);
const std::string getName() const;
+ void setID(const std::string &data);
+ const std::string getID() const;
+ std::string getFileNameID() const;
+
void setModeType(Mode::ModeType val);
ModeType getModeType() const;
void undo();
private:
std::string name;
+ std::string id;
ModeType type;
bool hidden;
bool essential;
return undoDir;
}
-bool ModeCareTaker::hasUndoInfo(const std::string &modeName)
+bool ModeCareTaker::hasUndoInfo(const std::string &filenameID)
{
- std::string file = undoDir + "/tizen_" + modeName + MODES_UNDO_FILE_SUFFIX;
+ std::string file = undoDir + "/tizen_" + filenameID + MODES_UNDO_FILE_SUFFIX;
return (access(file.c_str(), F_OK) == 0);
}
void ModeCareTaker::restoreMode(Mode &mode)
{
- std::string file = undoDir + "/tizen_" + mode.getName() + MODES_UNDO_FILE_SUFFIX;
+ std::string file = undoDir + "/tizen_" + mode.getFileNameID() + MODES_UNDO_FILE_SUFFIX;
try {
UndoInfoParser undoInfoParser(file);
undoInfoParser.putUndoInfo(mode);
realPushMode(mode);
XMLGenerator gen;
- gen.makeUndoInfoXML(undoDir + "/tizen_" + mode.getName() + MODES_UNDO_FILE_SUFFIX, mode);
+ gen.makeUndoInfoXML(undoDir + "/tizen_" + mode.getFileNameID() + MODES_UNDO_FILE_SUFFIX, mode);
}
-int ModeCareTaker::popMode(const std::string &name, Mode &mode)
+int ModeCareTaker::popMode(const std::string &id, Mode &mode)
{
- auto found = savedModes.find(name);
+ auto found = savedModes.find(id);
if (savedModes.end() == found) {
- ERR("No Mode(%s)", name.c_str());
+ ERR("No Mode(%s)", id.c_str());
return MODES_ERROR_NO_DATA;
}
- std::string filePath = undoDir + "/tizen_" + name + MODES_UNDO_FILE_SUFFIX;
+ mode = found->second;
+ std::string filePath = undoDir + "/tizen_" + mode.getFileNameID() + MODES_UNDO_FILE_SUFFIX;
if (0 != remove(filePath.c_str()))
ERR("remove(%s) Fail(%d)", filePath.c_str(), errno);
for (auto it = essentialMap.begin(); it != essentialMap.end();) {
- if (it->second == name)
+ if (it->second == id)
it = essentialMap.erase(it);
else
++it;
}
- mode = found->second;
savedModes.erase(found);
-
return MODES_ERROR_NONE;
}
bool ModeCareTaker::isConflict(const Mode &mode)
{
- if (isSavedMode(mode.getName()))
+ if (isSavedMode(mode.getID()))
return true;
if (checkConflictAction(mode))
return false;
}
-bool ModeCareTaker::isSavedMode(const std::string &name)
+bool ModeCareTaker::isSavedMode(const std::string &id)
{
- auto found = savedModes.find(name);
+ auto found = savedModes.find(id);
if (savedModes.end() != found) {
- INFO("Mode(%s) is Saved Mode", name.c_str());
+ INFO("Mode(%s) is Saved Mode", id.c_str());
return true;
}
void ModeCareTaker::realPushMode(const Mode &mode)
{
- savedModes.insert(std::pair<std::string, Mode>(mode.getName(), mode));
+ savedModes.insert(std::pair<std::string, Mode>(mode.getID(), mode));
if (mode.hasEssential())
handleEssentialAction(mode);
void ModeCareTaker::handleEssentialAction(const Mode &mode)
{
- DBG("Mode has Essential Action(%s)", mode.getName().c_str());
+ DBG("Mode has Essential Action(%s)", mode.getID().c_str());
std::list<std::shared_ptr<Action>> actionList = mode.getActionList();
for (auto it = actionList.begin(); it != actionList.end(); it++) {
if ((*it)->getRestrict() == Action::ESSENTIAL) {
DBG("Essential Action(%s)", (*it)->getRuleName().c_str());
- essentialMap.insert(std::make_pair((*it).get(), mode.getName()));
+ essentialMap.insert(std::make_pair((*it).get(), mode.getID()));
if (true == (*it)->checkChanged()) {
EssentialHandler::undoHandler(mode.getName());
return;
--- /dev/null
+/*
+ * Copyright (c) 2019-2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <string>
+#include "mdss.h"
+
+MODES_NAMESPACE_BEGIN
+struct ModeInfo {
+ std::string id;
+ std::string name;
+ std::string path;
+ bool hidden;
+ int type;
+ int state;
+};
+MODES_NAMESPACE_END
#include <exception>
#include "mdss.h"
#include "ModesEx.h"
+#include "ModeInfo.h"
#include "ModeObserver.h"
#include "XMLGenerator.h"
#include "ModeXMLParser.h"
void ModeManager::addModeAttributes(ModeXMLParser &parser, const string &path)
{
Mode mode = parser.getMode();
- auto infos = std::make_tuple(path, mode.getModeType(), mode.isHidden());
- modeMap.insert(std::make_pair(mode.getName(), infos));
+ ModeInfo info = { mode.getID(), mode.getName(), path, mode.isHidden(), mode.getModeType(), 0 };
+ modeMap.insert(std::make_pair(mode.getID(), info));
- if (careTaker.hasUndoInfo(mode.getName()))
+ if (careTaker.hasUndoInfo(mode.getFileNameID()))
careTaker.restoreMode(mode);
- DBG("[%zu]Name(%s), Path(%s), Type(%d), hidden(%s)", modeMap.size(), mode.getName().c_str(),
- path.c_str(), mode.getModeType(), mode.isHidden() ? "true": "false");
+ DBG("[%zu]ID(%s), Name(%s), Path(%s), Type(%d), hidden(%s)", modeMap.size(), mode.getID().c_str(),
+ mode.getName().c_str(), path.c_str(), mode.getModeType(), mode.isHidden() ? "true": "false");
}
-int ModeManager::applyMode(const string &modeName, ClientPrivilege &priv, bool isTest)
+int ModeManager::applyMode(const string &modeID, ClientPrivilege &priv, bool isTest)
{
- auto found = modeMap.find(modeName);
+ auto found = modeMap.find(modeID);
if (modeMap.end() == found) {
- ERR("No Mode(%s)", modeName.c_str());
+ ERR("No Mode(%s)", modeID.c_str());
return MODES_ERROR_NO_DATA;
}
- string path = std::get<0>(found->second);
+ string path = found->second.path;
DBG("applyMode(%s)", path.c_str());
try {
ModeXMLParser parser(path, ruleMgr);
Mode mode = parser.getMode();
- DBG("applyMode(%s) Run", mode.getName().c_str());
+ DBG("applyMode(%s) Run", mode.getID().c_str());
int ret = priv.check(mode);
if (MODES_ERROR_NONE != ret) {
}
if (careTaker.isConflict(mode)) {
- ERR("mode(%s) is conflict", mode.getName().c_str());
+ ERR("mode(%s) is conflict", mode.getID().c_str());
return MODES_ERROR_CONFLICT;
}
if (Mode::MODE_ONESHOT == mode.getModeType()) {
ret = mode.applyOneShot();
if (MODES_ERROR_NONE != ret) {
- ERR("mode(%s) apply() Fail", mode.getName().c_str());
+ ERR("mode(%s) apply() Fail", mode.getID().c_str());
mode.undo();
return ret;
}
} else {
ret = mode.apply();
if (MODES_ERROR_NONE != ret) {
- ERR("mode(%s) apply() Fail", mode.getName().c_str());
+ ERR("mode(%s) apply() Fail", mode.getID().c_str());
mode.undo();
return ret;
}
return MODES_ERROR_SYSTEM;
}
}
- notifyObservers(modeName, ModeObserver::ON);
+ notifyObservers(modeID, ModeObserver::ON);
return MODES_ERROR_NONE;
}
int ModeManager::addMode(const Mode &mode)
{
- string path = MODES_CUSTOM_MODE_DEFAULT_DIR "/tizen_" + mode.getName() + "_mode.xml";
+ string path = MODES_CUSTOM_MODE_DEFAULT_DIR "/tizen_" + mode.getFileNameID() + "_mode.xml";
XMLGenerator xmlWriter;
- auto element = std::make_pair(mode.getName(), std::make_tuple(path, mode.getModeType(), false));
- auto result = modeMap.insert(element);
+ ModeInfo info = { mode.getID(), mode.getName(), path, false, mode.getModeType(), 0};
+ auto result = modeMap.insert(std::make_pair(mode.getID(), info));
if (false == result.second) {
- ERR("Invalid mode(%s), already exists", mode.getName().c_str());
+ ERR("Invalid mode(%s), already exists", mode.getID().c_str());
return MODES_ERROR_INVALID_PARAMETER;
}
}
}
- DBG("[%zu]addMode : Name(%s), Path(%s), Type(%d)", modeMap.size(), mode.getName().c_str(),
- path.c_str(), mode.getModeType());
+ DBG("[%zu]addMode : ID(%s), Name(%s), Path(%s), Type(%d)", modeMap.size(), mode.getID().c_str(),
+ mode.getName().c_str(), path.c_str(), mode.getModeType());
return MODES_ERROR_NONE;
}
-int ModeManager::removeMode(const string &modeName)
+int ModeManager::removeMode(const string &modeID)
{
- if (true == careTaker.isSavedMode(modeName)) {
- ERR("Mode(%s) is applied.", modeName.c_str());
+ if (true == careTaker.isSavedMode(modeID)) {
+ ERR("Mode(%s) is applied.", modeID.c_str());
return MODES_ERROR_CONFLICT;
}
- auto result = modeMap.find(modeName);
+ auto result = modeMap.find(modeID);
if (result == modeMap.end()) {
- ERR("Invalid mode(%s), not found", modeName.c_str());
+ ERR("Invalid mode(%s), not found", modeID.c_str());
return MODES_ERROR_INVALID_PARAMETER;
}
- string path = std::get<0>(result->second);
+ string path = result->second.path;
if (string::npos == path.find(MODES_CUSTOM_MODE_DEFAULT_DIR)) {
- ERR("Invalid mode(%s), custom mode only can be removed.", modeName.c_str());
+ ERR("Invalid mode(%s), custom mode only can be removed.", modeID.c_str());
return MODES_ERROR_INVALID_PARAMETER;
}
if (0 != remove(path.c_str()))
ERR("remove(%s) Fail(%d)", path.c_str(), errno);
- DBG("[%zu]removeMode : Name(%s), Path(%s)", modeMap.size(), modeName.c_str(), path.c_str());
+ DBG("[%zu]removeMode : ID(%s), Path(%s)", modeMap.size(), modeID.c_str(), path.c_str());
return MODES_ERROR_NONE;
}
-int ModeManager::undoMode(const string &modeName, ClientPrivilege &priv)
+int ModeManager::undoMode(const string &modeID, ClientPrivilege &priv)
{
Mode mode;
- int ret = careTaker.popMode(modeName, mode);
+ int ret = careTaker.popMode(modeID, mode);
if (MODES_ERROR_NONE != ret) {
ERR("popMode() Fail(%d)", ret);
return ret;
}
mode.undo();
- notifyObservers(modeName, ModeObserver::OFF);
+ notifyObservers(modeID, ModeObserver::OFF);
return MODES_ERROR_NONE;
}
-int ModeManager::undoMode(const string &modeName)
+int ModeManager::undoMode(const string &modeID)
{
Mode mode;
- int ret = careTaker.popMode(modeName, mode);
+ int ret = careTaker.popMode(modeID, mode);
if (MODES_ERROR_NONE != ret) {
ERR("popMode() Fail(%d)", ret);
return ret;
}
mode.undo();
- notifyObservers(modeName, ModeObserver::OFF);
+ notifyObservers(modeID, ModeObserver::OFF);
return MODES_ERROR_NONE;
}
-std::list<std::tuple<string, int, int>> ModeManager::getModes()
+std::list<ModeInfo> ModeManager::getModes()
{
- std::list<std::tuple<string, int, int>> modeList;
+ std::list<ModeInfo> modeList;
for (auto it = modeMap.begin(); it != modeMap.end(); ++it) {
- bool hidden = std::get<2>(it->second);
- if (true == hidden)
+ if (true == it->second.hidden)
continue;
- int type = std::get<1>(it->second);
- int state = careTaker.isSavedMode(it->first);
- modeList.push_back(std::tuple<string, int, int>(it->first, type, state));
+ it->second.state = careTaker.isSavedMode(it->first);
+ modeList.push_back(it->second);
}
return modeList;
observers.remove(obs);
}
-void ModeManager::notifyObservers(const string &modeName, ModeObserver::ModeState state)
+void ModeManager::notifyObservers(const string &modeID, ModeObserver::ModeState state)
{
for (auto it = observers.begin(); it != observers.end(); ++it)
- (*it)->update(modeName, state);
+ (*it)->update(modeID, state);
}
bool ModeManager::makeModeMap(const string &dirPath)
modeDirList.insert(dirPath);
}
-
#include <utility>
#include <set>
#include "mdss.h"
+#include "ModeInfo.h"
#include "RuleManager.h"
#include "ModeObserver.h"
#include "ModeCareTaker.h"
int removeMode(const std::string &modeName);
int undoMode(const std::string &modeName);
int undoMode(const std::string &modeName, ClientPrivilege &priv);
- std::list<std::tuple<std::string, int, int>> getModes();
+ std::list<ModeInfo> getModes();
void attachObserver(ModeObserver *obs);
void detachObserver(ModeObserver *obs);
private:
bool makeModeMap(const std::string &dirPath);
void addModeAttributes(ModeXMLParser &parser, const std::string &path);
- std::map<std::string, std::tuple<std::string, int, bool>> modeMap;
+ std::map<std::string, ModeInfo> modeMap;
std::set<std::string> modeDirList;
std::string modeSyntaxFile;
RuleManager &ruleMgr;
void ModeXMLParser::parseModeAttr(xmlNodePtr node)
{
+ mode.setID(extractModeID(node));
mode.setName(extractModeName(node));
mode.setModeType(extractModeType(node));
mode.setHidden(extractHidden(node));
}
+std::string ModeXMLParser::extractModeID(xmlNodePtr node)
+{
+ return extractValueOfTag(node, ModesXMLTag::ID);
+}
+
std::string ModeXMLParser::extractModeName(xmlNodePtr node)
{
return extractValueOfTag(node, ModesXMLTag::NAME);
private:
void parseModeAttr(xmlNodePtr node);
std::string extractModeName(xmlNodePtr node);
+ std::string extractModeID(xmlNodePtr node);
Mode::ModeType extractModeType(xmlNodePtr node);
bool extractHidden(xmlNodePtr node);
void parseActionAttr(xmlNodePtr node, Action *action);
const xmlChar* const ModesXMLTag::TYPE = (xmlChar*)"type";
const xmlChar* const ModesXMLTag::TRUE = (xmlChar*)"true";
const xmlChar* const ModesXMLTag::FALSE = (xmlChar*)"false";
+const xmlChar* const ModesXMLTag::ID = (xmlChar*)"ID";
//Mode
const xmlChar* const ModesXMLTag::MODE = (xmlChar*)"mode";
const xmlChar* const ModesXMLTag::NAME = (xmlChar*)"name";
const xmlChar* const ModesXMLTag::RESTRICT = (xmlChar*)"restrict";
const char* const ModesXMLTag::RESTRICT_LOCK = "lock";
const char* const ModesXMLTag::RESTRICT_ESSENTIAL = "essential";
-const xmlChar* const ModesXMLTag::ID = (xmlChar*)"ID";
//UndoInfo
const xmlChar* const ModesXMLTag::UNDO_INFO = (xmlChar*)"UndoInfo";
const xmlChar* const ModesXMLTag::INFO = (xmlChar*)"info";
static const xmlChar* const TYPE;
static const xmlChar* const TRUE;
static const xmlChar* const FALSE;
+ static const xmlChar* const ID;
//Mode
static const xmlChar* const MODE;
static const xmlChar* const RESTRICT;
static const char* const RESTRICT_LOCK;
static const char* const RESTRICT_ESSENTIAL;
- static const xmlChar* const ID;
//UndoInfo
static const xmlChar* const UNDO_INFO;
static const xmlChar* const INFO;
}
gboolean RequestHandler::canApplyModeHandler(mdsDbus *object, GDBusMethodInvocation *invocation,
- const gchar *modeName, gpointer userData)
+ const gchar *modeID, gpointer userData)
{
RETV_IF(NULL == modeMgr, FALSE);
- DBG("mode name = %s", modeName);
+ DBG("mode ID = %s", modeID);
ClientPrivilege privInfo(invocation);
- int ret = modeMgr->applyMode(modeName, privInfo, true);
+ int ret = modeMgr->applyMode(modeID, privInfo, true);
mds_dbus_complete_can_apply(object, invocation, ret);
}
gboolean RequestHandler::applyModeHandler(mdsDbus *object, GDBusMethodInvocation *invocation,
- const gchar *modeName, gpointer userData)
+ const gchar *modeID, gpointer userData)
{
RETV_IF(NULL == modeMgr, FALSE);
- RETV_IF(NULL == modeName, FALSE);
+ RETV_IF(NULL == modeID, FALSE);
- DBG("mode name = %s", modeName);
+ DBG("mode name = %s", modeID);
ClientPrivilege privInfo(invocation);
- int ret = modeMgr->applyMode(modeName, privInfo, false);
+ int ret = modeMgr->applyMode(modeID, privInfo, false);
mds_dbus_complete_apply_mode(object, invocation, ret);
}
gboolean RequestHandler::undoModeHandler(mdsDbus *object, GDBusMethodInvocation *invocation,
- const gchar *modeName, gpointer userData)
+ const gchar *modeID, gpointer userData)
{
RETV_IF(NULL == modeMgr, FALSE);
- RETV_IF(NULL == modeName, FALSE);
+ RETV_IF(NULL == modeID, FALSE);
- DBG("mode name = %s", modeName);
+ DBG("mode ID = %s", modeID);
ClientPrivilege privInfo(invocation);
- int ret = modeMgr->undoMode(modeName, privInfo);
+ int ret = modeMgr->undoMode(modeID, privInfo);
mds_dbus_complete_undo_mode(object, invocation, ret);
}
gboolean RequestHandler::removeModeHandler(mdsDbus *object, GDBusMethodInvocation *invocation,
- const gchar *modeName, gpointer userData)
+ const gchar *modeID, gpointer userData)
{
RETV_IF(NULL == modeMgr, FALSE);
- RETV_IF(NULL == modeName, FALSE);
+ RETV_IF(NULL == modeID, FALSE);
- int ret = modeMgr->removeMode(modeName);
+ int ret = modeMgr->removeMode(modeID);
mds_dbus_complete_remove_mode(object, invocation, ret);
return TRUE;
RETV_IF(NULL == modeMgr, FALSE);
- std::list<std::tuple<std::string, int, int>> modeList = modeMgr->getModes();
+ std::list<ModeInfo> modeList = modeMgr->getModes();
if (modeList.empty()) {
ERR("getModes() : No Data");
ret = MODES_ERROR_NO_DATA;
GVariantBuilder *modeListBuilder = g_variant_builder_new(G_VARIANT_TYPE(MODES_DBUS_GET_MODES_SIG));
for (auto it = modeList.begin(); it != modeList.end(); ++it) {
- int state;
- int type;
- std::string name;
- std::tie(name, type, state) = *it;
- g_variant_builder_add(modeListBuilder, MODES_DBUS_GET_MODES_MODE_SIG, name.c_str(), type, state);
+ g_variant_builder_add(modeListBuilder, MODES_DBUS_GET_MODES_MODE_SIG, it->id.c_str(),
+ it->name.c_str(), it->type, it->state);
}
GVariant *outList = g_variant_new(MODES_DBUS_GET_MODES_SIG, modeListBuilder);
Mode RequestHandler::getModefromData(GVariant *inData)
{
GVariant *actionList;
- gchar *modeName;
+ gchar *modeID, *modeName;
gchar *id, *actName, *value;
gint32 type;
GVariantIter *iter;
Mode::ModeType modeType;
gboolean modeHidden;
- g_variant_get(inData, MODES_DBUS_MODE_SIG, &modeName, &type, &modeHidden, &actionList);
- DBG("mode_name : %s // type : %d // hidden : %s", modeName, type, modeHidden? "true" : "false");
+ g_variant_get(inData, MODES_DBUS_MODE_SIG, &modeID, &modeName, &type, &modeHidden, &actionList);
+ DBG("id : %s // mode_name : %s // type : %d // hidden : %s", modeID, modeName, type, modeHidden? "true" : "false");
switch (type) {
case MODES_TYPE_MODE_NORMAL:
modeType = Mode::MODE_ONESHOT;
}
+ mode.setID(modeID);
mode.setName(modeName);
mode.setModeType(modeType);
mode.setHidden(modeHidden);
+ g_free(modeID);
g_free(modeName);
g_variant_get(actionList, MODES_DBUS_ACTION_LIST_SIG, &iter);
const std::string modeType = getModeTypeStr(mode.getModeType());
std::string modeName = mode.getName();
+ std::string modeID = mode.getID();
xmlNodePtr modeNode = xmlNewNode(NULL, ModesXMLTag::MODE);
+ xmlSetProp(modeNode, ModesXMLTag::ID, (xmlChar*)modeID.c_str());
xmlSetProp(modeNode, ModesXMLTag::NAME, (xmlChar*)modeName.c_str());
xmlSetProp(modeNode, ModesXMLTag::TYPE, (xmlChar*)modeType.c_str());
if (true == mode.isHidden())
TEST_F(AsyncTest, normalAsync)
{
- const char *modeName = "asyncEx1";
- modes_undo_mode(handle, modeName);
- g_idle_add(ModeIdler, (gpointer)modeName);
+ const char *modeID = "http://tizen.org/mode/example.asyncEx1";
+ modes_undo_mode(handle, modeID);
+ g_idle_add(ModeIdler, (gpointer)modeID);
g_main_loop_run(loop);
}
TEST_F(AsyncTest, oneshotAsync)
{
- const char *modeName = "asyncEx2";
- int ret = modes_apply_mode(handle, modeName);
+ const char *modeID = "http://tizen.org/mode/example.asyncEx2";
+ int ret = modes_apply_mode(handle, modeID);
EXPECT_EQ(MODES_ERROR_NONE, ret);
}
TEST_F(AsyncTest, normalAsyncFail)
{
- const char *modeName = "asyncFail1";
- modes_undo_mode(handle, modeName);
- g_idle_add(failIdler, (gpointer)modeName);
+ const char *modeID = "http://tizen.org/mode/example.asyncFail1";
+ modes_undo_mode(handle, modeID);
+ g_idle_add(failIdler, (gpointer)modeID);
g_main_loop_run(loop);
}
TEST_F(AsyncTest, oneshotAsyncFail)
{
- const char *modeName = "asyncFail2";
- g_idle_add(failIdler, (gpointer)modeName);
+ const char *modeID = "http://tizen.org/mode/example.asyncFail2";
+ g_idle_add(failIdler, (gpointer)modeID);
g_main_loop_run(loop);
}
* limitations under the License.
*/
#include <iostream>
+#include <string>
#include <glib.h>
#include <gtest/gtest.h>
#include <modes.h>
return G_SOURCE_REMOVE;
}
- static void addModeTest(gpointer data)
+ static void addModeTest(std::string name)
{
- modes_mode_h created_mode = modes_create_mode((char*)data, MODES_TYPE_MODE_NORMAL);
+ std::string id = MODES_ID_PREFIX"example." + name;
+ modes_mode_h created_mode = modes_create_mode(id.c_str(), name.c_str(), MODES_TYPE_MODE_NORMAL);
modes_action_h action_handle[2];
action_handle[0] = modes_create_action("test.printBool", "on");
action_handle[1] = modes_create_action("test.printBool", "off");
modes_destroy_mode(created_mode);
EXPECT_EQ(MODES_ERROR_NONE, result);
- result = modes_apply_mode(handle, (char*)data);
+ result = modes_apply_mode(handle, id.c_str());
EXPECT_EQ(MODES_ERROR_NONE, result);
}
static gboolean addModeIdler(gpointer data)
{
- addModeTest(data);
- modes_undo_mode(handle, (char*)data);
- modes_remove_mode(handle, (char*)data);
+ addModeTest((char*)data);
+
+ std::string id = MODES_ID_PREFIX"example." + std::string((char*)data);
+ modes_undo_mode(handle, id.c_str());
+ modes_remove_mode(handle, id.c_str());
g_main_loop_quit(loop);
return G_SOURCE_REMOVE;
static gboolean removeModeIdler(gpointer data)
{
- addModeTest(data);
+ addModeTest((char*)data);
- result = modes_remove_mode(handle, (char*)data);
+ std::string id = MODES_ID_PREFIX"example." + std::string((char*)data);
+ result = modes_remove_mode(handle, id.c_str());
EXPECT_EQ(MODES_ERROR_CONFLICT, result);
- modes_undo_mode(handle, (char*)data);
- result = modes_remove_mode(handle, (char*)data);
+ modes_undo_mode(handle, id.c_str());
+ result = modes_remove_mode(handle, id.c_str());
EXPECT_EQ(MODES_ERROR_NONE, result);
g_main_loop_quit(loop);
TEST_F(ClientTest, applyModeP)
{
- modes_undo_mode(handle, "ex1");
- g_idle_add(applyModeIdler, (gpointer)"ex1");
+ modes_undo_mode(handle, "http://tizen.org/mode/example.ex1");
+ g_idle_add(applyModeIdler, (gpointer)"http://tizen.org/mode/example.ex1");
g_main_loop_run(loop);
EXPECT_EQ(MODES_ERROR_NONE, result);
}
TEST_F(ClientTest, applyModeN)
{
- g_idle_add(applyModeIdler, (gpointer)"non_ex2");
+ g_idle_add(applyModeIdler, (gpointer)"http://tizen.org/mode/example.non_ex2");
g_main_loop_run(loop);
EXPECT_EQ(MODES_ERROR_NO_DATA, result);
}
TEST_F(ClientTest, canApplyModeP)
{
- modes_undo_mode(handle, "ex1");
- int ret = modes_can_apply(handle, "ex1");
+ modes_undo_mode(handle, "http://tizen.org/mode/example.ex1");
+ int ret = modes_can_apply(handle, "http://tizen.org/mode/example.ex1");
EXPECT_EQ(MODES_ERROR_NONE, ret);
}
TEST_F(ClientTest, canApplyModeN)
{
- int ret = modes_can_apply(handle, "ex4");
+ int ret = modes_can_apply(handle, "http://tizen.org/mode/example.ex4");
EXPECT_EQ(MODES_ERROR_NO_DATA, ret);
}
TEST_F(ClientTest, undoModeEx1)
{
- modes_undo_mode(handle, "ex1");
- g_idle_add(undoModeIdler, (gpointer)"ex1");
+ modes_undo_mode(handle, "http://tizen.org/mode/example.ex1");
+ g_idle_add(undoModeIdler, (gpointer)"http://tizen.org/mode/example.ex1");
g_main_loop_run(loop);
EXPECT_EQ(MODES_ERROR_NONE, result);
}
TEST_F(ClientTest, undoModeEx2)
{
- modes_undo_mode(handle, "ex2");
- g_idle_add(undoModeIdler, (gpointer)"ex2");
+ modes_undo_mode(handle, "http://tizen.org/mode/example.ex2");
+ g_idle_add(undoModeIdler, (gpointer)"http://tizen.org/mode/example.ex2");
g_main_loop_run(loop);
EXPECT_EQ(MODES_ERROR_NONE, result);
}
for (cur = g_list_first(list); cur; cur = g_list_next(cur)) {
EXPECT_NE(nullptr, cur->data);
+ const char *id = modes_get_mode_id((mode_list_data_h)cur->data);
+
const char *name = modes_get_mode_name((mode_list_data_h)cur->data);
EXPECT_NE(nullptr, name);
int state = modes_get_mode_state((mode_list_data_h)cur->data);
EXPECT_NE(MODES_ERROR_INVALID_PARAMETER, state);
- std::cout << name << " " << typeList[type] << "(" << type << ") :state(" << state << ")" << std::endl;
+ std::cout << id << " "<< name << " " << typeList[type] << "(" << type << ") :state(" << state << ")" << std::endl;
}
modes_free_modes(list);
}
{
ModeXMLParser modeparser("tizen_conflictErrBase_mode.xml", ruleMgr);
Mode mode = modeparser.getMode();
- EXPECT_TRUE(careTaker.isSavedMode(mode.getName()));
+ EXPECT_TRUE(careTaker.isSavedMode(mode.getID()));
}
TEST_F(ConflictTest, checkConflictAction)
"MODE_EXCLUSIVE" };
if (!mdMgr.modeMap.empty()) {
- cout << "| "; cout.width(15); cout << "Mode Name" << " | " << "ModeXML file Path" << "| type | hidden" << endl;
+ cout << "| "; cout.width(30); cout << "Mode ID" << " | "; cout.width(15); cout << "Mode Name" << " | " << "ModeXML file Path" << "| type | hidden" << endl;
for (auto it = mdMgr.modeMap.begin(); it != mdMgr.modeMap.end(); it++) {
- cout << "| "; cout.width(15); cout << it->first.c_str() << " | " << std::get<0>(it->second).c_str() << " | ";
- cout << mode_type[std::get<1>(it->second)];
- if (std::get<2>(it->second))
+ cout << "| "; cout.width(30); cout << it->first.c_str() << " | " << it->second.name.c_str() << " | ";
+ cout << it->second.path.c_str() << " | ";
+ cout << mode_type[it->second.type] << " | ";
+ if (it->second.hidden)
cout << "hidden";
else
cout << "Not hidden";
return G_SOURCE_REMOVE;
}
- static int notiFunc(const char *modeName, int state, void *user_data)
+ static int notiFunc(const char *modeID, int state, void *user_data)
{
char *requestMode = (char*)user_data;
- std::cout << "notiFunc Changed Mode : " << modeName << std::endl;
- EXPECT_EQ(requestMode, std::string(modeName));
+ std::cout << "notiFunc Changed Mode : " << modeID << std::endl;
+ EXPECT_EQ(requestMode, std::string(modeID));
std::cout << "state : " << state << std::endl;
EXPECT_EQ(expectedState, state);
return MODES_ERROR_NONE;
}
- static int changeFn(const char *modeName, int state, void *user_data)
+ static int changeFn(const char *modeID, int state, void *user_data)
{
char *requestMode = (char*)user_data;
- std::cout << "changeFn Changed Mode : " << modeName << std::endl;
- EXPECT_EQ(requestMode, std::string(modeName));
+ std::cout << "changeFn Changed Mode : " << modeID << std::endl;
+ EXPECT_EQ(requestMode, std::string(modeID));
std::cout << "state : " << state << std::endl;
if (0 == state)
return MODES_ERROR_NONE;
}
- static int notiMultiFunc1(const char *modeName, int state, void *user_data)
+ static int notiMultiFunc1(const char *modeID, int state, void *user_data)
{
- std::cout << "notiMultiFunc1 Changed Mode : " << modeName << std::endl;
+ std::cout << "notiMultiFunc1 Changed Mode : " << modeID << std::endl;
std::cout << "state : " << state << std::endl;
calledbit1 |= 0x1 << state;
return MODES_ERROR_NONE;
}
- static int notiMultiFunc2(const char *modeName, int state, void *user_data)
+ static int notiMultiFunc2(const char *modeID, int state, void *user_data)
{
- std::cout << "notiMultiFunc2 Changed Mode : " << modeName << std::endl;
+ std::cout << "notiMultiFunc2 Changed Mode : " << modeID << std::endl;
std::cout << "state : " << state << std::endl;
calledbit2 |= 0x1 << state;
return MODES_ERROR_NONE;
}
- static int notiMultiFunc3(const char *modeName, int state, void *user_data)
+ static int notiMultiFunc3(const char *modeID, int state, void *user_data)
{
- std::cout << "notiMultiFunc3 Changed Mode : " << modeName << std::endl;
+ std::cout << "notiMultiFunc3 Changed Mode : " << modeID << std::endl;
std::cout << "state : " << state << std::endl;
EXPECT_TRUE(NULL == user_data || notiTestMode == user_data);
unsigned char ClientNotiTest::calledbit3 = 0;
unsigned char ClientNotiTest::calledbit4 = 0;
GMainLoop *ClientNotiTest::loop = NULL;
-const char *ClientNotiTest::notiTestMode = "ex2";
+const char *ClientNotiTest::notiTestMode = "http://tizen.org/mode/example.ex2";
TEST_F(ClientNotiTest, subscribeCB)
{
- const char *testMode = "ex2";
+ const char *testMode = "http://tizen.org/mode/example.ex2";
modes_noti_ID id = modes_subscribe_mode_changes(handle, notiFunc, (void*)testMode);
EXPECT_NE(nullptr , id);
TEST_F(ClientNotiTest, essentialAction)
{
- const char *testMode = "essential_ex";
+ const char *testMode = "http://tizen.org/mode/example.essential_ex";
modes_noti_ID id = modes_subscribe_mode_changes(handle, changeFn, (void*)testMode);
EXPECT_NE(nullptr, id);