/* IRC Client - March 00 - DMS - by Sébastien DENEUX*/ var ChannelTopicBackColor=0;; /*black*/ var ChannelTopicColor=0xff0000;; /*blue*/ typeof IRCserverHost=ObjText;; typeof IRCserverPort=ObjText;; typeof IRCserverMaxNickNameLength=ObjText;; typeof IRCquitURL=ObjText;; typeof browsecombo = ObjListTab;; typeof addButton = ObjButton;; typeof editButton = ObjButton;; typeof delButton = ObjButton;; typeof secureLogin=ObjCheck;; typeof nickChanServ=ObjCheck;; typeof channelsList=[[S S] r1];; typeof currentSelection = I;; typeof editWin=ObjWin;; /*-------------*/ fun remove_nth_from_list (list, n)= if n < 0 then list else let list -> [first next] in if n==0 then next else first::remove_nth_from_list next n-1;; /*-------------*/ fun listcat (p, q)= if p==nil then q else let p -> [h nxt] in h::listcat nxt q;; /*-------------*/ fun buildAction (l)= if l==nil then nil else let hd l -> [txt name] in ("channelName"::name::nil):: ("channelInfo"::txt::nil):: ("actionC"::(strcat "unregisterChannel" (strlowercase name))::nil):: ("actionC"::(strcat "connectAndRegisterChannel" (strlowercase name))::nil):: ("actionC"::(strcatn "unregisterChannel"::(strlowercase name)::"AndDisconnect"::nil)::nil):: ("eventC"::(strcatn "channel"::(strlowercase name)::"_REGISTER_OK"::nil)::nil):: ("eventC"::(strcatn "channel"::(strlowercase name)::"_REGISTER_ERROR"::nil)::nil):: ("eventC"::(strcatn "channel"::(strlowercase name)::"_UNREGISTERED"::nil)::nil):: ("eventC"::(strcatn "channel"::(strlowercase name)::"_FORCEDPART"::nil)::nil):: buildAction tl l;; /*-------------*/ fun reBuild(l,res)= if l==nil then res else let l -> [[a b] queue] in reBuild queue listcat b::nil res;; /*-------------*/ fun save (filename, n)= /*("zoneC"::"compUsersList"::nil)::*/ ("zoneC"::"UsersList"::nil):: ("zoneC"::"ChannelTopic"::nil):: ("eventC"::"channelMsg"::"channelMsg"::nil):: /*("eventC"::"log"::"log"::nil)::*/ ("eventC"::"privateMsgWarning"::"privateMsgWarning"::nil):: ("actionC"::"command"::"command"::nil):: ("actionC"::"showLoginInterface"::"showLoginInterface"::nil):: ("actionC"::"showContextualMenu"::"showContextualMenu"::nil):: ("action"::"start"::"start"::nil):: ("eventC"::"in"::"in"::nil):: ("event"::"loginChanged"::"loginChanged"::nil):: ("actionC"::"connect"::"connect"::nil):: ("eventC"::"connection_OK"::"connection_OK"::nil):: ("eventC"::"connection_ERROR"::"connection_ERROR"::nil):: ("actionC"::"disconnect"::"disconnect"::nil):: ("eventC"::"disconnected"::"disconnected"::nil):: ("eventC"::"registerMacro"::"registerMacro"::nil):: ("eventC"::"unregisterMacro"::"unregisterMacro"::nil):: ("action"::"destroy"::"destroy"::nil):: ("event"::"destroyed"::"destroyed"::nil):: ("event"::"checkLoginPassword"::"checkLoginPassword"::nil):: ("actionC"::"avatarList"::"avatarList"::nil):: ("eventC"::"CenterOnPlayer"::"CenterOnPlayer"::nil):: ("ChannelTopicBackColor"::(itoa ChannelTopicBackColor)::nil):: ("ChannelTopicColor"::(itoa ChannelTopicColor)::nil):: ("IRCserverHost"::(_GETtext IRCserverHost)::nil):: ("IRCserverPort"::(_GETtext IRCserverPort)::nil):: ("IRCserverMaxNickNameLength"::(_GETtext IRCserverMaxNickNameLength)::nil):: ("IRCquitURL"::(_GETtext IRCquitURL)::nil):: ("secureLogin"::(itoa _GETcheck secureLogin)::nil):: ("nickChanServ"::(itoa _GETcheck nickChanServ)::nil):: ("ChannelsList"::(strbuild (reBuild channelsList nil)::nil)::nil):: buildAction channelsList;; /*-------------*/ fun _parser (l)= if l==nil then 0 else let hd l-> [key [sound _]] in ( if !strcmp key "channelName" then let hd tl l -> [key [name _]] in if !strcmp key "channelInfo" then set channelsList = listcat channelsList [name sound]::nil else nil else nil; _parser tl l );; /*-------------*/ fun addtocombo (l, index)= if l==nil then browsecombo else let hd l -> [name file] in ( _ADDlistTabItem browsecombo index index file; /*_SETlistTabItem browsecombo index 1 name;*/ addtocombo tl l index+1; );; /*-------------*/ fun _updatelist ()= _RSTlistTab browsecombo; addtocombo channelsList 0;; /*-------------*/ fun load (l)= _SETtext IRCserverHost getInfo l "IRCserverHost"; _SETtext IRCserverPort getInfo l "IRCserverPort"; _SETtext IRCserverMaxNickNameLength getInfo l "IRCserverMaxNickNameLength"; _SETtext IRCquitURL getInfo l "IRCquitURL"; _SETcheck secureLogin atoi getInfo l "secureLogin"; _SETcheck nickChanServ atoi getInfo l "nickChanServ"; let atoi getInfo l "ChannelTopicBackColor" -> tmp in if tmp==nil then nil else set ChannelTopicBackColor = tmp; let atoi getInfo l "ChannelTopicColor" -> tmp in if tmp==nil then nil else set ChannelTopicColor = tmp; set channelsList=nil; _parser l; _updatelist; 0;; /*-------------*/ fun _paintE(a,b)= _PAINTrectangle editWin 270 295 15 15 DRAW_SOLID 1 0 DRAW_SOLID ChannelTopicBackColor; _PAINTrectangle editWin 270 320 15 15 DRAW_SOLID 1 0 DRAW_SOLID ChannelTopicColor;; /*-------------*/ fun is_in_box(x,y,bx,by,bw,bh)= (x>=bx) && (x<=(bx+bw)) && (y>=by) && (y<=(by+bh));; /*-------------*/ fun _endColor1(a)=if a!=nil then set ChannelTopicBackColor=a else nil;; fun _endColor2(a)=if a!=nil then set ChannelTopicColor=a else nil;; /*-------------*/ fun _clickE(a,b,x,y,button)= if button==1 then ( /* loc( if is_in_box x y 270 295 15 15 then _CRcolorMap _channel editWin 100 100 "Choose topic background color" @_endColor1 ChannelTopicBackColor else nil; ) */ if is_in_box x y 270 295 15 15 then _CRcolorMap _channel editWin 100 100 (_locEditor "2050-IRCEDI-choosetopi" nil) @_endColor1 ChannelTopicBackColor else nil; /* loc( if is_in_box x y 270 320 15 15 then _CRcolorMap _channel editWin 100 100 "Choose topic text color" @_endColor2 ChannelTopicColor else nil; ) */ if is_in_box x y 270 320 15 15 then _CRcolorMap _channel editWin 100 100 (_locEditor "2060-IRCEDI-choosetopi" nil) @_endColor2 ChannelTopicColor else nil; 0; ) else 0;; /*-------------*/ fun _strcmp (i1, i2)= let i1->[n1 s1] in let i2->[n2 s2] in if strcmp n1 n2 then 0 else 1;; /*-------------*/ fun _strcmp2 (i1, i2)= let i1->[n1 s1] in let i2->[n2 s2] in if (!strcmp n1 n2) && (!strcmp s1 s2) then 1 else 0;; /*-------------*/ fun _okaddwin (obj,u)= let u -> [n s w] in let (_GETtext n)->name in let (_GETtext s)->sound in let nth_char sound 0 -> c0 in if /*(!strcmp name "") ||*/ (!strcmp sound "") || ((c0!='#) && (c0!='&)) then nil else let search_in_list channelsList @_strcmp [name sound]->elem in if elem!=nil then nil else ( set channelsList = listcat channelsList [name sound]::nil; _updatelist; _DSwindow w );; /*-------------*/ fun _okeditwin (obj,u)= let u -> [o n s w] in let _GETtext n->name in let _GETtext s->sound in let nth_char sound 0 -> c0 in if /*(!strcmp name "") ||*/ (!strcmp sound "") || ((c0!='#) && (c0!='&)) then nil else let search_in_list channelsList @_strcmp [o ""] -> elem in if elem==nil then nil else /*let search_in_list channelsList @_strcmp2 [name sound] -> elem in if elem!=nil then nil else*/ ( mutate elem <- [name sound]; _updatelist; _DSwindow w );; /*-------------*/ fun _quiteditwin (obj,u)= _DSwindow u;; /*-------------*/ fun _editwin (name,sound,v)= /* loc( let if v==1 then "Add Channel name" else "Edit Channel Name" -> winname in ) */ let if v==1 then (_locEditor "2730-IRCEDI-addchannel" nil) else (_locEditor "2731-IRCEDI-editchanne" nil) -> winname in let _CRwindow _channel editWin 0 0 400 80 WN_MENU winname -> w in ( /* loc( _CRtext _channel w 5 5 90 20 ET_ALIGN_CENTER "Channel Name :"; ) */ _CRtext _channel w 5 5 90 20 ET_ALIGN_CENTER (_locEditor "2760-IRCEDI-channelnam" nil); /* loc( /*_CRtext _channel w 5 30 90 20 ET_ALIGN_CENTER "Channe Info :";*/ ) */ /*_CRtext _channel w 5 30 90 20 ET_ALIGN_CENTER (_locEditor "2770-IRCEDI-channeinfo" nil);*/ /*let _GETbitmapSize openButtonIcone -> [wi hi] in*/ let [0 0] -> [wi hi] in let _CReditLine _channel w 100 5 290-wi 20 ET_DOWN+ET_AHSCROLL sound -> s in /*let _CReditLine _channel w 100 30 295 20 ET_DOWN+ET_AHSCROLL name -> n in*/ let s -> n in ( /*_CBbutton _CRbuttonBitmap _channel w openButtonIcone 395-wi 5 wi hi 0 nil [n s];*/ if v==0 then /* loc( _CBbutton _CRbutton _channel w 5 55 55 20 0 "OK" @_okeditwin [name n s w] ) */ _CBbutton _CRbutton _channel w 5 55 55 20 0 (_locEditor "2870-IRCEDI-ok" nil) @_okeditwin [name n s w] else /* loc( _CBbutton _CRbutton _channel w 5 55 70 20 0 "OK" @_okaddwin [n s w]; ) */ _CBbutton _CRbutton _channel w 5 55 70 20 0 (_locEditor "2870-IRCEDI-ok" nil) @_okaddwin [n s w]; /* loc( _CBbutton _CRbutton _channel w 340 55 55 20 0 "Cancel" @_quiteditwin w; ) */ _CBbutton _CRbutton _channel w 340 55 55 20 0 (_locEditor "2900-IRCEDI-cancel" nil) @_quiteditwin w; ) );; /*-------------*/ fun rflListDclick (obj, u, ident, col)= let nth_list channelsList ident -> [name txt] in _editwin name txt 0;; /*-------------*/ fun rflAddChannel (obj, i)= _editwin nil nil 1;; /*-------------*/ fun rflEditChannel (obj, i)= if currentSelection == nil then nil else let nth_list channelsList currentSelection -> [name sound] in _editwin name sound 0;; /*-------------*/ fun rflDelChannel (obj, c)= if currentSelection == nil then nil else ( set channelsList = remove_nth_from_list channelsList currentSelection; _updatelist; set currentSelection = nil; );; /*-------------*/ fun rflListClick (obj, u, ident)= set currentSelection = ident;; /*-------------*/ fun IniEditor (s)= let [315 440] -> [w h] in let startEditor _channel nil nil nil w h WN_NORMAL EDITOR_NORMAL s "Dms/commTools/irc/irc.dmc" nil nil @load @save nil -> ed in ( set editWin = getEditWin ed; /* loc( _CRtext _channel editWin 5 5 100 20 ET_ALIGN_LEFT "Server host : "; ) */ _CRtext _channel editWin 5 5 100 20 ET_ALIGN_LEFT (_locEditor "3390-IRCEDI-serverhost" nil); set IRCserverHost=_CReditLine _channel editWin 140 5 165 20 ET_DOWN|ET_AHSCROLL "irc.insat.com"; /* loc( _CRtext _channel editWin 5 30 100 20 ET_ALIGN_LEFT "Server Port :"; ) */ _CRtext _channel editWin 5 30 100 20 ET_ALIGN_LEFT (_locEditor "3420-IRCEDI-serverport" nil); set IRCserverPort= _CReditLine _channel editWin 140 30 165 20 ET_DOWN|ET_AHSCROLL "6667"; /* loc( _CRtext _channel editWin 5 55 130 40 ET_ALIGN_LEFT "Max nickName length\naccepted by server"; ) */ _CRtext _channel editWin 5 55 130 40 ET_ALIGN_LEFT (_locEditor "3450-IRCEDI-maxnicknam" nil); set IRCserverMaxNickNameLength=_CReditLine _channel editWin 140 55 165 20 ET_DOWN+ET_AHSCROLL "9"; /* loc( _CRtext _channel editWin 5 295 230 20 ET_ALIGN_LEFT "Topic background color"; ) */ _CRtext _channel editWin 5 295 230 20 ET_ALIGN_LEFT (_locEditor "3490-IRCEDI-topicbackg" nil); /* loc( _CRtext _channel editWin 5 320 230 20 ET_ALIGN_LEFT "Topic text color"; ) */ _CRtext _channel editWin 5 320 230 20 ET_ALIGN_LEFT (_locEditor "3500-IRCEDI-topictextc" nil); _CBwinPaint editWin @_paintE nil; _CBwinClick editWin @_clickE nil; /* loc( _CRtext _channel editWin 50 85 200 20 ET_ALIGN_CENTER "Channels list"; ) */ _CRtext _channel editWin 50 85 200 20 ET_ALIGN_CENTER (_locEditor "3580-IRCEDI-channelsli" nil); set browsecombo= _CRlistTab _channel editWin 5 100 300 150 LV_SINGLESEL+LV_DOWN; /* loc( _ADDlistTabColumn browsecombo 0 150 0 "Channel Name"; ) */ _ADDlistTabColumn browsecombo 0 150 0 (_locEditor "3640-IRCEDI-channelnam" nil); /* loc( /*_ADDlistTabColumn browsecombo 1 150 0 "Info";*/ ) */ /*_ADDlistTabColumn browsecombo 1 150 0 (_locEditor "3660-IRCEDI-info" nil);*/ _CBlistTabDClick browsecombo @rflListDclick 0; _CBlistTabSelect browsecombo @rflListClick 0; /* loc( set addButton = _CBbutton _CRbutton _channel editWin 5 260 42 20 0 "Add" @rflAddChannel nil; ) */ set addButton = _CBbutton _CRbutton _channel editWin 5 260 42 20 0 (_locEditor "3740-IRCEDI-add" nil) @rflAddChannel nil; /* loc( /*set editButton = _CBbutton _CRbutton _channel editWin 95 260 30 20 0 "Edit" @rflEditChannel nil;*/ ) */ /*set editButton = _CBbutton _CRbutton _channel editWin 95 260 30 20 0 (_locEditor "3750-IRCEDI-edit" nil) @rflEditChannel nil;*/ /* loc( set delButton = _CBbutton _CRbutton _channel editWin 50 260 60 20 0 "Del" @rflDelChannel nil; ) */ set delButton = _CBbutton _CRbutton _channel editWin 50 260 60 20 0 (_locEditor "3760-IRCEDI-del" nil) @rflDelChannel nil; /* loc( _CRtext _channel editWin 5 350 100 20 ET_ALIGN_LEFT "QUIT url : "; ) */ _CRtext _channel editWin 5 350 100 20 ET_ALIGN_LEFT (_locEditor "3780-IRCEDI-quiturl:" nil); set IRCquitURL=_CReditLine _channel editWin 130 350 175 20 ET_DOWN|ET_AHSCROLL ""; /* loc( set secureLogin=_SETcheck (_CRcheck _channel editWin 5 380 150 20 0 "check SCOL secured login") 0; ) */ set secureLogin=_SETcheck (_CRcheck _channel editWin 5 380 150 20 0 (_locEditor "3810-IRCEDI-checkscols" nil)) 0; /* loc( set nickChanServ=_SETcheck (_CRcheck _channel editWin 5 410 250 20 0 "Enable NickServ/ChanServ commands") 0; ) */ set nickChanServ=_SETcheck (_CRcheck _channel editWin 5 410 250 20 0 (_locEditor "3830-IRCEDI-enablenick" nil)) 0; if s==nil then nil else openDMI ed ); 0;;