Allow multiple presence
[platform/core/iot/iotcon.git] / daemon / icd-ioty.h
index 18c4c85..dfa36b5 100644 (file)
 #ifndef __IOT_CONNECTIVITY_MANAGER_DAEMON_IOTIVITY_H__
 #define __IOT_CONNECTIVITY_MANAGER_DAEMON_IOTIVITY_H__
 
+#include <stdio.h>
 #include <stdint.h>
+#include <glib.h>
+#include <gio/gio.h>
+
+#include <octypes.h>
 
 #include "iotcon.h"
+#include "ic-dbus.h"
+
+#define ICD_IOTY_COAP "coap://"
+#define ICD_IOTY_COAPS "coaps://"
+
+#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_sig_ctx_s;
+
+typedef struct {
+       OCDoHandle handle;
+       int client_count;
+} icd_presence_handle_info;
+
+enum {
+       ICD_CRUD_GET,
+       ICD_CRUD_PUT,
+       ICD_CRUD_POST,
+       ICD_CRUD_DELETE,
+       ICD_DEVICE_INFO,
+       ICD_PLATFORM_INFO,
+       ICD_TIZEN_INFO,
+};
 
-void icd_ioty_config(const char *addr, unsigned short port);
+void icd_ioty_csdk_lock();
 
-void* icd_ioty_register_resource(const char *uri, const char* const* res_types, int ifaces,
-               uint8_t properties);
+void icd_ioty_csdk_unlock();
 
-int icd_ioty_unregister_resource(iotcon_resource_h resource_handle);
+GThread* icd_ioty_init(const char *addr, unsigned short port);
 
-int icd_ioty_bind_interface(void *resource_handle, iotcon_interface_e iface);
+void icd_ioty_deinit(GThread *thread);
 
-int icd_ioty_bind_type(void *resource_handle, const char *resource_type);
+OCResourceHandle icd_ioty_register_resource(const char *uri_path,
+               const char* const* res_types, int ifaces, int properties);
 
-int icd_ioty_bind_resource(void *parent, void *child);
+int icd_ioty_unregister_resource(OCResourceHandle handle);
 
-int icd_ioty_unbind_resource(void *parent, void *child);
+int icd_ioty_bind_interface(OCResourceHandle handle, iotcon_interface_e iface);
 
-int icd_ioty_notify_list_of_observers(int resHandle, GVariant *msg, GVariant *observers);
+int icd_ioty_bind_type(OCResourceHandle handle, const char *resource_type);
 
-int icd_ioty_notify_all(int resHandle);
+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_send_response(GVariant *resp);
 
-int icd_ioty_find_resource(const char *host_address, const char *resource_type,
-               const char *sig_name);
+int icd_ioty_find_resource(const char *host_address, int conn_type,
+               const char *resource_type, 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);
+
+gboolean icd_ioty_get(icDbus *object, GDBusMethodInvocation *invocation,
+               GVariant *resource, GVariant *query);
 
-int icd_ioty_get(GVariant *resource, GVariant *query, const char *sig_name);
+gboolean icd_ioty_put(icDbus *object, GDBusMethodInvocation *invocation,
+               GVariant *resource, GVariant *repr, GVariant *query);
 
-int icd_ioty_put(GVariant *resource, const char *repr, GVariant *query,
-               const char *sig_name);
+gboolean icd_ioty_post(icDbus *object, GDBusMethodInvocation *invocation,
+               GVariant *resource, GVariant *repr, GVariant *query);
 
-int icd_ioty_post(GVariant *resource, const char *repr, GVariant *query,
-               const char *sig_name);
+gboolean icd_ioty_delete(icDbus *object, GDBusMethodInvocation *invocation,
+               GVariant *resource);
 
-int icd_ioty_delete(GVariant *resource, const char *sig_name);
+OCDoHandle icd_ioty_observer_start(GVariant *resource, int observe_type,
+               GVariant *query, int64_t signal_number, const char *bus_name);
 
-int icd_ioty_observer_start(GVariant *resource, int observe_type, GVariant *query,
-          const char *sig_name, int *observe_h);
+int icd_ioty_observer_stop(OCDoHandle handle, GVariant *options);
 
-int icd_ioty_observer_stop(void *observe_h);
+int icd_ioty_get_info(int type, const char *host_address, int conn_type,
+               int64_t signal_number, const char *bus_name);
 
-int icd_ioty_register_device_info(GVariant *value);
+int icd_ioty_set_device_info();
+int icd_ioty_set_platform_info();
+int icd_ioty_set_tizen_info();
 
-int icd_ioty_get_device_info(const char *host_address, const char *sig_name);
+gboolean icd_ioty_get_tizen_info(icDbus *object, GDBusMethodInvocation *invocation,
+               const gchar *host_address, int conn_type);
 
-iotcon_presence_h icd_ioty_subscribe_presence(const char *host_address,
-               const char *resource_type, const char *sig_name);
+int icd_ioty_tizen_info_get_property(char **device_name, char **tizen_device_id);
 
-int icd_ioty_unsubscribe_presence(iotcon_presence_h presence_handle);
+OCDoHandle icd_ioty_presence_table_get_handle(const char *host_address);
+
+OCDoHandle icd_ioty_subscribe_presence(const char *host_address, int conn_type,
+               const char *resource_type);
+
+int icd_ioty_unsubscribe_presence(OCDoHandle handle, const char *host_address);
 
 int icd_ioty_start_presence(unsigned int time_to_live);
 
 int icd_ioty_stop_presence();
 
+static inline int icd_ioty_convert_error(int ret)
+{
+       switch (ret) {
+       case OC_STACK_NO_MEMORY:
+               return IOTCON_ERROR_OUT_OF_MEMORY;
+       case OC_STACK_NO_RESOURCE:
+               return IOTCON_ERROR_NO_DATA;
+       default:
+               break;
+       }
+       return IOTCON_ERROR_IOTIVITY;
+}
+
 #endif /*__IOT_CONNECTIVITY_MANAGER_DAEMON_IOTIVITY_H__*/