- }
-
- /* get the application */
- INFO("method start called for %s", appid);
- appli = afm_udb_get_application_private(afudb, appid);
- if (appli == NULL) {
- jbus_reply_error_s(smsg, error_not_found);
- return;
- }
-
- /* launch the application */
- uri = NULL;
- runid = afm_urun_start(appli);
- if (runid <= 0) {
- jbus_reply_error_s(smsg, error_cant_start);
- free(uri);
- return;
- }
-
- if (uri == NULL) {
- /* returns only the runid */
- snprintf(runidstr, sizeof runidstr, "%d", runid);
- runidstr[sizeof runidstr - 1] = 0;
- jbus_reply_s(smsg, runidstr);
- return;
- }
-
- /* returns the runid and its uri */
- resp = json_object_new_object();
- if (resp != NULL && j_add_integer(resp, "runid", runid)
- && j_add_string(resp, "uri", uri))
- jbus_reply_j(smsg, resp);
- else {
- afm_urun_terminate(runid);
- jbus_reply_error_s(smsg, error_system);
- }
- json_object_put(resp);
- free(uri);
-}
-
-/*
- * On query "once" from 'smsg' with parameters of 'obj'.
- */
-static void on_once(struct sd_bus_message *smsg, struct json_object *obj, void *unused)
-{
- const char *appid;
- struct json_object *appli, *resp;
- int runid;
-
- /* get the parameters */
- if (!j_read_string(obj, &appid) && !j_read_string_at(obj, "id", &appid)) {
- jbus_reply_error_s(smsg, error_bad_request);
- return;
- }
-
- /* get the application */
- INFO("method once called for %s", appid);
- appli = afm_udb_get_application_private(afudb, appid);
- if (appli == NULL) {
- jbus_reply_error_s(smsg, error_not_found);
- return;
- }
-
- /* launch the application */
- runid = afm_urun_once(appli);
- if (runid <= 0) {
- jbus_reply_error_s(smsg, error_cant_start);
- return;
- }
-
- /* returns the state */
- resp = afm_urun_state(afudb, runid);
- reply(smsg, resp, error_not_found);
- json_object_put(resp);
-}
-
-/*
- * On query "pause" from 'smsg' with parameters of 'obj'.
- */
-static void on_pause(struct sd_bus_message *smsg, struct json_object *obj, void *unused)
-{
- int runid, status;
- if (onrunid(smsg, obj, "pause", &runid)) {
- status = afm_urun_pause(runid);
- reply_status(smsg, status, error_not_found);
- }
-}
-
-/*
- * On query "resume" from 'smsg' with parameters of 'obj'.
- */
-static void on_resume(struct sd_bus_message *smsg, struct json_object *obj, void *unused)
-{
- int runid, status;
- if (onrunid(smsg, obj, "resume", &runid)) {
- status = afm_urun_resume(runid);
- reply_status(smsg, status, error_not_found);