1999-10-23 04:10:24 +04:00
# include "stdafx.h"
# include <Winbase.h>
1999-11-03 04:51:54 +03:00
# include <direct.h>
1999-10-23 04:10:24 +04:00
# include "globals.h"
1999-11-05 03:36:17 +03:00
# include "comp.h"
1999-11-03 04:51:54 +03:00
# include "ib.h"
2000-08-04 22:09:21 +04:00
# include "fstream.h"
1999-11-23 02:11:38 +03:00
# include <afxtempl.h>
2000-01-07 23:31:27 +03:00
# include <afxdisp.h>
1999-12-21 05:34:06 +03:00
# include "resource.h"
# include "NewDialog.h"
1999-10-23 04:10:24 +04:00
# define MAX_SIZE 1024
1999-11-03 04:51:54 +03:00
int interpret ( char * cmd ) ;
CString rootPath ;
CString configName ;
CString configPath ;
CString workspacePath ;
CString cdPath ;
1999-11-18 20:34:18 +03:00
CString networkPath ;
1999-11-03 04:51:54 +03:00
CString tempPath ;
1999-11-06 03:04:08 +03:00
CString iniDstPath ;
CString iniSrcPath ;
1999-11-03 04:51:54 +03:00
CString scriptPath ;
CString nscpxpiPath ;
1999-12-08 00:26:20 +03:00
CString cdshellPath ;
1999-12-10 02:53:03 +03:00
CString outputPath ;
2000-03-09 04:46:00 +03:00
CString xpiDstPath ;
2001-09-11 04:45:57 +04:00
// variables for CCK Linux build
CString linuxOption ;
CString linuxblobPath ;
CString templinuxPath ;
CString linuxDir ;
CString nscpxpilinuxPath ;
CString nsinstPath ;
CString nsinstallerDir ;
CString xpiDir ;
CString templinuxDir ;
CString tarfile ;
2001-09-14 21:39:17 +04:00
CString tarfile1 ;
1999-11-03 04:51:54 +03:00
1999-11-23 02:11:38 +03:00
WIDGET * tempWidget ;
1999-11-03 04:51:54 +03:00
char buffer [ 50000 ] ;
XPI xpiList [ 100 ] ;
int xpiLen = - 1 ;
2000-09-27 05:42:51 +04:00
JAR jarList [ 100 ] ;
int jarLen = - 1 ;
2000-03-09 11:56:15 +03:00
// Setup Sections for config.ini
2001-08-29 01:10:28 +04:00
CString Setup0Short = " R&ecommended " ;
2000-03-09 11:56:15 +03:00
CString Setup1Short = " C&ustom " ;
2000-04-01 00:47:46 +04:00
CString quotes = " \" " ;
CString spaces = " " ;
2000-08-30 05:26:39 +04:00
BOOL prefDoesntExist = TRUE ;
1999-11-05 22:18:33 +03:00
COMPONENT Components [ 100 ] ;
1999-11-05 03:36:17 +03:00
int numComponents ;
2000-03-09 22:39:29 +03:00
int componentOrder ;
2001-07-19 06:14:39 +04:00
CString componentstr ;
char tempcomponentstr [ MAX_SIZE ] ;
1999-11-05 03:36:17 +03:00
1999-11-03 04:51:54 +03:00
int findXPI ( CString xpiname , CString filename )
{
int found = FALSE ;
2001-06-05 02:35:03 +04:00
for ( int i = 0 ; ! found & & i < = xpiLen ; i + + )
//xpiList is an array of structures where each structure contains
//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 04:51:54 +03:00
if ( ! found )
{
xpiLen + + ;
xpiList [ xpiLen ] . xpiname = xpiname ;
xpiList [ xpiLen ] . filename = filename ;
}
return found ;
}
int ExtractXPIFile ( CString xpiname , CString xpifile )
{
CString command ;
2000-09-27 05:42:51 +04:00
// AfxMessageBox("The xpiname is "+xpiname+" and the file is "+xpifile,MB_OK);
1999-11-03 04:51:54 +03:00
if ( findXPI ( xpiname , xpifile ) )
return TRUE ;
// Can use -d instead of change CWD???
2001-06-05 02:35:03 +04:00
CString xpiArchive = nscpxpiPath + " \\ " + xpiname ; //xpiArchive = CCKTool\NSCPXPI
2000-04-01 00:47:46 +04:00
command = quotes + rootPath + " unzip.exe " + quotes + " -o " + spaces + quotes + xpiArchive + quotes + spaces + quotes + xpifile + quotes ;
1999-11-03 04:51:54 +03: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-05 02:35:03 +04:00
xpiArchive = nscpxpiPath + " \\ " + xpiList [ i ] . xpiname ; //nscpxpiPath=CCKTool\NSCPXPI
xpiArcDest = xpiDstPath + " \\ " + xpiList [ i ] . xpiname ; //xpiDstPath=CCKTool\Configs\ configName\Output\Core
1999-11-03 04:51:54 +03:00
if ( ! CopyFile ( xpiArchive , xpiArcDest , TRUE ) )
2001-06-05 02:35:03 +04:00
DWORD e = GetLastError ( ) ;
2001-06-22 06:19:34 +04:00
if ( ( strcmp ( xpiList [ i ] . filename , " bin/defaults/isp/US " ) = = 0 ) | | ( strcmp ( xpiList [ i ] . filename , " bin/defaults/isp " ) = = 0 ) )
2001-06-05 02:35:03 +04: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 04:51:54 +03:00
ExecuteCommand ( ( char * ) ( LPCTSTR ) command , SW_HIDE , INFINITE ) ;
}
return TRUE ;
}
2000-09-27 05:42:51 +04: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 ;
}
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 ;
//We have to get rid of the bin/chrome/ and hence the delete.
jarname . Delete ( 0 , 11 ) ;
if ( findJAR ( jarname , xpifile ) )
return TRUE ;
// Can use -d instead of change CWD???
CString jarArchive = tempPath + " \\ bin \\ chrome \\ " + jarname ;
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?
jarArchive = tempPath + " \\ bin \\ chrome \\ " + jarList [ i ] . jarname ;
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 04:51:54 +03:00
int ReplaceINIFile ( )
{
2000-11-11 00:52:44 +03:00
CString command1 , command2 , commandReadme ;
2000-08-30 03:27:11 +04:00
CString zipName ( " N6Setup.zip " ) ;
2000-07-14 00:31:14 +04:00
CString exeName ( " N6Setup.exe " ) ;
2000-08-30 03:27:11 +04:00
CString copyb = " copy /b " ;
1999-11-03 04:51:54 +03:00
char olddir [ 1024 ] ;
GetCurrentDirectory ( sizeof ( olddir ) , olddir ) ;
2000-03-09 04:46:00 +03:00
if ( SetCurrentDirectory ( ( char * ) ( LPCTSTR ) xpiDstPath ) = = FALSE )
1999-11-03 04:51:54 +03:00
return FALSE ;
2000-08-30 03:27:11 +04:00
CString Src = nscpxpiPath + " \\ " + zipName ;
CString Dst = xpiDstPath + " \\ " + zipName ;
2000-02-22 05:26:56 +03:00
if ( ! CopyFile ( Src , Dst , FALSE ) )
1999-11-03 04:51:54 +03:00
DWORD e = GetLastError ( ) ;
2000-11-16 02:07:32 +03:00
2000-08-30 03:27:11 +04:00
// command = quotes + rootPath + "nszip.exe " + quotes + spaces + exeName + spaces + "config.ini";
command1 = quotes + rootPath + " zip.exe " + quotes + " -m " + spaces + zipName + spaces + " config.ini " ;
ExecuteCommand ( ( char * ) ( LPCTSTR ) command1 , SW_SHOW , INFINITE ) ;
2000-11-11 00:52:44 +03:00
// Copy the Readme file to the core directory and insert it inside the N6Setup.zip**********
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 " ;
ExecuteCommand ( ( char * ) ( LPCTSTR ) commandReadme , SW_SHOW , INFINITE ) ;
// Finished copying readme and inserting into the zip**********
2000-08-30 03:27:11 +04:00
command2 = copyb + quotes + rootPath + " unzipsfx.exe " + quotes + " + N6Setup.zip N6Setup.exe " ;
// copy /b unzipsfx.exe+letters.zip letters.exe
///////////////////////////////////////////////////////
CString copycat = " copycat.bat " ;
ofstream cc ( copycat ) ;
2000-10-20 02:01:06 +04:00
cc < < command2 < < " \n echo off \n cls \n " ;
2000-08-30 03:27:11 +04:00
cc . close ( ) ;
CString command3 = " copycat.bat " ;
///////////////////////////////////////////////////////
ExecuteCommand ( ( char * ) ( LPCTSTR ) command3 , SW_SHOW , INFINITE ) ;
DeleteFile ( " copycat.bat " ) ;
2000-10-20 02:01:06 +04:00
CString unzipN6 = quotes + rootPath + " unzip.exe " + quotes + " -o " + spaces + quotes + zipName + quotes ;
ExecuteCommand ( ( char * ) ( LPCTSTR ) unzipN6 , SW_SHOW , INFINITE ) ;
2000-08-30 03:27:11 +04:00
DeleteFile ( zipName ) ;
1999-11-03 04:51:54 +03:00
SetCurrentDirectory ( olddir ) ;
return TRUE ;
}
2000-02-22 05:26:56 +03:00
void ModifyPref ( char * buffer , CString entity , CString newvalue )
{
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 ) ;
strcpy ( buffer , ( char * ) ( LPCTSTR ) buf ) ;
2000-08-30 05:26:39 +04:00
prefDoesntExist = FALSE ;
2000-02-22 05:26:56 +03:00
}
2000-08-04 22:09:21 +04: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 ;
}
2000-08-30 05:26:39 +04:00
void AddPref ( CString xpifile , CString entity , CString newvalue )
{
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 ;
}
tf < < " pref( " < < entity < < " , \" " < < newvalue < < " \" ); \n " ;
ifstream pf ( prefFile ) ;
if ( ! pf )
{
rv = FALSE ;
cout < < " Cannot open: " < < prefFile < < " \n " ;
return ;
}
while ( ! pf . eof ( ) )
{
pf . getline ( properties , 400 ) ;
tf < < properties < < " \n " ;
}
pf . close ( ) ;
tf . close ( ) ;
remove ( xpifile ) ;
rename ( tempFile , xpifile ) ;
return ;
}
2000-08-04 22:09:21 +04:00
2000-02-22 05:26:56 +03:00
int ModifyJS ( 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 " ) ;
CString apost = ' " ' ;
entity . Insert ( 0 , apost ) ;
entity . Insert ( 1000 , apost ) ;
if ( ! srcf )
rv = FALSE ;
else
{
int done = FALSE ;
while ( ! done )
{
fgetsrv = fgets ( buffer , sizeof ( buffer ) , srcf ) ;
done = feof ( srcf ) ;
if ( ! done )
{
if ( ! fgetsrv | | ferror ( srcf ) )
{
rv = FALSE ;
break ;
}
ModifyPref ( buffer , entity , newvalue ) ;
fputs ( buffer , dstf ) ;
}
}
fclose ( srcf ) ;
fclose ( dstf ) ;
}
remove ( xpifile ) ;
rename ( newfile , xpifile ) ;
2000-08-30 05:26:39 +04:00
if ( prefDoesntExist )
AddPref ( xpifile , entity , newvalue ) ;
2000-02-22 05:26:56 +03:00
return TRUE ;
}
1999-11-03 04:51:54 +03: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
{
int done = FALSE ;
while ( ! done )
{
fgetsrv = fgets ( buffer , sizeof ( buffer ) , srcf ) ;
done = feof ( srcf ) ;
if ( ! done )
{
if ( ! fgetsrv | | ferror ( srcf ) )
{
rv = FALSE ;
break ;
}
ModifyEntity ( buffer , entity , newvalue ) ;
fputs ( buffer , dstf ) ;
}
}
fclose ( srcf ) ;
fclose ( dstf ) ;
}
remove ( xpifile ) ;
rename ( newfile , xpifile ) ;
return TRUE ;
}
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 04:39:19 +03: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 04:51:54 +03:00
if ( ! t )
2000-03-08 04:39:19 +03:00
return TRUE ; //*** Changed FALSE to TRUE
1999-11-03 04:51:54 +03:00
* t = ' \0 ' ;
newvalue = ( char * ) ( LPCTSTR ) GetGlobal ( value ) ;
}
if ( ! section | | ! key | | ! newvalue )
2000-03-08 04:39:19 +03:00
return TRUE ; //***Changed FALSE to TRUE
1999-11-06 03:04:08 +03:00
if ( ! CopyFile ( iniSrcPath , iniDstPath , TRUE ) )
1999-11-03 04:51:54 +03:00
DWORD e = GetLastError ( ) ;
2000-11-15 04:30:50 +03:00
if ( strcmp ( key , " Program Folder Name " ) = = 0 )
1999-11-03 04:51:54 +03:00
{
2001-05-04 03:37:48 +04:00
if ( strcmp ( newvalue , " " ) = = 0 )
strcpy ( temp , " Netscape 6 " ) ;
else
strcpy ( temp , " Netscape 6 by " ) ;
1999-11-03 04:51:54 +03:00
strcat ( temp , newvalue ) ;
newvalue = temp ;
}
2000-11-15 04:30:50 +03:00
WritePrivateProfileString ( section , key , newvalue , iniDstPath ) ;
1999-11-03 04:51:54 +03:00
}
else if ( strcmp ( cmdname , " replaceXPI " ) = = 0 )
{
char * xpiname = strtok ( NULL , " ,) " ) ;
2000-09-27 05:42:51 +04:00
char * jname = strtok ( NULL , " ,) " ) ;
1999-11-03 04:51:54 +03:00
char * xpifile = strtok ( NULL , " ,) " ) ;
char * value = strtok ( NULL , " ,) " ) ;
char * newvalue = value ;
2000-09-27 05:42:51 +04:00
CString jarname = jname ;
1999-11-03 04:51:54 +03:00
if ( value [ 0 ] = = ' % ' )
{
value + + ;
char * t = strchr ( value , ' % ' ) ;
if ( ! t )
2000-03-08 04:39:19 +03:00
return TRUE ; //*** Changed FALSE to TRUE
1999-11-03 04:51:54 +03:00
* t = ' \0 ' ;
newvalue = ( char * ) ( LPCTSTR ) GetGlobal ( value ) ;
}
if ( ! xpiname | | ! xpifile | | ! newvalue )
2000-03-08 04:39:19 +03: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 03:08:25 +03: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 05:42:51 +04:00
//check to see if it is a jar and then do accordingly
if ( jarname . CompareNoCase ( " no.jar " ) = = 0 )
1999-11-03 04:51:54 +03:00
ExtractXPIFile ( xpiname , xpifile ) ;
2000-09-27 05:42:51 +04:00
else
ExtractJARFile ( xpiname , jarname , xpifile ) ;
1999-11-03 04:51:54 +03:00
if ( ! CopyFile ( newvalue , xpifile , FALSE ) )
{
DWORD e = GetLastError ( ) ;
2000-03-08 04:39:19 +03:00
return TRUE ; //*** Changed FALSE to TRUE
1999-11-03 04:51:54 +03:00
}
2001-06-05 02:35:03 +04: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 ;
2001-06-22 06:19:34 +04:00
// decompressing the directory path within the XPI file
command = quotes + rootPath + " unzip.exe " + quotes + " -o " + spaces + quotes + xpiArchive + quotes + spaces + quotes + xpifile + " /*.* " + quotes ;
2001-06-05 02:35:03 +04:00
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
}
}
2000-02-22 05:26:56 +03:00
else if ( ( strcmp ( cmdname , " modifyDTD " ) = = 0 ) | |
2000-08-04 22:09:21 +04:00
( strcmp ( cmdname , " modifyJS " ) = = 0 ) | |
( strcmp ( cmdname , " modifyProperties " ) = = 0 ) )
1999-11-03 04:51:54 +03:00
{
char * xpiname = strtok ( NULL , " ,) " ) ;
2000-09-27 05:42:51 +04:00
char * jname = strtok ( NULL , " ,) " ) ;
1999-11-03 04:51:54 +03:00
char * xpifile = strtok ( NULL , " ,) " ) ;
char * entity = strtok ( NULL , " ,) " ) ;
char * value = strtok ( NULL , " ,) " ) ;
char * newvalue = value ;
2000-09-27 05:42:51 +04:00
CString jarname = jname ;
1999-11-03 04:51:54 +03:00
if ( value [ 0 ] = = ' % ' )
{
value + + ;
char * t = strchr ( value , ' % ' ) ;
if ( ! t )
2000-03-08 04:39:19 +03:00
return TRUE ; //*** Changed FALSE to TRUE
1999-11-03 04:51:54 +03:00
* t = ' \0 ' ;
newvalue = ( char * ) ( LPCTSTR ) GetGlobal ( value ) ;
}
if ( ! xpiname | | ! xpifile | | ! entity | | ! newvalue )
2000-03-08 04:39:19 +03:00
return TRUE ; //*** Changed FALSE to TRUE
2000-09-27 05:42:51 +04:00
//check to see if it is a jar and then do accordingly
if ( jarname . CompareNoCase ( " no.jar " ) = = 0 )
1999-11-03 04:51:54 +03:00
ExtractXPIFile ( xpiname , xpifile ) ;
2000-09-27 05:42:51 +04:00
else
ExtractJARFile ( xpiname , jarname , xpifile ) ;
2000-02-22 05:26:56 +03:00
if ( strcmp ( cmdname , " modifyJS " ) = = 0 )
ModifyJS ( xpifile , entity , newvalue ) ;
2000-08-04 22:09:21 +04:00
else if ( strcmp ( cmdname , " modifyProperties " ) = = 0 )
ModifyProperties ( xpifile , entity , newvalue ) ;
2001-06-05 23:42:43 +04: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-12 02:38:06 +04:00
newvalue = " &brandShortName; " ;
2001-06-05 02:35:03 +04:00
ModifyDTD ( xpifile , entity , newvalue ) ;
2001-06-05 23:42:43 +04:00
}
1999-11-03 04:51:54 +03:00
}
else if ( strcmp ( cmdname , " wrapXPI " ) = = 0 )
{
}
else
2000-03-08 04:39:19 +03:00
return FALSE ; //*** We have to handle this condition better.
1999-11-03 04:51:54 +03:00
return TRUE ;
}
1999-11-05 03:36:17 +03:00
void init_components ( )
{
int i ;
WIDGET * w = findWidget ( " SelectedComponents " ) ;
2001-07-19 06:14:39 +04:00
BuildComponentList ( Components , & numComponents , iniSrcPath , 0 ) ;
1999-11-05 03:36:17 +03:00
// Turn off components that aren't selected
for ( i = 0 ; i < numComponents ; i + + )
2000-12-08 07:00:29 +03:00
{
if ( ( strstr ( w - > value , Components [ i ] . name ) = = NULL ) )
{
if ( ! ( Components [ i ] . selected & & Components [ i ] . invisible ) )
1999-11-05 22:18:33 +03:00
Components [ i ] . selected = FALSE ;
2000-12-08 07:00:29 +03:00
}
else
if ( Components [ i ] . additional )
Components [ i ] . selected = TRUE ;
}
1999-11-05 03:36:17 +03:00
}
2000-03-09 11:56:15 +03: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 20:34:18 +03:00
void invisible ( )
{
2000-03-09 11:56:15 +03: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 20:34:18 +03:00
tempWidget = findWidget ( " SelectedComponents " ) ;
CString component ;
2000-03-09 11:56:15 +03:00
for ( int i = 0 ; i < numComponents ; i + + )
1999-11-18 20:34:18 +03:00
{
2000-03-09 11:56:15 +03:00
if ( Components [ i ] . selected )
1999-11-18 20:34:18 +03:00
{
component = Components [ i ] . compname ;
2000-03-09 22:39:29 +03:00
Cee . Format ( " C%d " , componentOrder ) ;
2000-03-09 11:56:15 +03:00
WritePrivateProfileString ( " Setup Type0 " , ( LPCTSTR ) Cee , ( LPCTSTR ) component , iniDstPath ) ;
WritePrivateProfileString ( " Setup Type1 " , ( LPCTSTR ) Cee , ( LPCTSTR ) component , iniDstPath ) ;
2000-12-08 07:00:29 +03:00
if ( Components [ i ] . additional & & ! ( Components [ i ] . launchapp ) & & ! ( Components [ i ] . invisible ) )
2001-07-25 07:36:38 +04:00
WritePrivateProfileString ( Components [ i ] . compname , " Attributes " , " SELECTED|ADDITIONAL " , iniDstPath ) ;
else if ( ! ( Components [ i ] . disabled ) & & ! ( Components [ i ] . additional ) & & ! ( Components [ i ] . invisible ) )
WritePrivateProfileString ( Components [ i ] . compname , " Attributes " , " SELECTED|FORCE_UPGRADE " , iniDstPath ) ;
else if ( Components [ i ] . additional & & Components [ i ] . launchapp & & ! ( Components [ i ] . invisible ) )
WritePrivateProfileString ( Components [ i ] . compname , " Attributes " , " SELECTED|LAUNCHAPP|ADDITIONAL " , iniDstPath ) ;
2000-03-09 22:39:29 +03:00
componentOrder + + ;
1999-11-18 20:34:18 +03:00
}
2000-03-09 11:56:15 +03:00
else
WritePrivateProfileString ( Components [ i ] . compname , " Attributes " , " INVISIBLE " , iniDstPath ) ;
1999-11-18 20:34:18 +03:00
}
}
2001-09-11 04:45:57 +04: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
WritePrivateProfileString ( Components [ i ] . compname , " Attributes " ,
" SELECTED " , iniDstPath ) ;
componentOrder + + ;
}
}
}
1999-11-23 02:11:38 +03:00
void AddThirdParty ( )
{
CString tpCompPath1 = GetGlobal ( " CustomComponent1 " ) ;
CString tpCompPath2 = GetGlobal ( " CustomComponent137 " ) ;
CString tpComp1 = GetGlobal ( " CustomComponent2 " ) ;
CString tpComp2 = GetGlobal ( " CustomComponent23 " ) ;
CString tpCompSize1 = GetGlobal ( " ComponentSize " ) ;
CString tpCompSize2 = GetGlobal ( " ModuleSize " ) ;
2001-07-21 05:03:32 +04:00
CString componentName ;
1999-11-23 02:11:38 +03:00
CString cName ;
CString compSDesc = " Description Short= " ;
CString compLDesc = " Description Long= " ;
CString compArchive = " Archive= " ;
2000-03-09 11:56:15 +03:00
CString compISize = " Install Size Archive= " ;
1999-11-23 02:11:38 +03: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-29 00:59:19 +04:00
CString firstSix = tpCompPath1 . Left ( 6 ) ;
1999-11-23 02:11:38 +03:00
2000-03-29 00:59:19 +04:00
if ( ( firstSix . CompareNoCase ( " Please " ) ! = 0 ) & & ! ( tpCompPath1 . IsEmpty ( ) ) )
1999-11-23 02:11:38 +03:00
{
2001-07-21 05:03:32 +04:00
componentName . Format ( " C%d " , ( numComponents ) ) ;
2000-03-09 22:39:29 +03:00
cName . Format ( " C%d " , componentOrder ) ;
componentOrder + + ;
1999-11-23 02:11:38 +03:00
WritePrivateProfileString ( " Setup Type0 " , cName , componentName , iniDstPath ) ;
WritePrivateProfileString ( " Setup Type1 " , cName , componentName , iniDstPath ) ;
WritePrivateProfileSection ( componentName , cBuffer1 , iniDstPath ) ;
2000-03-09 11:56:15 +03:00
numComponents + + ;
2000-03-09 04:46:00 +03:00
CopyFile ( tpCompPath1 , xpiDstPath + " \\ " + Archive1 , FALSE ) ;
1999-11-23 02:11:38 +03:00
DWORD e1 = GetLastError ( ) ;
}
2000-03-29 00:59:19 +04:00
firstSix = tpCompPath2 . Left ( 6 ) ;
if ( ( firstSix . CompareNoCase ( " Please " ) ! = 0 ) & & ! ( tpCompPath2 . IsEmpty ( ) ) )
1999-11-23 02:11:38 +03:00
{
2001-07-21 05:03:32 +04:00
componentName . Format ( " C%d " , ( numComponents ) ) ;
2000-03-09 22:39:29 +03:00
cName . Format ( " C%d " , componentOrder ) ;
1999-11-23 02:11:38 +03:00
WritePrivateProfileString ( " Setup Type0 " , cName , componentName , iniDstPath ) ;
WritePrivateProfileString ( " Setup Type1 " , cName , componentName , iniDstPath ) ;
WritePrivateProfileSection ( componentName , cBuffer2 , iniDstPath ) ;
2000-03-09 04:46:00 +03:00
CopyFile ( tpCompPath2 , xpiDstPath + " \\ " + Archive2 , FALSE ) ;
1999-11-23 02:11:38 +03:00
DWORD e2 = GetLastError ( ) ;
}
delete [ ] cBuffer1 ;
delete [ ] cBuffer2 ;
}
2000-01-07 23:31:27 +03: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 ;
}
2001-05-04 02:55:33 +04:00
void EraseDirectory ( CString sPath )
{
CFileFind finder ;
CString sFullPath = sPath + " \\ *.* " ;
BOOL bWorking = finder . FindFile ( sFullPath ) ;
while ( bWorking )
{
bWorking = finder . FindNextFile ( ) ;
if ( finder . IsDots ( ) ) continue ;
if ( finder . IsDirectory ( ) )
{
CString dirPath = finder . GetFilePath ( ) ;
EraseDirectory ( dirPath ) ;
_rmdir ( finder . GetFilePath ( ) ) ;
continue ;
}
_unlink ( finder . GetFilePath ( ) ) ;
}
}
2001-09-11 04:45:57 +04:00
void CopyDirectory ( CString source , CString dest )
{
CFileFind finder ;
CString sFileToFind = source + " \\ *.* " ;
BOOL bWorking = finder . FindFile ( sFileToFind ) ;
while ( bWorking )
{
bWorking = finder . FindNextFile ( ) ;
CString newPath = dest + " \\ " ;
if ( finder . IsDots ( ) ) continue ;
if ( finder . IsDirectory ( ) )
{
CString dirPath = finder . GetFilePath ( ) ;
newPath + = finder . GetFileName ( ) ;
_mkdir ( newPath ) ;
CopyDirectory ( dirPath , newPath ) ;
if ( ! CopyFile ( dirPath , newPath , 0 ) )
DWORD e = GetLastError ( ) ;
continue ;
}
newPath + = finder . GetFileName ( ) ;
CString source = finder . GetFilePath ( ) ;
if ( ! CopyFile ( source , newPath , 0 ) )
DWORD e = GetLastError ( ) ;
}
}
void CreateLinuxInstaller ( )
{
char currentdir [ _MAX_PATH ] ;
_getcwd ( currentdir , _MAX_PATH ) ;
CopyDirectory ( xpiDstPath , templinuxPath + xpiDir ) ;
2001-09-14 21:39:17 +04:00
DeleteFile ( templinuxPath + xpiDir + " \\ N6Setup.exe " ) ;
2001-09-11 04:45:57 +04:00
CopyFile ( xpiDstPath + " \\ Config.ini " , templinuxPath + " \\ Config.ini " , FALSE ) ;
2001-09-14 21:39:17 +04:00
DeleteFile ( templinuxPath + xpiDir + " \\ Config.ini " ) ;
2001-09-11 04:45:57 +04:00
_chdir ( outputPath ) ;
templinuxPath = tempPath ;
templinuxPath . Replace ( " \\ " , " / " ) ;
2001-09-14 21:39:17 +04:00
DeleteFile ( tarfile1 ) ;
DeleteFile ( tarfile ) ;
CString command = " tar -cvf " + tarfile1 + " -C " + templinuxPath + " / " + templinuxDir + spaces + nsinstallerDir ;
ExecuteCommand ( ( char * ) ( LPCTSTR ) command , SW_HIDE , INFINITE ) ;
command = " gzip " + tarfile1 ;
2001-09-11 04:45:57 +04:00
ExecuteCommand ( ( char * ) ( LPCTSTR ) command , SW_HIDE , INFINITE ) ;
_chdir ( currentdir ) ;
}
2001-05-04 02:55:33 +04:00
1999-10-23 04:10:24 +04:00
extern " C " __declspec ( dllexport )
1999-11-04 23:19:27 +03:00
int StartIB ( CString parms , WIDGET * curWidget )
1999-10-23 04:10:24 +04:00
{
1999-11-03 04:51:54 +03:00
char * fgetsrv ;
int rv = TRUE ;
char olddir [ 1024 ] ;
2000-03-09 22:39:29 +03:00
componentOrder = 0 ;
1999-11-03 04:51:54 +03:00
rootPath = GetGlobal ( " Root " ) ;
configName = GetGlobal ( " CustomizationList " ) ;
configPath = rootPath + " Configs \\ " + configName ;
1999-12-10 02:53:03 +03:00
outputPath = configPath + " \\ Output " ;
1999-12-08 00:26:20 +03:00
cdPath = configPath + " \\ Output \\ Core " ;
cdshellPath = configPath + " \\ Output \\ Shell " ;
1999-11-18 20:34:18 +03:00
networkPath = configPath + " \\ Network " ;
1999-11-03 04:51:54 +03:00
tempPath = configPath + " \\ Temp " ;
1999-11-06 03:04:08 +03:00
iniDstPath = cdPath + " \\ config.ini " ;
1999-11-03 04:51:54 +03:00
scriptPath = rootPath + " \\ script.ib " ;
workspacePath = configPath + " \\ Workspace " ;
2001-09-11 04:45:57 +04:00
xpiDstPath = cdPath ;
// initializing variables for CCK linux build
linuxOption = GetGlobal ( " lPlatform " ) ;
linuxblobPath = GetGlobal ( " LinuxPath " ) ;
templinuxPath = tempPath + " \\ templinux \\ netscape-installer " ;
linuxDir = " nscpxpiLinux " ;
nscpxpilinuxPath = rootPath + linuxDir ;
nsinstPath = " \\ netscape-installer \\ xpi " ;
nsinstallerDir = " netscape-installer " ;
xpiDir = " \\ xpi " ;
templinuxDir = " tempLinux " ;
tarfile = " netscape-i686-pc-linux-gnu-sea.tar.gz " ;
2001-09-14 21:39:17 +04:00
tarfile1 = " netscape-i686-pc-linux-gnu-sea.tar " ;
2001-09-11 04:45:57 +04:00
1999-11-03 04:51:54 +03:00
if ( SearchPath ( workspacePath , " NSCPXPI " , NULL , 0 , NULL , NULL ) )
nscpxpiPath = workspacePath + " \\ NSCPXPI " ;
else
2001-09-11 04:45:57 +04:00
nscpxpiPath = rootPath + " NSCPXPI " ;
if ( linuxOption = = " Linux " )
{
nscpxpiPath = nscpxpilinuxPath + nsinstPath ;
char currentdir [ _MAX_PATH ] ;
_getcwd ( currentdir , _MAX_PATH ) ;
_mkdir ( tempPath ) ;
_chdir ( tempPath ) ;
_mkdir ( templinuxDir ) ;
_chdir ( templinuxDir ) ;
_mkdir ( nsinstallerDir ) ;
_chdir ( nsinstallerDir ) ;
CString tPath = nscpxpiPath ;
tPath . Replace ( xpiDir , " " ) ;
CopyDirectory ( tPath , templinuxPath ) ;
_chdir ( currentdir ) ;
}
1999-11-06 03:04:08 +03:00
iniSrcPath = nscpxpiPath + " \\ config.ini " ;
2000-03-28 23:58:24 +04:00
//Check for disk space before continuing
ULARGE_INTEGER nTotalBytes , nTotalFreeBytes , nTotalAvailable ;
2001-07-21 04:37:17 +04:00
GetDiskFreeSpaceEx ( NULL , & nTotalAvailable , & nTotalBytes , & nTotalFreeBytes ) ;
// Checking for 26.3MB disk space
if ( ( nTotalAvailable . QuadPart ) > 27 , 577 , 549 )
2000-03-28 23:58:24 +04:00
;
else
{
AfxMessageBox ( " You dont have enough Disk space " , MB_OK ) ;
return FALSE ;
}
//Check for Disk space over
1999-10-23 04:10:24 +04:00
1999-11-05 03:36:17 +03:00
init_components ( ) ;
2000-03-09 04:46:00 +03: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 06:26:25 +04: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 04:46:00 +03:00
2000-08-30 05:26:39 +04:00
//Check to see if the User Agent string exists and if so then append -CCK to it ;
CString userAgent = GetGlobal ( " OrganizationName " ) ;
2001-06-09 03:22:03 +04:00
if ( userAgent )
{
2001-07-21 04:31:17 +04:00
CString templeft = userAgent . Left ( 3 ) ;
if ( ( templeft . CompareNoCase ( " CK- " ) ) ! = 0 )
2001-07-21 04:25:49 +04:00
userAgent = " CK- " + userAgent ;
2001-06-09 03:22:03 +04:00
}
SetGlobal ( " OrganizationName " , userAgent ) ;
2000-08-30 05:26:39 +04:00
2000-03-29 02:27:48 +04: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-17 00:26:50 +04: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 06:26:25 +04: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-17 01:05:11 +04:00
CString HelpUrl = GetGlobal ( " HelpMenuCommandURL " ) ;
2000-05-17 00:26:50 +04:00
leftvalue = HelpUrl . Left ( 7 ) ;
httpvalue = " http:// " ;
if ( leftvalue . CompareNoCase ( " http:// " ) ! = 0 )
{
httpvalue = httpvalue + HelpUrl ;
2000-05-17 01:05:11 +04:00
SetGlobal ( " HelpMenuCommandURL " , httpvalue ) ;
2000-05-17 00:26:50 +04:00
}
// Create the HelpMenu.xul in the beginning so that it can be called from the script.ib
2000-10-26 04:34:18 +04:00
CString setHlpRDF = tempPath + " \\ helpMenu.rdf " ;
SetGlobal ( " HlpRDF " , setHlpRDF ) ;
2000-05-17 00:26:50 +04:00
CreateHelpMenu ( ) ;
2001-06-05 02:35:03 +04:00
CString setIspRDF = tempPath + " \\ mailaccount.rdf " ;
SetGlobal ( " IspRDF " , setIspRDF ) ;
CreateIspMenu ( ) ;
CString setnewsRDF = tempPath + " \\ newsaccount.rdf " ;
SetGlobal ( " NewsRDF " , setnewsRDF ) ;
CreateNewsMenu ( ) ;
2000-05-17 00:26:50 +04:00
2000-03-09 04:46:00 +03:00
if ( cdDir . Compare ( " 1 " ) = = 0 )
{
_mkdir ( ( char * ) ( LPCTSTR ) cdPath ) ;
}
else
{
iniDstPath = outputPath + " \\ config.ini " ;
xpiDstPath = outputPath ;
}
1999-12-21 05:34:06 +03:00
CNewDialog newprog ;
newprog . Create ( IDD_NEW_DIALOG , NULL ) ;
newprog . ShowWindow ( SW_SHOW ) ;
2000-01-19 01:42:18 +03:00
/////////////////////////////
CWnd * dlg ;
CRect tmpRect = CRect ( 7 , 7 , 173 , 13 ) ;
dlg = newprog . GetDlgItem ( IDC_BASE_TEXT ) ;
CWnd * pwnd = newprog . GetDlgItem ( IDD_NEW_DIALOG ) ;
dlg - > SetWindowText ( " Customization is in Progress " ) ;
/////////////////////////////
1999-11-03 04:51:54 +03:00
_mkdir ( ( char * ) ( LPCTSTR ) tempPath ) ;
_mkdir ( ( char * ) ( LPCTSTR ) workspacePath ) ;
2000-01-19 02:41:08 +03:00
// _mkdir((char *)(LPCTSTR) cdshellPath);
1999-11-03 04:51:54 +03:00
GetCurrentDirectory ( sizeof ( olddir ) , olddir ) ;
1999-10-23 04:10:24 +04:00
1999-11-03 04:51:54 +03:00
if ( SetCurrentDirectory ( ( char * ) ( LPCTSTR ) tempPath ) = = FALSE )
2000-03-08 04:39:19 +03: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 04:10:24 +04:00
1999-11-03 04:51:54 +03: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
if ( ! interpret ( buffer ) )
{
rv = FALSE ;
break ;
}
}
}
fclose ( f ) ;
}
2000-05-24 04:30:55 +04:00
dlg - > SetWindowText ( " Customization is in Progress \n ||||||||| " ) ;
2000-01-19 01:42:18 +03:00
1999-11-03 04:51:54 +03:00
// Put all the extracted files back into their new XPI homes
2000-09-27 05:42:51 +04:00
ReplaceJARFiles ( ) ;
1999-11-03 04:51:54 +03:00
ReplaceXPIFiles ( ) ;
2000-05-24 04:30:55 +04:00
dlg - > SetWindowText ( " Customization is in Progress \n |||||||||||||||||| " ) ;
2000-01-19 01:42:18 +03:00
1999-11-03 04:51:54 +03:00
// Copy remaining default installer files into config
// preserving any existing files that we created already
// in previous steps
1999-11-05 22:18:33 +03:00
/* -- Need to be more selective than this
1999-11-03 04:51:54 +03:00
CopyDir ( nscpxpiPath , cdPath , NULL , FALSE ) ;
1999-11-05 22:18:33 +03:00
*/
1999-11-18 20:34:18 +03:00
1999-12-08 09:45:16 +03:00
for ( int i = 0 ; i < numComponents ; i + + )
{
if ( Components [ i ] . selected )
CopyFile ( nscpxpiPath + " \\ " + Components [ i ] . archive ,
2000-03-09 04:46:00 +03:00
xpiDstPath + " \\ " + Components [ i ] . archive , TRUE ) ;
1999-12-08 09:45:16 +03:00
}
1999-11-18 20:34:18 +03:00
if ( cdDir . Compare ( " 1 " ) = = 0 )
1999-11-05 22:18:33 +03:00
{
1999-12-08 09:45:16 +03:00
1999-12-10 02:53:03 +03:00
CString shellPath = workspacePath + " \\ Autorun \\ " ;
CopyDir ( shellPath , outputPath , NULL , TRUE ) ;
2001-07-31 01:15:01 +04:00
CreateRshell ( ) ;
WritePrivateProfileString ( " Message Stream " , " Status " , " Disabled " , iniDstPath ) ;
1999-11-05 22:18:33 +03:00
}
1999-12-08 09:45:16 +03:00
else
{
FILE * infout ;
2000-01-19 02:41:08 +03:00
CString infFile = outputPath + " \\ autorun.inf " ;
1999-12-08 09:45:16 +03:00
infout = fopen ( infFile , " w " ) ;
if ( ! infout )
exit ( 3 ) ;
1999-11-18 20:34:18 +03:00
2000-11-14 22:20:47 +03:00
fprintf ( infout , " [autorun] \n open = setup.exe " ) ;
1999-12-08 09:45:16 +03:00
}
1999-11-18 20:34:18 +03:00
CString component ;
2000-03-09 04:46:00 +03:00
CString configiniPath = xpiDstPath + " \\ config.ini " ;
1999-12-08 09:45:16 +03:00
if ( ftpLocation . Compare ( " ftp:// " ) ! = 0 )
1999-11-18 20:34:18 +03:00
{
2000-11-16 02:07:32 +03:00
//**************** 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);
//
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-11 01:38:49 +04:00
WritePrivateProfileString ( " Site Selector " , " Domain0 " , ftpLocation , configiniPath ) ;
2000-11-16 02:07:32 +03:00
// }
1999-11-18 20:34:18 +03:00
}
2000-03-09 11:56:15 +03:00
1999-11-05 22:18:33 +03:00
// Didn't work...
2000-05-24 04:30:55 +04:00
dlg - > SetWindowText ( " Customization is in Progress \n ||||||||||||||||||||||||||| " ) ;
2001-09-11 04:45:57 +04:00
if ( linuxOption = = " Linux " )
{
LinuxInvisible ( ) ;
}
else
invisible ( ) ;
2000-01-19 01:42:18 +03:00
2000-05-24 04:30:55 +04:00
dlg - > SetWindowText ( " Customization is in Progress \n |||||||||||||||||||||||||||||||||||| " ) ;
1999-11-18 20:34:18 +03:00
1999-11-23 02:11:38 +03:00
AddThirdParty ( ) ;
2000-05-24 04:30:55 +04:00
dlg - > SetWindowText ( " Customization is in Progress \n ||||||||||||||||||||||||||||||||||||||||||||| " ) ;
2000-01-19 01:42:18 +03:00
1999-11-03 04:51:54 +03:00
ReplaceINIFile ( ) ;
2001-09-11 04:45:57 +04:00
if ( linuxOption = = " Linux " )
{
dlg - > SetWindowText ( " Customization is in Progress \n ||||||||||||||||||||||||||||||||||||||||||||||| " ) ;
CreateLinuxInstaller ( ) ;
}
2000-05-24 04:30:55 +04:00
dlg - > SetWindowText ( " Customization is in Progress \n |||||||||||||||||||||||||||||||||||||||||||||||||||||| " ) ;
2000-01-19 01:42:18 +03:00
1999-11-03 04:51:54 +03:00
SetCurrentDirectory ( olddir ) ;
2000-01-07 23:31:27 +03:00
CString TargetDir = GetGlobal ( " Root " ) ;
CString TargetFile = TargetDir + " wizardmachine.ini " ;
CString MozBrowser = GetBrowser ( ) ;
2000-04-13 23:12:25 +04:00
// CreateShortcut(MozBrowser, TargetFile, "HelpLink", TargetDir, FALSE);
2000-01-19 01:42:18 +03:00
2000-05-24 04:30:55 +04:00
dlg - > SetWindowText ( " Customization is in Progress \n ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| " ) ;
2000-01-19 01:42:18 +03:00
newprog . DestroyWindow ( ) ;
2001-05-04 02:55:33 +04:00
EraseDirectory ( tempPath ) ;
_chdir ( configPath ) ;
_rmdir ( " Temp " ) ;
2000-03-08 04:39:19 +03:00
return TRUE ;
1999-12-08 00:26:20 +03:00
1999-10-23 04:10:24 +04:00
}
1999-11-03 04:51:54 +03:00