event sender: better naming
authorJosé Bollo <jose.bollo@iot.bzh>
Tue, 17 May 2016 21:47:13 +0000 (23:47 +0200)
committerJosé Bollo <jose.bollo@iot.bzh>
Tue, 17 May 2016 21:47:13 +0000 (23:47 +0200)
Change-Id: I82d918cd14b1e368ef509fa3a1b21c3e55a6b98d
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
include/afb/afb-event-sender-itf.h [moved from include/afb/afb-evmgr-itf.h with 71% similarity]
include/afb/afb-plugin.h
plugins/afm-main-plugin/afm-main-plugin.c
plugins/samples/HelloWorld.c
src/afb-api-so.c

similarity index 71%
rename from include/afb/afb-evmgr-itf.h
rename to include/afb/afb-event-sender-itf.h
index 90b1e0a..ad35431 100644 (file)
 
 struct json_object;
 
-struct afb_evmgr_itf {
-       void (*push)(void *evmgr, const char *name, struct json_object *object);
+struct afb_event_sender_itf {
+       void (*push)(void *event_sender, const char *name, struct json_object *object);
 };
 
-struct afb_evmgr {
-       const struct afb_evmgr_itf *itf;
+struct afb_event_sender {
+       const struct afb_event_sender_itf *itf;
        void *closure;
 };
 
-static inline void afb_evmgr_push(struct afb_evmgr mgr, const char *name, struct json_object *object)
+static inline void afb_event_sender_push(struct afb_event_sender mgr, const char *name, struct json_object *object)
 {
        return mgr.itf->push(mgr.closure, name, object);
 }
index d3f6423..de1ab41 100644 (file)
@@ -18,7 +18,7 @@
 #pragma once
 
 #include <afb/afb-req-itf.h>
-#include <afb/afb-evmgr-itf.h>
+#include <afb/afb-event-sender-itf.h>
 
 /*
  * Definition of the versions of the plugin.
@@ -93,7 +93,7 @@ struct sd_bus;
  * Definition of the facilities provided by the daemon.
  */
 struct afb_daemon_itf {
-       struct afb_evmgr (*get_evmgr)(void *closure);           /* get the event manager */
+       struct afb_event_sender (*get_event_sender)(void *closure);           /* get the event manager */
        struct sd_event *(*get_event_loop)(void *closure);      /* get the common systemd's event loop */
        struct sd_bus *(*get_user_bus)(void *closure);          /* get the common systemd's user d-bus */
        struct sd_bus *(*get_system_bus)(void *closure);        /* get the common systemd's system d-bus */
@@ -101,7 +101,7 @@ struct afb_daemon_itf {
 
 /*
  * Structure for accessing daemon.
- * See also: afb_daemon_get_evmgr, afb_daemon_get_event_loop, afb_daemon_get_user_bus, afb_daemon_get_system_bus
+ * See also: afb_daemon_get_event_sender, afb_daemon_get_event_loop, afb_daemon_get_user_bus, afb_daemon_get_system_bus
  */
 struct afb_daemon {
        const struct afb_daemon_itf *itf;       /* the interfacing functions */
@@ -127,9 +127,9 @@ extern const struct AFB_plugin *pluginAfbV1Register (const struct AFB_interface
  * Retrieves the event sender of AFB
  * 'daemon' MUST be the daemon given in interface when activating the plugin.
  */
-static inline struct afb_evmgr afb_daemon_get_evmgr(struct afb_daemon daemon)
+static inline struct afb_event_sender afb_daemon_get_event_sender(struct afb_daemon daemon)
 {
-       return daemon.itf->get_evmgr(daemon.closure);
+       return daemon.itf->get_event_sender(daemon.closure);
 }
 
 /*
index 41e5540..786468a 100644 (file)
@@ -46,7 +46,7 @@ static const char _uninstall_[] = "uninstall";
 static const char _uri_[]       = "uri";
 
 static const struct AFB_interface *afb_interface;
-static struct afb_evmgr evmgr;
+static struct afb_event_sender event_sender;
 
 static struct jbus *jbus;
 
@@ -69,7 +69,7 @@ static struct memo *make_memo(struct afb_req request, const char *method)
 
 static void application_list_changed(const char *data, void *closure)
 {
-       afb_evmgr_push(evmgr, "application-list-changed", NULL);
+       afb_event_sender_push(event_sender, "application-list-changed", NULL);
 }
 
 static struct json_object *embed(const char *tag, struct json_object *obj)
@@ -343,7 +343,7 @@ const struct AFB_plugin *pluginAfbV1Register(const struct AFB_interface *itf)
        /* records the interface */
        assert (afb_interface == NULL);
        afb_interface = itf;
-       evmgr = afb_daemon_get_evmgr(itf->daemon);
+       event_sender = afb_daemon_get_event_sender(itf->daemon);
 
        /* creates the jbus for accessing afm-user-daemon */
        sbus = afb_daemon_get_user_bus(itf->daemon);
index 35b95ca..78a1eaf 100644 (file)
@@ -54,7 +54,7 @@ static void pingBug (struct afb_req request)
 static void pingEvent(struct afb_req request)
 {
        json_object *query = afb_req_json(request);
-       afb_evmgr_push(afb_daemon_get_evmgr(interface->daemon), "event", query);
+       afb_event_sender_push(afb_daemon_get_event_sender(interface->daemon), "event", query);
        ping(request, json_object_get(query), "event");
 }
 
index cc3447a..693385d 100644 (file)
@@ -29,7 +29,7 @@
 
 #include <afb/afb-plugin.h>
 #include <afb/afb-req-itf.h>
-#include <afb/afb-evmgr-itf.h>
+#include <afb/afb-event-sender-itf.h>
 
 #include "session.h"
 #include "afb-common.h"
@@ -50,7 +50,7 @@ static int api_timeout = 15;
 
 static const char plugin_register_function[] = "pluginAfbV1Entry";
 
-static void afb_api_so_evmgr_push(struct api_so_desc *desc, const char *name, struct json_object *object)
+static void afb_api_so_event_sender_push(struct api_so_desc *desc, const char *name, struct json_object *object)
 {
        size_t length;
        char *event;
@@ -64,17 +64,17 @@ static void afb_api_so_evmgr_push(struct api_so_desc *desc, const char *name, st
        ctxClientEventSend(NULL, event, object);
 }
 
-static const struct afb_evmgr_itf evmgr_itf = {
-       .push = (void*)afb_api_so_evmgr_push
+static const struct afb_event_sender_itf event_sender_itf = {
+       .push = (void*)afb_api_so_event_sender_push
 };
 
-static struct afb_evmgr afb_api_so_get_evmgr(struct api_so_desc *desc)
+static struct afb_event_sender afb_api_so_get_event_sender(struct api_so_desc *desc)
 {
-       return (struct afb_evmgr){ .itf = &evmgr_itf, .closure = desc };
+       return (struct afb_event_sender){ .itf = &event_sender_itf, .closure = desc };
 }
 
 static const struct afb_daemon_itf daemon_itf = {
-       .get_evmgr = (void*)afb_api_so_get_evmgr,
+       .get_event_sender = (void*)afb_api_so_get_event_sender,
        .get_event_loop = (void*)afb_common_get_event_loop,
        .get_user_bus = (void*)afb_common_get_user_bus,
        .get_system_bus = (void*)afb_common_get_system_bus