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 Alarm Alarm
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
59 * 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.
69 int callback(alarm_id_t alarm_id, void *user_param)
75 printf("Alarm[%d] has expired at %s\n", alarm_id, ctime(¤t_time));
83 alarm_entry_t* alarm_info;
86 alarm_date_t test_time;
90 printf("current time: %s\n", ctime(¤t_time));
91 localtime_r(¤t_time, ¤t_tm);
93 alarm_info = alarmmgr_create_alarm();
95 test_time.year = current_tm.tm_year+1900;
96 test_time.month = current_tm.tm_mon+1;
97 test_time.day = current_tm.tm_mday;
98 test_time.hour = current_tm.tm_hour;
99 test_time.min = current_tm.tm_min+1;
102 alarmmgr_set_time(alarm_info,test_time);
103 alarmmgr_set_repeat_mode(alarm_info,ALARM_REPEAT_MODE_WEEKLY,
105 ALARM_WDAY_TUESDAY|ALARM_WDAY_WEDNESDAY| \
106 ALARM_WDAY_THURSDAY|ALARM_WDAY_FRIDAY );
108 alarmmgr_set_type(alarm_info,ALARM_TYPE_VOLATILE);
109 alarmmgr_add_alarm_with_localtime(alarm_info,NULL,&alarm_id);
111 if(result != ALARMMGR_RESULT_SUCCESS)
112 printf("fail to alarmmgr_create : error_code : %d\n",result);
116 int main(int argc, char** argv)
123 mainloop = g_main_loop_new(NULL, FALSE);
124 result = alarmmgr_init("org.tizen.test");
126 if(result != ALARMMGR_RESULT_SUCCESS) {
127 printf("fail to alarmmgr_init : error_code : %d\n",result);
130 result = alarmmgr_set_cb(callback,NULL);
131 if(result != ALARMMGR_RESULT_SUCCESS) {
132 printf("fail to alarmmgr_set_cb : error_code :
139 g_main_loop_run(mainloop);
151 #include<sys/types.h>
159 * Type of an alarm id
161 typedef int alarm_id_t;
163 * The prototype of alarm handler.
164 * param [in] alarm_id the id of expired alarm
166 typedef int (*alarm_cb_t) (alarm_id_t alarm_id, void *user_param);
168 typedef int (*alarm_enum_fn_t) (alarm_id_t alarm_id, void *user_param);
171 * This enumeration has day of a week of alarm
174 ALARM_WDAY_SUNDAY = 0x01, /**< enalbe alarm on Sunday*/
175 ALARM_WDAY_MONDAY = 0x02, /**< enalbe alarm on Monday*/
176 ALARM_WDAY_TUESDAY = 0x04, /**< enable alarm on Tuesday*/
177 ALARM_WDAY_WEDNESDAY = 0x08, /**< enalbe alarm on Wednesday*/
178 ALARM_WDAY_THURSDAY = 0x10, /**< enable alarm on Thursday*/
179 ALARM_WDAY_FRIDAY = 0x20, /**< enable alarm on Friday*/
180 ALARM_WDAY_SATURDAY = 0x40,/**< enable alarm on Saturday*/
181 } alarm_day_of_week_t;
184 * This enumeration has error codes of alarm
187 ERR_ALARM_INVALID_PARAM = -10,
188 /**<Invalid parameter*/
189 ERR_ALARM_INVALID_ID, /**<Invalid id*/
190 ERR_ALARM_INVALID_REPEAT,
191 /**<Invalid repeat mode*/
192 ERR_ALARM_INVALID_TIME, /**<Invalid time. */
193 ERR_ALARM_INVALID_DATE, /**<Invalid date. */
194 ERR_ALARM_NO_SERVICE_NAME,
195 /**<there is no alarm service
196 for this applicaation. */
197 ERR_ALARM_SYSTEM_FAIL = -1,
198 ALARMMGR_RESULT_SUCCESS = 0,
202 * This enumeration has repeat mode of alarm
205 ALARM_REPEAT_MODE_ONCE = 0, /**<once : the alarm will be expired
207 ALARM_REPEAT_MODE_REPEAT, /**<repeat : the alarm will be expired
209 ALARM_REPEAT_MODE_WEEKLY, /**<weekly*/
210 ALARM_REPEAT_MODE_MONTHLY, /**< monthly*/
211 ALARM_REPEAT_MODE_ANNUALLY, /**< annually*/
212 ALARM_REPEAT_MODE_MAX,
213 } alarm_repeat_mode_t;
216 #define ALARM_TYPE_DEFAULT 0x0 /*< non volatile */
217 #define ALARM_TYPE_VOLATILE 0x02 /*< volatile */
221 * This struct has date information
224 int year; /**< specifies the year */
225 int month; /**< specifies the month */
226 int day; /**< specifies the day */
227 int hour; /**< specifies the hour */
228 int min; /**< specifies the minute*/
229 int sec; /**< specifies the second*/
233 typedef struct alarm_info_t alarm_entry_t;
238 * This function initializes alarm library. It connects to system bus and registers the application's service name.
240 * @param [in] pkg_name a package of application
242 * @return On success, ALARMMGR_RESULT_SUCCESS is returned. On error, a negative number is returned
247 * @remark An application must call this function before using other alarm APIs.
254 int ret_val = ALARMMGR_RESULT_SUCCESS;
255 const char* pkg_name = "org.tizen.test";
259 ret_val =alarmmgr_init(pkg_name) ;
260 if(ret_val == ALARMMGR_RESULT_SUCCESS)
262 //alarmmgr_init() is successful
266 //alarmmgr_init () failed
272 int alarmmgr_init(const char *pkg_name);
274 void alarmmgr_fini();
278 * This function registers handler which handles an alarm event. An application should register the alarm handler
279 * before it enters mainloop.
281 * @param [in] handler Callback function
282 * @param [in] user_param User Parameter
284 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
286 * @pre alarmmgr_init().
289 * @remark An application can have only one alarm handler. If an application
290 * calls this function more than one times, the handler regitered during the
291 * last call of this funiction will be called when an alarm event has occured.
297 // Call back function
298 int callback(alarm_id_t alarm_id,void* user_param)
303 printf("Alarm[%d] has expired at %s\n", alarm_id, ctime(¤t_time));
311 int ret_val = ALARMMGR_RESULT_SUCCESS;
312 void *user_param = NULL;
314 ret_val = alarmmgr_set_cb( callback, user_param);
315 if(ret_val == ALARMMGR_RESULT_SUCCESS)
317 //alarmmgr_set_cb() is successful
321 //alarmmgr_set_cb () failed
328 int alarmmgr_set_cb(alarm_cb_t handler, void *user_param);
332 * This function creates a new alarm entry, will not be known to the server until alarmmgr_add_alarm is called.
334 * @return This function returns the pointer of alarm_entry_t
339 * @remark After an application use this object, an application free this pointer through alarmmgr_free_alarm
347 alarm_entry_t* alarm;
349 alarm = alarmmgr_create_alarm() ;
352 //alarmmgr_create_alarm() is successful
356 //alarmmgr_create_alarm () failed
364 alarm_entry_t *alarmmgr_create_alarm(void);
368 * This function frees an alarm entry.
370 * @param [in] alarm alarm entry
372 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
385 int ret_val = ALARMMGR_RESULT_SUCCESS;
386 alarm_entry_t* alarm;
388 alarm = alarmmgr_create_alarm() ;
391 //alarmmgr_create_alarm () failed
396 ret_val = alarmmgr_free_alarm( alarm) ;
397 if(ret_val == ALARMMGR_RESULT_SUCCESS)
399 //alarmmgr_free_alarm() is successful
403 //alarmmgr_free_alarm() failed
411 int alarmmgr_free_alarm(alarm_entry_t *alarm);
415 * This function sets time that alarm should be expried.
417 * @param [in] alarm alarm entry
418 * @param [in] time time the alarm should first go off
420 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
433 int ret_val = ALARMMGR_RESULT_SUCCESS;
434 alarm_entry_t* alarm;
436 struct tm current_tm;
437 alarm_date_t test_time;
441 localtime_r(¤t_time, ¤t_tm);
443 alarm = alarmmgr_create_alarm();
446 //alarmmgr_create_alarm () failed
449 test_time.year = current_tm.tm_year;
450 test_time.month = current_tm.tm_mon;
451 test_time.day = current_tm.tm_mday;
453 test_time.hour = current_tm.tm_hour;
454 test_time.min = current_tm.tm_min+1;
457 ret_val=alarmmgr_set_time(alarm,test_time);
458 if(ret_val == ALARMMGR_RESULT_SUCCESS)
460 //alarmmgr_set_time() is successful
464 //alarmmgr_set_time() failed
466 alarmmgr_free_alarm( alarm) ;
473 int alarmmgr_set_time(alarm_entry_t *alarm, alarm_date_t time);
476 * This function gives an application time that alarm should be expried.
478 * @param [in] alarm alarm entry
479 * @param [out] time time the alarm should first go off
481 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
486 * @remark But an application does not need to specify year, month, and day field of alarm_info. If an application sets
487 * those fields with zero, the function sets them with proper values.
495 int ret_val = ALARMMGR_RESULT_SUCCESS;
496 alarm_entry_t* alarm;
499 struct tm current_tm;
500 alarm_date_t test_time;
501 alarm_date_t new_time;
505 localtime_r(¤t_time, ¤t_tm);
507 alarm = alarmmgr_create_alarm();
509 //alarmmgr_create_alarm () failed
512 test_time.year = current_tm.tm_year;
513 test_time.month = current_tm.tm_mon;
514 test_time.day = current_tm.tm_mday;
516 test_time.hour = current_tm.tm_hour;
517 test_time.min = current_tm.tm_min+1;
520 ret_val = alarmmgr_set_time(alarm,test_time);
521 if(ret_val == ALARMMGR_RESULT_SUCCESS) {
522 //alarmmgr_set_time() is successful
525 //alarmmgr_set_time() failed
528 ret_val = alarmmgr_get_time(alarm, &new_time);
529 if(ret_val == ALARMMGR_RESULT_SUCCESS) {
530 //alarmmgr_get_time() is successful
533 //alarmmgr_get_time() failed
535 alarmmgr_free_alarm( alarm) ;
542 int alarmmgr_get_time(const alarm_entry_t *alarm, alarm_date_t *time);
545 * This function sets an alarm repeat mode
547 * @param [in] alarm alarm entry
548 * @param [in] repeat_mode one of ALARM_REPEAT_MODE_ONCE, ALARM_REPEAT_MODE_REPEAT,
549 * ALARM_REPEAT_MODE_WEEKLY, ALARM_REPEAT_MODE_MONTHLY or ALARM_REPEAT_MODE_ANNUALLY.
550 * @param [in] repeat_value the ALARM_REPEAT_MODE_REPEAT mode : interval between subsequent repeats of the alarm.
551 * the ALARM_REPEAT_MODE_WEEKLY mode : days of a week
552 * (ALARM_WDAY_SUNDAY, ALARM_WDAY_MONDAY, ALARM_WDAY_TUESDAY, ALARM_WDAY_WEDNESDAY,
553 * ALARM_WDAY_THURSDAY, ALARM_WDAY_FRIDAY, ALARM_WDAY_SATURDAY)
554 * the others : this parameter is ignored.
556 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
569 int ret_val = ALARMMGR_RESULT_SUCCESS;
570 alarm_entry_t* alarm;
571 alarm_repeat_mode_t repeat_mode =ALARM_REPEAT_MODE_WEEKLY;
572 int interval = ALARM_WDAY_MONDAY; //| ALARM_WDAY_TUESDAY|
573 ALARM_WDAY_WEDNESDAY| ALARM_WDAY_THURSDAY|ALARM_WDAY_FRIDAY ;
576 alarm = alarmmgr_create_alarm();
579 //alarmmgr_create_alarm () failed
583 ret_val = alarmmgr_set_repeat_mode
584 (alarm, repeat_mode,interval);
586 if(ret_val == ALARMMGR_RESULT_SUCCESS)
588 //alarmmgr_set_repeat_mode() is successful
592 //alarmmgr_set_repeat_mode() failed
594 alarmmgr_free_alarm( alarm) ;
601 int alarmmgr_set_repeat_mode(alarm_entry_t *alarm,
602 alarm_repeat_mode_t repeat_mode,
606 * This function gives an application an alarm mode
608 * @param [in] alarm alarm entry
609 * @param [out] repeat_mode one of ALARM_REPEAT_MODE_ONCE, ALARM_REPEAT_MODE_REPEAT,
610 * ALARM_REPEAT_MODE_WEEKLY, ALARM_REPEAT_MODE_MONTHLY or ALARM_REPEAT_MODE_ANNUALLY.
611 * @param [out] repeat_value the ALARM_REPEAT_MODE_REPEAT mode : interval between subsequent repeats of the alarm.
612 * the ALARM_REPEAT_MODE_WEEKLY mode : days of a week
613 * (ALARM_WDAY_SUNDAY, ALARM_WDAY_MONDAY, ALARM_WDAY_TUESDAY, ALARM_WDAY_WEDNESDAY,
614 * ALARM_WDAY_THURSDAY, ALARM_WDAY_FRIDAY, ALARM_WDAY_SATURDAY)
615 * the others : this parameter is ignored.
617 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
630 int ret_val = ALARMMGR_RESULT_SUCCESS;
631 alarm_entry_t* alarm;
632 alarm_repeat_mode_t repeat;
635 alarm = alarmmgr_create_alarm();
638 //alarmmgr_create_alarm () failed
641 ret_val =alarmmgr_get_repeat_mode
642 (alarm, &repeat, &interval) ;
643 if(ret_val == ALARMMGR_RESULT_SUCCESS
644 && repeat == ALARM_REPEAT_MODE_ONCE) {
645 //alarmmgr_get_repeat_mode() is successful
648 //alarmmgr_get_repeat_mode() failed
650 alarmmgr_free_alarm(alarm) ;
657 int alarmmgr_get_repeat_mode(const alarm_entry_t *alarm,
658 alarm_repeat_mode_t *repeat_mode,
662 * This function sets an alarm mode
664 * @param [in] alarm alarm entry
665 * @param [in] alarm_type one of ALARM_TYPE_DEFAULT : After the device reboot, the alarm still works.
666 * ALARM_TYPE_VOLATILE : After the device reboot, the alarm does not work.
668 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
681 int ret_val = ALARMMGR_RESULT_SUCCESS;
682 alarm_entry_t* alarm;
683 int alarm_type = ALARM_TYPE_VOLATILE;
685 alarm = alarmmgr_create_alarm();
688 //alarmmgr_create_alarm () failed
692 ret_val = alarmmgr_set_type(alarm, alarm_type);
693 if(ret_val == ALARMMGR_RESULT_SUCCESS)
695 //alarmmgr_set_type() is successful
699 //alarmmgr_set_type() failed
701 alarmmgr_free_alarm( alarm) ;
708 int alarmmgr_set_type(alarm_entry_t *alarm, int alarm_type);
711 * This function gives an application an alarm mode
713 * @param [in] alarm alarm entry
714 * @param [out] alarm_type one of ALARM_TYPE_DEFAULT, ALARM_TYPE_VOLATILE
716 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
729 int ret_val = ALARMMGR_RESULT_SUCCESS;
730 alarm_entry_t* alarm;
733 alarm = alarmmgr_create_alarm();
735 //alarmmgr_create_alarm () failed
738 ret_val = alarmmgr_get_type( alarm, &alarm_type);
739 if(ret_val == ALARMMGR_RESULT_SUCCESS && alarm_type
740 == ALARM_TYPE_DEFAULT ) {
741 //alarmmgr_get_type() is successful
744 //alarmmgr_get_type() failed
746 alarmmgr_free_alarm( alarm) ;
753 int alarmmgr_get_type(const alarm_entry_t *alarm, int *alarm_type);
756 * This function adds an alarm entry to the server.
757 * Server will remember this entry, and generate alarm events for it when necessary.
758 * Server will call app-svc interface to sent notification to destination application. Destination information
759 * should be available in the input bundle.
760 * Alarm entries registered with the server cannot be changed.
761 * Remove from server before changing.
762 * Before the application calls alarmmgr_add_alarm_appsvc_with_localtime(), the application have to call alarmmgr_set_time().
763 * The time set is localtime.
764 * If the application does not call alarmmgr_set_repeat_mode, the default repeat_mode is ALARM_REPEAT_MODE_ONCE.
765 * If the application does not call alarmmgr_set_type, the default alarm_type is ALARM_TYPE_DEFAULT.
766 * The id of the new alarm will be copied to alarm_id if the fuction successes to create an alarm.
768 * @param [in] alarm the entry of an alarm to be created.
769 * @param [in] bundle_data bundle which contains information about the destination.
770 * @param [out] alarm_id the id of the alarm added.
772 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
776 * @see alarmmgr_add_alarm
786 struct tm current_tm;
787 alarm_entry_t* alarm_info;
790 alarm_date_t test_time;
799 printf("Unable to create bundle!!!\n");
803 appsvc_set_operation(b,APPSVC_OPERATION_DEFAULT);
804 appsvc_set_pkgname(b,"org.tizen.alarm-test");
808 printf("current time: %s\n", ctime(¤t_time));
809 localtime_r(¤t_time, ¤t_tm);
811 alarm_info = alarmmgr_create_alarm();
813 test_time.year = current_tm.tm_year;
814 test_time.month = current_tm.tm_mon;
815 test_time.day = current_tm.tm_mday;
817 test_time.hour = current_tm.tm_hour;
818 test_time.min = current_tm.tm_min+1;
822 alarmmgr_set_time(alarm_info,test_time);
823 alarmmgr_set_repeat_mode(alarm_info,ALARM_REPEAT_MODE_WEEKLY,ALARM_WDAY_MONDAY| \
824 ALARM_WDAY_TUESDAY|ALARM_WDAY_WEDNESDAY| \
825 ALARM_WDAY_THURSDAY|ALARM_WDAY_FRIDAY );
827 alarmmgr_set_type(alarm_info, ALARM_TYPE_DEFAULT);
828 //alarmmgr_set_type(alarm_info,ALARM_TYPE_VOLATILE);
829 if ((result = alarmmgr_add_alarm_appsvc_with_localtime(alarm_info,(void *)b,&alarm_id)) < 0)
831 printf("Alarm creation failed!!! Alrmgr error code is %d\n",result);
835 printf("Alarm created succesfully with alarm id %d\n",alarm_id);
842 int alarmmgr_add_alarm_appsvc_with_localtime(alarm_entry_t *alarm,void *bundle_data, alarm_id_t *alarm_id);
845 * This function adds an alarm entry to the server.
846 * Server will remember this entry, and generate alarm events for it when necessary.
847 * Alarm entries registered with the server cannot be changed.
848 * Remove from server before changing.
849 * Before the application calls alarmmgr_add_alarm_with_localtime(), the application have to call alarmmgr_set_time().
850 * The time set is localtime.
851 * If the application does not call alarmmgr_set_repeat_mode, the default repeat_mode is ALARM_REPEAT_MODE_ONCE.
852 * If the application does not call alarmmgr_set_type, the default alarm_type is ALARM_TYPE_DEFAULT.
853 * The id of the new alarm will be copied to alarm_id if the fuction successes to create an alarm.
855 * @param [in] alarm the entry of an alarm to be created.
856 * @param [in] destination the packname of application that the alarm will be expired.
857 * @param [out] alarm_id the id of the alarm added.
859 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
863 * @see alarmmgr_add_alarm
872 int ret_val = ALARMMGR_RESULT_SUCCESS;
873 alarm_entry_t* alarm;
874 const char* destination = NULL;
878 struct tm current_tm;
879 alarm_date_t test_time;
881 const char* pkg_name = "org.tizen.test";
885 ret_val =alarmmgr_init(pkg_name) ;
886 if(ret_val != ALARMMGR_RESULT_SUCCESS) {
887 //alarmmgr_init () failed
893 printf("current time: %s\n", ctime(¤t_time));
894 localtime_r(¤t_time, ¤t_tm);
896 alarm = alarmmgr_create_alarm();
899 test_time.month = 0;test_time.day = 0;
901 test_time.hour = current_tm.tm_hour;
902 test_time.min = current_tm.tm_min+1;
906 alarmmgr_set_time(alarm,test_time);
907 alarmmgr_set_repeat_mode(alarm,ALARM_REPEAT_MODE_WEEKLY, \
909 alarmmgr_set_type(alarm,ALARM_TYPE_VOLATILE);
912 ret_val=alarmmgr_add_alarm_with_localtime(alarm,destination,&alarm_id);
914 if(ret_val == ALARMMGR_RESULT_SUCCESS)
916 //alarmmgr_add_alarm_with_localtime() is successful
920 //alarmmgr_add_alarm_with_localtime() failed
922 alarmmgr_free_alarm( alarm) ;
927 int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm,
928 const char *destination,
929 alarm_id_t *alarm_id);
933 * This function adds an alarm entry to the server.
934 * Server will remember this entry, and generate alarm events for it when necessary.
935 * Server will call app-svc interface to sent notification to destination application. Destination information
936 * should be available in the input bundle.
937 * Alarm entries registered with the server cannot be changed.
938 * Remove from server before changing.
939 * After the trigger_at_time seconds from now, the alarm will be expired.
940 * If the interval is zero, the repeat_mode is ALARM_REPEAT_MODE_ONCE.
941 * If the interval is >0, the repeat_mode is ALARM_REPEAT_MODE_REPEAT.
942 * The id of the new alarm will be copied to alarm_id if the fuction successes to create an alarm.
944 * @param [in] alarm_type one of ALARM_TYPE_DEFAULT, ALARM_TYPE_VOLATILE
945 * @param [in] trigger_at_time time interval to be triggered from now(sec). an alarm also will be expired at triggering time.
946 * @param [in] interval Interval between subsequent repeats of the alarm
947 * @param [in] bundle_data bundle which contains information about the destination.
948 * @param [out] alarm_id the id of the alarm added.
950 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
954 * @see alarmmgr_add_alarm_with_localtime alarmmgr_remove_alarm
972 printf("Unable to create bundle!!!\n");
976 appsvc_set_pkgname(b,"org.tizen.alarm-test");
977 //appsvc_set_operation(b,APPSVC_OPERATION_SEND_TEXT);
978 appsvc_set_operation(b,APPSVC_OPERATION_DEFAULT);
980 if ((result = alarmmgr_add_alarm_appsvc(ALARM_TYPE_DEFAULT, 10, 0, (void *)b ,&alarm_id)))
981 printf("Unable to add alarm. Alarmmgr alarm no is %d\n", result);
983 printf("Alarm added successfully. Alarm Id is %d\n", alarm_id);
991 int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time,
992 time_t interval, void *bundle_data,
993 alarm_id_t *alarm_id);
997 * This function adds an alarm entry to the server.
998 * Server will remember this entry, and generate alarm events for it when necessary.
999 * Alarm entries registered with the server cannot be changed.
1000 * Remove from server before changing.
1001 * After the trigger_at_time seconds from now, the alarm will be expired.
1002 * If the interval is zero, the repeat_mode is ALARM_REPEAT_MODE_ONCE.
1003 * If the interval is >0, the repeat_mode is ALARM_REPEAT_MODE_REPEAT.
1004 * The id of the new alarm will be copied to alarm_id if the fuction successes to create an alarm.
1006 * @param [in] alarm_type one of ALARM_TYPE_DEFAULT, ALARM_TYPE_VOLATILE
1007 * @param [in] trigger_at_time time interval to be triggered from now(sec). an alarm also will be expired at triggering time.
1008 * @param [in] interval Interval between subsequent repeats of the alarm
1009 * @param [in] destination the packname of application that the alarm will be expired.
1010 * @param [out] alarm_id the id of the alarm added.
1012 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
1016 * @see alarmmgr_add_alarm_with_localtime alarmmgr_remove_alarm
1025 int ret_val = ALARMMGR_RESULT_SUCCESS;
1027 int alarm_type = ALARM_TYPE_VOLATILE;
1028 time_t trigger_at_time = 10;
1029 time_t interval = 10;
1030 const char* destination = NULL;
1031 alarm_id_t alarm_id;
1033 const char* pkg_name = "org.tizen.test";
1037 ret_val =alarmmgr_init(pkg_name) ;
1038 if(ret_val != ALARMMGR_RESULT_SUCCESS)
1040 //alarmmgr_init () failed
1044 ret_val = alarmmgr_add_alarm( alarm_type, trigger_at_time, interval,
1045 destination, &alarm_id);
1046 if(ret_val == ALARMMGR_RESULT_SUCCESS)
1048 //alarmmgr_add_alarm() is successful
1052 //alarmmgr_add_alarm() failed
1054 alarmmgr_remove_alarm( alarm_id) ;
1060 int alarmmgr_add_alarm(int alarm_type, time_t trigger_at_time,
1061 time_t interval, const char *destination,
1062 alarm_id_t *alarm_id);
1065 * This function deletes the alarm associated with the given alarm_id.
1067 * @param [in] alarm_id Specifies the ID of the alarm to be deleted.
1069 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
1073 * @see alarmmgr_add_alarm_with_localtime alarmmgr_add_alarm
1082 int ret_val = ALARMMGR_RESULT_SUCCESS;
1083 int alarm_type = ALARM_TYPE_VOLATILE;
1084 time_t trigger_at_time = 10;
1085 time_t interval = 10;
1086 const char* destination = NULL;
1087 alarm_id_t alarm_id;
1089 const char* pkg_name = "org.tizen.test";
1093 ret_val =alarmmgr_init(pkg_name) ;
1094 if(ret_val != ALARMMGR_RESULT_SUCCESS) {
1095 //alarmmgr_init () failed
1099 alarmmgr_add_alarm( alarm_type, trigger_at_time, interval,
1100 destination, &alarm_id);
1102 ret_val =alarmmgr_remove_alarm( alarm_id) ;
1103 if(ret_val == ALARMMGR_RESULT_SUCCESS) {
1104 /alarmmgr_remove_alarm() is successful
1107 //alarmmgr_remove_alarm() failed
1114 int alarmmgr_remove_alarm(alarm_id_t alarm_id);
1117 * This function gives a list of alarm ids that the application adds to the server.
1119 * @param [in] fn a user callback function
1120 * @param [in] user_param user parameter
1122 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
1126 * @see alarm_get_info
1133 int callback_2(alarm_id_t id, void* user_param)
1135 int* n = (int*)user_param;
1136 printf("[%d]alarm id : %d\n",*n,id);
1143 int ret_val = ALARMMGR_RESULT_SUCCESS;
1146 const char* pkg_name = "org.tizen.test";
1150 ret_val =alarmmgr_init(pkg_name) ;
1151 if(ret_val != ALARMMGR_RESULT_SUCCESS)
1153 //alarmmgr_init() failed
1157 ret_val = alarmmgr_enum_alarm_ids( callback_2, (void*)&n) ;
1158 if(ret_val == ALARMMGR_RESULT_SUCCESS)
1160 //alarmmgr_enum_alarm_ids() is successful
1164 //alarmmgr_enum_alarm_ids() failed
1171 int alarmmgr_enum_alarm_ids(alarm_enum_fn_t fn, void *user_param);
1175 * This function gets the information of the alarm assosiated with alarm_id to alarm_info. The application
1176 * must allocate alarm_info before calling this function.
1178 * @param [in] alarm_id the id of the alarm
1179 * @param [out] alarm the buffer alarm informaiton will be copied to
1181 * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
1185 * @see alarmmgr_enum_alarm_ids
1194 int ret_val = ALARMMGR_RESULT_SUCCESS;
1195 int alarm_type = ALARM_TYPE_VOLATILE;
1196 time_t trigger_at_time = 10;
1197 time_t interval = ALARM_WDAY_SUNDAY;
1198 const char* destination = NULL;
1199 alarm_id_t alarm_id;
1201 alarm_entry_t *alarm;
1203 const char* pkg_name = "org.tizen.test_get_info1";
1207 ret_val =alarmmgr_init(pkg_name) ;
1208 if(ret_val != ALARMMGR_RESULT_SUCCESS) {
1209 //alarmmgr_init() failed
1212 ret_val = alarmmgr_add_alarm( alarm_type,trigger_at_time,interval,
1213 destination, &alarm_id);
1215 if(ret_val != ALARMMGR_RESULT_SUCCESS) {
1216 //alarmmgr_add_alarm() failed
1219 ret_val = alarmmgr_get_info(alarm_id, alarm);
1220 if(ret_val == ALARMMGR_RESULT_SUCCESS) {
1221 //alarmmgr_get_info() is successful
1224 //alarmmgr_get_info() failed
1226 alarmmgr_remove_alarm( alarm_id) ;
1231 int alarmmgr_get_info(alarm_id_t alarm_id, alarm_entry_t *alarm);
1243 int alarmmgr_power_on(bool on_off);
1250 #endif/* ALARM_LIB_H*/