Merge branch '2.0_beta' of ssh://tizendev.org:29418/apps/home/settings into 2.0_beta
[apps/core/preloaded/settings.git] / setting-time / src / setting-time-engine.c
1 /*
2  * setting
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
5  *
6  * Contact: MyoungJune Park <mj2004.park@samsung.com>
7  * 
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 #include <setting-time-engine.h>
22
23 /*  To set system time takes some time. It makes some time before firing heynoti of setting_time_changed.*/
24 int setting_time_update_cb(void *data)
25 {
26         /* time_t time_input = (time_t)data; */
27
28         char time_str[SETTING_TIME_ENGINE_TIME_STR_LEN];
29         struct tm *ts;
30         struct tm ts_ret;
31         time_t ctime;
32
33         retv_if(data == NULL, -1);
34         SettingTimeUG *ad = data;
35
36         // get time from datefield UI
37         ctime = ad->changed_time;
38         //ctime = time(NULL);
39         ts = localtime_r(&ctime, &ts_ret);
40         retv_if(!ts, 1);
41         strftime(time_str, SETTING_TIME_ENGINE_TIME_STR_LEN, "%H:%M", &ts_ret);
42         SETTING_TRACE("After setting time ::: tm is_dst --> %d", ts_ret.tm_isdst);
43         SETTING_TRACE("After Setting time time_str:%s", time_str);
44 #if SUPPORT_SCREEN_PROTECTED
45         pm_unlock_state(LCD_NORMAL, STAY_CUR_STATE);
46 #endif
47
48         if (ad->pop_progress) {
49                 evas_object_del(ad->pop_progress);
50                 ad->pop_progress = NULL;
51         }
52         return 0;
53 }