summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2017-09-18 18:03:22 -0500
committerDenis Kenzior <denkenz@gmail.com>2017-10-05 11:08:38 -0500
commit8dc66c11bdabcdbf132ac60ec1e7eb47b2a66eae (patch)
tree893944ac6468a090fce59b57386ddc143122d52a /src/main.c
parentabe70b50e3fa9726b5e4e993804dac7629071e46 (diff)
downloadofono-8dc66c11bdabcdbf132ac60ec1e7eb47b2a66eae.tar.gz
build: Add optional ell dependency
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index b43bb4e7..2d359dde 100644
--- a/src/main.c
+++ b/src/main.c
@@ -32,6 +32,10 @@
#include <gdbus.h>
+#ifdef HAVE_ELL
+#include <ell/ell.h>
+#endif
+
#include "ofono.h"
#define SHUTDOWN_GRACE_SECONDS 10
@@ -170,6 +174,32 @@ static GOptionEntry options[] = {
{ NULL },
};
+#ifdef HAVE_ELL
+struct ell_event_source {
+ GSource source;
+ GPollFD pollfd;
+};
+
+static gboolean event_prepare(GSource *source, gint *timeout)
+{
+ int r = l_main_prepare();
+ *timeout = r;
+
+ return FALSE;
+}
+
+static gboolean event_check(GSource *source)
+{
+ l_main_iterate(0);
+ return FALSE;
+}
+
+static GSourceFuncs event_funcs = {
+ .prepare = event_prepare,
+ .check = event_check,
+};
+#endif
+
int main(int argc, char **argv)
{
GOptionContext *context;
@@ -177,6 +207,9 @@ int main(int argc, char **argv)
DBusConnection *conn;
DBusError error;
guint signal;
+#ifdef HAVE_ELL
+ struct ell_event_source *source;
+#endif
#ifdef NEED_THREADS
if (g_thread_supported() == FALSE)
@@ -220,6 +253,23 @@ int main(int argc, char **argv)
}
#endif
+#ifdef HAVE_ELL
+ l_log_set_stderr();
+ l_debug_enable("*");
+ l_main_init();
+
+ source = (struct ell_event_source *) g_source_new(&event_funcs,
+ sizeof(struct ell_event_source));
+
+ source->pollfd.fd = l_main_get_epoll_fd();
+ source->pollfd.events = G_IO_IN | G_IO_HUP | G_IO_ERR;
+
+ g_source_add_poll((GSource *)source, &source->pollfd);
+ g_source_attach((GSource *) source,
+ g_main_loop_get_context(event_loop));
+#endif
+
+
signal = setup_signalfd();
__ofono_log_init(argv[0], option_debug, option_detach);
@@ -267,6 +317,10 @@ int main(int argc, char **argv)
cleanup:
g_source_remove(signal);
+#ifdef HAVE_ELL
+ g_source_destroy((GSource *) source);
+ l_main_exit();
+#endif
g_main_loop_unref(event_loop);
__ofono_log_cleanup();