home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: OtherApp / OtherApp.zip / avcmachi.zip / tauto.cmd < prev    next >
OS/2 REXX Batch file  |  2001-01-17  |  19KB  |  946 lines

  1. /* Script to Answer On Voice Calls */
  2.  
  3. Call RxFuncAdd 'SysSleep', 'RexxUtil', 'SysSleep'
  4. Call RxFuncAdd 'SysGetKey', 'RexxUtil', 'SysGetKey'
  5. Call RxFuncAdd 'SysCls', 'RexxUtil', 'SysCls'
  6. Call RxFuncAdd 'SysTempFileName', 'RexxUtil', 'SysTempFileName'
  7. Call RxFuncAdd 'SysFileDelete', 'RexxUtil', 'SysFileDelete'
  8. Call RxFuncAdd 'SysFileTree', 'RexxUtil', 'SysFileTree'
  9. Call RxFuncAdd 'RxAsyncRead', 'RXASYNC', 'RxAsyncRead'
  10. Call RxFuncAdd 'RxAsyncWait', 'RXASYNC', 'RxAsyncWait'
  11. call RxFuncAdd 'RxAsyncLoadFuncs', 'RXASYNC', 'RxAsyncLoadFuncs'
  12. call RxAsyncLoadFuncs
  13.  
  14. signal on halt
  15.  
  16. /* --------------------- Initialization ----------------------------- */
  17.  
  18.  
  19. Call SysFileTree tauto.ini, rc
  20. if rc.0 = 0 then
  21. do
  22. say "Tauto.ini file not found, Please create according to documentation."
  23. signal prog_quit
  24. end
  25. else
  26.  
  27. do while lines(tauto.ini) \= "0"
  28. rc=linein(tauto.ini,,1)
  29. parse upper value rc with selvar selvalue .
  30.  select
  31.  when left(selvar,1)='[' | left(selvar,1)=';' | selvar='' then NOP
  32.  when selvar='COMPORT' then interpret selvar '=selvalue'
  33.  when selvar='RINGTIME' then interpret selvar '=selvalue'
  34.  when selvar='ADD_AON' then interpret selvar '=selvalue'
  35.  when selvar='USE_SOUND' then interpret selvar '=selvalue'
  36.  when selvar='MAINLOG' then interpret selvar '=selvalue'
  37.  when selvar='DEBUG' then interpret selvar '=selvalue'
  38.  when left(selvar,4)='DTMF' then interpret selvar '=selvalue'
  39.  otherwise
  40.  say "Unknown Directive" selvar
  41.  signal prog_quit
  42.  end
  43. end
  44.  
  45.  
  46. /* [Global] */
  47. init="AT&F1H0E1V1"
  48. hang="ATZ"
  49. offhook="ATH1"
  50. command_delay=0.5    /* delay between AT commands (sec) */
  51. silence='ATMO'
  52.  
  53. /* [AON+RINGING Emulation] AVC56 ONLY !!! */
  54. ringing="ATR1"
  55. AonInit="ATJ2S90=19S30=0S99=1S70=3S7="RingTime||Add_aon
  56.  
  57. /* [Voice] */
  58. VoiceInit="ATE0J2#CLS=8"
  59. speaker="AT#VLS=4M1"
  60. record="AT#VRX"
  61. playback="AT#VTX"
  62. beep_1="AT#VTS=[933,0,12]"
  63. dle=x2c(10)
  64. dle_etx=x2c(10)x2c(3)
  65. cancel=x2c(10)x2c(18)
  66. VoiceDir=".\VOICE"
  67. GreetDir=".\GREET"
  68.  
  69. /* [DTMFs] */
  70.  
  71.  
  72. /* [Internal] Don't modify w/o necessity !!! */
  73. PortHandle=''
  74. remaining=''
  75. end_rec=1
  76. aonname=1
  77. lend=x2c(a5)
  78. extern_run=0
  79. num=0
  80. rez=0
  81. rej=0
  82. crlf=d2c(13)d2c(10)
  83.  
  84. /* ------------- Entry Point -------------- */
  85.  
  86. parse arg par
  87. PortHandle=par
  88. if par <> "" then
  89. do
  90. call com_init
  91.  
  92. rc = RxAsyncWrite( PortHandle, 0, AonInit||crlf, 'Remaining' )
  93. if rc <> 0 then signal err1
  94. call check_string "AonInit", "OK", "  AON Init Error... Exitting... ;("
  95.  
  96. extern_run=1
  97. signal ans
  98. end
  99.  
  100. port_not_checked=1
  101.  
  102.  
  103. rc=" -- "date()"ú  " time() " Program Started --"
  104. num=num+length(rc)
  105. call lineout numlog,crlf
  106. call charout numlog,rc
  107. call stream numlog,'c','close'
  108.  
  109. space:
  110. rez=0
  111. rej=0
  112.  
  113. patrol:
  114. dtmf_comp=""
  115.  
  116. Call SysCls
  117.  
  118. rc=crlf "       Automatic AVC56 AutoAnswer v 1.00 (c) By Alek Winner." crlf
  119. say rc
  120. if mainlog then call charout rclog,rc
  121.  
  122. if port_not_checked then
  123. do
  124. call comport_check
  125. port_not_checked=0
  126. end
  127.  
  128.  
  129. user="Unknown"
  130. hallo=greetdir"\hallo.gsm"
  131.  
  132. rc = RxAsyncWrite( PortHandle, 0, init||crlf, 'Remaining' )
  133. if rc <> 0 then signal err1
  134.  
  135. rc = RxAsyncWrite( PortHandle, 0, init||crlf, 'Remaining' )
  136. if rc <> 0 then signal err1
  137.  
  138. call check_string "Init", "OK", "  Modem Init Error... Exitting... ;("
  139.  
  140.  
  141. rc = RxAsyncWrite( PortHandle, 0, AonInit||crlf, 'Remaining' )
  142. if rc <> 0 then signal err1
  143. call check_string "AonInit", "OK", "  AON Init Error... Exitting... ;("
  144.  
  145.  
  146. if mainlog then call charout rclog,crlf
  147. rc=" "date()"ú  " time() "  Modem Initialized OK" crlf
  148. say rc
  149. if mainlog then call charout rclog,rc
  150.  
  151. rc=linein(numlog,,0)
  152. rc=stream(numlog,'c','seek <'num)
  153. do while rc <> ''
  154. rc=linein(numlog)
  155. say rc
  156. end
  157. call stream numlog,'c','close'
  158.  
  159. say
  160. say "        Waiting For Enemy Calls..." rez "granted" "|" rej "rejected"
  161. say
  162. say "        Press <A> to Answer, <N> for New or <ESC> to Exit..."
  163. say
  164.  
  165. InpStr=""
  166. do while InpStr \= 'RING'||crlf
  167.  
  168. rc =  RxAsyncRead( PortHandle, 0, 1500, 'InpStr' )
  169.  
  170. if chars()=1 then
  171.   do
  172.   key=c2d(SysGetKey(noecho))
  173.     select
  174.     when key=110 | key=78 then signal sel_key  /* (N) */
  175.     when key=27 then signal term
  176.     when key=97 | key=65 then
  177.      do
  178.      rc = RxAsyncWrite( PortHandle, 0, 'RING'||crlf, 'Remaining' )
  179.      if rc <> 0 then signal err1
  180.      end
  181.     otherwise
  182.     end
  183.   end
  184.  
  185. end
  186.  
  187. ans:
  188.  
  189. call syssleep command_delay
  190.  
  191.  
  192. rc=" "date()"ú  " time() "  Answering..." crlf
  193. say rc
  194. if mainlog then call charout rclog,rc
  195.  
  196. /* --------------- AON & Emulation part --------------- */
  197.  
  198. rc = RxAsyncWrite( PortHandle, 0, offhook||crlf, 'Remaining' )
  199. if rc <> 0 then signal err1
  200.  
  201.  
  202. InpStr=""
  203. do until left(InpStr,6) = 'CALLER'
  204. rc = RxAsyncRead( PortHandle, 0, -1, 'InpStr' )
  205. if rc <> 0 then signal err1
  206. db="OffHook" InpStr crlf
  207. if debug then call charout debug.log,db
  208.  
  209.  if InpStr='OK'||crlf then
  210.   do
  211.   caller='CALLER ID:XXXXXXX:X'
  212.   signal not_det
  213.   end
  214.  
  215. end
  216.  
  217. caller=InpStr
  218. call check_string "Offhook", "OK", "  Modem not Report Offhook... Exitting... ;("
  219.  
  220.  
  221. not_det:
  222.  
  223. rc=" "date()"ú  " time() " " caller crlf
  224. say rc
  225. if mainlog then call charout rclog,rc
  226.  
  227.  
  228. do while rc \= ""
  229. rc=linein(users.lst,,1)
  230. if subword(rc,1,2)=left(caller,17) then
  231.   do
  232.   user=subword(rc,6)
  233.   permit=word(rc,3)
  234.   if permit='rejected' | permit='admin_mob' then signal reject
  235.   hallo=greetdir"\"word(rc,4)
  236.   rc=""
  237.   end
  238. end
  239. call stream users.lst,'c','close'
  240.  
  241. if use_sound then '@start /c tnum.cmd' caller
  242.  
  243. aonname=SysTempFileName(voicedir'\aw???.num')
  244. voicename=left(aonname,14)"gsm"
  245.  
  246. rc=crlf" "time()" "left(caller,19)  " granted " right(voicename,9) " "user "  "
  247. num=num+length(rc)
  248. call charout numlog,rc
  249. call stream numlog,'c','close'
  250.  
  251.  
  252. rc=" "date()"ú  " time() " " aonname crlf
  253. say rc
  254. if mainlog then call charout rclog,rc
  255. call lineout aonname,caller
  256. call stream aonname,'c','close'
  257.  
  258.  
  259. if permit="admin" then signal owner_proc
  260.  
  261.  
  262. ring_begin:
  263.  
  264. rc = RxAsyncWrite( PortHandle, 0, ringing||crlf, 'Remaining' )
  265. if rc <> 0 then signal err1
  266.  
  267. inpstr=""
  268. rc=time(R)
  269. do until inpstr="OK"||crlf
  270.  
  271.  if chars()=1 then
  272.  do
  273.  key=c2d(SysGetKey(noecho))
  274.  if key=82 | key=114 then ring_flag=1   /* (R) */
  275.  else signal sel_key
  276.  end
  277.  
  278. call syssleep 1
  279.  
  280. rc = RxAsyncRead( PortHandle, 0, 7000, 'InpStr' )
  281. if rc<>0 then signal err1
  282.  
  283. if inpstr="RINGBACK"||crlf then
  284. do
  285. rc=" "date()"ú  " time() " " 'Ringing...' crlf
  286. say rc
  287. if mainlog then call charout rclog,rc
  288. call beep 600,650
  289. end
  290.  
  291. if ring_flag=1 then
  292. do
  293. ring_flag=0
  294. signal ring_begin
  295. end
  296.  
  297. end
  298.  
  299. if time(E) < ringtime then
  300. do
  301. rc=" No Message"
  302. num=num+length(rc)
  303. call charout numlog,rc
  304. if extern_run then signal term
  305. signal patrol
  306. end
  307.  
  308. ring_end:
  309.  
  310.  
  311. rez=rez+1
  312.  
  313. rc=crlf date()"ú  " time() "  Launching Autoanswer call N" rez crlf
  314. say rc
  315. if mainlog then call charout rclog,rc
  316.  
  317.  
  318.  
  319. /* ------------ AutoAnswer Part ------------------ */
  320.  
  321. call voice_init
  322.  
  323. call play_file
  324.  
  325. go_rec:
  326.  
  327. call beep_to_line
  328.  
  329. rc = RxAsyncWrite( PortHandle, 0, record||crlf, 'Remaining' )
  330. if rc <> 0 then signal err1
  331. call check_string "record", "CONNECT", "  Error switching to RECORD mode... Exitting... ;("
  332.  
  333.  
  334. rc=" "date()"ú  " time() "  Recording..." crlf
  335. say rc
  336. if mainlog then call charout rclog,rc
  337.  
  338.  
  339. busy=0
  340.  
  341.  
  342. rc=" "date()"ú  " time() " " voicename crlf
  343. say rc
  344. if mainlog then call charout rclog,rc
  345.  
  346.  
  347.  
  348. do until c2x(rc) = ''
  349.  
  350. frame=''
  351.  
  352. do while c2x(right(frame,2)) <> 'A5A5'
  353.  
  354. fram=frame
  355.  
  356. db = RxAsyncRead( PortHandle, 0, 2000, 'frame',,lend )
  357. if db <> 0 then
  358.   do
  359.  
  360.   if voicename='busy.fil' then
  361.    do
  362.    voicename=oldvoice
  363.    call stream "busy.fil",'c','close'
  364.    call SysFileDelete("busy.fil")
  365.    end
  366.  
  367.   call stream voicename,'c','close'
  368.   signal done
  369.  
  370.   end
  371.  
  372. frame=fram||frame
  373. end
  374.  
  375.  n=length(frame)
  376.  i=1
  377.  
  378.  do while i <= n
  379.  
  380.  rc=SUBSTR(frame,i,1)
  381.  i=i+1
  382.  
  383.  if c2x(rc)=10 then
  384.  do
  385.  rc=SUBSTR(frame,i,1)
  386.  i=i+1
  387.  
  388.  say c2x(rc)
  389.  
  390.    select
  391.  
  392.    when c2x(rc)=10 then NOP
  393.  
  394.    when rc='b' then
  395.      do
  396.      rc=SUBSTR(frame,i,1)
  397.      i=i+1
  398.  
  399.      xx=" "date()"ú  " time() "  Äí¡áαπªÑ¡ ß¿ú¡á½ ó ½¿¡¿¿..." crlf
  400.      say xx
  401.      if mainlog then call charout rclog,xx
  402.  
  403.      call RxAsyncTxImmediate PortHandle, c2x(dle)
  404.      end_rec="d_tone"
  405.  
  406.      end
  407.  
  408.    when rc='d' then
  409.      do
  410.      rc=SUBSTR(frame,i,1)
  411.      i=i+1
  412.  
  413.      tm=time(R)
  414.      say tm
  415.      if tm>13 | busy=0 then
  416.       do
  417.       busy=0
  418.       tm=02
  419.       if voicename="busy.fil" then
  420.        do
  421.         bsy="BSY"
  422.         do until bsy=""
  423.         bsy=charin("busy.fil",,1)
  424.         call charout oldvoice,bsy
  425.        end
  426.       voicename=oldvoice
  427.       bsy="BSY=" bsy crlf
  428.       say bsy
  429.       if debug then call charout debug.log,bsy
  430.       call stream "busy.fil",'c','close'
  431.       call SysFileDelete("busy.fil")
  432.       end
  433.       else
  434.        do
  435.        oldvoice=voicename
  436.        voicename="busy.fil"
  437.        end
  438.   end
  439.  
  440.      if busy<3 & tm<13 then busy=busy+1
  441.      say busy "BUSY VALUE"
  442.      if busy=3 then
  443.        do
  444.        call stream "busy.fil",'c','close'
  445.        call SysFileDelete("busy.fil")
  446.  
  447.        bussy:
  448.        xx=" "date()"ú  " time() "  Äí¡áαπªÑ¡ ß¿ú¡á½ ó ½¿¡¿¿..." crlf
  449.        say xx
  450.        if mainlog then call charout rclog,xx
  451.  
  452.        call RxAsyncTxImmediate PortHandle, c2x(dle)
  453.        end_rec="d_tone"
  454.  
  455.        end
  456.      end
  457.  
  458.  
  459.    when rc='#' then
  460.      do
  461.      DTMF_COMP=""
  462.      rc=SUBSTR(frame,i,1)
  463.      i=i+1
  464.      end
  465.  
  466.  
  467.    when rc='1' | rc='2' | rc='3' | rc='4' | rc='5' | rc='6' | rc='7' | rc='8' | rc='9' | rc='0' | rc='*' then
  468.      do
  469.      rc0=" "date()"ú  " time() " " "Pressed "rc crlf
  470.      say rc0
  471.      if mainlog then call charout rclog,rc0
  472.  
  473.  
  474.      if DTMF_COMP="PASSED" then
  475.      do
  476.      
  477.       if value(DTMF_||rc) <> "" then
  478.         do
  479.         call RxAsyncTxImmediate PortHandle, c2x(dle)
  480.         db="pressed" rc crlf
  481.         if debug then call charout debug.log,db
  482.         end_rec=value(DTMF_||rc)
  483.         end        
  484.       else NOP
  485.      
  486.      end
  487.      else
  488.      do
  489.      DTMF_COMP=DTMF_COMP||rc
  490.       IF DTMF_PASS=DTMF_COMP THEN
  491.        do
  492.        DTMF_COMP="PASSED"
  493.        call RxAsyncTxImmediate PortHandle, c2x(dle)
  494.        db="Pass entered" rc crlf
  495.        if debug then call charout debug.log,db
  496.        end_rec="ADMIN"
  497.        end
  498.      end
  499.  
  500.    rc=SUBSTR(frame,i,1)
  501.    i=i+1
  502.    end
  503.  
  504.    otherwise
  505.    call beep 262,250
  506.    rc=" "date()"ú  " time() " " "ERROR Pressed "rc crlf
  507.    say rc
  508.    if mainlog then call charout rclog,rc
  509.  
  510.    rc=SUBSTR(frame,i,1)
  511.    i=i+1
  512.    end
  513.  end
  514.  
  515. call charout voicename,rc
  516. if chars()=1 then
  517. do
  518. rc=SysGetKey(noecho)
  519. call RxAsyncTxImmediate PortHandle, c2x(dle)
  520. end_rec="kb_key"
  521. end
  522. end
  523. end
  524.  
  525. done:
  526.  
  527. select
  528.  
  529. when end_rec="PLAY_NEW" then
  530.  do
  531.  ext=".gsm"
  532.  call play_new
  533.  end
  534.  
  535. when left(end_rec,9)="PLAY_FILE" then
  536.  do
  537.  hallo=greetdir"\"||substr(end_rec,11)
  538.  call voice_init
  539.  call play_file
  540.  end
  541.  
  542. when end_rec="GOODBYE" then NOP
  543.  
  544. when end_rec="ADMIN" then
  545.  do
  546.  hallo=greetdir"\owner.gsm"
  547.  signal owner_proc
  548.  end
  549.  
  550. when end_rec="d_tone" then NOP
  551.  
  552. when end_rec="kb_key" then NOP
  553.  
  554. otherwise
  555. end
  556.  
  557. rc=" "chars(voicename) / 38 * 0.02 "sec"
  558. num=num+length(rc)
  559. call charout numlog,rc
  560.  
  561. call close_all
  562. if extern_run then signal term
  563. signal patrol
  564.  
  565.  
  566.  
  567. /* --- Banner Proc --------*/
  568.  
  569.  
  570. /* --- Banner Ends --------*/
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577. /* --- Check Port State --------*/
  578. comport_check:
  579. if stream(comport,'c','open') = 'NOTREADY:32' then signal err0
  580.  
  581. call stream comport,'c','close'
  582. rc = RxAsyncOpen( Comport, 'PortHandle' )
  583.  
  584. com_init:
  585.  
  586. rc = RxAsyncSetLnCtrl( PortHandle, 57600, 8, 'N', 1 )
  587. if rc <> 0 then signal err0
  588.  
  589. rc=RxAsyncSetDcbInfo(PortHandle,400,50,'00001001','10000000','','','','','' )
  590. return
  591.  
  592. err0:
  593. rc=" "date()"ú  " time() "  Comport is not respond... ;(" crlf
  594. say rc
  595. if mainlog then call charout rclog,rc
  596. call beep 262,250
  597. exit
  598. /* -----------------------------*/
  599.  
  600.  
  601.  
  602. /* -- Check Modem String --------- */
  603. check_string:
  604. PARSE ARG deb_str, ok_str, err_str
  605.  
  606. InpStr = ""
  607. do until InpStr=ok_str||crlf | InpStr='ERROR'||crlf
  608. rc = RxAsyncRead( PortHandle, 0, 3000, 'InpStr' )
  609. if rc <> 0 then signal err1
  610. db=deb_str InpStr crlf
  611. if debug then call charout debug.log,db
  612. end
  613.  
  614. if InpStr = ok_str||crlf then return
  615.  
  616. err1:
  617. rc=" "date()"ú  " time() err_str crlf
  618. say rc
  619. if mainlog then call charout rclog,rc
  620. call beep 262,250
  621. signal term
  622. /* -- Check Modem String - Ends -- */
  623.  
  624.  
  625.  
  626. /* ----- Close All Files -------*/
  627. close_all:
  628. call stream hallo,'c','close'
  629. call stream voicename,'c','close'
  630. call stream numlog,'c','close'
  631. call stream rclog,'c','close'
  632. call stream debug.log,'c','close'
  633. return
  634. /* -----------------------------*/
  635.  
  636.  
  637. /* ---- Play Voice File --------*/
  638. play_file:
  639.  
  640. rc = RxAsyncWrite( PortHandle, 0, playback||crlf, 'Remaining' )
  641. if rc <> 0 then signal err1
  642. call check_string "Playback", "CONNECT", "  PlayBack Failed... Exitting... ;("
  643.  
  644. rc=" "date()"ú  " time() "  Playing..." crlf
  645. say rc
  646. if mainlog then call charout rclog,rc
  647.  
  648. do forever
  649.  
  650. write_buf=''
  651.  
  652. do 50
  653.  
  654. rc=charin(hallo,,1)
  655. if c2x(rc)="" then signal done_play
  656.  
  657. if c2x(rc)=10 then write_buf=write_buf||rc
  658. write_buf=write_buf||rc
  659.  
  660. if chars()=1 then
  661.   do
  662.   rc=SysGetKey(noecho)
  663.   call RxAsyncWrite PortHandle, 2, cancel, 'Remaining'
  664.   signal done_play
  665.   end
  666.  
  667. end
  668.  
  669. rc = RxAsyncWrite( PortHandle, 0, write_buf, 'Remaining' )
  670. if rc <> 0 then signal done_play
  671.  
  672. end
  673.  
  674. done_play:
  675.  
  676.  
  677. call RxAsyncWrite PortHandle, 2, dle_etx, 'Remaining'
  678.  
  679. call cancel_stream
  680.  
  681. call stream hallo,'c','close'
  682. return
  683. /* ----------------------------------------- */
  684.  
  685.  
  686. /* ----------- Play New Messages ------------*/
  687. play_new:
  688. rc=linein(numlog,,0)
  689. rc=stream(numlog,'c','seek <'num)
  690.  
  691. rc=" "date()"ú  " time() " " "Play New..."
  692. say rc
  693. if mainlog then call charout rclog,rc
  694.  
  695. begin_new:
  696. caller=" "linein(numlog,,1) crlf
  697. hallo=word(caller,5)
  698. if hallo='' then
  699. do
  700. call voice_init
  701. call beep_to_line
  702. hallo=greetdir"\hallo.gsm"
  703. call close_all
  704. return
  705. end
  706.  
  707. if substr(caller,3,2) = '--' then signal begin_new
  708.  
  709. say crlf caller
  710. if mainlog then call charout rclog,crlf||caller
  711.  
  712. hall=hallo
  713. call voice_init
  714.  
  715. aonname=substr(word(caller,3),4,7)
  716.  
  717. do while rc \= ""
  718. rc=linein(users.lst,,1)
  719. parse value rc with . c_id . . v_name . .
  720. if c_id = "ID:"||aonname & left(v_name,1) <> "-" then
  721.   do
  722.   hallo=".\names\"v_name||ext
  723.   if ext=".gsm" then call play_file
  724.   else if use_sound then call play_wav_file
  725.   signal speak
  726.   end
  727. end
  728.  
  729.  
  730. do i=1 to 7
  731. hallo=".\number\"substr(aonname,i,1)".gsm"
  732. call play_file
  733. end
  734.  
  735. speak:
  736. call stream users.lst,'c','close'
  737.  
  738. hallo=hall
  739.  
  740. if right(hallo,3)\='gsm' then signal begin_new
  741.  
  742. rc=" "date()"ú  " time() " " hallo crlf
  743. say rc
  744. if mainlog then call charout rclog,rc
  745.  
  746. hallo=VoiceDir"\"hallo
  747. call voice_init
  748. call play_file
  749. signal begin_new
  750. return
  751. /* ------------------------------------------------------------- */
  752.  
  753. /* ------------ Voice Initialization ------------------------- */
  754.  
  755. voice_init:
  756.  
  757. rc = RxAsyncWrite( PortHandle, 0, VoiceInit||crlf, 'Remaining' )
  758. if rc <> 0 then signal err1
  759. call check_string "VoiceInit", "OK", "Error entering to Voice mode... Exitting... ;("
  760.  
  761.  
  762. rc = RxAsyncWrite( PortHandle, 0, speaker||crlf, 'Remaining' )
  763. if rc <> 0 then signal err1
  764. call check_string "Speaker", "OK", "  Error setting audio device... ;("
  765. return
  766.  
  767. /* ---------------  Voice Init Endp  -------------------------*/
  768.  
  769.  
  770. /* ---- Reading Tail of Stream from Port ---- */
  771.  
  772. cancel_stream:
  773.  
  774. rc=" "date()"ú  " time() "  Done..." crlf
  775. say rc
  776. if mainlog then call charout rclog,rc
  777.  
  778. do until rc='VCON'||crlf
  779. db = RxAsyncRead( PortHandle, 0, 0, 'rc' )
  780. db="process end" rc crlf
  781. if debug then call charout debug.log,db
  782. end
  783.  
  784. return
  785.  
  786. /* -------------- End Proc ----------------- */
  787.  
  788.  
  789. /* ---------------  Beep To Line  --------------------------*/
  790. beep_to_line:
  791.  
  792. rc = RxAsyncWrite( PortHandle, 0, beep_1||crlf, 'Remaining' )
  793. if rc <> 0 then signal err1
  794. call check_string "Beep_1", "OK", ""
  795.  
  796. return
  797. /* ---------------  Beep To Line Ends ----------------------*/
  798.  
  799. /* ---------------  Reject Proc  -------------- */
  800. reject:
  801.  
  802. call stream users.lst,'c','close'
  803. if use_sound then '@start /c tnum.cmd' caller
  804.  
  805. rej=rej+1
  806.  
  807. rc=crlf" "time()" "left(caller,19) " rejected" "--------- " user"  No Message"
  808. num=num+length(rc)
  809. call charout numlog,rc
  810.  
  811. call syssleep 0.5
  812.  
  813. if permit="admin_mob" then
  814. do
  815. call voice_init
  816. hallo=".\number\"rez".gsm"
  817. call play_file
  818. hallo=".\number\"rej".gsm"
  819. call play_file
  820. end
  821.  
  822. call stream numlog,'c','close'
  823.  
  824. if extern_run then signal hang_line
  825. signal patrol
  826. /* -------------- Reject End --------------- */
  827.  
  828. /* -------------- Ring Break Proc -------------- */
  829. ring_break:
  830.  
  831. call RxAsyncTxImmediate PortHandle, c2x(dle)
  832. call syssleep 1
  833. call check_string "ringing", "OK", "  Ring Emulation not Work... Exitting... ;("
  834.  
  835. return
  836. /* -------------- Ring break Ends -------------- */
  837.  
  838. /* -------------- Owner_Proc ------------------- */
  839. owner_proc:
  840.  
  841. call voice_init
  842. call play_file
  843.  
  844. if rez=0 & rej=0 then hallo=greetdir"\call_off.gsm"
  845. else
  846. do
  847. hallo=greetdir"\call_on.gsm"
  848. call play_file
  849. hallo=greetdir"\white.gsm"
  850. call play_file
  851. hallo=".\number\"rez".gsm"
  852. call play_file
  853. hallo=greetdir"\black.gsm"
  854. call play_file
  855. hallo=".\number\"rej".gsm"
  856. end
  857.  
  858. call play_file
  859. signal go_rec
  860.  
  861. /* -------------- Owner_Endp ------------------- */
  862.  
  863. /* -------------- Play_Wave_File --------------- */
  864. play_wav_file:
  865.  
  866. /* Load the DLL, initialize MCI REXX support */
  867. call RXFUNCADD 'mciRxInit','MCIAPI','mciRxInit'
  868. rc=mciRxInit()
  869.  
  870. retst=''
  871. myopen="Open" hallo "Alias Wave shareable"
  872. myplay="Play Wave Wait"
  873.  
  874. MacRC = mciRxSendString(myopen, 'RetSt', '0', '0')
  875.  
  876. MacRC = mciRxSendString(myplay, 'RetSt', '0', '0')
  877.  
  878. MacRC = mciRxSendString('close Wave wait', 'RetSt', '0', '0')
  879.  
  880. MacRC = mciRxExit()
  881. return
  882.  
  883. /* -------------- Play_Wave_File Ends ---------- */
  884.  
  885.  
  886. fals_key:
  887. key=c2d(SysGetKey())
  888.  
  889. sel_key:
  890. select
  891. when key=27 | key=32 then
  892. do
  893. rc=" "date()"ú  " time() "  ESC pressed, Aborting... ;)" crlf
  894. say rc
  895. if mainlog then call charout rclog,rc
  896.  
  897. call ring_break
  898.  
  899. rc=" Aborted..."
  900. num=num+length(rc)
  901. call charout numlog,rc
  902. call stream numlog,'c','close'
  903.  
  904. signal patrol
  905. end
  906.  
  907. when key=13 then
  908. do
  909. call ring_break
  910. signal ring_end
  911. end
  912.  
  913. when key=110 | key=78 then    /* (N) */
  914. do
  915. ext=".wav"
  916. call play_new
  917. signal space
  918. end
  919.  
  920. otherwise
  921. return
  922. end
  923.  
  924. hang_line:
  925. rc = RxAsyncWrite( PortHandle, 0, init||crlf, 'Remaining' )
  926. if rc <> 0 then signal err1
  927.  
  928. call check_string "Init", "OK", "  Modem not ready... Exitting... ;("
  929.  
  930.  
  931. halt:
  932. say "îÑ¡∩ πí¿½¿..."
  933. term:
  934.  
  935. call close_all
  936. call RxAsyncClose PortHandle
  937.  
  938. /*
  939. do until rc=-1
  940. rc = RxAsyncRead( PortHandle, 0, 0, 'InpStr' )
  941. db="Echo" InpStr crlf
  942. if debug then call charout debug.log,db
  943. end
  944. */
  945.  
  946. prog_quit: