dd2b8e461437be09dc7bf16030cf732efde4c4d9
[platform/framework/native/bluetooth.git] / inc / FNetBtBluetoothSppInitiator.h
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
18 /**
19  * @file    FNetBtBluetoothSppInitiator.h
20  * @brief   This is the header file for the %BluetoothSppInitiator class.
21  *
22  * This header file contains the declarations of the %BluetoothSppInitiator class.
23  */
24 #ifndef _FNET_BT_BLUETOOTH_SPP_INITIATOR_H_
25 #define _FNET_BT_BLUETOOTH_SPP_INITIATOR_H_
26
27 #include <FBaseObject.h>
28 #include <FBaseResult.h>
29 #include <FBaseUuId.h>
30 #include <FNetBtBluetoothTypes.h>
31
32 namespace Tizen { namespace Base
33 {
34 class ByteBuffer;
35 } }
36
37 namespace Tizen { namespace Net { namespace Bluetooth
38 {
39
40 // forward declarations
41 class BluetoothDevice;
42 class IBluetoothSppInitiatorEventListener;
43 class _BluetoothSppInitiatorImpl;
44
45 /**
46  * @class   BluetoothSppInitiator
47  * @brief   This class provides the methods to handle the %Bluetooth Serial Port Profile (SPP) initiator, such as the
48  *          outgoing connection requests.
49  * @since   2.0
50  *
51  * The %BluetoothSppInitiator class provides the methods to handle the %Bluetooth Serial Port Profile (SPP) initiator, such as
52  * the outgoing connection requests.
53  *
54  * For more information on the class features, see
55  * <a href="../org.tizen.native.appprogramming/html/guide/net/bluetooth_namespace.htm">Bluetooth Guide</a>.
56  */
57 class _OSP_EXPORT_ BluetoothSppInitiator
58         : public Tizen::Base::Object
59 {
60 public:
61         /**
62          * The object is not fully constructed after this constructor is called. For full construction, the Construct()
63          * method must be called right after calling this constructor.
64          *
65          * @since       2.0
66          */
67         BluetoothSppInitiator(void);
68
69         /**
70          * This destructor overrides Tizen::Base::Object::~Object().
71          *
72          * @since       2.0
73          */
74         virtual ~BluetoothSppInitiator(void);
75
76         /**
77          * Constructs and initializes this instance of %BluetoothSppInitiator with the specified listener.
78          *
79          * @since       2.0
80          * @feature     %http://tizen.org/feature/network.bluetooth
81          *
82          * @return      An error code
83          * @param[in]   listener                The event listener for the SPP initiator
84          * @exception   E_SUCCESS               The method is successful.
85          * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
86          * @exception   E_UNSUPPORTED_OPERATION The Emulator or target device does not support the required feature.
87          *                                      For more information, see
88          *                                      <a href=”../org.tizen.gettingstarted/html/tizen_overview/application_filtering.htm”>
89          *                                      Application Filtering</a>.
90          * @exception   E_SYSTEM                A system error has occurred.
91          * @remarks     Before calling this method, check whether the feature is supported by %Tizen::System::SystemInfo::GetValue()
92          *              methods.
93          */
94         result Construct(IBluetoothSppInitiatorEventListener& listener);
95
96         /**
97          * Connects to a remote SPP acceptor with the default service UUID - BT_SVC_UUID_SPP. @n
98          * This method establishes a connection after the SPP acceptor accepts the request.
99          *
100          * @since       2.0
101          * @privlevel   public
102          * @privilege   %http://tizen.org/privilege/bluetooth.spp
103          *
104          * @return      An error code
105          * @param[in]   remoteDevice                The remote device to connect
106          * @exception   E_SUCCESS                   The method is successful.
107          * @exception   E_INVALID_STATE             This instance is in an invalid state. @n
108          *                                          For example, this instance has not been constructed as yet or
109          *                                          %Bluetooth is not activated.
110          * @exception   E_IN_PROGRESS               The connection process is in progress.
111          * @exception   E_ALREADY_CONNECTED         The connection with an SPP acceptor has already been established.
112          * @exception   E_PRIVILEGE_DENIED          The application does not have the privilege to call this method.
113          * @exception   E_SERVICE_UNAVAILABLE       The SPP connection is unavailable.
114          * @exception   E_REMOTE_DEVICE_NOT_FOUND   The input device is not found. @n
115          *                                          This exception is currently not in use.
116          * @exception   E_FAILURE                   The method has failed.
117          * @see         IBluetoothSppAcceptorEventListener::OnSppConnectionRequested()
118          * @remarks     If the local device is not paired with the specified target device, the pairing process starts
119          *              internally before the connect request is sent.
120          */
121         result Connect(const BluetoothDevice& remoteDevice);
122
123         /**
124          * Connects to a remote SPP acceptor with the specified service UUID. @n
125          * This method establishes a connection after the SPP acceptor accepts the request.
126          *
127          * @since 2.0
128          * @privlevel   public
129          * @privilege   %http://tizen.org/privilege/bluetooth.spp
130          *
131          * @return      An error code
132          * @param[in]   remoteDevice                The remote device to connect
133          * @param[in]   serviceUuid                 The UUID of SPP service to connect
134          * @exception   E_SUCCESS                   The method is successful.
135          * @exception   E_INVALID_STATE             This instance is in an invalid state. @n
136          *                                          For example, this instance has not been constructed as yet or
137          *                                          %Bluetooth is not activated.
138          * @exception   E_INVALID_ARG               A specified input parameter is invalid.
139          * @exception   E_IN_PROGRESS               The connection process is in progress.
140          * @exception   E_ALREADY_CONNECTED         The connection with an SPP acceptor has already been established.
141          * @exception   E_PRIVILEGE_DENIED          The application does not have the privilege to call this method.
142          * @exception   E_SERVICE_UNAVAILABLE       The SPP connection is unavailable.
143          * @exception   E_REMOTE_DEVICE_NOT_FOUND   The input device is not found. @n
144          *                                          This exception is currently not in use.
145          * @exception   E_FAILURE                   The method has failed.
146          * @see         IBluetoothSppAcceptorEventListener::OnSppConnectionRequested()
147          * @remarks     If the local device is not paired with the specified target device, the pairing process starts
148          *              internally before the connect request is sent.
149          */
150         result Connect(const BluetoothDevice& remoteDevice, const Tizen::Base::UuId& serviceUuid);
151
152         /**
153          * Disconnects the current connection. @n
154          * If this method is called before the SPP acceptor accepts the connection request, the
155          * IBluetoothSppInitiatorEventListener::OnSppConnectionResponded() and its result @c E_SYSTEM is thrown. @n
156          * If this method is called on connection, the IBluetoothSppInitiatorEventListener::OnSppDisconnected() and
157          * its result @c E_SUCCESS is thrown.
158          *
159          * @since       2.0
160          * @privlevel   public
161          * @privilege   %http://tizen.org/privilege/bluetooth.spp
162          *
163          * @return      An error code
164          * @exception   E_SUCCESS               The method is successful.
165          * @exception   E_INVALID_STATE         This instance is in an invalid state. @n
166          *                                      For example, this instance has not been constructed as yet or %Bluetooth is
167          *                                      not activated.
168          * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified
169          *                                      operation. @n
170          *                                      For example, the connection request is not sent or a connection with a
171          *                                      remote device is not established yet.
172          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
173          * @exception   E_FAILURE               The method has failed.
174          * @see         IBluetoothSppAcceptorEventListener::OnSppDisconnected()
175          */
176         result Disconnect(void);
177
178         /**
179          * Sends the specified data.
180          *
181          * @since       2.0
182          * @privlevel   public
183          * @privilege   %http://tizen.org/privilege/bluetooth.spp
184          *
185          * @return      An error code
186          * @param[in]   buffer                  The data to send. @n
187          *                                      The size of the buffer should not exceed @c 1000 bytes.
188          * @exception   E_SUCCESS               The method is successful.
189          * @exception   E_INVALID_STATE         This instance is in an invalid state. @n
190          *                                      For example, this instance has not been constructed as yet or %Bluetooth is
191          *                                      not activated.
192          * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified
193          *                                      operation. @n
194          *                                      For example, the connection request is not sent or a connection with a
195          *                                      remote device is not established yet.
196          * @exception   E_INVALID_ARG           The argument has no data.
197          * @exception   E_SYSTEM                A system error has occurred.
198          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
199          * @exception   E_FAILURE               The method has failed.
200          * @see         IBluetoothSppAcceptorEventListener::OnSppDataReceived()
201          */
202         result SendData(const Tizen::Base::ByteBuffer& buffer);
203
204 private:
205         //
206         // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying
207         // of objects.
208         //
209         BluetoothSppInitiator(const BluetoothSppInitiator& value);
210         //
211         // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit
212         // copying of objects.
213         //
214         BluetoothSppInitiator& operator =(const BluetoothSppInitiator& value);
215
216 private:
217         _BluetoothSppInitiatorImpl* __pImpl;
218
219 }; // BluetoothSppInitiator
220
221 } } }
222 #endif // _FNET_BT_BLUETOOTH_SPP_INITIATOR_H_