25
25
#include <glib/gi18n.h>
26
26
#include <gio/gio.h>
27
#include <libnotify/notify.h>
29
#include "planner-eds.h"
30
#include "planner-mock.h"
28
31
#include "service.h"
37
/* When enabled, new alarms will show up every minute to test snap decisions */
38
static gboolean test_alarms = FALSE;
40
static GOptionEntry entries[] = {
41
{ "test-alarms", '\0', 0, G_OPTION_ARG_NONE, &test_alarms, "Test Alarms", NULL },
35
46
on_name_lost (gpointer instance G_GNUC_UNUSED, gpointer loop)
37
48
g_message ("exiting: service couldn't acquire or lost ownership of busname");
38
g_main_loop_quit ((GMainLoop*)loop);
51
g_main_loop_quit ((GMainLoop*)loop);
42
55
main (int argc G_GNUC_UNUSED, char ** argv G_GNUC_UNUSED)
57
GOptionContext * context;
59
IndicatorDatetimePlanner * planner;
60
IndicatorDatetimeService * service;
45
IndicatorDatetimeService * service;
47
63
/* boilerplate i18n */
48
64
setlocale (LC_ALL, "");
49
65
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
50
66
textdomain (GETTEXT_PACKAGE);
69
if (!notify_init ("indicator-datetime-service"))
70
g_critical ("libnotify initialization failed");
72
/* parse command-line options */
73
context = g_option_context_new (NULL);
74
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
75
if (!g_option_context_parse (context, &argc, &argv, &error))
77
g_print("option parsing failed: %s\n", error->message);
81
/* set up the planner */
84
g_message ("Using fake appointment book for testing alarms.");
85
planner = indicator_datetime_planner_mock_new ();
89
planner = indicator_datetime_planner_eds_new ();
53
service = indicator_datetime_service_new ();
93
service = indicator_datetime_service_new (planner);
54
94
loop = g_main_loop_new (NULL, FALSE);
55
95
g_signal_connect (service, INDICATOR_DATETIME_SERVICE_SIGNAL_NAME_LOST,
56
96
G_CALLBACK(on_name_lost), loop);
57
97
g_main_loop_run (loop);
60
g_clear_object (&service);
61
100
g_main_loop_unref (loop);
101
g_object_unref (service);
102
g_object_unref (planner);