</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">
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;
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);
}
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,
{
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
}
-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);
return NULL;
}
- value = g_variant_new("(ia(qs)ivxx)",
- response->error_code,
+ value = g_variant_new("(a(qs)ivxx)",
&options,
response->result,
repr_gvar,
#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);
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)
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;
}
#define ICL_URI_PATH_LENGTH_MAX 36
struct icl_notify_msg {
- int error_code;
iotcon_interface_e iface;
iotcon_representation_h repr;
};
resp->oic_request_h = request->oic_request_h;
resp->oic_resource_h = request->oic_resource_h;
- resp->error_code = 200;
*response = 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;
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)
{
struct icl_resource_response {
- int error_code;
int seq_number;
iotcon_options_h header_options;
iotcon_interface_e iface;
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,
+++ /dev/null
-/*
- * 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__ */
*
* @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,
*
* @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);
* @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.
* @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);
/**
* @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
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
#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>
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;
{
int ret;
static int i = 0;
- iotcon_notimsg_h msg;
door_resource_s *door;
iotcon_representation_h repr;
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;
{
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);