a9eeba337643a2c5e0d6201296f5c2d73b40657d
[framework/appfw/alarm-manager.git] / test / 2alarm_create_test.c
1 /*
2  *  alarm-manager
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
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>
8  *
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
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
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.
20  *
21  */
22
23 #include<stdio.h>
24 #include<stdlib.h>
25 #include<glib.h>
26
27 #include "alarm.h"
28
29 int callback(alarm_id_t alarm_id,void* user_param)
30 {
31         int error;
32         time_t current_time;
33         time(&current_time);
34
35         printf("Alarm[%d] has expired at %s\n", alarm_id, ctime(&current_time));
36
37         return 0;
38
39 }
40
41 void create_test()
42 {
43                 time_t current_time;
44                 alarm_id_t alarm_id;
45                 int result;
46
47                 time(&current_time);
48
49                 printf("current time: %s\n", ctime(&current_time));
50        
51
52                 result = alarmmgr_add_alarm(ALARM_TYPE_VOLATILE, 8, 0, NULL,&alarm_id);
53                 if(result < 0)
54                         printf("fail to alarmmgr_create : error_code : %d\n",result);
55         
56 }
57
58 int main(int argc, char** argv)
59 {       
60         int error_code;
61         GMainLoop *mainloop;
62                 int result;
63         
64         g_type_init();
65         
66         mainloop = g_main_loop_new(NULL, FALSE);
67                 
68         result = alarmmgr_init("org.tizen.test");
69
70                 if(result<0)
71                 {
72                         printf("fail to alarmmgr_init : error_code : %d\n",result);
73                 }
74                 else{
75                         
76            result = alarmmgr_set_cb(callback,NULL);
77
78                    if(result<0)
79                         {
80                                 printf("fail to alarmmgr_set_cb : error_code : %d\n",result);
81                         }
82                         else{
83                                 create_test();
84                         }
85                 }
86
87         g_main_loop_run(mainloop);
88 }
89
90