X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Finclude%2FOCPlatform.h;h=d9fe21ae7bd3d61126dc16ee8133aa11eb7f0781;hb=b9f147a837d6947528ac9440d2d39fd47a68ed5f;hp=c3d540f413258fd9a045964529f80f362daa8a6c;hpb=8cb3267080d8a9785ca83b60460c5e980d4626d8;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/include/OCPlatform.h b/resource/include/OCPlatform.h index c3d540f..d9fe21a 100644 --- a/resource/include/OCPlatform.h +++ b/resource/include/OCPlatform.h @@ -44,12 +44,27 @@ namespace OC * @note Any calls made to this AFTER the first call to OCPlatform::Instance * will have no affect */ - void Configure(const PlatformConfig& config); + OCStackResult Configure(const PlatformConfig& config); // typedef for handle to cancel presence info with typedef OCDoHandle OCPresenceHandle; /** + * API for stop Base layer including resource and connectivity abstraction. + * + * @return Returns ::OC_STACK_OK if success. + */ + OCStackResult stop(); + + /** + * API for start Base layer including resource and connectivity abstraction. + * OCInit will be invoked. + * + * @return Returns ::OC_STACK_OK if success. + */ + OCStackResult start(); + + /** * API for notifying base that resource's attributes have changed. * * @param resourceHandle resource handle of the resource @@ -173,6 +188,18 @@ namespace OC OCConnectivityType connectivityType, FindCallback resourceHandler, FindErrorCallback errorHandler, QualityOfService QoS); + OCStackResult findResourceList(const std::string& host, const std::string& resourceURI, + OCConnectivityType connectivityType, FindResListCallback resourceHandler, + QualityOfService QoS = QualityOfService::LowQos); + + OCStackResult findResourceList(const std::string& host, const std::string& resourceURI, + OCConnectivityType connectivityType, FindResListCallback resourceHandler, + FindErrorCallback errorHandler, QualityOfService QoS = QualityOfService::LowQos); + + OCStackResult setPropertyValue(OCPayloadType type, const std::string& tag, const std::string& value); + OCStackResult setPropertyValue(OCPayloadType type, const std::string& tag, const std::vector& value); + OCStackResult getPropertyValue(OCPayloadType type, const std::string& tag, std::string& value); + OCStackResult getPropertyValue(OCPayloadType type, const std::string& tag, std::vector& value); /** * API for Device Discovery * @@ -266,6 +293,13 @@ namespace OC * first parameter can take fully qualified URI and core will take that as is for further * operations * @note OCStackResult is defined in ocstack.h. + * @note entity handler callback : + * When you set specific return value like OC_EH_CHANGED, OC_EH_CONTENT, + * OC_EH_SLOW and etc in entity handler callback, + * ocstack will be not send response automatically to client + * except for error return value like OC_EH_ERROR + * If you want to send response to client with specific result, + * OCDoResponse API should be called with the result value. */ OCStackResult registerResource(OCResourceHandle& resourceHandle, std::string& resourceURI, @@ -310,6 +344,13 @@ namespace OC * any undefined resources or default actions. * if NULL is passed it removes the device default entity handler. * @return Returns ::OC_STACK_OK if no errors and ::OC_STACK_ERROR in case of stack process error + * @note entity handler callback : + * When you set specific return value like OC_EH_CHANGED, OC_EH_CONTENT, + * OC_EH_SLOW and etc in entity handler callback, + * ocstack will be not send response automatically to client + * except for error return value like OC_EH_ERROR + * If you want to send response to client with specific result, + * sendResponse API should be called with the result value. */ OCStackResult setDefaultDeviceEntityHandler(EntityHandler entityHandler); @@ -444,6 +485,17 @@ namespace OC const std::string& resourceTypeName); /** + * Reset resource types of resource to newly passed resource type. + * + * @param resourceHandle handle to the resource + * @param newResourceType new typename to bind to the resource + * + * @return Returns ::OC_STACK_OK if success. + */ + OCStackResult resetResourceTypes(const OCResourceHandle& resourceHandle, + const std::string& newResourceType); + + /** * Binds an interface to a particular resource * @param resourceHandle handle to the resource * @param resourceInterfaceName new interface to bind to the resource @@ -453,6 +505,16 @@ namespace OC OCStackResult bindInterfaceToResource(const OCResourceHandle& resourceHandle, const std::string& resourceInterfaceName); + /** + * Reset resource interfaces of resource to newly passed interface. + * + * @param resourceHandle handle to the resource + * @param newResourceInterface new interface to bind to the resource + * + * @return Returns ::OC_STACK_OK if success. + */ + OCStackResult resetResourceInterfaces(const OCResourceHandle& resourceHandle, + const std::string& newResourceInterface); /** * Start Presence announcements. @@ -534,6 +596,7 @@ namespace OC */ OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle); +#ifdef WITH_CLOUD /** * Subscribes to a server's device presence change events. * @@ -542,7 +605,9 @@ namespace OC * It will be set upon successful return of this method. * @param host The IP address/addressable name of the server to subscribe to. * This should be in the format coap://address:port - * @param queryParams map which can have the query parameter name and list of value. + * @param di Vector which can have the devices id. + * @param connectivityType ::OCConnectivityType type of connectivity indicating the + * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP. * @param observeHandler handles callback * The callback function will be invoked with a map of attribute name and values. * The callback function will also have the result from this observe operation @@ -552,9 +617,10 @@ namespace OC */ OCStackResult subscribeDevicePresence(OCPresenceHandle& presenceHandle, const std::string& host, - const QueryParamsList& queryParams, + const std::vector& di, OCConnectivityType connectivityType, ObserveCallback callback); +#endif /** * Creates a resource proxy object so that get/put/observe functionality @@ -576,7 +642,7 @@ namespace OC * * @param connectivityType ::OCConnectivityType type of connectivity indicating the * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP. - * if you want to use specific a Flag like IPv4 + * if you want to use a specific Flag like IPv4, * you should apply OR operation for the flag in here. * Example: static_cast(CT_ADAPTER_TCP * | OC_IP_USE_V4) @@ -639,84 +705,65 @@ namespace OC DirectPairingCallback resultCallback); #ifdef WITH_CLOUD /** - * API for Account Registration to Account Server - * @note Not supported on client mode for now since device id is not generated yet on - * client mode. So it should be server or both mode for API to work. + * Create an account manager object that can be used for doing request to account server. + * You can only create this object if OCPlatform was initialized to be a Client or + * Client/Server. Otherwise, this will return an empty shared ptr. + * + * @note For now, OCPlatform SHOULD be initialized to be a Client/Server(Both) for the + * methods of this object to work since device id is not generated on Client mode. * * @param host Host IP Address of a account server. - * @param authProvider Provider name used for authentication. - * @param authCode The authorization code obtained by using an authorization server - * as an intermediary between the client and resource owner. * @param connectivityType ::OCConnectivityType type of connectivity indicating the * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP. - * @param cloudConnectHandler Callback function that will get the result of the operation. + * if you want to use a specific Flag like IPv4, + * you should apply OR operation for the flag in here. + * Example: static_cast(CT_ADAPTER_TCP + * | OC_IP_USE_V4) * - * @return Returns ::OC_STACK_OK if success + * @return OCAccountManager::Ptr a shared pointer to the new account manager object */ - OCStackResult signUp(const std::string& host, - const std::string& authProvider, - const std::string& authCode, - OCConnectivityType connectivityType, - PostCallback cloudConnectHandler); + OCAccountManager::Ptr constructAccountManagerObject(const std::string& host, + OCConnectivityType connectivityType); +#endif // WITH_CLOUD +#ifdef TCP_ADAPTER /** - * API for Sign-In to Account Server - * @note Not supported on client mode for now since device id is not generated yet on - * client mode. So it should be server or both mode for API to work. - * - * @param host Host IP Address of a account server. - * @param accessToken Identifier of the resource obtained by account registration. - * @param connectivityType ::OCConnectivityType type of connectivity indicating the - * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP. - * @param cloudConnectHandler Callback function that will get the result of the operation. + * gets OCRepresentation of KeepAlive resource from given host. * - * @return Returns ::OC_STACK_OK if success + * @param host Host IP Address of KeepAlive resource + * @param resultCallback Function to callback with result code and OCRepresentation. + * @return Returns ::OC_STACK_OK if success. */ - OCStackResult signIn(const std::string& host, - const std::string& accessToken, - OCConnectivityType connectivityType, - PostCallback cloudConnectHandler); + OCStackResult findKeepAliveResource(std::string host, KeepAliveCallback resultCallback); /** - * API for Sign-Out to Account Server - * @note Not supported on client mode for now since device id is not generated yet on - * client mode. So it should be server or both mode for API to work. - * - * @param host Host IP Address of a account server. - * @param accessToken Identifier of the resource obtained by account registration. - * @param connectivityType ::OCConnectivityType type of connectivity indicating the - * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP. - * @param cloudConnectHandler Callback function that will get the result of the operation. + * send KeepAlive request to given host. + * + * @param rep include interval time of expected pong response + * @param resultCallback handles callback + * + * @return Returns ::OC_STACK_OK on success, some other value upon failure. + * + */ + OCStackResult sendKeepAliveRequest(std::string host, const OCRepresentation& rep, + KeepAliveCallback resultCallback); +#endif + /** + * gets the deviceId of the client * - * @return Returns ::OC_STACK_OK if success + * @param deviceId pointer. + * @return Returns ::OC_STACK_OK if success. */ - OCStackResult signOut(const std::string& host, - const std::string& accessToken, - OCConnectivityType connectivityType, - PostCallback cloudConnectHandler); + OCStackResult getDeviceId(OCUUIdentity *deviceId); /** - * API for Refresh Access token to Account Server - * @note Not supported on client mode for now since device id is not generated yet on - * client mode. So it should be server or both mode for API to work. + * sets the deviceId of the client * - * @param host Host IP Address of a account server. - * @param refreshToken Refresh token used for access token refresh. - * @param connectivityType ::OCConnectivityType type of connectivity indicating the - * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP. - * @param cloudConnectHandler Callback function that will get the result of the operation. - * - * @return Returns ::OC_STACK_OK if success + * @param deviceId pointer. + * @return Returns ::OC_STACK_OK if success. */ - OCStackResult refreshAccessToken(const std::string& host, - const std::string& refreshToken, - OCConnectivityType connectivityType, - PostCallback cloudConnectHandler); -#endif // WITH_CLOUD + OCStackResult setDeviceId(const OCUUIdentity *deviceId); } } #endif // OC_PLATFORM_H_ - - -