Merge "Merge branch 'master' into resource-encapsulation" into resource-encapsulation
[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 duplication of device's Device ID with
43  * provisioning database.
44  *
45  * @param[in] uuidOfDevice information about the target device's uuid.
46  *
47  * @return false when non-duplication and true when duplication or uuidOfDevicea is NULL .
48  */
49 bool PDMIsDuplicateDevice(const OicUuid_t* uuidOfDevice);
50
51 /**
52  * This method is used by provisioning manager to add owned device's Device ID.
53  *
54  * @param[in] uuidOfDevice information about the owned device's uuid.
55  *
56  * @return OC_STACK_OK in case of success and other value otherwise.
57  */
58 OCStackResult PDMAddDevice(const OicUuid_t* uuidOfDevice);
59
60 /**
61  * This method is used by provisioning manager to update linked status of owned devices.
62  *
63  * @param[in] uuidOfDevice1 DeviceID which is going to be linked with uuid of device 2.
64  * @param[in] uuidOfDevice2 DeviceID which is going to be linked with uuid of device 1.
65  *
66  * @return OC_STACK_OK in case of success and other value otherwise.
67  */
68 OCStackResult PDMLinkDevices(const OicUuid_t *uuidOfDevice1, const OicUuid_t *uuidOfDevice2);
69
70 /**
71  * This method is used by provisioning manager to unlink pairwise devices.
72  *
73  * @param[in] uuidOfDevice1 DeviceID which is going to be unlinked with uuid of device 2.
74  * @param[in] uuidOfDevice2 DeviceID which is going to be unlinked with uuid of device 1.
75  *
76  * @return OC_STACK_OK in case of success and other value otherwise.
77  */
78 OCStackResult PDMUnlinkDevices(const OicUuid_t *uuidOfDevice1, const OicUuid_t *uuidOfDevice2);
79
80 /**
81  * This method is used by provisioning manager to delete owned device's Device ID.
82  *
83  * @param[in] uuidOfDevice information about the owned device's uuid to be deleted.
84  *
85  * @return OC_STACK_OK in case of success and other value otherwise.
86  */
87 OCStackResult PDMDeleteDevice(const OicUuid_t *uuidOfDevice);
88
89 /**
90  * This method is used by provisioning manager to get owned devices' Device IDs.
91  *
92  * @param[out] uuidList information about the list of owned devices' uuids.
93  * @param[out] numOfDevices total number of owned devices.
94  *
95  * @return OC_STACK_OK in case of success and other value otherwise.
96  */
97 OCStackResult PDMGetOwnedDevices(OCUuidList_t** uuidList, size_t* numOfDevices);
98
99 /**
100  * This method is used by provisioning manager to get linked devices' IDs.
101  *
102  * @param[in] uuidOfDevice a target device's uuid.
103  * @param[out] uuidList information about the list of linked devices' uuids.
104  * @param[out] numOfDevices total number of linked devices.
105  *
106  * @return OC_STACK_OK in case of success and other value otherwise.
107  */
108 OCStackResult PDMGetLinkedDevices(const OicUuid_t* uuidOfDevice, OCUuidList_t** uuidList,
109                                     size_t* numOfDevices);
110
111 /**
112  * This method is used by provisioning manager to update linked status as stale.
113  *
114  * @param[in] uuidOfDevice1 first id of stale link.
115  * @param[in] uuidOfDevice2 other id for stale link.
116  *
117  * @return OC_STACK_OK in case of success and other value otherwise.
118  */
119 OCStackResult PDMSetLinkStale(const OicUuid_t* uuidOfDevice1, const OicUuid_t* uuidOfDevice2);
120
121 /**
122  * This method is used by provisioning manager to get stale devices.
123  *
124  * @note in case of sqllite, the caller should set NULL for parameters.
125  *
126  * @param[out] staleDevices information about the list of "To be Removed" devices' uuid.
127  * @param[out] numOfDevices total number of devices to be removed.
128  *
129  * @return OC_STACK_OK in case of success and other value otherwise.
130  */
131 OCStackResult PDMGetToBeUnlinkedDevices(OCPairList_t** staleDevList, size_t* numOfDevices);
132
133 /**
134  * This method is used by provisioning manager to close provisioning database.
135  *
136  * @return  OC_STACK_OK in case of success and other value otherwise.
137  */
138 OCStackResult PDMClose();
139
140 /**
141  * This method is used by provisioning manager free memory allocated to OCUuidList_t lists.
142  *
143  * @param[in] ptr start pointer of link list.
144  */
145 void PDMDestoryOicUuidLinkList(OCUuidList_t* ptr);
146
147 /**
148  * This method is used by provisioning manager free memory allocated to Stalelist.
149  *
150  * @param[in] ptr start pointer of link list.
151  *
152  */
153 void PDMDestoryStaleLinkList(OCPairList_t* ptr);
154
155 #ifdef __cplusplus
156 }
157 #endif
158 #endif //PROVISIONING_DATABASE_MANAGER_H