replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / service / easy-setup / mediator / richsdk / src / EnrolleeResource.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 ENROLLEE_RESOURCE_H_
22 #define ENROLLEE_RESOURCE_H_
23
24 #include <mutex>
25 #include <memory>
26
27 #include "ESRichCommon.h"
28
29 #include "OCApi.h"
30
31 using namespace OC;
32
33 namespace OIC
34 {
35     namespace Service
36     {
37         class OCResource;
38         class EnrolleeSecurity;
39
40         typedef std::function<void(const HeaderOptions& headerOptions,
41                                    const OCRepresentation& rep,
42                                    const int eCode)> ESEnrolleeResourceCb;
43         /**
44          * This class contains the resource discovery methods.
45          *
46          * @see EnrolleeResource
47          */
48         class EnrolleeResource : public std::enable_shared_from_this<EnrolleeResource>
49         {
50             friend class EnrolleeSecurity;
51
52         public:
53             EnrolleeResource(std::shared_ptr< OC::OCResource > resource);
54
55             ~EnrolleeResource() = default;
56
57             void registerGetStatusCallback(const GetStatusCb callback);
58             void registerGetConfigurationStatusCallback(
59                 const GetConfigurationStatusCb callback);
60             void registerDevicePropProvStatusCallback(
61                 const DevicePropProvStatusCb callback);
62             void registerConnectRequestStatusCallback(
63                 const ConnectRequestStatusCb callback);
64
65             void getConfiguration();
66             void getStatus();
67             void provisionProperties(const DeviceProp& deviceProp);
68             void requestToConnect(const std::vector<ES_CONNECT_TYPE> &connectTypes);
69
70         private:
71             std::shared_ptr< OC::OCResource > m_ocResource;
72
73             GetStatusCb m_getStatusCb;
74             GetConfigurationStatusCb m_getConfigurationStatusCb;
75             DevicePropProvStatusCb m_devicePropProvStatusCb;
76             ConnectRequestStatusCb m_connectRequestStatusCb;
77
78         private:
79             static void onEnrolleeResourceSafetyCB(const HeaderOptions& headerOptions,
80                                     const OCRepresentation& rep,
81                                     const int eCode,
82                                     ESEnrolleeResourceCb cb,
83                                     std::weak_ptr<EnrolleeResource> this_ptr);
84
85
86             void onGetStatusResponse(const HeaderOptions& headerOptions,
87                                                 const OCRepresentation& rep,
88                                                 const int eCode);
89             void onGetConfigurationResponse(const HeaderOptions& headerOptions,
90                                                            const OCRepresentation& rep,
91                                                            const int eCode);
92             void onProvisioningResponse(const HeaderOptions& headerOptions,
93                                                     const OCRepresentation& rep,
94                                                     const int eCode);
95             void onConnectRequestResponse(const HeaderOptions& headerOptions,
96                                                     const OCRepresentation& rep,
97                                                     const int eCode);
98         };
99     }
100 }
101 #endif