/*
- * Copyright (C) 2015 "IoT.bzh"
+ * Copyright (C) 2015, 2016 "IoT.bzh"
* Author "Fulup Ar Foll"
*
* Licensed under the Apache License, Version 2.0 (the "License");
#include <assert.h>
#include <json-c/json.h>
-#include "afb-plugin.h"
+#include <afb/afb-plugin.h>
#include "utils-jbus.h"
static const char _uninstall_[] = "uninstall";
static const char _uri_[] = "uri";
-static const struct AFB_interface *interface;
-static struct afb_evmgr evmgr;
+static const struct AFB_interface *afb_interface;
+static struct afb_event_sender event_sender;
static struct jbus *jbus;
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)
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) {
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) {
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) {
/* 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 */
/* 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);
}
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);
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"},
};
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;
- evmgr = afb_daemon_get_evmgr(itf->daemon);
+ assert (afb_interface == NULL);
+ afb_interface = itf;
+ 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);