Geofence3 / src /

view.c

  1. /*
  2. * Copyright (c) 2016 Samsung Electronics Co., Ltd
  3. *
  4. * Licensed under the Flora License, Version 1.1 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://floralicense.org/license/
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16.  
  17. #include <tizen.h>
  18. #include <dlog.h>
  19. #include <app.h>
  20. #include <efl_extension.h>
  21. #include <Elementary.h>
  22. #include <system_info.h>
  23.  
  24. #include "$(appName).h"
  25. #include "view.h"
  26. #include "data.h"
  27.  
  28. int myfence_index = 0;
  29.  
  30. static struct view_info {
  31. Evas_Object *win;
  32. Evas_Object *conform;
  33. Evas_Object *nf;
  34. Evas_Object *entry;
  35. Evas_Object *event_entry;
  36. Evas_Object *state_entry;
  37. Evas_Object *proximity_entry;
  38. Evas_Object *table;
  39.  
  40. Evas_Object *create_btn;
  41. Evas_Object *fence_state_btn;
  42. Evas_Object *add_fence_btn;
  43. Evas_Object *add_place_btn;
  44. Evas_Object *start_btn;
  45. Evas_Object *stop_btn;
  46. Evas_Object *remove_fence_btn;
  47. Evas_Object *remove_place_btn;
  48. Evas_Object *update_place_btn;
  49. Evas_Object *destroy_btn;
  50.  
  51. Evas_Object *popup;
  52. Evas_Object *gen_entry;
  53. Evas_Object *gen_entry_nd;
  54. } s_info = {
  55. .win = NULL,
  56. .conform = NULL,
  57. .nf = NULL,
  58. .entry = NULL,
  59. .event_entry = NULL,
  60. .state_entry = NULL,
  61. .proximity_entry = NULL,
  62. .table = NULL,
  63. .create_btn = NULL,
  64. .fence_state_btn = NULL,
  65. .add_fence_btn = NULL,
  66. .add_place_btn = NULL,
  67. .start_btn = NULL,
  68. .stop_btn = NULL,
  69. .remove_fence_btn = NULL,
  70. .remove_place_btn = NULL,
  71. .update_place_btn = NULL,
  72. .destroy_btn = NULL,
  73. .popup = NULL,
  74. .gen_entry = NULL,
  75. .gen_entry_nd = NULL,
  76. };
  77.  
  78. static Evas_Object *view_create_naviframe(Evas_Object *conform);
  79. static Evas_Object *view_create_grid_and_content(Evas_Object *nf, appdata_s *ad);
  80. static Evas_Object *create_entry(Evas_Object *grid);
  81. static Evas_Object *create_panel_and_content(Evas_Object *grid, appdata_s *ad);
  82. static Evas_Object *create_panel_basic_content(Evas_Object *panel, appdata_s *ad);
  83.  
  84. static void clicked_create_cb(void *data, Evas_Object *obj, void *event_info);
  85. static void clicked_destroy_cb(void *data, Evas_Object *obj, void *event_info);
  86. static void show_popup_cb(void *data, Evas_Object *obj, void *event_info);
  87.  
  88. static void select_fence_list(appdata_s *ad, Evas_Smart_Cb func);
  89. static void select_place_list(appdata_s *ad, Evas_Smart_Cb func);
  90. static void select_method_list(appdata_s *ad, Evas_Smart_Cb func, int place_id);
  91. static void insert_place_name(appdata_s *ad, Evas_Object *obj, int place_id, char *place_name);
  92. static void insert_fence_value(appdata_s *ad, int place_id, int method);
  93. static void popup_method_value_cb(void *data, Evas_Object *obj, void *event_info);
  94.  
  95. static bool get_place_cb(int place_id, const char *place_name, int place_index, int place_cnt, void *user_data);
  96. static bool get_fence_cb(int geofence_id, geofence_h fence, int fence_index, int fence_cnt, void *user_data);
  97. static void get_state_cb(void *data, Evas_Object *obj, void *event_info);
  98. static bool get_started_fence_cb(int geofence_id, geofence_h fence, int fence_index, int fence_cnt, void *user_data);
  99. static bool get_stopped_fence_cb(int geofence_id, geofence_h fence, int fence_index, int fence_cnt, void *user_data);
  100.  
  101. static void add_fence_cb(void *data, Evas_Object *obj, void *event_info);
  102. static void add_fence_nd_cb(void *data, Evas_Object *obj, void *event_info);
  103. static void remove_fence_cb(void *data, Evas_Object *obj, void *event_info);
  104. static void start_fence_cb(void *data, Evas_Object *obj, void *event_info);
  105. static void stop_fence_cb(void *data, Evas_Object *obj, void *event_info);
  106. static void remove_place_cb(void *data, Evas_Object *obj, void *event_info);
  107. static void update_place_cb(void *data, Evas_Object *obj, void *event_info);
  108.  
  109. static void show_event_cb(int place_id, int geofence_id, geofence_manager_error_e error, geofence_manage_e manage, void *user_data);
  110. static void show_state_changed_cb(int geofence_id, geofence_state_e state, void *user_data);
  111. static void show_proximity_changed_cb(int geofence_id, geofence_proximity_state_e state, geofence_proximity_provider_e provider, void *user_data);
  112. static void showError(Evas_Object *obj, int ret);
  113.  
  114. static void popup_cancel_cb(void *data, Evas_Object *obj, void *event_info);
  115. static void popup_place_name_cb(void *data, Evas_Object *obj, void *event_info);
  116.  
  117. static char *gl_id_text_get_cb(void *data, Evas_Object *obj, const char *part);
  118. static char *gl_method_text_get_cb(void *data, Evas_Object *obj, const char *part);
  119. static Evas_Object *gl_entry_content_get(void *data, Evas_Object *obj, const char *part);
  120.  
  121. static void show_toast_popup(char *str);
  122. static void popup_timeout_cb(void *data, Evas_Object *obj, void *event_info);
  123. static Eina_Bool naviframe_pop_cb(void *data, Elm_Object_Item *it);
  124. static void _win_delete_request_cb(void *data, Evas_Object *obj, void *event_info);
  125.  
  126. /**
  127. * @brief Creates objects of view : window, conformant.
  128. */
  129. Eina_Bool view_create(void *user_data)
  130. {
  131. /* Create the window */
  132. s_info.win = view_create_win(PACKAGE);
  133. if (s_info.win == NULL) {
  134. dlog_print(DLOG_ERROR, LOG_TAG, "failed to create a window.");
  135. return EINA_FALSE;
  136. }
  137.  
  138. /* Create the conformant */
  139. s_info.conform = view_create_conformant_without_indicator(s_info.win);
  140. if (s_info.conform == NULL) {
  141. dlog_print(DLOG_ERROR, LOG_TAG, "failed to create a conformant");
  142. return EINA_FALSE;
  143. }
  144.  
  145. /* Create the naviframe */
  146. s_info.nf = view_create_naviframe(s_info.conform);
  147. if (s_info.nf == NULL) {
  148. dlog_print(DLOG_ERROR, LOG_TAG, "failed to create a naviframe");
  149. return EINA_FALSE;
  150. }
  151.  
  152. /* Create the grid and content of grid */
  153. Evas_Object *grid = view_create_grid_and_content(s_info.nf, (appdata_s *)user_data);
  154. if (grid == NULL) {
  155. dlog_print(DLOG_ERROR, LOG_TAG, "failed to create a grid");
  156. return EINA_FALSE;
  157. }
  158.  
  159. /* push an item to the naviframe */
  160. Elm_Object_Item *nf_it = elm_naviframe_item_push(s_info.nf, "Geofence", NULL, NULL, grid, NULL);
  161. elm_naviframe_item_pop_cb_set(nf_it, naviframe_pop_cb, NULL);
  162.  
  163. /* Show the window after main view is set up */
  164. evas_object_show(s_info.win);
  165. return EINA_TRUE;
  166. }
  167.  
  168. /**
  169. * @brief Creates a basic window named package.
  170. * @param[in] pkg_name Name of the window
  171. */
  172. Evas_Object *view_create_win(const char *pkg_name)
  173. {
  174. Evas_Object *win = NULL;
  175.  
  176. /*
  177. * Window
  178. * Create and initialize elm_win.
  179. * elm_win is mandatory to manipulate the window.
  180. */
  181. win = elm_win_util_standard_add(pkg_name, pkg_name);
  182. elm_win_conformant_set(win, EINA_TRUE);
  183. elm_win_autodel_set(win, EINA_TRUE);
  184.  
  185. evas_object_smart_callback_add(win, "delete,request", _win_delete_request_cb, NULL);
  186.  
  187. return win;
  188. }
  189.  
  190. /**
  191. * @brief Creates a conformant without indicator for wearable app.
  192. * @param[in] win The object to which you want to set this conformant
  193. * Conformant is mandatory for base GUI to have proper size
  194. */
  195. Evas_Object *view_create_conformant_without_indicator(Evas_Object *win)
  196. {
  197. /*
  198. * Conformant
  199. * Create and initialize elm_conformant.
  200. * elm_conformant is mandatory for base GUI to have proper size
  201. * when indicator or virtual keypad is visible.
  202. */
  203. Evas_Object *conform = NULL;
  204.  
  205. if (win == NULL) {
  206. dlog_print(DLOG_ERROR, LOG_TAG, "window is NULL.");
  207. return NULL;
  208. }
  209.  
  210. conform = elm_conformant_add(win);
  211. evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  212. elm_win_resize_object_add(win, conform);
  213.  
  214. evas_object_show(conform);
  215.  
  216. return conform;
  217. }
  218.  
  219. /**
  220. * @brief Destroys window and frees its resources.
  221. */
  222. void view_destroy(void)
  223. {
  224. if (s_info.win == NULL)
  225. return;
  226.  
  227. evas_object_del(s_info.win);
  228. }
  229.  
  230. /**
  231. * @brief Creates a naviframe
  232. * @param[in] conform The object to which you want to set this naviframe
  233. */
  234. static Evas_Object *view_create_naviframe(Evas_Object *conform)
  235. {
  236. /*
  237. * Naviframe
  238. * Create and initialize elm_naviframe.
  239. */
  240. Evas_Object *nf = NULL;
  241.  
  242. if (conform == NULL) {
  243. dlog_print(DLOG_ERROR, LOG_TAG, "conform is NULL.");
  244. return NULL;
  245. }
  246.  
  247. nf = elm_naviframe_add(conform);
  248. elm_object_part_content_set(conform, "elm.swallow.content", nf);
  249. eext_object_event_callback_add(nf, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
  250.  
  251. evas_object_show(nf);
  252.  
  253. return nf;
  254. }
  255.  
  256. /**
  257. * @brief Creates a grid
  258. * @param[in] nf The object to which you want to set this grid
  259. */
  260. static Evas_Object *view_create_grid_and_content(Evas_Object *nf, appdata_s *ad)
  261. {
  262. /*
  263. * grid
  264. * Create and initialize elm_grid.
  265. */
  266. Evas_Object *grid = NULL;
  267.  
  268. if (nf == NULL) {
  269. dlog_print(DLOG_ERROR, LOG_TAG, "naviframe is NULL.");
  270. return NULL;
  271. }
  272.  
  273. grid = elm_grid_add(nf);
  274. evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  275. evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
  276. elm_object_content_set(nf, grid);
  277.  
  278. /* Entry for API name */
  279. s_info.entry = create_entry(grid);
  280. elm_grid_pack(grid, s_info.entry, 0, 5, 90, 10);
  281.  
  282. /* Entry for API result */
  283. s_info.event_entry = create_entry(grid);
  284. elm_grid_pack(grid, s_info.event_entry, 0, 15, 90, 10);
  285.  
  286. /* Entry for fence state */
  287. s_info.state_entry = create_entry(grid);
  288. elm_grid_pack(grid, s_info.state_entry, 0, 25, 90, 10);
  289.  
  290. /* Entry for proximity state */
  291. s_info.proximity_entry = create_entry(grid);
  292. elm_grid_pack(grid, s_info.proximity_entry, 0, 35, 90, 10);
  293.  
  294. /* Panel */
  295. Evas_Object *panel = create_panel_and_content(grid, ad);
  296. elm_grid_pack(grid, panel, 0, 55, 100, 45);
  297.  
  298. return grid;
  299. }
  300.  
  301. /**
  302. * @brief Creates a entry
  303. * @param[in] grid The object to which you want to set this entry
  304. */
  305. static Evas_Object *create_entry(Evas_Object *grid)
  306. {
  307. /*
  308. * entry
  309. * Create and initialize elm_entry.
  310. */
  311. Evas_Object *entry = NULL;
  312.  
  313. if (grid == NULL) {
  314. dlog_print(DLOG_ERROR, LOG_TAG, "grid is NULL.");
  315. return NULL;
  316. }
  317.  
  318. entry = elm_entry_add(grid);
  319. elm_entry_editable_set(entry, EINA_FALSE);
  320. elm_entry_context_menu_disabled_set(entry, EINA_TRUE);
  321. elm_entry_entry_set(entry, "<font_size=30><align=left></align></font_size>");
  322. evas_object_show(entry);
  323.  
  324. return entry;
  325. }
  326.  
  327. /**
  328. * @brief Creates a panel and contents
  329. * @param[in] grid The object to which you want to set this panel
  330. */
  331. static Evas_Object *create_panel_and_content(Evas_Object *grid, appdata_s *ad)
  332. {
  333. /*
  334. * panel
  335. * Create and initialize elm_panel.
  336. */
  337. Evas_Object *panel = NULL;
  338.  
  339. if (grid == NULL) {
  340. dlog_print(DLOG_ERROR, LOG_TAG, "grid is NULL.");
  341. return NULL;
  342. }
  343.  
  344. /* Panel */
  345. panel = elm_panel_add(grid);
  346. evas_object_show(panel);
  347.  
  348. /*
  349. * button_grid
  350. * Create and initialize elm_grid.
  351. */
  352. Evas_Object *button_grid = NULL;
  353.  
  354. if (panel == NULL) {
  355. dlog_print(DLOG_ERROR, LOG_TAG, "panel is NULL.");
  356. return NULL;
  357. }
  358.  
  359. /* Grid */
  360. button_grid = elm_grid_add(panel);
  361. evas_object_size_hint_weight_set(button_grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  362. evas_object_size_hint_align_set(button_grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
  363. elm_object_content_set(panel, button_grid);
  364.  
  365. if (button_grid == NULL) {
  366. dlog_print(DLOG_ERROR, LOG_TAG, "button_grid is NULL.");
  367. return NULL;
  368. }
  369.  
  370. /* Panel basic content */
  371. s_info.table = create_panel_basic_content(button_grid, ad);
  372. evas_object_size_hint_weight_set(s_info.table, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  373. evas_object_size_hint_align_set(s_info.table, EVAS_HINT_FILL, EVAS_HINT_FILL);
  374. elm_grid_pack(button_grid, s_info.table, 3, 3, 94, 94);
  375.  
  376. return panel;
  377. }
  378.  
  379. /**
  380. * @brief Creates a table and buttons
  381. * @param[in] panel The object to which you want to set this table
  382. */
  383. static Evas_Object *create_panel_basic_content(Evas_Object *panel, appdata_s *ad)
  384. {
  385. /*
  386. * table
  387. * Create and initialize elm_table.
  388. */
  389. Evas_Object *table = NULL;
  390.  
  391. if (panel == NULL) {
  392. dlog_print(DLOG_ERROR, LOG_TAG, "panel is NULL.");
  393. return NULL;
  394. }
  395.  
  396. table = elm_table_add(panel);
  397. elm_table_padding_set(table, 10, 5);
  398.  
  399. /*
  400. * create_btn
  401. * Create and initialize elm_button.
  402. */
  403. s_info.create_btn = elm_button_add(table);
  404. evas_object_size_hint_weight_set(s_info.create_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  405. evas_object_size_hint_align_set(s_info.create_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
  406. elm_object_text_set(s_info.create_btn, "<font_size=30>Create</font_size>");
  407. elm_object_disabled_set(s_info.create_btn, EINA_FALSE);
  408. evas_object_smart_callback_add(s_info.create_btn, "clicked", clicked_create_cb, ad);
  409. evas_object_show(s_info.create_btn);
  410. elm_table_pack(table, s_info.create_btn, 0, 0, 1, 1);
  411.  
  412. /*
  413. * fence_state_btn
  414. * Create and initialize elm_button.
  415. */
  416. s_info.fence_state_btn = elm_button_add(table);
  417. evas_object_size_hint_weight_set(s_info.fence_state_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  418. evas_object_size_hint_align_set(s_info.fence_state_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
  419. elm_object_text_set(s_info.fence_state_btn, "<font_size=30>Fence Status</font_size>");
  420. elm_object_disabled_set(s_info.fence_state_btn, EINA_TRUE);
  421. evas_object_smart_callback_add(s_info.fence_state_btn, "clicked", show_popup_cb, ad);
  422. evas_object_show(s_info.fence_state_btn);
  423. elm_table_pack(table, s_info.fence_state_btn, 1, 0, 1, 1);
  424.  
  425. /*
  426. * add_fence_btn
  427. * Create and initialize elm_button.
  428. */
  429. s_info.add_fence_btn = elm_button_add(table);
  430. evas_object_size_hint_weight_set(s_info.add_fence_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  431. evas_object_size_hint_align_set(s_info.add_fence_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
  432. elm_object_text_set(s_info.add_fence_btn, "<font_size=30>Add Fence</font_size>");
  433. elm_object_disabled_set(s_info.add_fence_btn, EINA_TRUE);
  434. evas_object_smart_callback_add(s_info.add_fence_btn, "clicked", show_popup_cb, ad);
  435. evas_object_show(s_info.add_fence_btn);
  436. elm_table_pack(table, s_info.add_fence_btn, 0, 1, 1, 1);
  437.  
  438. /*
  439. * add_place_btn
  440. * Create and initialize elm_button.
  441. */
  442. s_info.add_place_btn = elm_button_add(table);
  443. evas_object_size_hint_weight_set(s_info.add_place_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  444. evas_object_size_hint_align_set(s_info.add_place_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
  445. elm_object_text_set(s_info.add_place_btn, "<font_size=30>Add Place</font_size>");
  446. elm_object_disabled_set(s_info.add_place_btn, EINA_TRUE);
  447. evas_object_smart_callback_add(s_info.add_place_btn, "clicked", show_popup_cb, ad);
  448. evas_object_show(s_info.add_place_btn);
  449. elm_table_pack(table, s_info.add_place_btn, 1, 1, 1, 1);
  450.  
  451. /*
  452. * start_btn
  453. * Create and initialize elm_button.
  454. */
  455. s_info.start_btn = elm_button_add(table);
  456. evas_object_size_hint_weight_set(s_info.start_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  457. evas_object_size_hint_align_set(s_info.start_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
  458. elm_object_text_set(s_info.start_btn, "<font_size=30>Start</font_size>");
  459. elm_object_disabled_set(s_info.start_btn, EINA_TRUE);
  460. evas_object_smart_callback_add(s_info.start_btn, "clicked", show_popup_cb, ad);
  461. evas_object_show(s_info.start_btn);
  462. elm_table_pack(table, s_info.start_btn, 0, 2, 1, 1);
  463.  
  464. /*
  465. * stop_btn
  466. * Create and initialize elm_button.
  467. */
  468. s_info.stop_btn = elm_button_add(table);
  469. evas_object_size_hint_weight_set(s_info.stop_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  470. evas_object_size_hint_align_set(s_info.stop_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
  471. elm_object_text_set(s_info.stop_btn, "<font_size=30>Stop</font_size>");
  472. elm_object_disabled_set(s_info.stop_btn, EINA_TRUE);
  473. evas_object_smart_callback_add(s_info.stop_btn, "clicked", show_popup_cb, ad);
  474. evas_object_show(s_info.stop_btn);
  475. elm_table_pack(table, s_info.stop_btn, 1, 2, 1, 1);
  476.  
  477. /*
  478. * remove_fence_btn
  479. * Create and initialize elm_button.
  480. */
  481. s_info.remove_fence_btn = elm_button_add(table);
  482. evas_object_size_hint_weight_set(s_info.remove_fence_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  483. evas_object_size_hint_align_set(s_info.remove_fence_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
  484. elm_object_text_set(s_info.remove_fence_btn, "<font_size=30>Remove Fence</font_size>");
  485. elm_object_disabled_set(s_info.remove_fence_btn, EINA_TRUE);
  486. evas_object_smart_callback_add(s_info.remove_fence_btn, "clicked", show_popup_cb, ad);
  487. evas_object_show(s_info.remove_fence_btn);
  488. elm_table_pack(table, s_info.remove_fence_btn, 0, 3, 1, 1);
  489.  
  490. /*
  491. * remove_place_btn
  492. * Create and initialize elm_button.
  493. */
  494. s_info.remove_place_btn = elm_button_add(table);
  495. evas_object_size_hint_weight_set(s_info.remove_place_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  496. evas_object_size_hint_align_set(s_info.remove_place_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
  497. elm_object_text_set(s_info.remove_place_btn, "<font_size=30>Remove Place</font_size>");
  498. elm_object_disabled_set(s_info.remove_place_btn, EINA_TRUE);
  499. evas_object_smart_callback_add(s_info.remove_place_btn, "clicked", show_popup_cb, ad);
  500. evas_object_show(s_info.remove_place_btn);
  501. elm_table_pack(table, s_info.remove_place_btn, 1, 3, 1, 1);
  502.  
  503. /*
  504. * update_place_btn
  505. * Create and initialize elm_button.
  506. */
  507. s_info.update_place_btn = elm_button_add(table);
  508. evas_object_size_hint_weight_set(s_info.update_place_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  509. evas_object_size_hint_align_set(s_info.update_place_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
  510. elm_object_text_set(s_info.update_place_btn, "<font_size=30>Update Place</font_size>");
  511. elm_object_disabled_set(s_info.update_place_btn, EINA_TRUE);
  512. evas_object_smart_callback_add(s_info.update_place_btn, "clicked", show_popup_cb, ad);
  513. evas_object_show(s_info.update_place_btn);
  514. elm_table_pack(table, s_info.update_place_btn, 0, 4, 1, 1);
  515.  
  516. /*
  517. * destroy_btn
  518. * Create and initialize elm_button.
  519. */
  520. s_info.destroy_btn = elm_button_add(table);
  521. evas_object_size_hint_weight_set(s_info.destroy_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  522. evas_object_size_hint_align_set(s_info.destroy_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
  523. elm_object_text_set(s_info.destroy_btn, "<font_size=30>Destroy</font_size>");
  524. elm_object_disabled_set(s_info.destroy_btn, EINA_TRUE);
  525. evas_object_smart_callback_add(s_info.destroy_btn, "clicked", clicked_destroy_cb, ad);
  526. evas_object_show(s_info.destroy_btn);
  527. elm_table_pack(table, s_info.destroy_btn, 1, 4, 1, 1);
  528.  
  529. evas_object_show(table);
  530.  
  531. return table;
  532. }
  533.  
  534. /**
  535. * @brief Function will be operated when registered event is triggered.
  536. * @param[in] data The data to be passed to the callback function
  537. * @param[in] obj The Evas object to be passed to the callback function
  538. * @param[in] event_info The Event information to be passed to the callback function
  539. */
  540. static void clicked_create_cb(void *data, Evas_Object *obj, void *event_info)
  541. {
  542. appdata_s *ad = (appdata_s *) data;
  543. int ret = 0;
  544.  
  545. if (ad == NULL) {
  546. dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
  547. return;
  548. }
  549.  
  550. /* Create geofence handle */
  551. ret = geofence_manager_create(&(ad->geo_manager));
  552.  
  553. /* show called API */
  554. elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_manager_create</align></font_size>");
  555. /* show API result */
  556. showError(s_info.event_entry, ret);
  557. /* clear the entry of fence state */
  558. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
  559. /* clear the entry of proximity state */
  560. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
  561.  
  562. /* enable button when geofence handle is created */
  563. if (ret == GEOFENCE_MANAGER_ERROR_NONE) {
  564. elm_object_disabled_set(s_info.create_btn, EINA_TRUE);
  565. elm_object_disabled_set(s_info.fence_state_btn, EINA_FALSE);
  566. elm_object_disabled_set(s_info.add_fence_btn, EINA_FALSE);
  567. elm_object_disabled_set(s_info.add_place_btn, EINA_FALSE);
  568. elm_object_disabled_set(s_info.start_btn, EINA_FALSE);
  569. elm_object_disabled_set(s_info.stop_btn, EINA_FALSE);
  570. elm_object_disabled_set(s_info.remove_fence_btn, EINA_FALSE);
  571. elm_object_disabled_set(s_info.remove_place_btn, EINA_FALSE);
  572. elm_object_disabled_set(s_info.update_place_btn, EINA_FALSE);
  573. elm_object_disabled_set(s_info.destroy_btn, EINA_FALSE);
  574.  
  575. /* set callback for geofence event */
  576. geofence_manager_set_geofence_event_cb(ad->geo_manager, show_event_cb, NULL);
  577. /* set callback for geofence state */
  578. geofence_manager_set_geofence_state_changed_cb(ad->geo_manager, show_state_changed_cb, NULL);
  579. /* set callback for proximity state */
  580. geofence_manager_set_geofence_proximity_state_changed_cb(ad->geo_manager, show_proximity_changed_cb, NULL);
  581. }
  582. }
  583.  
  584. /**
  585. * @brief Function will be operated when registered event is triggered.
  586. * @param[in] data The data to be passed to the callback function
  587. * @param[in] obj The Evas object to be passed to the callback function
  588. * @param[in] event_info The Event information to be passed to the callback function
  589. */
  590. static void clicked_destroy_cb(void *data, Evas_Object *obj, void *event_info)
  591. {
  592. appdata_s *ad = (appdata_s *) data;
  593. int ret = 0;
  594.  
  595. if (ad == NULL) {
  596. dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
  597. return;
  598. }
  599.  
  600. /* unset callback for geofence event */
  601. geofence_manager_unset_geofence_event_cb(ad->geo_manager);
  602. /* unset callback for geofence state */
  603. geofence_manager_unset_geofence_state_changed_cb(ad->geo_manager);
  604. /* unset callback for proximity state */
  605. geofence_manager_unset_geofence_proximity_state_changed_cb(ad->geo_manager);
  606.  
  607. /* Destroy geofence handle */
  608. ret = geofence_manager_destroy(ad->geo_manager);
  609.  
  610. /* show called API */
  611. elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_manager_destroy</align></font_size>");
  612. /* show API result */
  613. showError(s_info.event_entry, ret);
  614. /* clear the entry of fence state */
  615. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
  616. /* clear the entry of proximity state */
  617. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
  618.  
  619. /* disable button when geofence handle is destroyed */
  620. if (ret == GEOFENCE_MANAGER_ERROR_NONE) {
  621. elm_object_disabled_set(s_info.create_btn, EINA_FALSE);
  622. elm_object_disabled_set(s_info.fence_state_btn, EINA_TRUE);
  623. elm_object_disabled_set(s_info.add_fence_btn, EINA_TRUE);
  624. elm_object_disabled_set(s_info.add_place_btn, EINA_TRUE);
  625. elm_object_disabled_set(s_info.start_btn, EINA_TRUE);
  626. elm_object_disabled_set(s_info.stop_btn, EINA_TRUE);
  627. elm_object_disabled_set(s_info.remove_fence_btn, EINA_TRUE);
  628. elm_object_disabled_set(s_info.remove_place_btn, EINA_TRUE);
  629. elm_object_disabled_set(s_info.update_place_btn, EINA_TRUE);
  630. elm_object_disabled_set(s_info.destroy_btn, EINA_TRUE);
  631.  
  632. ad->geo_manager = NULL;
  633. }
  634. }
  635.  
  636. /**
  637. * @brief Function will be operated when registered event is triggered.
  638. * @param[in] data The data to be passed to the callback function
  639. * @param[in] obj The Evas object to be passed to the callback function
  640. * @param[in] event_info The Event information to be passed to the callback function
  641. */
  642. static void show_popup_cb(void *data, Evas_Object *obj, void *event_info)
  643. {
  644. appdata_s *ad = (appdata_s *)data;
  645.  
  646. /* set function and parameter for each button */
  647. if (obj == s_info.fence_state_btn)
  648. select_fence_list(ad, get_state_cb);
  649. else if (obj == s_info.add_fence_btn)
  650. select_place_list(ad, add_fence_cb);
  651. else if (obj == s_info.add_place_btn)
  652. insert_place_name(ad, s_info.add_place_btn, -1, NULL);
  653. else if (obj == s_info.start_btn)
  654. select_fence_list(ad, start_fence_cb);
  655. else if (obj == s_info.stop_btn)
  656. select_fence_list(ad, stop_fence_cb);
  657. else if (obj == s_info.remove_fence_btn)
  658. select_fence_list(ad, remove_fence_cb);
  659. else if (obj == s_info.remove_place_btn)
  660. select_place_list(ad, remove_place_cb);
  661. else if (obj == s_info.update_place_btn)
  662. select_place_list(ad, update_place_cb);
  663. }
  664.  
  665. /**
  666. * @brief Create a popup to select fence.
  667. * @param[in] ad The application data to be passed
  668. * @param[in] func The Evas object to be passed to the callback function
  669. */
  670. static void select_fence_list(appdata_s *ad, Evas_Smart_Cb func)
  671. {
  672. Elm_Genlist_Item_Class *itc;
  673. Evas_Object *box;
  674. Evas_Object *genlist;
  675. int ret = 0;
  676. int i = 0;
  677. myfence_index = 0;
  678.  
  679. if (ad == NULL || func == NULL) {
  680. dlog_print(DLOG_ERROR, LOG_TAG, "Application data or func is NULL.");
  681. return;
  682. }
  683.  
  684. /* clear all fence_id */
  685. for (i = 0; i < MAX_COUNT; i++)
  686. ad->fence_id[i] = -1;
  687.  
  688. /* request geofence list and set callback as func */
  689. if (func == start_fence_cb)
  690. ret = geofence_manager_foreach_geofence_list(ad->geo_manager, get_stopped_fence_cb, ad);
  691. else if (func == stop_fence_cb)
  692. ret = geofence_manager_foreach_geofence_list(ad->geo_manager, get_started_fence_cb, ad);
  693. else
  694. ret = geofence_manager_foreach_geofence_list(ad->geo_manager, get_fence_cb, ad);
  695.  
  696. /* show called API */
  697. elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_manager_foreach_geofence_list</align></font_size>");
  698. /* show API result */
  699. showError(s_info.event_entry, ret);
  700. /* clear the entry of fence state */
  701. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
  702. /* clear the entry of proximity state */
  703. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
  704.  
  705. /* error handling */
  706. if (ret != GEOFENCE_MANAGER_ERROR_NONE)
  707. return;
  708. else if (ad->fence_id[0] == -1) {
  709. show_toast_popup("Empty");
  710. return;
  711. }
  712.  
  713. /*
  714. * popup
  715. * Create and initialize elm_popup.
  716. */
  717. s_info.popup = elm_popup_add(s_info.nf);
  718. elm_popup_align_set(s_info.popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
  719. eext_object_event_callback_add(s_info.popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL);
  720. evas_object_size_hint_weight_set(s_info.popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  721. elm_object_part_text_set(s_info.popup, "title,text", "Fence");
  722.  
  723. /*
  724. * box
  725. * Create and initialize elm_box.
  726. */
  727. box = elm_box_add(s_info.popup);
  728. evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  729.  
  730. /*
  731. * genlist
  732. * Create and initialize elm_genlist.
  733. */
  734. genlist = elm_genlist_add(box);
  735. evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  736. evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
  737.  
  738. evas_object_data_set(genlist, "app_data", ad);
  739.  
  740. itc = elm_genlist_item_class_new();
  741. itc->item_style = "default";
  742. itc->func.text_get = gl_id_text_get_cb;
  743. itc->func.content_get = NULL;
  744. itc->func.state_get = NULL;
  745. itc->func.del = NULL;
  746.  
  747. /* append items of genlist */
  748. for (i = 0; ad->fence_id[i] != -1; i++)
  749. elm_genlist_item_append(genlist, itc, (void *)ad->fence_id[i], NULL, ELM_GENLIST_ITEM_NONE, func, (void *)ad->fence_id[i]);
  750.  
  751. evas_object_show(genlist);
  752. elm_box_pack_end(box, genlist);
  753. evas_object_size_hint_min_set(box, -1, 150);
  754. elm_object_content_set(s_info.popup, box);
  755.  
  756. evas_object_show(s_info.popup);
  757. elm_genlist_item_class_free(itc);
  758. }
  759.  
  760. /**
  761. * @brief Create a popup to select place.
  762. * @param[in] ad The application data to be passed
  763. * @param[in] func The Evas object to be passed to the callback function
  764. */
  765. static void select_place_list(appdata_s *ad, Evas_Smart_Cb func)
  766. {
  767. Elm_Genlist_Item_Class *itc;
  768. Evas_Object *box;
  769. Evas_Object *genlist;
  770. int ret = 0;
  771. int i = 0;
  772.  
  773. if (ad == NULL || func == NULL) {
  774. dlog_print(DLOG_ERROR, LOG_TAG, "Application data or func is NULL.");
  775. return;
  776. }
  777.  
  778. /* clear all place_id */
  779. for (i = 0; i < MAX_COUNT; i++)/* clear the entry of fence state */
  780. ad->place_id[i] = -1;
  781.  
  782. /* request place list and set callback */
  783. ret = geofence_manager_foreach_place_list(ad->geo_manager, get_place_cb, ad);
  784.  
  785. /* show called API */
  786. elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_manager_foreach_place_list</align></font_size>");
  787. /* show API result */
  788. showError(s_info.event_entry, ret);
  789. /* clear the entry of fence state */
  790. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
  791. /* clear the entry of proximity state */
  792. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
  793.  
  794. /* error handling */
  795. if (ret != GEOFENCE_MANAGER_ERROR_NONE)
  796. return;
  797.  
  798. /*
  799. * popup
  800. * Create and initialize elm_popup.
  801. */
  802. s_info.popup = elm_popup_add(s_info.nf);
  803. elm_popup_align_set(s_info.popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
  804. eext_object_event_callback_add(s_info.popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL);
  805. evas_object_size_hint_weight_set(s_info.popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  806. elm_object_part_text_set(s_info.popup, "title,text", "Place");
  807.  
  808. /*
  809. * box
  810. * Create and initialize elm_box.
  811. */
  812. box = elm_box_add(s_info.popup);
  813. evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  814.  
  815. /*
  816. * genlist
  817. * Create and initialize elm_genlist.
  818. */
  819. genlist = elm_genlist_add(box);
  820. evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  821. evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
  822.  
  823. evas_object_data_set(genlist, "app_data", ad);
  824.  
  825. itc = elm_genlist_item_class_new();
  826. itc->item_style = "default";
  827. itc->func.text_get = gl_id_text_get_cb;
  828. itc->func.content_get = NULL;
  829. itc->func.state_get = NULL;
  830. itc->func.del = NULL;
  831.  
  832. /* append items of genlist */
  833. for (i = 0; ad->place_id[i] != -1; i++)
  834. elm_genlist_item_append(genlist, itc, (void *)ad->place_id[i], NULL, ELM_GENLIST_ITEM_NONE, func, (void *)ad->place_id[i]);
  835.  
  836. evas_object_show(genlist);
  837. elm_box_pack_end(box, genlist);
  838. evas_object_size_hint_min_set(box, -1, 300);
  839. elm_object_content_set(s_info.popup, box);
  840.  
  841. evas_object_show(s_info.popup);
  842. elm_genlist_item_class_free(itc);
  843. }
  844.  
  845. /**
  846. * @brief Create a popup to select place.
  847. * @param[in] ad The application data to be passed
  848. * @param[in] func The Evas object to be passed to the callback function
  849. * @param[in] place_id The place id
  850. */
  851. static void select_method_list(appdata_s *ad, Evas_Smart_Cb func, int place_id)
  852. {
  853. Elm_Genlist_Item_Class *itc_gps, *itc_wifi, *itc_bt;
  854. Elm_Object_Item *gi_gps, *gi_wifi, *gi_bt;
  855. Evas_Object *box;
  856. Evas_Object *genlist;
  857.  
  858. const char *wifi_feature = "http://tizen.org/feature/network.wifi";
  859. const char *bluetooth_feature = "http://tizen.org/feature/network.bluetooth";
  860.  
  861. bool wifi_supported = false;
  862. bool bt_supported = false;
  863.  
  864. /*
  865. * popup
  866. * Create and initialize elm_popup.
  867. */
  868. s_info.popup = elm_popup_add(s_info.nf);
  869. elm_popup_align_set(s_info.popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
  870. eext_object_event_callback_add(s_info.popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL);
  871. evas_object_size_hint_weight_set(s_info.popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  872. elm_object_part_text_set(s_info.popup, "title,text", "Method");
  873.  
  874. /*
  875. * box
  876. * Create and initialize elm_box.
  877. */
  878. box = elm_box_add(s_info.popup);
  879. evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  880.  
  881. /*
  882. * genlist
  883. * Create and initialize elm_genlist.
  884. */
  885. genlist = elm_genlist_add(box);
  886. evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  887. evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
  888.  
  889. evas_object_data_set(genlist, "app_data", ad);
  890. evas_object_data_set(genlist, "place_id", (void *)place_id);
  891.  
  892. /* append items of genlist */
  893. itc_gps = elm_genlist_item_class_new();
  894. itc_gps->item_style = "default";
  895. itc_gps->func.text_get = gl_method_text_get_cb;
  896. itc_gps->func.content_get = NULL;
  897. itc_gps->func.state_get = NULL;
  898. itc_gps->func.del = NULL;
  899. gi_gps = elm_genlist_item_append(genlist, itc_gps, (void *)METHOD_GPS, NULL, ELM_GENLIST_ITEM_NONE, func, (void *)METHOD_GPS);
  900.  
  901. /* append items of genlist */
  902. itc_wifi = elm_genlist_item_class_new();
  903. itc_wifi->item_style = "default";
  904. itc_wifi->func.text_get = gl_method_text_get_cb;
  905. itc_wifi->func.content_get = NULL;
  906. itc_wifi->func.state_get = NULL;
  907. itc_wifi->func.del = NULL;
  908. gi_wifi = elm_genlist_item_append(genlist, itc_wifi, (void *)METHOD_WIFI, NULL, ELM_GENLIST_ITEM_NONE, func, (void *)METHOD_WIFI);
  909.  
  910. /* append items of genlist */
  911. itc_bt = elm_genlist_item_class_new();
  912. itc_bt->item_style = "default";
  913. itc_bt->func.text_get = gl_method_text_get_cb;
  914. itc_bt->func.content_get = NULL;
  915. itc_bt->func.state_get = NULL;
  916. itc_bt->func.del = NULL;
  917. gi_bt = elm_genlist_item_append(genlist, itc_bt, (void *)METHOD_BT, NULL, ELM_GENLIST_ITEM_NONE, func, (void *)METHOD_BT);
  918.  
  919. /*
  920. * check WI-FI feature
  921. * set disable the WI-FI item if WI-FI is not supported .
  922. */
  923. system_info_get_platform_bool(wifi_feature, &wifi_supported);
  924. if (wifi_supported == false)
  925. elm_object_item_disabled_set(gi_wifi, EINA_TRUE);
  926. else
  927. elm_object_item_disabled_set(gi_wifi, EINA_FALSE);
  928.  
  929. /*
  930. * check Bluetooth feature
  931. * set disable the Bluetooth item if Bluetooth is not supported .
  932. */
  933. system_info_get_platform_bool(bluetooth_feature, &bt_supported);
  934. if (bt_supported == false)
  935. elm_object_item_disabled_set(gi_bt, EINA_TRUE);
  936. else
  937. elm_object_item_disabled_set(gi_bt, EINA_FALSE);
  938.  
  939. evas_object_show(genlist);
  940. elm_box_pack_end(box, genlist);
  941. evas_object_size_hint_min_set(box, -1, 300);
  942. elm_object_content_set(s_info.popup, box);
  943.  
  944. evas_object_show(s_info.popup);
  945. elm_genlist_item_class_free(itc_gps);
  946. elm_genlist_item_class_free(itc_wifi);
  947. elm_genlist_item_class_free(itc_bt);
  948. }
  949.  
  950. /**
  951. * @brief Create a popup to insert or update the place name.
  952. * @param[in] ad The application data to be passed
  953. * @param[in] obj The Evas object to be passed to the function
  954. * @param[in] place_id The place id to insert or update
  955. * @param[in] place_name The place name to insert or update
  956. */
  957. static void insert_place_name(appdata_s *ad, Evas_Object *obj, int place_id, char *place_name)
  958. {
  959. Elm_Genlist_Item_Class *itc;
  960. Evas_Object *box;
  961. Evas_Object *genlist;
  962. Evas_Object *cancel_btn, *done_btn;
  963.  
  964. if (ad == NULL || obj == NULL) {
  965. dlog_print(DLOG_ERROR, LOG_TAG, "Application data or obj is NULL.");
  966. return;
  967. }
  968.  
  969. /*
  970. * popup
  971. * Create and initialize elm_popup.
  972. */
  973. s_info.popup = elm_popup_add(s_info.nf);
  974. elm_popup_align_set(s_info.popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
  975. eext_object_event_callback_add(s_info.popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL);
  976. evas_object_size_hint_weight_set(s_info.popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  977. if (obj == s_info.add_place_btn)
  978. elm_object_part_text_set(s_info.popup, "title,text", "Add Place");
  979. else
  980. elm_object_part_text_set(s_info.popup, "title,text", "Update Place");
  981.  
  982. /*
  983. * box
  984. * Create and initialize elm_box.
  985. */
  986. box = elm_box_add(s_info.popup);
  987. evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  988.  
  989. /*
  990. * genlist
  991. * Create and initialize elm_genlist.
  992. */
  993. genlist = elm_genlist_add(box);
  994. evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  995. evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
  996.  
  997. evas_object_data_set(genlist, "app_data", ad);
  998. evas_object_data_set(genlist, "value", place_name);
  999.  
  1000. itc = elm_genlist_item_class_new();
  1001. itc->item_style = "full";
  1002. itc->func.text_get = NULL;
  1003. itc->func.content_get = gl_entry_content_get;
  1004. itc->func.state_get = NULL;
  1005. itc->func.del = NULL;
  1006.  
  1007. /* append item of genlist */
  1008. elm_genlist_item_append(genlist, itc, "input Name", NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
  1009.  
  1010. evas_object_show(genlist);
  1011. elm_box_pack_end(box, genlist);
  1012. evas_object_size_hint_min_set(box, -1, 150);
  1013. elm_object_content_set(s_info.popup, box);
  1014.  
  1015. /*
  1016. * cancel_btn
  1017. * Create and initialize elm_genlist.
  1018. */
  1019. cancel_btn = elm_button_add(s_info.popup);
  1020. elm_object_style_set(cancel_btn, "popup");
  1021. elm_object_text_set(cancel_btn, "Cancel");
  1022. elm_object_part_content_set(s_info.popup, "button1", cancel_btn);
  1023. evas_object_smart_callback_add(cancel_btn, "clicked", popup_cancel_cb, NULL);
  1024.  
  1025. /*
  1026. * done_btn
  1027. * Create and initialize elm_button.
  1028. */
  1029. done_btn = elm_button_add(s_info.popup);
  1030. evas_object_data_set(done_btn, "app_data", ad);
  1031. elm_object_style_set(done_btn, "popup");
  1032. elm_object_text_set(done_btn, "Done");
  1033. elm_object_part_content_set(s_info.popup, "button2", done_btn);
  1034. evas_object_smart_callback_add(done_btn, "clicked", popup_place_name_cb, (void *)place_id);
  1035.  
  1036. evas_object_show(s_info.popup);
  1037. elm_genlist_item_class_free(itc);
  1038. }
  1039.  
  1040. /**
  1041. * @brief Create a popup to insert the fence value.
  1042. * @param[in] ad The application data to be passed
  1043. * @param[in] place_id The place id to insert or update
  1044. * @param[in] method The method for fence
  1045. */
  1046. static void insert_fence_value(appdata_s *ad, int place_id, int method)
  1047. {
  1048. Elm_Genlist_Item_Class *itc;
  1049. Evas_Object *box;
  1050. Evas_Object *genlist;
  1051. Evas_Object *cancel_btn, *done_btn;
  1052.  
  1053. /*
  1054. * popup
  1055. * Create and initialize elm_popup.
  1056. */
  1057. s_info.popup = elm_popup_add(s_info.nf);
  1058. elm_popup_align_set(s_info.popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
  1059. eext_object_event_callback_add(s_info.popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL);
  1060. evas_object_size_hint_weight_set(s_info.popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  1061. if (method == METHOD_GPS)
  1062. elm_object_part_text_set(s_info.popup, "title,text", "GPS");
  1063. else if (method == METHOD_WIFI)
  1064. elm_object_part_text_set(s_info.popup, "title,text", "Wi-Fi");
  1065. else
  1066. elm_object_part_text_set(s_info.popup, "title,text", "Bluetooth");
  1067.  
  1068. /*
  1069. * box
  1070. * Create and initialize elm_box.
  1071. */
  1072. box = elm_box_add(s_info.popup);
  1073. evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  1074.  
  1075. /*
  1076. * genlist
  1077. * Create and initialize elm_genlist.
  1078. */
  1079. genlist = elm_genlist_add(box);
  1080. evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  1081. evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
  1082.  
  1083. evas_object_data_set(genlist, "app_data", ad);
  1084.  
  1085. itc = elm_genlist_item_class_new();
  1086. itc->item_style = "full";
  1087. itc->func.text_get = NULL;
  1088. itc->func.content_get = gl_entry_content_get;
  1089. itc->func.state_get = NULL;
  1090. itc->func.del = NULL;
  1091.  
  1092. /* append item of genlist as method */
  1093. if (method == METHOD_GPS) {
  1094. elm_genlist_item_append(genlist, itc, "input Latitude", NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
  1095. elm_genlist_item_append(genlist, itc, "input Longitude", NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
  1096. } else
  1097. elm_genlist_item_append(genlist, itc, "input Bssid", NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
  1098.  
  1099. evas_object_show(genlist);
  1100. elm_box_pack_end(box, genlist);
  1101. if (method == METHOD_GPS)
  1102. evas_object_size_hint_min_set(box, -1, 300);
  1103. else
  1104. evas_object_size_hint_min_set(box, -1, 150);
  1105. elm_object_content_set(s_info.popup, box);
  1106.  
  1107. /*
  1108. * cancel_btn
  1109. * Create and initialize elm_genlist.
  1110. */
  1111. cancel_btn = elm_button_add(s_info.popup);
  1112. elm_object_style_set(cancel_btn, "popup");
  1113. elm_object_text_set(cancel_btn, "Cancel");
  1114. elm_object_part_content_set(s_info.popup, "button1", cancel_btn);
  1115. evas_object_smart_callback_add(cancel_btn, "clicked", popup_cancel_cb, NULL);
  1116.  
  1117. /*
  1118. * done_btn
  1119. * Create and initialize elm_genlist.
  1120. */
  1121. done_btn = elm_button_add(s_info.popup);
  1122. evas_object_data_set(done_btn, "app_data", (void *)ad);
  1123. evas_object_data_set(done_btn, "place_id", (void *)place_id);
  1124. elm_object_style_set(done_btn, "popup");
  1125. elm_object_text_set(done_btn, "Done");
  1126. elm_object_part_content_set(s_info.popup, "button2", done_btn);
  1127. evas_object_smart_callback_add(done_btn, "clicked", popup_method_value_cb, (void *)method);
  1128.  
  1129. evas_object_show(s_info.popup);
  1130. elm_genlist_item_class_free(itc);
  1131. }
  1132.  
  1133. /**
  1134. * @brief Function will be operated when registered event is triggered.
  1135. * @param[in] data The data to be passed to the callback function
  1136. * @param[in] obj The Evas object to be passed to the callback function
  1137. * @param[in] event_info The Event information to be passed to the callback function
  1138. */
  1139. static void popup_method_value_cb(void *data, Evas_Object *obj, void *event_info)
  1140. {
  1141. appdata_s *ad = evas_object_data_get(obj, "app_data");
  1142. int place_id = (int)evas_object_data_get(obj, "place_id");;
  1143. int method = (int)data;
  1144.  
  1145. const char *value = elm_entry_entry_get(s_info.gen_entry);
  1146. const char *value_nd = elm_entry_entry_get(s_info.gen_entry_nd);
  1147.  
  1148. if (ad == NULL) {
  1149. dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
  1150. return;
  1151. }
  1152.  
  1153. geofence_h fence = NULL;
  1154. double latitude = 0.0, longitude = 0.0;
  1155. int geofence_id = -1;
  1156. int ret = 0;
  1157.  
  1158. if (!strcmp(value, "")) {
  1159. show_toast_popup("Empty Value");
  1160. return;
  1161. }
  1162. if (method == METHOD_GPS) {
  1163. if (!strcmp(value_nd, "")) {
  1164. show_toast_popup("Empty Value");
  1165. return;
  1166. }
  1167. }
  1168.  
  1169. switch (method) {
  1170. case METHOD_GPS:
  1171. latitude = atof(value);
  1172. longitude = atof(value_nd);
  1173. /* create a handle of geopoint fence */
  1174. ret = geofence_create_geopoint(place_id, latitude, longitude, 200, "Dubai MR", &fence);
  1175. /* show called API */
  1176. elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_create_geopoint</align></font_size>");
  1177. break;
  1178. case METHOD_WIFI:
  1179. /* create a handle of wifi fence */
  1180. ret = geofence_create_wifi(place_id, value, "Dubai MR", &fence);
  1181. /* show called API */
  1182. elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_create_wifi</align></font_size>");
  1183. break;
  1184. case METHOD_BT:
  1185. /* create a handle of bluetooth fence */
  1186. ret = geofence_create_bluetooth(place_id, value, "Dubai MR", &fence);
  1187. /* show called API */
  1188. elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_create_bluetooth</align></font_size>");
  1189. break;
  1190. default:
  1191. break;
  1192. }
  1193. /* show API result */
  1194. showError(s_info.event_entry, ret);
  1195. /* clear the entry of fence state */
  1196. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
  1197. /* clear the entry of proximity state */
  1198. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
  1199.  
  1200. /* add the fence */
  1201. ret = geofence_manager_add_fence(ad->geo_manager, fence, &geofence_id);
  1202. /* show API result */
  1203. showError(s_info.event_entry, ret);
  1204.  
  1205. evas_object_del(s_info.popup);
  1206. }
  1207.  
  1208. /**
  1209. * @brief Function will be operated when registered event is triggered.
  1210. * @param[in] place_id The place id
  1211. * @param[in] place_name The place name
  1212. * @param[in] place_index The place index
  1213. * @param[in] place_cnt The total place
  1214. */
  1215. static bool get_place_cb(int place_id, const char *place_name, int place_index, int place_cnt, void *user_data)
  1216. {
  1217. appdata_s *ad = (appdata_s *)user_data;
  1218.  
  1219. if (ad == NULL) {
  1220. dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
  1221. return false;
  1222. }
  1223.  
  1224. ad->place_id[place_index-1] = place_id;
  1225.  
  1226. return true;
  1227. }
  1228.  
  1229. /**
  1230. * @brief Function will be operated when registered event is triggered.
  1231. * @param[in] geofence_id The fence id
  1232. * @param[in] fence_index The fence index
  1233. * @param[in] fence_cnt The total fence
  1234. */
  1235. static bool get_fence_cb(int geofence_id, geofence_h fence, int fence_index, int fence_cnt, void *user_data)
  1236. {
  1237. appdata_s *ad = (appdata_s *)user_data;
  1238.  
  1239. if (ad == NULL) {
  1240. dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
  1241. return false;
  1242. }
  1243.  
  1244. ad->fence_id[fence_index-1] = geofence_id;
  1245.  
  1246. return true;
  1247. }
  1248.  
  1249. /**
  1250. * @brief Function will be operated when registered event is triggered.
  1251. * @param[in] data The data to be passed to the callback function
  1252. * @param[in] obj The Evas object to be passed to the callback function
  1253. * @param[in] event_info The Event information to be passed to the callback function
  1254. */
  1255. static void get_state_cb(void *data, Evas_Object *obj, void *event_info)
  1256. {
  1257. int geofence_id = (int) data;
  1258. geofence_status_h status = NULL;
  1259. geofence_state_e state;
  1260. int seconds = 0;
  1261. int ret = 0;
  1262. char buf[50] = {};
  1263. char *state_str[] = {"UNCERTAIN", "IN", "OUT"};
  1264.  
  1265. evas_object_del(s_info.popup);
  1266.  
  1267. /* create geofence status handle */
  1268. ret = geofence_status_create(geofence_id, &status);
  1269.  
  1270. /* show called API */
  1271. elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_status_create</align></font_size>");
  1272. /* show API result */
  1273. showError(s_info.event_entry, ret);
  1274. /* clear the entry of fence state */
  1275. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
  1276. /* clear the entry of proximity state */
  1277. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
  1278.  
  1279. if (ret != GEOFENCE_MANAGER_ERROR_NONE)
  1280. return;
  1281.  
  1282. /* get state */
  1283. ret = geofence_status_get_state(status, &state);
  1284.  
  1285. /* show called API */
  1286. elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_status_get_state</align></font_size>");
  1287. /* show API result */
  1288. showError(s_info.event_entry, ret);
  1289. /* clear the entry of fence state */
  1290. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
  1291. /* clear the entry of proximity state */
  1292. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
  1293.  
  1294. /* get duration */
  1295. ret = geofence_status_get_duration(status, &seconds);
  1296.  
  1297. /* show called API */
  1298. elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_status_get_duration</align></font_size>");
  1299. /* show API result */
  1300. showError(s_info.event_entry, ret);
  1301. /* clear the entry of fence state */
  1302. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
  1303. /* clear the entry of proximity state */
  1304. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
  1305.  
  1306. if (ret != GEOFENCE_MANAGER_ERROR_NONE)
  1307. return;
  1308.  
  1309. /* destroy geofence status handle */
  1310. ret = geofence_status_destroy(status);
  1311.  
  1312. /* show called API */
  1313. elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_status_destroy</align></font_size>");
  1314. /* show API result */
  1315. showError(s_info.event_entry, ret);
  1316. /* show fence state */
  1317. snprintf(buf, sizeof(buf), "Fence ID: %d, State: %s, Duration: %d", geofence_id, state_str[state], seconds);
  1318. elm_entry_entry_append(s_info.state_entry, "<font_size=25><align=left>");
  1319. elm_entry_entry_append(s_info.state_entry, buf);
  1320. elm_entry_entry_append(s_info.state_entry, "</align></font_size>");
  1321. /* clear the entry of proximity state */
  1322. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
  1323. }
  1324.  
  1325. /**
  1326. * @brief Function will be operated when registered event is triggered.
  1327. * @param[in] geofence_id The fence id
  1328. * @param[in] fence The fence handle
  1329. * @param[in] fence_index The fence index
  1330. * @param[in] fence_cnt The total fence
  1331. */
  1332. static bool get_started_fence_cb(int geofence_id, geofence_h fence, int fence_index, int fence_cnt, void *user_data)
  1333. {
  1334. appdata_s *ad = (appdata_s *)user_data;
  1335. geofence_status_h status = NULL;
  1336. geofence_state_e state;
  1337. int ret = 0;
  1338.  
  1339. if (ad == NULL) {
  1340. dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
  1341. return false;
  1342. }
  1343.  
  1344. /* create geofence status handle */
  1345. ret = geofence_status_create(geofence_id, &status);
  1346. /* show called API */
  1347. elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_status_create</align></font_size>");
  1348. /* show API result */
  1349. showError(s_info.event_entry, ret);
  1350. /* clear the entry of fence state */
  1351. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
  1352. /* clear the entry of proximity state */
  1353. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
  1354.  
  1355. if (ret != GEOFENCE_MANAGER_ERROR_NONE)
  1356. return false;
  1357.  
  1358. /* get state */
  1359. ret = geofence_status_get_state(status, &state);
  1360. /* show called API */
  1361. elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_status_get_state</align></font_size>");
  1362. /* show API result */
  1363. showError(s_info.event_entry, ret);
  1364. /* clear the entry of fence state */
  1365. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
  1366. /* clear the entry of proximity state */
  1367. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
  1368.  
  1369. if (ret != GEOFENCE_MANAGER_ERROR_NONE)
  1370. return false;
  1371.  
  1372. if (state != GEOFENCE_STATE_UNCERTAIN) {
  1373. ad->fence_id[myfence_index] = geofence_id;
  1374. myfence_index++;
  1375. }
  1376.  
  1377. /* destroy geofence status handle */
  1378. ret = geofence_status_destroy(status);
  1379. /* show called API */
  1380. elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_status_destroy</align></font_size>");
  1381. /* show API result */
  1382. showError(s_info.event_entry, ret);
  1383. /* clear the entry of fence state */
  1384. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
  1385. /* clear the entry of proximity state */
  1386. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
  1387.  
  1388. if (ret != GEOFENCE_MANAGER_ERROR_NONE)
  1389. return false;
  1390.  
  1391. return true;
  1392. }
  1393.  
  1394. /**
  1395. * @brief Function will be operated when registered event is triggered.
  1396. * @param[in] geofence_id The fence id
  1397. * @param[in] fence The fence handle
  1398. * @param[in] fence_index The fence index
  1399. * @param[in] fence_cnt The total fence
  1400. */
  1401. static bool get_stopped_fence_cb(int geofence_id, geofence_h fence, int fence_index, int fence_cnt, void *user_data)
  1402. {
  1403. appdata_s *ad = (appdata_s *)user_data;
  1404. geofence_status_h status = NULL;
  1405. geofence_state_e state;
  1406. int ret = 0;
  1407.  
  1408. if (ad == NULL) {
  1409. dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
  1410. return false;
  1411. }
  1412.  
  1413. /* create geofence status handle */
  1414. ret = geofence_status_create(geofence_id, &status);
  1415. /* show called API */
  1416. elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_status_create</align></font_size>");
  1417. /* show API result */
  1418. showError(s_info.event_entry, ret);
  1419. /* clear the entry of fence state */
  1420. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
  1421. /* clear the entry of proximity state */
  1422. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
  1423.  
  1424. if (ret != GEOFENCE_MANAGER_ERROR_NONE)
  1425. return false;
  1426.  
  1427. /* get state */
  1428. ret = geofence_status_get_state(status, &state);
  1429. /* show called API */
  1430. elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_status_get_state</align></font_size>");
  1431. /* show API result */
  1432. showError(s_info.event_entry, ret);
  1433. /* clear the entry of fence state */
  1434. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
  1435. /* clear the entry of proximity state */
  1436. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
  1437.  
  1438. if (ret != GEOFENCE_MANAGER_ERROR_NONE)
  1439. return false;
  1440.  
  1441. if (state == GEOFENCE_STATE_UNCERTAIN) {
  1442. ad->fence_id[myfence_index] = geofence_id;
  1443. myfence_index++;
  1444. }
  1445.  
  1446. /* destroy geofence status handle */
  1447. ret = geofence_status_destroy(status);
  1448. /* show called API */
  1449. elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_status_destroy</align></font_size>");
  1450. /* show API result */
  1451. showError(s_info.event_entry, ret);
  1452. /* clear the entry of fence state */
  1453. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
  1454. /* clear the entry of proximity state */
  1455. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
  1456.  
  1457. if (ret != GEOFENCE_MANAGER_ERROR_NONE)
  1458. return false;
  1459.  
  1460. return true;
  1461. }
  1462.  
  1463. /**
  1464. * @brief Function will be operated when registered event is triggered.
  1465. * @param[in] data The data to be passed to the callback function
  1466. * @param[in] obj The Evas object to be passed to the callback function
  1467. * @param[in] event_info The Event information to be passed to the callback function
  1468. */
  1469. static void add_fence_cb(void *data, Evas_Object *obj, void *event_info)
  1470. {
  1471. appdata_s *ad = evas_object_data_get(obj, "app_data");
  1472. int place_id = (int) data;
  1473.  
  1474. evas_object_del(s_info.popup);
  1475. select_method_list(ad, add_fence_nd_cb, place_id);
  1476. }
  1477.  
  1478. /**
  1479. * @brief Function will be operated when registered event is triggered.
  1480. * @param[in] data The data to be passed to the callback function
  1481. * @param[in] obj The Evas object to be passed to the callback function
  1482. * @param[in] event_info The Event information to be passed to the callback function
  1483. */
  1484. static void add_fence_nd_cb(void *data, Evas_Object *obj, void *event_info)
  1485. {
  1486. appdata_s *ad = evas_object_data_get(obj, "app_data");
  1487. int place_id = (int)evas_object_data_get(obj, "place_id");
  1488. int method = (int) data;
  1489.  
  1490. evas_object_del(s_info.popup);
  1491. insert_fence_value(ad, place_id, method);
  1492. }
  1493.  
  1494. /**
  1495. * @brief Function will be operated when registered event is triggered.
  1496. * @param[in] data The data to be passed to the callback function
  1497. * @param[in] obj The Evas object to be passed to the callback function
  1498. * @param[in] event_info The Event information to be passed to the callback function
  1499. */
  1500. static void remove_fence_cb(void *data, Evas_Object *obj, void *event_info)
  1501. {
  1502. appdata_s *ad = evas_object_data_get(obj, "app_data");
  1503. int fence_id = (int) data;
  1504. int ret = 0;
  1505.  
  1506. if (ad == NULL) {
  1507. dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
  1508. return;
  1509. }
  1510.  
  1511. evas_object_del(s_info.popup);
  1512.  
  1513. /* remove the fence */
  1514. ret = geofence_manager_remove_fence(ad->geo_manager, fence_id);
  1515.  
  1516. /* show called API */
  1517. elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_manager_remove_fence</align></font_size>");
  1518. /* show API result */
  1519. showError(s_info.event_entry, ret);
  1520. /* clear the entry of fence state */
  1521. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
  1522. /* clear the entry of proximity state */
  1523. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
  1524. }
  1525.  
  1526. /**
  1527. * @brief Function will be operated when registered event is triggered.
  1528. * @param[in] data The data to be passed to the callback function
  1529. * @param[in] obj The Evas object to be passed to the callback function
  1530. * @param[in] event_info The Event information to be passed to the callback function
  1531. */
  1532. static void start_fence_cb(void *data, Evas_Object *obj, void *event_info)
  1533. {
  1534. appdata_s *ad = evas_object_data_get(obj, "app_data");
  1535. int fence_id = (int) data;
  1536. int ret = 0;
  1537.  
  1538. if (ad == NULL) {
  1539. dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
  1540. return;
  1541. }
  1542.  
  1543. evas_object_del(s_info.popup);
  1544.  
  1545. /* start the fence */
  1546. ret = geofence_manager_start(ad->geo_manager, fence_id);
  1547.  
  1548. /* show called API */
  1549. elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_manager_start</align></font_size>");
  1550. /* show API result */
  1551. showError(s_info.event_entry, ret);
  1552. /* clear the entry of fence state */
  1553. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
  1554. /* clear the entry of proximity state */
  1555. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
  1556. }
  1557.  
  1558. /**
  1559. * @brief Function will be operated when registered event is triggered.
  1560. * @param[in] data The data to be passed to the callback function
  1561. * @param[in] obj The Evas object to be passed to the callback function
  1562. * @param[in] event_info The Event information to be passed to the callback function
  1563. */
  1564. static void stop_fence_cb(void *data, Evas_Object *obj, void *event_info)
  1565. {
  1566. appdata_s *ad = evas_object_data_get(obj, "app_data");
  1567. int fence_id = (int) data;
  1568. int ret = 0;
  1569.  
  1570. if (ad == NULL) {
  1571. dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
  1572. return;
  1573. }
  1574.  
  1575. evas_object_del(s_info.popup);
  1576.  
  1577. /* stop the fence */
  1578. ret = geofence_manager_stop(ad->geo_manager, fence_id);
  1579.  
  1580. /* show called API */
  1581. elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_manager_stop</align></font_size>");
  1582. /* show API result */
  1583. showError(s_info.event_entry, ret);
  1584. /* clear the entry of fence state */
  1585. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
  1586. /* clear the entry of proximity state */
  1587. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
  1588. }
  1589.  
  1590. /**
  1591. * @brief Function will be operated when registered event is triggered.
  1592. * @param[in] data The data to be passed to the callback function
  1593. * @param[in] obj The Evas object to be passed to the callback function
  1594. * @param[in] event_info The Event information to be passed to the callback function
  1595. */
  1596. static void remove_place_cb(void *data, Evas_Object *obj, void *event_info)
  1597. {
  1598. appdata_s *ad = evas_object_data_get(obj, "app_data");
  1599. int place_id = (int) data;
  1600. int ret = 0;
  1601.  
  1602. if (ad == NULL) {
  1603. dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
  1604. return;
  1605. }
  1606.  
  1607. evas_object_del(s_info.popup);
  1608.  
  1609. /* remove the place */
  1610. ret = geofence_manager_remove_place(ad->geo_manager, place_id);
  1611.  
  1612. /* show called API */
  1613. elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_manager_remove_place</align></font_size>");
  1614. /* show API result */
  1615. showError(s_info.event_entry, ret);
  1616. /* show or clear the fence state */
  1617. if (place_id <= 3)
  1618. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left>The deletion of default place is impossible</align></font_size>");
  1619. else
  1620. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
  1621. /* clear the entry of proximity state */
  1622. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
  1623. }
  1624.  
  1625. /**
  1626. * @brief Function will be operated when registered event is triggered.
  1627. * @param[in] data The data to be passed to the callback function
  1628. * @param[in] obj The Evas object to be passed to the callback function
  1629. * @param[in] event_info The Event information to be passed to the callback function
  1630. */
  1631. static void update_place_cb(void *data, Evas_Object *obj, void *event_info)
  1632. {
  1633. appdata_s *ad = evas_object_data_get(obj, "app_data");
  1634. int place_id = (int) data;
  1635. char *name = NULL;
  1636. int ret = 0;
  1637.  
  1638. if (ad == NULL) {
  1639. dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
  1640. return;
  1641. }
  1642.  
  1643. evas_object_del(s_info.popup);
  1644.  
  1645. /* update the place name */
  1646. ret = geofence_manager_get_place_name(ad->geo_manager, place_id, &name);
  1647.  
  1648. /* show called API */
  1649. elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_manager_get_place_name</align></font_size>");
  1650. /* show API result */
  1651. showError(s_info.event_entry, ret);
  1652. /* clear the entry of fence state */
  1653. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
  1654. /* clear the entry of proximity state */
  1655. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
  1656.  
  1657. insert_place_name(ad, s_info.update_place_btn, place_id, name);
  1658. }
  1659.  
  1660. /**
  1661. * @brief Function will be operated when registered event is triggered.
  1662. * @param[in] place_id The place id
  1663. * @param[in] geofence_id The geofence id
  1664. * @param[in] error The enum value of error
  1665. * @param[in] manage The enum value of geofence event
  1666. */
  1667. static void show_event_cb(int place_id, int geofence_id, geofence_manager_error_e error, geofence_manage_e manage, void *user_data)
  1668. {
  1669. char buf[10] = {};
  1670.  
  1671. /* check error */
  1672. if (error == GEOFENCE_MANAGER_ERROR_NONE) {
  1673. /* check and shoe the geofence event */
  1674. switch (manage) {
  1675. case GEOFENCE_MANAGE_FENCE_ADDED:
  1676. elm_entry_entry_set(s_info.event_entry, "<font_size=25><align=left>GEOFENCE_MANAGE_FENCE_ADDED</align></font_size>");
  1677. snprintf(buf, sizeof(buf), " : %d", geofence_id);
  1678. break;
  1679. case GEOFENCE_MANAGE_FENCE_REMOVED:
  1680. elm_entry_entry_set(s_info.event_entry, "<font_size=25><align=left>GEOFENCE_MANAGE_FENCE_REMOVED</align></font_size>");
  1681. snprintf(buf, sizeof(buf), " : %d", geofence_id);
  1682. break;
  1683. case GEOFENCE_MANAGE_FENCE_STARTED:
  1684. elm_entry_entry_set(s_info.event_entry, "<font_size=25><align=left>GEOFENCE_MANAGE_FENCE_STARTED</align></font_size>");
  1685. snprintf(buf, sizeof(buf), " : %d", geofence_id);
  1686. break;
  1687. case GEOFENCE_MANAGE_FENCE_STOPPED:
  1688. elm_entry_entry_set(s_info.event_entry, "<font_size=25><align=left>GEOFENCE_MANAGE_FENCE_STOPPED</align></font_size>");
  1689. snprintf(buf, sizeof(buf), " : %d", geofence_id);
  1690. break;
  1691. case GEOFENCE_MANAGE_PLACE_ADDED:
  1692. elm_entry_entry_set(s_info.event_entry, "<font_size=25><align=left>GEOFENCE_MANAGE_PLACE_ADDED</align></font_size>");
  1693. snprintf(buf, sizeof(buf), " : %d", place_id);
  1694. break;
  1695. case GEOFENCE_MANAGE_PLACE_REMOVED:
  1696. elm_entry_entry_set(s_info.event_entry, "<font_size=25><align=left>GEOFENCE_MANAGE_PLACE_REMOVED</align></font_size>");
  1697. snprintf(buf, sizeof(buf), " : %d", place_id);
  1698. break;
  1699. case GEOFENCE_MANAGE_PLACE_UPDATED:
  1700. elm_entry_entry_set(s_info.event_entry, "<font_size=25><align=left>GEOFENCE_MANAGE_PLACE_UPDATED</align></font_size>");
  1701. snprintf(buf, sizeof(buf), " : %d", place_id);
  1702. break;
  1703. case GEOFENCE_MANAGE_SETTING_ENABLED:
  1704. elm_entry_entry_set(s_info.event_entry, "<font_size=25><align=left>GEOFENCE_MANAGE_SETTING_ENABLED</align></font_size>");
  1705. break;
  1706. case GEOFENCE_MANAGE_SETTING_DISABLED:
  1707. elm_entry_entry_set(s_info.event_entry, "<font_size=25><align=left>GEOFENCE_MANAGE_SETTING_DISABLED</align></font_size>");
  1708. break;
  1709. default:
  1710. elm_entry_entry_set(s_info.event_entry, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_NONE</align></font_size>");
  1711. break;
  1712. }
  1713. elm_entry_entry_append(s_info.event_entry, "<font_size=30>");
  1714. elm_entry_entry_append(s_info.event_entry, buf);
  1715. elm_entry_entry_append(s_info.event_entry, "</font_size>");
  1716. } else
  1717. showError(s_info.event_entry, error);
  1718. }
  1719.  
  1720. /**
  1721. * @brief Function will be operated when registered event is triggered.
  1722. * @param[in] geofence_id The geofence id
  1723. * @param[in] state The enum value of geofence state
  1724. */
  1725. static void show_state_changed_cb(int geofence_id, geofence_state_e state, void *user_data)
  1726. {
  1727. char buf[10] = {};
  1728.  
  1729. /* check and show the geofence state */
  1730. if (state == GEOFENCE_STATE_IN)
  1731. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left>GEOFENCE_STATE_IN");
  1732. else if (state == GEOFENCE_STATE_OUT)
  1733. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left>GEOFENCE_STATE_OUT");
  1734. else
  1735. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left>GEOFENCE_STATE_UNCERTAIN");
  1736.  
  1737. snprintf(buf, sizeof(buf), " : %d", geofence_id);
  1738. elm_entry_entry_append(s_info.state_entry, buf);
  1739. elm_entry_entry_append(s_info.state_entry, "</align></font_size>");
  1740. }
  1741.  
  1742. /**
  1743. * @brief Function will be operated when registered event is triggered.
  1744. * @param[in] geofence_id The geofence id
  1745. * @param[in] state The enum value of proximity state
  1746. * @param[in] provider The enum value of proximity provider
  1747. */
  1748. static void show_proximity_changed_cb(int geofence_id, geofence_proximity_state_e state, geofence_proximity_provider_e provider, void *user_data)
  1749. {
  1750. char buf[10] = {};
  1751.  
  1752. /* check and show the proximity state */
  1753. if (state == GEOFENCE_PROXIMITY_STATE_IMMEDIATE)
  1754. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left>PROXIMITY_STATE_IMMEDIATE");
  1755. else if (state == GEOFENCE_PROXIMITY_STATE_NEAR)
  1756. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left>PROXIMITY_STATE_NEAR");
  1757. else if (state == GEOFENCE_PROXIMITY_STATE_FAR)
  1758. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left>PROXIMITY_STATE_FAR");
  1759. else
  1760. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left>PROXIMITY_STATE_UNCERTAIN");
  1761.  
  1762. /* check and show the proximity provider */
  1763. if (provider == GEOFENCE_PROXIMITY_PROVIDER_LOCATION)
  1764. elm_entry_entry_append(s_info.proximity_entry, " by LOCATION");
  1765. else if (provider == GEOFENCE_PROXIMITY_PROVIDER_WIFI)
  1766. elm_entry_entry_append(s_info.proximity_entry, " by WIFI");
  1767. else if (provider == GEOFENCE_PROXIMITY_PROVIDER_BLUETOOTH)
  1768. elm_entry_entry_append(s_info.proximity_entry, " by BLUETOOTH");
  1769. else if (provider == GEOFENCE_PROXIMITY_PROVIDER_BLE)
  1770. elm_entry_entry_append(s_info.proximity_entry, " by BLE");
  1771. else
  1772. elm_entry_entry_append(s_info.proximity_entry, " by SENSOR");
  1773.  
  1774. snprintf(buf, sizeof(buf), " : %d", geofence_id);
  1775. elm_entry_entry_append(s_info.proximity_entry, buf);
  1776. elm_entry_entry_append(s_info.proximity_entry, "</align></font_size>");
  1777. }
  1778.  
  1779. /**
  1780. * @brief Show Errors
  1781. * @param[in] obj The Evas object to be passed to the callback function
  1782. * @param[in] ret The return value of API
  1783. */
  1784. static void showError(Evas_Object *obj, int ret)
  1785. {
  1786. /* check and show the error */
  1787. switch (ret) {
  1788. case GEOFENCE_MANAGER_ERROR_NONE:
  1789. elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_NONE</align></font_size>");
  1790. break;
  1791. case GEOFENCE_MANAGER_ERROR_OUT_OF_MEMORY:
  1792. elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_OUT_OF_MEMORY</align></font_size>");
  1793. break;
  1794. case GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER:
  1795. elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER</align></font_size>");
  1796. break;
  1797. case GEOFENCE_MANAGER_ERROR_PERMISSION_DENIED:
  1798. elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_PERMISSION_DENIED</align></font_size>");
  1799. break;
  1800. case GEOFENCE_MANAGER_ERROR_NOT_SUPPORTED:
  1801. elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_NOT_SUPPORTED</align></font_size>");
  1802. break;
  1803. case GEOFENCE_MANAGER_ERROR_NOT_INITIALIZED:
  1804. elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_NOT_INITIALIZED</align></font_size>");
  1805. break;
  1806. case GEOFENCE_MANAGER_ERROR_INVALID_ID:
  1807. elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_INVALID_ID</align></font_size>");
  1808. break;
  1809. case GEOFENCE_MANAGER_ERROR_EXCEPTION:
  1810. elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_EXCEPTION</align></font_size>");
  1811. break;
  1812. case GEOFENCE_MANAGER_ERROR_ALREADY_STARTED:
  1813. elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_ALREADY_STARTED</align></font_size>");
  1814. break;
  1815. case GEOFENCE_MANAGER_ERROR_TOO_MANY_GEOFENCE:
  1816. elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_TOO_MANY_GEOFENCE</align></font_size>");
  1817. break;
  1818. case GEOFENCE_MANAGER_ERROR_IPC:
  1819. elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_IPC</align></font_size>");
  1820. break;
  1821. case GEOFENCE_MANAGER_ERROR_DATABASE:
  1822. elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_DATABASE</align></font_size>");
  1823. break;
  1824. case GEOFENCE_MANAGER_ERROR_PLACE_ACCESS_DENIED:
  1825. elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_PLACE_ACCESS_DENIED</align></font_size>");
  1826. break;
  1827. case GEOFENCE_MANAGER_ERROR_GEOFENCE_ACCESS_DENIED:
  1828. elm_entry_entry_set(obj, "<font_size=25><align=left>GEOFENCE_MANAGER_ERROR_GEOFENCE_ACCESS_DENIED</align></font_size>");
  1829. break;
  1830. default:
  1831. elm_entry_entry_set(obj, "<font_size=25><align=left>FAILED with UNKNOWN ERROR</align></font_size>");
  1832. break;
  1833. }
  1834. }
  1835.  
  1836. /**
  1837. * @brief Function will be operated when registered event is triggered.
  1838. * @param[in] data The data to be passed to the callback function
  1839. * @param[in] obj The Evas object handle to be passed to the callback function
  1840. * @param[in] part The part of object
  1841. */
  1842. static void popup_cancel_cb(void *data, Evas_Object *obj, void *event_info)
  1843. {
  1844. evas_object_del(s_info.popup);
  1845. }
  1846.  
  1847. /**
  1848. * @brief Function will be operated when registered event is triggered.
  1849. * @param[in] data The data to be passed to the callback function
  1850. * @param[in] obj The Evas object handle to be passed to the callback function
  1851. * @param[in] part The part of object
  1852. */
  1853. static void popup_place_name_cb(void *data, Evas_Object *obj, void *event_info)
  1854. {
  1855. appdata_s *ad = evas_object_data_get(obj, "app_data");
  1856. int ret = 0;
  1857. int place_id = (int)data;
  1858. const char *place_name = elm_entry_entry_get(s_info.gen_entry);
  1859.  
  1860. if (ad == NULL) {
  1861. dlog_print(DLOG_ERROR, LOG_TAG, "Application data is NULL.");
  1862. return;
  1863. }
  1864.  
  1865. /* check that a name is inserted or not */
  1866. if (!strcmp(place_name, "")) {
  1867. show_toast_popup("Empty Value");
  1868. return;
  1869. }
  1870.  
  1871. if (place_id < 0) {
  1872. /* add place */
  1873. ret = geofence_manager_add_place(ad->geo_manager, place_name, &place_id);
  1874. /* show called API */
  1875. elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_manager_add_place</align></font_size>");
  1876. } else {
  1877. /* update place */
  1878. ret = geofence_manager_update_place(ad->geo_manager, place_id, place_name);
  1879. /* show called API */
  1880. elm_entry_entry_set(s_info.entry, "<font_size=30><align=left>geofence_manager_update_place</align></font_size>");
  1881. }
  1882.  
  1883. /* show API result */
  1884. showError(s_info.event_entry, ret);
  1885.  
  1886. /* show or clear the geofence state */
  1887. if (place_id > 0 && place_id <= 3)
  1888. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left>The renaming of default place is impossible</align></font_size>");
  1889. else
  1890. elm_entry_entry_set(s_info.state_entry, "<font_size=25><align=left></align></font_size>");
  1891.  
  1892. /* clear the proximity state */
  1893. elm_entry_entry_set(s_info.proximity_entry, "<font_size=25><align=left></align></font_size>");
  1894. evas_object_del(s_info.popup);
  1895. }
  1896.  
  1897. /**
  1898. * @brief Function will be operated when registered event is triggered.
  1899. * @param[in] data The data to be passed to the callback function
  1900. * @param[in] obj The Evas object handle to be passed to the callback function
  1901. * @param[in] part The part of object
  1902. */
  1903. static char *gl_id_text_get_cb(void *data, Evas_Object *obj, const char *part)
  1904. {
  1905. char buf[10] = {};
  1906. snprintf(buf, sizeof(buf), "ID : %d", (int)data);
  1907. return strdup(buf);
  1908. }
  1909.  
  1910. /**
  1911. * @brief Function will be operated when registered event is triggered.
  1912. * @param[in] data The data to be passed to the callback function
  1913. * @param[in] obj The Evas object handle to be passed to the callback function
  1914. * @param[in] part The part of object
  1915. */
  1916. static char *gl_method_text_get_cb(void *data, Evas_Object *obj, const char *part)
  1917. {
  1918. switch ((int)data) {
  1919. case METHOD_GPS:
  1920. return strdup("GPS");
  1921. case METHOD_WIFI:
  1922. return strdup("Wi-Fi");
  1923. case METHOD_BT:
  1924. return strdup("Bluetooth");
  1925. default:
  1926. break;
  1927. }
  1928. return NULL;
  1929. }
  1930.  
  1931. /**
  1932. * @brief Function will be operated when registered event is triggered.
  1933. * @param[in] data The data to be passed to the callback function
  1934. * @param[in] obj The Evas object handle to be passed to the callback function
  1935. * @param[in] part The part of object
  1936. */
  1937. static Evas_Object *gl_entry_content_get(void *data, Evas_Object *obj, const char *part)
  1938. {
  1939. char *value = evas_object_data_get(obj, "value");
  1940.  
  1941. if (!strcmp(part, "elm.swallow.content")) {
  1942. /*
  1943. * editfield
  1944. * Create and initialize elm_layout.
  1945. */
  1946. Evas_Object *editfield = elm_layout_add(obj);
  1947. elm_layout_theme_set(editfield, "layout", "searchfield", "singleline");
  1948. evas_object_size_hint_align_set(editfield, EVAS_HINT_FILL, 0.0);
  1949. evas_object_size_hint_weight_set(editfield, EVAS_HINT_EXPAND, 0.0);
  1950. eext_entry_selection_back_event_allow_set(editfield, EINA_TRUE);
  1951.  
  1952. /* check that the entry is for latitude or longitude */
  1953. if (!strcmp(data, "input Longitude")) {
  1954. /*
  1955. * gen_entry_nd
  1956. * Create and initialize elm_entry.
  1957. */
  1958. s_info.gen_entry_nd = elm_entry_add(editfield);
  1959. evas_object_size_hint_weight_set(s_info.gen_entry_nd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  1960. evas_object_size_hint_align_set(s_info.gen_entry_nd, EVAS_HINT_FILL, EVAS_HINT_FILL);
  1961. elm_entry_single_line_set(s_info.gen_entry_nd, EINA_TRUE);
  1962. elm_entry_scrollable_set(s_info.gen_entry_nd, EINA_TRUE);
  1963. evas_object_show(s_info.gen_entry_nd);
  1964.  
  1965. if (value == NULL)
  1966. elm_object_part_text_set(s_info.gen_entry_nd, "elm.guide", data);
  1967. else
  1968. elm_entry_entry_set(s_info.gen_entry_nd, value);
  1969. elm_object_part_content_set(editfield, "elm.swallow.content", s_info.gen_entry_nd);
  1970. } else {
  1971. /*
  1972. * gen_entry
  1973. * Create and initialize elm_entry.
  1974. */
  1975. s_info.gen_entry = elm_entry_add(editfield);
  1976. evas_object_size_hint_weight_set(s_info.gen_entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  1977. evas_object_size_hint_align_set(s_info.gen_entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
  1978. elm_entry_single_line_set(s_info.gen_entry, EINA_TRUE);
  1979. elm_entry_scrollable_set(s_info.gen_entry, EINA_TRUE);
  1980. evas_object_show(s_info.gen_entry);
  1981.  
  1982. if (value == NULL)
  1983. elm_object_part_text_set(s_info.gen_entry, "elm.guide", data);
  1984. else
  1985. elm_entry_entry_set(s_info.gen_entry, value);
  1986. elm_object_part_content_set(editfield, "elm.swallow.content", s_info.gen_entry);
  1987. }
  1988. return editfield;
  1989. }
  1990. return NULL;
  1991. }
  1992.  
  1993. /**
  1994. * @brief Function will be operated when registered event is triggered.
  1995. * @param[in] str The string to display on toast popup
  1996. */
  1997. static void show_toast_popup(char *str)
  1998. {
  1999. Evas_Object *popup;
  2000.  
  2001. /*
  2002. * popup
  2003. * Create and initialize elm_popup.
  2004. */
  2005. popup = elm_popup_add(s_info.win);
  2006. elm_object_style_set(popup, "toast");
  2007. evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  2008. elm_object_text_set(popup, str);
  2009.  
  2010. /* set timeout for toast popup */
  2011. elm_popup_timeout_set(popup, 2.0);
  2012. /* set callback for timeout of popup */
  2013. evas_object_smart_callback_add(popup, "timeout", popup_timeout_cb, NULL);
  2014.  
  2015. evas_object_show(popup);
  2016. }
  2017.  
  2018. /**
  2019. * @brief Function will be operated when registered event is triggered.
  2020. * @param[in] data The data to be passed to the callback function
  2021. * @param[in] obj The Evas object handle to be passed to the callback function
  2022. * @param[in] event_info The system event information
  2023. */
  2024. static void popup_timeout_cb(void *data, Evas_Object *obj, void *event_info)
  2025. {
  2026. /* delete the object */
  2027. evas_object_del(obj);
  2028. }
  2029.  
  2030. /**
  2031. * @brief Function will be operated when registered event is triggered.
  2032. * @param[in] data The data to be passed to the callback function
  2033. * @param[in] it The Evas object item to be passed to the callback function
  2034. */
  2035. static Eina_Bool naviframe_pop_cb(void *data, Elm_Object_Item *it)
  2036. {
  2037. ui_app_exit();
  2038. return EINA_TRUE;
  2039. }
  2040.  
  2041. /**
  2042. * @brief Function will be operated when registered event is triggered.
  2043. * @param[in] data The data to be passed to the callback function
  2044. * @param[in] obj The Evas object handle to be passed to the callback function
  2045. * @param[in] event_info The system event information
  2046. */
  2047. static void _win_delete_request_cb(void *data, Evas_Object *obj, void *event_info)
  2048. {
  2049. /*
  2050. * Write your code here for smart callback.
  2051. */
  2052. ui_app_exit();
  2053. }
  2054.