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 <boost/shared_ptr.hpp>
22 :
23 : #include <osl/mutex.hxx>
24 : #include <osl/socket.hxx>
25 : #include <rtl/ref.hxx>
26 : #include <salhelper/thread.hxx>
27 :
28 : #include <com/sun/star/presentation/XSlideShowController.hpp>
29 :
30 : #include "sddllapi.h"
31 :
32 : /**
33 : * The port for use for the main communication between LibO and remote control app.
34 : */
35 : #define PORT 1599
36 :
37 : #define CHARSET RTL_TEXTENCODING_UTF8
38 :
39 : namespace sd
40 : {
41 : class Communicator;
42 : class BufferedStreamSocket;
43 :
44 : struct ClientInfo
45 : {
46 : OUString mName;
47 : OUString mAddress;
48 :
49 : bool mbIsAlreadyAuthorised;
50 :
51 : enum PROTOCOL { NETWORK = 1, BLUETOOTH };
52 0 : ClientInfo( const OUString& rName,
53 : const OUString& rAddress,
54 : const bool bIsAlreadyAuthorised ) :
55 : mName( rName ),
56 : mAddress( rAddress ),
57 0 : mbIsAlreadyAuthorised( bIsAlreadyAuthorised ) {}
58 :
59 0 : virtual ~ClientInfo() {};
60 : };
61 :
62 : struct ClientInfoInternal;
63 :
64 : class RemoteServer : public salhelper::Thread
65 : {
66 : public:
67 : // Internal setup
68 : static void setup();
69 :
70 : // For slideshowimpl to inform us.
71 : static void presentationStarted( const css::uno::Reference<
72 : css::presentation::XSlideShowController > &rController );
73 : static void presentationStopped();
74 :
75 : // For the control dialog
76 : SD_DLLPUBLIC static std::vector< ::boost::shared_ptr< ClientInfo > > getClients();
77 : SD_DLLPUBLIC static bool connectClient( ::boost::shared_ptr< ClientInfo > pClient,
78 : const OUString& aPin );
79 : SD_DLLPUBLIC static void deauthoriseClient( ::boost::shared_ptr< ClientInfo > pClient );
80 :
81 : /// ensure that discoverability (eg. for Bluetooth) is enabled
82 : SD_DLLPUBLIC static void ensureDiscoverable();
83 : /// restore the state of discoverability from before ensureDiscoverable
84 : SD_DLLPUBLIC static void restoreDiscoverable();
85 :
86 : // For the communicator
87 : static void removeCommunicator( Communicator* pCommunicator );
88 : private:
89 : RemoteServer();
90 : virtual ~RemoteServer();
91 : static RemoteServer *spServer;
92 : static ::osl::Mutex sDataMutex;
93 : static ::std::vector<Communicator*> sCommunicators;
94 : osl::AcceptorSocket mSocket;
95 :
96 : ::std::vector< ::boost::shared_ptr< ClientInfoInternal > > mAvailableClients;
97 :
98 : void execute() SAL_OVERRIDE;
99 : };
100 : }
101 :
102 : #endif // INCLUDED_SD_SOURCE_UI_INC_REMOTESERVER_HXX
103 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|