(ACR) Remove iotcon_notimsg_h
authorsung.goo.kim <sung.goo.kim@samsung.com>
Mon, 2 Nov 2015 06:46:44 +0000 (15:46 +0900)
committeryoungman <yman.jung@samsung.com>
Tue, 3 Nov 2015 11:08:20 +0000 (20:08 +0900)
Change-Id: Ib532d1b168e34b885489f149d47774a2fd4d384a

17 files changed:
common/ic-dbus.xml
daemon/icd-ioty.c
doc/iotcon_doc.h
lib/icl-dbus-type.c
lib/icl-dbus-type.h
lib/icl-resource.c
lib/icl-resource.h
lib/icl-response.c
lib/icl-response.h
lib/include/iotcon-constant.h
lib/include/iotcon-notimsg.h [deleted file]
lib/include/iotcon-remote-resource.h
lib/include/iotcon-resource.h
lib/include/iotcon-response.h
lib/include/iotcon-server.h
test/iotcon-test-basic-server.c
test/iotcon-test-repr-server.c

index 023a8f0..7302b94 100644 (file)
                </method>
                <method name="notify">
                        <arg type="x" name="resource" direction="in"/>
-                       <arg type="a(iv)" name="notify_msg" direction="in"/>
+                       <arg type="av" name="notify_msg" direction="in"/>
                        <arg type="ai" name="observers" direction="in"/>
                        <arg type="i" name="ret" direction="out"/>
                </method>
                <method name="sendResponse">
-                       <arg type="(ia(qs)ivxx)" name="response" direction="in"/>
+                       <arg type="(a(qs)ivxx)" name="response" direction="in"/>
                        <arg type="i" name="ret" direction="out"/>
                </method>
                <method name="findResource">
index 668be65..003d6a5 100644 (file)
@@ -251,10 +251,9 @@ int icd_ioty_unbind_resource(OCResourceHandle parent, OCResourceHandle child)
        return IOTCON_ERROR_NONE;
 }
 
