ADD_SUBDIRECTORY(wifi)
ADD_SUBDIRECTORY(vconf)
+ADD_SUBDIRECTORY(appfw)
ADD_SUBDIRECTORY(bluetooth)
ADD_SUBDIRECTORY(unittests)
--- /dev/null
+/*
+ * Copyright (c) 2019 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.
+ */
+#include "AppfwAction.h"
+#include <modes_errors.h>
+
+MODES_NAMESPACE_USE;
+
+AppfwAction::AppfwAction()
+{
+}
+
+AppfwAction::~AppfwAction()
+{
+}
+
+int AppfwAction::set(const std::string &val)
+{
+ return MODES_ERROR_NOT_SUPPORTED;
+}
+
+void AppfwAction::setName(std::string name)
+{
+ this->name = name;
+}
+
+std::string AppfwAction::getName()
+{
+ return name;
+}
--- /dev/null
+/*
+ * Copyright (c) 2019 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 "plugin-def.h"
+
+MODES_NAMESPACE_BEGIN
+
+class AppfwAction {
+public:
+ AppfwAction();
+ virtual ~AppfwAction();
+
+ std::string getName();
+ virtual int set(const std::string &val);
+
+protected:
+ void setName(std::string name);
+
+private:
+ std::string name;
+};
+
+MODES_NAMESPACE_END
+
--- /dev/null
+/*
+ * Copyright (c) 2019 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.
+ */
+#include "AppfwActionLaunch.h"
+
+#include <app_control.h>
+#include <modes_errors.h>
+#include "plugin-log.h"
+
+MODES_NAMESPACE_USE;
+
+const std::string AppfwActionLaunch::NAME = "launch";
+
+AppfwActionLaunch::AppfwActionLaunch()
+{
+ setName(NAME);
+}
+
+int AppfwActionLaunch::set(const std::string &val)
+{
+ DBG("id(%s)", val.c_str());
+
+ app_control_h service;
+ app_control_create(&service);
+ app_control_set_app_id(service, val.c_str());
+ app_control_set_operation(service, APP_CONTROL_OPERATION_DEFAULT);
+ app_control_set_launch_mode(service, APP_CONTROL_LAUNCH_MODE_SINGLE);
+
+ int ret = app_control_send_launch_request(service, NULL, NULL);
+ if (APP_CONTROL_ERROR_NONE != ret) {
+ ERR("app_control_send_launch_request() Fail(%s)", get_error_message(ret));
+ return MODES_ERROR_IO_ERROR;
+ }
+
+ app_control_destroy(service);
+ return MODES_ERROR_NONE;
+}
--- /dev/null
+/*
+ * Copyright (c) 2019 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 "AppfwAction.h"
+
+MODES_NAMESPACE_BEGIN
+
+class AppfwActionLaunch : public AppfwAction {
+public:
+ AppfwActionLaunch();
+
+ virtual int set(const std::string &val) override;
+
+ static const std::string NAME;
+};
+
+MODES_NAMESPACE_END
--- /dev/null
+/*
+ * Copyright (c) 2019 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.
+ */
+#include "AppfwFactory.h"
+#include <modes_errors.h>
+#include "plugin-log.h"
+#include "AppfwActionLaunch.h"
+
+MODES_NAMESPACE_USE;
+
+AppfwFactory::AppfwFactory()
+{
+ actionMap[AppfwActionLaunch::NAME] = APPFW_ACT_LAUNCH;
+}
+
+AppfwAction* AppfwFactory::createAction(const std::string &key)
+{
+ auto search = actionMap.find(key);
+ if (search == actionMap.end()) {
+ ERR("No AppfwAction(%s)", key.c_str());
+ return nullptr;
+ }
+
+ switch (search->second) {
+ case APPFW_ACT_LAUNCH:
+ AppfwActionLaunch *appfwActionLaunch = new AppfwActionLaunch();
+ return appfwActionLaunch;
+ break;
+ }
+
+ return nullptr;
+}
+
+void AppfwFactory::destroyAction(AppfwAction *action)
+{
+ delete action;
+}
--- /dev/null
+/*
+ * Copyright (c) 2019 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 <map>
+#include "AppfwAction.h"
+
+MODES_NAMESPACE_BEGIN
+
+class AppfwFactory {
+public:
+ AppfwFactory();
+ ~AppfwFactory() = default;
+
+ AppfwAction* createAction(const std::string &key);
+ void destroyAction(AppfwAction *action);
+private:
+ enum actionKey{
+ APPFW_ACT_LAUNCH
+ };
+
+ std::map<std::string, enum actionKey> actionMap;
+};
+
+MODES_NAMESPACE_END
--- /dev/null
+/*
+ * Copyright (c) 2019 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.
+ */
+#include <string>
+#include <map>
+#include <modes_errors.h>
+#include <Plugin.h>
+#include "plugin-log.h"
+#include "AppfwFactory.h"
+
+MODES_NAMESPACE_USE;
+
+class AppfwPlugin : public Plugin {
+public:
+ AppfwPlugin();
+ ~AppfwPlugin();
+
+ int set(const std::string &key, const std::string &val, std::string *oldVal) override;
+private:
+ AppfwFactory appfwFactory;
+};
+
+extern "C" API Plugin *objectCreate(void)
+{
+ return new AppfwPlugin;
+}
+
+extern "C" API void objectDelete(Plugin *plugin)
+{
+ delete plugin;
+}
+
+AppfwPlugin::AppfwPlugin()
+{
+ setName("appfw");
+}
+
+AppfwPlugin::~AppfwPlugin()
+{
+}
+
+int AppfwPlugin::set(const std::string &key, const std::string &val, std::string *oldVal)
+{
+ AppfwAction *action = appfwFactory.createAction(key);
+ RETVM_IF(nullptr == action, MODES_ERROR_INVALID_PARAMETER, "action(%s) is null", key.c_str());
+
+ DBG("set [%s, %s]", key.c_str(), val.c_str());
+
+ int appfwRet = action->set(val);
+ appfwFactory.destroyAction(action);
+ return appfwRet;
+}
+
--- /dev/null
+SET(APPFW_PLUGIN "modes-plugin-appfw")
+
+FILE(GLOB APPFW_SRCS *.cpp)
+
+pkg_check_modules(appfw_pkgs REQUIRED modes dlog capi-base-common capi-appfw-application)
+INCLUDE_DIRECTORIES(${appfw_pkgs_INCLUDE_DIRS})
+LINK_DIRECTORIES(${appfw_pkgs_LIBRARY_DIRS})
+
+ADD_LIBRARY(${APPFW_PLUGIN} SHARED ${APPFW_SRCS})
+TARGET_LINK_LIBRARIES(${APPFW_PLUGIN} ${appfw_pkgs_LIBRARIES})
+SET_TARGET_PROPERTIES(${APPFW_PLUGIN} PROPERTIES NO_SONAME 1 )
+INSTALL(TARGETS ${APPFW_PLUGIN} DESTINATION ${MODES_PLUGIN_DEFAULT_DIR})
* limitations under the License.
*/
#include <string>
-#include <map>
-#include <utility>
#include <modes_errors.h>
#include <bluetooth.h>
#include <Plugin.h>
BuildRequires: pkgconfig(modes)
BuildRequires: modes-plugin-devel
BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(capi-appfw-application)
BuildRequires: pkgconfig(capi-base-common)
+BuildRequires: pkgconfig(libxml-2.0)
BuildRequires: pkgconfig(capi-network-wifi-manager)
BuildRequires: pkgconfig(capi-network-bluetooth)
BuildRequires: pkgconfig(vconf)
%define modes_plugin_dir %{_libdir}/modes-plugins
%define modes_test_dir %{_bindir}/%{name}
+%define modes_data_dir %{_datadir}/modes
%prep
%setup -q
%install
%make_install
+mkdir -p %{buildroot}%{modes_data_dir}/rule
+install -m 0644 xml/*_rule.xml %{buildroot}%{modes_data_dir}/rule/
%check
-#TBD
+pushd xml
+xmllint --noout --schema %{modes_data_dir}/xsd/tizen_action_rule.xsd tizen_action_rule.xml
+popd
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%manifest %{name}.manifest
%{modes_plugin_dir}/*.so
+%{modes_data_dir}/rule/*
%license LICENSE.APLv2
%files unittests
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE")
ADD_DEFINITIONS("-DMDS_TEST")
-pkg_check_modules(test_pkgs REQUIRED modes dlog capi-network-wifi-manager capi-network-bluetooth gmock)
+pkg_check_modules(test_pkgs REQUIRED modes dlog capi-network-wifi-manager capi-network-bluetooth gmock capi-appfw-application)
INCLUDE_DIRECTORIES(${test_pkgs_INCLUDE_DIRS})
LINK_DIRECTORIES(${test_pkgs_LIBRARY_DIRS})
ADD_EXECUTABLE(${BT_PLUGIN_TEST} ${BT_SRCS})
TARGET_LINK_LIBRARIES(${BT_PLUGIN_TEST} ${test_pkgs_LIBRARIES} dl)
INSTALL(TARGETS ${BT_PLUGIN_TEST} DESTINATION ${TEST_INSTALL_DIR})
+#===================================================================#
+SET(APPFW_SRC_DIR "${CMAKE_SOURCE_DIR}/appfw" )
+SET(APPFW_PLUGIN_TEST "modes-gtest-appfw")
+FILE(GLOB APPFW_SRCS ${APPFW_SRC_DIR}/*.cpp)
+SET(APPFW_SRCS ${APPFW_SRCS} "mdsp_appfw_main.cpp")
+
+ADD_EXECUTABLE(${APPFW_PLUGIN_TEST} ${APPFW_SRCS})
+TARGET_LINK_LIBRARIES(${APPFW_PLUGIN_TEST} ${test_pkgs_LIBRARIES} dl)
+INSTALL(TARGETS ${APPFW_PLUGIN_TEST} DESTINATION ${TEST_INSTALL_DIR})
--- /dev/null
+/*
+ * Copyright (c) 2019 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.
+ */
+#include <glib.h>
+#include <string>
+#include <gtest/gtest.h>
+#include <Plugin.h>
+#include <modes.h>
+#include <modes_errors.h>
+#include "plugin-log.h"
+#include "plugin-def.h"
+
+MODES_NAMESPACE_USE;
+
+extern "C" API Plugin *objectCreate(void);
+extern "C" API void objectDelete(Plugin *plugin);
+
+TEST(PluginTest, setPluginAppfw)
+{
+ int ret;
+ Plugin *plugin = objectCreate();
+
+ ret = plugin->set("launch", std::string("org.tizen.w-stopwatch"), nullptr);
+ EXPECT_EQ(ret, MODES_ERROR_NONE);
+
+ objectDelete(plugin);
+}
+
+int main(int argc, char **argv) {
+ testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
* limitations under the License.
*/
#include <string>
-#include <map>
-#include <utility>
#include <modes_errors.h>
#include <wifi-manager.h>
#include <Plugin.h>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<tizenModes xmlns="http://www.tizen.org" version="5.5">
+ <actionRule>
+ <rule name="wifi.power" type="bool" since="5.5" plugin="wifi-manager">
+ <alias name="on">1</alias>
+ <alias name="off">0</alias>
+ <defaultVal>0</defaultVal>
+ <desc>wifi On/Off</desc>
+ <domain>Network & Connectivity</domain>
+ </rule>
+ <rule name="bluetooth.power" type="bool" since="5.5" plugin="bluetooth">
+ <alias name="on">1</alias>
+ <alias name="off">0</alias>
+ <defaultVal>0</defaultVal>
+ <desc>bluetooth On/Off</desc>
+ <domain>Network & Connectivity</domain>
+ </rule>
+ <rule name="bluetooth.audioConnect" type="string" since="5.5" plugin="bluetooth">
+ <defaultVal>0:0:0:0:0:0</defaultVal>
+ <desc>bluetooth Audio Connect</desc>
+ <domain>Network & Connectivity</domain>
+ </rule>
+ <rule name="sensord.changeAccuracy" type="int" since="5.5" plugin="sensor-fw">
+ <defaultVal>100</defaultVal>
+ <conflict>sensord.exactness</conflict>
+ <desc>Sensor Accuracy</desc>
+ <domain>System</domain>
+ </rule>
+ <rule name="sensord.exactness" type="int" since="5.5" plugin="sensor-fw">
+ <defaultVal>100</defaultVal>
+ <conflict>sensord.changeAccuracy</conflict>
+ <desc>Sensor Exactness</desc>
+ <domain>System</domain>
+ </rule>
+ <rule name="vconf.db.setting.psmode" type="int" since="5.5" plugin="vconf">
+ <alias name="SETTING_PSMODE_NORMAL">0</alias>
+ <alias name="SETTING_PSMODE_POWERFUL">1</alias>
+ <alias name="SETTING_PSMODE_ADVISOR">1</alias>
+ <alias name="SETTING_PSMODE_SURVIVAL">2</alias>
+ <alias name="SETTING_PSMODE_EMERGENCY">2</alias>
+ <alias name="SETTING_PSMODE_WEARABLE">3</alias>
+ <alias name="SETTING_PSMODE_WEARABLE_ENHANCED">4</alias>
+ <alias name="SETTING_PSMODE_MAX">0</alias>
+ <defaultVal>0</defaultVal>
+ <conflict>sensord.changeAccuracy</conflict>
+ <desc>test</desc>
+ <domain>System</domain>
+ </rule>
+ <rule name="vconf.db.bluetooth.status" type="int" since="5.5" plugin="vconf">
+ <alias name="VCONFKEY_BT_STATUS_OFF">0</alias>
+ <alias name="VCONFKEY_BT_STATUS_ON">1</alias>
+ <alias name="VCONFKEY_BT_STATUS_BT_VISIBLE">2</alias>
+ <alias name="VCONFKEY_BT_STATUS_TRANSFER">4</alias>
+ <defaultVal>0</defaultVal>
+ <desc>test</desc>
+ <domain>Network & Connectivity</domain>
+ </rule>
+ <rule name="browser.url" type="string" since="5.5" plugin="web">
+ <defaultVal>about:blank</defaultVal>
+ <desc>browser</desc>
+ <domain>Web Framework</domain>
+ </rule>
+ <rule name="display.nightLight" type="int" since="5.5" plugin="display">
+ <defaultVal>70</defaultVal>
+ <conflict>display.autoLight</conflict>
+ <desc>It makes the screen color warmer.</desc>
+ <domain>System</domain>
+ </rule>
+ <rule name="appfw.launch" type="string" since="5.5" plugin="appfw">
+ <defaultVal>0</defaultVal>
+ <desc>Launch App</desc>
+ <domain>App Framework</domain>
+ </rule>
+ <rule name="test.printInt" type="int" since="5.5" plugin="test">
+ <defaultVal>0</defaultVal>
+ <desc>It prints integerv value</desc>
+ <domain>System</domain>
+ </rule>
+ <rule name="test.printBool" type="bool" since="5.5" plugin="test">
+ <defaultVal>0</defaultVal>
+ <desc>It prints boolean value</desc>
+ <domain>System</domain>
+ </rule>
+ </actionRule>
+</tizenModes>