<arg type="s" name="host_address" direction="in"/>
<arg type="i" name="connectivity" direction="in"/>
<arg type="s" name="type" direction="in"/>
+ <arg type="b" name="is_secure" direction="in"/>
<arg type="x" name="signal_number" direction="out"/>
<arg type="i" name="ret" direction="out"/>
</method>
<arg type="x" name="signal_number" direction="out"/>
<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"/>
GDBusMethodInvocation *invocation,
const gchar *host_address,
gint connectivity,
- const gchar *type)
+ const gchar *type,
+ bool is_secure)
{
int ret;
const gchar *sender;
sender = g_dbus_method_invocation_get_sender(invocation);
signal_number = icd_dbus_generate_signal_number();
- ret = icd_ioty_find_resource(host_address, connectivity, type, signal_number, sender);
+ ret = icd_ioty_find_resource(host_address, connectivity, type, is_secure,
+ signal_number, sender);
if (IOTCON_ERROR_NONE != ret)
ERR("icd_ioty_find_resource() Fail(%d)", ret);
G_CALLBACK(_dbus_handle_get_device_info), NULL);
g_signal_connect(icd_dbus_object, "handle-get-platform-info",
G_CALLBACK(_dbus_handle_get_platform_info), NULL);
- g_signal_connect(icd_dbus_object, "handle-get-tizen-info",
- G_CALLBACK(icd_ioty_get_tizen_info), NULL);
g_signal_connect(icd_dbus_object, "handle-start-presence",
G_CALLBACK(_dbus_handle_start_presence), NULL);
g_signal_connect(icd_dbus_object, "handle-stop-presence",
};
-struct icd_tizen_info_context {
- OCRequestHandle request_h;
- OCResourceHandle resource_h;
- GDBusMethodInvocation *invocation;
-};
-
-
struct icd_observe_context {
int64_t signal_number;
int res;
}
-static int _worker_tizen_info_handler(void *context)
-{
- int ret;
- char *device_name;
- char *tizen_device_id;
- OCStackResult result;
- OCRepPayload *payload;
- OCEntityHandlerResponse response = {0};
- struct icd_tizen_info_context *ctx = context;
-
- response.requestHandle = ctx->request_h;
- response.resourceHandle = ctx->resource_h;
- response.ehResult = OC_EH_OK;
-
- /* Get Tizen Info */
- ret = icd_ioty_tizen_info_get_property(&device_name, &tizen_device_id);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("icd_ioty_tizen_info_get_property() Fail(%d)", ret);
- response.ehResult = OC_EH_ERROR;
- }
-
- /* payload */
- payload = OCRepPayloadCreate();
- OCRepPayloadSetUri(payload, ICD_IOTY_TIZEN_INFO_URI);
- OCRepPayloadAddResourceType(payload, ICD_IOTY_TIZEN_INFO_TYPE);
- OCRepPayloadAddInterface(payload, IC_INTERFACE_DEFAULT);
-
- OCRepPayloadSetPropString(payload, ICD_IOTY_TIZEN_INFO_DEVICE_NAME,
- ic_utils_dbus_encode_str(device_name));
- OCRepPayloadSetPropString(payload, ICD_IOTY_TIZEN_INFO_TIZEN_DEVICE_ID,
- ic_utils_dbus_encode_str(tizen_device_id));
- response.payload = (OCPayload*)payload;
-
- icd_ioty_csdk_lock();
- result = OCDoResponse(&response);
- icd_ioty_csdk_unlock();
-
- if (OC_STACK_OK != result) {
- ERR("OCDoResponse() Fail(%d)", result);
- free(ctx);
- return IOTCON_ERROR_IOTIVITY;
- }
-
- free(ctx);
- return IOTCON_ERROR_NONE;
-}
-
-
-OCEntityHandlerResult icd_ioty_ocprocess_tizen_info_handler(OCEntityHandlerFlag flag,
- OCEntityHandlerRequest *request, void *user_data)
-{
- int ret;
- struct icd_tizen_info_context *tizen_info_ctx;
-
- if ((0 == (OC_REQUEST_FLAG & flag)) || (OC_REST_GET != request->method)) {
- ERR("Prohibited Action");
- return OC_EH_FORBIDDEN;
- }
-
- tizen_info_ctx = calloc(1, sizeof(struct icd_tizen_info_context));
- if (NULL == tizen_info_ctx) {
- ERR("calloc() Fail(%d)", errno);
- return OC_EH_ERROR;
- }
-
- tizen_info_ctx->request_h = request->requestHandle;
- tizen_info_ctx->resource_h = request->resource;
-
- ret = _ocprocess_worker_start(_worker_tizen_info_handler, tizen_info_ctx);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("_ocprocess_worker_start() Fail(%d)", ret);
- free(tizen_info_ctx);
- return OC_EH_ERROR;
- }
-
- return OC_EH_OK;
-}
-
-
-OCStackApplicationResult icd_ioty_ocprocess_get_tizen_info_cb(void *ctx,
- OCDoHandle handle, OCClientResponse *resp)
-{
- int res;
- char *device_name;
- char *tizen_device_id;
- GVariant *tizen_info;
- OCRepPayload *payload;
- OCRepPayloadValue *val;
-
- RETV_IF(NULL == ctx, OC_STACK_DELETE_TRANSACTION);
-
- if (NULL == resp->payload) {
- ERR("payload is empty");
- icd_ioty_complete_error(ICD_TIZEN_INFO, ctx, IOTCON_ERROR_IOTIVITY);
- return OC_STACK_DELETE_TRANSACTION;
- }
-
- payload = (OCRepPayload*)resp->payload;
- val = payload->values;
- if (NULL == val) {
- ERR("Invalid payload");
- icd_ioty_complete_error(ICD_TIZEN_INFO, ctx, IOTCON_ERROR_IOTIVITY);
- return OC_STACK_DELETE_TRANSACTION;
- }
- device_name = val->str;
-
- val = val->next;
- if (NULL == val) {
- ERR("Invalid Payload");
- icd_ioty_complete_error(ICD_TIZEN_INFO, ctx, IOTCON_ERROR_IOTIVITY);
- return OC_STACK_DELETE_TRANSACTION;
- }
-
- tizen_device_id = val->str;
-
- if (OC_STACK_OK == resp->result)
- res = IOTCON_RESPONSE_OK;
- else
- res = IOTCON_RESPONSE_ERROR;
-
- tizen_info = g_variant_new("(ssi)", device_name, tizen_device_id, res);
-
- icd_ioty_complete(ICD_TIZEN_INFO, ctx, tizen_info);
-
- return OC_STACK_DELETE_TRANSACTION;
-}
-
-
static int _worker_encap_get_cb(void *context)
{
int ret;
return OC_STACK_KEEP_TRANSACTION;
}
-
OCStackApplicationResult icd_ioty_ocprocess_info_cb(void *ctx, OCDoHandle handle,
OCClientResponse *resp);
-OCEntityHandlerResult icd_ioty_ocprocess_tizen_info_handler(OCEntityHandlerFlag flag,
- OCEntityHandlerRequest *request, void *user_data);
-
-OCStackApplicationResult icd_ioty_ocprocess_get_tizen_info_cb(void *ctx,
- OCDoHandle handle, OCClientResponse* resp);
-
OCStackApplicationResult icd_ioty_ocprocess_encap_get_cb(void *ctx, OCDoHandle handle,
OCClientResponse* resp);
}
+int icd_ioty_oic_properties_to_properties(int oic_properties)
+{
+ int prop = IOTCON_RESOURCE_NO_PROPERTY;
+
+ if (OC_DISCOVERABLE & oic_properties)
+ prop |= IOTCON_RESOURCE_DISCOVERABLE;
+
+ if (OC_OBSERVABLE & oic_properties)
+ prop |= IOTCON_RESOURCE_OBSERVABLE;
+
+ if (OC_ACTIVE & oic_properties)
+ prop |= IOTCON_RESOURCE_ACTIVE;
+
+ if (OC_SLOW & oic_properties)
+ prop |= IOTCON_RESOURCE_SLOW;
+
+ if (OC_SECURE & oic_properties)
+ prop |= IOTCON_RESOURCE_SECURE;
+
+ if (OC_EXPLICIT_DISCOVERABLE & oic_properties)
+ prop |= IOTCON_RESOURCE_EXPLICIT_DISCOVERABLE;
+
+ return prop;
+}
int icd_ioty_get_host_address(OCDevAddr *dev_addr, char **host_address, int *conn_type);
+int icd_ioty_oic_properties_to_properties(int oic_properties);
+
#endif /*__IOT_CONNECTIVITY_MANAGER_DAEMON_IOTIVITY_TYPE_H__*/
static int icd_remote_resource_time_interval = ICD_REMOTE_RESOURCE_DEFAULT_TIME_INTERVAL;
-static const char *ICD_SYSTEM_INFO_TIZEN_ID = "http://tizen.org/system/tizenid";
static const char *ICD_SYSTEM_INFO_PLATFORM_NAME = "http://tizen.org/system/platform.name";
static const char *ICD_SYSTEM_INFO_PLATFORM_VERSION = "http://tizen.org/feature/platform.version";
static const char *ICD_SYSTEM_INFO_MANUF_NAME = "http://tizen.org/system/manufacturer";
static const char *ICD_SYSTEM_INFO_MODEL_NAME = "http://tizen.org/system/model_name";
static const char *ICD_SYSTEM_INFO_BUILD_STRING = "http://tizen.org/system/build.string";
-typedef struct {
- char *device_name;
- char *tizen_device_id;
-} icd_tizen_info_s;
-
-static icd_tizen_info_s icd_tizen_info = {0};
-
static GHashTable *icd_ioty_encap_table;
static GHashTable *icd_ioty_presence_table;
}
-int icd_ioty_find_resource(const char *host_address, int conn_type,
- const char *resource_type, int64_t signal_number, const char *bus_name)
+int icd_ioty_find_resource(const char *host_address,
+ int conn_type,
+ const char *resource_type,
+ bool is_secure,
+ int64_t signal_number,
+ const char *bus_name)
{
int len;
+ char *coap_str;
OCStackResult result;
icd_sig_ctx_s *context;
char uri[PATH_MAX] = {0};
OCCallbackData cbdata = {0};
OCConnectivityType oic_conn_type;
+ coap_str = is_secure? ICD_IOTY_COAPS:ICD_IOTY_COAP;
+
if (IC_STR_EQUAL == strcmp(IC_STR_NULL, host_address)) {
len = snprintf(uri, sizeof(uri), "%s", OC_RSRVD_WELL_KNOWN_URI);
} else {
- len = snprintf(uri, sizeof(uri), ICD_IOTY_COAP"%s%s", host_address,
+ len = snprintf(uri, sizeof(uri), "%s%s%s", coap_str, host_address,
OC_RSRVD_WELL_KNOWN_URI);
}
if (len <= 0 || sizeof(uri) <= len) {
case ICD_CRUD_DELETE:
ic_dbus_complete_delete(icd_dbus_get_object(), invocation, value);
break;
- case ICD_TIZEN_INFO:
- ic_dbus_complete_get_tizen_info(icd_dbus_get_object(), invocation, value);
- break;
default:
- INFO("Invalid type(%d)", type);
+ INFO("Invalid Type(%d)", type);
}
}
value = g_variant_new("(a(qs)i)", &options, ret_val);
ic_dbus_complete_delete(icd_dbus_get_object(), invocation, value);
break;
- case ICD_TIZEN_INFO:
- value = g_variant_new("(ssi)", IC_STR_NULL, IC_STR_NULL, ret_val);
- ic_dbus_complete_get_tizen_info(icd_dbus_get_object(), invocation, value);
- break;
+ default:
+ INFO("Invalid Type(%d)", type);
}
}
return IOTCON_ERROR_NONE;
}
-static int _icd_ioty_get_tizen_id(char **tizen_device_id)
-{
- int ret;
- char *tizen_id = NULL;
-
- ret = system_info_get_platform_string(ICD_SYSTEM_INFO_TIZEN_ID, &tizen_id);
- if (SYSTEM_INFO_ERROR_NONE != ret) {
- ERR("system_info_get_platform_string() Fail(%d)", ret);
- return IOTCON_ERROR_SYSTEM;
- }
- *tizen_device_id = tizen_id;
-
- return IOTCON_ERROR_NONE;
-}
-
static int _ioty_set_device_info()
{
int ret;
return icd_ioty_convert_error(ret);
}
- free(icd_tizen_info.device_name);
- icd_tizen_info.device_name = device_name;
-
return IOTCON_ERROR_NONE;
}
return IOTCON_ERROR_NONE;
}
-int icd_ioty_set_tizen_info()
-{
- int result;
- OCStackResult ret;
- OCResourceHandle handle;
- char *tizen_device_id = NULL;
-
- result = _icd_ioty_get_tizen_id(&tizen_device_id);
- if (IOTCON_ERROR_NONE != result) {
- ERR("_icd_ioty_get_tizen_id() Fail(%d)", result);
- return result;
- }
-
- icd_tizen_info.tizen_device_id = tizen_device_id;
- DBG("tizen_device_id : %s", icd_tizen_info.tizen_device_id);
-
- icd_ioty_csdk_lock();
- ret = OCCreateResource(&handle,
- ICD_IOTY_TIZEN_INFO_TYPE,
- IC_INTERFACE_DEFAULT,
- ICD_IOTY_TIZEN_INFO_URI,
- icd_ioty_ocprocess_tizen_info_handler,
- NULL,
- OC_EXPLICIT_DISCOVERABLE);
- icd_ioty_csdk_unlock();
- if (OC_STACK_OK != ret) {
- ERR("OCCreateResource() Fail(%d)", ret);
- return icd_ioty_convert_error(ret);
- }
-
- return IOTCON_ERROR_NONE;
-}
-
-
-gboolean icd_ioty_get_tizen_info(icDbus *object, GDBusMethodInvocation *invocation,
- const gchar *host_address, int conn_type)
-{
- int ret;
- OCStackResult result;
- OCDevAddr dev_addr = {0};
- OCCallbackData cbdata = {0};
- OCConnectivityType oic_conn_type;
-
- cbdata.cb = icd_ioty_ocprocess_get_tizen_info_cb;
- cbdata.context = invocation;
-
- oic_conn_type = icd_ioty_conn_type_to_oic_conn_type(conn_type);
-
- ret = icd_ioty_get_dev_addr(host_address, conn_type, &dev_addr);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("icd_ioty_get_dev_addr() Fail(%d)", ret);
- icd_ioty_complete_error(ICD_TIZEN_INFO, invocation, IOTCON_ERROR_IOTIVITY);
- return TRUE;
- }
-
- icd_ioty_csdk_lock();
- result = OCDoResource(NULL, OC_REST_GET, ICD_IOTY_TIZEN_INFO_URI, &dev_addr, NULL,
- oic_conn_type, OC_LOW_QOS, &cbdata, NULL, 0);
- icd_ioty_csdk_unlock();
-
- if (OC_STACK_OK != result) {
- ERR("OCDoResource() Fail(%d)", result);
- icd_ioty_complete_error(ICD_TIZEN_INFO, invocation, icd_ioty_convert_error(result));
- return TRUE;
- }
-
- return TRUE;
-}
-
-
-int icd_ioty_tizen_info_get_property(char **device_name, char **tizen_device_id)
-{
- RETV_IF(NULL == device_name, IOTCON_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == tizen_device_id, IOTCON_ERROR_INVALID_PARAMETER);
-
- *device_name = icd_tizen_info.device_name;
- *tizen_device_id = icd_tizen_info.tizen_device_id;
-
- return IOTCON_ERROR_NONE;
-}
-
static void _icd_ioty_presence_table_create()
{
#define ICD_MULTICAST_ADDRESS "224.0.1.187:5683"
-/* TODO Define Tizen Information Resource(uri, resource type) */
-#define ICD_IOTY_TIZEN_INFO_URI "/org/tizen/iot/d"
-#define ICD_IOTY_TIZEN_INFO_TYPE "org.tizen.iot.d"
-
-#define ICD_IOTY_TIZEN_INFO_DEVICE_NAME "device_name"
-#define ICD_IOTY_TIZEN_INFO_TIZEN_DEVICE_ID "tizen_device_id"
-
typedef struct {
int64_t signal_number;
char *bus_name;
ICD_CRUD_DELETE,
ICD_DEVICE_INFO,
ICD_PLATFORM_INFO,
- ICD_TIZEN_INFO,
ICD_ENCAP_MONITORING,
ICD_ENCAP_CACHING,
ICD_PRESENCE,
int icd_ioty_send_response(GVariant *resp);
-int icd_ioty_find_resource(const char *host_address, int conn_type,
- const char *resource_type, int64_t signal_number, const char *bus_name);
+int icd_ioty_find_resource(const char *host_address,
+ int conn_type,
+ const char *resource_type,
+ bool is_secure,
+ int64_t 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);
int icd_ioty_set_device_info();
int icd_ioty_set_platform_info();
-int icd_ioty_set_tizen_info();
-
-gboolean icd_ioty_get_tizen_info(icDbus *object, GDBusMethodInvocation *invocation,
- const gchar *host_address, int conn_type);
-
-int icd_ioty_tizen_info_get_property(char **device_name, char **tizen_device_id);
OCDoHandle icd_ioty_presence_table_get_handle(const char *host_address);
#include "ic-utils.h"
#include "icd.h"
#include "icd-ioty.h"
+#include "icd-ioty-type.h"
#include "icd-payload.h"
union icd_state_value_u {
OCRandomUuidResult random_res;
OCDiscoveryPayload *discovered;
struct OCResourcePayload *resource;
- int i, is_observable, ret, res_count;
+ int i, properties, ret, res_count;
char device_id[UUID_STRING_SIZE] = {0};
discovered = (OCDiscoveryPayload*)payload;
node = node->next;
}
- /* is_observable */
- is_observable = resource->bitmap & OC_OBSERVABLE;
+ /* Resource Properties */
+ properties = icd_ioty_oic_properties_to_properties(resource->bitmap);
/* port */
port = (resource->port)? resource->port:dev_addr->port;
+ /* TODO
+ * Check "resource->secure" and "resource->bitmap" */
value[i] = g_variant_new("(ssiasibsi)", resource->uri, device_id, ifaces, &types,
- is_observable, resource->secure, dev_addr->addr, port);
+ properties, resource->secure, dev_addr->addr, port);
DBG("found resource[%d] : %s", i, g_variant_print(value[i], FALSE));
resource = resource->next;
return -1;
}
- ret = icd_ioty_set_tizen_info();
- if (IOTCON_ERROR_NONE != ret) {
- ERR("icd_ioty_set_tizen_info() Fail(%d)", ret);
- icd_ioty_deinit(thread);
- icd_dbus_deinit(id);
- return -1;
- }
-
g_main_loop_run(loop);
icd_ioty_deinit(thread);
const char *type = "org.tizen.door";
ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4, type,
- _found_resource, NULL);
+ false, _found_resource, NULL);
if (IOTCON_ERROR_NONE != ret)
return;
}
GVariant* icl_dbus_remote_resource_to_gvariant(struct icl_remote_resource *resource)
{
FN_CALL;
+ bool is_secure;
GVariant *value;
GHashTableIter iter;
GVariantBuilder options;
}
}
+ is_secure = resource->properties & IOTCON_RESOURCE_SECURE;
value = g_variant_new("(ssba(qs)i)", resource->uri_path, resource->host_address,
- resource->is_secure, &options, resource->connectivity_type);
+ is_secure, &options, resource->connectivity_type);
return value;
}
int timeout_id;
} icl_platform_info_s;
-typedef struct {
- iotcon_tizen_info_cb cb;
- void *user_data;
-} icl_tizen_info_s;
-
API int iotcon_device_info_get_property(iotcon_device_info_h device_info,
iotcon_device_info_e property, char **value)
return ret;
}
-
-
-static void _icl_tizen_info_cb(GObject *object, GAsyncResult *g_async_res,
- gpointer user_data)
-{
- int res;
- GVariant *result;
- char *device_name;
- char *tizen_device_id;
- GError *error = NULL;
- struct icl_tizen_info info = {0};
- icl_tizen_info_s *cb_container = user_data;
- iotcon_tizen_info_cb cb = cb_container->cb;
-
- ic_dbus_call_get_tizen_info_finish(IC_DBUS(object), &result, g_async_res, &error);
- if (error) {
- ERR("ic_dbus_call_get_tizen_info_finish() Fail(%s)", error->message);
- if (cb) {
- int ret = icl_dbus_convert_dbus_error(error->code);
- cb(&info, ret, cb_container->user_data);
- }
- g_error_free(error);
- /* TODO contain time out error */
- free(cb_container);
- return;
- }
-
- g_variant_get(result, "(&s&si)", &device_name, &tizen_device_id, &res);
-
- if (IOTCON_ERROR_NONE == res && NULL != ic_utils_dbus_decode_str(tizen_device_id)) {
- info.device_name = ic_utils_dbus_decode_str(device_name);
- info.tizen_device_id = tizen_device_id;
- }
-
- if (cb)
- cb(&info, res, cb_container->user_data);
-
- free(cb_container);
-}
-
-
-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;
-
- RETV_IF(NULL == icl_dbus_get_object(), IOTCON_ERROR_DBUS);
- RETV_IF(NULL == host_address, IOTCON_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
-
- cb_container = calloc(1, sizeof(icl_tizen_info_s));
- if (NULL == cb_container) {
- ERR("calloc() Fail(%d)", errno);
- return IOTCON_ERROR_OUT_OF_MEMORY;
- }
-
- cb_container->cb = cb;
- cb_container->user_data = user_data;
-
- 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;
-}
-
-
-API int iotcon_tizen_info_get_property(iotcon_tizen_info_h tizen_info,
- iotcon_tizen_info_e property, char **value)
-{
- RETV_IF(NULL == tizen_info, IOTCON_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == value, IOTCON_ERROR_INVALID_PARAMETER);
-
- switch (property) {
- case IOTCON_TIZEN_INFO_DEVICE_NAME:
- *value = tizen_info->device_name;
- break;
- case IOTCON_TIZEN_INFO_TIZEN_DEVICE_ID:
- *value = tizen_info->tizen_device_id;
- break;
- default:
- ERR("Invalid property(%d)", property);
- return IOTCON_ERROR_INVALID_PARAMETER;
- }
-
- return IOTCON_ERROR_NONE;
-}
char *system_time;
};
-struct icl_tizen_info {
- char *device_name;
- char *tizen_device_id;
-};
-
#endif /* __IOT_CONNECTIVITY_MANAGER_LIBRARY_DEVICE_H__ */
API int iotcon_find_resource(const char *host_address,
iotcon_connectivity_type_e connectivity_type,
const char *resource_type,
+ bool is_secure,
iotcon_found_resource_cb cb,
void *user_data)
{
ic_utils_dbus_encode_str(host_address),
connectivity_type,
ic_utils_dbus_encode_str(resource_type),
+ is_secure,
&signal_number,
&ret,
NULL,
API int iotcon_remote_resource_create(const char *host_address,
iotcon_connectivity_type_e connectivity_type,
const char *uri_path,
- bool is_observable,
+ int properties,
iotcon_resource_types_h resource_types,
int resource_ifs,
iotcon_remote_resource_h *resource_handle)
resource->host_address = ic_utils_strdup(host_address);
resource->connectivity_type = connectivity_type;
resource->uri_path = ic_utils_strdup(uri_path);
- resource->is_observable = is_observable;
+ resource->properties = properties;
resource->types = icl_resource_types_ref(resource_types);
resource->ifaces = resource_ifs;
resource->host_address = ic_utils_strdup(src->host_address);
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;
+ resource->properties = src->properties;
if (src->header_options) {
ret = iotcon_options_foreach(src->header_options,
}
-API int iotcon_remote_resource_is_observable(iotcon_remote_resource_h resource,
- bool *observable)
+API int iotcon_remote_resource_get_properties(iotcon_remote_resource_h resource,
+ int *properties)
{
RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == observable, IOTCON_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == properties, IOTCON_ERROR_INVALID_PARAMETER);
- *observable = resource->is_observable;
+ *properties = resource->properties;
return IOTCON_ERROR_NONE;
}
char host_addr[PATH_MAX] = {0};
iotcon_resource_types_h res_types;
char *uri_path, *device_id, *res_type, *addr;
- int ifaces, is_observable, is_secure, port;
+ int ifaces, properties, is_secure, port;
g_variant_get(payload, "(&s&siasib&si)", &uri_path, &device_id, &ifaces, &types_iter,
- &is_observable, &is_secure, &addr, &port);
+ &properties, &is_secure, &addr, &port);
switch (connectivity_type) {
case IOTCON_CONNECTIVITY_IPV6:
iotcon_resource_types_add(res_types, res_type);
ret = iotcon_remote_resource_create(host_addr, connectivity_type, uri_path,
- !!is_observable, res_types, ifaces, &resource);
+ properties, res_types, ifaces, &resource);
if (res_types)
iotcon_resource_types_destroy(res_types);
return NULL;
}
resource->connectivity_type = connectivity_type;
- resource->is_secure = is_secure;
+ resource->properties = properties;
return resource;
}
char *uri_path;
char *host_address;
char *device_id;
- bool is_secure;
- bool is_observable;
+ int properties;
iotcon_options_h header_options;
iotcon_resource_types_h types;
int ifaces;
* @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] is_secure The flag for secure communication with the server
* @param[in] cb The callback function to invoke
* @param[in] user_data The user data to pass to the function
*
int iotcon_find_resource(const char *host_address,
iotcon_connectivity_type_e connectivity_type,
const char *resource_type,
+ bool is_secure,
iotcon_found_resource_cb cb,
void *user_data);
int iotcon_platform_info_get_property(iotcon_platform_info_h platform_info,
iotcon_platform_info_e property, char **value);
-/**
- * @brief Specifies the type of function passed to iotcon_get_tizen_info().
- * @details The @a result could be one of #iotcon_error_e.
- *
- * @since_tizen 3.0
- *
- * @param[in] tizen_info The information of tizen device from remote server.
- * @param[in] result The result code (0 on success, other wise a negative error value)
- * @param[in] user_data The user data to pass to the function
- *
- * @pre iotcon_get_tizen_info() will invoke this callback function.
- *
- * @see iotcon_get_tizen_info()
- * @see iotcon_tizen_info_get_property()
- */
-typedef void (*iotcon_tizen_info_cb)(iotcon_tizen_info_h tizen_info,
- iotcon_error_e result, void *user_data);
-
-/**
- * @brief Gets the tizen device information of remote server, asynchronously.
- * @details Request tizen device information to server and pass the information by calling
- * iotcon_tizen_info_cb().\n
- * If succeed to getting tizen information, iotcon_tizen_info_cb() will be invoked with
- * information.
- *
- * @since_tizen 3.0
- * @privlevel public
- * @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
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #IOTCON_ERROR_NONE Successful
- * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #IOTCON_ERROR_DBUS Dbus error
- * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #IOTCON_ERROR_PERMISSION_DENIED Permission denied
- *
- * @pre iotcon_connect() should be called to connect a connection to the iotcon.
- * @post iotcon_tizen_info_cb() will be invoked.
- *
- * @see iotcon_tizen_info_cb()
- * @see iotcon_tizen_info_get_property()
- * @see iotcon_set_timeout()
- */
-int iotcon_get_tizen_info(const char *host_address,
- iotcon_connectivity_type_e connectivity_type,
- iotcon_tizen_info_cb cb,
- void *user_data);
-
-/**
- * @brief Gets tizen device properties from the tizen device information handle
- *
- * @since_tizen 3.0
- *
- * @remarks @a value must not be released using free().
- *
- * @param[in] tizen_info The handle of the tizen device information
- * @param[in] property The properties of the tizen device information
- * @param[out] value The value of the property
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #IOTCON_ERROR_NONE Successful
- * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
- *
- * @see iotcon_tizen_info_cb()
- * @see iotcon_get_tizen_info()
- */
-int iotcon_tizen_info_get_property(iotcon_tizen_info_h tizen_info,
- iotcon_tizen_info_e property, char **value);
-
/**
* @}
*/
IOTCON_PLATFORM_INFO_SYSTEM_TIME, /**< Indicates reference time for the device */
} iotcon_platform_info_e;
-/**
- * @brief Enumeration for properties of tizen device information.
- *
- * @since_tizen 3.0
- */
-typedef enum {
- IOTCON_TIZEN_INFO_DEVICE_NAME = 0, /**< Indicates human friendly name for device */
- IOTCON_TIZEN_INFO_TIZEN_DEVICE_ID, /**< Indicates randomly generated id value for tizen device */
-} iotcon_tizen_info_e;
-
/**
* @brief Enumeration for states of remote resource.
*
int ret;
ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,
- "org.tizen.light", _on_find, NULL);
+ "org.tizen.light", false, _on_find, NULL);
if (IOTCON_ERROR_NONE != ret)
return;
}
* API can be used without discovering the object in advance.\n
* To use this API, you should provide all of the details required to correctly contact and
* observe the object.\n
- * If not, you should discover the resource object manually.
+ * If not, you should discover the resource object manually.\n
+ * The @a properties can contain multiple properties like
+ * IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE.
*
* @since_tizen 3.0
*
* @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] properties The properties of the resource
* @param[in] resource_types The resource type of the resource. For example, "core.light"
* @param[in] resource_ifaces The resource interfaces (whether it is collection etc)
* @param[out] remote_resource Generated resource handle
int iotcon_remote_resource_create(const char *host_address,
iotcon_connectivity_type_e connectivity_type,
const char *uri_path,
- bool is_observable,
+ int properties,
iotcon_resource_types_h resource_types,
int resource_ifaces,
iotcon_remote_resource_h *remote_resource);
* @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_get_properties()
* @see iotcon_remote_resource_set_options()
*/
int iotcon_remote_resource_get_uri_path(iotcon_remote_resource_h resource,
* @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_get_properties()
* @see iotcon_remote_resource_set_options()
*/
int iotcon_remote_resource_get_connectivity_type(iotcon_remote_resource_h resource,
* @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_get_properties()
* @see iotcon_remote_resource_set_options()
*/
int iotcon_remote_resource_get_host_address(iotcon_remote_resource_h resource,
* @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()
+ * @see iotcon_remote_resource_get_properties()
* @see iotcon_remote_resource_set_options()
*/
int iotcon_remote_resource_get_device_id(iotcon_remote_resource_h resource,
* @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()
+ * @see iotcon_remote_resource_get_properties()
* @see iotcon_remote_resource_set_options()
*/
int iotcon_remote_resource_get_types(iotcon_remote_resource_h resource,
* @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()
+ * @see iotcon_remote_resource_get_properties()
* @see iotcon_remote_resource_set_options()
*/
int iotcon_remote_resource_get_interfaces(iotcon_remote_resource_h resource, int *ifaces);
/**
* @brief Checks whether the remote resource is observable or not.
*
+ * @details The @a properties can contain multiple properties like
+ * IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE.
* @since_tizen 3.0
*
* @param[in] resource The handle of the resource
- * @param[out] observable The value of observable
+ * @param[out] properties The Properties of the resource
*
* @return 0 on success, otherwise a negative error value.
* @retval #IOTCON_ERROR_NONE Successful
* @see iotcon_remote_resource_get_interfaces()
* @see iotcon_remote_resource_set_options()
*/
-int iotcon_remote_resource_is_observable(iotcon_remote_resource_h resource,
- bool *observable);
+int iotcon_remote_resource_get_properties(iotcon_remote_resource_h resource,
+ int *properties);
/**
* @see iotcon_remote_resource_get_types()
* @see iotcon_remote_resource_get_interfaces()
* @see iotcon_remote_resource_set_options()
- * @see iotcon_remote_resource_is_observable()
+ * @see iotcon_remote_resource_get_properties()
*/
int iotcon_remote_resource_get_options(iotcon_remote_resource_h resource,
iotcon_options_h *options);
* @see iotcon_remote_resource_get_types()
* @see iotcon_remote_resource_get_interfaces()
* @see iotcon_remote_resource_get_options()
- * @see iotcon_remote_resource_is_observable()
+ * @see iotcon_remote_resource_get_properties()
*/
int iotcon_remote_resource_set_options(iotcon_remote_resource_h resource,
iotcon_options_h options);
* @param[in] uri_path The URI path of the resource.
* @param[in] res_types The list of type of the resource.
* @param[in] ifaces The interfaces of the resource.
- * @param[in] properties The property of the resource.
+ * @param[in] properties The properties of the resource.
* @param[in] cb The request handler callback function
* @param[in] user_data The user data to pass to the callback function
* @param[out] resource_handle The handle of the resource
*/
typedef struct icl_platform_info* iotcon_platform_info_h;
-/**
- * @brief The handle of tizen device information.
- * @details @a iotcon_tizen_info_h is a handle of tizen device information.
- *
- * @since_tizen 3.0
- */
-typedef struct icl_tizen_info* iotcon_tizen_info_h;
-
/**
* @brief The handle of resource types
* @details @a iotcon_resource_types_h is an opaque data structure to have list
/**
* @brief Gets the timeout seconds of asynchronous API.
* @details This API get the timeout of iotcon_get_device_info(),
- * iotcon_get_platform_info(), iotcon_get_tizen_info(), iotcon_find_resource(),
+ * iotcon_get_platform_info(), iotcon_find_resource(),
* iotcon_remote_resource_get(), iotcon_remote_resource_put(),
* iotcon_remote_resource_post() and iotcon_remote_resource_delete().
*
/**
* @brief Sets the timeout seconds of asynchrous APIs.
* @details This API set the timeout of iotcon_get_device_info(),
- * iotcon_get_platform_info(), iotcon_get_tizen_info(), iotcon_find_resource(),
+ * iotcon_get_platform_info(), iotcon_find_resource(),
* iotcon_remote_resource_get(), iotcon_remote_resource_put(),
* iotcon_remote_resource_post() and iotcon_remote_resource_delete().\n
* Default timeout interval value is 30.
<check send_destination="@DBUS_INTERFACE@"
send_interface="@DBUS_INTERFACE@" send_member="getPlatformInfo"
privilege="http://tizen.org/privilege/internet"/>
- <check send_destination="@DBUS_INTERFACE@"
- send_interface="@DBUS_INTERFACE@" send_member="getTizenInfo"
- privilege="http://tizen.org/privilege/internet"/>
<check send_destination="@DBUS_INTERFACE@"
send_interface="@DBUS_INTERFACE@" send_member="subscribePresence"
privilege="http://tizen.org/privilege/internet"/>
return;
}
- ret = iotcon_remote_resource_create(host, connectivity_type, created_uri_path, true,
- types, ifaces, &new_door_resource);
+ ret = iotcon_remote_resource_create(host, connectivity_type, created_uri_path,
+ IOTCON_RESOURCE_NO_PROPERTY, types, ifaces, &new_door_resource);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_remote_resource_create() Fail(%d)", ret);
return;
return strcmp(a, b);
}
-static void _request_tizen_info(iotcon_tizen_info_h info, iotcon_error_e result,
- void *user_data)
-{
- int ret;
- char *device_name = NULL;
- char *tizen_device_id = NULL;
-
- RETM_IF(IOTCON_ERROR_NONE != result,
- "_request_tizen_info Response error(%d)", result);
-
- ret = iotcon_tizen_info_get_property(info, IOTCON_TIZEN_INFO_DEVICE_NAME,
- &device_name);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_tizen_info_get_property() Fail(%d)", ret);
- return;
- }
-
- ret = iotcon_tizen_info_get_property(info, IOTCON_TIZEN_INFO_TIZEN_DEVICE_ID,
- &tizen_device_id);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_tizen_info_get_property() Fail(%d)", ret);
- return;
- }
-
- INFO("This is Tizen Device.");
- INFO("- Device name : %s", device_name);
- INFO("- Tizen Device ID : %s", tizen_device_id);
-}
-
static void _on_response(iotcon_remote_resource_h resource, iotcon_error_e err,
iotcon_request_type_e request_type, iotcon_response_h response, void *user_data)
{
return;
}
- /* request tizen info */
- ret = iotcon_get_tizen_info(resource_host, connectivity_type, _request_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);
- free(door_resource_device_id);
- return;
- }
-
ret = iotcon_add_presence_cb(resource_host, connectivity_type, DOOR_RESOURCE_TYPE,
_presence_handler, NULL, &presence_handle);
if (IOTCON_ERROR_NONE != ret) {
return;
}
- ret = iotcon_remote_resource_observe_register(resource_clone, IOTCON_OBSERVE_IGNORE_OUT_OF_ORDER, NULL,
- _on_observe, NULL);
+ ret = iotcon_remote_resource_observe_register(resource_clone,
+ IOTCON_OBSERVE_IGNORE_OUT_OF_ORDER, NULL, _on_observe, NULL);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_remote_resource_observe_register() Fail(%d)", ret);
/* find door typed resources */
ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,
- DOOR_RESOURCE_TYPE, _found_resource, NULL);
+ DOOR_RESOURCE_TYPE, false, _found_resource, NULL);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_find_resource() Fail(%d)", ret);
iotcon_disconnect();
}
new_door_handle = _create_door_resource(DOOR_RESOURCE_URI2, door->type,
- IOTCON_INTERFACE_DEFAULT, (IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE), door);
+ IOTCON_INTERFACE_DEFAULT, IOTCON_RESOURCE_NO_PROPERTY, door);
if (NULL == new_door_handle) {
ERR("_create_door_resource() Fail");
return -1;
/* find door typed resources */
ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,
- DOOR_RESOURCE_TYPE, _found_resource, &resource);
+ DOOR_RESOURCE_TYPE, false, _found_resource, &resource);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_find_resource() Fail(%d)", ret);
iotcon_disconnect();
/* find room typed resources */
ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,
- ROOM_RESOURCE_TYPE, _found_resource, NULL);
+ ROOM_RESOURCE_TYPE, false, _found_resource, NULL);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_find_resource() Fail(%d)", ret);
iotcon_disconnect();