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_SERVER_HXX
10 : : #define _SD_IMPRESSREMOTE_SERVER_HXX
11 : :
12 : : // SERVER
13 : : #include <stdio.h>
14 : : #include <stdlib.h>
15 : : #include <unistd.h>
16 : : #include <sys/types.h>
17 : : #include <vector>
18 : :
19 : : #include <osl/mutex.hxx>
20 : : #include <osl/socket.hxx>
21 : : #include <rtl/ref.hxx>
22 : : #include <salhelper/thread.hxx>
23 : :
24 : : #include <com/sun/star/presentation/XSlideShowController.hpp>
25 : :
26 : : #include "sddllapi.h"
27 : :
28 : : namespace css = ::com::sun::star;
29 : :
30 : : /**
31 : : * The port for use for the main communication between LibO and remote control app.
32 : : */
33 : : #define PORT 1599
34 : :
35 : : #define CHARSET RTL_TEXTENCODING_UTF8
36 : : namespace css = ::com::sun::star;
37 : :
38 : : namespace sd
39 : : {
40 : : class Communicator;
41 : : class BufferedStreamSocket;
42 : :
43 : : struct ClientInfo
44 : : {
45 : : rtl::OUString mName;
46 : : rtl::OUString mAddress;
47 : :
48 : : enum PROTOCOL { NETWORK = 1, BLUETOOTH };
49 : 0 : ClientInfo( const rtl::OUString rName, const rtl::OUString rAddress ) :
50 : : mName( rName ),
51 : 0 : mAddress( rAddress ) {}
52 : : };
53 : :
54 : : struct ClientInfoInternal:
55 : : ClientInfo
56 : : {
57 : : BufferedStreamSocket *mpStreamSocket;
58 : : rtl::OUString mPin;
59 : :
60 : 0 : ClientInfoInternal( const rtl::OUString rName,
61 : : const rtl::OUString rAddress,
62 : : BufferedStreamSocket *pSocket, rtl::OUString rPin ):
63 : : ClientInfo( rName, rAddress ),
64 : : mpStreamSocket( pSocket ),
65 : 0 : mPin( rPin ) {}
66 : : };
67 : :
68 : : class RemoteServer : public salhelper::Thread
69 : : {
70 : : public:
71 : : // Internal setup
72 : : static void setup();
73 : :
74 : : // For slideshowimpl to inform us.
75 : : static void presentationStarted( const css::uno::Reference<
76 : : css::presentation::XSlideShowController > &rController );
77 : : static void presentationStopped();
78 : :
79 : : // For the control dialog
80 : : SD_DLLPUBLIC static std::vector<ClientInfo*> getClients();
81 : : SD_DLLPUBLIC static sal_Bool connectClient( ClientInfo *pClient,
82 : : rtl::OUString aPin );
83 : :
84 : : // For the communicator
85 : : static void removeCommunicator( Communicator* pCommunicator );
86 : : private:
87 : : RemoteServer();
88 : : ~RemoteServer();
89 : : static RemoteServer *spServer;
90 : : osl::AcceptorSocket mSocket;
91 : :
92 : : ::osl::Mutex mDataMutex;
93 : : ::std::vector<Communicator*> mCommunicators;
94 : : ::std::vector<ClientInfoInternal*> mAvailableClients;
95 : :
96 : : void execute();
97 : : };
98 : : }
99 : :
100 : : #endif // _SD_IMPRESSREMOTE_SERVER_HXX
101 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|