4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
7 * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
31 * @addtogroup APPLICATION_FRAMEWORK
34 * @defgroup AlarmManager
38 * Alarm supports APIs that add, delete, and update an alarm.
39 * @n An application can use alarm APIs by including @c alarm.h. The definitions
40 * of APIs are defined as follows:
42 * @li @c #alarmmgr_init initialize alarm library
43 * @li @c #alarmmgr_set_cb set the callback for an alarm event
44 * @li @c #alarmmgr_create_alarm create an alarm entry
45 * @li @c #alarmmgr_free_alarm free an alarm entry
46 * @li @c #alarmmgr_set_time set a time will be expired
47 * @li @c #alarmmgr_get_time get a time will be expired
48 * @li @c #alarmmgr_set_repeat_mode set repeat mode
49 * @li @c #alarmmgr_get_repeat_mode get repeat mode
50 * @li @c #alarmmgr_set_type set type
51 * @li @c #alarmmgr_get_type get type
52 * @li @c #alarmmgr_add_alarm_with_localtime add an alarm with localtime
53 * @li @c #alarmmgr_add_alarm add an alarm
54 * @li @c #alarmmgr_remove_alarm remove an alarm from alarm server
55 * @li @c #alarmmgr_enum_alarm_ids get the list of alarm ids
56 * @li @c #alarmmgr_get_info get the information of an alarm
57 * @li @c #alarmmgr_fini de-initialize alarm library
60 * 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.
70 int callback(alarm_id_t alarm_id, void *user_param)
76 printf("Alarm[%d] has expired at %s\n", alarm_id, ctime(¤t_time));
84 alarm_entry_t* alarm_info;
87 alarm_date_t test_time;
91 printf("current time: %s\n", ctime(¤t_time));
92 localtime_r(¤t_time, ¤t_tm);
94 alarm_info = alarmmgr_create_alarm();
96 test_time.year = current_tm.tm_year+1900;
97 test_time.month = current_tm.tm_mon+1;
98 test_time.day = current_tm.tm_mday;
99 test_time.hour = current_tm.tm_hour;
100 test_time.min = current_tm.tm_min+1;
103 alarmmgr_set_time(alarm_info,test_time);
104 alarmmgr_set_repeat_mode(alarm_info,ALARM_REPEAT_MODE_WEEKLY,
106 ALARM_WDAY_TUESDAY|ALARM_WDAY_WEDNESDAY| \
107 ALARM_WDAY_THURSDAY|ALARM_WDAY_FRIDAY );
109 alarmmgr_set_type(alarm_info,ALARM_TYPE_VOLATILE);
110 alarmmgr_add_alarm_with_localtime(alarm_info,NULL,&alarm_id);
112 if(result != ALARMMGR_RESULT_SUCCESS)
113 printf("fail to alarmmgr_create : error_code : %d\n",result);
117 int main(int argc, char** argv)
124 mainloop = g_main_loop_new(NULL, FALSE);
125 result = alarmmgr_init("org.tizen.test");
127 if(result != ALARMMGR_RESULT_SUCCESS) {
128 printf("fail to alarmmgr_init : error_code : %d\n",result);
131 result = alarmmgr_set_cb(callback,NULL);
132 if(result != ALARMMGR_RESULT_SUCCESS) {
133 printf("fail to alarmmgr_set_cb : error_code :
140 g_main_loop_run(mainloop);
148 * @addtogroup AlarmManager
152 #include<sys/types.h>
160 * Type of an alarm id
162 typedef int alarm_id_t;
164 * The prototype of alarm handler.
165 * param [in] alarm_id the id of expired alarm
167 typedef int (*alarm_cb_t) (alarm_id_t alarm_id, void *user_param);
169 typedef int (*alarm_enum_fn_t) (alarm_id_t alarm_id, void *user_param);
172 * This enumeration has day of a week of alarm
175 ALARM_WDAY_SUNDAY = 0x01, /**< enalbe alarm on Sunday*/
176 ALARM_WDAY_MONDAY = 0x02, /**< enalbe alarm on Monday*/
177 ALARM_WDAY_TUESDAY = 0x04, /**< enable alarm on Tuesday*/
178 ALARM_WDAY_WEDNESDAY = 0x08, /**< enalbe alarm on Wednesday*/
179 ALARM_WDAY_THURSDAY = 0x10, /**< enable alarm on Thursday*/
180 ALARM_WDAY_FRIDAY = 0x20, /**< enable alarm on Friday*/
181 ALARM_WDAY_SATURDAY = 0x40,/**< enable alarm on Saturday*/
182 } alarm_day_of_week_t;
185 * This enumeration has error codes of alarm
188 ERR_ALARM_INVALID_PARAM = -10,
189 /**<Invalid parameter*/
190 ERR_ALARM_INVALID_ID, /**<Invalid id*/
191 ERR_ALARM_INVALID_REPEAT,
192 /**<Invalid repeat mode*/
193 ERR_ALARM_INVALID_TIME, /**<Invalid time. */
194 ERR_ALARM_INVALID_DATE, /**<Invalid date. */
195 ERR_ALARM_NO_SERVICE_NAME,
196 /**<there is no alarm service
197 for this applicaation. */
198 ERR_ALARM_INVALID_TYPE, /*Invalid type*/
199 ERR_ALARM_NO_PERMISSION, /*No permission*/
200 ERR_ALARM_SYSTEM_FAIL = -1,
201 ALARMMGR_RESULT_SUCCESS = 0,
205 * This enumeration has repeat mode of alarm
208 ALARM_REPEAT_MODE_ONCE = 0, /**<once : the alarm will be expired
210 ALARM_REPEAT_MODE_REPEAT, /**<repeat : the alarm will be expired
212 ALARM_REPEAT_MODE_WEEKLY, /**<weekly*/
213 ALARM_REPEAT_MODE_MONTHLY, /**< monthly*/
214 ALARM_REPEAT_MODE_ANNUALLY, /**< annually*/
215 ALARM_REPEAT_MODE_MAX,
216 } alarm_repeat_mode_t;
219 #define ALARM_TYPE_DEFAULT 0x0 /*< non volatile */
220 #define ALARM_TYPE_VOLATILE 0x02 /*< volatile */
221 #define ALARM_TYPE_NOLAUNCH 0x04 /*<without launch */
225 * This struct has date information
228 int year; /**< specifies the year */
229 int month; /**< specifies the month */
230 int day; /**< specifies the day */
231 int hour; /**< specifies the hour */
232 int min; /**< specifies the minute*/
233 int sec; /**< specifies the second*/
237 typedef struct alarm_info_t alarm_entry_t;
242 * This function initializes alarm library. It connects to system bus and registers the application's service name.
244 * @param [in] pkg_name a package of application
246 * @return On success, ALARMMGR_RESULT_SUCCESS is returned. On error, a negative number is returned
251 * @remark An application must call this function before using other alarm APIs.
258 int ret_val = ALARMMGR_RESULT_SUCCESS;
259 const char* pkg_name = "org.tizen.test";
263 ret_val =alarmmgr_init(pkg_name) ;
264 if(ret_val == ALARMMGR_RESULT_SUCCESS)
266 //alarmmgr_init() is successful
270 //alarmmgr_init () failed
276 int alarmmgr_init(const char *appid);
280 * This function de-initializes alarm library. It un-registers the application's service name and dis-connects from system bus.
286 * @pre Alarm manager is initialized
287 * @post Alarm manager is de-initialized
288 * @remark An application must call this function once it is done with alarmmanger usage
295 // Initialize alarmmanager
303 void alarmmgr_fini();
307 * This function registers handler which handles an alarm event. An application should register the alarm handler
308 * before it enters mainloop.
310 * @param [in] handler Callback function
311 * @param [in] user_param User Parameter
313 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
315 * @pre alarmmgr_init().
318 * @remark An application can have only one alarm handler. If an application
319 * calls this function more than one times, the handler regitered during the
320 * last call of this funiction will be called when an alarm event has occured.
326 // Call back function
327 int callback(alarm_id_t alarm_id,void* user_param)
332 printf("Alarm[%d] has expired at %s\n", alarm_id, ctime(¤t_time));
340 int ret_val = ALARMMGR_RESULT_SUCCESS;
341 void *user_param = NULL;
343 ret_val = alarmmgr_set_cb( callback, user_param);
344 if(ret_val == ALARMMGR_RESULT_SUCCESS)
346 //alarmmgr_set_cb() is successful
350 //alarmmgr_set_cb () failed
357 int alarmmgr_set_cb(alarm_cb_t handler, void *user_param);
361 * This function creates a new alarm entry, will not be known to the server until alarmmgr_add_alarm is called.
363 * @return This function returns the pointer of alarm_entry_t
368 * @remark After an application use this object, an application free this pointer through alarmmgr_free_alarm
376 alarm_entry_t* alarm;
378 alarm = alarmmgr_create_alarm() ;
381 //alarmmgr_create_alarm() is successful
385 //alarmmgr_create_alarm () failed
393 alarm_entry_t *alarmmgr_create_alarm(void);
397 * This function frees an alarm entry.
399 * @param [in] alarm alarm entry
401 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
414 int ret_val = ALARMMGR_RESULT_SUCCESS;
415 alarm_entry_t* alarm;
417 alarm = alarmmgr_create_alarm() ;
420 //alarmmgr_create_alarm () failed
425 ret_val = alarmmgr_free_alarm( alarm) ;
426 if(ret_val == ALARMMGR_RESULT_SUCCESS)
428 //alarmmgr_free_alarm() is successful
432 //alarmmgr_free_alarm() failed
440 int alarmmgr_free_alarm(alarm_entry_t *alarm);
444 * This function sets time that alarm should be expried.
446 * @param [in] alarm alarm entry
447 * @param [in] time time the alarm should first go off
449 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
462 int ret_val = ALARMMGR_RESULT_SUCCESS;
463 alarm_entry_t* alarm;
465 struct tm current_tm;
466 alarm_date_t test_time;
470 localtime_r(¤t_time, ¤t_tm);
472 alarm = alarmmgr_create_alarm();
475 //alarmmgr_create_alarm () failed
478 test_time.year = current_tm.tm_year;
479 test_time.month = current_tm.tm_mon;
480 test_time.day = current_tm.tm_mday;
482 test_time.hour = current_tm.tm_hour;
483 test_time.min = current_tm.tm_min+1;
486 ret_val=alarmmgr_set_time(alarm,test_time);
487 if(ret_val == ALARMMGR_RESULT_SUCCESS)
489 //alarmmgr_set_time() is successful
493 //alarmmgr_set_time() failed
495 alarmmgr_free_alarm( alarm) ;
502 int alarmmgr_set_time(alarm_entry_t *alarm, alarm_date_t time);
505 * This function gives an application time that alarm should be expried.
507 * @param [in] alarm alarm entry
508 * @param [out] time time the alarm should first go off
510 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
515 * @remark But an application does not need to specify year, month, and day field of alarm_info. If an application sets
516 * those fields with zero, the function sets them with proper values.
524 int ret_val = ALARMMGR_RESULT_SUCCESS;
525 alarm_entry_t* alarm;
528 struct tm current_tm;
529 alarm_date_t test_time;
530 alarm_date_t new_time;
534 localtime_r(¤t_time, ¤t_tm);
536 alarm = alarmmgr_create_alarm();
538 //alarmmgr_create_alarm () failed
541 test_time.year = current_tm.tm_year;
542 test_time.month = current_tm.tm_mon;
543 test_time.day = current_tm.tm_mday;
545 test_time.hour = current_tm.tm_hour;
546 test_time.min = current_tm.tm_min+1;
549 ret_val = alarmmgr_set_time(alarm,test_time);
550 if(ret_val == ALARMMGR_RESULT_SUCCESS) {
551 //alarmmgr_set_time() is successful
554 //alarmmgr_set_time() failed
557 ret_val = alarmmgr_get_time(alarm, &new_time);
558 if(ret_val == ALARMMGR_RESULT_SUCCESS) {
559 //alarmmgr_get_time() is successful
562 //alarmmgr_get_time() failed
564 alarmmgr_free_alarm( alarm) ;
571 int alarmmgr_get_time(const alarm_entry_t *alarm, alarm_date_t *time);
574 * This function sets an alarm repeat mode
576 * @param [in] alarm alarm entry
577 * @param [in] repeat_mode one of ALARM_REPEAT_MODE_ONCE, ALARM_REPEAT_MODE_REPEAT,
578 * ALARM_REPEAT_MODE_WEEKLY, ALARM_REPEAT_MODE_MONTHLY or ALARM_REPEAT_MODE_ANNUALLY.
579 * @param [in] repeat_value the ALARM_REPEAT_MODE_REPEAT mode : interval between subsequent repeats of the alarm.
580 * the ALARM_REPEAT_MODE_WEEKLY mode : days of a week
581 * (ALARM_WDAY_SUNDAY, ALARM_WDAY_MONDAY, ALARM_WDAY_TUESDAY, ALARM_WDAY_WEDNESDAY,
582 * ALARM_WDAY_THURSDAY, ALARM_WDAY_FRIDAY, ALARM_WDAY_SATURDAY)
583 * the others : this parameter is ignored.
585 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
598 int ret_val = ALARMMGR_RESULT_SUCCESS;
599 alarm_entry_t* alarm;
600 alarm_repeat_mode_t repeat_mode =ALARM_REPEAT_MODE_WEEKLY;
601 int interval = ALARM_WDAY_MONDAY; //| ALARM_WDAY_TUESDAY|
602 ALARM_WDAY_WEDNESDAY| ALARM_WDAY_THURSDAY|ALARM_WDAY_FRIDAY ;
605 alarm = alarmmgr_create_alarm();
608 //alarmmgr_create_alarm () failed
612 ret_val = alarmmgr_set_repeat_mode
613 (alarm, repeat_mode,interval);
615 if(ret_val == ALARMMGR_RESULT_SUCCESS)
617 //alarmmgr_set_repeat_mode() is successful
621 //alarmmgr_set_repeat_mode() failed
623 alarmmgr_free_alarm( alarm) ;
630 int alarmmgr_set_repeat_mode(alarm_entry_t *alarm,
631 alarm_repeat_mode_t repeat_mode,
635 * This function gives an application an alarm mode
637 * @param [in] alarm alarm entry
638 * @param [out] repeat_mode one of ALARM_REPEAT_MODE_ONCE, ALARM_REPEAT_MODE_REPEAT,
639 * ALARM_REPEAT_MODE_WEEKLY, ALARM_REPEAT_MODE_MONTHLY or ALARM_REPEAT_MODE_ANNUALLY.
640 * @param [out] repeat_value the ALARM_REPEAT_MODE_REPEAT mode : interval between subsequent repeats of the alarm.
641 * the ALARM_REPEAT_MODE_WEEKLY mode : days of a week
642 * (ALARM_WDAY_SUNDAY, ALARM_WDAY_MONDAY, ALARM_WDAY_TUESDAY, ALARM_WDAY_WEDNESDAY,
643 * ALARM_WDAY_THURSDAY, ALARM_WDAY_FRIDAY, ALARM_WDAY_SATURDAY)
644 * the others : this parameter is ignored.
646 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
659 int ret_val = ALARMMGR_RESULT_SUCCESS;
660 alarm_entry_t* alarm;
661 alarm_repeat_mode_t repeat;
664 alarm = alarmmgr_create_alarm();
667 //alarmmgr_create_alarm () failed
670 ret_val =alarmmgr_get_repeat_mode
671 (alarm, &repeat, &interval) ;
672 if(ret_val == ALARMMGR_RESULT_SUCCESS
673 && repeat == ALARM_REPEAT_MODE_ONCE) {
674 //alarmmgr_get_repeat_mode() is successful
677 //alarmmgr_get_repeat_mode() failed
679 alarmmgr_free_alarm(alarm) ;
686 int alarmmgr_get_repeat_mode(const alarm_entry_t *alarm,
687 alarm_repeat_mode_t *repeat_mode,
691 * This function sets an alarm mode
693 * @param [in] alarm alarm entry
694 * @param [in] alarm_type one of ALARM_TYPE_DEFAULT : After the device reboot, the alarm still works.
695 * ALARM_TYPE_VOLATILE : After the device reboot, the alarm does not work.
697 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
710 int ret_val = ALARMMGR_RESULT_SUCCESS;
711 alarm_entry_t* alarm;
712 int alarm_type = ALARM_TYPE_VOLATILE;
714 alarm = alarmmgr_create_alarm();
717 //alarmmgr_create_alarm () failed
721 ret_val = alarmmgr_set_type(alarm, alarm_type);
722 if(ret_val == ALARMMGR_RESULT_SUCCESS)
724 //alarmmgr_set_type() is successful
728 //alarmmgr_set_type() failed
730 alarmmgr_free_alarm( alarm) ;
737 int alarmmgr_set_type(alarm_entry_t *alarm, int alarm_type);
740 * This function gives an application an alarm mode
742 * @param [in] alarm alarm entry
743 * @param [out] alarm_type one of ALARM_TYPE_DEFAULT, ALARM_TYPE_VOLATILE
745 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
758 int ret_val = ALARMMGR_RESULT_SUCCESS;
759 alarm_entry_t* alarm;
762 alarm = alarmmgr_create_alarm();
764 //alarmmgr_create_alarm () failed
767 ret_val = alarmmgr_get_type( alarm, &alarm_type);
768 if(ret_val == ALARMMGR_RESULT_SUCCESS && alarm_type
769 == ALARM_TYPE_DEFAULT ) {
770 //alarmmgr_get_type() is successful
773 //alarmmgr_get_type() failed
775 alarmmgr_free_alarm( alarm) ;
782 int alarmmgr_get_type(const alarm_entry_t *alarm, int *alarm_type);
785 * This function adds an alarm entry to the server.
786 * Server will remember this entry, and generate alarm events for it when necessary.
787 * Server will call app-svc interface to sent notification to destination application. Destination information
788 * should be available in the input bundle.
789 * Alarm entries registered with the server cannot be changed.
790 * Remove from server before changing.
791 * Before the application calls alarmmgr_add_alarm_appsvc_with_localtime(), the application have to call alarmmgr_set_time().
792 * The time set is localtime.
793 * If the application does not call alarmmgr_set_repeat_mode, the default repeat_mode is ALARM_REPEAT_MODE_ONCE.
794 * If the application does not call alarmmgr_set_type, the default alarm_type is ALARM_TYPE_DEFAULT.
795 * The id of the new alarm will be copied to alarm_id if the fuction successes to create an alarm.
797 * @param [in] alarm the entry of an alarm to be created.
798 * @param [in] bundle_data bundle which contains information about the destination.
799 * @param [out] alarm_id the id of the alarm added.
801 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
805 * @see alarmmgr_add_alarm
815 struct tm current_tm;
816 alarm_entry_t* alarm_info;
819 alarm_date_t test_time;
828 printf("Unable to create bundle!!!\n");
832 appsvc_set_operation(b,APPSVC_OPERATION_DEFAULT);
833 appsvc_set_pkgname(b,"org.tizen.alarm-test");
837 printf("current time: %s\n", ctime(¤t_time));
838 localtime_r(¤t_time, ¤t_tm);
840 alarm_info = alarmmgr_create_alarm();
842 test_time.year = current_tm.tm_year;
843 test_time.month = current_tm.tm_mon;
844 test_time.day = current_tm.tm_mday;
846 test_time.hour = current_tm.tm_hour;
847 test_time.min = current_tm.tm_min+1;
851 alarmmgr_set_time(alarm_info,test_time);
852 alarmmgr_set_repeat_mode(alarm_info,ALARM_REPEAT_MODE_WEEKLY,ALARM_WDAY_MONDAY| \
853 ALARM_WDAY_TUESDAY|ALARM_WDAY_WEDNESDAY| \
854 ALARM_WDAY_THURSDAY|ALARM_WDAY_FRIDAY );
856 alarmmgr_set_type(alarm_info, ALARM_TYPE_DEFAULT);
857 //alarmmgr_set_type(alarm_info,ALARM_TYPE_VOLATILE);
858 if ((result = alarmmgr_add_alarm_appsvc_with_localtime(alarm_info,(void *)b,&alarm_id)) < 0)
860 printf("Alarm creation failed!!! Alrmgr error code is %d\n",result);
864 printf("Alarm created succesfully with alarm id %d\n",alarm_id);
871 int alarmmgr_add_alarm_appsvc_with_localtime(alarm_entry_t *alarm,void *bundle_data, alarm_id_t *alarm_id);
874 * This function adds an alarm entry to the server.
875 * Server will remember this entry, and generate alarm events for it when necessary.
876 * Alarm entries registered with the server cannot be changed.
877 * Remove from server before changing.
878 * Before the application calls alarmmgr_add_alarm_with_localtime(), the application have to call alarmmgr_set_time().
879 * The time set is localtime.
880 * If the application does not call alarmmgr_set_repeat_mode, the default repeat_mode is ALARM_REPEAT_MODE_ONCE.
881 * If the application does not call alarmmgr_set_type, the default alarm_type is ALARM_TYPE_DEFAULT.
882 * The id of the new alarm will be copied to alarm_id if the fuction successes to create an alarm.
884 * @param [in] alarm the entry of an alarm to be created.
885 * @param [in] destination the packname of application that the alarm will be expired.
886 * @param [out] alarm_id the id of the alarm added.
888 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
892 * @see alarmmgr_add_alarm
901 int ret_val = ALARMMGR_RESULT_SUCCESS;
902 alarm_entry_t* alarm;
903 const char* destination = NULL;
907 struct tm current_tm;
908 alarm_date_t test_time;
910 const char* pkg_name = "org.tizen.test";
914 ret_val =alarmmgr_init(pkg_name) ;
915 if(ret_val != ALARMMGR_RESULT_SUCCESS) {
916 //alarmmgr_init () failed
922 printf("current time: %s\n", ctime(¤t_time));
923 localtime_r(¤t_time, ¤t_tm);
925 alarm = alarmmgr_create_alarm();
928 test_time.month = 0;test_time.day = 0;
930 test_time.hour = current_tm.tm_hour;
931 test_time.min = current_tm.tm_min+1;
935 alarmmgr_set_time(alarm,test_time);
936 alarmmgr_set_repeat_mode(alarm,ALARM_REPEAT_MODE_WEEKLY, \
938 alarmmgr_set_type(alarm,ALARM_TYPE_VOLATILE);
941 ret_val=alarmmgr_add_alarm_with_localtime(alarm,destination,&alarm_id);
943 if(ret_val == ALARMMGR_RESULT_SUCCESS)
945 //alarmmgr_add_alarm_with_localtime() is successful
949 //alarmmgr_add_alarm_with_localtime() failed
951 alarmmgr_free_alarm( alarm) ;
956 int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm,
957 const char *destination,
958 alarm_id_t *alarm_id);
962 * This function adds an alarm entry to the server.
963 * Server will remember this entry, and generate alarm events for it when necessary.
964 * Server will call app-svc interface to sent notification to destination application. Destination information
965 * should be available in the input bundle.
966 * Alarm entries registered with the server cannot be changed.
967 * Remove from server before changing.
968 * After the trigger_at_time seconds from now, the alarm will be expired.
969 * If the interval is zero, the repeat_mode is ALARM_REPEAT_MODE_ONCE.
970 * If the interval is >0, the repeat_mode is ALARM_REPEAT_MODE_REPEAT.
971 * The id of the new alarm will be copied to alarm_id if the fuction successes to create an alarm.
973 * @param [in] alarm_type one of ALARM_TYPE_DEFAULT, ALARM_TYPE_VOLATILE
974 * @param [in] trigger_at_time time interval to be triggered from now(sec). an alarm also will be expired at triggering time.
975 * @param [in] interval Interval between subsequent repeats of the alarm
976 * @param [in] bundle_data bundle which contains information about the destination.
977 * @param [out] alarm_id the id of the alarm added.
979 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
983 * @see alarmmgr_add_alarm_with_localtime alarmmgr_remove_alarm
1001 printf("Unable to create bundle!!!\n");
1005 appsvc_set_pkgname(b,"org.tizen.alarm-test");
1006 //appsvc_set_operation(b,APPSVC_OPERATION_SEND_TEXT);
1007 appsvc_set_operation(b,APPSVC_OPERATION_DEFAULT);
1009 if ((result = alarmmgr_add_alarm_appsvc(ALARM_TYPE_DEFAULT, 10, 0, (void *)b ,&alarm_id)))
1010 printf("Unable to add alarm. Alarmmgr alarm no is %d\n", result);
1012 printf("Alarm added successfully. Alarm Id is %d\n", alarm_id);
1020 int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time,
1021 time_t interval, void *bundle_data,
1022 alarm_id_t *alarm_id);
1026 * This function adds an alarm entry to the server.
1027 * Server will remember this entry, and generate alarm events for it when necessary.
1028 * Alarm entries registered with the server cannot be changed.
1029 * Remove from server before changing.
1030 * After the trigger_at_time seconds from now, the alarm will be expired.
1031 * If the interval is zero, the repeat_mode is ALARM_REPEAT_MODE_ONCE.
1032 * If the interval is >0, the repeat_mode is ALARM_REPEAT_MODE_REPEAT.
1033 * The id of the new alarm will be copied to alarm_id if the fuction successes to create an alarm.
1035 * @param [in] alarm_type one of ALARM_TYPE_DEFAULT, ALARM_TYPE_VOLATILE
1036 * @param [in] trigger_at_time time interval to be triggered from now(sec). an alarm also will be expired at triggering time.
1037 * @param [in] interval Interval between subsequent repeats of the alarm
1038 * @param [in] destination the packname of application that the alarm will be expired.
1039 * @param [out] alarm_id the id of the alarm added.
1041 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
1045 * @see alarmmgr_add_alarm_with_localtime alarmmgr_remove_alarm
1054 int ret_val = ALARMMGR_RESULT_SUCCESS;
1056 int alarm_type = ALARM_TYPE_VOLATILE;
1057 time_t trigger_at_time = 10;
1058 time_t interval = 10;
1059 const char* destination = NULL;
1060 alarm_id_t alarm_id;
1062 const char* pkg_name = "org.tizen.test";
1066 ret_val =alarmmgr_init(pkg_name) ;
1067 if(ret_val != ALARMMGR_RESULT_SUCCESS)
1069 //alarmmgr_init () failed
1073 ret_val = alarmmgr_add_alarm( alarm_type, trigger_at_time, interval,
1074 destination, &alarm_id);
1075 if(ret_val == ALARMMGR_RESULT_SUCCESS)
1077 //alarmmgr_add_alarm() is successful
1081 //alarmmgr_add_alarm() failed
1083 alarmmgr_remove_alarm( alarm_id) ;
1089 int alarmmgr_add_alarm(int alarm_type, time_t trigger_at_time,
1090 time_t interval, const char *destination,
1091 alarm_id_t *alarm_id);
1094 * This function deletes the alarm associated with the given alarm_id.
1096 * @param [in] alarm_id Specifies the ID of the alarm to be deleted.
1098 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
1102 * @see alarmmgr_add_alarm_with_localtime alarmmgr_add_alarm
1111 int ret_val = ALARMMGR_RESULT_SUCCESS;
1112 int alarm_type = ALARM_TYPE_VOLATILE;
1113 time_t trigger_at_time = 10;
1114 time_t interval = 10;
1115 const char* destination = NULL;
1116 alarm_id_t alarm_id;
1118 const char* pkg_name = "org.tizen.test";
1122 ret_val =alarmmgr_init(pkg_name) ;
1123 if(ret_val != ALARMMGR_RESULT_SUCCESS) {
1124 //alarmmgr_init () failed
1128 alarmmgr_add_alarm( alarm_type, trigger_at_time, interval,
1129 destination, &alarm_id);
1131 ret_val =alarmmgr_remove_alarm( alarm_id) ;
1132 if(ret_val == ALARMMGR_RESULT_SUCCESS) {
1133 /alarmmgr_remove_alarm() is successful
1136 //alarmmgr_remove_alarm() failed
1143 int alarmmgr_remove_alarm(alarm_id_t alarm_id);
1146 * This function deletes all registered alarms
1148 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
1150 int alarmmgr_remove_all(void);
1153 * This function gives a list of alarm ids that the application adds to the server.
1155 * @param [in] fn a user callback function
1156 * @param [in] user_param user parameter
1158 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
1162 * @see alarm_get_info
1169 int callback_2(alarm_id_t id, void* user_param)
1171 int* n = (int*)user_param;
1172 printf("[%d]alarm id : %d\n",*n,id);
1179 int ret_val = ALARMMGR_RESULT_SUCCESS;
1182 const char* pkg_name = "org.tizen.test";
1186 ret_val =alarmmgr_init(pkg_name) ;
1187 if(ret_val != ALARMMGR_RESULT_SUCCESS)
1189 //alarmmgr_init() failed
1193 ret_val = alarmmgr_enum_alarm_ids( callback_2, (void*)&n) ;
1194 if(ret_val == ALARMMGR_RESULT_SUCCESS)
1196 //alarmmgr_enum_alarm_ids() is successful
1200 //alarmmgr_enum_alarm_ids() failed
1207 int alarmmgr_enum_alarm_ids(alarm_enum_fn_t fn, void *user_param);
1211 * This function gets the information of the alarm assosiated with alarm_id to alarm_info. The application
1212 * must allocate alarm_info before calling this function.
1214 * @param [in] alarm_id the id of the alarm
1215 * @param [out] alarm the buffer alarm informaiton will be copied to
1217 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
1221 * @see alarmmgr_enum_alarm_ids
1230 int ret_val = ALARMMGR_RESULT_SUCCESS;
1231 int alarm_type = ALARM_TYPE_VOLATILE;
1232 time_t trigger_at_time = 10;
1233 time_t interval = ALARM_WDAY_SUNDAY;
1234 const char* destination = NULL;
1235 alarm_id_t alarm_id;
1237 alarm_entry_t *alarm;
1239 const char* pkg_name = "org.tizen.test_get_info1";
1243 ret_val =alarmmgr_init(pkg_name) ;
1244 if(ret_val != ALARMMGR_RESULT_SUCCESS) {
1245 //alarmmgr_init() failed
1248 ret_val = alarmmgr_add_alarm( alarm_type,trigger_at_time,interval,
1249 destination, &alarm_id);
1251 if(ret_val != ALARMMGR_RESULT_SUCCESS) {
1252 //alarmmgr_add_alarm() failed
1255 ret_val = alarmmgr_get_info(alarm_id, alarm);
1256 if(ret_val == ALARMMGR_RESULT_SUCCESS) {
1257 //alarmmgr_get_info() is successful
1260 //alarmmgr_get_info() failed
1262 alarmmgr_remove_alarm( alarm_id) ;
1267 int alarmmgr_get_info(alarm_id_t alarm_id, alarm_entry_t *alarm);
1271 * This function retrieves bundle associated with alarm.
1272 * Server will remember this entry, and pass the bundle information upon alarm expiry.
1273 * Server will call app-svc interface to sent notification to destination application. Destination information
1274 * should be available in the input bundle.
1275 * @param [in] alarm_id alarm id
1276 * @param [out] ALARMMGR_RESULT_SUCCESS on success or negative number on failure.
1278 * @return This function returns bundle on success or NULL on failure.
1291 alarm_id_t alarm_id;
1300 printf("Unable to create bundle!!!\n");
1304 appsvc_set_pkgname(b,"org.tizen.alarm-test");
1305 appsvc_set_operation(b,APPSVC_OPERATION_DEFAULT);
1307 if ((result = alarmmgr_add_alarm_appsvc(ALARM_TYPE_DEFAULT, 10, 0, (void *)b ,&alarm_id)))
1308 printf("Unable to add alarm. Alarmmgr alarm no is %d\n", result);
1310 printf("Alarm added successfully. Alarm Id is %d\n", alarm_id);
1312 int main(int argc,char **argv {
1315 int return_code = 0;
1317 b = alarmmgr_get_alarm_appsvc_info(alarm_id, &return_code);
1319 const char *pkgname = appsvc_get_pkgname(b);
1321 printf("Package name is %s\n",pkgname);
1331 void *alarmmgr_get_alarm_appsvc_info(alarm_id_t alarm_id, int *return_code);
1334 * This function gets the scheduled time of the alarm assosiated with alarm_id.
1336 * @param [in] alarm_id the id of the alarm
1337 * @param [out] duetime the scheduled time of the alarm
1339 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
1346 int alarmmgr_get_next_duetime(alarm_id_t alarm_id, time_t* duetime);
1349 * This function sets power RTC (which can power on the system).
1350 * @param [in] alarm_date_t time
1352 * @return This function returns the result. On success, ALARMMGR_RESULT_SUCCESS will be returned
1353 * else, appropriate error no will be returned.
1365 alarm_date_t alarm_date={2012,04,05,10,10,00};
1367 int main(int argc,char **argv {
1368 int return_code = 0;
1369 return_code = alarmmgr_set_rtc_time(&alarm_date);
1370 if (return_code != ALARMMGR_RESULT_SUCCESS){
1371 printf("Error returned is %d\n",return_code);
1379 int alarmmgr_set_rtc_time(alarm_date_t *time);
1381 int alarmmgr_add_alarm_withcb(int alarm_type, time_t trigger_at_time,
1382 time_t interval, alarm_cb_t handler, void *user_param, alarm_id_t *alarm_id);
1394 int alarmmgr_power_on(bool on_off);
1401 #endif/* ALARM_LIB_H*/