/****************************************************************************/ /* */ /* File: Dms/Wizard/page/c7.pkg */ /* Use : Source code for the C7 PAGE */ /* */ /****************************************************************************/ struct Card = [ nameFAV : S, authorFAV : S, emailFAV : S ] mkCARD ;; typeof sourceCard = [ Card r1 ] ;; typeof destCard = [ Card r1 ] ;; typeof listsource = ListBoxStr ;; typeof listdest = ListBoxStr ;; typeof sitename = EditLineStr ;; typeof siteauthor = EditLineStr ;; typeof siteemail = EditLineStr ;; typeof addcard = ButtonStr ;; typeof removecard = ButtonStr ;; typeof newcard = ButtonStr ;; typeof srv = Srv ;; var listS = "scol://dir.scol-technologies.org:3102" ;; var selectedSource = -1 ;; var selectedDest = -1 ;; defcom Copen=open S;; typeof C7Timer = Timer ;; /****************************************************************************/ /* */ /* find a favorite in a list and return 1 or 0 */ /* */ /****************************************************************************/ fun findFav(name,author,email,l)=if l == nil then 0 else let l -> [ nameC [ authorC [ emailC next ]]] in if (!strcmp name nameC) && (!strcmp author authorC) && (!strcmp email emailC) then 1 else findFav name author email next ;; fun findExistingFav(name,author,email,l)=if l == nil then 0 else let l -> [ c next ] in if (!strcmp name c.nameFAV) && (!strcmp author c.authorFAV) && (!strcmp email c.emailFAV) then 1 else findExistingFav name author email next ;; /****************************************************************************/ /* */ /* end reflex for the page C7 */ /* */ /****************************************************************************/ fun makeWzd(l)=if l == nil then nil else let l -> [ c next ] in c.nameFAV::c.authorFAV::c.emailFAV::makeWzd next ;; fun end ()= WZDwrite wizard ".Links.cards" strbuild (makeWzd destCard)::nil ; if C7Timer != nil then _deltimer C7Timer else 0 ; 0;; /****************************************************************************/ /* */ /* get the initial card list from the bookmark */ /* */ /****************************************************************************/ 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 getCards(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 mkCARD [ nil nil nil ] strextr endarg -> c in if c.nameFAV != nil then ( if (findExistingFav c.nameFAV c.authorFAV c.emailFAV listcat sourceCard destCard)==0 then if (findFav c.nameFAV c.authorFAV c.emailFAV hd strextr WZDread wizard ".Links.cards")==0 then set sourceCard = [ c sourceCard ] else set destCard = [ c destCard ] else nil ) else nil ; 0 ) else 0 ; getCards next ) ;; /****************************************************************************/ /* */ /* display a list of favorite into a listboxstr item */ /* */ /****************************************************************************/ fun displayFav(lb,favs)=if favs == nil then 0 else let favs -> [ c next ] in let LISTBOX_GETlistCount lb.o2dListBoxStr -> count in ( LISTBOX_ADDlist lb.o2dListBoxStr count c.nameFAV ; displayFav lb next ) ;; /****************************************************************************/ /* */ /* displaying info on a card */ /* */ /****************************************************************************/ fun displayInfo(c)= EDL_SetText sitename.o2dEditLineStr c.nameFAV 1; EDL_SetText siteauthor.o2dEditLineStr c.authorFAV 1; EDL_SetText siteemail.o2dEditLineStr c.emailFAV 1; 0 ;; /****************************************************************************/ /* */ /* reflex on button addcard : add a card to the site list of favorites */ /* */ /****************************************************************************/ fun reflexAddCard(button,x,y,etat,param)= if (etat ==1) && (selectedSource >=0) then let nth_list sourceCard selectedSource -> c in ( LISTBOX_DELlist listsource.o2dListBoxStr selectedSource ; set sourceCard = remove_from_list sourceCard c ; set selectedSource = -1 ; set selectedDest = LISTBOX_GETlistCount listdest.o2dListBoxStr ; LISTBOX_ADDlist listdest.o2dListBoxStr selectedDest c.nameFAV ; set destCard = listcat destCard c::nil ; LISTBOX_SELlist listdest.o2dListBoxStr selectedDest ; 0 ) else 0 ; button ;; /****************************************************************************/ /* */ /* reflex of a button card : remove a card from the list of favorites */ /* */ /****************************************************************************/ fun reflexRemoveCard(button,x,y,etat,param)= if (etat == 1) && (selectedDest >= 0 ) then let nth_list destCard selectedDest -> c in ( LISTBOX_DELlist listdest.o2dListBoxStr selectedDest ; set destCard = remove_from_list destCard c ; set selectedDest = -1 ; set selectedSource = LISTBOX_GETlistCount listsource.o2dListBoxStr ; LISTBOX_ADDlist listsource.o2dListBoxStr selectedSource c.nameFAV ; set sourceCard = listcat sourceCard c::nil ; LISTBOX_SELlist listsource.o2dListBoxStr selectedSource ; 0 ) else 0 ; button ;; /****************************************************************************/ /* */ /* selection of a dest/source card */ /* */ /****************************************************************************/ fun reflexSelectSource(list,rank,name,u)= set selectedSource = rank ; displayInfo nth_list sourceCard rank ; LISTBOX_SELlist listdest.o2dListBoxStr nil ; set selectedDest = -1 ; list ;; fun reflexSelectDest(list,rank,name,u)=set selectedDest = rank ; displayInfo nth_list destCard rank ; set selectedSource = -1 ; LISTBOX_SELlist listsource.o2dListBoxStr nil ; list ;; /****************************************************************************/ /* */ /* reflex button : add new cards : launch a new machine connected */ /* to the scol directory */ /* */ /****************************************************************************/ typeof Signature = S ;; fun reflexTimer(t,u)= if !strcmp Signature _getlongname _getpack _checkpack "locked/etc/bookmark.txt" "" "#" then 0 else ( WZDwrite wizard ".Links.cards" strbuild (makeWzd destCard)::nil ; set sourceCard = nil ; set destCard = nil ; set selectedSource = nil ; set selectedDest = nil ; LISTBOX_RSTlist listsource.o2dListBoxStr ; LISTBOX_RSTlist listdest.o2dListBoxStr ; getCards strextr _getpack _checkpack "locked/etc/bookmark.txt"; set Signature = _getlongname _getpack _checkpack "locked/etc/bookmark.txt" "" "#" ; displayFav listsource sourceCard ; displayFav listdest destCard ; ) ;; fun reflexNewCard(button,x,y,etat,param)= if etat==1 then ( _on _masterchannel Copen [ "scol://dir.scol-technologies.org:3102" ]; if C7Timer == nil then ( set Signature = _getlongname _getpack _checkpack "locked/etc/bookmark.txt" "" "#" ; set C7Timer = _rfltimer _starttimer _channel 2000 @reflexTimer 0 ) else nil ; 0 ) else 0 ; button ;; /****************************************************************************/ /* */ /* initialisation of the page C7 */ /* */ /****************************************************************************/ fun iniPage ()= registerEndFun @end; set homeWarning = 1; set listsource = searchListBoxByName currentList "BoxSource" ; set listdest = searchListBoxByName currentList "BoxDest" ; set sitename = searchEditLineByName currentList "SiteName" ; set siteauthor = searchEditLineByName currentList "SiteAuthor" ; set siteemail = searchEditLineByName currentList "SiteEmail" ; set addcard = searchButtonByName currentList "AddCard" ; set removecard = searchButtonByName currentList "RemoveCard" ; set newcard = searchButtonByName currentList "NewCard" ; LISTBOX_SetClickReflex listsource.o2dListBoxStr @reflexSelectSource 0 ; LISTBOX_SetClickReflex listdest.o2dListBoxStr @reflexSelectDest 0 ; EDL_SetEditable sitename.o2dEditLineStr 0 ; EDL_SetEditable siteauthor.o2dEditLineStr 0 ; EDL_SetEditable siteemail.o2dEditLineStr 0 ; ANB_SetClickReflex addcard.o2dButtonStr @reflexAddCard 0 ; ANB_SetClickReflex removecard.o2dButtonStr @reflexRemoveCard 0 ; ANB_SetClickReflex newcard.o2dButtonStr @reflexNewCard 0 ; getCards strextr _getpack _checkpack "locked/etc/bookmark.txt"; displayFav listsource sourceCard ; displayFav listdest destCard ; enableStep 6; 0;;