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"
31
28
#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 },
46
35
on_name_lost (gpointer instance G_GNUC_UNUSED, gpointer loop)
48
37
g_message ("exiting: service couldn't acquire or lost ownership of busname");
51
g_main_loop_quit ((GMainLoop*)loop);
38
g_main_loop_quit ((GMainLoop*)loop);
55
42
main (int argc G_GNUC_UNUSED, char ** argv G_GNUC_UNUSED)
57
GOptionContext * context;
59
IndicatorDatetimePlanner * planner;
60
45
IndicatorDatetimeService * service;
63
47
/* Work around a deadlock in glib's type initialization. It can be
64
48
* removed when https://bugzilla.gnome.org/show_bug.cgi?id=674885 is
71
55
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
72
56
textdomain (GETTEXT_PACKAGE);
75
if (!notify_init ("indicator-datetime-service"))
76
g_critical ("libnotify initialization failed");
78
/* parse command-line options */
79
context = g_option_context_new (NULL);
80
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
81
if (!g_option_context_parse (context, &argc, &argv, &error))
83
g_print("option parsing failed: %s\n", error->message);
87
/* set up the planner */
90
g_message ("Using fake appointment book for testing alarms.");
91
planner = indicator_datetime_planner_mock_new ();
95
planner = indicator_datetime_planner_eds_new ();
99
service = indicator_datetime_service_new (planner);
59
service = indicator_datetime_service_new ();
100
60
loop = g_main_loop_new (NULL, FALSE);
101
61
g_signal_connect (service, INDICATOR_DATETIME_SERVICE_SIGNAL_NAME_LOST,
102
62
G_CALLBACK(on_name_lost), loop);
103
63
g_main_loop_run (loop);
66
g_clear_object (&service);
106
67
g_main_loop_unref (loop);
107
g_object_unref (service);
108
g_object_unref (planner);