home *** CD-ROM | disk | FTP | other *** search
- /*
- * 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>
-
- extern char chrImage[CCHMAXPATH];/* Path to iso-image */
- extern char chrCDRecord[CCHMAXPATH];/* Path to cdrecord */
- extern char chrCDROptions[CCHMAXPATH];
- extern char chrGrabberPath[CCHMAXPATH];
- extern LONG lCDROptions;
- extern char chrInstallDir[CCHMAXPATH];
- extern LONG lMKOptions;
- extern BOOL bMultiSessionDone;
- extern char chosenMultiSessionCD[3];
- extern char chrMkisofs[CCHMAXPATH];/* Path to mkisofs */
- extern char chrMkisofsOptions[CCHMAXPATH];
-
- HMODULE queryModuleHandle(void);
- void changeBackslash(char* text);
-
-
- PSZ buildWrapName(PSZ wrapperName);
- PSZ buildWriteParam(CWAudioFolder* thisPtr, PSZ trackname);
-
- PSZ buildWrapName(PSZ wrapperName)
- {
- char exename[CCHMAXPATH];
-
- /* Build full path */
- sprintf(exename,"%s\\%s",chrInstallDir,wrapperName);
- return exename;
- }
-
- void changeSpace(char* text)
- {
- char * chrPtr;
-
- chrPtr=strchr(text,' ');
-
- while(chrPtr!=NULL) {
- *chrPtr='^';
- chrPtr=strchr(text,' ');
- }
- }
-
- PSZ buildAudioWriteParam(CWAudioFolder* thisPtr, PSZ trackname)
- {
- char chrParams[CCHMAXPATH*2];
- ULONG ulWriteFlagsLocal;
-
- if(thisPtr)
- ulWriteFlagsLocal=thisPtr->cwQueryWriteFlags();
-
- sprintf(chrParams,"%s -audio",chrCDROptions);
- if(ulWriteFlagsLocal & IDWF_DUMMY)
- sprintf(chrParams,"%s -dummy",chrParams);
- if(ulWriteFlagsLocal & IDWF_PAD)
- sprintf(chrParams,"%s -pad",chrParams);
- if(thisPtr->bWrite+1 == thisPtr->aWrite) {
- if(ulWriteFlagsLocal & IDWF_NOFIX)
- sprintf(chrParams,"%s -nofix",chrParams);
- }
- else
- sprintf(chrParams,"%s -nofix",chrParams);/* -nofix for all but the last track */
- if(ulWriteFlagsLocal & IDWF_PREEMP)
- sprintf(chrParams,"%s -preemp",chrParams);
- /* The ' will be replaced with " in cdr2lnch.exe to allow spaces in track names.
- Included " are eaten by DosStartSession() so the track name would be broken.
- The ^ included by changeSpace() for every space (' ') in the track name is
- necessary because DosStartSession() seems to eat every space except one.
- */
- changeSpace(trackname);
- sprintf(chrParams,"%s \'%s\' ",chrParams,trackname);/* add track path to cmd-line */
- return chrParams;
- }
-
- void buildDataWriteParam(CWDataFolder* thisPtr, char * text)
- {
-
- ULONG ulWriteFlagsLocal;
-
- if(thisPtr)
- ulWriteFlagsLocal=thisPtr->cwQueryCDTypeFlags();
-
- /* Build cdrecord/2 cmd-line parameters */
- sprintf(text,chrCDROptions);//Cdrecord/2-options
- /* Check if we write a multisession CD */
- if( ulWriteFlagsLocal & IDCDT_MULTISESSION)
- strcat(text," -multi");//multisessionswitch
- else {
- /* We write a singlesession disk so give the right track type */
- if(ulWriteFlagsLocal & IDCDT_TRACKDATA)
- strcat(text," -data");
- if(ulWriteFlagsLocal & IDCDT_TRACKMODE2)
- strcat(text," -mode2");
- if(ulWriteFlagsLocal & IDCDT_TRACKXA1)
- strcat(text," -xa1");
- if(ulWriteFlagsLocal & IDCDT_TRACKXA2)
- strcat(text," -xa2");
- if(ulWriteFlagsLocal & IDCDT_TRACKCDI)
- strcat(text," -cdi");
- }
-
- return;
- }
-
-
- void buildMkisofsParam(CWDataFolder* thisPtr, char * text, char * outputName)
- {
- char *chrPtrParam;
- ULONG ulFlags;
- char filename[CCHMAXPATH];
- char * chrPtr;
- char * chrPtr2;
- ULONG ulSize;
- HWND hwnd;
- PMINIRECORDCORE mrc;
- WPObject * contentObject;
- LONG lValue1,lValue2;
-
- /* Build cmd-line for mkisofs */
- ulFlags=thisPtr->cwQueryMkisofsFlags();
- /* Path to mkisofs */
- strcat(text,chrMkisofs);
- strcat(text," ");
- //chrPtrParam=strchr(text,0);
- /* Additional options */
- strncat(text,chrMkisofsOptions,sizeof(chrMkisofsOptions));
- /* Filename options */
- if(ulFlags & IDMK_ALLOW32CHARS)
- strncat(text," -l",4);
- if(ulFlags & IDMK_LEADINGPERIODS)
- strncat(text," -L",4);
- if(ulFlags & IDMK_JOLIET)
- strncat(text," -J",4);
- if(ulFlags & IDMK_ROCKRIDGE)
- strncat(text," -r",4);
- if(ulFlags & IDMK_TRANSTABLE)
- strncat(text," -T",4);
- // if(ulFlags & IDMK_LOGFILE)
- // strncat(text," -log-filemkisofs.log",sizeof(" -log-filemkisofs.log"));
- /* Add the autor-stuff */
- if(strlen(thisPtr->chrApplication)) {
- strncat(text," -A",strlen(" -A"));
- strncat(text,thisPtr->chrApplication,strlen(thisPtr->chrApplication));
- }
- if(strlen(thisPtr->chrPublisher)) {
- strncat(text," -P",strlen(" -P"));
- strncat(text,thisPtr->chrPublisher,strlen(thisPtr->chrPublisher));
- }
- if(strlen(thisPtr->chrPreparer)) {
- strncat(text," -p",strlen(" -p"));
- strncat(text,thisPtr->chrPreparer,strlen(thisPtr->chrPreparer));
- }
- /* if(strlen(chrCopyright)) {
- strncat(text," -copyright",strlen(" -copyright"));
- strncat(text,chrCopyright,strlen(chrCopyright));
- }*/
-
-
- ulFlags=thisPtr->cwQueryCDTypeFlags();
- if((ulFlags & IDCDT_MULTISESSION) && !(ulFlags & IDCDT_FIRSTSESSION)) {
- /* We are building the second image of a multisession disk */
- /* Check if we did some setup stuff on the ms-page. Caution! Isn't bullet proof! */
- if(!bMultiSessionDone) {
- sprintf(text,"You have to provide some information on the 'CD-type selection' page prior to the creating \
- of multisession CDs!");
- WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
- text,
- "Imagefile creation error",
- 0UL, MB_OK | MB_ICONEXCLAMATION |MB_MOVEABLE);
- DosFreeMem(thisPtr->pvSharedMem);
- thisPtr->pvSharedMem=NULL;
- return;
- }
-
- /* Check if we have the necessary sectornumbers */
- lValue1=thisPtr->cwQueryPreviousStartSector();
- lValue2=thisPtr->cwQueryNextStartSector();
- if(lValue1==lValue2) {
- sprintf(text,"Need sector information of previous session. Go to the 'CD-type selection' page in \
- the settings notebook to supply it.");
- WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
- text,
- "Imagefile creation error",
- 0UL, MB_OK | MB_ICONEXCLAMATION |MB_MOVEABLE);
- DosFreeMem(thisPtr->pvSharedMem);
- thisPtr->pvSharedMem=NULL;
- return;
- }
- sprintf(filename," -C%d,%d",lValue1,lValue2);
- strncat(text,filename,strlen(filename));
-
- /* Check if we have a source drive for previous image */
- strncat(text," -M",4);
- if(ulFlags & IDCDT_USEWRITER) {
- /* We use the writer as source. Check if 'dev=x,y,z' is given as cdrecord options */
- chrPtr=strstr(chrCDROptions,"dev=");
- if(NULL==chrPtr) {
- sprintf(text,"There is no device given as a CD-writer . Go to the 'CD-type selection' page in \
- the settings notebook to chose a drive letter instead or go to the 'CDRecord/2' page to include a 'dev=x,y,z'-\
- statement in the options entryfield.");
- WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
- text,
- "Imagefile creation error",
- 0UL, MB_OK | MB_ICONEXCLAMATION |MB_MOVEABLE);
- DosFreeMem(thisPtr->pvSharedMem);
- thisPtr->pvSharedMem=NULL;
- return;
- }
- /* Find '=' in 'dev=...' statement */
- // chrPtr=strstr(chrCDROptions,"=");
- //chrPtr++;/* Get address of value for dev=... */
- /* Find end of 'dev=...' statement */
- chrPtr2=chrPtr;
- while(*chrPtr2!=' '&& *chrPtr2!=0)
- chrPtr2++;
- filename[0]=*chrPtr2;
- *chrPtr2=0;
- chrPtr=chrPtr2;
- /* Find begin of traget,lun */
- chrPtr-=3;
- /* Add dev=... statement to cmd-line */
- strncat(text,chrPtr,strlen(chrPtr));
- *chrPtr2=filename[0];
- }/* if(ulFlags & IDCDT_USEWRITER) */
- else {
- /* We use a drive letter as source drive */
- strncat(text,chosenMultiSessionCD,sizeof(chosenMultiSessionCD));
- }
- /* We have all information. Build the rest of the cmd-line */
- }/* end of if((ulFlags & IDCDT_MULTISESSION) && !(ulFlags & IDCDT_FIRSTSESSION)) */
- else {
-
- }
- if(outputName!=NULL) {
- /* Name of output file */
- strncat(text," -o",4);
- strncat(text,chrImage,sizeof(chrImage));
- }
- /*****************************/
- /* Query input files/folders */
- /*****************************/
- strncat(text," ",2);
- /* Find last space. It's the beginning of the file names */
- chrPtrParam=strrchr(text,' ');
-
- ulSize=sizeof(filename);
- /* Query name of this folder */
- if(!thisPtr->wpQueryRealName(filename,&ulSize,TRUE)) {
- sprintf(text,"Error while quering the foldername!");
- WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, text,"Image file creation",
- 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
- DosFreeMem(thisPtr->pvSharedMem);
- thisPtr->pvSharedMem=NULL;
- return;/* There's an error */
- }
- strncat(text,filename,ulSize);
-
- hwnd=WinQueryWindow(thisPtr->hwndMkisofsMain,QW_PARENT); // Get folder HWND
- /* Get hwnd of folder container */
- hwnd=WinWindowFromID(hwnd,FID_CLIENT);
- if(!WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP),hwnd)) {
- sprintf(text,"Error while quering the container HWND!");
- WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, text,"void CWDataFolder::cwCreateImage()",
- 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
- DosFreeMem(thisPtr->pvSharedMem);
- thisPtr->pvSharedMem=NULL;
- return;
- }
- mrc=(PMINIRECORDCORE)WinSendMsg(hwnd,CM_QUERYRECORD,NULL,
- MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
- if(!mrc){
- sprintf(text,"Error! The folder is empty!");
- WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, text,"Image file creation",
- 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
- DosFreeMem(thisPtr->pvSharedMem);
- thisPtr->pvSharedMem=NULL;
- return;
- }
-
- /* Enumerate folder contents. We only use filesystem objects. If we find a shadow we follow
- the link and use the linked object if it's a filesystem object */
- while(mrc) {
- /* Get wps-object-ptr. from container item */
- contentObject=(WPObject*)OBJECT_FROM_PREC(mrc);//Get object
- if(contentObject) {
- /* Check if it's a shadow */
- if(somResolveByName(contentObject,"wpQueryShadowedObject"))
- /* Yes, it's a shadow. Get file system object or NULL */
- contentObject=thisPtr->cwGetFileSystemObject(contentObject);
- else
- /* It's no shadow, so do nothing. If it's a filesystem object it's included in our list
- because we yet provide this folder as input directory. If it's any other object (abstract)
- mkisofs will skip it because it uses the filesystem for querying directory contents. */
- contentObject=NULL;
- }
- if(contentObject){
- /* It's a file system object */
- strncat(text," ",2);
- /* Check if it's folder */
- if(somResolveByName(contentObject,"wpQueryContent")) {
- /* It's a folder. Query the name. */
- ulSize=sizeof(filename);
- ((WPFileSystem*)contentObject)->wpQueryRealName(filename,&ulSize,FALSE);
- /* Add the graft point to the command line. If not done, mkisofs will include the contents of
- of the folder in the image, not the folder itself */
- if((strlen(text)+strlen(filename)+2)>=SHAREDMEM_SIZE) {
- sprintf(text,"Error! The length of the cmd-line exceeds %d Bytes!!\n",SHAREDMEM_SIZE);
- WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, text,"Image file creation",
- 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
- DosFreeMem(thisPtr->pvSharedMem);
- thisPtr->pvSharedMem=NULL;
- return;
- }
- strncat(text,filename,ulSize);
- strncat(text,"/=",2);
- }
- /* Query the full path */
- ulSize=sizeof(filename);
- ((WPFileSystem*)contentObject)->wpQueryRealName(filename,&ulSize,TRUE);
- /* Add the name to the command line */
- if((strlen(text)+strlen(filename)+2)>=SHAREDMEM_SIZE) {
- sprintf(text,"Error! The length of the cmd-line exceeds %d Bytes!!\n",SHAREDMEM_SIZE);
- WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, text,"Image file creation",
- 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
- DosFreeMem(thisPtr->pvSharedMem);
- thisPtr->pvSharedMem=NULL;
- return;
- }
- strncat(text,filename,ulSize);
- }/* end of if(contentObject) */
- /* Get next container item */
- mrc=(PMINIRECORDCORE)WinSendMsg(hwnd,CM_QUERYRECORD,MPFROMP(mrc),
- MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
- }// end of while(mrc)
-
- /* Change backslashs in sourcefiles */
- changeBackslash(chrPtrParam);
- return;
- }
-
- /* This function launches the writer with the params given */
- /* in PSZ parameter. PSZ folderPath is the path to put the */
- /* write.log. HWND hwnd is the window waiting for the */
- /* WM_APPTERMINATE message */
- ULONG launchWriter(PSZ parameter, PSZ folderPath,HWND hwnd, PSZ wrapperExe)
- {
- STARTDATA startData={0};
- APIRET rc;
- PID pid;
- ULONG ulSessionID=0;
- PSZ pszTitle="Write CD";
- char chrLoadError[CCHMAXPATH];
- char startParams[CCHMAXPATH*4];
- char exename[CCHMAXPATH]={0};
-
- memset(&startData,0,sizeof(startData));
- startData.Length=sizeof(startData);
- //startData.Related=SSF_RELATED_CHILD;
- startData.Related=SSF_RELATED_INDEPENDENT;
- startData.FgBg=SSF_FGBG_FORE;
- startData.TraceOpt=SSF_TRACEOPT_NONE;
- startData.PgmTitle=pszTitle;
-
- // sprintf(exename,"%s",buildWrapName("cdr2lnch.exe"));
- sprintf(exename,"%s",buildWrapName(wrapperExe));
-
- startData.PgmName=exename;
- startData.InheritOpt=SSF_INHERTOPT_SHELL;
- startData.SessionType=SSF_TYPE_WINDOWABLEVIO;
- startData.PgmControl=0;
- if(lCDROptions&IDCDR_HIDEWINDOW)
- startData.PgmControl|=SSF_CONTROL_INVISIBLE;//|SSF_CONTROL_MAXIMIZE|SSF_CONTROL_NOAUTOCLOSE;
- if(!(lCDROptions&IDCDR_CLOSEWINDOW))
- startData.PgmControl|=SSF_CONTROL_NOAUTOCLOSE;
- startData.InitXPos=30;
- startData.InitYPos=30;
- startData.InitXSize=500;
- startData.InitYSize=400;
- startData.ObjectBuffer=chrLoadError;
- startData.ObjectBuffLen=(ULONG)sizeof(chrLoadError);
- sprintf(startParams,"%d %s %s %s",hwnd,chrCDRecord,folderPath ,parameter);
- startData.PgmInputs=startParams;
-
- rc=DosStartSession(&startData,&ulSessionID,&pid);
- return 0;
- }
-
-
- ULONG launchMsInfo(HWND hwnd)
- {
- /* hwnd: notification window
-
- msinfo.exe sends a WM_APPTERMINATIONNOTIFY msg to that window which contains in mp1/mp2 the
- two numbers necessary for creating of the second session.
- The correct cmd-line for calling cdrecord/2 is build by msinfo. So we supply only the generic
- cdrecord/2 information.
- */
-
- STARTDATA startData={0};
- APIRET rc;
- PID pid;
- ULONG ulSessionID=0;
- PSZ pszTitle="Query multisession info";
- char chrLoadError[CCHMAXPATH];
- char startParams[CCHMAXPATH*4];
- char exename[CCHMAXPATH]={0};
-
- memset(&startData,0,sizeof(startData));
- startData.Length=sizeof(startData);
- startData.Related=SSF_RELATED_INDEPENDENT;
- startData.FgBg=SSF_FGBG_BACK;
- startData.TraceOpt=SSF_TRACEOPT_NONE;
- startData.PgmTitle=pszTitle;
-
- sprintf(exename,"%s",buildWrapName("msinfo.exe"));
- startData.PgmName=exename;
- startData.InheritOpt=SSF_INHERTOPT_SHELL;
- startData.SessionType=SSF_TYPE_WINDOWABLEVIO;
- startData.PgmControl=SSF_CONTROL_INVISIBLE;//|SSF_CONTROL_MAXIMIZE|SSF_CONTROL_NOAUTOCLOSE;
- startData.InitXPos=30;
- startData.InitYPos=30;
- startData.InitXSize=500;
- startData.InitYSize=400;
- startData.ObjectBuffer=chrLoadError;
- startData.ObjectBuffLen=(ULONG)sizeof(chrLoadError);
- sprintf(startParams,"%d %s %s",hwnd, chrCDRecord, chrCDROptions);
- startData.PgmInputs=startParams;
- rc=DosStartSession(&startData,&ulSessionID,&pid);
- return 0;
- }
-
- ULONG launchGrabber(PSZ parameter, PSZ folderPath,HWND hwnd)
- {
- STARTDATA startData={0};
- APIRET rc;
- PID pid;
- ULONG ulSessionID=0;
- PSZ pszTitle="Grab tracks";
- char chrLoadError[CCHMAXPATH];
- char startParams[CCHMAXPATH*4];
- char exename[CCHMAXPATH]={0};
-
- memset(&startData,0,sizeof(startData));
- startData.Length=sizeof(startData);
- //startData.Related=SSF_RELATED_CHILD;
- startData.Related=SSF_RELATED_INDEPENDENT;
- startData.FgBg=SSF_FGBG_BACK;
- startData.TraceOpt=SSF_TRACEOPT_NONE;
- startData.PgmTitle=pszTitle;
-
- sprintf(exename,"%s",buildWrapName("wrapper.exe"));
- startData.PgmName=exename;
- startData.InheritOpt=SSF_INHERTOPT_SHELL;
- startData.SessionType=SSF_TYPE_WINDOWABLEVIO;
- startData.PgmControl=SSF_CONTROL_INVISIBLE;//|SSF_CONTROL_MAXIMIZE|SSF_CONTROL_NOAUTOCLOSE;
- startData.InitXPos=30;
- startData.InitYPos=30;
- startData.InitXSize=500;
- startData.InitYSize=400;
- startData.ObjectBuffer=chrLoadError;
- startData.ObjectBuffLen=(ULONG)sizeof(chrLoadError);
- sprintf(startParams,"%d %s %s %s",hwnd,chrGrabberPath,folderPath ,parameter);
- startData.PgmInputs=startParams;
-
- rc=DosStartSession(&startData,&ulSessionID,&pid);
- return 0;
- }
-
-
- ULONG launchMkisofs(HWND hwnd)
- {
- /* hwnd: notification window
-
- */
-
- STARTDATA startData={0};
- APIRET rc;
- PID pid;
- ULONG ulSessionID=0;
- PSZ pszTitle="Create ISO-Image";
- char chrLoadError[CCHMAXPATH];
- char startParams[CCHMAXPATH*4];
- char exename[CCHMAXPATH]={0};
-
- memset(&startData,0,sizeof(startData));
- startData.Length=sizeof(startData);
- startData.Related=SSF_RELATED_INDEPENDENT;
- startData.FgBg=SSF_FGBG_FORE;
- startData.TraceOpt=SSF_TRACEOPT_NONE;
- startData.PgmTitle=pszTitle;
-
- sprintf(exename,"%s",buildWrapName("lnchmkis.exe"));
- startData.PgmName=exename;
- startData.InheritOpt=SSF_INHERTOPT_SHELL;
- startData.SessionType=SSF_TYPE_WINDOWABLEVIO;
- startData.PgmControl=0;
- if(lMKOptions&IDMK_HIDEWINDOW)
- startData.PgmControl|=SSF_CONTROL_INVISIBLE;
- if(!(lMKOptions&IDMK_CLOSEWINDOW))
- startData.PgmControl|=SSF_CONTROL_NOAUTOCLOSE;//|SSF_CONTROL_MAXIMIZE|SSF_CONTROL_NOAUTOCLOSE;
- startData.InitXPos=30;
- startData.InitYPos=30;
- startData.InitXSize=500;
- startData.InitYSize=400;
- startData.ObjectBuffer=chrLoadError;
- startData.ObjectBuffLen=(ULONG)sizeof(chrLoadError);
- sprintf(startParams,"%d",hwnd);
- startData.PgmInputs=startParams;
- rc=DosStartSession(&startData,&ulSessionID,&pid);
- return rc;
- }
-
-
-
-
-
-
-
-
-
-
-