Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : */
9 : : #ifndef _SD_IMPRESSREMOTE_BUFFEREDSTREAMSOCKET_HXX
10 : : #define _SD_IMPRESSREMOTE_BUFFEREDSTREAMSOCKET_HXX
11 : :
12 : : #include <boost/noncopyable.hpp>
13 : : #include <osl/socket.hxx>
14 : : #include <vector>
15 : :
16 : : #define CHARSET RTL_TEXTENCODING_UTF8
17 : : #define MAX_LINE_LENGTH 20000
18 : :
19 : : namespace sd
20 : : {
21 : :
22 : : /**
23 : : * [A wrapper for an osl StreamSocket to allow reading lines.]
24 : : *
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.
29 : : */
30 : 0 : class BufferedStreamSocket :
31 : : private ::osl::StreamSocket,
32 : : private ::boost::noncopyable
33 : : {
34 : : public:
35 : : /**
36 : : * Create a BufferedStreamSocket on top of an
37 : : * osl::StreamSocket.
38 : : */
39 : : BufferedStreamSocket( const osl::StreamSocket &aSocket );
40 : : /**
41 : : * Create a BufferedStreamSocket on top of a standard c socket.
42 : : */
43 : : BufferedStreamSocket( int aSocket );
44 : : BufferedStreamSocket( const BufferedStreamSocket &aSocket );
45 : : /**
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.
49 : : */
50 : : sal_Int32 readLine(OString& aLine);
51 : :
52 : : sal_Int32 write( const void* pBuffer, sal_uInt32 n );
53 : :
54 : : void getPeerAddr(osl::SocketAddr&);
55 : : private:
56 : : sal_Int32 aRet, aRead;
57 : : std::vector<char> aBuffer;
58 : : int mSocket;
59 : : bool usingCSocket;
60 : : };
61 : : }
62 : :
63 : : #endif // _SD_IMPRESSREMOTE_BUFFEREDSTREAMSOCKET_HXX
64 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|