1 /* *****************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * *****************************************************************/
21 #ifndef PROVISIONING_DATABASE_MANAGER_H
22 #define PROVISIONING_DATABASE_MANAGER_H
23 #include "securevirtualresourcetypes.h"
33 * This method is used by provisioning manager to open provisioning database.
35 * @param[in] dbPath file path of the sqlite3 db
37 * @return OC_STACK_OK in case of success and other value otherwise.
39 OCStackResult PDMInit(const char* dbPath);
42 * This method is used by provisioning manager to check duplication of device's Device ID with
43 * provisioning database.
45 * @param[in] uuidOfDevice information about the target device's uuid.
46 * @param[out] result true in case device UUID already exist otherwise false.
48 * @return OC_STACK_OK in case of success and other value otherwise.
50 OCStackResult PDMIsDuplicateDevice(const OicUuid_t* uuidOfDevice, bool* result);
53 * This method is used by provisioning manager to add owned device's Device ID.
55 * @param[in] uuidOfDevice information about the owned device's uuid.
57 * @return OC_STACK_OK in case of success and other value otherwise.
59 OCStackResult PDMAddDevice(const OicUuid_t* uuidOfDevice);
62 * This method is used by provisioning manager to update linked status of owned devices.
64 * @param[in] uuidOfDevice1 DeviceID which is going to be linked with uuid of device 2.
65 * @param[in] uuidOfDevice2 DeviceID which is going to be linked with uuid of device 1.
67 * @return OC_STACK_OK in case of success and other value otherwise.
69 OCStackResult PDMLinkDevices(const OicUuid_t *uuidOfDevice1, const OicUuid_t *uuidOfDevice2);
72 * This method is used by provisioning manager to unlink pairwise devices.
74 * @param[in] uuidOfDevice1 DeviceID which is going to be unlinked with uuid of device 2.
75 * @param[in] uuidOfDevice2 DeviceID which is going to be unlinked with uuid of device 1.
77 * @return OC_STACK_OK in case of success and other value otherwise.
79 OCStackResult PDMUnlinkDevices(const OicUuid_t *uuidOfDevice1, const OicUuid_t *uuidOfDevice2);
82 * This method is used by provisioning manager to delete owned device's Device ID.
84 * @param[in] uuidOfDevice information about the owned device's uuid to be deleted.
86 * @return OC_STACK_OK in case of success and other value otherwise.
88 OCStackResult PDMDeleteDevice(const OicUuid_t *uuidOfDevice);
91 * This method is used by provisioning manager to get owned devices' Device IDs.
93 * @param[out] uuidList information about the list of owned devices' uuids.
94 * @param[out] numOfDevices total number of owned devices.
96 * @return OC_STACK_OK in case of success and other value otherwise.
98 OCStackResult PDMGetOwnedDevices(OCUuidList_t** uuidList, size_t* numOfDevices);
101 * This method is used by provisioning manager to get linked devices' IDs.
103 * @param[in] uuidOfDevice a target device's uuid.
104 * @param[out] uuidList information about the list of linked devices' uuids.
105 * @param[out] numOfDevices total number of linked devices.
107 * @return OC_STACK_OK in case of success and other value otherwise.
109 OCStackResult PDMGetLinkedDevices(const OicUuid_t* uuidOfDevice, OCUuidList_t** uuidList,
110 size_t* numOfDevices);
113 * This method is used by provisioning manager to update linked status as stale.
115 * @param[in] uuidOfDevice1 first id of stale link.
116 * @param[in] uuidOfDevice2 other id for stale link.
118 * @return OC_STACK_OK in case of success and other value otherwise.
120 OCStackResult PDMSetLinkStale(const OicUuid_t* uuidOfDevice1, const OicUuid_t* uuidOfDevice2);
123 * This method is used by provisioning manager to update device status as stale.
125 * @param[in] uuidOfDevice id of stale device.
127 * @return OC_STACK_OK in case of success and other value otherwise.
129 OCStackResult PDMSetDeviceStale(const OicUuid_t* uuidOfDevice);
132 * This method is used by provisioning manager to get stale devices.
134 * @note in case of sqllite, the caller should set NULL for parameters.
136 * @param[out] staleDevices information about the list of "To be Removed" devices' uuid.
137 * @param[out] numOfDevices total number of devices to be removed.
139 * @return OC_STACK_OK in case of success and other value otherwise.
141 OCStackResult PDMGetToBeUnlinkedDevices(OCPairList_t** staleDevList, size_t* numOfDevices);
144 * This method is used by provisioning manager to close provisioning database.
146 * @return OC_STACK_OK in case of success and other value otherwise.
148 OCStackResult PDMClose();
151 * This method is used by provisioning manager free memory allocated to OCUuidList_t lists.
153 * @param[in] ptr start pointer of link list.
155 void PDMDestoryOicUuidLinkList(OCUuidList_t* ptr);
158 * This method is used by provisioning manager free memory allocated to Stalelist.
160 * @param[in] ptr start pointer of link list.
163 void PDMDestoryStaleLinkList(OCPairList_t* ptr);
166 * This method is used by provisioning manager to check does the link exists between
167 * two devices or not.
169 * @param[in] uuidOfDevice1 UUID of device1.
170 * @param[in] uuidOfDevice2 UUID of device2.
171 * @param[out] result true when link exists otherwise false.
173 * @return OC_STACK_OK in case of success and other value otherwise.
175 OCStackResult PDMIsLinkExists(const OicUuid_t* uuidOfDevice1, const OicUuid_t* uuidOfDevice2,
182 #endif //PROVISIONING_DATABASE_MANAGER_H