Imported Upstream version 1.1.1
[platform/upstream/iotivity.git] / resource / csdk / security / provisioning / include / internal / provisioningdatabasemanager.h
1 /* *****************************************************************
2  *
3  * Copyright 2015 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  * *****************************************************************/
20
21 #ifndef PROVISIONING_DATABASE_MANAGER_H
22 #define PROVISIONING_DATABASE_MANAGER_H
23 #include "securevirtualresourcetypes.h"
24 #include "ocstack.h"
25 #include "pmtypes.h"
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31
32 /**
33  * This method is used by provisioning manager to open provisioning database.
34  *
35  * @param[in] dbPath file path of the sqlite3 db
36  *
37  * @return OC_STACK_OK in case of success and other value otherwise.
38  */
39 OCStackResult PDMInit(const char* dbPath);
40
41 /**
42  * This method is used by provisioning manager to check whether device is stale or not with PDM.
43  *
44  * @param[in] uuid information about the target device's uuid.
45  * @param[out] result true in case device is stale.
46  *
47  * @return OC_STACK_OK in case of success and other value otherwise.
48  */
49 OCStackResult PDMIsDeviceStale(const OicUuid_t *uuid, bool *result);
50
51 /**
52  * This method is used by provisioning manager to check duplication of device's Device ID with
53  * provisioning database.
54  *
55  * @param[in] uuidOfDevice information about the target device's uuid.
56  * @param[out] result true in case device UUID already exist otherwise false.
57  *
58  * @return OC_STACK_OK in case of success and other value otherwise.
59  */
60 OCStackResult PDMIsDuplicateDevice(const OicUuid_t* uuidOfDevice, bool* result);
61
62 /**
63  * This method is used by provisioning manager to add owned device's Device ID.
64  *
65  * @param[in] uuidOfDevice information about the owned device's uuid.
66  *
67  * @return OC_STACK_OK in case of success and other value otherwise.
68  */
69 OCStackResult PDMAddDevice(const OicUuid_t* uuidOfDevice);
70
71 /**
72  * This method is used by provisioning manager to update linked status of owned devices.
73  *
74  * @param[in] uuidOfDevice1 DeviceID which is going to be linked with uuid of device 2.
75  * @param[in] uuidOfDevice2 DeviceID which is going to be linked with uuid of device 1.
76  *
77  * @return OC_STACK_OK in case of success and other value otherwise.
78  */
79 OCStackResult PDMLinkDevices(const OicUuid_t *uuidOfDevice1, const OicUuid_t *uuidOfDevice2);
80
81 /**
82  * This method is used by provisioning manager to unlink pairwise devices.
83  *
84  * @param[in] uuidOfDevice1 DeviceID which is going to be unlinked with uuid of device 2.
85  * @param[in] uuidOfDevice2 DeviceID which is going to be unlinked with uuid of device 1.
86  *
87  * @return OC_STACK_OK in case of success and other value otherwise.
88  */
89 OCStackResult PDMUnlinkDevices(const OicUuid_t *uuidOfDevice1, const OicUuid_t *uuidOfDevice2);
90
91 /**
92  * This method is used by provisioning manager to delete owned device's Device ID.
93  *
94  * @param[in] uuidOfDevice information about the owned device's uuid to be deleted.
95  *
96  * @return OC_STACK_OK in case of success and other value otherwise.
97  */
98 OCStackResult PDMDeleteDevice(const OicUuid_t *uuidOfDevice);
99
100 /**
101  * This method is used by provisioning manager to get owned devices' Device IDs.
102  *
103  * @param[out] uuidList information about the list of owned devices' uuids.
104  * @param[out] numOfDevices total number of owned devices.
105  *
106  * @return OC_STACK_OK in case of success and other value otherwise.
107  */
108 OCStackResult PDMGetOwnedDevices(OCUuidList_t** uuidList, size_t* numOfDevices);
109
110 /**
111  * This method is used by provisioning manager to get linked devices' IDs.
112  *
113  * @param[in] uuidOfDevice a target device's uuid.
114  * @param[out] uuidList information about the list of linked devices' uuids.
115  * @param[out] numOfDevices total number of linked devices.
116  *
117  * @return OC_STACK_OK in case of success and other value otherwise.
118  */
119 OCStackResult PDMGetLinkedDevices(const OicUuid_t* uuidOfDevice, OCUuidList_t** uuidList,
120                                     size_t* numOfDevices);
121
122 /**
123  * This method is used by provisioning manager to update linked status as stale.
124  *
125  * @param[in] uuidOfDevice1 first id of stale link.
126  * @param[in] uuidOfDevice2 other id for stale link.
127  *
128  * @return OC_STACK_OK in case of success and other value otherwise.
129  */
130 OCStackResult PDMSetLinkStale(const OicUuid_t* uuidOfDevice1, const OicUuid_t* uuidOfDevice2);
131
132 /**
133  * This method is used by provisioning manager to update device status as stale.
134  *
135  * @param[in] uuidOfDevice id of stale device.
136  *
137  * @return OC_STACK_OK in case of success and other value otherwise.
138  */
139 OCStackResult PDMSetDeviceStale(const OicUuid_t* uuidOfDevice);
140
141 /**
142  * This method is used by provisioning manager to get stale devices.
143  *
144  * @note in case of sqllite, the caller should set NULL for parameters.
145  *
146  * @param[out] staleDevices information about the list of "To be Removed" devices' uuid.
147  * @param[out] numOfDevices total number of devices to be removed.
148  *
149  * @return OC_STACK_OK in case of success and other value otherwise.
150  */
151 OCStackResult PDMGetToBeUnlinkedDevices(OCPairList_t** staleDevList, size_t* numOfDevices);
152
153 /**
154  * This method is used by provisioning manager to close provisioning database.
155  *
156  * @return  OC_STACK_OK in case of success and other value otherwise.
157  */
158 OCStackResult PDMClose();
159
160 /**
161  * This method is used by provisioning manager free memory allocated to OCUuidList_t lists.
162  *
163  * @param[in] ptr start pointer of link list.
164  */
165 void PDMDestoryOicUuidLinkList(OCUuidList_t* ptr);
166
167 /**
168  * This method is used by provisioning manager free memory allocated to Stalelist.
169  *
170  * @param[in] ptr start pointer of link list.
171  *
172  */
173 void PDMDestoryStaleLinkList(OCPairList_t* ptr);
174
175 /**
176  * This method is used by provisioning manager to check does the link exists between
177  * two devices or not.
178  *
179  * @param[in] uuidOfDevice1 UUID of device1.
180  * @param[in] uuidOfDevice2 UUID of device2.
181  * @param[out] result true when link exists otherwise false.
182  *
183  * @return OC_STACK_OK in case of success and other value otherwise.
184  */
185 OCStackResult PDMIsLinkExists(const OicUuid_t* uuidOfDevice1, const OicUuid_t* uuidOfDevice2,
186                                 bool *result);
187
188
189 #ifdef __cplusplus
190 }
191 #endif
192 #endif //PROVISIONING_DATABASE_MANAGER_H