Line data Source code
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 :
10 : #include "sdattr.hxx"
11 : #include "sdresid.hxx"
12 : #include "cusshow.hxx"
13 :
14 : #include "RemoteDialog.hxx"
15 : #include "RemoteDialog.hrc"
16 : #include "RemoteServer.hxx"
17 :
18 : using namespace ::sd;
19 : using namespace ::std;
20 :
21 0 : RemoteDialog::RemoteDialog( Window *pWindow ) :
22 : ModalDialog( pWindow, SdResId( DLG_PAIR_REMOTE ) ),
23 : mButtonConnect( this, SdResId( BTN_CONNECT ) ),
24 : mButtonCancel( this, SdResId( BTN_CANCEL ) ),
25 0 : mClientBox( this, NULL, SdResId( LB_SERVERS ) )
26 : {
27 0 : FreeResource();
28 :
29 : #ifdef ENABLE_SDREMOTE
30 0 : RemoteServer::ensureDiscoverable();
31 :
32 0 : vector<ClientInfo*> aClients( RemoteServer::getClients() );
33 :
34 0 : const vector<ClientInfo*>::const_iterator aEnd( aClients.end() );
35 :
36 0 : for ( vector<ClientInfo*>::const_iterator aIt( aClients.begin() );
37 : aIt != aEnd; ++aIt )
38 : {
39 0 : mClientBox.addEntry( *aIt );
40 : }
41 : #endif
42 :
43 0 : mButtonConnect.SetClickHdl( LINK( this, RemoteDialog, HandleConnectButton ) );
44 0 : SetCloseHdl( LINK( this, RemoteDialog, CloseHdl ) );
45 0 : mButtonCancel.SetClickHdl( LINK( this, RemoteDialog, CloseHdl ) );
46 0 : }
47 :
48 0 : RemoteDialog::~RemoteDialog()
49 : {
50 0 : }
51 :
52 : // -----------------------------------------------------------------------
53 0 : IMPL_LINK_NOARG(RemoteDialog, HandleConnectButton)
54 : {
55 : // setBusy( true );
56 : // Fixme: Try and connect
57 : #if defined(ENABLE_SDREMOTE) && defined(ENABLE_SDREMOTE_BLUETOOTH)
58 0 : long aSelected = mClientBox.GetActiveEntryIndex();
59 0 : if ( aSelected < 0 )
60 0 : return 1;
61 0 : TClientBoxEntry aEntry = mClientBox.GetEntryData(aSelected);
62 0 : OUString aPin ( mClientBox.getPin() );
63 0 : if ( RemoteServer::connectClient( aEntry->m_pClientInfo, aPin ) )
64 : {
65 0 : return CloseHdl( 0 );
66 : }
67 : else
68 : {
69 0 : return 1;
70 0 : }
71 : #else
72 : return 0;
73 : #endif
74 : }
75 :
76 0 : IMPL_LINK_NOARG( RemoteDialog, CloseHdl )
77 : {
78 : #ifdef ENABLE_SDREMOTE
79 0 : RemoteServer::restoreDiscoverable();
80 : #endif
81 0 : Close();
82 0 : return 0;
83 0 : }
84 :
85 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|