Add qos enumeration for iotcon_resource_notify
authorsung.goo.kim <sung.goo.kim@samsung.com>
Wed, 13 Jan 2016 05:26:29 +0000 (14:26 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Wed, 13 Jan 2016 08:29:37 +0000 (17:29 +0900)
Change-Id: I7da24bb1401c45ce84dfd6aef770acb5240445ff

common/ic-dbus.xml
daemon/icd-dbus.c
daemon/icd-ioty.c
daemon/icd-ioty.h
doc/iotcon_doc.h
lib/icl-lite-resource.c
lib/icl-resource.c
lib/include/iotcon-constant.h
lib/include/iotcon-observers.h
lib/include/iotcon-resource.h
test/iotcon-test-basic-server.c

index 8d374127ea9efca53d56661441fe5f7f5c0e570c..66c72483e7cc37e565748385bf3ad72e2baaba33 100644 (file)
@@ -36,6 +36,7 @@
                        <arg type="x" name="resource" direction="in"/>
                        <arg type="av" name="notify_msg" direction="in"/>
                        <arg type="ai" name="observers" direction="in"/>
+                       <arg type="i" name="qos" direction="in"/>
                        <arg type="i" name="ret" direction="out"/>
                </method>
                <method name="sendResponse">
index f8fc9b75350b7af6f06dba090ee3956c8f96ae1f..e07487e6a59918b7b914c66148de01a7caf624b5 100644 (file)
@@ -917,7 +917,8 @@ static gboolean _dbus_handle_notify(icDbus *object,
                GDBusMethodInvocation *invocation,
                gint64 resource,
                GVariant *notify_msg,
-               GVariant *observers)
+               GVariant *observers,
+               gint qos)
 {
        int ret;
 
@@ -930,7 +931,7 @@ static gboolean _dbus_handle_notify(icDbus *object,
                return TRUE;
        }
 
-       ret = icd_ioty_notify(ICD_INT64_TO_POINTER(resource), notify_msg, observers);
+       ret = icd_ioty_notify(ICD_INT64_TO_POINTER(resource), notify_msg, observers, qos);
        if (IOTCON_ERROR_NONE != ret)
                ERR("icd_ioty_notify() Fail(%d)", ret);
 
index 22322e34a9f1be547b1b80010ccf8665d746d2b6..675989b5d6b70f96b66128d42a82e6004ec28648 100644 (file)
@@ -280,13 +280,28 @@ int icd_ioty_unbind_resource(OCResourceHandle parent, OCResourceHandle child)
        return IOTCON_ERROR_NONE;
 }
 
-int icd_ioty_notify(OCResourceHandle handle, GVariant *msg, GVariant *observers)
+static OCQualityOfService _icd_ioty_convert_qos(gint qos)
+{
+       switch (qos) {
+       case IOTCON_QOS_HIGH:
+               return OC_HIGH_QOS;
+       case IOTCON_QOS_LOW:
+               return OC_LOW_QOS;
+       default:
+               ERR("Invalid value(%d)", qos);
+               return OC_NA_QOS;
+       }
+}
+
+
+int icd_ioty_notify(OCResourceHandle handle, GVariant *msg, GVariant *observers, gint qos)
 {
        int i, obs_length, msg_length;
        GVariant *repr_gvar;
        GVariantIter obs_iter, msg_iter;
        OCStackResult ret;
-       OCRepPayload *payload;
+       OCRepPayload *payload = NULL;
+       OCQualityOfService oc_qos;
 
        g_variant_iter_init(&obs_iter, observers);
        obs_length = g_variant_iter_n_children(&obs_iter);
@@ -305,12 +320,14 @@ int icd_ioty_notify(OCResourceHandle handle, GVariant *msg, GVariant *observers)
                payload = icd_payload_representation_from_gvariant(repr_gvar);
        }
 
+       oc_qos = _icd_ioty_convert_qos(qos);
+
        icd_ioty_csdk_lock();
        /* TODO : QoS is come from lib. */
        if (msg_length)
-               ret = OCNotifyListOfObservers(handle, obs_ids, obs_length, payload, OC_LOW_QOS);
+               ret = OCNotifyListOfObservers(handle, obs_ids, obs_length, payload, oc_qos);
        else
