Tracking OTM state on client side
[platform/upstream/iotivity.git] / resource / csdk / security / provisioning / include / internal / provisioningdatabasemanager.h
index 13cd8a4..9d0d2a4 100644 (file)
 extern "C" {
 #endif
 
+typedef enum PdmDeviceState {
+    PDM_DEVICE_ACTIVE = 0,
+    PDM_DEVICE_STALE = 1,
+    PDM_DEVICE_INIT = 2,
+    PDM_DEVICE_UNKNOWN = 99
+}PdmDeviceState_t;
 
 /**
  * This method is used by provisioning manager to open provisioning database.
  *
  * @param[in] dbPath file path of the sqlite3 db
  *
- * @return  OC_STACK_OK in case of success and other value otherwise.
+ * @return OC_STACK_OK in case of success and other value otherwise.
  */
 OCStackResult PDMInit(const char* dbPath);
 
 /**
+ * This method is used by provisioning manager to check device status.
+ *
+ * @param[in] uuid information about the target device's uuid.
+ * @param[out] result device status.
+ *
+ * @return OC_STACK_OK in case of success and other value otherwise.
+ */
+OCStackResult PDMGetDeviceState(const OicUuid_t* uuid, PdmDeviceState_t* result);
+
+/**
+ * This method is used by provisioning manager to update device status.
+ *
+ * @param[in] uuid id of device.
+ * @param[in] state device state. (ref. PdmDeviceState_t)
+ *
+ * @return OC_STACK_OK in case of success and other value otherwise.
+ */
+OCStackResult PDMSetDeviceState(const OicUuid_t* uuid, PdmDeviceState_t state);
+
+/**
  * This method is used by provisioning manager to check duplication of device's Device ID with
  * provisioning database.
  *
  * @param[in] uuidOfDevice information about the target device's uuid.
+ * @param[out] result true in case device UUID already exist otherwise false.
  *
- * @return  false when non-duplication and true when duplication or uuidOfDevicea is NULL .
+ * @return OC_STACK_OK in case of success and other value otherwise.
  */
-bool PDMIsDuplicateDevice(const OicUuid_t* uuidOfDevice);
+OCStackResult PDMIsDuplicateDevice(const OicUuid_t* uuidOfDevice, bool* result);
 
 /**
  * This method is used by provisioning manager to add owned device's Device ID.
  *
  * @param[in] uuidOfDevice information about the owned device's uuid.
  *
- * @return  OC_STACK_OK in case of success and other value otherwise.
+ * @return OC_STACK_OK in case of success and other value otherwise.
  */
 OCStackResult PDMAddDevice(const OicUuid_t* uuidOfDevice);
 
@@ -63,7 +90,7 @@ OCStackResult PDMAddDevice(const OicUuid_t* uuidOfDevice);
  * @param[in] uuidOfDevice1 DeviceID which is going to be linked with uuid of device 2.
  * @param[in] uuidOfDevice2 DeviceID which is going to be linked with uuid of device 1.
  *
- * @return  OC_STACK_OK in case of success and other value otherwise.
+ * @return OC_STACK_OK in case of success and other value otherwise.
  */
 OCStackResult PDMLinkDevices(const OicUuid_t *uuidOfDevice1, const OicUuid_t *uuidOfDevice2);
 
@@ -73,7 +100,7 @@ OCStackResult PDMLinkDevices(const OicUuid_t *uuidOfDevice1, const OicUuid_t *uu
  * @param[in] uuidOfDevice1 DeviceID which is going to be unlinked with uuid of device 2.
  * @param[in] uuidOfDevice2 DeviceID which is going to be unlinked with uuid of device 1.
  *
- * @return  OC_STACK_OK in case of success and other value otherwise.
+ * @return OC_STACK_OK in case of success and other value otherwise.
  */
 OCStackResult PDMUnlinkDevices(const OicUuid_t *uuidOfDevice1, const OicUuid_t *uuidOfDevice2);
 
@@ -82,17 +109,26 @@ OCStackResult PDMUnlinkDevices(const OicUuid_t *uuidOfDevice1, const OicUuid_t *
  *
  * @param[in] uuidOfDevice information about the owned device's uuid to be deleted.
  *
- * @return  OC_STACK_OK in case of success and other value otherwise.
+ * @return OC_STACK_OK in case of success and other value otherwise.
  */
 OCStackResult PDMDeleteDevice(const OicUuid_t *uuidOfDevice);
 
 /**
+ * This method is used by OTM & PDM to remove device information with device state.
+ *
+ * @param[in] state device state to be removed.
+ *
+ * @return OC_STACK_OK in case of success and other value otherwise.
+ */
+OCStackResult PDMDeleteDeviceWithState(const PdmDeviceState_t state);
+
+/**
  * This method is used by provisioning manager to get owned devices' Device IDs.
  *
  * @param[out] uuidList information about the list of owned devices' uuids.
  * @param[out] numOfDevices total number of owned devices.
  *
- * @return  OC_STACK_OK in case of success and other value otherwise.
+ * @return OC_STACK_OK in case of success and other value otherwise.
  */
 OCStackResult PDMGetOwnedDevices(OCUuidList_t** uuidList, size_t* numOfDevices);
 
@@ -103,7 +139,7 @@ OCStackResult PDMGetOwnedDevices(OCUuidList_t** uuidList, size_t* numOfDevices);
  * @param[out] uuidList information about the list of linked devices' uuids.
  * @param[out] numOfDevices total number of linked devices.
  *
- * @return  OC_STACK_OK in case of success and other value otherwise.
+ * @return OC_STACK_OK in case of success and other value otherwise.
  */
 OCStackResult PDMGetLinkedDevices(const OicUuid_t* uuidOfDevice, OCUuidList_t** uuidList,
                                     size_t* numOfDevices);
@@ -114,7 +150,7 @@ OCStackResult PDMGetLinkedDevices(const OicUuid_t* uuidOfDevice, OCUuidList_t**
  * @param[in] uuidOfDevice1 first id of stale link.
  * @param[in] uuidOfDevice2 other id for stale link.
  *
- * @return  OC_STACK_OK in case of success and other value otherwise.
+ * @return OC_STACK_OK in case of success and other value otherwise.
  */
 OCStackResult PDMSetLinkStale(const OicUuid_t* uuidOfDevice1, const OicUuid_t* uuidOfDevice2);
 
@@ -126,7 +162,7 @@ OCStackResult PDMSetLinkStale(const OicUuid_t* uuidOfDevice1, const OicUuid_t* u
  * @param[out] staleDevices information about the list of "To be Removed" devices' uuid.
  * @param[out] numOfDevices total number of devices to be removed.
  *
- * @return  OC_STACK_OK in case of success and other value otherwise.
+ * @return OC_STACK_OK in case of success and other value otherwise.
  */
 OCStackResult PDMGetToBeUnlinkedDevices(OCPairList_t** staleDevList, size_t* numOfDevices);
 
@@ -138,20 +174,71 @@ OCStackResult PDMGetToBeUnlinkedDevices(OCPairList_t** staleDevList, size_t* num
 OCStackResult PDMClose();
 
 /**
- * This method is used by provisioning manager free memory allocated to  OicUuidList lists.
+ * This method is used by provisioning manager free memory allocated to OCUuidList_t lists.
  *
  * @param[in] ptr start pointer of link list.
- * @return  OC_STACK_OK in case of success and other value otherwise.
  */
-OCStackResult PDMDestoryOicUuidLinkList(OCUuidList_t* ptr);
+void PDMDestoryOicUuidLinkList(OCUuidList_t* ptr);
 
 /**
  * This method is used by provisioning manager free memory allocated to Stalelist.
  *
  * @param[in] ptr start pointer of link list.
- * @return  OC_STACK_OK in case of success and other value otherwise.
+ *
+ */
+void PDMDestoryStaleLinkList(OCPairList_t* ptr);
+
+/**
+ * This method is used by provisioning manager to check does the link exists between
+ * two devices or not.
+ *
+ * @param[in] uuidOfDevice1 UUID of device1.
+ * @param[in] uuidOfDevice2 UUID of device2.
+ * @param[out] result true when link exists otherwise false.
+ *
+ * @return OC_STACK_OK in case of success and other value otherwise.
+ */
+OCStackResult PDMIsLinkExists(const OicUuid_t* uuidOfDevice1, const OicUuid_t* uuidOfDevice2,
+                                bool *result);
+
+/**
+ * This method put device and owner to otm table when start OTM
+ *
+ * @param[in] uuid - the device uuid
+ * @param[in] owner - the owner uuid
+ *
+ * @return OC_STACK_OK in case of success and other value otherwise.
+ */
+OCStackResult OTMStart(const OicUuid_t *uuid, const OicUuid_t *owner);
+
+/**
+ * This method set device state
+ *
+ * @param[in] uuid - the device uuid
+ * @param[in] state - the state
+ *
+ * @return OC_STACK_OK in case of success and other value otherwise.
+ */
+OCStackResult OTMSetState(const OicUuid_t *uuid, int state);
+
+/**
+ * This method stop OTM device
+ *
+ * @param[in] uuid - the device uuid
+ *
+ * @return OC_STACK_OK in case of success and other value otherwise.
+ */
+OCStackResult OTMStop(const OicUuid_t *uuid);
+
+/**
+ * This method get device state
+ *
+ * @param[in] uuid - the device uuid
+ * @param[out] state - the state
+ *
+ * @return OC_STACK_OK in case of success and other value otherwise.
  */
-OCStackResult PDMDestoryStaleLinkList(OCPairList_t* ptr);
+OCStackResult OTMGetState(const OicUuid_t *uuid, int *state);
 
 #ifdef __cplusplus
 }