#define IOTCON_DBUS_OBJPATH "/org/tizen/iotcon/dbus"
-#define IC_DBUS_SIGNAL_LENGTH 20
+#define IC_DBUS_SIGNAL_LENGTH 30
#define IC_DBUS_SIGNAL_REQUEST_HANDLER "REQ"
#define IC_DBUS_SIGNAL_FOUND_RESOURCE "RES"
<arg type="as" name="resource_types" direction="in"/>
<arg type="i" name="ifaces" direction="in"/>
<arg type="i" name="properties" direction="in"/>
- <arg type="u" name="signal_number" direction="in"/>
+ <arg type="x" name="signal_number" direction="in"/>
<arg type="x" name="resource" direction="out"/>
</method>
<method name="unregisterResource">
<arg type="s" name="host_address" direction="in"/>
<arg type="i" name="connectivity" direction="in"/>
<arg type="s" name="type" direction="in"/>
- <arg type="u" name="signal_number" direction="in"/>
+ <arg type="x" name="signal_number" direction="in"/>
<arg type="i" name="ret" direction="out"/>
</method>
<method name="get">
<arg type="(ssba(qs)i)" name="remote_resource" direction="in"/>
<arg type="i" name="observe_type" direction="in"/>
<arg type="a(ss)" name="query" direction="in"/>
- <arg type="u" name="signal_number" direction="in"/>
+ <arg type="x" name="signal_number" direction="in"/>
<arg type="x" name="observe_h" direction="out"/>
</method>
<method name="observerStop">
<method name="getDeviceInfo">
<arg type="s" name="host_address" direction="in"/>
<arg type="i" name="connectivity" direction="in"/>
- <arg type="u" name="signal_number" direction="in"/>
+ <arg type="x" name="signal_number" direction="in"/>
<arg type="i" name="ret" direction="out"/>
</method>
<method name="getPlatformInfo">
<arg type="s" name="host_address" direction="in"/>
<arg type="i" name="connectivity" direction="in"/>
- <arg type="u" name="signal_number" direction="in"/>
+ <arg type="x" name="signal_number" direction="in"/>
<arg type="i" name="ret" direction="out"/>
</method>
<method name="getTizenInfo">
<arg type="s" name="host_address" direction="in"/>
<arg type="i" name="connectivity" direction="in"/>
<arg type="s" name="type" direction="in"/>
- <arg type="u" name="signal_number" direction="in"/>
<arg type="x" name="presence_h" direction="out"/>
</method>
<method name="unsubscribePresence">
<arg type="x" name="presence_h" direction="in"/>
+ <arg type="s" name="host_address" direction="in"/>
<arg type="i" name="ret" direction="out"/>
</method>
<method name="startPresence">
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <stdint.h>
#include <stdlib.h>
#include <gio/gio.h>
typedef struct _icd_resource_handle {
OCResourceHandle handle;
- unsigned int signal_number;
+ int64_t signal_number;
} icd_resource_handle_s;
}
int icd_dbus_client_list_get_info(OCResourceHandle handle,
- unsigned int *signal_number, gchar **bus_name)
+ int64_t *signal_number, gchar **bus_name)
{
FN_CALL;
icd_dbus_client_s *client;
if (FALSE == ret) {
ERR("g_dbus_connection_emit_signal() Fail(%s)", error->message);
g_error_free(error);
+ g_variant_unref(value);
return IOTCON_ERROR_DBUS;
}
if (FALSE == g_dbus_connection_flush_sync(conn, NULL, &error)) {
ERR("g_dbus_connection_flush_sync() Fail(%s)", error->message);
g_error_free(error);
+ g_variant_unref(value);
return IOTCON_ERROR_DBUS;
}
}
static int _icd_dbus_resource_list_append_handle(const gchar *bus_name,
- OCResourceHandle handle, unsigned int signal_number)
+ OCResourceHandle handle, int64_t signal_number)
{
FN_CALL;
GList *cur_client, *cur_hd;
const gchar* const *resource_types,
gint ifaces,
gint properties,
- guint signal_number)
+ gint64 signal_number)
{
FN_CALL;
int ret;
const gchar *host_address,
gint connectivity,
const gchar *type,
- guint signal_number)
+ gint64 signal_number)
{
int ret;
const gchar *sender;
GVariant *resource,
gint observe_policy,
GVariant *query,
- guint signal_number)
+ gint64 signal_number)
{
OCDoHandle observe_h;
const gchar *sender;
GDBusMethodInvocation *invocation,
const gchar *host_address,
gint connectivity,
- guint signal_number)
+ gint64 signal_number)
{
int ret;
const gchar *sender;
GDBusMethodInvocation *invocation,
const gchar *host_address,
gint connectivity,
- guint signal_number)
+ gint64 signal_number)
{
int ret;
const gchar *sender;
GDBusMethodInvocation *invocation,
const gchar *host_address,
gint connectivity,
- const gchar *type,
- guint signal_number)
+ const gchar *type)
{
OCDoHandle presence_h;
- const gchar *sender;
- sender = g_dbus_method_invocation_get_sender(invocation);
- presence_h = icd_ioty_subscribe_presence(host_address, connectivity, type,
- signal_number, sender);
+ presence_h = icd_ioty_subscribe_presence(host_address, connectivity, type);
if (NULL == presence_h)
ERR("icd_ioty_subscribe_presence() Fail");
static gboolean _dbus_handle_unsubscribe_presence(icDbus *object,
GDBusMethodInvocation *invocation,
- gint64 presence_h)
+ gint64 presence_h,
+ const gchar *host_address)
{
int ret;
- ret = icd_ioty_unsubscribe_presence(ICD_INT64_TO_POINTER(presence_h));
+ ret = icd_ioty_unsubscribe_presence(ICD_INT64_TO_POINTER(presence_h), host_address);
if (IOTCON_ERROR_NONE != ret)
ERR("icd_ioty_unsubscribe_presence() Fail(%d)", ret);
#define ICD_POINTER_TO_INT64(p) ((int64_t)(intptr_t)(p))
icDbus* icd_dbus_get_object();
-int icd_dbus_client_list_get_info(void *handle, unsigned int *signal_number,
+int icd_dbus_client_list_get_info(void *handle, int64_t *signal_number,
gchar **bus_name);
int icd_dbus_emit_signal(const char *dest, const char *signal_name,
GVariant *value);
* limitations under the License.
*/
+#include <stdint.h>
#include <stdlib.h>
#include <unistd.h> /* for usleep() */
#include <glib.h>
struct icd_req_context {
- unsigned int signal_number;
+ int64_t signal_number;
char *bus_name;
int request_type;
int observe_id;
struct icd_find_context {
- unsigned int signal_number;
+ int64_t signal_number;
char *bus_name;
int conn_type;
GVariant **payload;
struct icd_info_context {
- unsigned int signal_number;
+ int64_t signal_number;
int info_type;
char *bus_name;
GVariant *payload;
struct icd_observe_context {
- unsigned int signal_number;
+ int64_t signal_number;
int res;
int seqnum;
char *bus_name;
struct icd_presence_context {
- unsigned int signal_number;
- char *bus_name;
+ OCDoHandle handle;
int result;
unsigned int nonce;
OCDevAddr *dev_addr;
static int _ocprocess_response_signal(const char *dest, const char *signal_prefix,
- unsigned int signal_number, GVariant *value)
+ int64_t signal_number, GVariant *value)
{
int ret;
char signal_name[IC_DBUS_SIGNAL_LENGTH] = {0};
- ret = snprintf(signal_name, sizeof(signal_name), "%s_%u", signal_prefix, signal_number);
+ ret = snprintf(signal_name, sizeof(signal_name), "%s_%llx", signal_prefix, signal_number);
if (ret <= 0 || sizeof(signal_name) <= ret) {
ERR("snprintf() Fail(%d)", ret);
return IOTCON_ERROR_IO_ERROR;
{
FN_CALL;
int ret;
- unsigned int signal_number;
+ int64_t signal_number;
char *query_str, *query_key, *query_value;
char *token, *save_ptr1, *save_ptr2;
char *bus_name = NULL;
static void _observe_cb_response_error(const char *dest,
- unsigned int signal_number, int ret_val)
+ int64_t signal_number, int ret_val)
{
int ret;
GVariant *value;
static int _worker_presence_cb(void *context)
{
- GVariant *value;
- int ret, conn_type;
+ int conn_type;
+ OCDoHandle handle;
char *host_address;
+ GVariant *value, *value2;
+ int ret = IOTCON_ERROR_NONE;
struct icd_presence_context *ctx = context;
RETV_IF(NULL == ctx, IOTCON_ERROR_INVALID_PARAMETER);
if (IOTCON_ERROR_NONE != ret) {
ERR("icd_ioty_get_host_address() Fail(%d)", ret);
free(ctx->resource_type);
- free(ctx->bus_name);
free(ctx->dev_addr);
free(ctx);
return ret;
value = g_variant_new("(iusiis)", ctx->result, ctx->nonce, host_address, conn_type,
ctx->trigger, ic_utils_dbus_encode_str(ctx->resource_type));
+ value2 = g_variant_ref(value);
free(host_address);
- ret = _ocprocess_response_signal(ctx->bus_name, IC_DBUS_SIGNAL_PRESENCE,
- ctx->signal_number, value);
+ ret = _ocprocess_response_signal(NULL, IC_DBUS_SIGNAL_PRESENCE,
+ ICD_POINTER_TO_INT64(ctx->handle), value);
if (IOTCON_ERROR_NONE != ret)
ERR("_ocprocess_response_signal() Fail(%d)", ret);
+ handle = icd_ioty_presence_table_get_handle(ICD_MULTICAST_ADDRESS);
+ if (handle && (handle != ctx->handle)) {
+ ret = _ocprocess_response_signal(NULL, IC_DBUS_SIGNAL_PRESENCE,
+ ICD_POINTER_TO_INT64(handle), value2);
+ if (IOTCON_ERROR_NONE != ret)
+ ERR("_ocprocess_response_signal() Fail(%d)", ret);
+ } else {
+ g_variant_unref(value2);
+ }
+
/* ctx was allocated from icd_ioty_ocprocess_presence_cb() */
free(ctx->resource_type);
- free(ctx->bus_name);
free(ctx->dev_addr);
free(ctx);
}
-static void _presence_cb_response_error(const char *dest, unsigned int signal_number,
- int ret_val)
+static void _presence_cb_response_error(OCDoHandle handle, int ret_val)
{
FN_CALL;
int ret;
- GVariant *value;
+ OCDoHandle handle2;
+ GVariant *value, *value2;
value = g_variant_new("(iusiis)", ret_val, 0, IC_STR_NULL, IOTCON_CONNECTIVITY_ALL,
IOTCON_PRESENCE_TRIGGER_RESOURCE_CREATED, IC_STR_NULL);
+ value2 = g_variant_ref(value);
- ret = _ocprocess_response_signal(dest, IC_DBUS_SIGNAL_PRESENCE, signal_number, value);
+ ret = _ocprocess_response_signal(NULL, IC_DBUS_SIGNAL_PRESENCE,
+ ICD_POINTER_TO_INT64(handle), value);
if (IOTCON_ERROR_NONE != ret)
ERR("_ocprocess_response_signal() Fail(%d)", ret);
+
+ handle2 = icd_ioty_presence_table_get_handle(ICD_MULTICAST_ADDRESS);
+ if (handle2 && (handle2 != handle)) {
+ ret = _ocprocess_response_signal(NULL, IC_DBUS_SIGNAL_PRESENCE,
+ ICD_POINTER_TO_INT64(handle), value2);
+ if (IOTCON_ERROR_NONE != ret)
+ ERR("_ocprocess_response_signal() Fail(%d)", ret);
+ } else {
+ g_variant_unref(value2);
+ }
}
int ret;
OCDevAddr *dev_addr;
OCPresencePayload *payload;
- icd_sig_ctx_s *sig_context = ctx;
struct icd_presence_context *presence_ctx;
- RETV_IF(NULL == ctx, OC_STACK_KEEP_TRANSACTION);
RETV_IF(NULL == resp, OC_STACK_KEEP_TRANSACTION);
presence_ctx = calloc(1, sizeof(struct icd_presence_context));
if (NULL == presence_ctx) {
ERR("calloc() Fail(%d)", errno);
- _presence_cb_response_error(sig_context->bus_name, sig_context->signal_number,
- IOTCON_ERROR_OUT_OF_MEMORY);
+ _presence_cb_response_error(handle, IOTCON_ERROR_OUT_OF_MEMORY);
return OC_STACK_KEEP_TRANSACTION;
}
dev_addr = calloc(1, sizeof(OCDevAddr));
if (NULL == dev_addr) {
ERR("calloc() Fail(%d)", errno);
- _presence_cb_response_error(sig_context->bus_name, sig_context->signal_number,
- IOTCON_ERROR_OUT_OF_MEMORY);
+ _presence_cb_response_error(handle, IOTCON_ERROR_OUT_OF_MEMORY);
free(presence_ctx);
return OC_STACK_KEEP_TRANSACTION;
}
ret = _presence_trigger_to_ioty_trigger(payload->trigger, &presence_ctx->trigger);
if (IOTCON_ERROR_NONE != ret) {
ERR("_presence_trigger_to_ioty_trigger() Fail(%d)", ret);
- _presence_cb_response_error(sig_context->bus_name, sig_context->signal_number,
- ret);
+ _presence_cb_response_error(handle, ret);
free(presence_ctx);
return OC_STACK_KEEP_TRANSACTION;
}
presence_ctx->result = IOTCON_ERROR_IOTIVITY;
}
- presence_ctx->signal_number = sig_context->signal_number;
- presence_ctx->bus_name = ic_utils_strdup(sig_context->bus_name);
+ presence_ctx->handle = handle;
presence_ctx->nonce = resp->sequenceNumber;
presence_ctx->dev_addr = dev_addr;
ret = _ocprocess_worker_start(_worker_presence_cb, presence_ctx);
if (IOTCON_ERROR_NONE != ret) {
ERR("_ocprocess_worker_start() Fail(%d)", ret);
- _presence_cb_response_error(sig_context->bus_name, sig_context->signal_number, ret);
+ _presence_cb_response_error(handle, ret);
free(presence_ctx->resource_type);
- free(presence_ctx->bus_name);
free(presence_ctx->dev_addr);
free(presence_ctx);
return OC_STACK_KEEP_TRANSACTION;
}
- /* DO NOT FREE sig_context. It MUST be freed in the ocstack */
/* DO NOT FREE presence_ctx. It MUST be freed in the _worker_presence_cb func */
return OC_STACK_KEEP_TRANSACTION;
#include "icd-ioty-type.h"
#include "icd-ioty-ocprocess.h"
-#define ICD_MULTICAST_ADDRESS "224.0.1.187:5683"
#define ICD_UUID_LENGTH 37
static const char *ICD_SYSTEM_INFO_TIZEN_ID = "http://tizen.org/system/tizenid";
static icd_tizen_info_s icd_tizen_info = {0};
+static GHashTable *icd_ioty_presence_table;
+
static GMutex icd_csdk_mutex;
void icd_ioty_csdk_lock()
int icd_ioty_find_resource(const char *host_address, int conn_type,
- const char *resource_type, unsigned int signal_number, const char *bus_name)
+ const char *resource_type, int64_t signal_number, const char *bus_name)
{
int len;
OCStackResult result;
OCDoHandle icd_ioty_observer_start(GVariant *resource, int observe_policy,
- GVariant *query, unsigned int signal_number, const char *bus_name)
+ GVariant *query, int64_t signal_number, const char *bus_name)
{
bool is_secure;
OCMethod method;
}
int icd_ioty_get_info(int type, const char *host_address, int conn_type,
- unsigned int signal_number, const char *bus_name)
+ int64_t signal_number, const char *bus_name)
{
OCStackResult result;
icd_sig_ctx_s *context;
}
+static void _icd_ioty_presence_table_create()
+{
+ if (icd_ioty_presence_table)
+ return;
+
+ icd_ioty_presence_table = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
+}
+
+
+static icd_presence_handle_info* _icd_ioty_presence_table_add(const char *host_address)
+{
+ icd_presence_handle_info *handle_info;
+
+ handle_info = calloc(1, sizeof(icd_presence_handle_info));
+ if (NULL == handle_info) {
+ ERR("calloc() Fail(%d)", errno);
+ return NULL;
+ }
+
+ handle_info->client_count = 1;
+
+ g_hash_table_insert(icd_ioty_presence_table, ic_utils_strdup(host_address),
+ handle_info);
+
+ return handle_info;
+}
+
+
+static void _icd_ioty_presence_table_destroy()
+{
+ g_hash_table_destroy(icd_ioty_presence_table);
+ icd_ioty_presence_table = NULL;
+}
+
+
+static void _icd_ioty_presence_table_remove(const char *host_address)
+{
+ icd_presence_handle_info *handle_info;
+
+ handle_info = g_hash_table_lookup(icd_ioty_presence_table, host_address);
+ if (NULL == handle_info)
+ return;
+
+ handle_info->client_count--;
+ if (0 < handle_info->client_count)
+ return;
+
+ g_hash_table_remove(icd_ioty_presence_table, host_address);
+
+ if (0 == g_hash_table_size(icd_ioty_presence_table))
+ _icd_ioty_presence_table_destroy();
+
+ return;
+}
+
+
+static icd_presence_handle_info* _icd_ioty_presence_table_get_handle_info(
+ const char *host_address)
+{
+ return g_hash_table_lookup(icd_ioty_presence_table, host_address);
+}
+
+
+OCDoHandle icd_ioty_presence_table_get_handle(const char *host_address)
+{
+ icd_presence_handle_info *handle_info;
+
+ handle_info = g_hash_table_lookup(icd_ioty_presence_table, host_address);
+ if (NULL == handle_info)
+ return NULL;
+
+ return handle_info->handle;
+}
+
+
OCDoHandle icd_ioty_subscribe_presence(const char *host_address, int conn_type,
- const char *resource_type, unsigned int signal_number, const char *bus_name)
+ const char *resource_type)
{
- int len;
OCDoHandle handle;
+ const char *address;
OCStackResult result;
- icd_sig_ctx_s *context;
char uri[PATH_MAX] = {0};
OCCallbackData cbdata = {0};
OCConnectivityType oic_conn_type;
+ icd_presence_handle_info *handle_info;
- if (IC_STR_EQUAL == strcmp(IC_STR_NULL, host_address) || '\0' == host_address[0]) {
- len = snprintf(uri, sizeof(uri), "%s%s", ICD_MULTICAST_ADDRESS,
- OC_RSRVD_PRESENCE_URI);
- } else {
- len = snprintf(uri, sizeof(uri), "%s%s", host_address, OC_RSRVD_PRESENCE_URI);
- }
- if (len <= 0 || sizeof(uri) <= len) {
- ERR("snprintf() Fail(%d)", len);
- return NULL;
- }
+ _icd_ioty_presence_table_create();
- if (IC_STR_EQUAL != strcmp(IC_STR_NULL, resource_type))
- snprintf(uri + len, sizeof(uri) - len, "?rt=%s", resource_type);
+ if (IC_STR_EQUAL == strcmp(IC_STR_NULL, host_address) || '\0' == host_address[0])
+ address = ICD_MULTICAST_ADDRESS;
+ else
+ address = host_address;
- context = calloc(1, sizeof(icd_sig_ctx_s));
- if (NULL == context) {
- ERR("calloc() Fail(%d)", errno);
+ handle_info = _icd_ioty_presence_table_get_handle_info(address);
+ if (handle_info) {
+ DBG("Already subscribe presence(%s)", address);
+ handle_info->client_count++;
+ return handle_info->handle;
+ }
+
+ handle_info = _icd_ioty_presence_table_add(address);
+ if (NULL == handle_info) {
+ ERR("_icd_ioty_presence_table_add() Fail");
return NULL;
}
- context->bus_name = ic_utils_strdup(bus_name);
- context->signal_number = signal_number;
- cbdata.context = context;
+ snprintf(uri, sizeof(uri), "%s%s", address, OC_RSRVD_PRESENCE_URI);
+
cbdata.cb = icd_ioty_ocprocess_presence_cb;
cbdata.cd = _ioty_free_signal_context;
if (OC_STACK_OK != result) {
ERR("OCDoResource() Fail(%d)", result);
- free(context->bus_name);
- free(context);
+ _icd_ioty_presence_table_remove(address);
return NULL;
}
+
+ handle_info->handle = handle;
+
return handle;
}
-int icd_ioty_unsubscribe_presence(OCDoHandle handle)
+int icd_ioty_unsubscribe_presence(OCDoHandle handle, const char *host_address)
{
OCStackResult ret;
return icd_ioty_convert_error(ret);
}
+ _icd_ioty_presence_table_remove(host_address);
+
return IOTCON_ERROR_NONE;
}
#define ICD_IOTY_COAP "coap://"
#define ICD_IOTY_COAPS "coaps://"
+#define ICD_MULTICAST_ADDRESS "224.0.1.187:5683"
+
/* TODO Define Tizen Information Resource(uri, resource type) */
#define ICD_IOTY_TIZEN_INFO_URI "/org/tizen/iot/d"
#define ICD_IOTY_TIZEN_INFO_TYPE "org.tizen.iot.d"
#define ICD_IOTY_TIZEN_INFO_TIZEN_DEVICE_ID "tizen_device_id"
typedef struct {
- unsigned int signal_number;
+ int64_t signal_number;
char *bus_name;
} icd_sig_ctx_s;
+typedef struct {
+ OCDoHandle handle;
+ int client_count;
+} icd_presence_handle_info;
+
enum {
ICD_CRUD_GET,
ICD_CRUD_PUT,
int icd_ioty_send_response(GVariant *resp);
int icd_ioty_find_resource(const char *host_address, int conn_type,
- const char *resource_type, unsigned int signal_number, const char *bus_name);
+ const char *resource_type, int64_t signal_number, const char *bus_name);
void icd_ioty_complete(int type, GDBusMethodInvocation *invocation, GVariant *value);
void icd_ioty_complete_error(int type, GDBusMethodInvocation *invocation, int ret_val);
GVariant *resource);
OCDoHandle icd_ioty_observer_start(GVariant *resource, int observe_type,
- GVariant *query, unsigned int signal_number, const char *bus_name);
+ GVariant *query, int64_t signal_number, const char *bus_name);
int icd_ioty_observer_stop(OCDoHandle handle, GVariant *options);
int icd_ioty_get_info(int type, const char *host_address, int conn_type,
- unsigned int signal_number, const char *bus_name);
+ int64_t signal_number, const char *bus_name);
int icd_ioty_set_device_info();
int icd_ioty_set_platform_info();
int icd_ioty_tizen_info_get_property(char **device_name, char **tizen_device_id);
+OCDoHandle icd_ioty_presence_table_get_handle(const char *host_address);
+
OCDoHandle icd_ioty_subscribe_presence(const char *host_address, int conn_type,
- const char *resource_type, unsigned int signal_number, const char *bus_name);
+ const char *resource_type);
-int icd_ioty_unsubscribe_presence(OCDoHandle handle);
+int icd_ioty_unsubscribe_presence(OCDoHandle handle, const char *host_address);
int icd_ioty_start_presence(unsigned int time_to_live);
* limitations under the License.
*/
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <gio/gio.h>
#include <tizen_type.h>
}
-unsigned int icl_dbus_generate_signal_number()
+int64_t icl_dbus_generate_signal_number()
{
- static unsigned int i = 0;
+ static int64_t i = 0;
return i++;
}
#ifndef __IOT_CONNECTIVITY_MANAGER_DBUS_H__
#define __IOT_CONNECTIVITY_MANAGER_DBUS_H__
+#include <stdint.h>
+
#include "ic-dbus.h"
#define ICL_DBUS_TIMEOUT_DEFAULT 30 /* 30 sec */
icDbus* icl_dbus_get_object();
-unsigned int icl_dbus_generate_signal_number();
+int64_t icl_dbus_generate_signal_number();
unsigned int icl_dbus_subscribe_signal(char *signal_name, void *cb_container,
void *cb_free, GDBusSignalCallback sig_handler);
* limitations under the License.
*/
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
void *user_data)
{
int ret;
+ unsigned int sub_id;
GError *error = NULL;
icl_device_info_s *cb_container;
- unsigned int sub_id, signal_number;
+ int64_t signal_number;
char signal_name[IC_DBUS_SIGNAL_LENGTH] = {0};
RETV_IF(NULL == icl_dbus_get_object(), IOTCON_ERROR_DBUS);
return icl_dbus_convert_daemon_error(ret);
}
- snprintf(signal_name, sizeof(signal_name), "%s_%u", IC_DBUS_SIGNAL_DEVICE,
+ snprintf(signal_name, sizeof(signal_name), "%s_%llx", IC_DBUS_SIGNAL_DEVICE,
signal_number);
cb_container = calloc(1, sizeof(icl_device_info_s));
void *user_data)
{
int ret;
+ unsigned int sub_id;
GError *error = NULL;
icl_platform_info_s *cb_container;
- unsigned int sub_id, signal_number;
+ int64_t signal_number;
char signal_name[IC_DBUS_SIGNAL_LENGTH] = {0};
RETV_IF(NULL == icl_dbus_get_object(), IOTCON_ERROR_DBUS);
return icl_dbus_convert_daemon_error(ret);
}
- snprintf(signal_name, sizeof(signal_name), "%s_%u", IC_DBUS_SIGNAL_PLATFORM,
+ snprintf(signal_name, sizeof(signal_name), "%s_%llx", IC_DBUS_SIGNAL_PLATFORM,
signal_number);
cb_container = calloc(1, sizeof(icl_platform_info_s));
iotcon_lite_resource_h *resource_handle)
{
int ret, iface;
+ unsigned int sub_id;
const gchar **types;
GError *error = NULL;
iotcon_lite_resource_h resource;
- unsigned int sub_id, signal_number;
+ int64_t signal_number;
char signal_name[IC_DBUS_SIGNAL_LENGTH];
RETV_IF(NULL == icl_dbus_get_object(), IOTCON_ERROR_DBUS);
return ret;
}
- snprintf(signal_name, sizeof(signal_name), "%s_%u", IC_DBUS_SIGNAL_REQUEST_HANDLER,
+ snprintf(signal_name, sizeof(signal_name), "%s_%llx", IC_DBUS_SIGNAL_REQUEST_HANDLER,
signal_number);
sub_id = icl_dbus_subscribe_signal(signal_name, resource,
g_variant_get(parameters, "(iu&sii&s)", &res, &nonce, &host_address,
&connectivity_type, &trigger, &resource_type);
+ response.resource_type = ic_utils_dbus_decode_str(resource_type);
+
+ if (response.resource_type && presence->resource_type) {
+ if (IC_STR_EQUAL != strcmp(response.resource_type, presence->resource_type))
+ return;
+ }
+
if (res < IOTCON_ERROR_NONE && cb)
cb(presence, icl_dbus_convert_daemon_error(res), NULL, presence->user_data);
- DBG("presence nonce : %d", nonce);
+ DBG("presence nonce : %u", nonce);
response.host_address = host_address;
response.connectivity_type = connectivity_type;
- response.resource_type = ic_utils_dbus_decode_str(resource_type);
response.result = res;
response.trigger = trigger;
{
FN_CALL;
int ret;
+ unsigned int sub_id;
GError *error = NULL;
icl_presence_s *presence;
- unsigned int sub_id, signal_number;
char signal_name[IC_DBUS_SIGNAL_LENGTH] = {0};
RETV_IF(NULL == icl_dbus_get_object(), IOTCON_ERROR_INVALID_PARAMETER);
return IOTCON_ERROR_INVALID_PARAMETER;
}
- signal_number = icl_dbus_generate_signal_number();
-
presence = calloc(1, sizeof(icl_presence_s));
if (NULL == presence) {
ERR("calloc() Fail(%d)", errno);
return IOTCON_ERROR_OUT_OF_MEMORY;
}
- resource_type = ic_utils_dbus_encode_str(resource_type);
-
ic_dbus_call_subscribe_presence_sync(icl_dbus_get_object(),
ic_utils_dbus_encode_str(host_address),
connectivity_type,
- resource_type,
- signal_number,
+ ic_utils_dbus_encode_str(resource_type),
&(presence->handle),
NULL,
&error);
return IOTCON_ERROR_IOTIVITY;
}
- snprintf(signal_name, sizeof(signal_name), "%s_%u", IC_DBUS_SIGNAL_PRESENCE,
- signal_number);
+ snprintf(signal_name, sizeof(signal_name), "%s_%llx", IC_DBUS_SIGNAL_PRESENCE,
+ presence->handle);
presence->cb = cb;
presence->user_data = user_data;
}
ic_dbus_call_unsubscribe_presence_sync(icl_dbus_get_object(), presence->handle,
- &ret, NULL, &error);
+ presence->host_address, &ret, NULL, &error);
if (error) {
ERR("ic_dbus_call_unsubscribe_presence_sync() Fail(%s)", error->message);
ret = icl_dbus_convert_dbus_error(error->code);
* limitations under the License.
*/
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <errno.h>
#include <glib.h>
{
int ret;
GError *error = NULL;
- unsigned int signal_number;
+ int64_t signal_number;
GVariant *arg_query, *arg_remote_resource;
char signal_name[IC_DBUS_SIGNAL_LENGTH] = {0};
return IOTCON_ERROR_IOTIVITY;
}
- snprintf(signal_name, sizeof(signal_name), "%s_%u", IC_DBUS_SIGNAL_OBSERVE,
+ snprintf(signal_name, sizeof(signal_name), "%s_%llx", IC_DBUS_SIGNAL_OBSERVE,
signal_number);
*sub_id = icl_dbus_subscribe_signal(signal_name, cb_container, cb_free, sig_handler);
* limitations under the License.
*/
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
void *user_data)
{
int ret;
+ unsigned int sub_id;
GError *error = NULL;
+ int64_t signal_number;
icl_found_resource_s *cb_container;
- unsigned int sub_id, signal_number;
char signal_name[IC_DBUS_SIGNAL_LENGTH] = {0};
RETV_IF(NULL == icl_dbus_get_object(), IOTCON_ERROR_DBUS);
return icl_dbus_convert_daemon_error(ret);
}
- snprintf(signal_name, sizeof(signal_name), "%s_%u", IC_DBUS_SIGNAL_FOUND_RESOURCE,
+ snprintf(signal_name, sizeof(signal_name), "%s_%llx", IC_DBUS_SIGNAL_FOUND_RESOURCE,
signal_number);
cb_container = calloc(1, sizeof(icl_found_resource_s));
iotcon_resource_h *resource_handle)
{
int ret;
+ unsigned int sub_id;
const gchar **types;
GError *error = NULL;
iotcon_resource_h resource;
- unsigned int sub_id, signal_number;
+ int64_t signal_number;
char signal_name[IC_DBUS_SIGNAL_LENGTH];
RETV_IF(NULL == icl_dbus_get_object(), IOTCON_ERROR_DBUS);
resource->ifaces = ifaces;
resource->properties = properties;
- snprintf(signal_name, sizeof(signal_name), "%s_%u", IC_DBUS_SIGNAL_REQUEST_HANDLER,
+ snprintf(signal_name, sizeof(signal_name), "%s_%llx", IC_DBUS_SIGNAL_REQUEST_HANDLER,
signal_number);
sub_id = icl_dbus_subscribe_signal(signal_name, resource, _icl_resource_conn_cleanup,