ADD_SUBDIRECTORY(wifi)
ADD_SUBDIRECTORY(vconf)
-ADD_SUBDIRECTORY(appfw)
+ADD_SUBDIRECTORY(app)
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 "AppAction.h"
+#include <modes_errors.h>
+
+MODES_NAMESPACE_USE;
+
+AppAction::AppAction()
+{
+}
+
+AppAction::~AppAction()
+{
+}
+
+int AppAction::set(const std::string &val)
+{
+ return MODES_ERROR_NOT_SUPPORTED;
+}
+
+int AppAction::undo(const std::string &val)
+{
+ return MODES_ERROR_NOT_SUPPORTED;
+}
+
+int AppAction::get(std::string *val)
+{
+ return MODES_ERROR_NOT_SUPPORTED;
+}
+
+void AppAction::setName(std::string name)
+{
+ this->name = name;
+}
+
+std::string AppAction::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 AppAction {
+public:
+ AppAction();
+ virtual ~AppAction();
+
+ std::string getName();
+ virtual int set(const std::string &val);
+ virtual int get(std::string *val);
+ virtual int undo(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 "AppActionLaunch.h"
+
+#include <algorithm>
+#include <app_control.h>
+#include <app_manager.h>
+#include <app_manager_extension.h>
+#include <modes_errors.h>
+#include "plugin-log.h"
+
+MODES_NAMESPACE_USE;
+
+const std::string AppActionLaunch::NAME = "launch";
+std::list<std::string> AppActionLaunch::appidList;
+void AppActionLaunch::appContextStatusCallback(app_context_h app_context, app_context_status_e status, void *user_data)
+{
+ char *appid = NULL;
+ DBG("appContextStatusCallback(status:%d)", status);
+ if (app_context_get_app_id(app_context, &appid) != APP_MANAGER_ERROR_NONE) {
+ ERR("Failed to get appid\n");
+ return;
+ }
+
+ DBG("app_context_cb(appid:%s)", appid);
+ if (APP_CONTEXT_STATUS_TERMINATED == status) {
+ DBG("APP_CONTEXT_STATUS_TERMINATED appid : %s\n", appid);
+ appidList.remove(appid);
+ }
+
+ free(appid);
+ return;
+}
+
+AppActionLaunch::AppActionLaunch()
+{
+ setName(NAME);
+}
+
+int AppActionLaunch::set(const std::string &val)
+{
+ DBG("id(%s)", val.c_str());
+
+ auto found = std::find(appidList.begin(), appidList.end(), val);
+
+ if (found == appidList.end())
+ {
+ bool running;
+ app_manager_is_running(val.c_str(), &running);
+
+ if (running) {
+ ERR("It's already running before started mode-supervisor daemon");
+ return MODES_ERROR_CONFLICT;
+ }
+
+ 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);
+
+ appidList.push_back(val);
+
+ DBG("APP_CONTEXT_EVENT_LAUNCHED(appid : %s) added list\n", val.c_str());
+
+ ret = app_manager_set_app_context_status_cb(AppActionLaunch::appContextStatusCallback, val.c_str(), NULL);
+ if (APP_MANAGER_ERROR_NONE != ret) {
+ ERR("app_manager_set_app_context_status_cb() Fail(%s)", get_error_message(ret));
+ return MODES_ERROR_IO_ERROR;
+ }
+
+ appID = val;
+ }
+
+ return MODES_ERROR_NONE;
+}
+
+int AppActionLaunch::get(std::string *val)
+{
+ if(val)
+ *val = appID;
+ return MODES_ERROR_NONE;
+}
+
+int AppActionLaunch::undo(const std::string &val)
+{
+ bool running;
+ app_context_h runAppContext;
+
+ app_manager_is_running(val.c_str(), &running);
+ if (!running) {
+ DBG("It's NOT running");
+ return MODES_ERROR_NONE;
+ }
+
+ int ret = app_manager_unset_app_context_status_cb(AppActionLaunch::appContextStatusCallback, val.c_str());
+ if (APP_MANAGER_ERROR_NONE != ret) {
+ ERR("app_manager_unset_app_context_status_cb() Fail(%s)", get_error_message(ret));
+ return MODES_ERROR_IO_ERROR;
+ }
+
+ appidList.remove(val);
+
+ ret = app_manager_get_app_context(val.c_str(), &runAppContext);
+ if (APP_MANAGER_ERROR_NONE != ret) {
+ ERR("app_manager_get_app_context(%s) Fail(%s)", val.c_str(), get_error_message(ret));
+ return MODES_ERROR_IO_ERROR;
+ }
+ ret = app_manager_terminate_app(runAppContext);
+ if (APP_MANAGER_ERROR_NONE != ret) {
+ ERR("app_manager_terminate_app() Fail(%s)", get_error_message(ret));
+ return MODES_ERROR_IO_ERROR;
+ }
+ 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 <list>
+#include <string>
+#include <app_manager.h>
+#include <app_manager_extension.h>
+#include "AppAction.h"
+
+MODES_NAMESPACE_BEGIN
+
+class AppActionLaunch : public AppAction {
+public:
+ AppActionLaunch();
+
+ virtual int set(const std::string &val) override;
+ virtual int get(std::string *val) override;
+ virtual int undo(const std::string &val) override;
+
+ static const std::string NAME;
+ static void appContextStatusCallback(app_context_h app_context, app_context_status_e status, void *user_data);
+
+private:
+ std::string appID;
+ static std::list<std::string> appidList;
+};
+
+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 "AppFactory.h"
+#include "plugin-log.h"
+#include "AppActionLaunch.h"
+
+MODES_NAMESPACE_USE;
+
+AppFactory::AppFactory()
+{
+ actionMap[AppActionLaunch::NAME] = APP_ACT_LAUNCH;
+}
+
+AppAction* AppFactory::createAction(const std::string &key)
+{
+ auto search = actionMap.find(key);
+ if (search == actionMap.end()) {
+ ERR("No AppAction(%s)", key.c_str());
+ return nullptr;
+ }
+
+ switch (search->second) {
+ case APP_ACT_LAUNCH:
+ AppActionLaunch *appActionLaunch = new AppActionLaunch();
+ return appActionLaunch;
+ break;
+ }
+
+ return nullptr;
+}
+
+void AppFactory::destroyAction(AppAction *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 <map>
+#include <string>
+#include "AppAction.h"
+
+MODES_NAMESPACE_BEGIN
+
+class AppFactory {
+public:
+ AppFactory();
+ ~AppFactory() = default;
+
+ AppAction* createAction(const std::string &key);
+ void destroyAction(AppAction *action);
+private:
+ enum actionKey{
+ APP_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 <modes_errors.h>
+#include <Plugin.h>
+#include "plugin-log.h"
+#include "AppFactory.h"
+
+MODES_NAMESPACE_USE;
+
+class AppPlugin : public Plugin {
+public:
+ AppPlugin();
+ ~AppPlugin();
+
+ int set(const std::string &key, const std::string &val, std::string *oldVal) override;
+ int undo(const std::string &key, const std::string &val) override;
+
+private:
+ AppFactory appFactory;
+};
+
+extern "C" API Plugin *objectCreate(void)
+{
+ return new AppPlugin;
+}
+
+extern "C" API void objectDelete(Plugin *plugin)
+{
+ delete plugin;
+}
+
+AppPlugin::AppPlugin()
+{
+ setName("app");
+}
+
+AppPlugin::~AppPlugin()
+{
+}
+
+int AppPlugin::set(const std::string &key, const std::string &val, std::string *oldVal)
+{
+ AppAction *action = appFactory.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 appRet = action->set(val);
+
+ if (oldVal)
+ action->get(oldVal);
+
+ appFactory.destroyAction(action);
+ return appRet;
+}
+
+int AppPlugin::undo(const std::string &key, const std::string &val)
+{
+ AppAction *action = appFactory.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 appRet = action->undo(val);
+ appFactory.destroyAction(action);
+ return appRet;
+}
--- /dev/null
+SET(APP_PLUGIN "modes-plugin-app")
+
+FILE(GLOB APP_SRCS *.cpp)
+
+PKG_CHECK_MODULES(app_pkgs REQUIRED modes dlog capi-base-common capi-appfw-application capi-appfw-app-manager aul)
+INCLUDE_DIRECTORIES(${app_pkgs_INCLUDE_DIRS})
+LINK_DIRECTORIES(${app_pkgs_LIBRARY_DIRS})
+
+ADD_LIBRARY(${APP_PLUGIN} SHARED ${APP_SRCS})
+TARGET_LINK_LIBRARIES(${APP_PLUGIN} ${app_pkgs_LIBRARIES})
+SET_TARGET_PROPERTIES(${APP_PLUGIN} PROPERTIES NO_SONAME 1 )
+INSTALL(TARGETS ${APP_PLUGIN} DESTINATION ${MODES_PLUGIN_DEFAULT_DIR})
+INSTALL(FILES tizen_app_rule.xml DESTINATION ${MODES_ACTIONRULE_DEFAULT_DIR})
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<tizenModes xmlns="http://www.tizen.org" version="5.5">
+ <actionRule>
+ <rule name="app.launch" type="string" since="5.5" plugin="app">
+ <desc>Launch App</desc>
+ <domain>App Framework</domain>
+ </rule>
+ </actionRule>
+</tizenModes>
+++ /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;
-}
-
-int AppfwAction::undo(const std::string &val)
-{
- return MODES_ERROR_NOT_SUPPORTED;
-}
-
-int AppfwAction::get(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);
- virtual int get(std::string *val);
- virtual int undo(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 <algorithm>
-#include <app_control.h>
-#include <app_manager.h>
-#include <app_manager_extension.h>
-#include <modes_errors.h>
-#include "plugin-log.h"
-
-MODES_NAMESPACE_USE;
-
-const std::string AppfwActionLaunch::NAME = "launch";
-std::list<std::string> AppfwActionLaunch::appidList;
-void AppfwActionLaunch::appContextStatusCallback(app_context_h app_context, app_context_status_e status, void *user_data)
-{
- char *appid = NULL;
- DBG("appContextStatusCallback(status:%d)", status);
- if (app_context_get_app_id(app_context, &appid) != APP_MANAGER_ERROR_NONE) {
- ERR("Failed to get appid\n");
- return;
- }
-
- DBG("app_context_cb(appid:%s)", appid);
- if (APP_CONTEXT_STATUS_TERMINATED == status) {
- DBG("APP_CONTEXT_STATUS_TERMINATED appid : %s\n", appid);
- appidList.remove(appid);
- }
-
- free(appid);
- return;
-}
-
-AppfwActionLaunch::AppfwActionLaunch()
-{
- setName(NAME);
-}
-
-int AppfwActionLaunch::set(const std::string &val)
-{
- DBG("id(%s)", val.c_str());
-
- auto found = std::find(appidList.begin(), appidList.end(), val);
-
- if (found == appidList.end())
- {
- bool running;
- app_manager_is_running(val.c_str(), &running);
-
- if (running) {
- ERR("It's already running before started mode-supervisor daemon");
- return MODES_ERROR_CONFLICT;
- }
-
- 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);
-
- appidList.push_back(val);
-
- DBG("APP_CONTEXT_EVENT_LAUNCHED(appid : %s) added list\n", val.c_str());
-
- ret = app_manager_set_app_context_status_cb(AppfwActionLaunch::appContextStatusCallback, val.c_str(), NULL);
- if (APP_MANAGER_ERROR_NONE != ret) {
- ERR("app_manager_set_app_context_status_cb() Fail(%s)", get_error_message(ret));
- return MODES_ERROR_IO_ERROR;
- }
-
- appID = val;
- }
-
- return MODES_ERROR_NONE;
-}
-
-int AppfwActionLaunch::get(std::string *val)
-{
- if(val)
- *val = appID;
- return MODES_ERROR_NONE;
-}
-
-int AppfwActionLaunch::undo(const std::string &val)
-{
- bool running;
- app_context_h runAppContext;
-
- app_manager_is_running(val.c_str(), &running);
- if (!running) {
- DBG("It's NOT running");
- return MODES_ERROR_NONE;
- }
-
- int ret = app_manager_unset_app_context_status_cb(AppfwActionLaunch::appContextStatusCallback, val.c_str());
- if (APP_MANAGER_ERROR_NONE != ret) {
- ERR("app_manager_unset_app_context_status_cb() Fail(%s)", get_error_message(ret));
- return MODES_ERROR_IO_ERROR;
- }
-
- appidList.remove(val);
-
- ret = app_manager_get_app_context(val.c_str(), &runAppContext);
- if (APP_MANAGER_ERROR_NONE != ret) {
- ERR("app_manager_get_app_context(%s) Fail(%s)", val.c_str(), get_error_message(ret));
- return MODES_ERROR_IO_ERROR;
- }
- ret = app_manager_terminate_app(runAppContext);
- if (APP_MANAGER_ERROR_NONE != ret) {
- ERR("app_manager_terminate_app() Fail(%s)", get_error_message(ret));
- return MODES_ERROR_IO_ERROR;
- }
- 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 <list>
-#include <string>
-#include <app_manager.h>
-#include <app_manager_extension.h>
-#include "AppfwAction.h"
-
-MODES_NAMESPACE_BEGIN
-
-class AppfwActionLaunch : public AppfwAction {
-public:
- AppfwActionLaunch();
-
- virtual int set(const std::string &val) override;
- virtual int get(std::string *val) override;
- virtual int undo(const std::string &val) override;
-
- static const std::string NAME;
- static void appContextStatusCallback(app_context_h app_context, app_context_status_e status, void *user_data);
-
-private:
- std::string appID;
- static std::list<std::string> appidList;
-};
-
-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 "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 <map>
-#include <string>
-#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 <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;
- int undo(const std::string &key, const std::string &val) 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);
-
- if (oldVal)
- action->get(oldVal);
-
- appfwFactory.destroyAction(action);
- return appfwRet;
-}
-
-int AppfwPlugin::undo(const std::string &key, const std::string &val)
-{
- 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->undo(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 capi-appfw-app-manager aul)
-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})
-INSTALL(FILES tizen_appfw_rule.xml DESTINATION ${MODES_ACTIONRULE_DEFAULT_DIR})
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<tizenModes xmlns="http://www.tizen.org" version="5.5">
- <actionRule>
- <rule name="appfw.launch" type="string" since="5.5" plugin="appfw">
- <desc>Launch App</desc>
- <domain>App Framework</domain>
- </rule>
- </actionRule>
-</tizenModes>
systemctl restart modes.service
%post unittests
-%{modes_plugin_test_dir}/modes-gtest-appfw
+%{modes_plugin_test_dir}/modes-gtest-app
%{modes_plugin_test_dir}/modes-gtest-vconf
%postun -p /sbin/ldconfig
TARGET_LINK_LIBRARIES(${BT_PLUGIN_TEST} ${test_pkgs_LIBRARIES})
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_test_appfw.cpp")
+SET(APP_SRC_DIR "${CMAKE_SOURCE_DIR}/app" )
+SET(APP_PLUGIN_TEST "modes-gtest-app")
+FILE(GLOB APP_SRCS ${APP_SRC_DIR}/*.cpp)
+SET(APP_SRCS ${APP_SRCS} "mdsp_test_app.cpp")
-ADD_EXECUTABLE(${APPFW_PLUGIN_TEST} ${APPFW_SRCS})
-TARGET_LINK_LIBRARIES(${APPFW_PLUGIN_TEST} ${test_pkgs_LIBRARIES})
-INSTALL(TARGETS ${APPFW_PLUGIN_TEST} DESTINATION ${TEST_INSTALL_DIR})
+ADD_EXECUTABLE(${APP_PLUGIN_TEST} ${APP_SRCS})
+TARGET_LINK_LIBRARIES(${APP_PLUGIN_TEST} ${test_pkgs_LIBRARIES})
+INSTALL(TARGETS ${APP_PLUGIN_TEST} DESTINATION ${TEST_INSTALL_DIR})
#===================================================================#
SET(VCONF_SRC_DIR "${CMAKE_SOURCE_DIR}/vconf" )
SET(VCONF_PLUGIN_TEST "modes-gtest-vconf")
--- /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_errors.h>
+#include <app_manager.h>
+#include <app_manager_extension.h>
+#include "plugin-def.h"
+
+MODES_NAMESPACE_USE;
+
+extern "C" API Plugin *objectCreate(void);
+extern "C" API void objectDelete(Plugin *plugin);
+
+class PluginTest : public ::testing::Test {
+protected:
+ void SetUp() override
+ {
+ loop = g_main_loop_new(NULL, FALSE);
+ }
+
+ void TearDown() override
+ {
+ g_main_loop_unref(loop);
+ loop = NULL;
+ }
+
+ static gboolean appPluginUndoConflictIdler(gpointer data)
+ {
+ app_context_h runAppContext;
+ Plugin *plugin = objectCreate();
+ result = plugin->set("launch", std::string("org.tizen.w-stopwatch"), nullptr);
+ EXPECT_EQ(MODES_ERROR_NONE, result);
+ app_manager_get_app_context("org.tizen.w-stopwatch", &runAppContext);
+ app_manager_terminate_app(runAppContext);
+ result = plugin->undo("launch", std::string("org.tizen.w-stopwatch"));
+ EXPECT_EQ(MODES_ERROR_NONE, result);
+ objectDelete(plugin);
+ g_main_loop_quit(loop);
+
+ return G_SOURCE_REMOVE;
+ }
+
+ static gboolean appPluginSetUndoTimeout(gpointer data)
+ {
+ Plugin *plugin = (Plugin *)data;
+ result = plugin->undo("launch", std::string("org.tizen.w-stopwatch"));
+ EXPECT_EQ(MODES_ERROR_NONE, result);
+ g_main_loop_quit(loop);
+ return false;
+ }
+
+ static gboolean appPluginSetUndoIdler(gpointer data)
+ {
+ Plugin *plugin = (Plugin *)data;
+ result = plugin->set("launch", std::string("org.tizen.w-stopwatch"), nullptr);
+ EXPECT_EQ(MODES_ERROR_NONE, result);
+
+ g_timeout_add(1000, appPluginSetUndoTimeout, plugin);
+ return G_SOURCE_REMOVE;
+ }
+
+ static int result;
+ static GMainLoop *loop;
+ static GThread *my_thread;
+};
+
+int PluginTest::result = 0;
+GMainLoop *PluginTest::loop = NULL;
+
+TEST_F(PluginTest, setUndoPluginApp)
+{
+ Plugin *plugin = objectCreate();
+ g_idle_add(appPluginSetUndoIdler, plugin);
+ g_main_loop_run(loop);
+ objectDelete(plugin);
+}
+
+TEST_F(PluginTest, undoConflictPluginApp)
+{
+ g_idle_add(appPluginUndoConflictIdler, nullptr);
+ g_main_loop_run(loop);
+}
+
+
+int main(int argc, char **argv) {
+ testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
+++ /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_errors.h>
-#include <app_manager.h>
-#include <app_manager_extension.h>
-#include "plugin-def.h"
-
-MODES_NAMESPACE_USE;
-
-extern "C" API Plugin *objectCreate(void);
-extern "C" API void objectDelete(Plugin *plugin);
-
-class PluginTest : public ::testing::Test {
-protected:
- void SetUp() override
- {
- loop = g_main_loop_new(NULL, FALSE);
- }
-
- void TearDown() override
- {
- g_main_loop_unref(loop);
- loop = NULL;
- }
-
- static gboolean appfwPluginUndoConflictIdler(gpointer data)
- {
- app_context_h runAppContext;
- Plugin *plugin = objectCreate();
- result = plugin->set("launch", std::string("org.tizen.w-stopwatch"), nullptr);
- EXPECT_EQ(MODES_ERROR_NONE, result);
- app_manager_get_app_context("org.tizen.w-stopwatch", &runAppContext);
- app_manager_terminate_app(runAppContext);
- result = plugin->undo("launch", std::string("org.tizen.w-stopwatch"));
- EXPECT_EQ(MODES_ERROR_NONE, result);
- objectDelete(plugin);
- g_main_loop_quit(loop);
-
- return G_SOURCE_REMOVE;
- }
-
- static gboolean appfwPluginSetUndoTimeout(gpointer data)
- {
- Plugin *plugin = (Plugin *)data;
- result = plugin->undo("launch", std::string("org.tizen.w-stopwatch"));
- EXPECT_EQ(MODES_ERROR_NONE, result);
- g_main_loop_quit(loop);
- return false;
- }
-
- static gboolean appfwPluginSetUndoIdler(gpointer data)
- {
- Plugin *plugin = (Plugin *)data;
- result = plugin->set("launch", std::string("org.tizen.w-stopwatch"), nullptr);
- EXPECT_EQ(MODES_ERROR_NONE, result);
-
- g_timeout_add(1000, appfwPluginSetUndoTimeout, plugin);
- return G_SOURCE_REMOVE;
- }
-
- static int result;
- static GMainLoop *loop;
- static GThread *my_thread;
-};
-
-int PluginTest::result = 0;
-GMainLoop *PluginTest::loop = NULL;
-
-TEST_F(PluginTest, setUndoPluginAppfw)
-{
- Plugin *plugin = objectCreate();
- g_idle_add(appfwPluginSetUndoIdler, plugin);
- g_main_loop_run(loop);
- objectDelete(plugin);
-}
-
-TEST_F(PluginTest, undoConflictPluginAppfw)
-{
- g_idle_add(appfwPluginUndoConflictIdler, nullptr);
- g_main_loop_run(loop);
-}
-
-
-int main(int argc, char **argv) {
- testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}