home *** CD-ROM | disk | FTP | other *** search
- /* EMCheck 1.1 (11.11.2000) */
-
- signal on halt
- signal on break_c
-
- call init()
-
- call CreateApp()
-
- call handleApp()
-
- /* never reached */
-
- init:procedure expose global.
- l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit
- if AddLibrary("rxmui.library")~=0 then exit
- call RxMUIOpt("DebugMode ShowErr")
-
- global.this=x2d(pragma("ID"))
- global.fun=""
- global.closing=0
- return
-
-
- HandleApp: procedure expose global.
- do forever
- call HandleAppOnce()
- end
- /* never reached */
-
- HandleAppOnce: procedure expose global.
- ctrl_c=2**12
- sig = or(ctrl_c,global.aps)
- call NewHandle("APP","H",sig)
- if and(h.signals,ctrl_c)>0 then call SafeQuit(1)
- if and(h.signals,global.aps)>0 then call HandleArexxPort()
- if h.EventFlag then
- select
- when h.event="QUIT" then call SafeQuit(1)
- otherwise interpret h.event
- end
- return
-
- CreateApp: procedure expose global.
-
- mstrip.0="MProject"
- MProject.class="menu"
- MProject.title="Project"
- MProject.0=MenuItem("MAbout","About...","?")
- MProject.1=MenuItem("MAboutRxMUI","About RxMUI...")
- MProject.2=MenuItem("MAboutMUI","About MUI...")
- MProject.3=MenuItem("","BAR")
- MProject.4=MenuItem("MHide","Hide","H")
- MProject.5=MenuItem("","BAR")
- MProject.6=MenuItem("MQuit","Quit","Q")
- mstrip.1="MSettings"
- MSettings.class="menu"
- MSettings.title="Preferences"
- MSettings.0=MenuItem("MUse","Use","U")
- MSettings.1=MenuItem("MSave","Save","S")
- MSettings.2=MenuItem("MRestore","Last saved","R")
- MSettings.3=MenuItem("","BAR")
- MSettings.4=MenuItem("MMUI","MUI...")
- res=NewObj("menustrip","mstrip")
- if res>0 then exit
-
- app.title="EMCheck"
- app.version="$VER: EMCheck 1.1 (11.11.2000)"
- app.copyright="Under GNU public licence"
- app.author="Alfonso [alfie] Ranieri"
- app.description="Checks a pop3 email account."
- app.base="EMCHECK"
- app.DiskObject="emcheck"
- app.OwnArexx=1
- app.MenuStrip="mstrip"
- app.SubWindow="mwin"
-
- mwin.ID="MAIN"
- mwin.Title="EMCheck 1.1"
- mwin.Contents="mgroup"
-
- mgroup.0="g0"
- g0.Class="group"
- g0.Frame="group"
- g0.Columns=2
- g0.0=label("_Host")
- g0.1="hg"
- hg.Class="group"
- hg.Horiz=1
- hg.spacing=1
- host.CycleChain=1
- host.ObjectID=1
- hg.0=string("host","h")
- HostPort.Weight=30
- HostPort.CycleChain=1
- HostPort.ObjectID=2
- HostPort.IsNumeric=1
- HostPort.MinVal=1
- HostPort.MaxVal=65535
- HostPort.Format="right"
- hg.1=string("HostPort",,110)
- g0.2=label("_User")
- user.CycleChain=1
- user.ObjectID=3
- g0.3=string("user","u")
- g0.4=label("_Pass")
- pass.CycleChain=1
- pass.ObjectID=4
- pass.Secret=1
- g0.5=string("pass","p")
-
- mgroup.1=text("info","Welcome to EMCheck!")
-
- mgroup.2="g1"
- g1.Class="group"
- g1.PageMode=1
- start.CycleChain=1
- g1.0=button("start","_Start")
- stop.CycleChain=1
- g1.1=button("stop","_Stop")
-
- res=NewObj("application","app")
- if res>0 then exit
-
- call notify("mwin","CloseRequest",1,"app","ReturnID","QUIT")
-
- call notify("MAbout","MenuTrigger","EveryTime","app","About","mwin")
- call notify("MAboutRxMUI","MenuTrigger","EveryTime","app","AboutRxMUI","mwin")
- call notify("MAboutMUI","MenuTrigger","EveryTime","app","AboutMUI","mwin")
- call notify("MHide","MenuTrigger","EveryTime","app","set","iconified",1)
- call notify("MQuit","MenuTrigger","EveryTime","app","returnid","quit")
- call notify("MUse","MenuTrigger","EveryTime","app","save","env")
- call notify("MSave","MenuTrigger","EveryTime","app","save","envarc")
- call notify("MSave","MenuTrigger","EveryTime","app","save","env")
- call notify("MRestore","MenuTrigger","EveryTime","app","load","envarc")
- call notify("MMUI","MenuTrigger","EveryTime","app","OpenConfigWindow")
-
- call notify("start","pressed",0,"app","return","call SafeStart")
- call notify("stop","pressed",0,"app","return","call SafeQuit(0)")
-
- call notify("g1","ActivePage","EveryTime","g0","set","disabled","TriggerValue")
- call notify("g1","ActivePage",0,"mwin","set","DefaultObject","start")
- call notify("g1","ActivePage",1,"mwin","set","DefaultObject","stop")
- call notify("g1","ActivePage",0,"mwin","set","ActiveObject","start")
- call notify("g1","ActivePage",1,"mwin","set","ActiveObject","stop")
-
- call DoMethod("app","load","env")
-
- call getattr("app","base","GLOBAL.REXXPORT")
- global.aps=PortSignal(global.RexxPort)
-
- call set("mwin","open",1)
- call getattr("mwin","open","o")
- if o=0 then exit
-
- call set("g1","ActivePage",0)
-
- return
-
- halt:
- break_c:
- call SafeQuit(1)
-
- HandleArexxPort: procedure expose global.
-
- do while pkt~=null()
- pkt=GetPkt(global.RexxPort)
- if pkt~=null() then call HandleARexxMsg(pkt)
- call DoMethod("app","InputBuffered")
- end
- return
-
- HandleARexxMsg: procedure expose global.
- parse arg pkt
-
- msg=GetArg(pkt)
- parse var msg cmd args
- ret1=0
- ret2=0
-
- select
-
- when cmd="QUIT" then call SafeQuit(1)
- when cmd="HIDE" then call set("app","iconified",1)
- when cmd="SHOW" then call set("app","iconified",0)
-
- when cmd="MACRO" then do
- parse var args id macro
- if id=global.this then do
- global.fun=macro
- call set("app","sleep",0)
- end
- else ret1=20
- end
-
- when cmd="ERR" | cmd="EOM" then do
- parse var args id msg
- if id=global.this then do
- global.fun=""
- if cmd="ERR" then call info(msg)
- call set("g1","ActivePage",0)
- end
- else ret1=20
- end
-
- when cmd="INFO" then do
- parse var args id msg
- if id=global.this then call info(msg)
- else ret1=20
- end
-
- otherwise ret1=20
-
- end
-
- call reply(pkt,ret1,ret2)
-
- return
-
-
- SafeStart: procedure expose global.
-
- if ~IsLibOn("SOCKET") then do
- call info("No TCP/IP stack running !!!")
- return
- end
-
- if ~exists("EMCheckFun.rexx") then do
- call info("EMCheckFun.rexx not found !!!")
- return
- end
-
- call getattr("host","contents","H")
- if h="" then do
- call info("Host not suppleid.")
- return
- end
-
- call getattr("HostPort","contents","HP")
- if hp="" then do
- call info("Host porta not supplied.")
- return
- end
- if hp=0 | hp>65535 then do
- call info("Host port not valid '"hp"'.")
- return
- end
-
- call getattr("user","contents","U")
- if user="" then do
- call info("User not supplied.")
- return
- end
-
- call getattr("pass","contents","P")
- if p="" then do
- call info("Password not supplied.")
- return
- end
-
- call set("app","sleep",1)
- call set("g1","ActivePage",1)
- call info("Launching child macro...")
-
- /*ID/A,HOST/A,HOSTPORT/A/N,USER/A,PASS/A*/
- cmd="EMCheckFun.rexx" global.this '"'h'"' '"'hp'"' '"'u'"' '"'p'"'
- call RxsCall(cmd,,,global.RexxPort)
-
- return
-
- SafeQuit: procedure expose global.
- parse arg e
-
- if global.closing then return
-
- call set("app","sleep",1)
- global.closing=1
-
- if global.fun~="" then do
- call info("Waiting for child macro...")
- call Signal(global.fun,2**12)
- do while global.fun~=""
- call HandleAppOnce()
- end
- end
-
- if e then exit
-
- call set("g1","ActivePage",0)
- call set("app","sleep",0)
- global.closing=0
- return
-
-
-
- info: procedure expose global.
- parse arg msg
- call set("info","contents",msg)
- return
-
-