xref: /trunk/main/extensions/source/abpilot/admininvokationpage.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_extensions.hxx"
30 #include "admininvokationpage.hxx"
31 #include "abspilot.hxx"
32 #include "admininvokationimpl.hxx"
33 
34 //.........................................................................
35 namespace abp
36 {
37 //.........................................................................
38 
39     //=====================================================================
40     //= AdminDialogInvokationPage
41     //=====================================================================
42     AdminDialogInvokationPage::AdminDialogInvokationPage( OAddessBookSourcePilot* _pParent )
43         :AddressBookSourcePage(_pParent, ModuleRes(RID_PAGE_ADMININVOKATION))
44         ,m_aExplanation         (this, ModuleRes(FT_ADMINEXPLANATION))
45         ,m_aInvokeAdminDialog   (this, ModuleRes(PB_INVOKE_ADMIN_DIALOG))
46         ,m_aErrorMessage        (this, ModuleRes(FT_ERROR))
47         ,m_bSuccessfullyExecutedDialog(sal_False)
48     {
49         FreeResource();
50 
51         m_aInvokeAdminDialog.SetClickHdl( LINK(this, AdminDialogInvokationPage, OnInvokeAdminDialog) );
52     }
53 
54     //---------------------------------------------------------------------
55     void AdminDialogInvokationPage::ActivatePage()
56     {
57         AddressBookSourcePage::ActivatePage();
58         m_aInvokeAdminDialog.GrabFocus();
59     }
60 
61     //---------------------------------------------------------------------
62     void AdminDialogInvokationPage::implUpdateErrorMessage()
63     {
64         const sal_Bool bIsConnected = getDialog()->getDataSource().isConnected();
65         m_aErrorMessage.Show( !bIsConnected );
66     }
67 
68     //---------------------------------------------------------------------
69     void AdminDialogInvokationPage::initializePage()
70     {
71         AddressBookSourcePage::initializePage();
72         m_aErrorMessage.Hide();
73             // if we're entering this page, we assume we had no connection trial with this data source
74     }
75 
76     //---------------------------------------------------------------------
77     void AdminDialogInvokationPage::implTryConnect()
78     {
79         getDialog()->connectToDataSource( sal_True );
80 
81         // show our error message if and only if we could not connect
82         implUpdateErrorMessage();
83 
84         // the status of the next button may have changed
85         updateDialogTravelUI();
86 
87         // automatically go to the next page (if successfully connected)
88         if ( canAdvance() )
89             getDialog()->travelNext();
90     }
91 
92     //---------------------------------------------------------------------
93     bool AdminDialogInvokationPage::canAdvance() const
94     {
95         return AddressBookSourcePage::canAdvance() && getDialog()->getDataSource().isConnected();
96     }
97 
98     //---------------------------------------------------------------------
99     IMPL_LINK( AdminDialogInvokationPage, OnInvokeAdminDialog, void*, /*NOTINTERESTEDIN*/ )
100     {
101         OAdminDialogInvokation aInvokation( getORB(), getDialog()->getDataSource().getDataSource(), getDialog() );
102         if ( aInvokation.invokeAdministration( AST_LDAP == getSettings().eType ) )
103         {
104             // try to connect to this data source
105             implTryConnect();
106         }
107 
108         return 0L;
109     }
110 
111 //.........................................................................
112 }   // namespace abp
113 //.........................................................................
114 
115