xref: /aoo41x/main/desktop/win32/source/setup/setup.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include "setup_main.hxx"
29 
30 //--------------------------------------------------------------------------
31 
32 #ifdef SetupAppX
33  #undef SetupAppX
34 #endif
35 
36 #ifdef Create_SetupAppX
37  #undef Create_SetupAppX
38 #endif
39 
40 #ifdef LanguageDataX
41  #undef LanguageDataX
42 #endif
43 
44 
45 #ifdef UNICODE
46  #define SetupAppX          SetupAppW
47  #define Create_SetupAppX   Create_SetupAppW
48  #define LanguageDataX      LanguageDataW
49 #else
50  #define SetupAppX          SetupAppA
51  #define Create_SetupAppX   Create_SetupAppA
52  #define LanguageDataX      LanguageDataA
53 #endif
54 
55 //--------------------------------------------------------------------------
56 
57 struct LanguageDataX
58 {
59     long    m_nLanguageID;
60     LPTSTR  m_pTransform;
61 
62      LanguageDataX( LPTSTR pData );
63     ~LanguageDataX();
64 };
65 
66 //--------------------------------------------------------------------------
67 
68 class SetupAppX : public SetupApp
69 {
70     HINSTANCE   m_hInst;
71     HANDLE      m_hMapFile;
72     LPTSTR      m_pAppTitle;
73     LPTSTR      m_pCmdLine;
74     LPTSTR      m_pDatabase;
75     LPTSTR      m_pReqVersion;
76     LPTSTR      m_pProductName;
77     LPTSTR      m_pAdvertise;
78     LPTSTR      m_pTmpName;
79     LPTSTR      m_pErrorText;
80     LPTSTR      m_pModuleFile;
81     LPTSTR      m_pPatchFiles;
82     LPCTSTR     m_pUpgradeKey;
83     LPCTSTR     m_pProductVersion;
84     int        *m_pMSIErrorCode;
85 
86     boolean     m_bQuiet            : 1;
87     boolean     m_bIgnoreAlreadyRunning : 1;
88     boolean     m_bRegNoMsoTypes :1;
89     boolean     m_bRegAllMsoTypes :1;
90     boolean     m_bIsMinorUpgrade :1;
91     boolean     m_bSupportsPatch :1;
92 
93     FILE       *m_pLogFile;
94 
95     long            m_nLanguageID;
96     long            m_nLanguageCount;
97     LanguageDataX** m_ppLanguageList;
98 
99 private:
100 
101     boolean     GetPathToFile( TCHAR* pFileName, TCHAR **pPath );
102     LPCTSTR     GetPathToMSI();
103 
104     int         GetNameValue( TCHAR* pLine, TCHAR **pName, TCHAR **pValue );
105     boolean     GetProfileSection( LPCTSTR pFileName, LPCTSTR pSection,
106                                    DWORD& rSize, LPTSTR *pRetBuf );
107     LPTSTR      CopyIniFile( LPCTSTR pIniFile );
108     void        ConvertNewline( LPTSTR pText ) const;
109 
110     boolean     LaunchInstaller( LPCTSTR pParam );
111     HMODULE     LoadMsiLibrary();
112     DWORD       WaitForProcess( HANDLE hHandle );
113 
114     boolean     GetCmdLineParameters( LPTSTR *pCmdLine );
115     DWORD       GetNextArgument( LPCTSTR pStr, LPTSTR *pArg,
116                                  LPTSTR *pNext, boolean bStripQuotes = false );
117     boolean     IsAdmin();
118 
119     boolean     GetCommandLine();
120 
121     boolean     IsTerminalServerInstalled() const;
122     void        AddFileToPatchList( TCHAR* pPath, TCHAR* pFile );
123     boolean     IsPatchInstalled( TCHAR* pBaseDir, TCHAR* pFileName );
124     boolean     InstallRuntimes( TCHAR* pProductCode, TCHAR* pFileName );
125 
126 public:
127                     SetupAppX();
128                    ~SetupAppX();
129 
130     virtual boolean Initialize( HINSTANCE hInst );
131     virtual boolean AlreadyRunning() const;
132     virtual boolean ReadProfile();
133     virtual boolean GetPatches();
134     virtual boolean ChooseLanguage( long& rLanguage );
135     virtual boolean CheckVersion();
136     virtual boolean CheckForUpgrade();
137     virtual boolean InstallRuntimes();
138     virtual boolean Install( long nLanguage );
139 
140     virtual UINT    GetError() const;
141     virtual void    DisplayError( UINT nErr ) const;
142 
143     void            Log( LPCTSTR pMessage, LPCTSTR pText = NULL ) const;
144 
145     long            GetLanguageCount() const { return m_nLanguageCount; }
146     long            GetLanguageID( long nIndex ) const;
147     void            GetLanguageName( long nLanguage, LPTSTR sName ) const;
148 
149     LPCTSTR         GetAppTitle() const { return m_pAppTitle; }
150     LPTSTR          SetProdToAppTitle( LPCTSTR pProdName );
151     HINSTANCE       GetHInst() const { return m_hInst; }
152 };
153 
154 //--------------------------------------------------------------------------
155