Release version 0.12.34
[platform/core/appfw/alarm-manager.git] / tool / alarmmgr_add_reference_periodic_alarm_withcb.c
1 /*
2  * Copyright (c) 2015 - 2019 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include<stdio.h>
17 #include<stdlib.h>
18 #include<glib.h>
19
20 #include "alarm.h"
21
22 int callback(alarm_id_t alarm_id, void* user_param)
23 {
24         time_t current_time;
25         time(&current_time);
26
27         printf("Alarm[%d] has expired at %s\n", alarm_id, ctime(&current_time));
28
29         return 0;
30 }
31
32 void create_test()
33 {
34         int result = 0;
35         alarm_id_t alarm_id;
36
37         result = alarmmgr_add_reference_periodic_alarm_withcb(1, callback, NULL, &alarm_id);
38
39         if (result < 0)
40                 printf("alarmmgr_add_reference_periodic_alarm_withcb : error_code : %d\n", result);
41 }
42
43 int main(int argc, char** argv)
44 {
45         GMainLoop *mainloop;
46         int result;
47
48         mainloop = g_main_loop_new(NULL, FALSE);
49         result = alarmmgr_init("org.tizen.alarmmgr.refperiodic");
50
51         if (result < 0)
52                 printf("fail to alarmmgr_init : error_code : %d\n", result);
53         else
54                 create_test();
55
56         g_main_loop_run(mainloop);
57
58         return 0;
59 }
60