#include <gio/gio.h>
#include <gio/gunixsocketaddress.h>
#include <app_common.h>
+#include <json.h>
#include "log-private.h"
#include "things-service.h"
#include "common-app-inf.h"
struct _ts_data {
char *app_id;
char *token;
+ char *project;
GSocket *socket;
GSocketAddress *addr;
GSocket *cl_socket;
ret_if(!a_obj);
obj = json_object_new_object();
- retv_if(!obj);
+ ret_if(!obj);
- time_o = json_object_new_int64(tb_int->time);
+ time_o = json_object_new_int64(tb_int->i_time);
goto_if(!time_o, ERROR);
json_object_object_add(obj, "x", time_o);
struct json_object *value_o = NULL;
struct json_object *time_o = NULL;
- ret_if(!tb_int);
+ ret_if(!tb_double);
ret_if(!a_obj);
obj = json_object_new_object();
- retv_if(!obj, NULL);
+ ret_if(!obj);
- time_o = json_object_new_int64(tb_double->time);
+ time_o = json_object_new_int64(tb_double->i_time);
goto_if(!time_o, ERROR);
json_object_object_add(obj, "x", time_o);
struct json_object *obj = NULL;
struct json_object *a_obj = NULL;
char *json_str = NULL;
- int i = 0;
- GList *temp_l = NULL;
retv_if(!tb_data, NULL);
retvm_if(!((tb_data->type == TS_VALUE_TYPE_INT) ||
break;
default:
_E("invalid type [%d]", tb_data->type);
- goto ERROR:
+ goto ERROR;
break;
}
if (handle->app_id)
g_free(handle->app_id);
+ if (handle->project)
+ g_free(handle->project);
+
if (handle->token)
g_free(handle->token);
{
GVariant *response = NULL;
int ret = 0;
+ const char *ret_msg = 0;
GError *error = NULL;
_D("call method [%s]", method);
response = g_dbus_proxy_call_sync(handle->proxy,
method,
- g_variant_new("(ssu)", handle->token, handle->app_id, (guint)getpid()),
+ g_variant_new("(sssu)",
+ handle->project, handle->token, handle->app_id, (guint)getpid()),
G_DBUS_CALL_FLAGS_NONE,
-1, /* The timeout in milliseconds or -1 to use the proxy default timeout. */
NULL, /* cancellable */
g_error_free(error);
return -1;
}
- g_variant_get(response, "(i)", ret);
- _D("method[%s] get response ret[%d]", method, ret);
+ if (!response)
+ return -1;
+
+ g_variant_get(response, "(i&s)", ret, &ret_msg);
+ _D("method[%s] get response ret[%d] - %s", method, ret, ret_msg);
g_variant_unref(response);
- return 0;
+ return ret;
}
static int _client_call_register(ts_handle handle)
return __client_method_call(TTD_APP_INF_METHOD_UNREG, handle);
}
-int things_service_init(ts_handle *handle)
+int things_service_init(ts_handle *handle, const char *project)
{
ts_handle _handle = NULL;
GError *error = NULL;
retv_if(!handle, -1);
_handle = g_try_malloc0(sizeof(ts_handle));
+ _handle->project = g_strdup(project);
_handle->app_id = _get_app_id();
if (!_handle->app_id) {
_E("failed to get app id");
{
ret_if(!tb_data);
- t_data = g_try_malloc0(sizeof(timebased_data));
- if (!t_data)
- return NULL;
-
- if (t_data->v_list)
+ if (tb_data->v_list)
g_list_free_full(tb_data->v_list, __timebase_value_free);
g_free(tb_data);