Main Page | Data Structures | File List | Data Fields | Globals

tests/apitest.c

Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include "alarm_event.h"
00004 
00005 int main()
00006 {
00007         cookie_t identifier;
00008         cookie_t identifier2;
00009         cookie_t identifier3;
00010         cookie_t *list;
00011         int i;
00012         alarm_event_t event = {
00013                 .alarm_time = 0,
00014                 .recurrence = 0,
00015                 .recurrence_count = 0,
00016                 .snooze = 5,
00017                 .message = (char *)"Rairairai",
00018                 .sound = NULL,
00019                 .icon = (char *)"qgn_indi_voip_mute",
00020                 .dbus_interface = NULL,
00021                 .dbus_service = NULL,
00022                 .dbus_path = NULL,
00023                 .dbus_name = NULL,
00024                 .exec_name = (char *)"/bin/ls",
00025                 .flags = ALARM_EVENT_SHOW_ICON
00026         };
00027         event.alarm_time = time(NULL) + 20;
00028         identifier = alarm_event_add(&event);
00029         event.alarm_time += 20;
00030         identifier2 = alarm_event_add(&event);
00031         event.alarm_time += 20;
00032         identifier3 = alarm_event_add(&event);
00033         printf("Got id: %ld\n", identifier);
00034         printf("Got id2: %ld\n", identifier2);
00035         printf("Got id3: %ld\n", identifier3);
00036         list = alarm_event_query(time(NULL), time(NULL) + 40, 0, 0);
00037         printf("Listing events.\n");
00038         for (i = 0; list && list[i]; i++) {
00039                 printf("Event[%d]: %ld\n", i, list[i]);
00040         }
00041         if (list && list[0]) {
00042                 alarm_event_t *queried = NULL;
00043                 queried = alarm_event_get(list[0]);
00044                 if (queried) {
00045                         printf("message =  %s, icon = %s, exec_name = %s\n", queried->message, queried->icon, queried->exec_name);
00046                         alarm_event_free(queried);
00047                 }
00048         }
00049         free(list);
00050         if (alarm_event_del(identifier)) {
00051                 printf("Removing event succeeded.\n");
00052         } else {
00053                 printf("Removing event failed.\n");
00054         }
00055         if (alarm_event_del(identifier2)) {
00056                 printf("Removing event2 succeeded.\n");
00057         } else {
00058                 printf("Removing event2 failed.\n");
00059         }
00060         if (alarm_event_del(identifier3)) {
00061                 printf("Removing event3 succeeded.\n");
00062         } else {
00063                 printf("Removing event3 failed.\n");
00064         }
00065         printf("Listing events.\n");
00066         list = alarm_event_query(time(NULL), time(NULL) + 40, 0, 0);
00067         for (i = 0; list && list[i]; i++) {
00068                 printf("Event[%d]: %ld\n", i, list[i]);
00069         }
00070         free(list);
00071 
00072         return 0;
00073 }

Generated on Thu Dec 21 18:23:30 2006 for Alarmd by  doxygen 1.4.2