X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fsrc%2FOCPlatform_impl.cpp;h=f5817c66fa50f658d8f34321d4e07ae20222fb16;hb=fb1a9ab3bfa193414f1d2acfa4eec2ec517d2534;hp=09c32df1c4e353fb9acc0d5f0d3cd2146d2499b8;hpb=ae6e681f3aa422e0bad2cc0cf706b54bde18bb1b;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/src/OCPlatform_impl.cpp b/resource/src/OCPlatform_impl.cpp index 09c32df..f5817c6 100644 --- a/resource/src/OCPlatform_impl.cpp +++ b/resource/src/OCPlatform_impl.cpp @@ -80,6 +80,7 @@ namespace OC break; case ModeType::Both: + case ModeType::Gateway: m_server = m_WrapperInstance->CreateServerWrapper(m_csdkLock, config); m_client = m_WrapperInstance->CreateClientWrapper(m_csdkLock, config); break; @@ -155,10 +156,15 @@ namespace OC return std::shared_ptr(); } + uint8_t resourceProperty = 0; + if (isObservable) + { + resourceProperty = (resourceProperty | OC_OBSERVABLE); + } return std::shared_ptr(new OCResource(m_client, host, uri, "", connectivityType, - isObservable, + resourceProperty, resourceTypes, interfaces)); } @@ -181,6 +187,28 @@ namespace OC host, resourceName, connectivityType, resourceHandler, QoS); } + OCStackResult OCPlatform_impl::findResource(const std::string& host, + const std::string& resourceName, + OCConnectivityType connectivityType, + FindCallback resourceHandler, + FindErrorCallback errorHandler) + { + return findResource(host, resourceName, connectivityType, resourceHandler, + errorHandler, m_cfg.QoS); + } + + OCStackResult OCPlatform_impl::findResource(const std::string& host, + const std::string& resourceName, + OCConnectivityType connectivityType, + FindCallback resourceHandler, + FindErrorCallback errorHandler, + QualityOfService QoS) + { + return checked_guard(m_client, &IClientWrapper::ListenErrorForResource, + host, resourceName, connectivityType, resourceHandler, + errorHandler, QoS); + } + OCStackResult OCPlatform_impl::getDeviceInfo(const std::string& host, const std::string& deviceURI, OCConnectivityType connectivityType, @@ -354,6 +382,18 @@ namespace OC std::ref(presenceHandle)); } +#ifdef WITH_CLOUD + OCStackResult OCPlatform_impl::subscribeDevicePresence(OCPresenceHandle& presenceHandle, + const std::string& host, + const QueryParamsList& queryParams, + OCConnectivityType connectivityType, + ObserveCallback callback) + { + return checked_guard(m_client, &IClientWrapper::SubscribeDevicePresence, + &presenceHandle, host, queryParams, connectivityType, callback); + } +#endif + OCStackResult OCPlatform_impl::sendResponse(const std::shared_ptr pResponse) { return checked_guard(m_server, &IServerWrapper::sendResponse, @@ -364,5 +404,145 @@ namespace OC { return m_csdkLock; } + + OCStackResult OCPlatform_impl::findDirectPairingDevices(unsigned short waittime, + GetDirectPairedCallback directPairingHandler) + { + return checked_guard(m_client, &IClientWrapper::FindDirectPairingDevices, + waittime, directPairingHandler); + + } + + OCStackResult OCPlatform_impl::getDirectPairedDevices( + GetDirectPairedCallback directPairingHandler) + { + + return checked_guard(m_client, &IClientWrapper::GetDirectPairedDevices, + directPairingHandler); + } + + OCStackResult OCPlatform_impl::doDirectPairing(std::shared_ptr peer, + OCPrm_t pmSel, + const std::string& pinNumber, + DirectPairingCallback resultCallback) + { + return checked_guard(m_client, &IClientWrapper::DoDirectPairing, + peer, pmSel, pinNumber, resultCallback); + } +#ifdef WITH_CLOUD + OCStackResult OCPlatform_impl::signUp(const std::string& host, + const std::string& authProvider, + const std::string& authCode, + OCConnectivityType connectivityType, + PostCallback cloudConnectHandler) + { + const char* di = OCGetServerInstanceIDString(); + if (!di) + { + oclog() << "The mode should be Server or Both to generate UUID" << std::flush; + return result_guard(OC_STACK_ERROR); + } + std::string deviceId(di); + + OCRepresentation rep; + rep.setValue(OC_RSRVD_DEVICE_ID, deviceId); + rep.setValue(OC_RSRVD_AUTHPROVIDER, authProvider); + rep.setValue(OC_RSRVD_AUTHCODE, authCode); + + std::string uri = host + OC_RSRVD_ACCOUNT_URI; + + OCDevAddr devAddr; + QueryParamsMap queryParams; + HeaderOptions headerOptions; + + QualityOfService defaultQos = OC::QualityOfService::NaQos; + checked_guard(m_client, &IClientWrapper::GetDefaultQos, defaultQos); + + return checked_guard(m_client, &IClientWrapper::PostResourceRepresentation, + devAddr, uri, rep, queryParams, headerOptions, + connectivityType, cloudConnectHandler, defaultQos); + } + + OCStackResult OCPlatform_impl::signIn(const std::string& host, + const std::string& accessToken, + OCConnectivityType connectivityType, + PostCallback cloudConnectHandler) + { + return signInOut(host, accessToken, true, connectivityType, cloudConnectHandler); + } + + OCStackResult OCPlatform_impl::signOut(const std::string& host, + const std::string& accessToken, + OCConnectivityType connectivityType, + PostCallback cloudConnectHandler) + { + return signInOut(host, accessToken, false, connectivityType, cloudConnectHandler); + } + + OCStackResult OCPlatform_impl::signInOut(const std::string& host, + const std::string& accessToken, + bool isSignIn, + OCConnectivityType connectivityType, + PostCallback cloudConnectHandler) + { + const char* di = OCGetServerInstanceIDString(); + if (!di) + { + oclog() << "The mode should be Server or Both to generate UUID" << std::flush; + return result_guard(OC_STACK_ERROR); + } + std::string deviceId(di); + + OCRepresentation rep; + rep.setValue(OC_RSRVD_DEVICE_ID, deviceId); + rep.setValue(OC_RSRVD_ACCESS_TOKEN, accessToken); + rep.setValue(OC_RSRVD_STATUS, isSignIn); + + std::string uri = host + OC_RSRVD_ACCOUNT_SESSION_URI; + + OCDevAddr devAddr; + QueryParamsMap queryParams; + HeaderOptions headerOptions; + + QualityOfService defaultQos = OC::QualityOfService::NaQos; + checked_guard(m_client, &IClientWrapper::GetDefaultQos, defaultQos); + + return checked_guard(m_client, &IClientWrapper::PostResourceRepresentation, + devAddr, uri, rep, queryParams, headerOptions, + connectivityType, cloudConnectHandler, defaultQos); + } + + OCStackResult OCPlatform_impl::refreshAccessToken(const std::string& host, + const std::string& refreshToken, + OCConnectivityType connectivityType, + PostCallback cloudConnectHandler) + { + const char* di = OCGetServerInstanceIDString(); + if (!di) + { + oclog() << "The mode should be Server or Both to generate UUID" << std::flush; + return result_guard(OC_STACK_ERROR); + } + std::string deviceId(di); + + OCRepresentation rep; + rep.setValue(OC_RSRVD_DEVICE_ID, deviceId); + rep.setValue(OC_RSRVD_REFRESH_TOKEN, refreshToken); + rep.setValue(OC_RSRVD_GRANT_TYPE, OC_RSRVD_GRANT_TYPE_REFRESH_TOKEN); + + std::string uri = host + OC_RSRVD_ACCOUNT_TOKEN_REFRESH_URI; + + OCDevAddr devAddr; + QueryParamsMap queryParams; + HeaderOptions headerOptions; + + QualityOfService defaultQos = OC::QualityOfService::NaQos; + checked_guard(m_client, &IClientWrapper::GetDefaultQos, defaultQos); + + return checked_guard(m_client, &IClientWrapper::PostResourceRepresentation, + devAddr, uri, rep, queryParams, headerOptions, + connectivityType, cloudConnectHandler, defaultQos); + } +#endif // WITH_CLOUD } //namespace OC