Add APIs of cloud provisioning for Android and JNI layer
[platform/upstream/iotivity.git] / service / easy-setup / mediator / richsdk / inc / RemoteEnrollee.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 REMOTE_ENROLLEE_H_
22 #define REMOTE_ENROLLEE_H_
23
24 #include <memory>
25
26 #include "ESRichCommon.h"
27 #include "OCApi.h"
28
29 using namespace OC;
30
31 namespace OIC
32 {
33     namespace Service
34     {
35         class OCResource;
36         class EnrolleeResource;
37         class CloudResource;
38         class EnrolleeSecurity;
39
40         /**
41          * This class represents Remote Enrollee device instance.
42          * It will provide APIs for Mediator to perform operations to enable the Enrollee device
43          * to connect to the Enroller.
44          */
45         class RemoteEnrollee
46         {
47         public:
48             ~RemoteEnrollee() = default;
49
50 #ifdef __WITH_DTLS__
51             /**
52              * Register Security status and other information callback handlers.
53              *
54              * @param secProvisioningDbCb Callback to be invoked when the stack expects a
55              *        path for the provisioning db.
56              * @param securityPinCb Callback to get security pin during pin based ownership transfer.
57              *
58              * @throws InvalidParameterException If callback is an empty function or null.
59              * @throws ESBadRequestException If registration is already completed.
60              *
61              * @see SecProvisioningResult
62              */
63             ESResult registerSecurityCallbackHandler(SecurityPinCb securityPinCb,
64                     SecProvisioningDbPathCb secProvisioningDbPathCb);
65 #endif //__WITH_DTLS__
66
67             /**
68              * Start provisioning of target Enrollers information to the Enrollee.
69              *
70              * @throws ESBadRequestException If RemoteEnrollee device not created prior to this call.
71              *
72              * @see RemoteEnrollee
73              */
74             void  initRemoteEnrollee();
75
76             /**
77              * Start provisioning of target Enrollers information to the Enrollee.
78              *
79              * @throws ESBadRequestException If RemoteEnrollee device not created prior to this call.
80              *
81              * @see RemoteEnrollee
82              */
83             void requestPropertyData(RequestPropertyDataStatusCb callback);
84
85              /**
86              * Start provisioning of target Enrollers information to the Enrollee.
87              *
88              * @throws ESBadRequestException If RemoteEnrollee device not created prior to this call.
89              *
90              * @see RemoteEnrollee
91              */
92             void startSecurityProvisioning(EnrolleeSecStatusCb callback);
93
94             /**
95              * Start provisioning of target Enrollers information to the Enrollee.
96              *
97              * @throws ESBadRequestException If RemoteEnrollee device not created prior to this call.
98              *
99              * @see RemoteEnrollee
100              */
101             void startDataProvisioning(DataProvStatusCb callback);
102
103             /**
104              * Start provisioning of target Enrollers information to the Enrollee.
105              *
106              * @throws ESBadRequestException If RemoteEnrollee device not created prior to this call.
107              *
108              * @see RemoteEnrollee
109              */
110             void startCloudProvisioning(CloudProvStatusCb callback);
111
112             /**
113              * Get the Provisioning information provided for the current Enrollee.
114              *
115              * @return DataProvInfo Provisioning information provided for the current Enrollee.
116              */
117             DataProvInfo getDataProvInfo();
118
119             void setDataProvInfo(const DataProvInfo& );
120             void setCloudProvInfo(const CloudProvInfo& );
121
122         private:
123             RemoteEnrollee();
124
125             ESResult discoverResource();
126             ESResult ESDiscoveryTimeout(unsigned short waittime);
127             void onDeviceDiscovered(std::shared_ptr<OC::OCResource> resource);
128             void initCloudResource();
129
130             void RequestPropertyDataStatusHandler (std::shared_ptr< RequestPropertyDataStatus > status);
131             void dataProvisioningStatusHandler (std::shared_ptr< DataProvisioningStatus > status);
132             void cloudProvisioningStatusHandler (std::shared_ptr< CloudProvisioningStatus > status);
133             void easySetupSecurityStatusCallback(std::shared_ptr< SecProvisioningStatus > status);
134
135         private:
136             std::shared_ptr< OC::OCResource > m_ocResource;
137             std::shared_ptr< EnrolleeResource > m_enrolleeResource;
138             std::shared_ptr< EnrolleeSecurity > m_enrolleeSecurity;
139             std::shared_ptr< CloudResource > m_cloudResource;
140
141             std::string  m_deviceId;
142             bool m_discoveryResponse;
143
144             EnrolleeSecStatusCb m_enrolleeSecStatusCb;
145             RequestPropertyDataStatusCb m_RequestPropertyDataStatusCb;
146             SecurityPinCb m_securityPinCb;
147             SecProvisioningDbPathCb m_secProvisioningDbPathCb;
148             DataProvStatusCb m_dataProvStatusCb;
149             CloudProvStatusCb m_cloudProvStatusCb;
150
151             DataProvInfo m_dataProvInfo;
152             CloudProvInfo m_cloudProvInfo;
153             PropertyData m_propertyData;
154
155             friend class EasySetup;
156         };
157     }
158 }
159
160 #endif //REMOTE_ENROLLEE_H_