#include "afb-common.h"
#include "session.h"
+#include "afb-msg-json.h"
#include "afb-apis.h"
#include "afb-api-so.h"
#include "afb-context.h"
#include "afb-evt.h"
+#include "afb-subcall.h"
#include "verbose.h"
static const char DEFAULT_PATH_PREFIX[] = "/org/agl/afb/api/";
/* get the argument of the request of 'name' */
static struct afb_arg dbus_req_get(struct dbus_req *dreq, const char *name)
{
- struct afb_arg arg;
- struct json_object *value, *root;
-
- root = dbus_req_json(dreq);
- if (root != NULL && json_object_object_get_ex(root, name, &value)) {
- arg.name = name;
- arg.value = json_object_get_string(value);
- } else {
- arg.name = NULL;
- arg.value = NULL;
- }
- arg.path = NULL;
- return arg;
+ return afb_msg_json_get_arg(dbus_req_json(dreq), name);
}
static void dbus_req_reply(struct dbus_req *dreq, uint8_t type, const char *first, const char *second)
dbus_req_reply(dreq, RETRAW, buffer, "");
}
+static int dbus_req_subscribe(struct dbus_req *dreq, struct afb_event event)
+{
+ return -1;
+}
+
+static int dbus_req_unsubscribe(struct dbus_req *dreq, struct afb_event event)
+{
+ return -1;
+}
+
+static void dbus_req_subcall(struct dbus_req *dreq, const char *api, const char *verb, struct json_object *args, void (*callback)(void*, int, struct json_object*), void *closure);
+
const struct afb_req_itf afb_api_dbus_req_itf = {
.json = (void*)dbus_req_json,
.get = (void*)dbus_req_get,
.context_get = (void*)afb_context_get,
.context_set = (void*)afb_context_set,
.addref = (void*)dbus_req_addref,
- .unref = (void*)dbus_req_unref
+ .unref = (void*)dbus_req_unref,
+ .session_close = (void*)afb_context_close,
+ .session_set_LOA = (void*)afb_context_change_loa,
+ .subscribe = (void*)dbus_req_subscribe,
+ .unsubscribe = (void*)dbus_req_unsubscribe,
+ .subcall = (void*)dbus_req_subcall
};
+static void dbus_req_subcall(struct dbus_req *dreq, const char *api, const char *verb, struct json_object *args, void (*callback)(void*, int, struct json_object*), void *closure)
+{
+ afb_subcall(&dreq->context, api, verb, args, callback, closure, (struct afb_req){ .itf = &afb_api_dbus_req_itf, .closure = dreq });
+}
+
/******************* server part **********************************/
/* called when the object for the service is called */