/*                 Create the default CD-Creator config folders
 *
 *                   (C) Chris Wohlgemuth 2001-2002
*/

/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; see the file COPYING.  If not, write to
 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 */

 call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
 call SysLoadFuncs


instObj= arg(1)

/* Get curent directory */
curdir = directory()
say ''
instDir=FILESPEC("drive",curdir)||FILESPEC("path",curdir)

/* Check if WPS-Wizard is installed */
list.0=0
found=0
rc=SysQueryClassList(list.)
DO a=1 to list.0
	if TRANSLATE(WORD(list.a,1))='CWWIZZSETTINGS' THEN DO
		found=1
		LEAVE
	END
END

IF found=0 THEN DO
	/* WPS-Wizard not yet installed */
	call createWizInst
	exit
END

/* Create a context menu folder for Data-CD-Creator */
say 'Creating menufolder for Data-CD-Creator class...'
/*rc=SysDestroyObject("<MENU_CWDataFolder>")*/
setupstring='DEFAULTVIEW=TREE;SHOWALLINTREEVIEW=YES;CLEARMENUCACHE=1;OBJECTID=<MENU_CWDataFolder>'
if SysCreateObject("CWMenuFolder", "Context menu for^Data-CD Folder", "<CREATOR_CONFIG>",setupstring,"update")<>1 then
             do
                say ''
                say 'Menufolder not created.'
	     /*call createWizInst
	     exit*/
             end

setupstring='DEFAULTVIEW=TREE;SHOWALLINTREEVIEW=YES;OBJECTID=<SUBMENU_DWRITING>'
if SysCreateObject("CWMenuFolder", '~CD-Writing',"<MENU_CWDataFolder>",setupstring,"update") = 1 then
             do
	setupstring='SHADOWID=<CD_WRITING>'
	if SysCreateObject("WPShadow", " ","<SUBMENU_DWRITING>",setupstring,"update")<>1 then
                say 'Menuitem 1 not created.'
	setupstring='SHADOWID=<CWCREATOR_SETTINGS>'
	if SysCreateObject("WPShadow", " ","<SUBMENU_DWRITING>",setupstring,"update")<>1 then
                say 'Menuitem 2 not created.'
	setupstring='SHADOWID=<CWCREATOR_TUTORIAL>'
	if SysCreateObject("WPShadow", " ","<SUBMENU_DWRITING>",setupstring,"update")<>1 then
                say 'Menuitem 3 not created.'
	setupstring='SHADOWID=<CD_COPY>'
	if SysCreateObject("WPShadow", " ","<SUBMENU_DWRITING>",setupstring,"update")<>1 then
                say 'Menuitem 4 not created.'
	end

/* Create the folder for user defined menu items */
/*rc=SysDestroyObject("<USERMENU_DATAFOLDER>")*/
setupstring='DEFAULTVIEW=TREE;SHOWALLINTREEVIEW=YES;CLEARMENUCACHE=1;HIDECLASSPAGE=1;OBJECTID=<USERMENU_DATAFOLDER>'
if SysCreateObject("CWMenuFolder", "User menu for^Data-CD Folder", "<CREATOR_CONFIG>",setupstring,"update")<>1 then
             do
                say ''
                say 'Menufolder not created.'
	/*     call createWizInst
	     exit*/
             end
/* Fill the user menu with some default items */
setupstring='DEFAULTVIEW=TREE;SHOWALLINTREEVIEW=YES;OBJECTID=<USERMENU_DWRITING>'
if SysCreateObject("CWMenuFolder", '~CD-Writing',"<USERMENU_DATAFOLDER>",setupstring,"update") = 1 then
             do
		setupstring='SHADOWID=<CD_WRITING>'
		if SysCreateObject("WPShadow", " ","<USERMENU_DWRITING>",setupstring,"update")<>1 then
                	say 'Menuitem 1 not created.'
		setupstring='SHADOWID=<CWCREATOR_SETTINGS>'
		if SysCreateObject("WPShadow", " ","<USERMENU_DWRITING>",setupstring,"update")<>1 then
	           say 'Menuitem 2 not created.'
		setupstring='SHADOWID=<CWCREATOR_TUTORIAL>'
		if SysCreateObject("WPShadow", " ","<USERMENU_DWRITING>",setupstring,"update")<>1 then
                	say 'Menuitem 3 not created.'
		setupstring='SHADOWID=<CD_COPY>'
		if SysCreateObject("WPShadow", " ","<USERMENU_DWRITING>",setupstring,"update")<>1 then
                	say 'Menuitem 4 not created.'
	END

