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"
31 typedef enum PdmDeviceState {
32 PDM_DEVICE_ACTIVE = 0,
35 PDM_DEVICE_UNKNOWN = 99
39 * This method is used by provisioning manager to open provisioning database.
41 * @param[in] dbPath file path of the sqlite3 db
43 * @return OC_STACK_OK in case of success and other value otherwise.
45 OCStackResult PDMInit(const char* dbPath);
48 * This method is used by provisioning manager to check device status.
50 * @param[in] uuid information about the target device's uuid.
51 * @param[out] result device status.
53 * @return OC_STACK_OK in case of success and other value otherwise.
55 OCStackResult PDMGetDeviceState(const OicUuid_t* uuid, PdmDeviceState_t* result);
58 * This method is used by provisioning manager to update device status.
60 * @param[in] uuid id of device.
61 * @param[in] state device state. (ref. PdmDeviceState_t)
63 * @return OC_STACK_OK in case of success and other value otherwise.
65 OCStackResult PDMSetDeviceState(const OicUuid_t* uuid, PdmDeviceState_t state);
68 * This method is used by provisioning manager to check duplication of device's Device ID with
69 * provisioning database.
71 * @param[in] uuidOfDevice information about the target device's uuid.
72 * @param[out] result true in case device UUID already exist otherwise false.
74 * @return OC_STACK_OK in case of success and other value otherwise.
76 OCStackResult PDMIsDuplicateDevice(const OicUuid_t* uuidOfDevice, bool* result);
79 * This method is used by provisioning manager to add owned device's Device ID.
81 * @param[in] uuidOfDevice information about the owned device's uuid.
83 * @return OC_STACK_OK in case of success and other value otherwise.
85 OCStackResult PDMAddDevice(const OicUuid_t* uuidOfDevice);
88 * This method is used by provisioning manager to update linked status of owned devices.
90 * @param[in] uuidOfDevice1 DeviceID which is going to be linked with uuid of device 2.
91 * @param[in] uuidOfDevice2 DeviceID which is going to be linked with uuid of device 1.
93 * @return OC_STACK_OK in case of success and other value otherwise.
95 OCStackResult PDMLinkDevices(const OicUuid_t *uuidOfDevice1, const OicUuid_t *uuidOfDevice2);
98 * This method is used by provisioning manager to unlink pairwise devices.
100 * @param[in] uuidOfDevice1 DeviceID which is going to be unlinked with uuid of device 2.
101 * @param[in] uuidOfDevice2 DeviceID which is going to be unlinked with uuid of device 1.
103 * @return OC_STACK_OK in case of success and other value otherwise.
105 OCStackResult PDMUnlinkDevices(const OicUuid_t *uuidOfDevice1, const OicUuid_t *uuidOfDevice2);
108 * This method is used by provisioning manager to delete owned device's Device ID.
110 * @param[in] uuidOfDevice information about the owned device's uuid to be deleted.
112 * @return OC_STACK_OK in case of success and other value otherwise.
114 OCStackResult PDMDeleteDevice(const OicUuid_t *uuidOfDevice);
117 * This method is used by OTM & PDM to remove device information with device state.
119 * @param[in] state device state to be removed.
121 * @return OC_STACK_OK in case of success and other value otherwise.
123 OCStackResult PDMDeleteDeviceWithState(const PdmDeviceState_t state);
126 * This method is used by provisioning manager to get owned devices' Device IDs.
128 * @param[out] uuidList information about the list of owned devices' uuids.
129 * @param[out] numOfDevices total number of owned devices.
131 * @return OC_STACK_OK in case of success and other value otherwise.
133 OCStackResult PDMGetOwnedDevices(OCUuidList_t** uuidList, size_t* numOfDevices);
136 * This method is used by provisioning manager to get linked devices' IDs.
138 * @param[in] uuidOfDevice a target device's uuid.
139 * @param[out] uuidList information about the list of linked devices' uuids.
140 * @param[out] numOfDevices total number of linked devices.
142 * @return OC_STACK_OK in case of success and other value otherwise.
144 OCStackResult PDMGetLinkedDevices(const OicUuid_t* uuidOfDevice, OCUuidList_t** uuidList,
145 size_t* numOfDevices);
148 * This method is used by provisioning manager to update linked status as stale.
150 * @param[in] uuidOfDevice1 first id of stale link.
151 * @param[in] uuidOfDevice2 other id for stale link.
153 * @return OC_STACK_OK in case of success and other value otherwise.
155 OCStackResult PDMSetLinkStale(const OicUuid_t* uuidOfDevice1, const OicUuid_t* uuidOfDevice2);
158 * This method is used by provisioning manager to get stale devices.
160 * @note in case of sqllite, the caller should set NULL for parameters.
162 * @param[out] staleDevices information about the list of "To be Removed" devices' uuid.
163 * @param[out] numOfDevices total number of devices to be removed.
165 * @return OC_STACK_OK in case of success and other value otherwise.
167 OCStackResult PDMGetToBeUnlinkedDevices(OCPairList_t** staleDevList, size_t* numOfDevices);
170 * This method is used by provisioning manager to close provisioning database.
172 * @return OC_STACK_OK in case of success and other value otherwise.
174 OCStackResult PDMClose();
177 * This method is used by provisioning manager free memory allocated to OCUuidList_t lists.
179 * @param[in] ptr start pointer of link list.
181 void PDMDestoryOicUuidLinkList(OCUuidList_t* ptr);
184 * This method is used by provisioning manager free memory allocated to Stalelist.
186 * @param[in] ptr start pointer of link list.
189 void PDMDestoryStaleLinkList(OCPairList_t* ptr);
192 * This method is used by provisioning manager to check does the link exists between
193 * two devices or not.
195 * @param[in] uuidOfDevice1 UUID of device1.
196 * @param[in] uuidOfDevice2 UUID of device2.
197 * @param[out] result true when link exists otherwise false.
199 * @return OC_STACK_OK in case of success and other value otherwise.
201 OCStackResult PDMIsLinkExists(const OicUuid_t* uuidOfDevice1, const OicUuid_t* uuidOfDevice2,
208 #endif //PROVISIONING_DATABASE_MANAGER_H