-const char error_nothing[] = "[]";
-const char error_bad_request[] = "\"bad request\"";
-const char error_not_found[] = "\"not found\"";
-const char error_cant_start[] = "\"can't start\"";
-const char error_system[] = "\"system error\"";
-
-
-/*
- * retrieves the 'runid' in 'obj' parameters received with the
- * request 'smsg' for the 'method'.
- *
- * Returns 1 in case of success.
- * Otherwise, if the 'runid' can't be retrived, an error stating
- * the bad request is replied for 'smsg' and 0 is returned.
- */
-static int onrunid(struct sd_bus_message *smsg, struct json_object *obj,
- const char *method, int *runid)
-{
- if (!j_read_integer(obj, runid)
- && !j_read_integer_at(obj, "runid", runid)) {
- INFO("bad request method %s: %s", method,
- json_object_to_json_string(obj));
- jbus_reply_error_s(smsg, error_bad_request);
- return 0;
- }
-
- INFO("method %s called for %d", method, *runid);
- return 1;
-}
-
-/*
- * Sends the reply 'resp' to the request 'smsg' if 'resp' is not NULL.
- * Otherwise, when 'resp' is NULL replies the error string 'errstr'.
- */
-static void reply(struct sd_bus_message *smsg, struct json_object *resp,
- const char *errstr)
-{
- if (resp)
- jbus_reply_j(smsg, resp);
- else
- jbus_reply_error_s(smsg, errstr);
-}
-
-/*
- * Sends the reply "true" to the request 'smsg' if 'status' is zero.
- * Otherwise, when 'status' is not zero replies the error string 'errstr'.
- */
-static void reply_status(struct sd_bus_message *smsg, int status, const char *errstr)
-{
- if (status)
- jbus_reply_error_s(smsg, errstr);
- else
- jbus_reply_s(smsg, "true");
-}
-
-/*
- * On query "runnables" from 'smsg' with parameters of 'obj'.
- *
- * Nothing is expected in 'obj' that can be anything.
- */
-static void on_runnables(struct sd_bus_message *smsg, struct json_object *obj, void *unused)
-{
- struct json_object *resp;
- INFO("method runnables called");
-#ifdef LEGACY_MODE_WITHOUT_SYSTEMD
- resp = afm_db_application_list(afdb);
-#else
- resp = afm_udb_applications_public(afudb);
-#endif
- jbus_reply_j(smsg, resp);
- json_object_put(resp);
-}
-
-/*
- * On query "detail" from 'smsg' with parameters of 'obj'.
- */
-static void on_detail(struct sd_bus_message *smsg, struct json_object *obj, void *unused)
-{
- const char *appid;
- struct json_object *resp;
-
- /* get the parameters */
- if (j_read_string(obj, &appid))
- ; /* appid as a string */
- else if (j_read_string_at(obj, "id", &appid))
- ; /* appid as obj.id string */
- else {
- INFO("method detail called but bad request!");
- jbus_reply_error_s(smsg, error_bad_request);
- return;
- }
-
- /* wants details for appid */
- INFO("method detail called for %s", appid);
-#ifdef LEGACY_MODE_WITHOUT_SYSTEMD
- resp = afm_db_get_application_public(afdb, appid);
-#else
- resp = afm_udb_get_application_public(afudb, appid);
-#endif
- reply(smsg, resp, error_not_found);
- json_object_put(resp);
-}