home *** CD-ROM | disk | FTP | other *** search
- /* SendMsg.rexx 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("rexxsupport.library","rxsocket.library","rxmui.library")~=0 then exit
-
- call RxMUIOpt("DebugMode ShowErr")
-
- global.this=x2d(pragma("ID"))
- global.fun=""
- global.closing=0
-
- parm.1.value=""
- parm.2.value=""
- parm.3.value=""
- if ~ReadArgs("NEW/S,TO/K,SUBJECT/K,MSG/K/F") then do
- call PrintFault()
- exit
- end
- global.MsgType=parm.0.flag
- if global.MsgType then do
- global.to=""
- global.group=parm.1.value
- end
- else do
- global.to=parm.1.value
- global.group=""
- end
- global.esubject=parm.2.value
- global.nsubject=parm.2.value
- global.msg=parm.3.value
-
- global.CM=exists("MUI:Libs/MUI/CManager.mcc")
-
- return
- /***********************************************************************/
- CreateApp: procedure expose global.
-
- strip.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")
- strip.1="MSettings"
- MSettings.Title="Settings"
- MSettings.Class="menu"
- MShowP.ObjectID=1
- MSettings.0=MenuItem("MShowP","Show Prefs","P","CHEKIT TOGGLE")
- MSettings.1=MenuItem("MMUI","MUI...")
- res=NewObj("Menustrip","strip")
- if res~=0 then call err(res)
-
- to.CycleChain=1
- if string("to","n")="" then call err(57)
-
- if global.cm then do
- ToObj.object="cmg"
- cmg.Class="group"
- cmg.Frame="InputList"
- cmg.0="cm"
- cm.Class="cm"
- cm.AutoLoad=1
- cm.HideUsers=0
- cm.HideWWW=1
- cm.HideFtp=1
- cm.HideChat=1
- cm.HideTelnet=1
- cm.NoMenu=1
- cm.DoubleClick="GLOBAL.CMENTRY"
- ToObj.String="to"
- ToObj.Button=MakeObj("","ImageButton","Popup")
- ToObj.Toggle=1
-
- res=NewObj("popobject","ToObj")
- if res~=0 then call err(res)
- end
- else NameObj="to"
-
- app.Title="SendMsg"
- app.Version="$VER: SendMsg 1.0 (20.7.2000)"
- app.Copyright="Copyright 2000 by alfie"
- app.Author="alfie"
- app.Description="Send e-messages"
- app.Base="SENDMSG"
- app.OwnARexx=1
- app.MenuStrip="strip"
- app.SubWindow="mwin"
-
- mwin.ID="MAIN"
- mwin.Title="SendMsg"
- mwin.Contents="mgroup"
-
- call child("mgroup","mg","group")
-
- call child("mg","swg","group")
- swg.Horiz=1
- swg.0=label("Send _what")
- swg.1=MakeObj("MsgType","Cycle","EMail|New","w",global.MsgType)
-
- call child("mg","eg","group")
- eg.Frame="group"
- eg.FrameTitle="Message data"
- eg.Background="groupback"
- call child("eg","sg","group")
- sg.PageMode=1
- sg.ActivePage=global.MsgType
- call child("sg","sge","group")
- sge.Columns=2
- call child("sge",label("_To"))
- call child("sge","ToObj")
- call child("sge",label("S_ubject"))
- esubject.CycleChain=1; call child("sge",string("ESUBJECT","u",global.esubject))
- call child("sg","sgn","group")
- sgn.Columns=2
- call child("sgn",label("_Group"))
- group.CycleChain=1; call child("sgn",string("group","g",global.group))
- call child("sgn",label("S_ubject"))
- nsubject.CycleChain=1; call child("sgn",string("NSUBJECT","u",global.nsubject))
- call child("eg","text","TextInputScroll")
- text.Frame="string"
- text.CycleChain=1
- text.MaxLen=1024
- text.Styles="EMAIL"
- text.ScrollVertScrollerOnly=1
- text.MaxLines=256
- text.Multiline=1
- text.Contents=global.msg
-
- call child("mgroup","g0","group")
- g0.Weight=0
- g0.Frame="group"
- g0.FrameTitle="Preferences"
- g0.BAckground="groupback"
- g0.Columns=2
- call child("g0",label("Real _name"))
- name.CycleChain=1; name.ObjectID=2; call child("g0",string("NAME","n"))
- call child("g0",label("_EMail"))
- email.CycleChain=1; email.ObjectID=3; call child("g0",string("EMAIL","e"))
- call child("g0",label("_Host"))
- call child("g0","hg","group")
- hg.PageMode=1
- hg.ActivePage=global.MsgType
- ehost.CycleChain=1; ehost.ObjectID=4; call child("hg",string("EHOST","h"))
- nhost.CycleChain=1; nhost.ObjectID=5; call child("hg",string("NHOST","h"))
-
- info.Weight=20;
- call child("mgroup",text("info","Welcome to SendMsg!"))
-
- call child("mgroup","abg","group")
- abg.Weight=20
- abg.Horiz=1
- abg.PageMode=1
- call child("abg","abg0","group")
- abg0.Horiz=1
- send.CycleChain=1; call child("abg0",button("SEND","_Send"))
- call child("abg0",hspace())
- call child("abg0",button("QUIT","_Quit"))
- call child("abg",button("STOP","_Stop"))
-
- res=NewObj("application","app")
- if res~=0 then call err(res)
-
- call notify("mwin","CloseRequest",1,"app","return","call SafeQuit(1)")
-
- call notify("MAbout","MenuTrigger","everytime","app","about","win")
- call notify("MAboutRxMUI","MenuTrigger","everytime","app","aboutrxmui","win")
- call notify("MAboutMUI","MenuTrigger","everytime","app","aboutmui","win")
- call notify("MHide","MenuTrigger","everytime","app","Set","iconified",1)
- call notify("MQuit","MenuTrigger","everytime","app","return","call SafeQuit(1)")
- call notify("MShowP",""Checked"","everytime","g0","Set","ShowMe","triggervalue")
- call notify("mmui","MenuTrigger","everytime","app","openconfigwindow","win")
-
- call notify("MsgType","active","everytime","hg","Set","ActivePage","triggervalue")
- call notify("MsgType","active","everytime","sg","Set","ActivePage","triggervalue")
-
- call notify("send","pressed",0,"app","return","call SafeStart()")
- call notify("stop","pressed",0,"app","return","call SafeQuit(0)")
- call notify("quit","pressed",0,"app","return","call SafeQuit(1)")
-
- call notify("abg","ActivePage","everytime","mg","Set","disabled","triggervalue")
-
- if global.CM then do
- call Notify("cm","doubleclick","everytime","ToObj","close",1)
- call Notify("ToObj","success",1,"app","return","call set('to','contents',global.cmentry.email)")
- end
-
- call DoMethod("app","load","envarc")
- call GetAttr("MShowP",""Checked"","S")
- call set("g0","ShowMe",s)
- call set("mwin","defaultobject","send")
-
- call set("mwin","open",1)
- call GetAttr("mwin","open","o")
- if o=0 then do
- say "can't open window"
- call SafeQuit(1)
- end
-
- call GetAttr("app","base","GLOBAL.REXXPORT")
- global.aps = portSignal(global.rexxPort)
-
- return
- /**************************************************************************/
- HandleApp: procedure expose global.
- do forever
- call HandleAppOnce()
- end
- /**************************************************************************/
- 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
- /**************************************************************************/
- 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("abg","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("sendmsgfun.rexx") then do
- call info "Macro 'sendmsgfun.rexx' not found"
- call set("app","sleep",0)
- return
- end
-
- call GetAttr("MsgType","active","T")
- if t then do
- call GetAttr("nhost","contents","H")
- call GetAttr("name","contents","N")
- call GetAttr("email","contents","E")
- call GetAttr("group","contents","TO")
- call GetAttr("nsubject","contents","S")
- call GetAttr("text","contents","TE")
- end
- else do
- call GetAttr("ehost","contents","H")
- call GetAttr("name","contents","N")
- call GetAttr("email","contents","E")
- call GetAttr("to","contents","TO")
- call GetAttr("esubject","contents","S")
- call GetAttr("text","contents","TE")
- end
-
- if h="" then do
- if t then call info("You must supply a valid News host name")
- else call info("You must supply a valid SMTP host name")
- call set("app","sleep",0)
- return
- end
-
- if n="" then do
- call info("No Real name supplied")
- call set("app","sleep",0)
- return
- end
-
- if e="" then do
- call info("No EMail address supplied")
- call set("app","sleep",0)
- return
- end
-
- if to="" then do
- if t then call info("You must supply a newsgroup name")
- else call info("You must supply a dest EMail address")
- call set("app","sleep",0)
- return
- end
-
- if s="" then do
- call info("No subject supplied")
- call set("app","sleep",0)
- return
- end
-
- if te="" then do
- call info("Can't send an empty message")
- call set("app","sleep",0)
- return
- end
-
- call set("app","sleep",1)
- call set("abg","ActivePage",1)
- call info("Launching child...")
-
- if t then hp=119
- else hp=25
-
-
- /* ID/A,TYPE/A/N,HOST/A,HOSTPORT/A,REALNAME/A,EMAIL/A,TO/A,SUBJECT/A,TEXT/A/K/F */
- cmd="SendMsgFun.rexx" global.this t h hp '"'n'"' '"'e'"' '"'to'"' '"'s'"' "TEXT" te
- 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("Breaking child task...")
-
- call Signal(global.fun,2**12)
- do while global.fun~=""
- call HandleAppOnce()
- end
- end
-
- if e then do
- call DoMethod("app","save","envarc")
- exit
- end
-
- call set("abg","ActivePage",0)
- call set("app","sleep",0)
- global.closing=0
- return
- /**************************************************************************/
- info: procedure expose global.
- parse arg txt
- call set("info","contents",txt)
- return
- /**************************************************************************/
- halt:
- break_c:
- call SafeQuit(1)
- /**************************************************************************/
-