aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c49
1 files changed, 45 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index c75b2d7..f791683 100644
--- a/src/main.c
+++ b/src/main.c
@@ -24,40 +24,81 @@
#include <glib/gi18n.h>
#include <gio/gio.h>
+#include <libnotify/notify.h>
+#include "planner-eds.h"
+#include "planner-mock.h"
#include "service.h"
/***
****
***/
+/* When enabled, new alarms will show up every minute to test snap decisions */
+static gboolean test_alarms = FALSE;
+
+static GOptionEntry entries[] = {
+ { "test-alarms", '\0', 0, G_OPTION_ARG_NONE, &test_alarms, "Test Alarms", NULL },
+ { NULL }
+};
+
static void
on_name_lost (gpointer instance G_GNUC_UNUSED, gpointer loop)
{
g_message ("exiting: service couldn't acquire or lost ownership of busname");
- g_main_loop_quit ((GMainLoop*)loop);
+
+ if (!test_alarms)
+ g_main_loop_quit ((GMainLoop*)loop);
}
int
main (int argc G_GNUC_UNUSED, char ** argv G_GNUC_UNUSED)
{
- GMainLoop * loop;
+ GOptionContext * context;
+ GError * error;
+ IndicatorDatetimePlanner * planner;
IndicatorDatetimeService * service;
+ GMainLoop * loop;
/* boilerplate i18n */
setlocale (LC_ALL, "");
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
textdomain (GETTEXT_PACKAGE);
+ /* init libnotify */
+ if (!notify_init ("indicator-datetime-service"))
+ g_critical ("libnotify initialization failed");
+
+ /* parse command-line options */
+ context = g_option_context_new (NULL);
+ g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
+ if (!g_option_context_parse (context, &argc, &argv, &error))
+ {
+ g_print("option parsing failed: %s\n", error->message);
+ return EXIT_FAILURE;
+ }
+
+ /* set up the planner */
+ if (test_alarms)
+ {
+ g_message ("Using fake appointment book for testing alarms.");
+ planner = indicator_datetime_planner_mock_new ();
+ }
+ else
+ {
+ planner = indicator_datetime_planner_eds_new ();
+ }
+
/* run */
- service = indicator_datetime_service_new ();
+ service = indicator_datetime_service_new (planner);
loop = g_main_loop_new (NULL, FALSE);
g_signal_connect (service, INDICATOR_DATETIME_SERVICE_SIGNAL_NAME_LOST,
G_CALLBACK(on_name_lost), loop);
g_main_loop_run (loop);
/* cleanup */
- g_clear_object (&service);
g_main_loop_unref (loop);
+ g_object_unref (service);
+ g_object_unref (planner);
return 0;
}