1 | /*
|
---|
2 | * This file is (C) Chris Wohlgemuth 2002
|
---|
3 | *
|
---|
4 | * It's part of the media folder distribution
|
---|
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 | #include "cdfolder.hh"
|
---|
23 | #include <stdio.h>
|
---|
24 | #include <stdlib.h>
|
---|
25 |
|
---|
26 | //extern HMODULE hResource;
|
---|
27 | extern char chrInstallDir[CCHMAXPATH];
|
---|
28 |
|
---|
29 | ULONG launchRexx(PSZ rexxFile);
|
---|
30 | HMODULE queryModuleHandle(PSZ pszClassName);
|
---|
31 | HMODULE queryResModuleHandle(void);
|
---|
32 | BOOL _queryHelpLibrary(char * chrBuffer, int iSize);
|
---|
33 | BOOL getMessage(char* text,ULONG ulID, LONG lSizeText, HMODULE hResource,HWND hwnd);
|
---|
34 | BOOL extern CDQueryCDDrives(int *iNumCD, char * cFirstDrive);
|
---|
35 | SOMClass* somhlpGetSomClass(char* chrClassName);
|
---|
36 | HMODULE queryModuleHandle(PSZ pszClassName);
|
---|
37 |
|
---|
38 | /* Overriden function which returns our class name */
|
---|
39 | PSZ M_CWCDFolder::wpclsQueryTitle()
|
---|
40 | {
|
---|
41 | static char chrTitle[40];
|
---|
42 |
|
---|
43 | if(getMessage(chrTitle, IDSTR_TITLECDFOLDER,sizeof(chrTitle), queryResModuleHandle(), HWND_DESKTOP))
|
---|
44 | return chrTitle;
|
---|
45 | /* Fall back in case of error */
|
---|
46 | return "CD-Player";
|
---|
47 | }
|
---|
48 |
|
---|
49 | ULONG M_CWCDFolder::wpclsQueryStyle()
|
---|
50 | {
|
---|
51 | return (M_CWMediaFolder::wpclsQueryStyle()|CLSSTYLE_NEVERTEMPLATE|CLSSTYLE_DONTTEMPLATE);
|
---|
52 | }
|
---|
53 |
|
---|
54 | BOOL M_CWCDFolder::wpclsCreateDefaultTemplates(WPObject * wpObject)
|
---|
55 | {
|
---|
56 | /* We don't wont any templates */
|
---|
57 | return TRUE;
|
---|
58 | }
|
---|
59 |
|
---|
60 | /* Overriden function which returns the custom icon */
|
---|
61 | ULONG M_CWCDFolder::wpclsQueryIconData(PICONINFO pIconInfo)
|
---|
62 | {
|
---|
63 | // HMODULE hResource=queryResModuleHandle();
|
---|
64 | HMODULE hResource=queryModuleHandle("M_CWCDFolder");
|
---|
65 |
|
---|
66 | if(!hResource)
|
---|
67 | return M_CWMediaFolder::wpclsQueryIconData(pIconInfo);
|
---|
68 |
|
---|
69 | if (pIconInfo) {
|
---|
70 | pIconInfo->fFormat = ICON_RESOURCE;
|
---|
71 | pIconInfo->hmod = hResource;
|
---|
72 | pIconInfo->resid = IDICON_CDFOLDER;
|
---|
73 | } /* endif */
|
---|
74 |
|
---|
75 | return ( sizeof(ICONINFO) );
|
---|
76 | }
|
---|
77 |
|
---|
78 |
|
---|
79 |
|
---|
80 | /* Overriden function which returns the custom icon */
|
---|
81 | ULONG M_CWCDFolder::wpclsQueryIconDataN(PICONINFO pIconInfo, ULONG ulIconIndex)
|
---|
82 | {
|
---|
83 | HMODULE hResource=queryResModuleHandle();
|
---|
84 |
|
---|
85 | if(!hResource)
|
---|
86 | return M_CWMediaFolder::wpclsQueryIconData(pIconInfo);
|
---|
87 |
|
---|
88 | if (pIconInfo) {
|
---|
89 | pIconInfo->fFormat = ICON_RESOURCE;
|
---|
90 | pIconInfo->hmod = hResource;
|
---|
91 | pIconInfo->resid = IDICON_CDFOLDER;
|
---|
92 | } /* endif */
|
---|
93 |
|
---|
94 | return ( sizeof(ICONINFO) );
|
---|
95 | }
|
---|
96 |
|
---|
97 | #if 0
|
---|
98 | MRESULT EXPENTRY cdCreateObjWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
99 | {
|
---|
100 |
|
---|
101 | switch (msg)
|
---|
102 | {
|
---|
103 | case WM_APPTERMINATENOTIFY:
|
---|
104 | {
|
---|
105 | DosBeep(5000, 200);
|
---|
106 | WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, 1, 2500);
|
---|
107 | break;
|
---|
108 | }
|
---|
109 | case WM_TIMER:
|
---|
110 | if(SHORT1FROMMP(mp1)==1) {
|
---|
111 | int iNumCD;
|
---|
112 | char cFirst;
|
---|
113 |
|
---|
114 | WinStopTimer(WinQueryAnchorBlock(hwnd), hwnd,1);
|
---|
115 |
|
---|
116 | if(CDQueryCDDrives(&iNumCD, &cFirst)) {
|
---|
117 | char name[100];
|
---|
118 | char setup[100];
|
---|
119 | char id[40];
|
---|
120 | int a;
|
---|
121 |
|
---|
122 | DosSleep(1000);
|
---|
123 |
|
---|
124 | while(!somhlpGetSomClass(CDFLDR_CLASSNAME))
|
---|
125 | DosSleep(100);
|
---|
126 |
|
---|
127 | for(a=0;a<iNumCD;a++) {
|
---|
128 | int b;
|
---|
129 | /* Build folder name */
|
---|
130 | sprintf(name, "CD-Audio^Drive %c:", cFirst+a);
|
---|
131 | /* Build object ID */
|
---|
132 | sprintf(id, CDFLDR_ID, cFirst+a);
|
---|
133 | /* Build setup string */
|
---|
134 | sprintf(setup, "%s=%c:;OBJECTID=%s;", CDFLDR_DRIVE, cFirst+a, id);
|
---|
135 | for(b=1;b<=5;b++) {
|
---|
136 | /* Wait to let WPS load the class if not yet done. Then retry */
|
---|
137 | if(!WinCreateObject(CDFLDR_CLASSNAME, name, setup,CDFLDR_LOCATION, CO_UPDATEIFEXISTS))
|
---|
138 | printf("Can't create %s\n", name);
|
---|
139 | else
|
---|
140 | break;
|
---|
141 | DosSleep(1000);
|
---|
142 | }
|
---|
143 | }
|
---|
144 | }
|
---|
145 | return (MRESULT)FALSE;
|
---|
146 | }
|
---|
147 | break;
|
---|
148 | default:
|
---|
149 | break;
|
---|
150 | }
|
---|
151 | return WinDefWindowProc( hwnd, msg, mp1, mp2);
|
---|
152 | }
|
---|
153 |
|
---|
154 | void _Optlink createCDThreadFunc (void *arg)
|
---|
155 | {
|
---|
156 | HAB hab;
|
---|
157 | HMQ hmq;
|
---|
158 | QMSG qmsg;
|
---|
159 |
|
---|
160 | hab=WinInitialize(0);
|
---|
161 | if(hab) {
|
---|
162 | hmq=WinCreateMsgQueue(hab,0);
|
---|
163 | if(hmq) {
|
---|
164 | HWND hwnd;
|
---|
165 | int iNumCD;
|
---|
166 | char cFirst;
|
---|
167 |
|
---|
168 | if(CDQueryCDDrives(&iNumCD, &cFirst)) {
|
---|
169 | char name[100];
|
---|
170 | char setup[100];
|
---|
171 | char id[40];
|
---|
172 | int a;
|
---|
173 |
|
---|
174 | DosSleep(1000);
|
---|
175 |
|
---|
176 | while(!somhlpGetSomClass(CDFLDR_CLASSNAME))
|
---|
177 | DosSleep(100);
|
---|
178 |
|
---|
179 | for(a=0;a<iNumCD;a++) {
|
---|
180 | int b;
|
---|
181 | /* Build folder name */
|
---|
182 | sprintf(name, "CD-Audio^Drive %c:", cFirst+a);
|
---|
183 | /* Build object ID */
|
---|
184 | sprintf(id, CDFLDR_ID, cFirst+a);
|
---|
185 | /* Build setup string */
|
---|
186 | sprintf(setup, "%s=%c:;OBJECTID=%s;", CDFLDR_DRIVE, cFirst+a, id);
|
---|
187 | for(b=1;b<=5;b++) {
|
---|
188 | /* Wait to let WPS load the class if not yet done. Then retry */
|
---|
189 | if(!WinCreateObject(CDFLDR_CLASSNAME, name, setup,CDFLDR_LOCATION, CO_UPDATEIFEXISTS))
|
---|
190 | printf("Can't create %s\n", name);
|
---|
191 | else
|
---|
192 | break;
|
---|
193 | DosSleep(1000);
|
---|
194 | }
|
---|
195 | }
|
---|
196 | }
|
---|
197 | WinDestroyMsgQueue(hmq);
|
---|
198 | }
|
---|
199 | WinTerminate(hab);
|
---|
200 | }
|
---|
201 | }
|
---|
202 | #endif
|
---|
203 |
|
---|
204 | void _Optlink createCDThreadFunc (void *arg)
|
---|
205 | {
|
---|
206 | HAB hab;
|
---|
207 | HMQ hmq;
|
---|
208 | QMSG qmsg;
|
---|
209 |
|
---|
210 | hab=WinInitialize(0);
|
---|
211 | if(hab) {
|
---|
212 | hmq=WinCreateMsgQueue(hab,0);
|
---|
213 | if(hmq) {
|
---|
214 |
|
---|
215 | launchRexx( SCRIPT_CREATEPLAYERS);
|
---|
216 |
|
---|
217 | WinDestroyMsgQueue(hmq);
|
---|
218 | }
|
---|
219 | WinTerminate(hab);
|
---|
220 | }
|
---|
221 | }
|
---|
222 |
|
---|
223 | void M_CWCDFolder::wpclsInitData()
|
---|
224 | {
|
---|
225 | static BOOL bObjectsCreated=FALSE;
|
---|
226 |
|
---|
227 | /* Call parent */
|
---|
228 | M_CWMediaFolder::wpclsInitData();
|
---|
229 |
|
---|
230 | /* Be sure we have our install dir */
|
---|
231 | queryModuleHandle("M_CWCDFolder");
|
---|
232 |
|
---|
233 | /*
|
---|
234 | V0.2.8 CW 2004/11/01
|
---|
235 |
|
---|
236 | Don't start a thread here for creating the cd objects. That will hang the
|
---|
237 | system in many cases.
|
---|
238 | */
|
---|
239 | #if 0
|
---|
240 | /* Start skript to create cd objects */
|
---|
241 | _beginthread(createCDThreadFunc,NULL,8192*16, NULLHANDLE); //Fehlerbehandlung fehlt
|
---|
242 | #endif
|
---|
243 |
|
---|
244 | #if 0
|
---|
245 | if(!bObjectsCreated) {
|
---|
246 | HWND hwnd;
|
---|
247 |
|
---|
248 | // _beginthread(createCDThreadFunc,NULL,8192*16, NULLHANDLE); //Fehlerbehandlung fehlt
|
---|
249 | // launchRexx( SCRIPT_CREATEPLAYERS);
|
---|
250 | hwnd=WinCreateWindow(HWND_OBJECT,WC_STATIC,"playObj", 0, 0, 0, 0, 0,
|
---|
251 | NULLHANDLE, HWND_BOTTOM,12343,NULL,NULL);
|
---|
252 | if(hwnd) {
|
---|
253 | /* Window created. */
|
---|
254 |
|
---|
255 | if(WinSubclassWindow(hwnd,cdCreateObjWindowProc))
|
---|
256 | DosBeep(1000, 200);
|
---|
257 | WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, 0, 0);
|
---|
258 | }
|
---|
259 | }
|
---|
260 | bObjectsCreated=TRUE;
|
---|
261 | #endif
|
---|
262 | }
|
---|
263 |
|
---|
264 | BOOL M_CWCDFolder::wpclsQueryDefaultHelp(PULONG HelpPanelId,PSZ HelpLibrary)
|
---|
265 | {
|
---|
266 | if(HelpLibrary)
|
---|
267 | _queryHelpLibrary(HelpLibrary, CCHMAXPATH);
|
---|
268 |
|
---|
269 | if(HelpPanelId)
|
---|
270 | *HelpPanelId= IDHLP_CDFOLDERMAIN;
|
---|
271 |
|
---|
272 | return TRUE;
|
---|
273 | }
|
---|