/* Hide & Show Server - DMS - July 98 - by Patrick MARTY */ /* Hide & Show Server - DMS2 - Jun 99 - by Christophe LOREK */ /* rev. September 99 - by Sebastien DENEUX */ typeof class = S;; var configPath="locked/conf/Hide/";;/*path used to save current Hide-Show state and reload it when restarting server*/ /*-------------*/ fun cbcomm(ui,cli,action,param,z)= let z ->[state _] in if (!strcmp action "state?") && (state!=nil) then /*the client ask for the hide-show state*/ if state then UsendCli this cli ui "Hide" nil else UsendCli this cli ui "Show" nil else nil;; /*-------------*/ fun changeState(z,newState)= let z -> [_ configFileName] in ( mutate z <- [newState _]; _storepack strbuild ("state"::(itoa newState)::nil)::nil configFileName ) ;; /*-------------*/ fun activate(o,from,cli,action,param,reply,z)= let z ->[state _] in if !strcmp action (strcat (ObName o) ".HideS") then (changeState z 1; UsendCli this nil (ObUi o) "Hide" (ObName o); 0) else if !strcmp action (strcat (ObName o) ".ShowS") then (changeState z 0; UsendCli this nil (ObUi o) "Show" (ObName o); 0) else if !strcmp action (strcat (ObName o) ".HideOrShowS") then ( if state then (changeState z 0; UsendCli this nil (ObUi o) "Show" (ObName o)) else (changeState z 1; UsendCli this nil (ObUi o) "Hide" (ObName o)) ) else nil;; /*-------------*/ fun newOb(o)= let strcatn configPath::(substr _getlongname strcat this.fileDMI ObName o "" "#" 1 8)::".conf"::nil -> configFileName in let [0 configFileName] -> z in ( if !strcmp hd UgetParam ObUi o "keepDynamicChanges" "1" then let strextr _getpack _checkpack configFileName -> l in let getInfo l "state" -> state in if state==nil then let hd UgetParam ObUi o "initState" -> initState in changeState z atoi initState else changeState z atoi state else let hd UgetParam ObUi o "initState" -> initState in changeState z atoi initState; UcbComm this ObUi o mkfun5 @cbcomm z; ObRegisterAction o (strcatn (ObName o)::".HideS"::nil) mkfun7 @activate z; ObRegisterAction o (strcatn (ObName o)::".ShowS"::nil) mkfun7 @activate z; ObRegisterAction o (strcatn (ObName o)::".HideOrShowS"::nil) mkfun7 @activate z; ); 0;; /*-------------*/ fun IniPlug(file)= set class=getInfo strextr _getpack _checkpack file "name"; PlugRegister class @newOb nil; 0;;