[evolution-data-server] Add a --keep-running option to e-addressbook-factory.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Add a --keep-running option to e-addressbook-factory.
- Date: Sat, 5 Feb 2011 16:30:46 +0000 (UTC)
commit 877d4b28accb3138a5d264fcca945f6cdb06af5d
Author: Matthew Barnes <mbarnes redhat com>
Date: Sat Feb 5 11:02:28 2011 -0500
Add a --keep-running option to e-addressbook-factory.
Prevents the D-Bus service from automatically terminating after the last
client connection is closed. Mainly to aid in testing and development.
addressbook/libedata-book/e-data-book-factory.c | 34 +++++++++++++++++++++--
1 files changed, 31 insertions(+), 3 deletions(-)
---
diff --git a/addressbook/libedata-book/e-data-book-factory.c b/addressbook/libedata-book/e-data-book-factory.c
index 5b025a1..918257c 100644
--- a/addressbook/libedata-book/e-data-book-factory.c
+++ b/addressbook/libedata-book/e-data-book-factory.c
@@ -51,6 +51,9 @@
static GMainLoop *loop;
+/* Keep running after the last client is closed. */
+static gboolean opt_keep_running = FALSE;
+
/* Convenience macro to test and set a GError/return on failure */
#define g_set_error_val_if_fail(test, returnval, error, domain, code) G_STMT_START{ \
if G_LIKELY (test) {} else { \
@@ -266,8 +269,11 @@ book_freed_cb (EDataBookFactory *factory, GObject *dead)
}
}
+ if (g_hash_table_size (priv->books) > 0)
+ return;
+
/* If there are no open books, start a timer to quit */
- if (priv->exit_timeout == 0 && g_hash_table_size (priv->books) == 0)
+ if (!opt_keep_running && priv->exit_timeout == 0)
priv->exit_timeout = g_timeout_add_seconds (
10, (GSourceFunc) g_main_loop_quit, loop);
}
@@ -584,12 +590,24 @@ setup_quit_signal (void)
}
#endif
+static GOptionEntry entries[] = {
+
+ /* FIXME Have the description translated for 3.2, but this
+ * option is to aid in testing and development so it
+ * doesn't really matter. */
+ { "keep-running", 'r', 0, G_OPTION_ARG_NONE, &opt_keep_running,
+ "Keep running after the last client is closed", NULL },
+ { NULL }
+};
+
gint
main (gint argc, gchar **argv)
{
EOfflineListener *eol;
+ GOptionContext *context;
EDataBookFactory *factory;
guint owner_id;
+ GError *error = NULL;
#ifdef G_OS_WIN32
/* Reduce risks */
@@ -617,6 +635,16 @@ main (gint argc, gchar **argv)
g_set_prgname (E_PRGNAME);
if (!g_thread_supported ()) g_thread_init (NULL);
+ context = g_option_context_new (NULL);
+ g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
+ g_option_context_parse (context, &argc, &argv, &error);
+ g_option_context_free (context);
+
+ if (error != NULL) {
+ g_printerr ("%s\n", error->message);
+ exit (EXIT_FAILURE);
+ }
+
factory = g_object_new (E_TYPE_DATA_BOOK_FACTORY, NULL);
loop = g_main_loop_new (NULL, FALSE);
@@ -639,9 +667,9 @@ main (gint argc, gchar **argv)
/* Migrate user data from ~/.evolution to XDG base directories. */
e_data_book_migrate ();
- #ifndef G_OS_WIN32
+#ifndef G_OS_WIN32
setup_quit_signal ();
- #endif
+#endif
g_print ("Server is up and running...\n");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]