/* Ignore Client - DMS - Apr 99 - by Christophe LOREK */ /* rev Apr 00 - by Sebastien DENEUX */ defcom Cregistered=registered;; typeof IgnoreList = [[I S [S r1]] r1];; typeof WIgnoreList = ObjList;; typeof cbchatin = ObjCheck;; typeof cbchatout = ObjCheck;; typeof cbphoto = ObjCheck;; typeof cbavatar = ObjCheck;; typeof cbspeakin = ObjCheck;; typeof cbspeakout = ObjCheck;; typeof cbpager = ObjCheck;; typeof selectedUser_name = S;; typeof selectedUser_id = I;; typeof selectedUser_IgnChatin = I;; typeof selectedUser_IgnChatout = I;; typeof selectedUser_IgnPhoto = I;; typeof selectedUser_IgnAvatar = I;; typeof selectedUser_IgnSpeakin = I;; typeof selectedUser_IgnSpeakout = I;; typeof selectedUser_IgnPager = I;; fun mylinebuild(l)= if l == nil then nil else let l -> [currentstr nl] in strcat strcat currentstr " " (mylinebuild nl);; /* IsInIgnList - Apr 99 - by Christophe LOREK */ /* This function tests if a given Client name is already present in the */ /* IgnoreList, If yes, then it returns TRUE (1), otherwise it returns */ /* FALSE (0). */ fun IsInIgnList(Cliname, IgnoreList, pos) = if IgnoreList == nil then -1 else let IgnoreList -> [[_ currentname _] NIgnoreList] in if !strcmp Cliname currentname then pos else IsInIgnList Cliname NIgnoreList pos+1;; /* UpdateWIgnoreList - Apr 99 - by Christophe LOREK */ /* this function Updates the Windows Object List containing the names */ /* of the users. A call to _RSTlist must be performed before calling */ /* this function, otherwise the name would be duplicated (in fact, the */ /* function recreates the list, so it should be emptied before the call). */ fun UpdateWIgnoreList(IgnoreList)= if IgnoreList == nil then 0 else let IgnoreList -> [[_ name paramlist] NIgnoreList] in ( UpdateWIgnoreList NIgnoreList; _ADDlist WIgnoreList 0 strcatn name::" ":: (mylinebuild paramlist)::nil; 0 );; /* ChangeNameIgnList - Apr 99 - by Christophe LOREK */ /* This function updates the name of a player in the IgnoreList when the */ /* user changes his login name. */ fun ChangeNameIgnList (oldname, newname, IgnList)= if IgnList == nil then 0 else let IgnList -> [[currentid currentname paramlist] NIgnList] in if !strcmp oldname currentname then ( mutate IgnList <- [[currentid newname paramlist] _]; _RSTlist WIgnoreList; UpdateWIgnoreList IgnoreList;/* global var, NOT the local IgnList !!! */ 1 ) else ChangeNameIgnList oldname newname NIgnList;; /* _resizeList - Apr 99 - by Christophe LOREK */ /* this function deals with the resize event of the Windows Object List. */ fun _resizeList(coord,zone)= let coord -> [win x y w h] in ( _SIZElist WIgnoreList w h-140 x y; _SIZEcheck cbchatin w-10 20 x+10 (y+h-140); _SIZEcheck cbchatout w-10 20 x+10 (y+h-120); _SIZEcheck cbphoto w-10 20 x+10 (y+h-100); _SIZEcheck cbavatar w-10 20 x+10 (y+h-80); _SIZEcheck cbspeakin w-10 20 x+10 (y+h-60); _SIZEcheck cbspeakout w-10 20 x+10 (y+h-40); _SIZEcheck cbpager w-10 20 x+10 (y+h-20); 0 );; fun AddSentClis(CliList)= if CliList == nil then nil else let CliList -> [[cliidstr [cliname _]] NCliList] in ( set IgnoreList = [(atoi cliidstr) cliname "0"::"0"::"0"::"0"::"0"::"0"::"0"::nil]::IgnoreList; set WIgnoreList = _ADDlist WIgnoreList 0 strcatn cliname::" ":: (mylinebuild "0"::"0"::"0"::"0"::"0"::"0"::"0"::nil)::nil; AddSentClis NCliList; 0 );; /* interface callbacks */ fun findUserInIgnList(list,pos)= if list == nil then nil else let list -> [current_user nlist] in if pos == 0 then current_user else findUserInIgnList nlist pos-1;; fun selectUser(WIgnList, a, pos, str)= let (findUserInIgnList IgnoreList pos) -> [monuserid username paramlist] in let paramlist -> [IgnChatin [IgnChatout [IgnPhoto [IgnAvatar [IgnSpeakin [IgnSpeakout [IgnPager _]]]]]]] in ( set selectedUser_name = username; set selectedUser_id = monuserid; _SETcheck cbchatin set selectedUser_IgnChatin = atoi IgnChatin; _SETcheck cbchatout set selectedUser_IgnChatout = atoi IgnChatout; _SETcheck cbphoto set selectedUser_IgnPhoto = atoi IgnPhoto; _SETcheck cbavatar set selectedUser_IgnAvatar = atoi IgnAvatar; _SETcheck cbspeakin set selectedUser_IgnSpeakin = atoi IgnSpeakin; _SETcheck cbspeakout set selectedUser_IgnSpeakout = atoi IgnSpeakout; _SETcheck cbpager set selectedUser_IgnPager = atoi IgnPager );; fun UpdateCurrentUser(IgnList)= if IgnList == nil then 0 else let IgnList -> [[currentid currentname _] NIgnList] in if !strcmp selectedUser_name currentname then ( mutate IgnList <- [[currentid currentname (itoa selectedUser_IgnChatin):: (itoa selectedUser_IgnChatout):: (itoa selectedUser_IgnPhoto):: (itoa selectedUser_IgnAvatar):: (itoa selectedUser_IgnSpeakin):: (itoa selectedUser_IgnSpeakout):: (itoa selectedUser_IgnPager)::nil ] _]; _RSTlist WIgnoreList; UpdateWIgnoreList IgnoreList; /* global var, NOT the local IgnList !!! */ 1 ) else UpdateCurrentUser NIgnList;; fun SetInIgnList(obcb, cbaction, state)= if !strcmp cbaction "ChatIn" then ( set selectedUser_IgnChatin = state; UpdateCurrentUser IgnoreList; _DMSevent this "IgnoreFlag" linebuild "ChatIn"::(itoa selectedUser_id)::selectedUser_name::(itoa state)::nil nil ) else if !strcmp cbaction "ChatOut" then ( set selectedUser_IgnChatout = state; UpdateCurrentUser IgnoreList; _DMSevent this "IgnoreFlag" linebuild "ChatOut"::(itoa selectedUser_id)::selectedUser_name::(itoa state)::nil nil ) else if !strcmp cbaction "Photo" then ( set selectedUser_IgnPhoto = state; UpdateCurrentUser IgnoreList; _DMSevent this "IgnoreFlag" linebuild "Photo"::(itoa selectedUser_id)::selectedUser_name::(itoa state)::nil nil ) else if !strcmp cbaction "Avatar" then ( set selectedUser_IgnAvatar = state; UpdateCurrentUser IgnoreList; _DMSevent this "IgnoreFlag" linebuild "Avatar"::(itoa selectedUser_id)::selectedUser_name::(itoa state)::nil nil ) else if !strcmp cbaction "SpeakIn" then ( set selectedUser_IgnSpeakin = state; UpdateCurrentUser IgnoreList; _DMSevent this "IgnoreFlag" linebuild "SpeakIn"::(itoa selectedUser_id)::selectedUser_name::(itoa state)::nil nil ) else if !strcmp cbaction "SpeakOut" then ( set selectedUser_IgnSpeakout = state; UpdateCurrentUser IgnoreList; _DMSevent this "IgnoreFlag" linebuild "SpeakOut"::(itoa selectedUser_id)::selectedUser_name::(itoa state)::nil nil ) else if !strcmp cbaction "Pager" then ( set selectedUser_IgnPager = state; UpdateCurrentUser IgnoreList; _DMSevent this "IgnoreFlag" linebuild "Pager"::(itoa selectedUser_id)::selectedUser_name::(itoa state)::nil nil ) else 0;; fun ShowIgnore()= let _DMSgetZone this "IgnoreList" nil @_resizeList nil -> [win x y w h] in if win == nil then nil else ( set WIgnoreList = _CRlist _channel win x y w h-140 LB_VSCROLL|LB_DOWN; _CBlistClick WIgnoreList @selectUser nil; UpdateWIgnoreList IgnoreList; set cbchatin = _CRcheck _channel win x+10 (y+h-140) w-10 20 0 "ChatIn"; _CBcheck cbchatin @SetInIgnList "ChatIn"; /*_ENcheck cbchatin 0;*/ set cbchatout = _CRcheck _channel win x+10 (y+h-120) w-10 20 0 "ChatOut"; _CBcheck cbchatout @SetInIgnList "ChatOut"; _ENcheck cbchatout 0; set cbphoto = _CRcheck _channel win x+10 (y+h-100) w-10 20 0 "Photo"; _CBcheck cbphoto @SetInIgnList "Photo"; set cbavatar = _CRcheck _channel win x+10 (y+h-80) w-10 20 0 "Avatar"; _CBcheck cbavatar @SetInIgnList "Avatar"; _ENcheck cbavatar 0; set cbspeakin = _CRcheck _channel win x+10 (y+h-60) w-10 20 0 "SpeakIn"; _CBcheck cbspeakin @SetInIgnList "SpeakIn"; set cbspeakout = _CRcheck _channel win x+10 (y+h-40) w-10 20 0 "SpeakOut"; _CBcheck cbspeakout @SetInIgnList "SpeakOut"; set cbpager = _CRcheck _channel win x+10 (y+h-20) w-10 20 0 "Pager"; _CBcheck cbpager @SetInIgnList "Pager"; _DMSevent this "shown" nil nil; 0 );; fun HideIgnore()= _DSlist WIgnoreList; _DScheck cbchatin; _DScheck cbchatout; _DScheck cbphoto; _DScheck cbavatar; _DScheck cbspeakin; _DScheck cbspeakout; _DScheck cbpager; _DMSreleaseZone this "IgnoreList"; _DMSevent this "Hidden" nil nil;; fun activate(from,action,param,rep)= if !strcmp action "Show" then ShowIgnore else if !strcmp action "Hide" then HideIgnore else nil;; fun IniDMI(param)= _DMSregisterDMI this @activate nil; _DMSsend this Cregistered []; _DMSevent this "in" nil nil;; /* __register - Apr 99 - by Christophe LOREK */ /* this function is called when a new client is created. */ fun __register(id, name, paramstring)= let lineextr paramstring -> paramlist in if (IsInIgnList name IgnoreList 0) > 0 then nil else ( set IgnoreList = [id name paramlist]::IgnoreList; set WIgnoreList = _ADDlist WIgnoreList 0 strcatn name::" ":: (mylinebuild paramlist)::nil; 0 );; /* __chglogin - Apr 99 - by Christophe LOREK */ /* */ fun __chglogin(oldname, newname)= ChangeNameIgnList oldname newname IgnoreList; _DMSevent this "IgnChgLogin" (linebuild oldname::newname::nil) nil;; fun __sendClis(clientNames)= let strextr clientNames -> clientList in AddSentClis clientList;; fun __delCli (clientid, clientname)= _DMSevent this "IgnLogout" (linebuild (itoa clientid)::clientname::nil) nil; let (IsInIgnList clientname IgnoreList 0) -> pos in if pos < 0 then nil else ( set IgnoreList = remove_nth_from_list IgnoreList pos; _DELlist WIgnoreList pos );; fun __testMsg (clientname, msg)= let (IsInIgnList clientname IgnoreList 0) -> pos in let findUserInIgnList IgnoreList pos -> [userid username [IgnChatin [IgnChatout [IgnPhoto [IgnAvatar [IgnSpeakin [IgnSpeakout [IgnPager _]]]]]]]] in if (!atoi IgnChatin) then if username == nil then _DMSevent this "privateMsg" strcatn "<"::DMSlogin::"> "::msg::"\n"::nil nil else _DMSevent this "privateMsg" strcatn "<"::username::"> "::msg::"\n"::nil nil else 0;; /*-------------------*/ fun sendIgnoreEvents (state)= _DMSevent this "IgnoreFlag" linebuild "ChatIn"::(itoa selectedUser_id)::selectedUser_name::state::nil nil; _DMSevent this "IgnoreFlag" linebuild "ChatOut"::(itoa selectedUser_id)::selectedUser_name::state::nil nil; _DMSevent this "IgnoreFlag" linebuild "Photo"::(itoa selectedUser_id)::selectedUser_name::state::nil nil; _DMSevent this "IgnoreFlag" linebuild "Avatar"::(itoa selectedUser_id)::selectedUser_name::state::nil nil; _DMSevent this "IgnoreFlag" linebuild "SpeakIn"::(itoa selectedUser_id)::selectedUser_name::state::nil nil; _DMSevent this "IgnoreFlag" linebuild "SpeakOut"::(itoa selectedUser_id)::selectedUser_name::state::nil nil; _DMSevent this "IgnoreFlag" linebuild "Pager"::(itoa selectedUser_id)::selectedUser_name::state::nil nil;; /*-------------------*/ /*the server wants us to ignore the user for eveything*/ fun __ignoreBroad(state,id,name)= if !strcmp name DMSlogin then nil else ( set selectedUser_name=name; set selectedUser_id=id; set selectedUser_IgnChatin=state; set selectedUser_IgnChatout=state; set selectedUser_IgnPhoto=state; set selectedUser_IgnAvatar=state; set selectedUser_IgnSpeakin=state; set selectedUser_IgnSpeakout=state; set selectedUser_IgnPager=state; UpdateCurrentUser IgnoreList; sendIgnoreEvents itoa state; 0 );;