Remove unneeded re-definition of EAPI
[framework/uifw/edbus.git] / src / bin / notify.c
1 #ifdef HAVE_CONFIG_H
2 #include "config.h"
3 #endif
4
5 #include <stdio.h>
6
7 #include <Ecore.h>
8 #include <E_DBus.h>
9 #include <E_Notify.h>
10
11 void
12 cb_sent(void *data __UNUSED__, void *ret, DBusError *err)
13 {
14   E_Notification_Return_Notify *notify;
15   notify = ret;
16   if (notify) 
17   {
18     printf("id: %d\n", notify->notification_id);
19   }
20   else if (dbus_error_is_set(err))
21   {
22     printf("Error: %s\n", err->message);
23   }
24 }
25
26 Eina_Bool
27 cb_timer(void *data __UNUSED__)
28 {
29   E_Notification *n;
30   char buf[1024];
31   static int num = 0;
32   static const char *icons[] = {
33     "xterm",
34     "firefox",
35     "gvim"
36   };
37
38   snprintf(buf, sizeof(buf), "<i>%s</i> says <b>Hello</b> #%d", icons[num%3], num / 3); 
39   n = e_notification_full_new(icons[num%3], 0, icons[num%3], "Summary", buf, -1);
40   e_notification_send(n, cb_sent, NULL);
41   e_notification_unref(n);
42   num++;
43
44   return ECORE_CALLBACK_RENEW;
45 }
46
47 void
48 cb_action_invoked(void *data __UNUSED__, int type __UNUSED__, void *event)
49 {
50   E_Notification_Event_Action_Invoked *ev;
51
52   ev = event;
53   printf("Action (%d): %s\n", ev->notification_id, ev->action_id);
54   free(ev);
55 }
56
57 void
58 cb_note_closed(void *data __UNUSED__, int type __UNUSED__, void *event)
59 {
60   E_Notification_Event_Notification_Closed *ev;
61   static const char *reasons[] = {
62     "Expired",
63     "Dismissed",
64     "Requested",
65     "Undefined"
66   };
67
68   ev = event;
69   printf("Note %d closed: %s\n", ev->notification_id, reasons[ev->reason]);
70   free(ev);
71 }
72
73 int
74 main()
75 {
76   int ret = 0;
77   ecore_init();
78   if (e_notification_init())
79   {
80     ecore_timer_add(1, cb_timer, NULL);
81     ecore_main_loop_begin();
82     e_notification_shutdown();
83   }
84
85   ecore_shutdown();
86   return ret;
87 }