File: MozSounds.cmd

package info (click to toggle)
wine-gecko-2.24 2.24%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 740,092 kB
  • ctags: 688,789
  • sloc: cpp: 3,160,639; ansic: 1,619,153; python: 164,084; java: 128,022; asm: 114,527; xml: 69,863; sh: 55,281; makefile: 49,648; perl: 20,454; objc: 2,344; yacc: 2,066; pascal: 995; lex: 982; exp: 449; php: 244; lisp: 228; awk: 211; sed: 61; csh: 21; ada: 16; ruby: 3
file content (337 lines) | stat: -rw-r--r-- 10,190 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
/* mozillasounds.cmd */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/*****************************************************************************/
/*                                                                           */
/* MozSounds.cmd enables the user to associate sounds with Mozilla events    */
/* using the WPS Sound object in the System Setup folder.  It does not set   */
/* the sounds itself - it simply adds entries to the Sound object's list of  */
/* events.  This script only needs to be run once or twice:  the first time  */
/* to enable selected sounds, and the second time to disable most of them    */
/* because they're so annoying.                                              */
/*                                                                           */
/* This script's design is coordinated with code in widget\os2\nsSound.cpp.  */
/* Please don't make significant changes to it (e.g. changing the names of   */
/* ini-file entries) without first examining nsSound.cpp.                    */
/*                                                                           */
/* Note to Translators:  everything that needs to be translated has been     */
/* grouped together and placed toward the end of the file (a heading         */
/* identifies where to start).  Please preserve the formatting and don't     */
/* change any of the numeric values.  Thanks...                              */
/*                                                                           */
/*****************************************************************************/

call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
call InitVariables
call Main
exit

/*****************************************************************************/

Main:

  /* Get the location of the MMOS2 directory. */
  path = value('MMBASE',,'OS2ENVIRONMENT')
  if path = '' then do
    call SysCls
    call EnvError
    return
  end
  path = strip(path, B, ';')

  /* Confirm that mmpm.ini can be found where we expect it to be. */
  iniFile = path'\MMPM.INI'
  call SysFileTree iniFile, 'stem', 'FO'
  if stem.0 <> 1 then do
    call SysCls
    call IniError
    return
  end

  /* Make a backup of mmpm.ini if one doesn't already exist. */
  call SysFileTree iniFile'.BAK', 'stem', 'FO'
  if stem.0 = 0 then
    '@xcopy' iniFile path'\*.*.BAK /T > NUL'

  /* Events are identified by number - MMOS2 uses 0-12.  Mozilla events */
  /* start at 800.  If this conflicts with another app, the base index  */
  /* can be changed.  The new value is stored in mmpm.ini where it can  */
  /* be accessed by the Mozilla apps and this script.                   */
  baseIndex = SysIni(iniFile, 'MOZILLA_Events', 'BaseIndex')
  baseIndex = strip(baseIndex, T, X2C('0'))
  if baseIndex = 'ERROR:' | baseIndex <= '12' then
    baseIndex = defaultIndex

  /* The main loop:  display current status & respond to commands */
  do FOREVER
    call SysCls
    call GetStatus
    call Display
    pull cmd parms

    select
      when cmd = soundCmd then do
        rc = SysOpenObject('<WP_SOUND>', 2, 'TRUE')
        leave
      end

      when cmd = exitCmd then do
        leave
      end

      when cmd = disableCmd then do
        call Disable
      end

      when cmd = enableCmd then do
        call Enable
      end

      /* this command is "undocumented" & should NOT be translated */
      when cmd = 'BASEINDEX' then do
        call ChangeBaseIndex
      end

      otherwise
    end
  end

  return

/*****************************************************************************/

/* Generate a listing of Mozilla events and their status: */
/* 'enabled' if there's an entry, 'disabled' if not.      */

GetStatus:

  ctr = 1
  show = 0

  do nbr = 1 to events.0
    rc = SysIni(iniFile, 'MMPM2_AlarmSounds', baseIndex + events.nbr.ndx)
    if rc = 'ERROR:' then
      status = disabledWord
    else
      status = enabledWord

    if show = 0 then do
      out = " "nbr". " left(events.nbr.name, 15) status
      show = 1
    end
    else do
      line.ctr = left(out, 35) " " nbr". " left(events.nbr.name, 15) status
      ctr = ctr + 1
      show = 0
    end
  end

  if show = 1 then
    line.ctr = left(out, 35)

  return

/*****************************************************************************/

/* Disable an event sound by deleting its entry. */

Disable:

  parse var parms nbr parms

  if nbr = allWord then do
    nbr = '1'
    parms = '2 3 4 5 6 7'
  end

  do while nbr <> ''
    if nbr >= '1' & nbr <= '7' then do
      key = baseIndex + events.nbr.ndx
      rc = SysIni(iniFile, 'MMPM2_AlarmSounds', key, 'DELETE:')
    end
    parse var parms nbr parms
  end

return

/*****************************************************************************/

/* Enable an event sound by adding an entry whose format is:     */
/*   'fq_soundfile#event_name#volume'.                           */
/* Since this script isn't intended to set the actual soundfile, */
/* it uses the same dummy value as MMOS2: 'x:\MMOS2\SOUNDS\'     */

