From b3249e80e9217954d7d6b27f6e89e244a1975063 Mon Sep 17 00:00:00 2001 From: Ismo Puustinen Date: Wed, 12 Feb 2014 11:06:46 +0200 Subject: [PATCH] amb: update to the new FindObject API. Change-Id: Id69004a0790c962e6b035c95814dc8d66a3f489d --- src/plugins/plugin-amb.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/plugins/plugin-amb.c b/src/plugins/plugin-amb.c index 46ae57b..de164ee 100644 --- a/src/plugins/plugin-amb.c +++ b/src/plugins/plugin-amb.c @@ -1049,11 +1049,32 @@ static void find_property_reply_handler(mrp_dbus_t *dbus, mrp_dbus_msg_t *msg, goto error; } + /* Array of object paths */ + + if (mrp_dbus_msg_arg_type(msg, NULL) != MRP_DBUS_TYPE_ARRAY) { + mrp_log_error("AMB: FindObject response doesn't contain an array"); + goto error; + } + + mrp_dbus_msg_enter_container(msg, MRP_DBUS_TYPE_ARRAY, NULL); + + /* We take the first one for now. */ + + /* TODO: open this for configuration? What does it mean if there are + multiple VehicleSpeed property objects, for example? */ + + if (mrp_dbus_msg_arg_type(msg, NULL) != MRP_DBUS_TYPE_OBJECT_PATH) { + mrp_log_error("AMB: no objects in the object path array"); + goto error; + } + if(!mrp_dbus_msg_read_basic(msg, MRP_DBUS_TYPE_OBJECT_PATH, &obj)) { mrp_log_error("AMB: Error fetching the object path from the message"); goto error; } + mrp_dbus_msg_exit_container(msg); /* array */ + mrp_free((char *) w->lua_prop->dbus_data.obj); w->lua_prop->dbus_data.obj = mrp_strdup(obj); @@ -1078,7 +1099,7 @@ static int find_property_object(data_t *ctx, dbus_property_watch_t *w, mrp_dbus_call(ctx->dbus, ctx->amb_addr, "/", "org.automotive.Manager", - "findProperty", 3000, find_property_reply_handler, w, + "FindObject", 3000, find_property_reply_handler, w, MRP_DBUS_TYPE_STRING, prop, MRP_DBUS_TYPE_INVALID); return 0; -- 2.7.4