-               ret = OCNotifyAllObservers(handle, OC_LOW_QOS);
+               ret = OCNotifyAllObservers(handle, oc_qos);
 
        icd_ioty_csdk_unlock();
 
@@ -697,7 +714,7 @@ static gboolean _icd_ioty_crud(int type,
        icd_ioty_csdk_lock();
        /* TODO : QoS is come from lib. And user can set QoS to client structure.  */
        result = OCDoResource(NULL, rest_type, uri, &dev_addr, payload, oic_conn_type,
-                       OC_LOW_QOS, &cbdata, oic_options_ptr, options_size);
+                       OC_HIGH_QOS, &cbdata, oic_options_ptr, options_size);
        icd_ioty_csdk_unlock();
 
        free(uri);
@@ -770,7 +787,7 @@ static OCDoHandle _icd_ioty_observe_register(const char *uri_path,
        icd_ioty_csdk_lock();
        /* TODO : QoS is come from lib. And user can set QoS to client structure.  */
        result = OCDoResource(&handle, method, uri_path, dev_addr, NULL, oic_conn_type,
-                       OC_LOW_QOS, cbdata, oic_options_ptr, options_size);
+                       OC_HIGH_QOS, cbdata, oic_options_ptr, options_size);
        icd_ioty_csdk_unlock();
 
        if (OC_STACK_OK != result) {
@@ -1437,7 +1454,7 @@ gboolean icd_ioty_encap_get(gpointer user_data)
 
        icd_ioty_csdk_lock();
        result = OCDoResource(NULL, OC_REST_GET, encap_info->uri_path, &encap_info->dev_addr,
-                       NULL, encap_info->oic_conn_type, OC_LOW_QOS, &cbdata, NULL, 0);
+                       NULL, encap_info->oic_conn_type, OC_HIGH_QOS, &cbdata, NULL, 0);
        icd_ioty_csdk_unlock();
 
        if (OC_STACK_OK != result)
index aa11aa1ed7027bf43047fb7804f0d2b3578357ba..99a999641e1d907dad5b32c56af3f4ab74537d60 100644 (file)
@@ -98,7 +98,7 @@ int icd_ioty_bind_resource(OCResourceHandle parent, OCResourceHandle child);
 
 int icd_ioty_unbind_resource(OCResourceHandle parent, OCResourceHandle child);
 
-int icd_ioty_notify(OCResourceHandle handle, GVariant *msg, GVariant *observers);
+int icd_ioty_notify(OCResourceHandle handle, GVariant *msg, GVariant *observers, gint qos);
 
 int icd_ioty_send_response(GVariant *resp);
 
index 7712c22853e288c5bb3164e6e86c5a687d4cb2ec..2a9ed8f9da5747f5d2418aaf532d66db7e8ac6ef 100644 (file)
@@ -332,7 +332,7 @@ static void _request_handler(iotcon_request_h request, void *user_data)
                return;
        }
 
