2001-12-18 17:56:45 +00:00
// Includes
1999-10-23 00:10:24 +00:00
# include "stdafx.h"
# include <Winbase.h>
1999-11-03 01:51:54 +00:00
# include <direct.h>
2001-11-14 00:23:13 +00:00
# include <stdio.h>
2001-10-19 18:44:44 +00:00
# include <stdlib.h>
1999-10-23 00:10:24 +00:00
# include "globals.h"
1999-11-05 00:36:17 +00:00
# include "comp.h"
1999-11-03 01:51:54 +00:00
# include "ib.h"
2000-08-04 18:09:21 +00:00
# include "fstream.h"
1999-11-22 23:11:38 +00:00
# include <afxtempl.h>
2000-01-07 20:31:27 +00:00
# include <afxdisp.h>
1999-12-21 02:34:06 +00:00
# include "resource.h"
# include "NewDialog.h"
1999-10-23 00:10:24 +00:00
# define MAX_SIZE 1024
2001-11-14 00:23:13 +00:00
# define CRVALUE 0x0D
# define BUF_SIZE 4096
2001-12-18 17:56:45 +00:00
// for the xml parser used for PrefsTree
2001-12-28 21:17:11 +00:00
# include "xmlparse.h"
# include "prefselement.h"
2001-12-18 17:56:45 +00:00
2001-10-19 18:44:44 +00:00
// Required disk space for Linux build
# define LDISK_SPACE 84934656
1999-10-23 00:10:24 +00:00
1999-11-03 01:51:54 +00:00
int interpret ( char * cmd ) ;
CString rootPath ;
CString configName ;
CString configPath ;
CString workspacePath ;
2002-05-23 17:25:11 +00:00
CString shellPath ;
1999-11-03 01:51:54 +00:00
CString cdPath ;
1999-11-18 17:34:18 +00:00
CString networkPath ;
1999-11-03 01:51:54 +00:00
CString tempPath ;
1999-11-06 00:04:08 +00:00
CString iniDstPath ;
CString iniSrcPath ;
1999-11-03 01:51:54 +00:00
CString scriptPath ;
CString nscpxpiPath ;
1999-12-07 21:26:20 +00:00
CString cdshellPath ;
1999-12-09 23:53:03 +00:00
CString outputPath ;
2000-03-09 01:46:00 +00:00
CString xpiDstPath ;
2002-02-14 22:31:23 +00:00
CString remoteAdminFile ;
2002-01-22 18:37:26 +00:00
2001-11-14 00:23:13 +00:00
// variables for CCK Linux build
2002-02-12 19:13:15 +00:00
CString curPlatform ;
CString platformPath ;
2001-11-14 00:23:13 +00:00
CString templinuxPath ;
CString nsinstPath ;
CString nsinstallerDir ;
CString xpiDir ;
CString templinuxDir ;
CString tarfile ;
1999-11-03 01:51:54 +00:00
2001-12-28 21:17:11 +00:00
// For use with PrefsTree
2002-02-14 22:31:23 +00:00
CString gstrCFGPrefFile ;
CString gstrPlainPrefFile ;
2001-12-28 21:17:11 +00:00
CString gstrInstallFile ;
1999-11-22 23:11:38 +00:00
WIDGET * tempWidget ;
1999-11-03 01:51:54 +00:00
char buffer [ 50000 ] ;
XPI xpiList [ 100 ] ;
int xpiLen = - 1 ;
2000-09-27 01:42:51 +00:00
JAR jarList [ 100 ] ;
int jarLen = - 1 ;
2000-03-09 08:56:15 +00:00
// Setup Sections for config.ini
2001-08-28 21:10:28 +00:00
CString Setup0Short = " R&ecommended " ;
2000-03-09 08:56:15 +00:00
CString Setup1Short = " C&ustom " ;
2000-03-31 20:47:46 +00:00
CString quotes = " \" " ;
CString spaces = " " ;
2000-08-30 01:26:39 +00:00
BOOL prefDoesntExist = TRUE ;
1999-11-05 19:18:33 +00:00
COMPONENT Components [ 100 ] ;
1999-11-05 00:36:17 +00:00
int numComponents ;
2000-03-09 19:39:29 +00:00
int componentOrder ;
2001-11-14 00:23:13 +00:00
CString componentstr ;
2001-07-19 02:14:39 +00:00
char tempcomponentstr [ MAX_SIZE ] ;
1999-11-05 00:36:17 +00:00
1999-11-03 01:51:54 +00:00
int findXPI ( CString xpiname , CString filename )
{
int found = FALSE ;
2001-11-14 00:23:13 +00:00
for ( int i = 0 ; ! found & & i < = xpiLen ; i + + )
//xpiList is an array of structures where each structure contains
2001-06-04 22:35:03 +00:00
//the name of the xpi file and the subpath of the file within.
if ( xpiList [ i ] . xpiname = = xpiname & & xpiList [ i ] . filename = = filename )
found = TRUE ;
1999-11-03 01:51:54 +00:00
if ( ! found )
{
xpiLen + + ;
xpiList [ xpiLen ] . xpiname = xpiname ;
xpiList [ xpiLen ] . filename = filename ;
}
return found ;
}
int ExtractXPIFile ( CString xpiname , CString xpifile )
{
2002-01-24 21:34:58 +00:00
CString command ;
2000-09-27 01:42:51 +00:00
// AfxMessageBox("The xpiname is "+xpiname+" and the file is "+xpifile,MB_OK);
1999-11-03 01:51:54 +00:00
if ( findXPI ( xpiname , xpifile ) )
return TRUE ;
// Can use -d instead of change CWD???
2001-06-04 22:35:03 +00:00
CString xpiArchive = nscpxpiPath + " \\ " + xpiname ; //xpiArchive = CCKTool\NSCPXPI
2000-03-31 20:47:46 +00:00
command = quotes + rootPath + " unzip.exe " + quotes + " -o " + spaces + quotes + xpiArchive + quotes + spaces + quotes + xpifile + quotes ;
1999-11-03 01:51:54 +00:00
ExecuteCommand ( ( char * ) ( LPCTSTR ) command , SW_HIDE , INFINITE ) ;
return TRUE ;
}
int ReplaceXPIFiles ( )
{
CString command ;
CString xpiArchive ;
CString xpiArcDest ;
// Go through the whole list putting them into the archives
for ( int i = 0 ; i < = xpiLen ; i + + )
{
// This copy preserves the existing archive if it exists - do we
// need to delete it the first time through?
2001-06-04 22:35:03 +00:00
xpiArchive = nscpxpiPath + " \\ " + xpiList [ i ] . xpiname ; //nscpxpiPath=CCKTool\NSCPXPI
xpiArcDest = xpiDstPath + " \\ " + xpiList [ i ] . xpiname ; //xpiDstPath=CCKTool\Configs\ configName\Output\Core
1999-11-03 01:51:54 +00:00
if ( ! CopyFile ( xpiArchive , xpiArcDest , TRUE ) )
2001-11-14 00:23:13 +00:00
DWORD e = GetLastError ( ) ;
2002-02-12 19:13:15 +00:00
// if ((strcmp(xpiList[i].filename,"bin/defaults/isp/US") == 0) || (strcmp(xpiList[i].filename,"bin/defaults/isp") == 0))
if ( ( ( xpiList [ i ] . filename ) . Find ( " isp " ) ) ! = - 1 )
2001-11-14 00:23:13 +00:00
command = quotes + rootPath + " zip.exe " + quotes + " -m " + spaces + quotes + xpiArcDest + quotes + spaces + quotes + xpiList [ i ] . filename + " /*.* " + quotes ;
else
command = quotes + rootPath + " zip.exe " + quotes + " -m " + spaces + quotes + xpiArcDest + quotes + spaces + quotes + xpiList [ i ] . filename + quotes ;
1999-11-03 01:51:54 +00:00
ExecuteCommand ( ( char * ) ( LPCTSTR ) command , SW_HIDE , INFINITE ) ;
}
return TRUE ;
}
2000-09-27 01:42:51 +00:00
int findJAR ( CString jarname , CString filename )
{
int found = FALSE ;
for ( int i = 0 ; ! found & & i < = jarLen ; i + + )
if ( jarList [ i ] . jarname = = jarname & &
jarList [ i ] . filename = = filename )
found = TRUE ;
if ( ! found )
{
jarLen + + ;
jarList [ jarLen ] . jarname = jarname ;
jarList [ jarLen ] . filename = filename ;
}
return found ;
}
2001-11-14 00:23:13 +00:00
// Decrypt a file to another file.
int UnHash ( CString HashedFile , CString ClearTextFile )
{
CString command = quotes + rootPath + " parse_cfg.exe " + quotes + " -Y -input " + HashedFile + " -output " + ClearTextFile ;
ExecuteCommand ( ( char * ) ( LPCTSTR ) command , SW_HIDE , INFINITE ) ;
return TRUE ;
}
// Encrypt a file to another file.
int Hash ( CString ClearTextFile , CString HashedFile )
{
2002-02-20 03:13:31 +00:00
CString command = quotes + rootPath + " make_cfg.exe " + quotes +
" -Y -input " + quotes + ClearTextFile + quotes + " -output " +
quotes + HashedFile + quotes ;
2001-11-14 00:23:13 +00:00
ExecuteCommand ( ( char * ) ( LPCTSTR ) command , SW_HIDE , INFINITE ) ;
return TRUE ;
}
2000-09-27 01:42:51 +00:00
int ExtractJARFile ( CString xpiname , CString jarname , CString xpifile )
{
// AfxMessageBox("The xpiname is "+xpiname+" and the jar name is "+jarname+" and the file is "+xpifile,MB_OK);
ExtractXPIFile ( xpiname , jarname ) ;
CString command ;
2002-02-12 19:13:15 +00:00
CString jarArchive ;
2002-03-09 02:14:01 +00:00
if ( curPlatform = = " Mac OS " )
2002-02-12 19:13:15 +00:00
{
jarname . Replace ( " / " , " \\ " ) ;
jarname . Insert ( 0 , " \\ " ) ;
jarArchive = tempPath + jarname ;
}
else
{
//We have to get rid of the bin/chrome/ and hence the delete.
jarname . Delete ( 0 , 11 ) ;
jarArchive = tempPath + " \\ bin \\ chrome \\ " + jarname ;
}
2000-09-27 01:42:51 +00:00
if ( findJAR ( jarname , xpifile ) )
return TRUE ;
// Can use -d instead of change CWD???
command = quotes + rootPath + " unzip.exe " + quotes + " -o " + spaces + quotes + jarArchive + quotes + spaces + quotes + xpifile + quotes ;
ExecuteCommand ( ( char * ) ( LPCTSTR ) command , SW_HIDE , INFINITE ) ;
return TRUE ;
}
int ReplaceJARFiles ( )
{
CString command ;
CString jarArchive ;
// Go through the whole list putting them into the archives
for ( int i = 0 ; i < = jarLen ; i + + )
{
// This copy preserves the existing archive if it exists - do we
// need to delete it the first time through?
2002-03-09 02:14:01 +00:00
if ( curPlatform = = " Mac OS " )
2002-02-12 19:13:15 +00:00
jarArchive = tempPath + jarList [ i ] . jarname ;
else
jarArchive = tempPath + " \\ bin \\ chrome \\ " + jarList [ i ] . jarname ;
2000-09-27 01:42:51 +00:00
command = quotes + rootPath + " zip.exe " + quotes + " -m " + spaces + quotes + jarArchive + quotes + spaces + quotes + jarList [ i ] . filename + quotes ;
ExecuteCommand ( ( char * ) ( LPCTSTR ) command , SW_HIDE , INFINITE ) ;
}
return TRUE ;
}
1999-11-03 01:51:54 +00:00
int ReplaceINIFile ( )
{
2000-11-10 21:52:44 +00:00
CString command1 , command2 , commandReadme ;
2002-04-30 02:46:51 +00:00
CString zipName ( " NSSetup.zip " ) ;
CString exeName ( " NSSetup.exe " ) ;
2000-08-29 23:27:11 +00:00
CString copyb = " copy /b " ;
1999-11-03 01:51:54 +00:00
char olddir [ 1024 ] ;
GetCurrentDirectory ( sizeof ( olddir ) , olddir ) ;
2000-03-09 01:46:00 +00:00
if ( SetCurrentDirectory ( ( char * ) ( LPCTSTR ) xpiDstPath ) = = FALSE )
1999-11-03 01:51:54 +00:00
return FALSE ;
2000-08-29 23:27:11 +00:00
CString Src = nscpxpiPath + " \\ " + zipName ;
CString Dst = xpiDstPath + " \\ " + zipName ;
2000-02-22 02:26:56 +00:00
if ( ! CopyFile ( Src , Dst , FALSE ) )
1999-11-03 01:51:54 +00:00
DWORD e = GetLastError ( ) ;
2000-11-15 23:07:32 +00:00
2000-08-29 23:27:11 +00:00
// command = quotes + rootPath + "nszip.exe " + quotes + spaces + exeName + spaces + "config.ini";
command1 = quotes + rootPath + " zip.exe " + quotes + " -m " + spaces + zipName + spaces + " config.ini " ;
2001-11-14 19:05:48 +00:00
ExecuteCommand ( ( char * ) ( LPCTSTR ) command1 , SW_HIDE , INFINITE ) ;
2002-04-30 02:46:51 +00:00
// Copy the Readme file to the core directory and insert it inside the NSSetup.zip**********
2000-11-10 21:52:44 +00:00
CString readmePath = GetGlobal ( " ReadMeFile " ) ;
CString replaceReadme = xpiDstPath + " \\ Readme.txt " ;
if ( ! CopyFile ( readmePath , replaceReadme , FALSE ) )
DWORD e = GetLastError ( ) ;
commandReadme = quotes + rootPath + " zip.exe " + quotes + " -m " + spaces + zipName + spaces + " Readme.txt " ;
2001-11-14 19:05:48 +00:00
ExecuteCommand ( ( char * ) ( LPCTSTR ) commandReadme , SW_HIDE , INFINITE ) ;
2000-11-10 21:52:44 +00:00
// Finished copying readme and inserting into the zip**********
2002-04-30 02:46:51 +00:00
command2 = copyb + quotes + rootPath + " unzipsfx.exe " + quotes + " + NSSetup.zip NSSetup.exe " ;
2000-08-29 23:27:11 +00:00
// copy /b unzipsfx.exe+letters.zip letters.exe
///////////////////////////////////////////////////////
CString copycat = " copycat.bat " ;
ofstream cc ( copycat ) ;
2000-10-19 22:01:06 +00:00
cc < < command2 < < " \n echo off \n cls \n " ;
2000-08-29 23:27:11 +00:00
cc . close ( ) ;
CString command3 = " copycat.bat " ;
///////////////////////////////////////////////////////
2001-11-14 19:05:48 +00:00
ExecuteCommand ( ( char * ) ( LPCTSTR ) command3 , SW_HIDE , INFINITE ) ;
2000-08-29 23:27:11 +00:00
DeleteFile ( " copycat.bat " ) ;
2000-10-19 22:01:06 +00:00
CString unzipN6 = quotes + rootPath + " unzip.exe " + quotes + " -o " + spaces + quotes + zipName + quotes ;
2001-11-14 19:05:48 +00:00
ExecuteCommand ( ( char * ) ( LPCTSTR ) unzipN6 , SW_HIDE , INFINITE ) ;
2000-08-29 23:27:11 +00:00
DeleteFile ( zipName ) ;
1999-11-03 01:51:54 +00:00
SetCurrentDirectory ( olddir ) ;
return TRUE ;
}
2001-11-14 00:23:13 +00:00
void ModifyPref ( char * buffer , CString entity , CString newvalue , BOOL bLockPref )
2000-02-22 02:26:56 +00:00
{
CString buf ( buffer ) ;
int i = buf . Find ( entity ) ;
if ( i = = - 1 ) return ;
i = buf . Find ( ' " ' , i + 1 ) ;
if ( i = = - 1 ) return ;
i + + ;
i = buf . Find ( ' " ' , i + 1 ) ;
if ( i = = - 1 ) return ;
i + + ;
int j = buf . Find ( ' " ' , i ) ;
if ( j = = - 1 ) return ;
j - - ;
buf . Delete ( i , j - i + 1 ) ;
buf . Insert ( i , newvalue ) ;
2001-11-14 00:23:13 +00:00
if ( bLockPref )
{
2002-01-18 20:28:09 +00:00
// If it's not lockPref( already.
if ( buf . Find ( " lockPref( " ) < 0 )
buf . Replace ( " pref( " , " lockPref( " ) ;
2001-11-14 00:23:13 +00:00
}
2000-02-22 02:26:56 +00:00
strcpy ( buffer , ( char * ) ( LPCTSTR ) buf ) ;
2000-08-30 01:26:39 +00:00
prefDoesntExist = FALSE ;
2000-02-22 02:26:56 +00:00
}
2000-08-04 18:09:21 +00:00
int ModifyProperties ( CString xpifile , CString entity , CString newvalue )
{
int rv = TRUE ;
CString propFile = xpifile ;
CString tempFile = xpifile + " .temp " ;
char properties [ 400 ] ;
ofstream tf ( tempFile ) ;
if ( ! tf )
{
rv = FALSE ;
cout < < " Cannot open: " < < tempFile < < " \n " ;
return rv ;
}
tf < < entity < < " = " < < newvalue < < " \n " ;
ifstream pf ( propFile ) ;
if ( ! pf )
{
rv = FALSE ;
cout < < " Cannot open: " < < propFile < < " \n " ;
return rv ;
}
while ( ! pf . eof ( ) )
{
pf . getline ( properties , 400 ) ;
tf < < properties < < " \n " ;
}
pf . close ( ) ;
tf . close ( ) ;
remove ( xpifile ) ;
rename ( tempFile , xpifile ) ;
return rv ;
}
2001-11-14 00:23:13 +00:00
void AddPref ( CString xpifile , CString entity , CString newvalue , BOOL bUseQuotes , BOOL bLockPref )
2000-08-30 01:26:39 +00:00
{
int rv = TRUE ;
CString prefFile = xpifile ;
CString tempFile = xpifile + " .temp " ;
char properties [ 400 ] ;
ofstream tf ( tempFile ) ;
if ( ! tf )
{
rv = FALSE ;
cout < < " Cannot open: " < < tempFile < < " \n " ;
return ;
}
ifstream pf ( prefFile ) ;
if ( ! pf )
{
rv = FALSE ;
cout < < " Cannot open: " < < prefFile < < " \n " ;
return ;
}
while ( ! pf . eof ( ) )
{
pf . getline ( properties , 400 ) ;
tf < < properties < < " \n " ;
}
2001-11-14 00:23:13 +00:00
CString Quote = bUseQuotes ? quotes : " " ;
2002-01-18 20:28:09 +00:00
CString FuncName = bLockPref ? " lockPref( " : " pref( " ;
2001-11-14 00:23:13 +00:00
tf < < FuncName < < entity < < " , " < < Quote < < newvalue < < Quote < < " ); \n " ;
2000-08-30 01:26:39 +00:00
pf . close ( ) ;
tf . close ( ) ;
remove ( xpifile ) ;
rename ( tempFile , xpifile ) ;
return ;
}
2000-08-04 18:09:21 +00:00
2001-11-14 00:23:13 +00:00
int ModifyJS ( CString xpifile , CString entity , CString newvalue , BOOL bLockPref )
2000-02-22 02:26:56 +00:00
{
2002-01-11 19:33:33 +00:00
2000-02-22 02:26:56 +00:00
int rv = TRUE ;
2001-11-14 00:23:13 +00:00
CString newfile = xpifile + " .new " ;
2000-02-22 02:26:56 +00:00
char * fgetsrv ;
// Read in DTD file and make substitutions
FILE * srcf = fopen ( xpifile , " r " ) ;
FILE * dstf = fopen ( newfile , " w " ) ;
CString apost = ' " ' ;
entity . Insert ( 0 , apost ) ;
entity . Insert ( 1000 , apost ) ;
if ( ! srcf )
rv = FALSE ;
else
{
2001-11-14 00:23:13 +00:00
prefDoesntExist = TRUE ;
2002-02-12 19:13:15 +00:00
while ( ! feof ( srcf ) )
2000-02-22 02:26:56 +00:00
{
fgetsrv = fgets ( buffer , sizeof ( buffer ) , srcf ) ;
2002-02-12 19:13:15 +00:00
if ( ! fgetsrv | | ferror ( srcf ) )
2000-02-22 02:26:56 +00:00
{
2002-02-12 19:13:15 +00:00
rv = FALSE ;
break ;
2000-02-22 02:26:56 +00:00
}
2002-02-12 19:13:15 +00:00
ModifyPref ( buffer , entity , newvalue , bLockPref ) ;
fputs ( buffer , dstf ) ;
2000-02-22 02:26:56 +00:00
}
fclose ( srcf ) ;
fclose ( dstf ) ;
}
remove ( xpifile ) ;
rename ( newfile , xpifile ) ;
2000-08-30 01:26:39 +00:00
if ( prefDoesntExist )
2001-11-14 00:23:13 +00:00
AddPref ( xpifile , entity , newvalue , TRUE , bLockPref ) ;
2000-02-22 02:26:56 +00:00
return TRUE ;
}
2002-02-12 19:13:15 +00:00
1999-11-03 01:51:54 +00:00
void ModifyEntity ( char * buffer , CString entity , CString newvalue )
{
CString buf ( buffer ) ;
entity = entity + " " ; // Ensure we don't get false matches
int i = buf . Find ( entity ) ;
if ( i = = - 1 ) return ;
i = buf . Find ( ' " ' , i + 1 ) ;
if ( i = = - 1 ) return ;
i + + ;
int j = buf . Find ( ' " ' , i ) ;
if ( j = = - 1 ) return ;
j - - ;
buf . Delete ( i , j - i + 1 ) ;
buf . Insert ( i , newvalue ) ;
strcpy ( buffer , ( char * ) ( LPCTSTR ) buf ) ;
}
int ModifyDTD ( CString xpifile , CString entity , CString newvalue )
{
CString newfile = xpifile + " .new " ;
int rv = TRUE ;
char * fgetsrv ;
// Read in DTD file and make substitutions
FILE * srcf = fopen ( xpifile , " r " ) ;
FILE * dstf = fopen ( newfile , " w " ) ;
if ( ! srcf )
rv = FALSE ;
else
{
2002-02-12 19:13:15 +00:00
while ( ! feof ( srcf ) )
1999-11-03 01:51:54 +00:00
{
fgetsrv = fgets ( buffer , sizeof ( buffer ) , srcf ) ;
2002-02-12 19:13:15 +00:00
if ( ! fgetsrv | | ferror ( srcf ) )
1999-11-03 01:51:54 +00:00
{
2002-02-12 19:13:15 +00:00
rv = FALSE ;
break ;
1999-11-03 01:51:54 +00:00
}
2002-02-12 19:13:15 +00:00
ModifyEntity ( buffer , entity , newvalue ) ;
fputs ( buffer , dstf ) ;
1999-11-03 01:51:54 +00:00
}
fclose ( srcf ) ;
fclose ( dstf ) ;
}
remove ( xpifile ) ;
rename ( newfile , xpifile ) ;
return TRUE ;
}
2001-11-14 00:23:13 +00:00
void ModifyEntity1 ( char * buffer , CString entity , CString newvalue , BOOL bLockPref )
{
CString buf ( buffer ) ;
entity = entity + " \" " ;
int i = buf . Find ( entity ) ;
if ( i = = - 1 ) return ;
i = buf . ReverseFind ( ' " ' ) ;
if ( i = = - 1 ) return ;
CString tempbuf = buf ;
tempbuf . Left ( i ) ;
int j = tempbuf . ReverseFind ( ' " ' ) ;
if ( j = = - 1 ) return ;
buf . Delete ( j , i - j ) ;
buf . Insert ( j , newvalue ) ;
if ( bLockPref )
{
// If it's not LockPref( already, change Pref( to LockPref(.
2002-01-18 20:28:09 +00:00
if ( buf . Find ( " lockPref( " ) < 0 )
buf . Replace ( " pref( " , " lockPref( " ) ;
2001-11-14 00:23:13 +00:00
}
strcpy ( buffer , ( char * ) ( LPCTSTR ) buf ) ;
}
int ModifyJS1 ( CString xpifile , CString entity , CString newvalue , BOOL bLockPref )
{
CString newfile = xpifile + " .new " ;
int rv = TRUE ;
char * fgetsrv ;
// Read in all.js file and make substitutions
FILE * srcf = fopen ( xpifile , " r " ) ;
FILE * dstf = fopen ( newfile , " w " ) ;
if ( ! srcf )
rv = FALSE ;
else
{
2002-02-12 19:13:15 +00:00
while ( ! feof ( srcf ) )
2001-11-14 00:23:13 +00:00
{
fgetsrv = fgets ( buffer , sizeof ( buffer ) , srcf ) ;
2002-02-12 19:13:15 +00:00
if ( ! fgetsrv | | ferror ( srcf ) )
2001-11-14 00:23:13 +00:00
{
2002-02-12 19:13:15 +00:00
rv = FALSE ;
break ;
2001-11-14 00:23:13 +00:00
}
2002-02-12 19:13:15 +00:00
ModifyEntity1 ( buffer , entity , newvalue , bLockPref ) ;
fputs ( buffer , dstf ) ;
2001-11-14 00:23:13 +00:00
}
fclose ( srcf ) ;
fclose ( dstf ) ;
}
remove ( xpifile ) ;
rename ( newfile , xpifile ) ;
return TRUE ;
}
void ModifyEntity2 ( char * buffer , CString entity , CString newvalue , BOOL bLockPref )
{
CString buf ( buffer ) ;
newvalue = " " + newvalue ;
int i = buf . Find ( entity ) ;
if ( i = = - 1 ) return ;
i = buf . ReverseFind ( ' ) ' ) ;
if ( i = = - 1 ) return ;
CString tempbuf = buf ;
tempbuf . Left ( i ) ;
int j = tempbuf . ReverseFind ( ' , ' ) ;
if ( j = = - 1 ) return ;
buf . Delete ( j + 1 , i - j - 1 ) ;
buf . Insert ( j + 1 , newvalue ) ;
if ( bLockPref )
{
// If it's not LockPref( already.
2002-01-18 20:28:09 +00:00
if ( buf . Find ( " lockPref( " ) < 0 )
buf . Replace ( " pref( " , " lockPref( " ) ;
2001-11-14 00:23:13 +00:00
}
strcpy ( buffer , ( char * ) ( LPCTSTR ) buf ) ;
prefDoesntExist = FALSE ;
}
int ModifyJS2 ( CString xpifile , CString entity , CString newvalue , BOOL bLockPref )
{
CString newfile = xpifile + " .new " ;
int rv = TRUE ;
char * fgetsrv ;
// Read in all.js file and make substitutions
FILE * srcf = fopen ( xpifile , " r " ) ;
FILE * dstf = fopen ( newfile , " w " ) ;
if ( ! srcf )
rv = FALSE ;
else
{
prefDoesntExist = TRUE ;
2002-02-12 19:13:15 +00:00
while ( ! feof ( srcf ) )
2001-11-14 00:23:13 +00:00
{
fgetsrv = fgets ( buffer , sizeof ( buffer ) , srcf ) ;
2002-02-12 19:13:15 +00:00
if ( ! fgetsrv | | ferror ( srcf ) )
2001-11-14 00:23:13 +00:00
{
2002-02-12 19:13:15 +00:00
rv = FALSE ;
break ;
2001-11-14 00:23:13 +00:00
}
2002-02-12 19:13:15 +00:00
ModifyEntity2 ( buffer , entity , newvalue , bLockPref ) ;
fputs ( buffer , dstf ) ;
2001-11-14 00:23:13 +00:00
}
fclose ( srcf ) ;
fclose ( dstf ) ;
}
remove ( xpifile ) ;
rename ( newfile , xpifile ) ;
if ( prefDoesntExist )
{
// AddPref expects pref name to be surrounded in quotes.
CString prefName = " \" " + entity + " \" " ;
AddPref ( xpifile , prefName , newvalue , FALSE , bLockPref ) ;
}
return TRUE ;
}
BOOL FileExists ( CString file )
{
WIN32_FIND_DATA data ;
HANDLE d = FindFirstFile ( ( const char * ) file , & data ) ;
return ( d ! = INVALID_HANDLE_VALUE ) ;
}
BOOL CreateNewFile ( CString & Filename , CString Contents )
{
FILE * f = fopen ( Filename , " w " ) ;
if ( ! f )
return FALSE ;
fprintf ( f , Contents ) ;
fclose ( f ) ;
return TRUE ;
}
// Modifies a preference in a hashed prefs file.
// Specify whether the pref value should be "string", "bool", or "int".
// Adds the pref if it is missing.
// Creates the file if missing.
// Returns TRUE if OK, or FALSE on error.
int ModifyHashedPref ( CString HashedPrefsFile , CString PrefName , CString NewPrefValue , CString PrefType , BOOL bLockPref )
{
// Unhash the prefs file to a plain text file. If there is no hashed file yet,
// create a plaintext file with only a comment.
CString PlainTextPrefsFile = HashedPrefsFile + " .js " ;
if ( FileExists ( HashedPrefsFile ) )
{
if ( ! UnHash ( HashedPrefsFile , PlainTextPrefsFile ) )
return FALSE ;
}
else
{
// Create a plain text prefs with only a comment.
2002-01-30 03:21:40 +00:00
CreateNewFile ( PlainTextPrefsFile , " /* prefs configured in NCADM */ \n " ) ;
2001-11-14 00:23:13 +00:00
}
// Modify the pref.
if ( PrefType . CompareNoCase ( " string " ) = = 0 )
{
if ( ! ModifyJS ( PlainTextPrefsFile , PrefName , NewPrefValue , bLockPref ) )
return FALSE ;
}
else if ( PrefType . CompareNoCase ( " int " ) = = 0 )
{
if ( NewPrefValue . IsEmpty ( ) )
NewPrefValue = " 0 " ;
if ( ! ModifyJS2 ( PlainTextPrefsFile , PrefName , NewPrefValue , bLockPref ) )
return FALSE ;
}
else if ( PrefType . CompareNoCase ( " bool " ) = = 0 )
{
2002-01-08 21:11:27 +00:00
if ( NewPrefValue . IsEmpty ( ) | | NewPrefValue = = " 0 " | | ( NewPrefValue . CompareNoCase ( " false " ) = = 0 ) )
NewPrefValue = " false " ;
else
NewPrefValue = " true " ;
2001-11-14 00:23:13 +00:00
if ( ! ModifyJS2 ( PlainTextPrefsFile , PrefName , NewPrefValue , bLockPref ) )
return FALSE ;
}
// And rehash it.
if ( ! Hash ( PlainTextPrefsFile , HashedPrefsFile ) )
return FALSE ;
return TRUE ;
}
2001-12-28 21:17:11 +00:00
// This processes a prefs tree XML file, adding preferences to install files
// as specified in the prefs tree XML file. See PrefsTree.html for file
// format details.
//
// Called by the XML parser when a new element is read.
void startElement ( void * userData , const char * name , const char * * atts )
{
ASSERT ( userData ) ;
( ( CPrefElement * ) userData ) - > startElement ( name , atts ) ;
}
void characterData ( void * userData , const XML_Char * s , int len )
{
ASSERT ( userData ) ;
( ( CPrefElement * ) userData ) - > characterData ( s , len ) ;
}
// Called by the XML parser when an element close tag is read.
void endElement ( void * userData , const char * name )
2001-12-18 17:56:45 +00:00
{
2001-12-28 21:17:11 +00:00
ASSERT ( userData ) ;
( ( CPrefElement * ) userData ) - > endElement ( name ) ;
2001-12-18 17:56:45 +00:00
2001-12-28 21:17:11 +00:00
if ( stricmp ( name , " PREF " ) = = 0 )
2001-12-18 17:56:45 +00:00
{
2001-12-28 21:17:11 +00:00
2002-02-14 22:31:23 +00:00
// If locked, write to the .cfg file. Don't care if it's default or not.
2002-04-05 19:34:39 +00:00
BOOL bLocked = ( ( CPrefElement * ) userData ) - > IsLocked ( ) ;
BOOL bRemoteAdmin = ( ( CPrefElement * ) userData ) - > IsRemoteAdmin ( ) ;
BOOL bDefault = ( ( CPrefElement * ) userData ) - > IsDefault ( ) ;
if ( bLocked & & ! bRemoteAdmin )
2002-02-14 22:31:23 +00:00
{
// Write the pref element to prefs file.
ExtractXPIFile ( gstrInstallFile , gstrCFGPrefFile ) ;
ModifyHashedPref ( gstrCFGPrefFile , ( ( CPrefElement * ) userData ) - > GetPrefName ( ) , ( ( CPrefElement * ) userData ) - > GetPrefValue ( ) , ( ( CPrefElement * ) userData ) - > GetPrefType ( ) , TRUE ) ;
}
2001-12-28 21:17:11 +00:00
2002-02-14 22:31:23 +00:00
// If not locked, and not NS default, write to the .js file.
else if ( ! bDefault )
2001-12-28 21:17:11 +00:00
{
2002-02-14 22:31:23 +00:00
ExtractXPIFile ( gstrInstallFile , gstrPlainPrefFile ) ;
2001-12-28 21:17:11 +00:00
2002-02-14 22:31:23 +00:00
if ( ( ( ( CPrefElement * ) userData ) - > GetPrefType ( ) = = " int " ) | | ( ( ( CPrefElement * ) userData ) - > GetPrefType ( ) = = " bool " ) )
ModifyJS2 ( gstrPlainPrefFile , ( ( CPrefElement * ) userData ) - > GetPrefName ( ) , ( ( CPrefElement * ) userData ) - > GetPrefValue ( ) , FALSE ) ;
else // string
ModifyJS ( gstrPlainPrefFile , ( ( CPrefElement * ) userData ) - > GetPrefName ( ) , ( ( CPrefElement * ) userData ) - > GetPrefValue ( ) , FALSE ) ;
2001-12-28 21:17:11 +00:00
}
2002-02-14 22:31:23 +00:00
// If remote admin, write to the .jsc file.
if ( bRemoteAdmin )
2001-12-28 21:17:11 +00:00
{
2002-02-14 22:31:23 +00:00
if ( ! FileExists ( remoteAdminFile ) )
{
CString strURL = GetGlobal ( " RemoteAdminURL " ) ;
CString strComment ;
strComment . Format ( " /* This Remote Admin file should be placed at %s */ \n " , strURL ) ;
CreateNewFile ( remoteAdminFile , strComment ) ;
}
2001-12-28 21:17:11 +00:00
if ( ( ( ( CPrefElement * ) userData ) - > GetPrefType ( ) = = " int " ) | | ( ( ( CPrefElement * ) userData ) - > GetPrefType ( ) = = " bool " ) )
2002-02-14 22:31:23 +00:00
ModifyJS2 ( remoteAdminFile , ( ( CPrefElement * ) userData ) - > GetPrefName ( ) , ( ( CPrefElement * ) userData ) - > GetPrefValue ( ) , TRUE ) ;
2001-12-28 21:17:11 +00:00
else // string
2002-02-14 22:31:23 +00:00
ModifyJS ( remoteAdminFile , ( ( CPrefElement * ) userData ) - > GetPrefName ( ) , ( ( CPrefElement * ) userData ) - > GetPrefValue ( ) , TRUE ) ;
2001-12-28 21:17:11 +00:00
2001-12-18 17:56:45 +00:00
}
}
}
2002-04-05 19:34:39 +00:00
// special case for homepage URL: if locked or remote admin, do the right thing.
// otherwise, call the originally called ModifyProperties method
BOOL ModifyHomepageURL ( CString xpifile , CString entity , CString newvalue )
{
bool bLocked = GetGlobal ( " HomePageURLLocked " ) = = " 1 " ;
bool bRemoteAdmin = GetGlobal ( " HomePageURLRemoteAdmin " ) = = " 1 " ;
CString strPref = " browser.startup.homepage " ;
CString strURL = GetGlobal ( " HomePageURL " ) ;
if ( bLocked & & ! bRemoteAdmin )
{
// Write the pref element to prefs file.
ExtractXPIFile ( gstrInstallFile , gstrCFGPrefFile ) ;
ModifyHashedPref ( gstrCFGPrefFile , strPref , strURL , " string " , TRUE ) ;
}
// If remote admin, write to the .jsc file.
else if ( bRemoteAdmin )
{
if ( ! FileExists ( remoteAdminFile ) )
{
CString strComment ;
strComment . Format ( " /* The Homepage URL should be %s */ \n " , strURL ) ;
CreateNewFile ( remoteAdminFile , strComment ) ;
}
ModifyJS ( remoteAdminFile , strPref , strURL , TRUE ) ;
}
// not locked, or remote, just modify the property
else
ModifyProperties ( xpifile , entity , newvalue ) ;
return TRUE ;
}
2002-02-14 22:31:23 +00:00
// Sets the autoadmin.global_config_url in strPrefFile to strURL.
BOOL ConfigureRemoteAdmin ( CString strURL , CString strPrefFile )
2002-01-08 21:11:27 +00:00
{
2002-02-14 22:31:23 +00:00
ASSERT ( ! strURL . IsEmpty ( ) & & ! strPrefFile . IsEmpty ( ) ) ;
if ( strURL . IsEmpty ( ) | | strPrefFile . IsEmpty ( ) )
2002-01-08 21:11:27 +00:00
return FALSE ;
ASSERT ( strPrefFile . Find ( " .cfg " ) > 0 ) ;
if ( strPrefFile . Find ( " .cfg " ) < = 0 )
return FALSE ;
ModifyHashedPref ( strPrefFile , " autoadmin.global_config_url " , strURL , " string " , TRUE ) ;
2002-02-13 23:30:41 +00:00
CString strFailoverCached = GetGlobal ( " RemoteAdminFailoverToCached " ) ;
ModifyHashedPref ( strPrefFile , " autoadmin.failover_to_cached " , strFailoverCached , " bool " , TRUE ) ;
2002-01-08 21:11:27 +00:00
CString strFailover = GetGlobal ( " RemoteAdminFailover " ) ;
ModifyHashedPref ( strPrefFile , " autoadmin.offline_failover " , strFailover , " bool " , TRUE ) ;
2002-02-13 23:30:41 +00:00
CString strPoll = GetGlobal ( " RemoteAdminPoll " ) ;
if ( strPoll = = " 1 " )
{
CString strPollFreq = GetGlobal ( " RemoteAdminPollFreq " ) ;
ModifyHashedPref ( strPrefFile , " autoadmin.refresh_interval " , strPollFreq , " int " , TRUE ) ;
}
2002-01-08 21:11:27 +00:00
return TRUE ;
}
2001-12-18 17:56:45 +00:00
// This function can easily be rewriten to parse the XML file by hand if it
// needs to be ported to a non-MS OS. The XML is pretty simple.
2002-02-14 22:31:23 +00:00
BOOL ProcessPrefsTree ( CString strPrefsTreeFile )
2001-12-18 17:56:45 +00:00
{
2002-02-14 22:31:23 +00:00
//AfxMessageBox("Pause", MB_OK);
2001-12-28 21:17:11 +00:00
XML_Parser parser = XML_ParserCreate ( NULL ) ;
XML_SetElementHandler ( parser , startElement , endElement ) ;
XML_SetCharacterDataHandler ( parser , characterData ) ;
// Used by the XML parser. The data object passed to the handlers.
static CPrefElement element ;
XML_SetUserData ( parser , & element ) ;
// Load the XML from the file.
CString strPrefsXML ;
FILE * pFile = fopen ( strPrefsTreeFile , " r " ) ;
if ( ! pFile )
{
fprintf ( stderr , " Can't open the file %s. " , strPrefsTreeFile ) ;
return FALSE ;
}
// obtain file size.
fseek ( pFile , 0 , SEEK_END ) ;
long lSize = ftell ( pFile ) ;
rewind ( pFile ) ;
// allocate memory to contain the whole file.
char * buffer = ( char * ) malloc ( lSize + 1 ) ;
if ( buffer = = NULL )
{
fprintf ( stderr , " Memory allocation error. " ) ;
return FALSE ;
}
buffer [ lSize ] = ' \0 ' ;
// copy the file into the buffer.
size_t len = fread ( buffer , 1 , lSize , pFile ) ;
2002-01-08 21:11:27 +00:00
// the whole file is loaded in the buffer.
2001-12-28 21:17:11 +00:00
int done = 0 ;
if ( ! XML_Parse ( parser , buffer , len , done ) )
{
fprintf ( stderr ,
" %s at line %d \n " ,
XML_ErrorString ( XML_GetErrorCode ( parser ) ) ,
XML_GetCurrentLineNumber ( parser ) ) ;
return FALSE ;
}
XML_ParserFree ( parser ) ;
2002-01-08 21:11:27 +00:00
free ( buffer ) ;
2001-12-18 17:56:45 +00:00
return TRUE ;
}
2001-11-14 00:23:13 +00:00
2002-01-11 19:33:33 +00:00
BOOL ModifyUserJS ( CString HashedPrefsFile , CString jsSourceFile )
{
// Unhash the prefs file to a plain text file. If there is no hashed file yet,
// create a plaintext file with only a comment.
CString PlainTextPrefsFile = HashedPrefsFile + " .js " ;
if ( FileExists ( HashedPrefsFile ) )
{
if ( ! UnHash ( HashedPrefsFile , PlainTextPrefsFile ) )
return FALSE ;
}
else
{
// Create a plain text prefs with only a comment.
2002-01-30 03:21:40 +00:00
CreateNewFile ( PlainTextPrefsFile , " /* prefs configured in NCADM */ \n " ) ;
2002-01-11 19:33:33 +00:00
}
// find the block and replace it with the contents of the source file
CString newPrefsFile = PlainTextPrefsFile + " .new " ;
// Read in all.js file and make substitutions
CStdioFile srcJSC ;
FILE * destJSC = fopen ( newPrefsFile , " w " ) ;
if ( srcJSC . Open ( PlainTextPrefsFile , CFile : : modeRead | CFile : : typeText ) & & destJSC )
{
CString strLine ;
bool bInJSBlock = FALSE ;
bool bInsertUserJSNow = FALSE ;
bool bDroppedPayload = FALSE ;
int iBraceLevel = 0 ; // these are in case cfg file has braces
bool bPastFirstBrace = FALSE ;
while ( srcJSC . ReadString ( strLine ) )
{
strLine + = " \n " ;
// count braces
/*
char buffer [ 4096 ] ;
strcpy ( buffer , strLine ) ;
char * token = strtok ( buffer , " { " ) ;
while ( token ! = NULL )
{
bPastFirstBrace = TRUE ;
iBraceLevel + + ;
token = strtok ( NULL , " { " ) ;
}
strcpy ( buffer , strLine ) ;
token = strtok ( buffer , " } " ) ;
while ( token ! = NULL )
{
iBraceLevel - - ;
token = strtok ( NULL , " } " ) ;
}
if ( bPastFirstBrace & & iBraceLevel < 1 )
bInsertUserJSNow = TRUE ;
*/
// looking for //ADMJS_BEG (ADM JavaScript Begin)
// or //ADMJS_END (ADM JavaScript End) which must be on a line by themselves
int len = strLine . GetLength ( ) ;
if ( strLine . GetLength ( ) > 10
& & strLine [ 0 ] = = ' / '
& & strLine [ 1 ] = = ' / ' )
{
CString str = strLine . Left ( 6 ) ;
if ( str . CompareNoCase ( " \n \n //ADMJS_BEG \n " ) = = 0 )
{
bInsertUserJSNow = TRUE ;
bInJSBlock = TRUE ;
}
else if ( str . CompareNoCase ( " //ADMJS_END \n " ) = = 0 )
bInJSBlock = FALSE ;
}
// drop our payload
//
if ( bInsertUserJSNow )
{
CStdioFile srcJS ;
CString strJSLine ;
fputs ( strLine , destJSC ) ; // write out "//ADMJS_BEG"
if ( srcJS . Open ( jsSourceFile , CFile : : modeRead | CFile : : typeText ) )
{
while ( srcJS . ReadString ( strJSLine ) )
{
strJSLine + = " \n " ;
fputs ( strJSLine , destJSC ) ;
}
srcJS . Close ( ) ;
}
bInsertUserJSNow = FALSE ;
bDroppedPayload = TRUE ;
}
else
{
fputs ( strLine , destJSC ) ; // drop whatever line we have
}
} // while source lines
if ( ! bDroppedPayload )
{
CStdioFile srcJS ;
CString strJSLine ;
strJSLine = " \n \n //ADMJS_BEG \n " ;
fputs ( strJSLine , destJSC ) ;
if ( srcJS . Open ( jsSourceFile , CFile : : modeRead | CFile : : typeText ) )
{
while ( srcJS . ReadString ( strJSLine ) )
{
strJSLine + = " \n " ;
fputs ( strJSLine , destJSC ) ;
}
srcJS . Close ( ) ;
}
strJSLine = " //ADMJS_END \n " ;
fputs ( strJSLine , destJSC ) ;
}
srcJSC . Close ( ) ;
fclose ( destJSC ) ;
} // if can open source file
// delete orig and rename new file to correct name
remove ( PlainTextPrefsFile ) ;
rename ( newPrefsFile , PlainTextPrefsFile ) ;
// And rehash it.
if ( ! Hash ( PlainTextPrefsFile , HashedPrefsFile ) )
return FALSE ;
return TRUE ;
}
2002-01-24 21:34:58 +00:00
BOOL MarkCFGVersion ( CString HashedPrefsFile , CString versionTxt )
{
// Unhash the prefs file to a plain text file. If there is no hashed file yet,
// create a plaintext file with only a comment.
CString PlainTextPrefsFile = HashedPrefsFile + " .js " ;
if ( FileExists ( HashedPrefsFile ) )
{
if ( ! UnHash ( HashedPrefsFile , PlainTextPrefsFile ) )
return FALSE ;
}
else
{
// Create a plain text prefs with only a comment.
2002-01-30 03:21:40 +00:00
CreateNewFile ( PlainTextPrefsFile , " /* prefs configured in NCADM */ \n " ) ;
2002-01-24 21:34:58 +00:00
}
// find the block and replace it with the contents of the source file
CString newPrefsFile = PlainTextPrefsFile + " .new " ;
// Read in all.js file and make substitutions
CStdioFile srcJSC ;
FILE * destJSC = fopen ( newPrefsFile , " w " ) ;
if ( srcJSC . Open ( PlainTextPrefsFile , CFile : : modeRead | CFile : : typeText ) & & destJSC )
{
CString strLine ;
strLine = " //ADMVERSION: " + versionTxt + " \n " ;
fputs ( strLine , destJSC ) ;
while ( srcJSC . ReadString ( strLine ) )
{
strLine + = " \n " ;
CString str = strLine . Left ( 8 ) ;
if ( str . Compare ( " //ADMVER " ) = = 0 ) // throw away any previous //ADMVERSION tags
continue ;
fputs ( strLine , destJSC ) ; // drop whatever line we have
}
srcJSC . Close ( ) ;
fclose ( destJSC ) ;
} // if can open source file
// delete orig and rename new file to correct name
remove ( PlainTextPrefsFile ) ;
rename ( newPrefsFile , PlainTextPrefsFile ) ;
// And rehash it.
if ( ! Hash ( PlainTextPrefsFile , HashedPrefsFile ) )
return FALSE ;
return TRUE ;
}
2002-01-11 19:33:33 +00:00
2002-06-04 17:55:33 +00:00
void ModifySidebar ( CString inputFile , CString outputFile )
{
// Add a sidebar tab at the topmost location in 'My sidebar'
char tempbuf [ MAX_SIZE ] ;
CString searchstr = " <RDF:Seq> " ;
CString sidebartabTitle = GetGlobal ( " SidebartabTitle " ) ;
CString sidebartabURL = GetGlobal ( " SidebartabURL " ) ;
ifstream srcf ( inputFile ) ;
if ( ! srcf )
{
AfxMessageBox ( " Cannot open input file: " + CString ( inputFile ) , MB_OK ) ;
return ;
}
ofstream dstf ( outputFile ) ;
if ( ! dstf )
{
AfxMessageBox ( " Cannot open output file: " + CString ( outputFile ) , MB_OK ) ;
return ;
}
while ( ! srcf . eof ( ) )
{
srcf . getline ( tempbuf , MAX_SIZE ) ;
dstf < < tempbuf < < " \n " ;
if ( ( CString ( tempbuf ) . Find ( searchstr ) ) ! = - 1 )
{
dstf < < " <RDF:li> " < < " \n " ;
dstf < < " <RDF:Description about= \" " < < sidebartabTitle < < " \" > \n " ;
dstf < < " <NC:title> " < < sidebartabTitle < < " </NC:title> " < < " \n " ;
dstf < < " <NC:content> " < < sidebartabURL < < " </NC:content> " < < " \n " ;
dstf < < " </RDF:Description> " < < " \n " ;
dstf < < " </RDF:li> " < < " \n " ;
}
}
srcf . close ( ) ;
dstf . close ( ) ;
}
2002-06-22 00:15:05 +00:00
void ModifyBookmarks ( CString inputFile , CString outputFile )
// add custom bookmark(s) either at the top or bottom of the bookmark menu
{
char tempbuf [ MAX_SIZE ] ;
// variables for custom personal toolbar
CString toolbarURL1 = GetGlobal ( " ToolbarURL1 " ) ;
CString toolbarURL2 = GetGlobal ( " ToolbarURL2 " ) ;
CString toolbarURL3 = GetGlobal ( " ToolbarURL3 " ) ;
CString toolbarTitle1 = GetGlobal ( " ToolbarTitle1 " ) ;
CString toolbarTitle2 = GetGlobal ( " ToolbarTitle2 " ) ;
CString toolbarTitle3 = GetGlobal ( " ToolbarTitle3 " ) ;
CString toolbarSearchStr = " >Personal Toolbar Folder< " ;
// variables for custom bookmark
CString bkmkChoice = GetGlobal ( " radioGroup3 " ) ;
CString bkmkLocation = GetGlobal ( " BookmarkLocation " ) ;
CString firstbkmkSearchStr = " <h1>Bookmarks</h1> " ;
CString lastbkmkSearchStr = " >Travel< " ;
CString folderTitle = GetGlobal ( " FolderTitle " ) ;
CString bookmarkTitle = GetGlobal ( " BookmarkTitle " ) ;
CString bookmarkTitle1 = GetGlobal ( " BookmarkTitle1 " ) ;
CString bookmarkTitle2 = GetGlobal ( " BookmarkTitle2 " ) ;
CString bookmarkTitle3 = GetGlobal ( " BookmarkTitle3 " ) ;
CString bookmarkTitle4 = GetGlobal ( " BookmarkTitle4 " ) ;
CString bookmarkTitle5 = GetGlobal ( " BookmarkTitle5 " ) ;
CString bookmarkURL = GetGlobal ( " BookmarkURL " ) ;
CString bookmarkURL1 = GetGlobal ( " BookmarkURL1 " ) ;
CString bookmarkURL2 = GetGlobal ( " BookmarkURL2 " ) ;
CString bookmarkURL3 = GetGlobal ( " BookmarkURL3 " ) ;
CString bookmarkURL4 = GetGlobal ( " BookmarkURL4 " ) ;
CString bookmarkURL5 = GetGlobal ( " BookmarkURL5 " ) ;
ifstream srcf ( inputFile ) ;
if ( ! srcf )
{
AfxMessageBox ( " Cannot open input file: " + CString ( inputFile ) , MB_OK ) ;
return ;
}
ofstream dstf ( outputFile ) ;
if ( ! dstf )
{
AfxMessageBox ( " Cannot open output file: " + CString ( outputFile ) , MB_OK ) ;
srcf . close ( ) ;
return ;
}
while ( ! srcf . eof ( ) )
{
srcf . getline ( tempbuf , MAX_SIZE ) ;
dstf < < tempbuf < < " \n " ;
if ( ( CString ( tempbuf ) . Find ( toolbarSearchStr ) ) ! = - 1 )
// add custom personal toolbar items
{
srcf . getline ( tempbuf , MAX_SIZE ) ;
dstf < < tempbuf < < " \n " ;
if ( ! ( toolbarTitle1 . IsEmpty ( ) ) & & ! ( toolbarURL1 . IsEmpty ( ) ) )
dstf < < " <dt><a HREF= \" " < < toolbarURL1 < < " \" > " < < toolbarTitle1 < < " </a> \n " ;
if ( ! ( toolbarTitle2 . IsEmpty ( ) ) & & ! ( toolbarURL2 . IsEmpty ( ) ) )
dstf < < " <dt><a HREF= \" " < < toolbarURL2 < < " \" > " < < toolbarTitle2 < < " </a> \n " ;
if ( ! ( toolbarTitle3 . IsEmpty ( ) ) & & ! ( toolbarURL3 . IsEmpty ( ) ) )
dstf < < " <dt><a HREF= \" " < < toolbarURL3 < < " \" > " < < toolbarTitle3 < < " </a> \n " ;
}
if ( bkmkChoice = = " 1 " )
// add single custom bookmark
{
if ( ( ( bkmkLocation = = " First " ) & & ( ( CString ( tempbuf ) . Find ( firstbkmkSearchStr ) ) ! = - 1 ) ) | |
( ( bkmkLocation = = " Last " ) & & ( ( CString ( tempbuf ) . Find ( lastbkmkSearchStr ) ) ! = - 1 ) ) )
{
srcf . getline ( tempbuf , MAX_SIZE ) ;
dstf < < tempbuf < < " \n " ;
if ( bkmkLocation = = " Last " )
{
// read one more line if bookmark location is 'last'
srcf . getline ( tempbuf , MAX_SIZE ) ;
dstf < < tempbuf < < " \n " ;
}
if ( ! ( bookmarkTitle . IsEmpty ( ) ) & & ! ( bookmarkURL . IsEmpty ( ) ) )
dstf < < " <dt><a HREF= \" " < < bookmarkURL < < " \" > " < < bookmarkTitle < < " </a> \n " ;
}
}
else if ( bkmkChoice = = " 2 " )
// add custom bookmark folder
{
if ( ( ( bkmkLocation = = " First " ) & & ( ( CString ( tempbuf ) . Find ( firstbkmkSearchStr ) ) ! = - 1 ) ) | |
( ( bkmkLocation = = " Last " ) & & ( ( CString ( tempbuf ) . Find ( lastbkmkSearchStr ) ) ! = - 1 ) ) )
{
srcf . getline ( tempbuf , MAX_SIZE ) ;
dstf < < tempbuf < < " \n " ;
if ( bkmkLocation = = " Last " )
{
// read one more line if bookmark location is 'last'
srcf . getline ( tempbuf , MAX_SIZE ) ;
dstf < < tempbuf < < " \n " ;
}
if ( ! ( folderTitle . IsEmpty ( ) ) )
{
dstf < < " <dt><h3> " < < folderTitle < < " </h3> \n " ;
dstf < < " <dl><p> \n " ;
if ( ! ( bookmarkTitle1 . IsEmpty ( ) ) & & ! ( bookmarkURL1 . IsEmpty ( ) ) )
dstf < < " <dt><a HREF= \" " < < bookmarkURL1 < < " \" > " < < bookmarkTitle1 < < " </a> \n " ;
if ( ! ( bookmarkTitle2 . IsEmpty ( ) ) & & ! ( bookmarkURL2 . IsEmpty ( ) ) )
dstf < < " <dt><a HREF= \" " < < bookmarkURL2 < < " \" > " < < bookmarkTitle2 < < " </a> \n " ;
if ( ! ( bookmarkTitle3 . IsEmpty ( ) ) & & ! ( bookmarkURL3 . IsEmpty ( ) ) )
dstf < < " <dt><a HREF= \" " < < bookmarkURL3 < < " \" > " < < bookmarkTitle3 < < " </a> \n " ;
if ( ! ( bookmarkTitle4 . IsEmpty ( ) ) & & ! ( bookmarkURL4 . IsEmpty ( ) ) )
dstf < < " <dt><a HREF= \" " < < bookmarkURL4 < < " \" > " < < bookmarkTitle4 < < " </a> \n " ;
if ( ! ( bookmarkTitle5 . IsEmpty ( ) ) & & ! ( bookmarkURL5 . IsEmpty ( ) ) )
dstf < < " <dt><a HREF= \" " < < bookmarkURL5 < < " \" > " < < bookmarkTitle5 < < " </a> \n " ;
dstf < < " </dl><p> \n " ;
}
}
}
}
srcf . close ( ) ;
dstf . close ( ) ;
}
2002-06-27 19:11:37 +00:00
void ModifyHelpMenu ( CString inputFile , CString outputFile )
{
// Add an item to the Help menu
char tempbuf [ MAX_SIZE ] ;
CString searchstr = " oncommand= \" openTopWin( \' urn:clienturl:help:security \' ); \" /> " ;
CString helpMenuName = GetGlobal ( " HelpMenuCommandName " ) ;
CString helpMenuUrl = GetGlobal ( " HelpMenuCommandURL " ) ;
ifstream srcf ( inputFile ) ;
if ( ! srcf )
{
AfxMessageBox ( " Cannot open input file: " + CString ( inputFile ) , MB_OK ) ;
return ;
}
ofstream dstf ( outputFile ) ;
if ( ! dstf )
{
AfxMessageBox ( " Cannot open output file: " + CString ( outputFile ) , MB_OK ) ;
srcf . close ( ) ;
return ;
}
while ( ! srcf . eof ( ) )
{
srcf . getline ( tempbuf , MAX_SIZE ) ;
dstf < < tempbuf < < " \n " ;
if ( ( CString ( tempbuf ) . Find ( searchstr ) ) ! = - 1 )
{
dstf < < " <menuitem label= \" " < < helpMenuName < < " \" \n " ;
dstf < < " position= \" 7 \" \n " ;
dstf < < " oncommand= \" openTopWin(' " < < helpMenuUrl < < " '); \" /> \n " ;
}
}
srcf . close ( ) ;
dstf . close ( ) ;
}
1999-11-03 01:51:54 +00:00
int interpret ( char * cmd )
{
char * cmdname = strtok ( cmd , " ( " ) ;
if ( strcmp ( cmdname , " configure " ) = = 0 )
{
char temp [ 1024 ] ;
char * section = strtok ( NULL , " ,) " ) ;
char * key = strtok ( NULL , " ,) " ) ;
char * value = strtok ( NULL , " ,) " ) ;
char * newvalue = value ;
if ( value [ 0 ] = = ' % ' )
{
value + + ;
char * t = strchr ( value , ' % ' ) ;
2000-03-08 01:39:19 +00:00
//Post Beta - we have to figure a way to handle these cases - right now returning FALSE
//causes the other commands to not be carried through- changing return FALSE to TRUE
1999-11-03 01:51:54 +00:00
if ( ! t )
2000-03-08 01:39:19 +00:00
return TRUE ; //*** Changed FALSE to TRUE
1999-11-03 01:51:54 +00:00
* t = ' \0 ' ;
newvalue = ( char * ) ( LPCTSTR ) GetGlobal ( value ) ;
}
if ( ! section | | ! key | | ! newvalue )
2000-03-08 01:39:19 +00:00
return TRUE ; //***Changed FALSE to TRUE
1999-11-06 00:04:08 +00:00
if ( ! CopyFile ( iniSrcPath , iniDstPath , TRUE ) )
1999-11-03 01:51:54 +00:00
DWORD e = GetLastError ( ) ;
2000-11-15 01:30:50 +00:00
if ( strcmp ( key , " Program Folder Name " ) = = 0 )
1999-11-03 01:51:54 +00:00
{
2002-05-06 21:34:23 +00:00
CString browserName = GetGlobal ( " BrowserName " ) ;
2001-05-03 23:37:48 +00:00
if ( strcmp ( newvalue , " " ) = = 0 )
2002-05-06 21:34:23 +00:00
strcpy ( temp , browserName ) ;
2001-05-03 23:37:48 +00:00
else
2002-05-06 21:34:23 +00:00
{
browserName = browserName + " by " ;
strcpy ( temp , browserName ) ;
}
1999-11-03 01:51:54 +00:00
strcat ( temp , newvalue ) ;
newvalue = temp ;
}
2002-04-05 22:55:03 +00:00
CString encodedValue = newvalue ;
WritePrivateProfileString ( section , key , ConvertUTF8toANSI ( encodedValue ) ,
iniDstPath ) ;
1999-11-03 01:51:54 +00:00
}
2002-06-05 20:55:33 +00:00
else if ( strcmp ( cmdname , " configureAddText " ) = = 0 )
{
char * fileToAdd = strtok ( NULL , " ,) " ) ;
// copy config.ini to destination if it hasn't already been done
if ( ! CopyFile ( iniSrcPath , iniDstPath , TRUE ) )
DWORD e = GetLastError ( ) ;
CStdioFile sfConfig , sfAddText ;
CString strAddTextFile = rootPath + fileToAdd ;
if ( sfConfig . Open ( iniDstPath , CFile : : modeReadWrite | CFile : : typeText ) = = 0 )
return TRUE ;
if ( sfAddText . Open ( strAddTextFile , CFile : : modeRead | CFile : : typeText ) = = 0 )
{
sfConfig . Close ( ) ;
return TRUE ;
}
sfConfig . SeekToEnd ( ) ;
CString strLine ;
while ( sfAddText . ReadString ( strLine ) )
{
sfConfig . WriteString ( strLine + ' \n ' ) ;
}
sfAddText . Close ( ) ;
sfConfig . Flush ( ) ;
sfConfig . Close ( ) ;
}
1999-11-03 01:51:54 +00:00
else if ( strcmp ( cmdname , " replaceXPI " ) = = 0 )
{
char * xpiname = strtok ( NULL , " ,) " ) ;
2000-09-27 01:42:51 +00:00
char * jname = strtok ( NULL , " ,) " ) ;
1999-11-03 01:51:54 +00:00
char * xpifile = strtok ( NULL , " ,) " ) ;
char * value = strtok ( NULL , " ,) " ) ;
char * newvalue = value ;
2000-09-27 01:42:51 +00:00
CString jarname = jname ;
1999-11-03 01:51:54 +00:00
if ( value [ 0 ] = = ' % ' )
{
value + + ;
char * t = strchr ( value , ' % ' ) ;
if ( ! t )
2000-03-08 01:39:19 +00:00
return TRUE ; //*** Changed FALSE to TRUE
1999-11-03 01:51:54 +00:00
* t = ' \0 ' ;
newvalue = ( char * ) ( LPCTSTR ) GetGlobal ( value ) ;
}
if ( ! xpiname | | ! xpifile | | ! newvalue )
2000-03-08 01:39:19 +00:00
return TRUE ; //*** Changed FALSE to TRUE
/*Post Beta -This is a hack to prevent the last page from staying up there endlessly;
2000-03-03 00:08:25 +00:00
We check to see if the filename is null and if it is so we return true
so that the return value isnt made FALSE */
CString filename = newvalue ;
if ( filename . IsEmpty ( ) )
return TRUE ;
////////////////////////////////
2000-09-27 01:42:51 +00:00
//check to see if it is a jar and then do accordingly
if ( jarname . CompareNoCase ( " no.jar " ) = = 0 )
1999-11-03 01:51:54 +00:00
ExtractXPIFile ( xpiname , xpifile ) ;
2000-09-27 01:42:51 +00:00
else
ExtractJARFile ( xpiname , jarname , xpifile ) ;
1999-11-03 01:51:54 +00:00
if ( ! CopyFile ( newvalue , xpifile , FALSE ) )
{
DWORD e = GetLastError ( ) ;
2000-03-08 01:39:19 +00:00
return TRUE ; //*** Changed FALSE to TRUE
1999-11-03 01:51:54 +00:00
}
2001-11-14 00:23:13 +00:00
}
// If the string in script.ib matches "addrdfFile" perform this code
// This code decompresses the xpi files to which the rdf files must be
// added and copies the rdf files (mailaccount.rdf and newsaccount.rdf)
// from the Temp directory to the resulting directory after decompression
else if ( strcmp ( cmdname , " addrdfFile " ) = = 0 )
{
char * xpiname = strtok ( NULL , " ,) " ) ; // xpi file name
char * jname = strtok ( NULL , " ,) " ) ; // jar name within xpi file
char * xpifile = strtok ( NULL , " ,) " ) ; // directory path within jar file
char * value2 = strtok ( NULL , " ,) " ) ; // name of rdf file to be added
char * value = strtok ( NULL , " ,) " ) ; // variable which specifies the path of the Temp dir
char * newvalue = value ;
CString jarname = jname ;
if ( value [ 0 ] = = ' % ' )
{
value + + ;
char * t = strchr ( value , ' % ' ) ;
if ( ! t )
return TRUE ; //*** Changed FALSE to TRUE
* t = ' \0 ' ;
newvalue = ( char * ) ( LPCTSTR ) GetGlobal ( value ) ;
}
if ( ! xpiname | | ! xpifile | | ! newvalue )
return TRUE ; //*** Changed FALSE to TRUE
CString command ;
if ( strcmp ( value2 , " newsaccount.rdf " ) ! = 0 )
{
if ( findXPI ( xpiname , xpifile ) )
return TRUE ;
}
// nscpxpipath = \CCKTool\NSCPXPI
CString xpiArchive = nscpxpiPath + " \\ " + xpiname ;
// decompressing the directory path within the XPI file
command = quotes + rootPath + " unzip.exe " + quotes + " -o " + spaces + quotes + xpiArchive + quotes + spaces + quotes + xpifile + " /*.* " + quotes ;
ExecuteCommand ( ( char * ) ( LPCTSTR ) command , SW_HIDE , INFINITE ) ;
CString xpifile1 = xpifile ;
CString tempval = value2 ;
CString newxpifile = xpifile1 + " / " + tempval ;
// copy rdf file from Temp directory
if ( ! CopyFile ( newvalue , newxpifile , FALSE ) )
{
DWORD e = GetLastError ( ) ;
return TRUE ; //*** Changed FALSE to TRUE
}
}
2002-06-22 00:15:05 +00:00
else if ( ( strcmp ( cmdname , " modifySidebar " ) = = 0 ) | |
2002-06-27 19:11:37 +00:00
( strcmp ( cmdname , " modifyBookmarks " ) = = 0 ) | |
( strcmp ( cmdname , " modifyHelpMenu " ) = = 0 ) )
2002-06-04 17:55:33 +00:00
{
// extract the file to be modified from the jar/xpi
// and process the file
char * xpiname = strtok ( NULL , " ,) " ) ; // xpi file name
char * jarname = strtok ( NULL , " ,) " ) ; // jar name within xpi file
char * filename = strtok ( NULL , " ,) " ) ; // file name within jar file
CString inputFile = filename ;
inputFile . Replace ( " / " , " \\ " ) ;
inputFile = tempPath + " \\ " + inputFile ;
CString outputFile = inputFile + " .new " ;
if ( ! xpiname | | ! filename )
return TRUE ;
//check to see if it is a jar and then do accordingly
if ( stricmp ( jarname , " no.jar " ) = = 0 )
ExtractXPIFile ( xpiname , filename ) ;
else
ExtractJARFile ( xpiname , ( CString ) jarname , filename ) ;
2001-06-04 22:35:03 +00:00
2002-06-04 17:55:33 +00:00
if ( strcmp ( cmdname , " modifySidebar " ) = = 0 )
ModifySidebar ( inputFile , outputFile ) ;
2002-06-22 00:15:05 +00:00
else if ( strcmp ( cmdname , " modifyBookmarks " ) = = 0 )
ModifyBookmarks ( inputFile , outputFile ) ;
2002-06-27 19:11:37 +00:00
else if ( strcmp ( cmdname , " modifyHelpMenu " ) = = 0 )
ModifyHelpMenu ( inputFile , outputFile ) ;
2002-06-04 17:55:33 +00:00
remove ( inputFile ) ;
rename ( outputFile , inputFile ) ;
}
2000-02-22 02:26:56 +00:00
else if ( ( strcmp ( cmdname , " modifyDTD " ) = = 0 ) | |
2000-08-04 18:09:21 +00:00
( strcmp ( cmdname , " modifyJS " ) = = 0 ) | |
2001-11-14 00:23:13 +00:00
( strcmp ( cmdname , " modifyJS1 " ) = = 0 ) | |
( strcmp ( cmdname , " modifyJS2 " ) = = 0 ) | |
2002-04-05 19:34:39 +00:00
( strcmp ( cmdname , " modifyHomepageURL " ) = = 0 ) | |
2001-11-14 00:23:13 +00:00
( strcmp ( cmdname , " modifyProperties " ) = = 0 ) | |
( strcmp ( cmdname , " modifyHashedPrefString " ) = = 0 ) | |
( strcmp ( cmdname , " modifyHashedPrefInt " ) = = 0 ) | |
( strcmp ( cmdname , " modifyHashedPrefBool " ) = = 0 ) )
1999-11-03 01:51:54 +00:00
{
char * xpiname = strtok ( NULL , " ,) " ) ;
2000-09-27 01:42:51 +00:00
char * jname = strtok ( NULL , " ,) " ) ;
1999-11-03 01:51:54 +00:00
char * xpifile = strtok ( NULL , " ,) " ) ;
char * entity = strtok ( NULL , " ,) " ) ;
char * value = strtok ( NULL , " ,) " ) ;
char * newvalue = value ;
2000-09-27 01:42:51 +00:00
CString jarname = jname ;
1999-11-03 01:51:54 +00:00
if ( value [ 0 ] = = ' % ' )
{
value + + ;
char * t = strchr ( value , ' % ' ) ;
if ( ! t )
2000-03-08 01:39:19 +00:00
return TRUE ; //*** Changed FALSE to TRUE
1999-11-03 01:51:54 +00:00
* t = ' \0 ' ;
newvalue = ( char * ) ( LPCTSTR ) GetGlobal ( value ) ;
}
2001-11-14 00:23:13 +00:00
1999-11-03 01:51:54 +00:00
if ( ! xpiname | | ! xpifile | | ! entity | | ! newvalue )
2000-03-08 01:39:19 +00:00
return TRUE ; //*** Changed FALSE to TRUE
2000-09-27 01:42:51 +00:00
//check to see if it is a jar and then do accordingly
if ( jarname . CompareNoCase ( " no.jar " ) = = 0 )
2001-11-14 00:23:13 +00:00
ExtractXPIFile ( xpiname , xpifile ) ;
2000-09-27 01:42:51 +00:00
else
2001-11-14 00:23:13 +00:00
ExtractJARFile ( xpiname , jarname , xpifile ) ;
if ( strcmp ( cmdname , " modifyHashedPrefString " ) = = 0 )
2002-02-14 22:31:23 +00:00
ModifyHashedPref ( xpifile , entity , newvalue , " string " , TRUE ) ;
2001-11-14 00:23:13 +00:00
else if ( strcmp ( cmdname , " modifyHashedPrefInt " ) = = 0 )
2002-02-14 22:31:23 +00:00
ModifyHashedPref ( xpifile , entity , newvalue , " int " , TRUE ) ;
2001-12-18 17:56:45 +00:00
else if ( strcmp ( cmdname , " modifyHashedPrefBool " ) = = 0 )
2002-02-14 22:31:23 +00:00
ModifyHashedPref ( xpifile , entity , newvalue , " bool " , TRUE ) ;
2002-04-05 19:34:39 +00:00
else if ( strcmp ( cmdname , " modifyHomepageURL " ) = = 0 )
ModifyHomepageURL ( xpifile , entity , newvalue ) ;
2001-11-14 00:23:13 +00:00
else if ( strcmp ( cmdname , " modifyJS " ) = = 0 )
2002-02-14 22:31:23 +00:00
ModifyJS ( xpifile , entity , newvalue , FALSE ) ;
2000-08-04 18:09:21 +00:00
else if ( strcmp ( cmdname , " modifyProperties " ) = = 0 )
ModifyProperties ( xpifile , entity , newvalue ) ;
2001-11-14 00:23:13 +00:00
else if ( strcmp ( cmdname , " modifyJS1 " ) = = 0 )
2002-02-14 22:31:23 +00:00
ModifyJS1 ( xpifile , entity , newvalue , FALSE ) ;
2001-11-14 00:23:13 +00:00
else if ( strcmp ( cmdname , " modifyJS2 " ) = = 0 )
2002-02-14 22:31:23 +00:00
ModifyJS2 ( xpifile , entity , newvalue , FALSE ) ;
2001-11-14 00:23:13 +00:00
else
{
// If the browser window's title bar text field is empty,
// the default browser value is displayed
if ( ( strcmp ( entity , " mainWindow.titlemodifier " ) = = 0 ) & &
( strcmp ( newvalue , " " ) = = 0 ) )
2001-06-11 22:38:06 +00:00
newvalue = " &brandShortName; " ;
2001-11-14 00:23:13 +00:00
ModifyDTD ( xpifile , entity , newvalue ) ;
}
1999-11-03 01:51:54 +00:00
}
else if ( strcmp ( cmdname , " wrapXPI " ) = = 0 )
{
}
2001-12-18 17:56:45 +00:00
else if ( strcmp ( cmdname , " processPrefsTree " ) = = 0 )
{
2002-02-14 22:31:23 +00:00
char * prefsTreeFile = strtok ( NULL , " ,) " ) ;
2001-12-18 17:56:45 +00:00
CString fileWithPath = configPath + " \\ " + prefsTreeFile ;
2002-02-14 22:31:23 +00:00
char * installFile = strtok ( NULL , " ,) " ) ;
gstrInstallFile = installFile ;
char * cfgPrefFile = strtok ( NULL , " ,) " ) ;
gstrCFGPrefFile = cfgPrefFile ;
char * plainPrefFile = strtok ( NULL , " ,) " ) ;
gstrPlainPrefFile = plainPrefFile ;
ProcessPrefsTree ( fileWithPath ) ;
2002-01-08 21:11:27 +00:00
}
2002-02-14 22:31:23 +00:00
else if ( strcmp ( cmdname , " configureRemoteAdmin " ) = = 0 )
2002-01-08 21:11:27 +00:00
{
char * vConvert = strtok ( NULL , " ,) " ) ; // if set, then do the convert to remote admin
if ( vConvert [ 0 ] = = ' % ' )
{
vConvert + + ;
char * t = strchr ( vConvert , ' % ' ) ;
if ( ! t )
return TRUE ;
* t = ' \0 ' ;
char * bConvert = ( char * ) ( LPCTSTR ) GetGlobal ( vConvert ) ;
// The convert checkbox was not checked. No need to continue.
if ( strcmp ( bConvert , " 1 " ) ! = 0 )
return TRUE ;
}
char * url = strtok ( NULL , " ,) " ) ;
if ( url [ 0 ] = = ' % ' )
{
url + + ;
char * t = strchr ( url , ' % ' ) ;
if ( ! t )
return TRUE ;
* t = ' \0 ' ;
url = ( char * ) ( LPCTSTR ) GetGlobal ( url ) ;
if ( ! url )
return TRUE ;
}
char * prefFile = strtok ( NULL , " ,) " ) ;
2002-02-14 22:31:23 +00:00
if ( ! prefFile )
2002-01-08 21:11:27 +00:00
return TRUE ;
2002-02-14 22:31:23 +00:00
ConfigureRemoteAdmin ( url , prefFile ) ;
2002-01-08 21:11:27 +00:00
2002-01-11 19:33:33 +00:00
}
else if ( strcmp ( cmdname , " modifyUserJS " ) = = 0 )
{
// modifyUserJS(XPIname, fileWithinXPI, JSsourcefile) // within XPI
// modifyUserJS(browser.xpi, bin, jsedit.jsc) // example
// modifyUserJS(none, pathAndFilename, JSsourcefile) // normal file
// modifyUserJS(none, \autoadmin\test.jsc, jsedit.jsc) // example
char * xpiname = strtok ( NULL , " ,) " ) ;
char * filename = strtok ( NULL , " ,) " ) ;
char * jssource = strtok ( NULL , " ,) " ) ;
CString jsSourceFile = configPath + " \\ " + jssource ;
// pull the cfg file out of the XPI
//
ExtractXPIFile ( xpiname , filename ) ;
// replace the appropriate block of javascript
//
ModifyUserJS ( filename , jsSourceFile ) ;
// cfg file gets repackaged with call to ReplaceXPIFiles in StartIB after all the interpret calls,
// so no need to repacked it ourself.
2001-12-18 17:56:45 +00:00
}
2002-01-24 21:34:58 +00:00
else if ( strcmp ( cmdname , " markcfgversion " ) = = 0 )
{
char * xpiname = strtok ( NULL , " ,) " ) ;
char * filename = strtok ( NULL , " ,) " ) ;
char * versiontxt = strtok ( NULL , " ,) " ) ;
2002-05-22 00:46:11 +00:00
// make a substitution if the text is a variable
if ( versiontxt [ 0 ] = = ' % ' )
{
versiontxt + + ;
char * t = strchr ( versiontxt , ' % ' ) ;
if ( t )
{
* t = ' \0 ' ;
versiontxt = ( char * ) ( LPCTSTR ) GetGlobal ( versiontxt ) ;
}
}
2002-01-24 21:34:58 +00:00
// pull the cfg file out of the XPI
//
ExtractXPIFile ( xpiname , filename ) ;
// replace the appropriate block of javascript
//
MarkCFGVersion ( filename , versiontxt ) ;
// cfg file gets repackaged with call to ReplaceXPIFiles in StartIB after all the interpret calls,
// so no need to repacked it ourself.
}
else
2000-03-08 01:39:19 +00:00
return FALSE ; //*** We have to handle this condition better.
1999-11-03 01:51:54 +00:00
return TRUE ;
}
1999-11-05 00:36:17 +00:00
void init_components ( )
{
int i ;
WIDGET * w = findWidget ( " SelectedComponents " ) ;
2001-07-19 02:14:39 +00:00
BuildComponentList ( Components , & numComponents , iniSrcPath , 0 ) ;
1999-11-05 00:36:17 +00:00
// Turn off components that aren't selected
for ( i = 0 ; i < numComponents ; i + + )
2000-12-08 04:00:29 +00:00
{
2002-04-05 22:55:03 +00:00
if ( ( strstr ( ConvertUTF8toANSI ( w - > value ) , Components [ i ] . name ) = = NULL ) )
2000-12-08 04:00:29 +00:00
{
if ( ! ( Components [ i ] . selected & & Components [ i ] . invisible ) )
1999-11-05 19:18:33 +00:00
Components [ i ] . selected = FALSE ;
2000-12-08 04:00:29 +00:00
}
else
2001-09-29 01:51:57 +00:00
if ( ( Components [ i ] . additional ) | | ! ( Components [ i ] . empty ) )
2000-12-08 04:00:29 +00:00
Components [ i ] . selected = TRUE ;
}
1999-11-05 00:36:17 +00:00
}
2000-03-09 08:56:15 +00:00
/*Post Beta - we will use the DISABLED key.
Now this is implemented the round about way here .
We have to take only the components that are chosen and mark the rest as disabled
Disabled doesnt work now - so what we are doing is re writing every key in the sections
besides that we are also deleting the keys in the setup types 2 & 3 so that we have only two
as per request of mktg .
*/
1999-11-18 17:34:18 +00:00
void invisible ( )
{
2000-03-09 08:56:15 +00:00
CString Setup0Long = " Program will be installed with the most common options " ;
CString Setup1Long = " You may choose the options you want to install. Recommended for advanced users. " ;
WritePrivateProfileString ( " Setup Type0 " , NULL , " " , iniDstPath ) ;
WritePrivateProfileString ( " Setup Type1 " , NULL , " " , iniDstPath ) ;
WritePrivateProfileString ( " Setup Type0 " , " Description Short " , ( LPCTSTR ) Setup0Short , iniDstPath ) ;
WritePrivateProfileString ( " Setup Type0 " , " Description Long " , ( LPCTSTR ) Setup0Long , iniDstPath ) ;
WritePrivateProfileString ( " Setup Type1 " , " Description Short " , ( LPCTSTR ) Setup1Short , iniDstPath ) ;
WritePrivateProfileString ( " Setup Type1 " , " Description Long " , ( LPCTSTR ) Setup1Long , iniDstPath ) ;
WritePrivateProfileString ( " Setup Type2 " , NULL , " " , iniDstPath ) ;
WritePrivateProfileString ( " Setup Type3 " , NULL , " " , iniDstPath ) ;
CString Cee ;
1999-11-18 17:34:18 +00:00
tempWidget = findWidget ( " SelectedComponents " ) ;
CString component ;
2000-03-09 08:56:15 +00:00
for ( int i = 0 ; i < numComponents ; i + + )
1999-11-18 17:34:18 +00:00
{
2000-03-09 08:56:15 +00:00
if ( Components [ i ] . selected )
1999-11-18 17:34:18 +00:00
{
component = Components [ i ] . compname ;
2000-03-09 19:39:29 +00:00
Cee . Format ( " C%d " , componentOrder ) ;
2000-03-09 08:56:15 +00:00
WritePrivateProfileString ( " Setup Type0 " , ( LPCTSTR ) Cee , ( LPCTSTR ) component , iniDstPath ) ;
WritePrivateProfileString ( " Setup Type1 " , ( LPCTSTR ) Cee , ( LPCTSTR ) component , iniDstPath ) ;
2001-11-14 00:23:13 +00:00
if ( Components [ i ] . additional & & ! ( Components [ i ] . launchapp ) & &
2001-09-29 01:51:57 +00:00
! Components [ i ] . forceupgrade & & ! ( Components [ i ] . invisible ) )
2001-11-14 00:23:13 +00:00
WritePrivateProfileString ( Components [ i ] . compname , " Attributes " ,
" SELECTED|ADDITIONAL " , iniDstPath ) ;
else if ( Components [ i ] . additional & & ! ( Components [ i ] . launchapp ) & &
Components [ i ] . forceupgrade & & ! ( Components [ i ] . unselected ) & &
! ( Components [ i ] . invisible ) )
WritePrivateProfileString ( Components [ i ] . compname , " Attributes " ,
" SELECTED|ADDITIONAL|FORCE_UPGRADE " , iniDstPath ) ;
else if ( Components [ i ] . additional & & ! ( Components [ i ] . launchapp ) & &
Components [ i ] . forceupgrade & & Components [ i ] . unselected & &
! ( Components [ i ] . invisible ) )
WritePrivateProfileString ( Components [ i ] . compname , " Attributes " ,
" UNSELECTED|ADDITIONAL|FORCE_UPGRADE " , iniDstPath ) ;
else if ( ! ( Components [ i ] . disabled ) & & ! ( Components [ i ] . additional ) & &
2001-12-07 19:52:01 +00:00
Components [ i ] . forceupgrade & & ! ( Components [ i ] . invisible ) )
2001-11-14 00:23:13 +00:00
WritePrivateProfileString ( Components [ i ] . compname , " Attributes " ,
" SELECTED|FORCE_UPGRADE " , iniDstPath ) ;
else if ( Components [ i ] . additional & & Components [ i ] . launchapp & &
Components [ i ] . uncompress & & ! ( Components [ i ] . invisible ) )
WritePrivateProfileString ( Components [ i ] . compname , " Attributes " ,
" SELECTED|UNCOMPRESS|LAUNCHAPP|ADDITIONAL " , iniDstPath ) ;
2001-12-07 19:52:01 +00:00
else if ( ! ( Components [ i ] . additional ) & &
! ( Components [ i ] . forceupgrade ) & & ! ( Components [ i ] . invisible ) )
WritePrivateProfileString ( Components [ i ] . compname , " Attributes " ,
" SELECTED|INVISIBLE " , iniDstPath ) ;
2000-03-09 19:39:29 +00:00
componentOrder + + ;
1999-11-18 17:34:18 +00:00
}
2000-03-09 08:56:15 +00:00
else
WritePrivateProfileString ( Components [ i ] . compname , " Attributes " , " INVISIBLE " , iniDstPath ) ;
1999-11-18 17:34:18 +00:00
}
}
2001-11-14 00:23:13 +00:00
void LinuxInvisible ( )
{
Setup0Short = " Recommended " ;
Setup1Short = " Custom " ;
CString Setup0Long = " Installs the most common options. Quickest to download; recommended for most users. Java not included. " ;
CString Setup1Long = " Recommended for advanced users or users with specific international language package requirements. (Navigator will be installed by default.) " ;
WritePrivateProfileString ( " Setup Type0 " , NULL , " " , iniDstPath ) ;
WritePrivateProfileString ( " Setup Type1 " , NULL , " " , iniDstPath ) ;
WritePrivateProfileString ( " Setup Type0 " , " Description Short " ,
( LPCTSTR ) Setup0Short , iniDstPath ) ;
WritePrivateProfileString ( " Setup Type0 " , " Description Long " ,
( LPCTSTR ) Setup0Long , iniDstPath ) ;
WritePrivateProfileString ( " Setup Type1 " , " Description Short " ,
( LPCTSTR ) Setup1Short , iniDstPath ) ;
WritePrivateProfileString ( " Setup Type1 " , " Description Long " ,
( LPCTSTR ) Setup1Long , iniDstPath ) ;
WritePrivateProfileString ( " Setup Type2 " , NULL , " " , iniDstPath ) ;
WritePrivateProfileString ( " Setup Type3 " , NULL , " " , iniDstPath ) ;
CString Cee ;
tempWidget = findWidget ( " SelectedComponents " ) ;
CString component ;
for ( int i = 0 ; i < numComponents ; i + + )
{
if ( Components [ i ] . selected )
{
component = Components [ i ] . compname ;
Cee . Format ( " C%d " , componentOrder ) ;
WritePrivateProfileString ( " Setup Type0 " , ( LPCTSTR ) Cee ,
( LPCTSTR ) component , iniDstPath ) ;
WritePrivateProfileString ( " Setup Type1 " , ( LPCTSTR ) Cee ,
( LPCTSTR ) component , iniDstPath ) ;
if ( ( Components [ i ] . invisible ) & & ( Components [ i ] . downloadonly ) )
WritePrivateProfileString ( Components [ i ] . compname , " Attributes " ,
" SELECTED|INVISIBLE|DOWNLOAD_ONLY " , iniDstPath ) ;
else if ( ( Components [ i ] . invisible ) & & ! ( Components [ i ] . downloadonly ) )
WritePrivateProfileString ( Components [ i ] . compname , " Attributes " ,
" SELECTED|INVISIBLE " , iniDstPath ) ;
else if ( ! Components [ i ] . empty )
WritePrivateProfileString ( Components [ i ] . compname , " Attributes " ,
" " , iniDstPath ) ;
else
WritePrivateProfileString ( Components [ i ] . compname , " Attributes " ,
" SELECTED " , iniDstPath ) ;
componentOrder + + ;
}
else
WritePrivateProfileString ( Components [ i ] . compname , " Attributes " ,
" INVISIBLE " , iniDstPath ) ;
}
}
1999-11-22 23:11:38 +00:00
void AddThirdParty ( )
{
2001-10-03 00:01:48 +00:00
CString tpCompPath1 = GetGlobal ( " CustomComponentPath1 " ) ;
CString tpCompPath2 = GetGlobal ( " CustomComponentPath2 " ) ;
2002-04-05 22:55:03 +00:00
CString tpComp1 = ConvertUTF8toANSI ( GetGlobal ( " CustomComponentDesc1 " ) ) ;
CString tpComp2 = ConvertUTF8toANSI ( GetGlobal ( " CustomComponentDesc2 " ) ) ;
2001-10-03 00:01:48 +00:00
CString tpCompSize1 = GetGlobal ( " CustomComponentSize1 " ) ;
CString tpCompSize2 = GetGlobal ( " CustomComponentSize2 " ) ;
2001-07-21 01:03:32 +00:00
CString componentName ;
1999-11-22 23:11:38 +00:00
CString cName ;
CString compSDesc = " Description Short= " ;
CString compLDesc = " Description Long= " ;
CString compArchive = " Archive= " ;
2000-03-09 08:56:15 +00:00
CString compISize = " Install Size Archive= " ;
1999-11-22 23:11:38 +00:00
CString compAttrib = " Attributes=SELECTED|LAUNCHAPP " ;
int archiveLen = tpCompPath1 . GetLength ( ) ;
int findLen = tpCompPath1 . ReverseFind ( ' \\ ' ) ;
CString Archive1 = tpCompPath1 . Right ( archiveLen - findLen - 1 ) ;
archiveLen = tpCompPath2 . GetLength ( ) ;
findLen = tpCompPath2 . ReverseFind ( ' \\ ' ) ;
CString Archive2 = tpCompPath2 . Right ( archiveLen - findLen - 1 ) ;
CString tempstr ;
char * cBuffer1 = new char [ MAX_SIZE ] ;
char * p = cBuffer1 ;
strcpy ( p , LPCTSTR ( compSDesc + tpComp1 ) ) ;
tempstr = compSDesc + tpComp1 ;
p + = ( tempstr . GetLength ( ) + 1 ) ;
strcpy ( p , LPCTSTR ( compLDesc + tpComp1 ) ) ;
tempstr = compLDesc + tpComp1 ;
p + = ( tempstr . GetLength ( ) + 1 ) ;
strcpy ( p , LPCTSTR ( compArchive + Archive1 ) ) ;
tempstr = compArchive + Archive1 ;
p + = ( tempstr . GetLength ( ) + 1 ) ;
strcpy ( p , LPCTSTR ( compISize + tpCompSize1 ) ) ;
tempstr = compISize + tpCompSize1 ;
p + = ( tempstr . GetLength ( ) + 1 ) ;
strcpy ( p , LPCTSTR ( compAttrib ) ) ;
p + = ( compAttrib . GetLength ( ) + 1 ) ;
* p = 0 ;
char * cBuffer2 = new char [ MAX_SIZE ] ;
char * q = cBuffer2 ;
strcpy ( q , LPCTSTR ( compSDesc + tpComp2 ) ) ;
tempstr = compSDesc + tpComp2 ;
q + = ( tempstr . GetLength ( ) + 1 ) ;
strcpy ( q , LPCTSTR ( compLDesc + tpComp2 ) ) ;
tempstr = compLDesc + tpComp2 ;
q + = ( tempstr . GetLength ( ) + 1 ) ;
strcpy ( q , LPCTSTR ( compArchive + Archive2 ) ) ;
tempstr = compArchive + Archive2 ;
q + = ( tempstr . GetLength ( ) + 1 ) ;
strcpy ( q , LPCTSTR ( compISize + tpCompSize2 ) ) ;
tempstr = compISize + tpCompSize2 ;
q + = ( tempstr . GetLength ( ) + 1 ) ;
strcpy ( q , LPCTSTR ( compAttrib ) ) ;
q + = ( compAttrib . GetLength ( ) + 1 ) ;
* q = 0 ;
/*
char cBuffer1 [ MAX_SIZE ] [ MAX_SIZE ] = { LPCTSTR ( compSDesc + tpComp1 ) , LPCTSTR ( compLDesc + tpComp1 ) ,
LPCTSTR ( compArchive + Archive1 ) , LPCTSTR ( compISize + tpCompSize1 ) ,
LPCTSTR ( compAttrib ) } ;
char * cBuffer2 [ ] = { LPCTSTR ( compSDesc + tpComp2 ) , LPCTSTR ( compLDesc + tpComp2 ) ,
LPCTSTR ( compArchive + Archive2 ) , LPCTSTR ( compISize + tpCompSize2 ) ,
LPCTSTR ( compAttrib ) } ;
*/
2000-03-28 20:59:19 +00:00
CString firstSix = tpCompPath1 . Left ( 6 ) ;
1999-11-22 23:11:38 +00:00
2000-03-28 20:59:19 +00:00
if ( ( firstSix . CompareNoCase ( " Please " ) ! = 0 ) & & ! ( tpCompPath1 . IsEmpty ( ) ) )
1999-11-22 23:11:38 +00:00
{
2001-11-14 00:23:13 +00:00
componentName . Format ( " C%d " , ( numComponents ) ) ;
2000-03-09 19:39:29 +00:00
cName . Format ( " C%d " , componentOrder ) ;
componentOrder + + ;
1999-11-22 23:11:38 +00:00
WritePrivateProfileString ( " Setup Type0 " , cName , componentName , iniDstPath ) ;
WritePrivateProfileString ( " Setup Type1 " , cName , componentName , iniDstPath ) ;
WritePrivateProfileSection ( componentName , cBuffer1 , iniDstPath ) ;
2000-03-09 08:56:15 +00:00
numComponents + + ;
2000-03-09 01:46:00 +00:00
CopyFile ( tpCompPath1 , xpiDstPath + " \\ " + Archive1 , FALSE ) ;
1999-11-22 23:11:38 +00:00
DWORD e1 = GetLastError ( ) ;
}
2000-03-28 20:59:19 +00:00
firstSix = tpCompPath2 . Left ( 6 ) ;
if ( ( firstSix . CompareNoCase ( " Please " ) ! = 0 ) & & ! ( tpCompPath2 . IsEmpty ( ) ) )
1999-11-22 23:11:38 +00:00
{
2001-11-14 00:23:13 +00:00
componentName . Format ( " C%d " , ( numComponents ) ) ;
2000-03-09 19:39:29 +00:00
cName . Format ( " C%d " , componentOrder ) ;
1999-11-22 23:11:38 +00:00
WritePrivateProfileString ( " Setup Type0 " , cName , componentName , iniDstPath ) ;
WritePrivateProfileString ( " Setup Type1 " , cName , componentName , iniDstPath ) ;
WritePrivateProfileSection ( componentName , cBuffer2 , iniDstPath ) ;
2000-03-09 01:46:00 +00:00
CopyFile ( tpCompPath2 , xpiDstPath + " \\ " + Archive2 , FALSE ) ;
1999-11-22 23:11:38 +00:00
DWORD e2 = GetLastError ( ) ;
}
delete [ ] cBuffer1 ;
delete [ ] cBuffer2 ;
}
2000-01-07 20:31:27 +00:00
HRESULT CreateShortcut ( const CString Target , const CString Arguments , const CString
LinkFileName , const CString WorkingDir , bool IsFolder )
{
// Initialize OLE libraries
if ( ! AfxOleInit ( ) )
return FALSE ;
HRESULT hres ;
CString Desktop = getenv ( " USERPROFILE " ) ;
Desktop + = " \\ Desktop \\ " ;
CString Link = Desktop + LinkFileName ;
if ( ! IsFolder )
{
IShellLink * psl ;
hres = CoCreateInstance ( CLSID_ShellLink , NULL , CLSCTX_INPROC_SERVER , IID_IShellLink ,
( LPVOID * ) & psl ) ;
if ( SUCCEEDED ( hres ) )
{
IPersistFile * ppf ;
psl - > SetPath ( Target ) ;
psl - > SetArguments ( Arguments ) ;
psl - > SetWorkingDirectory ( WorkingDir ) ;
hres = psl - > QueryInterface ( IID_IPersistFile , ( LPVOID * ) & ppf ) ;
if ( SUCCEEDED ( hres ) )
{
CString Temp = Link ;
Temp . MakeLower ( ) ;
if ( Temp . Find ( " .lnk " ) = = - 1 )
Link + = " .lnk " ; // Important !!!
WORD wsz [ MAX_PATH ] ;
MultiByteToWideChar ( CP_ACP , MB_PRECOMPOSED , Link , - 1 , wsz , MAX_PATH ) ;
hres = ppf - > Save ( wsz , TRUE ) ;
ppf - > Release ( ) ;
}
psl - > Release ( ) ;
}
}
else
{
hres = _mkdir ( Link ) ;
}
return hres ;
}
BOOL GetRegistryKey ( HKEY key , char * subkey , char * retdata )
{
long retval ;
HKEY hkey ;
retval = RegOpenKeyEx ( key , subkey , 0 , KEY_QUERY_VALUE , & hkey ) ;
if ( retval = = ERROR_SUCCESS )
{
long datasize = MAX_SIZE ;
char data [ MAX_SIZE ] ;
RegQueryValue ( hkey , NULL , ( LPSTR ) data , & datasize ) ;
lstrcpy ( retdata , data ) ;
RegCloseKey ( hkey ) ;
}
return retval ;
}
CString GetBrowser ( void )
{
char key [ MAX_SIZE + MAX_SIZE ] ;
CString retflag = " " ;
/* get the .htm regkey and lookup the program */
if ( GetRegistryKey ( HKEY_CLASSES_ROOT , " .htm " , key ) = = ERROR_SUCCESS )
{
lstrcat ( key , " \\ shell \\ open \\ command " ) ;
if ( GetRegistryKey ( HKEY_CLASSES_ROOT , key , key ) = = ERROR_SUCCESS )
{
char * pos ;
pos = strstr ( key , " \" %1 \" " ) ;
if ( pos = = NULL ) /* if no quotes */
{
/* now check for %1, without the quotes */
pos = strstr ( key , " %1 " ) ;
if ( pos = = NULL ) /* if no parameter */
pos = key + lstrlen ( key ) - 1 ;
else
* pos = ' \0 ' ; /* remove the parameter */
}
else
* pos = ' \0 ' ; /* remove the parameter */
retflag = key ;
}
}
return retflag ;
}
2002-03-08 22:28:04 +00:00
CString SubstituteValues ( CString inLine )
// Replace tokens in script template with appropriate locale values
{
CString newValue , oldValue , strTemp ;
int tokenStartPos , tokenEndPos ,
searchPos = 0 , count = 0 ;
int inLineLength = inLine . GetLength ( ) ;
while ( count < inLineLength )
{
tokenStartPos = inLine . Find ( ' % ' , searchPos ) ;
if ( tokenStartPos ! = - 1 )
{
tokenEndPos = inLine . Find ( ' % ' , tokenStartPos + 1 ) ;
tokenEndPos + = 1 ;
strTemp = inLine . Left ( tokenEndPos ) ;
oldValue = strTemp . Right ( tokenEndPos - tokenStartPos ) ;
WIDGET * w = findWidget ( oldValue ) ;
if ( w )
{
newValue = GetGlobal ( oldValue ) ;
searchPos = 0 ;
}
else
{
newValue = oldValue ;
searchPos = tokenEndPos ;
}
inLine . Replace ( oldValue , newValue ) ;
count = tokenEndPos ;
}
else
count = inLineLength ;
}
return inLine ;
}
2001-11-14 00:23:13 +00:00
void CreateLinuxInstaller ( )
{
char currentdir [ _MAX_PATH ] ;
_getcwd ( currentdir , _MAX_PATH ) ;
2002-03-15 01:18:27 +00:00
if ( FileExists ( xpiDstPath + " \\ " + tarfile ) )
DeleteFile ( xpiDstPath + " \\ " + tarfile ) ;
2001-10-23 17:11:52 +00:00
CopyDirectory ( xpiDstPath , templinuxPath + xpiDir , TRUE ) ;
2001-11-14 00:23:13 +00:00
CopyFile ( xpiDstPath + " \\ Config.ini " , templinuxPath + " \\ Config.ini " , FALSE ) ;
DeleteFile ( templinuxPath + xpiDir + " \\ Config.ini " ) ;
FILE * fout = fopen ( templinuxPath + " \\ config.tmp " , " wb " ) ;
if ( ! fout )
{
AfxMessageBox ( " Cannot open output file " , MB_OK ) ;
exit ( 3 ) ;
}
FILE * fin = fopen ( templinuxPath + " \\ Config.ini " , " rb " ) ;
if ( ! fin )
{
AfxMessageBox ( " Cannot open Config.ini file " , MB_OK ) ;
exit ( 3 ) ;
}
else
{
char inbuf [ BUF_SIZE ] , outbuf [ BUF_SIZE ] ;
int cnt2 = 0 ;
while ( ! feof ( fin ) )
{
int count = fread ( & inbuf , sizeof ( char ) , sizeof ( inbuf ) , fin ) ;
if ( ferror ( fin ) )
{
AfxMessageBox ( " Error in reading Config.ini file " , MB_OK ) ;
exit ( 3 ) ;
}
char * cpin = inbuf ;
char * cpout = outbuf ;
while ( count - - > 0 )
{
if ( * cpin = = CRVALUE )
cpin + + ;
else
{
* cpout + + = * cpin + + ;
cnt2 + + ;
}
}
fwrite ( & outbuf , sizeof ( char ) , cnt2 , fout ) ;
if ( ferror ( fout ) )
{
AfxMessageBox ( " Error in writing Config.ini file " , MB_OK ) ;
exit ( 3 ) ;
}
cnt2 = 0 ;
}
fclose ( fin ) ;
}
2002-06-25 23:05:10 +00:00
fputs ( " [END] \n " , fout ) ;
2001-11-14 00:23:13 +00:00
fclose ( fout ) ;
DeleteFile ( templinuxPath + " \\ Config.ini " ) ;
rename ( templinuxPath + " \\ config.tmp " , templinuxPath + " \\ config.ini " ) ;
_chdir ( outputPath ) ;
templinuxPath = tempPath ;
templinuxPath . Replace ( " \\ " , " / " ) ;
templinuxPath . Replace ( " : " , " " ) ;
templinuxPath . Insert ( 0 , " /cygdrive/ " ) ;
CString command = " tar -zcvf " + tarfile + " -C " + quotes + templinuxPath + " / " + templinuxDir + quotes + spaces + nsinstallerDir ;
ExecuteCommand ( ( char * ) ( LPCTSTR ) command , SW_HIDE , INFINITE ) ;
_chdir ( currentdir ) ;
}
2001-05-03 22:55:33 +00:00
2002-02-12 19:13:15 +00:00
void CreateMacZipFile ( )
// Creating a single customized Mac zip file which contains mac scripts
// and customized mac files
{
CString customizedZipFile = " CustomizedMacFiles.zip " ;
if ( FileExists ( customizedZipFile ) )
DeleteFile ( customizedZipFile ) ;
// Adding Mac scripts shipped with the tool to the final Mac zip file
CString command = quotes + rootPath + " zip.exe " + quotes + spaces + " -j " +
spaces + quotes + xpiDstPath + " \\ " + customizedZipFile + quotes +
spaces + quotes + platformPath + " \\ *.* " + quotes ;
ExecuteCommand ( ( char * ) ( LPCTSTR ) command , SW_HIDE , INFINITE ) ;
// Adding customized mac files created in output directory to the
// final Mac zip file
command = quotes + rootPath + " zip.exe " + quotes + spaces + " -jm " +
spaces + quotes + xpiDstPath + " \\ " + customizedZipFile + quotes +
spaces + quotes + xpiDstPath + " \\ *.* " + quotes ;
ExecuteCommand ( ( char * ) ( LPCTSTR ) command , SW_HIDE , INFINITE ) ;
}
2001-10-19 18:44:44 +00:00
void InsertComma ( CString & requiredSpace )
{
int len = requiredSpace . GetLength ( ) ;
int pos = len % 3 ;
if ( pos = = 0 )
pos = 3 ;
for ( int i = pos ; i < len ; i + = 3 )
{
requiredSpace . Insert ( i , ' , ' ) ;
i + + ;
}
}
void DiskSpaceAlert ( ULONGLONG required , ULONGLONG available )
{
char tempavailspace [ 20 ] , tempreqspace [ 20 ] ;
CString availableSpace , requiredSpace ;
_ui64toa ( available , tempavailspace , 10 ) ;
availableSpace = tempavailspace ;
InsertComma ( availableSpace ) ;
_ui64toa ( required , tempreqspace , 10 ) ;
requiredSpace = tempreqspace ;
InsertComma ( requiredSpace ) ;
AfxMessageBox ( " Not enough disk space. Required: " + requiredSpace + " bytes. Available: " + availableSpace + " bytes. " , MB_OK ) ;
}
2002-05-23 17:25:11 +00:00
ULONGLONG FindDirSize ( CString dirPath )
// Find the total size of a directory in bytes
{
ULONGLONG dirSize = 0 ;
CFileFind fileFind ;
dirPath + = " \\ *.* " ;
BOOL bFound = fileFind . FindFile ( dirPath ) ;
while ( bFound )
{
bFound = fileFind . FindNextFile ( ) ;
if ( fileFind . IsDirectory ( ) & & ! fileFind . IsDots ( ) )
{
dirSize + = FindDirSize ( fileFind . GetFilePath ( ) ) ;
}
else
{
dirSize + = fileFind . GetLength ( ) ;
}
}
return dirSize ;
}
2001-12-17 23:07:47 +00:00
2002-05-23 17:25:11 +00:00
ULONGLONG FindFileSize ( CString fileName )
// Find the size of a file in bytes
{
CFile file ( fileName , CFile : : modeReadWrite ) ;
ULONGLONG fileSize = file . GetLength ( ) ;
file . Close ( ) ;
return fileSize ;
}
ULONGLONG ComputeReqdWinDiskSpace ( )
/*
Compute required disk space for Windows build
Required disk space =
Total size for selected components +
Total size for third party components +
Total size for CD autorun +
Total size used for various file operations +
Size of skinclas . xpi +
Total size of setupfiles ( contents of NSSetup . zip ) and NSSetup . exe
*/
{
ULONGLONG requiredSize = 0 ;
// Total size of selected components
for ( int i = 0 ; i < numComponents ; i + + )
{
if ( Components [ i ] . selected )
requiredSize + = FindFileSize ( nscpxpiPath + " \\ " + Components [ i ] . archive ) ;
}
// Total size of thirdparty components
if ( ! ( ( GetGlobal ( " CustomComponentPath1 " ) ) . IsEmpty ( ) ) )
requiredSize + = FindFileSize ( GetGlobal ( " CustomComponentPath1 " ) ) ;
if ( ! ( ( GetGlobal ( " CustomComponentPath2 " ) ) . IsEmpty ( ) ) )
requiredSize + = FindFileSize ( GetGlobal ( " CustomComponentPath2 " ) ) ;
// Total size of CD autorun files
CString cdDir = GetGlobal ( " CD image " ) ;
if ( cdDir . Compare ( " 1 " ) = = 0 )
requiredSize + = FindDirSize ( shellPath ) ;
// Approximate size (4MB) for various file operations
requiredSize + = 4194304 ;
// size of skinclas.xpi since it gets copied even though deselected
requiredSize + = FindFileSize ( nscpxpiPath + " \\ skinclas.xpi " ) ;
// size of setup files and NSSetup.exe
requiredSize + = 691926 ;
return requiredSize ;
}
ULONGLONG ComputeReqdMacDiskSpace ( )
/*
Compute required disk space for Mac OS build
Required disk space =
Total size of Mac scripts and zip file +
Total size for various file operations
*/
{
ULONGLONG requiredSize = 0 ;
// size of Mac scripts and zip file
requiredSize + = FindDirSize ( platformPath ) ;
// Approximate size (4MB) for various file operations
requiredSize + = 4194304 ;
return requiredSize ;
}
2001-12-17 23:07:47 +00:00
BOOL FillGlobalWidgetArray ( CString file )
{
char buffer [ MAX_SIZE ] = { ' \0 ' } ;
CString name = " " ;
CString value = " " ;
FILE * globs = fopen ( file , " r " ) ;
if ( ! globs )
return FALSE ;
while ( ! feof ( globs ) )
{
while ( fgets ( buffer , MAX_SIZE , globs ) )
{
if ( strstr ( buffer , " = " ) )
{
name = CString ( strtok ( buffer , " = " ) ) ;
value = CString ( strtok ( NULL , " = " ) ) ;
value . TrimRight ( ) ;
if ( value . Find ( " % " ) > = 0 ) {
//We should never enter this condition via wizardmachine.exe
AfxMessageBox ( " The current .che file called: " + file + " contains some unfilled parameters. "
" These parameters will appear between two percent (%) signs such as %Root% "
" Please replace these parameters with their appropriate values and restart "
" the program " , MB_OK ) ;
// value=theInterpreter->replaceVars((char *) (LPCSTR) value,NULL);
}
WIDGET * w = SetGlobal ( name , value ) ;
if ( w )
w - > cached = TRUE ;
}
}
}
fclose ( globs ) ;
return TRUE ;
}
int StartIB ( /*CString parms, WIDGET *curWidget*/ )
1999-10-23 00:10:24 +00:00
{
1999-11-03 01:51:54 +00:00
char * fgetsrv ;
int rv = TRUE ;
char olddir [ 1024 ] ;
2002-03-08 22:28:04 +00:00
CString curVersion , curLanguage , localePath ,
strLang , strRegion , strREGION ;
componentOrder = 0 ;
rootPath = GetModulePath ( ) ;
2001-12-17 23:07:47 +00:00
SetGlobal ( " Root " , rootPath ) ;
2002-03-08 22:28:04 +00:00
configName = GetGlobal ( " _NewConfigName " ) ;
2001-12-17 23:07:47 +00:00
SetGlobal ( " CustomizationList " , configName ) ;
2002-03-08 22:28:04 +00:00
curVersion = GetGlobal ( " Version " ) ;
curPlatform = GetGlobal ( " lPlatform " ) ;
platformPath = rootPath + " Version \\ " + curVersion + " \\ " + curPlatform ;
2002-05-06 20:41:55 +00:00
curLanguage = GetLocaleCode ( GetGlobal ( " Language " ) ) ;
2002-03-08 22:28:04 +00:00
localePath = rootPath + " Version \\ " + curVersion + " \\ " + curPlatform + " \\ " + curLanguage ;
configPath = rootPath + " Configs \\ " + configName ;
outputPath = configPath + " \\ Output " ;
cdPath = configPath + " \\ Output \\ Core " ;
cdshellPath = configPath + " \\ Output \\ Shell " ;
remoteAdminFile = outputPath + " \\ autoconfig.jsc " ;
networkPath = configPath + " \\ Network " ;
tempPath = configPath + " \\ Temp " ;
iniDstPath = cdPath + " \\ config.ini " ;
scriptPath = rootPath + " script_ " + curPlatform + " .ib " ;
workspacePath = configPath + " \\ Workspace " ;
2002-05-23 17:25:11 +00:00
shellPath = workspacePath + " \\ Autorun \\ " ;
2002-03-08 22:28:04 +00:00
xpiDstPath = cdPath ;
// variables for language-region information
strLang = curLanguage . Left ( 2 ) ;
strRegion = curLanguage . Right ( 2 ) ;
strREGION = strRegion ;
strREGION . MakeUpper ( ) ;
SetGlobal ( " %lang% " , strLang ) ;
SetGlobal ( " %region% " , strRegion ) ;
SetGlobal ( " %REGION% " , strREGION ) ;
2002-01-22 18:37:26 +00:00
2001-11-14 00:23:13 +00:00
// initializing variables for CCK linux build
2002-02-01 01:49:05 +00:00
templinuxPath = tempPath + " \\ templinux \\ netscape-installer " ;
nsinstPath = " \\ netscape-installer \\ xpi " ;
2001-11-14 00:23:13 +00:00
nsinstallerDir = " netscape-installer " ;
2002-02-01 01:49:05 +00:00
xpiDir = " \\ xpi " ;
templinuxDir = " tempLinux " ;
2002-02-12 20:10:02 +00:00
tarfile = " netscape-i686-pc-linux-gnu-sea.tar.gz " ;
2001-09-11 00:45:57 +00:00
2002-01-11 19:33:33 +00:00
// AfxMessageBox("set breakpoint",MB_OK);
2002-06-10 18:14:59 +00:00
// delete contents of output directory before creating customized installer
EraseDirectory ( outputPath ) ;
1999-11-03 01:51:54 +00:00
if ( SearchPath ( workspacePath , " NSCPXPI " , NULL , 0 , NULL , NULL ) )
nscpxpiPath = workspacePath + " \\ NSCPXPI " ;
else
2002-01-22 18:37:26 +00:00
nscpxpiPath = localePath + " \\ Nscpxpi " ;
2002-02-01 01:49:05 +00:00
if ( curPlatform = = " Linux " )
2001-11-14 00:23:13 +00:00
{
_mkdir ( tempPath ) ;
_chdir ( tempPath ) ;
_mkdir ( templinuxDir ) ;
_chdir ( templinuxDir ) ;
_mkdir ( nsinstallerDir ) ;
2002-01-22 18:37:26 +00:00
CopyDirectory ( nscpxpiPath + " \\ " + nsinstallerDir , templinuxPath , TRUE ) ;
2001-11-14 00:23:13 +00:00
// get rid of this ugly code when bugzilla bug 105351 is fixed
2001-10-19 22:12:15 +00:00
CopyFile ( nscpxpiPath + " \\ full.start " ,
templinuxPath + " \\ xpi \\ full.start " , FALSE ) ;
CopyFile ( nscpxpiPath + " \\ full.end " ,
templinuxPath + " \\ xpi \\ full.end " , FALSE ) ;
CopyFile ( nscpxpiPath + " \\ recommended.start " ,
templinuxPath + " \\ xpi \\ recommended.start " , FALSE ) ;
CopyFile ( nscpxpiPath + " \\ recommended.end " ,
templinuxPath + " \\ xpi \\ recommended.end " , FALSE ) ;
2001-09-11 00:45:57 +00:00
}
2001-12-17 23:07:47 +00:00
1999-11-06 00:04:08 +00:00
iniSrcPath = nscpxpiPath + " \\ config.ini " ;
2002-05-23 17:25:11 +00:00
init_components ( ) ;
2001-12-17 23:07:47 +00:00
2000-03-28 19:58:24 +00:00
//Check for disk space before continuing
ULARGE_INTEGER nTotalBytes , nTotalFreeBytes , nTotalAvailable ;
2001-11-14 00:23:13 +00:00
GetDiskFreeSpaceEx ( NULL , & nTotalAvailable , & nTotalBytes , & nTotalFreeBytes ) ;
2002-02-12 19:13:15 +00:00
if ( curPlatform = = " Windows " )
2001-11-14 00:23:13 +00:00
{
2002-05-23 17:25:11 +00:00
ULONGLONG reqdWinDiskSpace = ComputeReqdWinDiskSpace ( ) ;
if ( ( nTotalAvailable . QuadPart ) < reqdWinDiskSpace )
2001-10-03 15:57:53 +00:00
{
2002-05-23 17:25:11 +00:00
DiskSpaceAlert ( reqdWinDiskSpace , ( nTotalAvailable . QuadPart ) ) ;
2001-10-03 15:57:53 +00:00
return FALSE ;
2001-10-19 18:44:44 +00:00
}
2001-11-14 00:23:13 +00:00
}
2002-02-12 19:13:15 +00:00
else if ( curPlatform = = " Linux " )
2001-11-14 00:23:13 +00:00
{
2001-10-19 18:44:44 +00:00
if ( ( nTotalAvailable . QuadPart ) < LDISK_SPACE )
{
DiskSpaceAlert ( LDISK_SPACE , ( nTotalAvailable . QuadPart ) ) ;
return FALSE ;
}
2000-03-28 19:58:24 +00:00
}
2002-03-09 02:14:01 +00:00
else if ( curPlatform = = " Mac OS " )
2002-02-12 19:13:15 +00:00
{
2002-05-23 17:25:11 +00:00
ULONGLONG reqdMacDiskSpace = ComputeReqdMacDiskSpace ( ) ;
if ( ( nTotalAvailable . QuadPart ) < reqdMacDiskSpace )
2002-02-12 19:13:15 +00:00
{
2002-05-23 17:25:11 +00:00
DiskSpaceAlert ( reqdMacDiskSpace , ( nTotalAvailable . QuadPart ) ) ;
2002-02-12 19:13:15 +00:00
return FALSE ;
}
}
2000-03-28 19:58:24 +00:00
//Check for Disk space over
2002-05-23 17:25:11 +00:00
2000-03-09 01:46:00 +00:00
//checking for the autorun CD shell - inorder to create a Core dir or not
CString cdDir = GetGlobal ( " CD image " ) ;
CString networkDir = GetGlobal ( " Network " ) ;
CString ftpLocation = GetGlobal ( " FTPLocation " ) ;
2000-03-28 02:26:25 +00:00
//checking to see if the AnimatedLogoURL has a http:// appended in front of it
//if not then we have to append it;
2000-03-09 01:46:00 +00:00
2001-11-14 00:23:13 +00:00
//Check to see if the User Agent string exists and if so then prefix with -CK
//(-CK can be replaced with a string UserAgentPrefix global.)
CString userAgentPrefix = GetGlobal ( " UserAgentPrefix " ) ;
if ( userAgentPrefix . IsEmpty ( ) )
userAgentPrefix = " CK- " ;
2000-08-30 01:26:39 +00:00
CString userAgent = GetGlobal ( " OrganizationName " ) ;
2001-11-14 00:23:13 +00:00
if ( userAgent )
{
CString templeft = userAgent . Left ( 3 ) ;
if ( ( templeft . CompareNoCase ( userAgentPrefix ) ) ! = 0 )
userAgent = userAgentPrefix + userAgent ;
}
2001-06-08 23:22:03 +00:00
SetGlobal ( " OrganizationName " , userAgent ) ;
2000-08-30 01:26:39 +00:00
2001-11-14 00:23:13 +00:00
2000-03-28 22:27:48 +00:00
// check to see if the bmp for rshell background is bigger than 302KB;
HANDLE hFile ;
DWORD dwFileSize ;
CString Rshellbmp = GetGlobal ( " ShellBgBitmap " ) ;
hFile = CreateFile ( ( LPCTSTR ) Rshellbmp , GENERIC_READ , FILE_SHARE_READ , NULL ,
OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , ( HANDLE ) NULL ) ;
dwFileSize = GetFileSize ( hFile , NULL ) ;
int returnValue ;
if ( dwFileSize < 300000 )
returnValue = AfxMessageBox ( " You have chosen a background BitMap that is too small for the customized RShell-If you want to proceed anyway choose Cancel or click on Retry and go back and make your changes " , MB_RETRYCANCEL ) ;
if ( returnValue = = IDRETRY )
return FALSE ;
//end of filesize check;
2000-05-16 20:26:50 +00:00
// Check to see if the animatedlogourl has the http before it or not- else the browser
// looks only in the chrome directory.
2000-03-28 02:26:25 +00:00
CString animLogoUrl = GetGlobal ( " AnimatedLogoURL " ) ;
CString leftvalue = animLogoUrl . Left ( 7 ) ;
CString httpvalue = " http:// " ;
if ( leftvalue . CompareNoCase ( " http:// " ) ! = 0 )
{
httpvalue = httpvalue + animLogoUrl ;
SetGlobal ( " AnimatedLogoURL " , httpvalue ) ;
}
2000-05-16 21:05:11 +00:00
CString HelpUrl = GetGlobal ( " HelpMenuCommandURL " ) ;
2000-05-16 20:26:50 +00:00
leftvalue = HelpUrl . Left ( 7 ) ;
httpvalue = " http:// " ;
if ( leftvalue . CompareNoCase ( " http:// " ) ! = 0 )
{
httpvalue = httpvalue + HelpUrl ;
2000-05-16 21:05:11 +00:00
SetGlobal ( " HelpMenuCommandURL " , httpvalue ) ;
2000-05-16 20:26:50 +00:00
}
2001-11-14 00:23:13 +00:00
CString setIspRDF = tempPath + " \\ mailaccount.rdf " ;
SetGlobal ( " IspRDF " , setIspRDF ) ;
CreateIspMenu ( ) ;
CString setnewsRDF = tempPath + " \\ newsaccount.rdf " ;
SetGlobal ( " NewsRDF " , setnewsRDF ) ;
CreateNewsMenu ( ) ;
// Determine which proxy configuration is chosen
CString proxyConfigoption = GetGlobal ( " radioGroup2 " ) ;
if ( proxyConfigoption = = " 3 " )
SetGlobal ( " ProxyConfig " , " 2 " ) ;
else if ( proxyConfigoption = = " 2 " )
SetGlobal ( " ProxyConfig " , " 1 " ) ;
else
SetGlobal ( " ProxyConfig " , " 0 " ) ;
// Determine which SOCKS version is chosen
CString socksVer = GetGlobal ( " socksv " ) ;
if ( socksVer = = " SOCKS v4 " )
SetGlobal ( " SocksVersion " , " 4 " ) ;
else
SetGlobal ( " SocksVersion " , " 5 " ) ;
2002-02-12 19:13:15 +00:00
if ( ( cdDir . Compare ( " 1 " ) = = 0 ) & & ( curPlatform . Compare ( " Windows " ) = = 0 ) )
2000-03-09 01:46:00 +00:00
{
_mkdir ( ( char * ) ( LPCTSTR ) cdPath ) ;
}
else
{
iniDstPath = outputPath + " \\ config.ini " ;
xpiDstPath = outputPath ;
}
2000-01-18 22:42:18 +00:00
/////////////////////////////
1999-11-03 01:51:54 +00:00
_mkdir ( ( char * ) ( LPCTSTR ) tempPath ) ;
_mkdir ( ( char * ) ( LPCTSTR ) workspacePath ) ;
2002-01-22 18:37:26 +00:00
// Copying config.ini file to the output directory
if ( ! CopyFile ( iniSrcPath , iniDstPath , TRUE ) )
DWORD e = GetLastError ( ) ;
2000-01-18 23:41:08 +00:00
// _mkdir((char *)(LPCTSTR) cdshellPath);
1999-11-03 01:51:54 +00:00
GetCurrentDirectory ( sizeof ( olddir ) , olddir ) ;
1999-10-23 00:10:24 +00:00
1999-11-03 01:51:54 +00:00
if ( SetCurrentDirectory ( ( char * ) ( LPCTSTR ) tempPath ) = = FALSE )
2000-03-08 01:39:19 +00:00
{
AfxMessageBox ( " Windows System Error:Unable to change directory " , MB_OK ) ;
return TRUE ;
}
//PostBeta - We have to inform the user that he has not set any value
//and that it will default.Returning TRUE so that it doesnt stay in the last
//screen forever.
1999-10-23 00:10:24 +00:00
1999-11-03 01:51:54 +00:00
// Read in script file and interpret commands from it
FILE * f = fopen ( scriptPath , " r " ) ;
if ( ! f )
rv = FALSE ;
else
{
int done = FALSE ;
while ( ! done )
{
fgetsrv = fgets ( buffer , sizeof ( buffer ) , f ) ;
done = feof ( f ) ;
if ( ! done )
{
if ( ! fgetsrv | | ferror ( f ) )
{
rv = FALSE ;
break ;
}
buffer [ strlen ( buffer ) ] = ' \0 ' ; // Eliminate the trailing newline
2002-03-08 22:28:04 +00:00
CString strTempBuffer = buffer ;
strcpy ( buffer , SubstituteValues ( strTempBuffer ) ) ;
1999-11-03 01:51:54 +00:00
if ( ! interpret ( buffer ) )
{
rv = FALSE ;
break ;
}
}
}
fclose ( f ) ;
}
2000-01-18 22:42:18 +00:00
1999-11-03 01:51:54 +00:00
// Put all the extracted files back into their new XPI homes
2000-09-27 01:42:51 +00:00
ReplaceJARFiles ( ) ;
2001-11-14 00:23:13 +00:00
2000-09-27 01:42:51 +00:00
1999-11-03 01:51:54 +00:00
ReplaceXPIFiles ( ) ;
2000-01-18 22:42:18 +00:00
1999-11-03 01:51:54 +00:00
// Copy remaining default installer files into config
// preserving any existing files that we created already
// in previous steps
1999-11-05 19:18:33 +00:00
/* -- Need to be more selective than this
1999-11-03 01:51:54 +00:00
CopyDir ( nscpxpiPath , cdPath , NULL , FALSE ) ;
1999-11-05 19:18:33 +00:00
*/
1999-11-18 17:34:18 +00:00
1999-12-08 06:45:16 +00:00
for ( int i = 0 ; i < numComponents ; i + + )
{
if ( Components [ i ] . selected )
CopyFile ( nscpxpiPath + " \\ " + Components [ i ] . archive ,
2000-03-09 01:46:00 +00:00
xpiDstPath + " \\ " + Components [ i ] . archive , TRUE ) ;
1999-12-08 06:45:16 +00:00
}
2001-11-14 00:23:13 +00:00
2002-02-12 19:13:15 +00:00
if ( curPlatform = = " Windows " )
2001-10-02 21:22:36 +00:00
{
2002-02-01 01:49:05 +00:00
if ( cdDir . Compare ( " 1 " ) = = 0 )
{
CopyDir ( shellPath , outputPath , NULL , TRUE ) ;
CreateRshell ( ) ;
WritePrivateProfileString ( " Message Stream " , " Status " , " Disabled " , iniDstPath ) ;
}
else
{
FILE * infout ;
CString infFile = outputPath + " \\ autorun.inf " ;
infout = fopen ( infFile , " w " ) ;
if ( ! infout )
exit ( 3 ) ;
fprintf ( infout , " [autorun] \n open = setup.exe " ) ;
}
1999-12-08 06:45:16 +00:00
2002-02-12 19:13:15 +00:00
CString component ;
CString configiniPath = xpiDstPath + " \\ config.ini " ;
if ( ftpLocation . Compare ( " ftp:// " ) ! = 0 )
{
// Change the ftp section to accomodate changes from PR3 to RTM
// for (int i=0; i<numComponents; i++)
// {
// if (Components[i].selected)
// CopyFile(nscpxpiPath + "\\" + Components[i].archive,
// networkPath + "\\" + Components[i].archive, TRUE);
2000-11-15 23:07:32 +00:00
WritePrivateProfileString ( " General " , " url " , ftpLocation , configiniPath ) ;
WritePrivateProfileString ( " Redirect " , " Status " , " Disabled " , configiniPath ) ;
WritePrivateProfileString ( " Site Selector " , NULL , " " , configiniPath ) ;
WritePrivateProfileString ( " Site Selector " , " Identifier0 " , " Site0 " , configiniPath ) ;
WritePrivateProfileString ( " Site Selector " , " Description0 " , " Default " , configiniPath ) ;
2001-08-10 21:38:49 +00:00
WritePrivateProfileString ( " Site Selector " , " Domain0 " , ftpLocation , configiniPath ) ;
2001-11-14 00:23:13 +00:00
// HTTP support for network installer
CString httpstr = ftpLocation . Left ( 7 ) ;
if ( httpstr . Compare ( " http:// " ) = = 0 )
WritePrivateProfileString ( " Dialog Advanced Settings " ,
" Use Protocol " , " HTTP " , configiniPath ) ;
else
WritePrivateProfileString ( " Dialog Advanced Settings " ,
" Use Protocol " , " FTP " , configiniPath ) ;
2002-02-12 19:13:15 +00:00
// }
}
1999-11-18 17:34:18 +00:00
2002-02-12 19:13:15 +00:00
invisible ( ) ;
AddThirdParty ( ) ;
ReplaceINIFile ( ) ;
1999-11-18 17:34:18 +00:00
}
2000-03-09 08:56:15 +00:00
2002-02-12 19:13:15 +00:00
else if ( curPlatform = = " Linux " )
2001-11-14 00:23:13 +00:00
{
LinuxInvisible ( ) ;
2001-10-13 00:37:42 +00:00
AddThirdParty ( ) ;
CreateLinuxInstaller ( ) ;
2001-11-14 00:23:13 +00:00
}
1999-11-18 17:34:18 +00:00
2002-03-09 02:14:01 +00:00
else if ( curPlatform = = " Mac OS " )
2002-02-12 19:13:15 +00:00
{
CreateMacZipFile ( ) ;
2001-10-13 00:37:42 +00:00
}
2002-02-12 19:13:15 +00:00
1999-11-03 01:51:54 +00:00
SetCurrentDirectory ( olddir ) ;
2000-01-07 20:31:27 +00:00
CString TargetDir = GetGlobal ( " Root " ) ;
CString TargetFile = TargetDir + " wizardmachine.ini " ;
CString MozBrowser = GetBrowser ( ) ;
2000-04-13 19:12:25 +00:00
// CreateShortcut(MozBrowser, TargetFile, "HelpLink", TargetDir, FALSE);
2000-01-18 22:42:18 +00:00
2002-04-05 22:55:03 +00:00
SetCurrentDirectory ( configPath ) ;
2001-05-03 22:55:33 +00:00
EraseDirectory ( tempPath ) ;
2002-04-05 22:55:03 +00:00
RemoveDirectory ( tempPath ) ;
2000-03-08 01:39:19 +00:00
return TRUE ;
1999-12-07 21:26:20 +00:00
1999-10-23 00:10:24 +00:00
}
1999-11-03 01:51:54 +00:00