/*                 Create the default WPFolder config folder
 *
 *                   (C) Chris Wohlgemuth 2001
*/

/*
 * 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)
/*say 'Installation directory is '||instDir
*/

/* Create a context menu folder for Data-CD-Creator */
say 'Creating menufolder for Data-CD-Creator class...'
rc=SysDestroyObject("<MENU_CWDataFolder>")
setupstring='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='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='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='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='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='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='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='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='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.'

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 for 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
