// // Open Service Platform // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. // // Licensed under the Apache License, Version 2.0 (the License); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // @file FNetBtBluetoothOppClient.cpp // @brief This is the implementation file for the BluetoothOppClient class. // #include #include #include #include #include #include #include #include "FNetBt_BluetoothOppClientImpl.h" using namespace Tizen::Security; namespace Tizen { namespace Net { namespace Bluetooth { BluetoothOppClient::BluetoothOppClient(void) : __pImpl(null) { } BluetoothOppClient::~BluetoothOppClient(void) { delete __pImpl; } result BluetoothOppClient::Construct(IBluetoothOppClientEventListener& listener) { result r = E_SUCCESS; bool isBtSupported = false; Tizen::System::_SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/network.bluetooth", isBtSupported); SysTryReturnResult(NID_NET_BT, isBtSupported == true, E_UNSUPPORTED_OPERATION, "Bluetooth is not supported."); SysAssertf(__pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); __pImpl = new (std::nothrow) _BluetoothOppClientImpl; SysTryReturnResult(NID_NET_BT, __pImpl != null, E_OUT_OF_MEMORY, "Creation of a _BluetoothOppClientImpl instance failed."); r = __pImpl->Construct(listener); if (r != E_SUCCESS) { delete __pImpl; __pImpl = null; } return r; } result BluetoothOppClient::PushFile(const BluetoothDevice& remoteDevice, const Base::String& filePath) { result r = E_SUCCESS; // Privilege check r = _AccessController::CheckUserPrivilege(_PRV_BLUETOOTH_OPP); r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED, E_OUT_OF_MEMORY); SysTryReturnResult(NID_NET_BT, r == E_SUCCESS, r, "The application is not permitted to call this method."); // Check Construct SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use."); return __pImpl->PushFile(remoteDevice, filePath); } result BluetoothOppClient::CancelPush(void) { result r = E_SUCCESS; // Privilege check r = _AccessController::CheckUserPrivilege(_PRV_BLUETOOTH_OPP); r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED, E_OUT_OF_MEMORY); SysTryReturnResult(NID_NET_BT, r == E_SUCCESS, r, "The application is not permitted to call this method."); // Check Construct SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use."); return __pImpl->CancelPush(); } result BluetoothOppClient::SetMinProgressInterval(int percent) { // Check Construct SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use."); return __pImpl->SetMinProgressInterval(percent); } } } } // Tizen::Net::Bluetooth