_init_done = false;
}
-int mmi_api_handler_send_resullt(const char *app_id, int event_type, const char *output_result)
+int mmi_api_handler_send_result(mmi_client *client, int event_type, const char *output_result)
{
- if (app_id == NULL) {
- LOGE("App ID is NULL");
+ if (client == NULL) {
+ LOGE("Client handle is NULL");
return MMI_ERROR_INVALID_PARAMETER;
}
- mmi_client *mclient = client_manager_get_client(app_id);
- if (mclient == NULL) {
- LOGE("Failed to get client information from sender(%s)!", app_id);
- return MMI_ERROR_INVALID_PARAMETER;
- }
-
- rpc_port_stub_mmi_result_cb_h result_cb = client_manager_get_result_cb_handle(mclient, event_type);
+ const char* app_id = client_manager_get_client_sender(client);
+ rpc_port_stub_mmi_result_cb_h result_cb = client_manager_get_result_cb_handle(client, event_type);
if (result_cb == NULL) {
LOGE("Failed to get result callback. App ID(%s), event Type(%d)!", app_id, event_type);
return MMI_ERROR_INVALID_PARAMETER;
#ifndef __MMI_API_HANDLER_H__
#define __MMI_API_HANDLER_H__
-#include "mmi_stub.h"
+
+#include "mmi-client.h"
#ifdef __cplusplus
extern "C" {
#endif
+
int mmi_api_handler_initialize(void);
void mmi_api_handler_deinitialize(void);
-int mmi_api_handler_send_resullt(const char *app_id, int event_type, const char *output_result);
+int mmi_api_handler_send_result(mmi_client *client, int event_type, const char *output_result);
#ifdef __cplusplus
}
#include <Ecore.h>
+#include <glib.h>
+
#include "mmi-manager.h"
#include "mmi-manager-dbg.h"
#include "mmi-api-handler.h"
EVENT_HANDLER_MAX
};
+typedef struct {
+ int event_type;
+ const char *json_data;
+} output_result_s;
+
+
static Ecore_Event_Handler *_event_handlers[EVENT_HANDLER_MAX];
static mmi_client *g_client = NULL;
+
+static void __send_result_to_client(gpointer data, gpointer user_data)
+{
+ mmi_client *client = (mmi_client *)data;
+ output_result_s *output_result = (char *)user_data;
+
+ if (client == NULL || output_result == NULL) {
+ _E("Invalid parameters. Skip this item");
+ return;
+ }
+
+ const char *app_id = client_manager_get_client_sender(client);
+ _D("Send result. app_id(%s), event(%d)", app_id, output_result->event_type);
+
+ int ret = mmi_api_handler_send_result(client, output_result->event_type, output_result->json_data);
+ if (ret != MMI_ERROR_NONE) {
+ _E("Fail to send result. ret(%d/%s)", ret, get_error_message(ret));
+ }
+}
+
static void __output_result_received_cb(const char *app_id, int type, const char *json_data, void *user_data)
{
- int ret = mmi_api_handler_send_resullt(app_id, type, json_data);
+ GList *clients = client_manager_get_clients_listening_event(type);
+ if (clients == NULL) {
+ _E("Fail to get clients which set event type (%d)", type);
+ }
+
+ output_result_s output_result;
+ output_result.event_type = type;
+ output_result.json_data = json_data;
+
+ g_list_foreach(clients, __send_result_to_client, (gpointer)&output_result);
+ g_list_free(clients);
}
static void __output_modality_received_cb(const char *app_id, int type, void *event, void *user_data)