summaryrefslogtreecommitdiffstats
path: root/plugins/afm-main-plugin/afm-main-plugin.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-04-15 16:40:38 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2016-04-15 16:40:38 +0200
commit68a8eaafe5f43480f29308bfd2ec12ad54da43f1 (patch)
tree5c8782a09cb48df20695fa6ba562e00f523d22f3 /plugins/afm-main-plugin/afm-main-plugin.c
parent67966a2f96613d833f493ef3773c442d35f8ed31 (diff)
use upoll for event loop
also add '#pragma once' in headers Change-Id: I90cc2d53ec60d4d1e66cf0f229109621e4019864 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'plugins/afm-main-plugin/afm-main-plugin.c')
-rw-r--r--plugins/afm-main-plugin/afm-main-plugin.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/plugins/afm-main-plugin/afm-main-plugin.c b/plugins/afm-main-plugin/afm-main-plugin.c
index b026fd80..418cc508 100644
--- a/plugins/afm-main-plugin/afm-main-plugin.c
+++ b/plugins/afm-main-plugin/afm-main-plugin.c
@@ -23,7 +23,9 @@
#include "afb-plugin.h"
#include "afb-req-itf.h"
+#include "afb-poll-itf.h"
+#include "utils-sbus.h"
#include "utils-jbus.h"
static const char _auto_[] = "auto";
@@ -276,14 +278,33 @@ static const struct AFB_plugin plug_desc = {
.apis = plug_apis
};
+static struct sbus_itf sbusitf;
+
const struct AFB_plugin *pluginRegister(const struct AFB_interface *itf)
{
+ struct sbus *sbus;
+
+ if (interface != NULL)
+ return NULL;
+
interface = itf;
+ sbusitf.wait = itf->pollitf->wait;
+ sbusitf.open = itf->pollitf->open;
+ sbusitf.on_readable = itf->pollitf->on_readable;
+ sbusitf.on_writable = itf->pollitf->on_writable;
+ sbusitf.on_hangup = itf->pollitf->on_hangup;
+ sbusitf.close = itf->pollitf->close;
+
+ sbus = sbus_session(&sbusitf, itf->pollclosure);
+ if (sbus == NULL) {
+ fprintf(stderr, "ERROR: %s:%d: can't connect to DBUS session\n", __FILE__, __LINE__);
+ return NULL;
+ }
- jbus = create_jbus_session("/org/AGL/afm/user");
+ jbus = create_jbus(sbus, "/org/AGL/afm/user");
if (jbus)
return &plug_desc;
- fprintf(stderr, "ERROR: %s:%d: can't connect to DBUS session\n", __FILE__, __LINE__);
+ sbus_unref(sbus);
return NULL;
}