comp-manager: Monitor Invited device
[platform/core/api/multi-device-group.git] / src / companion-manager / include / comp_group.h
1 /*
2  * Copyright (c) 2018 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  */
17
18 #ifndef __COMP_GROUP_H__
19 #define __COMP_GROUP_H__
20
21 #include <comp_iot.h>
22
23 #ifdef __cplusplus
24 extern "C"
25 {
26 #endif
27
28 typedef struct {
29         char *uri_path; /**< URI path */
30         char *device_id; /**< Device ID */
31         char *host_addr; /**< Host address */
32         char *group_name; /**< Group name */
33         char *resource_type; /**< Resource type */
34         comp_group_type_e type; /**< Group yype */
35 } comp_group_t;
36
37 typedef struct {
38         char *device_id; /**< Device Id */
39         int adapter; /**< Adapter type */
40         int flags; /**< Flags */
41         int port; /**< Remtoe device is listening this port */
42         char *addr; /**< IP Address of remote device */
43         int ifindex; /**< Network interfce index of Remote device */
44         char *route_data; /**< Route data */
45         char *remote_id; /**< Remote Id */
46         int conn_type; /**< Connection type */
47         int secure_port; /**< Secured port once TLS handhaking complete */
48         int tcp_port; /**< TCP port when using CoAP over TCP */
49         char *sec_ver; /**< OCF Security specification version */
50         int dev_status; /**< Device status */
51         char *model_name; /**< Device ID */
52         char *device_name; /**< Host address */
53         char *platform_ver; /**< Group name */
54         char *vendor_id; /**< Resource type */
55         char *profile; /**< Group yype */
56         bool mowned;
57         comp_device_type_e type;
58 } comp_mot_device_t;
59
60 typedef struct {
61         char *group_name;
62         char *uuid_dev1; /**< Source device Id */
63         char *uuid_dev2; /**< Target device Id */
64         char *pin; /**< Random or pre-configured PIN */
65         char *uri_1; /**< URI at source resource */
66         char *rt_1; /**< Resource type at source resource */
67         char *interface_1; /**< Interface at source resource */
68         int permission_1; /**< CRUDN for target device */
69         char *uri_2; /**< URI at target resource */
70         char *rt_2; /**< Resource type at target resource */
71         char *interface_2; /**< Interface at target resource */
72         int permission_2; /**< CRUDN for source device */
73 } comp_group_invite_info_t;
74
75 typedef struct {
76         char *group_name; /**< Group Name */
77         char *uuid; /**< Device ID */
78         char *host; /**< Device Host Address */
79         int count; /**< Count of successful post method */
80 } comp_invited_device_t;
81
82 /* Called when daemon is start. */
83 int comp_group_initialize();
84
85 /* create group and destroy */
86 int comp_group_create(const char* name);
87 int comp_group_destroy(comp_group_t *handle);
88
89 /* Find Remote groups */
90 int comp_group_find(int timeout);
91 GVariant *comp_group_get_found_groups();
92 int comp_group_add_new(char *uri_path, char *device_id, char *device_name,
93                                  char *host_addr, char *resource_type, comp_group_type_e type);
94
95 /* Join the remote devices in my daemon */
96 int comp_group_get_groups(comp_group_t ***handles, int *count); //Get all of group in my daemon
97 int comp_group_get_remote_devices(/* callback */); //Get all of device in network (Async)
98
99 int comp_group_add_new_mot_device(comp_mot_device_t *device);
100 void comp_group_notify_mot_enable_device_done();
101 int comp_group_find_mot_enabled_devices(int timeout);
102
103 char *comp_group_invite_get_uuid();
104 char *comp_group_invite_get_pin();
105
106 /* Join to device in group (async) */
107 int comp_group_invite(const char *group_name, const char *uuid,
108                                           const char *pin);
109 comp_group_invite_info_t *comp_group_get_invite_info();
110 void comp_group_free_invite_info();
111 void comp_group_notify_group_invite(int result);
112
113 /* eject from group (async) */
114 int comp_group_eject(const gchar *group_name, gchar *uuid_dev1, const char *uuid_dev2);
115 void comp_group_notify_group_dismiss(int result);
116
117 int comp_group_pair_resource(char* target1, char *subject1, char *uri1,
118         char *rt1, char *interface1, int permission1, char* target2, char *subject2,
119         char *uri2, char *rt2, char *interface2, int permission2);
120
121 int comp_group_unpair_resource(gchar *uuid_dev1, gchar *uuid_dev2);
122 int comp_group_send_data(gchar *uuid_dev, gchar *addr, int port,
123                                                  unsigned char *data, int len);
124 void comp_group_notify_keepalive_response(comp_command_t *cmd);
125
126 GVariant *comp_group_get_remote_mot_enabled_devices();
127 int comp_group_get_mot_device_count();
128
129 int comp_group_add_new_mowned_device(comp_mot_device_t *device);
130 void comp_group_notify_mowned_device_find_done();
131 int comp_group_find_mowned_devices();
132 GVariant *comp_group_get_mowned_devices();
133 int comp_group_get_mowned_device_count();
134 GVariant *comp_group_get_my_mowned_devices();
135 void comp_group_change_mowned_device(comp_mot_device_t *device);
136
137 /* Join to remote device group */
138 int comp_group_join();
139 int comp_group_leave_from(/* callback */); //leave from certain remote group (Async)
140
141 /* Called when daemon is end. */
142 int comp_group_deinitialize();
143
144 /* Getter for a group */
145 int comp_group_get_group_name(comp_group_t *handle, char **name);
146 int comp_group_get_group_type(comp_group_t *handle, int *type);
147 int comp_group_get_group_device_type(comp_group_t *handle);
148 int comp_group_get_group_device_id(comp_group_t *handle);
149
150 /* notify */
151 int comp_group_event_handler(/*callback*/); // event hadnler
152 int comp_group_add_device_in_group(const char *group_name, const char *uuid);
153 int comp_group_remove_device_in_group(char *group_name, char *uuid);
154
155 /* Group management */
156 int comp_group_request_create_group(char *uuid, char *group_name);
157 int comp_group_request_invite(char *uuid, char *group_name, char *target_uuid, char *PIN);
158 int comp_group_request_eject(char *uuid, char *group_name, char *target_uuid);
159 int comp_group_request_delete_group(char *uuid, char *group_name);
160
161 int comp_group_start_invited_device_monitor();
162
163 #ifdef __cplusplus
164 }
165 #endif
166 #endif /* __COMP_GROUP_H__ */