X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafm-user-daemon.c;h=ff58e0334e596a1ee754e400ff6a9d8000281b25;hb=c9c0f8989ec6cdd55a8e584e8c93041ae2126282;hp=f6d2aef5488fe0511ee4a890d23bbeebab12252c;hpb=7fc272e5a9afc922f14c47b4c27d0a564e2de4ca;p=src%2Fapp-framework-main.git diff --git a/src/afm-user-daemon.c b/src/afm-user-daemon.c index f6d2aef..ff58e03 100644 --- a/src/afm-user-daemon.c +++ b/src/afm-user-daemon.c @@ -63,6 +63,7 @@ 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\""; static const char *getappid(struct json_object *obj) { @@ -168,6 +169,25 @@ static void on_state(struct jreq *jreq, struct json_object *obj) json_object_put(resp); } +static void propagate(struct jreq *jreq, const char *msg, const char *method) +{ + char *reply = jbus_call_ss_sync(jbuses[0], method, msg); + if (reply) + jbus_reply_s(jreq, reply); + else + jbus_reply_error_s(jreq, error_system); +} + +static void on_install(struct jreq *jreq, const char *msg) +{ + return propagate(jreq, msg, "install"); +} + +static void on_uninstall(struct jreq *jreq, const char *msg) +{ + return propagate(jreq, msg, "uninstall"); +} + static void on_signal_changed(struct json_object *obj) { /* update the database */ @@ -295,7 +315,9 @@ int main(int ac, char **av) || jbus_add_service_j(jbuses[1], "stop", on_stop) || jbus_add_service_j(jbuses[1], "continue", on_continue) || jbus_add_service_j(jbuses[1], "runners", on_runners) - || jbus_add_service_j(jbuses[1], "state", on_state)) { + || jbus_add_service_j(jbuses[1], "state", on_state) + || jbus_add_service_s(jbuses[1], "install", on_install) + || jbus_add_service_s(jbuses[1], "uninstall", on_uninstall)) { ERROR("adding services failed"); return 1; }