/*
- * Copyright 2016 Samsung Electronics Co., Ltd
+ * Copyright 2017 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
profile = wearable-3.0
# C/CPP Sources
-USER_SRCS = src/App/src/App.cpp src/main.cpp src/Common/src/PathUtils.cpp src/Common/src/Window.cpp src/Common/src/Logger.cpp src/Common/src/View.cpp
+USER_SRCS = src/App/src/App.cpp src/App/src/TaskMngrService.cpp src/main.cpp src/Common/src/PathUtils.cpp src/Common/src/Window.cpp src/Common/src/Logger.cpp src/App/src/MainController.cpp src/App/src/MainLayout.cpp src/Common/src/View.cpp
# EDC Sources
USER_EDCS =
USER_INC_DIRS = $(USER_C_INC_DIRS) $(USER_CPP_INC_DIRS)
# User Library Path
-USER_LIB_DIRS = lib
+USER_LIB_DIRS =
# EDC Resource Path
USER_EDCS_IMAGE_DIRS = ${OUTPUT_DIR} edje/images
# EDC Flags
USER_EXT_EDC_KEYS = EDC0
-USER_EXT_EDC0_EDCS = res/edje/taskmanager.edc
+USER_EXT_EDC0_EDCS = res/edje/main_layout.edc
USER_EXT_EDC0_EDCS_IMAGE_DIRS = ${OUTPUT_DIR} edje/images
USER_EXT_EDC0_EDCS_SOUND_DIRS = ${OUTPUT_DIR} edje/sounds
USER_EXT_EDC0_EDCS_FONT_DIRS = ${OUTPUT_DIR} edje/fonts
/*
- * Task Manager
- * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ * Copyright 2017 Samsung Electronics Co., Ltd
*
- * Licensed under the Flora License, Version 1.1 (the License);
+ * Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
+ * 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.
/*
- * Copyright 2016 Samsung Electronics Co., Ltd
+ * Copyright 2017 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
#include <app.h>
#include <app_control.h>
-namespace TaskMngr
-{
+namespace TaskMngr {
class Window;
class TaskMngrService;
class MainController;
- class App
- {
+ class App {
public:
static App &getInst();
int start(int argc, char *argv[]);
/*
- * Copyright 2016 Samsung Electronics Co., Ltd
+ * Copyright 2017 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
#include "MainLayout.h"
-namespace TaskMngr
-{
+namespace TaskMngr {
class MainController
- : public MainLayout
- {
+ : public MainLayout {
public:
MainController(Evas_Object *parent);
virtual ~MainController();
/*
- * Copyright 2016 Samsung Electronics Co., Ltd
+ * Copyright 2017 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
#include "View.h"
-namespace TaskMngr
-{
+namespace TaskMngr {
class MainLayout
- : public View
- {
+ : public View {
public:
MainLayout(Evas_Object *parent);
virtual ~MainLayout();
/*
- * Copyright 2016 Samsung Electronics Co., Ltd
+ * Copyright 2017 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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.
+ */
+
+#ifndef TaskMngrService_h_
+#define TaskMngrService_h_
+
+#include <string>
+#include <vector>
+#include <app_info.h>
+#include <rua.h>
+
+namespace TaskMngr {
+ struct AppInfo {
+ std::string pkgid;
+ std::string appid;
+ std::string instanceId;
+ std::string name;
+ std::string icon;
+ std::string uri;
+ time_t launchTime;
+ };
+
+ class TaskMngrService {
+ public:
+ TaskMngrService();
+ ~TaskMngrService();
+
+ /**
+ * @brief Shutdowns given currently running application.
+ *
+ * @param[in] appid The ID of the application
+ * @param[in] instance_id The instance ID of the application
+ *
+ * @return true or false on failure
+ */
+ bool killApp(const std::string &appid, const std::string &instanceId = std::string());
+ /**
+ * @brief Resumes the given application.
+ *
+ * @param[in] appid The ID of the application
+ * @param[in] uri The URI of the data
+ *
+ * @return true or false on failure
+ */
+ bool launchApp(const std::string &appid, const std::string &uri = std::string());
+ /**
+ * @brief Get or create list of launched applications
+ *
+ * @return list with information about launched applications
+ */
+ std::vector<AppInfo> getAppInfo();
+
+ private:
+ TaskMngrService(const TaskMngrService&) = delete;
+ TaskMngrService& operator=(TaskMngrService) = delete;
+
+ void init();
+ void finit();
+ void filterCreate();
+ void findAndAppendApp();
+ bool appInfoCb(app_info_h app_info);
+ void fillAppInfoList(char **table, int &rows, int &cols);
+
+ private:
+ rua_rec m_RuaRecord;
+ app_info_filter_h m_Filter;
+ std::vector<AppInfo> m_AppInfo;
+ };
+}
+
+#endif /* TaskMngrService_h_ */
/*
- * Copyright 2016 Samsung Electronics Co., Ltd
+ * Copyright 2017 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
/*
- * Copyright 2016 Samsung Electronics Co., Ltd
+ * Copyright 2017 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
/*
- * Copyright 2016 Samsung Electronics Co., Ltd
+ * Copyright 2017 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
void MainLayout::showNoContents(bool show)
{
- if (show && !m_pNoContent)
- {
+ if (show && !m_pNoContent) {
m_pNoContent = elm_layout_add(getEo());
elm_layout_theme_set(getEo(), "layout", "nocontents", "text");
setContent(m_pNoContent, "swl.bg");
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 "TaskMngrService.h"
+#include "Logger.h"
+#include "Callback.h"
+
+#include <app_manager_extension.h>
+#include <utility>
+#include <app_control.h>
+#include <app_manager.h>
+
+using namespace TaskMngr;
+
+TaskMngrService::TaskMngrService()
+ : m_RuaRecord()
+ , m_Filter()
+{
+ init();
+}
+
+TaskMngrService::~TaskMngrService()
+{
+ finit();
+}
+
+bool TaskMngrService::killApp(const std::string &appid, const std::string &instanceId)
+{
+ TRACE;
+ int ret = 0;
+ bool running = false;
+ app_context_h context = nullptr;
+
+ if (instanceId.empty()) {
+ app_manager_is_running(appid.c_str(), &running);
+ if (running) {
+ app_manager_get_app_context(appid.c_str(), &context);
+ } else {
+ rua_delete_history_with_instance_id(appid.c_str(), nullptr);
+ return false;
+ }
+ } else {
+ app_manager_get_app_context_by_instance_id(appid.c_str(), instanceId.c_str(), &context);
+ }
+
+ if (context) {
+ app_manager_terminate_app(context);
+ app_context_destroy(context);
+ }
+
+ LOG("terminate app = ", appid);
+ ret = rua_delete_history_with_instance_id(appid.c_str(), instanceId.c_str());
+
+ return !ret;
+}
+
+bool TaskMngrService::launchApp(const std::string &appid, const std::string &uri)
+{
+ TRACE;
+ int ret = 0;
+ app_control_h service = nullptr;
+
+ app_control_create(&service);
+ if (!service)
+ return false;
+
+ app_control_set_operation(service, APP_CONTROL_OPERATION_MAIN);
+ app_control_set_app_id(service, appid.c_str());
+
+ if (!uri.empty())
+ app_control_set_uri(service, uri.c_str());
+
+ ret = app_control_send_launch_request(service, nullptr, nullptr);
+ app_control_destroy(service);
+ if (ret != APP_CONTROL_ERROR_NONE) {
+ LOG_ERROR("Failed to send launch request");
+ return false;
+ }
+
+ return true;
+}
+
+std::vector<AppInfo> TaskMngrService::getAppInfo()
+{
+ m_AppInfo.clear();
+
+ char **table = nullptr;
+ int rows = 0;
+ int cols = 0;
+
+ if (rua_history_load_db(&table, &rows, &cols)) {
+ LOG_ERROR("rua_history_load_db failed!");
+ }
+
+ if (table) {
+ fillAppInfoList(table, rows, cols);
+ rua_history_unload_db(&table);
+ }
+
+ return m_AppInfo;
+}
+
+void TaskMngrService::init()
+{
+ if (rua_init()) {
+ LOG_ERROR("rua_init failed!");
+ }
+
+ filterCreate();
+}
+
+void TaskMngrService::finit()
+{
+ app_info_filter_destroy(m_Filter);
+ rua_fini();
+}
+
+void TaskMngrService::filterCreate()
+{
+ app_info_filter_create(&m_Filter);
+ app_info_filter_add_bool(m_Filter, PACKAGE_INFO_PROP_APP_TASKMANAGE, true);
+}
+
+void TaskMngrService::findAndAppendApp()
+{
+ app_info_filter_add_string(m_Filter, PACKAGE_INFO_PROP_APP_ID, m_RuaRecord.pkg_name);
+ app_info_filter_foreach_appinfo(m_Filter, makeCbLast(&TaskMngrService::appInfoCb), this);
+}
+
+bool TaskMngrService::appInfoCb(app_info_h appInfo)
+{
+ AppInfo item;
+ char *variable = nullptr;
+ int ret = 0;
+
+ app_info_get_app_id(appInfo, &variable);
+ if (variable) {
+ item.appid = variable;
+ free(variable);
+ variable = nullptr;
+ }
+
+ app_info_get_package(appInfo, &variable);
+ if (variable) {
+ item.pkgid = variable;
+ free(variable);
+ variable = nullptr;
+ }
+
+ if (m_RuaRecord.uri)
+ item.uri = m_RuaRecord.uri;
+
+ if (m_RuaRecord.instance_id)
+ item.instanceId = m_RuaRecord.instance_id;
+
+ if (m_RuaRecord.instance_name) {
+ item.name = m_RuaRecord.instance_name;
+ } else {
+ app_info_get_label(appInfo, &variable);
+ if (variable) {
+ item.name = variable;
+ free(variable);
+ variable = nullptr;
+ }
+ }
+
+ if (m_RuaRecord.icon) {
+ item.icon = m_RuaRecord.icon;
+ } else {
+ ret = app_info_get_icon(appInfo, &variable);
+ if (variable) {
+ item.icon = variable;
+ free(variable);
+ variable = nullptr;
+ }
+ }
+ item.launchTime = m_RuaRecord.launch_time;
+
+ if (item.pkgid == "org.tizen.task-mgr" || item.pkgid == "org.tizen.taskmanager") {
+ LOG_ERROR("ignoring Recents app");
+ return false;
+ }
+
+ m_AppInfo.push_back(std::move(item));
+
+ return true;
+}
+
+void TaskMngrService::fillAppInfoList(char **table, int &rows, int &cols)
+{
+ for (int row = 0; row < rows; ++row) {
+ rua_history_get_rec(&m_RuaRecord, table, rows, cols, row);
+ findAndAppendApp();
+ }
+}
/*
- * Copyright 2016 Samsung Electronics Co., Ltd
+ * Copyright 2017 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
#include "Config.h"
#include <Elementary.h>
-namespace TaskMngr
-{
+namespace TaskMngr {
/**
* @brief Wrapper for Elm_Interface_Atspi_Accessible interface (Screen reader)
*/
- class AtspiAccessibleInterface
- {
+ class AtspiAccessibleInterface {
public:
AtspiAccessibleInterface(Elm_Interface_Atspi_Accessible *obj);
void wrap(Elm_Interface_Atspi_Accessible *obj);
/*
- * Copyright 2016 Samsung Electronics Co., Ltd
+ * Copyright 2017 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
#include "PathUtils.h"
#include "AtspiAccessibleInterface.h"
-namespace TaskMngr
-{
+namespace TaskMngr {
/**
* @brief Basic interface for all visual objects used across the whole application.
*/
- class BaseView
- {
+ class BaseView {
public:
BaseView();
virtual ~BaseView() {};
/*
- * Copyright 2016 Samsung Electronics Co., Ltd
+ * Copyright 2017 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
struct Callback;
template <class R, class C, class... A>
-struct Callback<R(C::*)(A...)>
-{
+struct Callback<R(C::*)(A...)> {
using M = R(C::*)(A...);
template <M m>
/*
- * Copyright 2016 Samsung Electronics Co., Ltd
+ * Copyright 2017 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
#include <stdio.h>
#include <stdarg.h>
-namespace TaskMngr
-{
+namespace TaskMngr {
// Translatable Text
- struct TText
- {
+ struct TText {
explicit TText(const char *stringId, const char *domainName)
: m_pDomain(domainName)
, m_pMsg(stringId)
};
// dgettext
- struct DText
- {
+ struct DText {
explicit DText(const char *stringId, const char *domainName)
{
m_pMsg = dgettext(domainName, stringId);
/*
- * Copyright 2016 Samsung Electronics Co., Ltd
+ * Copyright 2017 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
/*
- * Copyright 2016 Samsung Electronics Co., Ltd
+ * Copyright 2017 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
#include <string>
#include "Resource.h"
-namespace TaskMngr
-{
- namespace PathUtils
- {
+namespace TaskMngr {
+ namespace PathUtils {
/**
* @brief Gets the absolute path to file in the application resource directory.
* @param[in] path to file in res. dir (without slash at begin/end)
/*
- * Copyright 2016 Samsung Electronics Co., Ltd
+ * Copyright 2017 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
#include <Elementary.h>
-namespace TaskMngr
-{
+namespace TaskMngr {
/**
* @brief Wraps all basic Evas_Object operations and manages automatic self-removal by EVAS_CALLBACK_FREE and EVAS_CALLBACK_DEL events.
*/
class View
- : public BaseView
- {
+ : public BaseView {
public:
View();
/*
- * Copyright 2016 Samsung Electronics Co., Ltd
+ * Copyright 2017 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
#include "View.h"
-namespace TaskMngr
-{
+namespace TaskMngr {
class Window
- : public View
- {
+ : public View {
public:
Window();
virtual ~Window();
/*
- * Copyright 2016 Samsung Electronics Co., Ltd
+ * Copyright 2017 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
#include "Logger.h"
-namespace
-{
+namespace {
const std::string enterFraseFormat = "%s: %s(%d) -> [ENTER]";
const std::string leaveFraseFormat = "%s: %s -> [LEAVE]";
const log_priority defaultPriority = DLOG_DEBUG;
/*
- * Copyright 2016 Samsung Electronics Co., Ltd
+ * Copyright 2017 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
{
std::string res;
static std::string basePath;
- if (basePath.empty())
- {
+ if (basePath.empty()) {
char *path = app_get_resource_path();
- if (path)
- {
+ if (path) {
basePath = path;
free(path);
}
{
std::string res;
static std::string basePath;
- if (basePath.empty())
- {
+ if (basePath.empty()) {
char *path = app_get_data_path();
- if (path)
- {
+ if (path) {
basePath = path;
free(path);
}
{
std::string res;
char* resPath = app_get_resource_path();
- if (resPath)
- {
+ if (resPath) {
res = resPath;
free(resPath);
}
std::string getLocalePath()
{
std::string resPath(getResourcePath());
- if (!resPath.empty())
- {
+ if (!resPath.empty()) {
resPath.append("locale");
}
static bool storageCb(int storageId, storage_type_e type, storage_state_e state, const char *path, void *userData)
{
- if (type == STORAGE_TYPE_INTERNAL)
- {
+ if (type == STORAGE_TYPE_INTERNAL) {
int *internalStorage = (int *)userData;
*internalStorage = storageId;
return false;
if (error == STORAGE_ERROR_NONE)
storage_get_directory(storageId, STORAGE_DIRECTORY_DOWNLOADS, &dirPath);
- if (dirPath)
- {
+ if (dirPath) {
downloadPath = dirPath;
free(dirPath);
}
/*
- * Copyright 2016 Samsung Electronics Co., Ltd
+ * Copyright 2017 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
using namespace TaskMngr;
-namespace
-{
+namespace {
const char *thisKey = "this";
}
void View::setEventCb(Evas_Callback_Type type)
{
Evas_Object_Event_Cb cb = getCb(type);
- if (cb)
- {
+ if (cb) {
evas_object_event_callback_add(m_pEo, type, cb, this);
} else {
LOG_ERROR("Not implemented");
void View::setEo(Evas_Object *eo)
{
- if (m_pEo)
- {
+ if (m_pEo) {
LOG_ERROR("m_pEo not null");
assert(false);
}
BaseView::setEo(eo);
- if (eo)
- {
+ if (eo) {
setData(this);
setEventCb(EVAS_CALLBACK_FREE);
setEventCb(EVAS_CALLBACK_DEL);
void View::unsetEventCb(Evas_Callback_Type type)
{
Evas_Object_Event_Cb cb = getCb(type);
- if (cb)
- {
+ if (cb) {
evas_object_event_callback_del(m_pEo, type, cb);
} else {
LOG_ERROR("Not implemented");
std::string res;
char *markup = elm_entry_markup_to_utf8(str);
- if (markup)
- {
+ if (markup) {
res = markup;
free(markup);
}
std::string res;
char *markup = elm_entry_utf8_to_markup(str);
- if (markup)
- {
+ if (markup) {
res = markup;
free(markup);
}
/*
- * Copyright 2016 Samsung Electronics Co., Ltd
+ * Copyright 2017 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
/*
- * Copyright 2016 Samsung Electronics Co., Ltd
+ * Copyright 2017 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns="http://tizen.org/ns/packages" api-version="3.0" package="org.tizen.taskmanager" version="1.0.0">
- <profile name="wearable" />
- <ui-application appid="org.tizen.taskmanager" exec="taskmanager" type="capp" multiple="false" taskmanage="true" nodisplay="false" hw-acceleration="on">
- <icon>taskmanager.png</icon>
- <label>taskmanager</label>
- </ui-application>
+ <profile name="wearable" />
+ <ui-application appid="org.tizen.taskmanager" exec="taskmanager" type="capp" multiple="false" taskmanage="true" nodisplay="false" hw-acceleration="on">
+ <icon>taskmanager.png</icon>
+ <label>taskmanager</label>
+ </ui-application>
+ <privileges>
+ <privilege>http://tizen.org/privilege/packagemanager.clearcache</privilege>
+ <privilege>http://tizen.org/privilege/appmanager.kill.bgapp</privilege>
+ <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+ <privilege>http://tizen.org/privilege/packagemanager.info</privilege>
+ </privileges>
</manifest>