2012-08-07 18:03:23 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "sdattr.hxx"
|
|
|
|
#include "sdresid.hxx"
|
|
|
|
#include "cusshow.hxx"
|
|
|
|
|
|
|
|
#include "RemoteDialog.hxx"
|
|
|
|
#include "RemoteDialog.hrc"
|
2012-08-10 13:27:40 +02:00
|
|
|
#include "RemoteServer.hxx"
|
2012-08-07 18:03:23 +02:00
|
|
|
|
2012-08-10 13:27:40 +02:00
|
|
|
using namespace ::sd;
|
|
|
|
using namespace ::std;
|
2012-08-08 11:42:58 +02:00
|
|
|
|
|
|
|
RemoteDialog::RemoteDialog( Window *pWindow ) :
|
2012-08-10 13:27:40 +02:00
|
|
|
ModalDialog( pWindow, SdResId( DLG_PAIR_REMOTE ) ),
|
|
|
|
mButtonConnect( this, SdResId( BTN_CONNECT ) ),
|
|
|
|
mButtonCancel( this, SdResId( BTN_CANCEL ) ),
|
2012-09-18 18:22:12 +02:00
|
|
|
mClientBox( this, NULL, SdResId( LB_SERVERS ) ),
|
|
|
|
mPreviouslyDiscoverable()
|
2012-08-07 18:03:23 +02:00
|
|
|
{
|
2012-08-13 16:09:46 +02:00
|
|
|
FreeResource();
|
2012-08-10 13:27:40 +02:00
|
|
|
|
2012-09-18 18:22:12 +02:00
|
|
|
mPreviouslyDiscoverable = RemoteServer::isBluetoothDiscoverable();
|
|
|
|
if ( !mPreviouslyDiscoverable )
|
|
|
|
RemoteServer::setBluetoothDiscoverable( true );
|
|
|
|
|
2012-08-10 17:20:16 +02:00
|
|
|
vector<ClientInfo*> aClients( RemoteServer::getClients() );
|
2012-08-10 13:27:40 +02:00
|
|
|
|
2012-08-10 17:20:16 +02:00
|
|
|
for ( vector<ClientInfo*>::const_iterator aIt( aClients.begin() );
|
2012-08-10 13:27:40 +02:00
|
|
|
aIt < aClients.end(); aIt++ )
|
|
|
|
{
|
2012-08-13 16:09:46 +02:00
|
|
|
mClientBox.addEntry( *aIt );
|
2012-08-10 13:27:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
mButtonConnect.SetClickHdl( LINK( this, RemoteDialog, HandleConnectButton ) );
|
2012-09-18 18:22:12 +02:00
|
|
|
SetCloseHdl( LINK( this, RemoteDialog, CloseHdl ) );
|
|
|
|
mButtonCancel.SetClickHdl( LINK( this, RemoteDialog, CloseHdl ) );
|
2012-08-07 18:03:23 +02:00
|
|
|
}
|
|
|
|
|
2012-08-08 11:42:58 +02:00
|
|
|
RemoteDialog::~RemoteDialog()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-10 13:27:40 +02:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
IMPL_LINK_NOARG(RemoteDialog, HandleConnectButton)
|
|
|
|
{
|
|
|
|
// setBusy( true );
|
|
|
|
// Fixme: Try and connect
|
2012-09-18 20:24:02 +02:00
|
|
|
#ifdef ENABLE_SDREMOTE
|
2012-08-13 16:09:46 +02:00
|
|
|
long aSelected = mClientBox.GetActiveEntryIndex();
|
|
|
|
if ( aSelected < 0 )
|
|
|
|
return 1;
|
|
|
|
TClientBoxEntry aEntry = mClientBox.GetEntryData(aSelected);
|
2012-08-13 21:39:12 +02:00
|
|
|
OUString aPin ( mClientBox.getPin() );
|
2012-08-13 16:09:46 +02:00
|
|
|
if ( RemoteServer::connectClient( aEntry->m_pClientInfo, aPin ) )
|
2012-08-13 21:39:12 +02:00
|
|
|
{
|
2012-09-18 18:22:12 +02:00
|
|
|
return CloseHdl( 0 );
|
2012-08-13 21:39:12 +02:00
|
|
|
}
|
2012-08-13 16:09:46 +02:00
|
|
|
else
|
|
|
|
return 1;
|
2012-09-18 20:24:02 +02:00
|
|
|
#endif
|
2012-08-10 13:27:40 +02:00
|
|
|
}
|
|
|
|
|
2012-09-18 18:22:12 +02:00
|
|
|
IMPL_LINK_NOARG( RemoteDialog, CloseHdl )
|
|
|
|
{
|
2012-09-18 20:24:02 +02:00
|
|
|
#ifdef ENABLE_SDREMOTE
|
2012-09-18 18:22:12 +02:00
|
|
|
if ( !mPreviouslyDiscoverable )
|
|
|
|
{
|
|
|
|
RemoteServer::setBluetoothDiscoverable( false );
|
|
|
|
}
|
|
|
|
Close();
|
|
|
|
return 0;
|
2012-09-18 20:24:02 +02:00
|
|
|
#endif
|
2012-09-18 18:22:12 +02:00
|
|
|
}
|
|
|
|
|
2012-08-07 18:03:23 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|