xref: /aoo42x/main/desktop/inc/app.hxx (revision 0a1e2f0e)
1*0a1e2f0eSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*0a1e2f0eSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*0a1e2f0eSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*0a1e2f0eSAndrew Rist  * distributed with this work for additional information
6*0a1e2f0eSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*0a1e2f0eSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*0a1e2f0eSAndrew Rist  * "License"); you may not use this file except in compliance
9*0a1e2f0eSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*0a1e2f0eSAndrew Rist  *
11*0a1e2f0eSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*0a1e2f0eSAndrew Rist  *
13*0a1e2f0eSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*0a1e2f0eSAndrew Rist  * software distributed under the License is distributed on an
15*0a1e2f0eSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*0a1e2f0eSAndrew Rist  * KIND, either express or implied.  See the License for the
17*0a1e2f0eSAndrew Rist  * specific language governing permissions and limitations
18*0a1e2f0eSAndrew Rist  * under the License.
19*0a1e2f0eSAndrew Rist  *
20*0a1e2f0eSAndrew Rist  *************************************************************/
21*0a1e2f0eSAndrew Rist 
22*0a1e2f0eSAndrew 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,
77cdf0e10cSrcweir             BE_OFFICECONFIG_BROKEN
78cdf0e10cSrcweir 		};
79cdf0e10cSrcweir         enum BootstrapStatus
80cdf0e10cSrcweir         {
81cdf0e10cSrcweir             BS_OK,
82cdf0e10cSrcweir             BS_TERMINATE
83cdf0e10cSrcweir         };
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 								Desktop();
86cdf0e10cSrcweir 								~Desktop();
87cdf0e10cSrcweir 		virtual void			Main( );
88cdf0e10cSrcweir 		virtual void			Init();
89cdf0e10cSrcweir 		virtual void			DeInit();
90cdf0e10cSrcweir 		virtual sal_Bool			QueryExit();
91cdf0e10cSrcweir 		virtual sal_uInt16			Exception(sal_uInt16 nError);
92cdf0e10cSrcweir 		virtual void			SystemSettingsChanging( AllSettings& rSettings, Window* pFrame );
93cdf0e10cSrcweir 		virtual void			AppEvent( const ApplicationEvent& rAppEvent );
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 		DECL_LINK(          OpenClients_Impl, void* );
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 		static void				OpenClients();
98cdf0e10cSrcweir 		static void				OpenDefault();
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 		DECL_LINK( EnableAcceptors_Impl, void*);
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 		static void				HandleAppEvent( const ApplicationEvent& rAppEvent );
103cdf0e10cSrcweir 		static ResMgr*			GetDesktopResManager();
104cdf0e10cSrcweir 		static CommandLineArgs* GetCommandLineArgs();
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 		void					HandleBootstrapErrors( BootstrapError );
107cdf0e10cSrcweir 		void					SetBootstrapError( BootstrapError nError )
108cdf0e10cSrcweir 		{
109cdf0e10cSrcweir 			if ( m_aBootstrapError == BE_OK )
110cdf0e10cSrcweir 				m_aBootstrapError = nError;
111cdf0e10cSrcweir 		}
112cdf0e10cSrcweir         BootstrapError          GetBootstrapError() const
113cdf0e10cSrcweir         {
114cdf0e10cSrcweir             return m_aBootstrapError;
115cdf0e10cSrcweir         }
116cdf0e10cSrcweir 
117cdf0e10cSrcweir         void					SetBootstrapStatus( BootstrapStatus nStatus )
118cdf0e10cSrcweir 		{
119cdf0e10cSrcweir             m_aBootstrapStatus = nStatus;
120cdf0e10cSrcweir 		}
121cdf0e10cSrcweir         BootstrapStatus          GetBootstrapStatus() const
122cdf0e10cSrcweir         {
123cdf0e10cSrcweir             return m_aBootstrapStatus;
124cdf0e10cSrcweir         }
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 		static sal_Bool         CheckOEM();
127cdf0e10cSrcweir         static sal_Bool         isCrashReporterEnabled();
128cdf0e10cSrcweir 
129cdf0e10cSrcweir         // first-start (ever) & license relate methods
130cdf0e10cSrcweir         static rtl::OUString    GetLicensePath();
131cdf0e10cSrcweir         static sal_Bool         LicenseNeedsAcceptance();
132cdf0e10cSrcweir         static sal_Bool         IsFirstStartWizardNeeded();
133cdf0e10cSrcweir         static sal_Bool         CheckExtensionDependencies();
134cdf0e10cSrcweir 
135cdf0e10cSrcweir         static void             DoRestartActionsIfNecessary( sal_Bool bQuickStart );
136cdf0e10cSrcweir         static void             SetRestartState();
137cdf0e10cSrcweir 
138cdf0e10cSrcweir         void                    SynchronizeExtensionRepositories();
139cdf0e10cSrcweir         void                    SetSplashScreenText( const ::rtl::OUString& rText );
140cdf0e10cSrcweir         void                    SetSplashScreenProgress( sal_Int32 );
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 	private:
143cdf0e10cSrcweir 		// Bootstrap methods
144cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > CreateApplicationServiceManager();
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 		void					RegisterServices( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xSMgr );
147cdf0e10cSrcweir 		void					DeregisterServices();
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 		void					DestroyApplicationServiceManager( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xSMgr );
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 		void					CreateTemporaryDirectory();
152cdf0e10cSrcweir 		void					RemoveTemporaryDirectory();
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 		sal_Bool				InitializeInstallation( const rtl::OUString& rAppFilename );
155cdf0e10cSrcweir 		sal_Bool				InitializeConfiguration();
156cdf0e10cSrcweir         void                    FlushConfiguration();
157cdf0e10cSrcweir 		sal_Bool				InitializeQuickstartMode( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rSMgr );
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 		void					HandleBootstrapPathErrors( ::utl::Bootstrap::Status, const ::rtl::OUString& aMsg );
160cdf0e10cSrcweir 		void					StartSetup( const ::rtl::OUString& aParameters );
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 		// Get a resource message string securely e.g. if resource cannot be retrieved return aFaultBackMsg
163cdf0e10cSrcweir 		::rtl::OUString			GetMsgString( sal_uInt16 nId, const ::rtl::OUString& aFaultBackMsg );
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 		// Create a error message depending on bootstrap failure code and an optional file url
166cdf0e10cSrcweir 		::rtl::OUString			CreateErrorMsgString( utl::Bootstrap::FailureCode nFailureCode,
167cdf0e10cSrcweir 													  const ::rtl::OUString& aFileURL );
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 		static void             PreloadModuleData( CommandLineArgs* );
170cdf0e10cSrcweir         static void             PreloadConfigurationData();
171cdf0e10cSrcweir 
172cdf0e10cSrcweir         Reference<XStatusIndicator> m_rSplashScreen;
173cdf0e10cSrcweir         void                    OpenSplashScreen();
174cdf0e10cSrcweir         void                    CloseSplashScreen();
175cdf0e10cSrcweir 
176cdf0e10cSrcweir     	void					EnableOleAutomation();
177cdf0e10cSrcweir 								DECL_LINK( ImplInitFilterHdl, ConvertData* );
178cdf0e10cSrcweir 		DECL_LINK(			AsyncInitFirstRun, void* );
179cdf0e10cSrcweir 		/** checks if the office is run the first time
180cdf0e10cSrcweir 			<p>If so, <method>DoFirstRunInitializations</method> is called (asynchronously and delayed) and the
181cdf0e10cSrcweir 			respective flag in the configuration is reset.</p>
182cdf0e10cSrcweir 		*/
183cdf0e10cSrcweir 		void					CheckFirstRun( );
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 		/// does initializations which are necessary for the first run of the office
186cdf0e10cSrcweir 		void					DoFirstRunInitializations();
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 		static sal_Bool			SaveTasks();
189cdf0e10cSrcweir         static sal_Bool         _bTasksSaved;
190cdf0e10cSrcweir 
191cdf0e10cSrcweir         static void             retrieveCrashReporterState();
192cdf0e10cSrcweir         static sal_Bool         isUIOnSessionShutdownAllowed();
193cdf0e10cSrcweir 
194cdf0e10cSrcweir         // on-demand acceptors
195cdf0e10cSrcweir 		static void							createAcceptor(const OUString& aDescription);
196cdf0e10cSrcweir 		static void							enableAcceptors();
197cdf0e10cSrcweir 		static void							destroyAcceptor(const OUString& aDescription);
198cdf0e10cSrcweir 
199cdf0e10cSrcweir 		sal_Bool						m_bMinimized;
200cdf0e10cSrcweir 		sal_Bool						m_bInvisible;
201cdf0e10cSrcweir 		bool                            m_bServicesRegistered;
202cdf0e10cSrcweir 		sal_uInt16							m_nAppEvents;
203cdf0e10cSrcweir 		BootstrapError					m_aBootstrapError;
204cdf0e10cSrcweir         BootstrapStatus                 m_aBootstrapStatus;
205cdf0e10cSrcweir 
206cdf0e10cSrcweir 		Lockfile *m_pLockfile;
207cdf0e10cSrcweir         Timer    m_firstRunTimer;
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 		static ResMgr*					pResMgr;
210cdf0e10cSrcweir         static sal_Bool                 bSuppressOpenDefault;
211cdf0e10cSrcweir };
212cdf0e10cSrcweir 
213cdf0e10cSrcweir }
214cdf0e10cSrcweir 
215cdf0e10cSrcweir #endif // _DESKTOP_APP_HXX_
216