/* Meeting Point Client v1.0 - DMS - mar 98 - by Marc BARILLEY */ var iniPath = "Dms/Interf/MeetingPoint/L/";; defcom Cstarted = started;; defcom Cclosed = closed;; defcom Ccontact = contact S;; defcom Chidden = hidden;; defcom Cshown = shown;; typeof iniWrite = W;; typeof cardWrite = W;; struct Card = [ nicknameCard : S, emailCard : S, eworldCard : S, firstnameCard : S, lastnameCard : S, phoneCard : S, faxCard : S, snailCard : S, notesCard : S ] mkCard;; typeof cards = [Card r1];; typeof mainButton = ObjButton;; typeof mainWindow = ObjWin;; typeof usersList = ObjList;; typeof addCardButton = ObjButton;; typeof viewCardsButton = ObjButton;; typeof filterButton = ObjButton;; var filterMode = 0;; typeof users = [[S S] r1];; typeof filteredUsers = [[S S] r1];; typeof cardbookWindow = ObjWin;; typeof cardbookList = ObjList;; typeof newCardButton = ObjButton;; typeof delCardButton = ObjButton;; typeof optionsButton = ObjButton;; typeof closeCardbookWindowButton = ObjButton;; typeof optionsWindow = ObjWin;; typeof cardFileEdit = ObjText;; struct CardWindow = [ winCardWindow : ObjWin, moreButtonCardWindow : ObjButton, cardOKButtonCardWindow : ObjButton, cardCancelButtonCardWindow : ObjButton, nicknameStaticCardWindow : ObjText, nicknameEditCardWindow : ObjText, emailStaticCardWindow : ObjText, emailEditCardWindow : ObjText, eworldStaticCardWindow : ObjText, eworldEditCardWindow : ObjText, firstnameStaticCardWindow : ObjText, firstnameEditCardWindow : ObjText, lastnameStaticCardWindow : ObjText, lastnameEditCardWindow : ObjText, telStaticCardWindow : ObjText, telEditCardWindow : ObjText, faxStaticCardWindow : ObjText, faxEditCardWindow : ObjText, snailStaticCardWindow : ObjText, snailEditCardWindow : ObjText, notesStaticCardWindow : ObjText, notesEditCardWindow : ObjText ] mkCardWindow;; typeof cardWindowList = [CardWindow r1];; /* internal */ fun userByNickname (user, nickname)= let user -> [nick _] in !strcmp nick nickname;; fun cardWindowByWin (cardWindow, win)= cardWindow.winCardWindow == win;; fun cardByNickname (card, nickname)= !strcmp card.nicknameCard nickname;; fun loadCards (l)= if l==nil then nil else (mkCard [ hd hd l hd tl hd l hd tl tl hd l hd tl tl tl hd l hd tl tl tl tl hd l hd tl tl tl tl tl hd l hd tl tl tl tl tl tl hd l hd tl tl tl tl tl tl tl hd l hd tl tl tl tl tl tl tl tl hd l ]) ::(loadCards tl l) ;; fun saveCards (l)= if l == nil then 0 else { let hd l -> c in _appendpack strbuild (c.nicknameCard::c.emailCard:: (if (c.eworldCard==nil) || (strlen c.eworldCard)==0 then "_" else c.eworldCard):: (if (c.firstnameCard==nil) || (strlen c.firstnameCard)==0 then "_" else c.firstnameCard):: (if (c.lastnameCard==nil) || (strlen c.lastnameCard)==0 then "_" else c.lastnameCard):: (if (c.phoneCard==nil) || (strlen c.phoneCard)==0 then "_" else c.phoneCard):: (if (c.faxCard==nil) || (strlen c.faxCard)==0 then "_" else c.faxCard):: (if (c.snailCard==nil) || (strlen c.snailCard)==0 then "_" else c.snailCard):: (if (c.notesCard==nil) || (strlen c.notesCard)==0 then "_" else c.notesCard):: nil)::nil cardWrite; saveCards tl l } ;; fun fillCardbookList (lb, cards)= if cards==nil then lb else { let hd cards -> card in _ADDlist lb (_GETlistCount lb) strcatn card.nicknameCard::" <"::(if !strcmp card.emailCard "_" then "" else card.emailCard)::">"::nil; fillCardbookList lb tl cards };; fun fillUserList (lb, ul)= if ul==nil then lb else { let hd ul -> [nickname email] in _ADDlist lb (_GETlistCount lb) strcatn nickname::" <"::email::">"::nil; fillUserList lb tl ul };; fun filterUsers (ul)= if ul==nil then nil else let hd ul -> [nickname email] in if isf_in_list cards @cardByNickname nickname then (hd ul)::(filterUsers tl ul) else filterUsers tl ul;; fun saveFiles ()= _createpack strbuild ("cardfile"::(_GetFileNameFromP _WtoP cardWrite)::nil)::nil iniWrite; _createpack "" cardWrite; saveCards cards; 0;; /* comm */ fun __addUser (nickname, email)= let search_in_list users @userByNickname nickname -> u in if u==nil then let [nickname email] -> u in { set users = listcat users u::nil; if !filterMode || (isf_in_list cards @cardByNickname nickname) then { set filteredUsers = listcat filteredUsers u::nil; _ADDlist usersList (_GETlistCount usersList) (strcatn nickname::" <"::email::">"::nil) } else nil } else nil;; fun __delUser (nickname)= let search_in_list users @userByNickname nickname -> u in if u==nil then nil else let pos_in_list users u 0 -> pos in let pos_in_list filteredUsers u 0 -> fupos in { set users = remove_nth_from_list users pos; set filteredUsers = remove_nth_from_list filteredUsers fupos; _DELlist usersList fupos };; fun __chglogin (old, new)= let search_in_list users @userByNickname old -> u in if u==nil then nil else let u -> [_ email] in let [new email] -> nu in { set users = replace_in_list users u nu; let search_in_list filteredUsers @userByNickname old -> fu in if fu==nil then nil else let pos_in_list filteredUsers fu 0 -> pos in { set filteredUsers = replace_nth_in_list filteredUsers pos nu; _DELlist usersList pos; _ADDlist usersList pos (strcatn new::" <"::email::">"::nil); } };; fun __destroy ()= _DMSdelete this;; fun showWindow (cardWindow, flag)= _SHOWwindow cardWindow.winCardWindow flag;; fun __hide ()= _SHOWwindow mainWindow WINDOW_HIDDEN; _SHOWwindow cardbookWindow WINDOW_HIDDEN; _SHOWwindow optionsWindow WINDOW_HIDDEN; apply_on_list cardWindowList @showWindow WINDOW_HIDDEN; _DMSsend this Chidden []; _DMSevent this "hidden" nil nil ;; fun __show ()= _SHOWwindow mainWindow WINDOW_UNHIDDEN; _SHOWwindow cardbookWindow WINDOW_UNHIDDEN; _SHOWwindow optionsWindow WINDOW_UNHIDDEN; apply_on_list cardWindowList @showWindow WINDOW_UNHIDDEN; _DMSsend this Cshown []; _DMSevent this "shown" nil nil ;; /* reflexes optionsWindow */ fun rflDestroyOptionsWindow (win, blurp)= set optionsWindow = nil;; fun rflOpenCardFile (ob, blurp, pack)= if pack==nil then nil else _SETtext cardFileEdit _PtoScol pack;; fun rflBrowseCardFileButton (button, blurp)= let getPathFile _PtoScol _WtoP cardWrite "" -> [path filename] in _DLGrflopen _DLGOpenFile _channel optionsWindow path filename "All (*.*)\0*.*\0\0" @rflOpenCardFile 0;; fun rflOKButtonOptions (button, blurp)= set cardWrite = _getmodifypack _GETtext cardFileEdit; _DSwindow optionsWindow; set optionsWindow = nil;; fun rflCancelButtonOptions (button, blurp)= _DSwindow optionsWindow; set optionsWindow = nil;; /* reflexes cardWindow */ fun rflDestroyCardWindow (win, blurp)= let search_in_list cardWindowList @cardWindowByWin win -> cardWindow in set cardWindowList = remove_from_list cardWindowList cardWindow ;; proto rflMoreButtonCard = fun [ObjButton ObjWin] I;; fun rflLessButtonCard (button, win)= let search_in_list cardWindowList @cardWindowByWin win -> cardWindow in { let _GETwindowPositionSize cardWindow.winCardWindow -> [x y w h] in _SIZEwindow cardWindow.winCardWindow 265 105 x y; _SIZEbutton cardWindow.cardOKButtonCardWindow 60 20 5 80; _SIZEbutton cardWindow.cardCancelButtonCardWindow 65 20 75 80; _CBbutton _SETbuttonName cardWindow.moreButtonCardWindow (_loc this "MP_MORE" nil) @rflMoreButtonCard win; } ;; fun rflMoreButtonCard (button, win)= let search_in_list cardWindowList @cardWindowByWin win -> cardWindow in { let _GETwindowPositionSize cardWindow.winCardWindow -> [x y w h] in _SIZEwindow cardWindow.winCardWindow 265 400 x y; _SIZEbutton cardWindow.cardOKButtonCardWindow 60 20 5 375; _SIZEbutton cardWindow.cardCancelButtonCardWindow 65 20 75 375; _CBbutton _SETbuttonName cardWindow.moreButtonCardWindow (_loc this "MP_LESS" nil) @rflLessButtonCard win; }; 0;; fun rflOKbuttonCard (button, win)= let search_in_list cardWindowList @cardWindowByWin win -> cardWindow in let _GETtext cardWindow.nicknameEditCardWindow -> nickname in if (nickname==nil) || ((strlen nickname)==0) then nil else let mkCard [ nickname let _GETtext cardWindow.emailEditCardWindow -> t in if t==nil then "_" else t let _GETtext cardWindow.eworldEditCardWindow -> t in if t==nil then "_" else t let _GETtext cardWindow.firstnameEditCardWindow -> t in if t==nil then "_" else t let _GETtext cardWindow.lastnameEditCardWindow -> t in if t==nil then "_" else t let _GETtext cardWindow.telEditCardWindow -> t in if t==nil then "_" else t let _GETtext cardWindow.faxEditCardWindow -> t in if t==nil then "_" else t let _GETtext cardWindow.snailEditCardWindow -> t in if t==nil then "_" else t let _GETtext cardWindow.notesEditCardWindow -> t in if t==nil then "_" else t ] -> newCard in let search_in_list cards @cardByNickname nickname -> oldCard in set cards = if oldCard==nil then newCard::cards else newCard::(remove_from_list cards oldCard); rflDestroyCardWindow win 0; _DSwindow win; fillCardbookList _RSTlist cardbookList cards; 0;; fun rflCancelButtonCard (button, win)= rflDestroyCardWindow win 0; _DSwindow win ;; fun makeCardWindow (c)= let _CBwinDestroy _CRwindow _channel DMSwin 200+(20*sizelist cardWindowList) 100+(20*sizelist cardWindowList) 265 105 WN_MENU|WN_MINBOX strcat "Card for " c.nicknameCard @rflDestroyCardWindow 0 -> win in { set cardWindowList = (mkCardWindow [ win _CBbutton _CRbutton _channel win 200 80 60 20 0 (_loc this "MP_MORE" nil) @rflMoreButtonCard win _CBbutton _CRbutton _channel win 5 80 60 20 0 (_loc this "MP_OK" nil) @rflOKbuttonCard win _CBbutton _CRbutton _channel win 75 80 65 20 0 (_loc this "MP_CANCEL" nil) @rflCancelButtonCard win _CRtext _channel win 5 5 80 20 ET_BORDER (_loc this "MP_NICKNAME" nil) _CReditLine _channel win 90 5 170 20 ET_BORDER|ET_DOWN if !strcmp c.nicknameCard "_" then "" else c.nicknameCard _CRtext _channel win 5 30 80 20 ET_BORDER (_loc this "MP_MAIL" nil) _CReditLine _channel win 90 30 170 20 ET_BORDER|ET_DOWN if !strcmp c.emailCard "_" then "" else c.emailCard _CRtext _channel win 5 55 80 20 ET_BORDER (_loc this "MP_WORLD" nil) _CReditLine _channel win 90 55 170 20 ET_BORDER|ET_DOWN if !strcmp c.eworldCard "_" then "" else c.eworldCard _CRtext _channel win 5 105 80 20 ET_BORDER (_loc this "MP_FNAME" nil) _CReditLine _channel win 90 105 170 20 ET_BORDER|ET_DOWN if !strcmp c.firstnameCard "_" then "" else c.firstnameCard _CRtext _channel win 5 130 80 20 ET_BORDER (_loc this "MP_LNAME" nil) _CReditLine _channel win 90 130 170 20 ET_BORDER|ET_DOWN if !strcmp c.lastnameCard "_" then "" else c.lastnameCard _CRtext _channel win 5 155 80 20 ET_BORDER (_loc this "MP_PHONE" nil) _CReditLine _channel win 90 155 170 20 ET_BORDER|ET_DOWN if !strcmp c.phoneCard "_" then "" else c.phoneCard _CRtext _channel win 5 180 80 20 ET_BORDER (_loc this "MP_FAX" nil) _CReditLine _channel win 90 180 170 20 ET_BORDER|ET_DOWN if !strcmp c.faxCard "_" then "" else c.faxCard _CRtext _channel win 5 205 80 20 ET_BORDER (_loc this "MP_SMAIL" nil) _CReditText _channel win 90 205 170 80 ET_BORDER|ET_DOWN|ET_VSCROLL|ET_HSCROLL if !strcmp c.snailCard "_" then "" else c.snailCard _CRtext _channel win 5 290 80 20 ET_BORDER (_loc this "MP_NOTES" nil) _CReditText _channel win 90 290 170 80 ET_BORDER|ET_DOWN|ET_VSCROLL|ET_HSCROLL if !strcmp c.notesCard "_" then "" else c.notesCard ]) ::cardWindowList } ;; /* reflexes cardbookWindow */ fun rflDestroyCardbookWindow (win, blurp)= set cardbookWindow = nil;; fun endCardbookWindow (zone)= set cardbookWindow = nil; 0;; fun rflDMSresizeCardbookWindow (x,s)= let x->[wn x y w h] in { _SIZEwindow cardbookWindow w h x y; _SIZElist cardbookList (w-10) (h-35) 5 5; _SIZEbutton newCardButton 70 20 5 h-25; _SIZEbutton delCardButton 70 20 80 h-25; _SIZEbutton optionsButton 70 20 w-150 h-25; _SIZEbutton closeCardbookWindowButton 70 20 w-75 h-25; }; 0;; fun rflCloseCardbookWindowButton (button, blurp)= _DSwindow cardbookWindow; set cardbookWindow = nil;; fun rflDclickCardbookList (lb, blurp, index, string)= makeCardWindow (nth_list cards index) ;; fun rflNewCardButton (button, blurp)= makeCardWindow mkCard ["" "" "" "" "" "" "" "" ""];; fun rflDelCardButton (button, blurp)= let _GETlist cardbookList -> [index string] in if index==nil then nil else { let nth_list cards index -> c in set cards = remove_from_list cards c; fillCardbookList _RSTlist cardbookList cards; };; fun rflOptionsButton (button, blurp)= set optionsWindow = _CBwinDestroy _CRwindow _channel mainWindow 120 100 300 80 WN_MENU|WN_MINBOX (_loc this "MP_OPTIONS" nil) @rflDestroyOptionsWindow 0; _CRtext _channel optionsWindow 5 5 290 20 ET_BORDER (_loc this "MP_CARDSFILE" nil); set cardFileEdit = _CReditLine _channel optionsWindow 5 30 265 20 ET_BORDER|ET_DOWN _PtoScol _WtoP cardWrite; _CBbutton _CRbutton _channel optionsWindow 275 30 20 20 0 "..." @rflBrowseCardFileButton 0; _CBbutton _CRbutton _channel optionsWindow 5 60 70 20 0 (_loc this "MP_OK" nil) @rflOKButtonOptions 0; _CBbutton _CRbutton _channel optionsWindow 225 60 70 20 0 (_loc this "MP_CANCEL" nil) @rflCancelButtonOptions 0;; /* reflexes mainWindow */ fun rflDestroyMainWindow (win, blurp)= set mainWindow = nil;; fun rflDclickUsersList (ul, blurp, index, string)= let nth_list filteredUsers /*users*/ index -> [nickname _] in _DMSsend this Ccontact [nickname];; fun rflAddCardButton (button, blurp)= let _GETlist usersList -> [index string] in if index==nil then nil else let nth_list filteredUsers index -> [nickname email] in let search_in_list cards @cardByNickname nickname -> c in let if c==nil then mkCard [nickname email "" "" "" "" "" "" ""] else c -> card in makeCardWindow card;; fun rflViewCardsButton (button, blurp)= if cardbookWindow==nil then let _DMSgetZone this "cardbook" @endCardbookWindow @rflDMSresizeCardbookWindow @endCardbookWindow -> [wn x y w h] in { set cardbookWindow = _CBwinDestroy if wn==nil then { set w=305; set h=235; _CRwindow _channel DMSwin 100 80 305 235 WN_MENU+WN_MINBOX "Card Book" } else _CRwindow _channel wn x y w h WN_CHILDINSIDE|WN_NOCAPTION|WN_NOBORDER "Card Book" @rflDestroyCardbookWindow 0; set cardbookList = fillCardbookList _CBlistDclick _CRlist _channel cardbookWindow 5 5 (w-10) (h-35) LB_VSCROLL|LB_DOWN @rflDclickCardbookList 0 cards; set newCardButton = _CBbutton _CRbutton _channel cardbookWindow 5 h-25 70 20 0 (_loc this "MP_NEWCARD" nil) @rflNewCardButton 0; set delCardButton = _CBbutton _CRbutton _channel cardbookWindow 80 h-25 70 20 0 (_loc this "MP_DELCARD" nil) @rflDelCardButton 0; set optionsButton = _CBbutton _CRbutton _channel cardbookWindow w-150 h-25 70 20 0 (_loc this "MP_OPTIONS" nil) @rflOptionsButton 0; set closeCardbookWindowButton = _CBbutton _CRbutton _channel cardbookWindow w-75 h-25 70 20 0 (_loc this "MP_CLOSE" nil) @rflCloseCardbookWindowButton 0; } else nil;; proto rflFilterCardsButton = fun [ObjButton u0] I;; fun rflNofilterCardsButton (button, blurp)= set filterMode = 0; set filteredUsers = users; _CBbutton _SETbuttonName filterButton (_loc this "MP_FILTER" nil) @rflFilterCardsButton 0; fillUserList _RSTlist usersList users;; fun rflFilterCardsButton (button, blurp)= set filterMode = 1; _CBbutton _SETbuttonName filterButton (_loc this "MP_NOFILTER" nil) @rflNofilterCardsButton 0; set filteredUsers = filterUsers users; fillUserList _RSTlist usersList filteredUsers; 0;; /* DMS */ fun activate(from,action,param,rep)= 0;; fun beforeclose ()= saveFiles; _DMSsend this Cclosed []; 0;; fun end (zone)= 0;; fun rflDMSResizeMainWindow (x,s)= let x->[wn x y w h] in { _SIZEwindow mainWindow w h x y; _SIZElist usersList w-2 h-30 x+1 y+1; _SIZEbutton addCardButton 70 20 5 h-25; _SIZEbutton viewCardsButton 75 20 w-80 h-25; _SIZEbutton filterButton 70 20 w/2-35 h-25; }; 0;; fun rflDMSResizeMainButton (coord, zone)= let coord -> [wn x y w h] in _SIZEbutton mainButton w h x y; 0;; fun rflMainButton (b, blurp)= if mainWindow==nil then let _DMSgetZone this "meetingPoint" @end @rflDMSResizeMainWindow @end ->[wn x y w h] in { set mainWindow= if wn==nil then { set w=280; set h=240; _CRwindow _channel nil 5 5 w h WN_MENU+WN_MINBOX _DMSgetName this } else _CRwindow _channel wn x y w h WN_CHILDINSIDE|WN_NOCAPTION|WN_NOBORDER _DMSgetName this; _CBwinDestroy mainWindow @rflDestroyMainWindow 0; set usersList = _CBlistDclick _CRlist _channel mainWindow 1 1 w-2 h-30 LB_VSCROLL|LB_DOWN @rflDclickUsersList 0; set addCardButton = _CBbutton _CRbutton _channel mainWindow 5 h-25 70 20 0 (_loc this "MP_ADDCARDS" nil) @rflAddCardButton 0; set viewCardsButton = _CBbutton _CRbutton _channel mainWindow w-80 h-25 75 20 0 (_loc this "MP_VCARDS" nil) @rflViewCardsButton 0; set filterButton = _CBbutton _CRbutton _channel mainWindow w/2-35 h-25 70 20 0 (_loc this "MP_FILTER" nil) @rflFilterCardsButton 0; fillUserList _RSTlist usersList users; } else nil ;; fun IniDMI (param)= _DMSregisterDMI this @activate @beforeclose; set mainButton = let _DMSgetZone this "button" nil @rflDMSResizeMainButton nil ->[wn x y w h] in if wn==nil then nil else _CBbutton _CRbutton _channel wn x y w h 0 (_loc this "MP_MEETING" nil) @rflMainButton 0; set iniWrite = _getmodifypack strcat iniPath "MeetingPoint.ini"; set cardWrite = let getInfo strextr _getpack (_WtoP iniWrite) "cardfile" -> cardfile in if (iniWrite == nil) || (cardfile == nil) then _getmodifypack strcat iniPath "cardfile.ini" else _getmodifypack strcat iniPath cardfile; set cards = loadCards strextr _getpack (_WtoP cardWrite); _DMSsend this Cstarted []; _DMSevent this "started" nil nil;;