1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "typeselectionpage.hxx"
#include "addresssettings.hxx"
#include "abspilot.hxx"
#include <vcl/msgbox.hxx>
#include <com/sun/star/sdbc/XDriver.hpp>
#include <com/sun/star/sdbc/DriverManager.hpp>
#include <comphelper/processfactory.hxx>
namespace abp
{
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::sdbc;
// TypeSelectionPage
TypeSelectionPage::TypeSelectionPage( OAddessBookSourcePilot* _pParent )
: AddressBookSourcePage(_pParent, "SelectTypePage",
"modules/sabpilot/ui/selecttypepage.ui")
{
get(m_pEvolution, "evolution");
get(m_pEvolutionGroupwise, "groupwise");
get(m_pEvolutionLdap, "evoldap");
get(m_pMORK, "firefox");
get(m_pThunderbird, "thunderbird");
get(m_pKab, "kde");
get(m_pMacab, "macosx");
get(m_pLDAP, "ldap");
get(m_pOutlook, "outlook");
get(m_pOE, "windows");
get(m_pOther, "other");
//TODO: For now, try to keep offering the same choices like before the
// Mozilla/MORK cleanup, even if the status of what driver actually
// provides which functionality is somewhat unclear, see the discussions
// of fdo#57285 "Address Book Data Source Wizard lists 'Mac OS X address
// book' on Linux" and fdo#57322 "Moz-free LDAP Address Book driver."
// In accordance with ancient OOo 3.3, this is as follows:
//
// On Linux:
// - EVOLUTION, EVOLUTION_GROUPWISE, EVOLUTION_LDAP (if applicable)
// - MORK (via mork driver, which is built unconditionally)
// - KAB (if applicable)
// - OTHER
//
// On Mac OS X:
// - MACAB (if applicable)
// - MORK (via mork driver, which is built unconditionally)
// - OTHER
//
// On Windows:
// - MORK, THUNDERBIRD, LDAP, OUTLOOK, OUTLOOKEXPRESS (via mozab driver,
// if WITH_MOZILLA)
// - OTHER
bool bWithMozilla = false;
bool bHaveEvolution = false;
bool bHaveKab = false;
bool bHaveMacab = false;
bool bWithMork = false;
#if defined WNT
#if defined WITH_MOZILLA
bWithMozilla = true;
#endif
#else
bWithMork = true;
Reference< XDriverManager2 > xManager = DriverManager::create( _pParent->getORB() );
try
{
// check whether Evolution is available
Reference< XDriver > xDriver( xManager->getDriverByURL(OUString("sdbc:address:evolution:local")) );
if ( xDriver.is() )
bHaveEvolution = true;
}
catch (...)
{
}
// check whether KDE address book is available
try
{
Reference< XDriver > xDriver( xManager->getDriverByURL(OUString("sdbc:address:kab")) );
if ( xDriver.is() )
bHaveKab = true;
}
catch (...)
{
}
try
{
// check whether Mac OS X address book is available
Reference< XDriver > xDriver( xManager->getDriverByURL(OUString("sdbc:address:macab")) );
if ( xDriver.is() )
bHaveMacab = true;
}
catch(...)
{
}
#endif
// Items are displayed in list order
m_aAllTypes.push_back( ButtonItem( m_pEvolution, AST_EVOLUTION, bHaveEvolution ) );
m_aAllTypes.push_back( ButtonItem( m_pEvolutionGroupwise, AST_EVOLUTION_GROUPWISE, bHaveEvolution ) );
m_aAllTypes.push_back( ButtonItem( m_pEvolutionLdap, AST_EVOLUTION_LDAP, bHaveEvolution ) );
m_aAllTypes.push_back( ButtonItem( m_pMORK, AST_MORK, bWithMozilla || bWithMork) );
m_aAllTypes.push_back( ButtonItem( m_pThunderbird, AST_THUNDERBIRD, bWithMozilla || bWithMork) );
m_aAllTypes.push_back( ButtonItem( m_pKab, AST_KAB, bHaveKab ) );
m_aAllTypes.push_back( ButtonItem( m_pMacab, AST_MACAB, bHaveMacab ) );
m_aAllTypes.push_back( ButtonItem( m_pLDAP, AST_LDAP, bWithMozilla ) );
m_aAllTypes.push_back( ButtonItem( m_pOutlook, AST_OUTLOOK, bWithMozilla ) );
m_aAllTypes.push_back( ButtonItem( m_pOE, AST_OE, bWithMozilla ) );
m_aAllTypes.push_back( ButtonItem( m_pOther, AST_OTHER, true ) );
Link aTypeSelectionHandler = LINK(this, TypeSelectionPage, OnTypeSelected );
for ( ::std::vector< ButtonItem >::const_iterator loop = m_aAllTypes.begin();
loop != m_aAllTypes.end(); ++loop )
{
ButtonItem aItem = *loop;
if (!aItem.m_bVisible)
aItem.m_pItem->Hide();
else
{
aItem.m_pItem->SetClickHdl( aTypeSelectionHandler );
aItem.m_pItem->Show();
}
}
}
TypeSelectionPage::~TypeSelectionPage()
{
for ( ::std::vector< ButtonItem >::iterator loop = m_aAllTypes.begin();
loop != m_aAllTypes.end(); ++loop )
{
loop->m_bVisible = false;
}
}
void TypeSelectionPage::ActivatePage()
{
AddressBookSourcePage::ActivatePage();
for ( ::std::vector< ButtonItem >::const_iterator loop = m_aAllTypes.begin();
loop != m_aAllTypes.end(); ++loop )
{
const ButtonItem& rItem = (*loop);
if( rItem.m_pItem->IsChecked() && rItem.m_bVisible )
{
rItem.m_pItem->GrabFocus();
break;
}
}
getDialog()->enableButtons(WZB_PREVIOUS, false);
}
void TypeSelectionPage::DeactivatePage()
{
AddressBookSourcePage::DeactivatePage();
getDialog()->enableButtons(WZB_PREVIOUS, true);
}
void TypeSelectionPage::selectType( AddressSourceType _eType )
{
for ( ::std::vector< ButtonItem >::const_iterator loop = m_aAllTypes.begin();
loop != m_aAllTypes.end(); ++loop )
{
ButtonItem aItem = (*loop);
aItem.m_pItem->Check( _eType == aItem.m_eType );
}
}
AddressSourceType TypeSelectionPage::getSelectedType() const
{
for ( ::std::vector< ButtonItem >::const_iterator loop = m_aAllTypes.begin();
loop != m_aAllTypes.end(); ++loop )
{
ButtonItem aItem = (*loop);
if ( aItem.m_pItem->IsChecked() )
return aItem.m_eType;
}
return AST_INVALID;
}
void TypeSelectionPage::initializePage()
{
AddressBookSourcePage::initializePage();
const AddressSettings& rSettings = getSettings();
selectType(rSettings.eType);
}
bool TypeSelectionPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
{
if (!AddressBookSourcePage::commitPage(_eReason))
return false;
if (AST_INVALID == getSelectedType( ))
{
ErrorBox aError(this, ModuleRes(RID_ERR_NEEDTYPESELECTION));
aError.Execute();
return false;
}
AddressSettings& rSettings = getSettings();
rSettings.eType = getSelectedType();
return true;
}
bool TypeSelectionPage::canAdvance() const
{
return AddressBookSourcePage::canAdvance()
&& (AST_INVALID != getSelectedType());
}
IMPL_LINK( TypeSelectionPage, OnTypeSelected, void*, /*NOTINTERESTEDIN*/ )
{
getDialog()->typeSelectionChanged( getSelectedType() );
updateDialogTravelUI();
return 0L;
}
} // namespace abp
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|