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