source: trunk/src/helpers/syssound.c@ 59

Last change on this file since 59 was 59, checked in by umoeller, 24 years ago

Various fixes for V0.9.10.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 26.2 KB
Line 
1
2/*
3 *@@sourcefile syssound.c:
4 * this has code for querying and manipulating the
5 * system sounds, which are stored in MMPM.INI in
6 * the MMOS2 directory. Also, we have support for
7 * manipulating Warp 4 sound schemes in here too.
8 * This code works on Warp 3 also.
9 *
10 * Usage: All OS/2 programs.
11 *
12 * Some of this code used to be in XWorkplace's main\common.c,
13 * as far as the regular system sounds were concerned.
14 * However, all this code has been greatly reworked
15 * and extended with V0.9.0.
16 *
17 * <B>About system sound configuration data</B>
18 *
19 * The current system sounds are stored in ?:\MMOS2\MMPM.INI.
20 *
21 * These are the general flags in the "MMPM2_AlarmSoundsData"
22 * application:
23 * -- If "EnableSounds" is FALSE, all system sounds are disabled.
24 * This defaults to TRUE (tested).
25 * -- If "ApplyVolumeToAll" is TRUE, the same volume is used for
26 * all sounds. This defaults to FALSE (tested).
27 * -- If ApplyVolumeToAll is TRUE, "Volume" is used for the
28 * global volume. Otherwise, the individual sound volumes
29 * (below) will be used.
30 *
31 * "MMPM2_AlarmSounds" then has all the system sounds. The keys
32 * in that application are numerical indices, which are listed
33 * in syssound.h.
34 *
35 * Each sound data block in there consists of three elements:
36 + soundfile#description#volume
37 * where "description" is what is listed in the "Sound" object.
38 * "volume" is only used when "ApplyVolumeToAll" (above) is FALSE.
39 *
40 * We have functions in this code file for decoding/setting this
41 * (sndParseSoundData, sndQuerySystemSound, sndWriteSoundData,
42 * sndSetSystemSound).
43 *
44 * By contrast (and for no real reason), Warp 4 stores the
45 * "sound schemes" in OS2SYS.INI. I stuck with that for compatibility,
46 * although this prevents several users from having different
47 * sound schemes. What the heck.
48 *
49 * Anyways, the "PM_SOUND_SCHEMES_LIST" application is a directory of
50 * schemes, which in turn point to other applications in OS2SYS.INI
51 * which have the actual sound scheme data. All these applications
52 * appear to start with "PM_SOUND_xxx" by convention.
53 *
54 * Note that as opposed to the sound data in MMPM.INI, only the
55 * sound file name is stored here (not the three elements as
56 * described above). We slightly extend that mechanism to add an
57 * additional volume data field after the first null byte. This
58 * allows the default WPSound object to still be able to read
59 * the sound scheme data (it apparently uses PrfQueryProfileString)
60 * while the XWorkplace sound object replacement (XWPSound) can
61 * still store volume data as well.
62 *
63 * I have created more functions in this code file to easily load and
64 * store sound schemes (sndDoesSchemeExist, sndCreateSoundScheme,
65 * sndLoadSoundScheme, sndDestroySoundScheme).
66 *
67 * Note: Version numbering in this file relates to XWorkplace version
68 * numbering.
69 *
70 *@@header "helpers\syssound.h"
71 *@@added V0.9.0 [umoeller]
72 */
73
74#define OS2EMX_PLAIN_CHAR
75 // this is needed for "os2emx.h"; if this is defined,
76 // emx will define PSZ as _signed_ char, otherwise
77 // as unsigned char
78
79#define INCL_DOSERRORS
80#define INCL_WINSHELLDATA
81#include <os2.h>
82
83#include <stdlib.h>
84#include <stdio.h>
85#include <string.h>
86
87#include "setup.h" // code generation and debugging options
88
89#include "helpers\dosh.h"
90#include "helpers\prfh.h"
91
92#include "helpers\syssound.h"
93
94#pragma hdrstop
95
96/*
97 *@@category: Helpers\Profile (INI) helpers\System sounds
98 * see syssound.c.
99 */
100
101/*
102 *@@ sndParseSoundData:
103 * this helper func splits the system sound data
104 * passed to it into three buffers.
105 * Each key data in there has the following format:
106 + soundfile#description#volume.
107 *
108 * This is copied into the three specified buffers.
109 * You can set any buffer pointer to NULL if you're
110 * not interested in that data.
111 *
112 * Returns the number of items successfully parsed,
113 * which should be 3.
114 *
115 *@@added V0.9.0 [umoeller]
116 */
117
118ULONG sndParseSoundData(PSZ pszSoundData, // in: INI data from MMPM.INI
119 PSZ pszDescr, // out: sound description, as displayed
120 // in the "Sound" object (ptr may be NULL)
121 PSZ pszFile, // out: sound file to (ptr may be NULL)
122 PULONG pulVolume) // out: sound volume (0-100). Note:
123 // this always returns the individual sound volume,
124 // even if "Global volume" is set in MMPM.INI.
125{
126 PSZ p1 = pszSoundData, p2;
127 ULONG ulrc = 0;
128 // get sound file
129 p2 = strchr(p1, '#');
130 if (p2)
131 {
132 ulrc++;
133 if (pszFile)
134 {
135 strncpy(pszFile, p1, p2-p1);
136 pszFile[p2-p1] = '\0';
137 }
138 p1 = p2+1;
139
140 // get sound description
141 p2 = strchr(p1, '#');
142 if (p2)
143 {
144 ulrc++;
145 if (pszDescr)
146 {
147 strncpy(pszDescr, p1, p2-p1);
148 pszDescr[p2-p1] = '\0';
149 }
150 p1 = p2+1;
151
152 // get volume (0-100)
153 if (pulVolume)
154 {
155 // individual volume settings per sound
156 sscanf(p1, "%lu", pulVolume);
157 ulrc++;
158 }
159 }
160 }
161
162 return (ulrc);
163}
164
165/*
166 *@@ sndQueryMmpmIniPath:
167 * writes the full path of MMPM.INI into
168 * the specified buffer (e.g. C:\MMOS2\MMPM.INI).
169 *
170 *@@added V0.9.10 (2001-04-16) [umoeller]
171 */
172
173VOID sndQueryMmpmIniPath(PSZ pszMMPM) // out: fully q'fied MMPM.INI
174{
175 PSZ pszMMPMPath = getenv("MMBASE"); // V0.9.6 (2000-10-16) [umoeller]
176 if (pszMMPMPath)
177 {
178 // variable set:
179 PSZ p;
180
181 strcpy(pszMMPM, pszMMPMPath); // V0.9.7 (2000-12-17) [umoeller]
182
183 // kill semicolon if present
184 p = strchr(pszMMPM, ';');
185 if (p)
186 *p = 0;
187
188 strcat(pszMMPM, "\\MMPM.INI");
189 }
190 else
191 // variable not set (shouldn't happen): try boot drive
192 sprintf(pszMMPM, "%c:\\MMOS2\\MMPM.INI", doshQueryBootDrive());
193}
194
195/*
196 *@@ sndOpenMmpmIni:
197 * this opens \MMOS2\MMPM.INI on the
198 * boot drive and returns the profile
199 * handle (or NULLHANDLE upon errors).
200 * Use PrfCloseProfile to close the
201 * profile again.
202 *
203 *@@added V0.9.1 (99-12-19) [umoeller]
204 *@@changed V0.9.6 (2000-10-16) [umoeller]: now using MMBASE environment variable
205 *@@changed V0.9.6 (2000-10-16) [umoeller]: added proper HAB param
206 *@@changed V0.9.7 (2000-12-17) [umoeller]: fixed broken MMBASE handling
207 */
208
209HINI sndOpenMmpmIni(HAB hab)
210{
211 HAB habDesktop = WinQueryAnchorBlock(HWND_DESKTOP);
212 CHAR szMMPM[CCHMAXPATH];
213 HINI hini = NULLHANDLE;
214
215 sndQueryMmpmIniPath(szMMPM);
216
217 hini = PrfOpenProfile(habDesktop, szMMPM);
218 return (hini);
219}
220
221/*
222 *@@ sndQuerySystemSound:
223 * this gets a system sound from the MMPM.INI file.
224 * usIndex must be the sound to query. The following
225 * MMSOUND_* IDs are declared in syssound.h:
226 *
227 * Default system sounds (syssound.h):
228 * -- MMSOUND_WARNING 0
229 * -- MMSOUND_INFORMATION 1
230 * -- MMSOUND_ERROR 2
231 * -- MMSOUND_ANIMATEOPEN 3
232 * -- MMSOUND_ANIMATECLOSE 4
233 * -- MMSOUND_DRAG 5
234 * -- MMSOUND_DROP 6
235 * -- MMSOUND_SYSTEMSTARTUP 7
236 * -- MMSOUND_SHUTDOWN 8
237 * -- MMSOUND_SHREDDER 9
238 * -- MMSOUND_LOCKUP 10
239 * -- MMSOUND_ALARMCLOCK 11
240 * -- MMSOUND_PRINTERROR 12
241 *
242 * BTW, these values match those of the WinAlarm call
243 * (WA_* values), but only the first three are documented
244 * in PMREF and pmwin.h (WA_WARNING, WA_NOTE, WA_ERROR).
245 *
246 * New XWorkplace system sounds:
247 * -- MMSOUND_XFLD_SHUTDOWN 555
248 * -- MMSOUND_XFLD_RESTARTWPS 556
249 * -- MMSOUND_XFLD_CTXTOPEN 558
250 * -- MMSOUND_XFLD_CTXTSELECT 559
251 * -- MMSOUND_XFLD_CNRDBLCLK 560
252 *
253 * The string buffers are recommended to be at least
254 * CCHMAXPATH in size.
255 *
256 *@@changed V0.9.0 [umoeller]: this used to be cmnQuerySystemSound
257 *@@changed V0.9.0 [umoeller]: exported stuff to sndParseSoundData
258 *@@changed V0.9.6 (2000-10-16) [umoeller]: added proper HAB param
259 */
260
261BOOL sndQuerySystemSound(HAB hab, // in: caller's anchor block
262 USHORT usIndex, // in: sound index to query
263 PSZ pszDescr, // out: sound description, as displayed
264 // in the "Sound" object (ptr may be NULL)
265 PSZ pszFile, // out: sound file to (ptr may be NULL)
266 PULONG pulVolume) // out: sound volume (0-100).
267 // If the "Global volume" flag is
268 // set in MMPM.INI, this will return the global
269 // volume instead. Ptr may be NULL also.
270{
271 BOOL rc = FALSE;
272 HINI hiniMMPM = sndOpenMmpmIni(hab);
273
274 #ifdef DEBUG_SOUNDS
275 _Pmpf((__FUNCTION__ ": entering, hiniMMPM is 0x%lX", hiniMMPM));
276 #endif
277
278 if (hiniMMPM)
279 {
280 CHAR szData[1000];
281 CHAR szData2[100];
282 CHAR szKey[10];
283 sprintf(szKey, "%d", usIndex);
284 PrfQueryProfileString(hiniMMPM,
285 MMINIKEY_SOUNDSETTINGS, "EnableSounds",
286 "TRUE", // default string
287 szData2, sizeof(szData2));
288 #ifdef DEBUG_SOUNDS
289 _Pmpf((" sounds enabled: %s", szData2));
290 #endif
291 if (strcmp(szData2, "TRUE") == 0)
292 // sounds enabled at all?
293 if (PrfQueryProfileString(hiniMMPM,
294 MMINIKEY_SYSSOUNDS, szKey,
295 ".",
296 szData, sizeof(szData)-1) > 3)
297 {
298 sndParseSoundData(szData,
299 pszDescr,
300 pszFile,
301 pulVolume);
302
303 // if "global volume" has been enabled,
304 // we do not return the value specified
305 // here, but the global value
306 PrfQueryProfileString(hiniMMPM,
307 MMINIKEY_SOUNDSETTINGS, "ApplyVolumeToAll",
308 "FALSE",
309 szData2, sizeof(szData2));
310 if (strcmp(szData2, "FALSE") != 0)
311 {
312 // global volume setting for all sounds
313 PrfQueryProfileString(hiniMMPM,
314 MMINIKEY_SOUNDSETTINGS, "Volume",
315 "100",
316 szData2, sizeof(szData2));
317 sscanf(szData2, "%lu", pulVolume);
318 }
319
320 rc = TRUE;
321 }
322
323 PrfCloseProfile(hiniMMPM);
324 }
325
326 return (rc);
327}
328
329/*
330 *@@ sndWriteSoundData:
331 * this sets a system sound in MMPM.INI.
332 * Gets called by sndSetSystemSound. As opposed
333 * to that function, this needs the profile handle
334 * of MMPM.INI.
335 *
336 * If (pszDescr == NULL), that sound entry is removed.
337 *
338 * Returns the return value of PrfWriteProfileString.
339 *
340 *@@added V0.9.0 [umoeller]
341 *@@changed V0.9.1 (99-12-30) [umoeller]: added delete support
342 *@@changed V0.9.6 (2000-10-16) [umoeller]: added MMPM/2 notify
343 */
344
345BOOL sndWriteSoundData(HINI hiniMMPM, // in: MMPM.INI handle (from sndOpenMmpmIni)
346 USHORT usIndex, // in: sound index
347 PSZ pszDescr, // in: sound name or NULL for removal
348 PSZ pszFile, // in: sound file
349 ULONG ulVolume) // in: sound volume
350{
351 BOOL brc = FALSE;
352 CHAR szKey[10];
353
354 sprintf(szKey, "%d", usIndex);
355 if (pszDescr)
356 {
357 CHAR szData[1000];
358 // format: soundfile#description#volume
359 sprintf(szData, "%s#%s#%lu", pszFile, pszDescr, ulVolume);
360 brc = PrfWriteProfileString(hiniMMPM,
361 MMINIKEY_SYSSOUNDS, szKey,
362 szData);
363 }
364 else
365 // pszDescr == NULL:
366 // delete entry
367 brc = PrfWriteProfileString(hiniMMPM,
368 MMINIKEY_SYSSOUNDS, szKey,
369 NULL);
370
371 if (brc)
372 // success:
373 if (usIndex < 100)
374 // one of the default OS/2 sounds has changed:
375 // we then need to notify MMPM/2...
376 // this is done by calling WinAlarm with 1000+index!
377 // sick stuff..
378 WinAlarm(HWND_DESKTOP, usIndex+1000); // V0.9.6 (2000-10-16) [umoeller]
379
380 return (brc);
381}
382
383/*
384 *@@ sndSetSystemSound:
385 * this sets a system sound in MMPM.INI by
386 * calling sndWriteSoundData.
387 * Returns FALSE if an error occured.
388 *
389 * See sndQuerySystemSound for the parameters.
390 *
391 *@@changed V0.9.0 [umoeller]: this used to be cmnSetSystemSound
392 *@@changed V0.9.0 [umoeller]: exported stuff to sndWriteSoundData
393 *@@changed V0.9.6 (2000-10-16) [umoeller]: added proper HAB param
394 */
395
396BOOL sndSetSystemSound(HAB hab,
397 USHORT usIndex,
398 PSZ pszDescr,
399 PSZ pszFile,
400 ULONG ulVolume)
401{
402 BOOL brc = FALSE;
403 HINI hiniMMPM = sndOpenMmpmIni(hab);
404 if (hiniMMPM)
405 {
406 brc = sndWriteSoundData(hiniMMPM, usIndex, pszDescr, pszFile, ulVolume);
407 PrfCloseProfile(hiniMMPM);
408 }
409 return (brc);
410}
411
412/*
413 *@@ sndDoesSchemeExist:
414 * returns TRUE if pszScheme already exists
415 * in OS2SYS.INI.
416 *
417 *@@added V0.9.0 [umoeller]
418 */
419
420BOOL sndDoesSchemeExist(PSZ pszScheme)
421{
422 // check in OS2SYS.INI's scheme list whether that
423 // scheme exists already
424 PSZ pszExisting = prfhQueryProfileData(HINI_SYSTEM,
425 MMINIKEY_SOUNDSCHEMES, // "PM_SOUND_SCHEMES_LIST"
426 pszScheme,
427 NULL);
428 if (pszExisting)
429 {
430 free(pszExisting);
431 return (TRUE);
432 }
433
434 return (FALSE);
435}
436
437/*
438 *@@ sndCreateSoundScheme:
439 * this creates a new sound scheme and copies
440 * the current data in MMPM.INI into it.
441 * No check is made for whether that sound
442 * scheme exists already (use sndDoesSchemeExist
443 * for that). Data is overwritten without further
444 * discussion.
445 *
446 * Returns:
447 * -- NO_ERROR
448 * -- ERROR_INVALID_HANDLE: hiniMMPM invalid
449 * -- ERROR_NO_DATA: scheme not found.
450 *
451 *@@added V0.9.0 [umoeller]
452 */
453
454APIRET sndCreateSoundScheme(HINI hiniMMPM, // in: MMPM.INI handle (from sndOpenMmpmIni)
455 PSZ pszNewScheme) // in: name of new scheme
456{
457 APIRET arc = NO_ERROR;
458 CHAR szNewAppName[200] = "PM_SOUNDS_";
459
460 // create a unique new application name for
461 // this scheme in OS2SYS.INI (this is how
462 // Warp 4 apparently does it)
463 strcat(szNewAppName, pszNewScheme); // PM_SOUNDS_blahblah
464 strupr(szNewAppName); // PM_SOUNDS_BLAHBLAH
465
466 if (hiniMMPM)
467 {
468 // get applications list for sounds list in MMPM.INI
469 PSZ pszKeysList = prfhQueryKeysForApp(hiniMMPM,
470 MMINIKEY_SYSSOUNDS); // "MMPM2_AlarmSounds"
471 if (pszKeysList)
472 {
473 PSZ pKey2 = pszKeysList;
474
475 CHAR szFile[CCHMAXPATH+50];
476 ULONG ulVolume,
477 ulKeyLen;
478
479 while (*pKey2 != 0)
480 {
481 // now copy this key to the new sound scheme;
482 // however, we can't just copy the whole key,
483 // but need to extract the file name and
484 // volume first.
485 // Warp 4 normally _only_ stores the file name
486 // in the sound schemes. Since we want the
487 // volume also, we add a null char after the
488 // file name and append the volume...
489
490 PSZ pSoundData = prfhQueryProfileData(hiniMMPM,
491 MMINIKEY_SYSSOUNDS, // "MMPM2_AlarmSounds"
492 pKey2,
493 NULL);
494 if (pSoundData)
495 {
496 sndParseSoundData(pSoundData,
497 NULL, // we don't need the description
498 szFile,
499 &ulVolume);
500 ulKeyLen = strlen(szFile)+1; // go beyond null byte
501 ulKeyLen += sprintf(szFile+ulKeyLen,
502 "%lu",
503 ulVolume) + 1;
504 // and write to OS2SYS.INI
505 PrfWriteProfileData(HINI_SYSTEM,
506 szNewAppName,
507 pKey2,
508 szFile,
509 ulKeyLen);
510
511 free(pSoundData);
512 } // end if (pSoundData)
513
514 pKey2 += strlen(pKey2)+1;
515 } // end while (*pKey2 != 0)
516
517 free (pszKeysList);
518
519 // finally, store new scheme in schemes list
520 PrfWriteProfileString(HINI_SYSTEM,
521 MMINIKEY_SOUNDSCHEMES, // "PM_SOUND_SCHEMES_LIST"
522 pszNewScheme, // key is scheme name
523 szNewAppName); // data is new OS2SYS.INI application
524 }
525 else
526 arc = ERROR_NO_DATA;
527 }
528 else
529 arc = ERROR_INVALID_HANDLE;
530
531 return (arc);
532}
533
534/*
535 *@@ sndLoadSoundScheme:
536 * this loads the data in pszScheme (OS2SYS.INI)
537 * into MMPM.INI. Existing sound data
538 * in that profile will be overwritten.
539 *
540 * Note: Only those sounds in MMPM.INI will be
541 * overwritten for which a corresponding entry
542 * in the sound scheme exists. If it doesn't,
543 * the data in MMPM.INI for _that_ sound only
544 * will _not_ be changed. In other words, existing
545 * sound data will be merged with the scheme data.
546 *
547 * If you don't like this, delete the whole
548 * "MMPM2_AlarmSounds" application in MMPM.INI
549 * before calling this function.
550 *
551 * Returns:
552 * -- NO_ERROR
553 * -- ERROR_INVALID_HANDLE: hiniMMPM invalid
554 * -- ERROR_NO_DATA: scheme not found.
555 * -- ERROR_BAD_FORMAT: error in MMPM.INI data.
556 *
557 *@@added V0.9.0 [umoeller]
558 *@@changed V0.9.1 (99-12-20) [umoeller]: fixed memory leak
559 *@@changed V0.9.6 (2000-10-16) [umoeller]: added MMPM/2 notify
560 */
561
562APIRET sndLoadSoundScheme(HINI hiniMMPM, // in: HINI of ?:\MMOS2\MMPM.INI (PrfOpenProfile)
563 PSZ pszScheme) // in: scheme name
564{
565 APIRET arc = NO_ERROR;
566
567 #ifdef DEBUG_SOUNDS
568 _Pmpf(("Entering sndLoadSoundScheme"));
569 #endif
570
571 if (hiniMMPM)
572 {
573 // check in OS2SYS.INI's scheme list whether that
574 // scheme exists already
575 PSZ pszSchemeAppName = prfhQueryProfileData(HINI_SYSTEM,
576 MMINIKEY_SOUNDSCHEMES, // "PM_SOUND_SCHEMES_LIST"
577 pszScheme,
578 NULL);
579 #ifdef DEBUG_SOUNDS
580 _Pmpf((" pszSchemeAppName: %s", pszSchemeAppName));
581 #endif
582
583 if (pszSchemeAppName)
584 {
585 // now copy keys from OS2SYS.INI to MMPM.INI;
586 // since OS2SYS.INI _only_ has the file name
587 // (and _maybe_ the individual volume, if it
588 // was us who created the sound scheme --
589 // see sndCreateSoundScheme above), we need
590 // to go thru the MMPM.INI (!) sounds lists
591 // and merge the data in there with the
592 // corresponding sound data for the current
593 // scheme...
594
595 // get applications list for sounds list in MMPM.INI
596 PSZ pszMMPMKeysList = prfhQueryKeysForApp(hiniMMPM,
597 MMINIKEY_SYSSOUNDS); // "MMPM2_AlarmSounds"
598 if (pszMMPMKeysList)
599 {
600 PSZ pMMPMKey2 = pszMMPMKeysList,
601 pMMPMSoundData,
602 pSchemeSoundData;
603
604 CHAR szDescription[300]; // from MMPM.INI
605 CHAR szFile[CCHMAXPATH+50]; // from OS2SYS.INI
606 ULONG ulVolume; // from MMPM.INI _or_ OS2SYS.INI
607 CHAR szData[1000];
608
609 // go thru keys (numbers)
610 while (*pMMPMKey2 != 0)
611 {
612 ULONG cbSchemeSoundData = 0,
613 cbSchemeSoundFile = 0;
614
615 pMMPMSoundData = prfhQueryProfileData(hiniMMPM,
616 MMINIKEY_SYSSOUNDS, // "MMPM2_AlarmSounds"
617 pMMPMKey2,
618 NULL);
619 pSchemeSoundData = prfhQueryProfileData(HINI_SYSTEM,
620 pszSchemeAppName,
621 pMMPMKey2,
622 &cbSchemeSoundData);
623
624 if ((pMMPMSoundData) && (pSchemeSoundData))
625 {
626 sndParseSoundData(pMMPMSoundData,
627 szDescription,
628 NULL, // we don't need the file
629 &ulVolume);
630 // now overwrite this data with scheme data
631 strcpy(szFile,
632 pSchemeSoundData); // up to first null byte
633 cbSchemeSoundFile = strlen(pSchemeSoundData)+1;
634 if (cbSchemeSoundData > cbSchemeSoundFile)
635 // this means we have an additional volume string
636 // after the null byte (sndCreateSoundScheme);
637 // copy it
638 sscanf(pSchemeSoundData + cbSchemeSoundFile,
639 "%lu",
640 &ulVolume);
641
642 // and write data to MMPM.INI
643 // format: soundfile#description#volume
644 sprintf(szData, "%s#%s#%lu", szFile, szDescription, ulVolume);
645 if (PrfWriteProfileString(hiniMMPM,
646 MMINIKEY_SYSSOUNDS, // "MMPM2_AlarmSounds"
647 pMMPMKey2, // key (decimal number)
648 szData))
649 {
650 // success:
651 USHORT usIndex = atoi(pMMPMKey2);
652 if (usIndex < 100)
653 // this was one of the default OS/2 sounds:
654 // notify MMPM/2 of the change... see sndWriteSoundData
655 // V0.9.6 (2000-10-16) [umoeller]
656 WinAlarm(HWND_DESKTOP, usIndex+1000);
657 }
658 }
659
660 if (pMMPMSoundData)
661 free(pMMPMSoundData);
662 if (pSchemeSoundData)
663 free(pSchemeSoundData);
664
665 pMMPMKey2 += strlen(pMMPMKey2)+1;
666 } // end while (*pMMPMKey2 != 0)
667
668 free (pszMMPMKeysList);
669 }
670 else
671 arc = ERROR_BAD_FORMAT;
672
673 free(pszSchemeAppName);
674 } // end if (pszSchemeAppName)
675 else
676 arc = ERROR_NO_DATA;
677 }
678 else
679 arc = ERROR_INVALID_HANDLE;
680
681 #ifdef DEBUG_SOUNDS
682 _Pmpf(("End of sndLoadSoundScheme, arc: %d", arc));
683 #endif
684 return (arc);
685}
686
687/*
688 *@@ sndDestroySoundScheme:
689 * destroys pszScheme in OS2SYS.INI;
690 * returns TRUE is pszScheme was found
691 * and deleted.
692 *
693 * See xsound.c for explanations.
694 *
695 * Returns:
696 * -- NO_ERROR
697 * -- ERROR_NO_DATA: scheme not found.
698 *
699 *@@added V0.9.0 [umoeller]
700 */
701
702APIRET sndDestroySoundScheme(PSZ pszScheme)
703{
704 APIRET arc = NO_ERROR;
705
706 // check in OS2SYS.INI's scheme list whether that
707 // scheme exists already
708 PSZ pszExisting = prfhQueryProfileData(HINI_SYSTEM,
709 MMINIKEY_SOUNDSCHEMES, // "PM_SOUND_SCHEMES_LIST"
710 pszScheme,
711 NULL);
712 if (pszExisting)
713 {
714 // delete whole existing PM_SOUNDS_BLAHBLAH application
715 PrfWriteProfileString(HINI_SYSTEM,
716 pszExisting, // application
717 NULL,
718 NULL);
719 // and delete entry in sound schemes list
720 PrfWriteProfileString(HINI_SYSTEM,
721 MMINIKEY_SOUNDSCHEMES, // "PM_SOUND_SCHEMES_LIST"
722 pszScheme,
723 NULL);
724 free(pszExisting);
725 }
726 else
727 arc = ERROR_NO_DATA;
728
729 return (arc);
730}
731
732
Note: See TracBrowser for help on using the repository browser.