fix presence callback add function 21/101821/2 accepted/tizen/3.0/common/20161205.092141 accepted/tizen/3.0/ivi/20161205.001019 accepted/tizen/3.0/mobile/20161205.001004 accepted/tizen/3.0/tv/20161205.001009 accepted/tizen/3.0/wearable/20161205.001015 submit/tizen_3.0/20161204.225512
authorJooseok Park <jooseok.park@samsung.com>
Fri, 2 Dec 2016 07:49:57 +0000 (16:49 +0900)
committerJooseok Park <jooseok.park@samsung.com>
Fri, 2 Dec 2016 07:52:09 +0000 (16:52 +0900)
 - fix the uri in case of host address of NULL

Change-Id: Ie98c0e3beb003e499ac196c84071bfbc866a6406

packaging/iotcon.spec
src/ic-ioty-parse.c
src/ic-ioty.c

index 065ed90..c886c0c 100644 (file)
@@ -1,6 +1,6 @@
 Name:       iotcon
 Summary:    Tizen IoT Connectivity
-Version:    0.3.2
+Version:    0.3.3
 Release:    0
 Group:      Network & Connectivity/Service
 License:    Apache-2.0
index e9b5875..f80395f 100644 (file)
@@ -249,6 +249,9 @@ static int _parse_remote_resource(OCDevAddr *dev_addr,
        iotcon_remote_resource_h temp;
        iotcon_connectivity_type_e conn_type;
 
+       DBG("dev_addr: adapter [%d], flags [%d], port [%d], addr [%s]",
+               dev_addr->adapter, dev_addr->flags, dev_addr->port, dev_addr->addr);
+
        _ioty_parse_oic_transport(adapter, dev_addr->flags, &conn_type, &conn_options);
 
        switch (conn_type) {
index e5b055e..7678924 100644 (file)
@@ -727,30 +727,19 @@ int icl_ioty_add_presence_cb(const char *host_address,
                iotcon_presence_h *presence_handle)
 {
        int ret;
-       int index = 0;
        int conn_extra;
        int conn_options;
        OCDoHandle handle;
-       const char *address;
        char uri[PATH_MAX] = {0};
        OCCallbackData cbdata = {0};
        OCConnectivityType oic_conn_type;
        iotcon_presence_h presence = NULL;
+       OCDevAddr dev_addr = {0};
 
        RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == presence_handle, IOTCON_ERROR_INVALID_PARAMETER);
 
-       if (NULL == host_address)
-               address = IC_MULTICAST_ADDRESS;
-       else
-               address = host_address;
-
-       if (IC_EQUAL == strncmp(IC_COAPS, address, strlen(IC_COAPS)))
-               index = strlen(IC_COAPS);
-       else if (IC_EQUAL == strncmp(IC_COAP, address, strlen(IC_COAP)))
-               index = strlen(IC_COAP);
-
-       snprintf(uri, sizeof(uri), "%s%s", &address[index], OC_RSRVD_PRESENCE_URI);
+       snprintf(uri, sizeof(uri), "%s", OC_RSRVD_PRESENCE_URI);
 
        presence = calloc(1, sizeof(struct icl_presence));
        if (NULL == presence) {
@@ -783,14 +772,32 @@ int icl_ioty_add_presence_cb(const char *host_address,
        oic_conn_type = ic_ioty_convert_connectivity_type(presence->connectivity_type,
                        conn_options);
 
+       if (NULL != host_address) {
+               ret = ic_ioty_convert_host_address(host_address,
+                       connectivity_type, conn_options, &dev_addr);
+               if (IOTCON_ERROR_NONE != ret) {
+                       ERR("ic_ioty_convert_host_address() Fail(%d)", ret);
+                       icl_destroy_presence(presence);
+                       return ret;
+               }
+       }
+
        ret = icl_ioty_mutex_lock();
        if (IOTCON_ERROR_NONE != ret) {
                ERR("icl_ioty_mutex_lock() Fail(%d)", ret);
                icl_destroy_presence(presence);
                return ret;
        }
+       DBG("uri:[%s], oic_conn_type:[%d(0x%x)]", uri, oic_conn_type, oic_conn_type);
+       if (NULL != host_address) {
+               DBG("dev_addr.addr:[%s], dev_addr.port:[%d]", dev_addr.addr, dev_addr.port);
+               ret = OCDoResource(&handle, OC_REST_PRESENCE, uri, &dev_addr, NULL, oic_conn_type,
+                               OC_LOW_QOS, &cbdata, NULL, 0);
+       } else {
        ret = OCDoResource(&handle, OC_REST_PRESENCE, uri, NULL, NULL, oic_conn_type,
                        OC_LOW_QOS, &cbdata, NULL, 0);
+       }
+
        icl_ioty_mutex_unlock();
        presence->handle = handle;