/* Photo3 Client - DMS - march 99 - by Sylvain HUET */ /* Rev 26th May 99 - by Christophe LOREK */ /* added an event upon click on the displayed photo. added the possibility to affect the change photo interface to an existing zone defined in SCS. added the support of ignore function.*/ /* Rev November 99 - by Sebastien DENEUX (transparency of the photo = top left pixel + speed limitation of the default animation + action showPhoto + localisation)*/ defcom Ctrans=trans I;; defcom Caddbitmap=addbitmap S;; defcom CgetSign=getSign I;; var pref="locked/conf/photo.conf";; var plugfile="Dms/Avatar/Photo3/photo.plug";; var defaultphoto="logo.bmp";; typeof photo=S;; typeof shlog=MCl;; typeof button=ObjButton;; typeof winb=ObjWin;; typeof buf=ObjBitmap;; typeof bmpcur=ObjBitmap;; var flag=0;; typeof IgnoreList = [[I S] r1];; proto ignorephoto = fun [S] I;; fun _paintE(a,b)= let _GETbitmapSize buf -> [ww hh] in let _GETbitmapSize bmpcur -> [w h] in _SCPbitmap buf 0 0 ww-1 hh-1 bmpcur 0 0 w-1 h-1 nil; _BLTbitmap winb buf 0 0;; fun _resizeB(x,s)= let x->[win x y w h] in (_DSbitmap buf; set buf=_CRbitmap _channel w h; _SIZEwindow winb w h x y); _paintE nil nil; 0;; fun _endB(s)= _DSbitmap buf; set winb=nil; _DMSreleaseZone this "Photo"; 0;; fun _recoverB(s)= _DSwindow winb; _endB nil;; fun _clickWin(a,doub,x,y,i)= 0;; fun _unclickWin(a,doub,x,y,i)= _DMSevent this "clickPhoto" nil nil; 0;; fun chklogin(bmp,f)= _DMSreleaseZone this "Window"; set shlog=nil; if bmp==nil then nil else (set photo=bmp; set flag=f; _storepack strbuild (bmp::(itoa f)::nil)::nil pref; _DMSsend this Ctrans [f]; let _getpack _checkpack bmp -> s in if s==nil then nil else (_DMSsend this Caddbitmap [nil]; let 0->i in while i[win x y w h] in if win==nil then nil else (set winb=_CRwindow _channel win x y w h WN_CHILDINSIDE|WN_NOCAPTION|WN_NOBORDER "photo"; set buf=_CRbitmap _channel w h; _CBwinPaint winb @_paintE 0; _CBwinClick winb @_clickWin 0; _CBwinUnclick winb @_unclickWin 0 ) else nil; if winb==nil then nil else (_DSbitmap bmpcur; let _LDbitmap _channel _checkpack photo -> imagebmp in set bmpcur= if imagebmp==nil then _LDjpeg _channel _checkpack photo else imagebmp; _paintE nil nil) ); _DMSevent this "hidden" nil nil; 0;; /* ******* IgnoreList functions ******* */ 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;; fun IsInIgnListId(CliId, IgnoreList, pos) = if IgnoreList == nil then -1 else let IgnoreList -> [[currentid _] NIgnoreList] in if CliId == currentid then pos else IsInIgnListId CliId NIgnoreList pos+1;; fun ChangeNameIgnList (oldname, newname, IgnList)= if IgnList == nil then 0 else let IgnList -> [[currentid currentname] NIgnList] in if !strcmp oldname currentname then ( mutate IgnList <- [[currentid newname] _]; 1 ) else ChangeNameIgnList oldname newname NIgnList;; /* ******* end of IgnoreList functions ******* */ /* ******* Generic List functions ******* */ /* findUserInList - Apr 99 - by Christophe LOREK */ /* This function returns an element in a list according to its position in the list. */ fun findUserInList(list,pos)= if list == nil then nil else let list -> [current_user nlist] in if pos == 0 then current_user else findUserInList nlist pos-1;; /* RemoveFromList - Apr 99 - by Christophe LOREK */ /* This function removes an element from a list according to its position in the list. The function returns the modified list. */ fun RemoveFromList(list,pos)= if list == nil then nil else let list -> [current nlist] in if pos == 0 then nlist else current::(RemoveFromList nlist pos-1);; /* ******* end of Generic List functions ******* */ fun _Wend(s)= _DMSreleaseZone this "Window"; set shlog=nil; _DMSevent this "hidden" nil nil; 0;; fun showphoto()= if shlog!=nil then nil else set shlog= let _DMSgetZone this "Window" nil nil @_Wend ->[win x y w h] in if win==nil then iniMCl _channel DMSwin nil nil 320 128 (_loc this "SELECT_TITLE" nil) @chklogin 0 photo flag else (_DMSevent this "shown" nil nil; iniMCl _channel win x y w h (_loc this "SELECT_TITLE" nil) @chklogin PHOTO_CHILD photo flag ); 0;; fun closephoto()= if shlog==nil then nil else (delMCl shlog; _DMSreleaseZone this "Window"; set shlog=nil; _DMSevent this "hidden" nil nil); 0;; fun pressbut(a,b)=showphoto;; fun _end(s)= _DMSreleaseZone this "Button"; set button=nil; closephoto; 0;; fun _resizeI(x,s)= let x->[win x y w h] in _SIZEbutton button w h x y; 0;; fun showbutton()= if button!=nil then nil else (let _DMSgetZone this "Button" nil @_resizeI @_end ->[win x y w h] in if win==nil then nil else set button=_CBbutton _CRbutton _channel win x y w h 0 "Photo" @pressbut 0; 0 );; fun closebutton()= if button==nil then nil else (_DSbutton button; _end nil);; fun activate(from,action,param,rep)= if !strcmp action "show" then showbutton else if !strcmp action "hide" then closebutton else if !strcmp action "changePhoto" then showphoto else if !strcmp action "IgnChgLogin" then let lineextr param -> [oldname [newname _]] in ChangeNameIgnList oldname newname IgnoreList else if !strcmp action "IgnoreFlag" then ignorephoto param else if !strcmp action "IgnLogout" then let lineextr param -> [idstr [name _]] in ( let (IsInIgnList name IgnoreList 0) -> pos in if pos >= 0 then set IgnoreList = RemoveFromList IgnoreList pos else nil; 0 ) else nil;; /* partie en lien avec le plugin */ typeof req=[UserI r1];; fun reqbyfromid(r,z)= let r->[from id _] in let z->[f i] in from==f && i==id;; fun reqbyid(r,i)= r.userUI.idU==i;; /* getphot - Mar 99 - by Sylvain HUET */ /* modified on the 7th of may 1999 by Christophe LOREK */ /* I added a test to check if the given UserI is or not in the IgnoreList (testing the Id stored in the UsersList which keep the reference of the Id by UserI). If the UserI is to be ignored, the default logo is set, otherwise the photo of the UserI is get, nd will be set when the photo is received. */ fun getphot(ui)= let (UgetId UgetUser ui) -> current_id in if (IsInIgnListId current_id IgnoreList 0) < 0 then /* user is not in IgnoreList -> user is not ignored. */ ( if findList req ui then nil else ( set req=conc req ui::nil; _DMSsend this CgetSign [ui.userUI.idU] ) ) else ( if findList req ui then nil else ( /* no photo needs to be downloaded. */ set req=remove_from_list req ui; /* user is in IgnoreList -> user is ignored. */ Usend this ui "setPhoto" (strbuild (defaultphoto::(itoa 0)::nil)::nil) ) );; fun endDown(f,z)= let z->[ui fl] in (set req=remove_from_list req ui; Usend this ui "setPhoto" strbuild (f::(itoa fl)::nil)::nil);; fun cbdel(ui,r)= _RSCabort this r; set req=remove_from_list req ui; UcbDel this ui nil; 0;; fun UIlistFromUlist(pUIlist,pid)= if pUIlist == nil then nil else let pUIlist -> [currentUI nUIlist] in ( if ((UgetId UgetUser currentUI) == pid) then currentUI::(UIlistFromUlist nUIlist pid) else (UIlistFromUlist nUIlist pid) );; fun getPhotUIlist(pUIlist)= if pUIlist == nil then 0 else let pUIlist -> [currentui nUIlist] in ( if currentui == nil then _DLGMessageBox _channel nil "getPhotUIlist" "nil" 0 else nil; getphot currentui; getPhotUIlist nUIlist );; fun sendsetPhotoUIlist(pUIlist) = if pUIlist == nil then 0 else let pUIlist -> [currentui nUIlist] in ( if currentui == nil then _DLGMessageBox _channel nil "sendsetPhotoUIlist" "nil" 0 else nil; Usend this currentui "setPhoto" (strbuild (defaultphoto::(itoa 0)::nil)::nil); sendsetPhotoUIlist nUIlist );; /* ignorephoto - May 99 - by Christophe LOREK */ /* This function adds the name of the player in the IgnoreList if he is to be ignored and his name is not already present in the IgnoreList. */ fun ignorephoto(s)= let lineextr s -> [type [idstr [name [state _]]]] in if !strcmp type "Photo" then ( /* testing if the user is in the ignore and then ignores it. */ let (IsInIgnList name IgnoreList 0) -> pos in if (pos < 0) then /* ****** the user is not in the IgnoreList */ if (!atoi state) then /* *** the user is not ignored */ ( /* Photo must be retrieved and displayed */ let (UIlistFromUlist (Ulist this) (atoi idstr)) -> UIlist in getPhotUIlist UIlist; 0 ) else /* *** the user is ignored */ ( /* Photo must be ignored */ let (UIlistFromUlist (Ulist this) (atoi idstr)) -> UIlist in sendsetPhotoUIlist UIlist; set IgnoreList = [(atoi idstr) name]::IgnoreList; /* user must be added to IgnoreList */ 0 ) else /* ****** the user is in the IgnoreList */ if (!atoi state) then /* *** the user is not ignored */ ( /* user must be removed from IgnoreList */ set IgnoreList = RemoveFromList IgnoreList pos; /* Photo must be retrieved and displayed */ let (UIlistFromUlist (Ulist this) (atoi idstr)) -> UIlist in getPhotUIlist UIlist; 0 ) else /* *** the user is ignored */ /* Photo has already been ignored. (should not occur) */ nil ) else nil;; fun __setSign(id,sign,f)= let search_in_list req @reqbyid id -> ui in if ui==nil then nil else if sign==nil then (endDown nil [ui nil];nil) else UcbDel this ui mknode @cbdel _RSCdownload this itoa id sign mknode @endDown [ui f] 3;; fun cbcomm(ui,action,param)= if !strcmp action "getPhoto" then getphot ui else nil; 0;; fun newInst(ui)= UcbComm this ui @cbcomm; UcbDel this ui mknode @cbdel nil; 0 /*if DMSid==UgetId UgetUser ui then chklogin photo flag else 0 */ ;; fun IniDMI(param)= _DMSregisterDMI this @activate nil; UcbCreate this @newInst; let hd strextr _getpack _checkpack pref -> l in let hd l -> tmp1 in let atoi hd tl l -> tmp2 in ( set photo = if (tmp1 == nil) || ((strlen (_getpack _checkpack tmp1)) > 16384) then "logo.bmp" else tmp1 ; set flag = if tmp2 == nil then 0 else tmp2 ); if param!=nil then showbutton else nil; _DMSevent this "in" nil nil;; fun __ex()= if winb==nil then nil else (_DSwindow winb; _endB nil);; fun __getPlugin(h,rep)= let _DMSgetByHandle h-> d in if d==nil then nil else _DMSreply this d rep plugfile nil ;;