home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / Fax / AVMN199D.LHA / avminstall / rexx / processmailbox.avm < prev    next >
Encoding:
Text File  |  1995-08-19  |  21.1 KB  |  811 lines

  1. /* TITLE: avm:rexx/processmailbox.avm */
  2. /* This is called as a command with mailbox */
  3.  
  4. /* we want results! Otherwise, we wouldn't get anything from RESULT */
  5. options results
  6.  
  7. /* Need to make sure that stdtail.avm is also included */
  8. signal on halt
  9. signal on novalue
  10. signal on syntax
  11. signal on break_c
  12.  
  13. /* needed for some of the functions we use */
  14. call addlib("rexxsupport.library", 0, -30, 0)
  15.  
  16. /* a higher than normal priority since calls are important to us :) */
  17. call pragma('priority', 1)
  18.  
  19.  
  20. parse arg mailbox .
  21. call loadMailBox(mailbox)
  22. calledSysop = 0
  23. pagedSysop = 0
  24.  
  25. if mailbox.autoalertb = 1 & mailbox.autoalertscript ~= '' then
  26.   address rexx 'alertsysop' mailbox
  27.  
  28. 'playvoice' voiceFile(mailbox,'Personal')
  29. a_=rc
  30. if 0 then nop
  31. else if a_=1 then signal aakeypressed
  32. else if a_=4 then signal stdfax
  33. else if a_=5 then signal stddata
  34. else if a_=8 then signal stdbusy
  35. else if a_=12 then signal stdabort
  36.  
  37. aaAnnounce:
  38. if mailbox.autoforwardannounce = 1 & mailbox.autoforward ~= '' then call announceForwardNumber
  39.  
  40. aanopersonal:
  41. 'playvoice' 'avm:voices/MailboxGreeting'
  42. a_=rc
  43. if 0 then nop
  44. else if a_=1 then signal aakeypressed
  45. else if a_=4 then signal stdfax
  46. else if a_=5 then signal stddata
  47. else if a_=8 then signal stdbusy
  48. else if a_=12 then signal stdabort
  49. else if a_=14 then signal stderror
  50. else if a_=16 then signal stderror
  51.  
  52. /* Init log file stuff */
  53.  
  54. aaskipinstructions:
  55. handle = makeUniqueFile()
  56. call initLogEntry()
  57. call time('r')
  58.  
  59. userBeep = getclip('AVMUserBeep')
  60. if userBeep = 'YES' then do
  61.  
  62. 'playvoice' 'avm:voices/UserBeep'
  63. a_=rc
  64. if 0 then nop
  65. else if a_=1 then signal aakeypressed
  66. else if a_=4 then signal stdfax
  67. else if a_=5 then signal stddata
  68. else if a_=8 then signal stdbusy
  69. else if a_=12 then signal stdabort
  70. else if a_=14 then signal stderror
  71. else if a_=16 then signal stderror
  72.  
  73. end; else do
  74.  
  75. 'playbeep' '3000' '0' '4'
  76. call stdPlayXX(rc)
  77.  
  78. end
  79.  
  80. 'recordvoice' '0' '-1' '-1' voiceFile(mailbox,handle)
  81. a_=rc
  82. if 0 then nop
  83. else if a_=1 then do;call aafixlog; signal aakeypressedafterrecord;end
  84. else if a_=2 then do;call aafixlog; signal stdabort;end
  85. else if a_=3 then do;call aafixlog; if upper(getclip('AVMDataAfterSilence')) = 'YES' then signal stddata; else signal stdabort;end
  86. else if a_=4 then do;call aafixlog; signal stdfax;end
  87. else if a_=5 then do;call aafixlog; signal stddata;end
  88. else if a_=8 then do;call aafixlog; signal stdbusy;end
  89. else if a_=10 then do;call aafixlog; signal aakeypressedafterrecord;end
  90. else if a_=12 then do;call aafixlog; signal stdabort;end
  91. else if a_=14 then do;call aafixlog; signal stderror;end
  92. else if a_=16 then do;call aafixlog; signal stderror;end
  93.  
  94. /* Shouldn't get here */
  95. signal stderror
  96.  
  97. aafixlog:
  98. /* This writes out the log file */
  99.  
  100. if mailbox.autoforwardb = 1 & mailbox.autoforwardondemand = "" & calledSysop = 0 then do
  101.   call aaCallSysop
  102. end
  103. if mailbox.autopageb = 1 & mailbox.autopageondemand = "" & pagedSysop = 0 then do
  104.   call aaPageSysop
  105. end
  106.  
  107. log.filename = handle
  108. log.length = trunc(time('e'))
  109. log.type = 'voice'; log.origMailbox = mailbox
  110. call saveLogEntry(mailbox, handle)
  111. preConv = upper(getclip('AVMPreConvert')); preConvShow = upper(getclip('AVMShowPreConvertGUI'))
  112. if preConv = 'YES' then
  113.   if preConvShow = 'YES' then address command 'run >nil: <nil: avm:voice2iff' ,
  114.     voiceFile(mailbox, handle) voiceFile(mailbox, handle) || 'i' '-preconvert'
  115.   else address command 'run >nil: <nil: avm:voice2iff',
  116.     voiceFile(mailbox, handle) voiceFile(mailbox, handle) || 'i' '-preconvert -nogui'
  117. return
  118.  
  119. aakeypressedafterrecord:
  120. 'flushphonebuffer'
  121.  
  122. processmailboxmenu:
  123. call aapresentmenu('avm:voices/MailboxCaller', '012345679#*', '3')
  124. a_=result
  125. if 0 then nop
  126. else if a_='=0' then signal processmailboxmenu
  127. else if a_='=1' then signal aaAnnounce
  128. else if a_='=2' then signal stdfaxinstruct
  129. else if a_='=3' then do;call aaleavenumber();end
  130. else if a_='=4' then do;good = getpassword(mailbox.autoalertondemand); if good then address rexx 'alertsysop' mailbox;end
  131. else if a_='=5' then signal stddatainstruct
  132. else if a_='=6' then do;good = getpassword(mailbox.autoforwardondemand); if good & calledSysop = 0 then call aaCallSysop();end
  133. else if a_='=7' then do;good = getpassword(mailbox.autopageondemand); if good & pagedSysop = 0 then call aaPageSysop();end
  134. else if a_='=9' then do;call 'avmrexxalt:maintenancemode'(mailbox);if symbol('RESULT')~='VAR' then exit;end
  135. else if a_='=#' then do;return 1;end
  136. else if a_='=*' then signal answervoiceDone
  137. else if a_=4 then signal stdfax
  138. else if a_=5 then signal stddata
  139. else if a_=8 then signal stdbusy
  140. else if a_=10 then signal answervoiceDone
  141. else if a_=12 then signal stdabort
  142. else if a_=14 then signal stderror
  143. else if a_=16 then signal stderror
  144. signal processmailboxmenu
  145.  
  146. /* Shouldn't get here */
  147. signal stderror
  148.  
  149. aaleavenumber:
  150. number = getNumber()
  151.  
  152. log.returnnumber = number
  153. call updateLogEntry(mailbox, handle)
  154. return
  155.  
  156. aakeypressed:
  157. call aapresentmenu('avm:voices/SkipFaxMaintenance', '012359#*', '3')
  158. a_=result
  159. if 0 then nop
  160. else if a_='=0' then signal aakeypressed
  161. else if a_='=1' then signal aaskipinstructions
  162. else if a_='=2' then signal stdfaxinstruct
  163. else if a_='=3' then signal aaAnnounce
  164. else if a_='=5' then signal stddatainstruct
  165. else if a_='=9' then do;call 'avmrexxalt:maintenancemode'(mailbox);if symbol('RESULT')~='VAR' then exit;end
  166. else if a_='=#' then do;return 1;end
  167. else if a_='=*' then signal stdabort
  168. else if a_=4 then signal stdfax
  169. else if a_=5 then signal stddata
  170. else if a_=8 then signal stdbusy
  171. else if a_=10 then signal answervoiceDone
  172. else if a_=12 then signal stdabort
  173. else if a_=14 then signal stderror
  174. else if a_=16 then signal stderror
  175. return
  176.  
  177. aaCallSysop:
  178. procedure expose mailbox. mailbox calledSysop
  179. if mailbox.autoforwardscript ~= "" & mailbox.autoforward ~= "" then do
  180.      calledSysop = 1
  181.      handle = makeUniqueFile()
  182.      call initLogEntry(); log.origmailbox = mailbox
  183.      log.filename = 'avm:voices/autoforward'; log.type = 'voice'
  184.      log.returnsendfunc = mailbox.autoforwardscript; log.returninterval = 5
  185.      log.returnretry = 3; log.returnnumber = mailbox.autoforward; log.altFileName = voiceFile(mailbox, 'Introduction')
  186.      call saveLogEntry('Outgoing', handle)
  187.  
  188. 'playvoice' 'avm:voices/BeingForwarded'
  189. call stdPlayXX(rc)
  190.  
  191.     call playNumber(mailbox.autoforward)
  192.  
  193. 'flushphonebuffer'
  194.  
  195. end
  196. return
  197.  
  198. announceForwardNumber:
  199. 'playvoice' 'avm:voices/AnnounceForward'
  200. call stdPlayXX(rc)
  201.  
  202. call playNumber(mailbox.autoforward)
  203.  
  204. 'playvoice' 'avm:voices/AnnounceAgain'
  205. call stdPlayXX(rc)
  206. return
  207.  
  208. aaPageSysop:
  209. procedure expose mailbox. mailbox pagedSysop
  210. if mailbox.autopagescript ~= "" & mailbox.autopage ~= "" then do
  211.      pagedSysop = 1
  212.      handle = makeUniqueFile()
  213.      call initLogEntry(); log.origmailbox = mailbox
  214.      log.filename = 'avm:voices/autoforward'; log.type = 'voice'
  215.      log.returnsendfunc = mailbox.autopagescript; log.returninterval = 5
  216.      log.returnretry = 3; log.returnnumber = mailbox.autopage; log.altFileName = voiceFile(mailbox, 'Introduction')
  217.      call saveLogEntry('Outgoing', handle)
  218. end
  219. return
  220.  
  221. answerVoiceDone:
  222. 'playvoice' 'avm:voices/Goodbye'
  223. call stdPlayXX(rc)
  224. exit
  225.  
  226. /* TITLE: avm:rexx/simplestdtail.avm */
  227. /* This is the standard tail */
  228. exit
  229.  
  230. exit
  231.  
  232. mailboxDir: procedure
  233.     parse arg mailbox
  234.  
  235.     return 'avmmbox:' || mailbox || '/'
  236.  
  237. logFile: procedure
  238.     parse arg mailbox, magiccookie
  239.  
  240.     return 'avmmbox:' || mailbox || '/logs/' || magiccookie
  241.  
  242. voiceFile: procedure
  243.     parse arg mailbox, magiccookie
  244.  
  245.         if (verify(magiccookie, '/:', 'M') = 0) then
  246.           return 'avmmbox:' || mailbox || '/voices/' || magiccookie
  247.         else
  248.           return magiccookie
  249.  
  250. makeUniqueFile: procedure
  251.     if arg() ~= 0 then do
  252.         rc = "makeUniqueFile: bad args"
  253.         signal error
  254.     end
  255.     return address() || '.' || date('i') || '.' || time('s') || '.' || random(1, 999, time('s'))
  256.  
  257. convertToDate: procedure
  258.     if arg() ~= 1 then do
  259.         rc = "convertToDate: bad args"
  260.         signal error
  261.     end
  262.     parse arg timeInC
  263.  
  264.     actualTime = (timeInC - (2922)*86400) // (86400)
  265.     actualDate = (timeInC - actualTime - 2922*86400) % 86400
  266.  
  267.     return actualDate /* returning it in 'internal' format */
  268.  
  269. convertToTime: procedure
  270.     if arg() ~= 1 then do
  271.         rc = "convertToTime: bad args"
  272.         signal error
  273.     end
  274.     parse arg timeInC
  275.     
  276.     actualTime = (timeInC - (2922)*86400) // (86400)
  277.  
  278.     return actualTime
  279.  
  280. cTime: procedure
  281.     /* 2922 = 8*365 + 2 */
  282.     /* 86400 = 24*60*60 */
  283.     return (date('i')+2922)*86400 + time('s')
  284.  
  285. /* this returns a handle that you must use after initializing log. */
  286. initLogEntry: procedure expose log.
  287.     if arg() ~= 0 then do
  288.         rc = "initLogEntry: bad args"
  289.         signal error
  290.     end
  291.     
  292.     drop log.
  293.         log. = ''
  294.  
  295.         acidname = getclip(address() || 'CIDNAME')
  296.         acidnumber = getclip(address() || 'CIDNUMBER')
  297.  
  298.     /* 2922 = 8*365 + 2 */
  299.     /* 86400 = 24*60*60 */
  300.     log.time = (date('i')+2922)*86400 + time('s')
  301.     log.cidname = acidname
  302.     log.cidnumber = acidnumber
  303.  
  304.     return
  305.  
  306. loadLogEntry: procedure expose log.
  307.     if arg() ~= 2 then do
  308.         rc = "loadLogEntry: bad args"
  309.         signal error
  310.     end
  311.     parse arg mailbox, handle
  312.  
  313.         drop log.
  314.         log. = ''
  315.  
  316.     if ~exists(mailboxDir(mailbox)) then do
  317.         call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
  318.         return
  319.     end
  320.  
  321.     opened = open(handle, logFile(mailbox, handle), 'r')
  322.         if opened then do
  323.         call showDebugger('Loading entry' logFile(mailbox, handle))
  324.         do while ~eof(handle)
  325.             line = readln(handle)
  326.             parse upper var line variable '=' value
  327.             log.variable = value
  328.         end
  329.         call close(handle)
  330.     end; else call showDebugger('Could not load' logFile(mailbox, handle))
  331.     return
  332.  
  333. /* pass a handle here */
  334. saveLogEntry: procedure expose log.
  335.     if arg() ~= 2 then do
  336.         rc = "saveLogEntry: bad args"
  337.         signal error
  338.     end
  339.     parse arg mailbox, handle
  340.  
  341.     if ~exists(mailboxDir(mailbox)) then do
  342.         call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
  343.         return
  344.     end
  345.  
  346.     opened = open(handle, logFile(mailbox, handle), 'w')
  347.  
  348.     if opened then do
  349.         call showDebugger('Saving entry' logFile(mailbox, handle))
  350.         call writeln(handle, 'TYPE=' || log.type)
  351.         call writeln(handle, 'TIME=' || log.time)
  352.         call writeln(handle, 'LENGTH=' || log.length)
  353.  
  354.         call writeln(handle, 'ORIGMAILBOX=' || log.origmailbox)
  355.  
  356.         call writeln(handle, 'CIDNAME=' || log.cidname)
  357.         call writeln(handle, 'CIDNUMBER=' || log.cidnumber)
  358.  
  359.         call writeln(handle, 'COMMENT=' || log.comment)
  360.  
  361.         call writeln(handle, 'FILENAME=' || log.filename)
  362.         call writeln(handle, 'ALTFILENAME=' || log.altfilename)
  363.  
  364.         call writeln(handle, 'RETURNNUMBER=' || log.returnnumber)
  365.         call writeln(handle, 'RETURNSENDFUNC=' || log.returnsendfunc)
  366.         call writeln(handle, 'RETURNSTATUS=' || log.returnstatus)
  367.  
  368.         call writeln(handle, 'RETURNRETRY=' || log.returnretry)
  369.         call writeln(handle, 'RETURNINTERVAL=' || log.returninterval)
  370.  
  371.         call close(handle)
  372.         address rexx 'broadcast' 'addtomailbox' mailbox handle
  373.     end; else call showDebugger('Could not save' logFile(mailbox, handle))
  374.  
  375.     return
  376.  
  377. /* pass a handle here */
  378. updateLogEntry: procedure expose log.
  379.     if arg() ~= 2 then do
  380.         rc = "updateLogEntry: bad args"
  381.         signal error
  382.     end
  383.     parse arg mailbox, handle
  384.  
  385.     if ~exists(mailboxDir(mailbox)) then do
  386.         call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
  387.         return
  388.     end
  389.  
  390.     if ~exists(logFile(mailbox, handle)) then do
  391.         call showDebugger('Unable to update non-existent' logFile(mailbox, handle))
  392.         return
  393.     end
  394.     opened = open(handle, logFile(mailbox, handle), 'w')
  395.  
  396.     if opened then do
  397.         call showDebugger('Updating entry' logFile(mailbox, handle))
  398.         call writeln(handle, 'TYPE=' || log.type)
  399.         call writeln(handle, 'TIME=' || log.time)
  400.         call writeln(handle, 'LENGTH=' || log.length)
  401.  
  402.         call writeln(handle, 'ORIGMAILBOX=' || log.origmailbox)
  403.  
  404.         call writeln(handle, 'CIDNAME=' || log.cidname)
  405.         call writeln(handle, 'CIDNUMBER=' || log.cidnumber)
  406.  
  407.         call writeln(handle, 'COMMENT=' || log.comment)
  408.  
  409.         call writeln(handle, 'FILENAME=' || log.filename)
  410.         call writeln(handle, 'ALTFILENAME=' || log.altfilename)
  411.  
  412.         call writeln(handle, 'RETURNNUMBER=' || log.returnnumber)
  413.         call writeln(handle, 'RETURNSENDFUNC=' || log.returnsendfunc)
  414.         call writeln(handle, 'RETURNSTATUS=' || log.returnstatus)
  415.  
  416.         call writeln(handle, 'RETURNRETRY=' || log.returnretry)
  417.         call writeln(handle, 'RETURNINTERVAL=' || log.returninterval)
  418.  
  419.         call close(handle)
  420.         address rexx 'broadcast' 'refreshmailboxentry' mailbox handle
  421.     end; else call showDebugger('Could not update' logFile(mailbox, handle))
  422.  
  423.     return
  424.  
  425.  
  426.  
  427. showDebugger: procedure
  428.     if arg() ~= 1 then do
  429.         say "showDebugger: ERROR"
  430.         exit 20
  431.     end
  432.  
  433.     parse arg debuggerInfo
  434.     
  435.     firstLine = sourceline(1)
  436.     parse var firstLine '/*' 'TITLE:' title '*/'
  437.     if showlist('p', 'AVMLOGGER') then
  438.         address 'AVMLOGGER' 'add' title ':' debuggerInfo
  439.     else
  440.         say title ':' debuggerInfo
  441.  
  442.     return 
  443.  
  444. /*-----------------------------------------------------------------------*/
  445. /*                         signal processing                             */
  446.  
  447. arexxerror:
  448. error:
  449.     call showDebugger("Error" rc "at line" sigl)
  450.     exit 20
  451.  
  452. break_c:
  453. halt:
  454.     call showDebugger("Halt/Break_C at line" sigl)
  455.     exit 20
  456.  
  457. novalue:
  458.     call showDebugger("No value at line" sigl)
  459.     exit 20
  460.  
  461. syntax:
  462.     call showDebugger("Syntax error" rc "at line" sigl)
  463.     exit 20
  464.  
  465. /* TITLE: avm:rexx/stdplayvoice.avm */
  466. stdPlayXX:
  467. procedure
  468. parse arg ret
  469.  
  470. rs.normal = 0
  471. rs.keydetected = 1
  472. rs.quietdetected = 2
  473. rs.silencedetected = 3
  474. rs.faxdetected = 4
  475. rs.datadetected = 5
  476. rs.busydetected = 8
  477. rs.timedout = 10
  478. rs.signaldetected = 12
  479. rs.overflow = 14
  480. rs.error = 16
  481. /* CB 0000 */
  482.  
  483. select
  484.   when ret=rs.faxdetected then signal stdfax
  485.   when ret=rs.datadetected then signal stddata
  486.   when ret=rs.busydetected then signal stdbusy
  487.   when ret=rs.signaldetected then signal stdabort
  488.   when ret=rs.overflow then signal stderror
  489.   when ret=rs.error then signal stderror
  490.   otherwise nop
  491. end
  492. return
  493.  
  494.  
  495. aapresentmenu:
  496. /* TITLE: avm:rexx/presentmenu.avm */
  497. procedure expose pmRetries pmTimesAround
  498. parse arg filename, valid, retries
  499. timesaround = retries
  500. pmTimesAround = timesaround
  501. pmRetries = retries
  502.  
  503. rs.normal = 0
  504. rs.keydetected = 1
  505. rs.quietdetected = 2
  506. rs.silencedetected = 3
  507. rs.faxdetected = 4
  508. rs.datadetected = 5
  509. rs.busydetected = 8
  510. rs.timedout = 10
  511. rs.signaldetected = 12
  512. rs.overflow = 14
  513. rs.error = 16
  514. /* CB 0000 */
  515.  
  516. aapresentmenuloop:
  517. 'playvoice' filename
  518. a_=rc
  519. if 0 then nop
  520. else if a_=4 then do;return rs.faxdetected;end
  521. else if a_=5 then do;return rs.datadetected;end
  522. else if a_=8 then do;return rs.busydetected;end
  523. else if a_=12 then do;return rs.signaldetected;end
  524. else if a_=14 then do;return rs.error;end
  525. else if a_=16 then do;return rs.error;end
  526.  
  527. 'readnkeys' '1' '5'
  528. a_=rc
  529. if a_=0 then value=result
  530. if 0 then nop
  531. else if a_=0 then signal aapresentmenuvalue
  532. else if a_=4 then do;return rs.faxdetected;end
  533. else if a_=5 then do;return rs.datadetected;end
  534. else if a_=8 then do;return rs.busydetected;end
  535. else if a_=10 then signal aapresentmenutimeout
  536. else if a_=12 then do;return rs.signaldetected;end
  537. else if a_=14 then do;return rs.error;end
  538. else if a_=16 then do;return rs.error;end
  539. return rs.error
  540.  
  541. aapresentmenutimeout:
  542. 'flushphonebuffer'
  543.  
  544. 'playvoice' 'avm:voices/TimedOut'
  545. a_=rc
  546. if 0 then nop
  547. else if a_=4 then do;return rs.faxdetected;end
  548. else if a_=5 then do;return rs.datadetected;end
  549. else if a_=8 then do;return rs.busydetected;end
  550. else if a_=12 then do;return rs.signaldetected;end
  551. else if a_=14 then do;return rs.error;end
  552. else if a_=16 then do;return rs.error;end
  553.  
  554. timesaround = timesaround - 1; pmTimesAround = timesaround
  555. if timesaround <= 0 then return rs.timedout
  556. signal aapresentmenuloop
  557.  
  558. aapresentmenuvalue:
  559. if pos(value, valid) = 0 then signal aainvalid
  560. return '=' || value
  561.  
  562. aainvalid:
  563. 'flushphonebuffer'
  564.  
  565. 'playvoice' 'avm:voices/BadChoice'
  566. a_=rc
  567. if 0 then nop
  568. else if a_=4 then do;return rs.faxdetected;end
  569. else if a_=5 then do;return rs.datadetected;end
  570. else if a_=8 then do;return rs.busydetected;end
  571. else if a_=12 then do;return rs.signaldetected;end
  572. else if a_=14 then do;return rs.error;end
  573. else if a_=16 then do;return rs.error;end
  574.  
  575. timesaround = timesaround - 1; pmTimesAround = timesaround
  576. if timesaround <= 0 then return rs.timedout
  577. signal aapresentmenuloop
  578.  
  579.  
  580. stdabort:
  581. exit
  582.  
  583. stdbusy:
  584. exit
  585.  
  586. stderror:
  587. exit
  588.  
  589. stdtimedout:
  590. exit
  591.  
  592. stdfaxinstruct:
  593. 'playvoice' 'avm:voices/FaxStarting'
  594. a_=rc
  595. if 0 then nop
  596. else if a_=1 then do;call checkifabort;end
  597. else if a_=8 then signal stdbusy
  598. else if a_=12 then signal stdabort
  599.  
  600. stdfax:
  601. faxscript = getclip(address() || 'FAXSCRIPT')
  602. if faxscript = '' then faxscript = 'handlefax'
  603. if symbol('mailbox') = 'VAR' then address rexx faxscript address() mailbox
  604. else address rexx faxscript address() 'anonymous'
  605. exit
  606.  
  607. stddatainstruct:
  608. 'playvoice' 'avm:voices/DataStarting'
  609. a_=rc
  610. if 0 then nop
  611. else if a_=1 then do;call checkifabort;end
  612. else if a_=8 then signal stdbusy
  613. else if a_=12 then signal stdabort
  614.  
  615. stddata:
  616. datascript = getclip(address() || 'DATASCRIPT')
  617. if datascript = '' then datascript = 'handledata'
  618. if symbol('mailbox') = 'VAR' then address rexx datascript address() mailbox
  619. else address rexx datascript address()
  620. exit
  621.  
  622. checkifabort:
  623. 'readnkeys' '1' '3'
  624. a_=rc
  625. if a_=0 then value=result
  626. if 0 then nop
  627. else if a_=0 then do;if value = '*' then signal stdabort;end
  628. else if a_=8 then signal stdbusy
  629. else if a_=12 then signal stdabort
  630. else if a_=14 then signal stderror
  631. else if a_=16 then signal stderror
  632. return
  633.  
  634.  
  635. exit
  636.  
  637. /* this requires logfunctions.avm */
  638.  
  639. loadMailbox: procedure expose mailbox.
  640.     if arg() ~= 1 then do
  641.         rc = "loadMailbox: bad args"
  642.         signal error
  643.     end
  644.  
  645.         mailbox. = ''
  646.     parse arg mailbox
  647.  
  648.     handle = 'mailboxconfig'
  649.     opened = open(handle, mailboxDir(mailbox) || 'mailbox.cfg', 'r')
  650.     if opened then do
  651.         do while ~eof(handle)
  652.             line = readln(handle)
  653.             parse upper var line variable '=' value
  654.             mailbox.variable = value
  655.         end
  656.         call close(handle)
  657.     end
  658.     return
  659.  
  660. /* pass a handle here */
  661. saveMailbox: procedure expose mailbox.
  662.     if arg() ~= 1 then do
  663.         rc = "saveMailbox: bad args"
  664.         signal error
  665.     end
  666.     parse arg mailbox
  667.  
  668.     handle = 'mailboxconfig'
  669.     opened = open(handle, mailboxDir(mailbox) || 'mailbox.cfg', 'w')
  670.  
  671.     if opened then do
  672.         call writeln(handle, 'PASSWORD=' || mailbox.password)
  673.  
  674.         call writeln(handle, 'AUTOFAXFORWARDB=' || mailbox.autofaxforwardb)
  675.         call writeln(handle, 'AUTOFAXFORWARD=' || mailbox.autofaxforward)
  676.         call writeln(handle, 'AUTOFAXFORWARDSCRIPT=' || mailbox.autofaxforwardscript)
  677.  
  678.         call writeln(handle, 'AUTOFORWARDB=' || mailbox.autoforwardb)
  679.         call writeln(handle, 'AUTOFORWARDONDEMAND=' || mailbox.autoforwardondemand)
  680.         call writeln(handle, 'AUTOFORWARD=' || mailbox.autoforward)
  681.         call writeln(handle, 'AUTOFORWARDSCRIPT=' || mailbox.autoforwardscript)
  682.  
  683.         call writeln(handle, 'AUTOPAGEB=' || mailbox.autopageb)
  684.         call writeln(handle, 'AUTOPAGEONDEMAND=' || mailbox.autopageondemand)
  685.         call writeln(handle, 'AUTOPAGE=' || mailbox.autopage)
  686.         call writeln(handle, 'AUTOPAGESCRIPT=' || mailbox.autopagescript)
  687.  
  688.         call writeln(handle, 'AUTOALERTB=' || mailbox.autoalertb)
  689.         call writeln(handle, 'AUTOALERTONDEMAND=' || mailbox.autoalertondemand)
  690.         call writeln(handle, 'AUTOALERTSCRIPT=' || mailbox.autoalertscript)
  691.  
  692.         call close(handle)
  693.     end
  694.  
  695.     return
  696.  
  697. /* TITLE: avm:rexx/playnumber.avm */
  698. playnumber:
  699. /* Cycle through value and play each symbol */
  700.  
  701. procedure
  702. parse arg number
  703.  
  704. do i = 1 to length(number)
  705.   if pos(substr(number, i, 1), '0123456789') > 0 then
  706.     call playAVoice('avm:voices/number0'||substr(number, i, 1))
  707.   else if substr(number, i, 1) = '#' then
  708.     call playAVoice('avm:voices/numberpound')
  709.   else if substr(number, i, 1) = '*' then
  710.     call playAVoice('avm:voices/numberstar')
  711. end
  712. return
  713.  
  714. playAVoice:
  715. procedure
  716. parse arg filename
  717.  
  718. 'playvoice' filename
  719. call stdPlayXX(rc)
  720. return
  721.  
  722.  
  723. /* TITLE: avm:rexx/getnumber.avm */
  724. getnumber:
  725. procedure
  726.  
  727. aagetnumberagain:
  728. 'playvoice' 'avm:voices/GetNumber'
  729. call stdPlayXX(rc)
  730.  
  731. 'readkeysuntil' '#' '15' '7'
  732. a_=rc
  733. if a_=0 then value=result
  734. if 0 then nop
  735. else if a_=0 then do;number = value;end
  736. else if a_=4 then signal stdfax
  737. else if a_=5 then signal stddata
  738. else if a_=8 then signal stdbusy
  739. else if a_=10 then do;number = '';end
  740. else if a_=12 then signal stdabort
  741. else if a_=14 then signal stderror
  742. else if a_=16 then signal stderror
  743.  
  744. 'playvoice' 'avm:voices/NumberEntered'
  745. call stdPlayXX(rc)
  746.  
  747. call playNumber(number)
  748.  
  749. aagetnumbermenu:
  750. call aapresentmenu('avm:voices/numbercorrect', '02#*', '3')
  751. a_=result
  752. if 0 then nop
  753. else if a_='=0' then signal aagetnumbermenu
  754. else if a_='=2' then signal aagetnumberagain
  755. else if a_='=#' then signal aagetnumberdone
  756. else if a_='=*' then signal answerVoiceDone
  757. else if a_=4 then signal stdfax
  758. else if a_=5 then signal stddata
  759. else if a_=8 then signal stdbusy
  760. else if a_=10 then do;number = ''; signal aagetnumberdone;end
  761. else if a_=12 then signal stdabort
  762. else if a_=14 then signal stderror
  763. else if a_=16 then signal stderror
  764.  
  765. aagetnumberdone:
  766. /* We're done.  Number is in 'number' */
  767.  
  768. return number
  769.  
  770.  
  771. /* TITLE: avm:rexx/getpassword.avm */
  772. /* This is a procedure which accepts 1 argument, a password */
  773.  
  774. getpassword:
  775. procedure
  776. parse arg password
  777. count = 3 /* max of 3 times */
  778. if password = '' then return 1
  779.  
  780. getpasswordagain:
  781. count = count - 1
  782. if count = 0 then return 0 /* didn't get a good password */
  783.  
  784. 'playvoice' 'avm:voices/getpassword'
  785. call stdPlayXX(rc)
  786.  
  787. 'readkeysuntil' '#' '10' '7'
  788. a_=rc
  789. if a_=0 then value=result
  790. if 0 then nop
  791. else if a_=0 then signal getpasskeydetected
  792. else if a_=4 then signal stdfax
  793. else if a_=5 then signal stddata
  794. else if a_=8 then signal stdbusy
  795. else if a_=12 then signal stdabort
  796. else if a_=14 then signal stderror
  797. else if a_=16 then signal stderror
  798.  
  799. 'playvoice' 'avm:voices/passwordtimeout'
  800. call stdPlayXX(rc)
  801. signal getpasswordagain
  802.  
  803. getpasskeydetected:
  804. if value = password then return 1
  805.  
  806. 'playvoice' 'avm:voices/passwordbad'
  807. call stdPlayXX(rc)
  808. signal getpasswordagain
  809.  
  810.  
  811.