xref: /aoo41x/main/desktop/win32/source/setup/setup.hxx (revision 0a1e2f0e)
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 #include "setup_main.hxx"
25 
26 //--------------------------------------------------------------------------
27 
28 #ifdef SetupAppX
29  #undef SetupAppX
30 #endif
31 
32 #ifdef Create_SetupAppX
33  #undef Create_SetupAppX
34 #endif
35 
36 #ifdef LanguageDataX
37  #undef LanguageDataX
38 #endif
39 
40 
41 #ifdef UNICODE
42  #define SetupAppX          SetupAppW
43  #define Create_SetupAppX   Create_SetupAppW
44  #define LanguageDataX      LanguageDataW
45 #else
46  #define SetupAppX          SetupAppA
47  #define Create_SetupAppX   Create_SetupAppA
48  #define LanguageDataX      LanguageDataA
49 #endif
50 
51 //--------------------------------------------------------------------------
52 
53 struct LanguageDataX
54 {
55     long    m_nLanguageID;
56     LPTSTR  m_pTransform;
57 
58      LanguageDataX( LPTSTR pData );
59     ~LanguageDataX();
60 };
61 
62 //--------------------------------------------------------------------------
63 
64 class SetupAppX : public SetupApp
65 {
66     HINSTANCE   m_hInst;
67     HANDLE      m_hMapFile;
68     LPTSTR      m_pAppTitle;
69     LPTSTR      m_pCmdLine;
70     LPTSTR      m_pDatabase;
71     LPTSTR      m_pReqVersion;
72     LPTSTR      m_pProductName;
73     LPTSTR      m_pAdvertise;
74     LPTSTR      m_pTmpName;
75     LPTSTR      m_pErrorText;
76     LPTSTR      m_pModuleFile;
77     LPTSTR      m_pPatchFiles;
78     LPCTSTR     m_pUpgradeKey;
79     LPCTSTR     m_pProductVersion;
80     int        *m_pMSIErrorCode;
81 
82     boolean     m_bQuiet            : 1;
83     boolean     m_bIgnoreAlreadyRunning : 1;
84     boolean     m_bRegNoMsoTypes :1;
85     boolean     m_bRegAllMsoTypes :1;
86     boolean     m_bIsMinorUpgrade :1;
87     boolean     m_bSupportsPatch :1;
88 
89     FILE       *m_pLogFile;
90 
91     long            m_nLanguageID;
92     long            m_nLanguageCount;
93     LanguageDataX** m_ppLanguageList;
94 
95 private:
96 
97     boolean     GetPathToFile( TCHAR* pFileName, TCHAR **pPath );
98     LPCTSTR     GetPathToMSI();
99 
100     int         GetNameValue( TCHAR* pLine, TCHAR **pName, TCHAR **pValue );
101     boolean     GetProfileSection( LPCTSTR pFileName, LPCTSTR pSection,
102                                    DWORD& rSize, LPTSTR *pRetBuf );
103     LPTSTR      CopyIniFile( LPCTSTR pIniFile );
104     void        ConvertNewline( LPTSTR pText ) const;
105 
106     boolean     LaunchInstaller( LPCTSTR pParam );
107     HMODULE     LoadMsiLibrary();
108     DWORD       WaitForProcess( HANDLE hHandle );
109 
110     boolean     GetCmdLineParameters( LPTSTR *pCmdLine );
111     DWORD       GetNextArgument( LPCTSTR pStr, LPTSTR *pArg,
112                                  LPTSTR *pNext, boolean bStripQuotes = false );
113     boolean     IsAdmin();
114 
115     boolean     GetCommandLine();
116 
117     boolean     IsTerminalServerInstalled() const;
118     void        AddFileToPatchList( TCHAR* pPath, TCHAR* pFile );
119     boolean     IsPatchInstalled( TCHAR* pBaseDir, TCHAR* pFileName );
120     boolean     InstallRuntimes( TCHAR* pProductCode, TCHAR* pFileName );
121 
122 public:
123                     SetupAppX();
124                    ~SetupAppX();
125 
126     virtual boolean Initialize( HINSTANCE hInst );
127     virtual boolean AlreadyRunning() const;
128     virtual boolean ReadProfile();
129     virtual boolean GetPatches();
130     virtual boolean ChooseLanguage( long& rLanguage );
131     virtual boolean CheckVersion();
132     virtual boolean CheckForUpgrade();
133     virtual boolean InstallRuntimes();
134     virtual boolean Install( long nLanguage );
135 
136     virtual UINT    GetError() const;
137     virtual void    DisplayError( UINT nErr ) const;
138 
139     void            Log( LPCTSTR pMessage, LPCTSTR pText = NULL ) const;
140 
GetLanguageCount() const141     long            GetLanguageCount() const { return m_nLanguageCount; }
142     long            GetLanguageID( long nIndex ) const;
143     void            GetLanguageName( long nLanguage, LPTSTR sName ) const;
144 
GetAppTitle() const145     LPCTSTR         GetAppTitle() const { return m_pAppTitle; }
146     LPTSTR          SetProdToAppTitle( LPCTSTR pProdName );
GetHInst() const147     HINSTANCE       GetHInst() const { return m_hInst; }
148 };
149 
150 //--------------------------------------------------------------------------
151