2
* The contents of this file are subject to the Mozilla Public
3
* License Version 1.1 (the "License"); you may not use this file
4
* except in compliance with the License. You may obtain a copy of
5
* the License at http://www.mozilla.org/MPL/
7
* Software distributed under the License is distributed on an "AS
8
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9
* implied. See the License for the specific language governing
10
* rights and limitations under the License.
12
* The Original Code is Mozilla Navigator.
14
* The Initial Developer of the Original Code is Netscape Communications
15
* Corp. Portions created by Netscape Communications Corp. are
16
* Copyright (C) 2001 Netscape Communications Corp. All Rights
20
* Sean Su <ssu@netscape.com>
29
#define E_USER_CANCEL -813
31
int AppendToGlobalMessageStream(char *szInfo)
33
DWORD dwInfoLen = strlen(szInfo);
36
if(gErrorMessageStream.bEnabled && gErrorMessageStream.szMessage)
38
dwMessageLen = strlen(gErrorMessageStream.szMessage);
39
if((dwInfoLen + dwMessageLen) >= gErrorMessageStream.dwMessageBufSize)
41
if(NS_GlobalReAlloc(&gErrorMessageStream.szMessage,
42
gErrorMessageStream.dwMessageBufSize,
43
dwInfoLen + dwMessageLen + MAX_BUF_TINY) == NULL)
44
return(WIZ_OUT_OF_MEMORY);
46
gErrorMessageStream.dwMessageBufSize = dwInfoLen +
51
strcat(gErrorMessageStream.szMessage, szInfo);
57
void LogISTime(int iType)
64
timeinfo = localtime ( &rawtime );
67
sprintf(szBuf, "Start Log: %s\n", asctime (timeinfo));
69
sprintf(szBuf, "End Log: %s\n", asctime (timeinfo));
71
UpdateInstallStatusLog(szBuf);
74
void LogISProductInfo(void)
78
sprintf(szBuf, "\n Product Info:\n");
79
UpdateInstallStatusLog(szBuf);
81
switch(sgProduct.ulMode)
84
sprintf(szBuf, " Install mode: Silent\n");
87
sprintf(szBuf, " Install mode: Auto\n");
90
sprintf(szBuf, " Install mode: Normal\n");
93
UpdateInstallStatusLog(szBuf);
95
sprintf(szBuf, " Company name: %s\n Product name (external): %s\n Product name (internal): %s\n Uninstall Filename: %s\n UserAgent: %s\n Alternate search path: %s\n",
96
sgProduct.szCompanyName,
97
sgProduct.szProductName,
98
sgProduct.szProductNameInternal,
99
sgProduct.szUninstallFilename,
100
sgProduct.szUserAgent,
101
sgProduct.szAlternateArchiveSearchPath);
102
UpdateInstallStatusLog(szBuf);
105
void LogISDestinationPath(void)
110
"\n Destination Path:\n Main: %s\n SubPath: %s\n",
112
sgProduct.szSubPath);
113
UpdateInstallStatusLog(szBuf);
116
void LogISSetupType(void)
118
char szBuf[MAX_BUF_TINY];
123
sprintf(szBuf, "\n Setup Type: %s\n",
124
diSetupType.stSetupType3.szDescriptionShort);
128
sprintf(szBuf, "\n Setup Type: %s\n",
129
diSetupType.stSetupType2.szDescriptionShort);
133
sprintf(szBuf, "\n Setup Type: %s\n",
134
diSetupType.stSetupType1.szDescriptionShort);
138
sprintf(szBuf, "\n Setup Type: %s\n",
139
diSetupType.stSetupType0.szDescriptionShort);
143
UpdateInstallStatusLog(szBuf);
146
void LogISComponentsSelected(void)
148
char szBuf[MAX_BUF_TINY];
150
BOOL bFoundComponentSelected;
152
sprintf(szBuf, "\n Components selected:\n");
153
UpdateInstallStatusLog(szBuf);
155
bFoundComponentSelected = FALSE;
156
siCNode = siComponents;
162
if(siCNode->dwAttributes & SIC_SELECTED)
164
if(!siCNode->bForceUpgrade)
167
siCNode->szDescriptionShort);
171
siCNode->szDescriptionShort);
173
UpdateInstallStatusLog(szBuf);
174
bFoundComponentSelected = TRUE;
177
siCNode = siCNode->Next;
178
} while((siCNode != NULL) && (siCNode != siComponents));
180
if(!bFoundComponentSelected)
182
sprintf(szBuf, " none\n");
183
UpdateInstallStatusLog(szBuf);
187
void LogISComponentsToDownload(void)
189
char szBuf[MAX_BUF_TINY];
190
char szArchivePath[MAX_BUF_MEDIUM];
192
BOOL bFoundComponentSelected;
193
BOOL bFoundComponentsToDownload;
195
sprintf(szBuf, "\n Components to download:\n");
196
UpdateInstallStatusLog(szBuf);
198
bFoundComponentSelected = FALSE;
199
bFoundComponentsToDownload = FALSE;
200
siCNode = siComponents;
206
if(siCNode->dwAttributes & SIC_SELECTED)
209
if(LocateJar(siCNode,
211
sizeof(szArchivePath),
212
gbPreviousUnfinishedDownload) == AP_NOT_FOUND)
215
" %s will be downloaded\n",
216
siCNode->szDescriptionShort);
217
bFoundComponentsToDownload = TRUE;
222
siCNode->szDescriptionShort,
225
UpdateInstallStatusLog(szBuf);
226
bFoundComponentSelected = TRUE;
229
siCNode = siCNode->Next;
230
} while((siCNode != NULL) && (siCNode != siComponents));
232
if(!bFoundComponentSelected)
234
sprintf(szBuf, " none\n");
235
UpdateInstallStatusLog(szBuf);
237
if(!bFoundComponentsToDownload)
239
sprintf(szBuf, " **\n ** All components have been found locally. No components will be downloaded.\n **\n");
240
UpdateInstallStatusLog(szBuf);
244
void LogISDownloadProtocol(DWORD dwProtocolType)
247
char szProtocolType[MAX_BUF];
249
switch(dwProtocolType)
252
strcpy(szProtocolType, "HTTP");
256
strcpy(szProtocolType, "FTP");
260
sprintf(szBuf, "\n Download protocol: %s\n", szProtocolType);
261
UpdateInstallStatusLog(szBuf);
264
void LogISDownloadStatus(char *szStatus, char *szFailedFile)
267
siC *siCObject = NULL;
272
"\n Download status: %s\n file: %s\n\n",
277
"\n Download status: %s\n",
279
UpdateInstallStatusLog(szBuf);
282
siCObject = SiCNodeGetObject(dwIndex, TRUE, AC_ALL);
285
if(siCObject->dwAttributes & SIC_SELECTED)
287
sprintf(szBuf, " %s: NetRetries:%d, CRCRetries:%d, NetTimeOuts:%d\n",
288
siCObject->szDescriptionShort,
289
siCObject->iNetRetries,
290
siCObject->iCRCRetries,
291
siCObject->iNetTimeOuts);
292
UpdateInstallStatusLog(szBuf);
296
siCObject = SiCNodeGetObject(dwIndex, TRUE, AC_ALL);
300
void LogISComponentsFailedCRC(char *szList, int iWhen)
304
if(iWhen == W_STARTUP)
306
if(szList && (*szList != '\0'))
308
"\n Components corrupted (startup):\n%s",
312
"\n Components corrupted (startup):\n none\n");
316
if(szList && (*szList != '\0'))
318
"\n Components corrupted (download):\n%s",
322
"\n Components corrupted (download):\n none\n");
325
UpdateInstallStatusLog(szBuf);
328
void LogISXPInstall(int iWhen)
333
sprintf(szBuf, "\n XPInstall Start\n");
335
sprintf(szBuf, " XPInstall End\n");
337
UpdateInstallStatusLog(szBuf);
340
void LogISXPInstallComponent(char *szComponentName)
344
sprintf(szBuf, " %s", szComponentName);
345
UpdateInstallStatusLog(szBuf);
348
void LogISXPInstallComponentResult(DWORD dwErrorNumber)
351
char szErrorString[MAX_BUF];
353
// GetErrorString(dwErrorNumber, szErrorString, sizeof(szErrorString));
354
sprintf(szBuf, ": %d %s\n", dwErrorNumber, szErrorString);
355
UpdateInstallStatusLog(szBuf);
358
void LogISLaunchApps(int iWhen)
363
sprintf(szBuf, "\n Launch Apps Start\n");
365
sprintf(szBuf, " Launch Apps End\n");
367
UpdateInstallStatusLog(szBuf);
370
void LogISLaunchAppsComponent(char *szComponentName)
374
sprintf(szBuf, " launching %s\n", szComponentName);
375
UpdateInstallStatusLog(szBuf);
378
void LogISLaunchAppsComponentUncompress(char *szComponentName, DWORD dwErr)
382
sprintf(szBuf, " uncompressing %s: %d\n", szComponentName, dwErr);
383
UpdateInstallStatusLog(szBuf);
386
void LogISProcessXpcomFile(int iStatus, int iResult)
390
if(iStatus == LIS_SUCCESS)
391
sprintf(szBuf, "\n Uncompressing Xpcom Succeeded: %d\n", iResult);
393
sprintf(szBuf, "\n Uncompressing Xpcom Failed: %d\n", iResult);
395
UpdateInstallStatusLog(szBuf);
398
void LogISDiskSpace(dsN *dsnComponentDSRequirement)
403
char szDSRequired[MAX_BUF_TINY];
404
char szDSAvailable[MAX_BUF_TINY];
406
if(dsnComponentDSRequirement != NULL)
408
sprintf(szBuf, "\n Disk Space Info:\n");
409
UpdateInstallStatusLog(szBuf);
410
dsnTemp = dsnComponentDSRequirement;
416
ulDSAvailable = GetDiskSpaceAvailable(dsnTemp->szVDSPath);
417
_itoa(ulDSAvailable, szDSAvailable, 10);
418
_itoa(dsnTemp->ulSpaceRequired, szDSRequired, 10);
420
" Path: %s\n Required: %sKB\n Available: %sKB\n",
424
UpdateInstallStatusLog(szBuf);
426
dsnTemp = dsnTemp->Next;
427
} while((dsnTemp != NULL) && (dsnTemp != dsnComponentDSRequirement));
431
void LogISTurboMode(BOOL bTurboMode)
436
sprintf(szBuf, "\n Turbo Mode: true\n");
438
sprintf(szBuf, "\n Turbo Mode: false\n");
440
UpdateInstallStatusLog(szBuf);
443
void LogMSProductInfo(void)
446
char szOSType[MAX_BUF_TINY];
448
GetOSTypeString(szOSType, sizeof(szOSType));
449
if(*gSystemInfo.szExtraString != '\0')
450
sprintf(szBuf, "UserAgent=%s/%s (%s,%d.%d.%d,%s)",
451
sgProduct.szProductName,
452
sgProduct.szUserAgent,
454
gSystemInfo.ulMajorVersion,
455
gSystemInfo.ulMinorVersion,
456
gSystemInfo.ulBuildNumber,
457
gSystemInfo.szExtraString);
459
sprintf(szBuf, "UserAgent=%s/%s (%s,%d.%d.%d)",
460
sgProduct.szProductName,
461
sgProduct.szUserAgent,
463
gSystemInfo.ulMajorVersion,
464
gSystemInfo.ulMinorVersion,
465
gSystemInfo.ulBuildNumber);
467
AppendToGlobalMessageStream(szBuf);
470
void LogMSDownloadProtocol(DWORD dwProtocolType)
472
char szMessageStream[MAX_BUF_TINY];
473
char szProtocolType[MAX_BUF];
475
switch(dwProtocolType)
478
strcpy(szProtocolType, "HTTP");
482
strcpy(szProtocolType, "FTP");
486
sprintf(szMessageStream, "&DownloadProtocol=%s", szProtocolType);
487
AppendToGlobalMessageStream(szMessageStream);
490
void LogMSDownloadStatus(int iDownloadStatus)
492
char szMessageStream[MAX_BUF_TINY];
494
sprintf(szMessageStream, "&DownloadStatus=%d", iDownloadStatus);
495
AppendToGlobalMessageStream(szMessageStream);
496
gErrorMessageStream.bSendMessage = TRUE;
499
void LogMSDownloadFileStatus(void)
501
siC *siCObject = NULL;
503
char szMessageStream[MAX_BUF];
505
memset(szMessageStream, 0, sizeof(szMessageStream));
507
siCObject = SiCNodeGetObject(dwIndex, TRUE, AC_ALL);
510
if(siCObject->iNetRetries ||
511
siCObject->iCRCRetries ||
512
siCObject->iNetTimeOuts)
514
char szFileInfo[MAX_BUF_SMALL];
518
siCObject->szArchiveName,
519
siCObject->iNetRetries,
520
siCObject->iCRCRetries,
521
siCObject->iNetTimeOuts);
523
strcat(szMessageStream, szFileInfo);
526
siCObject = SiCNodeGetObject(dwIndex, TRUE, AC_ALL);
529
if(*szMessageStream != '\0')
530
AppendToGlobalMessageStream(szMessageStream);
533
void LogMSXPInstallStatus(char *szFile, int iErr)
535
char szMessageStream[MAX_BUF];
536
static BOOL bAlreadyLogged = FALSE;
542
sprintf(szMessageStream, "&XPInstallStatus=%d&XPInstallFile=%s", iErr, szFile);
544
sprintf(szMessageStream, "&XPInstallStatus=%d", iErr);
546
AppendToGlobalMessageStream(szMessageStream);
547
bAlreadyLogged = TRUE;
548
if((iErr != E_REBOOT) &&
549
(((iErr == E_USER_CANCEL) &&
550
!gErrorMessageStream.bShowConfirmation) ||
551
((iErr != E_USER_CANCEL) &&
553
gErrorMessageStream.bSendMessage = TRUE;
556
void LogMSTurboMode(BOOL bTurboMode)
558
char szMessageStream[MAX_BUF];
560
sprintf(szMessageStream, "&TM=%d", bTurboMode);
561
AppendToGlobalMessageStream(szMessageStream);