1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 #ifndef INCLUDED_SD_SOURCE_UI_REMOTECONTROL_BUFFEREDSTREAMSOCKET_HXX
10 #define INCLUDED_SD_SOURCE_UI_REMOTECONTROL_BUFFEREDSTREAMSOCKET_HXX
12 #include "IBluetoothSocket.hxx"
13 #include <osl/socket.hxx>
16 #define CHARSET RTL_TEXTENCODING_UTF8
17 #define MAX_LINE_LENGTH 20000
23 * [A wrapper for an osl StreamSocket to allow reading lines.]
25 * Currently wraps either an osl StreamSocket or a standard c socket,
26 * allowing reading and writing for our purposes. Should eventually be
27 * returned to being a StreamSocket wrapper if/when Bluetooth is
28 * integrated into osl Sockets.
30 class BufferedStreamSocket
:
31 public IBluetoothSocket
,
32 private ::osl::StreamSocket
36 * Create a BufferedStreamSocket on top of an
39 BufferedStreamSocket( const osl::StreamSocket
&aSocket
);
41 * Create a BufferedStreamSocket on top of a POSIX or WinSock socket.
43 BufferedStreamSocket( int aSocket
);
44 BufferedStreamSocket( const BufferedStreamSocket
&aSocket
);
46 * Blocks until a line is read.
47 * Returns whatever the last call of recv returned, i.e. 0 or less
48 * if there was a problem in communications.
50 virtual sal_Int32
readLine( OString
& aLine
) SAL_OVERRIDE
;
52 virtual sal_Int32
write( const void* pBuffer
, sal_uInt32 n
) SAL_OVERRIDE
;
54 virtual void close() SAL_OVERRIDE
;
56 void getPeerAddr(osl::SocketAddr
&);
58 sal_Int32 aRet
, aRead
;
59 std::vector
<char> aBuffer
;
65 #endif // INCLUDED_SD_SOURCE_UI_REMOTECONTROL_BUFFEREDSTREAMSOCKET_HXX
66 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */