From e9f214b51d3353fbc8f434dedaeeee1dbd4e0e8d Mon Sep 17 00:00:00 2001 From: Lukasz Stanislawski Date: Thu, 21 Jun 2018 16:59:00 +0200 Subject: [PATCH] app-provider: API design Change-Id: I70750d272eb9cc75c4bf211ac0695346d95d2e02 --- src/CMakeLists.txt | 1 + src/appinfo-provider.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/appinfo-provider.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 109 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 224d930..89167e0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,6 +23,7 @@ SET(SRCS task.c scheduler.c config-deserializer.c + appinfo-provider.c ) ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) diff --git a/src/appinfo-provider.c b/src/appinfo-provider.c index e69de29..0f41eb9 100644 --- a/src/appinfo-provider.c +++ b/src/appinfo-provider.c @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2018 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 "appinfo-provider.h" + +void app_info_provider_app_descriptor_free(struct app_info_descriptor *descr) +{ +} + +struct app_info_descriptor *app_info_provider_app_descriptor_copy(const struct app_info_descriptor *descr) +{ + return NULL; +} + +void app_info_provider_free_app_info_descriptor_list(struct app_info_descriptor *descriptors) +{ +} + +struct app_info_descriptor *app_info_provider_get_running_applications() +{ + return NULL; +} + +int app_info_provider_find_main_pid(const char *appid) +{ + return -1; +} + +char *app_info_provider_find_appid(int pid) +{ + return NULL; +} + +int app_provider_init() +{ + return -1; +} + +void app_provider_shutdown() +{ +} + diff --git a/src/appinfo-provider.h b/src/appinfo-provider.h index 7da097e..50b8419 100644 --- a/src/appinfo-provider.h +++ b/src/appinfo-provider.h @@ -19,6 +19,58 @@ #include "report.h" -char **app_info_provider_get_running_applications(); +struct app_info_descriptor { + int pid; + char *app_id; +}; + +/** + * @brief Frees descriptors list returned by app_info_provider_get_running_applications + */ +void app_info_provider_free_app_info_descriptor_list(struct app_info_descriptor *descriptors); + +/** + * @brief Returns list of running Tizen applications. + * + * @return array of app_desciptor (NULL-terminated), NULL on error + * + * @remark function is thread safe + * @remark returned value should be released with + * @app_info_provider_free_app_info_descriptor_list + */ +struct app_info_descriptor *app_info_provider_get_running_applications(); + +/** + * @brief Searches Tizen applications main process id. + * + * @return pid (>0) on success, -1 if app_id was not found + * + * @remark function is thread safe + * @remark app_provide_init should be called beforehead + */ +int app_info_provider_find_main_pid(const char *app_id); + +/** + * @brief Searches for Tizen application app_id with given pid. + * + * @return app_id, NULL on if pid was not found or not owned by any Tizen application + * + * @remark function is thread safe + * @remark app_provide_init should be called beforehead + * @remark the returned value should be released with @free + */ +char *app_info_provider_find_app_id(int pid); + +/** + * @brief Initializes app provider internals + * + * @return 0 on success, other value on error. + */ +int app_provider_init(); + +/** + * @brief Shutdowns app provider internals + */ +void app_provider_shutdown(); #endif -- 2.7.4