Initialize Tizen 2.3
[framework/appfw/alarm-manager.git] / test / appsvc-test / delete_alarm_appsvc.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 #include<glib-object.h>
27 #include <dlog/dlog.h>
28 #include <alarm.h>
29 #include <bundle.h>
30 #include <appsvc.h>
31
32
33 alarm_id_t alarm_id;
34
35 void create_test()
36 {
37         time_t current_time;
38         int result;
39
40         bundle *b = NULL;
41
42         b = bundle_create();
43
44         if (NULL == b) {
45                 printf("Unable to create bundle!!!\n");
46                 return;
47         }
48
49         time(&current_time);
50
51         printf("current time: %s\n", ctime(&current_time));
52
53         appsvc_set_operation(b, APPSVC_OPERATION_DEFAULT);
54         appsvc_set_pkgname(b, "com.samsung.alarm-test");
55
56         result =
57             alarmmgr_add_alarm_appsvc(ALARM_TYPE_VOLATILE, 10, 0, (void *)b, &alarm_id);
58
59         printf("Alarm Id is %d\n", alarm_id);
60
61         result = alarmmgr_remove_alarm(alarm_id);
62
63         if (result == ALARMMGR_RESULT_SUCCESS) {
64                 printf("Alarm deletion success!!!\n");
65         }
66         else
67         {
68                 printf("Unable to delete alarm!!!\n");
69         }
70 }
71
72 int main(int argc, char **argv)
73 {
74         GMainLoop *mainloop;
75
76         g_type_init();
77
78         mainloop = g_main_loop_new(NULL, FALSE);
79
80         create_test();
81
82         g_main_loop_run(mainloop);
83
84         return 0;
85
86 }