From: José Bollo <jose.bollo@iot.bzh>
Date: Fri, 5 Feb 2016 10:16:25 +0000 (+0100)
Subject: afm-system-daemon: fix signaling
X-Git-Tag: 2.0.2~77
X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;h=1ab49d93991d4061c822cc48cf9b824754f8de8c;p=src%2Fapp-framework-main.git

afm-system-daemon: fix signaling

Change-Id: If225a38efbd1809a623d2cf54b125a6ba94fd095
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
---

diff --git a/src/afm-system-daemon.c b/src/afm-system-daemon.c
index ab87c97..65e7e33 100644
--- a/src/afm-system-daemon.c
+++ b/src/afm-system-daemon.c
@@ -95,25 +95,23 @@ static void on_install(struct jreq *jreq, struct json_object *req)
 
 	/* install the widget */
 	ifo = install_widget(wgtfile, root, force);
-	if (ifo == NULL) {
+	if (ifo == NULL)
 		jbus_reply_error_s(jreq, "\"installation failed\"");
-		return;
-	}
-
-	/* build the response */
-	resp = json_object_new_object();
-	if(!resp || !j_add_string(resp, "added", wgt_info_desc(ifo)->idaver)) {
-		json_object_put(resp);
+	else {
+		/* 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);
+
+		/* clean-up */
 		wgt_info_unref(ifo);
-		jbus_reply_error_s(jreq, "\"out of memory but installed!\"");
-		return;
+		json_object_put(resp);
 	}
-	wgt_info_unref(ifo);
 
-	/* reply and propagate event */
-	jbus_reply_j(jreq, resp);
-	jbus_send_signal_j(jbus, "changed", resp);
-	json_object_put(resp);
+	/* still sends the signal */
+	jbus_send_signal_s(jbus, "changed", "true");
 }
 
 static void on_uninstall(struct jreq *jreq, struct json_object *req)
@@ -141,11 +139,13 @@ static void on_uninstall(struct jreq *jreq, struct json_object *req)
 
 	/* install the widget */
 	rc = uninstall_widget(idaver, root);
-	if (rc) {
+	if (rc)
 		jbus_reply_error_s(jreq, "\"uninstallation had error\"");
-		return;
-	}
-	jbus_reply_s(jreq, "true");
+	else
+		jbus_reply_s(jreq, "true");
+
+	/* still sends the signal */
+	jbus_send_signal_s(jbus, "changed", "true");
 }
 
 static int daemonize()