Removed #ifdef CA_INTs and other code cleanup.
[platform/upstream/iotivity.git] / resource / csdk / stack / include / internal / ocresourcehandler.h
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Mobile Communications GmbH 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 OC_RESOURCEHANDLER_H
22 #define OC_RESOURCEHANDLER_H
23
24 #include "ocstack.h"
25 #include "ocstackinternal.h"
26 #include "ocserverrequest.h"
27
28 #define OC_RSRVD_OC                     "oc"
29 #define OC_RSRVD_PAYLOAD                "payload"
30 #define OC_RSRVD_HREF                   "href"
31 #define OC_RSRVD_RESOURCE_TYPE          "rt"
32 #define OC_RSRVD_RESOURCE_TYPE_PRESENCE "core.presence"
33 #define OC_RSRVD_INTERFACE              "if"
34 #define OC_RSRVD_DEVICE_ID              "di"
35 #define OC_RSRVD_DEVICE_NAME            "dn"
36 #define OC_RSRVD_INTERFACE_DEFAULT      "oc.mi.def"
37 #define OC_RSRVD_INTERFACE_LL           "oc.mi.ll"
38 #define OC_RSRVD_INTERFACE_BATCH        "oc.mi.b"
39 #define OC_RSRVD_INTERFACE_GROUP        "oc.mi.grp"
40
41
42 #define OC_RSRVD_OBSERVABLE             "obs"
43 #define OC_RSRVD_SECURE                 "sec"
44 #define OC_RSRVD_HOSTING_PORT           "port"
45 #define OC_RSRVD_SERVER_INSTANCE_ID     "sid"
46
47 #define OC_JSON_PREFIX                     "{\"oc\":["
48 #define OC_JSON_PREFIX_LEN                 (sizeof(OC_JSON_PREFIX) - 1)
49 #define OC_JSON_SUFFIX                     "]}"
50 #define OC_JSON_SUFFIX_LEN                 (sizeof(OC_JSON_SUFFIX) - 1)
51 #define OC_JSON_SEPARATOR                  ','
52
53 #define OC_RESOURCE_OBSERVABLE   1
54 #define OC_RESOURCE_SECURE       1
55
56 typedef enum {
57     STACK_RES_DISCOVERY_NOFILTER = 0,
58     STACK_RES_DISCOVERY_IF_FILTER,
59     STACK_RES_DISCOVERY_RT_FILTER,
60     STACK_DEVICE_DISCOVERY_DI_FILTER,
61     STACK_DEVICE_DISCOVERY_DN_FILTER
62 } StackQueryTypes;
63
64 typedef enum {
65     OC_RESOURCE_VIRTUAL = 0,
66     OC_RESOURCE_NOT_COLLECTION_WITH_ENTITYHANDLER,
67     OC_RESOURCE_NOT_COLLECTION_DEFAULT_ENTITYHANDLER,
68     OC_RESOURCE_COLLECTION_WITH_ENTITYHANDLER,
69     OC_RESOURCE_COLLECTION_DEFAULT_ENTITYHANDLER,
70     OC_RESOURCE_DEFAULT_DEVICE_ENTITYHANDLER,
71     OC_RESOURCE_NOT_SPECIFIED
72 } ResourceHandling;
73
74 OCEntityHandlerResult defaultResourceEHandler(OCEntityHandlerFlag flag,
75         OCEntityHandlerRequest * request);
76
77 const char * GetVirtualResourceUri( OCVirtualResources resource);
78 OCResource *FindResourceByUri(const char* resourceUri);
79 uint8_t IsVirtualResource(const char* resourceUri);
80
81 OCStackResult DetermineResourceHandling (OCServerRequest *request,
82                                          ResourceHandling *handling,
83                                          OCResource **resource);
84
85 OCStackResult
86 ProcessRequest(ResourceHandling resHandling, OCResource *resource, OCServerRequest *request);
87
88 OCStackResult SaveDeviceInfo(OCDeviceInfo deviceInfo);
89
90 void DeleteDeviceInfo();
91
92 OCStackResult
93 BuildVirtualResourceResponse(OCResource *resourcePtr, uint8_t filterOn,
94                         char *filterValue, char * out, uint16_t *remaining,
95                         CAConnectivityType_t connType );
96
97 OCStackResult EntityHandlerCodeToOCStackCode(OCEntityHandlerResult ehResult);
98
99 #endif //OC_RESOURCEHANDLER_H