Geofence3 / src /

view.c

/*
 * Copyright (c) 2016 Samsung Electronics Co., Ltd
 *
 * Licensed under the Flora License, Version 1.1 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://floralicense.org/license/
 *
 * 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.
 */

#include <tizen.h>
#include <dlog.h>
#include <app.h>
#include <efl_extension.h>
#include <Elementary.h>
#include <system_info.h>

#include "$(appName).h"
#include "view.h"
#include "data.h"

int myfence_index = 0;

static struct view_info {
	Evas_Object *win;
	Evas_Object *conform;
	Evas_Object *nf;
	Evas_Object *entry;
	Evas_Object *event_entry;
	Evas_Object *state_entry;
	Evas_Object *proximity_entry;
	Evas_Object *table;

	Evas_Object *create_btn;
	Evas_Object *fence_state_btn;
	Evas_Object *add_fence_btn;
	Evas_Object *add_place_btn;
	Evas_Object *start_btn;
	Evas_Object *stop_btn;
	Evas_Object *remove_fence_btn;
	Evas_Object *remove_place_btn;
	Evas_Object *update_place_btn;
	Evas_Object *destroy_btn;

	Evas_Object *popup;
	Evas_Object *gen_entry;
	Evas_Object *gen_entry_nd;
} s_info = {
	.win = NULL,
	.conform = NULL,
	.nf = NULL,
	.entry = NULL,
	.event_entry = NULL,
	.state_entry = NULL,
	.proximity_entry = NULL,
	.table = NULL,
	.create_btn = NULL,
	.fence_state_btn = NULL,
	.add_fence_btn = NULL,
	.add_place_btn = NULL,
	.start_btn = NULL,
	.stop_btn = NULL,
	.remove_fence_btn = NULL,
	.remove_place_btn = NULL,
	.update_place_btn = NULL,
	.destroy_btn = NULL,
	.popup = NULL,
	.gen_entry = NULL,
	.gen_entry_nd = NULL,
};

static Evas_Object *view_create_naviframe(Evas_Object *conform);
static Evas_Object *view_create_grid_and_content(Evas_Object *nf, appdata_s *ad);
static Evas_Object *create_entry(Evas_Object *grid);
static Evas_Object *create_panel_and_content(Evas_Object *grid, appdata_s *ad);
static Evas_Object *create_panel_basic_content(Evas_Object *panel, appdata_s *ad);

static void clicked_create_cb(void *data, Evas_Object *obj, void *event_info);
static void clicked_destroy_cb(void *data, Evas_Object *obj, void *event_info);
static void show_popup_cb(void *data, Evas_Object *obj, void *event_info);

static void select_fence_list(appdata_s *ad, Evas_Smart_Cb func);
static void select_place_list(appdata_s *ad, Evas_Smart_Cb func);
static void select_method_list(appdata_s *ad, Evas_Smart_Cb func, int place_id);
static void insert_place_name(appdata_s *ad, Evas_Object *obj, int place_id, char *place_name);
static void insert_fence_value(appdata_s *ad, int place_id, int method);
static void popup_method_value_cb(void *data, Evas_Object *obj, void *event_info);

static bool get_place_cb(int place_id, const char *place_name, int place_index, int place_cnt, void *user_data);
static bool get_fence_cb(int geofence_id, geofence_h fence, int fence_index, int fence_cnt, void *user_data);
static void get_state_cb(void *data, Evas_Object *obj, void *event_info);
static bool get_started_fence_cb(int geofence_id, geofence_h fence, int fence_index, int fence_cnt, void *user_data);
static bool get_stopped_fence_cb(int geofence_id, geofence_h fence, int fence_index, int fence_cnt, void *user_data);

static void add_fence_cb(void *data, Evas_Object *obj, void *event_info);
static void add_fence_nd_cb(void *data, Evas_Object *obj, void *event_info);
static void remove_fence_cb(void *data, Evas_Object *obj, void *event_info);
static void start_fence_cb(void *data, Evas_Object *obj, void *event_info);
static void stop_fence_cb(void *data, Evas_Object *obj, void *event_info);
static void remove_place_cb(void *data, Evas_Object *obj, void *event_info);
static void update_place_cb(void *data, Evas_Object *obj, void *event_info);

static void show_event_cb(int place_id, int geofence_id, geofence_manager_error_e error, geofence_manage_e manage, void *user_data);
static void show_state_changed_cb(int geofence_id, geofence_state_e state, void *user_data);
static void show_proximity_changed_cb(int geofence_id, geofence_proximity_state_e state, geofence_proximity_provider_e provider, void *user_data);
static void showError(Evas_Object *obj, int ret);

static void popup_cancel_cb(void *data, Evas_Object *obj, void *event_info);
static void popup_place_name_cb(void *data, Evas_Object *obj, void *event_info);

static char *gl_id_text_get_cb(void *data, Evas_Object *obj, const char *part);
static char *gl_method_text_get_cb(void *data, Evas_Object *obj, const char *part);
static Evas_Object *gl_entry_content_get(void *data, Evas_Object *obj, const char *part);

static void show_toast_popup(char *str);
static void popup_timeout_cb(void *data, Evas_Object *obj, void *event_info);
static Eina_Bool naviframe_pop_cb(void *data, Elm_Object_Item *it);
static void _win_delete_request_cb(void *data, Evas_Object *obj, void *event_info);

/**
 * @brief Creates objects of view : window, conformant.
 */
Eina_Bool view_create(void *user_data)
{
	/* Create the window */
	s_info.win = view_create_win(PACKAGE);
	if (s_info.win == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "failed to create a window.");
		return EINA_FALSE;
	}

	/* Create the conformant */
	s_info.conform = view_create_conformant_without_indicator(s_info.win);
	if (s_info.conform == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "failed to create a conformant");
		return EINA_FALSE;
	}

	/* Create the naviframe */
	s_info.nf = view_create_naviframe(s_info.conform);
	if (s_info.nf == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "failed to create a naviframe");
		return EINA_FALSE;
	}

	/* Create the grid and content of grid */
	Evas_Object *grid = view_create_grid_and_content(s_info.nf, (appdata_s *)user_data);
	if (grid == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "failed to create a grid");
		return EINA_FALSE;
	}

	/* push an item to the naviframe */
	Elm_Object_Item *nf_it = elm_naviframe_item_push(s_info.nf, "Geofence", NULL, NULL, grid, NULL);
	elm_naviframe_item_pop_cb_set(nf_it, naviframe_pop_cb, NULL);

	/* Show the window after main view is set up */
	evas_object_show(s_info.win);
	return EINA_TRUE;
}

/**
 * @brief Creates a basic window named package.
 * @param[in] pkg_name Name of the window
 */
Evas_Object *view_create_win(const char *pkg_name)
{
	Evas_Object *win = NULL;

	/*
	 * Window
	 * Create and initialize elm_win.
	 * elm_win is mandatory to manipulate the window.
	 */
	win = elm_win_util_standard_add(pkg_name, pkg_name);
	elm_win_conformant_set(win, EINA_TRUE);
	elm_win_autodel_set(win, EINA_TRUE);

	evas_object_smart_callback_add(win, "delete,request", _win_delete_request_cb, NULL);

	return win;
}

/**
 * @brief Creates a conformant without indicator for wearable app.
 * @param[in] win The object to which you want to set this conformant
 * Conformant is mandatory for base GUI to have proper size
 */
Evas_Object *view_create_conformant_without_indicator(Evas_Object *win)
{
	/*
	 * Conformant
	 * Create and initialize elm_conformant.
	 * elm_conformant is mandatory for base GUI to have proper size
	 * when indicator or virtual keypad is visible.
	 */
	Evas_Object *conform = NULL;

	if (win == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "window is NULL.");
		return NULL;
	}

	conform = elm_conformant_add(win);
	evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	elm_win_resize_object_add(win, conform);

	evas_object_show(conform);

	return conform;
}

/**
 * @brief Destroys window and frees its resources.
 */
void view_destroy(void)
{
	if (s_info.win == NULL)
		return;

	evas_object_del(s_info.win);
}

/**
 * @brief Creates a naviframe
 * @param[in] conform The object to which you want to set this naviframe
 */
static Evas_Object *view_create_naviframe(Evas_Object *conform)
{
	/*
	 * Naviframe
	 * Create and initialize elm_naviframe.
	 */
	Evas_Object *nf = NULL;

	if (conform == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "conform is NULL.");
		return NULL;
	}

	nf = elm_naviframe_add(conform);
	elm_object_part_content_set(conform, "elm.swallow.content", nf);
	eext_object_event_callback_add(nf, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);

	evas_object_show(nf);

	return nf;
}

