(ACR) remove set_device/platform_info API, hide start/stop_presence API
[platform/core/iot/iotcon.git] / daemon / icd-ioty.h
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef __IOT_CONNECTIVITY_MANAGER_DAEMON_IOTIVITY_H__
17 #define __IOT_CONNECTIVITY_MANAGER_DAEMON_IOTIVITY_H__
18
19 #include <stdio.h>
20 #include <stdint.h>
21 #include <glib.h>
22 #include <gio/gio.h>
23
24 #include <octypes.h>
25
26 #include "iotcon.h"
27 #include "ic-dbus.h"
28
29 #define ICD_IOTY_COAP "coap://"
30 #define ICD_IOTY_COAPS "coaps://"
31
32 /* TODO Define Tizen Information Resource(uri, resource type) */
33 #define ICD_IOTY_TIZEN_INFO_URI "/org/tizen/iot/devInfo"
34 #define ICD_IOTY_TIZEN_INFO_TYPE "org.tizen.iot.devInfo"
35
36 #define ICD_IOTY_TIZEN_INFO_DEVICE_NAME "device_name"
37 #define ICD_IOTY_TIZEN_INFO_TIZEN_DEVICE_ID "tizen_device_id"
38
39 typedef struct {
40         unsigned int signum;
41         char *bus_name;
42 } icd_sig_ctx_s;
43
44 enum {
45         ICD_CRUD_GET,
46         ICD_CRUD_PUT,
47         ICD_CRUD_POST,
48         ICD_CRUD_DELETE,
49         ICD_DEVICE_INFO,
50         ICD_PLATFORM_INFO,
51         ICD_TIZEN_INFO,
52 };
53
54 void icd_ioty_csdk_lock();
55
56 void icd_ioty_csdk_unlock();
57
58 GThread* icd_ioty_init(const char *addr, unsigned short port);
59
60 void icd_ioty_deinit(GThread *thread);
61
62 OCResourceHandle icd_ioty_register_resource(const char *uri_path,
63                 const char* const* res_types, int ifaces, uint8_t properties);
64
65 int icd_ioty_unregister_resource(OCResourceHandle handle);
66
67 int icd_ioty_bind_interface(OCResourceHandle handle, iotcon_interface_e iface);
68
69 int icd_ioty_bind_type(OCResourceHandle handle, const char *resource_type);
70
71 int icd_ioty_bind_resource(OCResourceHandle parent, OCResourceHandle child);
72
73 int icd_ioty_unbind_resource(OCResourceHandle parent, OCResourceHandle child);
74
75 int icd_ioty_notify(OCResourceHandle handle, GVariant *msg, GVariant *observers);
76
77 int icd_ioty_send_response(GVariant *resp);
78
79 int icd_ioty_find_resource(const char *host_address, const char *resource_type,
80                 unsigned int signal_number, const char *bus_name);
81
82 void icd_ioty_complete(int type, GDBusMethodInvocation *invocation, GVariant *value);
83 void icd_ioty_complete_error(int type, GDBusMethodInvocation *invocation, int ret_val);
84
85 gboolean icd_ioty_get(icDbus *object, GDBusMethodInvocation *invocation,
86                 GVariant *resource, GVariant *query);
87
88 gboolean icd_ioty_put(icDbus *object, GDBusMethodInvocation *invocation,
89                 GVariant *resource, GVariant *repr, GVariant *query);
90
91 gboolean icd_ioty_post(icDbus *object, GDBusMethodInvocation *invocation,
92                 GVariant *resource, GVariant *repr, GVariant *query);
93
94 gboolean icd_ioty_delete(icDbus *object, GDBusMethodInvocation *invocation,
95                 GVariant *resource);
96
97 OCDoHandle icd_ioty_observer_start(GVariant *resource, int observe_type, GVariant *query,
98                 unsigned int signal_number, const char *bus_name);
99
100 int icd_ioty_observer_stop(OCDoHandle handle, GVariant *options);
101
102 int icd_ioty_register_device_info(char *device_name);
103
104 int icd_ioty_register_platform_info(char *platform_id,
105                 char *manufacturer_name,
106                 char *manufacturer_url,
107                 char *model_number,
108                 char *date_of_manufacture,
109                 char *platform_version,
110                 char *os_version,
111                 char *hw_version,
112                 char *firmware_version,
113                 char *support_url,
114                 char *system_time);
115
116 int icd_ioty_get_info(int type, const char *host_address, unsigned int signal_number,
117                 const char *bus_name);
118
119 int icd_ioty_set_tizen_info();
120
121 gboolean icd_ioty_get_tizen_info(icDbus *object, GDBusMethodInvocation *invocation,
122                 const gchar *host_address);
123
124 int icd_ioty_tizen_info_get_property(char **device_name, char **tizen_device_id);
125
126 OCDoHandle icd_ioty_subscribe_presence(const char *host_address,
127                 const char *resource_type, unsigned int signal_number, const char *bus_name);
128
129 int icd_ioty_unsubscribe_presence(OCDoHandle handle);
130
131 int icd_ioty_start_presence(unsigned int time_to_live);
132
133 int icd_ioty_stop_presence();
134
135 static inline int icd_ioty_convert_error(int ret)
136 {
137         switch (ret) {
138         case OC_STACK_NO_MEMORY:
139                 return IOTCON_ERROR_OUT_OF_MEMORY;
140         case OC_STACK_NO_RESOURCE:
141                 return IOTCON_ERROR_NO_DATA;
142         default:
143                 break;
144         }
145         return IOTCON_ERROR_IOTIVITY;
146 }
147
148 #endif /*__IOT_CONNECTIVITY_MANAGER_DAEMON_IOTIVITY_H__*/