diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2013-10-17 03:39:12 +0000 |
---|---|---|
committer | Tarmac <Unknown> | 2013-10-17 03:39:12 +0000 |
commit | e38b6293bb37557d27efd052c82ee44d70996077 (patch) | |
tree | ffcb823fe27b30a448422a7ef72f3727a81d4469 /src/main.c | |
parent | 3cb74c566f21cead559308c94f3b3995e35e6fa2 (diff) | |
parent | 05c1039f4b9f0014371bb767089755317ea2d322 (diff) | |
download | ayatana-indicator-datetime-e38b6293bb37557d27efd052c82ee44d70996077.tar.gz ayatana-indicator-datetime-e38b6293bb37557d27efd052c82ee44d70996077.tar.bz2 ayatana-indicator-datetime-e38b6293bb37557d27efd052c82ee44d70996077.zip |
== Changes to planner-eds:
The get-appointments GTask has a new task subtype for pulling an ECalComponent's uris asynchronously.
When get_appointments() is called, create one GTask. We add subtasks to it for each client we know of for calling e_cal_client_generate_instances(). What's new is that for each ECalComponent we find in generate_instances(), we add another new subtask that tries to get the uris for that component.
== Testing changes:
Make "planner" a property in IndicatorDatetimeService so that we can swap in different appointment planners at runtime. This is for unit testing purposes.
Add a mechanism for testing snap decisions without an EDS backend.
== Service changes:
Every time the appointment list changes, walk through it to find the alarm that will occur the soonest. Set a timer to wake up at that time. When the timer is reached, pop up a snap decision for each alarm set to that time. If the user clicks "OK", dispatch the URL associated with that alarm.
Made the appointment menuitems clickable, they now dispatch the appointment's URL. Fixes: https://bugs.launchpad.net/bugs/1233176.
Approved by PS Jenkins bot, Ted Gould.
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 49 |
1 files changed, 45 insertions, 4 deletions
@@ -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; } |