Cutting new release
[profile/ivi/clock.git] / timer / src / timer_setting.c
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.0 (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 #define __TMR_SETTING_C__
18
19 #include <feedback.h>
20 #include "timer_setting.h"
21 #include "timer_utils.h"
22 /**********************************************************************
23 ******************Local function declear, extern function declear*************************************
24 ***********************************************************************/
25 //
26 static void _timer_view_setting_update_time(void *data);
27 static int _timer_view_setting_btn_set(setting_view * view);
28 //callback
29 static int _timer_view_setting_key_num_cb(struct appdata *ad, char key);
30 static int _timer_view_setting_key_plu_cb(struct appdata *ad);
31 //
32 static int _timer_view_setting_create(void *data);
33 static int _timer_view_setting_destroy(void *data);
34 static int _timer_view_setting_update(void *data);
35 static int _timer_view_setting_cleanup(void *data);
36 //
37 static int _timer_view_setting_create_layout(void *data);
38 static int _timer_view_setting_update_layout(void *data);
39 /**********************************************************************
40 ******************Global val , static global val*************************************
41 ***********************************************************************/
42
43 static int first_focus;         // 1: for EINA_TRUE, it is first focus; 0: for EINA_FALSE, it is not first focus.
44
45 clk_view timer_view_setting = {
46         .create = _timer_view_setting_create,
47         .destroy = _timer_view_setting_destroy,
48         .update = _timer_view_setting_update,
49         .cleanup = _timer_view_setting_cleanup,
50         .is_create = EINA_FALSE,
51         .layer = MAX_CLK_FWK_VIEW_LAYER,
52 };
53
54 static Edje_Color_Class g_color_class_btn_hl = {
55         .name = STRING_TIMER_SETTING_BTN_TXT_COLOR,
56         .r = 249,.g = 249,.b = 249,.a = 255,
57         .r2 = 0,.g2 = 0,.b2 = 0,.a2 = 102,
58         .r3 = 0,.g3 = 0,.b3 = 0,.a3 = 0,
59 };
60
61 /**********************************************************************
62 ******************Local function ref*************************************
63 ***********************************************************************/
64
65 /**
66  * Debug function: to reset time to the value setted last time.
67  * This function requires data as parameters
68  *
69  * _timer_view_setting_update_time()
70  * @param[in] data                  Pointer to user data, which contains the data of application
71  *
72  * @return     void
73  */
74 static void _timer_view_setting_update_time(void *data)
75 {
76         retm_if(!data, "data null");
77         struct appdata *ad = (struct appdata *)data;
78         setting_view *view = ad->view_setting;
79         retm_if(!view, "view null");
80         int nErr = SUCCESS;
81
82         ad->entry_number = TIMER_FOCUS_MIN;
83         nErr = timer_vconf_load_start_time(ad);
84         if (nErr != SUCCESS) {
85                 set_default_time(ad);
86                 vconf_set_int(VCONF_TIMER_START_TIME, 100);
87         }
88         timer_vconf_load_focus_id(data);
89         //set focus
90         char time_str[30] = { 0 };
91         switch (ad->entry_number) {
92         case TIMER_FOCUS_HOUR:
93                 edje_object_signal_emit(_EDJ(view->eo_content),
94                                         STRING_TIMER_MOURSE_CLICKED_1,
95                                         STRING_TIMER_TIME_RECT_H);
96                 snprintf(time_str, sizeof(time_str), "%c", ad->chour[0]);
97                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_H1);
98                 snprintf(time_str, sizeof(time_str), "%c", ad->chour[1]);
99                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_H2);
100                 snprintf(time_str, sizeof(time_str), "%c.unfocused", ad->cminute[0]);
101                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_M1);
102                 snprintf(time_str, sizeof(time_str), "%c.unfocused", ad->cminute[1]);
103                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_M2);
104                 snprintf(time_str, sizeof(time_str), "%c.unfocused", ad->csecond[0]);
105                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_S1);
106                 snprintf(time_str, sizeof(time_str), "%c.unfocused", ad->csecond[1]);
107                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_S2);
108                 break;
109
110         case TIMER_FOCUS_MIN:
111                 edje_object_signal_emit(_EDJ(view->eo_content),
112                                         STRING_TIMER_MOURSE_CLICKED_1,
113                                         STRING_TIMER_TIME_RECT_M);
114                 snprintf(time_str, sizeof(time_str), "%c.unfocused", ad->chour[0]);
115                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_H1);
116                 snprintf(time_str, sizeof(time_str), "%c.unfocused", ad->chour[1]);
117                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_H2);
118                 snprintf(time_str, sizeof(time_str), "%c", ad->cminute[0]);
119                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_M1);
120                 snprintf(time_str, sizeof(time_str), "%c", ad->cminute[1]);
121                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_M2);
122                 snprintf(time_str, sizeof(time_str), "%c.unfocused", ad->csecond[0]);
123                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_S1);
124                 snprintf(time_str, sizeof(time_str), "%c.unfocused", ad->csecond[1]);
125                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_S2);
126                 break;
127
128         case TIMER_FOCUS_SEC:
129                 edje_object_signal_emit(_EDJ(view->eo_content),
130                                         STRING_TIMER_MOURSE_CLICKED_1,
131                                         STRING_TIMER_TIME_RECT_S);
132                 snprintf(time_str, sizeof(time_str), "%c.unfocused", ad->chour[0]);
133                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_H1);
134                 snprintf(time_str, sizeof(time_str), "%c.unfocused", ad->chour[1]);
135                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_H2);
136                 snprintf(time_str, sizeof(time_str), "%c.unfocused", ad->cminute[0]);
137                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_M1);
138                 snprintf(time_str, sizeof(time_str), "%c.unfocused", ad->cminute[1]);
139                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_M2);
140                 snprintf(time_str, sizeof(time_str), "%c", ad->csecond[0]);
141                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_S1);
142                 snprintf(time_str, sizeof(time_str), "%c", ad->csecond[1]);
143                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_S2);
144                 break;
145
146         default:
147                 return;
148         }
149 }
150
151 //
152 static int _timer_view_setting_btn_set(setting_view * view)
153 {
154         retvm_if(NULL_CHECK(view), FAILED, "view null");
155         edje_object_part_text_set(_EDJ(view->eo_btn), STRING_TIMER_TXT,
156                                   STRING_TIMER_IDS_TMR_SK_START_);
157         int start_time = 0;
158         vconf_get_int(VCONF_TIMER_START_TIME, &start_time);
159         if (IS_EQUAL(0, start_time)) {
160                 edje_object_signal_emit(_EDJ(view->eo_btn), STRING_TIMER_HIDE,
161                                         STRING_TIMER_RECT);
162                 edje_object_signal_emit(_EDJ(view->eo_btn), STRING_TIMER_DIM,
163                                         STRING_TIMER_IMAGE);
164                 edje_object_color_class_set(_EDJ(view->eo_btn),
165                                             STRING_TIMER_SETTING_BTN_TXT_COLOR,
166                                             255, 255, 255, 255, 0, 0, 0, 102, 0, 0,
167                                             0, 0);
168         } else {
169                 edje_object_signal_emit(_EDJ(view->eo_btn), STRING_TIMER_SHOW,
170                                         STRING_TIMER_RECT);
171                 edje_object_signal_emit(_EDJ(view->eo_btn), STRING_TIMER_NORMAL,
172                                         STRING_TIMER_IMAGE);
173                 edje_object_color_class_set(_EDJ(view->eo_btn),
174                                             STRING_TIMER_SETTING_BTN_TXT_COLOR,
175                                             255, 255, 255, 255, 0, 0, 0, 102, 0,
176                                             0, 0, 0);
177         }
178         return SUCCESS;
179 }
180
181 /**
182  * Debug function: to handle digit key click event for input digits
183  * when click a digit in keypad, this callback will be called
184  * This function requires data, obj, emission, source as parameters
185  *
186  * _timer_view_setting_key_num_cb()
187  * @param[in] ad                  Pointer to struct appdata
188  *
189  * @return      int   return SUCCESS when success, or return FAILED if failed
190  */
191 static int _timer_view_setting_key_num_cb(struct appdata *ad, char key)
192 {
193         int val_0 = 0, val_1 = 0, val_src = 0;  // to define variables for tens,    units of last setting for operating unit, and val_src is for the value on current pressed key
194         if (!ad) {
195                 return FAILED;
196         }
197         setting_view *view = ad->view_setting;
198         if (!view) {
199                 return FAILED;
200         }
201         char time_str[6] = { 0 };
202         switch (ad->entry_number) {
203         case TIMER_FOCUS_HOUR:
204                 val_0 = ad->chour[0] - '0';     // to get digit on tens of current unit of time
205                 val_1 = ad->chour[1] - '0';     // to get digit on units of current unit of time
206                 val_src = key - '0';    // to get the digit on current pressed key
207
208                 if (first_focus == 1) { // to confirm whether this is the first operation on this unit of time
209                         ad->chour[0] = '0';     // to set tens to 0 if it is the first operation.
210                         ad->chour[1] = key;     // to set units to the digit on current digit key
211                         first_focus = 0;        // to clear first operation flag
212                 } else {        // It is not the first operation on specified unit
213                         if (val_0 == 0) {       // condition that tens is zero
214                                 // the units value of last setting is 0, 1, because hour cannot larger than 12.
215                                 if ((val_1 == 0)
216                                     || ((val_1 == 1)
217                                         && ((val_src == 0) || (val_src == 1)
218                                             || (val_src == 2)))) {
219                                         ad->chour[0] = ad->chour[1];    // to move units to tens
220                                         ad->chour[1] = key;     // set units with the digit on current pressed key
221                                 } else if ((val_1 > 1) || ((val_1 == 1) && (val_src > 2))) {    // set hour 12 if hour is larger than 12.
222                                         ad->chour[0] = '1';     // to set tens of hour
223                                         ad->chour[1] = '2';     // to set units of hour
224                                 }
225                         } else {        // current input is even times
226                                 ad->chour[0] = '0';     // to set tens 0
227                                 ad->chour[1] = key;     // to set units with the digit on current pressed key
228                         }
229
230                 }
231
232                 // to update hour unit of time with new value
233                 snprintf(time_str, sizeof(time_str), "%c", ad->chour[0]);
234                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_H1);
235                 snprintf(time_str, sizeof(time_str), "%c", ad->chour[1]);
236                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_H2);
237                 break;
238
239         case TIMER_FOCUS_MIN:   //m
240                 // input digit to minute unit
241                 val_0 = ad->cminute[0] - '0';   // to get digit on tens of current unit of time
242                 val_1 = ad->cminute[1] - '0';   // to get digit on units of current unit of time
243
244                 if (first_focus == 1) { // to confirm whether this is the first operation on this unit of time
245                         ad->cminute[0] = '0';   // to set tens to 0 if it is the first operation.
246                         ad->cminute[1] = key;   // to set units to the digit on current digit key
247                         first_focus = 0;        // to clear first operation flag
248                 } else {        // It is not the first operation on specified unit
249                         if (val_0 == 0) {       // condition that tens is zero
250                                 // the units value of last setting is 0, 1, 2, 3, 4, 5, because minute cannot larger than 59, so the tens cannot larger than 5.
251                                 if ((val_1 == 0) || (val_1 == 1) || (val_1 == 2)
252                                     || (val_1 == 3) || (val_1 == 4)
253                                     || (val_1 == 5)) {
254                                         ad->cminute[0] = ad->cminute[1];        // to move units to tens
255                                         ad->cminute[1] = key;   // set units with the digit on current pressed key
256                                 } else {        // set minute 59 if minute is larger than 59.
257                                         ad->cminute[0] = '5';   // to set tens of minute
258                                         ad->cminute[1] = '9';   // to set units of minute
259                                 }
260                         } else {        // current input is even times
261                                 ad->cminute[0] = '0';   // to set tens 0
262                                 ad->cminute[1] = key;   // to set units with the digit on current pressed key
263                         }
264
265                 }
266
267                 // to update minute unit of time with new value
268                 snprintf(time_str, sizeof(time_str), "%c", ad->cminute[0]);
269                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_M1);
270                 snprintf(time_str, sizeof(time_str), "%c", ad->cminute[1]);
271                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_M2);
272                 break;
273
274         case TIMER_FOCUS_SEC:   //s1
275                 // input digit to minute unit
276                 val_0 = ad->csecond[0] - '0';   // to get digit on tens of current unit of time
277                 val_1 = ad->csecond[1] - '0';   // to get digit on units of current unit of time
278
279                 if (first_focus == 1) { // to confirm whether this is the first operation on this unit of time
280                         ad->csecond[0] = '0';   // to set tens to 0 if it is the first operation.
281                         ad->csecond[1] = key;   // to set units to the digit on current digit key
282                         first_focus = 0;        // to clear first operation flag
283                 } else {        // It is not the first operation on specified unit
284                         if (val_0 == 0) {       // condition that tens is zero
285                                 // the units value of last setting is 0, 1, 2, 3, 4, 5, because second cannot larger than 59, so the tens cannot larger than 5.
286                                 if ((val_1 == 0) || (val_1 == 1) || (val_1 == 2)
287                                     || (val_1 == 3) || (val_1 == 4)
288                                     || (val_1 == 5)) {
289                                         ad->csecond[0] = ad->csecond[1];
290                                         ad->csecond[1] = key;
291                                 } else {        // set minute 59 if second is larger than 59.
292                                         ad->csecond[0] = '5';   // to set tens of minute
293                                         ad->csecond[1] = '9';   // to set units of minute
294                                 }
295                         } else {        // current input is even times
296                                 ad->csecond[0] = '0';   // to set tens 0
297                                 ad->csecond[1] = key;   // to set units with the digit on current pressed key
298                         }
299
300                 }
301                 // to update second unit of time with new value
302                 snprintf(time_str, sizeof(time_str), "%c", ad->csecond[0]);
303                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_S1);
304                 snprintf(time_str, sizeof(time_str), "%c", ad->csecond[1]);
305                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_S2);
306                 break;
307
308         default:                //error
309                 CLK_ERR("no time entry selected\n");    // to print error information
310                 return SUCCESS;
311         }
312         timer_vconf_set_start_time(ad); // to save the time setting
313         //set button state
314         _timer_view_setting_btn_set(view);
315         return SUCCESS;
316 }
317
318 //
319 static int _timer_view_setting_key_plu_cb(struct appdata *ad)
320 {
321         if (!ad) {
322                 return FAILED;
323         }
324         setting_view *view = ad->view_setting;
325         if (!view) {
326                 return FAILED;
327         }
328         char time_str[6] = { 0 };
329         switch (ad->entry_number) {     // to start a switch loop  for implementing the logic of different units of time
330         case TIMER_FOCUS_HOUR:  //h
331                 ad->chour[0] = '0';
332                 ad->chour[1] = '0';
333                 // to update hour with new value.
334                 snprintf(time_str, sizeof(time_str), "%c", ad->chour[0]);
335                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_H1);
336                 snprintf(time_str, sizeof(time_str), "%c", ad->chour[1]);
337                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_H2);
338                 break;
339
340         case TIMER_FOCUS_MIN:   //m
341                 ad->cminute[0] = '0';
342                 ad->cminute[1] = '0';
343                 // to update minute with new value
344                 snprintf(time_str, sizeof(time_str), "%c", ad->cminute[0]);
345                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_M1);
346                 snprintf(time_str, sizeof(time_str), "%c", ad->cminute[1]);
347                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_M2);
348                 break;
349
350         case TIMER_FOCUS_SEC:   //s
351                 ad->csecond[0] = '0';
352                 ad->csecond[1] = '0';
353                 // to update second with new value
354                 snprintf(time_str, sizeof(time_str), "%c", ad->csecond[0]);
355                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_S1);
356                 snprintf(time_str, sizeof(time_str), "%c", ad->csecond[1]);
357                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_S2);
358                 break;
359
360         default:                //error
361                 CLK_ERR("no time entry selected\n");    // to print error information
362                 return SUCCESS;
363         }
364         timer_vconf_set_start_time(ad); // to save the time setting
365         //set button state
366         _timer_view_setting_btn_set(view);
367         return SUCCESS;
368 }
369
370 //
371 static int _timer_view_setting_create(void *data)
372 {
373         int ret = SUCCESS;
374         struct appdata *ad = NULL;
375         CLK_FUN_BEG();
376         ad = (struct appdata *)data;
377         //
378         ad->page = TIMER_VIEW_PAGE_SETTING;
379         ret = _timer_view_setting_create_layout(data);
380         ret |= _timer_view_setting_update_layout(data);
381
382         timer_show_view(ad, EINA_TRUE);
383         timer_view_setting.is_create = EINA_TRUE;
384         timer_view_setting.layer = 1;
385         CLK_FUN_END();
386         return ret;
387 }
388
389 //
390 static int __timer_view_setting_destroy_cb(void *data)
391 {
392         struct appdata *ad = NULL;
393         setting_view *view = NULL;
394         ad = (struct appdata *)data;
395         view = ad->view_setting;
396         //
397         EVAS_OBJECT_DELIF(view->eo_content);
398 //  EVAS_OBJECT_DELIF(view->eo_content_ly);
399         timer_view_setting.is_create = EINA_FALSE;
400         return SUCCESS;
401 }
402
403 //
404 static int _timer_view_setting_destroy(void *data)
405 {
406         int ret = SUCCESS;
407         CLK_FUN_BEG();
408         __timer_view_setting_destroy_cb(data);
409         CLK_FUN_END();
410         return ret;
411 }
412
413 //
414 static int _timer_view_setting_update(void *data)
415 {
416         int ret = SUCCESS;
417         struct appdata *ad = NULL;
418         CLK_FUN_BEG();
419         ad = (struct appdata *)data;
420         //
421         ad->page = TIMER_VIEW_PAGE_SETTING;
422         ret = _timer_view_setting_update_layout(data);
423         timer_show_view(ad, EINA_TRUE);
424         CLK_FUN_END();
425         return ret;
426 }
427
428 //
429 static int _timer_view_setting_cleanup(void *data)
430 {
431         return _timer_view_setting_destroy(data);
432 }
433
434 /**
435  * Debug function: to create and show setting view
436  * This function requires data as parameters
437  *
438  * _timer_view_setting_create_layout()
439  * @param[in] data                  Pointer to user data, which contains the data of application
440  *
441  * @return      int, which indicates whether the operation is successful.
442  */
443 static int _timer_view_setting_create_layout(void *data)
444 {
445         retvm_if(!data, FAILED, "data null");
446         struct appdata *ad = (struct appdata *)data;
447         setting_view *view = ad->view_setting;
448         retvm_if(!view, FAILED, "view null");
449         //
450         view->eo_parent = ad->parent;
451         view->eo_layout = ad->layout;
452         view->eo_content = load_edj(view->eo_layout, EDJ_NAME, CONTENT_SETTING);
453 //  elm_object_part_content_set(ad->eo_effect, "elm.swallow.center", view->eo_content);
454         //create button
455         view->eo_btn =
456             clk_widget_create_button(view->eo_content, EDJ_NAME,
457                                      STRING_TIMER_SETTING_BTN,
458                                      &g_color_class_btn_hl,
459                                      timer_setting_btn_cb, ad);
460         elm_object_part_content_set(view->eo_content, STRING_TIMER_SW_BTN,
461                                     view->eo_btn);
462
463         edje_object_part_text_set(_EDJ(view->eo_content),
464                                   STRING_TIMER_TIME_LABEL_HOUR,
465                                   STRING_TIMER_IDS_TMR_BODY_HOUR_);
466         edje_object_part_text_set(_EDJ(view->eo_content),
467                                   STRING_TIMER_TIME_LABEL_MINUTE,
468                                   STRING_TIMER_IDS_TMR_BODY_MIN_);
469         edje_object_part_text_set(_EDJ(view->eo_content),
470                                   STRING_TIMER_TIME_LABEL_SECOND,
471                                   STRING_TIMER_IDS_TMR_BODY_SEC_);
472         /* add callback */
473         edje_object_signal_callback_add(_EDJ(view->eo_content),
474                                         STRING_TIMER_CLICK_DIGIT, "*",
475                                         timer_digit_click_cb, ad);
476         edje_object_signal_callback_add(_EDJ(view->eo_content),
477                                         STRING_TIMER_CLICK_TIME, "*",
478                                         timer_time_click_cb, ad);
479         //
480         first_focus = 1;
481         return SUCCESS;
482 }
483
484 //
485 static int _timer_view_setting_update_layout(void *data)
486 {
487         retvm_if(!data, FAILED, "data null");
488         struct appdata *ad = (struct appdata *)data;
489         setting_view *view = ad->view_setting;
490         retvm_if(!view, FAILED, "view null");
491         edje_object_part_text_set(_EDJ(view->eo_content),
492                                           STRING_TIMER_TIME_LABEL_HOUR,
493                                           STRING_TIMER_IDS_TMR_BODY_HOUR_);
494         edje_object_part_text_set(_EDJ(view->eo_content),
495                                           STRING_TIMER_TIME_LABEL_MINUTE,
496                                           STRING_TIMER_IDS_TMR_BODY_MIN_);
497         edje_object_part_text_set(_EDJ(view->eo_content),
498                                           STRING_TIMER_TIME_LABEL_SECOND,
499                                           STRING_TIMER_IDS_TMR_BODY_SEC_);
500
501         _timer_view_setting_update_time(ad);
502         _timer_view_setting_btn_set(view);
503         return SUCCESS;
504 }
505
506 /**********************************************************************
507 ******************Global function ref*************************************
508 ***********************************************************************/
509
510 /**
511  * Debug function: to handle digit key click event for input digits
512  * when click a digit in keypad, this callback will be called
513  * This function requires data, obj, emission, source as parameters
514  *
515  * timer_digit_click_cb()
516  * @param[in] data                  Pointer to user data, which contains the data of application
517  * @param[in] obj                    Pointer to button object
518  * @param[in] emission             Pointer to signal
519  * @param[in] source               Pointer to the source from which signal is emitted
520  *
521  * @return      void
522  */
523 void timer_digit_click_cb(void *data, Evas_Object * obj, const char *emission,
524                           const char *source)
525 {
526         struct appdata *ad = (struct appdata *)data;
527         if (!source || !ad) {
528                 return;
529         }
530         char key = source[0];
531         if (TIMER_KEY_IS_NUM(key)) {
532                 _timer_view_setting_key_num_cb(ad, key);
533         } else if (TIMER_KEY_IS_PLUS(key)) {
534                 _timer_view_setting_key_plu_cb(ad);
535         } else {
536                 CLK_ERR("key=%d, not support", key);
537         }
538
539         feedback_play(FEEDBACK_PATTERN_SIP);
540 }
541
542 /**
543  * Debug function: to handle logic of focus on which unit of time
544  * It is callback function of signal "click_time"
545  * This function requires data, obj, emission, source as parameters
546  *
547  * timer_time_click_cb()
548  * @param[in] data                  Pointer to user data, which contains the data of application
549  * @param[in] obj                    Pointer to button object
550  * @param[in] emission             Pointer to signal
551  * @param[in] source               Pointer to the source from which signal is emitted
552  *
553  * @return      void
554  */
555 void timer_time_click_cb(void *data, Evas_Object * obj, const char *emission,
556                          const char *source)
557 {
558         struct appdata *ad = (struct appdata *)data;
559
560         if (IS_STR_EQUAL("h", source) && (ad->entry_number != TIMER_FOCUS_HOUR)) {
561                 ECORE_TIMER_DELIF(ad->tap_timer);
562                 ad->entry_number = TIMER_FOCUS_HOUR;
563                 first_focus = 1;
564         } else if (IS_STR_EQUAL("m", source)
565                    && (ad->entry_number != TIMER_FOCUS_MIN)) {
566                 ECORE_TIMER_DELIF(ad->tap_timer);
567                 ad->entry_number = TIMER_FOCUS_MIN;
568                 first_focus = 1;
569         } else if (IS_STR_EQUAL("s", source)
570                    && (ad->entry_number != TIMER_FOCUS_SEC)) {
571                 ECORE_TIMER_DELIF(ad->tap_timer);
572                 ad->entry_number = TIMER_FOCUS_SEC;
573                 first_focus = 1;
574         } else {
575                 CLK_ERR("invalid source\n");
576                 return;
577         }
578         timer_vconf_set_focus_id(ad);
579         char time_str[30] = { 0 };
580         setting_view *view = ad->view_setting;
581         retm_if(!view, "view null");
582         switch (ad->entry_number) {
583         case TIMER_FOCUS_HOUR:
584                 edje_object_signal_emit(_EDJ(view->eo_content),
585                                         STRING_TIMER_MOURSE_CLICKED_1,
586                                         STRING_TIMER_TIME_RECT_H);
587                 snprintf(time_str, sizeof(time_str), "%c", ad->chour[0]);
588                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_H1);
589                 snprintf(time_str, sizeof(time_str), "%c", ad->chour[1]);
590                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_H2);
591                 snprintf(time_str, sizeof(time_str), "%c.unfocused", ad->cminute[0]);
592                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_M1);
593                 snprintf(time_str, sizeof(time_str), "%c.unfocused", ad->cminute[1]);
594                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_M2);
595                 snprintf(time_str, sizeof(time_str), "%c.unfocused", ad->csecond[0]);
596                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_S1);
597                 snprintf(time_str, sizeof(time_str), "%c.unfocused", ad->csecond[1]);
598                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_S2);
599                 break;
600
601         case TIMER_FOCUS_MIN:
602                 edje_object_signal_emit(_EDJ(view->eo_content),
603                                         STRING_TIMER_MOURSE_CLICKED_1,
604                                         STRING_TIMER_TIME_RECT_M);
605                 snprintf(time_str, sizeof(time_str), "%c.unfocused", ad->chour[0]);
606                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_H1);
607                 snprintf(time_str, sizeof(time_str), "%c.unfocused", ad->chour[1]);
608                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_H2);
609                 snprintf(time_str, sizeof(time_str), "%c", ad->cminute[0]);
610                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_M1);
611                 snprintf(time_str, sizeof(time_str), "%c", ad->cminute[1]);
612                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_M2);
613                 snprintf(time_str, sizeof(time_str), "%c.unfocused", ad->csecond[0]);
614                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_S1);
615                 snprintf(time_str, sizeof(time_str), "%c.unfocused", ad->csecond[1]);
616                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_S2);
617                 break;
618
619         case TIMER_FOCUS_SEC:
620                 edje_object_signal_emit(_EDJ(view->eo_content),
621                                         STRING_TIMER_MOURSE_CLICKED_1,
622                                         STRING_TIMER_TIME_RECT_S);
623                 snprintf(time_str, sizeof(time_str), "%c.unfocused", ad->chour[0]);
624                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_H1);
625                 snprintf(time_str, sizeof(time_str), "%c.unfocused", ad->chour[1]);
626                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_H2);
627                 snprintf(time_str, sizeof(time_str), "%c.unfocused", ad->cminute[0]);
628                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_M1);
629                 snprintf(time_str, sizeof(time_str), "%c.unfocused", ad->cminute[1]);
630                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_M2);
631                 snprintf(time_str, sizeof(time_str), "%c", ad->csecond[0]);
632                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_S1);
633                 snprintf(time_str, sizeof(time_str), "%c", ad->csecond[1]);
634                 edje_object_signal_emit(_EDJ(view->eo_content), time_str, STRING_TIMER_TIME_IMG_S2);
635                 break;
636
637         default:
638                 return;
639         }
640 }
641
642 /**
643  * Debug function: to handle button clicking logic
644  * This function requires data, obj, emission, source as parameters
645  *
646  * timer_softkey_tap_cb()
647  * @param[in] data                  Pointer to user data, which contains the data of application
648  * @param[in] obj                    Pointer to button object
649  * @param[in] emission             Pointer to signal
650  * @param[in] source               Pointer to the source from which signal is emitted
651  *
652  * @return      void
653  */
654 void timer_setting_btn_cb(void *data, Evas_Object * obj, const char *emission,
655                           const char *source)
656 {
657         retm_if(!data, "data null");
658         struct appdata *ad = (struct appdata *)data;
659         timer_utils_time_get(ad);
660         if (EINA_FALSE == is_timer_utils_time_validate(ad)) {
661                 return;
662         }
663         int nErr = timer_utils_register_alarm(ad);
664         if (SUCCESS != nErr) {
665                 timer_widget_create_popup(ad->win_main, nErr);
666                 return;
667         }
668         timer_utils_view_change(ad);
669 }
670
671 void timer_view_setting_btn_cb_back(void *data, Evas_Object * obj,
672                                     void *event_info)
673 {
674         ret_if(!data);
675         Evas_Object *win = (Evas_Object *) data;
676         elm_win_lower(win);
677 }