-
 int icd_ioty_notify(OCResourceHandle handle, GVariant *msg, GVariant *observers)
 {
-       int i, error_code, obs_length, msg_length;
+       int i, obs_length, msg_length;
        GVariant *repr_gvar;
        GVariantIter obs_iter, msg_iter;
        OCStackResult ret;
@@ -272,7 +271,7 @@ int icd_ioty_notify(OCResourceHandle handle, GVariant *msg, GVariant *observers)
        g_variant_iter_init(&msg_iter, msg);
        msg_length = g_variant_iter_n_children(&msg_iter);
        if (msg_length) {
-               g_variant_iter_loop(&msg_iter, "(iv)", &error_code, &repr_gvar);
+               g_variant_iter_loop(&msg_iter, "v", &repr_gvar);
                /* TODO : How to use error_code. */
                payload = icd_payload_representation_from_gvariant(repr_gvar);
        }
@@ -330,11 +329,10 @@ int icd_ioty_send_response(GVariant *resp)
        GVariantIter *options;
        OCStackResult ret;
        OCEntityHandlerResponse response = {0};
-       int result, error_code, options_size;
+       int result, options_size;
        int64_t request_handle, resource_handle;
 
-       g_variant_get(resp, "(ia(qs)ivxx)",
-                       &error_code,
+       g_variant_get(resp, "(a(qs)ivxx)",
                        &options,
                        &result,
                        &repr_gvar,
index 0976853..c879392 100644 (file)
@@ -313,27 +313,18 @@ static void _request_handler(iotcon_request_h request, void *user_data)
 {
        int ret;
        iotcon_representation_h repr;
-       iotcon_notimsg_h msg;
 
        ret = iotcon_representation_create(&resp_repr);
        if (IOTCON_ERROR_NONE != ret) {
                return;
        }
 
-       ret = iotcon_notimsg_create(resp_repr, IOTCON_INTERFACE_DEFAULT, &msg);
+       ret = iotcon_resource_notify(door_handle, resp_repr, observers);
        if (IOTCON_ERROR_NONE != ret) {
                iotcon_representation_destroy(resp_repr);
                return;
        }
 
-       ret = iotcon_resource_notify(door_handle, msg, observers);
-       if (IOTCON_ERROR_NONE != ret) {
-               iotcon_notimsg_destroy(msg);
-               iotcon_representation_destroy(resp_repr);
-               return;
-       }
-
-       iotcon_notimsg_destroy(msg);
        iotcon_representation_destroy(resp_repr);
 }
  * @endcode
index bdb3362..23ac34d 100644 (file)
@@ -54,21 +54,21 @@ const char** icl_dbus_resource_types_to_array(iotcon_resource_types_h types)
 }
 
 
-GVariant* icl_dbus_notimsg_to_gvariant(struct icl_notify_msg *msg)
+GVariant* icl_dbus_representation_to_gvariant(struct icl_representation_s *repr)
 {
        GVariantBuilder builder;
        GVariant *repr_gvar;
 
-       g_variant_builder_init(&builder, G_VARIANT_TYPE("a(iv)"));
+       g_variant_builder_init(&builder, G_VARIANT_TYPE("av"));
 
-       if (msg) {
-               repr_gvar = icl_representation_to_gvariant(msg->repr);
+       if (repr) {
+               repr_gvar = icl_representation_to_gvariant(repr);
                if (NULL == repr_gvar) {
                        ERR("icl_representation_to_gvariant() Fail");
                        g_variant_builder_clear(&builder);
                        return NULL;
                }
-               g_variant_builder_add(&builder, "(iv)", msg->error_code, repr_gvar);
+               g_variant_builder_add(&builder, "v", repr_gvar);
        }
 
        return g_variant_builder_end(&builder);
@@ -100,8 +100,7 @@ GVariant* icl_dbus_response_to_gvariant(struct icl_resource_response *response)
                return NULL;
        }
 
-       value = g_variant_new("(ia(qs)ivxx)",
-                       response->error_code,
+       value = g_variant_new("(a(qs)ivxx)",
                        &options,
                        response->result,
                        repr_gvar,
index 0f3a427..18a096c 100644 (file)
@@ -22,7 +22,7 @@
 #include "icl-resource-types.h"
 
 const char** icl_dbus_resource_types_to_array(iotcon_resource_types_h types);
-GVariant* icl_dbus_notimsg_to_gvariant(struct icl_notify_msg *msg);
+GVariant* icl_dbus_representation_to_gvariant(struct icl_representation_s *repr);
 GVariant* icl_dbus_response_to_gvariant(struct icl_resource_response *response);
 GVariant* icl_dbus_remote_resource_to_gvariant(struct icl_remote_resource *resource);
 GVariant* icl_dbus_device_info_to_gvariant(struct icl_device_info *device_info);
index ee69af1..e3c68cf 100644 (file)
@@ -530,61 +530,27 @@ API int iotcon_resource_get_properties(iotcon_resource_h resource, int *properti
        return IOTCON_ERROR_NONE;
 }
 
-
-API int iotcon_notimsg_create(iotcon_representation_h repr, iotcon_interface_e iface,
-               iotcon_notimsg_h *notimsg_handle)
-{
-       iotcon_notimsg_h msg;
-
-       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == notimsg_handle, IOTCON_ERROR_INVALID_PARAMETER);
-
-       msg = calloc(1, sizeof(struct icl_notify_msg));
-       if (NULL == msg) {
-               ERR("calloc() Fail(%d)", errno);
-               return IOTCON_ERROR_OUT_OF_MEMORY;
-       }
-
-       msg->repr = repr;
-       icl_representation_inc_ref_count(msg->repr);
-       msg->iface = iface;
-       msg->error_code = 200;
-
-       *notimsg_handle = msg;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API void iotcon_notimsg_destroy(iotcon_notimsg_h msg)
-{
-       RET_IF(NULL == msg);
-
-       iotcon_representation_destroy(msg->repr);
-       free(msg);
-}
-
-API int iotcon_resource_notify(iotcon_resource_h resource, iotcon_notimsg_h msg,
-               iotcon_observers_h observers)
+API int iotcon_resource_notify(iotcon_resource_h resource,
+               iotcon_representation_h repr, iotcon_observers_h observers)
 {
        int ret;
        GError *error = NULL;
-       GVariant *noti_msg;
        GVariant *obs;
+       GVariant *repr_gvar;
 
        RETV_IF(NULL == icl_dbus_get_object(), IOTCON_ERROR_DBUS);
        RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
 
        if (0 == resource->sub_id) {
                ERR("Invalid Resource handle");
                return IOTCON_ERROR_INVALID_PARAMETER;
        }
 
-       /* TODO: Get default message if msg parameter is NULL */
-       noti_msg = icl_dbus_notimsg_to_gvariant(msg);
-       if (NULL == noti_msg) {
-               ERR("icl_dbus_notimsg_to_gvariant() Fail");
-               return IOTCON_ERROR_REPRESENTATION;
+       repr_gvar = icl_dbus_representation_to_gvariant(repr);
+       if (NULL == repr_gvar) {
+               ERR("icl_representation_to_gvariant() Fail");
+               return IOTCON_ERROR_SYSTEM;
        }
 
        if (observers)
@@ -592,14 +558,14 @@ API int iotcon_resource_notify(iotcon_resource_h resource, iotcon_notimsg_h msg,
        else
                obs = icl_dbus_observers_to_gvariant(resource->observers);
 
-       ic_dbus_call_notify_sync(icl_dbus_get_object(), resource->handle, noti_msg, obs, &ret,
+       ic_dbus_call_notify_sync(icl_dbus_get_object(), resource->handle, repr_gvar, obs, &ret,
                        NULL, &error);
        if (error) {
                ERR("ic_dbus_call_notify_sync() Fail(%s)", error->message);
                ret = icl_dbus_convert_dbus_error(error->code);
                g_error_free(error);
                g_variant_unref(obs);
-               g_variant_unref(noti_msg);
+               g_variant_unref(repr_gvar);
                return ret;
        }
 
index 2f08dc1..11ec1f3 100644 (file)
@@ -35,7 +35,6 @@
 #define ICL_URI_PATH_LENGTH_MAX 36
 
 struct icl_notify_msg {
-       int error_code;
        iotcon_interface_e iface;
        iotcon_representation_h repr;
 };
index da399f3..be6c6a2 100644 (file)
@@ -47,7 +47,6 @@ API int iotcon_response_create(iotcon_request_h request,
 
        resp->oic_request_h = request->oic_request_h;
        resp->oic_resource_h = request->oic_resource_h;
-       resp->error_code = 200;
 
        *response = resp;
 
@@ -114,12 +113,13 @@ API int iotcon_response_set_result(iotcon_response_h resp,
 
 
 API int iotcon_response_set_representation(iotcon_response_h resp,
-               iotcon_representation_h repr)
+               iotcon_interface_e iface, iotcon_representation_h repr)
 {
        RETV_IF(NULL == resp, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
 
        resp->repr = repr;
+       resp->iface = iface;
        icl_representation_inc_ref_count(resp->repr);
 
        return IOTCON_ERROR_NONE;
@@ -142,17 +142,6 @@ API int iotcon_response_set_header_options(iotcon_response_h resp,
        return IOTCON_ERROR_NONE;
 }
 
-
-API int iotcon_response_set_interface(iotcon_response_h resp, iotcon_interface_e iface)
-{
-       RETV_IF(NULL == resp, IOTCON_ERROR_INVALID_PARAMETER);
-
-       resp->iface = iface;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
 static bool _icl_response_representation_child_cb(iotcon_representation_h child,
                void *user_data)
 {
index 070ed87..bc07daf 100644 (file)
@@ -28,7 +28,6 @@ typedef enum {
 
 
 struct icl_resource_response {
-       int error_code;
        int seq_number;
        iotcon_options_h header_options;
        iotcon_interface_e iface;
index de5df10..2f1b9dc 100644 (file)
@@ -63,14 +63,6 @@ typedef struct icl_resource* iotcon_resource_h;
 typedef struct icl_lite_resource* iotcon_lite_resource_h;
 
 /**
- * @brief The handle of notifications message.
- * @details iotcon_notimsg_h is an opaque data structure to notify message to observers.
- *
- * @since_tizen 3.0
- */
-typedef struct icl_notify_msg* iotcon_notimsg_h;
-
-/**
 * @brief The handle of response
 * @details iotcon_response_h is an opaque data structure to respond to client.\n
 * iotcon_response_h is a data type of server's response which consists of result,
diff --git a/lib/include/iotcon-notimsg.h b/lib/include/iotcon-notimsg.h
deleted file mode 100644 (file)
index ff51cea..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __IOT_CONNECTIVITY_MANAGER_SERVER_NOTIMSG_H__
-#define __IOT_CONNECTIVITY_MANAGER_SERVER_NOTIMSG_H__
-
-#include <iotcon-constant.h>
-
-/**
- * @file iotcon-notimsg.h
- */
-
-/**
- * @ingroup CAPI_IOT_CONNECTIVITY_SERVER_MODULE
- * @defgroup CAPI_IOT_CONNECTIVITY_SERVER_NOTIMSG_MODULE Notimsg
- *
- * @brief Iotcon Notimsg provides API to create a message to notify to client.
- *
- * @section CAPI_IOT_CONNECTIVITY_SERVER_NOTIMSG_MODULE_HEADER Header
- *  \#include <iotcon.h>
- *
- * @{
- */
-
-/**
- * @brief Creates a new notifications message handle.
- * @details @a iface could be one of #iotcon_interface_e.
- *
- * @since_tizen 3.0
- *
- * @param[in] repr The handle of the representation
- * @param[in] iface The resource interface
- * @param[out] notimsg_handle The generated notifications message handle
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #IOTCON_ERROR_NONE  Successful
- * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
- * @retval #IOTCON_ERROR_OUT_OF_MEMORY  Out of memory
- *
- * @see iotcon_remote_resource_response_cb()
- * @see iotcon_remote_resource_start_observing()
- * @see iotcon_remote_resource_observer_stop()
- * @see iotcon_resource_notify()
- */
-int iotcon_notimsg_create(iotcon_representation_h repr, iotcon_interface_e iface,
-               iotcon_notimsg_h *notimsg_handle);
-
-/**
- * @brief Releases a notifications message handle.
- *
- * @since_tizen 3.0
- *
- * @param[in] msg The handle of the notifications message
- *
- * @return void
- *
- * @see iotcon_notimsg_create()
- */
-void iotcon_notimsg_destroy(iotcon_notimsg_h msg);
-
-/**
- * @}
- */
-
-#endif /* __IOT_CONNECTIVITY_MANAGER_SERVER_NOTIMSG_H__ */
index 290740d..1187521 100644 (file)
@@ -159,7 +159,6 @@ typedef void (*iotcon_remote_resource_response_cb)(iotcon_remote_resource_h reso
  *
  * @see iotcon_remote_resource_response_cb()
  * @see iotcon_remote_resource_observer_stop()
- * @see iotcon_notimsg_create()
  * @see iotcon_resource_notify()
  */
 int iotcon_remote_resource_start_observing(iotcon_remote_resource_h resource,
@@ -186,7 +185,6 @@ int iotcon_remote_resource_start_observing(iotcon_remote_resource_h resource,
  *
  * @see iotcon_remote_resource_response_cb()
  * @see iotcon_remote_resource_start_observing()
- * @see iotcon_notimsg_create()
  * @see iotcon_resource_notify()
  */
 int iotcon_remote_resource_observer_stop(iotcon_remote_resource_h resource);
index 218b613..e36f199 100644 (file)
@@ -291,7 +291,7 @@ int iotcon_resource_unbind_child_resource(iotcon_resource_h parent,
  * @privilege %http://tizen.org/privilege/internet
  *
  * @param[in] resource The handle of the resource
- * @param[in] msg The handle of the notifications message
+ * @param[in] repr The handle of the representation
  * @param[in] observers The handle of the observers.
  *
  * @return 0 on success, otherwise a negative error value.
@@ -305,14 +305,12 @@ int iotcon_resource_unbind_child_resource(iotcon_resource_h parent,
  * @see iotcon_remote_resource_response_cb()
  * @see iotcon_remote_resource_start_observing()
  * @see iotcon_remote_resource_observer_stop()
- * @see iotcon_notimsg_create()
- * @see iotcon_notimsg_destroy()
  * @see iotcon_observers_create()
  * @see iotcon_observers_destroy()
  * @see iotcon_observers_add()
  * @see iotcon_observers_remove()
  */
-int iotcon_resource_notify(iotcon_resource_h resource, iotcon_notimsg_h msg,
+int iotcon_resource_notify(iotcon_resource_h resource, iotcon_representation_h repr,
                iotcon_observers_h observers);
 
 /**
index 9f5e29e..6ca7d8a 100644 (file)
@@ -155,7 +155,7 @@ int iotcon_response_set_result(iotcon_response_h resp, iotcon_response_result_e
  * @see iotcon_response_destroy()
  */
 int iotcon_response_set_representation(iotcon_response_h resp,
-               iotcon_representation_h repr);
+               iotcon_interface_e iface, iotcon_representation_h repr);
 
 /**
  * @brief Sets header options into the response
@@ -176,24 +176,6 @@ int iotcon_response_set_representation(iotcon_response_h resp,
 int iotcon_response_set_header_options(iotcon_response_h resp, iotcon_options_h options);
 
 /**
- * @brief Sets resource interface into the response
- *
- * @since_tizen 3.0
- *
- * @param[in] resp The handle of the response
- * @param[in] iface The resource interface
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #IOTCON_ERROR_NONE  Successful
- * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
- * @retval #IOTCON_ERROR_OUT_OF_MEMORY  Out of memory
- *
- * @see iotcon_response_create()
- * @see iotcon_response_destroy()
- */
-int iotcon_response_set_interface(iotcon_response_h resp, iotcon_interface_e iface);
-
-/**
  * @brief Send response for incoming request.
  *
  * @since_tizen 3.0
index 4835890..22beac0 100644 (file)
@@ -18,7 +18,6 @@
 
 #include <iotcon-resource.h>
 #include <iotcon-lite-resource.h>
-#include <iotcon-notimsg.h>
 #include <iotcon-response.h>
 #include <iotcon-observers.h>
 #include <iotcon-request.h>
index 7970b3a..0848abc 100644 (file)
@@ -132,7 +132,7 @@ static int _send_response(iotcon_response_h response, iotcon_representation_h re
                return -1;
        }
 
-       ret = iotcon_response_set_representation(response, repr);
+       ret = iotcon_response_set_representation(response, IOTCON_INTERFACE_DEFAULT, repr);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("iotcon_response_set_representation() Fail(%d)", ret);
                return -1;
@@ -283,7 +283,6 @@ static gboolean _notifier(gpointer user_data)
 {
        int ret;
        static int i = 0;
-       iotcon_notimsg_h msg;
        door_resource_s *door;
        iotcon_representation_h repr;
 
@@ -299,22 +298,13 @@ static gboolean _notifier(gpointer user_data)
                return G_SOURCE_REMOVE;
        }
 
-       ret = iotcon_notimsg_create(repr, IOTCON_INTERFACE_DEFAULT, &msg);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_notimsg_create() Fail(%d)", ret);
-               iotcon_representation_destroy(repr);
-               return G_SOURCE_REMOVE;
-       }
-
-       ret = iotcon_resource_notify(door->handle, msg, door->observers);
+       ret = iotcon_resource_notify(door->handle, repr, door->observers);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("iotcon_resource_notify() Fail(%d)", ret);
-               iotcon_notimsg_destroy(msg);
                iotcon_representation_destroy(repr);
                return G_SOURCE_REMOVE;
        }
 
-       iotcon_notimsg_destroy(msg);
        iotcon_representation_destroy(repr);
 
        return G_SOURCE_CONTINUE;
index 6482561..ffe7214 100644 (file)
@@ -25,18 +25,12 @@ static int _send_response(iotcon_response_h response, iotcon_representation_h re
 {
        int ret;
 
-       ret = iotcon_response_set_representation(response, repr);
+       ret = iotcon_response_set_representation(response, iface, repr);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("iotcon_response_set_representation() Fail(%d)", ret);
                return -1;
        }
 
-       ret = iotcon_response_set_interface(response, iface);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_response_set_interface() Fail(%d)", ret);
-               return -1;
-       }
-
        ret = iotcon_response_set_result(response, IOTCON_RESPONSE_RESULT_OK);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("iotcon_response_set_result() Fail(%d)", ret);