From 643d893ee0f968010bb7d1102ea79cf4deda6787 Mon Sep 17 00:00:00 2001 From: jusung son Date: Mon, 19 Mar 2018 16:48:50 +0900 Subject: [PATCH] Add new APIs for complication Change-Id: If913893cd7607424845e85570f08c1b9a0a78bd3 Signed-off-by: jusung son --- CMakeLists.txt | 1 + include/aul_cmd.h | 1 + include/aul_complication.h | 31 ++++++++++++++++++ src/aul_complication.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+) mode change 100644 => 100755 CMakeLists.txt mode change 100644 => 100755 include/aul_cmd.h create mode 100755 include/aul_complication.h create mode 100755 src/aul_complication.c diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 index 8e5ec1b..1cbf8ed --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,7 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_window.h DESTINATION inclu INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_widget.h DESTINATION include/aul) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_job_scheduler.h DESTINATION include/aul) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_rpc_port.h DESTINATION include/aul) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_complication.h DESTINATION include/aul) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/aul.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/feature/preexec_list.txt DESTINATION ${SHARE_INSTALL_PREFIX}/aul ) INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/miregex DESTINATION ${SHARE_INSTALL_PREFIX}/aul ) diff --git a/include/aul_cmd.h b/include/aul_cmd.h old mode 100644 new mode 100755 index 82849bc..7a944fa --- a/include/aul_cmd.h +++ b/include/aul_cmd.h @@ -132,6 +132,7 @@ enum app_cmd { RPC_PORT_CREATE_SOCKET_PAIR = 101, RPC_PORT_NOTIFY_RPC_FINISHED = 102, + COMPLICATION_UPDATE_REQUEST = 103, APP_CMD_MAX }; diff --git a/include/aul_complication.h b/include/aul_complication.h new file mode 100755 index 0000000..ac072fe --- /dev/null +++ b/include/aul_complication.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2018 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. + */ + +#ifndef __AUL_COMPLICATION_H__ +#define __AUL_COMPLICATION_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +int aul_complication_update_request(const char *appid, const char *provider_appid, uid_t uid); + + +#ifdef __cplusplus +} +#endif + +#endif /* __AUL_COMPLICATION_H__ */ diff --git a/src/aul_complication.c b/src/aul_complication.c new file mode 100755 index 0000000..53ca32d --- /dev/null +++ b/src/aul_complication.c @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2018 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_api.h" +#include "aul_util.h" +#include "aul_sock.h" +#include "aul_complication.h" +#include "aul.h" + +#define MAX_UID_STR_BUFSZ 20 + +API int aul_complication_update_request(const char *appid, const char *provider_appid, uid_t uid) +{ + bundle *b; + int r; + char buf[MAX_UID_STR_BUFSZ]; + + if (!appid || !provider_appid) { + _E("Invalid parameter"); + return AUL_R_EINVAL; + } + + b = bundle_create(); + if (!b) { + _E("Out of memory"); + return AUL_R_ERROR; + } + + r = bundle_add(b, AUL_K_CALLER_APPID, appid); + if (r != BUNDLE_ERROR_NONE) { + _E("Failed to add appid(%s)", appid); + bundle_free(b); + return AUL_R_ERROR; + } + + r = bundle_add(b, AUL_K_APPID, provider_appid); + if (r != BUNDLE_ERROR_NONE) { + _E("Failed to add provider_appid(%s)", provider_appid); + bundle_free(b); + return AUL_R_ERROR; + } + + snprintf(buf, sizeof(buf), "%d", uid); + r = bundle_add(b, AUL_K_TARGET_UID, buf); + if (r != BUNDLE_ERROR_NONE) { + _E("Failed to add uid(%d)", uid); + bundle_free(b); + return AUL_R_ERROR; + } + + r = aul_sock_send_bundle(AUL_UTIL_PID, getuid(), + COMPLICATION_UPDATE_REQUEST, b, AUL_SOCK_QUEUE); + if (r < 0) { + _E("Failed to send request(%d:%s)", + COMPLICATION_UPDATE_REQUEST, appid); + bundle_free(b); + return r; + } + bundle_free(b); + + return AUL_R_OK; +} -- 2.7.4