/**
 * @brief Creates a grid
 * @param[in] nf The object to which you want to set this grid
 */
static Evas_Object *view_create_grid_and_content(Evas_Object *nf, appdata_s *ad)
{
	/*
	 * grid
	 * Create and initialize elm_grid.
	 */
	Evas_Object *grid = NULL;

	if (nf == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "naviframe is NULL.");
		return NULL;
	}

	grid = elm_grid_add(nf);
	evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
	elm_object_content_set(nf, grid);

	/* Entry for API name */
	s_info.entry = create_entry(grid);
	elm_grid_pack(grid, s_info.entry, 0, 5, 90, 10);

	/* Entry for API result */
	s_info.event_entry = create_entry(grid);
	elm_grid_pack(grid, s_info.event_entry, 0, 15, 90, 10);

	/* Entry for fence state */
	s_info.state_entry = create_entry(grid);
	elm_grid_pack(grid, s_info.state_entry, 0, 25, 90, 10);

	/* Entry for proximity state */
	s_info.proximity_entry = create_entry(grid);
	elm_grid_pack(grid, s_info.proximity_entry, 0, 35, 90, 10);

	/* Panel */
	Evas_Object *panel = create_panel_and_content(grid, ad);
	elm_grid_pack(grid, panel, 0, 55, 100, 45);

	return grid;
}

/**
 * @brief Creates a entry
 * @param[in] grid The object to which you want to set this entry
 */
static Evas_Object *create_entry(Evas_Object *grid)
{
	/*
	 * entry
	 * Create and initialize elm_entry.
	 */
	Evas_Object *entry = NULL;

	if (grid == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "grid is NULL.");
		return NULL;
	}

	entry = elm_entry_add(grid);
	elm_entry_editable_set(entry, EINA_FALSE);
	elm_entry_context_menu_disabled_set(entry, EINA_TRUE);
	elm_entry_entry_set(entry, "<font_size=30><align=left></align></font_size>");
	evas_object_show(entry);

	return entry;
}

/**
 * @brief Creates a panel and contents
 * @param[in] grid The object to which you want to set this panel
 */
