aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2013-10-09 22:55:26 -0500
committerCharles Kerr <charles.kerr@canonical.com>2013-10-09 22:55:26 -0500
commitdae4fdd39e5381083345e87759dbaffddabe14e4 (patch)
treec68345f54911053be886be9fe3231385bd37599d /src/main.c
parenta52e3b86ee0dbce56221d1327c6c62a6d8e163e3 (diff)
downloadayatana-indicator-datetime-dae4fdd39e5381083345e87759dbaffddabe14e4.tar.gz
ayatana-indicator-datetime-dae4fdd39e5381083345e87759dbaffddabe14e4.tar.bz2
ayatana-indicator-datetime-dae4fdd39e5381083345e87759dbaffddabe14e4.zip
more wiring in of mock objects
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/main.c b/src/main.c
index 34e9b98..45ee180 100644
--- a/src/main.c
+++ b/src/main.c
@@ -21,6 +21,7 @@
#include <locale.h>
#include <stdlib.h> /* exit() */
+#include <stdio.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
@@ -30,6 +31,8 @@
#include "planner-mock.h"
#include "service.h"
+#define TEST_MODE
+
/***
****
***/
@@ -41,6 +44,18 @@ on_name_lost (gpointer instance G_GNUC_UNUSED, gpointer loop)
g_main_loop_quit ((GMainLoop*)loop);
}
+#ifdef TEST_MODE
+static void
+log_handler (const gchar * log_domain,
+ GLogLevelFlags log_level,
+ const gchar * message,
+ gpointer fp)
+{
+ fprintf (fp, "%s %d %s\n", log_domain, (int)log_level, message);
+ fflush (fp);
+}
+#endif
+
int
main (int argc G_GNUC_UNUSED, char ** argv G_GNUC_UNUSED)
{
@@ -57,17 +72,15 @@ main (int argc G_GNUC_UNUSED, char ** argv G_GNUC_UNUSED)
if (!notify_init ("indicator-datetime-service"))
g_critical ("libnotify initialization failed");
-
- /* get the planner */
- if (g_getenv ("INDICATOR_DATETIME_USE_FAKE_PLANNER") != NULL)
- {
- g_message ("Using fake appointment book for testing");
- planner = indicator_datetime_planner_mock_new ();
- }
- else
- {
- planner = indicator_datetime_planner_eds_new ();
- }
+ /* set up the planner */
+#ifdef TEST_MODE
+ g_warning ("Using fake appointment book for testing! Probably shouldn't merge this to trunk.");
+ FILE * fp = fopen ("/tmp/indicator-datetime-log.txt", "w+");
+ g_log_set_handler ("Indicator-Datetime", G_LOG_LEVEL_MASK, log_handler, fp);
+ planner = indicator_datetime_planner_mock_new ();
+#else
+ planner = indicator_datetime_planner_eds_new ();
+#endif
/* run */
service = indicator_datetime_service_new (planner);
@@ -80,5 +93,8 @@ main (int argc G_GNUC_UNUSED, char ** argv G_GNUC_UNUSED)
g_main_loop_unref (loop);
g_object_unref (service);
g_object_unref (planner);
+#ifdef TEST_MODE
+ fclose (fp);
+#endif
return 0;
}