summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2018-05-22 18:47:22 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2018-06-14 15:19:08 +0200
commitfec10d1a986a807df4c6fa27d848199399806236 (patch)
tree9ac0dbeab771592c8391fa279814b7649290df87
parent436bbc24ea7fbe34d740f56574c52b5aaf7cbf58 (diff)
afm-user-daemon: Update to binder changes for bindings v3
The bindings v3 are now allowed to return an object with errors. To enforce taking that change into account, the signature of the object changed. It implies some change in clients. Change-Id: I810b625c7e3abec8dcce7fba44e3b4d7ac7f5473 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afm-user-daemon.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/afm-user-daemon.c b/src/afm-user-daemon.c
index 324e9a8..22c3d81 100644
--- a/src/afm-user-daemon.c
+++ b/src/afm-user-daemon.c
@@ -113,14 +113,23 @@ static const char *uri;
*
*/
static void on_pws_hangup(void *closure);
-static void on_pws_reply_success(void *closure, void *request, struct json_object *result, const char *info);
-static void on_pws_reply_fail(void *closure, void *request, const char *status, const char *info);
+static void on_pws_reply(void *closure, void *request, struct json_object *obj, const char *error, const char *info);
+#if !defined(AFB_PROTO_WS_VERSION) || (AFB_PROTO_WS_VERSION < 3)
+static void on_pws_reply_success(void *closure, void *request, struct json_object *result, const char *info)
+ { on_pws_reply(closure, request, result, NULL, info); }
+static void on_pws_reply_fail(void *closure, void *request, const char *error, const char *info)
+ { on_pws_reply(closure, request, NULL, error, info); }
+#endif
static void on_pws_event_broadcast(void *closure, const char *event_name, struct json_object *data);
/* the callback interface for pws */
static struct afb_proto_ws_client_itf pws_itf = {
+#if !defined(AFB_PROTO_WS_VERSION) || (AFB_PROTO_WS_VERSION < 3)
.on_reply_success = on_pws_reply_success,
.on_reply_fail = on_pws_reply_fail,
+#else
+ .on_reply = on_pws_reply,
+#endif
.on_event_broadcast = on_pws_event_broadcast,
};
@@ -156,16 +165,13 @@ static void attempt_connect_pws(int count)
}
}
-static void on_pws_reply_success(void *closure, void *request, struct json_object *result, const char *info)
-{
- struct sd_bus_message *smsg = request;
- jbus_reply_j(smsg, result);
-}
-
-static void on_pws_reply_fail(void *closure, void *request, const char *status, const char *info)
+static void on_pws_reply(void *closure, void *request, struct json_object *obj, const char *error, const char *info)
{
struct sd_bus_message *smsg = request;
- jbus_reply_error_s(smsg, status);
+ if (error)
+ jbus_reply_error_s(smsg, error);
+ else
+ jbus_reply_j(smsg, obj);
}
static void on_pws_event_broadcast(void *closure, const char *event_name, struct json_object *data)