LibreOffice Module sd (master) 1
RemoteDialogClientBox.cxx
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 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <utility>
21#include <vector>
22
24#include <RemoteServer.hxx>
25
26#include <vcl/svapp.hxx>
27
28namespace sd {
29
30// struct ClientBoxEntry
31
33 std::shared_ptr<ClientInfo> pClientInfo)
34 : m_xBuilder(Application::CreateBuilder(pClientBox->GetContainer(), "modules/simpress/ui/clientboxfragment.ui"))
35 , m_xContainer(m_xBuilder->weld_container("ClientboxFragment"))
36 , m_xDeviceName(m_xBuilder->weld_label("name"))
37 , m_xPinLabel(m_xBuilder->weld_label("pinlabel"))
38 , m_xPinBox(m_xBuilder->weld_entry("pin"))
39 , m_xDeauthoriseButton(m_xBuilder->weld_button("button"))
40 , m_xClientInfo(std::move(pClientInfo))
41 , m_pClientBox(pClientBox)
42{
43 m_xDeviceName->set_label(m_xClientInfo->mName);
44 m_xDeauthoriseButton->connect_clicked(LINK(this, ClientBoxEntry, DeauthoriseHdl));
45 m_xDeauthoriseButton->set_visible(m_xClientInfo->mbIsAlreadyAuthorised);
46 m_xPinBox->set_visible(!m_xClientInfo->mbIsAlreadyAuthorised);
47 m_xPinLabel->set_visible(!m_xClientInfo->mbIsAlreadyAuthorised);
48
49 m_xDeauthoriseButton->connect_focus_in(LINK(this, ClientBoxEntry, FocusHdl));
50 m_xPinBox->connect_focus_in(LINK(this, ClientBoxEntry, FocusHdl));
51}
52
54{
55 m_pClientBox->GetContainer()->move(m_xContainer.get(), nullptr);
56}
57
58// ClientBox
59ClientBox::ClientBox(std::unique_ptr<weld::ScrolledWindow> xScroll,
60 std::unique_ptr<weld::Container> xContents)
61 : m_xScroll(std::move(xScroll))
62 , m_xContents(std::move(xContents))
63 , m_pActive(nullptr)
64{
65 Size aSize(m_xScroll->get_approximate_digit_width() * 40,
66 m_xScroll->get_text_height() * 16);
67 m_xScroll->set_size_request(aSize.Width(), aSize.Height());
68
69 m_xContents->set_stack_background();
70
72}
73
75{
76}
77
79{
80 return m_pActive;
81}
82
83void ClientBox::addEntry( const std::shared_ptr<ClientInfo>& pClientInfo )
84{
85 TClientBoxEntry xEntry = std::make_shared<ClientBoxEntry>(this, pClientInfo);
86 m_vEntries.push_back(xEntry);
87}
88
90{
91 m_pActive = pClientEntry;
92}
93
95{
96 m_vEntries.clear();
97 m_pActive = nullptr;
98}
99
101{
102 clearEntries();
103
104#ifdef ENABLE_SDREMOTE
106
107 std::vector< std::shared_ptr< ClientInfo > > aClients( RemoteServer::getClients() );
108
109 for ( const auto& rxClient : aClients )
110 {
111 addEntry( rxClient );
112 }
113#endif
114
115}
116
118{
119#ifdef ENABLE_SDREMOTE
120 RemoteServer::deauthoriseClient(m_xClientInfo);
121#endif
122 m_pClientBox->populateEntries();
123}
124
126{
127 if (ClientBoxEntry* pOldEntry = m_pClientBox->GetActiveEntry())
128 pOldEntry->m_xContainer->set_stack_background();
129 m_pClientBox->setActive(this);
130 m_xContainer->set_highlight_background();
131}
132
133} //namespace sd
134
135/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void addEntry(const std::shared_ptr< ClientInfo > &pClientInfo)
std::unique_ptr< weld::ScrolledWindow > m_xScroll
ClientBoxEntry * GetActiveEntry()
void setActive(ClientBoxEntry *pClientData)
ClientBoxEntry * m_pActive
ClientBox(std::unique_ptr< weld::ScrolledWindow > xScroll, std::unique_ptr< weld::Container > xContents)
weld::Container * GetContainer()
std::unique_ptr< weld::Container > m_xContents
std::vector< TClientBoxEntry > m_vEntries
static SD_DLLPUBLIC std::vector< std::shared_ptr< ClientInfo > > getClients()
Definition: Server.cxx:227
static SD_DLLPUBLIC void deauthoriseClient(const std::shared_ptr< ClientInfo > &pClient)
Definition: Server.cxx:312
static SD_DLLPUBLIC void ensureDiscoverable()
ensure that discoverability (eg. for Bluetooth) is enabled
Definition: Server.cxx:359
virtual void move(weld::Widget *pWidget, weld::Container *pNewParent)=0
IMPL_LINK_NOARG(MainSequence, onTimerHdl, Timer *, void)
std::shared_ptr< ClientBoxEntry > TClientBoxEntry
Reference< XNameAccess > m_xContainer
std::unique_ptr< weld::Button > m_xDeauthoriseButton
std::unique_ptr< weld::Container > m_xContainer
std::shared_ptr< ClientInfo > m_xClientInfo
ClientBoxEntry(ClientBox *pClientBox, std::shared_ptr< ClientInfo > pClientInfo)
std::unique_ptr< weld::Entry > m_xPinBox
std::unique_ptr< weld::Label > m_xPinLabel
std::unique_ptr< weld::Label > m_xDeviceName