Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / extensions / source / abpilot / admininvokationpage.cxx
blobaf975768d3b4660eaa9b074ab44ca5437bc81a3a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "admininvokationpage.hxx"
21 #include "abspilot.hxx"
22 #include "admininvokationimpl.hxx"
23 #include "comphelper/processfactory.hxx"
25 namespace abp
27 AdminDialogInvokationPage::AdminDialogInvokationPage( OAddressBookSourcePilot* _pParent )
28 : AddressBookSourcePage(_pParent, "InvokeAdminPage",
29 "modules/sabpilot/ui/invokeadminpage.ui")
31 get(m_pInvokeAdminDialog, "settings");
32 get(m_pErrorMessage, "warning");
33 m_pInvokeAdminDialog->SetClickHdl( LINK(this, AdminDialogInvokationPage, OnInvokeAdminDialog) );
35 AdminDialogInvokationPage::~AdminDialogInvokationPage()
37 disposeOnce();
39 void AdminDialogInvokationPage::dispose()
41 m_pInvokeAdminDialog.clear();
42 m_pErrorMessage.clear();
43 AddressBookSourcePage::dispose();
45 void AdminDialogInvokationPage::ActivatePage()
47 AddressBookSourcePage::ActivatePage();
48 m_pInvokeAdminDialog->GrabFocus();
51 void AdminDialogInvokationPage::implUpdateErrorMessage()
53 const bool bIsConnected = getDialog()->getDataSource().isConnected();
54 m_pErrorMessage->Show( !bIsConnected );
57 void AdminDialogInvokationPage::initializePage()
59 AddressBookSourcePage::initializePage();
60 m_pErrorMessage->Hide();
61 // if we're entering this page, we assume we had no connection trial with this data source
64 void AdminDialogInvokationPage::implTryConnect()
66 getDialog()->connectToDataSource( true );
68 // show our error message if and only if we could not connect
69 implUpdateErrorMessage();
71 // the status of the next button may have changed
72 updateDialogTravelUI();
74 // automatically go to the next page (if successfully connected)
75 if ( canAdvance() )
76 getDialog()->travelNext();
79 bool AdminDialogInvokationPage::canAdvance() const
81 return AddressBookSourcePage::canAdvance() && getDialog()->getDataSource().isConnected();
84 // davido: Do we need it?
85 IMPL_LINK_NOARG( AdminDialogInvokationPage, OnInvokeAdminDialog, Button*, void )
87 OAdminDialogInvokation aInvokation( getORB(), getDialog()->getDataSource().getDataSource(), getDialog() );
88 if ( aInvokation.invokeAdministration() )
90 // try to connect to this data source
91 implTryConnect();
95 } // namespace abp
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */