/* * editor for the directory ( CardRegister class * by MagicalFred, novmber 98 * * version 1.02, ( 19 jan 1999 ) */ /****************************************************************************/ /* */ /* data structure */ /* */ /****************************************************************************/ struct Favorite = [ authorFAV : S , nameFAV : S , emailFAV : S , okFAV : I ] mkFAV ;; typeof Favs = [ Favorite r1 ] ;; /****************************************************************************/ /* */ /* variables declarations */ /* */ /****************************************************************************/ typeof ed = Editor;; typeof nameText = ObjText ;; typeof messageText = ObjText ;; typeof emailText = ObjText ;; typeof passText = ObjText ;; typeof bitmapfile = S ;; typeof bitmap = ObjBitmap ;; typeof listbitmap = ObjBitmapList ;; typeof tabcheck = BitmapIndex ;; typeof tabnocheck = BitmapIndex ;; typeof listText = ObjText ;; typeof listFav = ObjListTab ;; typeof registerC = ObjCheck ;; typeof authorS = S ;; typeof emailS = S ;; typeof messageS = S ;; typeof passS = S ;; var registerI = 0 ;; var listS = "scol://dir.scol-technologies.org:3102" ;; fun LDgenBitmap(s)=let _LDbitmap _channel _checkpack s -> u in if u != nil then u else _LDjpeg _channel _checkpack s ;; /****************************************************************************/ /* */ /* making the savefile */ /* */ /****************************************************************************/ fun saveFav(l)=if l == nil then nil else let l -> [ f next ] in if f.okFAV == 1 then let strbuild (f.authorFAV::f.nameFAV::f.emailFAV::nil)::nil -> fline in ("favorite"::(substr fline 0 (strlen fline)-1)::nil)::saveFav next else saveFav next ;; fun save (filename, n)= let _GETtext nameText -> author in let _GETtext emailText -> email in let _GETtext messageText -> msg in let _GETtext listText -> listdir in let _GETtext passText -> pass in ("action"::"start"::"start"::nil):: ("zoneC"::"Register"::nil):: ("author"::author::nil):: ("email"::email::nil):: ("msg"::msg::nil):: ("image"::bitmapfile::nil):: ("directory"::listdir::nil):: ("zoneC"::"Favorites"::nil):: (if (strlen pass)!=0 && (pass!=nil) then ("password"::pass::nil) else nil):: ("register"::(itoa _GETcheck registerC)::nil):: saveFav Favs ;; /****************************************************************************/ /* */ /* parsing the ressource to collect the favorites */ /* */ /****************************************************************************/ fun parseFav(card,l)=if l == nil then card else let l -> [ line next ] in let line -> [ kword arg ] in ( if !strcmp kword "name" then ( set card.nameFAV = strbuild arg::nil ; set card.nameFAV = substr card.nameFAV 0 (strlen card.nameFAV)-1 ) else if !strcmp kword "author" then ( set card.authorFAV = strbuild arg::nil ; set card.authorFAV = substr card.authorFAV 0 (strlen card.authorFAV)-1; ) else if !strcmp kword "email" then ( set card.emailFAV = strbuild arg::nil ; set card.emailFAV = substr card.emailFAV 0 (strlen card.emailFAV) -1 ; ) else nil ; parseFav card next ) ;; fun makeFavList(l)=if l == nil then 0 else let l -> [ line next ] in ( let line -> [ sitename [ arg _ ]] in let strlen listS -> len in let substr arg 0 len -> site in if !strcmp site listS then let substr arg len (strlen arg) - len -> endarg in ( let 0 -> i in while i < strlen endarg do ( if (nth_char endarg i) == '+ then set_nth_char endarg i 32 else nil ; if (nth_char endarg i) == '/ then set_nth_char endarg i 10 else nil ; set i = i + 1 ) ; let parseFav mkFAV [ nil nil nil 0 ] strextr endarg -> c in set Favs = [ c Favs ] ; 0 ) else 0 ; makeFavList next ) ;; /****************************************************************************/ /* */ /* find a favorite in a list by checking email+sitename+author */ /* */ /****************************************************************************/ fun findFav(site,author,email,list)=if list == nil then nil else let list -> [ f next ] in if (!strcmp site f.nameFAV) && (!strcmp author f.authorFAV) && (!strcmp email f.emailFAV) then f else findFav site author email next ;; /****************************************************************************/ /* */ /* parsing the dmi file to get the info */ /* */ /****************************************************************************/ fun CARDparsing(l)=if l == nil then 0 else let l -> [line next ] in let line -> [ kword [arg _ ]] in ( if !strcmp kword "author" then set authorS = arg else if !strcmp kword "email" then set emailS = arg else if !strcmp kword "msg" then set messageS = arg else if !strcmp kword "image" then set bitmapfile = arg else if !strcmp kword "directory" then set listS = arg else if !strcmp kword "password" then set passS = arg else if !strcmp kword "register" then (set registerI = atoi arg;nil) else if !strcmp kword "favorite" then ( let strextr arg -> [[ author [ sitename [ email _ ]]] _] in let findFav sitename author email Favs -> f in if f != nil then set f.okFAV = 1 else ( set Favs = [ mkFAV [ author sitename email 1 ] Favs ] ; 0 ) ; nil ) else nil ; CARDparsing next ) ;; /****************************************************************************/ /* */ /* fun PAINTeditWin (ObjWin, u0 u ) -> I */ /* */ /* paint reflex for the editWin window */ /* */ /****************************************************************************/ fun PAINTeditWin(w,u)= _BLTbitmap ed.EditorEditWin bitmap 165 130 ;; fun LOADbitmap () = if bitmap != nil then _DSbitmap bitmap else 0 ; let LDgenBitmap bitmapfile -> b in if b == nil then set bitmap = nil else let _GETbitmapSize b -> [w h ] in if (w != 128) && (h != 128) then ( _DLGMessageBox _channel ed.EditorEditWin "Error" "Your bitmap must be 128x128 large" 0 ; set bitmap = nil ; ) else set bitmap = b ;; /****************************************************************************/ /* */ /* selecting the bitmap */ /* */ /****************************************************************************/ fun CBselectBitmap2(a,u,fp)= set bitmapfile = _PtoScol fp ; LOADbitmap ; _PAINTwindow ed.EditorEditWin ;; fun CBselectBitmap(a,b)= _DLGrflopen _DLGOpenFile _channel ed.EditorEditWin "" "" "BMP bitmap (*.bmp)\0*.bmp\0Jpeg bitmap (*.jpg)\0*.jpg\0\0" @CBselectBitmap2 0 ; 0 ;; /****************************************************************************/ /* */ /* listing the favorites in the list tab */ /* */ /****************************************************************************/ fun LISTfav (l)=if l == nil then 0 else let l -> [ f next ] in let _GETlistTabCount listFav -> nb in ( _ADDlistTabItem listFav nb nb f.nameFAV ; _SETlistTabItem listFav nb 1 f.authorFAV ; if f.okFAV == 1 then _SETlistTabBitmap listFav nb tabcheck else _SETlistTabBitmap listFav nb tabnocheck ; LISTfav next ) ;; /****************************************************************************/ /* */ /* selection of a site : make it selected or unselected */ /* */ /****************************************************************************/ fun selectSite(a,b,rank)= let nth_list Favs rank -> f in if f !=nil then ( if f.okFAV == 0 then ( set f.okFAV = 1 ; _SETlistTabBitmap listFav rank tabcheck ) else ( set f.okFAV = 0 ; _SETlistTabBitmap listFav rank tabnocheck ) ) else nil ;; /****************************************************************************/ /* */ /* fun IniEditor ( S filename ) -> I */ /* */ /* init function for the card editor */ /* */ /****************************************************************************/ fun IniEditor (s)= set ed = startEditor _channel nil 0 0 315 465 WN_NORMAL-WN_SIZEBOX EDITOR_NORMAL s "Dms/CommTools/Card/card.dmc" "Dms/CommTools/Card/help.txt" "Dms/CommTools/Card/rcard.bmp" nil @save nil; makeFavList strextr _getpack _checkpack "locked/etc/bookmark.txt"; if s==nil then 0 else ( openDMI ed; CARDparsing strextr _getpack _checkpack s ) ; LOADbitmap ; _CBwinPaint ed.EditorEditWin @PAINTeditWin 0 ; _CRtext _channel ed.EditorEditWin 5 5 100 20 ET_DOWN "Author" ; set nameText = _CReditLine _channel ed.EditorEditWin 110 5 200 20 ET_DOWN authorS ; _CRtext _channel ed.EditorEditWin 5 30 100 20 ET_DOWN "Email" ; set emailText = _CReditLine _channel ed.EditorEditWin 110 30 200 20 ET_DOWN emailS ; _CRtext _channel ed.EditorEditWin 5 55 100 20 ET_DOWN "Directory" ; set listText = _CReditLine _channel ed.EditorEditWin 110 55 200 20 ET_DOWN listS ; _CRtext _channel ed.EditorEditWin 5 80 100 20 ET_DOWN "Password" ; set passText = _CReditLine _channel ed.EditorEditWin 110 80 200 20 ET_DOWN passS ; _CRtext _channel ed.EditorEditWin 5 105 150 20 ET_DOWN "Message" ; set messageText = _CReditText _channel ed.EditorEditWin 5 130 150 130 ET_DOWN messageS ; _CBbutton _CRbutton _channel ed.EditorEditWin 160 105 150 20 0 "Change Bitmap" @CBselectBitmap 0 ; set listbitmap = _CRbitmapList _channel 16 16 ; let _LDbitmap _channel _checkpack "Dms/CommTools/Card/tabno.bmp" -> bmp in set tabnocheck = _ADDbitmapList listbitmap bmp ; let _LDbitmap _channel _checkpack "Dms/CommTools/Card/tabcheck.bmp" -> bmp in set tabcheck = _ADDbitmapList listbitmap bmp ; set registerC = _CRcheck _channel ed.EditorEditWin 5 265 305 20 CH_DOWN "Automatic registering to the global directory" ; _SETcheck registerC registerI ; _CRtext _channel ed.EditorEditWin 5 290 305 20 ET_DOWN|ET_ALIGN_CENTER "Favorites" ; set listFav = _CRlistTab _channel ed.EditorEditWin 5 315 305 140 LV_DOWN; _ADDlistTabColumn listFav 0 180 0 "Site" ; _ADDlistTabColumn listFav 1 100 0 "Author" ; _SETlistTabBitmaps listFav listbitmap ; LISTfav Favs ; _CBlistTabSelect listFav @selectSite 0 ; _PAINTwindow ed.EditorEditWin ; 0;;