summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2015-12-22 22:04:01 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2015-12-22 22:04:01 +0100
commit84e91aa612523ebedcd1d58d2f2f9c30be4d405b (patch)
tree3387de66dba64dffce2cdeb5f62b630d726ef0f7
parent1398adf363c182f25603f7d0c1ff52c5be8267b2 (diff)
afm-main: update adress and bug fix
Change-Id: I01776950ddb1328957a8f59f7316aab1ad223f9a
-rw-r--r--plugins/afm-main-plugin/afm-main-plugin.c2
-rw-r--r--plugins/afm-main-plugin/utils-jbus.c18
-rw-r--r--plugins/afm-main-plugin/utils-jbus.h1
3 files changed, 16 insertions, 5 deletions
diff --git a/plugins/afm-main-plugin/afm-main-plugin.c b/plugins/afm-main-plugin/afm-main-plugin.c
index 56439905..bca28fe0 100644
--- a/plugins/afm-main-plugin/afm-main-plugin.c
+++ b/plugins/afm-main-plugin/afm-main-plugin.c
@@ -85,7 +85,7 @@ static AFB_plugin plug_desc = {
AFB_plugin *pluginRegister()
{
- jbus = create_jbus(1, "/org/AGL/afmMain");
+ jbus = create_jbus(1, "/org/AGL/afm/user");
return jbus ? &plug_desc : NULL;
}
diff --git a/plugins/afm-main-plugin/utils-jbus.c b/plugins/afm-main-plugin/utils-jbus.c
index 7e65723a..d58def90 100644
--- a/plugins/afm-main-plugin/utils-jbus.c
+++ b/plugins/afm-main-plugin/utils-jbus.c
@@ -272,6 +272,7 @@ static DBusHandlerResult incoming_resp(DBusConnection *connection, DBusMessage *
reply = json_tokener_parse(str);
status = reply ? 0 : -1;
jrw->onresp_j(iserror ? -1 : status, reply, jrw->data);
+ json_object_put(reply);
}
free(jrw);
@@ -318,6 +319,7 @@ static DBusHandlerResult incoming_call(DBusConnection *connection, DBusMessage *
if (query == NULL)
return reply_invalid_request(jreq);
srv->oncall_j(jreq, query);
+ json_object_put(query);
}
return DBUS_HANDLER_RESULT_HANDLED;
}
@@ -350,8 +352,10 @@ static DBusHandlerResult incoming_signal(DBusConnection *connection, DBusMessage
else {
/* handling json only */
obj = json_tokener_parse(str);
- if (obj != NULL)
+ if (obj != NULL) {
sig->onsignal_j(obj);
+ json_object_put(obj);
+ }
}
}
return DBUS_HANDLER_RESULT_HANDLED;
@@ -607,11 +611,17 @@ char *jbus_call_ss_sync(struct jbus *jbus, const char *method, const char *query
struct json_object *jbus_call_sj_sync(struct jbus *jbus, const char *method, const char *query)
{
- const char *str = jbus_call_ss_sync(jbus, method, query);
- return str ? json_tokener_parse(str) : NULL;
+ struct json_object *obj;
+ char *str = jbus_call_ss_sync(jbus, method, query);
+ if (str == NULL)
+ obj = NULL;
+ else {
+ obj = json_tokener_parse(str);
+ free(str);
+ }
+ return obj;
}
-
char *jbus_call_js_sync(struct jbus *jbus, const char *method, struct json_object *query)
{
const char *str = json_object_to_json_string(query);
diff --git a/plugins/afm-main-plugin/utils-jbus.h b/plugins/afm-main-plugin/utils-jbus.h
index 68e9b68a..218c21d6 100644
--- a/plugins/afm-main-plugin/utils-jbus.h
+++ b/plugins/afm-main-plugin/utils-jbus.h
@@ -51,3 +51,4 @@ extern int jbus_add_service_j(struct jbus *jbus, const char *method, void (*onca
extern int jbus_start_serving(struct jbus *jbus);
extern int jbus_send_signal_s(struct jbus *jbus, const char *name, const char *content);
extern int jbus_send_signal_j(struct jbus *jbus, const char *name, struct json_object *content);
+