4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
6 * Contact: MyoungJune Park <mj2004.park@samsung.com>
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include <mode-syspopup-alarmmgr.h>
22 /**********************************************************************
23 ******************Global function ref*************************************
24 ***********************************************************************/
28 * This function is used to create mgr
29 * @param data[in] pointer to AData
30 * @return when success, return EINA_TRUE or EINA_FALSE if error
33 int mode_syspopup_alarmmgr_create(MODE_BM_AData * alarm)
35 int nErr = -1; //no err
36 alarm_entry_t *alarm_entry = NULL;
37 alarm_date_t alarm_data;
40 alarm_entry = alarmmgr_create_alarm();
43 alarm_repeat_mode_t repeat_mode = 0;
44 nErr = alarmmgr_set_repeat_mode(alarm_entry, repeat_mode, repeat_value);
47 memset(&pt, 0, sizeof(struct tm));
48 time_t ctime = time(NULL);
49 if (NULL == localtime_r(&ctime, &pt)) {
50 _DBG("fail to call localtime_r");
53 _DBG("alarm->hour[%d], alarm->min[%d]",alarm->hour, alarm->min);
54 pt.tm_hour = alarm->hour;
55 pt.tm_min = alarm->min;
56 SET_BM_TIME_DATA_T(&alarm_data, pt.tm_year + 1900, pt.tm_mon + 1, pt.tm_mday, pt.tm_hour, pt.tm_min, 0);
57 nErr |= alarmmgr_set_time(alarm_entry, alarm_data);
60 nErr = alarmmgr_set_type(alarm_entry, ALARM_TYPE_DEFAULT);
64 nErr = alarmmgr_add_alarm_with_localtime(alarm_entry, SETTING_BM_ALARM_APP, &alarm_mgr_id);
65 //nErr = alarmmgr_add_alarm_appsvc_with_localtime(alarm_entry, (void *)b, &alarm_mgr_id);
66 _DBG("alarm_mgr_id [%d]", alarm_mgr_id);
69 _DBG("*** [ERR] alarmmgr_add_alarm_with_localtime failed ***");
72 alarm->alarm_mgr_id = alarm_mgr_id;
73 //vconf_set_int(VCONFKEY_SETAPPL_BM_ALARM_ID_START, alarm->alarm_mgr_id);
76 alarmmgr_free_alarm(alarm_entry);
83 * This function is used to remove mgr
84 * @param data[in] pointer to AData
85 * @return when success, return EINA_TRUE or EINA_FALSE if error
88 int mode_syspopup_alarmmgr_remove(MODE_BM_AData * alarm)
91 int start_block_id = -1;
92 int end_block_id = -1;
93 vconf_get_int(VCONFKEY_SETAPPL_BM_ALARM_ID_START, &start_block_id);
94 vconf_get_int(VCONFKEY_SETAPPL_BM_ALARM_ID_END, &end_block_id);
95 _DBG("alarm->alarm_mgr_id [%d]",alarm->alarm_mgr_id);
97 if(start_block_id==alarm->alarm_mgr_id) {
98 _DBG("start id remove");
99 ret = alarmmgr_remove_alarm(alarm->alarm_mgr_id);
100 vconf_set_int(VCONFKEY_SETAPPL_BM_ALARM_ID_START, -1);
102 else if(end_block_id==alarm->alarm_mgr_id) {
103 _DBG("end id remove");
104 ret = alarmmgr_remove_alarm(alarm->alarm_mgr_id);
105 vconf_set_int(VCONFKEY_SETAPPL_BM_ALARM_ID_END, -1);
109 _DBG("nothing to remove just create");
114 _DBG("*** [ERR] alarmmgr_remove_alarm failed : err_code=[%d]", ret);
122 * This function is used to update mgr
123 * @param data[in] pointer to AData
124 * @return when success, return EINA_TRUE or EINA_FALSE if error
127 int mode_syspopup_alarmmgr_update(MODE_BM_AData * alarm)
130 ret = mode_syspopup_alarmmgr_remove(alarm);
131 ret = mode_syspopup_alarmmgr_create(alarm);
132 _DBG("*** [ERR] mode_syspopup_alarmmgr_update failed ***");