LibreOffice Module sd (master) 1
RemoteServer.hxx
Go to the documentation of this file.
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#pragma once
10
11#include <memory>
12#include <utility>
13#include <vector>
14
15#include <osl/socket_decl.hxx>
16#include <salhelper/thread.hxx>
17
18#include <sddllapi.h>
19
20namespace osl { class Mutex; }
21namespace com::sun::star::presentation { class XSlideShowController; }
22namespace com::sun::star::uno { template <class interface_type> class Reference; }
23
27#define PORT 1599
28
29namespace sd
30{
31 class BufferedStreamSocket;
32 class Communicator;
33
35 {
36 OUString mName;
37
39
40 ClientInfo( OUString aName,
41 const bool bIsAlreadyAuthorised ) :
42 mName(std::move( aName )),
43 mbIsAlreadyAuthorised( bIsAlreadyAuthorised ) {}
44
45 virtual ~ClientInfo() {};
46 };
47
48 struct ClientInfoInternal;
49
50 class RemoteServer final : public salhelper::Thread
51 {
52 public:
53 // Internal setup
54 static void setup();
55
56 // For slideshowimpl to inform us.
57 static void presentationStarted( const css::uno::Reference<
58 css::presentation::XSlideShowController > &rController );
59 static void presentationStopped();
60
61 // For the control dialog
62 SD_DLLPUBLIC static std::vector< std::shared_ptr< ClientInfo > > getClients();
63 SD_DLLPUBLIC static bool connectClient( const std::shared_ptr< ClientInfo >& pClient,
64 std::u16string_view aPin );
65 SD_DLLPUBLIC static void deauthoriseClient( const std::shared_ptr< ClientInfo >& pClient );
66
68 SD_DLLPUBLIC static void ensureDiscoverable();
71
72 // For the communicator
73 static void removeCommunicator( Communicator const * pCommunicator );
74 private:
76 virtual ~RemoteServer() override;
78 static ::osl::Mutex sDataMutex;
79 static ::std::vector<Communicator*> sCommunicators;
80 osl::AcceptorSocket mSocket;
81
82 ::std::vector< std::shared_ptr< ClientInfoInternal > > mAvailableClients;
83
84 void execute() override;
86 };
87}
88
89/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
[A wrapper for an osl StreamSocket to allow reading lines.
Class used for communication with one single client, dealing with all tasks specific to this client.
static SD_DLLPUBLIC bool connectClient(const std::shared_ptr< ClientInfo > &pClient, std::u16string_view aPin)
Definition: Server.cxx:259
static void setup()
Definition: Server.cxx:182
static RemoteServer * spServer
void handleAcceptedConnection(BufferedStreamSocket *pSocket)
Definition: Server.cxx:110
static SD_DLLPUBLIC void restoreDiscoverable()
restore the state of discoverability from before ensureDiscoverable
Definition: Server.cxx:368
::osl::Mutex sDataMutex
static void presentationStopped()
Definition: Server.cxx:206
osl::AcceptorSocket mSocket
static ::std::vector< Communicator * > sCommunicators
static SD_DLLPUBLIC std::vector< std::shared_ptr< ClientInfo > > getClients()
Definition: Server.cxx:227
void execute() override
Definition: Server.cxx:76
static SD_DLLPUBLIC void deauthoriseClient(const std::shared_ptr< ClientInfo > &pClient)
Definition: Server.cxx:312
::std::vector< std::shared_ptr< ClientInfoInternal > > mAvailableClients
static void removeCommunicator(Communicator const *pCommunicator)
Definition: Server.cxx:217
virtual ~RemoteServer() override
Definition: Server.cxx:72
static SD_DLLPUBLIC void ensureDiscoverable()
ensure that discoverability (eg. for Bluetooth) is enabled
Definition: Server.cxx:359
static void presentationStarted(const css::uno::Reference< css::presentation::XSlideShowController > &rController)
Definition: Server.cxx:195
OUString aName
Reference
#define SD_DLLPUBLIC
Definition: sddllapi.h:27
bool mbIsAlreadyAuthorised
virtual ~ClientInfo()
ClientInfo(OUString aName, const bool bIsAlreadyAuthorised)