1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 "typeselectionpage.hxx"
21 #include "addresssettings.hxx"
22 #include "abspilot.hxx"
23 #include <vcl/layout.hxx>
24 #include <com/sun/star/sdbc/XDriver.hpp>
25 #include <com/sun/star/sdbc/DriverManager.hpp>
26 #include <comphelper/processfactory.hxx>
30 using namespace ::com::sun::star::uno
;
31 using namespace ::com::sun::star::sdbc
;
34 TypeSelectionPage::TypeSelectionPage( OAddessBookSourcePilot
* _pParent
)
35 : AddressBookSourcePage(_pParent
, "SelectTypePage",
36 "modules/sabpilot/ui/selecttypepage.ui")
38 get(m_pEvolution
, "evolution");
39 get(m_pEvolutionGroupwise
, "groupwise");
40 get(m_pEvolutionLdap
, "evoldap");
41 get(m_pMORK
, "firefox");
42 get(m_pThunderbird
, "thunderbird");
44 get(m_pMacab
, "macosx");
46 get(m_pOutlook
, "outlook");
47 get(m_pOE
, "windows");
48 get(m_pOther
, "other");
50 //TODO: For now, try to keep offering the same choices like before the
51 // Mozilla/MORK cleanup, even if the status of what driver actually
52 // provides which functionality is somewhat unclear, see the discussions
53 // of fdo#57285 "Address Book Data Source Wizard lists 'Mac OS X address
54 // book' on Linux" and fdo#57322 "Moz-free LDAP Address Book driver."
55 // In accordance with ancient OOo 3.3, this is as follows:
58 // - EVOLUTION, EVOLUTION_GROUPWISE, EVOLUTION_LDAP (if applicable)
59 // - MORK (via mork driver, which is built unconditionally)
60 // - KAB (if applicable)
64 // - MACAB (if applicable)
65 // - MORK (via mork driver, which is built unconditionally)
69 // - MORK, THUNDERBIRD, LDAP, OUTLOOK, OUTLOOKEXPRESS (via mozab driver,
73 bool bWithMozilla
= false;
74 bool bHaveEvolution
= false;
75 bool bHaveKab
= false;
76 bool bHaveMacab
= false;
77 bool bWithMork
= false;
80 #if defined WITH_MOZILLA
86 Reference
< XDriverManager2
> xManager
= DriverManager::create( _pParent
->getORB() );
90 // check whether Evolution is available
91 Reference
< XDriver
> xDriver( xManager
->getDriverByURL(OUString("sdbc:address:evolution:local")) );
93 bHaveEvolution
= true;
99 // check whether KDE address book is available
102 Reference
< XDriver
> xDriver( xManager
->getDriverByURL(OUString("sdbc:address:kab")) );
112 // check whether Mac OS X address book is available
113 Reference
< XDriver
> xDriver( xManager
->getDriverByURL(OUString("sdbc:address:macab")) );
123 // Items are displayed in list order
124 m_aAllTypes
.push_back( ButtonItem( m_pEvolution
, AST_EVOLUTION
, bHaveEvolution
) );
125 m_aAllTypes
.push_back( ButtonItem( m_pEvolutionGroupwise
, AST_EVOLUTION_GROUPWISE
, bHaveEvolution
) );
126 m_aAllTypes
.push_back( ButtonItem( m_pEvolutionLdap
, AST_EVOLUTION_LDAP
, bHaveEvolution
) );
127 m_aAllTypes
.push_back( ButtonItem( m_pMORK
, AST_MORK
, bWithMozilla
|| bWithMork
) );
128 m_aAllTypes
.push_back( ButtonItem( m_pThunderbird
, AST_THUNDERBIRD
, bWithMozilla
|| bWithMork
) );
129 m_aAllTypes
.push_back( ButtonItem( m_pKab
, AST_KAB
, bHaveKab
) );
130 m_aAllTypes
.push_back( ButtonItem( m_pMacab
, AST_MACAB
, bHaveMacab
) );
131 m_aAllTypes
.push_back( ButtonItem( m_pLDAP
, AST_LDAP
, bWithMozilla
) );
132 m_aAllTypes
.push_back( ButtonItem( m_pOutlook
, AST_OUTLOOK
, bWithMozilla
) );
133 m_aAllTypes
.push_back( ButtonItem( m_pOE
, AST_OE
, bWithMozilla
) );
134 m_aAllTypes
.push_back( ButtonItem( m_pOther
, AST_OTHER
, true ) );
136 Link
<> aTypeSelectionHandler
= LINK(this, TypeSelectionPage
, OnTypeSelected
);
137 for ( ::std::vector
< ButtonItem
>::const_iterator loop
= m_aAllTypes
.begin();
138 loop
!= m_aAllTypes
.end(); ++loop
)
140 ButtonItem aItem
= *loop
;
141 if (!aItem
.m_bVisible
)
142 aItem
.m_pItem
->Hide();
145 aItem
.m_pItem
->SetClickHdl( aTypeSelectionHandler
);
146 aItem
.m_pItem
->Show();
152 TypeSelectionPage::~TypeSelectionPage()
157 void TypeSelectionPage::dispose()
159 for ( ::std::vector
< ButtonItem
>::iterator loop
= m_aAllTypes
.begin();
160 loop
!= m_aAllTypes
.end(); ++loop
)
162 loop
->m_bVisible
= false;
164 m_pEvolution
.clear();
165 m_pEvolutionGroupwise
.clear();
166 m_pEvolutionLdap
.clear();
168 m_pThunderbird
.clear();
175 AddressBookSourcePage::dispose();
179 void TypeSelectionPage::ActivatePage()
181 AddressBookSourcePage::ActivatePage();
183 for ( ::std::vector
< ButtonItem
>::const_iterator loop
= m_aAllTypes
.begin();
184 loop
!= m_aAllTypes
.end(); ++loop
)
186 const ButtonItem
& rItem
= (*loop
);
187 if( rItem
.m_pItem
->IsChecked() && rItem
.m_bVisible
)
189 rItem
.m_pItem
->GrabFocus();
194 getDialog()->enableButtons(WizardButtonFlags::PREVIOUS
, false);
198 void TypeSelectionPage::DeactivatePage()
200 AddressBookSourcePage::DeactivatePage();
201 getDialog()->enableButtons(WizardButtonFlags::PREVIOUS
, true);
205 void TypeSelectionPage::selectType( AddressSourceType _eType
)
207 for ( ::std::vector
< ButtonItem
>::const_iterator loop
= m_aAllTypes
.begin();
208 loop
!= m_aAllTypes
.end(); ++loop
)
210 ButtonItem aItem
= (*loop
);
211 aItem
.m_pItem
->Check( _eType
== aItem
.m_eType
);
216 AddressSourceType
TypeSelectionPage::getSelectedType() const
218 for ( ::std::vector
< ButtonItem
>::const_iterator loop
= m_aAllTypes
.begin();
219 loop
!= m_aAllTypes
.end(); ++loop
)
221 ButtonItem aItem
= (*loop
);
222 if ( aItem
.m_pItem
->IsChecked() )
223 return aItem
.m_eType
;
230 void TypeSelectionPage::initializePage()
232 AddressBookSourcePage::initializePage();
234 const AddressSettings
& rSettings
= getSettings();
235 selectType(rSettings
.eType
);
239 bool TypeSelectionPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason
)
241 if (!AddressBookSourcePage::commitPage(_eReason
))
244 if (AST_INVALID
== getSelectedType( ))
246 ScopedVclPtrInstance
< MessageDialog
> aError(this, ModuleRes(RID_STR_NEEDTYPESELECTION
));
251 AddressSettings
& rSettings
= getSettings();
252 rSettings
.eType
= getSelectedType();
258 bool TypeSelectionPage::canAdvance() const
260 return AddressBookSourcePage::canAdvance()
261 && (AST_INVALID
!= getSelectedType());
265 IMPL_LINK_NOARG( TypeSelectionPage
, OnTypeSelected
)
267 getDialog()->typeSelectionChanged( getSelectedType() );
268 updateDialogTravelUI();
276 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */