{ "quiet", no_argument, NULL, 'q' },
{ "verbose", no_argument, NULL, 'v' },
{ "help", no_argument, NULL, 'h' },
{ "quiet", no_argument, NULL, 'q' },
{ "verbose", no_argument, NULL, 'v' },
{ "help", no_argument, NULL, 'h' },
-static void on_install(struct jreq *jreq, struct json_object *req)
+static void do_reloads()
+{
+ /* enforce daemon reload */
+ systemd_daemon_reload(0);
+ systemd_unit_restart_name(0, "sockets.target");
+}
+
+static void on_install(struct sd_bus_message *smsg, struct json_object *req, void *unused)
break;
case json_type_object:
wgtfile = j_string_at(req, "wgt", NULL);
if (wgtfile != NULL) {
root = j_string_at(req, "root", rootdir);
force = j_boolean_at(req, "force", 0);
break;
case json_type_object:
wgtfile = j_string_at(req, "wgt", NULL);
if (wgtfile != NULL) {
root = j_string_at(req, "root", rootdir);
force = j_boolean_at(req, "force", 0);
/* build the response */
resp = json_object_new_object();
if(!resp || !j_add_string(resp, "added", wgt_info_desc(ifo)->idaver))
/* build the response */
resp = json_object_new_object();
if(!resp || !j_add_string(resp, "added", wgt_info_desc(ifo)->idaver))
- jbus_reply_error_s(jreq, "\"out of memory but installed!\"");
- else
- jbus_reply_j(jreq, resp);
+ jbus_reply_error_s(smsg, "\"out of memory but installed!\"");
+ else {
+ jbus_send_signal_s(jbus, "changed", "true");
+ jbus_reply_j(smsg, resp);
+ }
- jbus_reply_error_s(jreq, "\"uninstallation had error\"");
- else
- jbus_reply_s(jreq, "true");
-
- /* still sends the signal */
- jbus_send_signal_s(jbus, "changed", "true");
+ jbus_reply_error_s(smsg, "\"uninstallation had error\"");
+ else {
+ jbus_send_signal_s(jbus, "changed", "true");
+ jbus_reply_s(smsg, "true");
+ }
- while ((i = getopt_long(ac, av, "hdqvr:", options, NULL)) >= 0) {
+ while ((i = getopt_long(ac, av, "hdqvVr:", options, NULL)) >= 0) {
+ /* get systemd objects */
+ rc = sd_event_new(&evloop);
+ if (rc < 0) {
+ ERROR("can't create event loop");
+ return 1;
+ }
+ rc = sd_bus_open_system(&sysbus);
+ if (rc < 0) {
+ ERROR("can't create system bus");
+ return 1;
+ }
+ rc = sd_bus_attach_event(sysbus, evloop, 0);
+ if (rc < 0) {
+ ERROR("can't attach system bus to event loop");
+ return 1;
+ }
+
- if(jbus_add_service_j(jbus, "install", on_install)
- || jbus_add_service_j(jbus, "uninstall", on_uninstall)) {
+ if(jbus_add_service_j(jbus, "install", on_install, NULL)
+ || jbus_add_service_j(jbus, "uninstall", on_uninstall, NULL)) {