say 'Creating menufolder for Audio-CD-Creator class...'
/*rc=SysDestroyObject("<MENU_CWAudioFolder>")*/
setupstring='DEFAULTVIEW=TREE;SHOWALLINTREEVIEW=YES;CLEARMENUCACHE=1;OBJECTID=<MENU_CWAudioFolder>'
if SysCreateObject("CWMenuFolder", "Context menu for^Audio-CD Folder", "<CREATOR_CONFIG>",setupstring,"update")<>1 then
             do
                say ''
                say 'Menufolder not created.'
/*	     call createWizInst
	     exit*/
             end
setupstring='DEFAULTVIEW=TREE;SHOWALLINTREEVIEW=YES;OBJECTID=<SUBMENU_AWRITING>'
if SysCreateObject("CWMenuFolder", '~CD-Writing',"<MENU_CWAudioFolder>",setupstring,"update") = 1 then
             do
	setupstring='SHADOWID=<CD_WRITING>'
	if SysCreateObject("WPShadow", " ","<SUBMENU_AWRITING>",setupstring,"update")<>1 then
                say 'Menuitem 1 not created.'
	setupstring='SHADOWID=<CWCREATOR_SETTINGS>'
	if SysCreateObject("WPShadow", " ","<SUBMENU_AWRITING>",setupstring,"update")<>1 then
                say 'Menuitem 2 not created.'
	setupstring='SHADOWID=<CWCREATOR_TUTORIAL>'
	if SysCreateObject("WPShadow", " ","<SUBMENU_AWRITING>",setupstring,"update")<>1 then
                say 'Menuitem 3 not created.'
	setupstring='SHADOWID=<CD_COPY>'
	if SysCreateObject("WPShadow", " ","<SUBMENU_AWRITING>",setupstring,"update")<>1 then
                say 'Menuitem 4 not created.'
	end

/* Create the folder for user defined menu items for audio-folders */
/*rc=SysDestroyObject("<USERMENU_AUDIOFOLDER>")*/
setupstring='DEFAULTVIEW=TREE;SHOWALLINTREEVIEW=YES;CLEARMENUCACHE=1;HIDECLASSPAGE=1;OBJECTID=<USERMENU_AUDIOFOLDER>'
if SysCreateObject("CWMenuFolder", "User menu for^Audio-CD Folder", "<CREATOR_CONFIG>",setupstring,"update")<>1 then
             do
                say ''
                say 'Menufolder not created.'
/*	     call createWizInst
	     exit*/
             end
/* Fill the user menu with some default items */
setupstring='DEFAULTVIEW=TREE;SHOWALLINTREEVIEW=YES;OBJECTID=<USERMENU_AWRITING>'
if SysCreateObject("CWMenuFolder", '~CD-Writing',"<USERMENU_AUDIOFOLDER>",setupstring,"update") = 1 then
             do
		setupstring='SHADOWID=<CD_WRITING>'
		if SysCreateObject("WPShadow", " ","<USERMENU_AWRITING>",setupstring,"update")<>1 then
                	say 'Menuitem 1 not created.'
		setupstring='SHADOWID=<CWCREATOR_SETTINGS>'
		if SysCreateObject("WPShadow", " ","<USERMENU_AWRITING>",setupstring,"update")<>1 then
	           say 'Menuitem 2 not created.'
		setupstring='SHADOWID=<CWCREATOR_TUTORIAL>'
		if SysCreateObject("WPShadow", " ","<USERMENU_AWRITING>",setupstring,"update")<>1 then
                	say 'Menuitem 3 not created.'
		setupstring='SHADOWID=<CD_COPY>'
		if SysCreateObject("WPShadow", " ","<USERMENU_AWRITING>",setupstring,"update")<>1 then
                	say 'Menuitem 4 not created.'
	END
