replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / service / easy-setup / enrollee / src / resourcehandler.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 // Do not remove the include below
22
23 #include <string.h>
24 #include "logger.h"
25 #include "ocstack.h"
26 #include "escommon.h"
27 #include "ESEnrolleeCommon.h"
28 #include "octypes.h"
29
30 #ifndef ES_RESOURCE_HANDLER_H_
31 #define ES_RESOURCE_HANDLER_H_
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 typedef void (*ESConnectRequestCB) (ESResult, ESConnectRequest *);
38 typedef void (*ESWiFiConfCB) (ESResult, ESWiFiConfData *);
39 typedef void (*ESCoapCloudConfCB) (ESResult, ESCoapCloudConfData *);
40 typedef void (*ESDevConfCB) (ESResult, ESDevConfData *);
41
42 typedef void (*ESWriteUserdataCb)(OCRepPayload* payload, char* resourceType);
43 typedef void (*ESReadUserdataCb)(OCRepPayload* payload, char* resourceType, void** userdata);
44
45 /* Structure to represent a Light resource */
46 typedef struct
47 {
48     OCResourceHandle handle;
49     ProvStatus status; // provisiong status
50     ESErrorCode lastErrCode;
51     ES_CONNECT_TYPE connectRequest[NUM_CONNECT_TYPE];
52     int numRequest;
53 } EasySetupResource;
54
55 typedef struct
56 {
57     OCResourceHandle handle;
58     WIFI_MODE supportedMode[NUM_WIFIMODE];
59     uint8_t numMode;        // the number of device's supported wifi modes
60     WIFI_FREQ supportedFreq;
61     char ssid[OIC_STRING_MAX_VALUE]; // SSID
62     char cred[OIC_STRING_MAX_VALUE]; // credential information.
63     WIFI_AUTHTYPE authType;
64     WIFI_ENCTYPE encType;
65 } WiFiConfResource;
66
67 typedef struct
68 {
69     OCResourceHandle handle;
70     char authCode[OIC_STRING_MAX_VALUE];
71     char accessToken[OIC_STRING_MAX_VALUE];
72     OAUTH_TOKENTYPE accessTokenType;
73     char authProvider[OIC_STRING_MAX_VALUE];
74     char ciServer[OIC_STRING_MAX_VALUE];
75 } CoapCloudConfResource;
76
77 typedef struct
78 {
79     OCResourceHandle handle;
80     char devName[OIC_STRING_MAX_VALUE];
81     char modelNumber[OIC_STRING_MAX_VALUE];
82     char location[OIC_STRING_MAX_VALUE];
83     char language[OIC_STRING_MAX_VALUE];
84     char country[OIC_STRING_MAX_VALUE];
85 } DevConfResource;
86
87 /* Note: These values of structures are not thread-safety */
88 extern EasySetupResource g_ESEasySetupResource;
89 extern WiFiConfResource g_ESWiFiConfResource;
90 extern CoapCloudConfResource g_ESCoapCloudConfResource;
91 extern DevConfResource g_ESDevConfResource;
92
93 OCStackResult CreateEasySetupResources(bool isSecured, ESResourceMask resourceMask);
94 OCStackResult DeleteEasySetupResources();
95
96 OCStackResult SetDeviceProperty(ESDeviceProperty *deviceProperty);
97 OCStackResult SetEnrolleeState(ESEnrolleeState esState);
98 OCStackResult SetEnrolleeErrCode(ESErrorCode esErrCode);
99 OCEntityHandlerResult CheckEhRequestPayload(OCEntityHandlerRequest *ehRequest);
100
101 void RegisterWifiRsrcEventCallBack(ESWiFiConfCB);
102 void RegisterCloudRsrcEventCallBack(ESCoapCloudConfCB);
103 void RegisterDevConfRsrcEventCallBack(ESDevConfCB);
104 void UnRegisterResourceEventCallBack(void);
105 ESResult SetCallbackForUserData(ESReadUserdataCb readCb, ESWriteUserdataCb writeCb);
106
107 #ifdef __cplusplus
108 }
109 #endif
110
111 #endif //ES_RESOURCE_HANDLER_H_