/* Plugin term3d - version 1.0 - part Server */ /* by iri : info@irizone.net - 03/2004 */ /* by iri rev. : add download resources, 05/2004 */ /* by iri rev. : add passerelle Term3d <-> ColorTerm, 08/2004 */ /* Licence : Cette création est mise à disposition selon le Contrat Paternité - Partage des Conditions Initiales à l'Identique disponible en ligne http://creativecommons.org/licenses/by-sa/2.0/fr/deed.fr ou par courrier postal à Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. */ typeof class = S;; typeof clis = [[S I] r1];; /* login color */ typeof color = I;; /* default */ typeof pathBgAvTop = S;; typeof pathBgAvDown = S;; typeof files = [S r1];; var NbPluginInstance = 0;; /*use to limit the number of instances (limited at 1 per c3D)*/ /* others functions in the file 'util.pkg', in same directory */ /***********************/ /* Debuggage (inactif) */ /***********************/ /* fun [[[S I] r1]] S */ fun testClis(ll)= if ll == nil then _fooS strcat ">>>clis>>>_" "nil" else let ll -> [[login col] q] in (_fooS strcatn ">>>clis>>>_"::login::"__"::(itoa col)::"_"::nil; testClis q);; /* cherche la couleur associée */ fun searchColor(list, login)= if list == nil then nil else let list -> [[l c] suite] in if !strcmp login l then c else searchColor suite login;; /* ll -> [[S I] r1] newLogin -> S oldLogin -> S not used <- [[S I] r1] */ /* Remplace l'ancien login par le nouveau */ fun myreplace_login_in_listS(ll, newLogin, oldLogin)= if ll == nil then nil else (let ll -> [[login c] q] in if !strcmp login oldLogin then set clis = myreplace_in_list clis [login c] [newLogin c] else myreplace_login_in_listS q newLogin oldLogin);; /* fun broadMsg(elt, o)= let elt -> [login col] in let _DMSbyLogin login -> cli in UsendMessage ObUi o cli "addUser" linebuild login::(itoa col)::nil;; */ /* lCli -> [[S I] r1] cli -> CLIENT o -> Ob I (not used)<- */ /* Indique aux clients présents le nouveau connecté (1) Envoie la liste des clients déjà connectés au nouveau (2) */ fun newUser(lCli, cli, o)= if lCli == nil then 0 else let lCli -> [[name col] q] in ( if (sizelist lCli) == (sizelist clis) then /* le client 'courant' ne reçoit ps le message ci-dessous ... ???? */ UsendMessage ObUi o nil "addUser" linebuild name::(itoa col)::nil /* (1)(2) */ /*apply_on_list clis @broadMsg o*/ else UsendMessage ObUi o cli "addUser" linebuild name::(itoa col)::nil; /* (2) */ newUser q cli o ) ;; /* ui -> UserI cli -> CLIENT action -> S param -> S col -> I p -> [Ob] not used <- I */ fun cbRegister (/*ui,*/ cli, /*action, param,*/ col, p) = let p -> [o] in (set clis = [_DMSgetLogin cli col]::clis; UsendMessage ObUi o cli "registered" itoa col; if files != nil then UsendMessage ObUi o cli "donwloadSmileys" linebuild files else 0; /* pour corriger le pb ci-dessus (cf fun newUser) envoie du msg ci-dessous */ UsendMessage ObUi o cli "addUser" linebuild (_DMSgetLogin cli)::(itoa col)::nil; newUser clis cli o; 0) ;; fun getSmileys(path)= set files = _listoffiles path; _RSregisterfiles this files RSfile+RScontrol; 0;; /***************************************************/ /* Fonctions de communications et d'initialisation */ /***************************************************/ /* o -> struct Ob from -> DMI emetteur cli -> CLIENT action -> S param -> S reply -> S I <- */ /* callback plugin (actions) */ fun activate(o, from, cli, action, param, reply)= if !strcmp action (strcat class ".privateMsg") then (UsendMessage ObUi o cli "incomingMsg" param; /* param : message */ 0) else if !strcmp action (strcat class ".broadInfo") then (UsendMessage ObUi o nil "broadInfo" param; /* param = message */ 0) else if !strcmp action (strcat class ".!chgLogin") then (set clis = myreplace_login_in_listS clis _DMSgetLogin cli param; /* param = old login */ UsendMessage ObUi o nil "loginChanged" linebuild (_DMSgetLogin cli)::param::nil; UsendMessage ObUi o cli "chgPseudo" param; 0) else if !strcmp action (strcat class ".!updateAv") then (UsendMessage ObUi o nil "updateAv" nil; 0) else if !strcmp action (strcat class ".fromColorTerm") then /* passerelle avec le ColorTerm */ let strcatn "<"::(_DMSgetLogin cli)::"> "::param::nil -> string in let searchColor clis _DMSgetLogin cli -> c in (UsendMessage ObUi o nil "incomingMsg" string; _DMSevent this cli strcat class ".getColorToColorTerm" itoa c nil; _DMSevent this cli strcat class ".toColorTerm" strcat string "\n" nil; 0) else if !strcmp action (strcat class ".!chgColorFromColorTerm") then (UsendMessage ObUi o nil "colorChanged" linebuild (_DMSgetLogin cli)::(param)::nil; set clis = myreplace_in_list clis [(_DMSgetLogin cli) nil] [(_DMSgetLogin cli) atoi param]; 0) else nil;; /* communications intramodules */ /* ui -> UserI cli -> CLIENT action -> S param -> S p -> [Ob] I <- */ fun cbcomm(ui, cli, action, param, p)= if !strcmp action "command" then (_DMSevent this nil strcat class ".toColorTerm" strcat param "\n" nil; /* passerelle avec le ColorTerm */ UsendMessage ui nil "incomingMsg" param) else if !strcmp action "chgColor" then (UsendMessage ui nil "colorChanged" param; let lineextr param -> [a[b _]] in set clis = myreplace_in_list clis [a nil] [a atoi b]; 0) else if !strcmp action "updatedAv" then (UsendMessage ui nil "updateAv" nil; 0) else if !strcmp action "register" then (cbRegister cli if param == nil then color else atoi param p; 0) else 0;; fun out(o, cli)= set clis = remove_from_clis clis _DMSgetLogin cli; 0;; fun newOb(o)= if NbPluginInstance == 0 then let hd UgetParam ObUi o "color" -> c in ( set color = atoi c; let atoi hd UgetParam ObUi o "smileys" -> b in if b then let hd UgetParam ObUi o "pathsmileys" -> path in getSmileys path else 0; let hd UgetParam o.uiOb "pathBgAv" -> pathBgAv in (if pathBgAv == nil then set pathBgAv = "dms/3d/plugins/term3d/" else (if (strfind "/" pathBgAv (strlen pathBgAv)-2) == nil then set pathBgAv = strcat pathBgAv "/" else nil); set pathBgAvTop = strcat pathBgAv "top.jpg"; set pathBgAvDown = strcat pathBgAv "down.jpg"; if (_checkpack pathBgAvTop) != nil then nil else set pathBgAvTop = "dms/3d/plugins/term3d/top.jpg"; if (_checkpack pathBgAvDown) != nil then nil else set pathBgAvDown = "dms/3d/plugins/term3d/down.jpg"; _RSregisterfiles this pathBgAvTop::nil RSfile|RScontrol; _RSregisterfiles this pathBgAvDown::nil RSfile|RScontrol; _RSregisterfiles this "dms/3d/plugins/term3d/profcursor.bmp":: "dms/3d/plugins/term3d/profcursorMAC.bmp":: nil RSfile|RScontrol ); UcbComm this ObUi o mkfun5 @cbcomm [o]; OB_CBclientDestroyed o @out; ObRegisterAction o (strcat class ".privateMsg") @activate; ObRegisterAction o (strcat class ".broadInfo") @activate; ObRegisterAction o (strcat class ".!chgLogin") @activate; ObRegisterAction o (strcat class ".!updateAv") @activate; ObRegisterAction o (strcat class ".fromColorTerm") @activate; ObRegisterAction o (strcat class ".!chgColorFromColorTerm") @activate; set NbPluginInstance = NbPluginInstance + 1 ) else ( _DLGMessageBox _channel nil "Warning" " Too many Login instanced.\nOnly one instance per C3d module instance is possible.\nOnly the first instance will be used." 0; set NbPluginInstance = NbPluginInstance + 1 ); 0;; /* file -> S */ fun IniPlug(file)= set class = getInfo strextr _getpack _checkpack file "name"; PlugRegister class @newOb nil; 0 ;;