Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sd/source/ui/inc/RemoteServer.hxx
Line
Count
Source
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
20
namespace osl { class Mutex; }
21
namespace com::sun::star::presentation { class XSlideShowController; }
22
namespace com::sun::star::uno { template <class interface_type> class Reference; }
23
24
/**
25
* The port for use for the main communication between LibO and remote control app.
26
*/
27
#define PORT 1599
28
29
namespace sd
30
{
31
    class BufferedStreamSocket;
32
    class Communicator;
33
34
    struct ClientInfo
35
    {
36
        OUString mName;
37
38
        bool mbIsAlreadyAuthorised;
39
40
        ClientInfo( OUString aName,
41
                    const bool bIsAlreadyAuthorised ) :
42
            mName(std::move( aName )),
43
0
            mbIsAlreadyAuthorised( bIsAlreadyAuthorised ) {}
44
45
0
        virtual ~ClientInfo() {};
46
    };
47
48
    struct ClientInfoInternal;
49
50
    class RemoteServer final
51
    {
52
        public:
53
            // For slideshowimpl to inform us.
54
            static void presentationStarted( const css::uno::Reference<
55
                css::presentation::XSlideShowController > &rController );
56
            static void presentationStopped();
57
58
            /// ensure that discoverability (eg. for Bluetooth) is enabled
59
            SD_DLLPUBLIC static void ensureDiscoverable();
60
            /// restore the state of discoverability from before ensureDiscoverable
61
            SD_DLLPUBLIC static void restoreDiscoverable();
62
63
            // For the communicator
64
            static void removeCommunicator( Communicator const * pCommunicator );
65
        //private:
66
            // these are public because 3 classes and a function need access
67
            static ::osl::Mutex sDataMutex;
68
            static ::std::vector<Communicator*> sCommunicators;
69
    };
70
71
    class IPRemoteServer final : public salhelper::Thread
72
    {
73
        public:
74
            // Internal setup
75
            static void setup();
76
77
            // For the control dialog
78
            SD_DLLPUBLIC static std::vector<std::shared_ptr<ClientInfo>> getClients();
79
            SD_DLLPUBLIC static bool connectClient(const std::shared_ptr<ClientInfo>& pClient,
80
                                                   std::u16string_view aPin);
81
            SD_DLLPUBLIC static void deauthoriseClient(const std::shared_ptr<ClientInfo>& pClient);
82
83
            void execute() override;
84
            void handleAcceptedConnection( BufferedStreamSocket *pSocket ) ;
85
86
        private:
87
            IPRemoteServer();
88
            virtual ~IPRemoteServer() override;
89
90
            osl::AcceptorSocket mSocket;
91
            ::std::vector<std::shared_ptr<ClientInfoInternal>> mAvailableClients;
92
93
            friend class RemoteServer;
94
            static IPRemoteServer *spServer;
95
    };
96
}
97
98
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */