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 INCLUDED_SD_SOURCE_UI_INC_REMOTESERVER_HXX
10 : #define INCLUDED_SD_SOURCE_UI_INC_REMOTESERVER_HXX
11 :
12 : // SERVER
13 : #include <stdio.h>
14 : #include <stdlib.h>
15 : #ifndef _WIN32
16 : #include <unistd.h>
17 : #endif
18 : #include <sys/types.h>
19 : #include <vector>
20 :
21 : #include <osl/mutex.hxx>
22 : #include <osl/socket.hxx>
23 : #include <rtl/ref.hxx>
24 : #include <salhelper/thread.hxx>
25 :
26 : #include <com/sun/star/presentation/XSlideShowController.hpp>
27 :
28 : #include "sddllapi.h"
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 :
37 : namespace sd
38 : {
39 : class Communicator;
40 : class BufferedStreamSocket;
41 :
42 : struct ClientInfo
43 : {
44 : OUString mName;
45 : OUString mAddress;
46 :
47 : enum PROTOCOL { NETWORK = 1, BLUETOOTH };
48 0 : ClientInfo( const OUString& rName, const OUString& rAddress ) :
49 : mName( rName ),
50 0 : mAddress( rAddress ) {}
51 : };
52 :
53 : struct ClientInfoInternal;
54 :
55 : class RemoteServer : public salhelper::Thread
56 : {
57 : public:
58 : // Internal setup
59 : static void setup();
60 :
61 : // For slideshowimpl to inform us.
62 : static void presentationStarted( const css::uno::Reference<
63 : css::presentation::XSlideShowController > &rController );
64 : static void presentationStopped();
65 :
66 : // For the control dialog
67 : SD_DLLPUBLIC static std::vector<ClientInfo*> getClients();
68 : SD_DLLPUBLIC static sal_Bool connectClient( ClientInfo *pClient,
69 : const OUString& aPin );
70 :
71 : /// ensure that discoverability (eg. for Bluetooth) is enabled
72 : SD_DLLPUBLIC static void ensureDiscoverable();
73 : /// restore the state of discoverability from before ensureDiscoverable
74 : SD_DLLPUBLIC static void restoreDiscoverable();
75 :
76 : // For the communicator
77 : static void removeCommunicator( Communicator* pCommunicator );
78 : private:
79 : RemoteServer();
80 : virtual ~RemoteServer();
81 : static RemoteServer *spServer;
82 : static ::osl::Mutex sDataMutex;
83 : static ::std::vector<Communicator*> sCommunicators;
84 : osl::AcceptorSocket mSocket;
85 :
86 : ::std::vector<ClientInfoInternal*> mAvailableClients;
87 :
88 : void execute() SAL_OVERRIDE;
89 : };
90 : }
91 :
92 : #endif // INCLUDED_SD_SOURCE_UI_INC_REMOTESERVER_HXX
93 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|