Enable:

  parse var parms nbr parms

  if nbr = allWord then do
    nbr = '1'
    parms = '2 3 4 5 6 7'
  end

  do while nbr <> ''
    if nbr >= '1' & nbr <= '7' then do
      key = baseIndex + events.nbr.ndx

      /* if there's an existing entry, preserve the filename */
      sndFile = SysIni(iniFile, 'MMPM2_AlarmSounds', key)
      if sndFile = 'ERROR:' | left(sndFile, 1) = '#' then
        sndFile = path'\'soundsDir'\'
      else
        parse var sndFile sndFile '#' .
      value = sndFile'#'events.nbr.name' (Mozilla)#80'X2C('0')

      rc = SysIni(iniFile, 'MMPM2_AlarmSounds', key, value)
    end
    parse var parms nbr parms
  end

return

/*****************************************************************************/

/* An "undocumented" function to change & restore the base index.     */
/* It renumbers existing entries using the new base & adds or deletes */
/* a 'MOZILLA_Events\BaseIndex' entry depending on the new value.     */

ChangeBaseIndex:

  parse var parms newIndex parms

  /* Ignore invalid values. */
  if newIndex = '' | newIndex <= '12' then
    return

  /* Do NOT translate this. */
  if newIndex = 'DEFAULT' then
    newIndex = defaultIndex

  /* If there's no change, exit after deleting the entry if it's the default */
  if newIndex = baseIndex then do
    if baseIndex = defaultIndex then
      rc SysIni(iniFile, 'MOZILLA_Events', 'BaseIndex', 'DELETE:')
    return
  end

  /* Move existing entries from the old index to the new index. */
  do nbr = 1 to events.0
    value = SysIni(iniFile, 'MMPM2_AlarmSounds', baseIndex + events.nbr.ndx)
    if value = 'ERROR:' then
      iterate

    rc = SysIni(iniFile, 'MMPM2_AlarmSounds', baseIndex + events.nbr.ndx, 'DELETE:')
    rc = SysIni(iniFile, 'MMPM2_AlarmSounds',  newIndex + events.nbr.ndx, value)
  end

  /* If the new index is the default, delete the ini entry; */
  /* otherwise, add or update the entry with the new value. */
  if newIndex = defaultIndex then
    rc = SysIni(iniFile, 'MOZILLA_Events', 'BaseIndex', 'DELETE:')
  else
    rc = SysIni(iniFile, 'MOZILLA_Events', 'BaseIndex', newIndex||X2C('0'))

  baseIndex = newIndex

  return

/*****************************************************************************/
/* All strings that need to be translated appear below                       */
/*****************************************************************************/

/* Just like it says, init variables. */

InitVariables:

  events.0 = 7
  events.1.ndx  = 0
  events.1.name = 'New Mail'
  events.2.ndx  = 1
  events.2.name = 'Alert Dialog'
  events.3.ndx  = 2
  events.3.name = 'Confirm Dialog'
  events.4.ndx  = 3
  events.4.name = 'Prompt Dialog'
  events.5.ndx  = 4
  events.5.name = 'Select Dialog'
  events.6.ndx  = 5
  events.6.name = 'Menu Execute'
  events.7.ndx  = 6
  events.7.name = 'Menu Popup'

  enabledWord   = 'enabled'
  disabledWord  = 'disabled'
  allWord       = 'ALL'
  soundsDir     = 'SOUNDS'

  enableCmd     = 'E'
  disableCmd    = 'D'
  soundCmd      = 'S'
  exitCmd       = 'X'

  defaultIndex  = '800'

  return

/*****************************************************************************/

/* Display event status & command info. */

Display:

  say
  say " MozSounds.cmd lets you use the WPS Sound object in your System Setup"
  say " folder to assign sounds to the Mozilla events listed below.  It does"
  say " NOT set the sound itself - it just adds and deletes entries in Sound."
  say " New or changed sounds take effect after the Mozilla app is restarted."
  say
  say "     Event           Status               Event           Status"
  say "     -----------     --------             -----------     --------"
  say line.1
  say line.2
  say line.3
  say line.4
  say
  say " Commands:"
  say " E - enable event sound(s)    example: 'E 1' or 'E 3 5 7' or 'E All'"
  say " D - disable event sound(s)   example: 'D 2' or 'D 1 4 6' or 'D All'"
  say " S - open the WPS Sound object"
  say " X - exit this script"
  say
  call charout ," Enter a command > "

  return

/*****************************************************************************/

/* Display an error message */

EnvError:

  say ""
  say "ERROR:  the 'MMBASE' environment variable is missing or invalid!"
  say "  Your Mozilla app won't be able to play system sounds without it."
  say "  Please add a line to config.sys like the following, then reboot."
  say "  SET MMBASE=x:\MMOS2  (where 'x' is the correct drive)"

  return

/*****************************************************************************/

/* Display an error message */

IniError:

  say ""
  say "ERROR:  file '"iniFile"' is missing or invalid!"
  say "  Your Mozilla app won't be able to play system sounds without it."
  say "  Please confirm that the 'SET MMBASE=' line in config.sys points"
  say "  at your MMOS2 directory and that it contains 'MMPM.INI'."

  return

/*****************************************************************************/