setupstring='DEFAULTVIEW=TREE;SHOWALLINTREEVIEW=YES;OBJECTID=<USERMENU_HOWTO>'
if SysCreateObject("CWMenuFolder", '~How to use this user menu',"<USERMENU_AUDIOFOLDER>",setupstring,"update") = 1 then
             do
		setupstring='EXENAME=help.cmd;PARAMETERS="'instDir'tutorial.inf" customization;MINIMIZED=YES'
		if SysCreateObject("WPProgram","~Open topic in tutorial","<USERMENU_HOWTO>",setupstring,"update")<>1 then
		do
                     		say 'Cannot create the object.'
           	end
		setupstring='EXENAME=e.exe;PARAMETERS="%*"'
		if SysCreateObject("WPProgram", "Show ~contents of file...","<USERMENU_HOWTO>",setupstring,"update")<>1 then
                	say 'Menuitem not created.'
		setupstring='SHADOWID=<USERMENU_AUDIOFOLDER>'
		if SysCreateObject("WPShadow", " ","<USERMENU_HOWTO>",setupstring,"update")<>1 then
                	say 'Menuitem not created.'
		setupstring='SHADOWID=<WPSWIZ_FOLDER>'
		if SysCreateObject("WPShadow", " ","<USERMENU_HOWTO>",setupstring,"update")<>1 then
                	say 'Menuitem not created.'
	end

setupstring='SHADOWID=<WPSWIZ_FOLDER>;OBJECTID=<CREATOR_SHADOW_WPSWIZ>'
if SysCreateObject("WPShadow", " ","<CREATOR_CONFIG>",setupstring,"update")<>1 then
               say 'Shadow to WPS-Wizard not created.'

/* Move menu folders to WPS-wizard config folder if not already done */
rc=SysMoveObject("<MENU_CWDataFolder>","<WPSWIZ_CONFIG>")
rc=SysMoveObject("<USERMENU_DATAFOLDER>","<WPSWIZ_CONFIG>")
rc=SysMoveObject("<MENU_CWAudioFolder>","<WPSWIZ_CONFIG>")
rc=SysMoveObject("<USERMENU_AUDIOFOLDER>","<WPSWIZ_CONFIG>")

setupstring='SHADOWID=<WPSWIZ_CONFIG>;OBJECTID=<WPSWIZ_CONFIG>_SHADOW>'
rc=SysCreateObject("WPShadow", " ","<CREATOR_CONFIG>",setupstring,"update")

rc=SysDestroyObject("<INST_WPSWIZADDON>")

if instObj=1 THEN DO
say ''
SAY '<ENTER> for exit.'
say '>'
parse value SysCurPos() with aktzeile aktspalte
newposition=SysCurPos(aktzeile-1,2)
pull taste 
END
exit

createWizInst:
/* parse source . .  thisfile
SAY thisfile */

IF instObj=1 THEN
DO

'cls'
SAY ''
SAY ''
SAY 'The WPS-Wizard Addon adds some additional menu items'
SAY 'to the contextmenus of the Data- and Audio-CD-Creator'
SAY 'classes if WPS-Wizard is installed.'
SAY ''
SAY 'WPS-Wizard is a WPS extension which gives you configurable'
SAY 'context menus for any filesystem object.'
SAY ''
SAY 'Do you want to visit the WPS-Wizard homepage now?'
SAY 'Type <y> to start netscape, any other key to continue.'

say ''
say '>'
parse value SysCurPos() with aktzeile aktspalte
newposition=SysCurPos(aktzeile-1,2)
pull taste
if TRANSLATE(taste)='Y' then do
	'start netscape.exe http://www.geocities.com/SiliconValley/Sector/5785/'
END

'cls'
SAY ''
SAY 'You may restart this installation object after WPS-Wizard is installed.'
SAY '<ENTER> for exit.'
SAY ''
say '>'
parse value SysCurPos() with aktzeile aktspalte
newposition=SysCurPos(aktzeile-1,2)
pull taste


END
ELSE DO
SAY 'Creating an object for WPS-Wizard addon installation...'
setupstring='EXENAME='curdir'\creatwiz.cmd;PARAMETERS=1;OBJECTID=<INST_WPSWIZADDON>;'
if SysCreateObject("WPProgram","Install WPS-Wizard Addon","<CREATOR_CONFIG>",setupstring,"update")<>1 then
		do
                     say 'Cannot create the object.'
            end
END

return
