1 |
|
---|
2 | /*
|
---|
3 | * (C) Chris Wohlgemuth 2002-2004
|
---|
4 | *
|
---|
5 | */
|
---|
6 | /*
|
---|
7 | * This program is free software; you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation; either version 2, or (at your option)
|
---|
10 | * any later version.
|
---|
11 | *
|
---|
12 | * This program is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with this program; see the file COPYING. If not, write to
|
---|
19 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
20 | */
|
---|
21 | /*
|
---|
22 | * If you need another license for your project/product contact me at
|
---|
23 | *
|
---|
24 | * http://www.os2world.com/cdwriting
|
---|
25 | * http://www.geocities.com/SiliconValley/Sector/5785/
|
---|
26 | */
|
---|
27 |
|
---|
28 | /*
|
---|
29 | * This file was generated by the SOM Compiler and Emitter Framework.
|
---|
30 | * Generated using:
|
---|
31 | * SOM Emitter emitctm: 2.42
|
---|
32 | */
|
---|
33 |
|
---|
34 | #ifndef SOM_Module_cwmmdisk_Source
|
---|
35 | #define SOM_Module_cwmmdisk_Source
|
---|
36 | #endif
|
---|
37 | #define CWMMDisk_Class_Source
|
---|
38 | #define M_CWMMDisk_Class_Source
|
---|
39 |
|
---|
40 | #define INCL_PM
|
---|
41 | #define INCL_DOS
|
---|
42 | #define INCL_DOSERRORS
|
---|
43 | #define INCL_WINWORKPLACE
|
---|
44 | #define INCL_DOSDEVIOCTL
|
---|
45 |
|
---|
46 | #include "os2.h"
|
---|
47 | #include <stdio.h>
|
---|
48 | #include "cwmmdisk.ih"
|
---|
49 | #include "wpobject.h"
|
---|
50 | #include "wpfolder.h"
|
---|
51 |
|
---|
52 | #include "sys_funcs.h"
|
---|
53 |
|
---|
54 | HFILE openDrive(char* drive);
|
---|
55 | void closeDrive(HFILE hfDrive);
|
---|
56 | int CDQueryAudioCDTracks(HFILE hfDrive);
|
---|
57 |
|
---|
58 | ULONG checkForCDDrive(ULONG ulDriveNum);
|
---|
59 | void invalidateDriveInList(ULONG ulDriveNum);
|
---|
60 |
|
---|
61 | //#define OPEN_MMDISK 0x6500+0x400
|
---|
62 |
|
---|
63 | /*
|
---|
64 | * wpInitData : override;
|
---|
65 | *wpDelete : override;
|
---|
66 | */
|
---|
67 |
|
---|
68 | SOM_Scope HWND SOMLINK cwmmdisk_wpViewObject(CWMMDisk *somSelf,
|
---|
69 | HWND hwndCnr, ULONG ulView,
|
---|
70 | ULONG param)
|
---|
71 | {
|
---|
72 | /* CWMMDiskData *somThis = CWMMDiskGetData(somSelf); */
|
---|
73 | CWMMDiskMethodDebug("CWMMDisk","cwmmdisk_wpViewObject");
|
---|
74 |
|
---|
75 | if(ulView == OPEN_DETAILS || ulView == OPEN_CONTENTS || ulView == OPEN_TREE || ulView == OPEN_DEFAULT) {
|
---|
76 | int iDiskNum;
|
---|
77 |
|
---|
78 | if((iDiskNum=_wpQueryLogicalDrive(somSelf))!=0) {
|
---|
79 | // if((iDiskNum>=iFirstCD && iDiskNum<=iFirstCD+iNumCD)) {
|
---|
80 | // SysWriteToTrapLog("Drive: %d, CD: %d\n", iDiskNum, checkForCDDrive(iDiskNum));
|
---|
81 | if(checkForCDDrive(iDiskNum)==1) {
|
---|
82 | /* It's a CD drive */
|
---|
83 | HOBJECT hObject;
|
---|
84 | char chrPlayerID[100];
|
---|
85 | HFILE hFile;
|
---|
86 |
|
---|
87 | /* Check if it's an audio CD */
|
---|
88 | sprintf(chrPlayerID, "%c:", 'A'+iDiskNum-1 );
|
---|
89 | if((hFile=openDrive(chrPlayerID))!=NULLHANDLE) {
|
---|
90 | int iNumTracks;
|
---|
91 |
|
---|
92 | iNumTracks=CDQueryAudioCDTracks( hFile);
|
---|
93 | // SysWriteToTrapLog("Drive %s opened. Num tracks: %d", chrPlayerID, iNumTracks);
|
---|
94 | closeDrive(hFile);
|
---|
95 | if(iNumTracks> 0) {
|
---|
96 | sprintf(chrPlayerID, "<CWMM_CDPLAYER_%c>", 'A'+iDiskNum-1);
|
---|
97 | if((hObject=WinQueryObject(chrPlayerID))!=NULLHANDLE) {
|
---|
98 | WPObject *wpObject;
|
---|
99 | HWND hwnd = 0;
|
---|
100 | wpObject=_wpclsQueryObject( _CWMMDisk , hObject);
|
---|
101 | if(somIsObj(wpObject)) {
|
---|
102 | hwnd=_wpViewObject(wpObject, NULLHANDLE, OPEN_DEFAULT, 0);
|
---|
103 | _wpUnlockObject(wpObject);
|
---|
104 | }
|
---|
105 | return hwnd;
|
---|
106 | }
|
---|
107 | }
|
---|
108 | }
|
---|
109 | }
|
---|
110 | }
|
---|
111 | }
|
---|
112 | return (CWMMDisk_parent_WPDisk_wpViewObject(somSelf, hwndCnr,
|
---|
113 | ulView, param));
|
---|
114 | }
|
---|
115 |
|
---|
116 | #if 0
|
---|
117 | /*
|
---|
118 | * wpInitData : override;
|
---|
119 | *wpDelete : override;
|
---|
120 | */
|
---|
121 |
|
---|
122 | SOM_Scope HWND SOMLINK cwmmdisk_wpViewObject(CWMMDisk *somSelf,
|
---|
123 | HWND hwndCnr, ULONG ulView,
|
---|
124 | ULONG param)
|
---|
125 | {
|
---|
126 | /* CWMMDiskData *somThis = CWMMDiskGetData(somSelf); */
|
---|
127 | CWMMDiskMethodDebug("CWMMDisk","cwmmdisk_wpViewObject");
|
---|
128 |
|
---|
129 | if(ulView == OPEN_DETAILS || ulView == OPEN_CONTENTS || ulView == OPEN_TREE || ulView == OPEN_DEFAULT) {
|
---|
130 | if(bGotCD) {
|
---|
131 | int iDiskNum;
|
---|
132 |
|
---|
133 | if((iDiskNum=_wpQueryLogicalDrive(somSelf))!=0) {
|
---|
134 | if((iDiskNum>=iFirstCD && iDiskNum<=iFirstCD+iNumCD)) {
|
---|
135 | /* It's a CD drive */
|
---|
136 | HOBJECT hObject;
|
---|
137 | char chrPlayerID[100];
|
---|
138 | ULONG ulRC;
|
---|
139 | HFILE hFile;
|
---|
140 |
|
---|
141 | /* Check if it's an audio CD */
|
---|
142 | sprintf(chrPlayerID, "%c:", 'A'+iDiskNum-1 );
|
---|
143 | if((hFile=openDrive(chrPlayerID))!=NULLHANDLE) {
|
---|
144 | int iNumTracks;
|
---|
145 | iNumTracks=CDQueryAudioCDTracks( hFile);
|
---|
146 | closeDrive(hFile);
|
---|
147 | if(iNumTracks> 0) {
|
---|
148 | sprintf(chrPlayerID, "<CWMM_CDPLAYER_%c>", 'A'+iDiskNum-1);
|
---|
149 |
|
---|
150 | if((hObject=WinQueryObject(chrPlayerID))!=NULLHANDLE) {
|
---|
151 | if((ulRC=WinOpenObject(hObject, OPEN_DEFAULT, TRUE))!=NULLHANDLE) {
|
---|
152 | return NULLHANDLE;}
|
---|
153 | }
|
---|
154 | /* For some strange reason WinOpenObject() returns 0 when the folder was already openend
|
---|
155 | by the user. If it's reopened using WinOpenObject() from this method it returns 1!?
|
---|
156 | We found the handle and tried to open it. Normally this succeeds so we just
|
---|
157 | proceed as if everything is ok. The only thing we might loose if opening wasn't
|
---|
158 | successful is the error box saying the CD isn't formatted properly (because it's an
|
---|
159 | audio CD). Most users will even not notice this difference ;-) */
|
---|
160 | return NULLHANDLE;
|
---|
161 | }
|
---|
162 | }
|
---|
163 | }
|
---|
164 | }
|
---|
165 | }
|
---|
166 | }
|
---|
167 | return (CWMMDisk_parent_WPDisk_wpViewObject(somSelf, hwndCnr,
|
---|
168 | ulView, param));
|
---|
169 | }
|
---|
170 | #endif
|
---|
171 |
|
---|
172 | #if 0
|
---|
173 | BOOL isCD(ULONG ulDriveNum)
|
---|
174 | {
|
---|
175 | /* This may be a remote drive */
|
---|
176 | char chrDev[8];
|
---|
177 | ULONG cbBuf;
|
---|
178 | ULONG rc;
|
---|
179 |
|
---|
180 | BYTE buf[sizeof(FSQBUFFER2)+3*CCHMAXPATH];
|
---|
181 | PFSQBUFFER2 pBuf=(PFSQBUFFER2)buf;
|
---|
182 |
|
---|
183 | sprintf(chrDev, "%c:", 'a'+ulDriveNum-1);
|
---|
184 | cbBuf=sizeof(buf);
|
---|
185 |
|
---|
186 | /* Check if local or remote (or anything else) */
|
---|
187 | rc= DosQueryFSAttach(chrDev, 0, FSAIL_QUERYNAME,(PFSQBUFFER2) &buf, &cbBuf);
|
---|
188 | if(!rc) {
|
---|
189 | PSZ pszFSDName;
|
---|
190 | PSZ prgFSAData;
|
---|
191 |
|
---|
192 | pszFSDName=pBuf->szName+pBuf->cbName+1;
|
---|
193 | prgFSAData=pszFSDName+pBuf->cbFSDName+1;
|
---|
194 | SysWriteToTrapLog(" %s, %s\n", pBuf->szName, pszFSDName, prgFSAData);
|
---|
195 |
|
---|
196 | // if(pBuf->iType==FSAT_REMOTEDRV)
|
---|
197 | // ulDisk=QDT_REMOTE_DRIVE;
|
---|
198 | }
|
---|
199 | return TRUE;
|
---|
200 | }
|
---|
201 | void isCD2(ULONG ulDriveNum) {
|
---|
202 | char chrPlayerID[100];
|
---|
203 | ULONG rc;
|
---|
204 | HFILE hFile;
|
---|
205 |
|
---|
206 | /* Check if it's an audio CD */
|
---|
207 | sprintf(chrPlayerID, "%c:", 'A'+ulDriveNum-1);
|
---|
208 | if((hFile=openDrive(chrPlayerID))!=NULLHANDLE) {
|
---|
209 | int iNumTracks;
|
---|
210 | ULONG ulParamLen;
|
---|
211 | ULONG ulDataLen;
|
---|
212 | ULONG ulData;
|
---|
213 |
|
---|
214 | ulParamLen=4;
|
---|
215 | ulDataLen=sizeof(ulData);
|
---|
216 | rc = DosDevIOCtl(hFile, IOCTL_CDROMDISK, CDROMDISK_DEVICESTATUS,
|
---|
217 | "CD01", 4, &ulParamLen, &ulData,
|
---|
218 | sizeof(ulData), &ulDataLen);
|
---|
219 | if(!rc)
|
---|
220 | SysWriteToTrapLog("%d: NO_ERROR, ", ulDriveNum);
|
---|
221 | else
|
---|
222 | SysWriteToTrapLog("%d: ERROR, ", ulDriveNum);
|
---|
223 | closeDrive(hFile);
|
---|
224 | return;
|
---|
225 | }
|
---|
226 | SysWriteToTrapLog("%d: Open drive failed, ", ulDriveNum);
|
---|
227 | }
|
---|
228 | #endif
|
---|
229 |
|
---|
230 | SOM_Scope BOOL SOMLINK cwmmdisk_wpFree(CWMMDisk *somSelf)
|
---|
231 | {
|
---|
232 | /* CWMMDiskData *somThis = CWMMDiskGetData(somSelf); */
|
---|
233 | CWMMDiskMethodDebug("CWMMDisk","cwmmdisk_wpFree");
|
---|
234 |
|
---|
235 | invalidateDriveInList(_wpQueryLogicalDrive(somSelf));
|
---|
236 | return (CWMMDisk_parent_WPDisk_wpFree(somSelf));
|
---|
237 | }
|
---|
238 |
|
---|
239 | SOM_Scope void SOMLINK cwmmdisk_wpObjectReady(CWMMDisk *somSelf,
|
---|
240 | ULONG ulCode,
|
---|
241 | WPObject* refObject)
|
---|
242 | {
|
---|
243 | ULONG ulDrive;
|
---|
244 |
|
---|
245 | /* CWMMDiskData *somThis = CWMMDiskGetData(somSelf); */
|
---|
246 | CWMMDiskMethodDebug("CWMMDisk","cwmmdisk_wpObjectReady");
|
---|
247 |
|
---|
248 | //SysWriteToTrapLog("\nLogical drive created: %d, Type is: %x\n",
|
---|
249 | // _wpQueryLogicalDrive(somSelf), SysQueryDriveType(_wpQueryLogicalDrive(somSelf)));
|
---|
250 |
|
---|
251 | // isCD2(_wpQueryLogicalDrive(somSelf));
|
---|
252 | // isCD(_wpQueryLogicalDrive(somSelf));
|
---|
253 |
|
---|
254 | CWMMDisk_parent_WPDisk_wpObjectReady(somSelf, ulCode, refObject);
|
---|
255 |
|
---|
256 | /*
|
---|
257 | @@CHANGE 0.2.8
|
---|
258 |
|
---|
259 | Insert CD drives into a global list whenever a drive object is created.
|
---|
260 | Remove it on destruction. This was added to support LVM systems with
|
---|
261 | dynamically attached USB CD-ROM drives.
|
---|
262 | */
|
---|
263 | ulDrive=_wpQueryLogicalDrive(somSelf);
|
---|
264 | if(ulDrive>2) /* Don't check floppies */
|
---|
265 | checkForCDDrive(ulDrive); /* This call inserts CD drives into a global list so
|
---|
266 | the entry is cached. It will be removed during processing of wpFree(). */
|
---|
267 |
|
---|
268 | }
|
---|
269 |
|
---|
270 |
|
---|
271 | SOM_Scope PSZ SOMLINK cwmmdiskM_wpclsQueryTitle(M_CWMMDisk *somSelf)
|
---|
272 | {
|
---|
273 | /* M_CWMMDiskData *somThis = M_CWMMDiskGetData(somSelf); */
|
---|
274 | M_CWMMDiskMethodDebug("M_CWMMDisk","cwmmdiskM_wpclsQueryTitle");
|
---|
275 |
|
---|
276 | return "CWMMDisk";
|
---|
277 | /* return (M_CWMMDisk_parent_M_WPDisk_wpclsQueryTitle(somSelf));*/
|
---|
278 | }
|
---|
279 |
|
---|
280 |
|
---|
281 |
|
---|
282 |
|
---|
283 |
|
---|