#include<dbus/dbus.h>
#include<dbus/dbus-glib-lowlevel.h>
#include<glib.h>
+#if !GLIB_CHECK_VERSION (2, 31, 0)
#include <glib/gmacros.h>
+#else
+#endif
/*#include "global-gconf.h"*/
#include"alarm.h"
GSList *g_expired_alarm_list = NULL;
+#ifndef RTC_WKALM_BOOT_SET
+#define RTC_WKALM_BOOT_SET _IOW('p', 0x80, struct rtc_wkalrm)
+#endif
+
#ifdef __ALARM_BOOT
bool enable_power_on_alarm;
bool alarm_boot;
__alarm_info->quark_bundle=g_quark_from_string(bundle_data);
__alarm_info->quark_app_service_name = g_quark_from_string("null");
__alarm_info->quark_dst_service_name = g_quark_from_string("null");
+ __alarm_info->quark_app_service_name_mod = g_quark_from_string("null");
+ __alarm_info->quark_dst_service_name_mod = g_quark_from_string("null");
__alarm_set_start_and_end_time(alarm_info, __alarm_info);
memcpy(&(__alarm_info->alarm_info), alarm_info, sizeof(alarm_info_t));
interval = difftime(alarm_context.c_due_time, current_time);
ALARM_MGR_LOG_PRINT("[alarm-server]: c_due_time(%d), "
- "current_time(%d), interval(%d)\n", alarm_context.c_due_time,
+ "current_time(%d), interval(%d)\n", alarm_context.c_due_time,
current_time, interval);
- if (alarm_context.c_due_time <= current_time - 1) {
- ALARM_MGR_LOG_PRINT("Wrong alarm is expired\n");
+ if (alarm_context.c_due_time > current_time) {
+ ALARM_MGR_LOG_PRINT("[alarm-server]: False Alarm\n");
goto done;
}
{
snprintf(alarm_id_val,31,"%d",alarm_id);
- if (bundle_add(b,"http://tizen.org/appsvc/data/alarm_id", alarm_id_val)){
+ if (bundle_add(b,"http://tizen.org/appcontrol/data/alarm_id", alarm_id_val)){
ALARM_MGR_EXCEPTION_PRINT("Unable to add alarm id to the bundle\n");
}
else
dbus_g_connection_get_connection(alarm_context.bus),
destination_app_service_name, NULL) == FALSE) {
__expired_alarm_t *expire_info;
- char pkg_name[MAX_SERVICE_NAME_LEN] = { 0, };
+ char appid[MAX_SERVICE_NAME_LEN] = { 0, };
char alarm_id_str[32] = { 0, };
expire_info = malloc(sizeof(__expired_alarm_t));
if (strncmp
(g_quark_to_string(__alarm_info->quark_dst_service_name),
"null",4) == 0) {
- strncpy(pkg_name,g_quark_to_string(__alarm_info->quark_app_service_name),strlen(g_quark_to_string(__alarm_info->quark_app_service_name))-6);
+ strncpy(appid,g_quark_to_string(__alarm_info->quark_app_service_name),strlen(g_quark_to_string(__alarm_info->quark_app_service_name))-6);
}
else
{
- strncpy(pkg_name,g_quark_to_string(__alarm_info->quark_dst_service_name),strlen(g_quark_to_string(__alarm_info->quark_dst_service_name))-6);
+ strncpy(appid,g_quark_to_string(__alarm_info->quark_dst_service_name),strlen(g_quark_to_string(__alarm_info->quark_dst_service_name))-6);
}
snprintf(alarm_id_str, 31, "%d", alarm_id);
- ALARM_MGR_LOG_PRINT("before aul_launch pkg_name(%s) "
- "alarm_id_str(%s)\n", pkg_name, alarm_id_str);
+ ALARM_MGR_LOG_PRINT("before aul_launch appid(%s) "
+ "alarm_id_str(%s)\n", appid, alarm_id_str);
bundle *kb;
kb = bundle_create();
bundle_add(kb, "__ALARM_MGR_ID", alarm_id_str);
- aul_launch_app(pkg_name, kb);
+ aul_launch_app(appid, kb);
bundle_free(kb);
} else {
ALARM_MGR_LOG_PRINT(
alarm_context.c_due_time);
_set_time(_time);
+
+ vconf_set_dbl(VCONFKEY_SYSTEM_TIMEDIFF, diff_time);
+ vconf_set_int(VCONFKEY_SYSTEM_TIME_CHANGED,(int)diff_time);
+
+ if (heynoti_publish(SYSTEM_TIME_CHANGED))
+ ALARM_MGR_EXCEPTION_PRINT("alarm-server: Unable to publish heynoti for system time change\n");
+
__alarm_update_due_time_of_all_items_in_list(diff_time);
ALARM_MGR_LOG_PRINT("2.alarm_context.c_due_time is %d\n",
return;
}
+gboolean alarm_manager_alarm_set_rtc_time(void *pObject, int pid,
+ int year, int mon, int day,
+ int hour, int min, int sec, char *e_cookie,
+ int *return_code){
+ guchar *cookie = NULL;
+ gsize size;
+ int retval = 0;
+ gboolean result = true;
+ gid_t call_gid;
+
+ const char *rtc = power_rtc;
+ int fd = 0;
+ struct rtc_time rtc_tm = {0,};
+ struct rtc_wkalrm rtc_wk;
+ struct tm *alarm_tm = NULL;
+ struct tm due_tm = {0,};
+
+
+ if (return_code){
+ *return_code = ALARMMGR_RESULT_SUCCESS;
+ }
+
+ cookie = g_base64_decode(e_cookie, &size);
+ if (NULL == cookie)
+ {
+ if (return_code)
+ *return_code = ERR_ALARM_NO_PERMISSION;
+ ALARM_MGR_EXCEPTION_PRINT("Unable to decode cookie!!!\n");
+ return true;
+ }
+
+ call_gid = security_server_get_gid("alarm");
+
+ ALARM_MGR_LOG_PRINT("call_gid : %d\n", call_gid);
+
+ retval = security_server_check_privilege((const char *)cookie, call_gid);
+ if (retval < 0) {
+ if (retval == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) {
+ ALARM_MGR_EXCEPTION_PRINT(
+ "%s", "access has been denied\n");
+ }
+ ALARM_MGR_EXCEPTION_PRINT("Error has occurred in security_server_check_privilege()\n");
+ if (return_code)
+ *return_code = ERR_ALARM_NO_PERMISSION;
+ }
+ else {
+
+ /*extract day of the week, day in the year &
+ daylight saving time from system*/
+ time_t ctime;
+ ctime = time(NULL);
+ alarm_tm = localtime(&ctime);
+
+ alarm_tm->tm_year = year;
+ alarm_tm->tm_mon = mon;
+ alarm_tm->tm_mday = day;
+ alarm_tm->tm_hour = hour;
+ alarm_tm->tm_min = min;
+ alarm_tm->tm_sec = sec;
+
+ /*convert to calendar time representation*/
+ time_t rtc_time = mktime(alarm_tm);
+
+ /*convert to Coordinated Universal Time (UTC)*/
+ gmtime_r(&rtc_time, &due_tm);
+
+ fd = open(rtc, O_RDONLY);
+ if (fd == -1) {
+ ALARM_MGR_EXCEPTION_PRINT("RTC open failed.\n");
+ if (return_code)
+ *return_code = ERR_ALARM_SYSTEM_FAIL;
+ return result;
+ }
+
+ /* Read the RTC time/date */
+ retval = ioctl(fd, RTC_RD_TIME, &rtc_tm);
+ if (retval == -1) {
+ ALARM_MGR_EXCEPTION_PRINT("RTC_RD_TIME ioctl failed");
+ close(fd);
+ if (return_code)
+ *return_code = ERR_ALARM_SYSTEM_FAIL;
+ return result;
+ }
+
+ rtc_tm.tm_mday = due_tm.tm_mday;
+ rtc_tm.tm_mon = due_tm.tm_mon;
+ rtc_tm.tm_year = due_tm.tm_year;
+ rtc_tm.tm_hour = due_tm.tm_hour;
+ rtc_tm.tm_min = due_tm.tm_min;
+ rtc_tm.tm_sec = due_tm.tm_sec;
+
+ memcpy(&rtc_wk.time, &rtc_tm, sizeof(rtc_tm));
+
+ rtc_wk.enabled = 1;
+ rtc_wk.pending = 0;
+
+ retval = ioctl(fd, RTC_WKALM_BOOT_SET, &rtc_wk);
+ if (retval == -1) {
+ if (errno == ENOTTY) {
+ ALARM_MGR_EXCEPTION_PRINT("\nAlarm IRQs not"
+ "supported.\n");
+ }
+ ALARM_MGR_EXCEPTION_PRINT("RTC_ALM_SET ioctl");
+ close(fd);
+ if (return_code)
+ *return_code = ERR_ALARM_SYSTEM_FAIL;
+ }
+ else{
+ ALARM_MGR_LOG_PRINT("[alarm-server]RTC alarm is setted");
+ /* Enable alarm interrupts */
+ retval = ioctl(fd, RTC_AIE_ON, 0);
+ if (retval == -1) {
+ ALARM_MGR_EXCEPTION_PRINT("RTC_AIE_ON ioctl failed");
+ if (return_code)
+ *return_code = ERR_ALARM_SYSTEM_FAIL;
+ }
+ close(fd);
+ }
+ }
+
+ if (cookie){
+ g_free(cookie);
+ cookie = NULL;
+ }
+
+ return result;
+
+}
gboolean alarm_manager_alarm_create_appsvc(void *pObject, int pid,
int start_year,