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.
- */
-
- #define INCL_DOSQUEUES
- #include "audiofolder.hh"
- #include "audiofolderhelp.h"
- #include <stdio.h>
- #include <stdlib.h>
- #include <wpshadow.hh>
- #include <string.h>
-
- extern BOOL setupDone;
- extern BOOL GrabberSetupDone;
-
- extern int iNumCD;
- extern char cFirstCD;
- extern char chosenCD[3];
- extern char chrGrabberPath[CCHMAXPATH];
- extern char chrGrabberOptions[CCHMAXPATH];
- extern int bTrackNumbers;
-
-
- extern char chrCDRecord[CCHMAXPATH];/* Path to cdrecord */
- extern char chrCDROptions[CCHMAXPATH];
-
-
- extern ATOM atomUpdateStatusbar;
- extern ATOM atomStartGrab;
- extern ATOM atomStartWrite;
-
- typedef struct
- {
- USHORT cb;
- CWAudioFolder* thisPtr;
- }WCNTRLDATA;
-
-
-
- HFILE openDrive(char * drive);
- void closeDrive(HFILE hfDrive);
- ULONG queryAudioCDTracks(HFILE hfDrive);
- MRESULT EXPENTRY CDToolsDlgProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
- MRESULT EXPENTRY trackDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
- LONG queryFreeDriveSpace(ULONG diskNum);
- LONG CDQueryTrackSize(ULONG numTrack, char * drive);
- PSZ buildWrapperName();
- ULONG launchGrabber(PSZ parameter, PSZ folderPath,HWND hwnd);
- MRESULT EXPENTRY grabberOptionDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) ;
- MRESULT EXPENTRY cdrecordOptionDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) ;
-
- /* Local */
- HMODULE queryModuleHandle(void);
- PSZ buildGrabberParam(int numTrack,PSZ trackname);
- MRESULT EXPENTRY grabStatusDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
- MRESULT EXPENTRY grabObjectProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
-
- /* This function returns the module handle of our class-dll */
- HMODULE queryModuleHandle(void)
- {
- static HMODULE hmod=0;
-
- if(!hmod) {
- PSZ pathname=SOMClassMgrObject //Query Pathname of class file
- ->somLocateClassFile(somIdFromString("CWAudioFolder"),1,2);
- DosQueryModuleHandle(pathname,&hmod); //Query module handle
- }
- return hmod;
- }
-
- PSZ buildGrabberParam(int numTrack,PSZ trackname)
- {
- char parameter[CCHMAXPATH*2];
- char *charPtr;
- char *charPtr2;
-
- // sprintf(statusText,"Grab tracks message");
- // WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, chrGrabberPath, chrGrabberOptions, 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
- // return "";
-
- /* Build commandline */
- charPtr=strchr(chrGrabberOptions,'%');
- if(charPtr) {
- /* There is a var */
- *charPtr=0;/* String splitten */
- sprintf(parameter,"%s",chrGrabberOptions);
-
- *charPtr='%';
- charPtr++;/* Parameter */
- if(*charPtr=='1')
- /* replace var with cd-drive letter */
- sprintf(parameter,"%s%c",parameter,chosenCD[0]);
- else
- /* replace var with tracknum */
- sprintf(parameter,"%s%d",parameter,numTrack);
- /* check rest of line */
- charPtr++;
- /* find second var */
- charPtr2=strchr(charPtr,'%');
- if(!charPtr2)
- /* No second parameter */
- sprintf(parameter,"%s%s",parameter,charPtr);
- else {
- *charPtr2=0;/* String splitten */
- sprintf(parameter,"%s%s",parameter,charPtr);
- *charPtr2='%';
- charPtr2++;
- if(*charPtr2=='1')
- /* replace var with cd-drive letter */
- sprintf(parameter,"%s%c",parameter,chosenCD[0]);
- else
- /* replace var with tracknum */
- sprintf(parameter,"%s%d",parameter,numTrack);
- charPtr2++;
- sprintf(parameter,"%s%s",parameter,charPtr2);
- }
- }
-
- /* append filename */
- /* check trackname for extension */
- if(bTrackNumbers) {
- /* Find last dot */
- charPtr=strrchr(trackname,'.');
- if(charPtr) {
- /* We have an extension */
- *charPtr=0; /* split string */
- charPtr++;
- if(numTrack<10)
- sprintf(parameter,"%s %s0%d.%s",parameter,trackname,numTrack,charPtr);/* insert tracknum */
- else
- sprintf(parameter,"%s %s%d.%s",parameter,trackname,numTrack,charPtr);/* insert tracknum */
- }
- else {
- /* No extension */
- if(numTrack<10)
- sprintf(parameter,"%s %s0%d",parameter,trackname,numTrack);/* append trackname */
- else
- sprintf(parameter,"%s %s%d",parameter,trackname,numTrack);/* append trackname */
- }
- }
- else {
- /* No tracknumbers */
- sprintf(parameter,"%s %s",parameter,trackname);
- }
- /* commandline is ready */
- return parameter;
- }
-
-
-
- MRESULT EXPENTRY grabStatusDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
- {
- CWAudioFolder * thisPtr;
-
- switch(msg)
- {
- case WM_INITDLG :
- WinSetWindowULong(hwnd,QWL_USER,(ULONG)PVOIDFROMMP(mp2));//Save object ptr.
- thisPtr=(CWAudioFolder*) PVOIDFROMMP(mp2);
- return (MRESULT) TRUE;
- case WM_HELP:
- thisPtr=(CWAudioFolder*) WinQueryWindowULong(hwnd,QWL_USER);
- thisPtr->wpDisplayHelp(IDDLG_GRABSTATUS, AFHELPLIBRARY);
-
- break;
- case WM_CLOSE:
- thisPtr=(CWAudioFolder*) WinQueryWindowULong(hwnd,QWL_USER);
- if(thisPtr->tid)
- /* We are currently grabbing, so hide the window */
- WinShowWindow(hwnd,FALSE);
- else
- WinPostMsg(hwnd,WM_QUIT,0,0);
- return 0;
- case WM_DESTROY:
- /* The dialog closes and gets destroyed */
- thisPtr=(CWAudioFolder*) WinQueryWindowULong(hwnd,QWL_USER);
- if(thisPtr){
- //thisPtr->wpSaveDeferred();
- }
- break;
- case WM_COMMAND:
- switch(SHORT1FROMMP(mp1))
- {
- case IDPB_BREAK:
- DosBeep(1000,100);
- thisPtr=(CWAudioFolder*) WinQueryWindowULong(hwnd,QWL_USER);
- thisPtr->cwEnableGrab(FALSE);
- WinEnableWindow(WinWindowFromID(hwnd,IDPB_BREAK),FALSE);
- break;
- case IDPB_ABORT:
- DosBeep(5000,300);
- break;
- default:
- break;
- }
- return (MRESULT) TRUE;
- default:
- break;
- }
- return WinDefDlgProc(hwnd, msg, mp1, mp2);
- }
-
- MRESULT EXPENTRY grabObjectProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
- {
- CWAudioFolder * thisPtr;
- SHORT a;
- SIZEL sizel;
- ULONG ulFlags;
- HWND hwndGrab;
- char text[CCHMAXPATH];
- char parameter[CCHMAXPATH*2];
- char folderName[CCHMAXPATH];
- HWND hwndTemp;
- ULONG ulSize;
- ULONG rc;
- char statusText[100];
- ULONG ulDrive;
-
- switch (msg)
- {
- case WM_APPTERMINATENOTIFY:
- rc=MBID_YES;
- if(LONGFROMMP(mp2)!=0) {
- if(!WinLoadString(WinQueryAnchorBlock(hwnd),queryModuleHandle(),IDSTR_GRABBERERRORTEXT,sizeof(text),text))
- sprintf(text,"Grabber returned a Non-zero resultcode. The grabbed track is probably corrupted. \
- Do you want to continue grabbing?");
- if(!WinLoadString(WinQueryAnchorBlock(hwnd),queryModuleHandle(),IDSTR_GRABBERERRORTITLE, sizeof(statusText),
- statusText))
- sprintf(statusText,"Grabber error!");
- rc=WinMessageBox( HWND_DESKTOP, hwnd, text, statusText, 0UL, MB_YESNO | MB_ICONEXCLAMATION|MB_MOVEABLE );
- }
- thisPtr=(CWAudioFolder*) WinQueryWindowULong(hwnd,QWL_USER);
- /* Update statusbar */
- if(thisPtr)
- thisPtr->cwForceStatusUpdate();
- if(thisPtr && rc==MBID_YES) {
- /* Continue Grabbing */
- hwndGrab=thisPtr->hwndGrab;/* Get grab dialog hwnd */
- if(thisPtr->cwQueryGrabEnabled()) {
- thisPtr->a=(int)WinSendMsg(WinWindowFromID(hwndGrab,IDLB_GRABTRACKS),LM_QUERYSELECTION,MPFROMSHORT(thisPtr->a),0);
- if(thisPtr->a!=LIT_NONE) {
- hwndTemp=thisPtr->cwQueryFrameCtl(WinQueryWindow(hwndGrab,QW_PARENT), &sizel,FCTL_TOP, &ulFlags);
- thisPtr->b++;
- /*********** Build commandline ******************/
- /* Get trackname */
- WinQueryWindowText( WinWindowFromID(hwndTemp,IDEF_TRACKNAME),sizeof(parameter),parameter);
-
- /* Get folder name */
- ulSize=sizeof(folderName);
- thisPtr->wpQueryRealName(folderName,&ulSize,TRUE);
- ulDrive=folderName[0]-'A'+1;/* Build drive num */
-
- /* Build full trackname */
- sprintf(text,"%s\\%s",folderName,parameter);
-
- /* Build grabber param line */
- sprintf(parameter,"%s",buildGrabberParam(thisPtr->a+1,text));
-
-
- /*************** Start the grabber here ****************/
-
- /* Build status window */
- sprintf(statusText,"Grabbing track %d of %d ",thisPtr->b,thisPtr->numTracks);
- WinSetWindowText(WinWindowFromID(thisPtr->hwndStatus,IDST_GRABSTATUS),statusText);
-
-
- if(CDQueryTrackSize(thisPtr->a+1,chosenCD)+44 > queryFreeDriveSpace(ulDrive)){/* 44 bytes for waveheader */
- if(!WinLoadString(WinQueryAnchorBlock(hwnd),queryModuleHandle(),IDSTR_NOGRABSPACETEXT,sizeof(text),text))
- sprintf(text,"Not enough free space on destination drive.");
- if(!WinLoadString(WinQueryAnchorBlock(hwnd),queryModuleHandle(),IDSTR_NOTRACKSSELECTEDTITLE, sizeof(statusText),
- statusText))
- sprintf(statusText,"Grab tracks message");
- WinMessageBox( HWND_DESKTOP, hwnd, text, statusText, 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
- }
- else {
- launchGrabber(parameter,folderName,hwnd);
- return (MRESULT)TRUE;
- }
- }
- }/* thisPtr->cwQueryGrabEnabled() */
- }/* end of if(thisPtr) */
- if(thisPtr) {
- // WinSendMsg(thisPtr->hwndStatus,WM_CLOSE,0,0);
- WinDestroyWindow(thisPtr->hwndStatus);
-
- /* Enable windows in grab dialog */
- thisPtr->cwEnableGrabControls(TRUE);
-
- /* Enable windows in selection dialog */
- thisPtr->cwEnableSelectControls(TRUE);
- }
- WinPostMsg(hwnd,WM_QUIT,(MPARAM)0,(MPARAM)0);
- return 0;
- default:
- if(msg == atomStartGrab) {
- /* Start grab message */
- thisPtr=(CWAudioFolder*)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;
- }
-
- hwndGrab=thisPtr->hwndGrab;
- thisPtr->a=SHORT1FROMMR(WinSendMsg(WinWindowFromID(hwndGrab,IDLB_GRABTRACKS),LM_QUERYSELECTION,MPFROMSHORT(LIT_FIRST),0));
- if(thisPtr->a==LIT_NONE) {
- WinPostMsg(hwnd,WM_QUIT,(MPARAM)0,(MPARAM)0);
- return 0;
- }
- /* sprintf(text,"hwndGrab=%x",hwndGrab);
- WinMessageBox( HWND_DESKTOP, hwnd, text, "Debug", 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );*/
- if(!hwndGrab) {
- WinPostMsg(hwnd,WM_QUIT,(MPARAM)0,(MPARAM)0);
- return 0;
- }
-
- hwndTemp=thisPtr->cwQueryFrameCtl(WinQueryWindow(hwndGrab,QW_PARENT), &sizel,FCTL_TOP, &ulFlags);
- thisPtr->cwEnableGrab(TRUE);
-
- /* Count selected files */
- a=SHORT1FROMMR(WinSendMsg(WinWindowFromID(hwndGrab,IDLB_GRABTRACKS),LM_QUERYSELECTION,MPFROMSHORT(LIT_FIRST),0));
- thisPtr->numTracks=0;
- do {
- if(a!=LIT_NONE) {
- thisPtr->numTracks++;
- a=SHORT1FROMMR(WinSendMsg(WinWindowFromID(hwndGrab,IDLB_GRABTRACKS),LM_QUERYSELECTION,MPFROMSHORT(a),0));
- /* sprintf(text,"numTracks=%x a=%x",thisPtr->numTracks,a);
- WinMessageBox( HWND_DESKTOP, hwnd, text, "Debug", 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
- if(thisPtr->numTracks==10) {
- WinPostMsg(hwnd,WM_QUIT,(MPARAM)0,(MPARAM)0);
- return 0;
- }*/
- }
- }
- while(a!=LIT_NONE);
- /* sprintf(text,"numTracks=%x",thisPtr->numTracks);
- WinMessageBox( HWND_DESKTOP, hwnd, text, "Debug", 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
- WinPostMsg(hwnd,WM_QUIT,(MPARAM)0,(MPARAM)0);
- return 0;*/
-
- thisPtr->b=1;
-
- /*********** Build commandline ******************/
- /* Get trackname */
- WinQueryWindowText( WinWindowFromID(hwndTemp,IDEF_TRACKNAME),sizeof(parameter),parameter);
- /* Get folder name */
- ulSize=sizeof(folderName);
- thisPtr->wpQueryRealName(folderName,&ulSize,TRUE);
- ulDrive=folderName[0]-'A'+1;/* Build drive num */
- /* Build full trackname */
- sprintf(text,"%s\\%s",folderName,parameter);
- /* Build grabber param line */
- sprintf(parameter,"%s",buildGrabberParam(thisPtr->a+1,text));
-
- /* Add redirection of stdout, stderr.*/
- //sprintf(parameter,"%s 2>>%s\\grab.log 1>>&2",parameter,folderName);
-
- /*************** Start the grabber here ****************/
- /* Build status window */
-
- thisPtr->hwndStatus=WinLoadDlg(HWND_DESKTOP,HWND_DESKTOP,
- grabStatusDialogProc,queryModuleHandle(),IDDLG_GRABSTATUS,thisPtr);
-
- sprintf(statusText,"Grabbing track %d of %d ",thisPtr->b,thisPtr->numTracks);
- WinSetWindowText(WinWindowFromID(thisPtr->hwndStatus,IDST_GRABSTATUS),statusText);
-
-
- if(CDQueryTrackSize(thisPtr->a+1,chosenCD)+44 > queryFreeDriveSpace(ulDrive)){/* 44 bytes for waveheader */
- if(!WinLoadString(WinQueryAnchorBlock(hwnd),queryModuleHandle(),IDSTR_NOGRABSPACETEXT,sizeof(text),text))
- sprintf(text,"Not enough free space on destination drive.");
- if(!WinLoadString(WinQueryAnchorBlock(hwnd),queryModuleHandle(),IDSTR_NOTRACKSSELECTEDTITLE, sizeof(statusText),
- statusText))
- sprintf(statusText,"Grab tracks message");
- WinMessageBox( HWND_DESKTOP, hwnd, text, statusText, 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
-
-
- WinDestroyWindow(thisPtr->hwndStatus);
- /* Enable windows in grab dialog */
- thisPtr->cwEnableGrabControls(TRUE);
- /* Enable windows in selection dialog */
- thisPtr->cwEnableSelectControls(TRUE);
- WinPostMsg(hwnd,WM_QUIT,(MPARAM)0,(MPARAM)0);
- return 0;
- }
- launchGrabber(parameter,folderName,hwnd);
- /* end of grabber start */
- return 0;
- }
- break;
- }
- return WinDefWindowProc( hwnd, msg, mp1, mp2);
- }
-
- /* This thread handles the audio grabbing */
- void _Optlink grabThreadFunc (void *arg)
- {
- HWND hwndGrab;
- HAB hab;
- HMQ hmq;
- QMSG qmsg;
- //HWND hwnd;
- CWAudioFolder * thisPtr;
-
- thisPtr=(CWAudioFolder*)arg;
- thisPtr->wpLockObject();
-
- hab=WinInitialize(0);
- if(hab) {
- hmq=WinCreateMsgQueue(hab,0);
- if(hmq) {
- hwndGrab=WinCreateWindow(HWND_OBJECT,WC_STATIC,"myObj",0,0,0,0,0,NULL,HWND_BOTTOM,1234,NULL,NULL);
- if(hwndGrab) {
- WinSubclassWindow(hwndGrab,&grabObjectProc);
- /* audio grab window created. Start grabbing */
- WinPostMsg(hwndGrab,atomStartGrab,MPFROMP(thisPtr),0);
- while(WinGetMsg(hab,&qmsg,(HWND)NULL,0,0))
- WinDispatchMsg(hab,&qmsg);
- WinDestroyWindow(hwndGrab);
- }
- WinDestroyMsgQueue(hmq);
- }
- WinTerminate(hab);
- }
- thisPtr->wpUnlockObject();
- thisPtr->tid=0;
- // DosBeep(100,2000);
- }
-
-
- /******************************************************/
- /* This function checks if the object is a wave file. */
- /* It only checks the extension because cdrecord */
- /* doesn't know types and needs the extension to */
- /* distinguish between wavefiles and raw data files. */
- /******************************************************/
- BOOL CWAudioFolder::cwIsWaveFile(WPObject* wpObject)
- {
- char objectName[CCHMAXPATH];
- ULONG ulNameSize;
- char* chrExtension;
-
- if(!somResolveByName(wpObject,"wpQueryRealName"))
- /* It's not a file system object */
- return FALSE;
-
- /* Check if it's folder */
- if(somResolveByName(wpObject,"wpQueryContent"))
- /* It's a folder */
- return FALSE;
-
- /* Check the extension */
- ulNameSize=sizeof(objectName);
- ((WPFileSystem*)wpObject)->wpQueryRealName(objectName,&ulNameSize,FALSE);
- chrExtension=strstr(strlwr(objectName),".wav");
- if(chrExtension)
- if(*(chrExtension+4)==0)return TRUE;//It's a wavefile
-
- return FALSE;
- }
-
- /* This thread handles the CDTools-dialog */
- void _Optlink toolsThreadFunc (void *arg)
- {
- HWND hwndTools;
- HAB hab;
- HMQ hmq;
- QMSG qmsg;
- CWAudioFolder *thisPtr;
-
- thisPtr=(CWAudioFolder*)arg; //Pointer auf CWAudioFolder-Object
- hab=WinInitialize(0);
- if(hab) {
- hmq=WinCreateMsgQueue(hab,0);
- if(hmq) {
- hwndTools=WinLoadDlg(HWND_DESKTOP,HWND_DESKTOP,CDToolsDlgProc,queryModuleHandle(),IDDLG_CDRTOOLS,thisPtr);
- if(hwndTools) {
- /* CDR tools window created */
- while(WinGetMsg(hab,&qmsg,(HWND)NULL,0,0))
- WinDispatchMsg(hab,&qmsg);
- WinDestroyWindow(hwndTools);
- }
- WinDestroyMsgQueue(hmq);
- }
- WinTerminate(hab);
- }
- // DosBeep(100,2000);
- }
-
- /********************************************************/
- /* New class function which inserts the Cdrecord option */
- /* page into the settings notebook */
- /********************************************************/
- BOOL CWAudioFolder::AddCdrecordOptionPage(HWND hwndNotebook)
- {
- PAGEINFO pageinfo;
-
- //Clear the pageinfo structure
- memset((PCH)&pageinfo, 0, sizeof(PAGEINFO));
- //Fill the pageinfo structure
- pageinfo.cb = sizeof(PAGEINFO);
- pageinfo.hwndPage = NULLHANDLE;
- pageinfo.usPageStyleFlags = BKA_MAJOR | BKA_STATUSTEXTON;
- pageinfo.usPageInsertFlags = BKA_FIRST;
- //We want page numbers
- pageinfo.usSettingsFlags = SETTINGS_PAGE_NUMBERS;
- //The dialog procedure for this page
- pageinfo.pfnwp = cdrecordOptionDlgProc;
- //The resource is in the class file
- pageinfo.resid = queryModuleHandle();
- //The ID of the dialog template
- pageinfo.dlgid = IDDLG_CDRECORDSETUP;
- //We need a pointer to our WPS-object in the dialog procedure
- //to call class functions
- pageinfo.pCreateParams = this;
- //The ID of the help panel for this page
- pageinfo.idDefaultHelpPanel = IDDLG_CDRECORDSETUP;
- //Tell the WPS the help library name
- pageinfo.pszHelpLibraryName = AFHELPLIBRARY;
- //We have a major tab so we need a name
- pageinfo.pszName = "CDRecord/2 options";
-
- //Insert the page into the settings notebook
- return wpInsertSettingsPage(hwndNotebook,&pageinfo);
- }
-
- /********************************************************/
- /* New class function which inserts the Grabber option */
- /* page into the settings notebook */
- /********************************************************/
- BOOL CWAudioFolder::AddGrabOptionPage(HWND hwndNotebook)
- {
- PAGEINFO pageinfo;
-
- //Clear the pageinfo structure
- memset((PCH)&pageinfo, 0, sizeof(PAGEINFO));
- //Fill the pageinfo structure
- pageinfo.cb = sizeof(PAGEINFO);
- pageinfo.hwndPage = NULLHANDLE;
- pageinfo.usPageStyleFlags = BKA_MAJOR | BKA_STATUSTEXTON;
- pageinfo.usPageInsertFlags = BKA_FIRST;
- //We want page numbers
- pageinfo.usSettingsFlags = SETTINGS_PAGE_NUMBERS;
- //The dialog procedure for this page
- pageinfo.pfnwp = grabberOptionDlgProc;
- //The resource is in the class file
- pageinfo.resid = queryModuleHandle();
- pageinfo.dlgid = IDDLG_GRABBERSETUP;
- //We need a pointer to our WPS-object in the dialog procedure
- //to call class functions
- pageinfo.pCreateParams = this;
- //The ID of the help panel for this page
- pageinfo.idDefaultHelpPanel = IDDLG_GRABBERSETUP;
- //Tell the WPS the help library name
- pageinfo.pszHelpLibraryName = AFHELPLIBRARY;
- //We have a major tab so we need a name
- pageinfo.pszName = "Grabber options";
-
- //Insert the page into the settings notebook
- return wpInsertSettingsPage(hwndNotebook,&pageinfo);
- }
-
-
- void CWAudioFolder::cwSetStatusTime(ULONG ulTrackSize)
- {
- char text[200];
- ULONG ulSize;
-
- ulSize=ulTrackSize;
- ulSize/=(2*2*44100);/* Calculate seconds */
- sprintf(text,"Total time: %d min %02d sec",ulSize/60 , (ulSize % 60));
- WinSetWindowText(WinWindowFromID(hwndStatusFrameCtl,IDST_STATUSTOTALTIME),text);
- }
-
- void CWAudioFolder::cwLoadIniValues()
- {
- ULONG keyLength;
- char profileName[CCHMAXPATH];
- char moduleName[CCHMAXPATH];
- char *chrPtr;
- HINI hini=0;
-
- /* Query the number of CD-drives */
- cwQueryCDDrives(&iNumCD,&cFirstCD);
-
- if(!wpRestoreLong("CWAudioFolder",IDKEY_FDRWRITEFLAGS,&ulWriteFlags))
- ulWriteFlags=IDWF_PAD|IDWF_NOFIX|IDWF_DUMMY;
- /* Get folder of class-dll. */
- DosQueryModuleName(queryModuleHandle(),sizeof(moduleName),moduleName);
- chrPtr=strrchr(moduleName,'\\');
- if(chrPtr)
- *chrPtr=0;
- /* Build full path for cdrecord.ini file */
- sprintf(profileName,"%s\\cdrecord.ini",moduleName);
- hini=PrfOpenProfile(WinQueryAnchorBlock(HWND_DESKTOP),profileName);
- do{
- if(!hini) {
- WinMessageBox( HWND_DESKTOP,
- HWND_DESKTOP,
- "Warning! Cannot open Ini-file!",
- "Audio-CD-Creator",
- 0UL,
- MB_OK | MB_ICONEXCLAMATION );
- break;
- }/* end of if(!hini) */
-
- keyLength=PrfQueryProfileString(hini,"CDWriter","cdrecord","",chrCDRecord,sizeof(chrCDRecord));
- if(keyLength==1){
- break;/* First opening. We havn't got entries yet */
- }
- PrfQueryProfileString(hini,"CDWriter","cdroptions","",chrCDROptions,sizeof(chrCDROptions));
- setupDone=TRUE;
-
- keyLength=PrfQueryProfileString(hini,"CDGrabber","grabber","",chrGrabberPath,sizeof(chrGrabberPath));
- if(keyLength==1){
- break;/* We havn't got entries yet */
- }
- PrfQueryProfileString(hini,"CDGrabber","graboptions","",chrGrabberOptions,sizeof(chrGrabberOptions));
- PrfQueryProfileString(hini,"CDGrabber","grabdrive","",chosenCD,sizeof(chosenCD));
- bTrackNumbers=PrfQueryProfileInt(hini,"CDGrabber","tracknumbers",1);
- GrabberSetupDone=TRUE;
- break;
- } while(TRUE);
- if(hini)PrfCloseProfile(hini);
- }
-
- ULONG CWAudioFolder::cwQueryWriteFlags()
- {
- return ulWriteFlags;
- }
-
- ULONG CWAudioFolder::cwSetWriteFlags(ULONG ulNewWriteFlags,ULONG ulMask)
- {
- ULONG rc;
-
- rc=cwQueryWriteFlags();
- ulWriteFlags=((ulNewWriteFlags&ulMask) | (~ulMask & ulWriteFlags));
-
- return rc;/* return previous flags */
- }
-
- void CWAudioFolder::cwEnableGrab(BOOL bEnable)
- {
- bGrabEnabled=bEnable;
- }
-
- BOOL CWAudioFolder::cwQueryGrabEnabled(void)
- {
- return bGrabEnabled;
- }
-
- void CWAudioFolder::cwEnableWrite(BOOL bEnable)
- {
- bWriteEnabled=bEnable;
- }
-
- BOOL CWAudioFolder::cwQueryWriteEnabled(void)
- {
- return bWriteEnabled;
- }
-
- void CWAudioFolder::cwEnableGrabControls(BOOL bEnable)
- {
- if(!hwndGrab)
- return;
- WinEnableWindow(WinWindowFromID(hwndGrab,IDPB_SELECTALL) ,bEnable);
- WinEnableWindow(WinWindowFromID(hwndGrab,IDLB_GRABTRACKS) ,bEnable);
- WinEnableWindow(WinWindowFromID(hwndGrab,IDPB_GRAB) ,bEnable);
- WinEnableWindow(WinWindowFromID(hwndGrab,IDPB_REFRESH) ,bEnable);
-
- }
-
- void CWAudioFolder::cwEnableSelectControls(BOOL bEnable)
- {
- if(!hwndSelect)
- return;
- WinEnableWindow(WinWindowFromID(hwndSelect,IDRB_WRITE) ,bEnable);
- WinEnableWindow(WinWindowFromID(hwndSelect,IDRB_GRAB) ,bEnable);
- WinEnableWindow(WinWindowFromID(hwndSelect,IDEF_TRACKNAME) ,bEnable);
- }
-
- void CWAudioFolder::cwForceStatusUpdate(void)
- {
- if(atomUpdateStatusbar)
- WinPostMsg(hwndStatusFrameCtl,atomUpdateStatusbar,0,MPFROMP(this));
- }
-
- void CWAudioFolder::cwEnableWriteControls(BOOL bEnable)
- {
- if(!hwndWrite)
- return;
- WinEnableWindow(WinWindowFromID(hwndWrite,IDCB_PAD) ,bEnable);
- WinEnableWindow(WinWindowFromID(hwndWrite,IDCB_NOFIX) ,bEnable);
- WinEnableWindow(WinWindowFromID(hwndWrite,IDCB_PREEMP) ,bEnable);
- WinEnableWindow(WinWindowFromID(hwndWrite,IDCB_DUMMY) ,bEnable);
- WinEnableWindow(WinWindowFromID(hwndWrite,IDPB_BURN) ,bEnable);
- }
-
- void CWAudioFolder::cwSetStatusText(char * text)
- {
- WinSetWindowText(WinWindowFromID(hwndStatusFrameCtl,IDST_STATUSTOTALTIME),text);
- }
-
- /*********************************************************************/
- /* */
- /* This procedure fills the given listbox with all the tracks of the */
- /* given folder. If no listbox is given only the size is returned */
- /* */
- /* Parameters: */
- /* hwndFrame: frame handle of wpFolder window */
- /* hwndListBox: handle of listbox where to insert the */
- /* wavefile names */
- /* */
- /* Returns: Size of all tracks in byte */
- /* */
- /*********************************************************************/
- ULONG CWAudioFolder::cwFillTrackList(HWND hwndFrame, HWND hwndListBox)
- {
- HWND hwndCnr;
- PMINIRECORDCORE mrc;
- WPObject * contentObject;
- char name[CCHMAXPATH];
- ULONG ulNameSize;
- ULONG ulSize;
-
- ulSize=0;
- /* Get hwnd of folder container */
- hwndCnr=WinWindowFromID(hwndFrame,FID_CLIENT);
- if(hwndCnr){ /* Catch error */
- /* Get first container item of our folder */
- mrc=(PMINIRECORDCORE)WinSendMsg(hwndCnr,CM_QUERYRECORD,NULL,
- MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
- if(mrc){
- while(mrc) {
- /* Get wps-object-ptr. from container item */
- contentObject=(WPObject*)OBJECT_FROM_PREC(mrc);//Get object
- ulNameSize=sizeof(name);
- if(contentObject) {
- /* Get file system object or NULL */
- contentObject=cwGetFileSystemObject(contentObject);
- }
- if(contentObject){
- /* It's a file system object */
- /* Check, if it's a wave file */
- if(cwIsWaveFile(contentObject)){
- /* Yes, query the full path */
- ((WPFileSystem*)contentObject)->wpQueryRealName(name,&ulNameSize,TRUE);
- /* Add tracksize to totalsize */
- ulSize+=((WPFileSystem*)contentObject)->wpQueryFileSize()-44;
- /* Add 2 seconds for pause between tracks */
- //ulSize+=8*44100;
- /* insert the name into the listbox */
- if(hwndListBox)
- WinInsertLboxItem(hwndListBox,LIT_END,
- name);
-
- }
- }/* end of if(contentObject) */
- /* Get next container item */
- mrc=(PMINIRECORDCORE)WinSendMsg(hwndCnr,CM_QUERYRECORD,MPFROMP(mrc),
- MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
- }// end of while(mrc)
- }// end of if(mrc)
- }
- return ulSize;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-