home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 22 / AACD 22.iso / AACD / Programming / RxMUI / Examples / EmCheck.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  2001-05-24  |  7.3 KB  |  248 lines

  1. /* EMCheck 1.2 (13.3.2001) */
  2.  
  3. signal on halt
  4. signal on break_c
  5.  
  6. call init()
  7. call CreateApp()
  8. call handleApp()
  9. /* never reached */
  10. /***************************************************************************/
  11. init:procedure expose global.
  12.     l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit
  13.     if AddLibrary("rxmui.library","rxsocket.library","rxlibnet.library")~=0 then exit
  14.     call RxMUIOpt("DebugMode ShowErr")
  15.  
  16.     global.MacroNotify="EMCHECK_"time(s)
  17.     global.mns=MacroNotifyCreate(global.MacroNotify)
  18.     if global.mns=0 then exit
  19.  
  20.     return
  21. /***************************************************************************/
  22. HandleApp: procedure expose global.
  23.  
  24.     ctrl_c=2**12
  25.     mask=or(global.mns,ctrl_c)
  26.  
  27.     do forever
  28.         call NewHandle("app","h",mask)
  29.  
  30.         if and(h.signals,ctrl_c)>0 then exit
  31.         if and(h.signals,global.mns)>0 then call HandleMacroEvent()
  32.  
  33.         if h.EventFlag then
  34.             select
  35.                 when h.event="QUIT" then exit
  36.                 otherwise interpret h.event
  37.             end
  38.  
  39.     end
  40.     /* never reached */
  41. /***********************************************************************/
  42. HandleMacroEvent: procedure expose global.
  43.     do forever
  44.         ev=MacroNotifyGetEvent(global.MacroNotify)
  45.         if ev="" then return
  46.  
  47.         parse var ev ev child d
  48.         select
  49.  
  50.             when ev="STARTED" then do
  51.                 call set("g1","ActivePage",1)
  52.                 call set("app","sleep",0)
  53.             end
  54.  
  55.             when ev="ENDED" then do
  56.                 call set("g1","ActivePage",0)
  57.             end
  58.  
  59.             when ev="INFO" then do
  60.                 call info(d)
  61.             end
  62.  
  63.             otherwise nop
  64.         end
  65.     end
  66.     /* never reached */
  67. /***********************************************************************/
  68. CreateApp: procedure expose global.
  69.  
  70.     mstrip.0="MProject"
  71.      MProject.class="menu"
  72.      MProject.title="Project"
  73.       MProject.0=MenuItem("MAbout","About...","?")
  74.       MProject.1=MenuItem("MAboutRxMUI","About RxMUI...")
  75.       MProject.2=MenuItem("MAboutMUI","About MUI...")
  76.       MProject.3=MenuItem("","BAR")
  77.       MProject.4=MenuItem("MHide","Hide","H")
  78.       MProject.5=MenuItem("","BAR")
  79.       MProject.6=MenuItem("MQuit","Quit","Q")
  80.     mstrip.1="MSettings"
  81.      MSettings.class="menu"
  82.      MSettings.title="Preferences"
  83.       MSettings.0=MenuItem("MUse","Use","U")
  84.       MSettings.1=MenuItem("MSave","Save","S")
  85.       MSettings.2=MenuItem("MRestore","Last saved","R")
  86.       MSettings.3=MenuItem("","BAR")
  87.       MSettings.4=MenuItem("MMUI","MUI...")
  88.     res=NewObj("menustrip","mstrip")
  89.     if res>0 then exit
  90.  
  91.     app.title="EMCheck"
  92.     app.version="$VER: EMCheck 1.1 (11.11.2000)"
  93.     app.copyright="Under GNU public licence"
  94.     app.author="Alfonso [alfie] Ranieri"
  95.     app.description="Checks a pop3 email account."
  96.     app.base="EMCHECK"
  97.     app.DiskObject="emcheck"
  98.     app.MenuStrip="mstrip"
  99.     app.SubWindow="mwin"
  100.  
  101.      mwin.ID="MAIN"
  102.      mwin.Title="EMCheck 1.1"
  103.      mwin.Contents="mgroup"
  104.  
  105.       mgroup.0="g0"
  106.        g0.Class="group"
  107.        g0.Frame="group"
  108.        g0.Background="groupback"
  109.        g0.Columns=2
  110.         g0.0=label("_Host")
  111.         g0.1="hg"
  112.          hg.Class="group"
  113.          hg.Horiz=1
  114.          hg.spacing=1
  115.            host.CycleChain=1
  116.            host.ObjectID=1
  117.           hg.0=string("host","h")
  118.            HostPort.Weight=30
  119.            HostPort.CycleChain=1
  120.            HostPort.ObjectID=2
  121.            HostPort.IsNumeric=1
  122.            HostPort.MinVal=1
  123.            HostPort.MaxVal=65535
  124.            HostPort.Format="right"
  125.           hg.1=string("HostPort",,110)
  126.         g0.2=label("_Login")
  127.          login.CycleChain=1
  128.          login.ObjectID=3
  129.         g0.3=string("login","l")
  130.         g0.4=label("_Pass")
  131.          pass.CycleChain=1
  132.          pass.ObjectID=4
  133.          pass.Secret=1
  134.         g0.5=string("pass","p")
  135.  
  136.       mgroup.1=text("info","Welcome to EMCheck!")
  137.  
  138.       mgroup.2="g1"
  139.        g1.Class="group"
  140.        g1.PageMode=1
  141.          start.CycleChain=1
  142.         g1.0=button("start","_Start")
  143.          stop.CycleChain=1
  144.         g1.1=button("stop","_Stop")
  145.  
  146.     res=NewObj("application","app")
  147.     if res>0 then exit
  148.  
  149.     call notify("mwin","CloseRequest",1,"app","ReturnID","QUIT")
  150.  
  151.     call notify("MAbout","MenuTrigger","EveryTime","app","About","mwin")
  152.     call notify("MAboutRxMUI","MenuTrigger","EveryTime","app","AboutRxMUI","mwin")
  153.     call notify("MAboutMUI","MenuTrigger","EveryTime","app","AboutMUI","mwin")
  154.     call notify("MHide","MenuTrigger","EveryTime","app","set","iconified",1)
  155.     call notify("MQuit","MenuTrigger","EveryTime","app","returnid","quit")
  156.     call notify("MUse","MenuTrigger","EveryTime","app","save","env")
  157.     call notify("MSave","MenuTrigger","EveryTime","app","save","envarc")
  158.     call notify("MSave","MenuTrigger","EveryTime","app","save","env")
  159.     call notify("MRestore","MenuTrigger","EveryTime","app","load","envarc")
  160.     call notify("MMUI","MenuTrigger","EveryTime","app","OpenConfigWindow")
  161.  
  162.     call notify("start","pressed",0,"app","return","call SafeStart")
  163.     call notify("stop","pressed",0,"app","return","call SafeQuit(0)")
  164.  
  165.     call notify("g1","ActivePage","EveryTime","g0","set","disabled","TriggerValue")
  166.     call notify("g1","ActivePage",0,"mwin","set","DefaultObject","start")
  167.     call notify("g1","ActivePage",1,"mwin","set","DefaultObject","stop")
  168.     call notify("g1","ActivePage",0,"mwin","set","ActiveObject","start")
  169.     call notify("g1","ActivePage",1,"mwin","set","ActiveObject","stop")
  170.  
  171.     call DoMethod("app","load","env")
  172.  
  173.     call set("mwin","open",1)
  174.     if ~xget("mwin","open") then exit
  175.  
  176.     call set("g1","ActivePage",0)
  177.  
  178.     return
  179. /***************************************************************************/
  180. halt:
  181. break_c:
  182.     call SafeQuit(1)
  183. /***************************************************************************/
  184. SafeStart: procedure expose global.
  185.  
  186.     if ~IsLibOn("SOCKET") then do
  187.         call info("No TCP/IP stack running !!!")
  188.         return
  189.     end
  190.  
  191.     if ~exists("EMCheckFun.rexx") then do
  192.         call info("EMCheckFun.rexx not found !!!")
  193.         return
  194.     end
  195.  
  196.     var.host=xget("host","contents")
  197.     if var.host="" then do
  198.         call info("Host not supplied.")
  199.         return
  200.     end
  201.  
  202.     var.HostPort=xget("HostPort","contents")
  203.     if var.HostPort="" then do
  204.         call info("Host port not supplied.")
  205.         return
  206.     end
  207.  
  208.     if var.HostPort=0 | var.HostPort>65535 then do
  209.         call info("Host port not valid '"var.HostPort"'.")
  210.         return
  211.     end
  212.  
  213.     var.login=xget("login","contents")
  214.     if var.login="" then do
  215.         call info("Login not supplied.")
  216.         return
  217.     end
  218.  
  219.     var.Pass=xget("pass","contents")
  220.     if var.Pass="" then do
  221.         call info("Password not supplied.")
  222.         return
  223.     end
  224.  
  225.     call set("app","sleep",1)
  226.     call set("g1","ActivePage",1)
  227.     call info("Launching child macro...")
  228.  
  229.     var.MacroNotify=global.MacroNotify
  230.     call StemToVar("var")
  231.  
  232.     call RxsCall("EMCheckFun.rexx")
  233.  
  234.     return
  235. /***************************************************************************/
  236. SafeQuit: procedure expose global.
  237. parse arg e
  238.     if e then exit
  239.     call MacroNotifySync()
  240.     return
  241. /***************************************************************************/
  242. info: procedure expose global.
  243. parse arg msg
  244.     call set("info","contents",msg)
  245.     return
  246. /***************************************************************************/
  247.  
  248.