Add connectivity type
authoryoungman <yman.jung@samsung.com>
Fri, 23 Oct 2015 09:59:51 +0000 (18:59 +0900)
committeryoungman <yman.jung@samsung.com>
Tue, 3 Nov 2015 11:08:20 +0000 (20:08 +0900)
Change-Id: I9e0e5dd3647437eef62b922e5a7ae254195cda2b
Signed-off-by: youngman <yman.jung@samsung.com>
23 files changed:
common/ic-dbus.xml
daemon/icd-dbus.c
daemon/icd-ioty-ocprocess.c
daemon/icd-ioty.c
daemon/icd-ioty.h
doc/iotcon_doc.h
lib/icl-dbus-type.c
lib/icl-device.c
lib/icl-lite-resource.c
lib/icl-presence.c
lib/icl-remote-resource-monitoring.c
lib/icl-remote-resource.c
lib/icl-remote-resource.h
lib/icl-request.c
lib/icl-request.h
lib/icl-resource.c
lib/include/iotcon-struct.h
lib/include/iotcon.h
test/iotcon-test-basic-client.c
test/iotcon-test-basic-server.c
test/iotcon-test-device-client.c
test/iotcon-test-encap-client.c
test/iotcon-test-repr-client.c

index 9ad38e3..2ad4bc2 100644 (file)
@@ -43,6 +43,7 @@
                </method>
                <method name="findResource">
                        <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="i" name="ret" direction="out"/>
                </method>
                <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="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="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="(ssi)" name="ret" direction="out"/>
                </method>
                <method name="subscribePresence">
                        <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"/>
