From: Sung-Jin Park Date: Mon, 12 Jul 2021 10:17:20 +0000 (+0900) Subject: mmifw: add initial implementation for mmifw ipc X-Git-Tag: submit/tizen/20210914.042010~25 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0c6254e2a5401647c6a59bae3f26197856379ebd;p=platform%2Fcore%2Fuifw%2Fmmi-framework.git mmifw: add initial implementation for mmifw ipc Change-Id: I8cb7119d3d85151c17061272eaab77ff3226ad52 Signed-off-by: Sung-Jin Park --- diff --git a/src/meson.build b/src/meson.build index 592e086..a838181 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,6 +1,9 @@ mmifw_srcs = [ 'mmifw.h', 'mmifw.c', + 'mmifw-ipc.h', + 'mmifw-ipc.c', + 'mmifw-dbg.h', 'interface/mmifw_proxy.h', 'interface/mmifw_proxy.c' ] diff --git a/src/mmifw-ipc.c b/src/mmifw-ipc.c new file mode 100644 index 0000000..7b433a7 --- /dev/null +++ b/src/mmifw-ipc.c @@ -0,0 +1,148 @@ +/* +* Copyright © 2021 Samsung Electronics co., Ltd. All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include "mmifw.h" +#include "mmifw-ipc.h" +#include "mmifw-dbg.h" + +#include +#include +#include + +static rpc_port_proxy_mmifw_h _rpc_h; +static const char* _appid = ""; +static const char* _stub_appid = "mmi-manager"; +static uid_t _uid = -1; +static int _connected = 0; +static mmi_state _state = MMI_STATE_NONE; + +rpc_port_proxy_mmifw_h +mmi_ipc_get_rpc_h(void) +{ + return _rpc_h; +} + +mmi_state +mmi_ipc_get_state(void) +{ + return _state; +} + +int +mmi_ipc_get_uid(void) +{ + return _uid; +} + +bool +mmi_ipc_is_connected(void) +{ + return _connected ? true : false; +} + +const char * +mmi_ipc_get_appid(void) +{ + return _appid; +} + +const char * +mmi_ipc_get_stub_appid(void) +{ + return _stub_appid; +} + +static void _on_connected(rpc_port_proxy_mmifw_h h, void *user_data) +{ + int r; + + LOGI("..."); + _connected = 1; +} + +static void _on_disconnected(rpc_port_proxy_mmifw_h h, void *user_data) +{ + LOGI("..."); + _connected = 0; +} +static void _on_rejected(rpc_port_proxy_mmifw_h h, void *user_data) +{ + LOGI("..."); + _connected = 0; +} + +int +mmi_ipc_init(const char *appid) +{ + /* initialize handles */ + _rpc_h = NULL; + + _uid = tzplatform_getuid(TZ_SYS_DEFAULT_USER); + LOGI("uid=%d\n", _uid); + + rpc_port_set_target_uid(_uid); + + int r = rpc_port_register_proc_info(appid); + if (r != RPC_PORT_ERROR_NONE) + { + LOGE("Failed to register proc info ! (error:%d)\n", r); + goto err; + } + + _appid = appid; + + rpc_port_proxy_mmifw_callback_s callback = { + .connected = _on_connected, + .disconnected = _on_disconnected, + .rejected = _on_rejected + }; + + r = rpc_port_proxy_mmifw_create(_stub_appid, &callback, NULL, &_rpc_h); + if (r != RPC_PORT_ERROR_NONE) + { + LOGE("Failed to create mmifw proxy handle ! (error:%d)\n", r); + goto err; + } + + r = rpc_port_proxy_mmifw_connect(_rpc_h); + if (r != RPC_PORT_ERROR_NONE) + { + LOGE("Failed to connect to %s ! (error:%d)\n", _stub_appid, r); + goto err; + } + + return 0; +err: + if (_rpc_h) + rpc_port_proxy_destroy(_rpc_h); + + _rpc_h = NULL; + return -1; +} + +void +mmi_ipc_shutdown(void) +{ + rpc_port_proxy_mmifw_destroy(_rpc_h); + _rpc_h = NULL; +} diff --git a/src/mmifw-ipc.h b/src/mmifw-ipc.h new file mode 100644 index 0000000..02ba8e8 --- /dev/null +++ b/src/mmifw-ipc.h @@ -0,0 +1,48 @@ +/* +* Copyright © 2021 Samsung Electronics co., Ltd. All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#ifndef __MMIFW_IPC_H__ +#define __MMIFW_IPC_H__ + +#include +#include "interface/mmifw_proxy.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int mmi_ipc_init(const char *appid); +void mmi_ipc_shutdown(void); + +rpc_port_proxy_mmifw_h mmi_ipc_get_rpc_h(void); +mmi_state mmi_ipc_get_state(void); +int mmi_ipc_get_uid(void); +bool mmi_ipc_is_connected(void); +const char *mmi_ipc_get_appid(void); +const char *mmi_ipc_get_stub_appid(void); + +#ifdef __cplusplus +} +#endif + +#endif //__MMIFW_IPC_H__