/* Alert Server - DMS - March 98 - by Sylvain HUET */ defcom Calert=alert I;; defcom CremoveAlarm = removeAlarm I;; typeof alrt=S;; typeof al=AlertWin;; typeof ll=[CLIENT r1];; fun broad(a,c)=_DMSsend this a c;; fun fireAlrt(i)= apply_on_list ll @broad Calert [i]; _setAlert al i;; fun removeAlarm (N) = apply_on_list ll @broad CremoveAlarm [N]; 0 ;; fun destroyWindow () =0;; fun broadevent (cli, action) = _DMSevent this cli action nil nil;; fun activate(from,cli,action,param,rep)= if !strcmp substr action 0 5 "alert" then (if fireAlrt atoi substr action 5 1 then nil else apply_on_list ll @broadevent action) else if !strcmp action "show" then (if (!_DMSclientAlive cli)||findList ll cli then nil else (_DMScreateClientDMI this cli alrt; set ll=cli::ll; _DMSevent this cli "shown" nil nil); 0) else if !strcmp action "hide" then if !findList ll cli then nil else (_DMSdelClientDMI this cli; set ll=remove_from_list ll cli; _DMSevent this cli "hidden" nil nil) else nil;; fun unregister(cli)= if !findList ll cli then nil else (set ll=remove_from_list ll cli; _DMSevent this cli "hidden" nil nil); 0;; fun getAlrt(l)= if l==nil then nil else let l->[q n] in if !strcmp hd q "alert" then (hd tl q)::getAlrt n else getAlrt n;; fun _resize(x,s)= let x->[win x y w h] in _SIZEwindow al.winAlrtW w h x y; 0;; fun startAlert()= let strcat "Alert." (_DMSgetName this) -> alrtname in set al= let _DMSgetZone this "Alert" nil @_resize nil ->[win x y w h] in if win==nil then iniAlrtW _channel DMSwin nil nil 200 190 alrtname nil 0 hd strextr alrt else iniAlrtW _channel win x y w h alrtname nil 1 hd strextr alrt; 0;; fun __removeAlarm (N) = let nth_list al.alrtAlrtW N -> a in mutate a<-[_ 0]; calcAlert al; apply_on_list ll @broad CremoveAlarm [N] ;; fun IniDMI(param)= _DMSregisterDMI this @activate nil @unregister nil; let strextr _getpack _checkpack param ->l in set alrt=strbuild (getAlrt l)::nil; startAlert;;