1 //******************************************************************
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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 ENROLLEE_RESOURCE_H_
22 #define ENROLLEE_RESOURCE_H_
27 #include "ESRichCommon.h"
38 class EnrolleeSecurity;
40 typedef std::function<void(const HeaderOptions& headerOptions,
41 const OCRepresentation& rep,
42 const int eCode)> ESEnrolleeResourceCb;
44 * This class contains the resource discovery methods.
46 * @see EnrolleeResource
48 class EnrolleeResource : public std::enable_shared_from_this<EnrolleeResource>
50 friend class EnrolleeSecurity;
53 EnrolleeResource(std::shared_ptr< OC::OCResource > resource);
55 ~EnrolleeResource() = default;
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);
65 void getConfiguration();
67 void provisionProperties(const DeviceProp& deviceProp);
68 void requestToConnect(const std::vector<ES_CONNECT_TYPE> &connectTypes);
71 std::shared_ptr< OC::OCResource > m_ocResource;
73 GetStatusCb m_getStatusCb;
74 GetConfigurationStatusCb m_getConfigurationStatusCb;
75 DevicePropProvStatusCb m_devicePropProvStatusCb;
76 ConnectRequestStatusCb m_connectRequestStatusCb;
79 static void onEnrolleeResourceSafetyCB(const HeaderOptions& headerOptions,
80 const OCRepresentation& rep,
82 ESEnrolleeResourceCb cb,
83 std::weak_ptr<EnrolleeResource> this_ptr);
86 void onGetStatusResponse(const HeaderOptions& headerOptions,
87 const OCRepresentation& rep,
89 void onGetConfigurationResponse(const HeaderOptions& headerOptions,
90 const OCRepresentation& rep,
92 void onProvisioningResponse(const HeaderOptions& headerOptions,
93 const OCRepresentation& rep,
95 void onConnectRequestResponse(const HeaderOptions& headerOptions,
96 const OCRepresentation& rep,