index bbe4ffb..6e12b2e 100644 (file)
@@ -495,6 +495,7 @@ static gboolean _dbus_handle_unbind_resource(icDbus *object,
 static gboolean _dbus_handle_find_resource(icDbus *object,
                GDBusMethodInvocation *invocation,
                const gchar *host_address,
+               gint connectivity,
                const gchar *type,
                guint signal_number)
 {
@@ -502,7 +503,7 @@ static gboolean _dbus_handle_find_resource(icDbus *object,
        const gchar *sender;
 
        sender = g_dbus_method_invocation_get_sender(invocation);
-       ret = icd_ioty_find_resource(host_address, type, signal_number, sender);
+       ret = icd_ioty_find_resource(host_address, connectivity, type, signal_number, sender);
        if (IOTCON_ERROR_NONE != ret)
                ERR("icd_ioty_find_resource() Fail(%d)", ret);
 
@@ -587,13 +588,15 @@ static gboolean _dbus_handle_send_response(icDbus *object,
 static gboolean _dbus_handle_get_device_info(icDbus *object,
                GDBusMethodInvocation *invocation,
                const gchar *host_address,
+               gint connectivity,
                guint signal_number)
 {
        int ret;
        const gchar *sender;
 
        sender = g_dbus_method_invocation_get_sender(invocation);
-       ret = icd_ioty_get_info(ICD_DEVICE_INFO, host_address, signal_number, sender);
+       ret = icd_ioty_get_info(ICD_DEVICE_INFO, host_address, connectivity, signal_number,
+                       sender);
        if (IOTCON_ERROR_NONE != ret)
                ERR("icd_ioty_get_info(device info) Fail(%d)", ret);
 
@@ -605,13 +608,15 @@ static gboolean _dbus_handle_get_device_info(icDbus *object,
 static gboolean _dbus_handle_get_platform_info(icDbus *object,
                GDBusMethodInvocation *invocation,
                const gchar *host_address,
+               gint connectivity,
                guint signal_number)
 {
        int ret;
        const gchar *sender;
 
        sender = g_dbus_method_invocation_get_sender(invocation);
-       ret = icd_ioty_get_info(ICD_PLATFORM_INFO, host_address, signal_number, sender);
+       ret = icd_ioty_get_info(ICD_PLATFORM_INFO, host_address, connectivity, signal_number,
+                       sender);
        if (IOTCON_ERROR_NONE != ret)
                ERR("icd_ioty_get_info(platform info) Fail(%d)", ret);
 
@@ -655,6 +660,7 @@ static gboolean _dbus_handle_stop_presence(icDbus *object,
 static gboolean _dbus_handle_subscribe_presence(icDbus *object,
                GDBusMethodInvocation *invocation,
                const gchar *host_address,
+               gint connectivity,
                const gchar *type,
                guint signal_number)
 {
@@ -662,7 +668,8 @@ static gboolean _dbus_handle_subscribe_presence(icDbus *object,
        const gchar *sender;
 
        sender = g_dbus_method_invocation_get_sender(invocation);
-       presence_h = icd_ioty_subscribe_presence(host_address, type, signal_number, sender);
+       presence_h = icd_ioty_subscribe_presence(host_address, connectivity, type,
+                       signal_number, sender);
        if (NULL == presence_h)
                ERR("icd_ioty_subscribe_presence() Fail");
 
index 5c41470..3ca4d8a 100644 (file)
@@ -211,8 +211,8 @@ static inline GVariantBuilder* _ocprocess_parse_header_options(
 
 static int _worker_req_handler(void *context)
 {
-       int ret;
        GVariant *value;
+       int ret, conn_type;
        struct icd_req_context *ctx = context;
        GVariantBuilder payload_builder;
        char addr[PATH_MAX] = {0};
@@ -226,8 +226,12 @@ static int _worker_req_handler(void *context)
        if (ctx->dev_addr->addr && *ctx->dev_addr->addr)
                snprintf(addr, sizeof(addr), "%s:%d", ctx->dev_addr->addr, ctx->dev_addr->port);
 
-       value = g_variant_new("(sia(qs)a(ss)iiavxx)",
+       conn_type = icd_ioty_transport_flag_to_conn_type(ctx->dev_addr->adapter,
+                       ctx->dev_addr->flags);
+
+       value = g_variant_new("(siia(qs)a(ss)iiavxx)",
                        addr,
+                       conn_type,
                        ctx->types,
                        ctx->options,
                        ctx->query,
index d7c6481..b7d40db 100644 (file)
@@ -385,8 +385,8 @@ static void _ioty_free_signal_context(void *data)
 }
 
 
-int icd_ioty_find_resource(const char *host_address, const char *resource_type,
-               unsigned int signum, const char *bus_name)
+int icd_ioty_find_resource(const char *host_address, int conn_type,
+               const char *resource_type, unsigned int signum, const char *bus_name)
 {
        int len;
        OCStackResult result;
@@ -394,7 +394,6 @@ int icd_ioty_find_resource(const char *host_address, const char *resource_type,
        char uri[PATH_MAX] = {0};
        OCCallbackData cbdata = {0};
        OCConnectivityType oic_conn_type;
-       iotcon_connectivity_type_e conn_type = IOTCON_CONNECTIVITY_IPV4;
 
        if (IC_STR_EQUAL == strcmp(IOTCON_MULTICAST_ADDRESS, host_address)) {
                len = snprintf(uri, sizeof(uri), "%s", OC_RSRVD_WELL_KNOWN_URI);
@@ -889,15 +888,14 @@ int icd_ioty_register_platform_info(char *platform_id,
 }
 
 
-int icd_ioty_get_info(int type, const char *host_address, unsigned int signal_number,
-               const char *bus_name)
+int icd_ioty_get_info(int type, const char *host_address, int conn_type,
+               unsigned int signal_number, const char *bus_name)
 {
        OCStackResult result;
        icd_sig_ctx_s *context;
        OCCallbackData cbdata = {0};
        char uri[PATH_MAX] = {0};
        char *uri_path = NULL;
-       iotcon_connectivity_type_e conn_type = IOTCON_CONNECTIVITY_IPV4;
        OCConnectivityType oic_conn_type;
 
        if (ICD_DEVICE_INFO == type)
@@ -993,7 +991,7 @@ int icd_ioty_set_tizen_info()
 
 
 gboolean icd_ioty_get_tizen_info(icDbus *object, GDBusMethodInvocation *invocation,
-               const gchar *host_address)
+               const gchar *host_address, int conn_type)
 {
        OCStackResult result;
        OCDevAddr dev_addr = {0};
@@ -1001,7 +999,6 @@ gboolean icd_ioty_get_tizen_info(icDbus *object, GDBusMethodInvocation *invocati
        OCConnectivityType oic_conn_type;
        char host[PATH_MAX] = {0};
        char *dev_host, *ptr = NULL;
-       int conn_type = IOTCON_CONNECTIVITY_IPV4;
 
        snprintf(host, sizeof(host), "%s", host_address);
 
@@ -1056,15 +1053,16 @@ int icd_ioty_tizen_info_get_property(char **device_name, char **tizen_device_id)
 }
 
 
-OCDoHandle icd_ioty_subscribe_presence(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)
 {
        int len;
        OCDoHandle handle;
        OCStackResult result;
+       icd_sig_ctx_s *context;
        char uri[PATH_MAX] = {0};
        OCCallbackData cbdata = {0};
-       icd_sig_ctx_s *context;
+       OCConnectivityType oic_conn_type;
 
        len = snprintf(uri, sizeof(uri), "%s%s", host_address, OC_RSRVD_PRESENCE_URI);
        if (len <= 0 || sizeof(uri) <= len) {
@@ -1087,7 +1085,12 @@ OCDoHandle icd_ioty_subscribe_presence(const char *host_address,
        cbdata.cb = icd_ioty_ocprocess_presence_cb;
        cbdata.cd = _ioty_free_signal_context;
 
+       oic_conn_type = icd_ioty_conn_type_to_oic_conn_type(conn_type);
+
        /* In case of IPV4 or IPV6, connectivity type is CT_ADAPTER_IP in iotivity 0.9.2 */
+       if (CT_IP_USE_V4 == oic_conn_type && CT_IP_USE_V6 == oic_conn_type)
+               oic_conn_type = CT_ADAPTER_IP;
+
        icd_ioty_csdk_lock();
        result = OCDoResource(&handle, OC_REST_PRESENCE, uri, NULL, NULL, CT_ADAPTER_IP,
                        OC_LOW_QOS, &cbdata, NULL, 0);
index 5875be8..8d3f02d 100644 (file)
@@ -76,8 +76,8 @@ int icd_ioty_notify(OCResourceHandle handle, GVariant *msg, GVariant *observers)
 
 int icd_ioty_send_response(GVariant *resp);
 
-int icd_ioty_find_resource(const char *host_address, const char *resource_type,
-               unsigned int signal_number, const char *bus_name);
+int icd_ioty_find_resource(const char *host_address, int conn_type,
+               const char *resource_type, unsigned int 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);
@@ -113,17 +113,17 @@ int icd_ioty_register_platform_info(char *platform_id,
                char *support_url,
                char *system_time);
 
-int icd_ioty_get_info(int type, const char *host_address, unsigned int signal_number,
-               const char *bus_name);
+int icd_ioty_get_info(int type, const char *host_address, int conn_type,
+               unsigned int signal_number, const char *bus_name);
 
 int icd_ioty_set_tizen_info();
 
 gboolean icd_ioty_get_tizen_info(icDbus *object, GDBusMethodInvocation *invocation,
-               const gchar *host_address);
+               const gchar *host_address, int conn_type);
 
 int icd_ioty_tizen_info_get_property(char **device_name, char **tizen_device_id);
 
-OCDoHandle icd_ioty_subscribe_presence(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);
 
 int icd_ioty_unsubscribe_presence(OCDoHandle handle);
index ab82716..79efc27 100644 (file)
@@ -175,7 +175,7 @@ static void _found_resource(iotcon_remote_resource_h resource, void *user_data)
                return;
        }
 
-       ret = iotcon_remote_resource_get_host(resource, &resource_host);
+       ret = iotcon_remote_resource_get_host_address(resource, &resource_host);
        if (IOTCON_ERROR_NONE != ret) {
                return;
        }
@@ -205,7 +205,8 @@ static void _found_resource(iotcon_remote_resource_h resource, void *user_data)
        int ret;
        const char *type = "core.door";
 
-       ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, type, &_found_resource, NULL);
+       ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4, type,
+                       &_found_resource, NULL);
        if (IOTCON_ERROR_NONE != ret) {
                return;
        }
index db75d2c..c67f268 100644 (file)
@@ -133,7 +133,7 @@ GVariant* icl_dbus_remote_resource_to_gvariant(struct icl_remote_resource *resou
        }
 
        value = g_variant_new("(ssba(qs)i)", resource->uri_path, resource->host,
-                       resource->is_secure, &options, resource->conn_type);
+                       resource->is_secure, &options, resource->connectivity_type);
 
        return value;
 }
index c5fc238..770f99e 100644 (file)
@@ -135,7 +135,9 @@ static gboolean _icl_timeout_get_device_info(gpointer p)
        return G_SOURCE_REMOVE;
 }
 
-API int iotcon_get_device_info(const char *host_address, iotcon_device_info_cb cb,
+API int iotcon_get_device_info(const char *host_address,
+               iotcon_connectivity_type_e connectivity_type,
+               iotcon_device_info_cb cb,
                void *user_data)
 {
        GError *error = NULL;
@@ -151,7 +153,7 @@ API int iotcon_get_device_info(const char *host_address, iotcon_device_info_cb c
        signal_number = icl_dbus_generate_signal_number();
 
        ic_dbus_call_get_device_info_sync(icl_dbus_get_object(), host_address,
-                       signal_number, &ret, NULL, &error);
+                       connectivity_type, signal_number, &ret, NULL, &error);
        if (error) {
                ERR("ic_dbus_call_get_device_info_sync() Fail(%s)", error->message);
                ret = icl_dbus_convert_dbus_error(error->code);
@@ -298,7 +300,9 @@ static gboolean _icl_timeout_get_platform_info(gpointer p)
        return G_SOURCE_REMOVE;
 }
 
-API int iotcon_get_platform_info(const char *host_address, iotcon_platform_info_cb cb,
+API int iotcon_get_platform_info(const char *host_address,
+               iotcon_connectivity_type_e connectivity_type,
+               iotcon_platform_info_cb cb,
                void *user_data)
 {
        GError *error = NULL;
@@ -314,7 +318,7 @@ API int iotcon_get_platform_info(const char *host_address, iotcon_platform_info_
        signal_number = icl_dbus_generate_signal_number();
 
        ic_dbus_call_get_platform_info_sync(icl_dbus_get_object(), host_address,
-                       signal_number, &ret, NULL, &error);
+                       connectivity_type, signal_number, &ret, NULL, &error);
        if (error) {
                ERR("ic_dbus_call_get_platform_info_sync() Fail(%s)", error->message);
                ret = icl_dbus_convert_dbus_error(error->code);
@@ -394,7 +398,9 @@ static void _icl_tizen_info_cb(GObject *object, GAsyncResult *g_async_res,
 }
 
 
-API int iotcon_get_tizen_info(const char *host_address, iotcon_tizen_info_cb cb,
+API int iotcon_get_tizen_info(const char *host_address,
+               iotcon_connectivity_type_e connectivity_type,
+               iotcon_tizen_info_cb cb,
                void *user_data)
 {
        icl_tizen_info_s *cb_container;
@@ -412,8 +418,8 @@ API int iotcon_get_tizen_info(const char *host_address, iotcon_tizen_info_cb cb,
        cb_container->cb = cb;
        cb_container->user_data = user_data;
 
-       ic_dbus_call_get_tizen_info(icl_dbus_get_object(), host_address, NULL,
-                       _icl_tizen_info_cb, cb_container);
+       ic_dbus_call_get_tizen_info(icl_dbus_get_object(), host_address, connectivity_type,
+                       NULL, _icl_tizen_info_cb, cb_container);
 
        return IOTCON_ERROR_NONE;
 }
index 66bb75c..2b525b4 100644 (file)
@@ -162,12 +162,14 @@ static void _icl_lite_resource_request_handler(GDBusConnection *connection,
                return;
        }
 
-       g_variant_get(parameters, "(ia(qs)a(ss)iiavxx)",
+       g_variant_get(parameters, "(siia(qs)a(ss)iiavxx)",
+                       NULL,   /* host address */
+                       NULL,   /* connectivity type */
                        &request_types,
-                       NULL,   // &options,
-                       NULL,   // &query,
-                       NULL,   // &action,
-                       NULL,   // &observer_id,
+                       NULL,   /* header options */
+                       NULL,   /* query */
+                       NULL,   /* observe action */
+                       NULL,   /* observer_id */
                        &repr_iter,
                        &oic_request_h,
                        &oic_resource_h);
index ea7935c..5dba296 100644 (file)
@@ -126,8 +126,12 @@ static void _icl_presence_conn_cleanup(icl_presence_s *presence)
 
 
 /* The length of resource_type should be less than or equal to 61. */
-API int iotcon_subscribe_presence(const char *host_address, const char *resource_type,
-               iotcon_presence_cb cb, void *user_data, iotcon_presence_h *presence_handle)
+API int iotcon_subscribe_presence(const char *host_address,
+               iotcon_connectivity_type_e connectivity_type,
+               const char *resource_type,
+               iotcon_presence_cb cb,
+               void *user_data,
+               iotcon_presence_h *presence_handle)
 {
        FN_CALL;
        GError *error = NULL;
@@ -155,8 +159,14 @@ API int iotcon_subscribe_presence(const char *host_address, const char *resource
 
        resource_type = ic_utils_dbus_encode_str(resource_type);
 
-       ic_dbus_call_subscribe_presence_sync(icl_dbus_get_object(), host_address,
-                       resource_type, signal_number, &(presence_container->handle), NULL, &error);
+       ic_dbus_call_subscribe_presence_sync(icl_dbus_get_object(),
+                       host_address,
+                       connectivity_type,
+                       resource_type,
+                       signal_number,
+                       &(presence_container->handle),
+                       NULL,
+                       &error);
        if (error) {
                ERR("ic_dbus_call_subscribe_presence_sync() Fail(%s)", error->message);
                ret = icl_dbus_convert_dbus_error(error->code);
index b9f3dc0..d83d90d 100644 (file)
@@ -86,8 +86,8 @@ API int iotcon_remote_resource_start_monitoring(iotcon_remote_resource_h resourc
                iotcon_remote_resource_state_changed_cb cb,
                void *user_data)
 {
-       int ret;
        char *host_address;
+       int ret, connectivity_type;
        unsigned int get_timer_id;
 
        RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
@@ -127,17 +127,26 @@ API int iotcon_remote_resource_start_monitoring(iotcon_remote_resource_h resourc
        resource->monitoring_handle->get_timer_id = get_timer_id;
 
        /* Device Presence */
-       ret = iotcon_remote_resource_get_host(resource, &host_address);
+       ret = iotcon_remote_resource_get_host_address(resource, &host_address);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("iotcon_remote_resource_get_host_address() Fail(%d)", ret);
+               g_source_remove(resource->monitoring_handle->get_timer_id);
+               free(resource->monitoring_handle);
+               resource->monitoring_handle = NULL;
+               return ret;
+       }
+
+       ret = iotcon_remote_resource_get_connectivity_type(resource, &connectivity_type);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_remote_resource_get_host() Fail(%d)", ret);
+               ERR("iotcon_remote_resource_get_connectivity_type() Fail(%d)", ret);
                g_source_remove(resource->monitoring_handle->get_timer_id);
                free(resource->monitoring_handle);
                resource->monitoring_handle = NULL;
                return ret;
        }
 
-       ret = iotcon_subscribe_presence(host_address, NULL, _monitoring_presence_cb, resource,
-                       &resource->monitoring_handle->presence);
+       ret = iotcon_subscribe_presence(host_address, connectivity_type, NULL,
+                       _monitoring_presence_cb, resource, &resource->monitoring_handle->presence);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("iotcon_subscribe_presence() Fail(%d)", ret);
                g_source_remove(resource->monitoring_handle->get_timer_id);
index 2975091..4056f5c 100644 (file)
@@ -38,7 +38,7 @@ typedef struct {
 } icl_found_resource_s;
 
 static iotcon_remote_resource_h _icl_remote_resource_from_gvariant(GVariant *payload,
-               iotcon_connectivity_type_e conn_type);
+               iotcon_connectivity_type_e connectivity_type);
 
 static void _icl_found_resource_cb(GDBusConnection *connection,
                const gchar *sender_name,
@@ -49,7 +49,7 @@ static void _icl_found_resource_cb(GDBusConnection *connection,
                gpointer user_data)
 {
        FN_CALL;
-       int conn_type;
+       int connectivity_type;
        iotcon_remote_resource_h resource;
 
        GVariant *payload;
@@ -61,9 +61,9 @@ static void _icl_found_resource_cb(GDBusConnection *connection,
                cb_container->timeout_id = 0;
        }
 
-       g_variant_get(parameters, "(vi)", &payload, &conn_type);
+       g_variant_get(parameters, "(vi)", &payload, &connectivity_type);
 
-       resource = _icl_remote_resource_from_gvariant(payload, conn_type);
+       resource = _icl_remote_resource_from_gvariant(payload, connectivity_type);
        if (NULL == resource) {
                ERR("icl_remote_resource_from_gvariant() Fail");
                return;
@@ -73,10 +73,6 @@ static void _icl_found_resource_cb(GDBusConnection *connection,
                cb(resource, IOTCON_ERROR_NONE, cb_container->user_data);
 
        iotcon_remote_resource_destroy(resource);
-
-       /* TODO
-        * When is callback removed?
-        */
 }
 
 static gboolean _icl_timeout_find_resource(gpointer p)
@@ -99,8 +95,11 @@ static gboolean _icl_timeout_find_resource(gpointer p)
 
 /* The length of resource_type should be less than or equal to 61.
  * If resource_type is NULL, then All resources in host are discovered. */
-API int iotcon_find_resource(const char *host_address, const char *resource_type,
-               iotcon_found_resource_cb cb, void *user_data)
+API int iotcon_find_resource(const char *host_address,
+               iotcon_connectivity_type_e connectivity_type,
+               const char *resource_type,
+               iotcon_found_resource_cb cb,
+               void *user_data)
 {
        unsigned int sub_id;
        GError *error = NULL;
@@ -118,7 +117,7 @@ API int iotcon_find_resource(const char *host_address, const char *resource_type
 
        signal_number = icl_dbus_generate_signal_number();
 
-       ic_dbus_call_find_resource_sync(icl_dbus_get_object(), host_address,
+       ic_dbus_call_find_resource_sync(icl_dbus_get_object(), host_address, connectivity_type,
                        ic_utils_dbus_encode_str(resource_type), signal_number, &ret, NULL, &error);
        if (error) {
                ERR("ic_dbus_call_find_resource_sync() Fail(%s)", error->message);
@@ -162,6 +161,7 @@ API int iotcon_find_resource(const char *host_address, const char *resource_type
 
 /* If you know the information of resource, then you can make a proxy of the resource. */
 API int iotcon_remote_resource_create(const char *host,
+               iotcon_connectivity_type_e connectivity_type,
                const char *uri_path,
                bool is_observable,
                iotcon_resource_types_h resource_types,
@@ -183,6 +183,7 @@ API int iotcon_remote_resource_create(const char *host,
        }
 
        resource->host = ic_utils_strdup(host);
+       resource->connectivity_type = connectivity_type;
        resource->uri_path = ic_utils_strdup(uri_path);
        resource->is_observable = is_observable;
        resource->types = icl_resource_types_ref(resource_types);
@@ -245,7 +246,8 @@ static int _icl_remote_resource_header_foreach_cb(unsigned short id,
        return IOTCON_FUNC_CONTINUE;
 }
 
-API int iotcon_remote_resource_clone(iotcon_remote_resource_h src, iotcon_remote_resource_h *dest)
+API int iotcon_remote_resource_clone(iotcon_remote_resource_h src,
+               iotcon_remote_resource_h *dest)
 {
        int ret;
        iotcon_remote_resource_h resource = NULL;
@@ -260,6 +262,7 @@ API int iotcon_remote_resource_clone(iotcon_remote_resource_h src, iotcon_remote
 
        resource->uri_path = ic_utils_strdup(src->uri_path);
        resource->host = ic_utils_strdup(src->host);
+       resource->connectivity_type = src->connectivity_type;
        resource->device_id = ic_utils_strdup(src->device_id);
        resource->is_secure = src->is_secure;
        resource->is_observable = src->is_observable;
@@ -284,7 +287,7 @@ API int iotcon_remote_resource_clone(iotcon_remote_resource_h src, iotcon_remote
        }
 
        resource->ifaces = src->ifaces;
-       resource->conn_type = src->conn_type;
+       resource->connectivity_type = src->connectivity_type;
 
        *dest = resource;
 
@@ -293,7 +296,8 @@ API int iotcon_remote_resource_clone(iotcon_remote_resource_h src, iotcon_remote
 
 
 /* The content of the resource should not be freed by user. */
-API int iotcon_remote_resource_get_uri_path(iotcon_remote_resource_h resource, char **uri_path)
+API int iotcon_remote_resource_get_uri_path(iotcon_remote_resource_h resource,
+               char **uri_path)
 {
        RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == uri_path, IOTCON_ERROR_INVALID_PARAMETER);
@@ -305,7 +309,8 @@ API int iotcon_remote_resource_get_uri_path(iotcon_remote_resource_h resource, c
 
 
 /* The content of the resource should not be freed by user. */
-API int iotcon_remote_resource_get_host(iotcon_remote_resource_h resource, char **host)
+API int iotcon_remote_resource_get_host_address(iotcon_remote_resource_h resource,
+               char **host)
 {
        RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == host, IOTCON_ERROR_INVALID_PARAMETER);
@@ -317,7 +322,21 @@ API int iotcon_remote_resource_get_host(iotcon_remote_resource_h resource, char
 
 
 /* The content of the resource should not be freed by user. */
-API int iotcon_remote_resource_get_device_id(iotcon_remote_resource_h resource, char **device_id)
+API int iotcon_remote_resource_get_connectivity_type(iotcon_remote_resource_h resource,
+               int *connectivity_type)
+{
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == connectivity_type, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *connectivity_type = resource->connectivity_type;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+/* The content of the resource should not be freed by user. */
+API int iotcon_remote_resource_get_device_id(iotcon_remote_resource_h resource,
+               char **device_id)
 {
        RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == device_id, IOTCON_ERROR_INVALID_PARAMETER);
@@ -328,7 +347,8 @@ API int iotcon_remote_resource_get_device_id(iotcon_remote_resource_h resource,
 }
 
 /* The content of the resource should not be freed by user. */
-API int iotcon_remote_resource_get_types(iotcon_remote_resource_h resource, iotcon_resource_types_h *types)
+API int iotcon_remote_resource_get_types(iotcon_remote_resource_h resource,
+               iotcon_resource_types_h *types)
 {
        RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == types, IOTCON_ERROR_INVALID_PARAMETER);
@@ -339,7 +359,8 @@ API int iotcon_remote_resource_get_types(iotcon_remote_resource_h resource, iotc
 }
 
 
-API int iotcon_remote_resource_get_interfaces(iotcon_remote_resource_h resource, int *ifaces)
+API int iotcon_remote_resource_get_interfaces(iotcon_remote_resource_h resource,
+               int *ifaces)
 {
        RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == ifaces, IOTCON_ERROR_INVALID_PARAMETER);
@@ -381,7 +402,7 @@ API int iotcon_remote_resource_set_options(iotcon_remote_resource_h resource,
 
 
 static iotcon_remote_resource_h _icl_remote_resource_from_gvariant(GVariant *payload,
-               iotcon_connectivity_type_e conn_type)
+               iotcon_connectivity_type_e connectivity_type)
 {
        int ret;
        iotcon_remote_resource_h resource;
@@ -394,7 +415,7 @@ static iotcon_remote_resource_h _icl_remote_resource_from_gvariant(GVariant *pay
        g_variant_get(payload, "(&s&siasib&si)", &uri_path, &device_id, &ifaces, &types_iter,
                        &is_observable, &is_secure, &addr, &port);
 
-       switch (conn_type) {
+       switch (connectivity_type) {
        case IOTCON_CONNECTIVITY_IPV6:
                snprintf(host_addr, sizeof(host_addr), "[%s]:%d", addr, port);
                break;
@@ -412,8 +433,8 @@ static iotcon_remote_resource_h _icl_remote_resource_from_gvariant(GVariant *pay
        while (g_variant_iter_loop(types_iter, "s", &res_type))
                iotcon_resource_types_add(res_types, res_type);
 
-       ret = iotcon_remote_resource_create(host_addr, uri_path, !!is_observable, res_types, ifaces,
-                       &resource);
+       ret = iotcon_remote_resource_create(host_addr, connectivity_type, uri_path,
+                       !!is_observable, res_types, ifaces, &resource);
        if (res_types)
                iotcon_resource_types_destroy(res_types);
 
@@ -428,7 +449,7 @@ static iotcon_remote_resource_h _icl_remote_resource_from_gvariant(GVariant *pay
                iotcon_remote_resource_destroy(resource);
                return NULL;
        }
-       resource->conn_type = conn_type;
+       resource->connectivity_type = connectivity_type;
        resource->is_secure = is_secure;
 
        return resource;
index e6a6860..a4311df 100644 (file)
@@ -62,7 +62,7 @@ struct icl_remote_resource {
        iotcon_options_h header_options;
        iotcon_resource_types_h types;
        int ifaces;
-       iotcon_connectivity_type_e conn_type;
+       iotcon_connectivity_type_e connectivity_type;
        int64_t observe_handle;
        unsigned int observe_sub_id;
        icl_remote_resource_caching_h caching_handle;
index 9c42130..ca95f54 100644 (file)
@@ -30,6 +30,18 @@ API int iotcon_request_get_host_address(iotcon_request_h request,
 }
 
 
+API int iotcon_request_get_connectivity_type(iotcon_request_h request,
+               int *connectivity_type)
+{
+       RETV_IF(NULL == request, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == connectivity_type, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *connectivity_type = request->connectivity_type;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
 /* The content of the request should not be freed by user. */
 API int iotcon_request_get_representation(iotcon_request_h request,
                iotcon_representation_h *repr)
index daf25a2..750100c 100644 (file)
@@ -27,6 +27,7 @@ struct icl_observe_info {
 
 struct icl_resource_request {
        char *host_address;
+       iotcon_connectivity_type_e connectivity_type;
        int types;
        iotcon_options_h header_options;
        iotcon_query_h query;
index a60f702..f4e6e87 100644 (file)
@@ -54,8 +54,9 @@ static void _icl_request_handler(GDBusConnection *connection,
        iotcon_resource_h resource = user_data;
        iotcon_request_handler_cb cb = resource->cb;
 
-       g_variant_get(parameters, "(sia(qs)a(ss)iiavxx)",
+       g_variant_get(parameters, "(siia(qs)a(ss)iiavxx)",
                        &request.host_address,
+                       &request.connectivity_type,
                        &request.types,
                        &options,
                        &query,
index b61465e..4d3ae65 100644 (file)
@@ -878,7 +878,8 @@ typedef struct icl_remote_resource* iotcon_remote_resource_h;
  * @retval #IOTCON_ERROR_NONE  Successful
  * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
  *
- * @see iotcon_remote_resource_get_host()
+ * @see iotcon_remote_resource_get_host_address()
+ * @see iotcon_remote_resource_get_connectivity_type()
  * @see iotcon_remote_resource_get_device_id()
  * @see iotcon_remote_resource_get_types()
  * @see iotcon_remote_resource_get_interfaces()
@@ -902,13 +903,38 @@ int iotcon_remote_resource_get_uri_path(iotcon_remote_resource_h resource,
  * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
  *
  * @see iotcon_remote_resource_get_uri_path()
+ * @see iotcon_remote_resource_get_connectivity_type()
  * @see iotcon_remote_resource_get_device_id()
  * @see iotcon_remote_resource_get_types()
  * @see iotcon_remote_resource_get_interfaces()
  * @see iotcon_remote_resource_is_observable()
  * @see iotcon_remote_resource_set_options()
  */
-int iotcon_remote_resource_get_host(iotcon_remote_resource_h resource, char **host);
+int iotcon_remote_resource_get_host_address(iotcon_remote_resource_h resource,
+               char **host);
+
+/**
+ * @brief Gets connectivity type of the remote resource
+ *
+ * @since_tizen 3.0
+ *
+ * @param[in] request The handle of the remote resource
+ * @param[out] connectivity_type The connectivity type of the remote resource
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #IOTCON_ERROR_NONE  Successful
+ * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
+
+ * @see iotcon_remote_resource_get_uri_path()
+ * @see iotcon_remote_resource_get_host_address()
+ * @see iotcon_remote_resource_get_device_id()
+ * @see iotcon_remote_resource_get_types()
+ * @see iotcon_remote_resource_get_interfaces()
+ * @see iotcon_remote_resource_is_observable()
+ * @see iotcon_remote_resource_set_options()
+ */
+int iotcon_remote_resource_get_connectivity_type(iotcon_remote_resource_h resource,
+               int *connectivity_type);
 
 /**
  * @brief Gets an device id of the remote resource
@@ -924,7 +950,8 @@ int iotcon_remote_resource_get_host(iotcon_remote_resource_h resource, char **ho
  * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
  *
  * @see iotcon_remote_resource_get_uri_path()
- * @see iotcon_remote_resource_get_host()
+ * @see iotcon_remote_resource_get_host_address()
+ * @see iotcon_remote_resource_get_connectivity_type()
  * @see iotcon_remote_resource_get_types()
  * @see iotcon_remote_resource_get_interfaces()
  * @see iotcon_remote_resource_is_observable()
@@ -946,7 +973,8 @@ int iotcon_remote_resource_get_device_id(iotcon_remote_resource_h resource,
  * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
  *
  * @see iotcon_remote_resource_get_uri_path()
- * @see iotcon_remote_resource_get_host()
+ * @see iotcon_remote_resource_get_host_address()
+ * @see iotcon_remote_resource_get_connectivity_type()
  * @see iotcon_remote_resource_get_device_id()
  * @see iotcon_remote_resource_get_interfaces()
  * @see iotcon_remote_resource_is_observable()
@@ -968,7 +996,8 @@ int iotcon_remote_resource_get_types(iotcon_remote_resource_h resource,
  * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
  *
  * @see iotcon_remote_resource_get_uri_path()
- * @see iotcon_remote_resource_get_host()
+ * @see iotcon_remote_resource_get_host_address()
+ * @see iotcon_remote_resource_get_connectivity_type()
  * @see iotcon_remote_resource_get_device_id()
  * @see iotcon_remote_resource_get_types()
  * @see iotcon_remote_resource_is_observable()
@@ -989,7 +1018,8 @@ int iotcon_remote_resource_get_interfaces(iotcon_remote_resource_h resource, int
  * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
  *
  * @see iotcon_remote_resource_get_uri_path()
- * @see iotcon_remote_resource_get_host()
+ * @see iotcon_remote_resource_get_host_address()
+ * @see iotcon_remote_resource_get_connectivity_type()
  * @see iotcon_remote_resource_get_device_id()
  * @see iotcon_remote_resource_get_types()
  * @see iotcon_remote_resource_get_interfaces()
@@ -1011,7 +1041,8 @@ int iotcon_remote_resource_is_observable(iotcon_remote_resource_h resource,
  * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
  *
  * @see iotcon_remote_resource_get_uri_path()
- * @see iotcon_remote_resource_get_host()
+ * @see iotcon_remote_resource_get_host_address()
+ * @see iotcon_remote_resource_get_connectivity_type()
  * @see iotcon_remote_resource_get_device_id()
  * @see iotcon_remote_resource_get_types()
  * @see iotcon_remote_resource_get_interfaces()
@@ -1042,6 +1073,7 @@ typedef struct icl_resource_request* iotcon_request_h;
  * @retval #IOTCON_ERROR_NONE  Successful
  * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
  *
+ * @see iotcon_request_get_connectivity_type()
  * @see iotcon_request_get_representation()
  * @see iotcon_request_get_types()
  * @see iotcon_request_get_options()
@@ -1052,6 +1084,28 @@ typedef struct icl_resource_request* iotcon_request_h;
 int iotcon_request_get_host_address(iotcon_request_h request,
                char **host_address);
 
+/**
+ * @brief Gets connectivity type of the request
+ *
+ * @since_tizen 3.0
+ *
+ * @param[in] request The handle of the request
+ * @param[out] connectivity_type The connectivity type of the request
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #IOTCON_ERROR_NONE  Successful
+ * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
+ *
+ * @see iotcon_request_get_host_address()
+ * @see iotcon_request_get_representation()
+ * @see iotcon_request_get_types()
+ * @see iotcon_request_get_options()
+ * @see iotcon_request_get_query()
+ * @see iotcon_request_get_observer_action()
+ * @see iotcon_request_get_observer_id()
+ */
+int iotcon_request_get_connectivity_type(iotcon_request_h request,
+               int *connectivity_type);
 
 /**
  * @brief Gets an representation of the request
@@ -1067,6 +1121,7 @@ int iotcon_request_get_host_address(iotcon_request_h request,
  * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
  *
  * @see iotcon_request_get_host_address()
+ * @see iotcon_request_get_connectivity_type()
  * @see iotcon_request_get_types()
  * @see iotcon_request_get_options()
  * @see iotcon_request_get_query()
@@ -1089,6 +1144,7 @@ int iotcon_request_get_representation(iotcon_request_h request,
  * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
  *
  * @see iotcon_request_get_host_address()
+ * @see iotcon_request_get_connectivity_type()
  * @see iotcon_request_get_representation()
  * @see iotcon_request_get_options()
  * @see iotcon_request_get_query()
@@ -1111,6 +1167,7 @@ int iotcon_request_get_types(iotcon_request_h request, int *types);
  * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
  *
  * @see iotcon_request_get_host_address()
+ * @see iotcon_request_get_connectivity_type()
  * @see iotcon_request_get_representation()
  * @see iotcon_request_get_types()
  * @see iotcon_request_get_query()
@@ -1133,6 +1190,7 @@ int iotcon_request_get_options(iotcon_request_h request, iotcon_options_h *optio
  * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
  *
  * @see iotcon_request_get_host_address()
+ * @see iotcon_request_get_connectivity_type()
  * @see iotcon_request_get_representation()
  * @see iotcon_request_get_types()
  * @see iotcon_request_get_options()
@@ -1155,6 +1213,7 @@ int iotcon_request_get_query(iotcon_request_h request, iotcon_query_h *query);
  * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
  *
  * @see iotcon_request_get_host_address()
+ * @see iotcon_request_get_connectivity_type()
  * @see iotcon_request_get_representation()
  * @see iotcon_request_get_types()
  * @see iotcon_request_get_options()
@@ -1176,6 +1235,7 @@ int iotcon_request_get_observer_action(iotcon_request_h request, int *action);
  * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
  *
  * @see iotcon_request_get_host_address()
+ * @see iotcon_request_get_connectivity_type()
  * @see iotcon_request_get_representation()
  * @see iotcon_request_get_types()
  * @see iotcon_request_get_options()
index fc3b7ee..c305d76 100644 (file)
@@ -427,6 +427,7 @@ typedef void (*iotcon_device_info_cb)(iotcon_device_info_h device_info, int resu
  * @privilege %http://tizen.org/privilege/internet
  *
  * @param[in] host_address The host address of remote server
+ * @param[in] connectivity_type The connectivity type
  * @param[in] cb The callback function to invoke
  * @param[in] user_data The user data to pass to the function
  *
@@ -442,7 +443,9 @@ typedef void (*iotcon_device_info_cb)(iotcon_device_info_h device_info, int resu
  * @see iotcon_device_info_cb()
  * @see iotcon_device_info_get_property()
  */
-int iotcon_get_device_info(const char *host_address, iotcon_device_info_cb cb,
+int iotcon_get_device_info(const char *host_address,
+               iotcon_connectivity_type_e connectivity_type,
+               iotcon_device_info_cb cb,
                void *user_data);
 
 /**
@@ -473,6 +476,7 @@ typedef void (*iotcon_platform_info_cb)(iotcon_platform_info_h platform_info, in
  * @privilege %http://tizen.org/privilege/internet
  *
  * @param[in] host_address The host address of remote server
+ * @param[in] connectivity_type The connectivity type
  * @param[in] cb The callback function to invoke
  * @param[in] user_data The user data to pass to the function
  *
@@ -490,7 +494,9 @@ typedef void (*iotcon_platform_info_cb)(iotcon_platform_info_h platform_info, in
  * @see iotcon_platform_info_cb()
  * @see iotcon_platform_info_get_property()
  */
-int iotcon_get_platform_info(const char *host_address, iotcon_platform_info_cb cb,
+int iotcon_get_platform_info(const char *host_address,
+               iotcon_connectivity_type_e connectivity_type,
+               iotcon_platform_info_cb cb,
                void *user_data);
 
 /**
@@ -521,6 +527,7 @@ typedef void (*iotcon_tizen_info_cb)(iotcon_tizen_info_h tizen_info,
  * @privilege %http://tizen.org/privilege/internet
  *
  * @param[in] host_address The host address of remote server
+ * @param[in] connectivity_type The connectivity type
  * @param[in] cb The callback function to invoke
  * @param[in] user_data The user data to pass to the function
  *
@@ -536,7 +543,9 @@ typedef void (*iotcon_tizen_info_cb)(iotcon_tizen_info_h tizen_info,
  * @see iotcon_tizen_info_cb()
  * @see iotcon_tizen_info_get_property()
  */
-int iotcon_get_tizen_info(const char *host_address, iotcon_tizen_info_cb cb,
+int iotcon_get_tizen_info(const char *host_address,
+               iotcon_connectivity_type_e connectivity_type,
+               iotcon_tizen_info_cb cb,
                void *user_data);
 
 /**
@@ -568,6 +577,7 @@ typedef void (*iotcon_presence_cb)(int result, unsigned int nonce,
  * @privilege %http://tizen.org/privilege/internet
  *
  * @param[in] host_address The address or addressable name of the server
+ * @param[in] connectivity_type The connectivity type
  * @param[in] resource_type A resource type that a client has interested in
  * @param[in] cb The callback function to invoke
  * @param[in] user_data The user data to pass to the function
@@ -588,8 +598,12 @@ typedef void (*iotcon_presence_cb)(int result, unsigned int nonce,
  * @see iotcon_unsubscribe_presence()
  * @see iotcon_presence_cb()
  */
-int iotcon_subscribe_presence(const char *host_address, const char *resource_type,
-               iotcon_presence_cb cb, void *user_data, iotcon_presence_h *presence_handle);
+int iotcon_subscribe_presence(const char *host_address,
+               iotcon_connectivity_type_e connectivity_type,
+               const char *resource_type,
+               iotcon_presence_cb cb,
+               void *user_data,
+               iotcon_presence_h *presence_handle);
 
 /**
  * @brief Unsubscribes to a server's presence events.
@@ -643,6 +657,7 @@ typedef void (*iotcon_found_resource_cb)(iotcon_remote_resource_h resource, int
  * @privilege %http://tizen.org/privilege/internet
  *
  * @param[in] host_address The address or addressable name of server
+ * @param[in] connectivity_type The connectivity type
  * @param[in] resource_type The resource type specified as a filter for the resource
  * @param[in] cb The callback function to invoke
  * @param[in] user_data The user data to pass to the function
@@ -658,8 +673,11 @@ typedef void (*iotcon_found_resource_cb)(iotcon_remote_resource_h resource, int
  *
  * @see iotcon_found_resource_cb()
  */
-int iotcon_find_resource(const char *host_address, const char *resource_type,
-               iotcon_found_resource_cb cb, void *user_data);
+int iotcon_find_resource(const char *host_address,
+               iotcon_connectivity_type_e connectivity_type,
+               const char *resource_type,
+               iotcon_found_resource_cb cb,
+               void *user_data);
 
 /**
  * @brief Creates a new resource handle.
@@ -672,6 +690,7 @@ int iotcon_find_resource(const char *host_address, const char *resource_type,
  * @since_tizen 3.0
  *
  * @param[in] host The host address of the resource
+ * @param[in] connectivity_type The connectivity type
  * @param[in] uri_path The URI path of the resource.
  * @param[in] is_observable Allow observation
  * @param[in] resource_types The resource type of the resource. For example, "core.light"
@@ -689,6 +708,7 @@ int iotcon_find_resource(const char *host_address, const char *resource_type,
  * @see iotcon_remote_resource_clone()
  */
 int iotcon_remote_resource_create(const char *host,
+               iotcon_connectivity_type_e connectivity_type,
                const char *uri_path,
                bool is_observable,
                iotcon_resource_types_h resource_types,
@@ -726,7 +746,8 @@ void iotcon_remote_resource_destroy(iotcon_remote_resource_h resource);
  * @see iotcon_remote_resource_create()
  * @see iotcon_remote_resource_destroy()
  */
-int iotcon_remote_resource_clone(iotcon_remote_resource_h src, iotcon_remote_resource_h *dest);
+int iotcon_remote_resource_clone(iotcon_remote_resource_h src,
+               iotcon_remote_resource_h *dest);
 
 /**
  * @brief Specifies the type of function passed to iotcon_remote_resource_observer_start().
index 7498997..0b6944f 100644 (file)
@@ -67,9 +67,9 @@ static void _on_delete(iotcon_remote_resource_h resource, iotcon_options_h heade
 static void _on_post(iotcon_remote_resource_h resource, iotcon_representation_h recv_repr,
                iotcon_options_h header_options, int response_result, void *user_data)
 {
-       int ret, ifaces = 0;
        iotcon_state_h recv_state;
        char *host, *created_uri_path;
+       int ret, connectivity_type, ifaces = 0;
        iotcon_resource_types_h types = NULL;
        iotcon_remote_resource_h new_door_resource, door_resource;
 
@@ -91,9 +91,15 @@ static void _on_post(iotcon_remote_resource_h resource, iotcon_representation_h
        }
        DBG("New resource created : %s", created_uri_path);
 
-       ret = iotcon_remote_resource_get_host(resource, &host);
+       ret = iotcon_remote_resource_get_host_address(resource, &host);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_remote_resource_get_host() Fail(%d)", ret);
+               ERR("iotcon_remote_resource_get_host_address() Fail(%d)", ret);
+               return;
+       }
+
+       ret = iotcon_remote_resource_get_connectivity_type(resource, &connectivity_type);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("iotcon_remote_resource_get_connectivity_type() Fail(%d)", ret);
                return;
        }
 
@@ -109,8 +115,8 @@ static void _on_post(iotcon_remote_resource_h resource, iotcon_representation_h
                return;
        }
 
-       ret = iotcon_remote_resource_create(host, created_uri_path, true, types, ifaces,
-                       &new_door_resource);
+       ret = iotcon_remote_resource_create(host, connectivity_type, created_uri_path, true,
+                       types, ifaces, &new_door_resource);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("iotcon_remote_resource_create() Fail(%d)", ret);
                return;
@@ -274,15 +280,16 @@ static void _get_tizen_info(iotcon_tizen_info_h info, int response_result,
        INFO("- Tizen Device ID : %s", tizen_device_id);
 }
 
-static void _found_resource(iotcon_remote_resource_h resource, int result, void *user_data)
+static void _found_resource(iotcon_remote_resource_h resource, int result,
+               void *user_data)
 {
        GList *node;
        char *resource_host;
        char *resource_uri_path;
        char *resource_device_id;
-       int ret, resource_interfaces;
        iotcon_presence_h presence_handle;
        iotcon_resource_types_h resource_types;
+       int ret, resource_interfaces, connectivity_type;
        iotcon_remote_resource_h resource_clone = NULL;
 
        RETM_IF(IOTCON_ERROR_NONE != result, "Invalid result(%d)", result);
@@ -324,15 +331,23 @@ static void _found_resource(iotcon_remote_resource_h resource, int result, void
        device_id_list = g_list_append(device_id_list, door_resource_device_id);
 
        /* get the resource host address */
-       ret = iotcon_remote_resource_get_host(resource, &resource_host);
+       ret = iotcon_remote_resource_get_host_address(resource, &resource_host);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_remote_resource_get_host() Fail(%d)", ret);
+               ERR("iotcon_remote_resource_get_host_address() Fail(%d)", ret);
                device_id_list = g_list_remove(device_id_list, door_resource_device_id);
                free(door_resource_device_id);
                return;
        }
        DBG("[%s] resource host : %s", resource_uri_path, resource_host);
 
+       ret = iotcon_remote_resource_get_connectivity_type(resource, &connectivity_type);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("iotcon_remote_resource_get_connectivity_type() Fail(%d)", ret);
+               device_id_list = g_list_remove(device_id_list, door_resource_device_id);
+               free(door_resource_device_id);
+               return;
+       }
+
        /* get the resource interfaces */
        ret = iotcon_remote_resource_get_interfaces(resource, &resource_interfaces);
        if (IOTCON_ERROR_NONE != ret) {
@@ -369,7 +384,7 @@ static void _found_resource(iotcon_remote_resource_h resource, int result, void
        }
 
        /* get tizen info */
-       ret = iotcon_get_tizen_info(resource_host, _get_tizen_info, NULL);
+       ret = iotcon_get_tizen_info(resource_host, connectivity_type, _get_tizen_info, NULL);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("iotcon_get_tizen_info() Fail(%d)", ret);
                device_id_list = g_list_remove(device_id_list, door_resource_device_id);
@@ -377,8 +392,8 @@ static void _found_resource(iotcon_remote_resource_h resource, int result, void
                return;
        }
 
-       ret = iotcon_subscribe_presence(resource_host, "core.door", _presence_handler, NULL,
-                       &presence_handle);
+       ret = iotcon_subscribe_presence(resource_host, connectivity_type, "core.door",
+                       _presence_handler, NULL, &presence_handle);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("iotcon_subscribe_presence() Fail(%d)", ret);
                device_id_list = g_list_remove(device_id_list, door_resource_device_id);
@@ -443,8 +458,8 @@ int main(int argc, char **argv)
        }
 
        /* find door typed resources */
-       ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, "core.door", &_found_resource,
-                       NULL);
+       ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,
+                       "core.door", &_found_resource, NULL);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("iotcon_find_resource() Fail(%d)", ret);
                iotcon_close();
index a2e95c1..ada1a25 100644 (file)
@@ -483,7 +483,6 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques
                        return;
                }
 
-
                if (IOTCON_OBSERVE_REGISTER == observer_action) {
                        ret = iotcon_request_get_observer_id(request, &observer_id);
                        if (IOTCON_ERROR_NONE != ret) {
index 88d3fc8..ae0b6f9 100644 (file)
@@ -180,14 +180,16 @@ int main()
                return -1;
        }
 
-       ret = iotcon_get_device_info(IOTCON_MULTICAST_ADDRESS, _get_device_info, NULL);
+       ret = iotcon_get_device_info(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,
+                       _get_device_info, NULL);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("iotcon_get_device_info() Fail(%d)", ret);
                iotcon_close();
                return -1;
        }
 
-       ret = iotcon_get_platform_info(IOTCON_MULTICAST_ADDRESS, _get_platform_info, NULL);
+       ret = iotcon_get_platform_info(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,
+                       _get_platform_info, NULL);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("iotcon_get_platform_info() Fail(%d)", ret);
                iotcon_close();
index 1e48d94..8351ece 100644 (file)
@@ -137,9 +137,9 @@ static void _found_resource(iotcon_remote_resource_h resource, int result,
        }
 
        /* get the resource host address */
-       ret = iotcon_remote_resource_get_host(resource, &resource_host);
+       ret = iotcon_remote_resource_get_host_address(resource, &resource_host);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_remote_resource_get_host() Fail(%d)", ret);
+               ERR("iotcon_remote_resource_get_host_address() Fail(%d)", ret);
                device_id_list = g_list_remove(device_id_list, door_resource_device_id);
                free(door_resource_device_id);
                return;
@@ -231,8 +231,8 @@ int main(int argc, char **argv)
        }
 
        /* find door typed resources */
-       ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, "core.door", &_found_resource,
-                       &resource);
+       ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,
+                       "core.door", &_found_resource, &resource);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("iotcon_find_resource() Fail(%d)", ret);
                iotcon_close();
index aa5117c..849d4f7 100644 (file)
@@ -164,6 +164,8 @@ static void _on_get_2nd(iotcon_remote_resource_h resource,
                void *user_data)
 {
        _on_get(recv_repr, response_result);
+
+       iotcon_remote_resource_destroy(resource);
 }
 
 static void _on_get_1st(iotcon_remote_resource_h resource,
@@ -215,7 +217,8 @@ static int _device_id_compare(const void *a, const void *b)
        return strcmp(a, b);
 }
 
-static void _found_resource(iotcon_remote_resource_h resource, int result, void *user_data)
+static void _found_resource(iotcon_remote_resource_h resource, int result,
+               void *user_data)
 {
        GList *node;
        char *resource_host;
@@ -223,6 +226,7 @@ static void _found_resource(iotcon_remote_resource_h resource, int result, void
        char *resource_device_id;
        int ret, resource_interfaces;
        iotcon_resource_types_h resource_types;
+       iotcon_remote_resource_h cloned_resource;
 
        RETM_IF(IOTCON_ERROR_NONE != result, "Invalid result(%d)", result);
 
@@ -262,9 +266,9 @@ static void _found_resource(iotcon_remote_resource_h resource, int result, void
        device_id_list = g_list_append(device_id_list, room_resource_device_id);
 
        /* get the resource host address */
-       ret = iotcon_remote_resource_get_host(resource, &resource_host);
+       ret = iotcon_remote_resource_get_host_address(resource, &resource_host);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_remote_resource_get_host() Fail(%d)", ret);
+               ERR("iotcon_remote_resource_get_host_address() Fail(%d)", ret);
                device_id_list = g_list_remove(device_id_list, room_resource_device_id);
                free(room_resource_device_id);
                return;
@@ -306,8 +310,16 @@ static void _found_resource(iotcon_remote_resource_h resource, int result, void
        }
 
        if (TEST_STR_EQUAL == strcmp(room_uri_path, resource_uri_path)) {
+               ret = iotcon_remote_resource_clone(resource, &cloned_resource);
+               if (IOTCON_ERROR_NONE != ret) {
+                       ERR("iotcon_remote_resource_clone() Fail(%d)", ret);
+                       device_id_list = g_list_remove(device_id_list, room_resource_device_id);
+                       free(room_resource_device_id);
+                       return;
+               }
+
                /* send GET request */
-               ret = iotcon_remote_resource_get(resource, NULL, _on_get_1st, NULL);
+               ret = iotcon_remote_resource_get(cloned_resource, NULL, _on_get_1st, NULL);
                if (IOTCON_ERROR_NONE != ret)
                        ERR("iotcon_remote_resource_get() Fail(%d)", ret);
        }
@@ -332,8 +344,8 @@ int main(int argc, char **argv)
        }
 
        /* find room typed resources */
-       ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, "core.room", &_found_resource,
-                       NULL);
+       ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,
+                       "core.room", &_found_resource, NULL);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("iotcon_find_resource() Fail(%d)", ret);
                iotcon_close();