-       ret = iotcon_resource_notify(_door_handle, resp_repr, _observers);
+       ret = iotcon_resource_notify(_door_handle, resp_repr, _observers, IOTCON_QOS_HIGH);
        if (IOTCON_ERROR_NONE != ret) {
                iotcon_representation_destroy(resp_repr);
                return;
index 9fbc06d6cb1a0e9473894306ea96c336d522394a..0c62f6e9a41bf39ce2ac2066c1f03b550561668d 100644 (file)
@@ -124,7 +124,7 @@ static int _icl_lite_resource_notify(iotcon_lite_resource_h lite_resource)
        resource.handle = lite_resource->handle;
        resource.sub_id = lite_resource->sub_id;
 
-       ret = iotcon_resource_notify(&resource, NULL, NULL);
+       ret = iotcon_resource_notify(&resource, NULL, NULL, IOTCON_QOS_HIGH);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("iotcon_resource_notify() Fail(%d)", ret);
                return ret;
index 277c01888763ccf66e76c10f506d751c8cbe0121..0bd4ef2dda744c0192bb44b681549c976e7ee760 100644 (file)
@@ -552,7 +552,7 @@ API int iotcon_resource_get_properties(iotcon_resource_h resource, int *properti
 }
 
 API int iotcon_resource_notify(iotcon_resource_h resource,
-               iotcon_representation_h repr, iotcon_observers_h observers)
+               iotcon_representation_h repr, iotcon_observers_h observers, iotcon_qos_e qos)
 {
        int ret;
        GError *error = NULL;
@@ -578,7 +578,7 @@ API int iotcon_resource_notify(iotcon_resource_h resource,
        else
                obs = icl_dbus_observers_to_gvariant(resource->observers);
 
-       ic_dbus_call_notify_sync(icl_dbus_get_object(), resource->handle, repr_gvar, obs,
+       ic_dbus_call_notify_sync(icl_dbus_get_object(), resource->handle, repr_gvar, obs, qos,
                        &ret, NULL, &error);
        if (error) {
                ERR("ic_dbus_call_notify_sync() Fail(%s)", error->message);
index 76a066ad46dcabfef673a24db533c212f0d56028..47433abcbdf39ba05e80d4499ad745680f19d8c1 100644 (file)
@@ -218,6 +218,17 @@ typedef enum {
        IOTCON_REMOTE_RESOURCE_LOST_SIGNAL, /**< Indicates remote resource is lost */
 } iotcon_remote_resource_state_e;
 
+/**
+ * @brief Enumeration for quality of service.
+ *
+ * @since_tizen 3.0
+ */
+typedef enum {
+       IOTCON_QOS_LOW,
+       IOTCON_QOS_HIGH,
+} iotcon_qos_e;
+
+
 /**
  * @}
  */
index 77d443f72fc9b420245ea264d232e96d7b073c16..c1104d578fb68056094cc7859eee9381339d3869 100644 (file)
@@ -92,7 +92,7 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques
                        return;
                }
                ...
-               ret = iotcon_resource_notify(resource, repr, _observers);
+               ret = iotcon_resource_notify(resource, repr, _observers, IOTCON_QOS_HIGH);
                if (IOTCON_ERROR_NONE != ret) {
                        iotcon_state_destroy(state);
                        iotcon_representation_destroy(repr);
index 6ea13509f6e01de14b3f76db78e105b8658b89ac..cdc3187f82cc43798297d08e330b88bf95f08659 100644 (file)
@@ -395,6 +395,7 @@ int iotcon_resource_unbind_child_resource(iotcon_resource_h parent,
  * @param[in] resource The handle of the resource
  * @param[in] repr The handle of the representation
  * @param[in] observers The handle of the observers.
+ * @param[in] qos The quality of service for message transfer.
  *
  * @return 0 on success, otherwise a negative error value.
  * @retval #IOTCON_ERROR_NONE  Successful
@@ -413,7 +414,7 @@ int iotcon_resource_unbind_child_resource(iotcon_resource_h parent,
  * @see iotcon_observers_remove()
  */
 int iotcon_resource_notify(iotcon_resource_h resource, iotcon_representation_h repr,
-               iotcon_observers_h observers);
+               iotcon_observers_h observers, iotcon_qos_e qos);
 
 /**
  * @brief Gets the number of children resources of the resource
index 69aa4b22b9200a1568cbd3ba37e97499e9e7075c..3ba6de579841d3b93b706ee2c0d96bb58695e6d2 100644 (file)
@@ -294,7 +294,7 @@ static int _request_handler_put(door_resource_s *door, iotcon_request_h request)
        }
 
        /* notify */
-       ret = iotcon_resource_notify(door->handle, resp_repr, door->observers);
+       ret = iotcon_resource_notify(door->handle, resp_repr, door->observers, IOTCON_QOS_HIGH);
        if (IOTCON_ERROR_NONE != ret)
                ERR("iotcon_resource_notify() Fail(%d)", ret);
 
@@ -329,7 +329,7 @@ static gboolean _door_state_changer(gpointer user_data)
                return G_SOURCE_REMOVE;
        }
 
-       ret = iotcon_resource_notify(door->handle, repr, door->observers);
+       ret = iotcon_resource_notify(door->handle, repr, door->observers, IOTCON_QOS_HIGH);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("iotcon_resource_notify() Fail(%d)", ret);
                iotcon_representation_destroy(repr);