aboutsummaryrefslogtreecommitdiffstats
path: root/src/afm-system-daemon.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-02-04 15:43:49 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2016-02-04 15:48:32 +0100
commit50dd441a11440201e1da9da81a7103677e2282ad (patch)
tree489d653e78e1be60ae10877656c7aa09c9c49297 /src/afm-system-daemon.c
parentbb15844347ed0d53a795d24dce7035ab27df4e53 (diff)
Adding uninstallation of widgets
Change-Id: I8558a77312590181de5313c89ea4c9bdb9b477c7 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afm-system-daemon.c')
-rw-r--r--src/afm-system-daemon.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/afm-system-daemon.c b/src/afm-system-daemon.c
index f02ff3d..ab87c97 100644
--- a/src/afm-system-daemon.c
+++ b/src/afm-system-daemon.c
@@ -31,6 +31,7 @@
#include "afm-db.h"
#include "wgt-info.h"
#include "wgtpkg-install.h"
+#include "wgtpkg-uninstall.h"
static const char appname[] = "afm-system-daemon";
static const char *rootdir = NULL;
@@ -117,7 +118,34 @@ static void on_install(struct jreq *jreq, struct json_object *req)
static void on_uninstall(struct jreq *jreq, struct json_object *req)
{
- jbus_reply_error_s(jreq, "\"not yet implemented\"");
+ const char *idaver;
+ const char *root;
+ int rc;
+
+ /* scan the request */
+ switch (json_object_get_type(req)) {
+ case json_type_string:
+ idaver = json_object_get_string(req);
+ root = rootdir;
+ break;
+ case json_type_object:
+ idaver = j_get_string(req, "id", NULL);
+ if (idaver != NULL) {
+ root = j_get_string(req, "root", rootdir);
+ break;
+ }
+ default:
+ jbus_reply_error_s(jreq, error_bad_request);
+ return;
+ }
+
+ /* install the widget */
+ rc = uninstall_widget(idaver, root);
+ if (rc) {
+ jbus_reply_error_s(jreq, "\"uninstallation had error\"");
+ return;
+ }
+ jbus_reply_s(jreq, "true");
}
static int daemonize()