GError *error = NULL;
if (sub_initialized) {
- ALARM_MGR_EXCEPTION_PRINT("__sub_init was already called.\n");
+ //ALARM_MGR_LOG_PRINT("__sub_init was already called.\n");
return ALARMMGR_RESULT_SUCCESS;
}
"[alarm-lib]:ALARM_BOOT feature is not supported. "
"so we return false.\n");
if (error_code)
- *error_code = -1; /*-1 means that system failed
+ *error_code = -1; /*-1 means that system failed
internally.*/
return false;
#endif
}
g_thread_init(NULL);
-
+
dbus_g_thread_init();
ret = __sub_init();
return ret;
b_initialized = true;
-
+
return ALARMMGR_RESULT_SUCCESS;
}
bundle *b=(bundle *)bundle_data;
+ ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n");
+
if (alarm == NULL) {
return ERR_ALARM_INVALID_PARAM;
}
return ERR_ALARM_INVALID_PARAM;
}
operation = appsvc_get_operation(b);
-
+
if (NULL == operation)
{
ALARM_MGR_EXCEPTION_PRINT("Invalid parameter bundle [appsvc operation not present]\n");
}
alarm_mode_t *mode = &alarm_info->mode;
- 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_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);
/* TODO: This should be changed to > ALARM_REPEAT_MODE_MAX ? */
if (mode->repeat >= ALARM_REPEAT_MODE_MAX) {
(alarm_context, alarm_info, alarm_id, b,
&error_code)) {
return error_code;
- }
+ }
return ALARMMGR_RESULT_SUCCESS;
}
int i = 0;
int j = 0;
+ ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n");
+
if (alarm == NULL) {
return ERR_ALARM_INVALID_PARAM;
}
if (ret < 0)
return ret;
- ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n");
-
- 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_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);
/* TODO: This should be changed to > ALARM_REPEAT_MODE_MAX ? */
if (mode->repeat >= ALARM_REPEAT_MODE_MAX) {
const char *operation = NULL;
char *appid = NULL;
+ ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n");
+
bundle *b=(bundle *)bundle_data;
if (NULL == b)
return ERR_ALARM_INVALID_PARAM;
}
operation = appsvc_get_operation(b);
-
+
if (NULL == operation)
{
ALARM_MGR_EXCEPTION_PRINT("Invalid parameter bundle [appsvc operation not present]\n");
return ERR_ALARM_SYSTEM_FAIL;
}
- ALARM_MGR_LOG_PRINT("interval(%d)", interval);
-
if (alarm_id == NULL) {
return ERR_ALARM_INVALID_PARAM;
}
alarm_info.mode.u_interval.interval = interval;
}
+ 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);
+
if (!_send_alarm_create_appsvc
(alarm_context, &alarm_info, alarm_id, b,
&error_code)) {
return error_code;
- }
+ }
return ALARMMGR_RESULT_SUCCESS;
}
alarm_info_t alarm_info;
int ret;
+ ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n");
+
ret = __sub_init();
if (ret < 0)
return ret;
- ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n");
-
- ALARM_MGR_LOG_PRINT("interval(%d)", interval);
-
if (alarm_id == NULL) {
return ERR_ALARM_INVALID_PARAM;
}
alarm_info.mode.u_interval.interval = interval;
}
+ 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);
+
if (destination != NULL) {
memset(dst_service_name, 0,
strlen(destination) + strlen(".ALARM") + 2);
return ALARMMGR_RESULT_SUCCESS;
}
+
+EXPORT_API int alarmmgr_get_next_duetime(alarm_id_t alarm_id, time_t* duetime)
+{
+ int error_code;
+ ALARM_MGR_LOG_PRINT("[alarm-lib]:alarmmgr_get_next_duetime() is called\n");
+
+ if (duetime == NULL) {
+ return ERR_ALARM_INVALID_PARAM;
+ }
+
+ if (!_send_alarm_get_next_duetime
+ (alarm_context, alarm_id, duetime, &error_code))
+ return error_code;
+
+ return ALARMMGR_RESULT_SUCCESS;
+}
#ifdef __WAKEUP_USING_RTC__
const char *rtc = default_rtc;
+ const char *rtc0 = power_rtc;
int fd = 0;
struct rtc_time rtc_tm;
struct rtc_wkalrm rtc_wk;
fd = open(rtc, O_RDONLY);
if (fd == -1) {
- ALARM_MGR_EXCEPTION_PRINT("RTC open failed.\n");
- return;
+ fd = open(rtc0, O_RDONLY);
+ if (fd == -1) {
+ ALARM_MGR_EXCEPTION_PRINT("RTC open failed.\n");
+ return;
+ }
}
/* Read the RTC time/date */
alarm_context.c_due_time);
if (alarm_context.c_due_time != -1) {
- time_t due_time = alarm_context.c_due_time - 1;
+ time_t due_time = alarm_context.c_due_time;
gmtime_r(&due_time, &due_tm);
rtc_tm.tm_mday = due_tm.tm_mday;
struct rtc_time rtc_tm = { 0, };
const char *rtc0 = power_rtc;
const char *rtc1 = default_rtc;
- struct tm *_tm = NULL;
struct tm time_r = { 0, };
fd0 = open(rtc0, O_RDONLY);
if (fd1 == -1) {
ALARM_MGR_LOG_PRINT("error to open /dev/rtc1.");
- perror("\t");
+// perror("\t");
}
memset(&rtc_tm, 0, sizeof(struct rtc_time));
if (fd0 != -1)
close(fd0);
- retval1 = ioctl(fd1, RTC_SET_TIME, &rtc_tm);
+ if (fd1 != -1) {
+ retval1 = ioctl(fd1, RTC_SET_TIME, &rtc_tm);
- if (retval1 == -1) {
- if (fd1 != -1)
- close(fd1);
- ALARM_MGR_LOG_PRINT("error to ioctl fd1.");
- perror("\t");
- }
- if (fd1 != -1)
+ if (retval1 == -1) {
+ if (fd1 != -1)
+ close(fd1);
+ ALARM_MGR_LOG_PRINT("error to ioctl fd1.");
+ perror("\t");
+ }
close(fd1);
-
+ }
return 1;
}
return false;
} else {
ret = read(fd, process_name, 512);
+ if (ret < 0 ) {
+ *error_code = -1; /*-1 means that system failed
+ internally.*/
+ free(__alarm_info);
+ close(fd);
+ return false;
+ }
close(fd);
while (process_name[i] != '\0') {
if (process_name[i] == ' ') {
current_time, interval);
if (alarm_context.c_due_time > current_time) {
- ALARM_MGR_LOG_PRINT("[alarm-server]: False Alarm (time changed to past)\n");
+ ALARM_MGR_EXCEPTION_PRINT("[alarm-server]: False Alarm. due time is (%d) seconds future\n",
+ alarm_context.c_due_time - current_time);
goto done;
}
// 3 seconds is maximum permitted delay from timer expire to this function
if (alarm_context.c_due_time + 3 < current_time) {
- ALARM_MGR_LOG_PRINT("[alarm-server]: False Alarm (time changed to future)\n");
+ ALARM_MGR_EXCEPTION_PRINT("[alarm-server]: False Alarm. due time is (%d) seconds past\n",
+ current_time - alarm_context.c_due_time);
goto done;
}
tzset();
- ALARM_MGR_ASSERT_PRINT("diff_time is %f\n", diff_time);
+ ALARM_MGR_EXCEPTION_PRINT("New time is %s, diff_time is %f\n", ctime(&_time), diff_time);
ALARM_MGR_LOG_PRINT("[alarm-server] System time has been changed\n");
ALARM_MGR_LOG_PRINT("1.alarm_context.c_due_time is %d\n",
_set_time(_time);
- vconf_set_dbl(VCONFKEY_SYSTEM_TIMEDIFF, diff_time);
vconf_set_int(VCONFKEY_SYSTEM_TIME_CHANGED,(int)diff_time);
__alarm_update_due_time_of_all_items_in_list(diff_time);
}
tzset();
+ time(&cur_time);
- ALARM_MGR_ASSERT_PRINT("diff_time is %f\n", diff_time);
+ ALARM_MGR_EXCEPTION_PRINT("diff_time is %f, New time is %s\n", diff_time, ctime(&cur_time));
ALARM_MGR_LOG_PRINT("[alarm-server] System time has been changed externally\n");
ALARM_MGR_LOG_PRINT("1.alarm_context.c_due_time is %d\n",
alarm_context.c_due_time);
// set rtc time only because the linux time is set externally
- time(&cur_time);
_set_rtc_time(cur_time);
- vconf_set_dbl(VCONFKEY_SYSTEM_TIMEDIFF, diff_time);
vconf_set_int(VCONFKEY_SYSTEM_TIME_CHANGED,(int)diff_time);
__alarm_update_due_time_of_all_items_in_list(diff_time);
return true;
} else {
ret = read(fd, process_name, 512);
+ if (ret <0 ) {
+ *return_code = -1; /* -1 means that system
+ failed internally. */
+ close(fd);
+ return false;
+ }
close(fd);
while (process_name[i] != '\0') {
if (process_name[i] == ' ') {
return true;
} else {
ret = read(fd, process_name, 512);
+ if (ret <0 ) {
+ *return_code = -1;
+ /* -1 means that system failed internally. */
+ close(fd);
+ return true;
+ }
close(fd);
while (process_name[i] != '\0') {
if (process_name[i] == ' ') {
return true;
}
+gboolean alarm_manager_alarm_get_next_duetime(void *pObject, int pid,
+ alarm_id_t alarm_id, time_t* duetime,
+ int *return_code)
+{
+ ALARM_MGR_LOG_PRINT("called for pid(%d) and alarm_id(%d)\n", pid,
+ alarm_id);
+
+ GSList *gs_iter = NULL;
+ __alarm_info_t *entry = NULL;
+
+ *return_code = 0;
+
+ for (gs_iter = alarm_context.alarms; gs_iter != NULL;
+ gs_iter = g_slist_next(gs_iter)) {
+ entry = gs_iter->data;
+ if (entry->alarm_id == alarm_id) {
+ break;
+ }
+ }
+
+ if (entry == NULL)
+ {
+ ALARM_MGR_EXCEPTION_PRINT("alarm id(%d) was not found\n",
+ alarm_id);
+ *return_code = ERR_ALARM_INVALID_ID;
+ } else {
+ ALARM_MGR_LOG_PRINT("alarm was found\n");
+ *duetime = _alarm_next_duetime(entry);
+ *return_code = 0;
+ }
+ return true;
+}
+
#include "alarm-skeleton.h"
typedef struct AlarmManagerObject AlarmManagerObject;
return;
}
retval = ioctl(fd, RTC_RD_TIME, &rtc_tm);
+ if (retval == -1) {
+ ALARM_MGR_EXCEPTION_PRINT("RTC_RD_TIME ioctl failed");
+ close(fd);
+ return;
+ }
close(fd);
fd2 = open(default_rtc, O_RDWR);
- if (fd2 < 0) {
- ALARM_MGR_EXCEPTION_PRINT("cannot open /dev/rtc1\n");
- return;
+ if (fd2 >= 0) {
+ retval = ioctl(fd2, RTC_SET_TIME, &rtc_tm);
+ if (retval == -1) {
+ ALARM_MGR_EXCEPTION_PRINT("RTC_SET_TIME ioctl failed");
+ close(fd2);
+ return;
+ }
+ close(fd2);
+// ALARM_MGR_EXCEPTION_PRINT("cannot open /dev/rtc1\n");
+// return;
+ } else {
+ fd = open(power_rtc, O_RDWR);
+ if (fd < 0) {
+ ALARM_MGR_EXCEPTION_PRINT("cannot open /dev/rtc0\n");
+ return;
+ }
+ retval = ioctl(fd, RTC_SET_TIME, &rtc_tm);
+ if (retval == -1) {
+ ALARM_MGR_EXCEPTION_PRINT("RTC_SET_TIME ioctl failed");
+ close(fd);
+ return;
+ }
+ close(fd);
}
- retval = ioctl(fd2, RTC_SET_TIME, &rtc_tm);
- close(fd2);
__initialize_timer();
if (__initialize_dbus() == false) { /* because dbus's initialize
*
* @defgroup Alarm Alarm
* @version 0.4.2
- *
*
- * Alarm supports APIs that add, delete, and update an alarm.
+ *
+ * Alarm supports APIs that add, delete, and update an alarm.
* @n An application can use alarm APIs by including @c alarm.h. The definitions
* of APIs are defined as follows:
*
* @li @c #alarmmgr_remove_alarm remove an alarm from alarm server
* @li @c #alarmmgr_enum_alarm_ids get the list of alarm ids
* @li @c #alarmmgr_get_info get the information of an alarm
- *
*
- * The following code shows how to initialize alarm library, how to register the alarm handler, and how to add an alarm. It first calls alarm_init to initialize the alarm library and sets the callback to handle an alarm event it received. In create_test fucnction, the application add an alarm which will be expired in one minute from it execute and will expire everyday at same time.
*
- *
+ * The following code shows how to initialize alarm library, how to register the alarm handler, and how to add an alarm. It first calls alarm_init to initialize the alarm library and sets the callback to handle an alarm event it received. In create_test fucnction, the application add an alarm which will be expired in one minute from it execute and will expire everyday at same time.
+ *
+ *
* @code
#include<stdio.h>
#include<stdlib.h>
#include "alarm.h"
-int callback(alarm_id_t alarm_id, void *user_param)
+int callback(alarm_id_t alarm_id, void *user_param)
{
int error;
time_t current_time;
time(¤t_time);
-
+
printf("Alarm[%d] has expired at %s\n", alarm_id, ctime(¤t_time));
return 0;
}
test_time.year = current_tm.tm_year+1900;
test_time.month = current_tm.tm_mon+1;
- test_time.day = current_tm.tm_mday;
+ test_time.day = current_tm.tm_mday;
test_time.hour = current_tm.tm_hour;
test_time.min = current_tm.tm_min+1;
test_time.sec = 0;
ALARM_WDAY_MONDAY| \
ALARM_WDAY_TUESDAY|ALARM_WDAY_WEDNESDAY| \
ALARM_WDAY_THURSDAY|ALARM_WDAY_FRIDAY );
-
+
alarmmgr_set_type(alarm_info,ALARM_TYPE_VOLATILE);
alarmmgr_add_alarm_with_localtime(alarm_info,NULL,&alarm_id);
-
+
if(result != ALARMMGR_RESULT_SUCCESS)
printf("fail to alarmmgr_create : error_code : %d\n",result);
-
+
}
-int main(int argc, char** argv)
+int main(int argc, char** argv)
{
int error_code;
GMainLoop *mainloop;
int result;
g_type_init();
-
+
mainloop = g_main_loop_new(NULL, FALSE);
result = alarmmgr_init("org.tizen.test");
if(result != ALARMMGR_RESULT_SUCCESS) {
printf("fail to alarmmgr_init : error_code : %d\n",result);
- }
+ }
else {
result = alarmmgr_set_cb(callback,NULL);
if(result != ALARMMGR_RESULT_SUCCESS) {
- printf("fail to alarmmgr_set_cb : error_code :
+ printf("fail to alarmmgr_set_cb : error_code :
%d\n",result);
}
else {
ERR_ALARM_INVALID_TIME, /**<Invalid time. */
ERR_ALARM_INVALID_DATE, /**<Invalid date. */
ERR_ALARM_NO_SERVICE_NAME,
- /**<there is no alarm service
+ /**<there is no alarm service
for this applicaation. */
ERR_ALARM_INVALID_TYPE, /*Invalid type*/
ERR_ALARM_NO_PERMISSION, /*No permission*/
* This enumeration has repeat mode of alarm
*/
typedef enum {
- ALARM_REPEAT_MODE_ONCE = 0, /**<once : the alarm will be expired
+ ALARM_REPEAT_MODE_ONCE = 0, /**<once : the alarm will be expired
only one time. */
- ALARM_REPEAT_MODE_REPEAT, /**<repeat : the alarm will be expired
+ ALARM_REPEAT_MODE_REPEAT, /**<repeat : the alarm will be expired
repeatly*/
ALARM_REPEAT_MODE_WEEKLY, /**<weekly*/
ALARM_REPEAT_MODE_MONTHLY, /**< monthly*/
/**
*
- * This function initializes alarm library. It connects to system bus and registers the application's service name.
+ * This function initializes alarm library. It connects to system bus and registers the application's service name.
*
* @param [in] pkg_name a package of application
*
- * @return On success, ALARMMGR_RESULT_SUCCESS is returned. On error, a negative number is returned
+ * @return On success, ALARMMGR_RESULT_SUCCESS is returned. On error, a negative number is returned
*
* @pre None.
* @post None.
* @see None.
- * @remark An application must call this function before using other alarm APIs.
+ * @remark An application must call this function before using other alarm APIs.
* @par Sample code:
* @code
#include <alarm.h>
* @param [in] handler Callback function
* @param [in] user_param User Parameter
*
- * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
+ * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
*
* @pre alarmmgr_init().
* @post None.
* @see None.
- * @remark An application can have only one alarm handler. If an application
+ * @remark An application can have only one alarm handler. If an application
* calls this function more than one times, the handler regitered during the
- * last call of this funiction will be called when an alarm event has occured.
+ * last call of this funiction will be called when an alarm event has occured.
* @par Sample code:
* @code
#include <alarm.h>
...
-// Call back function
+// Call back function
int callback(alarm_id_t alarm_id,void* user_param)
{
time_t current_time;
/**
* This function creates a new alarm entry, will not be known to the server until alarmmgr_add_alarm is called.
*
- * @return This function returns the pointer of alarm_entry_t
+ * @return This function returns the pointer of alarm_entry_t
*
* @pre None.
* @post None.
}
else
{
- //alarmmgr_create_alarm () failed
+ //alarmmgr_create_alarm () failed
}
}
/**
- * This function frees an alarm entry.
+ * This function frees an alarm entry.
*
* @param [in] alarm alarm entry
*
- * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
+ * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
*
* @pre None.
* @post None.
* @par Sample code:
* @code
#include <alarm.h>
-
+
...
{
int ret_val = ALARMMGR_RESULT_SUCCESS;
alarm_entry_t* alarm;
-
+
alarm = alarmmgr_create_alarm() ;
if(alarm == NULL)
{
- //alarmmgr_create_alarm () failed
+ //alarmmgr_create_alarm () failed
}
else
{
-
+
ret_val = alarmmgr_free_alarm( alarm) ;
if(ret_val == ALARMMGR_RESULT_SUCCESS)
{
else
{
//alarmmgr_free_alarm() failed
- }
+ }
}
- }
-
+ }
+
* @endcode
* @limo
*/
* @param [in] alarm alarm entry
* @param [in] time time the alarm should first go off
*
- * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
+ * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
*
* @pre None.
* @post None.
* @par Sample code:
* @code
#include <alarm.h>
-
+
...
{
int ret_val = ALARMMGR_RESULT_SUCCESS;
time_t current_time;
struct tm current_tm;
alarm_date_t test_time;
-
-
+
+
time(¤t_time);
localtime_r(¤t_time, ¤t_tm);
-
+
alarm = alarmmgr_create_alarm();
if(alarm == NULL)
{
- //alarmmgr_create_alarm () failed
+ //alarmmgr_create_alarm () failed
}
else {
test_time.year = current_tm.tm_year;
test_time.hour = current_tm.tm_hour;
test_time.min = current_tm.tm_min+1;
test_time.sec = 0;
-
+
ret_val=alarmmgr_set_time(alarm,test_time);
if(ret_val == ALARMMGR_RESULT_SUCCESS)
{
alarmmgr_free_alarm( alarm) ;
}
}
-
+
* @endcode
* @limo
*/
* @param [in] alarm alarm entry
* @param [out] time time the alarm should first go off
*
- * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
+ * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
*
* @pre None.
* @post None.
* @see None.
- * @remark But an application does not need to specify year, month, and day field of alarm_info. If an application sets
+ * @remark But an application does not need to specify year, month, and day field of alarm_info. If an application sets
* those fields with zero, the function sets them with proper values.
*
* @par Sample code:
* @code
#include <alarm.h>
-
+
...
{
int ret_val = ALARMMGR_RESULT_SUCCESS;
alarm_entry_t* alarm;
-
+
time_t current_time;
struct tm current_tm;
alarm_date_t test_time;
alarm_date_t new_time;
-
-
+
+
time(¤t_time);
localtime_r(¤t_time, ¤t_tm);
-
+
alarm = alarmmgr_create_alarm();
if(alarm == NULL) {
- //alarmmgr_create_alarm () failed
+ //alarmmgr_create_alarm () failed
}
else {
test_time.year = current_tm.tm_year;
int alarmmgr_get_time(const alarm_entry_t *alarm, alarm_date_t *time);
/**
- * This function sets an alarm repeat mode
+ * This function sets an alarm repeat mode
*
* @param [in] alarm alarm entry
- * @param [in] repeat_mode one of ALARM_REPEAT_MODE_ONCE, ALARM_REPEAT_MODE_REPEAT,
+ * @param [in] repeat_mode one of ALARM_REPEAT_MODE_ONCE, ALARM_REPEAT_MODE_REPEAT,
* ALARM_REPEAT_MODE_WEEKLY, ALARM_REPEAT_MODE_MONTHLY or ALARM_REPEAT_MODE_ANNUALLY.
* @param [in] repeat_value the ALARM_REPEAT_MODE_REPEAT mode : interval between subsequent repeats of the alarm.
* the ALARM_REPEAT_MODE_WEEKLY mode : days of a week
- * (ALARM_WDAY_SUNDAY, ALARM_WDAY_MONDAY, ALARM_WDAY_TUESDAY, ALARM_WDAY_WEDNESDAY,
+ * (ALARM_WDAY_SUNDAY, ALARM_WDAY_MONDAY, ALARM_WDAY_TUESDAY, ALARM_WDAY_WEDNESDAY,
* ALARM_WDAY_THURSDAY, ALARM_WDAY_FRIDAY, ALARM_WDAY_SATURDAY)
* the others : this parameter is ignored.
*
- * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
+ * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
*
* @pre None.
* @post None.
* @par Sample code:
* @code
#include <alarm.h>
-
+
...
{
int ret_val = ALARMMGR_RESULT_SUCCESS;
- alarm_entry_t* alarm;
- alarm_repeat_mode_t repeat_mode =ALARM_REPEAT_MODE_WEEKLY;
+ alarm_entry_t* alarm;
+ alarm_repeat_mode_t repeat_mode =ALARM_REPEAT_MODE_WEEKLY;
int interval = ALARM_WDAY_MONDAY; //| ALARM_WDAY_TUESDAY|
ALARM_WDAY_WEDNESDAY| ALARM_WDAY_THURSDAY|ALARM_WDAY_FRIDAY ;
-
-
+
+
alarm = alarmmgr_create_alarm();
if(alarm == NULL)
{
- //alarmmgr_create_alarm () failed
+ //alarmmgr_create_alarm () failed
}
else
{
ret_val = alarmmgr_set_repeat_mode
(alarm, repeat_mode,interval);
-
+
if(ret_val == ALARMMGR_RESULT_SUCCESS)
{
- //alarmmgr_set_repeat_mode() is successful
+ //alarmmgr_set_repeat_mode() is successful
}
else
{
alarmmgr_free_alarm( alarm) ;
}
}
-
+
* @endcode
* @limo
*/
int repeat_value);
/**
- * This function gives an application an alarm mode
+ * This function gives an application an alarm mode
*
* @param [in] alarm alarm entry
- * @param [out] repeat_mode one of ALARM_REPEAT_MODE_ONCE, ALARM_REPEAT_MODE_REPEAT,
+ * @param [out] repeat_mode one of ALARM_REPEAT_MODE_ONCE, ALARM_REPEAT_MODE_REPEAT,
* ALARM_REPEAT_MODE_WEEKLY, ALARM_REPEAT_MODE_MONTHLY or ALARM_REPEAT_MODE_ANNUALLY.
* @param [out] repeat_value the ALARM_REPEAT_MODE_REPEAT mode : interval between subsequent repeats of the alarm.
* the ALARM_REPEAT_MODE_WEEKLY mode : days of a week
- * (ALARM_WDAY_SUNDAY, ALARM_WDAY_MONDAY, ALARM_WDAY_TUESDAY, ALARM_WDAY_WEDNESDAY,
+ * (ALARM_WDAY_SUNDAY, ALARM_WDAY_MONDAY, ALARM_WDAY_TUESDAY, ALARM_WDAY_WEDNESDAY,
* ALARM_WDAY_THURSDAY, ALARM_WDAY_FRIDAY, ALARM_WDAY_SATURDAY)
* the others : this parameter is ignored.
*
- * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
+ * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
*
* @pre None.
* @post None.
* @par Sample code:
* @code
#include <alarm.h>
-
+
...
{
int ret_val = ALARMMGR_RESULT_SUCCESS;
alarm_entry_t* alarm;
alarm_repeat_mode_t repeat;
int interval;
-
+
alarm = alarmmgr_create_alarm();
if(alarm == NULL)
{
- //alarmmgr_create_alarm () failed
+ //alarmmgr_create_alarm () failed
}
else {
ret_val =alarmmgr_get_repeat_mode
(alarm, &repeat, &interval) ;
- if(ret_val == ALARMMGR_RESULT_SUCCESS
+ if(ret_val == ALARMMGR_RESULT_SUCCESS
&& repeat == ALARM_REPEAT_MODE_ONCE) {
//alarmmgr_get_repeat_mode() is successful
}
int *repeat_value);
/**
- * This function sets an alarm mode
+ * This function sets an alarm mode
*
* @param [in] alarm alarm entry
* @param [in] alarm_type one of ALARM_TYPE_DEFAULT : After the device reboot, the alarm still works.
* ALARM_TYPE_VOLATILE : After the device reboot, the alarm does not work.
*
- * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
+ * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
*
* @pre None.
* @post None.
* @code
#include <alarm.h>
- ...
+ ...
{
int ret_val = ALARMMGR_RESULT_SUCCESS;
alarm_entry_t* alarm;
int alarm_type = ALARM_TYPE_VOLATILE;
-
+
alarm = alarmmgr_create_alarm();
if(alarm == NULL)
{
- //alarmmgr_create_alarm () failed
+ //alarmmgr_create_alarm () failed
}
else
- {
+ {
ret_val = alarmmgr_set_type(alarm, alarm_type);
if(ret_val == ALARMMGR_RESULT_SUCCESS)
{
- //alarmmgr_set_type() is successful
+ //alarmmgr_set_type() is successful
}
else
{
alarmmgr_free_alarm( alarm) ;
}
}
-
+
* @endcode
* @limo
*/
int alarmmgr_set_type(alarm_entry_t *alarm, int alarm_type);
/**
- * This function gives an application an alarm mode
+ * This function gives an application an alarm mode
*
* @param [in] alarm alarm entry
* @param [out] alarm_type one of ALARM_TYPE_DEFAULT, ALARM_TYPE_VOLATILE
*
- * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
+ * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
*
* @pre None.
* @post None.
* @code
#include <alarm.h>
- ...
+ ...
{
int ret_val = ALARMMGR_RESULT_SUCCESS;
- alarm_entry_t* alarm;
+ alarm_entry_t* alarm;
int alarm_type;
-
+
alarm = alarmmgr_create_alarm();
if(alarm == NULL) {
//alarmmgr_create_alarm () failed
}
else {
ret_val = alarmmgr_get_type( alarm, &alarm_type);
- if(ret_val == ALARMMGR_RESULT_SUCCESS && alarm_type
+ if(ret_val == ALARMMGR_RESULT_SUCCESS && alarm_type
== ALARM_TYPE_DEFAULT ) {
//alarmmgr_get_type() is successful
}
alarmmgr_free_alarm( alarm) ;
}
}
-
+
* @endcode
* @limo
*/
int alarmmgr_get_type(const alarm_entry_t *alarm, int *alarm_type);
/**
- * This function adds an alarm entry to the server.
+ * This function adds an alarm entry to the server.
* Server will remember this entry, and generate alarm events for it when necessary.
* Server will call app-svc interface to sent notification to destination application. Destination information
* should be available in the input bundle.
- * Alarm entries registered with the server cannot be changed.
+ * Alarm entries registered with the server cannot be changed.
* Remove from server before changing.
* Before the application calls alarmmgr_add_alarm_appsvc_with_localtime(), the application have to call alarmmgr_set_time().
* The time set is localtime.
*
* @param [in] alarm the entry of an alarm to be created.
* @param [in] bundle_data bundle which contains information about the destination.
- * @param [out] alarm_id the id of the alarm added.
+ * @param [out] alarm_id the id of the alarm added.
*
- * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
+ * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
*
* @pre None.
* @post None.
* @code
#include <alarm.h>
- ...
+ ...
{
time_t current_time;
struct tm current_tm;
printf("current time: %s\n", ctime(¤t_time));
localtime_r(¤t_time, ¤t_tm);
-
+
alarm_info = alarmmgr_create_alarm();
-
- test_time.year = current_tm.tm_year;
- test_time.month = current_tm.tm_mon;
- test_time.day = current_tm.tm_mday;
-
+
+ test_time.year = current_tm.tm_year;
+ test_time.month = current_tm.tm_mon;
+ test_time.day = current_tm.tm_mday;
+
test_time.hour = current_tm.tm_hour;
test_time.min = current_tm.tm_min+1;
test_time.sec = 5;
-
+
alarmmgr_set_time(alarm_info,test_time);
alarmmgr_set_repeat_mode(alarm_info,ALARM_REPEAT_MODE_WEEKLY,ALARM_WDAY_MONDAY| \
ALARM_WDAY_TUESDAY|ALARM_WDAY_WEDNESDAY| \
int alarmmgr_add_alarm_appsvc_with_localtime(alarm_entry_t *alarm,void *bundle_data, alarm_id_t *alarm_id);
/**
- * This function adds an alarm entry to the server.
+ * This function adds an alarm entry to the server.
* Server will remember this entry, and generate alarm events for it when necessary.
- * Alarm entries registered with the server cannot be changed.
+ * Alarm entries registered with the server cannot be changed.
* Remove from server before changing.
* Before the application calls alarmmgr_add_alarm_with_localtime(), the application have to call alarmmgr_set_time().
* The time set is localtime.
*
* @param [in] alarm the entry of an alarm to be created.
* @param [in] destination the packname of application that the alarm will be expired.
- * @param [out] alarm_id the id of the alarm added.
+ * @param [out] alarm_id the id of the alarm added.
*
- * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
+ * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
*
* @pre None.
* @post None.
* @code
#include <alarm.h>
- ...
+ ...
{
int ret_val = ALARMMGR_RESULT_SUCCESS;
- alarm_entry_t* alarm;
- const char* destination = NULL;
+ alarm_entry_t* alarm;
+ const char* destination = NULL;
alarm_id_t alarm_id;
-
+
time_t current_time;
struct tm current_tm;
alarm_date_t test_time;
-
+
const char* pkg_name = "org.tizen.test";
-
+
g_type_init();
-
+
ret_val =alarmmgr_init(pkg_name) ;
if(ret_val != ALARMMGR_RESULT_SUCCESS) {
//alarmmgr_init () failed
return;
}
-
+
time(¤t_time);
-
+
printf("current time: %s\n", ctime(¤t_time));
localtime_r(¤t_time, ¤t_tm);
-
+
alarm = alarmmgr_create_alarm();
-
+
test_time.year = 0;
test_time.month = 0;test_time.day = 0;
-
+
test_time.hour = current_tm.tm_hour;
test_time.min = current_tm.tm_min+1;
test_time.sec = 0;
-
-
+
+
alarmmgr_set_time(alarm,test_time);
alarmmgr_set_repeat_mode(alarm,ALARM_REPEAT_MODE_WEEKLY, \
ALARM_WDAY_MONDAY);
alarmmgr_set_type(alarm,ALARM_TYPE_VOLATILE);
-
-
+
+
ret_val=alarmmgr_add_alarm_with_localtime(alarm,destination,&alarm_id);
-
+
if(ret_val == ALARMMGR_RESULT_SUCCESS)
{
- //alarmmgr_add_alarm_with_localtime() is successful
+ //alarmmgr_add_alarm_with_localtime() is successful
}
else
{
/**
- * This function adds an alarm entry to the server.
+ * This function adds an alarm entry to the server.
* Server will remember this entry, and generate alarm events for it when necessary.
* Server will call app-svc interface to sent notification to destination application. Destination information
* should be available in the input bundle.
- * Alarm entries registered with the server cannot be changed.
+ * Alarm entries registered with the server cannot be changed.
* Remove from server before changing.
* After the trigger_at_time seconds from now, the alarm will be expired.
* If the interval is zero, the repeat_mode is ALARM_REPEAT_MODE_ONCE.
* The id of the new alarm will be copied to alarm_id if the fuction successes to create an alarm.
*
* @param [in] alarm_type one of ALARM_TYPE_DEFAULT, ALARM_TYPE_VOLATILE
- * @param [in] trigger_at_time time interval to be triggered from now(sec). an alarm also will be expired at triggering time.
- * @param [in] interval Interval between subsequent repeats of the alarm
+ * @param [in] trigger_at_time time interval to be triggered from now(sec). an alarm also will be expired at triggering time.
+ * @param [in] interval Interval between subsequent repeats of the alarm
* @param [in] bundle_data bundle which contains information about the destination.
- * @param [out] alarm_id the id of the alarm added.
+ * @param [out] alarm_id the id of the alarm added.
*
- * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
+ * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
*
* @pre None.
* @post None.
* @code
#include <alarm.h>
- ...
+ ...
{
int result;
alarm_id_t alarm_id;
printf("Unable to add alarm. Alarmmgr alarm no is %d\n", result);
else
printf("Alarm added successfully. Alarm Id is %d\n", alarm_id);
- return;
+ return;
}
/**
- * This function adds an alarm entry to the server.
+ * This function adds an alarm entry to the server.
* Server will remember this entry, and generate alarm events for it when necessary.
- * Alarm entries registered with the server cannot be changed.
+ * Alarm entries registered with the server cannot be changed.
* Remove from server before changing.
* After the trigger_at_time seconds from now, the alarm will be expired.
* If the interval is zero, the repeat_mode is ALARM_REPEAT_MODE_ONCE.
* The id of the new alarm will be copied to alarm_id if the fuction successes to create an alarm.
*
* @param [in] alarm_type one of ALARM_TYPE_DEFAULT, ALARM_TYPE_VOLATILE
- * @param [in] trigger_at_time time interval to be triggered from now(sec). an alarm also will be expired at triggering time.
- * @param [in] interval Interval between subsequent repeats of the alarm
+ * @param [in] trigger_at_time time interval to be triggered from now(sec). an alarm also will be expired at triggering time.
+ * @param [in] interval Interval between subsequent repeats of the alarm
* @param [in] destination the packname of application that the alarm will be expired.
- * @param [out] alarm_id the id of the alarm added.
+ * @param [out] alarm_id the id of the alarm added.
*
- * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
+ * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
*
* @pre None.
* @post None.
* @code
#include <alarm.h>
- ...
+ ...
{
int ret_val = ALARMMGR_RESULT_SUCCESS;
-
+
int alarm_type = ALARM_TYPE_VOLATILE;
- time_t trigger_at_time = 10;
- time_t interval = 10;
+ time_t trigger_at_time = 10;
+ time_t interval = 10;
const char* destination = NULL;
alarm_id_t alarm_id;
-
+
const char* pkg_name = "org.tizen.test";
-
+
g_type_init();
-
+
ret_val =alarmmgr_init(pkg_name) ;
if(ret_val != ALARMMGR_RESULT_SUCCESS)
{
//alarmmgr_init () failed
return;
}
-
- ret_val = alarmmgr_add_alarm( alarm_type, trigger_at_time, interval,
+
+ ret_val = alarmmgr_add_alarm( alarm_type, trigger_at_time, interval,
destination, &alarm_id);
if(ret_val == ALARMMGR_RESULT_SUCCESS)
{
- //alarmmgr_add_alarm() is successful
+ //alarmmgr_add_alarm() is successful
}
else
{
/**
* This function deletes the alarm associated with the given alarm_id.
*
- * @param [in] alarm_id Specifies the ID of the alarm to be deleted.
+ * @param [in] alarm_id Specifies the ID of the alarm to be deleted.
*
- * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
+ * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
*
* @pre None.
* @post None.
* @code
#include <alarm.h>
- ...
+ ...
{
int ret_val = ALARMMGR_RESULT_SUCCESS;
int alarm_type = ALARM_TYPE_VOLATILE;
- time_t trigger_at_time = 10;
- time_t interval = 10;
+ time_t trigger_at_time = 10;
+ time_t interval = 10;
const char* destination = NULL;
alarm_id_t alarm_id;
-
+
const char* pkg_name = "org.tizen.test";
-
+
g_type_init();
-
+
ret_val =alarmmgr_init(pkg_name) ;
if(ret_val != ALARMMGR_RESULT_SUCCESS) {
//alarmmgr_init () failed
return;
}
- alarmmgr_add_alarm( alarm_type, trigger_at_time, interval,
+ alarmmgr_add_alarm( alarm_type, trigger_at_time, interval,
destination, &alarm_id);
-
+
ret_val =alarmmgr_remove_alarm( alarm_id) ;
if(ret_val == ALARMMGR_RESULT_SUCCESS) {
/alarmmgr_remove_alarm() is successful
//alarmmgr_remove_alarm() failed
}
}
-
+
* @endcode
* @limo
*/
* @param [in] fn a user callback function
* @param [in] user_param user parameter
*
- * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
+ * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
*
* @pre None.
* @post None.
* @par Sample code:
* @code
#include <alarm.h>
-
+
int callback_2(alarm_id_t id, void* user_param)
{
int* n = (int*)user_param;
return 0;
}
-...
+...
{
int ret_val = ALARMMGR_RESULT_SUCCESS;
int n = 1;
-
+
const char* pkg_name = "org.tizen.test";
-
+
g_type_init();
-
+
ret_val =alarmmgr_init(pkg_name) ;
if(ret_val != ALARMMGR_RESULT_SUCCESS)
{
//alarmmgr_init() failed
return;
}
-
+
ret_val = alarmmgr_enum_alarm_ids( callback_2, (void*)&n) ;
if(ret_val == ALARMMGR_RESULT_SUCCESS)
{
- //alarmmgr_enum_alarm_ids() is successful
+ //alarmmgr_enum_alarm_ids() is successful
}
else
{
/**
* This function gets the information of the alarm assosiated with alarm_id to alarm_info. The application
- * must allocate alarm_info before calling this function.
+ * must allocate alarm_info before calling this function.
*
* @param [in] alarm_id the id of the alarm
* @param [out] alarm the buffer alarm informaiton will be copied to
- *
- * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
+ *
+ * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
*
* @pre None.
* @post None.
{
int ret_val = ALARMMGR_RESULT_SUCCESS;
int alarm_type = ALARM_TYPE_VOLATILE;
- time_t trigger_at_time = 10;
- time_t interval = ALARM_WDAY_SUNDAY;
+ time_t trigger_at_time = 10;
+ time_t interval = ALARM_WDAY_SUNDAY;
const char* destination = NULL;
alarm_id_t alarm_id;
alarm_entry_t *alarm;
const char* pkg_name = "org.tizen.test_get_info1";
-
+
g_type_init();
-
+
ret_val =alarmmgr_init(pkg_name) ;
if(ret_val != ALARMMGR_RESULT_SUCCESS) {
//alarmmgr_init() failed
return;
- }
+ }
ret_val = alarmmgr_add_alarm( alarm_type,trigger_at_time,interval,
destination, &alarm_id);
if(ret_val != ALARMMGR_RESULT_SUCCESS) {
//alarmmgr_add_alarm() failed
return;
- }
+ }
ret_val = alarmmgr_get_info(alarm_id, alarm);
if(ret_val == ALARMMGR_RESULT_SUCCESS) {
//alarmmgr_get_info() is successful
*/
void *alarmmgr_get_alarm_appsvc_info(alarm_id_t alarm_id, int *return_code);
-
+/**
+ * This function gets the scheduled time of the alarm assosiated with alarm_id.
+ *
+ * @param [in] alarm_id the id of the alarm
+ * @param [out] duetime the scheduled time of the alarm
+ *
+ * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
+ *
+ * @pre None.
+ * @post None.
+ * @see None
+ * @remark None.
+ */
+ int alarmmgr_get_next_duetime(alarm_id_t alarm_id, time_t* duetime);
/**
* This function sets power RTC (which can power on the system).