(Circle) System Settings / src /

data.c

  1. /*
  2. * Copyright (c) 2015 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 <app.h>
  18. #include <Elementary.h>
  19. #include <dlog.h>
  20.  
  21. #include "$(appName).h"
  22. #include "data.h"
  23.  
  24.  
  25. static char *menu_its[] = {
  26. /*** 1line styles ***/
  27. "Display",
  28. "Vibration",
  29. "Device",
  30. "Call",
  31. "Connections",
  32. "Screen lock",
  33. "Input",
  34. "Power saving",
  35. "Gear info",
  36. /* do not delete below */
  37. NULL
  38. };
  39.  
  40. static char *display_its[] = {
  41. /*** 1line styles ***/
  42. "Watch faces",
  43. "Watch always on",
  44. "Notification indicator",
  45. "Brightness",
  46. "Screen timeout",
  47. "Font",
  48. /* do not delete below */
  49. NULL
  50. };
  51.  
  52. /*
  53. * display items's values.
  54. * states of check boxes is controlled by these values.
  55. */
  56. static int display_its_value[] = {
  57. -1, /* Watch faces */
  58. 0, /* Watch always on */
  59. 0, /* Notification indicator */
  60. -1, /* Brightness */
  61. -1, /* Screen timeout */
  62. -1 /* Font */
  63. };
  64.  
  65. /*
  66. * @brief: Initialize data that is used in this application.
  67. */
  68. void data_initialize(void)
  69. {
  70. /*
  71. * If you need to initialize managing data,
  72. * please use this function.
  73. */
  74. }
  75.  
  76. /*
  77. * @brief: Destroy data that is used in this application.
  78. */
  79. void data_finalize(void)
  80. {
  81. /*
  82. * If you need to finalize managing data,
  83. * please use this function.
  84. */
  85. }
  86. /*
  87. * @brief: Get text
  88. * @param[part]: Name string of one of the existing text parts in the EDJ group
  89. */
  90. char *data_get_text(const char *part)
  91. {
  92. /*
  93. * You can use this function to retrieve data.
  94. */
  95. return NULL;
  96. }
  97.  
  98. /*
  99. * @brief: Function will be operated when items are shown on the screen
  100. * @param[data]: Data passed from 'elm_genlist_item_append' as third parameter
  101. * @param[obj]: Genlist
  102. * @param[part]: Name string of one of the existing text parts in the EDJ group implementing the item's theme
  103. */
  104. char *data_get_menu_title_text(void *data, Evas_Object *obj, const char *part)
  105. {
  106. char buf[BUF_LEN];
  107.  
  108. snprintf(buf, sizeof(buf), "%s", "Settings");
  109. return strdup(buf);
  110. }
  111.  
  112. /*
  113. * @brief: Function will be operated when items are shown on the screen
  114. * @param[data]: Data passed from 'elm_genlist_item_append' as third parameter
  115. * @param[obj]: Genlist
  116. * @param[part]: Name string of one of the existing text parts in the EDJ group implementing the item's theme
  117. */
  118. char *data_get_display_title_text(void *data, Evas_Object *obj, const char *part)
  119. {
  120. char buf[BUF_LEN];
  121.  
  122. snprintf(buf, sizeof(buf), "%s", "Display");
  123. return strdup(buf);
  124. }
  125.  
  126. /*
  127. * @brief: Function will be operated when items are shown on the screen
  128. * @param[data]: Data passed from 'elm_genlist_item_append' as third parameter
  129. * @param[obj]: Genlist
  130. * @param[part]: Name string of one of the existing text parts in the EDJ group implementing the item's theme
  131. */
  132. char *data_get_menu_text(void *data, Evas_Object *obj, const char *part)
  133. {
  134. int index = (int)data;
  135. char buf[BUF_LEN];
  136.  
  137. if (!strcmp(part, "elm.text")) {
  138. snprintf(buf, sizeof(buf), "%s", menu_its[index]);
  139. return strdup(buf);
  140. }
  141. return NULL;
  142. }
  143.  
  144. /*
  145. * @brief: Function will be operated when items are shown on the screen
  146. * @param[data]: Data passed from 'elm_genlist_item_append' as third parameter
  147. * @param[obj]: Genlist
  148. * @param[part]: Name string of one of the existing text parts in the EDJ group implementing the item's theme
  149. */
  150. char *data_get_display_text(void *data, Evas_Object *obj, const char *part)
  151. {
  152. char buf[BUF_LEN];
  153. int index = (int)data;
  154.  
  155. if (!strcmp(part, "elm.text")) {
  156. snprintf(buf, sizeof(buf), "%s", display_its[index]);
  157. return strdup(buf);
  158. } else if (!strcmp(part, "elm.text.1")) {
  159. snprintf(buf, sizeof(buf), "%s", "30 seconds");
  160. return strdup(buf);
  161. }
  162.  
  163. return NULL;
  164. }
  165.  
  166. /*
  167. * @brief: Get display item's value that can shows state of check box
  168. * @param[index]: Index of display item's value
  169. * @param[value]: The point to which save value of display item
  170. */
  171. void data_get_display_int_value(int index, int *value)
  172. {
  173. *value = display_its_value[index];
  174. }
  175.  
  176. /*
  177. * @brief: Set display item's value that can shows state of check box
  178. * @param[index]: Index of display item's value
  179. * @param[value]: Value of display item
  180. */
  181. void data_set_display_int_value(int index, int value)
  182. {
  183. display_its_value[index] = value;
  184. }
  185.  
  186. /*
  187. * @brief: Get image name according as the number of index.
  188. * @param[index]: Index of genlist
  189. */
  190. char *data_get_icon_name(int index)
  191. {
  192. char buf[BUF_LEN];
  193.  
  194. switch (index) {
  195. case 0:
  196. snprintf(buf, sizeof(buf), "%s", "images/settings_list_display.png");
  197. break;
  198. case 1:
  199. snprintf(buf, sizeof(buf), "%s", "images/settings_list_vibration.png");
  200. break;
  201. case 2:
  202. snprintf(buf, sizeof(buf), "%s", "images/settings_list_device.png");
  203. break;
  204. case 3:
  205. snprintf(buf, sizeof(buf), "%s", "images/settings_list_call.png");
  206. break;
  207. case 4:
  208. snprintf(buf, sizeof(buf), "%s", "images/settings_list_connections.png");
  209. break;
  210. case 5:
  211. snprintf(buf, sizeof(buf), "%s", "images/settings_list_security.png");
  212. break;
  213. case 6:
  214. snprintf(buf, sizeof(buf), "%s", "images/settings_list_input.png");
  215. break;
  216. case 7:
  217. snprintf(buf, sizeof(buf), "%s", "images/settings_list_power_saving.png");
  218.  
  219. break;
  220. case 8:
  221. snprintf(buf, sizeof(buf), "%s", "images/settings_list_gear_info.png");
  222. break;
  223. default:
  224. dlog_print(DLOG_ERROR, LOG_TAG, "wrong approach");
  225. snprintf(buf, sizeof(buf), "%s", "");
  226. break;
  227. }
  228.  
  229. return strdup(buf);
  230. }
  231.  
  232. /*
  233. * @brief: Get path of resource.
  234. * @param[file_in]: File name
  235. * @param[file_path_out]: The point to which save full path of the resource
  236. * @param[file_path_max]: Size of file name include path
  237. */
  238. void data_get_resource_path(const char *file_in, char *file_path_out, int file_path_max)
  239. {
  240. char *res_path = app_get_resource_path();
  241. if (res_path) {
  242. snprintf(file_path_out, file_path_max, "%s%s", res_path, file_in);
  243. free(res_path);
  244. }
  245. }
  246.  
  247. /* End of file */