Restructuring of the easy-setup service.
[platform/upstream/iotivity.git] / service / easy-setup / mediator / richsdk / inc / Utility.h
1 //******************************************************************
2 //
3 // Copyright 2016 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 UTILITY_H_
22 #define UTILITY_H_
23
24 #ifndef WITH_ARDUINO
25 #include <memory>
26 #endif
27
28 #include "ocstack.h"
29 #include "octypes.h"
30
31 #ifndef WITH_ARDUINO
32 namespace OIC
33 {
34     namespace Service
35     {
36         typedef enum
37         {
38             ES_PROVISIONING_ERROR = -1,
39             ES_NEED_PROVISIONING,
40             ES_PROVISIONED_ALREADY,
41             ES_PROVISIONING_SUCCESS
42         } ESState;
43
44         typedef enum
45         {
46             ES_UNKNOWN = 0,
47             ES_ONBOARDED,
48             ES_OWNED,
49             ES_PROVISIONED
50         } CurrentESState;
51
52         typedef enum
53         {
54             ES_SEC_UNKNOWN = 0,
55             ES_SEC_OWNED,
56             ES_SEC_ACL_PROVISIONED,
57             ES_SEC_CREDS_PROVISIONED
58         } EnrolleeSecState;
59
60         /**
61          * Security Provisioning Status
62          */
63         class SecProvisioningResult
64         {
65         public:
66             std::shared_ptr< SecProvisioningResult > shared_ptr;
67             SecProvisioningResult(std::string deviceUUID, ESResult result) :
68                 m_devUUID(deviceUUID), m_result(result)
69             {
70
71             }
72
73             std::string getDeviceUUID()
74             {
75                 return m_devUUID;
76             }
77
78             ESResult getResult()
79             {
80                 return m_result;
81             }
82         private:
83             std::string m_devUUID;
84             ESResult m_result;
85         };
86
87         /**
88          * Callback function definition for providing Enrollee security status .
89          */
90         typedef std::function< void(std::shared_ptr<SecProvisioningResult>) > EnrolleeSecStatusCb;
91
92         /**
93          * Callback definition to be invoked when the security stack expects a pin from application.
94          */
95         typedef std::function< void(std::string&) > SecurityPinCb;
96
97         /**
98          * Callback definition to be invoked when the stack expects a db path.
99          */
100         typedef std::function< void(std::string&) > SecProvisioningDbPathCb;
101
102         class ProvisioningStatus
103         {
104         public:
105             std::shared_ptr< ProvisioningStatus > shared_ptr;
106             ProvisioningStatus(ESResult result, ESState esState) :
107                     m_result(result), m_esState(esState)
108             {
109
110             }
111
112             ESResult& getESResult()
113             {
114                 return m_result;
115             }
116
117             ESState& getESState()
118             {
119                 return m_esState;
120             }
121         private:
122             ESResult m_result;
123             ESState m_esState;
124         };
125
126         class EasySetupStatus
127         {
128         public:
129             std::shared_ptr< EasySetupStatus > shared_ptr;
130             EasySetupStatus(const EasySetupState& easySetupState,
131                     const EnrolleeNWProvInfo& enrolleeNWProvInfo) :
132                     m_easySetupState(easySetupState), m_enrolleeNWProvInfo(enrolleeNWProvInfo)
133             {
134
135             }
136
137             EnrolleeNWProvInfo& getEasySetupNWProvInfo()
138             {
139                 return m_enrolleeNWProvInfo;
140             }
141
142             EasySetupState& getEasySetupState()
143             {
144                 return m_easySetupState;
145             }
146         private:
147             EasySetupState m_easySetupState;
148             EnrolleeNWProvInfo m_enrolleeNWProvInfo;
149         };
150     }
151 }
152 #endif //WITH_ARDUINO
153
154 #endif //UTILITY_H_