X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fstack%2Finclude%2Finternal%2Focresourcehandler.h;h=e068231404486b8773af7fbf8096356626febb7a;hb=1b3989f5777db18d830407badd8e0332c1b1e33e;hp=f56769cefd40bb2df1acce1c0060bce93bb5cb21;hpb=e9915f761795ff5df3998d02d6991eacc83cfa1f;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/stack/include/internal/ocresourcehandler.h b/resource/csdk/stack/include/internal/ocresourcehandler.h old mode 100755 new mode 100644 index f56769c..e068231 --- a/resource/csdk/stack/include/internal/ocresourcehandler.h +++ b/resource/csdk/stack/include/internal/ocresourcehandler.h @@ -25,34 +25,29 @@ #include "ocstackinternal.h" #include "ocserverrequest.h" -#define OC_RSRVD_OC "oc" -#define OC_RSRVD_PAYLOAD "payload" -#define OC_RSRVD_HREF "href" -#define OC_RSRVD_RESOURCE_TYPE "rt" -#define OC_RSRVD_RESOURCE_TYPE_PRESENCE "core.presence" -#define OC_RSRVD_INTERFACE "if" -#define OC_RSRVD_DEVICE_ID "di" -#define OC_RSRVD_DEVICE_NAME "dn" -#define OC_RSRVD_INTERFACE_DEFAULT "oc.mi.def" -#define OC_RSRVD_INTERFACE_LL "oc.mi.ll" -#define OC_RSRVD_INTERFACE_BATCH "oc.mi.b" -#define OC_RSRVD_INTERFACE_GROUP "oc.mi.c" - - -#define OC_RSRVD_OBSERVABLE "obs" -#define OC_RSRVD_SECURE "sec" -#define OC_RSRVD_HOSTING_PORT "port" - -#define OC_JSON_PREFIX "{\"oc\":[" +/** + * Common JSON string components used by the stack to build JSON strings. + * These details are exposed in ocstackconfig.h file in the form of documentation. + * Remember to update the documentation there if these are changed. + */ +#define OC_JSON_PREFIX "{\"oic\":[" #define OC_JSON_PREFIX_LEN (sizeof(OC_JSON_PREFIX) - 1) #define OC_JSON_SUFFIX "]}" #define OC_JSON_SUFFIX_LEN (sizeof(OC_JSON_SUFFIX) - 1) #define OC_JSON_SEPARATOR ',' +#define OC_JSON_SEPARATOR_STR "," +/** + * Static values for various JSON attributes. + */ #define OC_RESOURCE_OBSERVABLE 1 #define OC_RESOURCE_SECURE 1 -typedef enum { +/** + * The type of query a request/response message is. + */ +typedef enum +{ STACK_RES_DISCOVERY_NOFILTER = 0, STACK_RES_DISCOVERY_IF_FILTER, STACK_RES_DISCOVERY_RT_FILTER, @@ -60,7 +55,11 @@ typedef enum { STACK_DEVICE_DISCOVERY_DN_FILTER } StackQueryTypes; -typedef enum { +/** + * The type of handling required to handle a request. + */ +typedef enum +{ OC_RESOURCE_VIRTUAL = 0, OC_RESOURCE_NOT_COLLECTION_WITH_ENTITYHANDLER, OC_RESOURCE_NOT_COLLECTION_DEFAULT_ENTITYHANDLER, @@ -70,28 +69,85 @@ typedef enum { OC_RESOURCE_NOT_SPECIFIED } ResourceHandling; +/** + * Default entity handler (ie. callback) to be used for resources with + * no entity handler. + */ OCEntityHandlerResult defaultResourceEHandler(OCEntityHandlerFlag flag, - OCEntityHandlerRequest * request); + OCEntityHandlerRequest * request, void* callbackParam); -const char * GetVirtualResourceUri( OCVirtualResources resource); +/** + * Get string value associated with a virtual resource type. + */ +const char * GetVirtualResourceUri(OCVirtualResources resource); + +/** + * Find and retrieve pointer to a resource associated with a specific resource + * URI. + */ OCResource *FindResourceByUri(const char* resourceUri); -uint8_t IsVirtualResource(const char* resourceUri); -OCStackResult DetermineResourceHandling (OCServerRequest *request, +/** + * Returns true if the specificed resource URI aligns with a pre-existing + * virtual resource; returns false otherwise. + */ +bool IsVirtualResource(const char* resourceUri); + +/** + * Parameter @ref handling returns by-reference the type of resource handling + * required by the internal stack based on the specified @ref request. + */ +OCStackResult DetermineResourceHandling (const OCServerRequest *request, ResourceHandling *handling, OCResource **resource); -OCStackResult -ProcessRequest(ResourceHandling resHandling, OCResource *resource, OCServerRequest *request); - -OCStackResult SaveDeviceInfo(OCDeviceInfo deviceInfo); - +/** + * Processes the specified @ref request based on the type of resource handling + * @ref resHandling. + */ +OCStackResult ProcessRequest(ResourceHandling resHandling, + OCResource *resource, + OCServerRequest *request); + +/** + * Internal API used to save all of the platform's information for use in platform + * discovery requests. + */ +OCStackResult SavePlatformInfo(OCPlatformInfo info); + +/** + * Internal API used to save all of the device's information for use in platform + * discovery requests. + * The device name is received from the appliation. + * The deviceID, spec version and data model verson are initialized by the stack. + */ +OCStackResult SaveDeviceInfo(OCDeviceInfo info); + +/** + * Internal API used to clear the platform information. + */ +void DeletePlatformInfo(); + +/** + * Internal API used to clear the device information. + */ void DeleteDeviceInfo(); -OCStackResult -BuildVirtualResourceResponse(OCResource *resourcePtr, uint8_t filterOn, - char *filterValue, char * out, uint16_t *remaining); - +/** + * Prepares a JSON string for response. + */ +OCStackResult BuildVirtualResourceResponse(const OCResource *resourcePtr, + uint8_t filterOn, + const char *filterValue, + char * out, + uint16_t *remaining, + CATransportAdapter_t adapter); + +/** + * A helper function that Maps an @ref OCEntityHandlerResult type to an + * @ref OCStackResult type. + */ OCStackResult EntityHandlerCodeToOCStackCode(OCEntityHandlerResult ehResult); #endif //OC_RESOURCEHANDLER_H +