Add hidden argument at modes_create_mode API
authorJinWang An <jinwang.an@samsung.com>
Thu, 26 Dec 2019 01:53:15 +0000 (10:53 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Wed, 18 Mar 2020 08:53:50 +0000 (17:53 +0900)
client/mdsc_register_mode.c
common/dbus.xml
common/dbus_def.h
include/modes.h
supervisor/RequestHandler.cpp
supervisor/XMLGenerator.cpp
unittest/modes_test_client.cpp

index 99c908b219a980c2c59af77eb0711a5930abb00b..73459000fc88b843713986a8fd25f4eed6eb7d23 100644 (file)
@@ -31,6 +31,7 @@ struct mds_action_handle {
 struct mds_handle {
        char *name;
        modes_type_mode_e type;
+       bool hidden;
        GList *action_list;
 };
 
@@ -79,7 +80,7 @@ static GVariant* _mdsc_create_mode_data(modes_h mode)
        }
 
        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, action);
+       GVariant *mode_data = g_variant_new(MODES_DBUS_MODE_SIG, mode->name, mode->type, mode->hidden, action);
        g_variant_builder_unref(action_builder);
 
        return mode_data;
@@ -96,11 +97,21 @@ API modes_h modes_create_mode(const char *name, modes_type_mode_e type)
 
        mode->name = strdup(name);
        mode->type = type;
+       mode->hidden = false;
        mode->action_list = NULL;
 
        return mode;
 }
 
+API int modes_set_hidden(modes_h mode, bool hidden)
+{
+       RETV_IF(NULL == mode, MODES_ERROR_INVALID_PARAMETER);
+
+       mode->hidden = hidden;
+
+       return MODES_ERROR_NONE;
+}
+
 API action_h modes_create_action(const char *name, const char *value)
 {
        struct mds_action_handle *action;
index 604b976e6ec582f668bd4d9154e80f476fdb44bb..714f539feac7b24d2fe934e830f668dca37361b9 100644 (file)
@@ -13,7 +13,7 @@
                        <arg type="i" name="ret" direction="out"/>
                </method>
                <method name="registerMode">
-                       <arg type="(siv)" name="modeData" direction="in"/>
+                       <arg type="(sibv)" name="modeData" direction="in"/>
                        <arg type="i" name="ret" direction="out"/>
                </method>
                <method name="getModes">
index 3717cf52e907db25a47d1affc026db8123a3b118..1fb28701800e102f51c5a75c2a236d77484dc277 100644 (file)
@@ -22,7 +22,7 @@
 
 #define MODES_DBUS_OBJPATH "/org/tizen/modes/dbus"
 
-#define MODES_DBUS_MODE_SIG "(siv)"
+#define MODES_DBUS_MODE_SIG "(sibv)"
 #define MODES_DBUS_ACTION_SIG "(sss)"
 #define MODES_DBUS_ACTION_LIST_SIG "a" MODES_DBUS_ACTION_SIG
 
index 12304b48fedd3b4b8d4a03c21102a92dd507c2da..c75665c6a31e878ae9763233da046c09d22423af 100644 (file)
@@ -104,6 +104,21 @@ int modes_undo_mode(const char *name);
  */
 modes_h modes_create_mode(const char *name, modes_type_mode_e type);
 
+/**
+ * @brief Set Mode hidden.
+ * @details Calls this function to hide mode list.
+ * @since_tizen 6.0
+ * @privlevel public
+ * @param[out]
+ * @param[in] Mode handle
+ * @param[in] Mode hidden
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #MODES_ERROR_NONE Successful
+ * @retval #MODES_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int modes_set_hidden(modes_h mode, bool hidden);
+
 /**
  * @brief Create Action.
  * @details Calls this function to create action.
@@ -122,7 +137,7 @@ action_h modes_create_action(const char *name, const char *value);
 
 /**
  * @brief Add Action to Mode.
- * @details Calls this function to add action to mode.
+ * @details Calls this function to set ID to action.
  * @since_tizen 6.0
  * @privlevel public
  * @param[in] Action handle
index 6b0f2716e3eea6921b3f26ffca5bec9902887b9d..2f4d847252f4a09640b4abe9252b6943086742dc 100644 (file)
@@ -139,9 +139,10 @@ Mode RequestHandler::getModefromData(GVariant *inData)
        GVariantIter *iter;
        Mode mode;
        Mode::ModeType modeType;
+       gboolean modeHidden;
 
-       g_variant_get(inData, MODES_DBUS_MODE_SIG, &modeName, &type, &actionList);
-       DBG("mode_name : %s // type : %d", modeName, type);
+       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");
 
        switch (type) {
        case MODES_TYPE_MODE_NORMAL:
@@ -158,6 +159,7 @@ Mode RequestHandler::getModefromData(GVariant *inData)
 
        mode.setName(modeName);
        mode.setModeType(modeType);
+       mode.setHidden(modeHidden);
        g_free(modeName);
 
        g_variant_get(actionList, MODES_DBUS_ACTION_LIST_SIG, &iter);
index 1336e72d66f9f6a6a42251d35a5a4c567691a16b..3b1e1c2030f1f4e8ccafb78a2792a81d2cbc8667 100644 (file)
@@ -84,6 +84,8 @@ void XMLGenerator::makeModeXML(const std::string &filename, const Mode &mode)
 
        xmlSetProp(modeNode, ModesXMLTag::NAME, (xmlChar*)modeName.c_str());
        xmlSetProp(modeNode, ModesXMLTag::TYPE, (xmlChar*)modeType.c_str());
+       if (true == mode.isHidden())
+               xmlSetProp(modeNode, ModesXMLTag::HIDDEN, (xmlChar*)"true");
        xmlAddChild(rootNode, modeNode);
 
        std::list<std::shared_ptr<Action>> actionList = mode.getActionList();
index e31cd0cc9ef7b9da3844d36a40b3d54377165068..b66418cd9fea75aec6eea4d99d3ff6f85bbff528 100644 (file)
@@ -59,8 +59,13 @@ protected:
                action_handle[1] = modes_create_action("test.printBool", "off");
                modes_action_set_id(action_handle[1], "printBoolOff");
 
-               for (int i = 0; i < 2; i++)
+               for (int i = 0; i < 2; i++) {
                        result = modes_mode_add_action(mode_handle, action_handle[i]);
+                       EXPECT_EQ(MODES_ERROR_NONE, result);
+               }
+
+               result = modes_set_hidden(mode_handle, true);
+               EXPECT_EQ(MODES_ERROR_NONE, result);
 
                result = modes_register_mode(mode_handle);
                modes_destroy_mode(mode_handle);