4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
7 * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 #ifndef _ALARM_INTERNAL_H
24 #define _ALARM_INTERNAL_H
26 #define MAX_SNOOZE_CNT 5
27 #define REPEAT_MODE_ONCE 0x80
29 #define SIG_TIMER 0x32
30 #define ALARM_INFO_MAX 100
39 #define INIT_ALARM_LIST_SIZE 64
40 #define INIT_SCHEDULED_ALARM_LIST_SIZE 32
41 #define MAX_BUNDLE_NAME_LEN 2048
42 #define MAX_SERVICE_NAME_LEN 256
43 #define MAX_PKG_NAME_LEN MAX_SERVICE_NAME_LEN-8
44 #define MAX_PKG_ID_LEN 256
46 #define SYSTEM_TIME_CHANGED "setting_time_changed"
51 #define LOG_TAG "ALARM_MANAGER"
53 /*Application ID for native application which is not launched by application
55 #define ALARM_NATIVE_APP_ID 99999
56 /* Application Instance ID for native application which is not launched by
58 #define ALARM_NATIVE_APP_INST_ID 99999
59 /* Prefix of dbus service name of native application.*/
60 #define ALARM_NATIVE_APP_DBUS_SVC_NAME_PREFIX "NATIVE"
62 /* how to send expire event : gproxy or low level dbus
63 * if you want to use gproxy for receiving expire_event, please enable
64 * _EXPIRE_ALARM_INTERFACE_IS_DBUS_GPROXY_ feature
65 * otherwise, lowlevel dbus interface will be used for receiving expire_event.
66 * Now we use low level dbus instead of gproxy
68 /*#define _EXPIRE_ALARM_INTERFACE_IS_DBUS_GPROXY_ */
71 GDBusConnection *connection;
73 alarm_cb_t alarm_handler;
75 int pid; /* this specifies pid*/
76 GQuark quark_app_service_name; /*dbus_service_name is converted
78 GQuark quark_app_service_name_mod;
82 int day_of_week; /**< days of a week */
87 * This struct has mode of an alarm
90 alarm_interval_u u_interval;
91 alarm_repeat_mode_t repeat; /**< repeat mode */
95 * This enumeration has alarm type
99 ALARM_TYPE_DEFAULT = 0x0,
100 ALARM_TYPE_RELATIVE = 0x01,
101 ALARM_TYPE_VOLATILE = 0x02,
104 #define ALARM_TYPE_RELATIVE 0x80000000 /**< relative */
105 #define ALARM_TYPE_WITHCB 0x40000000 /**< withcb */
106 #define ALARM_TYPE_PERIOD 0x10000000 /**< periodic */
109 * This struct has the information of an alarm
113 alarm_date_t start; /**< start time of the alarm */
114 alarm_date_t end; /**< end time of the alarm */
115 alarm_mode_t mode; /**< mode of alarm */
116 int alarm_type; /**< alarm type*/
120 bool _send_alarm_create(alarm_context_t context, alarm_info_t *alarm,
121 alarm_id_t *id, const char *dst_service_name,const char *dst_service_name_mod,
123 bool _send_alarm_create_appsvc(alarm_context_t context, alarm_info_t *alarm_info,
124 alarm_id_t *alarm_id, bundle *b,int *error_code);
125 bool _send_alarm_update(alarm_context_t context, int pid, alarm_id_t alarm_id,
126 alarm_info_t *alarm_info, int *error_code);
127 bool _send_alarm_delete(alarm_context_t context, alarm_id_t alarm_id,
129 bool _send_alarm_get_list_of_ids(alarm_context_t context, int maxnum_of_ids,
130 alarm_id_t *alarm_id, int *num_of_ids,
132 bool _send_alarm_get_number_of_ids(alarm_context_t context, int *num_of_ids,
134 bool _send_alarm_get_info(alarm_context_t context, alarm_id_t alarm_id,
135 alarm_info_t *alarm_info, int *error_code);
136 bool _send_alarm_reset(alarm_context_t context, int *error_code);
137 bool _remove_from_scheduled_alarm_list(int pid, alarm_id_t alarm_id);
138 bool _load_alarms_from_registry();
139 bundle *_send_alarm_get_appsvc_info(alarm_context_t context, alarm_id_t alarm_id, int *error_code);
140 bool _send_alarm_set_rtc_time(alarm_context_t context, alarm_date_t *time, int *error_code);
149 GQuark quark_caller_pkgid;
150 GQuark quark_callee_pkgid;
151 GQuark quark_app_unique_name; /*the fullpath of application's pid is
152 converted to quark value.*/
153 GQuark quark_app_service_name; /*dbus_service_name is converted to
154 quark value.app_service_name is a service name of application
155 that creates alarm_info.*/
156 GQuark quark_app_service_name_mod;
157 GQuark quark_dst_service_name; /*dbus_service_name is converted to
158 quark value.app_service_name is a service name for
159 dst_service_name of alarm_create_extend().*/
160 GQuark quark_dst_service_name_mod;
163 GQuark quark_bundle; /*Bundle Content containing app-svc info*/
165 alarm_info_t alarm_info;
167 periodic_method_e method;
168 long requested_interval;
174 __alarm_info_t *__alarm_info;
183 GDBusConnection *connection;
184 } __alarm_server_context_t;
190 __alarm_info_t *__alarm_info;
191 } __scheduled_alarm_t;
194 char service_name[MAX_SERVICE_NAME_LEN];
198 time_t _alarm_next_duetime(__alarm_info_t *alarm_info);
199 bool _alarm_schedule();
200 bool _clear_scheduled_alarm_list();
201 bool _add_to_scheduled_alarm_list(__alarm_info_t *__alarm_info);
203 bool _save_alarms(__alarm_info_t *__alarm_info);
204 bool _delete_alarms(alarm_id_t alarm_id);
205 bool _update_alarms(__alarm_info_t *__alarm_info);
207 bool _alarm_destory_timer(timer_t timer);
208 bool _alarm_set_timer(__alarm_server_context_t *alarm_context, int timer, time_t due_time);
209 bool _alarm_disable_timer(__alarm_server_context_t alarm_context);
210 bool _init_scheduled_alarm_list();
212 int _set_rtc_time(time_t _time);
213 int _set_sys_time(time_t _time);
214 int _set_time(time_t _time);
217 #define ALARM_MGR_LOG_PRINT(FMT, ARG...) do { printf("%5d", getpid()); printf
218 ("%s() : "FMT"\n", __FUNCTION__, ##ARG); } while (false)
219 #define ALARM_MGR_EXCEPTION_PRINT(FMT, ARG...) do { printf("%5d", getpid());
220 printf("%s() : "FMT"\n", __FUNCTION__, ##ARG); } while (false)
221 #define ALARM_MGR_ASSERT_PRINT(FMT, ARG...) do { printf("%5d", getpid()); printf
222 ("%s() : "FMT"\n", __FUNCTION__, ##ARG); } while (false)
224 #define ALARM_MGR_LOG_PRINT(FMT, ARG...) LOGD(FMT, ##ARG);
225 #define ALARM_MGR_EXCEPTION_PRINT(FMT, ARG...) LOGW(FMT, ##ARG);
226 #define ALARM_MGR_ASSERT_PRINT(FMT, ARG...) LOGE(FMT, ##ARG);
229 #endif /*_ALARM_INTERNAL_H*/