1 /* mozillasounds.
cmd */
2 /* ***** BEGIN LICENSE BLOCK
*****
3 * Version
: MPL
1.1/GPL
2.0/LGPL
2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the
"License"); you may
not use this file except in compliance with
7 * the License. You may obtain a
copy of the License at
8 * http
://www.mozilla.org
/MPL
/
10 * Software distributed under the License is distributed on an
"AS IS" basis
,
11 * WITHOUT WARRANTY OF ANY KIND
, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is a supplemental OS
/2 script.
17 * The Initial Developer of the Original Code is
18 * Rich Walsh
<dragtext@e
-vertise.com
>
19 * Portions created by the Initial Developer are Copyright
(C
) 2009
20 * the Initial Developer. All Rights Reserved.
24 * Alternatively
, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version
2 or later
(the
"GPL"), or
26 * the GNU Lesser General Public License Version
2.1 or later
(the
"LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above.
If you wish to allow
use of your version of this file only
29 * under the terms of either the GPL or the LGPL
, and
not to allow others to
30 * use your version of this file under the terms of the MPL
, indicate your
31 * decision by deleting the provisions above and
replace them with the notice
32 * and other provisions required by the GPL or the LGPL.
If you
do not delete
33 * the provisions above
, a recipient may
use your version of this file under
34 * the terms of any one of the MPL
, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK
***** */
38 /*****************************************************************************/
40 /* MozSounds.
cmd enables the user to associate sounds with Mozilla events
*/
41 /* using the WPS Sound object in the System Setup folder. It does
not set */
42 /* the sounds itself
- it simply adds entries to the Sound object
's list of */
43 /* events. This script only needs to be run once or twice: the first time */
44 /* to enable selected sounds, and the second time to disable most of them */
45 /* because they're so annoying.
*/
47 /* This script
's design is coordinated with code in widget\os2\nsSound.cpp. */
48 /* Please don't make significant changes to it
(e.g. changing the names of
*/
49 /* ini
-file entries
) without first examining nsSound.cpp.
*/
51 /* Note to Translators
: everything that needs to be translated has been
*/
52 /* grouped together and placed toward the
end of the file
(a heading
*/
53 /* identifies where to
start). Please preserve the formatting and don
't */
54 /* change any of the numeric values. Thanks... */
56 /*****************************************************************************/
58 call RxFuncAdd 'SysLoadFuncs
', 'RexxUtil
', 'SysLoadFuncs
'
64 /*****************************************************************************/
68 /* Get the location of the MMOS2 directory. */
69 path = value('MMBASE
',,'OS2ENVIRONMENT
')
75 path = strip(path, B, ';')
77 /* Confirm that mmpm.ini can be found where we expect it to be. */
78 iniFile = path'\MMPM.INI
'
79 call SysFileTree iniFile, 'stem
', 'FO
'
80 if stem.0 <> 1 then do
86 /* Make a backup of mmpm.ini if one doesn't already
exist.
*/
87 call SysFileTree iniFile
'.BAK', 'stem', 'FO'
89 '@xcopy' iniFile
path'\*.*.BAK /T > NUL'
91 /* Events are identified by number
- MMOS2 uses
0-12. Mozilla events
*/
92 /* start at
800.
If this conflicts with another app
, the base index
*/
93 /* can be changed. The new value is stored in mmpm.ini where it can
*/
94 /* be accessed by the Mozilla apps and this script.
*/
95 baseIndex
= SysIni
(iniFile
, 'MOZILLA_Events', 'BaseIndex')
96 baseIndex
= strip
(baseIndex
, T
, X2C
('0'))
97 if baseIndex
= 'ERROR:' | baseIndex
<= '12' then
98 baseIndex
= defaultIndex
100 /* The main loop
: display current status
& respond to commands
*/
108 when cmd = soundCmd
then do
109 rc
= SysOpenObject
('<WP_SOUND>', 2, 'TRUE')
113 when cmd = exitCmd
then do
117 when cmd = disableCmd
then do
121 when cmd = enableCmd
then do
125 /* this
command is
"undocumented" & should
NOT be translated
*/
126 when cmd = 'BASEINDEX' then do
136 /*****************************************************************************/
138 /* Generate a listing of Mozilla events and their status
: */
139 /* 'enabled' if there
's an entry, 'disabled
' if not. */
146 do nbr = 1 to events.0
147 rc = SysIni(iniFile, 'MMPM2_AlarmSounds
', baseIndex + events.nbr.ndx)
148 if rc = 'ERROR
:' then
149 status = disabledWord
154 out = " "nbr". " left(events.nbr.name, 15) status
158 line.ctr = left(out, 35) " " nbr". " left(events.nbr.name, 15) status
165 line.ctr = left(out, 35)
169 /*****************************************************************************/
171 /* Disable an event sound by deleting its entry. */
175 parse var parms nbr parms
177 if nbr = allWord then do
179 parms = '2 3 4 5 6 7'
183 if nbr >= '1' & nbr <= '7' then do
184 key = baseIndex + events.nbr.ndx
185 rc = SysIni(iniFile, 'MMPM2_AlarmSounds
', key, 'DELETE
:')
187 parse var parms nbr parms
192 /*****************************************************************************/
194 /* Enable an event sound by adding an entry whose format is: */
195 /* 'fq_soundfile#event_name#volume
'. */
196 /* Since this script isn't intended to
set the actual soundfile
, */
197 /* it uses the same dummy value as MMOS2
: 'x:\MMOS2\SOUNDS\' */
201 parse var parms nbr parms
203 if nbr = allWord then do
205 parms = '2 3 4 5 6 7'
209 if nbr >= '1' & nbr <= '7' then do
210 key = baseIndex + events.nbr.ndx
212 /* if there's an existing entry
, preserve the filename
*/
213 sndFile
= SysIni
(iniFile
, 'MMPM2_AlarmSounds', key
)
214 if sndFile
= 'ERROR:' | left
(sndFile
, 1) = '#' then
215 sndFile
= path'\'soundsDir'\'
217 parse var sndFile sndFile
'#' .
218 value
= sndFile
'#'events.nbr.name
' (Mozilla)#80'X2C
('0')
220 rc
= SysIni
(iniFile
, 'MMPM2_AlarmSounds', key
, value
)
222 parse var parms nbr parms
227 /*****************************************************************************/
229 /* An
"undocumented" function to change
& restore the base index.
*/
230 /* It renumbers existing entries using the new base
& adds or deletes
*/
231 /* a
'MOZILLA_Events\BaseIndex' entry depending on the new value.
*/
235 parse var parms newIndex parms
237 /* Ignore invalid values.
*/
238 if newIndex
= '' | newIndex
<= '12' then
241 /* Do NOT translate this.
*/
242 if newIndex
= 'DEFAULT' then
243 newIndex
= defaultIndex
245 /* If there
's no change, exit after deleting the entry if it's the default
*/
246 if newIndex
= baseIndex
then do
247 if baseIndex
= defaultIndex
then
248 rc SysIni
(iniFile
, 'MOZILLA_Events', 'BaseIndex', 'DELETE:')
252 /* Move existing entries from the old index to the new index.
*/
253 do nbr
= 1 to events
.0
254 value
= SysIni
(iniFile
, 'MMPM2_AlarmSounds', baseIndex
+ events.nbr.ndx
)
255 if value
= 'ERROR:' then
258 rc
= SysIni
(iniFile
, 'MMPM2_AlarmSounds', baseIndex
+ events.nbr.ndx
, 'DELETE:')
259 rc
= SysIni
(iniFile
, 'MMPM2_AlarmSounds', newIndex
+ events.nbr.ndx
, value
)
262 /* If the new index is the default
, delete the ini entry
; */
263 /* otherwise
, add or update the entry with the new value.
*/
264 if newIndex
= defaultIndex
then
265 rc
= SysIni
(iniFile
, 'MOZILLA_Events', 'BaseIndex', 'DELETE:')
267 rc
= SysIni
(iniFile
, 'MOZILLA_Events', 'BaseIndex', newIndex||X2C
('0'))
273 /*****************************************************************************/
274 /* All strings that need to be translated appear below
*/
275 /*****************************************************************************/
277 /* Just like it says
, init variables.
*/
283 events
.1.name
= 'New Mail'
285 events
.2.name
= 'Alert Dialog'
287 events
.3.name
= 'Confirm Dialog'
289 events
.4.name
= 'Prompt Dialog'
291 events
.5.name
= 'Select Dialog'
293 events
.6.name
= 'Menu Execute'
295 events
.7.name
= 'Menu Popup'
297 enabledWord
= 'enabled'
298 disabledWord
= 'disabled'
311 /*****************************************************************************/
313 /* Display event status
& command info.
*/
318 say " MozSounds.cmd lets you use the WPS Sound object in your System Setup"
319 say " folder to assign sounds to the Mozilla events listed below. It does"
320 say " NOT set the sound itself - it just adds and deletes entries in Sound."
321 say " New or changed sounds take effect after the Mozilla app is restarted."
323 say " Event Status Event Status"
324 say " ----------- -------- ----------- --------"
331 say " E - enable event sound(s) example: 'E 1' or 'E 3 5 7' or 'E All'"
332 say " D - disable event sound(s) example: 'D 2' or 'D 1 4 6' or 'D All'"
333 say " S - open the WPS Sound object"
334 say " X - exit this script"
336 call charout
," Enter a command > "
340 /*****************************************************************************/
342 /* Display an error message
*/
347 say "ERROR: the 'MMBASE' environment variable is missing or invalid!"
348 say " Your Mozilla app won't be able to play system sounds without it."
349 say " Please add a line to config.sys like the following, then reboot."
350 say " SET MMBASE=x:\MMOS2 (where 'x' is the correct drive)"
354 /*****************************************************************************/
356 /* Display an error message
*/
361 say "ERROR: file '"iniFile
"' is missing or invalid!"
362 say " Your Mozilla app won't be able to play system sounds without it."
363 say " Please confirm that the 'SET MMBASE=' line in config.sys points"
364 say " at your MMOS2 directory and that it contains 'MMPM.INI'."
368 /*****************************************************************************/