home *** CD-ROM | disk | FTP | other *** search
- /* TITLE: avm:rexx/defaultsender.avm */
- /* we want results! Otherwise, we wouldn't get anything from RESULT */
- options results
-
- /* Need to make sure that stdtail.avm is also included */
- signal on halt
- signal on novalue
- signal on syntax
- signal on break_c
-
- /* needed for some of the functions we use */
- call addlib("rexxsupport.library", 0, -30, 0)
-
- /* a higher than normal priority since calls are important to us :) */
- call pragma('priority', 1)
-
- /* ensure that commands are directed to the correct server */
- parse arg servername .
- address value servername
-
-
- parse upper arg servername mailbox magiccookie sendType .
-
- /* If type is voice, goto sendVoice. Otherwise, go to sendFax */
-
- call loadLogEntry(mailbox, magiccookie)
-
- if log.returnNumber = '' & upper(sendType) ~= 'MANUAL' then do
- log.returnStatus = 'No Tel#'
- log.returnRetry = 0
- signal sendVoiceDone
- end
- if log.filename = '' then do
- log.returnStatus = 'No File'
- log.returnRetry = 0
- signal sendVoiceDone
- end
-
- if upper(sendType) = 'MANUAL' then numberToDial = 'MAN!'; else numberToDial = log.returnNumber
- if upper(log.type) = 'VOICE' then signal sendVoice
- else if upper(log.type) = 'FAX' then signal sendFax
- log.returnstatus = 'Not Voice/Fax'
- log.returnretry = 0
- signal sendVoiceDone
-
- /* Going to send a voice file */
-
- /* Dial up to three times */
-
- sendVoice:
- numTries = 3
-
- sendVoiceRedial:
- 'dial' log.returnnumber
- a_=rc
- if 0 then nop
- else if a_=8 then signal sendVoiceAgain
- else if a_=10 then signal sendVoiceAgain
- else if a_=12 then do;log.returnStatus = 'Abort'; log.returnRetry = 0; signal sendVoiceDone;end
- else if a_=14 then do;log.returnStatus = 'Error'; log.returnRetry = 0; signal sendVoiceDone;end
- else if a_=16 then do;log.returnStatus = 'Error'; log.returnRetry = 0; signal sendVoiceDone;end
- signal sendVoiceConnected
-
- sendVoiceAgain:
- 'requiremode' 'Voice'
-
- 'delay' 5
- a_=rc
- if 0 then nop
- else if a_=12 then do;log.returnStatus = 'Abort'; log.returnRetry = 0; signal sendVoiceDone;end
- else if a_=14 then do;log.returnStatus = 'Error'; log.returnRetry = 0; signal sendVoiceDone;end
- else if a_=16 then do;log.returnStatus = 'Error'; log.returnRetry = 0; signal sendVoiceDone;end
-
-
- sendVoiceRetry:
- numTries = numTries - 1
- if numTries <= 0 then do
- log.returnStatus = 'Busy'
- signal sendVoiceDone
- end
- signal sendVoiceRedial
-
- sendVoiceConnected:
- actualFileName = log.fileName
- if verify(actualFileName, '/:', 'M') = 0 then
- actualFileName = voiceFile(mailbox, actualFileName)
- actualAltFileName = ''
- if symbol('log.altFileName') = 'VAR' then actualAltFileName = log.altFileName
- actualAltFileName = voiceFile(mailbox, actualAltFileName)
-
- numTimes = 5
-
- sendVoiceRepeat:
- if actualAltFileName = '' then signal sendVoiceSkipIntro
-
- 'playvoice' actualAltFileName
- a_=rc
- if 0 then nop
- else if a_=4 then do;log.returnStatus = 'Fax?'; log.returnRetry = 0; signal sendVoiceDone;end
- else if a_=5 then do;log.returnStatus = 'Data?'; log.returnRetry = 0; signal sendVoiceDone;end
- else if a_=8 then do;if numTimes = 3 then signal sendVoiceAgain; else signal sendVoiceBusy;end
- else if a_=12 then do;log.returnStatus = 'Abort'; log.returnRetry = 0; signal sendVoiceDone;end
-
- 'flushphonebuffer'
-
- sendVoiceSkipIntro:
- 'playvoice' actualFileName
- a_=rc
- if 0 then nop
- else if a_=4 then do;log.returnStatus = 'Fax?'; log.returnRetry = 0; signal sendVoiceDone;end
- else if a_=5 then do;log.returnStatus = 'Data?'; log.returnRetry = 0; signal sendVoiceDone;end
- else if a_=8 then do;if numTimes = 3 then signal sendVoiceAgain; else signal sendVoiceBusy;end
- else if a_=12 then do;log.returnStatus = 'Abort'; log.returnRetry = 0; signal sendVoiceDone;end
- else if a_=14 then do;log.returnStatus = 'Error'; log.returnRetry = 0; signal sendVoiceDone;end
- else if a_=16 then do;log.returnStatus = 'Error'; log.returnRetry = 0; signal sendVoiceDone;end
-
- 'flushphonebuffer'
-
- sendVoiceMenu:
- call aapresentmenu('avm:voices/SendVoice', '019#*', '1')
- a_=result
- if 0 then nop
- else if a_='=0' then signal sendVoiceMenu
- else if a_='=1' then signal sendVoiceRepeat
- else if a_='=9' then do;log.returnRetry = 0; log.returnStatus = 'Sent+'; call updateLogEntry(mailbox, magicCookie); call 'avmrexxalt:processmailbox'(log.origmailbox); signal answerVoiceDone;end
- else if a_='=#' then signal answerVoiceDone
- else if a_='=*' then signal sendVoiceOK
- else if a_=4 then do;log.returnStatus = 'Fax?'; log.returnRetry = 0; signal sendVoiceDone;end
- else if a_=5 then do;log.returnStatus = 'Data?'; log.returnRetry = 0; signal sendVoiceDone;end
- else if a_=8 then do;if numTimes = 3 then signal sendVoiceAgain; else signal sendVoiceBusy;end
- else if a_=12 then do;log.returnStatus = 'Abort'; log.returnRetry = 0; signal sendVoiceDone;end
- else if a_=14 then do;log.returnStatus = 'Error'; log.returnRetry = 0; signal sendVoiceDone;end
- else if a_=16 then do;log.returnStatus = 'Error'; log.returnRetry = 0; signal sendVoiceDone;end
-
- numTimes = numTimes - 1
- if numTimes <= 0 then do
- signal sendVoiceTimedOut
- end
- signal sendVoiceRepeat
-
- sendVoiceTimedOut:
- log.returnStatus = 'Sent-TimedOut'
- log.returnRetry = 0
- signal sendVoiceDone
-
- sendVoiceBusy:
- log.returnRetry = 0
- log.returnStatus = 'Sent-Busy'
- signal sendVoiceDone
-
- sendVoiceOK:
- log.returnRetry = 0
- log.returnStatus = 'Sent+'
-
- sendVoiceDone:
- if log.returnRetry > 0 then do
- log.returnRetry = log.returnRetry - 1
- log.time = cTime() + log.returnInterval * 60
- end
- call updateLogEntry(mailbox, magicCookie)
- exit
-
- startup:
- /* Pressing 0 usually gets us here */
-
- answerVoiceDone:
- /* Pressing * gets us here */
- exit
-
- /* Going to send a fax file */
-
- sendFax:
- options failat 50
- signal off syntax
-
- 'requiremode' 'Command'
-
- 'setserial' '19200' '8' 'N' '1' '7Wire'
- a_=rc
- if 0 then nop
-
- 'assumemode' 'Unknown'
-
- isTrapFax:
- faxprogram = getclip('AVMFaxProgram')
- if upper(faxprogram) = 'TRAPFAX' then do
-
- mypara = 'File ' || log.filename || ' call ' || log.returnnumber
- address command 'TrapFax:TFaxDoor >NIL:' mypara ' noowndev'
- sendok = rc
- log.returnstatus = 'Error'
-
- isGPFax:
- end; else if upper(faxprogram) = 'GPFAX' & show('p', 'REXX_GPFAX') then do
-
- address rexx_gpfax 'listen'
- address rexx_gpfax 'sendfax' log.filename 'to' log.returnnumber
- sendok = rc
- address rexx_gpfax 'reportlog' 'T' 3
- log.returnstatus = result
- address rexx_gpfax 'unlisten'
-
- isEFax:
- end; else if upper(faxprogram) = 'EFAX' then do
-
- /* now we need to find all files that match */
- toSend = ''
- base = upper(voiceFile(mailbox, log.fileName) || '.');
- do i = 1 to 999
- if exists(base || right(i, 3, '0')) then
- toSend = toSend base || right(i, 3, '0')
- else break
- end
-
- address command 'avm:gnu/efax -p' servername '-t' '"' || compress(numberToDial) || '"' toSend
- if rc = 0 then sendOK = 0
- else sendOK = 10
-
- isNeither:
- end; else do
- log.returnStatus = 'Fax Prog?'
- log.returnRetry = 0
- call updateLogEntry(mailbox, magiccookie)
- end
-
- sendFaxDone:
- if sendok < 5 then do; log.returnretry = 0; log.returnstatus = 'Sent OK'; end
- else do; log.returnRetry = log.returnRetry - 1; log.time = cTime() + log.returnInterval * 60; end
- call updateLogEntry(mailbox, magiccookie)
-
- 'delay' 5
- a_=rc
- if 0 then nop
- else if a_=12 then signal stdabort
- else if a_=14 then signal stderror
- else if a_=16 then signal stderror
-
- 'writeline' 'AT+FCLASS=0'
-
- 'readline' '2'
- a_=rc
- if a_=0 then value=result
- if 0 then nop
- else if a_=10 then signal stdtimedout
- else if a_=12 then signal stdabort
- else if a_=14 then signal stderror
- else if a_=16 then signal stderror
-
- 'readline' '2'
- a_=rc
- if a_=0 then value=result
- if 0 then nop
- else if a_=10 then signal stdtimedout
- else if a_=12 then signal stdabort
- else if a_=14 then signal stderror
- else if a_=16 then signal stderror
-
- /* We're done sending a fax */
- exit
-
- /* TITLE: avm:rexx/simplestdtail.avm */
- /* This is the standard tail */
- exit
-
- exit
-
- mailboxDir: procedure
- parse arg mailbox
-
- return 'avmmbox:' || mailbox || '/'
-
- logFile: procedure
- parse arg mailbox, magiccookie
-
- return 'avmmbox:' || mailbox || '/logs/' || magiccookie
-
- voiceFile: procedure
- parse arg mailbox, magiccookie
-
- if (verify(magiccookie, '/:', 'M') = 0) then
- return 'avmmbox:' || mailbox || '/voices/' || magiccookie
- else
- return magiccookie
-
- makeUniqueFile: procedure
- if arg() ~= 0 then do
- rc = "makeUniqueFile: bad args"
- signal error
- end
- return address() || '.' || date('i') || '.' || time('s') || '.' || random(1, 999, time('s'))
-
- convertToDate: procedure
- if arg() ~= 1 then do
- rc = "convertToDate: bad args"
- signal error
- end
- parse arg timeInC
-
- actualTime = (timeInC - (2922)*86400) // (86400)
- actualDate = (timeInC - actualTime - 2922*86400) % 86400
-
- return actualDate /* returning it in 'internal' format */
-
- convertToTime: procedure
- if arg() ~= 1 then do
- rc = "convertToTime: bad args"
- signal error
- end
- parse arg timeInC
-
- actualTime = (timeInC - (2922)*86400) // (86400)
-
- return actualTime
-
- cTime: procedure
- /* 2922 = 8*365 + 2 */
- /* 86400 = 24*60*60 */
- return (date('i')+2922)*86400 + time('s')
-
- /* this returns a handle that you must use after initializing log. */
- initLogEntry: procedure expose log.
- if arg() ~= 0 then do
- rc = "initLogEntry: bad args"
- signal error
- end
-
- drop log.
- log. = ''
-
- acidname = getclip(address() || 'CIDNAME')
- acidnumber = getclip(address() || 'CIDNUMBER')
-
- /* 2922 = 8*365 + 2 */
- /* 86400 = 24*60*60 */
- log.time = (date('i')+2922)*86400 + time('s')
- log.cidname = acidname
- log.cidnumber = acidnumber
-
- return
-
- loadLogEntry: procedure expose log.
- if arg() ~= 2 then do
- rc = "loadLogEntry: bad args"
- signal error
- end
- parse arg mailbox, handle
-
- drop log.
- log. = ''
-
- if ~exists(mailboxDir(mailbox)) then do
- call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
- return
- end
-
- opened = open(handle, logFile(mailbox, handle), 'r')
- if opened then do
- call showDebugger('Loading entry' logFile(mailbox, handle))
- do while ~eof(handle)
- line = readln(handle)
- parse upper var line variable '=' value
- log.variable = value
- end
- call close(handle)
- end; else call showDebugger('Could not load' logFile(mailbox, handle))
- return
-
- /* pass a handle here */
- saveLogEntry: procedure expose log.
- if arg() ~= 2 then do
- rc = "saveLogEntry: bad args"
- signal error
- end
- parse arg mailbox, handle
-
- if ~exists(mailboxDir(mailbox)) then do
- call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
- return
- end
-
- opened = open(handle, logFile(mailbox, handle), 'w')
-
- if opened then do
- call showDebugger('Saving entry' logFile(mailbox, handle))
- call writeln(handle, 'TYPE=' || log.type)
- call writeln(handle, 'TIME=' || log.time)
- call writeln(handle, 'LENGTH=' || log.length)
-
- call writeln(handle, 'ORIGMAILBOX=' || log.origmailbox)
-
- call writeln(handle, 'CIDNAME=' || log.cidname)
- call writeln(handle, 'CIDNUMBER=' || log.cidnumber)
-
- call writeln(handle, 'COMMENT=' || log.comment)
-
- call writeln(handle, 'FILENAME=' || log.filename)
- call writeln(handle, 'ALTFILENAME=' || log.altfilename)
-
- call writeln(handle, 'RETURNNUMBER=' || log.returnnumber)
- call writeln(handle, 'RETURNSENDFUNC=' || log.returnsendfunc)
- call writeln(handle, 'RETURNSTATUS=' || log.returnstatus)
-
- call writeln(handle, 'RETURNRETRY=' || log.returnretry)
- call writeln(handle, 'RETURNINTERVAL=' || log.returninterval)
-
- call close(handle)
- address rexx 'broadcast' 'addtomailbox' mailbox handle
- end; else call showDebugger('Could not save' logFile(mailbox, handle))
-
- return
-
- /* pass a handle here */
- updateLogEntry: procedure expose log.
- if arg() ~= 2 then do
- rc = "updateLogEntry: bad args"
- signal error
- end
- parse arg mailbox, handle
-
- if ~exists(mailboxDir(mailbox)) then do
- call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
- return
- end
-
- if ~exists(logFile(mailbox, handle)) then do
- call showDebugger('Unable to update non-existent' logFile(mailbox, handle))
- return
- end
- opened = open(handle, logFile(mailbox, handle), 'w')
-
- if opened then do
- call showDebugger('Updating entry' logFile(mailbox, handle))
- call writeln(handle, 'TYPE=' || log.type)
- call writeln(handle, 'TIME=' || log.time)
- call writeln(handle, 'LENGTH=' || log.length)
-
- call writeln(handle, 'ORIGMAILBOX=' || log.origmailbox)
-
- call writeln(handle, 'CIDNAME=' || log.cidname)
- call writeln(handle, 'CIDNUMBER=' || log.cidnumber)
-
- call writeln(handle, 'COMMENT=' || log.comment)
-
- call writeln(handle, 'FILENAME=' || log.filename)
- call writeln(handle, 'ALTFILENAME=' || log.altfilename)
-
- call writeln(handle, 'RETURNNUMBER=' || log.returnnumber)
- call writeln(handle, 'RETURNSENDFUNC=' || log.returnsendfunc)
- call writeln(handle, 'RETURNSTATUS=' || log.returnstatus)
-
- call writeln(handle, 'RETURNRETRY=' || log.returnretry)
- call writeln(handle, 'RETURNINTERVAL=' || log.returninterval)
-
- call close(handle)
- address rexx 'broadcast' 'refreshmailboxentry' mailbox handle
- end; else call showDebugger('Could not update' logFile(mailbox, handle))
-
- return
-
-
-
- showDebugger: procedure
- if arg() ~= 1 then do
- say "showDebugger: ERROR"
- exit 20
- end
-
- parse arg debuggerInfo
-
- firstLine = sourceline(1)
- parse var firstLine '/*' 'TITLE:' title '*/'
- if showlist('p', 'AVMLOGGER') then
- address 'AVMLOGGER' 'add' title ':' debuggerInfo
- else
- say title ':' debuggerInfo
-
- return
-
- /*-----------------------------------------------------------------------*/
- /* signal processing */
-
- arexxerror:
- error:
- call showDebugger("Error" rc "at line" sigl)
- exit 20
-
- break_c:
- halt:
- call showDebugger("Halt/Break_C at line" sigl)
- exit 20
-
- novalue:
- call showDebugger("No value at line" sigl)
- exit 20
-
- syntax:
- call showDebugger("Syntax error" rc "at line" sigl)
- exit 20
-
- /* TITLE: avm:rexx/stdplayvoice.avm */
- stdPlayXX:
- procedure
- parse arg ret
-
- rs.normal = 0
- rs.keydetected = 1
- rs.quietdetected = 2
- rs.silencedetected = 3
- rs.faxdetected = 4
- rs.datadetected = 5
- rs.busydetected = 8
- rs.timedout = 10
- rs.signaldetected = 12
- rs.overflow = 14
- rs.error = 16
- /* CB 0000 */
-
- select
- when ret=rs.faxdetected then signal stdfax
- when ret=rs.datadetected then signal stddata
- when ret=rs.busydetected then signal stdbusy
- when ret=rs.signaldetected then signal stdabort
- when ret=rs.overflow then signal stderror
- when ret=rs.error then signal stderror
- otherwise nop
- end
- return
-
-
- aapresentmenu:
- /* TITLE: avm:rexx/presentmenu.avm */
- procedure expose pmRetries pmTimesAround
- parse arg filename, valid, retries
- timesaround = retries
- pmTimesAround = timesaround
- pmRetries = retries
-
- rs.normal = 0
- rs.keydetected = 1
- rs.quietdetected = 2
- rs.silencedetected = 3
- rs.faxdetected = 4
- rs.datadetected = 5
- rs.busydetected = 8
- rs.timedout = 10
- rs.signaldetected = 12
- rs.overflow = 14
- rs.error = 16
- /* CB 0000 */
-
- aapresentmenuloop:
- 'playvoice' filename
- a_=rc
- if 0 then nop
- else if a_=4 then do;return rs.faxdetected;end
- else if a_=5 then do;return rs.datadetected;end
- else if a_=8 then do;return rs.busydetected;end
- else if a_=12 then do;return rs.signaldetected;end
- else if a_=14 then do;return rs.error;end
- else if a_=16 then do;return rs.error;end
-
- 'readnkeys' '1' '5'
- a_=rc
- if a_=0 then value=result
- if 0 then nop
- else if a_=0 then signal aapresentmenuvalue
- else if a_=4 then do;return rs.faxdetected;end
- else if a_=5 then do;return rs.datadetected;end
- else if a_=8 then do;return rs.busydetected;end
- else if a_=10 then signal aapresentmenutimeout
- else if a_=12 then do;return rs.signaldetected;end
- else if a_=14 then do;return rs.error;end
- else if a_=16 then do;return rs.error;end
- return rs.error
-
- aapresentmenutimeout:
- 'flushphonebuffer'
-
- 'playvoice' 'avm:voices/TimedOut'
- a_=rc
- if 0 then nop
- else if a_=4 then do;return rs.faxdetected;end
- else if a_=5 then do;return rs.datadetected;end
- else if a_=8 then do;return rs.busydetected;end
- else if a_=12 then do;return rs.signaldetected;end
- else if a_=14 then do;return rs.error;end
- else if a_=16 then do;return rs.error;end
-
- timesaround = timesaround - 1; pmTimesAround = timesaround
- if timesaround <= 0 then return rs.timedout
- signal aapresentmenuloop
-
- aapresentmenuvalue:
- if pos(value, valid) = 0 then signal aainvalid
- return '=' || value
-
- aainvalid:
- 'flushphonebuffer'
-
- 'playvoice' 'avm:voices/BadChoice'
- a_=rc
- if 0 then nop
- else if a_=4 then do;return rs.faxdetected;end
- else if a_=5 then do;return rs.datadetected;end
- else if a_=8 then do;return rs.busydetected;end
- else if a_=12 then do;return rs.signaldetected;end
- else if a_=14 then do;return rs.error;end
- else if a_=16 then do;return rs.error;end
-
- timesaround = timesaround - 1; pmTimesAround = timesaround
- if timesaround <= 0 then return rs.timedout
- signal aapresentmenuloop
-
-
- stdabort:
- exit
-
- stdbusy:
- exit
-
- stderror:
- exit
-
- stdtimedout:
- exit
-
- stdfaxinstruct:
- 'playvoice' 'avm:voices/FaxStarting'
- a_=rc
- if 0 then nop
- else if a_=1 then do;call checkifabort;end
- else if a_=8 then signal stdbusy
- else if a_=12 then signal stdabort
-
- stdfax:
- faxscript = getclip(address() || 'FAXSCRIPT')
- if faxscript = '' then faxscript = 'handlefax'
- if symbol('mailbox') = 'VAR' then address rexx faxscript address() mailbox
- else address rexx faxscript address() 'anonymous'
- exit
-
- stddatainstruct:
- 'playvoice' 'avm:voices/DataStarting'
- a_=rc
- if 0 then nop
- else if a_=1 then do;call checkifabort;end
- else if a_=8 then signal stdbusy
- else if a_=12 then signal stdabort
-
- stddata:
- datascript = getclip(address() || 'DATASCRIPT')
- if datascript = '' then datascript = 'handledata'
- if symbol('mailbox') = 'VAR' then address rexx datascript address() mailbox
- else address rexx datascript address()
- exit
-
- checkifabort:
- 'readnkeys' '1' '3'
- a_=rc
- if a_=0 then value=result
- if 0 then nop
- else if a_=0 then do;if value = '*' then signal stdabort;end
- else if a_=8 then signal stdbusy
- else if a_=12 then signal stdabort
- else if a_=14 then signal stderror
- else if a_=16 then signal stderror
- return
-
-
-