update the header for Doxygen
[platform/framework/native/bluetooth.git] / src / FNetBtBluetoothOppClient.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17 // @file    FNetBtBluetoothOppClient.cpp
18 // @brief   This is the implementation file for the BluetoothOppClient class.
19 //
20
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"
29
30 using namespace Tizen::Security;
31
32 namespace Tizen { namespace Net { namespace Bluetooth
33 {
34
35 BluetoothOppClient::BluetoothOppClient(void)
36         : __pImpl(null)
37 {
38 }
39
40 BluetoothOppClient::~BluetoothOppClient(void)
41 {
42         delete __pImpl;
43 }
44
45 result
46 BluetoothOppClient::Construct(IBluetoothOppClientEventListener& listener)
47 {
48         result r = E_SUCCESS;
49         bool isBtSupported = false;
50
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.");
53
54         SysAssertf(__pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
55
56         __pImpl = new (std::nothrow) _BluetoothOppClientImpl;
57
58         SysTryReturnResult(NID_NET_BT, __pImpl != null, E_OUT_OF_MEMORY, "Creation of a _BluetoothOppClientImpl instance failed.");
59
60         r = __pImpl->Construct(listener);
61
62         if (r != E_SUCCESS)
63         {
64                 delete __pImpl;
65                 __pImpl = null;
66         }
67
68         return r;
69 }
70
71
72 result
73 BluetoothOppClient::PushFile(const BluetoothDevice& remoteDevice, const Base::String& filePath)
74 {
75         result r = E_SUCCESS;
76
77         // Privilege check
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.");
80
81         // Check Construct
82         SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
83
84         return __pImpl->PushFile(remoteDevice, filePath);
85 }
86
87 result
88 BluetoothOppClient::CancelPush(void)
89 {
90         result r = E_SUCCESS;
91
92         // Privilege check
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.");
95
96         // Check Construct
97         SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
98
99         return __pImpl->CancelPush();
100 }
101
102 result
103 BluetoothOppClient::SetMinProgressInterval(int percent)
104 {
105         // Check Construct
106         SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
107
108         return __pImpl->SetMinProgressInterval(percent);
109 }
110
111 } } } // Tizen::Net::Bluetooth