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