subcall_req: introduce afb_req_subcall_req
[src/app-framework-binder.git] / src / afb-hook.c
index bf90732..05b04ae 100644 (file)
@@ -281,6 +281,16 @@ static void hook_xreq_unstore_default_cb(void * closure, const struct afb_xreq *
        _hook_xreq_(xreq, "unstore()");
 }
 
+static void hook_xreq_subcall_req_default_cb(void * closure, const struct afb_xreq *xreq, const char *api, const char *verb, struct json_object *args)
+{
+       _hook_xreq_(xreq, "subcall_req(%s/%s, %s) ...", api, verb, json_object_to_json_string(args));
+}
+
+static void hook_xreq_subcall_req_result_default_cb(void * closure, const struct afb_xreq *xreq, int status, struct json_object *result)
+{
+       _hook_xreq_(xreq, "    ...subcall_req... -> %d: %s", status, json_object_to_json_string(result));
+}
+
 static struct afb_hook_xreq_itf hook_xreq_default_itf = {
        .hook_xreq_begin = hook_xreq_begin_default_cb,
        .hook_xreq_end = hook_xreq_end_default_cb,
@@ -302,7 +312,9 @@ static struct afb_hook_xreq_itf hook_xreq_default_itf = {
        .hook_xreq_subcallsync_result = hook_xreq_subcallsync_result_default_cb,
        .hook_xreq_vverbose = hook_xreq_vverbose_default_cb,
        .hook_xreq_store = hook_xreq_store_default_cb,
-       .hook_xreq_unstore = hook_xreq_unstore_default_cb
+       .hook_xreq_unstore = hook_xreq_unstore_default_cb,
+       .hook_xreq_subcall_req = hook_xreq_subcall_req_default_cb,
+       .hook_xreq_subcall_req_result = hook_xreq_subcall_req_result_default_cb
 };
 
 /******************************************************************************
@@ -438,6 +450,16 @@ void afb_hook_xreq_unstore(const struct afb_xreq *xreq)
        _HOOK_XREQ_(unstore, xreq);
 }
 
+void afb_hook_xreq_subcall_req(const struct afb_xreq *xreq, const char *api, const char *verb, struct json_object *args)
+{
+       _HOOK_XREQ_(subcall_req, xreq, api, verb, args);
+}
+
+void afb_hook_xreq_subcall_req_result(const struct afb_xreq *xreq, int status, struct json_object *result)
+{
+       _HOOK_XREQ_(subcall_req_result, xreq, status, result);
+}
+
 /******************************************************************************
  * section: hooking xreqs
  *****************************************************************************/
@@ -647,6 +669,16 @@ static void hook_ditf_unstore_req_cb(void * closure,  const struct afb_ditf *dit
        _hook_ditf_(ditf, "unstore_req(%p)", sreq);
 }
 
+static void hook_ditf_require_api_cb(void *closure, const struct afb_ditf *ditf, const char *name, int initialized)
+{
+       _hook_ditf_(ditf, "require_api(%s, %d)...", name, initialized);
+}
+
+static void hook_ditf_require_api_result_cb(void *closure, const struct afb_ditf *ditf, const char *name, int initialized, int result)
+{
+       _hook_ditf_(ditf, "...require_api(%s, %d) -> %d", name, initialized, result);
+}
+
 static struct afb_hook_ditf_itf hook_ditf_default_itf = {
        .hook_ditf_event_broadcast_before = hook_ditf_event_broadcast_before_cb,
        .hook_ditf_event_broadcast_after = hook_ditf_event_broadcast_after_cb,
@@ -658,7 +690,9 @@ static struct afb_hook_ditf_itf hook_ditf_default_itf = {
        .hook_ditf_rootdir_get_fd = hook_ditf_rootdir_get_fd_cb,
        .hook_ditf_rootdir_open_locale = hook_ditf_rootdir_open_locale_cb,
        .hook_ditf_queue_job = hook_ditf_queue_job_cb,
-       .hook_ditf_unstore_req = hook_ditf_unstore_req_cb
+       .hook_ditf_unstore_req = hook_ditf_unstore_req_cb,
+       .hook_ditf_require_api = hook_ditf_require_api_cb,
+       .hook_ditf_require_api_result = hook_ditf_require_api_result_cb
 };
 
 /******************************************************************************
@@ -742,6 +776,17 @@ void afb_hook_ditf_unstore_req(const struct afb_ditf *ditf, struct afb_stored_re
        _HOOK_DITF_(unstore_req, ditf, sreq);
 }
 
+void afb_hook_ditf_require_api(const struct afb_ditf *ditf, const char *name, int initialized)
+{
+       _HOOK_DITF_(require_api, ditf, name, initialized);
+}
+
+int afb_hook_ditf_require_api_result(const struct afb_ditf *ditf, const char *name, int initialized, int result)
+{
+       _HOOK_DITF_(require_api_result, ditf, name, initialized, result);
+       return result;
+}
+
 /******************************************************************************
  * section: hooking ditf
  *****************************************************************************/