static Evas_Object *create_panel_and_content(Evas_Object *grid, appdata_s *ad)
{
	/*
	 * panel
	 * Create and initialize elm_panel.
	 */
	Evas_Object *panel = NULL;

	if (grid == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "grid is NULL.");
		return NULL;
	}

	/* Panel */
	panel = elm_panel_add(grid);
	evas_object_show(panel);

	/*
	 * button_grid
	 * Create and initialize elm_grid.
	 */
	Evas_Object *button_grid = NULL;

	if (panel == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "panel is NULL.");
		return NULL;
	}

	/* Grid */
	button_grid = elm_grid_add(panel);
	evas_object_size_hint_weight_set(button_grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(button_grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
	elm_object_content_set(panel, button_grid);

	if (button_grid == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "button_grid is NULL.");
		return NULL;
	}

	/* Panel basic content */
	s_info.table = create_panel_basic_content(button_grid, ad);
	evas_object_size_hint_weight_set(s_info.table, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(s_info.table, EVAS_HINT_FILL, EVAS_HINT_FILL);
	elm_grid_pack(button_grid, s_info.table, 3, 3, 94, 94);

	return panel;
}

/**
 * @brief Creates a table and buttons
 * @param[in] panel The object to which you want to set this table
 */
static Evas_Object *create_panel_basic_content(Evas_Object *panel, appdata_s *ad)
{
	/*
	 * table
	 * Create and initialize elm_table.
	 */
	Evas_Object *table = NULL;

	if (panel == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "panel is NULL.");
		return NULL;
	}

	table = elm_table_add(panel);
	elm_table_padding_set(table, 10, 5);

	/*
	 * create_btn
	 * Create and initialize elm_button.
	 */
	s_info.create_btn = elm_button_add(table);
	evas_object_size_hint_weight_set(s_info.create_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(s_info.create_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
	elm_object_text_set(s_info.create_btn, "<font_size=30>Create</font_size>");
	elm_object_disabled_set(s_info.create_btn, EINA_FALSE);
	evas_object_smart_callback_add(s_info.create_btn, "clicked", clicked_create_cb, ad);
	evas_object_show(s_info.create_btn);
	elm_table_pack(table, s_info.create_btn, 0, 0, 1, 1);

	/*
	 * fence_state_btn
	 * Create and initialize elm_button.
	 */
	s_info.fence_state_btn = elm_button_add(table);
	evas_object_size_hint_weight_set(s_info.fence_state_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(s_info.fence_state_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
	elm_object_text_set(s_info.fence_state_btn, "<font_size=30>Fence Status</font_size>");
	elm_object_disabled_set(s_info.fence_state_btn, EINA_TRUE);
	evas_object_smart_callback_add(s_info.fence_state_btn, "clicked", show_popup_cb, ad);
	evas_object_show(s_info.fence_state_btn);
	elm_table_pack(table, s_info.fence_state_btn, 1, 0, 1, 1);

	/*
	 * add_fence_btn
	 * Create and initialize elm_button.
	 */
	s_info.add_fence_btn = elm_button_add(table);
	evas_object_size_hint_weight_set(s_info.add_fence_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(s_info.add_fence_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
	elm_object_text_set(s_info.add_fence_btn, "<font_size=30>Add Fence</font_size>");
	elm_object_disabled_set(s_info.add_fence_btn, EINA_TRUE);
	evas_object_smart_callback_add(s_info.add_fence_btn, "clicked", show_popup_cb, ad);
	evas_object_show(s_info.add_fence_btn);
	elm_table_pack(table, s_info.add_fence_btn, 0, 1, 1, 1);

	/*
	 * add_place_btn
	 * Create and initialize elm_button.
	 */
	s_info.add_place_btn = elm_button_add(table);
	evas_object_size_hint_weight_set(s_info.add_place_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(s_info.add_place_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
	elm_object_text_set(s_info.add_place_btn, "<font_size=30>Add Place</font_size>");
	elm_object_disabled_set(s_info.add_place_btn, EINA_TRUE);
	evas_object_smart_callback_add(s_info.add_place_btn, "clicked", show_popup_cb, ad);
	evas_object_show(s_info.add_place_btn);
	elm_table_pack(table, s_info.add_place_btn, 1, 1, 1, 1);

	/*
	 * start_btn
	 * Create and initialize elm_button.
	 */
	s_info.start_btn = elm_button_add(table);
	evas_object_size_hint_weight_set(s_info.start_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(s_info.start_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
	elm_object_text_set(s_info.start_btn, "<font_size=30>Start</font_size>");
	elm_object_disabled_set(s_info.start_btn, EINA_TRUE);
	evas_object_smart_callback_add(s_info.start_btn, "clicked", show_popup_cb, ad);
	evas_object_show(s_info.start_btn);
	elm_table_pack(table, s_info.start_btn, 0, 2, 1, 1);

	/*
	 * stop_btn
	 * Create and initialize elm_button.
	 */
	s_info.stop_btn = elm_button_add(table);
	evas_object_size_hint_weight_set(s_info.stop_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(s_info.stop_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
	elm_object_text_set(s_info.stop_btn, "<font_size=30>Stop</font_size>");
	elm_object_disabled_set(s_info.stop_btn, EINA_TRUE);
	evas_object_smart_callback_add(s_info.stop_btn, "clicked", show_popup_cb, ad);
	evas_object_show(s_info.stop_btn);
	elm_table_pack(table, s_info.stop_btn, 1, 2, 1, 1);

	/*
	 * remove_fence_btn
	 * Create and initialize elm_button.
	 */
	s_info.remove_fence_btn = elm_button_add(table);
	evas_object_size_hint_weight_set(s_info.remove_fence_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(s_info.remove_fence_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
	elm_object_text_set(s_info.remove_fence_btn, "<font_size=30>Remove Fence</font_size>");
	elm_object_disabled_set(s_info.remove_fence_btn, EINA_TRUE);
	evas_object_smart_callback_add(s_info.remove_fence_btn, "clicked", show_popup_cb, ad);
	evas_object_show(s_info.remove_fence_btn);
	elm_table_pack(table, s_info.remove_fence_btn, 0, 3, 1, 1);

	/*
	 * remove_place_btn
	 * Create and initialize elm_button.
	 */
	s_info.remove_place_btn = elm_button_add(table);
	evas_object_size_hint_weight_set(s_info.remove_place_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(s_info.remove_place_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
	elm_object_text_set(s_info.remove_place_btn, "<font_size=30>Remove Place</font_size>");
	elm_object_disabled_set(s_info.remove_place_btn, EINA_TRUE);
	evas_object_smart_callback_add(s_info.remove_place_btn, "clicked", show_popup_cb, ad);
	evas_object_show(s_info.remove_place_btn);
	elm_table_pack(table, s_info.remove_place_btn, 1, 3, 1, 1);

	/*
	 * update_place_btn
	 * Create and initialize elm_button.
	 */
	s_info.update_place_btn = elm_button_add(table);
	evas_object_size_hint_weight_set(s_info.update_place_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(s_info.update_place_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
	elm_object_text_set(s_info.update_place_btn, "<font_size=30>Update Place</font_size>");
	elm_object_disabled_set(s_info.update_place_btn, EINA_TRUE);
	evas_object_smart_callback_add(s_info.update_place_btn, "clicked", show_popup_cb, ad);
	evas_object_show(s_info.update_place_btn);
	elm_table_pack(table, s_info.update_place_btn, 0, 4, 1, 1);

	/*
	 * destroy_btn
	 * Create and initialize elm_button.
	 */
	s_info.destroy_btn = elm_button_add(table);
	evas_object_size_hint_weight_set(s_info.destroy_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(s_info.destroy_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
	elm_object_text_set(s_info.destroy_btn, "<font_size=30>Destroy</font_size>");
	elm_object_disabled_set(s_info.destroy_btn, EINA_TRUE);
	evas_object_smart_callback_add(s_info.destroy_btn, "clicked", clicked_destroy_cb, ad);
	evas_object_show(s_info.destroy_btn);
	elm_table_pack(table, s_info.destroy_btn, 1, 4, 1, 1);

	evas_object_show(table);

	return table;
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] data The data to be passed to the callback function
 * @param[in] obj The Evas object to be passed to the callback function
 * @param[in] event_info The Event information to be passed to the callback function
 */
static void clicked_create_cb(void *data, Evas_Object *obj, void *event_info)
{
	appdata_s *ad = (appdata_s *) data;
	int ret = 0;

	if (ad == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
		return;
	}

	/* Create geofence handle */
	ret = geofence_manager_create(&(ad->geo_manager));

	/* show called API */
	elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_manager_create</align></font_size>");
	/* show API result */
	showError(s_info.event_entry, ret);
	/* clear the entry of fence state */
	elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
	/* clear the entry of proximity state */
	elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");

	/* enable button when geofence handle is created */
	if (ret == GEOFENCE_MANAGER_ERROR_NONE) {
		elm_object_disabled_set(s_info.create_btn, EINA_TRUE);
		elm_object_disabled_set(s_info.fence_state_btn, EINA_FALSE);
		elm_object_disabled_set(s_info.add_fence_btn, EINA_FALSE);
		elm_object_disabled_set(s_info.add_place_btn, EINA_FALSE);
		elm_object_disabled_set(s_info.start_btn, EINA_FALSE);
		elm_object_disabled_set(s_info.stop_btn, EINA_FALSE);
		elm_object_disabled_set(s_info.remove_fence_btn, EINA_FALSE);
		elm_object_disabled_set(s_info.remove_place_btn, EINA_FALSE);
		elm_object_disabled_set(s_info.update_place_btn, EINA_FALSE);
		elm_object_disabled_set(s_info.destroy_btn, EINA_FALSE);

		/* set callback for geofence event */
		geofence_manager_set_geofence_event_cb(ad->geo_manager, show_event_cb, NULL);
		/* set callback for geofence state */
		geofence_manager_set_geofence_state_changed_cb(ad->geo_manager, show_state_changed_cb, NULL);
		/* set callback for proximity state */
		geofence_manager_set_geofence_proximity_state_changed_cb(ad->geo_manager, show_proximity_changed_cb, NULL);
	}
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] data The data to be passed to the callback function
 * @param[in] obj The Evas object to be passed to the callback function
 * @param[in] event_info The Event information to be passed to the callback function
 */
static void clicked_destroy_cb(void *data, Evas_Object *obj, void *event_info)
{
	appdata_s *ad = (appdata_s *) data;
	int ret = 0;

	if (ad == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
		return;
	}

	/* unset callback for geofence event */
	geofence_manager_unset_geofence_event_cb(ad->geo_manager);
	/* unset callback for geofence state */
	geofence_manager_unset_geofence_state_changed_cb(ad->geo_manager);
	/* unset callback for proximity state */
	geofence_manager_unset_geofence_proximity_state_changed_cb(ad->geo_manager);

	/* Destroy geofence handle */
	ret = geofence_manager_destroy(ad->geo_manager);

	/* show called API */
	elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_manager_destroy</align></font_size>");
	/* show API result */
	showError(s_info.event_entry, ret);
	/* clear the entry of fence state */
	elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
	/* clear the entry of proximity state */
	elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");

	/* disable button when geofence handle is destroyed */
	if (ret == GEOFENCE_MANAGER_ERROR_NONE) {
		elm_object_disabled_set(s_info.create_btn, EINA_FALSE);
		elm_object_disabled_set(s_info.fence_state_btn, EINA_TRUE);
		elm_object_disabled_set(s_info.add_fence_btn, EINA_TRUE);
		elm_object_disabled_set(s_info.add_place_btn, EINA_TRUE);
		elm_object_disabled_set(s_info.start_btn, EINA_TRUE);
		elm_object_disabled_set(s_info.stop_btn, EINA_TRUE);
		elm_object_disabled_set(s_info.remove_fence_btn, EINA_TRUE);
		elm_object_disabled_set(s_info.remove_place_btn, EINA_TRUE);
		elm_object_disabled_set(s_info.update_place_btn, EINA_TRUE);
		elm_object_disabled_set(s_info.destroy_btn, EINA_TRUE);

		ad->geo_manager = NULL;
	}
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] data The data to be passed to the callback function
 * @param[in] obj The Evas object to be passed to the callback function
 * @param[in] event_info The Event information to be passed to the callback function
 */
static void show_popup_cb(void *data, Evas_Object *obj, void *event_info)
{
	appdata_s *ad = (appdata_s *)data;

	/* set function and parameter for each button */
	if (obj == s_info.fence_state_btn)
		select_fence_list(ad, get_state_cb);
	else if (obj == s_info.add_fence_btn)
		select_place_list(ad, add_fence_cb);
	else if (obj == s_info.add_place_btn)
		insert_place_name(ad, s_info.add_place_btn, -1, NULL);
	else if (obj == s_info.start_btn)
		select_fence_list(ad, start_fence_cb);
	else if (obj == s_info.stop_btn)
		select_fence_list(ad, stop_fence_cb);
	else if (obj == s_info.remove_fence_btn)
		select_fence_list(ad, remove_fence_cb);
	else if (obj == s_info.remove_place_btn)
		select_place_list(ad, remove_place_cb);
	else if (obj == s_info.update_place_btn)
		select_place_list(ad, update_place_cb);
}

/**
 * @brief Create a popup to select fence.
 * @param[in] ad The application data to be passed
 * @param[in] func The Evas object to be passed to the callback function
 */
static void select_fence_list(appdata_s *ad, Evas_Smart_Cb func)
{
	Elm_Genlist_Item_Class *itc;
	Evas_Object *box;
	Evas_Object *genlist;
	int ret = 0;
	int i = 0;
	myfence_index = 0;

	if (ad == NULL || func == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "Application data or func is NULL.");
		return;
	}

	/* clear all fence_id */
	for (i = 0; i < MAX_COUNT; i++)
		ad->fence_id[i] = -1;

	/* request geofence list and set callback as func */
	if (func == start_fence_cb)
		ret = geofence_manager_foreach_geofence_list(ad->geo_manager, get_stopped_fence_cb, ad);
	else if (func == stop_fence_cb)
		ret = geofence_manager_foreach_geofence_list(ad->geo_manager, get_started_fence_cb, ad);
	else
		ret = geofence_manager_foreach_geofence_list(ad->geo_manager, get_fence_cb, ad);

	/* show called API */
	elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_manager_foreach_geofence_list</align></font_size>");
	/* show API result */
	showError(s_info.event_entry, ret);
	/* clear the entry of fence state */
	elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
	/* clear the entry of proximity state */
	elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");

	/* error handling */
	if (ret != GEOFENCE_MANAGER_ERROR_NONE)
		return;
	else if (ad->fence_id[0] == -1) {
		show_toast_popup("Empty");
		return;
	}

	/*
	 * popup
	 * Create and initialize elm_popup.
	 */
	s_info.popup = elm_popup_add(s_info.nf);
	elm_popup_align_set(s_info.popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
	eext_object_event_callback_add(s_info.popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL);
	evas_object_size_hint_weight_set(s_info.popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	elm_object_part_text_set(s_info.popup, "title,text", "Fence");

	/*
	 * box
	 * Create and initialize elm_box.
	 */
	box = elm_box_add(s_info.popup);
	evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);

	/*
	 * genlist
	 * Create and initialize elm_genlist.
	 */
	genlist = elm_genlist_add(box);
	evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);

	evas_object_data_set(genlist, "app_data", ad);

	itc = elm_genlist_item_class_new();
	itc->item_style = "default";
	itc->func.text_get = gl_id_text_get_cb;
	itc->func.content_get = NULL;
	itc->func.state_get = NULL;
	itc->func.del = NULL;

	/* append items of genlist */
	for (i = 0; ad->fence_id[i] != -1; i++)
		elm_genlist_item_append(genlist, itc, (void *)ad->fence_id[i], NULL, ELM_GENLIST_ITEM_NONE, func, (void *)ad->fence_id[i]);

	evas_object_show(genlist);
	elm_box_pack_end(box, genlist);
	evas_object_size_hint_min_set(box, -1, 150);
	elm_object_content_set(s_info.popup, box);

	evas_object_show(s_info.popup);
	elm_genlist_item_class_free(itc);
}

/**
 * @brief Create a popup to select place.
 * @param[in] ad The application data to be passed
 * @param[in] func The Evas object to be passed to the callback function
 */
static void select_place_list(appdata_s *ad, Evas_Smart_Cb func)
{
	Elm_Genlist_Item_Class *itc;
	Evas_Object *box;
	Evas_Object *genlist;
	int ret = 0;
	int i = 0;

	if (ad == NULL || func == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "Application data or func is NULL.");
		return;
	}

	/* clear all place_id */
	for (i = 0; i < MAX_COUNT; i++)/* clear the entry of fence state */
		ad->place_id[i] = -1;

	/* request place list and set callback */
	ret = geofence_manager_foreach_place_list(ad->geo_manager, get_place_cb, ad);

	/* show called API */
	elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_manager_foreach_place_list</align></font_size>");
	/* show API result */
	showError(s_info.event_entry, ret);
	/* clear the entry of fence state */
	elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
	/* clear the entry of proximity state */
	elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");

	/* error handling */
	if (ret != GEOFENCE_MANAGER_ERROR_NONE)
		return;

	/*
	 * popup
	 * Create and initialize elm_popup.
	 */
	s_info.popup = elm_popup_add(s_info.nf);
	elm_popup_align_set(s_info.popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
	eext_object_event_callback_add(s_info.popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL);
	evas_object_size_hint_weight_set(s_info.popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	elm_object_part_text_set(s_info.popup, "title,text", "Place");

	/*
	 * box
	 * Create and initialize elm_box.
	 */
	box = elm_box_add(s_info.popup);
	evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);

	/*
	 * genlist
	 * Create and initialize elm_genlist.
	 */
	genlist = elm_genlist_add(box);
	evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);

	evas_object_data_set(genlist, "app_data", ad);

	itc = elm_genlist_item_class_new();
	itc->item_style = "default";
	itc->func.text_get = gl_id_text_get_cb;
	itc->func.content_get = NULL;
	itc->func.state_get = NULL;
	itc->func.del = NULL;

	/* append items of genlist */
	for (i = 0; ad->place_id[i] != -1; i++)
		elm_genlist_item_append(genlist, itc, (void *)ad->place_id[i], NULL, ELM_GENLIST_ITEM_NONE, func, (void *)ad->place_id[i]);

	evas_object_show(genlist);
	elm_box_pack_end(box, genlist);
	evas_object_size_hint_min_set(box, -1, 300);
	elm_object_content_set(s_info.popup, box);

	evas_object_show(s_info.popup);
	elm_genlist_item_class_free(itc);
}

/**
 * @brief Create a popup to select place.
 * @param[in] ad The application data to be passed
 * @param[in] func The Evas object to be passed to the callback function
 * @param[in] place_id The place id
 */
static void select_method_list(appdata_s *ad, Evas_Smart_Cb func, int place_id)
{
	Elm_Genlist_Item_Class *itc_gps, *itc_wifi, *itc_bt;
	Elm_Object_Item *gi_gps, *gi_wifi, *gi_bt;
	Evas_Object *box;
	Evas_Object *genlist;

	const char *wifi_feature = "http://tizen.org/feature/network.wifi";
	const char *bluetooth_feature = "http://tizen.org/feature/network.bluetooth";

	bool wifi_supported = false;
	bool bt_supported = false;

	/*
	 * popup
	 * Create and initialize elm_popup.
	 */
	s_info.popup = elm_popup_add(s_info.nf);
	elm_popup_align_set(s_info.popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
	eext_object_event_callback_add(s_info.popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL);
	evas_object_size_hint_weight_set(s_info.popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	elm_object_part_text_set(s_info.popup, "title,text", "Method");

	/*
	 * box
	 * Create and initialize elm_box.
	 */
	box = elm_box_add(s_info.popup);
	evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);

	/*
	 * genlist
	 * Create and initialize elm_genlist.
	 */
	genlist = elm_genlist_add(box);
	evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);

	evas_object_data_set(genlist, "app_data", ad);
	evas_object_data_set(genlist, "place_id", (void *)place_id);

	/* append items of genlist */
	itc_gps = elm_genlist_item_class_new();
	itc_gps->item_style = "default";
	itc_gps->func.text_get = gl_method_text_get_cb;
	itc_gps->func.content_get = NULL;
	itc_gps->func.state_get = NULL;
	itc_gps->func.del = NULL;
	gi_gps = elm_genlist_item_append(genlist, itc_gps, (void *)METHOD_GPS, NULL, ELM_GENLIST_ITEM_NONE, func, (void *)METHOD_GPS);

	/* append items of genlist */
	itc_wifi = elm_genlist_item_class_new();
	itc_wifi->item_style = "default";
	itc_wifi->func.text_get = gl_method_text_get_cb;
	itc_wifi->func.content_get = NULL;
	itc_wifi->func.state_get = NULL;
	itc_wifi->func.del = NULL;
	gi_wifi = elm_genlist_item_append(genlist, itc_wifi, (void *)METHOD_WIFI, NULL, ELM_GENLIST_ITEM_NONE, func, (void *)METHOD_WIFI);

	/* append items of genlist */
	itc_bt = elm_genlist_item_class_new();
	itc_bt->item_style = "default";
	itc_bt->func.text_get = gl_method_text_get_cb;
	itc_bt->func.content_get = NULL;
	itc_bt->func.state_get = NULL;
	itc_bt->func.del = NULL;
	gi_bt = elm_genlist_item_append(genlist, itc_bt, (void *)METHOD_BT, NULL, ELM_GENLIST_ITEM_NONE, func, (void *)METHOD_BT);

	/*
	 * check WI-FI feature
	 * set disable the WI-FI item if WI-FI is not supported .
	 */
	system_info_get_platform_bool(wifi_feature, &wifi_supported);
	if (wifi_supported == false)
		elm_object_item_disabled_set(gi_wifi, EINA_TRUE);
	else
		elm_object_item_disabled_set(gi_wifi, EINA_FALSE);

	/*
	 * check Bluetooth feature
	 * set disable the Bluetooth item if Bluetooth is not supported .
	 */
	system_info_get_platform_bool(bluetooth_feature, &bt_supported);
	if (bt_supported == false)
		elm_object_item_disabled_set(gi_bt, EINA_TRUE);
	else
		elm_object_item_disabled_set(gi_bt, EINA_FALSE);

	evas_object_show(genlist);
	elm_box_pack_end(box, genlist);
	evas_object_size_hint_min_set(box, -1, 300);
	elm_object_content_set(s_info.popup, box);

	evas_object_show(s_info.popup);
	elm_genlist_item_class_free(itc_gps);
	elm_genlist_item_class_free(itc_wifi);
	elm_genlist_item_class_free(itc_bt);
}

/**
 * @brief Create a popup to insert or update the place name.
 * @param[in] ad The application data to be passed
 * @param[in] obj The Evas object to be passed to the function
 * @param[in] place_id The place id to insert or update
 * @param[in] place_name The place name to insert or update
 */
static void insert_place_name(appdata_s *ad, Evas_Object *obj, int place_id, char *place_name)
{
	Elm_Genlist_Item_Class *itc;
	Evas_Object *box;
	Evas_Object *genlist;
	Evas_Object *cancel_btn, *done_btn;

	if (ad == NULL || obj == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "Application data or obj is NULL.");
		return;
	}

	/*
	 * popup
	 * Create and initialize elm_popup.
	 */
	s_info.popup = elm_popup_add(s_info.nf);
	elm_popup_align_set(s_info.popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
	eext_object_event_callback_add(s_info.popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL);
	evas_object_size_hint_weight_set(s_info.popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	if (obj == s_info.add_place_btn)
		elm_object_part_text_set(s_info.popup, "title,text", "Add Place");
	else
		elm_object_part_text_set(s_info.popup, "title,text", "Update Place");

	/*
	 * box
	 * Create and initialize elm_box.
	 */
	box = elm_box_add(s_info.popup);
	evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);

	/*
	 * genlist
	 * Create and initialize elm_genlist.
	 */
	genlist = elm_genlist_add(box);
	evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);

	evas_object_data_set(genlist, "app_data", ad);
	evas_object_data_set(genlist, "value", place_name);

	itc = elm_genlist_item_class_new();
	itc->item_style = "full";
	itc->func.text_get = NULL;
	itc->func.content_get = gl_entry_content_get;
	itc->func.state_get = NULL;
	itc->func.del = NULL;

	/* append item of genlist */
	elm_genlist_item_append(genlist, itc, "input Name", NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);

	evas_object_show(genlist);
	elm_box_pack_end(box, genlist);
	evas_object_size_hint_min_set(box, -1, 150);
	elm_object_content_set(s_info.popup, box);

	/*
	 * cancel_btn
	 * Create and initialize elm_genlist.
	 */
	cancel_btn = elm_button_add(s_info.popup);
	elm_object_style_set(cancel_btn, "popup");
	elm_object_text_set(cancel_btn, "Cancel");
	elm_object_part_content_set(s_info.popup, "button1", cancel_btn);
	evas_object_smart_callback_add(cancel_btn, "clicked", popup_cancel_cb, NULL);

	/*
	 * done_btn
	 * Create and initialize elm_button.
	 */
	done_btn = elm_button_add(s_info.popup);
	evas_object_data_set(done_btn, "app_data", ad);
	elm_object_style_set(done_btn, "popup");
	elm_object_text_set(done_btn, "Done");
	elm_object_part_content_set(s_info.popup, "button2", done_btn);
	evas_object_smart_callback_add(done_btn, "clicked", popup_place_name_cb, (void *)place_id);

	evas_object_show(s_info.popup);
	elm_genlist_item_class_free(itc);
}

/**
 * @brief Create a popup to insert the fence value.
 * @param[in] ad The application data to be passed
 * @param[in] place_id The place id to insert or update
 * @param[in] method The method for fence
 */
static void insert_fence_value(appdata_s *ad, int place_id, int method)
{
	Elm_Genlist_Item_Class *itc;
	Evas_Object *box;
	Evas_Object *genlist;
	Evas_Object *cancel_btn, *done_btn;

	/*
	 * popup
	 * Create and initialize elm_popup.
	 */
	s_info.popup = elm_popup_add(s_info.nf);
	elm_popup_align_set(s_info.popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
	eext_object_event_callback_add(s_info.popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL);
	evas_object_size_hint_weight_set(s_info.popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	if (method == METHOD_GPS)
		elm_object_part_text_set(s_info.popup, "title,text", "GPS");
	else if (method == METHOD_WIFI)
		elm_object_part_text_set(s_info.popup, "title,text", "Wi-Fi");
	else
		elm_object_part_text_set(s_info.popup, "title,text", "Bluetooth");

	/*
	 * box
	 * Create and initialize elm_box.
	 */
	box = elm_box_add(s_info.popup);
	evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);

	/*
	 * genlist
	 * Create and initialize elm_genlist.
	 */
	genlist = elm_genlist_add(box);
	evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);

	evas_object_data_set(genlist, "app_data", ad);

	itc = elm_genlist_item_class_new();
	itc->item_style = "full";
	itc->func.text_get = NULL;
	itc->func.content_get = gl_entry_content_get;
	itc->func.state_get = NULL;
	itc->func.del = NULL;

	/* append item of genlist as method */
	if (method == METHOD_GPS) {
		elm_genlist_item_append(genlist, itc, "input Latitude", NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
		elm_genlist_item_append(genlist, itc, "input Longitude", NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
	} else
		elm_genlist_item_append(genlist, itc, "input Bssid", NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);

	evas_object_show(genlist);
	elm_box_pack_end(box, genlist);
	if (method == METHOD_GPS)
		evas_object_size_hint_min_set(box, -1, 300);
	else
		evas_object_size_hint_min_set(box, -1, 150);
	elm_object_content_set(s_info.popup, box);

	/*
	 * cancel_btn
	 * Create and initialize elm_genlist.
	 */
	cancel_btn = elm_button_add(s_info.popup);
	elm_object_style_set(cancel_btn, "popup");
	elm_object_text_set(cancel_btn, "Cancel");
	elm_object_part_content_set(s_info.popup, "button1", cancel_btn);
	evas_object_smart_callback_add(cancel_btn, "clicked", popup_cancel_cb, NULL);

	/*
	 * done_btn
	 * Create and initialize elm_genlist.
	 */
	done_btn = elm_button_add(s_info.popup);
	evas_object_data_set(done_btn, "app_data", (void *)ad);
	evas_object_data_set(done_btn, "place_id", (void *)place_id);
	elm_object_style_set(done_btn, "popup");
	elm_object_text_set(done_btn, "Done");
	elm_object_part_content_set(s_info.popup, "button2", done_btn);
	evas_object_smart_callback_add(done_btn, "clicked", popup_method_value_cb, (void *)method);

	evas_object_show(s_info.popup);
	elm_genlist_item_class_free(itc);
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] data The data to be passed to the callback function
 * @param[in] obj The Evas object to be passed to the callback function
 * @param[in] event_info The Event information to be passed to the callback function
 */
static void popup_method_value_cb(void *data, Evas_Object *obj, void *event_info)
{
	appdata_s *ad = evas_object_data_get(obj, "app_data");
	int place_id = (int)evas_object_data_get(obj, "place_id");;
	int method = (int)data;

	const char *value = elm_entry_entry_get(s_info.gen_entry);
	const char *value_nd = elm_entry_entry_get(s_info.gen_entry_nd);

	if (ad == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
		return;
	}

	geofence_h fence = NULL;
	double latitude = 0.0, longitude = 0.0;
	int geofence_id = -1;
	int ret = 0;

	if (!strcmp(value, "")) {
		show_toast_popup("Empty Value");
		return;
	}
	if (method == METHOD_GPS) {
		if (!strcmp(value_nd, "")) {
			show_toast_popup("Empty Value");
			return;
		}
	}

	switch (method) {
	case METHOD_GPS:
		latitude = atof(value);
		longitude = atof(value_nd);
		/* create a handle of geopoint fence */
		ret = geofence_create_geopoint(place_id, latitude, longitude, 200, "Dubai MR", &fence);
		/* show called API */
		elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_create_geopoint</align></font_size>");
		break;
	case METHOD_WIFI:
		/* create a handle of wifi fence */
		ret = geofence_create_wifi(place_id, value, "Dubai MR", &fence);
		/* show called API */
		elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_create_wifi</align></font_size>");
		break;
	case METHOD_BT:
		/* create a handle of bluetooth fence */
		ret = geofence_create_bluetooth(place_id, value, "Dubai MR", &fence);
		/* show called API */
		elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_create_bluetooth</align></font_size>");
		break;
	default:
		break;
	}
	/* show API result */
	showError(s_info.event_entry, ret);
	/* clear the entry of fence state */
	elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
	/* clear the entry of proximity state */
	elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");

	/* add the fence */
	ret = geofence_manager_add_fence(ad->geo_manager, fence, &geofence_id);
	/* show API result */
	showError(s_info.event_entry, ret);

	evas_object_del(s_info.popup);
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] place_id The place id
 * @param[in] place_name The place name
 * @param[in] place_index The place index
 * @param[in] place_cnt The total place
 */
static bool get_place_cb(int place_id, const char *place_name, int place_index, int place_cnt, void *user_data)
{
	appdata_s *ad = (appdata_s *)user_data;

	if (ad == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
		return false;
	}

	ad->place_id[place_index-1] = place_id;

	return true;
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] geofence_id The fence id
 * @param[in] fence_index The fence index
 * @param[in] fence_cnt The total fence
 */
static bool get_fence_cb(int geofence_id, geofence_h fence, int fence_index, int fence_cnt, void *user_data)
{
	appdata_s *ad = (appdata_s *)user_data;

	if (ad == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
		return false;
	}

	ad->fence_id[fence_index-1] = geofence_id;

	return true;
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] data The data to be passed to the callback function
 * @param[in] obj The Evas object to be passed to the callback function
 * @param[in] event_info The Event information to be passed to the callback function
 */
static void get_state_cb(void *data, Evas_Object *obj, void *event_info)
{
	int geofence_id = (int) data;
	geofence_status_h status = NULL;
	geofence_state_e state;
	int seconds = 0;
	int ret = 0;
	char buf[50] = {};
	char *state_str[] = {"UNCERTAIN", "IN", "OUT"};

	evas_object_del(s_info.popup);

	/* create geofence status handle */
	ret = geofence_status_create(geofence_id, &status);

	/* show called API */
	elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_status_create</align></font_size>");
	/* show API result */
	showError(s_info.event_entry, ret);
	/* clear the entry of fence state */
	elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
	/* clear the entry of proximity state */
	elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");

	if (ret != GEOFENCE_MANAGER_ERROR_NONE)
		return;

	/* get state */
	ret = geofence_status_get_state(status, &state);

	/* show called API */
	elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_status_get_state</align></font_size>");
	/* show API result */
	showError(s_info.event_entry, ret);
	/* clear the entry of fence state */
	elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
	/* clear the entry of proximity state */
	elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");

	/* get duration */
	ret = geofence_status_get_duration(status, &seconds);

	/* show called API */
	elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_status_get_duration</align></font_size>");
	/* show API result */
	showError(s_info.event_entry, ret);
	/* clear the entry of fence state */
	elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
	/* clear the entry of proximity state */
	elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");

	if (ret != GEOFENCE_MANAGER_ERROR_NONE)
		return;

	/* destroy geofence status handle */
	ret = geofence_status_destroy(status);

	/* show called API */
	elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_status_destroy</align></font_size>");
	/* show API result */
	showError(s_info.event_entry, ret);
	/* show fence state */
	snprintf(buf, sizeof(buf), "Fence ID: %d, State: %s, Duration: %d", geofence_id, state_str[state], seconds);
	elm_entry_entry_append(s_info.state_entry, "<font_size=25><align=left>");
	elm_entry_entry_append(s_info.state_entry, buf);
	elm_entry_entry_append(s_info.state_entry, "</align></font_size>");
	/* clear the entry of proximity state */
	elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] geofence_id The fence id
 * @param[in] fence The fence handle
 * @param[in] fence_index The fence index
 * @param[in] fence_cnt The total fence
 */
static bool get_started_fence_cb(int geofence_id, geofence_h fence, int fence_index, int fence_cnt, void *user_data)
{
	appdata_s *ad = (appdata_s *)user_data;
	geofence_status_h status = NULL;
	geofence_state_e state;
	int ret = 0;

	if (ad == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
		return false;
	}

	/* create geofence status handle */
	ret = geofence_status_create(geofence_id, &status);
	/* show called API */
	elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_status_create</align></font_size>");
	/* show API result */
	showError(s_info.event_entry, ret);
	/* clear the entry of fence state */
	elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
	/* clear the entry of proximity state */
	elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");

	if (ret != GEOFENCE_MANAGER_ERROR_NONE)
		return false;

	/* get state */
	ret = geofence_status_get_state(status, &state);
	/* show called API */
	elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_status_get_state</align></font_size>");
	/* show API result */
	showError(s_info.event_entry, ret);
	/* clear the entry of fence state */
	elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
	/* clear the entry of proximity state */
	elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");

	if (ret != GEOFENCE_MANAGER_ERROR_NONE)
		return false;

	if (state != GEOFENCE_STATE_UNCERTAIN) {
		ad->fence_id[myfence_index] = geofence_id;
		myfence_index++;
	}

	/* destroy geofence status handle */
	ret = geofence_status_destroy(status);
	/* show called API */
	elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_status_destroy</align></font_size>");
	/* show API result */
	showError(s_info.event_entry, ret);
	/* clear the entry of fence state */
	elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
	/* clear the entry of proximity state */
	elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");

	if (ret != GEOFENCE_MANAGER_ERROR_NONE)
		return false;

	return true;
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] geofence_id The fence id
 * @param[in] fence The fence handle
 * @param[in] fence_index The fence index
 * @param[in] fence_cnt The total fence
 */
static bool get_stopped_fence_cb(int geofence_id, geofence_h fence, int fence_index, int fence_cnt, void *user_data)
{
	appdata_s *ad = (appdata_s *)user_data;
	geofence_status_h status = NULL;
	geofence_state_e state;
	int ret = 0;

	if (ad == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
		return false;
	}

	/* create geofence status handle */
	ret = geofence_status_create(geofence_id, &status);
	/* show called API */
	elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_status_create</align></font_size>");
	/* show API result */
	showError(s_info.event_entry, ret);
	/* clear the entry of fence state */
	elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
	/* clear the entry of proximity state */
	elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");

	if (ret != GEOFENCE_MANAGER_ERROR_NONE)
		return false;

	/* get state */
	ret = geofence_status_get_state(status, &state);
	/* show called API */
	elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_status_get_state</align></font_size>");
	/* show API result */
	showError(s_info.event_entry, ret);
	/* clear the entry of fence state */
	elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
	/* clear the entry of proximity state */
	elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");

	if (ret != GEOFENCE_MANAGER_ERROR_NONE)
		return false;

	if (state == GEOFENCE_STATE_UNCERTAIN) {
		ad->fence_id[myfence_index] = geofence_id;
		myfence_index++;
	}

	/* destroy geofence status handle */
	ret = geofence_status_destroy(status);
	/* show called API */
	elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_status_destroy</align></font_size>");
	/* show API result */
	showError(s_info.event_entry, ret);
	/* clear the entry of fence state */
	elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
	/* clear the entry of proximity state */
	elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");

	if (ret != GEOFENCE_MANAGER_ERROR_NONE)
		return false;

	return true;
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] data The data to be passed to the callback function
 * @param[in] obj The Evas object to be passed to the callback function
 * @param[in] event_info The Event information to be passed to the callback function
 */
static void add_fence_cb(void *data, Evas_Object *obj, void *event_info)
{
	appdata_s *ad = evas_object_data_get(obj, "app_data");
	int place_id = (int) data;

	evas_object_del(s_info.popup);
	select_method_list(ad, add_fence_nd_cb, place_id);
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] data The data to be passed to the callback function
 * @param[in] obj The Evas object to be passed to the callback function
 * @param[in] event_info The Event information to be passed to the callback function
 */
static void add_fence_nd_cb(void *data, Evas_Object *obj, void *event_info)
{
	appdata_s *ad = evas_object_data_get(obj, "app_data");
	int place_id = (int)evas_object_data_get(obj, "place_id");
	int method = (int) data;

	evas_object_del(s_info.popup);
	insert_fence_value(ad, place_id, method);
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] data The data to be passed to the callback function
 * @param[in] obj The Evas object to be passed to the callback function
 * @param[in] event_info The Event information to be passed to the callback function
 */
static void remove_fence_cb(void *data, Evas_Object *obj, void *event_info)
{
	appdata_s *ad = evas_object_data_get(obj, "app_data");
	int fence_id = (int) data;
	int ret = 0;

	if (ad == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
		return;
	}

	evas_object_del(s_info.popup);

	/* remove the fence */
	ret = geofence_manager_remove_fence(ad->geo_manager, fence_id);

	/* show called API */
	elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_manager_remove_fence</align></font_size>");
	/* show API result */
	showError(s_info.event_entry, ret);
	/* clear the entry of fence state */
	elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
	/* clear the entry of proximity state */
	elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] data The data to be passed to the callback function
 * @param[in] obj The Evas object to be passed to the callback function
 * @param[in] event_info The Event information to be passed to the callback function
 */
static void start_fence_cb(void *data, Evas_Object *obj, void *event_info)
{
	appdata_s *ad = evas_object_data_get(obj, "app_data");
	int fence_id = (int) data;
	int ret = 0;

	if (ad == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
		return;
	}

	evas_object_del(s_info.popup);

	/* start the fence */
	ret = geofence_manager_start(ad->geo_manager, fence_id);

	/* show called API */
	elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_manager_start</align></font_size>");
	/* show API result */
	showError(s_info.event_entry, ret);
	/* clear the entry of fence state */
	elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
	/* clear the entry of proximity state */
	elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] data The data to be passed to the callback function
 * @param[in] obj The Evas object to be passed to the callback function
 * @param[in] event_info The Event information to be passed to the callback function
 */
static void stop_fence_cb(void *data, Evas_Object *obj, void *event_info)
{
	appdata_s *ad = evas_object_data_get(obj, "app_data");
	int fence_id = (int) data;
	int ret = 0;

	if (ad == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
		return;
	}

	evas_object_del(s_info.popup);

	/* stop the fence */
	ret = geofence_manager_stop(ad->geo_manager, fence_id);

	/* show called API */
	elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_manager_stop</align></font_size>");
	/* show API result */
	showError(s_info.event_entry, ret);
	/* clear the entry of fence state */
	elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
	/* clear the entry of proximity state */
	elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] data The data to be passed to the callback function
 * @param[in] obj The Evas object to be passed to the callback function
 * @param[in] event_info The Event information to be passed to the callback function
 */
static void remove_place_cb(void *data, Evas_Object *obj, void *event_info)
{
	appdata_s *ad = evas_object_data_get(obj, "app_data");
	int place_id = (int) data;
	int ret = 0;

	if (ad == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
		return;
	}

	evas_object_del(s_info.popup);

	/* remove the place */
	ret = geofence_manager_remove_place(ad->geo_manager, place_id);

	/* show called API */
	elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_manager_remove_place</align></font_size>");
	/* show API result */
	showError(s_info.event_entry, ret);
	/* show or clear the fence state */
	if (place_id <= 3)
		elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left>The deletion of default place is impossible</align></font_size>");
	else
		elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
	/* clear the entry of proximity state */
	elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] data The data to be passed to the callback function
 * @param[in] obj The Evas object to be passed to the callback function
 * @param[in] event_info The Event information to be passed to the callback function
 */
static void update_place_cb(void *data, Evas_Object *obj, void *event_info)
{
	appdata_s *ad = evas_object_data_get(obj, "app_data");
	int place_id = (int) data;
	char *name = NULL;
	int ret = 0;

	if (ad == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
		return;
	}

	evas_object_del(s_info.popup);

	/* update the place name */
	ret = geofence_manager_get_place_name(ad->geo_manager, place_id, &name);

	/* show called API */
	elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_manager_get_place_name</align></font_size>");
	/* show API result */
	showError(s_info.event_entry, ret);
	/* clear the entry of fence state */
	elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
	/* clear the entry of proximity state */
	elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");

	insert_place_name(ad, s_info.update_place_btn, place_id, name);
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] place_id The place id
 * @param[in] geofence_id The geofence id
 * @param[in] error The enum value of error
 * @param[in] manage The enum value of geofence event
 */
static void show_event_cb(int place_id, int geofence_id, geofence_manager_error_e error, geofence_manage_e manage, void *user_data)
{
	char buf[10] = {};

	/* check error */
	if (error == GEOFENCE_MANAGER_ERROR_NONE) {
		/* check and shoe the geofence event */
		switch (manage) {
		case GEOFENCE_MANAGE_FENCE_ADDED:
			elm_entry_entry_set(s_info.event_entry, "<font_size=25><align=left>GEOFENCE_MANAGE_FENCE_ADDED</align></font_size>");
			snprintf(buf, sizeof(buf), " : %d", geofence_id);
			break;
		case GEOFENCE_MANAGE_FENCE_REMOVED:
			elm_entry_entry_set(s_info.event_entry, "<font_size=25><align=left>GEOFENCE_MANAGE_FENCE_REMOVED</align></font_size>");
			snprintf(buf, sizeof(buf), " : %d", geofence_id);
			break;
		case GEOFENCE_MANAGE_FENCE_STARTED:
			elm_entry_entry_set(s_info.event_entry, "<font_size=25><align=left>GEOFENCE_MANAGE_FENCE_STARTED</align></font_size>");
			snprintf(buf, sizeof(buf), " : %d", geofence_id);
			break;
		case GEOFENCE_MANAGE_FENCE_STOPPED:
			elm_entry_entry_set(s_info.event_entry, "<font_size=25><align=left>GEOFENCE_MANAGE_FENCE_STOPPED</align></font_size>");
			snprintf(buf, sizeof(buf), " : %d", geofence_id);
			break;
		case GEOFENCE_MANAGE_PLACE_ADDED:
			elm_entry_entry_set(s_info.event_entry, "<font_size=25><align=left>GEOFENCE_MANAGE_PLACE_ADDED</align></font_size>");
			snprintf(buf, sizeof(buf), " : %d", place_id);
			break;
		case GEOFENCE_MANAGE_PLACE_REMOVED:
			elm_entry_entry_set(s_info.event_entry, "<font_size=25><align=left>GEOFENCE_MANAGE_PLACE_REMOVED</align></font_size>");
			snprintf(buf, sizeof(buf), " : %d", place_id);
			break;
		case GEOFENCE_MANAGE_PLACE_UPDATED:
			elm_entry_entry_set(s_info.event_entry, "<font_size=25><align=left>GEOFENCE_MANAGE_PLACE_UPDATED</align></font_size>");
			snprintf(buf, sizeof(buf), " : %d", place_id);
			break;
		case GEOFENCE_MANAGE_SETTING_ENABLED:
			elm_entry_entry_set(s_info.event_entry, "<font_size=25><align=left>GEOFENCE_MANAGE_SETTING_ENABLED</align></font_size>");
			break;
		case GEOFENCE_MANAGE_SETTING_DISABLED:
			elm_entry_entry_set(s_info.event_entry, "<font_size=25><align=left>GEOFENCE_MANAGE_SETTING_DISABLED</align></font_size>");
			break;
		default:
			elm_entry_entry_set(s_info.event_entry, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_NONE</align></font_size>");
			break;
		}
		elm_entry_entry_append(s_info.event_entry, "<font_size=30>");
		elm_entry_entry_append(s_info.event_entry, buf);
		elm_entry_entry_append(s_info.event_entry, "</font_size>");
	} else
		showError(s_info.event_entry, error);
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] geofence_id The geofence id
 * @param[in] state The enum value of geofence state
 */
static void show_state_changed_cb(int geofence_id, geofence_state_e state, void *user_data)
{
	char buf[10] = {};

	/* check and show the geofence state */
	if (state == GEOFENCE_STATE_IN)
		elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left>GEOFENCE_STATE_IN");
	else if (state == GEOFENCE_STATE_OUT)
		elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left>GEOFENCE_STATE_OUT");
	else
		elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left>GEOFENCE_STATE_UNCERTAIN");

	snprintf(buf, sizeof(buf), " : %d", geofence_id);
	elm_entry_entry_append(s_info.state_entry, buf);
	elm_entry_entry_append(s_info.state_entry, "</align></font_size>");
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] geofence_id The geofence id
 * @param[in] state The enum value of proximity state
 * @param[in] provider The enum value of proximity provider
 */
static void show_proximity_changed_cb(int geofence_id, geofence_proximity_state_e state, geofence_proximity_provider_e provider, void *user_data)
{
	char buf[10] = {};

	/* check and show the proximity state */
	if (state == GEOFENCE_PROXIMITY_STATE_IMMEDIATE)
		elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left>PROXIMITY_STATE_IMMEDIATE");
	else if (state == GEOFENCE_PROXIMITY_STATE_NEAR)
		elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left>PROXIMITY_STATE_NEAR");
	else if (state == GEOFENCE_PROXIMITY_STATE_FAR)
		elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left>PROXIMITY_STATE_FAR");
	else
		elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left>PROXIMITY_STATE_UNCERTAIN");

	/* check and show the proximity provider */
	if (provider == GEOFENCE_PROXIMITY_PROVIDER_LOCATION)
		elm_entry_entry_append(s_info.proximity_entry, " by LOCATION");
	else if (provider == GEOFENCE_PROXIMITY_PROVIDER_WIFI)
		elm_entry_entry_append(s_info.proximity_entry, " by WIFI");
	else if (provider == GEOFENCE_PROXIMITY_PROVIDER_BLUETOOTH)
		elm_entry_entry_append(s_info.proximity_entry, " by BLUETOOTH");
	else if (provider == GEOFENCE_PROXIMITY_PROVIDER_BLE)
		elm_entry_entry_append(s_info.proximity_entry, " by BLE");
	else
		elm_entry_entry_append(s_info.proximity_entry, " by SENSOR");

	snprintf(buf, sizeof(buf), " : %d", geofence_id);
	elm_entry_entry_append(s_info.proximity_entry, buf);
	elm_entry_entry_append(s_info.proximity_entry, "</align></font_size>");
}

/**
 * @brief Show Errors
 * @param[in] obj The Evas object to be passed to the callback function
 * @param[in] ret The return value of API
 */
static void showError(Evas_Object *obj, int ret)
{
	/* check and show the error */
	switch (ret) {
	case GEOFENCE_MANAGER_ERROR_NONE:
		elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_NONE</align></font_size>");
		break;
	case GEOFENCE_MANAGER_ERROR_OUT_OF_MEMORY:
		elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_OUT_OF_MEMORY</align></font_size>");
		break;
	case GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER:
		elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER</align></font_size>");
		break;
	case GEOFENCE_MANAGER_ERROR_PERMISSION_DENIED:
		elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_PERMISSION_DENIED</align></font_size>");
		break;
	case GEOFENCE_MANAGER_ERROR_NOT_SUPPORTED:
		elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_NOT_SUPPORTED</align></font_size>");
		break;
	case GEOFENCE_MANAGER_ERROR_NOT_INITIALIZED:
		elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_NOT_INITIALIZED</align></font_size>");
		break;
	case GEOFENCE_MANAGER_ERROR_INVALID_ID:
		elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_INVALID_ID</align></font_size>");
		break;
	case GEOFENCE_MANAGER_ERROR_EXCEPTION:
		elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_EXCEPTION</align></font_size>");
		break;
	case GEOFENCE_MANAGER_ERROR_ALREADY_STARTED:
		elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_ALREADY_STARTED</align></font_size>");
		break;
	case GEOFENCE_MANAGER_ERROR_TOO_MANY_GEOFENCE:
		elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_TOO_MANY_GEOFENCE</align></font_size>");
		break;
	case GEOFENCE_MANAGER_ERROR_IPC:
		elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_IPC</align></font_size>");
		break;
	case GEOFENCE_MANAGER_ERROR_DATABASE:
		elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_DATABASE</align></font_size>");
		break;
	case GEOFENCE_MANAGER_ERROR_PLACE_ACCESS_DENIED:
		elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_PLACE_ACCESS_DENIED</align></font_size>");
		break;
	case GEOFENCE_MANAGER_ERROR_GEOFENCE_ACCESS_DENIED:
		elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_GEOFENCE_ACCESS_DENIED</align></font_size>");
		break;
	default:
		elm_entry_entry_set(obj, "<font_size=25><align=left>FAILED with UNKNOWN ERROR</align></font_size>");
		break;
	}
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] data The data to be passed to the callback function
 * @param[in] obj The Evas object handle to be passed to the callback function
 * @param[in] part The part of object
 */
static void popup_cancel_cb(void *data, Evas_Object *obj, void *event_info)
{
	evas_object_del(s_info.popup);
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] data The data to be passed to the callback function
 * @param[in] obj The Evas object handle to be passed to the callback function
 * @param[in] part The part of object
 */
static void popup_place_name_cb(void *data, Evas_Object *obj, void *event_info)
{
	appdata_s *ad = evas_object_data_get(obj, "app_data");
	int ret = 0;
	int place_id = (int)data;
	const char *place_name = elm_entry_entry_get(s_info.gen_entry);

	if (ad == NULL) {
		dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
		return;
	}

	/* check that a name is inserted or not */
	if (!strcmp(place_name, "")) {
		show_toast_popup("Empty Value");
		return;
	}

	if (place_id < 0) {
		/* add place */
		ret = geofence_manager_add_place(ad->geo_manager, place_name, &place_id);
		/* show called API */
		elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_manager_add_place</align></font_size>");
	} else {
		/* update place */
		ret = geofence_manager_update_place(ad->geo_manager, place_id, place_name);
		/* show called API */
		elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_manager_update_place</align></font_size>");
	}

	/* show API result */
	showError(s_info.event_entry, ret);

	/* show or clear the geofence state */
	if (place_id > 0 && place_id <= 3)
		elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left>The renaming of default place is impossible</align></font_size>");
	else
		elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");

	/* clear the proximity state */
	elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
	evas_object_del(s_info.popup);
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] data The data to be passed to the callback function
 * @param[in] obj The Evas object handle to be passed to the callback function
 * @param[in] part The part of object
 */
static char *gl_id_text_get_cb(void *data, Evas_Object *obj, const char *part)
{
	char buf[10] = {};
	snprintf(buf, sizeof(buf), "ID : %d", (int)data);
	return strdup(buf);
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] data The data to be passed to the callback function
 * @param[in] obj The Evas object handle to be passed to the callback function
 * @param[in] part The part of object
 */
static char *gl_method_text_get_cb(void *data, Evas_Object *obj, const char *part)
{
	switch ((int)data) {
	case METHOD_GPS:
		return strdup("GPS");
	case METHOD_WIFI:
		return strdup("Wi-Fi");
	case METHOD_BT:
		return strdup("Bluetooth");
	default:
		break;
	}
	return NULL;
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] data The data to be passed to the callback function
 * @param[in] obj The Evas object handle to be passed to the callback function
 * @param[in] part The part of object
 */
static Evas_Object *gl_entry_content_get(void *data, Evas_Object *obj, const char *part)
{
	char *value = evas_object_data_get(obj, "value");

	if (!strcmp(part, "elm.swallow.content")) {
		/*
		 * editfield
		 * Create and initialize elm_layout.
		 */
		Evas_Object *editfield = elm_layout_add(obj);
		elm_layout_theme_set(editfield, "layout", "searchfield", "singleline");
		evas_object_size_hint_align_set(editfield, EVAS_HINT_FILL, 0.0);
		evas_object_size_hint_weight_set(editfield, EVAS_HINT_EXPAND, 0.0);
		eext_entry_selection_back_event_allow_set(editfield, EINA_TRUE);

		/* check that the entry is for latitude or longitude */
		if (!strcmp(data, "input Longitude")) {
			/*
			 * gen_entry_nd
			 * Create and initialize elm_entry.
			 */
			s_info.gen_entry_nd = elm_entry_add(editfield);
			evas_object_size_hint_weight_set(s_info.gen_entry_nd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
			evas_object_size_hint_align_set(s_info.gen_entry_nd, EVAS_HINT_FILL, EVAS_HINT_FILL);
			elm_entry_single_line_set(s_info.gen_entry_nd, EINA_TRUE);
			elm_entry_scrollable_set(s_info.gen_entry_nd, EINA_TRUE);
			evas_object_show(s_info.gen_entry_nd);

			if (value == NULL)
				elm_object_part_text_set(s_info.gen_entry_nd, "elm.guide", data);
			else
				elm_entry_entry_set(s_info.gen_entry_nd, value);
			elm_object_part_content_set(editfield, "elm.swallow.content", s_info.gen_entry_nd);
		} else {
			/*
			 * gen_entry
			 * Create and initialize elm_entry.
			 */
			s_info.gen_entry = elm_entry_add(editfield);
			evas_object_size_hint_weight_set(s_info.gen_entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
			evas_object_size_hint_align_set(s_info.gen_entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
			elm_entry_single_line_set(s_info.gen_entry, EINA_TRUE);
			elm_entry_scrollable_set(s_info.gen_entry, EINA_TRUE);
			evas_object_show(s_info.gen_entry);

			if (value == NULL)
				elm_object_part_text_set(s_info.gen_entry, "elm.guide", data);
			else
				elm_entry_entry_set(s_info.gen_entry, value);
			elm_object_part_content_set(editfield, "elm.swallow.content", s_info.gen_entry);
		}
		return editfield;
	}
	return NULL;
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] str The string to display on toast popup
 */
static void show_toast_popup(char *str)
{
	Evas_Object *popup;

	/*
	 * popup
	 * Create and initialize elm_popup.
	 */
	popup = elm_popup_add(s_info.win);
	elm_object_style_set(popup, "toast");
	evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	elm_object_text_set(popup, str);

	/* set timeout for toast popup */
	elm_popup_timeout_set(popup, 2.0);
	/* set callback for timeout of popup */
	evas_object_smart_callback_add(popup, "timeout", popup_timeout_cb, NULL);

	evas_object_show(popup);
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] data The data to be passed to the callback function
 * @param[in] obj The Evas object handle to be passed to the callback function
 * @param[in] event_info The system event information
 */
static void popup_timeout_cb(void *data, Evas_Object *obj, void *event_info)
{
	/* delete the object */
	evas_object_del(obj);
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] data The data to be passed to the callback function
 * @param[in] it The Evas object item to be passed to the callback function
 */
static Eina_Bool naviframe_pop_cb(void *data, Elm_Object_Item *it)
{
	ui_app_exit();
	return EINA_TRUE;
}

/**
 * @brief Function will be operated when registered event is triggered.
 * @param[in] data The data to be passed to the callback function
 * @param[in] obj The Evas object handle to be passed to the callback function
 * @param[in] event_info The system event information
 */
static void _win_delete_request_cb(void *data, Evas_Object *obj, void *event_info)
{
	/*
	 * Write your code here for smart callback.
	 */
	ui_app_exit();
}