respintest.cxx (32b1fd08) respintest.cxx (0cf988a7)
1/**************************************************************
1/**************************************************************
2 *
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
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 *
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
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.
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 *
19 *
20 *************************************************************/
21
22
23
24#undef UNICODE
25#undef _UNICODE
26
27#define _WIN32_WINDOWS 0x0410

--- 14 unchanged lines hidden (view full) ---

42#include <tchar.h>
43#include <string>
44#include <systools/win32/uwinapi.h>
45
46#include <../tools/seterror.hxx>
47
48using namespace std;
49
20 *************************************************************/
21
22
23
24#undef UNICODE
25#undef _UNICODE
26
27#define _WIN32_WINDOWS 0x0410

--- 14 unchanged lines hidden (view full) ---

42#include <tchar.h>
43#include <string>
44#include <systools/win32/uwinapi.h>
45
46#include <../tools/seterror.hxx>
47
48using namespace std;
49
50namespace
50namespace
51{
52 string GetMsiProperty(MSIHANDLE handle, const string& sProperty)
53 {
54 string result;
55 TCHAR szDummy[1] = TEXT("");
56 DWORD nChars = 0;
57
58 if (MsiGetProperty(handle, sProperty.c_str(), szDummy, &nChars) == ERROR_MORE_DATA)

--- 16 unchanged lines hidden (view full) ---

75 {
76 MsiSetProperty(handle, sProperty.c_str(), NULL);
77 }
78
79 inline void SetMsiProperty(MSIHANDLE handle, const string& sProperty, const string&)
80 {
81 MsiSetProperty(handle, sProperty.c_str(), TEXT("1"));
82 }
51{
52 string GetMsiProperty(MSIHANDLE handle, const string& sProperty)
53 {
54 string result;
55 TCHAR szDummy[1] = TEXT("");
56 DWORD nChars = 0;
57
58 if (MsiGetProperty(handle, sProperty.c_str(), szDummy, &nChars) == ERROR_MORE_DATA)

--- 16 unchanged lines hidden (view full) ---

75 {
76 MsiSetProperty(handle, sProperty.c_str(), NULL);
77 }
78
79 inline void SetMsiProperty(MSIHANDLE handle, const string& sProperty, const string&)
80 {
81 MsiSetProperty(handle, sProperty.c_str(), TEXT("1"));
82 }
83} // namespace
83} // namespace
84
85extern "C" UINT __stdcall GetUserInstallMode(MSIHANDLE handle)
86{
87 string sOfficeInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION"));
88
89 // MessageBox(NULL, sOfficeInstallPath.c_str(), "DEBUG", MB_OK);
90
91 // unsetting all properties
92
93 UnsetMsiProperty( handle, TEXT("INVALIDDIRECTORY") );
94 UnsetMsiProperty( handle, TEXT("ISWRONGPRODUCT") );
95 UnsetMsiProperty( handle, TEXT("PATCHISOLDER") );
96 UnsetMsiProperty( handle, TEXT("ALLUSERS") );
97
98 // 1. Searching for "ProductCode" in setup.ini
99
100 string sSetupiniPath = sOfficeInstallPath + TEXT("program\\setup.ini");
84
85extern "C" UINT __stdcall GetUserInstallMode(MSIHANDLE handle)
86{
87 string sOfficeInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION"));
88
89 // MessageBox(NULL, sOfficeInstallPath.c_str(), "DEBUG", MB_OK);
90
91 // unsetting all properties
92
93 UnsetMsiProperty( handle, TEXT("INVALIDDIRECTORY") );
94 UnsetMsiProperty( handle, TEXT("ISWRONGPRODUCT") );
95 UnsetMsiProperty( handle, TEXT("PATCHISOLDER") );
96 UnsetMsiProperty( handle, TEXT("ALLUSERS") );
97
98 // 1. Searching for "ProductCode" in setup.ini
99
100 string sSetupiniPath = sOfficeInstallPath + TEXT("program\\setup.ini");
101
101
102 TCHAR szValue[32767];
103
102 TCHAR szValue[32767];
103
104 GetPrivateProfileString(
105 TEXT("Bootstrap"),
104 GetPrivateProfileString(
105 TEXT("Bootstrap"),
106 TEXT("ProductCode"),
107 TEXT("INVALIDDIRECTORY"),
108 szValue,
109 elementsof(szValue),
106 TEXT("ProductCode"),
107 TEXT("INVALIDDIRECTORY"),
108 szValue,
109 elementsof(szValue),
110 sSetupiniPath.c_str()
110 sSetupiniPath.c_str()
111 );
112
113 if ( !_tcsicmp( szValue, TEXT("INVALIDDIRECTORY") ) )
114 {
115 // No setup.ini or no "ProductCode" in setup.ini. This is an invalid directory.
116 SetMsiProperty( handle, TEXT("INVALIDDIRECTORY"), TEXT("YES") );
117 // MessageBox(NULL, "INVALIDDIRECTORY set, no setup.ini or ProductCode in setup.ini.", "DEBUG", MB_OK);
118 SetMsiErrorCode( MSI_ERROR_INVALIDDIRECTORY );
119 return ERROR_SUCCESS;
120 }
121
122 // 2. Comparing first three characters of "PRODUCTMAJOR" from property table and "buildid" from InfoFile
123
124 szValue[0] = '\0';
125
111 );
112
113 if ( !_tcsicmp( szValue, TEXT("INVALIDDIRECTORY") ) )
114 {
115 // No setup.ini or no "ProductCode" in setup.ini. This is an invalid directory.
116 SetMsiProperty( handle, TEXT("INVALIDDIRECTORY"), TEXT("YES") );
117 // MessageBox(NULL, "INVALIDDIRECTORY set, no setup.ini or ProductCode in setup.ini.", "DEBUG", MB_OK);
118 SetMsiErrorCode( MSI_ERROR_INVALIDDIRECTORY );
119 return ERROR_SUCCESS;
120 }
121
122 // 2. Comparing first three characters of "PRODUCTMAJOR" from property table and "buildid" from InfoFile
123
124 szValue[0] = '\0';
125
126 GetPrivateProfileString(
127 TEXT("Bootstrap"),
126 GetPrivateProfileString(
127 TEXT("Bootstrap"),
128 TEXT("buildid"),
129 TEXT("ISWRONGPRODUCT"),
130 szValue,
131 elementsof(szValue),
128 TEXT("buildid"),
129 TEXT("ISWRONGPRODUCT"),
130 szValue,
131 elementsof(szValue),
132 sSetupiniPath.c_str()
132 sSetupiniPath.c_str()
133 );
134
135 if ( !_tcsicmp( szValue, TEXT("ISWRONGPRODUCT") ) )
136 {
137 SetMsiProperty( handle, TEXT("ISWRONGPRODUCT"), TEXT("YES") );
138 // MessageBox(NULL, "ISWRONGPRODUCT 1 set after searching buildid", "DEBUG", MB_OK);
139 SetMsiErrorCode( MSI_ERROR_ISWRONGPRODUCT );
140 return ERROR_SUCCESS;

--- 4 unchanged lines hidden (view full) ---

145 // Comparing the first three characters, for example "680"
146 // If not equal, this version is not suited for patch or language pack
147
148 if (_tcsnicmp(ProductMajor.c_str(), szValue, 3))
149 {
150 SetMsiProperty( handle, TEXT("ISWRONGPRODUCT"), TEXT("YES") );
151 // MessageBox(NULL, "ISWRONGPRODUCT 2 set after searching PRODUCTMAJOR", "DEBUG", MB_OK);
152 SetMsiErrorCode( MSI_ERROR_ISWRONGPRODUCT );
133 );
134
135 if ( !_tcsicmp( szValue, TEXT("ISWRONGPRODUCT") ) )
136 {
137 SetMsiProperty( handle, TEXT("ISWRONGPRODUCT"), TEXT("YES") );
138 // MessageBox(NULL, "ISWRONGPRODUCT 1 set after searching buildid", "DEBUG", MB_OK);
139 SetMsiErrorCode( MSI_ERROR_ISWRONGPRODUCT );
140 return ERROR_SUCCESS;

--- 4 unchanged lines hidden (view full) ---

145 // Comparing the first three characters, for example "680"
146 // If not equal, this version is not suited for patch or language pack
147
148 if (_tcsnicmp(ProductMajor.c_str(), szValue, 3))
149 {
150 SetMsiProperty( handle, TEXT("ISWRONGPRODUCT"), TEXT("YES") );
151 // MessageBox(NULL, "ISWRONGPRODUCT 2 set after searching PRODUCTMAJOR", "DEBUG", MB_OK);
152 SetMsiErrorCode( MSI_ERROR_ISWRONGPRODUCT );
153 return ERROR_SUCCESS;
153 return ERROR_SUCCESS;
154 }
155
156 // 3. Only for patch: Comparing "PRODUCTMINOR from property table and "ProductMinor" from InfoFile
157
158 string isPatch = GetMsiProperty(handle, TEXT("ISPATCH"));
159
160 if (isPatch=="1")
161 {
162 string ProductMinor = GetMsiProperty(handle, TEXT("PRODUCTBUILDID"));
163 int PatchProductMinor = atoi(ProductMinor.c_str());
164
165 szValue[0] = '\0';
166
154 }
155
156 // 3. Only for patch: Comparing "PRODUCTMINOR from property table and "ProductMinor" from InfoFile
157
158 string isPatch = GetMsiProperty(handle, TEXT("ISPATCH"));
159
160 if (isPatch=="1")
161 {
162 string ProductMinor = GetMsiProperty(handle, TEXT("PRODUCTBUILDID"));
163 int PatchProductMinor = atoi(ProductMinor.c_str());
164
165 szValue[0] = '\0';
166
167 GetPrivateProfileString(
168 TEXT("Bootstrap"),
167 GetPrivateProfileString(
168 TEXT("Bootstrap"),
169 TEXT("ProductBuildid"),
170 TEXT("8918"),
171 szValue,
172 elementsof(szValue),
169 TEXT("ProductBuildid"),
170 TEXT("8918"),
171 szValue,
172 elementsof(szValue),
173 sSetupiniPath.c_str()
173 sSetupiniPath.c_str()
174 );
174 );
175
175
176 int InstalledProductMinor = atoi(szValue);
177
178 if ( InstalledProductMinor >= PatchProductMinor )
179 {
180 SetMsiProperty( handle, TEXT("PATCHISOLDER"), TEXT("YES") );
181 // MessageBox(NULL, "PATCHISOLDER set", "DEBUG", MB_OK);
182 SetMsiErrorCode( MSI_ERROR_PATCHISOLDER );
176 int InstalledProductMinor = atoi(szValue);
177
178 if ( InstalledProductMinor >= PatchProductMinor )
179 {
180 SetMsiProperty( handle, TEXT("PATCHISOLDER"), TEXT("YES") );
181 // MessageBox(NULL, "PATCHISOLDER set", "DEBUG", MB_OK);
182 SetMsiErrorCode( MSI_ERROR_PATCHISOLDER );
183 return ERROR_SUCCESS;
183 return ERROR_SUCCESS;
184 }
185 }
186
187 // 4. Setting property ALLUSERS with value from "setup.ini"
188
189 szValue[0] = '\0';
190
184 }
185 }
186
187 // 4. Setting property ALLUSERS with value from "setup.ini"
188
189 szValue[0] = '\0';
190
191 GetPrivateProfileString(
192 TEXT("Bootstrap"),
191 GetPrivateProfileString(
192 TEXT("Bootstrap"),
193 TEXT("ALLUSERS"),
194 TEXT(""),
195 szValue,
196 elementsof(szValue),
193 TEXT("ALLUSERS"),
194 TEXT(""),
195 szValue,
196 elementsof(szValue),
197 sSetupiniPath.c_str()
197 sSetupiniPath.c_str()
198 );
199
200 if ( szValue[0] )
201 {
202 SetMsiProperty( handle, TEXT("ALLUSERS"), szValue );
203 // MessageBox(NULL, "ALLUSERS set", "DEBUG", MB_OK);
204 }
198 );
199
200 if ( szValue[0] )
201 {
202 SetMsiProperty( handle, TEXT("ALLUSERS"), szValue );
203 // MessageBox(NULL, "ALLUSERS set", "DEBUG", MB_OK);
204 }
205
205
206 return ERROR_SUCCESS;
207}
206 return ERROR_SUCCESS;
207}
208