home *** CD-ROM | disk | FTP | other *** search
- /*
- * This file is (C) Chris Wohlgemuth 1999
- */
- /*
- * 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.
- */
-
- #include "audiofolder.hh"
- #include "audiofolderhelp.h"
-
- #include <stdio.h>
- #include <string.h>//for memccpy()
- #include <stdlib.h>
-
-
- extern char chrImage[CCHMAXPATH];/* Path to iso-image */
- extern LONG lMKOptions;
- extern BOOL setupDone;
- extern char lnchParam[1024];
- extern char chrInstallDir[CCHMAXPATH];
-
- extern ATOM atomStartWrite;
-
-
-
- HMODULE queryModuleHandle(void);
-
-
- PSZ buildWrapName(PSZ wrapperName);
- ULONG launchWriter(PSZ parameter, PSZ folderPath,HWND hwnd, PSZ wrapperExe);
-
- ULONG launchMkisofs(HWND hwnd);
-
-
-
-
-
-
- /* This Proc also handles the data CD writing */
- MRESULT EXPENTRY mkisofsObjectProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
- {
- CWDataFolder * thisPtr;
-
- switch (msg)
- {
- case WM_APPTERMINATENOTIFY:
- thisPtr=(CWDataFolder*)WinQueryWindowULong(hwnd,QWL_USER);/* Get object ptr */
- if(thisPtr) {
- thisPtr->cwSetStatusText("");
- if(thisPtr->pvSharedMem) {/* We just created an image or wrote on the fly */
- if(!(LONGFROMMP(mp1))) {/* imageCreation */
- if(!(LONGFROMMP(mp2)))
- WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, "CD-ROM image file created. You may burn this file on a CDR now.",
- "Create image file.",
- 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
- else
- WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, "Error while creating the image file.",
- "Create image file.",
- 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
- }
- else {/* On the fly */
- if(!(LONGFROMMP(mp2)))
- WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, "CD-ROM successfully created.",
- "On the fly writing.",
- 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
- else
- WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, "Error while writing on the fly!",
- "On the fly writing",
- 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
- }
- }
- else {/* We wrote an image file */
- if(!(LONGFROMMP(mp2)))
- WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, "Image file written by CDRecord/2.",
- "Write image file.",
- 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
- else
- WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, "Error while writing the image file. Examine 'write.log.'",
- "Write image file.",
- 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
- }
- }
- WinPostMsg(hwnd,WM_QUIT,0,0);
- break;
- default:
- if(msg == atomStartWrite) {
- thisPtr=(CWDataFolder*)PVOIDFROMMP(mp1);
- WinSetWindowULong(hwnd,QWL_USER,(ULONG)thisPtr);/* Save object ptr */
- if(!thisPtr) {
- /* Error: quit */
- WinPostMsg(hwnd,WM_QUIT,(MPARAM)0,(MPARAM)0);
- return 0;
- }
- if(!mp2) {
- /* Start mkisofs */
- if(launchMkisofs(hwnd))
- WinPostMsg(hwnd,WM_QUIT,(MPARAM)0,(MPARAM)0);
- return FALSE;
- }
- else {
- if(LONGFROMMP(mp2)==1) {
- /* Start cdrecord */
- launchWriter(lnchParam, chrInstallDir, hwnd,"cdr2lnch.exe");
- return FALSE;
- }
- else {
- launchWriter("", chrInstallDir, hwnd,"onthefly.exe");
- return FALSE;
- }
- }
- }
- return WinDefWindowProc( hwnd, msg, mp1, mp2);
- }
- return FALSE;
- }
-
- /* This thread waits for the mkisofs process to end */
- void _Optlink mkisofsThreadFunc (void *arg)
- {
- HWND hwndMkisofs;
- HAB hab;
- HMQ hmq;
- QMSG qmsg;
-
- CWDataFolder * thisPtr;
-
- thisPtr=(CWDataFolder*)arg;
-
- hab=WinInitialize(0);
- if(hab) {
- hmq=WinCreateMsgQueue(hab,0);
- if(hmq) {
- hwndMkisofs=WinCreateWindow(HWND_OBJECT,WC_STATIC,"myMkisofsObj",0,0,0,0,0,NULL,HWND_BOTTOM,12341,NULL,NULL);
- if(hwndMkisofs) {
- WinSubclassWindow(hwndMkisofs,&mkisofsObjectProc);
- /* Window created. */
- WinPostMsg(hwndMkisofs,atomStartWrite,MPFROMP(thisPtr),0);
-
- thisPtr->cwSetStatusText(NULL);
-
- thisPtr->cwEnableWriteControls(FALSE);
- while(WinGetMsg(hab,&qmsg,(HWND)NULL,0,0))
- WinDispatchMsg(hab,&qmsg);
- WinDestroyWindow(hwndMkisofs);
- }
-
- WinDestroyMsgQueue(hmq);
- }
- WinTerminate(hab);
- }
- /* Free cmd-line mem */
- if(thisPtr->pvSharedMem) {
- DosFreeMem(thisPtr->pvSharedMem);
- thisPtr->pvSharedMem=0;
- }
- thisPtr->cwEnableWriteControls(TRUE);
- sprintf(thisPtr->chrStatusText,"");
- // DosBeep(100,2000);
- }
-
- /* This thread waits for the write process to end */
- void _Optlink imageWriteThreadFunc (void *arg)
- {
- HWND hwndMkisofs;
- HAB hab;
- HMQ hmq;
- QMSG qmsg;
- char text[CCHMAXPATH+100];
-
- CWDataFolder * thisPtr;
-
- thisPtr=(CWDataFolder*)arg;
-
- hab=WinInitialize(0);
- if(hab) {
- hmq=WinCreateMsgQueue(hab,0);
- if(hmq) {
- hwndMkisofs=WinCreateWindow(HWND_OBJECT,WC_STATIC,"myImageWriteObj",0,0,0,0,0,NULL,HWND_BOTTOM,12342,NULL,NULL);
- if(hwndMkisofs) {
- WinSubclassWindow(hwndMkisofs,&mkisofsObjectProc);
- /* Window created. */
- WinPostMsg(hwndMkisofs,atomStartWrite,MPFROMP(thisPtr),MPFROMLONG(1L));
- //sprintf(text,"Writing image file %s ...",chrImage);
- thisPtr->cwSetStatusText(NULL);
- thisPtr->cwEnableWriteControls(FALSE);
- while(WinGetMsg(hab,&qmsg,(HWND)NULL,0,0))
- WinDispatchMsg(hab,&qmsg);
- WinDestroyWindow(hwndMkisofs);
- }
- WinDestroyMsgQueue(hmq);
- }
- WinTerminate(hab);
- }
- thisPtr->cwEnableWriteControls(TRUE);
- sprintf(thisPtr->chrStatusText,"");
- // DosBeep(100,2000);
- }
-
- /* This thread waits for the mkisofs process to end */
- void _Optlink flyThreadFunc (void *arg)
- {
- HWND hwndMkisofs;
- HAB hab;
- HMQ hmq;
- QMSG qmsg;
- char text[CCHMAXPATH+100];
-
- CWDataFolder * thisPtr;
-
- thisPtr=(CWDataFolder*)arg;
-
- hab=WinInitialize(0);
- if(hab) {
- hmq=WinCreateMsgQueue(hab,0);
- if(hmq) {
- hwndMkisofs=WinCreateWindow(HWND_OBJECT,WC_STATIC,"myOnTheFlyWriteObj",0,0,0,0,0,NULL,HWND_BOTTOM,12343,NULL,NULL);
- if(hwndMkisofs) {
- WinSubclassWindow(hwndMkisofs,&mkisofsObjectProc);
- /* Window created. */
- WinPostMsg(hwndMkisofs,atomStartWrite,MPFROMP(thisPtr),MPFROMLONG(2L));
- sprintf(text,"Writing on the fly...");
- thisPtr->cwSetStatusText(NULL);
- thisPtr->cwEnableWriteControls(FALSE);
- while(WinGetMsg(hab,&qmsg,(HWND)NULL,0,0))
- WinDispatchMsg(hab,&qmsg);
- WinDestroyWindow(hwndMkisofs);
- }
- WinDestroyMsgQueue(hmq);
- }
- WinTerminate(hab);
- }
- thisPtr->cwEnableWriteControls(TRUE);
- sprintf(thisPtr->chrStatusText,"");
- /* Free cmd-line mem */
- if(thisPtr->pvSharedMem) {
- DosFreeMem(thisPtr->pvSharedMem);
- thisPtr->pvSharedMem=0;
- }
- // DosBeep(100,2000);
- }
-
-
-
-
-
-
-
-
-
-