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