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 : mClientBox( this, NULL, SdResId( LB_SERVERS ) ),
26 0 : mPreviouslyDiscoverable()
27 : {
28 : #ifdef ENABLE_SDREMOTE
29 0 : FreeResource();
30 :
31 : #ifdef ENABLE_SDREMOTE_BLUETOOTH
32 0 : mPreviouslyDiscoverable = RemoteServer::isBluetoothDiscoverable();
33 0 : if ( !mPreviouslyDiscoverable )
34 0 : RemoteServer::setBluetoothDiscoverable( true );
35 : #else
36 : RemoteServer::setBluetoothDiscoverable( false );
37 : #endif
38 :
39 0 : vector<ClientInfo*> aClients( RemoteServer::getClients() );
40 :
41 0 : for ( vector<ClientInfo*>::const_iterator aIt( aClients.begin() );
42 0 : aIt < aClients.end(); aIt++ )
43 : {
44 0 : mClientBox.addEntry( *aIt );
45 : }
46 :
47 0 : mButtonConnect.SetClickHdl( LINK( this, RemoteDialog, HandleConnectButton ) );
48 0 : SetCloseHdl( LINK( this, RemoteDialog, CloseHdl ) );
49 0 : mButtonCancel.SetClickHdl( LINK( this, RemoteDialog, CloseHdl ) );
50 : #else
51 : (void) mPreviouslyDiscoverable; // avoid warnings about unused member
52 : #endif
53 0 : }
54 :
55 0 : RemoteDialog::~RemoteDialog()
56 : {
57 0 : }
58 :
59 : // -----------------------------------------------------------------------
60 0 : IMPL_LINK_NOARG(RemoteDialog, HandleConnectButton)
61 : {
62 : // setBusy( true );
63 : // Fixme: Try and connect
64 : #if defined(ENABLE_SDREMOTE) && defined(ENABLE_SDREMOTE_BLUETOOTH)
65 0 : long aSelected = mClientBox.GetActiveEntryIndex();
66 0 : if ( aSelected < 0 )
67 0 : return 1;
68 0 : TClientBoxEntry aEntry = mClientBox.GetEntryData(aSelected);
69 0 : OUString aPin ( mClientBox.getPin() );
70 0 : if ( RemoteServer::connectClient( aEntry->m_pClientInfo, aPin ) )
71 : {
72 0 : return CloseHdl( 0 );
73 : }
74 : else
75 : {
76 0 : return 1;
77 0 : }
78 : #else
79 : return 0;
80 : #endif
81 : }
82 :
83 0 : IMPL_LINK_NOARG( RemoteDialog, CloseHdl )
84 : {
85 : #if defined(ENABLE_SDREMOTE) && defined(ENABLE_SDREMOTE_BLUETOOTH)
86 0 : if ( !mPreviouslyDiscoverable )
87 : {
88 0 : RemoteServer::setBluetoothDiscoverable( false );
89 : }
90 0 : Close();
91 : #endif
92 0 : return 0;
93 : }
94 :
95 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|