1*2a97ec55SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2a97ec55SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2a97ec55SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2a97ec55SAndrew Rist  * distributed with this work for additional information
6*2a97ec55SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2a97ec55SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2a97ec55SAndrew Rist  * "License"); you may not use this file except in compliance
9*2a97ec55SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2a97ec55SAndrew Rist  *
11*2a97ec55SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2a97ec55SAndrew Rist  *
13*2a97ec55SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2a97ec55SAndrew Rist  * software distributed under the License is distributed on an
15*2a97ec55SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2a97ec55SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2a97ec55SAndrew Rist  * specific language governing permissions and limitations
18*2a97ec55SAndrew Rist  * under the License.
19*2a97ec55SAndrew Rist  *
20*2a97ec55SAndrew Rist  *************************************************************/
21*2a97ec55SAndrew Rist 
22*2a97ec55SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_extensions.hxx"
26cdf0e10cSrcweir #include "admininvokationpage.hxx"
27cdf0e10cSrcweir #include "abspilot.hxx"
28cdf0e10cSrcweir #include "admininvokationimpl.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir //.........................................................................
31cdf0e10cSrcweir namespace abp
32cdf0e10cSrcweir {
33cdf0e10cSrcweir //.........................................................................
34cdf0e10cSrcweir 
35cdf0e10cSrcweir 	//=====================================================================
36cdf0e10cSrcweir 	//= AdminDialogInvokationPage
37cdf0e10cSrcweir 	//=====================================================================
AdminDialogInvokationPage(OAddessBookSourcePilot * _pParent)38cdf0e10cSrcweir 	AdminDialogInvokationPage::AdminDialogInvokationPage( OAddessBookSourcePilot* _pParent )
39cdf0e10cSrcweir 		:AddressBookSourcePage(_pParent, ModuleRes(RID_PAGE_ADMININVOKATION))
40cdf0e10cSrcweir 		,m_aExplanation			(this, ModuleRes(FT_ADMINEXPLANATION))
41cdf0e10cSrcweir 		,m_aInvokeAdminDialog	(this, ModuleRes(PB_INVOKE_ADMIN_DIALOG))
42cdf0e10cSrcweir 		,m_aErrorMessage		(this, ModuleRes(FT_ERROR))
43cdf0e10cSrcweir 		,m_bSuccessfullyExecutedDialog(sal_False)
44cdf0e10cSrcweir 	{
45cdf0e10cSrcweir 		FreeResource();
46cdf0e10cSrcweir 
47cdf0e10cSrcweir 		m_aInvokeAdminDialog.SetClickHdl( LINK(this, AdminDialogInvokationPage, OnInvokeAdminDialog) );
48cdf0e10cSrcweir 	}
49cdf0e10cSrcweir 
50cdf0e10cSrcweir 	//---------------------------------------------------------------------
ActivatePage()51cdf0e10cSrcweir 	void AdminDialogInvokationPage::ActivatePage()
52cdf0e10cSrcweir 	{
53cdf0e10cSrcweir 		AddressBookSourcePage::ActivatePage();
54cdf0e10cSrcweir 		m_aInvokeAdminDialog.GrabFocus();
55cdf0e10cSrcweir 	}
56cdf0e10cSrcweir 
57cdf0e10cSrcweir 	//---------------------------------------------------------------------
implUpdateErrorMessage()58cdf0e10cSrcweir 	void AdminDialogInvokationPage::implUpdateErrorMessage()
59cdf0e10cSrcweir 	{
60cdf0e10cSrcweir 		const sal_Bool bIsConnected = getDialog()->getDataSource().isConnected();
61cdf0e10cSrcweir 		m_aErrorMessage.Show( !bIsConnected );
62cdf0e10cSrcweir 	}
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 	//---------------------------------------------------------------------
initializePage()65cdf0e10cSrcweir 	void AdminDialogInvokationPage::initializePage()
66cdf0e10cSrcweir 	{
67cdf0e10cSrcweir 		AddressBookSourcePage::initializePage();
68cdf0e10cSrcweir 		m_aErrorMessage.Hide();
69cdf0e10cSrcweir 			// if we're entering this page, we assume we had no connection trial with this data source
70cdf0e10cSrcweir 	}
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 	//---------------------------------------------------------------------
implTryConnect()73cdf0e10cSrcweir 	void AdminDialogInvokationPage::implTryConnect()
74cdf0e10cSrcweir 	{
75cdf0e10cSrcweir 		getDialog()->connectToDataSource( sal_True );
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 		// show our error message if and only if we could not connect
78cdf0e10cSrcweir 		implUpdateErrorMessage();
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 		// the status of the next button may have changed
81cdf0e10cSrcweir 		updateDialogTravelUI();
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 		// automatically go to the next page (if successfully connected)
84cdf0e10cSrcweir 		if ( canAdvance() )
85cdf0e10cSrcweir 			getDialog()->travelNext();
86cdf0e10cSrcweir 	}
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 	//---------------------------------------------------------------------
canAdvance() const89cdf0e10cSrcweir 	bool AdminDialogInvokationPage::canAdvance() const
90cdf0e10cSrcweir 	{
91cdf0e10cSrcweir 		return AddressBookSourcePage::canAdvance() && getDialog()->getDataSource().isConnected();
92cdf0e10cSrcweir 	}
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 	//---------------------------------------------------------------------
95cdf0e10cSrcweir 	IMPL_LINK( AdminDialogInvokationPage, OnInvokeAdminDialog, void*, /*NOTINTERESTEDIN*/ )
96cdf0e10cSrcweir 	{
97cdf0e10cSrcweir 		OAdminDialogInvokation aInvokation( getORB(), getDialog()->getDataSource().getDataSource(), getDialog() );
98cdf0e10cSrcweir 		if ( aInvokation.invokeAdministration( AST_LDAP == getSettings().eType ) )
99cdf0e10cSrcweir 		{
100cdf0e10cSrcweir 			// try to connect to this data source
101cdf0e10cSrcweir 			implTryConnect();
102cdf0e10cSrcweir 		}
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 		return 0L;
105cdf0e10cSrcweir 	}
106cdf0e10cSrcweir 
107cdf0e10cSrcweir //.........................................................................
108cdf0e10cSrcweir }	// namespace abp
109cdf0e10cSrcweir //.........................................................................
110cdf0e10cSrcweir 
111