1cdf0e10cSrcweir /************************************************************************* 2cdf0e10cSrcweir * 3cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4cdf0e10cSrcweir * 5cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6cdf0e10cSrcweir * 7cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8cdf0e10cSrcweir * 9cdf0e10cSrcweir * This file is part of OpenOffice.org. 10cdf0e10cSrcweir * 11cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14cdf0e10cSrcweir * 15cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20cdf0e10cSrcweir * 21cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25cdf0e10cSrcweir * 26cdf0e10cSrcweir ************************************************************************/ 27cdf0e10cSrcweir 28cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29cdf0e10cSrcweir #include "precompiled_desktop.hxx" 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <migration.hxx> 32cdf0e10cSrcweir #include "wizard.hxx" 33cdf0e10cSrcweir #include "wizard.hrc" 34cdf0e10cSrcweir #include "pages.hxx" 35cdf0e10cSrcweir #include "app.hxx" 36cdf0e10cSrcweir 37cdf0e10cSrcweir #include <rtl/ustring.hxx> 38cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 39cdf0e10cSrcweir #include <rtl/string.hxx> 40cdf0e10cSrcweir #include <rtl/strbuf.hxx> 41cdf0e10cSrcweir #include <rtl/bootstrap.hxx> 42cdf0e10cSrcweir 43cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 44cdf0e10cSrcweir #include <tools/date.hxx> 45cdf0e10cSrcweir #include <tools/time.hxx> 46cdf0e10cSrcweir #include <tools/datetime.hxx> 47cdf0e10cSrcweir #include <osl/file.hxx> 48cdf0e10cSrcweir #include <osl/time.h> 49cdf0e10cSrcweir #include <osl/module.hxx> 50cdf0e10cSrcweir #include <unotools/bootstrap.hxx> 51cdf0e10cSrcweir #include <vcl/msgbox.hxx> 52cdf0e10cSrcweir 53cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx> 54cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 55cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp> 56cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 57cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyState.hpp> 58cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp> 59cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 60cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 61cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp> 62cdf0e10cSrcweir #include <com/sun/star/util/XChangesBatch.hpp> 63cdf0e10cSrcweir #include <com/sun/star/container/XNameReplace.hpp> 64cdf0e10cSrcweir #include <com/sun/star/awt/WindowDescriptor.hpp> 65cdf0e10cSrcweir #include <com/sun/star/awt/WindowAttribute.hpp> 66cdf0e10cSrcweir 67cdf0e10cSrcweir using namespace svt; 68cdf0e10cSrcweir using namespace rtl; 69cdf0e10cSrcweir using namespace osl; 70cdf0e10cSrcweir using namespace utl; 71cdf0e10cSrcweir using namespace com::sun::star; 72cdf0e10cSrcweir using namespace com::sun::star::uno; 73cdf0e10cSrcweir using namespace com::sun::star::lang; 74cdf0e10cSrcweir using namespace com::sun::star::beans; 75cdf0e10cSrcweir using namespace com::sun::star::util; 76cdf0e10cSrcweir using namespace com::sun::star::container; 77cdf0e10cSrcweir 78cdf0e10cSrcweir #define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) 79cdf0e10cSrcweir 80cdf0e10cSrcweir namespace desktop 81cdf0e10cSrcweir { 82cdf0e10cSrcweir 83cdf0e10cSrcweir const FirstStartWizard::WizardState FirstStartWizard::STATE_WELCOME = 0; 84cdf0e10cSrcweir const FirstStartWizard::WizardState FirstStartWizard::STATE_LICENSE = 1; 85cdf0e10cSrcweir const FirstStartWizard::WizardState FirstStartWizard::STATE_MIGRATION = 2; 86cdf0e10cSrcweir const FirstStartWizard::WizardState FirstStartWizard::STATE_USER = 3; 87cdf0e10cSrcweir const FirstStartWizard::WizardState FirstStartWizard::STATE_UPDATE_CHECK = 4; 88cdf0e10cSrcweir const FirstStartWizard::WizardState FirstStartWizard::STATE_REGISTRATION = 5; 89cdf0e10cSrcweir 90cdf0e10cSrcweir static sal_Int32 getBuildId() 91cdf0e10cSrcweir { 92cdf0e10cSrcweir ::rtl::OUString aDefault; 93cdf0e10cSrcweir ::rtl::OUString aBuildIdData = utl::Bootstrap::getBuildIdData( aDefault ); 94cdf0e10cSrcweir sal_Int32 nBuildId( 0 ); 95cdf0e10cSrcweir sal_Int32 nIndex1 = aBuildIdData.indexOf(':'); 96cdf0e10cSrcweir sal_Int32 nIndex2 = aBuildIdData.indexOf(')'); 97cdf0e10cSrcweir if (( nIndex1 > 0 ) && ( nIndex2 > 0 ) && ( nIndex2-1 > nIndex1+1 )) 98cdf0e10cSrcweir { 99cdf0e10cSrcweir ::rtl::OUString aBuildId = aBuildIdData.copy( nIndex1+1, nIndex2-nIndex1-1 ); 100cdf0e10cSrcweir nBuildId = aBuildId.toInt32(); 101cdf0e10cSrcweir } 102cdf0e10cSrcweir return nBuildId; 103cdf0e10cSrcweir } 104cdf0e10cSrcweir 105cdf0e10cSrcweir WizardResId::WizardResId( sal_uInt16 nId ) : 106cdf0e10cSrcweir ResId( nId, *FirstStartWizard::GetResManager() ) 107cdf0e10cSrcweir { 108cdf0e10cSrcweir } 109cdf0e10cSrcweir 110cdf0e10cSrcweir ResMgr *FirstStartWizard::pResMgr = 0; 111cdf0e10cSrcweir 112cdf0e10cSrcweir ResMgr *FirstStartWizard::GetResManager() 113cdf0e10cSrcweir { 114cdf0e10cSrcweir if ( !FirstStartWizard::pResMgr ) 115cdf0e10cSrcweir { 116cdf0e10cSrcweir String aMgrName = String::CreateFromAscii( "dkt" ); 117cdf0e10cSrcweir FirstStartWizard::pResMgr = ResMgr::CreateResMgr( OUStringToOString( aMgrName, RTL_TEXTENCODING_UTF8 )); 118cdf0e10cSrcweir } 119cdf0e10cSrcweir return FirstStartWizard::pResMgr; 120cdf0e10cSrcweir } 121cdf0e10cSrcweir 122cdf0e10cSrcweir FirstStartWizard::FirstStartWizard( Window* pParent, sal_Bool bLicenseNeedsAcceptance, const rtl::OUString &rLicensePath ) 123cdf0e10cSrcweir :RoadmapWizard( pParent, WizardResId(DLG_FIRSTSTART_WIZARD), 124cdf0e10cSrcweir WZB_NEXT|WZB_PREVIOUS|WZB_FINISH|WZB_CANCEL|WZB_HELP) 125cdf0e10cSrcweir ,m_bOverride(sal_False) 126cdf0e10cSrcweir ,m_aDefaultPath(0) 127cdf0e10cSrcweir ,m_aMigrationPath(0) 128cdf0e10cSrcweir ,m_bDone(sal_False) 129cdf0e10cSrcweir ,m_bLicenseNeedsAcceptance( bLicenseNeedsAcceptance ) 130cdf0e10cSrcweir ,m_bLicenseWasAccepted(sal_False) 131cdf0e10cSrcweir ,m_bAutomaticUpdChk(sal_True) 132cdf0e10cSrcweir ,m_aThrobber(this, WizardResId(CTRL_THROBBER)) 133cdf0e10cSrcweir ,m_aLicensePath( rLicensePath ) 134cdf0e10cSrcweir { 135cdf0e10cSrcweir FreeResource(); 136cdf0e10cSrcweir // --- 137cdf0e10cSrcweir // enableState(STATE_USER, sal_False); 138cdf0e10cSrcweir // enableState(STATE_REGISTRATION, sal_False); 139cdf0e10cSrcweir 140cdf0e10cSrcweir Size aTPSize(TP_WIDTH, TP_HEIGHT); 141cdf0e10cSrcweir SetPageSizePixel(LogicToPixel(aTPSize, MAP_APPFONT)); 142cdf0e10cSrcweir 143cdf0e10cSrcweir //set help id 144cdf0e10cSrcweir m_pPrevPage->SetHelpId(HID_FIRSTSTART_PREV); 145cdf0e10cSrcweir m_pNextPage->SetHelpId(HID_FIRSTSTART_NEXT); 146cdf0e10cSrcweir m_pCancel->SetHelpId(HID_FIRSTSTART_CANCEL); 147cdf0e10cSrcweir m_pFinish->SetHelpId(HID_FIRSTSTART_FINISH); 148cdf0e10cSrcweir // m_pHelp->SetUniqueId(UID_FIRSTSTART_HELP); 149cdf0e10cSrcweir m_pHelp->Hide(); 150cdf0e10cSrcweir m_pHelp->Disable(); 151cdf0e10cSrcweir 152cdf0e10cSrcweir // save button lables 153cdf0e10cSrcweir m_sNext = m_pNextPage->GetText(); 154cdf0e10cSrcweir m_sCancel = m_pCancel->GetText(); 155cdf0e10cSrcweir 156cdf0e10cSrcweir // save cancel click handler 157cdf0e10cSrcweir m_lnkCancel = m_pCancel->GetClickHdl(); 158cdf0e10cSrcweir 159cdf0e10cSrcweir m_aDefaultPath = defineWizardPagesDependingFromContext(); 160cdf0e10cSrcweir activatePath(m_aDefaultPath, sal_True); 161cdf0e10cSrcweir 162cdf0e10cSrcweir ActivatePage(); 163cdf0e10cSrcweir 164cdf0e10cSrcweir // set text of finish putton: 165cdf0e10cSrcweir m_pFinish->SetText(String(WizardResId(STR_FINISH))); 166cdf0e10cSrcweir // disable "finish button" 167cdf0e10cSrcweir enableButtons(WZB_FINISH, sal_False); 168cdf0e10cSrcweir defaultButton(WZB_NEXT); 169cdf0e10cSrcweir } 170cdf0e10cSrcweir 171cdf0e10cSrcweir void FirstStartWizard::DisableButtonsWhileMigration() 172cdf0e10cSrcweir { 173cdf0e10cSrcweir enableButtons(0xff, sal_False); 174cdf0e10cSrcweir } 175cdf0e10cSrcweir 176cdf0e10cSrcweir ::svt::RoadmapWizardTypes::PathId FirstStartWizard::defineWizardPagesDependingFromContext() 177cdf0e10cSrcweir { 178cdf0e10cSrcweir ::svt::RoadmapWizardTypes::PathId aDefaultPath = 0; 179cdf0e10cSrcweir 180cdf0e10cSrcweir sal_Bool bPage_Welcome = sal_True; 181cdf0e10cSrcweir sal_Bool bPage_Migration = sal_True; 182cdf0e10cSrcweir sal_Bool bPage_User = sal_True; 183cdf0e10cSrcweir sal_Bool bPage_UpdateCheck = sal_True; 184cdf0e10cSrcweir 185cdf0e10cSrcweir bPage_Migration = Migration::checkMigration(); 186cdf0e10cSrcweir bPage_UpdateCheck = showOnlineUpdatePage(); 187cdf0e10cSrcweir 188cdf0e10cSrcweir WizardPath aPath; 189cdf0e10cSrcweir if (bPage_Welcome) 190cdf0e10cSrcweir aPath.push_back(STATE_WELCOME); 191cdf0e10cSrcweir if (bPage_Migration) 192cdf0e10cSrcweir aPath.push_back(STATE_MIGRATION); 193cdf0e10cSrcweir if (bPage_User) 194cdf0e10cSrcweir aPath.push_back(STATE_USER); 195cdf0e10cSrcweir if (bPage_UpdateCheck) 196cdf0e10cSrcweir aPath.push_back(STATE_UPDATE_CHECK); 197cdf0e10cSrcweir 198cdf0e10cSrcweir declarePath(aDefaultPath, aPath); 199cdf0e10cSrcweir 200cdf0e10cSrcweir // a) If license must be accepted by the user, all direct links 201cdf0e10cSrcweir // to wizard tab pages must be disabled. Because such pages 202cdf0e10cSrcweir // should be accessible only in case license was accepted ! 203cdf0e10cSrcweir // b) But if no license should be shown at all ... 204cdf0e10cSrcweir // such direct links can be enabled by default. 205*288ab9e2SHerbert Dürr sal_Bool bAllowDirectLink = true; 206cdf0e10cSrcweir 207cdf0e10cSrcweir if (bPage_User) 208cdf0e10cSrcweir enableState(STATE_USER, bAllowDirectLink); 209cdf0e10cSrcweir if (bPage_UpdateCheck) 210cdf0e10cSrcweir enableState(STATE_UPDATE_CHECK, bAllowDirectLink); 211cdf0e10cSrcweir if (bPage_Migration) 212cdf0e10cSrcweir enableState(STATE_MIGRATION, bAllowDirectLink); 213cdf0e10cSrcweir 214cdf0e10cSrcweir return aDefaultPath; 215cdf0e10cSrcweir } 216cdf0e10cSrcweir 217cdf0e10cSrcweir // catch F1 and disable help 218cdf0e10cSrcweir long FirstStartWizard::PreNotify( NotifyEvent& rNEvt ) 219cdf0e10cSrcweir { 220cdf0e10cSrcweir if( rNEvt.GetType() == EVENT_KEYINPUT ) 221cdf0e10cSrcweir { 222cdf0e10cSrcweir const KeyCode& rKey = rNEvt.GetKeyEvent()->GetKeyCode(); 223cdf0e10cSrcweir if( rKey.GetCode() == KEY_F1 && ! rKey.GetModifier() ) 224cdf0e10cSrcweir return sal_True; 225cdf0e10cSrcweir } 226cdf0e10cSrcweir return RoadmapWizard::PreNotify(rNEvt); 227cdf0e10cSrcweir } 228cdf0e10cSrcweir 229cdf0e10cSrcweir 230cdf0e10cSrcweir void FirstStartWizard::enterState(WizardState _nState) 231cdf0e10cSrcweir { 232cdf0e10cSrcweir RoadmapWizard::enterState(_nState); 233cdf0e10cSrcweir // default state 234cdf0e10cSrcweir // all on 235cdf0e10cSrcweir enableButtons(0xff, sal_True); 236cdf0e10cSrcweir // finish off 237cdf0e10cSrcweir enableButtons(WZB_FINISH, sal_False); 238cdf0e10cSrcweir // default text 239cdf0e10cSrcweir m_pCancel->SetText(m_sCancel); 240cdf0e10cSrcweir m_pCancel->SetClickHdl(m_lnkCancel); 241cdf0e10cSrcweir m_pNextPage->SetText(m_sNext); 242cdf0e10cSrcweir 243cdf0e10cSrcweir // default 244cdf0e10cSrcweir defaultButton(WZB_NEXT); 245cdf0e10cSrcweir 246cdf0e10cSrcweir // specialized state 247cdf0e10cSrcweir switch (_nState) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir case STATE_WELCOME: 250cdf0e10cSrcweir enableButtons(WZB_PREVIOUS, sal_False); 251cdf0e10cSrcweir break; 252cdf0e10cSrcweir case STATE_LICENSE: 253cdf0e10cSrcweir m_pCancel->SetText(String(WizardResId(STR_LICENSE_DECLINE))); 254cdf0e10cSrcweir m_pNextPage->SetText(String(WizardResId(STR_LICENSE_ACCEPT))); 255cdf0e10cSrcweir enableButtons(WZB_NEXT, sal_False); 256cdf0e10cSrcweir // attach warning dialog to cancel/decline button 257cdf0e10cSrcweir m_pCancel->SetClickHdl( LINK(this, FirstStartWizard, DeclineHdl) ); 258cdf0e10cSrcweir break; 259cdf0e10cSrcweir case STATE_REGISTRATION: 260cdf0e10cSrcweir enableButtons(WZB_NEXT, sal_False); 261cdf0e10cSrcweir enableButtons(WZB_FINISH, sal_True); 262cdf0e10cSrcweir defaultButton(WZB_FINISH); 263cdf0e10cSrcweir break; 264cdf0e10cSrcweir } 265cdf0e10cSrcweir 266cdf0e10cSrcweir // focus 267cdf0e10cSrcweir 268cdf0e10cSrcweir } 269cdf0e10cSrcweir 270cdf0e10cSrcweir IMPL_LINK( FirstStartWizard, DeclineHdl, PushButton *, EMPTYARG ) 271cdf0e10cSrcweir { 272cdf0e10cSrcweir QueryBox aBox(this, WizardResId(QB_ASK_DECLINE)); 273cdf0e10cSrcweir sal_Int32 ret = aBox.Execute(); 274cdf0e10cSrcweir if ( ret == BUTTON_OK || ret == BUTTON_YES) 275cdf0e10cSrcweir { 276cdf0e10cSrcweir Close(); 277cdf0e10cSrcweir return sal_False; 278cdf0e10cSrcweir } 279cdf0e10cSrcweir else 280cdf0e10cSrcweir return sal_True; 281cdf0e10cSrcweir } 282cdf0e10cSrcweir 283cdf0e10cSrcweir 284cdf0e10cSrcweir TabPage* FirstStartWizard::createPage(WizardState _nState) 285cdf0e10cSrcweir { 286cdf0e10cSrcweir TabPage *pTabPage = 0; 287cdf0e10cSrcweir switch (_nState) 288cdf0e10cSrcweir { 289cdf0e10cSrcweir case STATE_WELCOME: 290cdf0e10cSrcweir pTabPage = new WelcomePage(this, WizardResId(TP_WELCOME), m_bLicenseNeedsAcceptance); 291cdf0e10cSrcweir break; 292cdf0e10cSrcweir case STATE_MIGRATION: 293cdf0e10cSrcweir pTabPage = new MigrationPage(this, WizardResId(TP_MIGRATION), m_aThrobber); 294cdf0e10cSrcweir break; 295cdf0e10cSrcweir case STATE_USER: 296cdf0e10cSrcweir pTabPage = new UserPage(this, WizardResId(TP_USER)); 297cdf0e10cSrcweir break; 298cdf0e10cSrcweir case STATE_UPDATE_CHECK: 299cdf0e10cSrcweir pTabPage = new UpdateCheckPage(this, WizardResId(TP_UPDATE_CHECK)); 300cdf0e10cSrcweir break; 301cdf0e10cSrcweir } 302cdf0e10cSrcweir pTabPage->Show(); 303cdf0e10cSrcweir 304cdf0e10cSrcweir return pTabPage; 305cdf0e10cSrcweir } 306cdf0e10cSrcweir 307cdf0e10cSrcweir String FirstStartWizard::getStateDisplayName( WizardState _nState ) const 308cdf0e10cSrcweir { 309cdf0e10cSrcweir String sName; 310cdf0e10cSrcweir switch(_nState) 311cdf0e10cSrcweir { 312cdf0e10cSrcweir case STATE_WELCOME: 313cdf0e10cSrcweir sName = String(WizardResId(STR_STATE_WELCOME)); 314cdf0e10cSrcweir break; 315cdf0e10cSrcweir case STATE_MIGRATION: 316cdf0e10cSrcweir sName = String(WizardResId(STR_STATE_MIGRATION)); 317cdf0e10cSrcweir break; 318cdf0e10cSrcweir case STATE_USER: 319cdf0e10cSrcweir sName = String(WizardResId(STR_STATE_USER)); 320cdf0e10cSrcweir break; 321cdf0e10cSrcweir case STATE_UPDATE_CHECK: 322cdf0e10cSrcweir sName = String(WizardResId(STR_STATE_UPDATE_CHECK)); 323cdf0e10cSrcweir break; 324cdf0e10cSrcweir } 325cdf0e10cSrcweir return sName; 326cdf0e10cSrcweir } 327cdf0e10cSrcweir 328cdf0e10cSrcweir sal_Bool FirstStartWizard::prepareLeaveCurrentState( CommitPageReason _eReason ) 329cdf0e10cSrcweir { 330cdf0e10cSrcweir // the license acceptance is handled here, because it needs to change the state 331cdf0e10cSrcweir // of the roadmap wizard which the page implementation does not know. 332cdf0e10cSrcweir if ( 333cdf0e10cSrcweir (_eReason == eTravelForward) && 334cdf0e10cSrcweir (getCurrentState() == STATE_LICENSE ) && 335cdf0e10cSrcweir (m_bLicenseWasAccepted == sal_False ) 336cdf0e10cSrcweir ) 337cdf0e10cSrcweir { 338cdf0e10cSrcweir if (Migration::checkMigration()) 339cdf0e10cSrcweir enableState(FirstStartWizard::STATE_MIGRATION, sal_True); 340cdf0e10cSrcweir if ( showOnlineUpdatePage() ) 341cdf0e10cSrcweir enableState(FirstStartWizard::STATE_UPDATE_CHECK, sal_True); 342cdf0e10cSrcweir enableState(FirstStartWizard::STATE_USER, sal_True); 343cdf0e10cSrcweir enableState(FirstStartWizard::STATE_REGISTRATION, sal_True); 344cdf0e10cSrcweir 345cdf0e10cSrcweir storeAcceptDate(); 346cdf0e10cSrcweir m_bLicenseWasAccepted = sal_True; 347cdf0e10cSrcweir } 348cdf0e10cSrcweir 349cdf0e10cSrcweir return svt::RoadmapWizard::prepareLeaveCurrentState(_eReason); 350cdf0e10cSrcweir } 351cdf0e10cSrcweir 352cdf0e10cSrcweir sal_Bool FirstStartWizard::leaveState(WizardState) 353cdf0e10cSrcweir { 354cdf0e10cSrcweir if (( getCurrentState() == STATE_MIGRATION ) && m_bLicenseWasAccepted ) 355cdf0e10cSrcweir { 356cdf0e10cSrcweir // Store accept date and patch level now as it has been 357cdf0e10cSrcweir // overwritten by the migration process! 358cdf0e10cSrcweir storeAcceptDate(); 359cdf0e10cSrcweir setPatchLevel(); 360cdf0e10cSrcweir } 361cdf0e10cSrcweir 362cdf0e10cSrcweir return sal_True; 363cdf0e10cSrcweir } 364cdf0e10cSrcweir 365cdf0e10cSrcweir sal_Bool FirstStartWizard::onFinish() 366cdf0e10cSrcweir { 367cdf0e10cSrcweir // return sal_True; 368cdf0e10cSrcweir if ( svt::RoadmapWizard::onFinish() ) 369cdf0e10cSrcweir { 370cdf0e10cSrcweir #ifndef OS2 // cannot enable quickstart on first startup, see shutdownicon.cxx comments. 371cdf0e10cSrcweir enableQuickstart(); 372cdf0e10cSrcweir #endif 373cdf0e10cSrcweir disableWizard(); 374cdf0e10cSrcweir return sal_True; 375cdf0e10cSrcweir } 376cdf0e10cSrcweir else 377cdf0e10cSrcweir return sal_False; 378cdf0e10cSrcweir } 379cdf0e10cSrcweir 380cdf0e10cSrcweir short FirstStartWizard::Execute() 381cdf0e10cSrcweir { 382cdf0e10cSrcweir return svt::RoadmapWizard::Execute(); 383cdf0e10cSrcweir } 384cdf0e10cSrcweir 385cdf0e10cSrcweir static OUString _makeDateTimeString (const DateTime& aDateTime, sal_Bool bUTC = sal_False) 386cdf0e10cSrcweir { 387cdf0e10cSrcweir OStringBuffer aDateTimeString; 388cdf0e10cSrcweir aDateTimeString.append((sal_Int32)aDateTime.GetYear()); 389cdf0e10cSrcweir aDateTimeString.append("-"); 390cdf0e10cSrcweir if (aDateTime.GetMonth()<10) aDateTimeString.append("0"); 391cdf0e10cSrcweir aDateTimeString.append((sal_Int32)aDateTime.GetMonth()); 392cdf0e10cSrcweir aDateTimeString.append("-"); 393cdf0e10cSrcweir if (aDateTime.GetDay()<10) aDateTimeString.append("0"); 394cdf0e10cSrcweir aDateTimeString.append((sal_Int32)aDateTime.GetDay()); 395cdf0e10cSrcweir aDateTimeString.append("T"); 396cdf0e10cSrcweir if (aDateTime.GetHour()<10) aDateTimeString.append("0"); 397cdf0e10cSrcweir aDateTimeString.append((sal_Int32)aDateTime.GetHour()); 398cdf0e10cSrcweir aDateTimeString.append(":"); 399cdf0e10cSrcweir if (aDateTime.GetMin()<10) aDateTimeString.append("0"); 400cdf0e10cSrcweir aDateTimeString.append((sal_Int32)aDateTime.GetMin()); 401cdf0e10cSrcweir aDateTimeString.append(":"); 402cdf0e10cSrcweir if (aDateTime.GetSec()<10) aDateTimeString.append("0"); 403cdf0e10cSrcweir aDateTimeString.append((sal_Int32)aDateTime.GetSec()); 404cdf0e10cSrcweir if (bUTC) aDateTimeString.append("Z"); 405cdf0e10cSrcweir 406cdf0e10cSrcweir return OStringToOUString(aDateTimeString.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US); 407cdf0e10cSrcweir } 408cdf0e10cSrcweir 409cdf0e10cSrcweir static OUString _getCurrentDateString() 410cdf0e10cSrcweir { 411cdf0e10cSrcweir OUString aString; 412cdf0e10cSrcweir return _makeDateTimeString(DateTime()); 413cdf0e10cSrcweir } 414cdf0e10cSrcweir 415cdf0e10cSrcweir 416cdf0e10cSrcweir static const OUString sConfigSrvc( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ); 417cdf0e10cSrcweir static const OUString sAccessSrvc( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess" ) ); 418cdf0e10cSrcweir static const OUString sReadSrvc ( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationAccess" ) ); 419cdf0e10cSrcweir 420cdf0e10cSrcweir void FirstStartWizard::storeAcceptDate() 421cdf0e10cSrcweir { 422cdf0e10cSrcweir 423cdf0e10cSrcweir try { 424cdf0e10cSrcweir Reference < XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); 425cdf0e10cSrcweir // get configuration provider 426cdf0e10cSrcweir Reference< XMultiServiceFactory > theConfigProvider = Reference< XMultiServiceFactory >( 427cdf0e10cSrcweir xFactory->createInstance(sConfigSrvc), UNO_QUERY_THROW); 428cdf0e10cSrcweir Sequence< Any > theArgs(1); 429cdf0e10cSrcweir NamedValue v(OUString::createFromAscii("NodePath"), 430cdf0e10cSrcweir makeAny(OUString::createFromAscii("org.openoffice.Setup/Office"))); 431cdf0e10cSrcweir theArgs[0] <<= v; 432cdf0e10cSrcweir Reference< XPropertySet > pset = Reference< XPropertySet >( 433cdf0e10cSrcweir theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs), UNO_QUERY_THROW); 434cdf0e10cSrcweir Any result = pset->getPropertyValue(OUString::createFromAscii("LicenseAcceptDate")); 435cdf0e10cSrcweir 436cdf0e10cSrcweir OUString aAcceptDate = _getCurrentDateString(); 437cdf0e10cSrcweir pset->setPropertyValue(OUString::createFromAscii("LicenseAcceptDate"), makeAny(aAcceptDate)); 438cdf0e10cSrcweir Reference< XChangesBatch >(pset, UNO_QUERY_THROW)->commitChanges(); 439cdf0e10cSrcweir 440cdf0e10cSrcweir // since the license is accepted the local user registry can be cleaned if required 441cdf0e10cSrcweir cleanOldOfficeRegKeys(); 442cdf0e10cSrcweir } catch (const Exception&) 443cdf0e10cSrcweir { 444cdf0e10cSrcweir } 445cdf0e10cSrcweir 446cdf0e10cSrcweir } 447cdf0e10cSrcweir 448cdf0e10cSrcweir void FirstStartWizard::setPatchLevel() 449cdf0e10cSrcweir { 450cdf0e10cSrcweir try { 451cdf0e10cSrcweir Reference < XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); 452cdf0e10cSrcweir // get configuration provider 453cdf0e10cSrcweir Reference< XMultiServiceFactory > theConfigProvider = Reference< XMultiServiceFactory >( 454cdf0e10cSrcweir xFactory->createInstance(sConfigSrvc), UNO_QUERY_THROW); 455cdf0e10cSrcweir Sequence< Any > theArgs(1); 456cdf0e10cSrcweir NamedValue v(OUString::createFromAscii("NodePath"), 457cdf0e10cSrcweir makeAny(OUString::createFromAscii("org.openoffice.Office.Common/Help/Registration"))); 458cdf0e10cSrcweir theArgs[0] <<= v; 459cdf0e10cSrcweir Reference< XPropertySet > pset = Reference< XPropertySet >( 460cdf0e10cSrcweir theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs), UNO_QUERY_THROW); 461cdf0e10cSrcweir Any result = pset->getPropertyValue(OUString::createFromAscii("ReminderDate")); 462cdf0e10cSrcweir 463cdf0e10cSrcweir OUString aPatchLevel( RTL_CONSTASCII_USTRINGPARAM( "Patch" )); 464cdf0e10cSrcweir aPatchLevel += OUString::valueOf( getBuildId(), 10 ); 465cdf0e10cSrcweir pset->setPropertyValue(OUString::createFromAscii("ReminderDate"), makeAny(aPatchLevel)); 466cdf0e10cSrcweir Reference< XChangesBatch >(pset, UNO_QUERY_THROW)->commitChanges(); 467cdf0e10cSrcweir } catch (const Exception&) 468cdf0e10cSrcweir { 469cdf0e10cSrcweir } 470cdf0e10cSrcweir } 471cdf0e10cSrcweir 472cdf0e10cSrcweir #ifdef WNT 473cdf0e10cSrcweir typedef int ( __stdcall * CleanCurUserRegProc ) ( wchar_t* ); 474cdf0e10cSrcweir #endif 475cdf0e10cSrcweir 476cdf0e10cSrcweir void FirstStartWizard::cleanOldOfficeRegKeys() 477cdf0e10cSrcweir { 478cdf0e10cSrcweir #ifdef WNT 479cdf0e10cSrcweir // after the wizard is completed clean OOo1.1.x entries in the current user registry if required 480cdf0e10cSrcweir // issue i47658 481cdf0e10cSrcweir 482cdf0e10cSrcweir OUString aBaseLocationPath; 483cdf0e10cSrcweir OUString aSharedLocationPath; 484cdf0e10cSrcweir OUString aInstallMode; 485cdf0e10cSrcweir 486cdf0e10cSrcweir ::utl::Bootstrap::PathStatus aBaseLocateResult = 487cdf0e10cSrcweir ::utl::Bootstrap::locateBaseInstallation( aBaseLocationPath ); 488cdf0e10cSrcweir ::utl::Bootstrap::PathStatus aSharedLocateResult = 489cdf0e10cSrcweir ::utl::Bootstrap::locateSharedData( aSharedLocationPath ); 490cdf0e10cSrcweir aInstallMode = ::utl::Bootstrap::getAllUsersValue( ::rtl::OUString() ); 491cdf0e10cSrcweir 492cdf0e10cSrcweir // TODO: replace the checking for install mode 493cdf0e10cSrcweir if ( aBaseLocateResult == ::utl::Bootstrap::PATH_EXISTS && aSharedLocateResult == ::utl::Bootstrap::PATH_EXISTS 494cdf0e10cSrcweir && aInstallMode.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "1" ) ) ) ) 495cdf0e10cSrcweir { 496cdf0e10cSrcweir ::rtl::OUString aDeregCompletePath = 497cdf0e10cSrcweir aBaseLocationPath + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/program/regcleanold.dll" ) ); 498cdf0e10cSrcweir ::rtl::OUString aExecCompletePath = 499cdf0e10cSrcweir aSharedLocationPath + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/regdeinstall/userdeinst.exe" ) ); 500cdf0e10cSrcweir 501cdf0e10cSrcweir osl::Module aCleanModule( aDeregCompletePath ); 502cdf0e10cSrcweir CleanCurUserRegProc pNativeProc = ( CleanCurUserRegProc )( 503cdf0e10cSrcweir aCleanModule.getFunctionSymbol( 504cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CleanCurUserOldSystemRegistry" ) ) ) ); 505cdf0e10cSrcweir 506cdf0e10cSrcweir if( pNativeProc!=NULL ) 507cdf0e10cSrcweir { 508cdf0e10cSrcweir ::rtl::OUString aExecCompleteSysPath; 509cdf0e10cSrcweir if ( osl::File::getSystemPathFromFileURL( aExecCompletePath, aExecCompleteSysPath ) == FileBase::E_None 510cdf0e10cSrcweir && aExecCompleteSysPath.getLength() ) 511cdf0e10cSrcweir { 512cdf0e10cSrcweir ( *pNativeProc )( (wchar_t*)( aExecCompleteSysPath.getStr() ) ); 513cdf0e10cSrcweir } 514cdf0e10cSrcweir } 515cdf0e10cSrcweir } 516cdf0e10cSrcweir #endif 517cdf0e10cSrcweir } 518cdf0e10cSrcweir 519cdf0e10cSrcweir void FirstStartWizard::disableWizard() 520cdf0e10cSrcweir { 521cdf0e10cSrcweir 522cdf0e10cSrcweir try { 523cdf0e10cSrcweir Reference < XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); 524cdf0e10cSrcweir // get configuration provider 525cdf0e10cSrcweir Reference< XMultiServiceFactory > theConfigProvider = Reference< XMultiServiceFactory >( 526cdf0e10cSrcweir xFactory->createInstance(sConfigSrvc), UNO_QUERY_THROW); 527cdf0e10cSrcweir Sequence< Any > theArgs(1); 528cdf0e10cSrcweir NamedValue v(OUString::createFromAscii("NodePath"), 529cdf0e10cSrcweir makeAny(OUString::createFromAscii("org.openoffice.Setup/Office"))); 530cdf0e10cSrcweir theArgs[0] <<= v; 531cdf0e10cSrcweir Reference< XPropertySet > pset = Reference< XPropertySet >( 532cdf0e10cSrcweir theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs), UNO_QUERY_THROW); 533cdf0e10cSrcweir pset->setPropertyValue(OUString::createFromAscii("FirstStartWizardCompleted"), makeAny(sal_True)); 534cdf0e10cSrcweir Reference< XChangesBatch >(pset, UNO_QUERY_THROW)->commitChanges(); 535cdf0e10cSrcweir } catch (const Exception&) 536cdf0e10cSrcweir { 537cdf0e10cSrcweir } 538cdf0e10cSrcweir 539cdf0e10cSrcweir } 540cdf0e10cSrcweir 541cdf0e10cSrcweir 542cdf0e10cSrcweir void FirstStartWizard::enableQuickstart() 543cdf0e10cSrcweir { 544cdf0e10cSrcweir sal_Bool bQuickstart( sal_True ); 545cdf0e10cSrcweir sal_Bool bAutostart( sal_True ); 546cdf0e10cSrcweir Sequence< Any > aSeq( 2 ); 547cdf0e10cSrcweir aSeq[0] <<= bQuickstart; 548cdf0e10cSrcweir aSeq[1] <<= bAutostart; 549cdf0e10cSrcweir 550cdf0e10cSrcweir Reference < XInitialization > xQuickstart( ::comphelper::getProcessServiceFactory()->createInstance( 551cdf0e10cSrcweir OUString::createFromAscii( "com.sun.star.office.Quickstart" )),UNO_QUERY ); 552cdf0e10cSrcweir if ( xQuickstart.is() ) 553cdf0e10cSrcweir xQuickstart->initialize( aSeq ); 554cdf0e10cSrcweir 555cdf0e10cSrcweir } 556cdf0e10cSrcweir 557cdf0e10cSrcweir sal_Bool FirstStartWizard::showOnlineUpdatePage() 558cdf0e10cSrcweir { 559cdf0e10cSrcweir try { 560cdf0e10cSrcweir Reference < XNameReplace > xUpdateAccess; 561cdf0e10cSrcweir Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); 562cdf0e10cSrcweir 563cdf0e10cSrcweir xUpdateAccess = Reference < XNameReplace >( 564cdf0e10cSrcweir xFactory->createInstance( UNISTRING( "com.sun.star.setup.UpdateCheckConfig" ) ), UNO_QUERY_THROW ); 565cdf0e10cSrcweir 566cdf0e10cSrcweir if ( xUpdateAccess.is() ) 567cdf0e10cSrcweir { 568cdf0e10cSrcweir sal_Bool bAutoUpdChk = sal_False; 569cdf0e10cSrcweir Any result = xUpdateAccess->getByName( UNISTRING( "AutoCheckEnabled" ) ); 570cdf0e10cSrcweir result >>= bAutoUpdChk; 571cdf0e10cSrcweir if ( bAutoUpdChk == sal_False ) 572cdf0e10cSrcweir return sal_True; 573cdf0e10cSrcweir else 574cdf0e10cSrcweir return sal_False; 575cdf0e10cSrcweir } 576cdf0e10cSrcweir } catch (const Exception&) 577cdf0e10cSrcweir { 578cdf0e10cSrcweir } 579cdf0e10cSrcweir return sal_False; 580cdf0e10cSrcweir } 581cdf0e10cSrcweir 582cdf0e10cSrcweir } 583