12a97ec55SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 32a97ec55SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 42a97ec55SAndrew Rist * or more contributor license agreements. See the NOTICE file 52a97ec55SAndrew Rist * distributed with this work for additional information 62a97ec55SAndrew Rist * regarding copyright ownership. The ASF licenses this file 72a97ec55SAndrew Rist * to you under the Apache License, Version 2.0 (the 82a97ec55SAndrew Rist * "License"); you may not use this file except in compliance 92a97ec55SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 112a97ec55SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 132a97ec55SAndrew Rist * Unless required by applicable law or agreed to in writing, 142a97ec55SAndrew Rist * software distributed under the License is distributed on an 152a97ec55SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 162a97ec55SAndrew Rist * KIND, either express or implied. See the License for the 172a97ec55SAndrew Rist * specific language governing permissions and limitations 182a97ec55SAndrew Rist * under the License. 19cdf0e10cSrcweir * 202a97ec55SAndrew Rist *************************************************************/ 212a97ec55SAndrew Rist 22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 23cdf0e10cSrcweir #include "precompiled_extensions.hxx" 24cdf0e10cSrcweir #include "abspilot.hxx" 25cdf0e10cSrcweir #include "abpilot.hrc" 26cdf0e10cSrcweir #include "abpresid.hrc" 27cdf0e10cSrcweir #include "componentmodule.hxx" 28cdf0e10cSrcweir #include <tools/debug.hxx> 29cdf0e10cSrcweir #include <svtools/localresaccess.hxx> 30cdf0e10cSrcweir #include "typeselectionpage.hxx" 31cdf0e10cSrcweir #include "admininvokationpage.hxx" 32cdf0e10cSrcweir #include "tableselectionpage.hxx" 33cdf0e10cSrcweir #include <vcl/waitobj.hxx> 34cdf0e10cSrcweir #include <vcl/msgbox.hxx> 35cdf0e10cSrcweir #include "abpfinalpage.hxx" 36cdf0e10cSrcweir #include "fieldmappingpage.hxx" 37cdf0e10cSrcweir #include "fieldmappingimpl.hxx" 38cdf0e10cSrcweir 39cdf0e10cSrcweir namespace abp 40cdf0e10cSrcweir { 41cdf0e10cSrcweir //......................................................................... 42cdf0e10cSrcweir 43cdf0e10cSrcweir #define STATE_SELECT_ABTYPE 0 44cdf0e10cSrcweir #define STATE_INVOKE_ADMIN_DIALOG 1 45cdf0e10cSrcweir #define STATE_TABLE_SELECTION 2 46cdf0e10cSrcweir #define STATE_MANUAL_FIELD_MAPPING 3 47cdf0e10cSrcweir #define STATE_FINAL_CONFIRM 4 48cdf0e10cSrcweir 49cdf0e10cSrcweir #define PATH_COMPLETE 1 50cdf0e10cSrcweir #define PATH_NO_SETTINGS 2 51cdf0e10cSrcweir #define PATH_NO_FIELDS 3 52cdf0e10cSrcweir #define PATH_NO_SETTINGS_NO_FIELDS 4 53cdf0e10cSrcweir 54cdf0e10cSrcweir using namespace ::svt; 55cdf0e10cSrcweir using namespace ::com::sun::star::uno; 56cdf0e10cSrcweir using namespace ::com::sun::star::lang; 57cdf0e10cSrcweir 58cdf0e10cSrcweir //===================================================================== 59cdf0e10cSrcweir //= OAddessBookSourcePilot 60cdf0e10cSrcweir //===================================================================== 61cdf0e10cSrcweir //--------------------------------------------------------------------- OAddessBookSourcePilot(Window * _pParent,const Reference<XMultiServiceFactory> & _rxORB)62cdf0e10cSrcweir OAddessBookSourcePilot::OAddessBookSourcePilot(Window* _pParent, const Reference< XMultiServiceFactory >& _rxORB) 63cdf0e10cSrcweir :OAddessBookSourcePilot_Base( _pParent, ModuleRes( RID_DLG_ADDRESSBOOKSOURCEPILOT ), 64cdf0e10cSrcweir WZB_HELP | WZB_FINISH | WZB_CANCEL | WZB_NEXT | WZB_PREVIOUS ) 65cdf0e10cSrcweir ,m_xORB(_rxORB) 66cdf0e10cSrcweir ,m_aNewDataSource(_rxORB) 67cdf0e10cSrcweir ,m_eNewDataSourceType( AST_INVALID ) 68cdf0e10cSrcweir { 69cdf0e10cSrcweir SetPageSizePixel(LogicToPixel(Size(WINDOW_SIZE_X, WINDOW_SIZE_Y), MAP_APPFONT)); 70cdf0e10cSrcweir 71cdf0e10cSrcweir ShowButtonFixedLine(sal_True); 72cdf0e10cSrcweir 73cdf0e10cSrcweir declarePath( PATH_COMPLETE, 74cdf0e10cSrcweir STATE_SELECT_ABTYPE, 75cdf0e10cSrcweir STATE_INVOKE_ADMIN_DIALOG, 76cdf0e10cSrcweir STATE_TABLE_SELECTION, 77cdf0e10cSrcweir STATE_MANUAL_FIELD_MAPPING, 78cdf0e10cSrcweir STATE_FINAL_CONFIRM, 79cdf0e10cSrcweir WZS_INVALID_STATE 80cdf0e10cSrcweir ); 81cdf0e10cSrcweir declarePath( PATH_NO_SETTINGS, 82cdf0e10cSrcweir STATE_SELECT_ABTYPE, 83cdf0e10cSrcweir STATE_TABLE_SELECTION, 84cdf0e10cSrcweir STATE_MANUAL_FIELD_MAPPING, 85cdf0e10cSrcweir STATE_FINAL_CONFIRM, 86cdf0e10cSrcweir WZS_INVALID_STATE 87cdf0e10cSrcweir ); 88cdf0e10cSrcweir declarePath( PATH_NO_FIELDS, 89cdf0e10cSrcweir STATE_SELECT_ABTYPE, 90cdf0e10cSrcweir STATE_INVOKE_ADMIN_DIALOG, 91cdf0e10cSrcweir STATE_TABLE_SELECTION, 92cdf0e10cSrcweir STATE_FINAL_CONFIRM, 93cdf0e10cSrcweir WZS_INVALID_STATE 94cdf0e10cSrcweir ); 95cdf0e10cSrcweir declarePath( PATH_NO_SETTINGS_NO_FIELDS, 96cdf0e10cSrcweir STATE_SELECT_ABTYPE, 97cdf0e10cSrcweir STATE_TABLE_SELECTION, 98cdf0e10cSrcweir STATE_FINAL_CONFIRM, 99cdf0e10cSrcweir WZS_INVALID_STATE 100cdf0e10cSrcweir ); 101cdf0e10cSrcweir 102cdf0e10cSrcweir m_pPrevPage->SetHelpId(HID_ABSPILOT_PREVIOUS); 103cdf0e10cSrcweir m_pNextPage->SetHelpId(HID_ABSPILOT_NEXT); 104cdf0e10cSrcweir m_pCancel->SetHelpId(HID_ABSPILOT_CANCEL); 105cdf0e10cSrcweir m_pFinish->SetHelpId(HID_ABSPILOT_FINISH); 106cdf0e10cSrcweir m_pHelp->SetUniqueId(UID_ABSPILOT_HELP); 107cdf0e10cSrcweir 108cdf0e10cSrcweir m_pCancel->SetClickHdl( LINK( this, OAddessBookSourcePilot, OnCancelClicked) ); 109cdf0e10cSrcweir 110cdf0e10cSrcweir // some initial settings 111cdf0e10cSrcweir #ifdef MACOSX 112cdf0e10cSrcweir m_aSettings.eType = AST_MACAB; 113cdf0e10cSrcweir #elif WITH_MOZILLA 114cdf0e10cSrcweir #ifdef UNX 115*7dbe28d4SMatthias Seidel m_aSettings.eType = AST_THUNDERBIRD; 116cdf0e10cSrcweir #else 117cdf0e10cSrcweir m_aSettings.eType = AST_OE; 118cdf0e10cSrcweir #endif 119cdf0e10cSrcweir #else 120cdf0e10cSrcweir m_aSettings.eType = AST_OTHER; 121cdf0e10cSrcweir #endif 122cdf0e10cSrcweir m_aSettings.sDataSourceName = String(ModuleRes(RID_STR_DEFAULT_NAME)); 123cdf0e10cSrcweir m_aSettings.bRegisterDataSource = false; 124cdf0e10cSrcweir m_aSettings.bIgnoreNoTable = false; 125cdf0e10cSrcweir 126cdf0e10cSrcweir defaultButton(WZB_NEXT); 127cdf0e10cSrcweir enableButtons(WZB_FINISH, sal_False); 128cdf0e10cSrcweir ActivatePage(); 129cdf0e10cSrcweir 130cdf0e10cSrcweir typeSelectionChanged( m_aSettings.eType ); 131cdf0e10cSrcweir } 132cdf0e10cSrcweir 133cdf0e10cSrcweir //--------------------------------------------------------------------- getStateDisplayName(WizardState _nState) const134cdf0e10cSrcweir String OAddessBookSourcePilot::getStateDisplayName( WizardState _nState ) const 135cdf0e10cSrcweir { 136cdf0e10cSrcweir sal_uInt16 nResId = 0; 137cdf0e10cSrcweir switch ( _nState ) 138cdf0e10cSrcweir { 139cdf0e10cSrcweir case STATE_SELECT_ABTYPE: nResId = STR_SELECT_ABTYPE; break; 140cdf0e10cSrcweir case STATE_INVOKE_ADMIN_DIALOG: nResId = STR_INVOKE_ADMIN_DIALOG; break; 141cdf0e10cSrcweir case STATE_TABLE_SELECTION: nResId = STR_TABLE_SELECTION; break; 142cdf0e10cSrcweir case STATE_MANUAL_FIELD_MAPPING: nResId = STR_MANUAL_FIELD_MAPPING; break; 143cdf0e10cSrcweir case STATE_FINAL_CONFIRM: nResId = STR_FINAL_CONFIRM; break; 144cdf0e10cSrcweir } 145cdf0e10cSrcweir DBG_ASSERT( nResId, "OAddessBookSourcePilot::getStateDisplayName: don't know this state!" ); 146cdf0e10cSrcweir 147cdf0e10cSrcweir String sDisplayName; 148cdf0e10cSrcweir if ( nResId ) 149cdf0e10cSrcweir { 150cdf0e10cSrcweir svt::OLocalResourceAccess aAccess( ModuleRes( RID_DLG_ADDRESSBOOKSOURCEPILOT ), RSC_MODALDIALOG ); 151cdf0e10cSrcweir sDisplayName = String( ModuleRes( nResId ) ); 152cdf0e10cSrcweir } 153cdf0e10cSrcweir 154cdf0e10cSrcweir return sDisplayName; 155cdf0e10cSrcweir } 156cdf0e10cSrcweir 157cdf0e10cSrcweir //--------------------------------------------------------------------- implCommitAll()158cdf0e10cSrcweir void OAddessBookSourcePilot::implCommitAll() 159cdf0e10cSrcweir { 160cdf0e10cSrcweir // in real, the data source already exists in the data source context 161cdf0e10cSrcweir // Thus, if the user changed the name, we have to rename the data source 162cdf0e10cSrcweir if ( m_aSettings.sDataSourceName != m_aNewDataSource.getName() ) 163cdf0e10cSrcweir m_aNewDataSource.rename( m_aSettings.sDataSourceName ); 164cdf0e10cSrcweir 165cdf0e10cSrcweir // 1. the data source 166cdf0e10cSrcweir m_aNewDataSource.store(); 167cdf0e10cSrcweir 168cdf0e10cSrcweir // 2. check if we need to register the data source 169cdf0e10cSrcweir if ( m_aSettings.bRegisterDataSource ) 170cdf0e10cSrcweir m_aNewDataSource.registerDataSource(m_aSettings.sRegisteredDataSourceName); 171cdf0e10cSrcweir 172cdf0e10cSrcweir // 3. write the data source / table names into the configuration 173cdf0e10cSrcweir addressconfig::writeTemplateAddressSource( getORB(), m_aSettings.bRegisterDataSource ? m_aSettings.sRegisteredDataSourceName : m_aSettings.sDataSourceName, m_aSettings.sSelectedTable ); 174cdf0e10cSrcweir 175cdf0e10cSrcweir // 4. write the field mapping 176cdf0e10cSrcweir fieldmapping::writeTemplateAddressFieldMapping( getORB(), m_aSettings.aFieldMapping ); 177cdf0e10cSrcweir } 178cdf0e10cSrcweir 179cdf0e10cSrcweir //--------------------------------------------------------------------- implCleanup()180cdf0e10cSrcweir void OAddessBookSourcePilot::implCleanup() 181cdf0e10cSrcweir { 182cdf0e10cSrcweir if ( m_aNewDataSource.isValid() ) 183cdf0e10cSrcweir m_aNewDataSource.remove(); 184cdf0e10cSrcweir } 185cdf0e10cSrcweir 186cdf0e10cSrcweir //--------------------------------------------------------------------- 187cdf0e10cSrcweir IMPL_LINK( OAddessBookSourcePilot, OnCancelClicked, void*, /*NOTINTERESTEDIN*/ ) 188cdf0e10cSrcweir { 189cdf0e10cSrcweir // do cleanups 190cdf0e10cSrcweir implCleanup(); 191cdf0e10cSrcweir 192cdf0e10cSrcweir // reset the click hdl 193cdf0e10cSrcweir m_pCancel->SetClickHdl( Link() ); 194*7dbe28d4SMatthias Seidel // simulate the click again - this time, the default handling of the button will strike... 195cdf0e10cSrcweir m_pCancel->Click(); 196cdf0e10cSrcweir 197cdf0e10cSrcweir return 0L; 198cdf0e10cSrcweir } 199cdf0e10cSrcweir 200cdf0e10cSrcweir //--------------------------------------------------------------------- Close()201cdf0e10cSrcweir sal_Bool OAddessBookSourcePilot::Close() 202cdf0e10cSrcweir { 203cdf0e10cSrcweir implCleanup(); 204cdf0e10cSrcweir 205cdf0e10cSrcweir return OAddessBookSourcePilot_Base::Close(); 206cdf0e10cSrcweir } 207cdf0e10cSrcweir 208cdf0e10cSrcweir //--------------------------------------------------------------------- onFinish()209cdf0e10cSrcweir sal_Bool OAddessBookSourcePilot::onFinish() 210cdf0e10cSrcweir { 211cdf0e10cSrcweir if ( !OAddessBookSourcePilot_Base::onFinish() ) 212cdf0e10cSrcweir return sal_False; 213cdf0e10cSrcweir 214cdf0e10cSrcweir implCommitAll(); 215cdf0e10cSrcweir 216cdf0e10cSrcweir addressconfig::markPilotSuccess( getORB() ); 217cdf0e10cSrcweir 218cdf0e10cSrcweir return sal_True; 219cdf0e10cSrcweir } 220cdf0e10cSrcweir 221cdf0e10cSrcweir //--------------------------------------------------------------------- enterState(WizardState _nState)222cdf0e10cSrcweir void OAddessBookSourcePilot::enterState( WizardState _nState ) 223cdf0e10cSrcweir { 224cdf0e10cSrcweir switch ( _nState ) 225cdf0e10cSrcweir { 226cdf0e10cSrcweir case STATE_SELECT_ABTYPE: 227cdf0e10cSrcweir impl_updateRoadmap( static_cast< TypeSelectionPage* >( GetPage( STATE_SELECT_ABTYPE ) )->getSelectedType() ); 228cdf0e10cSrcweir break; 229cdf0e10cSrcweir 230cdf0e10cSrcweir case STATE_FINAL_CONFIRM: 231cdf0e10cSrcweir if ( !needManualFieldMapping( ) ) 232cdf0e10cSrcweir implDoAutoFieldMapping(); 233cdf0e10cSrcweir break; 234cdf0e10cSrcweir 235cdf0e10cSrcweir case STATE_TABLE_SELECTION: 236cdf0e10cSrcweir implDefaultTableName(); 237cdf0e10cSrcweir break; 238cdf0e10cSrcweir } 239cdf0e10cSrcweir 240cdf0e10cSrcweir OAddessBookSourcePilot_Base::enterState(_nState); 241cdf0e10cSrcweir } 242cdf0e10cSrcweir 243cdf0e10cSrcweir //--------------------------------------------------------------------- prepareLeaveCurrentState(CommitPageReason _eReason)244cdf0e10cSrcweir sal_Bool OAddessBookSourcePilot::prepareLeaveCurrentState( CommitPageReason _eReason ) 245cdf0e10cSrcweir { 246cdf0e10cSrcweir if ( !OAddessBookSourcePilot_Base::prepareLeaveCurrentState( _eReason ) ) 247cdf0e10cSrcweir return sal_False; 248cdf0e10cSrcweir 249cdf0e10cSrcweir if ( _eReason == eTravelBackward ) 250cdf0e10cSrcweir return sal_True; 251cdf0e10cSrcweir 252cdf0e10cSrcweir sal_Bool bAllow = sal_True; 253cdf0e10cSrcweir 254cdf0e10cSrcweir switch ( getCurrentState() ) 255cdf0e10cSrcweir { 256cdf0e10cSrcweir case STATE_SELECT_ABTYPE: 257cdf0e10cSrcweir implCreateDataSource(); 258cdf0e10cSrcweir if ( needAdminInvokationPage() ) 259cdf0e10cSrcweir break; 260cdf0e10cSrcweir // no break here 261cdf0e10cSrcweir 262cdf0e10cSrcweir case STATE_INVOKE_ADMIN_DIALOG: 263cdf0e10cSrcweir if ( !connectToDataSource( sal_False ) ) 264cdf0e10cSrcweir { 265cdf0e10cSrcweir // connecting did not succeed -> do not allow proceeding 266cdf0e10cSrcweir bAllow = sal_False; 267cdf0e10cSrcweir break; 268cdf0e10cSrcweir } 269cdf0e10cSrcweir 270cdf0e10cSrcweir // ........................................................ 271cdf0e10cSrcweir // now that we connected to the data source, check whether we need the "table selection" page 272cdf0e10cSrcweir const StringBag& aTables = m_aNewDataSource.getTableNames(); 273cdf0e10cSrcweir 274cdf0e10cSrcweir if ( aTables.empty() ) 275cdf0e10cSrcweir { 276cdf0e10cSrcweir if ( RET_YES != QueryBox( this, ModuleRes( RID_QRY_NOTABLES ) ).Execute() ) 277cdf0e10cSrcweir { 278cdf0e10cSrcweir // cannot ask the user, or the user chose to use this data source, though there are no tables 279cdf0e10cSrcweir bAllow = sal_False; 280cdf0e10cSrcweir break; 281cdf0e10cSrcweir } 282cdf0e10cSrcweir 283cdf0e10cSrcweir m_aSettings.bIgnoreNoTable = true; 284cdf0e10cSrcweir } 285cdf0e10cSrcweir 286cdf0e10cSrcweir if ( aTables.size() == 1 ) 287cdf0e10cSrcweir // remember the one and only table we have 288cdf0e10cSrcweir m_aSettings.sSelectedTable = *aTables.begin(); 289cdf0e10cSrcweir 290cdf0e10cSrcweir break; 291cdf0e10cSrcweir } 292cdf0e10cSrcweir 293cdf0e10cSrcweir impl_updateRoadmap( m_aSettings.eType ); 294cdf0e10cSrcweir return bAllow; 295cdf0e10cSrcweir } 296cdf0e10cSrcweir 297cdf0e10cSrcweir //--------------------------------------------------------------------- implDefaultTableName()298cdf0e10cSrcweir void OAddessBookSourcePilot::implDefaultTableName() 299cdf0e10cSrcweir { 300cdf0e10cSrcweir const StringBag& rTableNames = getDataSource().getTableNames(); 301cdf0e10cSrcweir if ( rTableNames.end() != rTableNames.find( getSettings().sSelectedTable ) ) 302cdf0e10cSrcweir // already a valid table selected 303cdf0e10cSrcweir return; 304cdf0e10cSrcweir 305cdf0e10cSrcweir const sal_Char* pGuess = NULL; 306cdf0e10cSrcweir switch ( getSettings().eType ) 307cdf0e10cSrcweir { 308cdf0e10cSrcweir case AST_THUNDERBIRD : pGuess = "Personal Address book"; break; 309cdf0e10cSrcweir case AST_LDAP : pGuess = "LDAP Directory"; break; 310cdf0e10cSrcweir case AST_EVOLUTION : 311cdf0e10cSrcweir case AST_EVOLUTION_GROUPWISE: 312cdf0e10cSrcweir case AST_EVOLUTION_LDAP : pGuess = "Personal"; break; 313cdf0e10cSrcweir default: 314cdf0e10cSrcweir DBG_ERROR( "OAddessBookSourcePilot::implDefaultTableName: unhandled case!" ); 315cdf0e10cSrcweir return; 316cdf0e10cSrcweir } 317cdf0e10cSrcweir const ::rtl::OUString sGuess = ::rtl::OUString::createFromAscii( pGuess ); 318cdf0e10cSrcweir if ( rTableNames.end() != rTableNames.find( sGuess ) ) 319cdf0e10cSrcweir getSettings().sSelectedTable = sGuess; 320cdf0e10cSrcweir } 321cdf0e10cSrcweir 322cdf0e10cSrcweir //--------------------------------------------------------------------- implDoAutoFieldMapping()323cdf0e10cSrcweir void OAddessBookSourcePilot::implDoAutoFieldMapping() 324cdf0e10cSrcweir { 325cdf0e10cSrcweir DBG_ASSERT( !needManualFieldMapping( ), "OAddessBookSourcePilot::implDoAutoFieldMapping: invalid call!" ); 326cdf0e10cSrcweir 327cdf0e10cSrcweir fieldmapping::defaultMapping( getORB(), m_aSettings.aFieldMapping ); 328cdf0e10cSrcweir } 329cdf0e10cSrcweir 330cdf0e10cSrcweir //--------------------------------------------------------------------- implCreateDataSource()331cdf0e10cSrcweir void OAddessBookSourcePilot::implCreateDataSource() 332cdf0e10cSrcweir { 333cdf0e10cSrcweir if (m_aNewDataSource.isValid()) 334cdf0e10cSrcweir { // we already have a data source object 335cdf0e10cSrcweir if ( m_aSettings.eType == m_eNewDataSourceType ) 336cdf0e10cSrcweir // and it already has the correct type 337cdf0e10cSrcweir return; 338cdf0e10cSrcweir 339cdf0e10cSrcweir // it has a wrong type -> remove it 340cdf0e10cSrcweir m_aNewDataSource.remove(); 341cdf0e10cSrcweir } 342cdf0e10cSrcweir 343cdf0e10cSrcweir ODataSourceContext aContext( getORB() ); 344cdf0e10cSrcweir aContext.disambiguate( m_aSettings.sDataSourceName ); 345cdf0e10cSrcweir 346cdf0e10cSrcweir switch (m_aSettings.eType) 347cdf0e10cSrcweir { 348cdf0e10cSrcweir case AST_THUNDERBIRD: 349cdf0e10cSrcweir m_aNewDataSource = aContext.createNewThunderbird( m_aSettings.sDataSourceName ); 350cdf0e10cSrcweir break; 351cdf0e10cSrcweir 352cdf0e10cSrcweir case AST_EVOLUTION: 353cdf0e10cSrcweir m_aNewDataSource = aContext.createNewEvolution( m_aSettings.sDataSourceName ); 354cdf0e10cSrcweir break; 355cdf0e10cSrcweir 356cdf0e10cSrcweir case AST_EVOLUTION_GROUPWISE: 357cdf0e10cSrcweir m_aNewDataSource = aContext.createNewEvolutionGroupwise( m_aSettings.sDataSourceName ); 358cdf0e10cSrcweir break; 359cdf0e10cSrcweir 360cdf0e10cSrcweir case AST_EVOLUTION_LDAP: 361cdf0e10cSrcweir m_aNewDataSource = aContext.createNewEvolutionLdap( m_aSettings.sDataSourceName ); 362cdf0e10cSrcweir break; 363cdf0e10cSrcweir 364cdf0e10cSrcweir case AST_KAB: 365cdf0e10cSrcweir m_aNewDataSource = aContext.createNewKab( m_aSettings.sDataSourceName ); 366cdf0e10cSrcweir break; 367cdf0e10cSrcweir 368cdf0e10cSrcweir case AST_MACAB: 369cdf0e10cSrcweir m_aNewDataSource = aContext.createNewMacab( m_aSettings.sDataSourceName ); 370cdf0e10cSrcweir break; 371cdf0e10cSrcweir 372cdf0e10cSrcweir case AST_LDAP: 373cdf0e10cSrcweir m_aNewDataSource = aContext.createNewLDAP( m_aSettings.sDataSourceName ); 374cdf0e10cSrcweir break; 375cdf0e10cSrcweir 376cdf0e10cSrcweir case AST_OUTLOOK: 377cdf0e10cSrcweir m_aNewDataSource = aContext.createNewOutlook( m_aSettings.sDataSourceName ); 378cdf0e10cSrcweir break; 379cdf0e10cSrcweir 380cdf0e10cSrcweir case AST_OE: 381cdf0e10cSrcweir m_aNewDataSource = aContext.createNewOE( m_aSettings.sDataSourceName ); 382cdf0e10cSrcweir break; 383cdf0e10cSrcweir 384cdf0e10cSrcweir case AST_OTHER: 385cdf0e10cSrcweir m_aNewDataSource = aContext.createNewDBase( m_aSettings.sDataSourceName ); 386cdf0e10cSrcweir break; 387cdf0e10cSrcweir 388cdf0e10cSrcweir case AST_INVALID: 389cdf0e10cSrcweir DBG_ERROR( "OAddessBookSourcePilot::implCreateDataSource: illegal data source type!" ); 390cdf0e10cSrcweir break; 391cdf0e10cSrcweir } 392cdf0e10cSrcweir m_eNewDataSourceType = m_aSettings.eType; 393cdf0e10cSrcweir } 394cdf0e10cSrcweir 395cdf0e10cSrcweir //--------------------------------------------------------------------- connectToDataSource(sal_Bool _bForceReConnect)396cdf0e10cSrcweir sal_Bool OAddessBookSourcePilot::connectToDataSource( sal_Bool _bForceReConnect ) 397cdf0e10cSrcweir { 398cdf0e10cSrcweir DBG_ASSERT( m_aNewDataSource.isValid(), "OAddessBookSourcePilot::implConnect: invalid current data source!" ); 399cdf0e10cSrcweir 400cdf0e10cSrcweir WaitObject aWaitCursor( this ); 401cdf0e10cSrcweir if ( _bForceReConnect && m_aNewDataSource.isConnected( ) ) 402cdf0e10cSrcweir m_aNewDataSource.disconnect( ); 403cdf0e10cSrcweir 404cdf0e10cSrcweir return m_aNewDataSource.connect( this ); 405cdf0e10cSrcweir } 406cdf0e10cSrcweir 407cdf0e10cSrcweir //--------------------------------------------------------------------- createPage(WizardState _nState)408cdf0e10cSrcweir OWizardPage* OAddessBookSourcePilot::createPage(WizardState _nState) 409cdf0e10cSrcweir { 410cdf0e10cSrcweir switch (_nState) 411cdf0e10cSrcweir { 412cdf0e10cSrcweir case STATE_SELECT_ABTYPE: 413cdf0e10cSrcweir return new TypeSelectionPage( this ); 414cdf0e10cSrcweir 415cdf0e10cSrcweir case STATE_INVOKE_ADMIN_DIALOG: 416cdf0e10cSrcweir return new AdminDialogInvokationPage( this ); 417cdf0e10cSrcweir 418cdf0e10cSrcweir case STATE_TABLE_SELECTION: 419cdf0e10cSrcweir return new TableSelectionPage( this ); 420cdf0e10cSrcweir 421cdf0e10cSrcweir case STATE_MANUAL_FIELD_MAPPING: 422cdf0e10cSrcweir return new FieldMappingPage( this ); 423cdf0e10cSrcweir 424cdf0e10cSrcweir case STATE_FINAL_CONFIRM: 425cdf0e10cSrcweir return new FinalPage( this ); 426cdf0e10cSrcweir 427cdf0e10cSrcweir default: 428cdf0e10cSrcweir DBG_ERROR("OAddessBookSourcePilot::createPage: invalid state!"); 429cdf0e10cSrcweir return NULL; 430cdf0e10cSrcweir } 431cdf0e10cSrcweir } 432cdf0e10cSrcweir 433cdf0e10cSrcweir //--------------------------------------------------------------------- impl_updateRoadmap(AddressSourceType _eType)434cdf0e10cSrcweir void OAddessBookSourcePilot::impl_updateRoadmap( AddressSourceType _eType ) 435cdf0e10cSrcweir { 436cdf0e10cSrcweir bool bSettingsPage = needAdminInvokationPage( _eType ); 437cdf0e10cSrcweir bool bTablesPage = needTableSelection( _eType ); 438cdf0e10cSrcweir bool bFieldsPage = needManualFieldMapping( _eType ); 439cdf0e10cSrcweir 440cdf0e10cSrcweir bool bConnected = m_aNewDataSource.isConnected(); 441cdf0e10cSrcweir bool bCanSkipTables = 442cdf0e10cSrcweir ( m_aNewDataSource.hasTable( m_aSettings.sSelectedTable ) 443cdf0e10cSrcweir || m_aSettings.bIgnoreNoTable 444cdf0e10cSrcweir ); 445cdf0e10cSrcweir 446cdf0e10cSrcweir enableState( STATE_INVOKE_ADMIN_DIALOG, bSettingsPage ); 447cdf0e10cSrcweir 448cdf0e10cSrcweir enableState( STATE_TABLE_SELECTION, 449cdf0e10cSrcweir bTablesPage && ( bConnected ? !bCanSkipTables : !bSettingsPage ) 450cdf0e10cSrcweir // if we do not need a settings page, we connect upon "Next" on the first page 451cdf0e10cSrcweir ); 452cdf0e10cSrcweir 453cdf0e10cSrcweir enableState( STATE_MANUAL_FIELD_MAPPING, 454cdf0e10cSrcweir bFieldsPage && bConnected && m_aNewDataSource.hasTable( m_aSettings.sSelectedTable ) 455cdf0e10cSrcweir ); 456cdf0e10cSrcweir 457cdf0e10cSrcweir enableState( STATE_FINAL_CONFIRM, 458cdf0e10cSrcweir bConnected && bCanSkipTables 459cdf0e10cSrcweir ); 460cdf0e10cSrcweir } 461cdf0e10cSrcweir 462cdf0e10cSrcweir //--------------------------------------------------------------------- typeSelectionChanged(AddressSourceType _eType)463cdf0e10cSrcweir void OAddessBookSourcePilot::typeSelectionChanged( AddressSourceType _eType ) 464cdf0e10cSrcweir { 465cdf0e10cSrcweir PathId nCurrentPathID( PATH_COMPLETE ); 466cdf0e10cSrcweir bool bSettingsPage = needAdminInvokationPage( _eType ); 467cdf0e10cSrcweir bool bFieldsPage = needManualFieldMapping( _eType ); 468cdf0e10cSrcweir if ( !bSettingsPage ) 469cdf0e10cSrcweir if ( !bFieldsPage ) 470cdf0e10cSrcweir nCurrentPathID = PATH_NO_SETTINGS_NO_FIELDS; 471cdf0e10cSrcweir else 472cdf0e10cSrcweir nCurrentPathID = PATH_NO_SETTINGS; 473cdf0e10cSrcweir else 474cdf0e10cSrcweir if ( !bFieldsPage ) 475cdf0e10cSrcweir nCurrentPathID = PATH_NO_FIELDS; 476cdf0e10cSrcweir else 477cdf0e10cSrcweir nCurrentPathID = PATH_COMPLETE; 478cdf0e10cSrcweir activatePath( nCurrentPathID, true ); 479cdf0e10cSrcweir 480cdf0e10cSrcweir m_aNewDataSource.disconnect(); 481cdf0e10cSrcweir m_aSettings.bIgnoreNoTable = false; 482cdf0e10cSrcweir impl_updateRoadmap( _eType ); 483cdf0e10cSrcweir } 484cdf0e10cSrcweir 485cdf0e10cSrcweir //......................................................................... 486cdf0e10cSrcweir } // namespace abp 487*7dbe28d4SMatthias Seidel 488*7dbe28d4SMatthias Seidel /* vim: set noet sw=4 ts=4: */ 489