home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1999 November / PCONLINE_11_99.ISO / filesbbs / OS2 / ACDCR032.ZIP / source / dataaddcdrecordpage.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-08-08  |  7.9 KB  |  262 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 <stdio.h>
  24. #include <string.h>//for memccpy()
  25. #include <stdlib.h>
  26.  
  27.  
  28. extern char chrImage[CCHMAXPATH];/* Path to iso-image */
  29. extern LONG lMKOptions;
  30. extern BOOL setupDone;
  31. extern char lnchParam[1024];
  32. extern char chrInstallDir[CCHMAXPATH];
  33.  
  34. extern ATOM atomStartWrite;
  35.  
  36.  
  37.  
  38. HMODULE queryModuleHandle(void);
  39.  
  40.  
  41. PSZ buildWrapName(PSZ wrapperName);
  42. ULONG launchWriter(PSZ parameter, PSZ folderPath,HWND hwnd, PSZ wrapperExe);
  43.  
  44. ULONG launchMkisofs(HWND hwnd);
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51. /* This Proc also handles the data CD writing */
  52. MRESULT EXPENTRY mkisofsObjectProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  53. {
  54.   CWDataFolder * thisPtr;
  55.  
  56.   switch (msg)
  57.     {
  58.     case WM_APPTERMINATENOTIFY:
  59.       thisPtr=(CWDataFolder*)WinQueryWindowULong(hwnd,QWL_USER);/* Get object ptr */
  60.       if(thisPtr) {
  61.         thisPtr->cwSetStatusText("");      
  62.         if(thisPtr->pvSharedMem) {/* We just created an image or wrote on the fly */
  63.           if(!(LONGFROMMP(mp1))) {/* imageCreation */
  64.             if(!(LONGFROMMP(mp2)))
  65.               WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, "CD-ROM image file created. You may burn this file on a CDR now.",
  66.                              "Create image file.",
  67.                              0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
  68.             else
  69.               WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, "Error while creating the image file.",
  70.                              "Create image file.",
  71.                              0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
  72.           }
  73.           else {/* On the fly */
  74.             if(!(LONGFROMMP(mp2)))
  75.               WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, "CD-ROM successfully created.",
  76.                              "On the fly writing.",
  77.                              0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
  78.             else
  79.               WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, "Error while writing on the fly!",
  80.                              "On the fly writing",
  81.                              0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
  82.           } 
  83.         }
  84.         else {/* We wrote an image file */
  85.           if(!(LONGFROMMP(mp2)))
  86.             WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, "Image file written by CDRecord/2.",
  87.                            "Write image file.",
  88.                            0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
  89.           else
  90.             WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, "Error while writing the image file. Examine 'write.log.'",
  91.                            "Write image file.",
  92.                            0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
  93.         }
  94.       }
  95.       WinPostMsg(hwnd,WM_QUIT,0,0);
  96.       break;
  97.     default:
  98.       if(msg == atomStartWrite) {
  99.         thisPtr=(CWDataFolder*)PVOIDFROMMP(mp1);
  100.         WinSetWindowULong(hwnd,QWL_USER,(ULONG)thisPtr);/* Save object ptr */
  101.         if(!thisPtr) {
  102.           /* Error: quit */
  103.           WinPostMsg(hwnd,WM_QUIT,(MPARAM)0,(MPARAM)0);
  104.           return 0;
  105.         }   
  106.         if(!mp2) {
  107.           /* Start mkisofs */
  108.           if(launchMkisofs(hwnd))
  109.             WinPostMsg(hwnd,WM_QUIT,(MPARAM)0,(MPARAM)0);
  110.           return FALSE;
  111.         }
  112.         else {
  113.           if(LONGFROMMP(mp2)==1) {
  114.             /* Start cdrecord */
  115.             launchWriter(lnchParam, chrInstallDir, hwnd,"cdr2lnch.exe");
  116.             return FALSE;
  117.           }
  118.           else {
  119.             launchWriter("", chrInstallDir, hwnd,"onthefly.exe");
  120.             return FALSE;
  121.           }
  122.         }
  123.       }
  124.       return WinDefWindowProc( hwnd, msg, mp1, mp2);
  125.     }
  126.   return FALSE;
  127. }
  128.  
  129. /* This thread waits for the mkisofs process to end */
  130. void _Optlink mkisofsThreadFunc (void *arg)
  131. {
  132.   HWND hwndMkisofs;
  133.   HAB  hab;
  134.   HMQ  hmq;
  135.   QMSG qmsg;
  136.  
  137.   CWDataFolder * thisPtr;
  138.  
  139.   thisPtr=(CWDataFolder*)arg;
  140.     
  141.   hab=WinInitialize(0);
  142.   if(hab) {
  143.     hmq=WinCreateMsgQueue(hab,0);
  144.     if(hmq) {
  145.       hwndMkisofs=WinCreateWindow(HWND_OBJECT,WC_STATIC,"myMkisofsObj",0,0,0,0,0,NULL,HWND_BOTTOM,12341,NULL,NULL);
  146.       if(hwndMkisofs) {
  147.         WinSubclassWindow(hwndMkisofs,&mkisofsObjectProc);
  148.         /* Window created. */             
  149.         WinPostMsg(hwndMkisofs,atomStartWrite,MPFROMP(thisPtr),0);
  150.  
  151.         thisPtr->cwSetStatusText(NULL);
  152.  
  153.         thisPtr->cwEnableWriteControls(FALSE);
  154.         while(WinGetMsg(hab,&qmsg,(HWND)NULL,0,0))
  155.           WinDispatchMsg(hab,&qmsg);
  156.         WinDestroyWindow(hwndMkisofs);
  157.       }
  158.  
  159.       WinDestroyMsgQueue(hmq);
  160.     }
  161.     WinTerminate(hab);
  162.   }
  163.   /* Free cmd-line mem */
  164.   if(thisPtr->pvSharedMem) {
  165.     DosFreeMem(thisPtr->pvSharedMem);
  166.     thisPtr->pvSharedMem=0;
  167.   }
  168.   thisPtr->cwEnableWriteControls(TRUE);
  169.   sprintf(thisPtr->chrStatusText,"");
  170.   //  DosBeep(100,2000);
  171. }
  172.  
  173. /* This thread waits for the write process to end */
  174. void _Optlink imageWriteThreadFunc (void *arg)
  175. {
  176.   HWND hwndMkisofs;
  177.   HAB  hab;
  178.   HMQ  hmq;
  179.   QMSG qmsg;
  180.   char text[CCHMAXPATH+100];
  181.  
  182.   CWDataFolder * thisPtr;
  183.  
  184.   thisPtr=(CWDataFolder*)arg;
  185.     
  186.   hab=WinInitialize(0);
  187.   if(hab) {
  188.     hmq=WinCreateMsgQueue(hab,0);
  189.     if(hmq) {
  190.       hwndMkisofs=WinCreateWindow(HWND_OBJECT,WC_STATIC,"myImageWriteObj",0,0,0,0,0,NULL,HWND_BOTTOM,12342,NULL,NULL);
  191.       if(hwndMkisofs) {
  192.         WinSubclassWindow(hwndMkisofs,&mkisofsObjectProc);
  193.         /* Window created. */             
  194.         WinPostMsg(hwndMkisofs,atomStartWrite,MPFROMP(thisPtr),MPFROMLONG(1L));
  195.         //sprintf(text,"Writing image file %s ...",chrImage);
  196.         thisPtr->cwSetStatusText(NULL);
  197.         thisPtr->cwEnableWriteControls(FALSE);
  198.         while(WinGetMsg(hab,&qmsg,(HWND)NULL,0,0))
  199.           WinDispatchMsg(hab,&qmsg);
  200.         WinDestroyWindow(hwndMkisofs);
  201.       }
  202.       WinDestroyMsgQueue(hmq);
  203.     }
  204.     WinTerminate(hab);
  205.   }
  206.   thisPtr->cwEnableWriteControls(TRUE);
  207.   sprintf(thisPtr->chrStatusText,"");
  208.   //  DosBeep(100,2000);
  209. }
  210.  
  211. /* This thread waits for the mkisofs process to end */
  212. void _Optlink flyThreadFunc (void *arg)
  213. {
  214.   HWND hwndMkisofs;
  215.   HAB  hab;
  216.   HMQ  hmq;
  217.   QMSG qmsg;
  218.   char text[CCHMAXPATH+100];
  219.  
  220.   CWDataFolder * thisPtr;
  221.  
  222.   thisPtr=(CWDataFolder*)arg;
  223.     
  224.   hab=WinInitialize(0);
  225.   if(hab) {
  226.     hmq=WinCreateMsgQueue(hab,0);
  227.     if(hmq) {
  228.       hwndMkisofs=WinCreateWindow(HWND_OBJECT,WC_STATIC,"myOnTheFlyWriteObj",0,0,0,0,0,NULL,HWND_BOTTOM,12343,NULL,NULL);
  229.       if(hwndMkisofs) {
  230.         WinSubclassWindow(hwndMkisofs,&mkisofsObjectProc);
  231.         /* Window created. */             
  232.         WinPostMsg(hwndMkisofs,atomStartWrite,MPFROMP(thisPtr),MPFROMLONG(2L));
  233.         sprintf(text,"Writing on the fly...");        
  234.         thisPtr->cwSetStatusText(NULL);
  235.         thisPtr->cwEnableWriteControls(FALSE);
  236.         while(WinGetMsg(hab,&qmsg,(HWND)NULL,0,0))
  237.           WinDispatchMsg(hab,&qmsg);
  238.         WinDestroyWindow(hwndMkisofs);
  239.       }
  240.       WinDestroyMsgQueue(hmq);
  241.     }
  242.     WinTerminate(hab);
  243.   }
  244.   thisPtr->cwEnableWriteControls(TRUE);
  245.   sprintf(thisPtr->chrStatusText,"");
  246.   /* Free cmd-line mem */
  247.   if(thisPtr->pvSharedMem) {
  248.     DosFreeMem(thisPtr->pvSharedMem);
  249.     thisPtr->pvSharedMem=0;
  250.   }
  251.   //  DosBeep(100,2000);
  252. }
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.