2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
17 // @file FNetBtBluetoothOppClient.cpp
18 // @brief This is the implementation file for the BluetoothOppClient class.
21 #include <FNetBtBluetoothOppClient.h>
22 #include <FNetBtBluetoothDevice.h>
23 #include <FNetBtIBluetoothOppClientEventListener.h>
24 #include <FBaseString.h>
25 #include <FBaseSysLog.h>
26 #include <FSec_AccessController.h>
27 #include <FSys_SystemInfoImpl.h>
28 #include "FNetBt_BluetoothOppClientImpl.h"
30 using namespace Tizen::Security;
32 namespace Tizen { namespace Net { namespace Bluetooth
35 BluetoothOppClient::BluetoothOppClient(void)
40 BluetoothOppClient::~BluetoothOppClient(void)
46 BluetoothOppClient::Construct(IBluetoothOppClientEventListener& listener)
49 bool isBtSupported = false;
51 Tizen::System::_SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/network.bluetooth", isBtSupported);
52 SysTryReturnResult(NID_NET_BT, isBtSupported == true, E_UNSUPPORTED_OPERATION, "Bluetooth is not supported.");
54 SysAssertf(__pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
56 __pImpl = new (std::nothrow) _BluetoothOppClientImpl;
58 SysTryReturnResult(NID_NET_BT, __pImpl != null, E_OUT_OF_MEMORY, "Creation of a _BluetoothOppClientImpl instance failed.");
60 r = __pImpl->Construct(listener);
73 BluetoothOppClient::PushFile(const BluetoothDevice& remoteDevice, const Base::String& filePath)
78 r = _AccessController::CheckUserPrivilege(_PRV_BLUETOOTH_OPP);
79 SysTryReturnResult(NID_NET_BT, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
82 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
84 return __pImpl->PushFile(remoteDevice, filePath);
88 BluetoothOppClient::CancelPush(void)
93 r = _AccessController::CheckUserPrivilege(_PRV_BLUETOOTH_OPP);
94 SysTryReturnResult(NID_NET_BT, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
97 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
99 return __pImpl->CancelPush();
103 BluetoothOppClient::SetMinProgressInterval(int percent)
106 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
108 return __pImpl->SetMinProgressInterval(percent);
111 } } } // Tizen::Net::Bluetooth