From 765433dbf701c38598fa19cba518deee066618b7 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 20 Mar 2019 09:01:24 +0900 Subject: [PATCH] Add new functions for component-based application Adds: - aul_comp_status_update() - aul_comp_notify_start() - aul_comp_notify_exit() Requires: - https://review.tizen.org/gerrit/#/c/platform/core/appfw/aul-1/+/201810/ - https://review.tizen.org/gerrit/#/c/platform/core/appfw/amd/+/201830/ Change-Id: Iba57157ea5318ac4417b47b92f5dc7e357b1d16e Signed-off-by: Hwankyu Jhun --- CMakeLists.txt | 1 + include/aul_cmd.h | 4 ++ include/aul_comp_status.h | 65 +++++++++++++++++++++++++ src/aul_cmd.c | 6 +++ src/aul_comp_status.c | 120 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 196 insertions(+) create mode 100644 include/aul_comp_status.h create mode 100644 src/aul_comp_status.c diff --git a/CMakeLists.txt b/CMakeLists.txt index ade9617..6e714b1 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,6 +67,7 @@ SET(HEADERS_LIB_AUL aul_watchdog.h aul_svc_internal.h aul_key.h + aul_comp_status.h ) # Install headers, other files diff --git a/include/aul_cmd.h b/include/aul_cmd.h index 7ade269..371d8bf 100755 --- a/include/aul_cmd.h +++ b/include/aul_cmd.h @@ -141,6 +141,10 @@ enum app_cmd { APP_SEND_LAUNCH_REQUEST = 109, APP_SEND_LAUNCH_REQUEST_SYNC = 110, + COMP_NOTIFY_START = 111, + COMP_NOTIFY_EXIT = 112, + COMP_STATUS_UPDATE = 113, + APP_CMD_MAX }; diff --git a/include/aul_comp_status.h b/include/aul_comp_status.h new file mode 100644 index 0000000..83dbaec --- /dev/null +++ b/include/aul_comp_status.h @@ -0,0 +1,65 @@ +/* + * 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 + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Updates a status of a component. + * @since_tizen 5.5 + * + * @param[in] instance_id The instance ID + * @param[in] status The status + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @remarks This function is only for App Framework internally. + */ +int aul_comp_status_update(const char *instance_id, int status); + +/** + * @brief Notifies that a component is starting. + * @since_tizen 5.5 + * + * @param[in] instance_id The instance ID + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @remarks This function is only for App Framework internally. + */ +int aul_comp_notify_start(const char *instance_id); + +/** + * @brief Notifies that a component is exiting. + * @since_tizen 5.5 + * + * @param[in] instance_id The instance ID + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @remarks This function is only for App Framework internally. + */ +int aul_comp_notify_exit(const char *instance_id); + +#ifdef __cplusplus +} +#endif diff --git a/src/aul_cmd.c b/src/aul_cmd.c index 66bff26..7ba1f22 100755 --- a/src/aul_cmd.c +++ b/src/aul_cmd.c @@ -246,6 +246,12 @@ API const char *aul_cmd_convert_to_string(int cmd) return "APP_SEND_LAUNCH_REQUEST"; case APP_SEND_LAUNCH_REQUEST_SYNC: return "APP_SEND_LAUNCH_REQUEST_SYNC"; + case COMP_NOTIFY_START: + return "COMP_NOTIFY_START"; + case COMP_NOTIFY_EXIT: + return "COMP_NOTIFY_EXIT"; + case COMP_STATUS_UPDATE: + return "COMP_STATUS_UPDATE"; default: return "CUSTOM_COMMAND"; } diff --git a/src/aul_comp_status.c b/src/aul_comp_status.c new file mode 100644 index 0000000..f0dbaf2 --- /dev/null +++ b/src/aul_comp_status.c @@ -0,0 +1,120 @@ +/* + * 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. + */ + +#define _GNU_SOURCE +#include +#include + +#include +#include + +#include "aul_util.h" +#include "aul_sock.h" +#include "aul_api.h" +#include "aul.h" + +API int aul_comp_status_update(const char *instance_id, int status) +{ + char buf[32]; + bundle *b; + int r; + + if (!instance_id || status > STATUS_TERMINATE) { + _E("Invalid parameter"); + return AUL_R_EINVAL; + } + + b = bundle_create(); + if (!b) { + _E("Failed to create bundle"); + return AUL_R_ERROR; + } + + bundle_add(b, AUL_K_INSTANCE_ID, instance_id); + snprintf(buf, sizeof(buf), "%d", status); + bundle_add(b, AUL_K_STATUS, buf); + + r = aul_sock_send_bundle(AUL_UTIL_PID, getuid(), + COMP_STATUS_UPDATE, b, AUL_SOCK_NOREPLY); + if (r < 0) { + _E("Failed to send the update request. error(%d)", r); + bundle_free(b); + return r; + } + bundle_free(b); + + return AUL_R_OK; +} + +API int aul_comp_notify_start(const char *instance_id) +{ + bundle *b; + int r; + + if (!instance_id) { + _E("Invalid parameter"); + return AUL_R_EINVAL; + } + + b = bundle_create(); + if (!b) { + _E("Failed to create bundle"); + return AUL_R_ERROR; + } + + bundle_add(b, AUL_K_INSTANCE_ID, instance_id); + + r = aul_sock_send_bundle(AUL_UTIL_PID, getuid(), + COMP_NOTIFY_START, b, AUL_SOCK_NOREPLY); + if (r < 0) { + _E("Failed to send the update request. error(%d)", r); + bundle_free(b); + return r; + } + bundle_free(b); + + return AUL_R_OK; +} + +API int aul_comp_notify_exit(const char *instance_id) +{ + bundle *b; + int r; + + if (!instance_id) { + _E("Invalid parameter"); + return AUL_R_EINVAL; + } + + b = bundle_create(); + if (!b) { + _E("Failed to create bundle"); + return AUL_R_ERROR; + } + + bundle_add(b, AUL_K_INSTANCE_ID, instance_id); + + r = aul_sock_send_bundle(AUL_UTIL_PID, getuid(), + COMP_NOTIFY_EXIT, b, AUL_SOCK_NOREPLY); + if (r < 0) { + _E("Failed to send the update request. error(%d)", r); + bundle_free(b); + return r; + } + bundle_free(b); + + return AUL_R_OK; +} -- 2.7.4