pkg_check_modules(pkgs REQUIRED ${DEPS_PKGS})
FOREACH(flag ${pkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag} -Wall -Wno-unused")
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag} -Wall -Werror")
ENDFOREACH(flag)
SET (${this_target}_SOURCE_FILES
#include<glib.h>
#include <db-util.h>
-#if !GLIB_CHECK_VERSION (2, 31, 0)
+#if !GLIB_CHECK_VERSION(2, 31, 0)
#include <glib/gmacros.h>
#endif
#include"alarm.h"
g_quark_from_string(app_unique_name);
__alarm_info->quark_app_service_name =
g_quark_from_string(app_service_name);
- __alarm_info->quark_app_service_name_mod=
+ __alarm_info->quark_app_service_name_mod =
g_quark_from_string(app_service_name_mod);
__alarm_info->quark_dst_service_name =
g_quark_from_string(dst_service_name);
- __alarm_info->quark_dst_service_name_mod=
+ __alarm_info->quark_dst_service_name_mod =
g_quark_from_string(dst_service_name_mod);
__alarm_info->quark_bundle = g_quark_from_string(bundle);
#include"alarm.h"
#include"alarm-internal.h"
#define WAKEUP_ALARM_APP_ID "org.tizen.alarm.ALARM" /*alarm ui
- application's alarm's dbus_service name instead of 21 value */
+ application's alarm's dbus_service name instead of 21 value */
#define DST_TIME_DIFF 1
extern __alarm_server_context_t alarm_context;
bool _add_to_scheduled_alarm_list(__alarm_info_t *__alarm_info)
{
-/*
- * 20080328. Sewook Park(sewook7.park@samsung.com)
- * When multiple alarms are expired at same time, dbus rpc call for alarm
- * ui should be invoked first.(Ui conflicting manager cannot manage the
- * different kinds of alarm popups(wake up alarm/org alarm) correctly,
- * when they are displayed at same time)So when arranging the schedule
- * alarm list, wake up alarm element is located ahead.
- */
+ /*
+ * 20080328. Sewook Park(sewook7.park@samsung.com)
+ * When multiple alarms are expired at same time, dbus rpc call for alarm
+ * ui should be invoked first.(Ui conflicting manager cannot manage the
+ * different kinds of alarm popups(wake up alarm/org alarm) correctly,
+ * when they are displayed at same time)So when arranging the schedule
+ * alarm list, wake up alarm element is located ahead.
+ */
bool prior = false;
gint count = 0;
__scheduled_alarm_t *entry = NULL;
alarm = g_malloc(sizeof(__scheduled_alarm_t));
- if (alarm == NULL) {
+ if (alarm == NULL)
return false;
- }
alarm->used = true;
alarm->alarm_id = __alarm_info->alarm_id;
if (alarm->__alarm_info->quark_app_service_name != g_quark_from_string(WAKEUP_ALARM_APP_ID)) {
g_scheduled_alarm_list = g_slist_append(g_scheduled_alarm_list, alarm);
- }
- else {
+ } else {
for (iter = g_scheduled_alarm_list; iter != NULL; iter = g_slist_next(iter)) {
count++;
entry = iter->data;
if (!prior) {
g_scheduled_alarm_list = g_slist_append(g_scheduled_alarm_list, alarm);
ALARM_MGR_LOG_PRINT("appended : prior is %d\tcount is %d\n", prior, count);
- }
- else {
+ } else {
g_scheduled_alarm_list = g_slist_insert(g_scheduled_alarm_list, alarm, count - 1);
ALARM_MGR_LOG_PRINT("appended : prior is %d\tcount is %d\n", prior, count);
}
}
}
- if (g_slist_length(g_scheduled_alarm_list) == 0) {
+ if (g_slist_length(g_scheduled_alarm_list) == 0)
alarm_context.c_due_time = -1;
- }
return result;
}
current_dst = duetime_tm.tm_isdst;
duetime_tm.tm_isdst = -1;
- if (start->year == 0 && start->month == 0 && start->day == 0)
- /*any date */ {
+ if (start->year == 0 && start->month == 0 && start->day == 0) {
+ /*any date */
due_time = mktime(&duetime_tm);
- if (!(due_time > current_time)) {
+ if (!(due_time > current_time))
due_time = due_time + 60 * 60 * 24;
- }
} else /*specific date*/ {
duetime_tm.tm_year = start->year - 1900;
duetime_tm.tm_mon = start->month - 1;
if (due_time <= current_time) {
ALARM_MGR_EXCEPTION_PRINT("duetime is less than or equal to current time. current_dst = %d", current_dst);
- duetime_tm.tm_isdst = 0; // DST off
+ duetime_tm.tm_isdst = 0; /* DST off */
due_time_tmp = mktime(&duetime_tm);
localtime_r(&due_time_tmp, &tmp_tm);
ALARM_MGR_LOG_PRINT("%d:%d:%d. duetime = %d", tmp_tm.tm_hour, tmp_tm.tm_min, tmp_tm.tm_sec, due_time);
- if (tmp_tm.tm_hour == start->hour && tmp_tm.tm_min == start->min && tmp_tm.tm_sec == start->sec ) {
+ if (tmp_tm.tm_hour == start->hour && tmp_tm.tm_min == start->min && tmp_tm.tm_sec == start->sec) {
due_time = due_time_tmp;
- ALARM_MGR_EXCEPTION_PRINT("due_time = %d",due_time);
+ ALARM_MGR_EXCEPTION_PRINT("due_time = %d", due_time);
}
- }
- else {
+ } else {
localtime_r(&due_time, &tmp_tm);
ALARM_MGR_LOG_PRINT("%d:%d:%d. current_dst = %d, duetime_dst = %d", tmp_tm.tm_hour, tmp_tm.tm_min, tmp_tm.tm_sec, current_dst, tmp_tm.tm_isdst);
if (current_dst == 1 && tmp_tm.tm_isdst == 1 && tmp_tm.tm_hour == start->hour + 1) {
- // When the calculated duetime is forwarded 1hour due to DST, Adds 23hours.
+ /* When the calculated duetime is forwarded 1hour due to DST, Adds 23hours. */
due_time += 60 * 60 * 23;
localtime_r(&due_time, &duetime_tm);
- ALARM_MGR_EXCEPTION_PRINT("due_time = %d",due_time);
+ ALARM_MGR_EXCEPTION_PRINT("due_time = %d", due_time);
}
}
- ALARM_MGR_EXCEPTION_PRINT("Final due_time = %d, %s",due_time, ctime(&due_time));
+ ALARM_MGR_EXCEPTION_PRINT("Final due_time = %d, %s", due_time, ctime(&due_time));
return due_time;
}
due_time = mktime(&duetime_tm);
}
- while (__alarm_info->start > due_time || current_time > due_time || ((!is_time_changed) && (current_time == due_time))) {
+ while (__alarm_info->start > due_time || current_time > due_time || ((!is_time_changed) && (current_time == due_time)))
due_time += alarm_info->mode.u_interval.interval;
- }
if (due_time - current_time < 10)
due_time += alarm_info->mode.u_interval.interval;
duetime_tm.tm_min = start->min;
duetime_tm.tm_sec = start->sec;
- if (start->year != 0) {
+ if (start->year != 0)
duetime_tm.tm_year = start->year - 1900;
- }
duetime_tm.tm_mon = start->month - 1;
duetime_tm.tm_mday = start->day;
}
return due_time;
-
}
static time_t __alarm_next_duetime_monthly(__alarm_info_t *__alarm_info)
duetime_tm.tm_min = start->min;
duetime_tm.tm_sec = start->sec;
- if (start->year != 0) {
+ if (start->year != 0)
duetime_tm.tm_year = start->year - 1900;
- }
- if (start->month != 0) {
+ if (start->month != 0)
duetime_tm.tm_mon = start->month - 1;
- }
duetime_tm.tm_mday = start->day;
}
return due_time;
-
}
static time_t __alarm_next_duetime_weekly(__alarm_info_t *__alarm_info)
localtime_r(&due_time, &tmp_tm);
SECURE_LOGD("%d:%d:%d. duetime = %d", tmp_tm.tm_hour, tmp_tm.tm_min, tmp_tm.tm_sec, due_time);
- if (tmp_tm.tm_hour != start->hour || tmp_tm.tm_min != start->min || tmp_tm.tm_sec != start->sec ) {
+ if (tmp_tm.tm_hour != start->hour || tmp_tm.tm_min != start->min || tmp_tm.tm_sec != start->sec) {
duetime_tm.tm_hour = start->hour;
duetime_tm.tm_min = start->min;
duetime_tm.tm_sec = start->sec;
due_time = mktime(&duetime_tm);
ALARM_MGR_LOG_PRINT("due_time = %d", due_time);
}
- }
- else {
+ } else {
if (current_dst == 1 && tmp_tm.tm_isdst == 1 && tmp_tm.tm_hour == start->hour + 1) {
- // When the calculated duetime is forwarded 1hour due to DST, Adds 23hours.
+ /* When the calculated duetime is forwarded 1hour due to DST, Adds 23hours. */
due_time += 60 * 60 * 23;
localtime_r(&due_time, &duetime_tm);
ALARM_MGR_LOG_PRINT("due_time = %d", due_time);
}
}
- // Gets the dst before calculating the duedate as interval
+ /* Gets the dst before calculating the duedate as interval */
localtime_r(&due_time, &before_tm);
SECURE_LOGD("before_dst = %d", before_tm.tm_isdst);
/* CQ defect(72810) : only one time alarm function is not working
under all recurrence_disabled. */
- if (due_time > current_time && mode->u_interval.day_of_week == 0) {
+ if (due_time > current_time && mode->u_interval.day_of_week == 0)
return due_time;
- }
if (current_time > due_time || !(mode->u_interval.day_of_week & 1 << wday) || ((!is_time_changed) && (current_time == due_time))) {
int day = wday + 1;
int interval = 1;
/*this week */
- if (day == 7) {
+ if (day == 7)
day = 0;
- }
while (!(mode->u_interval.day_of_week & 1 << day) && interval < 8) {
day += 1;
interval += 1;
- if (day == 7) {
+ if (day == 7)
day = 0;
- }
}
ALARM_MGR_LOG_PRINT("interval : %d\n", interval);
due_time += 60 * 60 * 24 * interval;
}
- // Gets the dst after calculating the duedate as interval
+ /* Gets the dst after calculating the duedate as interval */
localtime_r(&due_time, &after_tm);
SECURE_LOGD("after_dst = %d", after_tm.tm_isdst);
- // Revise the duetime as difference in tm_isdst
- if (before_tm.tm_isdst == 1 && after_tm.tm_isdst == 0) {
- due_time += 60 * 60; // Add an hour
- } else if (before_tm.tm_isdst == 0 && after_tm.tm_isdst == 1) {
- due_time -= 60 * 60; // Subtract an hour
- }
+ /* Revise the duetime as difference in tm_isdst */
+ if (before_tm.tm_isdst == 1 && after_tm.tm_isdst == 0)
+ due_time += 60 * 60; /* Add an hour */
+ else if (before_tm.tm_isdst == 0 && after_tm.tm_isdst == 1)
+ due_time -= 60 * 60; /* Subtract an hour */
ALARM_MGR_LOG_PRINT("Final due_time = %d", due_time);
return due_time;
time_t _alarm_next_duetime(__alarm_info_t *__alarm_info)
{
- int is_dst=0;
+ int is_dst = 0;
time_t current_time = 0;
time_t due_time = 0;
struct tm *cur_tm = NULL ;
due_time = __alarm_next_duetime_weekly(__alarm_info);
} else {
ALARM_MGR_EXCEPTION_PRINT("repeat mode(%d) is wrong\n",
- mode->repeat);
+ mode->repeat);
return 0;
}
if (mode->repeat != ALARM_REPEAT_MODE_WEEKLY && mode->repeat != ALARM_REPEAT_MODE_ONCE) {
due_tm = localtime(&due_time);
- if (is_dst==0 && due_tm && due_tm->tm_isdst==1){
- ALARM_MGR_LOG_PRINT("DST alarm found, enable\n");
- due_tm->tm_hour = due_tm->tm_hour - DST_TIME_DIFF;
- } else if (is_dst==1 && due_tm && due_tm->tm_isdst==0){
- ALARM_MGR_LOG_PRINT("DST alarm found. disable\n");
- due_tm->tm_hour = due_tm->tm_hour + DST_TIME_DIFF;
+ if (is_dst == 0 && due_tm && due_tm->tm_isdst == 1) {
+ ALARM_MGR_LOG_PRINT("DST alarm found, enable\n");
+ due_tm->tm_hour = due_tm->tm_hour - DST_TIME_DIFF;
+ } else if (is_dst == 1 && due_tm && due_tm->tm_isdst == 0) {
+ ALARM_MGR_LOG_PRINT("DST alarm found. disable\n");
+ due_tm->tm_hour = due_tm->tm_hour + DST_TIME_DIFF;
}
if (due_tm)
due_time = mktime(due_tm);
time(¤t_time);
for (iter = alarm_context.alarms; iter != NULL;
- iter = g_slist_next(iter)) {
+ iter = g_slist_next(iter)) {
entry = iter->data;
due_time = entry->due_time;
double interval = 0;
SECURE_LOGD("alarm[%d] with duetime(%u) at current(%u) pid: (%d)\n",
- entry->alarm_id, due_time, current_time, entry->pid);
+ entry->alarm_id, due_time, current_time, entry->pid);
if (due_time == 0) /*0 means this alarm has been disabled*/ {
continue;
}
interval = difftime(due_time, min_time);
- if ((interval < 0) || min_time == -1) {
+ if ((interval < 0) || min_time == -1)
min_time = due_time;
- }
-
}
*min_due_time = min_time;
entry = iter->data;
due_time = entry->due_time;
- if (due_time == min_time) {
+ if (due_time == min_time)
_add_to_scheduled_alarm_list(entry);
- }
}
_alarm_set_timer(&alarm_context, alarm_context.timer, min_time);
}
/*
- * alarm-manager
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
- * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
*/
#include <stdio.h>
#include <sys/types.h>
#include <errno.h>
#include <sys/timerfd.h>
-
#include <glib.h>
#include "alarm.h"
g_dummy_timer_is_set = true;
strftime(due_time_r, 30, "%c", &ts_ret);
ALARM_MGR_LOG_PRINT("create dummy alarm timer(%d), due_time(%s)", timer, due_time_r);
- }
- else {
+ } else {
g_dummy_timer_is_set = false;
}
/*
- * alarm-manager
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
- * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
*/
#define _GNU_SOURCE
#include <eventsystem.h>
#include <glib.h>
-#if !GLIB_CHECK_VERSION (2, 31, 0)
+#if !GLIB_CHECK_VERSION(2, 31, 0)
#include <glib/gmacros.h>
#endif
#define SIG_TIMER 0x32
#define WAKEUP_ALARM_APP_ID "org.tizen.alarm.ALARM"
- /* alarm ui application's alarm's dbus_service name instead of 21
- (alarm application's app_id) value */
+/* alarm ui application's alarm's dbus_service name instead of 21
+ * (alarm application's app_id) value */
__alarm_server_context_t alarm_context;
bool g_dummy_timer_is_set = FALSE;
#define RTC_WKALM_BOOT_SET _IOW('p', 0x80, struct rtc_wkalrm)
#endif
-/* 2008. 6. 3 sewook7.park
- When the alarm becoms sleeping mode, alarm timer is not expired.
- So using RTC, phone is awaken before alarm rings.
-*/
+/*
+ * 2008. 6. 3 sewook7.park
+ * When the alarm becoms sleeping mode, alarm timer is not expired.
+ * So using RTC, phone is awaken before alarm rings.
+ */
#define __WAKEUP_USING_RTC__
#ifdef __WAKEUP_USING_RTC__
#include <errno.h>
static int log_fd = 0;
#endif
-// display lock and unlock
+/* display lock and unlock */
#define DEVICED_BUS_NAME "org.tizen.system.deviced"
#define DEVICED_PATH_DISPLAY "/Org/Tizen/System/DeviceD/Display"
#define DEVICED_INTERFACE_DISPLAY "org.tizen.system.deviced.display"
#define DEVICED_STAY_CUR_STATE "staycurstate"
#define DEVICED_SLEEP_MARGIN "sleepmargin"
-// link path for timezone info
+/* link path for timezone info */
#define TIMEZONE_INFO_LINK_PATH tzplatform_mkpath(TZ_SYS_ETC, "localtime")
static const char default_rtc[] = "/dev/rtc";
static int gfd = -1;
-#endif /*__WAKEUP_USING_RTC__*/
+#endif /*__WAKEUP_USING_RTC__*/
/* GDBus Declaration */
#define ALARM_MGR_DBUS_PATH "/org/tizen/alarm/manager"
static AlarmManager* interface = NULL;
sqlite3 *alarmmgr_db;
-bool is_time_changed = false; // for calculating next duetime
+bool is_time_changed = false; /* for calculating next duetime */
-#define BILLION 1000000000 // for calculating nano seconds
+#define BILLION 1000000000 /* for calculating nano seconds */
static time_t periodic_alarm_standard_time = 0;
static bool __alarm_add_to_list(__alarm_info_t *__alarm_info);
static void __alarm_send_noti_to_application(const char *app_service_name, alarm_id_t alarm_id);
static void __alarm_expired();
static gboolean __alarm_handler_idle(gpointer user_data);
-static void __clean_registry();
-static bool __alarm_manager_reset();
static void __on_system_time_external_changed(keynode_t *node, void *data);
static void __initialize_timer();
static void __initialize_alarm_list();
static bool __initialize_db();
static void __initialize();
void on_bus_name_owner_changed(GDBusConnection *connection, const gchar *sender_name, const gchar *object_path,
- const gchar *interface_name, const gchar *signal_name, GVariant *parameters, gpointer user_data);
+ const gchar *interface_name, const gchar *signal_name, GVariant *parameters, gpointer user_data);
bool __get_caller_unique_name(int pid, char *unique_name, uid_t uid);
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
int __set_time(time_t _time);
-struct filtered_alarm_app_s
-{
+struct filtered_alarm_app_s {
int is_ui_app;
uid_t uid;
};
#ifdef __WAKEUP_USING_RTC__
const char *rtc = default_rtc;
struct tm due_tm;
- struct timespec alarm_time;
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
#endif
-#ifdef _SIMUL // RTC does not work in simulator.
+#ifdef _SIMUL /* RTC does not work in simulator. */
ALARM_MGR_EXCEPTION_PRINT("because it is simulator's mode, we don't set RTC.");
return;
#endif
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
char *timebuf = ctime(&alarm_context.c_due_time);
if (timebuf) {
- timebuf[strlen(timebuf) - 1] = '\0'; // to avoid new line
+ timebuf[strlen(timebuf) - 1] = '\0'; /* to avoid new line */
snprintf(log_message, sizeof(log_message), "wakeup time: %d, %s", (int)alarm_context.c_due_time, timebuf);
}
#endif
retval = ioctl(gfd, RTC_WKALM_SET, &rtc_wkalarm);
if (retval == -1) {
- if (errno == ENOTTY) {
+ if (errno == ENOTTY)
ALARM_MGR_EXCEPTION_PRINT("Alarm IRQs is not supported.");
- }
+
ALARM_MGR_EXCEPTION_PRINT("RTC_WKALM_SET disabled ioctl is failed. errno = %s", strerror(errno));
return;
}
rtc_wkalarm.time.tm_sec = due_tm.tm_sec - 1; /* Wakeup is 1000ms faster than expiring time to correct RTC error. */
retval = ioctl(gfd, RTC_WKALM_SET, &rtc_wkalarm);
if (retval == -1) {
- if (errno == ENOTTY) {
+ if (errno == ENOTTY)
ALARM_MGR_EXCEPTION_PRINT("Alarm IRQs is not supported.");
- }
+
ALARM_MGR_EXCEPTION_PRINT("RTC ALARM_SET ioctl is failed. errno = %s", strerror(errno));
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
__save_module_log("FAIL: SET RTC", log_message);
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
__save_module_log("SET RTC", log_message);
#endif
- }
- else {
+ } else {
ALARM_MGR_EXCEPTION_PRINT("[alarm-server]alarm_context.c_due_time is"
"less than 10 sec. RTC alarm does not need to be set");
}
-#endif /* __WAKEUP_USING_RTC__ */
+#endif /* __WAKEUP_USING_RTC__ */
return;
}
int __set_time(time_t _time)
{
- // Using /dev/alarm, this function changes both OS time and RTC.
+ /* Using /dev/alarm, this function changes both OS time and RTC. */
int ret = 0;
const char *rtc0 = default_rtc;
struct rtc_time _rtc_time;
ret = ioctl(gfd, RTC_SET_TIME, &_rtc_time);
if (ret == -1) {
ALARM_MGR_EXCEPTION_PRINT("ALARM_SET_RTC ioctl is failed. errno = %s", strerror(errno));
- #ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
+#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
strncpy(log_tag, "FAIL: SET RTC", strlen("FAIL: SET RTC"));
- #endif
+#endif
perror("\t");
}
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- else {
+ else
strncpy(log_tag, "SET RTC", strlen("SET RTC"));
- }
char *timebuf = ctime(&_time);
if (timebuf) {
- timebuf[strlen(timebuf) - 1] = '\0'; // to avoid new line
+ timebuf[strlen(timebuf) - 1] = '\0'; /* to avoid new line */
snprintf(log_message, sizeof(log_message), "RTC & OS =%d, %s", (int)_time, timebuf);
}
alarm_context.alarms = g_slist_append(alarm_context.alarms, __alarm_info);
ALARM_MGR_LOG_PRINT("[alarm-server]: After add alarm_id(%d)", __alarm_info->alarm_id);
- // alarm list
+ /* alarm list */
for (iter = alarm_context.alarms; iter != NULL; iter = g_slist_next(iter)) {
entry = iter->data;
ALARM_MGR_LOG_PRINT("[alarm-server]: alarm_id(%d).", entry->alarm_id);
}
if (!(alarm_info->alarm_type & ALARM_TYPE_VOLATILE)) {
- if (!_save_alarms(__alarm_info)) {
+ if (!_save_alarms(__alarm_info))
ALARM_MGR_EXCEPTION_PRINT("Saving alarm_id(%d) in DB is failed.", __alarm_info->alarm_id);
- }
}
return true;
}
if (!(alarm_info->alarm_type & ALARM_TYPE_VOLATILE)) {
- if (!_update_alarms(__alarm_info)) {
+ if (!_update_alarms(__alarm_info))
ALARM_MGR_EXCEPTION_PRINT("Updating alarm_id(%d) in DB is failed.", __alarm_info->alarm_id);
- }
}
return true;
ALARM_MGR_LOG_PRINT("[alarm-server]:Remove alarm id(%d)", entry->alarm_id);
- if (!(alarm_info->alarm_type & ALARM_TYPE_VOLATILE)) {
+ if (!(alarm_info->alarm_type & ALARM_TYPE_VOLATILE))
_delete_alarms(alarm_id);
- }
alarm_context.alarms = g_slist_remove(alarm_context.alarms, iter->data);
g_free(entry);
for (iter = alarm_context.alarms; iter != NULL; iter = g_slist_next(iter)) {
entry = iter->data;
alarm_info_t *alarm_info = &(entry->alarm_info);
- if (alarm_info->alarm_type & ALARM_TYPE_RELATIVE) {
+ if (alarm_info->alarm_type & ALARM_TYPE_RELATIVE)
_update_alarms(entry);
- }
}
if (sqlite3_exec(alarmmgr_db, "COMMIT", NULL, NULL, &error_message) != SQLITE_OK) {
interval = difftime(due_time, min_time);
- if ((interval < 0) || min_time == -1) {
+ if ((interval < 0) || min_time == -1)
min_time = due_time;
- }
}
is_time_changed = false;
}
__alarm_info->quark_app_unique_name = g_quark_from_string(app_name);
- // Get caller_appid and callee_appid to get each package id
- // caller
+ /* Get caller_appid and callee_appid to get each package id */
+ /* caller */
__alarm_info->quark_caller_pkgid = g_quark_from_string("null");
if (aul_app_get_appid_bypid_for_uid(pid, caller_appid, 256, uid) == AUL_R_OK) {
if (pkgmgrinfo_appinfo_get_usr_appinfo(caller_appid, uid, &caller_handle) == PMINFO_R_OK) {
if (pkgmgrinfo_appinfo_get_pkgid(caller_handle, &caller_pkgid) == PMINFO_R_OK) {
- if (caller_pkgid) {
+ if (caller_pkgid)
__alarm_info->quark_caller_pkgid = g_quark_from_string(caller_pkgid);
- }
}
pkgmgrinfo_appinfo_destroy_appinfo(caller_handle);
}
}
- // callee
+ /* callee */
__alarm_info->quark_callee_pkgid = g_quark_from_string("null");
b = bundle_decode((bundle_raw *)bundle_data, strlen(bundle_data));
callee_appid = appsvc_get_appid(b);
if (pkgmgrinfo_appinfo_get_usr_appinfo(callee_appid, uid, &callee_handle) == PMINFO_R_OK) {
if (pkgmgrinfo_appinfo_get_pkgid(callee_handle, &callee_pkgid) == PMINFO_R_OK) {
- if (callee_pkgid) {
+ if (callee_pkgid)
__alarm_info->quark_callee_pkgid = g_quark_from_string(callee_pkgid);
- }
}
pkgmgrinfo_appinfo_destroy_appinfo(callee_handle);
}
__alarm_info->is_ref = is_ref;
__alarm_info->global = false;
- // Get caller_appid to get caller's package id. There is no callee.
+ /* Get caller_appid to get caller's package id. There is no callee. */
if (aul_app_get_appid_bypid_for_uid(pid, caller_appid, 256, uid) == AUL_R_OK) {
if (pkgmgrinfo_appinfo_get_usr_appinfo(caller_appid, uid, &caller_handle) == PMINFO_R_OK) {
if (pkgmgrinfo_appinfo_get_pkgid(caller_handle, &caller_pkgid) == PMINFO_R_OK) {
- if (caller_pkgid) {
+ if (caller_pkgid)
__alarm_info->quark_caller_pkgid = g_quark_from_string(caller_pkgid);
- }
}
pkgmgrinfo_appinfo_destroy_appinfo(caller_handle);
}
__rtc_set();
- if (due_time == 0) {
+ if (due_time == 0)
ALARM_MGR_EXCEPTION_PRINT("[alarm-server]:Update alarm: due_time is 0.");
- }
+
free(__alarm_info);
return true;
}
due_time);
free(__alarm_info);
return true;
- } else if (difftime(due_time, current_time)< 0) {
+ } else if (difftime(due_time, current_time) < 0) {
ALARM_MGR_EXCEPTION_PRINT("[alarm-server]: Expired Due Time.[Due time=%d, Current Time=%d]!!!Do not add to schedule list\n", due_time, current_time);
free(__alarm_info);
return true;
from = (ts / dur) * dur;
to = from + dur;
- if ( ts >= from && ts < to && from > ts - alarm->mode.u_interval.interval) {
+ if (ts >= from && ts < to && from > ts - alarm->mode.u_interval.interval)
return false;
- }
return true;
}
GVariant *ret;
GError *error = NULL;
- ret = g_dbus_connection_call_sync (alarm_context.connection,
- "org.freedesktop.DBus",
- "/org/freedesktop/DBus",
- "org.freedesktop.DBus",
- "GetConnectionUnixProcessID",
- g_variant_new ("(s)", name),
- NULL,
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- &error);
- g_variant_get (ret, "(u)", &pid);
- g_variant_unref (ret);
+ ret = g_dbus_connection_call_sync(alarm_context.connection,
+ "org.freedesktop.DBus",
+ "/org/freedesktop/DBus",
+ "org.freedesktop.DBus",
+ "GetConnectionUnixProcessID",
+ g_variant_new("(s)", name),
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ g_variant_get(ret, "(u)", &pid);
+ g_variant_unref(ret);
return pid;
}
ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, uid, &appinfo_h);
- if (ret < 0 ) {
+ if (ret < 0)
return 0;
- }
char *component = NULL;
int found = 0;
ret = pkgmgrinfo_appinfo_get_component_type(appinfo_h, &component);
- if (ret == 0 && component != NULL && strncmp(component, "uiapp", 5) == 0) {
+ if (ret == 0 && component != NULL && strncmp(component, "uiapp", 5) == 0)
found = 1;
- }
if (appinfo_h)
pkgmgrinfo_appinfo_destroy_appinfo(appinfo_h);
return found;
}
-static int __iter_fn(const char* appid, void *data)
+static int __compare_api_version(int *result, int pid, uid_t uid)
{
- struct filtered_alarm_app_s *app = data;
-
- if (__is_ui_app(appid, app->uid)) {
- app->is_ui_app = 1;
- return 1;
- }
-
- return 0;
-}
-
-static int __have_ui_apps(bundle *b, uid_t uid)
-{
- struct filtered_alarm_app_s app;
- app.uid = uid;
- appsvc_usr_get_list(b, __iter_fn, &app, uid);
- return app.is_ui_app;
-}
-
-static int __compare_api_version(int *result, int pid, uid_t uid) {
int ret = 0;
pkgmgrinfo_pkginfo_h pkginfo = NULL;
char pkgid[512] = {0, };
ALARM_MGR_EXCEPTION_PRINT("Failed to get pkginfo\n");
} else {
ret = pkgmgrinfo_pkginfo_get_api_version(pkginfo, &pkg_version);
- if (ret != PMINFO_R_OK) {
+ if (ret != PMINFO_R_OK)
ALARM_MGR_EXCEPTION_PRINT("Failed to check api version [%d]\n", ret);
- }
*result = strverscmp(pkg_version, "2.4");
pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo);
}
alarm_id_t alarm_id = -1;
int app_pid = 0;
__alarm_info_t *__alarm_info = NULL;
- char alarm_id_val[32]={0,};
+ char alarm_id_val[32];
int b_len = 0;
bundle *b = NULL;
char *appid = NULL;
alarm_context.c_due_time - current_time);
goto done;
}
- // 10 seconds is maximum permitted delay from timer expire to this function
+ /* 10 seconds is maximum permitted delay from timer expire to this function */
if (alarm_context.c_due_time + 10 < current_time) {
ALARM_MGR_EXCEPTION_PRINT("[alarm-server]: False Alarm. due time is (%d) seconds past.",
current_time - alarm_context.c_due_time);
__alarm_info = alarm->__alarm_info;
app_pid = __alarm_info->pid;
- // Case #1. The process is an application launched by app_control.
- // It registered an alarm using launch-based APIs like alarm_schedule_xxx, alarmmgr_xxx_appsvc.
+ /* Case #1. The process is an application launched by app_control.
+ * It registered an alarm using launch-based APIs like alarm_schedule_xxx, alarmmgr_xxx_appsvc. */
if (strncmp(g_quark_to_string(__alarm_info->quark_bundle), "null", 4) != 0) {
b_len = strlen(g_quark_to_string(__alarm_info->quark_bundle));
b = bundle_decode((bundle_raw *)g_quark_to_string(__alarm_info->quark_bundle), b_len);
- if (b == NULL)
- {
+ if (b == NULL) {
ALARM_MGR_EXCEPTION_PRINT("Error!!!..Unable to decode the bundle!!\n");
- }
- else
- {
- snprintf(alarm_id_val,31,"%d",alarm_id);
+ } else {
+ snprintf(alarm_id_val, sizeof(alarm_id_val), "%d", alarm_id);
- if (bundle_add_str(b,"http://tizen.org/appcontrol/data/alarm_id", alarm_id_val)){
+ if (bundle_add_str(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 {
+ } else {
int result = 0;
if (__compare_api_version(&result, app_pid, __alarm_info->uid) < 0) {
result = -1;
}
- if (result < 0) { /* before 2.4 */
- if ( appsvc_usr_run_service(b, 0, NULL, NULL, __alarm_info->uid) < 0) {
+ if (result < 0) {
+ /* before 2.4 */
+ if (appsvc_usr_run_service(b, 0, NULL, NULL, __alarm_info->uid) < 0)
ALARM_MGR_EXCEPTION_PRINT("Unable to run app svc\n");
- }
- else {
+ else
ALARM_MGR_LOG_PRINT("Successfuly run app svc\n");
- }
- } else { /* since 2.4 */
+ } else {
+ /* since 2.4 */
appid = (char *)appsvc_get_appid(b);
- if( (__alarm_info->alarm_info.alarm_type & ALARM_TYPE_NOLAUNCH) && !aul_app_is_running(appid)) {
+ if ((__alarm_info->alarm_info.alarm_type & ALARM_TYPE_NOLAUNCH) && !aul_app_is_running(appid)) {
ALARM_MGR_EXCEPTION_PRINT("This alarm is ignored\n");
- } else if ( !(__alarm_info->alarm_info.alarm_type & ALARM_TYPE_INEXACT) ||
- !__can_skip_expired_cb(__alarm_info->alarm_id) ) {
+ } else if (!(__alarm_info->alarm_info.alarm_type & ALARM_TYPE_INEXACT) ||
+ !__can_skip_expired_cb(__alarm_info->alarm_id)) {
if (__alarm_info->global) {
if (__find_login_user(&target_uid) < 0) {
ALARM_MGR_EXCEPTION_PRINT("Fail to get login user\n");
if (ret < 0) {
ALARM_MGR_EXCEPTION_PRINT("Unable to launch app [%s] \n", appid);
- }
- else {
+ } else {
ALARM_MGR_LOG_PRINT("Successfuly ran app svc\n");
- if (__is_ui_app(appid, __alarm_info->uid)) {
+ if (__is_ui_app(appid, __alarm_info->uid))
device_display_change_state(DISPLAY_STATE_NORMAL);
- }
}
}
}
}
bundle_free(b);
}
- }
- else
- {
+ } else {
char appid[MAX_SERVICE_NAME_LEN] = { 0, };
pkgmgrinfo_appinfo_h appinfo_handle = NULL;
"/org/freedesktop/DBus",
"org.freedesktop.DBus",
"NameHasOwner",
- g_variant_new ("(s)", destination_app_service_name),
- G_VARIANT_TYPE ("(b)"),
+ g_variant_new("(s)", destination_app_service_name),
+ G_VARIANT_TYPE("(b)"),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
ALARM_MGR_EXCEPTION_PRINT("g_dbus_connection_call_sync() is failed. err: %s", error->message);
g_error_free(error);
} else {
- g_variant_get (result, "(b)", &name_has_owner_reply);
+ g_variant_get(result, "(b)", &name_has_owner_reply);
}
if (g_quark_to_string(__alarm_info->quark_dst_service_name) != NULL && strncmp(g_quark_to_string(__alarm_info->quark_dst_service_name), "null", 4) == 0) {
ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, __alarm_info->uid, &appinfo_handle);
ALARM_MGR_LOG_PRINT("appid : %s (%x)", appid, appinfo_handle);
- // Case #2. The process was killed && App type
- // This app is launched and owner of DBus connection is changed. and then, expiration noti is sent by DBus.
+ /* Case #2. The process was killed && App type
+ * This app is launched and owner of DBus connection is changed. and then, expiration noti is sent by DBus. */
if (name_has_owner_reply == false && ret == PMINFO_R_OK) {
__expired_alarm_t *expire_info;
char alarm_id_str[32] = { 0, };
bundle_add_str(kb, "__ALARM_MGR_ID", alarm_id_str);
if (__alarm_info->global) {
- if (__find_login_user(&target_uid) < 0) {
+ if (__find_login_user(&target_uid) < 0)
ALARM_MGR_EXCEPTION_PRINT("Fail to get login user\n");
- } else {
- aul_launch_app_for_uid(appid, kb, target_uid); // on_bus_name_owner_changed will be called.
- }
+ else
+ aul_launch_app_for_uid(appid, kb, target_uid); /* on_bus_name_owner_changed will be called. */
} else {
- aul_launch_app_for_uid(appid, kb, __alarm_info->uid); // on_bus_name_owner_changed will be called.
+ aul_launch_app_for_uid(appid, kb, __alarm_info->uid); /* on_bus_name_owner_changed will be called. */
}
bundle_free(kb);
} else {
- // Case #3. The process is alive or was killed && non-app type(daemon)
- // Expiration noti is sent by DBus. it makes the process alive. (dbus auto activation)
+ /* Case #3. The process is alive or was killed && non-app type(daemon)
+ * Expiration noti is sent by DBus. it makes the process alive. (dbus auto activation) */
ALARM_MGR_LOG_PRINT("before alarm_send_noti_to_application");
ALARM_MGR_LOG_PRINT("WAKEUP pid: %d", __alarm_info->pid);
/* TODO: implement aul_update_freezer_status */
- //aul_update_freezer_status(__alarm_info->pid, "wakeup");
- __alarm_send_noti_to_application(destination_app_service_name, alarm_id); // dbus auto activation
+ /* aul_update_freezer_status(__alarm_info->pid, "wakeup"); */
+ __alarm_send_noti_to_application(destination_app_service_name, alarm_id); /* dbus auto activation */
ALARM_MGR_LOG_PRINT("after __alarm_send_noti_to_application");
}
}
__save_module_log("EXPIRED", log_message);
#endif
- if (__alarm_info->alarm_info.mode.repeat == ALARM_REPEAT_MODE_ONCE) {
+ if (__alarm_info->alarm_info.mode.repeat == ALARM_REPEAT_MODE_ONCE)
__alarm_remove_from_list(__alarm_info->uid, alarm_id, NULL);
- } else {
+ else
_alarm_next_duetime(__alarm_info);
- }
}
- done:
+done:
_clear_scheduled_alarm_list();
alarm_context.c_due_time = -1;
}
ALARM_MGR_LOG_PRINT("Lock the display not to enter LCD OFF");
- if (__display_lock_state(DEVICED_LCD_OFF, DEVICED_STAY_CUR_STATE, 0) != ALARMMGR_RESULT_SUCCESS) {
+ if (__display_lock_state(DEVICED_LCD_OFF, DEVICED_STAY_CUR_STATE, 0) != ALARMMGR_RESULT_SUCCESS)
ALARM_MGR_EXCEPTION_PRINT("__display_lock_state() is failed");
- }
if (g_dummy_timer_is_set == true) {
ALARM_MGR_LOG_PRINT("dummy alarm timer has expired.");
- }
- else {
+ } else {
ALARM_MGR_LOG_PRINT("__alarm_handler_idle");
__alarm_expired();
}
*/
time(¤t_time);
if (alarm_context.c_due_time == current_time) {
- ALARM_MGR_LOG_PRINT("Expire alarms forcibly when duetime is same to current time(%d).", current_time)
+ ALARM_MGR_LOG_PRINT("Expire alarms forcibly when duetime is same to current time(%d).", current_time);
__alarm_expired();
_alarm_schedule();
}
__rtc_set();
ALARM_MGR_LOG_PRINT("Unlock the display from LCD OFF");
- if (__display_unlock_state(DEVICED_LCD_OFF, DEVICED_SLEEP_MARGIN) != ALARMMGR_RESULT_SUCCESS) {
+ if (__display_unlock_state(DEVICED_LCD_OFF, DEVICED_SLEEP_MARGIN) != ALARMMGR_RESULT_SUCCESS)
ALARM_MGR_EXCEPTION_PRINT("__display_unlock_state() is failed");
- }
return false;
}
-static void __clean_registry()
-{
-
- /*TODO:remove all db entries */
-}
-
-static bool __alarm_manager_reset()
-{
- _alarm_disable_timer(alarm_context);
-
- __alarm_clean_list();
-
- _clear_scheduled_alarm_list();
- __clean_registry();
-
- return true;
-}
-
static void __on_system_time_external_changed(keynode_t *node, void *data)
{
double diff_time = 0.0;
__set_time(cur_time);
- vconf_set_int(VCONFKEY_SYSTEM_TIME_CHANGED,(int)diff_time);
+ vconf_set_int(VCONFKEY_SYSTEM_TIME_CHANGED, (int)diff_time);
bundle *b = NULL;
b = bundle_create();
bundle_add_str(b, EVT_KEY_TIME_CHANGED, EVT_VAL_TIME_CHANGED_TRUE);
SECURE_LOGD("pkg_type(%s), pkgid(%s), key(%s), value(%s)", pkg_type, pkgid, key, val);
- if (strncmp(key, "end", 3) == 0 && strncmp(val, "ok", 2) == 0)
- {
- for (gs_iter = alarm_context.alarms; gs_iter != NULL; )
- {
+ if (strncmp(key, "end", 3) == 0 && strncmp(val, "ok", 2) == 0) {
+ for (gs_iter = alarm_context.alarms; gs_iter != NULL;) {
bool is_found = false;
entry = gs_iter->data;
const char* callee_pkgid = g_quark_to_string(entry->quark_callee_pkgid);
if ((caller_pkgid && strncmp(pkgid, caller_pkgid, strlen(pkgid)) == 0) ||
- (callee_pkgid && strncmp(pkgid, callee_pkgid, strlen(pkgid)) == 0))
- {
+ (callee_pkgid && strncmp(pkgid, callee_pkgid, strlen(pkgid)) == 0)) {
if (_remove_from_scheduled_alarm_list(entry->uid, entry->alarm_id))
- {
is_deleted = true;
- }
alarm_info = &entry->alarm_info;
- if (!(alarm_info->alarm_type & ALARM_TYPE_VOLATILE))
- {
- if(!_delete_alarms(entry->alarm_id))
- {
+ if (!(alarm_info->alarm_type & ALARM_TYPE_VOLATILE)) {
+ if (!_delete_alarms(entry->alarm_id))
SECURE_LOGE("_delete_alarms() is failed. pkgid[%s], alarm_id[%d]", pkgid, entry->alarm_id);
- }
}
is_found = true;
}
gs_iter = g_slist_next(gs_iter);
- if (is_found)
- {
+ if (is_found) {
SECURE_LOGD("Remove pkgid[%s], alarm_id[%d]", pkgid, entry->alarm_id);
alarm_context.alarms = g_slist_remove(alarm_context.alarms, entry);
g_free(entry);
}
}
- if (is_deleted && (g_slist_length(g_scheduled_alarm_list) == 0))
- {
+ if (is_deleted && (g_slist_length(g_scheduled_alarm_list) == 0)) {
_alarm_disable_timer(alarm_context);
_alarm_schedule();
}
bool __get_caller_unique_name(int pid, char *unique_name, uid_t uid)
{
char caller_appid[256] = {0,};
- char caller_cmdline[512] = {0,};
if (unique_name == NULL) {
ALARM_MGR_EXCEPTION_PRINT("unique_name should not be NULL.");
SECURE_LOGE("Caution!! pid(%d) seems to be killed.",
pid, proc_file);
return false;
- }
- else {
- if (read(fd, process_name, sizeof(process_name) - 1) <= 0)
- {
+ } else {
+ if (read(fd, process_name, sizeof(process_name) - 1) <= 0) {
ALARM_MGR_EXCEPTION_PRINT("Unable to get the process name.");
close(fd);
return false;
{
char buffer[ALARMMGR_LOG_BUFFER_STRING_SIZE] = {0,};
time_t now;
- int offset = 0;
if (log_fd == -1) {
ALARM_MGR_EXCEPTION_PRINT("The file is not ready.");
return false;
}
- if (log_index != 0) {
- offset = lseek(log_fd, 0, SEEK_CUR);
- } else {
- offset = lseek(log_fd, 0, SEEK_SET);
- }
+ if (log_index != 0)
+ lseek(log_fd, 0, SEEK_CUR);
+ else
+ lseek(log_fd, 0, SEEK_SET);
time(&now);
snprintf(buffer, ALARMMGR_LOG_BUFFER_STRING_SIZE, "[%-6d] %-20s %-120s %d-%s", log_index, tag, message, (int)now, ctime(&now));
return false;
}
- if (++log_index >= ALARMMGR_LOG_BUFFER_SIZE) {
+ if (++log_index >= ALARMMGR_LOG_BUFFER_SIZE)
log_index = 0;
- }
+
return true;
}
-#endif // _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
+#endif /* _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG */
int __display_lock_state(char *state, char *flag, unsigned int timeout)
{
return ERR_ALARM_SYSTEM_FAIL;
}
- g_dbus_message_set_body(msg, g_variant_new("(ss)", state, flag ));
+ g_dbus_message_set_body(msg, g_variant_new("(ss)", state, flag));
reply = g_dbus_connection_send_message_with_reply_sync(alarm_context.connection, msg, G_DBUS_SEND_MESSAGE_FLAGS_NONE, DEVICED_DBUS_REPLY_TIMEOUT, NULL, NULL, NULL);
if (!reply) {
entry = gs_iter->data;
if (entry->alarm_info.alarm_type & ALARM_TYPE_PERIOD) {
if (entry->alarm_info.mode.u_interval.interval <= interval &&
- entry->alarm_info.mode.u_interval.interval > maxInterval) {
+ entry->alarm_info.mode.u_interval.interval > maxInterval)
maxInterval = entry->alarm_info.mode.u_interval.interval;
- }
}
}
while (maxInterval * 2 <= interval ||
- (alarm_type & ALARM_TYPE_INEXACT && maxInterval < MIN_INEXACT_INTERVAL) ) {
+ (alarm_type & ALARM_TYPE_INEXACT && maxInterval < MIN_INEXACT_INTERVAL))
maxInterval *= 2;
- }
return maxInterval;
}
gboolean __alarm_expired_directly(gpointer user_data)
{
- if (g_scheduled_alarm_list == NULL || g_scheduled_alarm_list->data == NULL) {
+ if (g_scheduled_alarm_list == NULL || g_scheduled_alarm_list->data == NULL)
return false;
- }
- int time_sec = (int)user_data;
+ int time_sec = (int)(intptr_t)user_data;
__scheduled_alarm_t *alarm = g_scheduled_alarm_list->data;
__alarm_info_t *alarm_info = alarm->__alarm_info;
- // Expire alarms with duetime equal to newtime by force
+ /* Expire alarms with duetime equal to newtime by force */
if (alarm_info->due_time == time_sec) {
- if (__display_lock_state(DEVICED_LCD_OFF, DEVICED_STAY_CUR_STATE, 0) != ALARMMGR_RESULT_SUCCESS) {
+ if (__display_lock_state(DEVICED_LCD_OFF, DEVICED_STAY_CUR_STATE, 0) != ALARMMGR_RESULT_SUCCESS)
ALARM_MGR_EXCEPTION_PRINT("__display_lock_state() is failed");
- }
if (g_dummy_timer_is_set == true) {
ALARM_MGR_LOG_PRINT("dummy alarm timer has expired.");
- }
- else {
+ } else {
ALARM_MGR_LOG_PRINT("due_time=%d is expired.", alarm_info->due_time);
__alarm_expired();
}
_alarm_schedule();
__rtc_set();
- if (__display_unlock_state(DEVICED_LCD_OFF, DEVICED_SLEEP_MARGIN) != ALARMMGR_RESULT_SUCCESS) {
+ if (__display_unlock_state(DEVICED_LCD_OFF, DEVICED_SLEEP_MARGIN) != ALARMMGR_RESULT_SUCCESS)
ALARM_MGR_EXCEPTION_PRINT("__display_unlock_state() is failed");
- }
}
return false;
char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
#endif
- vconf_set_int(VCONFKEY_SYSTEM_TIME_CHANGED,(int)diff_time);
+ vconf_set_int(VCONFKEY_SYSTEM_TIME_CHANGED, (int)diff_time);
bundle *b = NULL;
b = bundle_create();
bundle_add_str(b, EVT_KEY_TIME_CHANGED, EVT_VAL_TIME_CHANGED_TRUE);
eventsystem_send_system_event(SYS_EVENT_TIME_CHANGED, b);
bundle_free(b);
- __alarm_update_due_time_of_all_items_in_list(diff_time); // Rescheduling alarms with ALARM_TYPE_RELATIVE
+ __alarm_update_due_time_of_all_items_in_list(diff_time); /* Rescheduling alarms with ALARM_TYPE_RELATIVE */
ALARM_MGR_LOG_PRINT("Next duetime is %d", alarm_context.c_due_time);
_clear_scheduled_alarm_list();
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
char *timebuf = ctime((const time_t *)&new_time);
if (timebuf) {
- timebuf[strlen(timebuf) - 1] = '\0'; // to avoid newline
+ timebuf[strlen(timebuf) - 1] = '\0'; /* to avoid newline */
snprintf(log_message, sizeof(log_message), "Current: %d, New: %d, %s, diff: %f", cur_time, new_time, timebuf, diff_time);
}
__save_module_log("CHANGE TIME", log_message);
#endif
- g_idle_add(__alarm_expired_directly, (gpointer)new_time); // Expire alarms with duetime equal to newtime directly
+ g_idle_add(__alarm_expired_directly, (gpointer)(intptr_t)new_time); /* Expire alarms with duetime equal to newtime directly */
return;
}
retval = ioctl(gfd, RTC_WKALM_SET, &rtc_wkalarm);
if (retval == -1) {
- if (errno == ENOTTY) {
+ if (errno == ENOTTY)
ALARM_MGR_EXCEPTION_PRINT("Alarm IRQs is not supported.");
- }
+
ALARM_MGR_EXCEPTION_PRINT("RTC ALARM_SET ioctl is failed. errno = %s", strerror(errno));
return_code = ERR_ALARM_SYSTEM_FAIL;
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
strncpy(log_tag, "FAIL: SET RTC", strlen("FAIL: SET RTC"));
#endif
- }
- else{
+ } else {
ALARM_MGR_LOG_PRINT("[alarm-server]RTC alarm is setted");
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
strncpy(log_tag, "SET RTC", strlen("SET RTC"));
return true;
}
-static int accrue_msec = 0; // To check a millisecond part of current time at changing the system time(sec)
+static int accrue_msec = 0; /* To check a millisecond part of current time at changing the system time(sec) */
gboolean alarm_manager_alarm_set_time(AlarmManager *pObj, GDBusMethodInvocation *invoc, int time_sec, gpointer user_data)
{
struct timeval cur_time = {0,};
int return_code = ALARMMGR_RESULT_SUCCESS;
- _alarm_disable_timer(alarm_context); // Disable the timer to reschedule the alarm before the time is changed.
+ _alarm_disable_timer(alarm_context); /* Disable the timer to reschedule the alarm before the time is changed. */
tzset();
gettimeofday(&cur_time, NULL);
- accrue_msec += (cur_time.tv_usec / 1000); // Accrue the millisecond to compensate the time
+ accrue_msec += (cur_time.tv_usec / 1000); /* Accrue the millisecond to compensate the time */
if (accrue_msec > 500) {
diff_time = difftime(time_sec, cur_time.tv_sec) - 1;
accrue_msec -= 1000;
diff_time = difftime(time_sec, cur_time.tv_sec);
}
- __set_time(time_sec); // Change both OS time and RTC
+ __set_time(time_sec); /* Change both OS time and RTC */
ALARM_MGR_LOG_PRINT("[TIMESTAMP]Current time(%d), New time(%d)(%s), diff_time(%f)",
cur_time.tv_sec, time_sec, ctime((const time_t *)&time_sec), diff_time);
struct timespec delay = {0,};
struct timespec sleep_time = {0,};
guint real_newtime = 0;
- accrue_msec = 0; // reset accrued msec
+ accrue_msec = 0; /* reset accrued msec */
- _alarm_disable_timer(alarm_context); // Disable the timer to reschedule the alarm before the time is changed.
+ _alarm_disable_timer(alarm_context); /* Disable the timer to reschedule the alarm before the time is changed. */
tzset();
clock_gettime(CLOCK_REALTIME, &cur_time);
- // Check validation of requested time
+ /* Check validation of requested time */
if (req_sec > cur_time.tv_sec || (req_sec == cur_time.tv_sec && req_nsec > cur_time.tv_nsec)) {
ALARM_MGR_EXCEPTION_PRINT("The requeted time(%d.%09d) must be equal to or less than current time(%d.%09d).",
req_sec, req_nsec, cur_time.tv_sec, cur_time.tv_nsec);
return true;
}
- // Compensate propagation delay
+ /* Compensate propagation delay */
if (req_nsec > cur_time.tv_nsec) {
delay.tv_sec = cur_time.tv_sec - 1 - req_sec;
delay.tv_nsec = cur_time.tv_nsec + BILLION - req_nsec;
sleep_time.tv_nsec = BILLION - (delay.tv_nsec + new_nsec);
}
- nanosleep(&sleep_time, NULL); // Wait until 0 nsec to match both OS time and RTC(sec)
+ nanosleep(&sleep_time, NULL); /* Wait until 0 nsec to match both OS time and RTC(sec) */
- __set_time(real_newtime); // Change both OS time and RTC
+ __set_time(real_newtime); /* Change both OS time and RTC */
diff_time = difftime(real_newtime, cur_time.tv_sec);
ALARM_MGR_LOG_PRINT("[TIMESTAMP]Current time(%d.%09d), New time(%d.%09d), Real Newtime(%d), diff_time(%f)",
retval = stat(TIMEZONE_INFO_LINK_PATH, &statbuf);
if (retval == 0 || (retval == -1 && errno != ENOENT)) {
- // unlink the current link
+ /* unlink the current link */
if (unlink(TIMEZONE_INFO_LINK_PATH) < 0) {
ALARM_MGR_EXCEPTION_PRINT("unlink() is failed.");
return_code = ERR_ALARM_SYSTEM_FAIL;
}
}
- // create a new symlink when the /opt/etc/localtime is empty.
+ /* create a new symlink when the /opt/etc/localtime is empty. */
if (symlink(tzpath_str, TIMEZONE_INFO_LINK_PATH) < 0) {
ALARM_MGR_EXCEPTION_PRINT("Failed to create an symlink of %s.", tzpath_str);
return_code = ERR_ALARM_SYSTEM_FAIL;
tzset();
- // Rescheduling alarms
+ /* Rescheduling alarms */
_alarm_disable_timer(alarm_context);
__alarm_update_due_time_of_all_items_in_list(0);
ALARM_MGR_LOG_PRINT("next expiring due_time is %d", alarm_context.c_due_time);
eventsystem_send_system_event(SYS_EVENT_TIME_CHANGED, b);
bundle_free(b);
- b = NULL;
b = bundle_create();
bundle_add_str(b, EVT_KEY_TIME_ZONE, tzpath_str);
eventsystem_send_system_event(SYS_EVENT_TIME_ZONE, b);
done:
g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", return_code));
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- if (return_code == ALARMMGR_RESULT_SUCCESS) {
+ if (return_code == ALARMMGR_RESULT_SUCCESS)
strncpy(log_tag, "SET TIMEZONE", strlen("SET TIMEZONE"));
- } else {
+ else
strncpy(log_tag, "FAIL: SET TIMEZONE", strlen("FAIL: SET TIMEZONE"));
- }
+
snprintf(log_message, sizeof(log_message), "Set the timezone to %s.", tzpath_str);
__save_module_log(log_tag, log_message);
#endif
gpointer user_data)
{
alarm_info_t alarm_info;
- int retval = 0;
int return_code = ALARMMGR_RESULT_SUCCESS;
int alarm_id = 0;
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
alarm_info.alarm_type |= ALARM_TYPE_PERIOD;
alarm_info.mode.u_interval.interval =
__get_proper_interval(mode_interval, alarm_info.alarm_type);
- } else if (mode_interval <= 0){
+ } else if (mode_interval <= 0) {
alarm_info.mode.u_interval.interval = 0;
}
strncpy(log_tag, "FAIL: CREATE", strlen("FAIL: CREATE"));
#endif
ret = false;
- }
+ } else {
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- else {
strncpy(log_tag, "CREATE", strlen("CREATE"));
- }
#endif
+ }
g_dbus_method_invocation_return_value(invoc, g_variant_new("(ii)", alarm_id, return_code));
gpointer user_data)
{
alarm_info_t alarm_info;
- int retval = 0;
int return_code = ALARMMGR_RESULT_SUCCESS;
int alarm_id = 0;
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
alarm_info.alarm_type = alarm_type;
alarm_info.reserved_info = reserved_info;
- if (!__alarm_create(&alarm_info, &alarm_id, uid, pid, 0, 0, 0, app_service_name,app_service_name_mod,
- reserved_service_name, reserved_service_name_mod, &return_code)) {
+ if (!__alarm_create(&alarm_info, &alarm_id, uid, pid, 0, 0, 0, app_service_name, app_service_name_mod,
+ reserved_service_name, reserved_service_name_mod, &return_code)) {
ALARM_MGR_EXCEPTION_PRINT("Unable to create alarm! return_code[%d]", return_code);
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
strncpy(log_tag, "FAIL: CREATE", strlen("FAIL: CREATE"));
#endif
ret = false;
- }
+ } else {
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- else {
strncpy(log_tag, "CREATE", strlen("CREATE"));
- }
#endif
+ }
g_dbus_method_invocation_return_value(invoc, g_variant_new("(ii)", alarm_id, return_code));
}
if (!__alarm_create(&alarm_info, &alarm_id, uid, pid, method, interval * 60, is_ref,
- app_service_name, app_service_name_mod,
- "null", "null", &return_code)) {
+ app_service_name, app_service_name_mod,
+ "null", "null", &return_code)) {
ALARM_MGR_EXCEPTION_PRINT("Unable to create alarm! return_code[%d]", return_code);
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
strncpy(log_tag, "FAIL: CREATE", strlen("FAIL: CREATE"));
gboolean alarm_manager_alarm_delete(AlarmManager *obj, GDBusMethodInvocation *invoc,
alarm_id_t alarm_id, gpointer user_data)
{
- int retval = 0;
int return_code = ALARMMGR_RESULT_SUCCESS;
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
alarm_info_t* alarm_info = NULL;
__alarm_info_t* entry = NULL;
bool is_deleted = false;
- int retval = 0;
int return_code = ALARMMGR_RESULT_SUCCESS;
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
SECURE_LOGD("Called by process (pid:%d, unique_name=%s)", pid, app_name);
- for (gs_iter = alarm_context.alarms; gs_iter != NULL; )
- {
+ for (gs_iter = alarm_context.alarms; gs_iter != NULL;) {
bool is_found = false;
entry = gs_iter->data;
const char* tmp_appname = g_quark_to_string(entry->quark_app_unique_name);
SECURE_LOGD("Try to remove app_name[%s], alarm_id[%d]\n", tmp_appname, entry->alarm_id);
- if (tmp_appname && strncmp(app_name, tmp_appname, strlen(tmp_appname)) == 0)
- {
+ if (tmp_appname && strncmp(app_name, tmp_appname, strlen(tmp_appname)) == 0) {
if (_remove_from_scheduled_alarm_list(uid, entry->alarm_id))
- {
is_deleted = true;
- }
alarm_info = &entry->alarm_info;
- if (!(alarm_info->alarm_type & ALARM_TYPE_VOLATILE))
- {
- if(!_delete_alarms(entry->alarm_id))
- {
+ if (!(alarm_info->alarm_type & ALARM_TYPE_VOLATILE)) {
+ if (!_delete_alarms(entry->alarm_id))
SECURE_LOGE("_delete_alarms() is failed. pid[%d], alarm_id[%d]", pid, entry->alarm_id);
- }
}
is_found = true;
}
gs_iter = g_slist_next(gs_iter);
- if (is_found)
- {
+ if (is_found) {
ALARM_MGR_LOG_PRINT("alarm_id[%d] is removed.", entry->alarm_id);
SECURE_LOGD("Removing is done. app_name[%s], alarm_id [%d]\n", tmp_appname, entry->alarm_id);
alarm_context.alarms = g_slist_remove(alarm_context.alarms, entry);
}
}
- if (is_deleted && (g_slist_length(g_scheduled_alarm_list) == 0))
- {
+ if (is_deleted && (g_slist_length(g_scheduled_alarm_list) == 0)) {
_alarm_disable_timer(alarm_context);
_alarm_schedule();
}
strncpy(log_tag, "FAIL: UPDATE", strlen("FAIL: UPDATE"));
#endif
ret = false;
- }
+ } else {
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- else {
strncpy(log_tag, "UPDATE", strlen("UPDATE"));
- }
#endif
+ }
g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", return_code));
GSList *gs_iter = NULL;
char app_name[256] = { 0 };
__alarm_info_t *entry = NULL;
- int retval = 0;
int num_of_ids = 0;
int return_code = ALARMMGR_RESULT_SUCCESS;
uid_t uid;
SECURE_LOGD("Called by process (uid: %d, pid:%d, unique_name=%s).", uid, pid, app_name);
- builder = g_variant_builder_new(G_VARIANT_TYPE ("ai"));
+ builder = g_variant_builder_new(G_VARIANT_TYPE("ai"));
for (gs_iter = alarm_context.alarms; gs_iter != NULL; gs_iter = g_slist_next(gs_iter)) {
entry = gs_iter->data;
if (entry->uid == uid &&
strncmp(app_name, g_quark_to_string(entry->quark_app_unique_name), strlen(app_name)) == 0) {
- g_variant_builder_add (builder, "i", entry->alarm_id);
- index ++;
+ g_variant_builder_add(builder, "i", entry->alarm_id);
+ index++;
SECURE_LOGE("called for alarmid(%d), but max_number_of_ids(%d) index %d.", entry->alarm_id, max_number_of_ids, index);
}
}
bool found = false;
GSList *gs_iter = NULL;
__alarm_info_t *entry = NULL;
- int retval = 0;
int return_code = ALARMMGR_RESULT_SUCCESS;
gchar *b_data = NULL;
uid_t uid;
GSList *gs_iter = NULL;
__alarm_info_t *entry = NULL;
alarm_info_t *alarm_info = NULL;
- int retval = 0;
int return_code = ALARMMGR_RESULT_SUCCESS;
uid_t uid;
const char *name = g_dbus_method_invocation_get_sender(invoc);
GSList *gs_iter = NULL;
__alarm_info_t *entry = NULL;
__alarm_info_t *find_item = NULL;
- int retval = 0;
int return_code = ALARMMGR_RESULT_SUCCESS;
time_t duetime = 0;
uid_t uid;
__alarm_info_t *entry = NULL;
char *error_message = NULL;
uid_t uid;
-
const char *name = g_dbus_method_invocation_get_sender(invoc);
uid = __get_caller_uid(name);
- // Open a DB
+ /* Open a DB */
time(¤t_time);
localtime_r(¤t_time, ¤t_tm);
snprintf(db_path_tmp, sizeof(db_path_tmp), "/tmp/alarmmgr_%d%d%d_%02d%02d%02d.db",
return true;
}
- // Drop a table
- if (sqlite3_exec(alarmmgr_tool_db, query_for_deleting_table, NULL, NULL, &error_message) != SQLITE_OK) {
+ /* Drop a table */
+ if (sqlite3_exec(alarmmgr_tool_db, query_for_deleting_table, NULL, NULL, &error_message) != SQLITE_OK)
ALARM_MGR_EXCEPTION_PRINT("Deleting the table is failed. error message = %s", error_message);
- }
- // Create a table if it does not exist
+ /* Create a table if it does not exist */
if (sqlite3_exec(alarmmgr_tool_db, query_for_creating_table, NULL, NULL, &error_message) != SQLITE_OK) {
ALARM_MGR_EXCEPTION_PRINT("Creating the table is failed. error message = %s", error_message);
sqlite3_close(alarmmgr_tool_db);
return true;
}
- // Get information of all alarms and save those into the DB.
+ /* Get information of all alarms and save those into the DB. */
int index = 0;
for (gs_iter = alarm_context.alarms; gs_iter != NULL; gs_iter = g_slist_next(gs_iter)) {
entry = gs_iter->data;
mode->repeat,
entry->alarm_info.alarm_type);
- if (sqlite3_exec(alarmmgr_tool_db, query, NULL, NULL, &error_message) != SQLITE_OK) {
+ if (sqlite3_exec(alarmmgr_tool_db, query, NULL, NULL, &error_message) != SQLITE_OK)
SECURE_LOGE("sqlite3_exec() is failed. error message = %s", error_message);
- }
sqlite3_free(query);
}
int return_code = ALARMMGR_RESULT_SUCCESS;
uid_t uid;
const char *name = g_dbus_method_invocation_get_sender(invoc);
+ char *callee_pkgid;
uid = __get_caller_uid(name);
} else {
ALARM_MGR_LOG_PRINT("The alarm(%d) is found.", alarm_id);
- char *callee_pkgid = (char *)g_quark_to_string(entry->quark_callee_pkgid);
- if (strncmp(callee_pkgid, "null", strlen(callee_pkgid)) == 0) {
+ callee_pkgid = (char *)g_quark_to_string(entry->quark_callee_pkgid);
+ if (strncmp(callee_pkgid, "null", strlen(callee_pkgid)) == 0)
callee_pkgid = (char *)g_quark_to_string(entry->quark_app_service_name)+6;
- }
ALARM_MGR_LOG_PRINT("The alarm pkgid : %s.", callee_pkgid);
retval = pkgmgrinfo_pkginfo_get_pkginfo(callee_pkgid, &handle);
if (retval != PMINFO_R_OK) {
ALARM_MGR_EXCEPTION_PRINT("The alarm(%d) is not permitted to set global.", alarm_id);
- return_code = ERR_ALARM_INVALID_ID; //TODO change error code
+ return_code = ERR_ALARM_INVALID_ID; /* TODO change error code */
} else {
bool is_global = 0;
retval = pkgmgrinfo_pkginfo_is_global(handle, &is_global);
if (retval == PMINFO_R_OK && is_global) {
entry->global = global;
- if (!__alarm_set_global_to_db(entry, global)) {
+ if (!__alarm_set_global_to_db(entry, global))
return_code = ERR_ALARM_SYSTEM_FAIL;
- }
} else if (retval == PMINFO_R_OK && !is_global) {
return_code = ERR_ALARM_NOT_PERMITTED_APP;
}
GSList *gs_iter = NULL;
__alarm_info_t *entry = NULL;
__alarm_info_t *find_item = NULL;
- int retval = 0;
int return_code = ALARMMGR_RESULT_SUCCESS;
bool global = false;
fd_list = src->poll_fds;
do {
tmp = (GPollFD *) fd_list->data;
- if (tmp->revents & (POLLIN | POLLPRI)) {
+ if (tmp->revents & (POLLIN | POLLPRI))
return TRUE;
- }
+
fd_list = fd_list->next;
} while (fd_list);
static bool __initialize_noti()
{
- // VCONFKEY_SYSTEM_TIMECHANGE_EXTERNAL is set by OSP app-service.
+ /* VCONFKEY_SYSTEM_TIMECHANGE_EXTERNAL is set by OSP app-service. */
if (vconf_notify_key_changed
(VCONFKEY_SYSTEM_TIMECHANGE_EXTERNAL, __on_system_time_external_changed, NULL) < 0) {
ALARM_MGR_LOG_PRINT("Failed to add callback for time external changing event.");
}
- // If the caller or callee app is uninstalled, all registered alarms will be canceled.
+ /* If the caller or callee app is uninstalled, all registered alarms will be canceled. */
int event_type = PMINFO_CLIENT_STATUS_UNINSTALL;
pkgmgrinfo_client* pc = pkgmgrinfo_client_new(PMINFO_LISTENING);
pkgmgrinfo_client_set_status_type(pc, event_type);
}
void on_bus_name_owner_changed(GDBusConnection *connection,
- const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal_name,
- GVariant *parameters,
- gpointer user_data)
-{
- // On expiry, the killed app can be launched by aul. Then, the owner of the bus name which was registered by the app is changed.
- // In this case, "NameOwnerChange" signal is broadcasted.
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
+{
+ GSList *entry = NULL;
+ __expired_alarm_t *expire_info = NULL;
+ char *service_name = NULL;
+
+ /* On expiry, the killed app can be launched by aul. Then, the owner of the bus name which was registered by the app is changed.
+ * In this case, "NameOwnerChange" signal is broadcasted. */
if (signal_name && strcmp(signal_name , "NameOwnerChanged") == 0) {
- GSList *entry = NULL;
- __expired_alarm_t *expire_info = NULL;
- char *service_name = NULL;
g_variant_get(parameters, "(sss)", &service_name, NULL, NULL);
for (entry = g_expired_alarm_list; entry; entry = entry->next) {
#endif
__initialize_timer();
- if (__initialize_dbus() == false) { /* because dbus's initialize
- failed, we cannot continue any more. */
+ if (__initialize_dbus() == false) {
+ /* because dbus's initialize
+ * failed, we cannot continue any more. */
ALARM_MGR_EXCEPTION_PRINT("because __initialize_dbus failed, "
"alarm-server cannot be runned.\n");
exit(1);
}
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- __initialize_module_log(); // for module log
+ __initialize_module_log(); /* for module log */
#endif
__initialize_scheduled_alarm_list();
#define ALARM_MGR_ASSERT_PRINT(FMT, ARG...) do { printf("%5d", getpid()); printf
("%s() : "FMT"\n", __FUNCTION__, ##ARG); } while (false)
#else
-#define ALARM_MGR_LOG_PRINT(FMT, ARG...) LOGD(FMT, ##ARG);
-#define ALARM_MGR_EXCEPTION_PRINT(FMT, ARG...) LOGW(FMT, ##ARG);
-#define ALARM_MGR_ASSERT_PRINT(FMT, ARG...) LOGE(FMT, ##ARG);
+#define ALARM_MGR_LOG_PRINT(FMT, ARG...) LOGD(FMT, ##ARG)
+#define ALARM_MGR_EXCEPTION_PRINT(FMT, ARG...) LOGW(FMT, ##ARG)
+#define ALARM_MGR_ASSERT_PRINT(FMT, ARG...) LOGE(FMT, ##ARG)
#endif
#endif /*_ALARM_INTERNAL_H*/
/*
- * alarm-manager
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
- * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
*/
-
-
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include "alarm-internal.h"
#include "alarm-mgr-stub.h"
-#define ALARM_SERVICE_NAME "appframework.alarm"
-#define ALARM_OBJECT_PATH "/appframework/alarm"
+#define ALARM_SERVICE_NAME "appframework.alarm"
+#define ALARM_OBJECT_PATH "/appframework/alarm"
#define ALARM_INTERFACE_NAME "appframework.alarm"
-
bool _send_alarm_create(alarm_context_t context, alarm_info_t *alarm_info,
- alarm_id_t *alarm_id, const char *dst_service_name, const char *dst_service_name_mod,
- int *error_code);
+ alarm_id_t *alarm_id, const char *dst_service_name,
+ const char *dst_service_name_mod, int *error_code);
bool _send_alarm_create_appsvc(alarm_context_t context, alarm_info_t *alarm_info,
- alarm_id_t *alarm_id, bundle *b,int *error_code);
+ alarm_id_t *alarm_id, bundle *b, int *error_code);
bool _send_alarm_delete(alarm_context_t context, alarm_id_t alarm_id,
- int *error_code);
+ int *error_code);
bool _send_alarm_get_list_of_ids(alarm_context_t context, int maxnum_of_ids,
- alarm_id_t *alarm_id, int *num_of_ids,
- int *error_code);
+ alarm_id_t *alarm_id, int *num_of_ids, int *error_code);
bool _send_alarm_get_number_of_ids(alarm_context_t context, int *num_of_ids,
- int *error_code);
+ int *error_code);
bool _send_alarm_get_info(alarm_context_t context, alarm_id_t alarm_id,
- alarm_info_t *alarm_info, int *error_code);
+ alarm_info_t *alarm_info, int *error_code);
bool _send_alarm_create_appsvc(alarm_context_t context, alarm_info_t *alarm_info,
- alarm_id_t *alarm_id, bundle *b,
- int *error_code)
+ alarm_id_t *alarm_id, bundle *b,
+ int *error_code)
{
gboolean ret;
GError *error = NULL;
bundle_raw *b_data = NULL;
int datalen = 0;
- if (bundle_encode(b, &b_data, &datalen))
- {
+ if (bundle_encode(b, &b_data, &datalen)) {
ALARM_MGR_EXCEPTION_PRINT("Unable to encode the bundle data\n");
- if (error_code) {
+ if (error_code)
*error_code = ERR_ALARM_SYSTEM_FAIL;
- }
return false;
}
ret = alarm_manager_call_alarm_create_appsvc_sync((AlarmManager*)context.proxy,
- alarm_info->start.year,
- alarm_info->start.month,
- alarm_info->start.day,
- alarm_info->start.hour,
- alarm_info->start.min,
- alarm_info->start.sec,
- alarm_info->end.year,
- alarm_info->end.month,
- alarm_info->end.day,
- alarm_info->mode.u_interval.day_of_week,
- alarm_info->mode.u_interval.interval,
- alarm_info->mode.repeat,
- alarm_info->alarm_type,
- alarm_info->reserved_info,
- (char *)b_data,
- alarm_id, &return_code,
- NULL, &error);
+ alarm_info->start.year,
+ alarm_info->start.month,
+ alarm_info->start.day,
+ alarm_info->start.hour,
+ alarm_info->start.min,
+ alarm_info->start.sec,
+ alarm_info->end.year,
+ alarm_info->end.month,
+ alarm_info->end.day,
+ alarm_info->mode.u_interval.day_of_week,
+ alarm_info->mode.u_interval.interval,
+ alarm_info->mode.repeat,
+ alarm_info->alarm_type,
+ alarm_info->reserved_info,
+ (char *)b_data,
+ alarm_id, &return_code,
+ NULL, &error);
if (b_data) {
free(b_data);
b_data = NULL;
/* g_dbus_proxy_call_sync error */
/* error_code should be set */
ALARM_MGR_EXCEPTION_PRINT(
- "alarm_manager_call_alarm_create_appsvc_sync()failed. alarm_id[%d], return_code[%d].", alarm_id, return_code);
+ "alarm_manager_call_alarm_create_appsvc_sync()failed. alarm_id[%d], return_code[%d].", alarm_id, return_code);
ALARM_MGR_EXCEPTION_PRINT("error->message is %s(%d)", error->message, error->code);
if (error_code) {
if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
}
if (return_code != 0) {
- if (error_code) {
+ if (error_code)
*error_code = return_code;
- }
return false;
}
return true;
}
-
bool _send_alarm_create(alarm_context_t context, alarm_info_t *alarm_info,
- alarm_id_t *alarm_id, const char *dst_service_name, const char *dst_service_name_mod,
- int *error_code)
+ alarm_id_t *alarm_id, const char *dst_service_name, const char *dst_service_name_mod,
+ int *error_code)
{
GError *error = NULL;
int return_code = 0;
/*TODO: Dbus bus name validation is must & will be added to avoid alarm-server crash*/
if (g_quark_to_string(context.quark_app_service_name) == NULL
- && strlen(dst_service_name) == 4
- && strncmp(dst_service_name, "null",4) == 0) {
- ALARM_MGR_EXCEPTION_PRINT("Invalid arg. Provide valid destination or call alarmmgr_init()\n");
- if (error_code) {
+ && strlen(dst_service_name) == 4
+ && strncmp(dst_service_name, "null", 4) == 0) {
+ ALARM_MGR_EXCEPTION_PRINT("Invalid arg. Provide valid destination or call alarmmgr_init()\n");
+ if (error_code)
*error_code = ERR_ALARM_INVALID_PARAM;
- }
return false;
}
if (!alarm_manager_call_alarm_create_sync((AlarmManager*)context.proxy,
- g_quark_to_string(context.quark_app_service_name),
- g_quark_to_string(context.quark_app_service_name_mod),
- alarm_info->start.year,
- alarm_info->start.month,
- alarm_info->start.day,
- alarm_info->start.hour,
- alarm_info->start.min,
- alarm_info->start.sec,
- alarm_info->end.year,
- alarm_info->end.month,
- alarm_info->end.day,
- alarm_info->mode.u_interval.day_of_week,
- alarm_info->mode.repeat,
- alarm_info->alarm_type,
- alarm_info->reserved_info,
- dst_service_name, dst_service_name_mod,
- alarm_id, &return_code,
- NULL, &error)) {
+ g_quark_to_string(context.quark_app_service_name),
+ g_quark_to_string(context.quark_app_service_name_mod),
+ alarm_info->start.year,
+ alarm_info->start.month,
+ alarm_info->start.day,
+ alarm_info->start.hour,
+ alarm_info->start.min,
+ alarm_info->start.sec,
+ alarm_info->end.year,
+ alarm_info->end.month,
+ alarm_info->end.day,
+ alarm_info->mode.u_interval.day_of_week,
+ alarm_info->mode.repeat,
+ alarm_info->alarm_type,
+ alarm_info->reserved_info,
+ dst_service_name, dst_service_name_mod,
+ alarm_id, &return_code,
+ NULL, &error)) {
/* g_dbus_proxy_call_sync error error */
/* error_code should be set */
ALARM_MGR_EXCEPTION_PRINT(
- "alarm_manager_call_alarm_create_sync()failed. alarm_id[%d], return_code[%d]", alarm_id, return_code);
+ "alarm_manager_call_alarm_create_sync()failed. alarm_id[%d], return_code[%d]", alarm_id, return_code);
ALARM_MGR_EXCEPTION_PRINT("error->message is %s(%d)", error->message, error->code);
if (error_code) {
if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
}
if (return_code != 0) {
- if (error_code) {
+ if (error_code)
*error_code = return_code;
- }
return false;
}
}
bool _send_alarm_create_periodic(alarm_context_t context, int interval, int is_ref,
- int method, alarm_id_t *alarm_id, int *error_code)
+ int method, alarm_id_t *alarm_id, int *error_code)
{
GError *error = NULL;
int return_code = 0;
if (g_quark_to_string(context.quark_app_service_name) == NULL) {
ALARM_MGR_EXCEPTION_PRINT("Invalid arg. Provide valid destination or call alarmmgr_init()\n");
- if (error_code) {
+ if (error_code)
*error_code = ERR_ALARM_INVALID_PARAM;
- }
return false;
}
if (!alarm_manager_call_alarm_create_periodic_sync((AlarmManager*)context.proxy,
- g_quark_to_string(context.quark_app_service_name),
- g_quark_to_string(context.quark_app_service_name_mod),
- interval, is_ref, method,
- alarm_id, &return_code, NULL, &error)) {
+ g_quark_to_string(context.quark_app_service_name),
+ g_quark_to_string(context.quark_app_service_name_mod),
+ interval, is_ref, method,
+ alarm_id, &return_code, NULL, &error)) {
ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_create_periodic_sync()failed. alarm_id[%d], return_code[%d]",
- alarm_id, return_code);
+ alarm_id, return_code);
ALARM_MGR_EXCEPTION_PRINT("error->message is %s(%d)", error->message, error->code);
if (error_code) {
if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
}
if (return_code != 0) {
- if (error_code) {
+ if (error_code)
*error_code = return_code;
- }
return false;
}
gchar *b_data = NULL;
if (!alarm_manager_call_alarm_get_appsvc_info_sync
- ((AlarmManager*)context.proxy, alarm_id, &b_data, &return_code, NULL, &error)) {
+ ((AlarmManager*)context.proxy, alarm_id, &b_data, &return_code, NULL, &error)) {
/* g_dbus_proxy_call_sync error */
/*error_code should be set */
ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_get_appsvc_info_sync() failed. alarm_id[%d], return_code[%d].", alarm_id, return_code);
}
g_error_free(error);
- if (b_data) {
+ if (b_data)
g_free(b_data);
- }
return NULL;
}
if (return_code != 0) {
- if (error_code) {
+ if (error_code)
*error_code = return_code;
- }
} else {
b = bundle_decode((bundle_raw *)b_data, strlen(b_data));
}
- if (b_data) {
+ if (b_data)
g_free(b_data);
- }
return b;
}
-
-bool _send_alarm_set_rtc_time(alarm_context_t context, alarm_date_t *time, int *error_code){
+bool _send_alarm_set_rtc_time(alarm_context_t context, alarm_date_t *time, int *error_code)
+{
GError *error = NULL;
int return_code = 0;
if (!alarm_manager_call_alarm_set_rtc_time_sync
- ((AlarmManager*)context.proxy, time->year, time->month, time->day,
- time->hour, time->min, time->sec, &return_code, NULL, &error)) {
+ ((AlarmManager*)context.proxy, time->year, time->month, time->day,
+ time->hour, time->min, time->sec, &return_code, NULL, &error)) {
/* g_dbus_proxy_call_sync error */
/*error_code should be set */
ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_set_rtc_time() failed. return_code[%d]", return_code);
}
if (return_code != 0) {
- if (error_code) {
+ if (error_code)
*error_code = return_code;
- }
return false;
}
int return_code = 0;
if (!alarm_manager_call_alarm_delete_sync
- ((AlarmManager*)context.proxy, alarm_id, &return_code, NULL, &error)) {
+ ((AlarmManager*)context.proxy, alarm_id, &return_code, NULL, &error)) {
/* g_dbus_proxy_call_sync error */
/*error_code should be set */
ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_delete_sync() failed. alarm_id[%d], return_code[%d]", alarm_id, return_code);
}
if (return_code != 0) {
- if (error_code) {
+ if (error_code)
*error_code = return_code;
- }
return false;
}
int return_code = 0;
if (!alarm_manager_call_alarm_delete_all_sync
- ((AlarmManager*)context.proxy, &return_code, NULL, &error)) {
+ ((AlarmManager*)context.proxy, &return_code, NULL, &error)) {
/* g_dbus_proxy_call_sync error */
/*error_code should be set */
ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_delete_all_sync() failed. return_code[%d]", return_code);
}
if (return_code != 0) {
- if (error_code) {
+ if (error_code)
*error_code = return_code;
- }
return false;
}
}
bool _send_alarm_get_list_of_ids(alarm_context_t context, int maxnum_of_ids,
- alarm_id_t *alarm_id, int *num_of_ids,
- int *error_code)
+ alarm_id_t *alarm_id, int *num_of_ids,
+ int *error_code)
{
GError *error = NULL;
GVariant *alarm_array = NULL;
int return_code = 0;
if (!alarm_manager_call_alarm_get_list_of_ids_sync((AlarmManager*)context.proxy,
- maxnum_of_ids, &alarm_array,
- num_of_ids, &return_code, NULL, &error)) {
+ maxnum_of_ids, &alarm_array,
+ num_of_ids, &return_code, NULL, &error)) {
/* g_dbus_proxy_call_sync error */
/*error_code should be set */
ALARM_MGR_EXCEPTION_PRINT(
- "alarm_manager_call_alarm_get_list_of_ids_sync() failed by dbus. alarm_id[%d], return_code[%d]\n", alarm_id, return_code);
+ "alarm_manager_call_alarm_get_list_of_ids_sync() failed by dbus. alarm_id[%d], return_code[%d]\n", alarm_id, return_code);
ALARM_MGR_EXCEPTION_PRINT("error->message is %s(%d)", error->message, error->code);
if (error_code) {
if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
}
if (return_code != 0) {
- if (error_code) {
+ if (error_code)
*error_code = return_code;
- }
return false;
- }
- else
- {
+ } else {
GVariantIter *iter = NULL;
gint i = 0;
- g_variant_get (alarm_array, "ai", &iter);
- while (g_variant_iter_loop (iter, "i", &alarm_id[i]))
- {
+ g_variant_get(alarm_array, "ai", &iter);
+ while (g_variant_iter_loop(iter, "i", &alarm_id[i])) {
ALARM_MGR_LOG_PRINT("alarm_id (%d)", alarm_id[i]);
i++;
}
- g_variant_iter_free (iter);
+ g_variant_iter_free(iter);
*num_of_ids = i;
g_variant_unref(alarm_array);
}
}
bool _send_alarm_get_number_of_ids(alarm_context_t context, int *num_of_ids,
- int *error_code)
+ int *error_code)
{
GError *error = NULL;
gint return_code = 0;
/* g_dbus_proxy_call_sync error */
/* error_code should be set */
ALARM_MGR_EXCEPTION_PRINT(
- "alarm_manager_call_alarm_get_number_of_ids_sync() failed by dbus. return_code[%d], return_code[%s].",
- return_code, error->message);
+ "alarm_manager_call_alarm_get_number_of_ids_sync() failed by dbus. return_code[%d], return_code[%s].",
+ return_code, error->message);
ALARM_MGR_EXCEPTION_PRINT("error->message is %s(%d)", error->message, error->code);
if (error_code) {
}
if (return_code != 0) {
- if (error_code) {
+ if (error_code)
*error_code = return_code;
- }
return false;
}
}
bool _send_alarm_get_info(alarm_context_t context, alarm_id_t alarm_id,
- alarm_info_t *alarm_info, int *error_code)
+ alarm_info_t *alarm_info, int *error_code)
{
GError *error = NULL;
int return_code = 0;
if (!alarm_manager_call_alarm_get_info_sync((AlarmManager*)context.proxy,
- alarm_id, &alarm_info->start.year,
- &alarm_info->start.month, &alarm_info->start.day,
- &alarm_info->start.hour, &alarm_info->start.min,
- &alarm_info->start.sec, &alarm_info->end.year,
- &alarm_info->end.month, &alarm_info->end.day,
- &alarm_info->mode.u_interval.day_of_week,
- (gint *)&alarm_info->mode.repeat,
- &alarm_info->alarm_type, &alarm_info->reserved_info, &return_code, NULL, &error)) {
+ alarm_id, &alarm_info->start.year,
+ &alarm_info->start.month, &alarm_info->start.day,
+ &alarm_info->start.hour, &alarm_info->start.min,
+ &alarm_info->start.sec, &alarm_info->end.year,
+ &alarm_info->end.month, &alarm_info->end.day,
+ &alarm_info->mode.u_interval.day_of_week,
+ (gint *)&alarm_info->mode.repeat,
+ &alarm_info->alarm_type, &alarm_info->reserved_info, &return_code, NULL, &error)) {
/* g_dbus_proxy_call_sync error */
/* error_code should be set */
ALARM_MGR_EXCEPTION_PRINT(
- "alarm_manager_call_alarm_get_info_sync() failed by dbus. alarm_id[%d], return_code[%d]\n", alarm_id, return_code);
+ "alarm_manager_call_alarm_get_info_sync() failed by dbus. alarm_id[%d], return_code[%d]\n", alarm_id, return_code);
ALARM_MGR_EXCEPTION_PRINT("error->message is %s(%d)", error->message, error->code);
if (error_code) {
if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
}
if (return_code != 0) {
- if (error_code) {
+ if (error_code)
*error_code = return_code;
- }
return false;
}
}
bool _send_alarm_get_next_duetime(alarm_context_t context,
- alarm_id_t alarm_id, time_t* duetime,
- int *error_code)
+ alarm_id_t alarm_id, time_t* duetime,
+ int *error_code)
{
GError *error = NULL;
int return_code = 0;
if (!alarm_manager_call_alarm_get_next_duetime_sync((AlarmManager*)context.proxy,
- alarm_id, (gint *)duetime, &return_code, NULL, &error)) {
+ alarm_id, (gint *)duetime, &return_code, NULL, &error)) {
/*g_dbus_proxy_call_sync error */
/*error_code should be set */
ALARM_MGR_EXCEPTION_PRINT(
- "alarm_manager_call_alarm_get_next_duetime_sync() failed by dbus. alarm_id[%d], return_code[%d]\n", alarm_id, return_code);
+ "alarm_manager_call_alarm_get_next_duetime_sync() failed by dbus. alarm_id[%d], return_code[%d]\n", alarm_id, return_code);
ALARM_MGR_EXCEPTION_PRINT("error->message is %s(%d)", error->message, error->code);
if (error_code) {
if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
}
if (return_code != 0) {
- if (error_code) {
+ if (error_code)
*error_code = return_code;
- }
return false;
}
}
if (return_code != ALARMMGR_RESULT_SUCCESS) {
- if (error_code) {
+ if (error_code)
*error_code = return_code;
- }
return false;
}
ALARM_MGR_EXCEPTION_PRINT("dbus error message: %s", error->message);
g_error_free(error);
}
- if (error_code) {
+ if (error_code)
*error_code = ERR_ALARM_SYSTEM_FAIL;
- }
return false;
}
if (return_code != ALARMMGR_RESULT_SUCCESS) {
- if (error_code) {
+ if (error_code)
*error_code = return_code;
- }
return false;
}
return true;
}
-
bool _send_alarm_set_time_with_propagation_delay(alarm_context_t context, unsigned int new_sec, unsigned int new_nsec, unsigned int req_sec, unsigned int req_nsec, int *error_code)
{
GError *error = NULL;
}
if (return_code != ALARMMGR_RESULT_SUCCESS) {
- if (error_code) {
+ if (error_code)
*error_code = return_code;
- }
return false;
}
}
if (return_code != ALARMMGR_RESULT_SUCCESS) {
- if (error_code) {
+ if (error_code)
*error_code = return_code;
- }
return false;
}
}
if (return_code != ALARMMGR_RESULT_SUCCESS) {
- if (error_code) {
+ if (error_code)
*error_code = return_code;
- }
return false;
}
}
if (return_code != ALARMMGR_RESULT_SUCCESS) {
- if (error_code) {
+ if (error_code)
*error_code = return_code;
- }
return false;
}
/*
- * alarm-manager
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
- * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
*/
#define _GNU_SOURCE
alarm_cb_info_t *info;
info = (alarm_cb_info_t *) malloc(sizeof(alarm_cb_info_t));
- if(info == NULL)
+ if (info == NULL)
return;
info->alarm_id = alarm_id;
info->cb_func = cb_func;
g_variant_get(param, "(is)", &alarm_id, &package_name);
ALARM_MGR_LOG_PRINT("[alarm-lib] : Alarm expired for [%s] : Alarm id [%d]", package_name, alarm_id);
- if (alarm_context.alarm_handler != NULL) {
+ if (alarm_context.alarm_handler != NULL)
alarm_context.alarm_handler(alarm_id, alarm_context.user_param);
- }
info = __find_resultcb(alarm_id);
- if (info && info->cb_func) {
+ if (info && info->cb_func)
info->cb_func(alarm_id, info->priv_data);
- }
+
g_free(package_name);
}
static int __alarm_validate_date(alarm_date_t *date, int *error_code)
{
-
- if (date->year == 0 && date->month == 0 && date->day == 0) {
+ if (date->year == 0 && date->month == 0 && date->day == 0)
return true;
- }
int year = date->year;
int month = date->month;
}
if ((month == 1 || month == 3 || month == 5 || month == 7 || month == 8
- || month == 10 || month == 12)
- && (day < 1 || day > 31)) {
+ || month == 10 || month == 12)
+ && (day < 1 || day > 31)) {
if (error_code)
*error_code = ERR_ALARM_INVALID_DATE;
return false;
}
if ((month == 4 || month == 6 || month == 9 || month == 11)
- && (day < 1 || day > 30)) {
+ && (day < 1 || day > 30)) {
if (error_code)
*error_code = ERR_ALARM_INVALID_DATE;
return false;
}
return true;
-
}
static bool __alarm_validate_time(alarm_date_t *date, int *error_code)
return true;
}
-static int __compare_api_version(int *result, uid_t uid) {
+static int __compare_api_version(int *result, uid_t uid)
+{
int ret = 0;
pkgmgrinfo_pkginfo_h pkginfo = NULL;
char pkgid[512] = {0, };
ALARM_MGR_EXCEPTION_PRINT("Failed to get pkginfo\n");
} else {
ret = pkgmgrinfo_pkginfo_get_api_version(pkginfo, &pkg_version);
- if (ret != PMINFO_R_OK) {
+ if (ret != PMINFO_R_OK)
ALARM_MGR_EXCEPTION_PRINT("Failed to check api version [%d]\n", ret);
- }
+
*result = strverscmp(pkg_version, "2.4");
pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo);
}
}
}
-out :
+out:
if (handle)
pkgmgrinfo_appinfo_destroy_appinfo(handle);
+
return _return;
}
}
alarm_context.proxy = g_dbus_proxy_new_sync(alarm_context.connection,
- G_DBUS_PROXY_FLAGS_NONE,
- NULL,
- "org.tizen.alarm.manager",
- "/org/tizen/alarm/manager",
- "org.tizen.alarm.manager",
- NULL,
- NULL);
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ "org.tizen.alarm.manager",
+ "/org/tizen/alarm/manager",
+ "org.tizen.alarm.manager",
+ NULL,
+ NULL);
if (alarm_context.proxy == NULL) {
ALARM_MGR_EXCEPTION_PRINT("Creating a proxy is failed.");
- g_object_unref (alarm_context.connection);
+ g_object_unref(alarm_context.connection);
pthread_mutex_unlock(&init_lock);
return ERR_ALARM_SYSTEM_FAIL;
}
if (b_initialized) {
SECURE_LOGD("alarm was already initialized. app_service_name=%s",
- g_quark_to_string(alarm_context.quark_app_service_name));
+ g_quark_to_string(alarm_context.quark_app_service_name));
return ALARMMGR_RESULT_SUCCESS;
}
EXPORT_API alarm_entry_t *alarmmgr_create_alarm(void)
{
- alarm_info_t *alarm = (alarm_info_t *) malloc(sizeof(alarm_info_t));
+ alarm_info_t *alarm = (alarm_info_t *)malloc(sizeof(alarm_info_t));
- if (NULL == alarm)
- {
+ if (alarm == NULL)
return NULL;
- }
alarm->start.year = 0;
alarm->start.month = 0;
EXPORT_API int alarmmgr_free_alarm(alarm_entry_t *alarm)
{
- if (alarm == NULL) {
+ if (alarm == NULL)
return ERR_ALARM_INVALID_PARAM;
- }
+
free(alarm);
return ALARMMGR_RESULT_SUCCESS;
EXPORT_API int alarmmgr_set_time(alarm_entry_t *alarm, alarm_date_t time)
{
- alarm_info_t *alarm_info; /*= (alarm_info_t*)alarm;*/
+ alarm_info_t *alarm_info;
int error_code;
- if (alarm == NULL) {
+ if (alarm == NULL)
return ERR_ALARM_INVALID_PARAM;
- }
-
- alarm_info = (alarm_info_t *) alarm;
+ alarm_info = (alarm_info_t *)alarm;
if (!__alarm_validate_date(&time, &error_code)) {
ALARM_MGR_EXCEPTION_PRINT("start date error\n");
return error_code;
}
EXPORT_API int alarmmgr_get_time(const alarm_entry_t *alarm,
- alarm_date_t *time)
+ alarm_date_t *time)
{
- alarm_info_t *alarm_info = (alarm_info_t *) alarm;
+ alarm_info_t *alarm_info = (alarm_info_t *)alarm;
- if (alarm == NULL) {
+ if (alarm == NULL)
return ERR_ALARM_INVALID_PARAM;
- }
if (time != NULL)
memcpy(time, &alarm_info->start, sizeof(alarm_date_t));
}
EXPORT_API int alarmmgr_set_repeat_mode(alarm_entry_t *alarm,
- alarm_repeat_mode_t repeat,
- int interval)
+ alarm_repeat_mode_t repeat, int interval)
{
- alarm_info_t *alarm_info = (alarm_info_t *) alarm;
+ alarm_info_t *alarm_info = (alarm_info_t *)alarm;
- if (repeat >= ALARM_REPEAT_MODE_MAX) {
+ if (repeat >= ALARM_REPEAT_MODE_MAX)
return ERR_ALARM_INVALID_PARAM;
- }
alarm_info->mode.repeat = repeat;
if (repeat == ALARM_REPEAT_MODE_REPEAT
- || repeat == ALARM_REPEAT_MODE_WEEKLY) {
- if (interval <= 0) {
+ || repeat == ALARM_REPEAT_MODE_WEEKLY) {
+ if (interval <= 0)
return ERR_ALARM_INVALID_PARAM;
- }
alarm_info->mode.u_interval.interval = interval;
}
}
EXPORT_API int alarmmgr_get_repeat_mode(const alarm_entry_t *alarm,
- alarm_repeat_mode_t *repeat,
- int *interval)
+ alarm_repeat_mode_t *repeat, int *interval)
{
- alarm_info_t *alarm_info = (alarm_info_t *) alarm;
+ alarm_info_t *alarm_info = (alarm_info_t *)alarm;
- if (alarm == NULL) {
+ if (alarm == NULL)
return ERR_ALARM_INVALID_PARAM;
- }
if (repeat != NULL)
*repeat = alarm_info->mode.repeat;
EXPORT_API int alarmmgr_set_type(alarm_entry_t *alarm, int alarm_type)
{
- alarm_info_t *alarm_info; /*= (alarm_info_t*)alarm;*/
+ alarm_info_t *alarm_info;
- if (alarm == NULL) {
+ if (alarm == NULL)
return ERR_ALARM_INVALID_PARAM;
- }
-
- alarm_info = (alarm_info_t *) alarm;
+ alarm_info = (alarm_info_t *)alarm;
alarm_info->alarm_type = alarm_type;
alarm_info->alarm_type &= (~ALARM_TYPE_RELATIVE);
EXPORT_API int alarmmgr_get_type(const alarm_entry_t *alarm, int *alarm_type)
{
- alarm_info_t *alarm_info = (alarm_info_t *) alarm;
+ alarm_info_t *alarm_info = (alarm_info_t *)alarm;
- if (alarm == NULL) {
+ if (alarm == NULL)
return ERR_ALARM_INVALID_PARAM;
- }
if (alarm_type != NULL)
*alarm_type = alarm_info->alarm_type;
return ALARMMGR_RESULT_SUCCESS;
}
-
static int __alarmmgr_init_appsvc(void)
{
if (b_initialized) {
return ALARMMGR_RESULT_SUCCESS;
}
-EXPORT_API void *alarmmgr_get_alarm_appsvc_info(alarm_id_t alarm_id, int *return_code){
+EXPORT_API void *alarmmgr_get_alarm_appsvc_info(alarm_id_t alarm_id, int *return_code)
+{
int ret = 0;
ret = __sub_init();
- if (ret < 0){
- if (return_code) {
+ if (ret < 0) {
+ if (return_code)
*return_code = ret;
- }
+
return NULL;
}
ALARM_MGR_LOG_PRINT("[alarm-lib]:alarmmgr_get_alarm_appsvc_info() is called.");
if (alarm_id <= 0) {
- if (return_code) {
+ if (return_code)
*return_code = ERR_ALARM_INVALID_ID;
- }
+
return NULL;
}
return _send_alarm_get_appsvc_info(alarm_context, alarm_id, return_code);
-
}
-EXPORT_API int alarmmgr_set_rtc_time(alarm_date_t *time){
+EXPORT_API int alarmmgr_set_rtc_time(alarm_date_t *time)
+{
int ret = 0;
int error_code = 0;
- if (!time){
+ if (!time) {
ALARM_MGR_EXCEPTION_PRINT("Invalid parameter time\n");
return ERR_ALARM_INVALID_PARAM;
}
ret = __sub_init();
- if (ret < 0){
+ if (ret < 0)
return ret;
- }
ALARM_MGR_LOG_PRINT("[alarm-lib]:alarmmgr_set_rtc_time() is called\n");
return error_code;
}
- time->year-=1900;
- time->month-=1;
+ time->year -= 1900;
+ time->month -= 1;
- if (!_send_alarm_set_rtc_time
- (alarm_context, time, &error_code)){
- return error_code;
- }
+ if (!_send_alarm_set_rtc_time(alarm_context, time, &error_code))
+ return error_code;
return ALARMMGR_RESULT_SUCCESS;
-
}
EXPORT_API int alarmmgr_add_alarm_appsvc_with_localtime(alarm_entry_t *alarm, void *bundle_data, alarm_id_t *alarm_id)
int error_code = 0;
const char *appid = NULL;
int result;
-
- bundle *b=(bundle *)bundle_data;
+ bundle *b;
ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n");
- if (alarm == NULL) {
+ if (alarm == NULL)
return ERR_ALARM_INVALID_PARAM;
- }
- if (NULL == b)
- {
+ b = (bundle *)bundle_data;
+ if (b == NULL) {
ALARM_MGR_EXCEPTION_PRINT("Invalid parameter bundle\n");
return ERR_ALARM_INVALID_PARAM;
}
operation = appsvc_get_operation(b);
-
- if (NULL == operation)
- {
+ if (operation == NULL)
appsvc_set_operation(b, APPSVC_OPERATION_DEFAULT);
- }
- if (__alarmmgr_init_appsvc() < 0)
- {
+ if (__alarmmgr_init_appsvc() < 0) {
ALARM_MGR_EXCEPTION_PRINT("Unable to initialize dbus!!!\n");
return ERR_ALARM_SYSTEM_FAIL;
}
- alarm_info = (alarm_info_t *) alarm;
-
+ alarm_info = (alarm_info_t *)alarm;
appid = appsvc_get_appid(b);
-
- if ( (NULL == appid && (alarm_info->alarm_type & ALARM_TYPE_NOLAUNCH)) ||
- (NULL == appid && operation && !strcmp(operation, APPSVC_OPERATION_DEFAULT)) )
- {
+ if ((appid == NULL && (alarm_info->alarm_type & ALARM_TYPE_NOLAUNCH)) ||
+ (appid == NULL && operation && !strcmp(operation, APPSVC_OPERATION_DEFAULT))) {
ALARM_MGR_EXCEPTION_PRINT("Invalid parameter\n");
return ERR_ALARM_INVALID_PARAM;
}
alarm_mode_t *mode = &alarm_info->mode;
ALARM_MGR_EXCEPTION_PRINT("start(%d-%d-%d, %02d:%02d:%02d), end(%d-%d-%d), repeat(%d), interval(%d), type(%d)",
- alarm_info->start.day, alarm_info->start.month, alarm_info->start.year,
- alarm_info->start.hour, alarm_info->start.min, alarm_info->start.sec,
- alarm_info->end.year, alarm_info->end.month, alarm_info->end.day,
- alarm_info->mode.repeat, alarm_info->mode.u_interval, alarm_info->alarm_type);
+ alarm_info->start.day, alarm_info->start.month, alarm_info->start.year,
+ alarm_info->start.hour, alarm_info->start.min, alarm_info->start.sec,
+ alarm_info->end.year, alarm_info->end.month, alarm_info->end.day,
+ alarm_info->mode.repeat, alarm_info->mode.u_interval, alarm_info->alarm_type);
/* TODO: This should be changed to > ALARM_REPEAT_MODE_MAX ? */
- if (mode->repeat >= ALARM_REPEAT_MODE_MAX) {
+ if (mode->repeat >= ALARM_REPEAT_MODE_MAX)
return ERR_ALARM_INVALID_PARAM;
- }
if (!__alarm_validate_date(&alarm_info->start, &error_code)) {
ALARM_MGR_EXCEPTION_PRINT("start date error\n");
return error_code;
}
-
- if (!_send_alarm_create_appsvc(alarm_context, alarm_info, alarm_id, b, &error_code)) {
+ if (!_send_alarm_create_appsvc(alarm_context, alarm_info, alarm_id, b, &error_code))
return error_code;
- }
return ALARMMGR_RESULT_SUCCESS;
}
-
-
-
EXPORT_API int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm,
- const char *destination,
- alarm_id_t *alarm_id)
+ const char *destination,
+ alarm_id_t *alarm_id)
{
char dst_service_name[MAX_SERVICE_NAME_LEN] = { 0 };
char dst_service_name_mod[MAX_SERVICE_NAME_LEN] = { 0 };
ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n");
- if (alarm == NULL) {
+ if (alarm == NULL)
return ERR_ALARM_INVALID_PARAM;
- }
alarm_info = (alarm_info_t *) alarm;
- if (alarm_info == NULL || alarm_id == NULL) {
+ if (alarm_info == NULL || alarm_id == NULL)
return ERR_ALARM_INVALID_PARAM;
- }
int error_code;
alarm_mode_t *mode = &alarm_info->mode;
return ret;
ALARM_MGR_LOG_PRINT("start(%d-%d-%d, %02d:%02d:%02d), end(%d-%d-%d), repeat(%d), interval(%d), type(%d)",
- alarm_info->start.day, alarm_info->start.month, alarm_info->start.year,
- alarm_info->start.hour, alarm_info->start.min, alarm_info->start.sec,
- alarm_info->end.year, alarm_info->end.month, alarm_info->end.day,
- alarm_info->mode.repeat, alarm_info->mode.u_interval, alarm_info->alarm_type);
+ alarm_info->start.day, alarm_info->start.month, alarm_info->start.year,
+ alarm_info->start.hour, alarm_info->start.min, alarm_info->start.sec,
+ alarm_info->end.year, alarm_info->end.month, alarm_info->end.day,
+ alarm_info->mode.repeat, alarm_info->mode.u_interval, alarm_info->alarm_type);
/* TODO: This should be changed to > ALARM_REPEAT_MODE_MAX ? */
- if (mode->repeat >= ALARM_REPEAT_MODE_MAX) {
+ if (mode->repeat >= ALARM_REPEAT_MODE_MAX)
return ERR_ALARM_INVALID_PARAM;
- }
- if (destination && strlen(destination) >= MAX_PKG_NAME_LEN){
+ if (destination && strlen(destination) >= MAX_PKG_NAME_LEN) {
ALARM_MGR_EXCEPTION_PRINT("[alarm-lib]: destination name is too long!\n");
return ERR_ALARM_INVALID_PARAM;
}
snprintf(dst_service_name, MAX_SERVICE_NAME_LEN, "ALARM.%s", destination);
memset(dst_service_name_mod, 'a', MAX_SERVICE_NAME_LEN-1);
- for (i=0; i<=strlen(dst_service_name); i++)
- {
- if (dst_service_name[i] == '.' )
- {
+ for (i = 0; i <= strlen(dst_service_name); i++) {
+ if (dst_service_name[i] == '.') {
dst_service_name_mod[j] = dst_service_name[i];
j++;
- }
- else
- {
+ } else {
dst_service_name_mod[j] = dst_service_name[i];
}
j++;
}
- if (!_send_alarm_create(alarm_context, alarm_info, alarm_id, dst_service_name, dst_service_name_mod, &error_code)) {
+ if (!_send_alarm_create(alarm_context, alarm_info, alarm_id, dst_service_name, dst_service_name_mod, &error_code))
return error_code;
- }
} else {
- if (!_send_alarm_create(alarm_context, alarm_info, alarm_id, "null", "null", &error_code)) {
+ if (!_send_alarm_create(alarm_context, alarm_info, alarm_id, "null", "null", &error_code))
return error_code;
- }
}
return ALARMMGR_RESULT_SUCCESS;
}
-
-
EXPORT_API int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time,
- time_t interval, void *bundle_data,
- alarm_id_t *alarm_id)
+ time_t interval, void *bundle_data,
+ alarm_id_t *alarm_id)
{
int error_code = 0;
int result;
alarm_info_t alarm_info;
const char *operation = NULL;
const char *appid = NULL;
+ bundle *b;
ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n");
- bundle *b=(bundle *)bundle_data;
-
- if (NULL == b)
- {
+ b = (bundle *)bundle_data;
+ if (b == NULL) {
ALARM_MGR_EXCEPTION_PRINT("Invalid parameter bundle\n");
return ERR_ALARM_INVALID_PARAM;
}
- operation = appsvc_get_operation(b);
- if (NULL == operation)
- {
+ operation = appsvc_get_operation(b);
+ if (operation == NULL)
appsvc_set_operation(b, APPSVC_OPERATION_DEFAULT);
- }
appid = appsvc_get_appid(b);
- if ( (NULL == appid && (alarm_type & ALARM_TYPE_NOLAUNCH)) ||
- (NULL == appid && operation && !strcmp(operation, APPSVC_OPERATION_DEFAULT)) )
- {
+ if ((appid == NULL && (alarm_type & ALARM_TYPE_NOLAUNCH)) ||
+ (appid == NULL && operation && !strcmp(operation, APPSVC_OPERATION_DEFAULT))) {
ALARM_MGR_EXCEPTION_PRINT("Invalid parameter\n");
return ERR_ALARM_INVALID_PARAM;
}
- if (__alarmmgr_init_appsvc() < 0)
- {
+ if (__alarmmgr_init_appsvc() < 0) {
ALARM_MGR_EXCEPTION_PRINT("Unable to initialize dbus!!!\n");
return ERR_ALARM_SYSTEM_FAIL;
}
- if (alarm_id == NULL) {
+ if (alarm_id == NULL)
return ERR_ALARM_INVALID_PARAM;
- }
- if (trigger_at_time < 0) {
+ if (trigger_at_time < 0)
return ERR_ALARM_INVALID_PARAM;
- }
alarm_info.alarm_type = alarm_type;
alarm_info.alarm_type |= ALARM_TYPE_RELATIVE;
return ERR_ALARM_SYSTEM_FAIL;
if (result < 0) {
- if (alarm_info.alarm_type & ALARM_TYPE_INEXACT) {
+ if (alarm_info.alarm_type & ALARM_TYPE_INEXACT)
alarm_info.alarm_type ^= ALARM_TYPE_INEXACT;
- }
- } else { //Since 2.4
+ } else { /* Since 2.4 */
if (!__is_permitted(appid, alarm_info.alarm_type)) {
ALARM_MGR_EXCEPTION_PRINT("[%s] is not permitted \n", appid);
return ERR_ALARM_NOT_PERMITTED_APP;
}
gettimeofday(¤t_time, NULL);
-
- if (current_time.tv_usec > 500 * 1000)
- {
- // When the millisecond part of the current_time is bigger than 500ms,
- // the duetime increases by extra 1sec.
+ if (current_time.tv_usec > 500 * 1000) {
+ /* When the millisecond part of the current_time is bigger than 500ms,
+ * the duetime increases by extra 1sec. */
current_time.tv_sec += (trigger_at_time + 1);
- }
- else
- {
+ } else {
current_time.tv_sec += trigger_at_time;
}
- tzset(); // Processes the TZ environment variable, and Set timezone, daylight, and tzname.
+ tzset(); /* Processes the TZ environment variable, and Set timezone, daylight, and tzname. */
localtime_r(¤t_time.tv_sec, &duetime_tm);
alarm_info.start.year = duetime_tm.tm_year + 1900;
alarm_info.start.min = duetime_tm.tm_min;
alarm_info.start.sec = duetime_tm.tm_sec;
- if ((alarm_info.alarm_type & ALARM_TYPE_INEXACT) && interval < MIN_INEXACT_INTERVAL) {
+ if ((alarm_info.alarm_type & ALARM_TYPE_INEXACT) && interval < MIN_INEXACT_INTERVAL)
interval = MIN_INEXACT_INTERVAL;
- }
if (interval <= 0) {
alarm_info.mode.repeat = ALARM_REPEAT_MODE_ONCE;
}
ALARM_MGR_LOG_PRINT("trigger_at_time(%d), start(%d-%d-%d, %02d:%02d:%02d), repeat(%d), interval(%d), type(%d)",
- trigger_at_time, alarm_info.start.day, alarm_info.start.month, alarm_info.start.year,
- alarm_info.start.hour, alarm_info.start.min, alarm_info.start.sec,
- alarm_info.mode.repeat, alarm_info.mode.u_interval.interval, alarm_info.alarm_type);
+ trigger_at_time, alarm_info.start.day, alarm_info.start.month, alarm_info.start.year,
+ alarm_info.start.hour, alarm_info.start.min, alarm_info.start.sec,
+ alarm_info.mode.repeat, alarm_info.mode.u_interval.interval, alarm_info.alarm_type);
- if (!_send_alarm_create_appsvc(alarm_context, &alarm_info, alarm_id, b, &error_code)) {
+ if (!_send_alarm_create_appsvc(alarm_context, &alarm_info, alarm_id, b, &error_code))
return error_code;
- }
return ALARMMGR_RESULT_SUCCESS;
}
-
EXPORT_API int alarmmgr_add_alarm(int alarm_type, time_t trigger_at_time,
- time_t interval, const char *destination,
- alarm_id_t *alarm_id)
+ time_t interval, const char *destination,
+ alarm_id_t *alarm_id)
{
char dst_service_name[MAX_SERVICE_NAME_LEN] = { 0 };
char dst_service_name_mod[MAX_SERVICE_NAME_LEN] = { 0 };
if (ret < 0)
return ret;
- if (alarm_id == NULL) {
+ if (alarm_id == NULL)
return ERR_ALARM_INVALID_PARAM;
- }
- if (trigger_at_time < 0) {
+ if (trigger_at_time < 0)
return ERR_ALARM_INVALID_PARAM;
- }
- if (destination && strlen(destination) >= MAX_PKG_NAME_LEN){
+ if (destination && strlen(destination) >= MAX_PKG_NAME_LEN) {
ALARM_MGR_EXCEPTION_PRINT("[alarm-lib]: destination name is too long!\n");
return ERR_ALARM_INVALID_PARAM;
}
gettimeofday(¤t_time, NULL);
- if (current_time.tv_usec > 500 * 1000)
- {
- // When the millisecond part of the current_time is bigger than 500ms,
- // the duetime increases by extra 1sec.
+ if (current_time.tv_usec > 500 * 1000) {
+ /* When the millisecond part of the current_time is bigger than 500ms,
+ * the duetime increases by extra 1sec. */
current_time.tv_sec += (trigger_at_time + 1);
- }
- else
- {
+ } else {
current_time.tv_sec += trigger_at_time;
}
- tzset(); // Processes the TZ environment variable, and Set timezone, daylight, and tzname.
+ tzset(); /* Processes the TZ environment variable, and Set timezone, daylight, and tzname. */
localtime_r(¤t_time.tv_sec, &duetime_tm);
alarm_info.start.year = duetime_tm.tm_year + 1900;
}
ALARM_MGR_LOG_PRINT("trigger_at_time(%d), start(%d-%d-%d, %02d:%02d:%02d), repeat(%d), interval(%d), type(%d)",
- trigger_at_time, alarm_info.start.day, alarm_info.start.month, alarm_info.start.year,
- alarm_info.start.hour, alarm_info.start.min, alarm_info.start.sec,
- alarm_info.mode.repeat, alarm_info.mode.u_interval, alarm_info.alarm_type);
+ trigger_at_time, alarm_info.start.day, alarm_info.start.month, alarm_info.start.year,
+ alarm_info.start.hour, alarm_info.start.min, alarm_info.start.sec,
+ alarm_info.mode.repeat, alarm_info.mode.u_interval, alarm_info.alarm_type);
if (destination != NULL) {
memset(dst_service_name, 0,
- strlen(destination) + strlen("ALARM.") + 2);
+ strlen(destination) + strlen("ALARM.") + 2);
snprintf(dst_service_name, MAX_SERVICE_NAME_LEN, "ALARM.%s",
- destination);
- memset(dst_service_name_mod,'a',MAX_SERVICE_NAME_LEN-1);
-
- j=0;
-
- for(i=0;i<=strlen(dst_service_name);i++)
- {
- if (dst_service_name[i] == '.')
- {
- dst_service_name_mod[j]=dst_service_name[i];
- j++;
- }
- else
- {
- dst_service_name_mod[j]=dst_service_name[i];
- }
- j++;
- }
-
- if (!_send_alarm_create
- (alarm_context, &alarm_info, alarm_id, dst_service_name,dst_service_name_mod,
- &error_code)) {
- return error_code;
+ destination);
+ memset(dst_service_name_mod, 'a', MAX_SERVICE_NAME_LEN - 1);
+
+ j = 0;
+ for (i = 0; i <= strlen(dst_service_name); i++) {
+ if (dst_service_name[i] == '.') {
+ dst_service_name_mod[j] = dst_service_name[i];
+ j++;
+ } else {
+ dst_service_name_mod[j] = dst_service_name[i];
+ }
+ j++;
}
- } else
- if (!_send_alarm_create
- (alarm_context, &alarm_info, alarm_id, "null","null", &error_code)) {
- return error_code;
+
+ if (!_send_alarm_create(alarm_context, &alarm_info,
+ alarm_id, dst_service_name,
+ dst_service_name_mod,
+ &error_code))
+ return error_code;
+ } else {
+ if (!_send_alarm_create(alarm_context, &alarm_info, alarm_id,
+ "null", "null", &error_code))
+ return error_code;
}
return ALARMMGR_RESULT_SUCCESS;
}
EXPORT_API int alarmmgr_add_alarm_withcb(int alarm_type, time_t trigger_at_time,
- time_t interval, alarm_cb_t handler, void *user_param, alarm_id_t *alarm_id)
+ time_t interval, alarm_cb_t handler, void *user_param, alarm_id_t *alarm_id)
{
int error_code = 0;
struct timeval current_time;
int ret = 0;
char appid[256] = {0,};
- if (aul_app_get_appid_bypid(getpid(), appid, sizeof(appid)) != AUL_R_OK) {
+ if (aul_app_get_appid_bypid(getpid(), appid, sizeof(appid)) != AUL_R_OK)
ALARM_MGR_EXCEPTION_PRINT("aul_app_get_appid_bypid() is failed. PID %d may not be app.", getpid());
- }
ret = alarmmgr_init(appid);
if (ret < 0)
ALARM_MGR_LOG_PRINT("[alarm-lib]:alarmmgr_add_alarm_withcb() is called");
- if (alarm_id == NULL) {
+ if (alarm_id == NULL)
return ERR_ALARM_INVALID_PARAM;
- }
- if (trigger_at_time < 0) {
+ if (trigger_at_time < 0)
return ERR_ALARM_INVALID_PARAM;
- }
alarm_info.alarm_type = alarm_type;
alarm_info.alarm_type |= ALARM_TYPE_RELATIVE;
gettimeofday(¤t_time, NULL);
- if (current_time.tv_usec > 500 * 1000)
- {
- // When the millisecond part of the current_time is bigger than 500ms,
- // the duetime increases by extra 1sec.
+ if (current_time.tv_usec > 500 * 1000) {
+ /* When the millisecond part of the current_time is bigger than 500ms, */
+ /* the duetime increases by extra 1sec. */
current_time.tv_sec += (trigger_at_time + 1);
- }
- else
- {
+ } else {
current_time.tv_sec += trigger_at_time;
}
- tzset(); // Processes the TZ environment variable, and Set timezone, daylight, and tzname.
+ tzset(); /* Processes the TZ environment variable, and Set timezone, daylight, and tzname. */
localtime_r(¤t_time.tv_sec, &duetime_tm);
alarm_info.start.year = duetime_tm.tm_year + 1900;
}
ALARM_MGR_LOG_PRINT("trigger_at_time(%d), start(%d-%d-%d, %02d:%02d:%02d), repeat(%d), interval(%d), type(%d)",
- trigger_at_time, alarm_info.start.day, alarm_info.start.month, alarm_info.start.year,
- alarm_info.start.hour, alarm_info.start.min, alarm_info.start.sec,
- alarm_info.mode.repeat, alarm_info.mode.u_interval.interval, alarm_info.alarm_type);
+ trigger_at_time, alarm_info.start.day, alarm_info.start.month, alarm_info.start.year,
+ alarm_info.start.hour, alarm_info.start.min, alarm_info.start.sec,
+ alarm_info.mode.repeat, alarm_info.mode.u_interval.interval, alarm_info.alarm_type);
- if (!_send_alarm_create(alarm_context, &alarm_info, alarm_id, "null","null", &error_code)) {
+ if (!_send_alarm_create(alarm_context, &alarm_info, alarm_id, "null", "null", &error_code))
return error_code;
- }
+
__add_resultcb(*alarm_id, handler, user_param);
return ALARMMGR_RESULT_SUCCESS;
ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_delete(%d) is called\n", alarm_id);
- if (alarm_id <= 0) {
+ if (alarm_id <= 0)
return ERR_ALARM_INVALID_ID;
- }
if (!_send_alarm_delete(alarm_context, alarm_id, &error_code))
return error_code;
int return_code = ALARMMGR_RESULT_SUCCESS;
int ret = __sub_init();
if (ret < 0)
- {
return ret;
- }
if (!_send_alarm_delete_all(alarm_context, &error_code))
return error_code;
int ret = 0;
GVariantIter *iter = NULL;
- if (fn == NULL) {
+ if (fn == NULL)
return ERR_ALARM_INVALID_PARAM;
- }
ret = __sub_init();
if (ret < 0) {
SECURE_LOGD("alarm_manager_call_alarm_get_number_of_ids_sync() is called");
if (!alarm_manager_call_alarm_get_number_of_ids_sync(
- (AlarmManager*)alarm_context.proxy, &maxnum_of_ids, &return_code, NULL, &error)) {
+ (AlarmManager*)alarm_context.proxy, &maxnum_of_ids, &return_code, NULL, &error)) {
/* dbus error. error_code should be set */
ALARM_MGR_EXCEPTION_PRINT(
- "alarm_manager_call_alarm_get_number_of_ids_sync() is failed by dbus. return_code[%d], err message[%s] err code[%d]",
- return_code, error->message, error->code);
+ "alarm_manager_call_alarm_get_number_of_ids_sync() is failed by dbus. return_code[%d], err message[%s] err code[%d]",
+ return_code, error->message, error->code);
if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
ret = ERR_ALARM_NO_PERMISSION;
else
SECURE_LOGD("alarm_manager_call_alarm_get_list_of_ids_sync() is called");
if (!alarm_manager_call_alarm_get_list_of_ids_sync(
- (AlarmManager*)alarm_context.proxy, maxnum_of_ids, &alarm_array, &num_of_ids, &return_code, NULL, &error)) {
+ (AlarmManager*)alarm_context.proxy, maxnum_of_ids, &alarm_array, &num_of_ids, &return_code, NULL, &error)) {
/* dbus error. error_code should be set */
ALARM_MGR_EXCEPTION_PRINT(
- "alarm_manager_call_alarm_get_list_of_ids_sync() failed by dbus. num_of_ids[%d], return_code[%d]. err message[%s] err code[%d]", num_of_ids, return_code, error->message, error->code);
+ "alarm_manager_call_alarm_get_list_of_ids_sync() failed by dbus. num_of_ids[%d], return_code[%d]. err message[%s] err code[%d]", num_of_ids, return_code, error->message, error->code);
if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
ret = ERR_ALARM_NO_PERMISSION;
else
return ret;
}
- if (return_code != ALARMMGR_RESULT_SUCCESS) {
+ if (return_code != ALARMMGR_RESULT_SUCCESS)
return return_code;
- }
if (error != NULL) {
ALARM_MGR_EXCEPTION_PRINT("Alarm server is not ready dbus. error message %s.", error->message);
}
g_variant_get(alarm_array, "ai", &iter);
- while (g_variant_iter_loop(iter, "i", &alarm_id))
- {
- (*fn) (alarm_id, user_param);
+ while (g_variant_iter_loop(iter, "i", &alarm_id)) {
+ (*fn)(alarm_id, user_param);
ALARM_MGR_LOG_PRINT("alarm_id (%d)", alarm_id);
}
g_variant_iter_free(iter);
{
int error_code;
alarm_info_t *alarm_info = (alarm_info_t *) alarm;
-
int ret;
ret = __sub_init();
ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_get_info() is called\n");
- if (alarm_id < 0 || alarm_info == NULL) {
+ if (alarm_id < 0 || alarm_info == NULL)
return ERR_ALARM_INVALID_PARAM;
- }
- if (!_send_alarm_get_info(alarm_context, alarm_id, alarm_info, &error_code)) {
+ if (!_send_alarm_get_info(alarm_context, alarm_id, alarm_info, &error_code))
return error_code;
- }
return ALARMMGR_RESULT_SUCCESS;
}
int alarmmgr_create(alarm_info_t *alarm_info, char *destination,
- alarm_id_t *alarm_id)
+ alarm_id_t *alarm_id)
{
char dst_service_name[MAX_SERVICE_NAME_LEN] = { 0 };
alarm_mode_t *mode = &alarm_info->mode;
ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n");
- if (alarm_info == NULL || alarm_id == NULL) {
+ if (alarm_info == NULL || alarm_id == NULL)
return ERR_ALARM_INVALID_PARAM;
- }
ALARM_MGR_LOG_PRINT("alarm_info->start.year(%d), "
- "alarm_info->start.month(%d), alarm_info->start.day(%d)",
- alarm_info->start.year, alarm_info->start.month,
- alarm_info->start.day);
+ "alarm_info->start.month(%d), alarm_info->start.day(%d)",
+ alarm_info->start.year, alarm_info->start.month,
+ alarm_info->start.day);
/* TODO: This should be changed to > ALARM_REPEAT_MODE_MAX ? */
- if (mode->repeat >= ALARM_REPEAT_MODE_MAX) {
+ if (mode->repeat >= ALARM_REPEAT_MODE_MAX)
return ERR_ALARM_INVALID_PARAM;
- }
if (!__alarm_validate_date(&alarm_info->start, &error_code)) {
ALARM_MGR_EXCEPTION_PRINT("start date error\n");
if (destination != NULL) {
memset(dst_service_name, 0,
- strlen(destination) + strlen("ALARM.") + 2);
+ strlen(destination) + strlen("ALARM.") + 2);
snprintf(dst_service_name, MAX_SERVICE_NAME_LEN, "ALARM.%s",
- destination);
- if (!_send_alarm_create
- (alarm_context, alarm_info, alarm_id, dst_service_name,"null",
- &error_code)) {
+ destination);
+ if (!_send_alarm_create(alarm_context, alarm_info,
+ alarm_id, dst_service_name, "null",
+ &error_code))
return error_code;
- }
}
-/*TODO: Currently this API is not exported. Hence not modifying*/
- if (!_send_alarm_create
- (alarm_context, alarm_info, alarm_id, "null", "null", &error_code)) {
+
+ /*TODO: Currently this API is not exported. Hence not modifying*/
+ if (!_send_alarm_create(alarm_context, alarm_info, alarm_id,
+ "null", "null", &error_code))
return error_code;
- }
return ALARMMGR_RESULT_SUCCESS;
-
}
int alarmmgr_get_number_of_ids(int *num_of_ids)
int error_code;
ALARM_MGR_LOG_PRINT("[alarm-lib]: alarm_get_number_of_ids() is called.");
- if (num_of_ids == NULL) {
+ if (num_of_ids == NULL)
return ERR_ALARM_INVALID_PARAM;
- }
+
ALARM_MGR_LOG_PRINT("call alarm_get_number_of_ids\n");
- if (!_send_alarm_get_number_of_ids(alarm_context, num_of_ids, &error_code)) {
+ if (!_send_alarm_get_number_of_ids(alarm_context, num_of_ids, &error_code))
return error_code;
- }
return ALARMMGR_RESULT_SUCCESS;
}
int alarmmgr_get_list_of_ids(int maxnum_of_ids, alarm_id_t *alarm_id,
- int *num_of_ids)
+ int *num_of_ids)
{
int error_code;
ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_get_list_of_ids() is called.");
- if (maxnum_of_ids < 0 || alarm_id == NULL || num_of_ids == NULL) {
+ if (maxnum_of_ids < 0 || alarm_id == NULL || num_of_ids == NULL)
return ERR_ALARM_INVALID_PARAM;
- }
if (maxnum_of_ids == 0) {
*num_of_ids = 0;
}
if (!_send_alarm_get_list_of_ids
- (alarm_context, maxnum_of_ids, alarm_id, num_of_ids, &error_code)) {
+ (alarm_context, maxnum_of_ids, alarm_id, num_of_ids, &error_code)) {
return error_code;
}
int error_code;
ALARM_MGR_LOG_PRINT("[alarm-lib]:alarmmgr_get_next_duetime() is called.");
- if (duetime == NULL) {
+ if (duetime == NULL)
return ERR_ALARM_INVALID_PARAM;
- }
- if (!_send_alarm_get_next_duetime(alarm_context, alarm_id, duetime, &error_code)) {
+ if (!_send_alarm_get_next_duetime(alarm_context, alarm_id, duetime, &error_code))
return error_code;
- }
return ALARMMGR_RESULT_SUCCESS;
}
int error_code;
ALARM_MGR_LOG_PRINT("[alarm-lib]:alarmmgr_get_all_info() is called.");
- if (db_path == NULL) {
+ if (db_path == NULL)
return ERR_ALARM_INVALID_PARAM;
- }
- if (!_send_alarm_get_all_info(alarm_context, db_path, &error_code)) {
+ if (!_send_alarm_get_all_info(alarm_context, db_path, &error_code))
return error_code;
- }
ALARM_MGR_LOG_PRINT("[alarm-lib]: successfully save info in %s.", *db_path);
return ALARMMGR_RESULT_SUCCESS;
}
EXPORT_API int alarmmgr_add_periodic_alarm_withcb(int interval, periodic_method_e method,
- alarm_cb_t handler, void *user_param, alarm_id_t *alarm_id)
+ alarm_cb_t handler, void *user_param, alarm_id_t *alarm_id)
{
int error_code = 0;
alarm_info_t alarm_info;
if (aul_app_get_appid_bypid(getpid(), appid, sizeof(appid)) != AUL_R_OK) {
ALARM_MGR_EXCEPTION_PRINT("aul_app_get_appid_bypid() is failed. PID %d may not be app.",
- getpid());
+ getpid());
}
ret = alarmmgr_init(appid);
if (ret < 0)
return ret;
- if (alarm_id == NULL) {
+ if (alarm_id == NULL)
return ERR_ALARM_INVALID_PARAM;
- }
- if (!_send_alarm_create_periodic(alarm_context, interval, 0, (int)method, alarm_id,
- &error_code)) {
+ if (!_send_alarm_create_periodic(alarm_context, interval, 0,
+ (int)method, alarm_id,
+ &error_code))
return error_code;
- }
+
__add_resultcb(*alarm_id, handler, user_param);
return ALARMMGR_RESULT_SUCCESS;
}
EXPORT_API int alarmmgr_add_reference_periodic_alarm_withcb(int interval,
- alarm_cb_t handler, void *user_param, alarm_id_t *alarm_id)
+ alarm_cb_t handler, void *user_param, alarm_id_t *alarm_id)
{
int error_code = 0;
alarm_info_t alarm_info;
if (aul_app_get_appid_bypid(getpid(), appid, sizeof(appid)) != AUL_R_OK) {
ALARM_MGR_EXCEPTION_PRINT("aul_app_get_appid_bypid() is failed. PID %d may not be app.",
- getpid());
+ getpid());
}
ret = alarmmgr_init(appid);
if (ret < 0)
return ret;
- if (alarm_id == NULL) {
+ if (alarm_id == NULL)
return ERR_ALARM_INVALID_PARAM;
- }
if (!_send_alarm_create_periodic(alarm_context, interval, 1, 0,
- alarm_id, &error_code)) {
+ alarm_id, &error_code))
return error_code;
- }
__add_resultcb(*alarm_id, handler, user_param);
int error_code;
ALARM_MGR_LOG_PRINT("[alarm-lib]:alarmmgr_set_systime(%d) is called.", new_time);
- if (__sub_init() < 0) {
+ if (__sub_init() < 0)
return ERR_ALARM_SYSTEM_FAIL;
- }
if (!_send_alarm_set_time(alarm_context, new_time, &error_code)) {
ALARM_MGR_EXCEPTION_PRINT("Failed to set time. error: %d", error_code);
{
int error_code;
ALARM_MGR_LOG_PRINT("[alarm-lib] New: %d(sec) %09d(nsec), Requested: %d(sec) %09d(nsec)",
- new_time.tv_sec, new_time.tv_nsec, req_time.tv_sec, req_time.tv_nsec);
+ new_time.tv_sec, new_time.tv_nsec, req_time.tv_sec, req_time.tv_nsec);
- if (__sub_init() < 0) {
+ if (__sub_init() < 0)
return ERR_ALARM_SYSTEM_FAIL;
- }
if (!_send_alarm_set_time_with_propagation_delay(alarm_context, new_time.tv_sec, new_time.tv_nsec, req_time.tv_sec, req_time.tv_nsec, &error_code)) {
ALARM_MGR_EXCEPTION_PRINT("Failed to set time with propagation delay. error: %d", error_code);
int error_code;
ALARM_MGR_LOG_PRINT("[alarm-lib]:alarmmgr_set_timezone() is called.");
- if (tzpath_str == NULL) {
+ if (tzpath_str == NULL)
return ERR_ALARM_INVALID_PARAM;
- }
- if (__sub_init() < 0) {
+ if (__sub_init() < 0)
return ERR_ALARM_SYSTEM_FAIL;
- }
- if (!_send_alarm_set_timezone(alarm_context, tzpath_str, &error_code)) {
+ if (!_send_alarm_set_timezone(alarm_context, tzpath_str, &error_code))
return error_code;
- }
ALARM_MGR_LOG_PRINT("[alarm-lib]: successfully set the timezone(%s) by pid(%d)", tzpath_str, getpid());
return ALARMMGR_RESULT_SUCCESS;
}
EXPORT_API int alarmmgr_set_global(const alarm_id_t alarm_id,
- bool global)
+ bool global)
{
int error_code;
ALARM_MGR_LOG_PRINT("[alarm-lib]:alarmmgr_set_global() is called.");
- if (!_send_alarm_set_global(alarm_context, alarm_id, global, &error_code)) {
+ if (!_send_alarm_set_global(alarm_context, alarm_id, global, &error_code))
return error_code;
- }
return ALARMMGR_RESULT_SUCCESS;
}
EXPORT_API int alarmmgr_get_global(const alarm_id_t alarm_id,
- bool *global)
+ bool *global)
{
bool _global;
int error_code;
- if (global == NULL) {
+ if (global == NULL)
return ERR_ALARM_INVALID_PARAM;
- }
- if (!_send_alarm_get_global(alarm_context, alarm_id, &_global, &error_code)) {
+ if (!_send_alarm_get_global(alarm_context, alarm_id, &_global, &error_code))
return error_code;
- }
return ALARMMGR_RESULT_SUCCESS;
}
-
mainloop = g_main_loop_new(NULL, FALSE);
result = alarmmgr_init("org.tizen.alarmmgr.periodic");
- if (result < 0) {
+ if (result < 0)
printf("fail to alarmmgr_init : error_code : %d\n", result);
- } else {
+ else
create_test();
- }
g_main_loop_run(mainloop);
return 0;
}
-
-
mainloop = g_main_loop_new(NULL, FALSE);
result = alarmmgr_init("org.tizen.alarmmgr.refperiodic");
- if (result < 0) {
+ if (result < 0)
printf("fail to alarmmgr_init : error_code : %d\n", result);
- } else {
+ else
create_test();
- }
g_main_loop_run(mainloop);
/*
- * alarm-manager
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2014 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
printf("=== Hi :) I will save info of all registered alarms in /tmp/alarmmgr_{datetime}.db\n");
int ret = alarmmgr_init("alarmmgr_tool");
- if (ret != ALARMMGR_RESULT_SUCCESS)
- {
+ if (ret != ALARMMGR_RESULT_SUCCESS) {
LOGE("alarmmgr_init() is failed. ret = %d", ret);
printf("=== Failed to get all alarms's info :(\n");
}
char *db_path = NULL;
ret = alarmmgr_get_all_info(&db_path);
- if (ret != ALARMMGR_RESULT_SUCCESS)
- {
+ if (ret != ALARMMGR_RESULT_SUCCESS) {
LOGE("alarmmgr_get_all_info() is failed. ret = %d", ret);
printf("=== Failed to get all alarms's info :(\n");
- }
- else
- {
+ } else {
LOGE("Getting all alarm's info is done successfully.");
printf("=== Success :)\n Please check %s\n", db_path);
}
if (db_path)
- {
free(db_path);
- }
return 0;
}