10a1e2f0eSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 30a1e2f0eSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 40a1e2f0eSAndrew Rist * or more contributor license agreements. See the NOTICE file 50a1e2f0eSAndrew Rist * distributed with this work for additional information 60a1e2f0eSAndrew Rist * regarding copyright ownership. The ASF licenses this file 70a1e2f0eSAndrew Rist * to you under the Apache License, Version 2.0 (the 80a1e2f0eSAndrew Rist * "License"); you may not use this file except in compliance 90a1e2f0eSAndrew Rist * with the License. You may obtain a copy of the License at 100a1e2f0eSAndrew Rist * 110a1e2f0eSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 120a1e2f0eSAndrew Rist * 130a1e2f0eSAndrew Rist * Unless required by applicable law or agreed to in writing, 140a1e2f0eSAndrew Rist * software distributed under the License is distributed on an 150a1e2f0eSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 160a1e2f0eSAndrew Rist * KIND, either express or implied. See the License for the 170a1e2f0eSAndrew Rist * specific language governing permissions and limitations 180a1e2f0eSAndrew Rist * under the License. 190a1e2f0eSAndrew Rist * 200a1e2f0eSAndrew Rist *************************************************************/ 210a1e2f0eSAndrew Rist 220a1e2f0eSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _DESKTOP_APP_HXX_ 25cdf0e10cSrcweir #define _DESKTOP_APP_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir // stl includes first 28cdf0e10cSrcweir #include <map> 29cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 30cdf0e10cSrcweir #include <vcl/svapp.hxx> 31cdf0e10cSrcweir #ifndef _VCL_TIMER_HXX_ 32cdf0e10cSrcweir #include <vcl/timer.hxx> 33cdf0e10cSrcweir #endif 34cdf0e10cSrcweir #include <tools/resmgr.hxx> 35cdf0e10cSrcweir #include <unotools/bootstrap.hxx> 36cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 37cdf0e10cSrcweir #include <com/sun/star/task/XStatusIndicator.hpp> 38cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h> 39cdf0e10cSrcweir #include <osl/mutex.hxx> 40cdf0e10cSrcweir 41cdf0e10cSrcweir using namespace com::sun::star::task; 42cdf0e10cSrcweir using namespace com::sun::star::uno; 43cdf0e10cSrcweir using namespace com::sun::star::lang; 44cdf0e10cSrcweir using namespace rtl; 45cdf0e10cSrcweir 46cdf0e10cSrcweir #define DESKTOP_SAVETASKS_MOD 0x1 47cdf0e10cSrcweir #define DESKTOP_SAVETASKS_UNMOD 0x2 48cdf0e10cSrcweir #define DESKTOP_SAVETASKS_ALL 0x3 49cdf0e10cSrcweir 50cdf0e10cSrcweir namespace desktop 51cdf0e10cSrcweir { 52cdf0e10cSrcweir 53cdf0e10cSrcweir /*-------------------------------------------------------------------- 54cdf0e10cSrcweir Description: Application-class 55cdf0e10cSrcweir --------------------------------------------------------------------*/ 56cdf0e10cSrcweir class CommandLineArgs; 57cdf0e10cSrcweir class Lockfile; 58cdf0e10cSrcweir class AcceptorMap : public std::map< OUString, Reference<XInitialization> > {}; 59cdf0e10cSrcweir struct ConvertData; 60cdf0e10cSrcweir class Desktop : public Application 61cdf0e10cSrcweir { 62cdf0e10cSrcweir friend class UserInstall; 63cdf0e10cSrcweir 64cdf0e10cSrcweir void doShutdown(); 65cdf0e10cSrcweir 66cdf0e10cSrcweir public: 67cdf0e10cSrcweir enum BootstrapError 68cdf0e10cSrcweir { 69cdf0e10cSrcweir BE_OK, 70cdf0e10cSrcweir BE_UNO_SERVICEMANAGER, 71cdf0e10cSrcweir BE_UNO_SERVICE_CONFIG_MISSING, 72cdf0e10cSrcweir BE_PATHINFO_MISSING, 73cdf0e10cSrcweir BE_USERINSTALL_FAILED, 74cdf0e10cSrcweir BE_LANGUAGE_MISSING, 75cdf0e10cSrcweir BE_USERINSTALL_NOTENOUGHDISKSPACE, 76cdf0e10cSrcweir BE_USERINSTALL_NOWRITEACCESS, 77*aa94018dSJürgen Schmidt BE_MUTLISESSION_NOT_SUPPROTED, 78cdf0e10cSrcweir BE_OFFICECONFIG_BROKEN 79cdf0e10cSrcweir }; 80cdf0e10cSrcweir enum BootstrapStatus 81cdf0e10cSrcweir { 82cdf0e10cSrcweir BS_OK, 83cdf0e10cSrcweir BS_TERMINATE 84cdf0e10cSrcweir }; 85cdf0e10cSrcweir 86cdf0e10cSrcweir Desktop(); 87cdf0e10cSrcweir ~Desktop(); 88cdf0e10cSrcweir virtual void Main( ); 89cdf0e10cSrcweir virtual void Init(); 90cdf0e10cSrcweir virtual void DeInit(); 91cdf0e10cSrcweir virtual sal_Bool QueryExit(); 92cdf0e10cSrcweir virtual sal_uInt16 Exception(sal_uInt16 nError); 93cdf0e10cSrcweir virtual void SystemSettingsChanging( AllSettings& rSettings, Window* pFrame ); 94cdf0e10cSrcweir virtual void AppEvent( const ApplicationEvent& rAppEvent ); 95cdf0e10cSrcweir 96cdf0e10cSrcweir DECL_LINK( OpenClients_Impl, void* ); 97cdf0e10cSrcweir 98cdf0e10cSrcweir static void OpenClients(); 99cdf0e10cSrcweir static void OpenDefault(); 100cdf0e10cSrcweir 101cdf0e10cSrcweir DECL_LINK( EnableAcceptors_Impl, void*); 102cdf0e10cSrcweir 103cdf0e10cSrcweir static void HandleAppEvent( const ApplicationEvent& rAppEvent ); 104cdf0e10cSrcweir static ResMgr* GetDesktopResManager(); 105cdf0e10cSrcweir static CommandLineArgs* GetCommandLineArgs(); 106cdf0e10cSrcweir 107cdf0e10cSrcweir void HandleBootstrapErrors( BootstrapError ); SetBootstrapError(BootstrapError nError)108cdf0e10cSrcweir void SetBootstrapError( BootstrapError nError ) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir if ( m_aBootstrapError == BE_OK ) 111cdf0e10cSrcweir m_aBootstrapError = nError; 112cdf0e10cSrcweir } GetBootstrapError() const113cdf0e10cSrcweir BootstrapError GetBootstrapError() const 114cdf0e10cSrcweir { 115cdf0e10cSrcweir return m_aBootstrapError; 116cdf0e10cSrcweir } 117cdf0e10cSrcweir SetBootstrapStatus(BootstrapStatus nStatus)118cdf0e10cSrcweir void SetBootstrapStatus( BootstrapStatus nStatus ) 119cdf0e10cSrcweir { 120cdf0e10cSrcweir m_aBootstrapStatus = nStatus; 121cdf0e10cSrcweir } GetBootstrapStatus() const122cdf0e10cSrcweir BootstrapStatus GetBootstrapStatus() const 123cdf0e10cSrcweir { 124cdf0e10cSrcweir return m_aBootstrapStatus; 125cdf0e10cSrcweir } 126cdf0e10cSrcweir 127cdf0e10cSrcweir static sal_Bool CheckOEM(); 128cdf0e10cSrcweir static sal_Bool isCrashReporterEnabled(); 129cdf0e10cSrcweir 130cdf0e10cSrcweir // first-start (ever) & license relate methods 131cdf0e10cSrcweir static rtl::OUString GetLicensePath(); 132cdf0e10cSrcweir static sal_Bool LicenseNeedsAcceptance(); 133cdf0e10cSrcweir static sal_Bool IsFirstStartWizardNeeded(); 134cdf0e10cSrcweir static sal_Bool CheckExtensionDependencies(); 13519720aa2SHerbert Dürr static void EnableQuickstart(); 13619720aa2SHerbert Dürr static void FinishFirstStart(); 137cdf0e10cSrcweir 138cdf0e10cSrcweir static void DoRestartActionsIfNecessary( sal_Bool bQuickStart ); 139cdf0e10cSrcweir static void SetRestartState(); 140cdf0e10cSrcweir 141cdf0e10cSrcweir void SynchronizeExtensionRepositories(); 142cdf0e10cSrcweir void SetSplashScreenText( const ::rtl::OUString& rText ); 143cdf0e10cSrcweir void SetSplashScreenProgress( sal_Int32 ); 144cdf0e10cSrcweir 145cdf0e10cSrcweir private: 146cdf0e10cSrcweir // Bootstrap methods 147cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > CreateApplicationServiceManager(); 148cdf0e10cSrcweir 149cdf0e10cSrcweir void RegisterServices( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xSMgr ); 150cdf0e10cSrcweir void DeregisterServices(); 151cdf0e10cSrcweir 152cdf0e10cSrcweir void DestroyApplicationServiceManager( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xSMgr ); 153cdf0e10cSrcweir 154cdf0e10cSrcweir void CreateTemporaryDirectory(); 155cdf0e10cSrcweir void RemoveTemporaryDirectory(); 156cdf0e10cSrcweir 157cdf0e10cSrcweir sal_Bool InitializeInstallation( const rtl::OUString& rAppFilename ); 158cdf0e10cSrcweir sal_Bool InitializeConfiguration(); 159cdf0e10cSrcweir void FlushConfiguration(); 160cdf0e10cSrcweir sal_Bool InitializeQuickstartMode( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rSMgr ); 161cdf0e10cSrcweir 162cdf0e10cSrcweir void HandleBootstrapPathErrors( ::utl::Bootstrap::Status, const ::rtl::OUString& aMsg ); 163cdf0e10cSrcweir void StartSetup( const ::rtl::OUString& aParameters ); 164cdf0e10cSrcweir 165cdf0e10cSrcweir // Get a resource message string securely e.g. if resource cannot be retrieved return aFaultBackMsg 166cdf0e10cSrcweir ::rtl::OUString GetMsgString( sal_uInt16 nId, const ::rtl::OUString& aFaultBackMsg ); 167cdf0e10cSrcweir 168cdf0e10cSrcweir // Create a error message depending on bootstrap failure code and an optional file url 169cdf0e10cSrcweir ::rtl::OUString CreateErrorMsgString( utl::Bootstrap::FailureCode nFailureCode, 170cdf0e10cSrcweir const ::rtl::OUString& aFileURL ); 171cdf0e10cSrcweir 172cdf0e10cSrcweir static void PreloadModuleData( CommandLineArgs* ); 173cdf0e10cSrcweir static void PreloadConfigurationData(); 174cdf0e10cSrcweir 175cdf0e10cSrcweir Reference<XStatusIndicator> m_rSplashScreen; 176cdf0e10cSrcweir void OpenSplashScreen(); 177cdf0e10cSrcweir void CloseSplashScreen(); 178cdf0e10cSrcweir 179cdf0e10cSrcweir void EnableOleAutomation(); 180cdf0e10cSrcweir DECL_LINK( ImplInitFilterHdl, ConvertData* ); 181cdf0e10cSrcweir DECL_LINK( AsyncInitFirstRun, void* ); 182cdf0e10cSrcweir /** checks if the office is run the first time 183cdf0e10cSrcweir <p>If so, <method>DoFirstRunInitializations</method> is called (asynchronously and delayed) and the 184cdf0e10cSrcweir respective flag in the configuration is reset.</p> 185cdf0e10cSrcweir */ 186cdf0e10cSrcweir void CheckFirstRun( ); 187cdf0e10cSrcweir 188cdf0e10cSrcweir /// does initializations which are necessary for the first run of the office 189cdf0e10cSrcweir void DoFirstRunInitializations(); 190cdf0e10cSrcweir 191cdf0e10cSrcweir static sal_Bool SaveTasks(); 192cdf0e10cSrcweir static sal_Bool _bTasksSaved; 193cdf0e10cSrcweir 194cdf0e10cSrcweir static void retrieveCrashReporterState(); 195cdf0e10cSrcweir static sal_Bool isUIOnSessionShutdownAllowed(); 196cdf0e10cSrcweir 197cdf0e10cSrcweir // on-demand acceptors 198cdf0e10cSrcweir static void createAcceptor(const OUString& aDescription); 199cdf0e10cSrcweir static void enableAcceptors(); 200cdf0e10cSrcweir static void destroyAcceptor(const OUString& aDescription); 201cdf0e10cSrcweir 202cdf0e10cSrcweir sal_Bool m_bMinimized; 203cdf0e10cSrcweir sal_Bool m_bInvisible; 204cdf0e10cSrcweir bool m_bServicesRegistered; 205cdf0e10cSrcweir sal_uInt16 m_nAppEvents; 206cdf0e10cSrcweir BootstrapError m_aBootstrapError; 207cdf0e10cSrcweir BootstrapStatus m_aBootstrapStatus; 208cdf0e10cSrcweir 209cdf0e10cSrcweir Lockfile *m_pLockfile; 210cdf0e10cSrcweir Timer m_firstRunTimer; 211cdf0e10cSrcweir 212cdf0e10cSrcweir static ResMgr* pResMgr; 213cdf0e10cSrcweir static sal_Bool bSuppressOpenDefault; 214cdf0e10cSrcweir }; 215cdf0e10cSrcweir 216cdf0e10cSrcweir } 217cdf0e10cSrcweir 218cdf0e10cSrcweir #endif // _DESKTOP_APP_HXX_ 219