home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1999 November / PCONLINE_11_99.ISO / filesbbs / OS2 / ACDCR032.ZIP / source / datacdfolder.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-08-22  |  28.3 KB  |  785 lines

  1. /*
  2.  * This file is (C) Chris Wohlgemuth 1999
  3.  */
  4. /*
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2, or (at your option)
  8.  * any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; see the file COPYING.  If not, write to
  17.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20. #include "audiofolder.hh"
  21. #include "audiofolderhelp.h"
  22.  
  23. #include <stdlib.h>
  24. #include <stdio.h>
  25.  
  26.  
  27.  
  28. char chrImage[CCHMAXPATH]={0};/* Path to iso-image */
  29. char lnchParam[1024];
  30. extern char chrCDROptions[CCHMAXPATH];
  31. extern char chrCDRecord[CCHMAXPATH];/* Path to cdrecord */
  32. extern char chrMkisofs[CCHMAXPATH];/* Path to mkisofs */
  33. extern char chrMkisofsOptions[CCHMAXPATH];
  34. extern BOOL bMultiSessionDone;
  35. extern char chosenMultiSessionCD[3];
  36.  
  37. HMODULE queryModuleHandle(void);
  38. MRESULT EXPENTRY cdTypeOptionDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  39. MRESULT EXPENTRY authorOptionDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  40. MRESULT EXPENTRY cdrecordOptionDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  41. MRESULT EXPENTRY mkisofsOptionDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  42. MRESULT EXPENTRY fileNameOptionDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  43. void _Optlink imageWriteThreadFunc (void *arg);
  44. void _Optlink mkisofsThreadFunc (void *arg);
  45. void _Optlink flyThreadFunc (void *arg);
  46. void buildDataWriteParam(CWDataFolder* thisPtr, char * text);
  47. void buildMkisofsParam(CWDataFolder* thisPtr, char * text, char * outputName);
  48. PSZ buildWrapName(PSZ wrapperName);
  49.  
  50. /********************************************************/
  51. /* New class function which inserts the filename option */
  52. /* page into the settings notebook                      */
  53. /********************************************************/
  54. BOOL CWDataFolder::AddFileNameOptionPage(HWND hwndNotebook)
  55. {
  56.   PAGEINFO pageinfo;
  57.   
  58.   //Clear the pageinfo structure
  59.   memset((PCH)&pageinfo, 0, sizeof(PAGEINFO));
  60.   //Fill the pageinfo structure
  61.   pageinfo.cb = sizeof(PAGEINFO);
  62.   pageinfo.hwndPage = NULLHANDLE;
  63.   pageinfo.usPageStyleFlags = BKA_MAJOR | BKA_STATUSTEXTON;
  64.   pageinfo.usPageInsertFlags = BKA_FIRST;
  65.   //We want page numbers
  66.   pageinfo.usSettingsFlags = SETTINGS_PAGE_NUMBERS;
  67.   //The dialog procedure for this page
  68.   pageinfo.pfnwp = fileNameOptionDlgProc;
  69.   //The resource is in the class file
  70.   pageinfo.resid = queryModuleHandle();
  71.   pageinfo.dlgid = IDDLG_FILENAMEOPTIONS;
  72.   //We need a pointer to our WPS-object in the dialog procedure
  73.   //to call class functions
  74.   pageinfo.pCreateParams = this;
  75.   //The ID of the help panel for this page
  76.   pageinfo.idDefaultHelpPanel = IDDLG_FILENAMEOPTIONS;
  77.   //Tell the WPS the help library name
  78.   pageinfo.pszHelpLibraryName = AFHELPLIBRARY;
  79.   //We have a major tab so we need a name
  80.   pageinfo.pszName = "Filename options";
  81.   
  82.   //Insert the page into the settings notebook
  83.   return wpInsertSettingsPage(hwndNotebook,&pageinfo);
  84. }
  85.  
  86. /********************************************************/
  87. /* New class function which inserts the mkisofs setup */
  88. /* page into the settings notebook                      */
  89. /********************************************************/
  90. BOOL CWDataFolder::AddMkisofsOptionPage(HWND hwndNotebook)
  91. {
  92.   PAGEINFO pageinfo;
  93.   
  94.   //Clear the pageinfo structure
  95.   memset((PCH)&pageinfo, 0, sizeof(PAGEINFO));
  96.   //Fill the pageinfo structure
  97.   pageinfo.cb = sizeof(PAGEINFO);
  98.   pageinfo.hwndPage = NULLHANDLE;
  99.   pageinfo.usPageStyleFlags = BKA_MAJOR | BKA_STATUSTEXTON;
  100.   pageinfo.usPageInsertFlags = BKA_FIRST;
  101.   //We want page numbers
  102.   pageinfo.usSettingsFlags = SETTINGS_PAGE_NUMBERS;
  103.   //The dialog procedure for this page
  104.   pageinfo.pfnwp = mkisofsOptionDlgProc;
  105.   //The resource is in the class file
  106.   pageinfo.resid = queryModuleHandle();
  107.   pageinfo.dlgid = IDDLG_MKISOFSSETUP;
  108.   //We need a pointer to our WPS-object in the dialog procedure
  109.   //to call class functions
  110.   pageinfo.pCreateParams = this;
  111.   //The ID of the help panel for this page
  112.   pageinfo.idDefaultHelpPanel = IDDLG_MKISOFSSETUP;
  113.   //Tell the WPS the help library name
  114.   pageinfo.pszHelpLibraryName = AFHELPLIBRARY;
  115.   //We have a major tab so we need a name
  116.   pageinfo.pszName = "Mkisofs setup";
  117.   
  118.   //Insert the page into the settings notebook
  119.   return wpInsertSettingsPage(hwndNotebook,&pageinfo);
  120. }
  121.  
  122. /********************************************************/
  123. /* New class function which inserts the Cdrecord option */
  124. /* page into the settings notebook                      */
  125. /********************************************************/
  126. BOOL CWDataFolder::AddCdrecordOptionPage(HWND hwndNotebook)
  127. {
  128.   PAGEINFO pageinfo;
  129.   
  130.   //Clear the pageinfo structure
  131.   memset((PCH)&pageinfo, 0, sizeof(PAGEINFO));
  132.   //Fill the pageinfo structure
  133.   pageinfo.cb = sizeof(PAGEINFO);
  134.   pageinfo.hwndPage = NULLHANDLE;
  135.   pageinfo.usPageStyleFlags = BKA_MAJOR | BKA_STATUSTEXTON;
  136.   pageinfo.usPageInsertFlags = BKA_FIRST;
  137.   //We want page numbers
  138.   pageinfo.usSettingsFlags = SETTINGS_PAGE_NUMBERS;
  139.   //The dialog procedure for this page
  140.   pageinfo.pfnwp = cdrecordOptionDlgProc;
  141.   //The resource is in the class file
  142.   pageinfo.resid = queryModuleHandle();
  143.   pageinfo.dlgid = IDDLG_CDRECORDSETUP;
  144.   //We need a pointer to our WPS-object in the dialog procedure
  145.   //to call class functions
  146.   pageinfo.pCreateParams = this;
  147.   //The ID of the help panel for this page
  148.   pageinfo.idDefaultHelpPanel = IDDLG_CDRECORDSETUP;
  149.   //Tell the WPS the help library name
  150.   pageinfo.pszHelpLibraryName = AFHELPLIBRARY;
  151.   //We have a major tab so we need a name
  152.   pageinfo.pszName = "CDRecord/2 options";
  153.   
  154.   //Insert the page into the settings notebook
  155.   return wpInsertSettingsPage(hwndNotebook,&pageinfo);
  156. }
  157.  
  158. /********************************************************/
  159. /* New class function which inserts the author          */
  160. /* page into the settings notebook                      */
  161. /********************************************************/
  162. BOOL CWDataFolder::AddAuthorOptionPage(HWND hwndNotebook)
  163. {
  164.   PAGEINFO pageinfo;
  165.   
  166.   //Clear the pageinfo structure
  167.   memset((PCH)&pageinfo, 0, sizeof(PAGEINFO));
  168.   //Fill the pageinfo structure
  169.   pageinfo.cb = sizeof(PAGEINFO);
  170.   pageinfo.hwndPage = NULLHANDLE;
  171.   pageinfo.usPageStyleFlags = BKA_MAJOR | BKA_STATUSTEXTON;
  172.   pageinfo.usPageInsertFlags = BKA_FIRST;
  173.   //We want page numbers
  174.   pageinfo.usSettingsFlags = SETTINGS_PAGE_NUMBERS;
  175.   //The dialog procedure for this page
  176.   pageinfo.pfnwp = authorOptionDlgProc;
  177.   //The resource is in the class file
  178.   pageinfo.resid = queryModuleHandle();
  179.   pageinfo.dlgid = IDDLG_AUTHOR;
  180.   //We need a pointer to our WPS-object in the dialog procedure
  181.   //to call class functions
  182.   pageinfo.pCreateParams = this;
  183.   //The ID of the help panel for this page
  184.   pageinfo.idDefaultHelpPanel = IDDLG_AUTHOR;
  185.   //Tell the WPS the help library name
  186.   pageinfo.pszHelpLibraryName = AFHELPLIBRARY;
  187.   //We have a major tab so we need a name
  188.   pageinfo.pszName = "Author";
  189.   
  190.   //Insert the page into the settings notebook
  191.   return wpInsertSettingsPage(hwndNotebook,&pageinfo);
  192. }
  193.  
  194. /********************************************************/
  195. /* New class function which inserts the CD-Type         */
  196. /* page into the settings notebook                      */
  197. /********************************************************/
  198. BOOL CWDataFolder::AddCDTypeOptionPage(HWND hwndNotebook)
  199. {
  200.   PAGEINFO pageinfo;
  201.   
  202.   //Clear the pageinfo structure
  203.   memset((PCH)&pageinfo, 0, sizeof(PAGEINFO));
  204.   //Fill the pageinfo structure
  205.   pageinfo.cb = sizeof(PAGEINFO);
  206.   pageinfo.hwndPage = NULLHANDLE;
  207.   pageinfo.usPageStyleFlags = BKA_MAJOR | BKA_STATUSTEXTON;
  208.   pageinfo.usPageInsertFlags = BKA_FIRST;
  209.   //We want page numbers
  210.   pageinfo.usSettingsFlags = SETTINGS_PAGE_NUMBERS;
  211.   //The dialog procedure for this page
  212.   pageinfo.pfnwp = cdTypeOptionDlgProc;
  213.   //The resource is in the class file
  214.   pageinfo.resid = queryModuleHandle();
  215.   pageinfo.dlgid = IDDLG_CDTYPE;
  216.   //We need a pointer to our WPS-object in the dialog procedure
  217.   //to call class functions
  218.   pageinfo.pCreateParams = this;
  219.   //The ID of the help panel for this page
  220.   pageinfo.idDefaultHelpPanel = IDDLG_CDTYPE;
  221.   //Tell the WPS the help library name
  222.   pageinfo.pszHelpLibraryName = AFHELPLIBRARY;
  223.   //We have a major tab so we need a name
  224.   pageinfo.pszName = "CD-Type selection";
  225.   
  226.   //Insert the page into the settings notebook
  227.   return wpInsertSettingsPage(hwndNotebook,&pageinfo);
  228. }
  229.  
  230. /********************************************************/
  231. /*BOOL CWDataFolder::AddCreateOptionPage(HWND hwndNotebook)
  232. {
  233.   PAGEINFO pageinfo;
  234.   
  235.   //Clear the pageinfo structure
  236.   memset((PCH)&pageinfo, 0, sizeof(PAGEINFO));
  237.   //Fill the pageinfo structure
  238.   pageinfo.cb = sizeof(PAGEINFO);
  239.   pageinfo.hwndPage = NULLHANDLE;
  240.   pageinfo.usPageStyleFlags = BKA_MAJOR | BKA_STATUSTEXTON;
  241.   pageinfo.usPageInsertFlags = BKA_FIRST;
  242.   //We want page numbers
  243.   pageinfo.usSettingsFlags = SETTINGS_PAGE_NUMBERS;
  244.   //The dialog procedure for this page
  245.   pageinfo.pfnwp = createOptionDlgProc;
  246.   //The resource is in the class file
  247.   pageinfo.resid = queryModuleHandle();
  248.   pageinfo.dlgid = IDDLG_CREATION;
  249.   //We need a pointer to our WPS-object in the dialog procedure
  250.   //to call class functions
  251.   pageinfo.pCreateParams = this;
  252.   //The ID of the help panel for this page
  253.   pageinfo.idDefaultHelpPanel = IDDLG_CDRECORDSETUP;
  254.   //Tell the WPS the help library name
  255.   pageinfo.pszHelpLibraryName = AFHELPLIBRARY;
  256.   //We have a major tab so we need a name
  257.   pageinfo.pszName = "Creation";
  258.   
  259.   //Insert the page into the settings notebook
  260.   return wpInsertSettingsPage(hwndNotebook,&pageinfo);
  261. }*/
  262.  
  263. void CWDataFolder::cwSetStatusText(PSZ pszText)
  264. {
  265.   if(pszText)
  266.     WinSetWindowText(WinWindowFromID(hwndStatusCntrl,IDST_STATUSTOTALTIME),pszText);
  267.   else
  268.     WinSetWindowText(WinWindowFromID(hwndStatusCntrl,IDST_STATUSTOTALTIME),chrStatusText);
  269. }
  270.  
  271. ULONG CWDataFolder::cwQueryMkisofsFlags()
  272. {
  273.   return ulMkisofsFlags;
  274. }
  275.  
  276. ULONG CWDataFolder::cwSetMkisofsFlags(ULONG ulNewMkisofsFlags,ULONG ulMask)
  277. {
  278.   ULONG rc;
  279.  
  280.   rc=cwQueryMkisofsFlags();
  281.   ulMkisofsFlags=((ulNewMkisofsFlags&ulMask) | (~ulMask & ulMkisofsFlags));
  282.  
  283.   return rc;/* return previous flags */
  284. }
  285.  
  286. LONG CWDataFolder::cwQueryPreviousStartSector()
  287. {
  288.   return lPreviousStart;
  289. }
  290.  
  291. LONG CWDataFolder::cwQueryNextStartSector()
  292. {
  293.   return lNextStart;
  294. }
  295.  
  296. void CWDataFolder::cwSetPreviousStartSector(LONG lSector)
  297. {
  298.   lPreviousStart=lSector;
  299. }
  300.  
  301. void CWDataFolder::cwSetNextStartSector(LONG lSector)
  302. {
  303.   lNextStart=lSector;
  304. }
  305.  
  306.  
  307. ULONG CWDataFolder::cwQueryCDTypeFlags()
  308. {
  309.   return ulCDTypeFlags;
  310. }
  311.  
  312. ULONG CWDataFolder::cwSetCDTypeFlags(ULONG ulNewCDTypeFlags,ULONG ulMask)
  313. {
  314.   ULONG rc;
  315.  
  316.   rc=cwQueryCDTypeFlags();
  317.   ulCDTypeFlags=((ulNewCDTypeFlags&ulMask) | (~ulMask & ulCDTypeFlags));
  318.  
  319.   return rc;/* return previous flags */
  320. }
  321.  
  322. void CWDataFolder::cwEnableMultiSessionCntrls(HWND hwnd, BOOL bEnable)
  323. {
  324.   /* hwnd:    Dialog-HWND
  325.      nEnable: New enable state */
  326.  
  327.   WinEnableWindow(WinWindowFromID(hwnd,IDCB_FIRSTSESSION),bEnable);
  328.   WinEnableWindow(WinWindowFromID(hwnd,IDCB_WRITERSOURCE),bEnable);
  329.   WinEnableWindow(WinWindowFromID(hwnd,IDDD_SOURCEDRIVE),bEnable);
  330.   WinEnableWindow(WinWindowFromID(hwnd,IDST_PREVIOUSINFO),bEnable);
  331.   WinEnableWindow(WinWindowFromID(hwnd,IDST_SOURCEDRIVE),bEnable);
  332.   WinEnableWindow(WinWindowFromID(hwnd,IDSB_PREVIOUSSTART),bEnable);
  333.   WinEnableWindow(WinWindowFromID(hwnd,IDSB_NEXTSTART),bEnable);
  334.   WinEnableWindow(WinWindowFromID(hwnd,IDPB_GETMSINFO),bEnable);
  335.   bEnable?bEnable=FALSE:bEnable=TRUE;
  336.   WinEnableWindow(WinWindowFromID(hwnd,IDRB_TRACKDATA),bEnable);
  337.   WinEnableWindow(WinWindowFromID(hwnd,IDRB_TRACKMODE2),bEnable);
  338.   WinEnableWindow(WinWindowFromID(hwnd,IDRB_TRACKXA1),bEnable);
  339.   WinEnableWindow(WinWindowFromID(hwnd,IDRB_TRACKXA2),bEnable);
  340.   WinEnableWindow(WinWindowFromID(hwnd,IDRB_TRACKCDI),bEnable);
  341. }
  342.  
  343. ULONG CWDataFolder::cwQueryCreateFlags()
  344. {
  345.   return ulCreateFlags;
  346. }
  347.  
  348. ULONG CWDataFolder::cwSetCreateFlags(ULONG ulNewCreateFlags,ULONG ulMask)
  349. {
  350.   ULONG rc;
  351.  
  352.   rc=cwQueryCreateFlags();
  353.   ulCreateFlags=((ulNewCreateFlags&ulMask) | (~ulMask & ulCreateFlags));
  354.  
  355.   return rc;/* return previous flags */
  356. }
  357.  
  358. void CWDataFolder::cwEnableWriteControls(BOOL bEnable)
  359. {
  360.   if(!hwndMkisofsMain)
  361.     return;
  362.   WinEnableWindow(WinWindowFromID(hwndMkisofsMain,IDRB_WRITEIMAGE) ,bEnable);
  363.   WinEnableWindow(WinWindowFromID(hwndMkisofsMain,IDRB_ONTHEFLY) ,bEnable);
  364.   WinEnableWindow(WinWindowFromID(hwndMkisofsMain,IDRB_IMAGEONLY) ,bEnable);
  365.   WinEnableWindow(WinWindowFromID(hwndMkisofsMain,IDPB_CREATE) ,bEnable);
  366.   WinEnableWindow(WinWindowFromID(hwndMkisofsMain,IDPB_WRITECD) ,bEnable);
  367.  
  368. }
  369.  
  370. void CWDataFolder::cwWriteImage()
  371. {
  372.   char * text;
  373.  
  374.   text=lnchParam;
  375.  
  376.   /* Get current filename from entryfield */
  377.   WinQueryWindowText( WinWindowFromID(hwndImageName,IDEF_IMAGENAME),sizeof(chrImage),chrImage);      
  378.  
  379.   /* Check if we have an output filename */
  380.   if(strlen(chrImage)<=3) {
  381.     WinMessageBox(  HWND_DESKTOP,   HWND_DESKTOP, "You have to specify a valid filename.","Write image file.",
  382.                     0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
  383.     return;
  384.   }
  385.   if(pvSharedMem) {
  386.     WinMessageBox(  HWND_DESKTOP,   HWND_DESKTOP,"There is an imagefile creation process running." ,"Write image file.",
  387.                     0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
  388.     return;
  389.   }
  390.  
  391.   /* Build cdrecord/2 cmd-line parameters */  
  392.   buildDataWriteParam(this, text);
  393.  
  394.   /* Check if we perform a dummy write */
  395.   if(sDummy==1)
  396.     strcat(text," -dummy");// Dummy write
  397.   else
  398.     if(WinMessageBox(  HWND_DESKTOP,   HWND_DESKTOP, "Dummy is unchecked!\n Do you want to perform a real write?","Write CDR",
  399.                     0UL, MB_YESNO | MB_ICONEXCLAMATION|MB_MOVEABLE )==MBID_NO)
  400.       return;
  401.  
  402.   /* Add the imagefile name */
  403.   strcat(text," ");
  404.   strcat(text,chrImage);
  405.  
  406.   /* Start cdrecord */
  407.   /*  WinMessageBox(  HWND_DESKTOP,   HWND_DESKTOP, text,"void CWDataFolder::cwWriteImage()",
  408.       0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
  409.       return;*/
  410.   sprintf(chrStatusText,"Writing image %s...",chrImage);
  411.   _beginthread(imageWriteThreadFunc,NULL,8192*16,(void*)this); //Fehlerbehandlung fehlt  
  412. }
  413.  
  414.  
  415. void changeBackslash(char* text)
  416. {
  417.   char * chrPtr;
  418.   
  419.   chrPtr=strchr(text,'\\');
  420.  
  421.   while(chrPtr!=NULL) {
  422.     *chrPtr='/';
  423.     chrPtr=strchr(text,'\\');
  424.   }
  425. }
  426.  
  427. void CWDataFolder::cwWriteOnTheFly()
  428. {
  429.   char *text;
  430.   char *chrPtrParam;
  431.   ULONG ulFlags;
  432.  
  433.   if(pvSharedMem) {
  434.     WinMessageBox(  HWND_DESKTOP,   HWND_DESKTOP,"There is already an imagefile creation process running. Currently there's \
  435. only one mkisofs process allowed." ,"Write on the fly",
  436.                     0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
  437.     return;
  438.   }
  439.  
  440.   ulFlags=cwQueryCDTypeFlags();
  441.   if((ulFlags & IDCDT_MULTISESSION) && !(ulFlags & IDCDT_FIRSTSESSION)) {
  442.     /* We are building the second image of a multisession disk */
  443.     WinMessageBox(  HWND_DESKTOP,   HWND_DESKTOP,"With this version of Data-CD-Creator it isn't possible \
  444. to write further sessions of a multisession CD on the fly." ,"Write on the fly",
  445.                     0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
  446.     return;
  447.   }
  448.  
  449.   if(DosAllocSharedMem(&pvSharedMem,"\\SHAREMEM\\MKISOFSCMDLINE",SHAREDMEM_SIZE,PAG_READ|PAG_WRITE|PAG_COMMIT)) {
  450.     WinMessageBox(  HWND_DESKTOP,   HWND_DESKTOP, "Can't allocate shared Mem!","Write on the fly",
  451.                     0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
  452.     return;
  453.   }
  454.   memset(pvSharedMem,0,SHAREDMEM_SIZE);
  455.   text= (char*)pvSharedMem;
  456.  
  457.   strcat(text,buildWrapName("spe t28 "));
  458.   chrPtrParam=strrchr(text,' ');
  459.  
  460.   /* Add the mkisofs command */
  461.   buildMkisofsParam(this, chrPtrParam,NULL);
  462.  
  463.   /* Add cdrecord command */
  464.   strcat(text," | ");
  465.   strcat(text,chrCDRecord);
  466.   strcat(text,"  ");
  467.   chrPtrParam=strrchr(text,' ');
  468.   /* Add cdrecord options */
  469.   buildDataWriteParam(this, chrPtrParam);
  470.  
  471.   /* Check if we perform a dummy write */
  472.   if(sDummy==1)
  473.     strcat(text," -dummy");// Dummy write
  474.   else {
  475.     if(WinMessageBox(  HWND_DESKTOP,   HWND_DESKTOP, "Dummy is unchecked!\n Do you want to perform a real write?","Write CDR",
  476.                        0UL, MB_YESNO | MB_ICONEXCLAMATION|MB_MOVEABLE )==MBID_NO) {
  477.       DosFreeMem(pvSharedMem);
  478.       pvSharedMem=NULL;
  479.       return;
  480.     }
  481.   }
  482.   /* Add the imagefile name */
  483.   strcat(text," -");
  484.   
  485.   /*   WinMessageBox(  HWND_DESKTOP,   HWND_DESKTOP, text,"void CWDataFolder::cwWriteOnTheFly()",
  486.        0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
  487.        */
  488.  
  489.   /* Change backslashs in parameters and sourcefiles */
  490.   //changeBackslash(chrPtrParam);  
  491.   sprintf(chrStatusText,"Writing on the fly...");
  492.   _beginthread(flyThreadFunc,NULL,8192*16,(void*)this); //Fehlerbehandlung fehlt  
  493.  
  494.   //DosFreeMem(pvSharedMem);
  495.   //pvSharedMem=NULL;
  496.   return;
  497. }
  498.  
  499. void CWDataFolder::cwCreateImage()
  500. {
  501.  
  502.   ULONG ulFlags;
  503.   char filename[CCHMAXPATH];
  504.   char * chrPtr;
  505.   char * chrPtr2;
  506.   ULONG ulSize;
  507.   HWND hwnd;
  508.   PMINIRECORDCORE mrc;   
  509.   WPObject * contentObject;
  510.   LONG lValue1,lValue2;
  511.   char *text;
  512.   char *chrPtrParam;
  513.  
  514.   if(pvSharedMem) {
  515.     WinMessageBox(  HWND_DESKTOP,   HWND_DESKTOP,"There is already an imagefile creation process running." ,"Image file creation",
  516.                     0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
  517.     return;
  518.   }
  519.  
  520.   /* Get current filename from entryfield */
  521.   WinQueryWindowText( WinWindowFromID(hwndImageName,IDEF_IMAGENAME),sizeof(chrImage),chrImage);      
  522.  
  523.   /* Check if we have an output filename */
  524.   if(strlen(chrImage)<=3) {
  525.     WinMessageBox(  HWND_DESKTOP,   HWND_DESKTOP, "You have to specify a valid filename including the path.",
  526.                     "Image file creation",
  527.                     0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
  528.     return;
  529.   }
  530.  /* Check if we have a full path (just a quick check) */
  531.   if(chrImage[1]!=':') {
  532.     WinMessageBox(  HWND_DESKTOP,   HWND_DESKTOP, "You have to specify a full path.","Image file creation",
  533.                     0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
  534.     return;
  535.   }
  536.  
  537.   if(DosAllocSharedMem(&pvSharedMem,"\\SHAREMEM\\MKISOFSCMDLINE",SHAREDMEM_SIZE,PAG_READ|PAG_WRITE|PAG_COMMIT)) {
  538.     WinMessageBox(  HWND_DESKTOP,   HWND_DESKTOP, "Can't allocate shared Mem!","Image file creation",
  539.                     0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
  540.     return;
  541.   }
  542.   memset(pvSharedMem,0,SHAREDMEM_SIZE);
  543.   text= (char*)pvSharedMem;
  544.  
  545.  
  546.   buildMkisofsParam(this, text,chrImage);
  547.   /* Change backslashs in parameters and sourcefiles */
  548.   //chrPtrParam=strchr(text,' ');
  549.   //  changeBackslash(chrPtrParam);  
  550.   sprintf(chrStatusText,"Creating image %s...",chrImage);
  551.   _beginthread(mkisofsThreadFunc,NULL,8192*16,(void*)this); //Fehlerbehandlung fehlt  
  552.  
  553.   return;
  554.  
  555.  
  556.  
  557.  
  558.   /**********************************/
  559.  
  560.   /* Build cmd-line for mkisofs */
  561.   ulFlags=cwQueryMkisofsFlags();
  562.   /* Path to mkisofs */
  563.   sprintf(text,"%s ",chrMkisofs);
  564.   chrPtrParam=strchr(text,0);
  565.   /* Additional options */
  566.   strncat(text,chrMkisofsOptions,sizeof(chrMkisofsOptions));
  567.   /* Filename options */
  568.   if(ulFlags & IDMK_ALLOW32CHARS)
  569.     strncat(text," -l",4);
  570.   if(ulFlags & IDMK_LEADINGPERIODS)
  571.     strncat(text," -L",4);
  572.   if(ulFlags & IDMK_JOLIET)
  573.     strncat(text," -J",4);
  574.   if(ulFlags & IDMK_ROCKRIDGE)
  575.     strncat(text," -r",4);
  576.   if(ulFlags & IDMK_TRANSTABLE)
  577.     strncat(text," -T",4);
  578.   //  if(ulFlags & IDMK_LOGFILE)
  579.   //   strncat(text," -log-filemkisofs.log",sizeof(" -log-filemkisofs.log"));
  580.   /* Add the autor-stuff */
  581.   if(strlen(chrApplication)) {
  582.     strncat(text," -A",strlen(" -A"));
  583.     strncat(text,chrApplication,strlen(chrApplication));
  584.   }
  585.   if(strlen(chrPublisher)) {
  586.     strncat(text," -P",strlen(" -P"));
  587.     strncat(text,chrPublisher,strlen(chrPublisher));
  588.   }
  589.   if(strlen(chrPreparer)) {
  590.     strncat(text," -p",strlen(" -p"));
  591.     strncat(text,chrPreparer,strlen(chrPreparer));
  592.   }
  593.   /*  if(strlen(chrCopyright)) {
  594.       strncat(text," -copyright",strlen(" -copyright"));
  595.       strncat(text,chrCopyright,strlen(chrCopyright));
  596.       }*/
  597.  
  598.  
  599.   ulFlags=cwQueryCDTypeFlags();
  600.   if((ulFlags & IDCDT_MULTISESSION) && !(ulFlags & IDCDT_FIRSTSESSION)) {
  601.     /* We are building the second image of a multisession disk */
  602.     /* Check if we did some setup stuff on the ms-page. Caution! Isn't bullet proof! */
  603.     if(!bMultiSessionDone) {
  604.       sprintf(text,"You have to provide some information on the 'CD-type selection' page prior to the creating \
  605. of multisession CDs!");  
  606.       WinMessageBox(  HWND_DESKTOP, HWND_DESKTOP,
  607.                       text,
  608.                       "Imagefile creation error",
  609.                       0UL, MB_OK | MB_ICONEXCLAMATION |MB_MOVEABLE);
  610.       DosFreeMem(pvSharedMem);
  611.       pvSharedMem=NULL;
  612.       return;
  613.     }
  614.  
  615.     /* Check if we have the necessary sectornumbers */
  616.     lValue1=cwQueryPreviousStartSector();
  617.     lValue2=cwQueryNextStartSector();
  618.     if(lValue1==lValue2) {
  619.       sprintf(text,"Need sector information of previous session. Go to the 'CD-type selection' page in \
  620. the settings notebook to supply it.");  
  621.       WinMessageBox(  HWND_DESKTOP, HWND_DESKTOP,
  622.                       text,
  623.                       "Imagefile creation error",
  624.                       0UL, MB_OK | MB_ICONEXCLAMATION |MB_MOVEABLE);
  625.       DosFreeMem(pvSharedMem);
  626.       pvSharedMem=NULL;
  627.       return;
  628.     }
  629.     sprintf(filename," -C%d,%d",lValue1,lValue2);
  630.     strncat(text,filename,strlen(filename));
  631.  
  632.     /* Check if we have a source drive for previous image */
  633.     strncat(text," -M",4);
  634.     if(ulFlags & IDCDT_USEWRITER) {
  635.       /* We use the writer as source. Check if 'dev=x,y,z' is given as cdrecord options */
  636.       chrPtr=strstr(chrCDROptions,"dev=");
  637.       if(NULL==chrPtr) {
  638.         sprintf(text,"There is no device given as a CD-writer . Go to the 'CD-type selection' page in \
  639. the settings notebook to chose a drive letter instead or go to the 'CDRecord/2' page to include a 'dev=x,y,z'-\
  640. statement in the options entryfield.");  
  641.         WinMessageBox(  HWND_DESKTOP, HWND_DESKTOP,
  642.                         text,
  643.                         "Imagefile creation error",
  644.                         0UL, MB_OK | MB_ICONEXCLAMATION |MB_MOVEABLE);
  645.         DosFreeMem(pvSharedMem);
  646.         pvSharedMem=NULL;
  647.         return;
  648.       }
  649.       /* Find '=' in 'dev=...' statement */
  650.       // chrPtr=strstr(chrCDROptions,"=");
  651.       //chrPtr++;/* Get address of value for dev=... */
  652.       /* Find end of 'dev=...' statement */
  653.       chrPtr2=chrPtr;
  654.       while(*chrPtr2!=' '&& *chrPtr2!=0)
  655.         chrPtr2++;
  656.       filename[0]=*chrPtr2;
  657.       *chrPtr2=0;
  658.       chrPtr=chrPtr2;
  659.       /* Find begin of traget,lun */
  660.       chrPtr-=3;
  661.       /* Add dev=... statement to cmd-line */
  662.       strncat(text,chrPtr,strlen(chrPtr));
  663.       *chrPtr2=filename[0];
  664.     }/* if(ulFlags & IDCDT_USEWRITER) */
  665.     else {
  666.       /* We use a drive letter as source drive */
  667.       strncat(text,chosenMultiSessionCD,sizeof(chosenMultiSessionCD));
  668.     }
  669.     /* We have all information. Build the rest of the cmd-line */
  670.   }/* end of if((ulFlags & IDCDT_MULTISESSION) && !(ulFlags & IDCDT_FIRSTSESSION)) */
  671.   else {
  672.   
  673.   }
  674.   /* Name of output file */
  675.   strncat(text," -o",4);
  676.   strncat(text,chrImage,sizeof(chrImage));
  677.   /*****************************/
  678.   /* Query input files/folders */
  679.   /*****************************/
  680.   strncat(text," ",2);
  681.   ulSize=sizeof(filename);
  682.   /* Query name of this folder */
  683.   if(!wpQueryRealName(filename,&ulSize,TRUE)) {
  684.     sprintf(text,"Error while quering the foldername!");  
  685.     WinMessageBox(  HWND_DESKTOP,   HWND_DESKTOP, text,"Image file creation",
  686.                     0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
  687.     DosFreeMem(pvSharedMem);
  688.     pvSharedMem=NULL;
  689.     return;/* There's an error */
  690.   }
  691.   strncat(text,filename,ulSize);
  692.  
  693.   hwnd=WinQueryWindow(hwndMkisofsMain,QW_PARENT); // Get folder HWND
  694.   /* Get hwnd of folder container */ 
  695.   hwnd=WinWindowFromID(hwnd,FID_CLIENT);
  696.   if(!WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP),hwnd)) {
  697.     sprintf(text,"Error while quering the container HWND!");  
  698.     WinMessageBox(  HWND_DESKTOP,   HWND_DESKTOP, text,"void CWDataFolder::cwCreateImage()",
  699.                     0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
  700.     DosFreeMem(pvSharedMem);
  701.     pvSharedMem=NULL;
  702.     return;
  703.   }
  704.   mrc=(PMINIRECORDCORE)WinSendMsg(hwnd,CM_QUERYRECORD,NULL,
  705.                                   MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
  706.   if(!mrc){ 
  707.     sprintf(text,"Error! The folder is empty!");  
  708.     WinMessageBox(  HWND_DESKTOP,   HWND_DESKTOP, text,"Image file creation",
  709.                     0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
  710.     DosFreeMem(pvSharedMem);
  711.     pvSharedMem=NULL;
  712.     return;
  713.   }
  714.  
  715.   /* Enumerate folder contents. We only use filesystem objects. If we find a shadow we follow
  716.      the link and use the linked object if it's a filesystem object */
  717.   while(mrc) {
  718.     /* Get wps-object-ptr. from container item */
  719.     contentObject=(WPObject*)OBJECT_FROM_PREC(mrc);//Get object
  720.     if(contentObject) {
  721.       /* Check if it's a shadow */
  722.       if(somResolveByName(contentObject,"wpQueryShadowedObject")) 
  723.         /* Yes, it's a shadow. Get file system object or NULL */
  724.         contentObject=cwGetFileSystemObject(contentObject);
  725.       else 
  726.         /* It's no shadow, so do nothing. If it's a filesystem object it's included in our list
  727.            because we yet provide this folder as input directory. If it's any other object (abstract)
  728.            mkisofs will skip it because it uses the filesystem for querying directory contents. */
  729.         contentObject=NULL;
  730.     }
  731.     if(contentObject){
  732.       /* It's a file system object */
  733.       strncat(text," ",2);
  734.       /* Check if it's folder */
  735.       if(somResolveByName(contentObject,"wpQueryContent")) {
  736.         /* It's a folder. Query the name. */
  737.         ulSize=sizeof(filename);
  738.         ((WPFileSystem*)contentObject)->wpQueryRealName(filename,&ulSize,FALSE);
  739.         /* Add the graft point to the command line. If not done, mkisofs will include the contents of
  740.            of the folder in the image, not the folder itself */ 
  741.         if((strlen(text)+strlen(filename)+2)>=SHAREDMEM_SIZE) {
  742.           sprintf(text,"Error! The length of the cmd-line exceeds %d Bytes!!\n",SHAREDMEM_SIZE);  
  743.           WinMessageBox(  HWND_DESKTOP,   HWND_DESKTOP, text,"Image file creation",
  744.                           0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
  745.           DosFreeMem(pvSharedMem);
  746.           pvSharedMem=NULL;
  747.           return;
  748.         }       
  749.         strncat(text,filename,ulSize);
  750.         strncat(text,"/=",2);        
  751.       }
  752.       /* Query the full path */
  753.       ulSize=sizeof(filename);
  754.       ((WPFileSystem*)contentObject)->wpQueryRealName(filename,&ulSize,TRUE);
  755.       /* Add the name to the command line */ 
  756.       if((strlen(text)+strlen(filename)+2)>=SHAREDMEM_SIZE) {
  757.         sprintf(text,"Error! The length of the cmd-line exceeds %d Bytes!!\n",SHAREDMEM_SIZE);  
  758.         WinMessageBox(  HWND_DESKTOP,   HWND_DESKTOP, text,"Image file creation",
  759.                         0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
  760.         DosFreeMem(pvSharedMem);
  761.         pvSharedMem=NULL;
  762.         return;
  763.       }
  764.       strncat(text,filename,ulSize);
  765.     }/* end of if(contentObject) */           
  766.     /* Get next container item */
  767.     mrc=(PMINIRECORDCORE)WinSendMsg(hwnd,CM_QUERYRECORD,MPFROMP(mrc),
  768.                                     MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
  769.   }// end of while(mrc)
  770.  
  771.   /* Change backslashs in parameters and sourcefiles */
  772.   changeBackslash(chrPtrParam);  
  773.   
  774.   /* start mkisofs here: */
  775.   // WinMessageBox(  HWND_DESKTOP,   HWND_DESKTOP, text,"void CWDataFolder::cwCreateImage()",
  776.   //                0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
  777.   
  778.  
  779.   _beginthread(mkisofsThreadFunc,NULL,8192*16,(void*)this); //Fehlerbehandlung fehlt  
  780.   //  DosFreeMem(pvSharedMem);
  781.   //  pvSharedMem=NULL;
  782. }
  783.  
  784.  
  785.