_connected = 0;
}
+int mmi_ipc_retry_connection(rpc_port_proxy_mmi_h h)
+{
+ LOGI("Retry connection");
+
+ if (mmi_ipc_is_connected() == false) {
+ LOGE("Not Connected.");
+ int ret = rpc_port_proxy_mmi_connect_sync(h);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ LOGE("Fail to retry connection(%d)", ret);
+ return MMI_ERROR_OPERATION_FAILED;
+ }
+ }
+
+ return MMI_ERROR_NONE;
+}
+
int mmi_ipc_initialize(void)
{
/* initialize handles */
_rpc_h = NULL;
- int r;
+ int ret;
rpc_port_proxy_mmi_callback_s callback = {
.connected = _on_connected,
.rejected = _on_rejected
};
- r = rpc_port_proxy_mmi_create(_stub_appid, &callback, NULL, &_rpc_h);
- if (r != RPC_PORT_ERROR_NONE)
- {
- LOGE("Failed to create mmi proxy handle ! (error:%d)\n", r);
- goto err;
+ ret = rpc_port_proxy_mmi_create(_stub_appid, &callback, NULL, &_rpc_h);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ LOGE("Failed to create mmi proxy handle ! (error:%d)\n", ret);
+ return MMI_ERROR_OPERATION_FAILED;
}
- r = rpc_port_proxy_mmi_connect_sync(_rpc_h);
- if (r != RPC_PORT_ERROR_NONE)
- {
- LOGE("Failed to connect to %s ! (error:%d)\n", _stub_appid, r);
- goto err;
+ ret = rpc_port_proxy_mmi_connect_sync(_rpc_h);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ LOGE("Try to connect again");
+ //Retry
+ ret = mmi_ipc_retry_connection(_rpc_h);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ LOGE("Fail to retry connection(%d)", ret);
+ return MMI_ERROR_OPERATION_FAILED;
+ }
}
LOGI("connect mmi ipc");
- return 0;
-err:
- if (_rpc_h)
- rpc_port_proxy_mmi_destroy(_rpc_h);
-
- rpc_port_deregister_proc_info();
-
- _rpc_h = NULL;
- return -1;
+ return MMI_ERROR_NONE;
}
void mmi_ipc_deinitialize(void)
int mmi_ipc_register_input_event_result_cb(int input_event_type, rpc_port_proxy_mmi_result_cb_cb callback)
{
LOGI("Register input event(%d) result cb to MMI Service", input_event_type);
+ int ret;
if (callback == NULL) {
LOGE("Parameter callback is NULL");
return MMI_ERROR_INVALID_PARAMETER;
}
+ if (mmi_ipc_is_connected() == false) {
+ LOGE("Try to connect again");
+ ret = mmi_ipc_retry_connection(rpc_h);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ LOGE("Fail to retry connection(%d)", ret);
+ return MMI_ERROR_OPERATION_FAILED;
+ }
+ }
+
rpc_port_proxy_mmi_result_cb_h result_cb_h;
- int ret = rpc_port_proxy_mmi_result_cb_create(&result_cb_h);
+ ret = rpc_port_proxy_mmi_result_cb_create(&result_cb_h);
if (ret != RPC_PORT_ERROR_NONE) {
LOGE("Failed to create result callback handle (error:%d)\n", ret);
return MMI_ERROR_OPERATION_FAILED;