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 FNetBtBluetoothOppServer.cpp
18 // @brief This is the implementation file for the BluetoothOppServer class.
21 #include <FBaseString.h>
22 #include <FNetBtBluetoothOppServer.h>
23 #include <FNetBtIBluetoothOppServerEventListener.h>
24 #include <FBaseSysLog.h>
25 #include <FSec_AccessController.h>
26 #include <FSys_SystemInfoImpl.h>
27 #include "FNetBt_BluetoothOppServerImpl.h"
29 using namespace Tizen::Security;
31 namespace Tizen { namespace Net { namespace Bluetooth
34 BluetoothOppServer::BluetoothOppServer(void)
39 BluetoothOppServer::~BluetoothOppServer(void)
45 BluetoothOppServer::Construct(IBluetoothOppServerEventListener& listener)
48 bool isBtSupported = false;
50 Tizen::System::_SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/network.bluetooth", isBtSupported);
51 SysTryReturnResult(NID_NET_BT, isBtSupported == true, E_UNSUPPORTED_OPERATION, "Bluetooth is not supported.");
53 SysAssertf(__pImpl == null,
54 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
56 __pImpl = new (std::nothrow) _BluetoothOppServerImpl;
57 SysTryReturnResult(NID_NET_BT, __pImpl != null, E_OUT_OF_MEMORY, "Creation of a _BluetoothOppServerImpl instance failed.");
59 r = __pImpl->Construct(listener);
71 BluetoothOppServer::AcceptPush(void)
76 r = _AccessController::CheckUserPrivilege(_PRV_BLUETOOTH_OPP);
77 SysTryReturnResult(NID_NET_BT, r == E_SUCCESS, E_PRIVILEGE_DENIED,
78 "The application does not have the privilege to call this method.");
81 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
83 return __pImpl->AcceptPush();
87 BluetoothOppServer::RejectPush(void)
92 r = _AccessController::CheckUserPrivilege(_PRV_BLUETOOTH_OPP);
93 SysTryReturnResult(NID_NET_BT, r == E_SUCCESS, E_PRIVILEGE_DENIED,
94 "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->RejectPush();
103 BluetoothOppServer::SetDestinationPath(const Tizen::Base::String& dstPath)
106 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
108 return __pImpl->SetDestinationPath(dstPath);
112 BluetoothOppServer::SetMinProgressInterval(int percent)
115 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
117 return __pImpl->SetMinProgressInterval(percent);
121 BluetoothOppServer::StartService(const Tizen::Base::String& dstPath)
123 result r = E_SUCCESS;
126 r = _AccessController::CheckUserPrivilege(_PRV_BLUETOOTH_OPP);
127 SysTryReturnResult(NID_NET_BT, r == E_SUCCESS, E_PRIVILEGE_DENIED,
128 "The application does not have the privilege to call this method.");
131 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
133 return __pImpl->StartService(dstPath);
137 BluetoothOppServer::StopService(void)
139 result r = E_SUCCESS;
142 r = _AccessController::CheckUserPrivilege(_PRV_BLUETOOTH_OPP);
143 SysTryReturnResult(NID_NET_BT, r == E_SUCCESS, E_PRIVILEGE_DENIED,
144 "The application does not have the privilege to call this method.");
147 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
149 return __pImpl->StopService();
153 BluetoothOppServer::StopTransfer(void)
155 result r = E_SUCCESS;
158 r = _AccessController::CheckUserPrivilege(_PRV_BLUETOOTH_OPP);
159 SysTryReturnResult(NID_NET_BT, r == E_SUCCESS, E_PRIVILEGE_DENIED,
160 "The application does not have the privilege to call this method.");
163 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
165 return __pImpl->StopTransfer();
168 } } } // Tizen::Net::Bluetooth