summaryrefslogtreecommitdiff
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
parentabe70b50e3fa9726b5e4e993804dac7629071e46 (diff)
downloadofono-8dc66c11bdabcdbf132ac60ec1e7eb47b2a66eae.tar.gz
build: Add optional ell dependency
-rw-r--r--Makefile.am5
-rw-r--r--configure.ac14
-rw-r--r--src/main.c54
3 files changed, 73 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index 5368b61d..d0ecb934 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -602,6 +602,11 @@ builtin_sources += plugins/push-notification.c
builtin_modules += allowed_apns
builtin_sources += plugins/allowed-apns.c
+if ELL
+builtin_cflags += @ELL_CFLAGS@
+builtin_libadd += @ELL_LIBS@
+endif
+
sbin_PROGRAMS = src/ofonod
src_ofonod_SOURCES = $(builtin_sources) $(gatchat_sources) src/ofono.ver \
diff --git a/configure.ac b/configure.ac
index 372053cb..e9b8491a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -218,6 +218,20 @@ AC_ARG_ENABLE(upower, AC_HELP_STRING([--disable-upower],
[enable_upower=${enableval}])
AM_CONDITIONAL(UPOWER, test "${enable_power}" != "no")
+AC_ARG_ENABLE(ell, AC_HELP_STRING([--enable-ell],
+ [enable support for ell]),
+ [enable_ell=${enableval}])
+
+if (test "${enable_ell}" = "yes"); then
+ AC_DEFINE(HAVE_ELL, 1, [Defined if Ell is enabled])
+ PKG_CHECK_MODULES(ELL, ell >= 0.2, dummy=yes,
+ AC_MSG_ERROR(ell library >= 0.2 is required))
+ AC_SUBST(ELL_CFLAGS)
+ AC_SUBST(ELL_LIBS)
+fi
+
+AM_CONDITIONAL(ELL, test "${enable_ell}" != "no")
+
AC_ARG_ENABLE(datafiles, AC_HELP_STRING([--disable-datafiles],
[do not install configuration and data files]),
[enable_datafiles=${enableval}])
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();