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