aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/afm-main-plugin/afm-main-plugin.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-05-17 23:36:23 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2016-05-17 23:40:04 +0200
commit65bc678960567038ca4d07d1f9c5784b6c7a7834 (patch)
tree2540a9bcfb1f1c14f68a8cdb2647fdc47793c5a3 /plugins/afm-main-plugin/afm-main-plugin.c
parentc4777bafebe62dc60c00f0dbd656112598267ccd (diff)
improves plugin interface
This commit improves the names and the organisation of the plugin interface for the developpers. Change-Id: Iaf191efbf8fd5d248884304b648258f0770ec5f5 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.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/plugins/afm-main-plugin/afm-main-plugin.c b/plugins/afm-main-plugin/afm-main-plugin.c
index 705efcb0..41e55404 100644
--- a/plugins/afm-main-plugin/afm-main-plugin.c
+++ b/plugins/afm-main-plugin/afm-main-plugin.c
@@ -45,7 +45,7 @@ static const char _terminate_[] = "terminate";
static const char _uninstall_[] = "uninstall";
static const char _uri_[] = "uri";
-static const struct AFB_interface *interface;
+static const struct AFB_interface *afb_interface;
static struct afb_evmgr evmgr;
static struct jbus *jbus;
@@ -96,7 +96,7 @@ static struct json_object *embed(const char *tag, struct json_object *obj)
static void embed_call_void_callback(int status, struct json_object *obj, struct memo *memo)
{
- if (interface->verbosity)
+ if (afb_interface->verbosity)
fprintf(stderr, "(afm-main-plugin) %s(true) -> %s\n", memo->method,
obj ? json_object_to_json_string(obj) : "NULL");
if (obj == NULL) {
@@ -127,7 +127,7 @@ static void embed_call_void(struct afb_req request, const char *method)
static void call_appid_callback(int status, struct json_object *obj, struct memo *memo)
{
- if (interface->verbosity)
+ if (afb_interface->verbosity)
fprintf(stderr, "(afm-main-plugin) %s -> %s\n", memo->method,
obj ? json_object_to_json_string(obj) : "NULL");
if (obj == NULL) {
@@ -171,7 +171,7 @@ static void call_runid(struct afb_req request, const char *method)
return;
}
obj = jbus_call_sj_sync(jbus, method, id);
- if (interface->verbosity)
+ if (afb_interface->verbosity)
fprintf(stderr, "(afm-main-plugin) %s(%s) -> %s\n", method, id,
obj ? json_object_to_json_string(obj) : "NULL");
if (obj == NULL) {
@@ -210,7 +210,7 @@ static void start(struct afb_req request)
/* get the mode */
mode = afb_req_value(request, _mode_);
if (mode == NULL || !strcmp(mode, _auto_)) {
- mode = interface->mode == AFB_MODE_REMOTE ? _remote_ : _local_;
+ mode = afb_interface->mode == AFB_MODE_REMOTE ? _remote_ : _local_;
}
/* create the query */
@@ -222,7 +222,7 @@ static void start(struct afb_req request)
/* calls the service */
obj = jbus_call_sj_sync(jbus, _start_, query);
- if (interface->verbosity)
+ if (afb_interface->verbosity)
fprintf(stderr, "(afm-main-plugin) start(%s) -> %s\n", query,
obj ? json_object_to_json_string(obj) : "NULL");
free(query);
@@ -287,7 +287,7 @@ static void install(struct afb_req request)
}
obj = jbus_call_sj_sync(jbus, _install_, query);
- if (interface->verbosity)
+ if (afb_interface->verbosity)
fprintf(stderr, "(afm-main-plugin) install(%s) -> %s\n", query,
obj ? json_object_to_json_string(obj) : "NULL");
free(query);
@@ -311,7 +311,7 @@ static void uninstall(struct afb_req request)
call_appid(request, _uninstall_);
}
-static const struct AFB_restapi plug_apis[] =
+static const struct AFB_verb_desc_v1 verbs[] =
{
{_runnables_, AFB_SESSION_CHECK, runnables, "Get list of runnable applications"},
{_detail_ , AFB_SESSION_CHECK, detail, "Get the details for one application"},
@@ -327,20 +327,22 @@ static const struct AFB_restapi plug_apis[] =
};
static const struct AFB_plugin plug_desc = {
- .type = AFB_PLUGIN_JSON,
- .info = "Application Framework Master Service",
- .prefix = "afm-main",
- .apis = plug_apis
+ .type = AFB_PLUGIN_VERSION_1,
+ .v1 = {
+ .info = "Application Framework Master Service",
+ .prefix = "afm-main",
+ .verbs = verbs
+ }
};
-const struct AFB_plugin *pluginRegister(const struct AFB_interface *itf)
+const struct AFB_plugin *pluginAfbV1Register(const struct AFB_interface *itf)
{
int rc;
struct sd_bus *sbus;
/* records the interface */
- assert (interface == NULL);
- interface = itf;
+ assert (afb_interface == NULL);
+ afb_interface = itf;
evmgr = afb_daemon_get_evmgr(itf->daemon);
/* creates the jbus for accessing afm-user-daemon */