#include <Eina.h>
static Eina_Bool _init_done = false;
+static Eina_List *_focus_candidates = NULL;
+static int _focus_candidates_cnt = 0;
+static mmi_client* _cur_focus_client = NULL;
int MMI_MANAGER_EVENT_FOCUS_CHANGE = -1;
int MMI_MANAGER_EVENT_STATE_CHANGE = -1;
int
+mmi_manager_remove_client_from_focus_candidates(mmi_client *client)
+{
+ if (!client)
+ return -1;
+
+ if (client != eina_list_data_find(_focus_candidates, client))
+ {
+ return -1;
+ }
+
+ _focus_candidates = eina_list_remove(_focus_candidates, client);
+ LOGI("Client(=%s) has been removed from focus_candidates !\n",
+ client_manager_get_client_sender(client));
+ _focus_candidates_cnt--;
+ return 0;
+}
+
+int
+_add_focus_change_event(mmi_client *cur_focus, mmi_client *new_focus)
+{
+ mmi_manager_event_focus_change *ev = NULL;
+ ev = calloc(1, sizeof(mmi_manager_event_focus_change));
+
+ if (!ev)
+ {
+ LOGE("Failed to allocate memory for focus change !\n");
+ return -1;
+ }
+
+ ev->timestamp = ecore_time_get();
+ ev->cur_focus = cur_focus;
+ ev->new_focus = new_focus;
+
+ ecore_event_add(MMI_MANAGER_EVENT_FOCUS_CHANGE, ev, NULL, NULL);
+ return 0;
+}
+
+int
+mmi_manager_remove_focus_client(mmi_client *client)
+{
+ mmi_client *new_focus = NULL;
+
+ if (!client || (client != _cur_focus_client) || !client_manager_get_client_has_focus(client))
+ {
+ LOGE("Invalid client was given !\n");
+ return -1;
+ }
+
+ new_focus = eina_list_nth(_focus_candidates, 0);
+ return _add_focus_change_event(client, new_focus);
+}
+
+int
mmi_manager_get_focus(mmi_client *client)
{
- (void) client;
+ if (!client)
+ return -1;
LOGI("...");
- return 0;
+
+ return _add_focus_change_event(_cur_focus_client, client);
}
int
mmi_manager_set_state(mmi_client *client, mmi_state state)
{
- (void) client;
- (void) state;
+ if (!client)
+ return -1;
+
+ if (client_manager_get_client_state(client) == state)
+ {
+ LOGI("Given state equals to the current state(=%d) of client !\n", state);
+ return 0;
+ }
LOGI("...");
+
+ mmi_manager_event_state_change *ev = NULL;
+ ev = calloc(1, sizeof(mmi_manager_event_state_change));
+
+ if (!ev)
+ {
+ LOGE("Failed to allocate memory for state change !\n");
+ goto err;
+ }
+
+ ev->timestamp = ecore_time_get();
+ ev->from_state = client_manager_get_client_state(client);
+ ev->to_state = state;
+
+ ecore_event_add(MMI_MANAGER_EVENT_STATE_CHANGE, ev, NULL, NULL);
return 0;
+err:
+ return -1;
}
static void