+ struct json_object *resp;
+ const char *id, *mode;
+ char *query;
+ int rc;
+
+ /* get the id */
+ id = getQueryValue(request, _id_);
+ if (id == NULL) {
+ request->errcode = MHD_HTTP_BAD_REQUEST;
+ return NULL;
+ }
+ /* get the mode */
+ mode = getQueryValue(request, _mode_);
+ if (mode == NULL || !strcmp(mode, _auto_)) {
+ mode = request->config->mode == AFB_MODE_REMOTE ? _remote_ : _local_;
+ }
+
+ /* create the query */
+ rc = asprintf(&query, "{\"id\":\"%s\",\"mode\":\"%s\"}", id, mode);
+ if (rc < 0) {
+ request->errcode = MHD_HTTP_INTERNAL_SERVER_ERROR;
+ return NULL;
+ }
+
+ /* calls the service */
+ resp = jbus_call_sj_sync(jbus, _start_, query);
+ if (verbose)
+ fprintf(stderr, "(afm-main-plugin) call_start: %s -> %s\n", query, resp ? json_object_to_json_string(resp) : "NULL");
+ free(query);
+
+ /* embed if needed */
+ if (json_object_get_type(resp) == json_type_int)
+ resp = embed(request, _runid_, resp);
+ request->errcode = resp ? MHD_HTTP_OK : MHD_HTTP_FAILED_DEPENDENCY;
+ return resp;