do
{ // Read off any additional non-empty lines // We know that we at least have the empty termination line to read. if ( ! pSocket->readLine( aLine ) ) { delete pSocket; return;
}
} while ( aLine.getLength() > 0 );
// Check if we already have this server.
Reference< XNameAccess > const xConfig = officecfg::Office::Impress::Misc::AuthorisedRemotes::get(); const Sequence< OUString > aNames = xConfig->getElementNames(); for ( constauto& rName : aNames )
{ if ( rName == pClient->mName )
{
Reference<XNameAccess> xSetItem( xConfig->getByName(rName), UNO_QUERY );
Any axPin(xSetItem->getByName(u"PIN"_ustr));
OUString sPin;
axPin >>= sPin;
if ( sPin == pClient->mPin ) {
SAL_INFO( "sdremote", "client found on validated list -- connecting" );
connectClient( pClient, sPin ); return;
}
}
}
// Pin not found so inform the client.
SAL_INFO( "sdremote", "client not found on validated list" );
pSocket->write( "LO_SERVER_VALIDATING_PIN\n\n",
strlen( "LO_SERVER_VALIDATING_PIN\n\n" ) );
}
void IPRemoteServer::setup()
{ if (spServer) return;
spServer = new IPRemoteServer();
spServer->launch();
}
void RemoteServer::presentationStarted( const css::uno::Reference<
css::presentation::XSlideShowController > &rController )
{ // note this can be invoked even when there is no IPRemoteServer instance // but there are communicators belonging to a BluetoothServer
MutexGuard aGuard( sDataMutex ); for ( constauto& rpCommunicator : sCommunicators )
{
rpCommunicator->presentationStarted( rController );
}
} void RemoteServer::presentationStopped()
{
MutexGuard aGuard( sDataMutex ); for ( constauto& rpCommunicator : sCommunicators )
{
rpCommunicator->disposeListener();
}
}
void RemoteServer::removeCommunicator( Communicator const * mCommunicator )
{
MutexGuard aGuard( sDataMutex ); auto aIt = std::find(sCommunicators.begin(), sCommunicators.end(), mCommunicator); if (aIt != sCommunicators.end())
sCommunicators.erase( aIt );
}
std::vector<std::shared_ptr<ClientInfo>> IPRemoteServer::getClients()
{
SAL_INFO( "sdremote", "IPRemoteServer::getClients() called" );
std::vector< std::shared_ptr< ClientInfo > > aClients; if ( spServer )
{
MutexGuard aGuard(RemoteServer::sDataMutex);
aClients.assign( spServer->mAvailableClients.begin(),
spServer->mAvailableClients.end() );
} else
{
SAL_INFO( "sdremote", "No remote server instance => no remote clients" );
} // We also need to provide authorised clients (no matter whether or not // they are actually available), so that they can be de-authorised if // necessary. We specifically want these to be at the end of the list // since the user is more likely to be trying to connect a new remote // than removing an existing remote. // We can also be sure that pre-authorised clients will not be on the // available clients list, as they get automatically connected if seen. // TODO: we should probably add some sort of extra labelling to mark // authorised AND connected client.
Reference< XNameAccess > const xConfig = officecfg::Office::Impress::Misc::AuthorisedRemotes::get(); const Sequence< OUString > aNames = xConfig->getElementNames();
std::transform(aNames.begin(), aNames.end(), std::back_inserter(aClients),
[](const OUString& rName) -> std::shared_ptr<ClientInfo> { return std::make_shared<ClientInfo>(rName, true); });
ClientInfoInternal* apClient = dynamic_cast< ClientInfoInternal* >( pClient.get() ); if ( !apClient ) // could happen if we try to "connect" an already authorised client
{ returnfalse;
}
if ( apClient->mPin == aPin )
{ // Save in settings first
std::shared_ptr< ConfigurationChanges > aChanges = ConfigurationChanges::create();
Reference< XNameContainer > const xConfig = officecfg::Office::Impress::Misc::AuthorisedRemotes::get( aChanges );
auto aIt = std::find(spServer->mAvailableClients.begin(), spServer->mAvailableClients.end(), pClient); if (aIt != spServer->mAvailableClients.end())
spServer->mAvailableClients.erase( aIt );
pCommunicator->launch(); returntrue;
} else
{ returnfalse;
}
}
void IPRemoteServer::deauthoriseClient(const std::shared_ptr<ClientInfo>& pClient)
{ // TODO: we probably want to forcefully disconnect at this point too? // But possibly via a separate function to allow just disconnecting from // the UI.
// The remote server is likely of no use in headless mode. And as only // one instance of the server can actually own the appropriate ports its // probably best to not even try to do so from our headless instance // (i.e. as to avoid blocking expected usage). // It could perhaps be argued that we would still need the remote // server for tiled rendering of presentations, but even then this // implementation would not be of much use, i.e. would be controlling // the purely imaginary headless presentation -- instead we'd need // to have some sort of mechanism of plugging in our tiled rendering // client to be controlled by the remote server, or provide an // alternative implementation. if ( Application::IsHeadlessModeEnabled() ) return;
if ( !officecfg::Office::Impress::Misc::Start::EnableSdremote::get() ) return;
if (!officecfg::Office::Security::Net::AllowInsecureImpressRemoteWiFi::get())
{
SAL_WARN("desktop", "Impress remote WiFi is disabled by configuration"); return;
}
// this is the IP/WiFi server
sd::IPRemoteServer::setup(); // assumption is that BluetoothServer doesn't need DiscoveryService
sd::DiscoveryService::setup();
}
void RemoteServer::ensureDiscoverable()
{ // FIXME: we could also enable listening on our WiFi // socket here to significantly reduce the attack surface. #ifdef ENABLE_SDREMOTE_BLUETOOTH
BluetoothServer::ensureDiscoverable(); #endif
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.