+ int runid;
+ struct json_object *resp;
+ if (onrunid(jreq, obj, "state", &runid)) {
+ resp = afm_run_state(runid);
+ reply(jreq, resp, error_not_found);
+ json_object_put(resp);
+ }
+}
+
+/*
+ * Calls the system daemon to achieve application management of
+ * the 'method' gotten from 'jreq' with the parameter's string 'msg'.
+ *
+ * The principle is very simple: call the corresponding system method
+ * and reply its response to the caller.
+ *
+ * The request and reply is synchronous and is blocking.
+ * It is possible to implment it in an asynchrounous way but it
+ * would brake the common behaviour. It would be a call like
+ * jbus_call_ss(system_bus, method, msg, callback, jreq)
+ */
+static void propagate(struct jreq *jreq, const char *msg, const char *method)
+{
+ char *reply;
+ INFO("method %s propagated with %s", method, msg);
+ reply = jbus_call_ss_sync(system_bus, method, msg);
+ if (reply) {
+ jbus_reply_s(jreq, reply);
+ free(reply);
+ }
+ else
+ jbus_reply_error_s(jreq, error_system);
+}
+
+/*
+ * On query "install" from 'jreq' with parameters of 'msg'.
+ */
+static void on_install(struct jreq *jreq, const char *msg, void *unused)
+{
+ return propagate(jreq, msg, "install");