/******************************************************************************* Module mailinglist Editor part Version: 1.0 Author: Catheline VEILLEUX, laurent PLUMAT Last update: 1/08/2001 Module mailinglist *******************************************************************************/ typeof editeur = Editor;; typeof senderTXT = ObjText;; typeof saveML = S;; typeof db= SqlDB ;; /*Data Base*/ typeof dbname=ObjText;; typeof ConnectBtn = ObjButton;; typeof comboTable = ObjBox;; typeof comboUser = ObjBox;; typeof comboEmail = ObjBox;; /******************************************************************************* return the name of the combo selection combo -> ObjBox : combo to get selection <- S : selection ********************************************************************************/ fun _getSelection (combo) = let _GETcombo combo -> [_ choice] in choice ;; /******************************************************************************* Save modifications a -> S : not used b -> S : not used editor -> Editor : editor <- [[S r1] r1] : the dmi contents *******************************************************************************/ fun cbSave (a, b) = setDef editeur "List" ("ML"::saveML::nil)::nil; setDef editeur "Data" ("sender"::(_GETtext senderTXT)::nil):: ("source"::(_GETtext dbname)::nil):: ("table"::(_getSelection comboTable)::nil):: ("login"::(_getSelection comboUser)::nil):: ("email"::(_getSelection comboEmail)::nil)::nil; ("action"::"start"::nil):: ("action"::"destroy"::nil):: ("action"::"edit"::nil):: ("actionC"::"show"::nil):: ("actionC"::"hide"::nil):: ("event"::"out"::nil):: ("event"::"sendMail"::nil):: ("eventC"::"in"::nil):: ("eventC"::"shown"::nil):: ("eventC"::"hidden"::nil):: nil ;; /*************************************************************************** Renvoie le login ou le password d'une base de donnees, on specifie l'alias dans odbcAlias, l'info que l'on souhaite reccueillir dans info ("login" ou "password") les valeurs sont recuperees dans usmress.ini format : odbc.odbcAlias.login odbc.odbcAlias.password attention : odbcAlias, infos ne doivent pas contenir les caracteres suivants : ".*?" ****************************************************************************/ fun GetODBCInfos(odbcAlias,info)= hd switchstr strextr _loadressini strcatn "odbc."::odbcAlias::"."::info::nil ;; /************************************************************************* fill a combo combo -> ObjBox : combo to fill list -> [S r1] : list to fill the combo *************************************************************************/ fun fill_combo(combo, list)= if list == nil then 0 else ( fill_combo (_ADDcombo combo _GETcomboCount combo hd hd list ) (tl list); 1 ) ;; /******************************************************************************* Loads the parameters for a module instance param -> [[S [S u0]] r1] : the dmi contents <- I : nothing special *******************************************************************************/ fun cbLoad (param) = let getDef editeur "Data" -> dataDef in let getInfo dataDef "sender" -> sender in let getInfo dataDef "source" -> source in let getInfo dataDef "table" -> table in let getInfo dataDef "login" -> login in let getInfo dataDef "email" -> email in ( _SETtext senderTXT sender; _SETtext dbname source; let GetODBCInfos source "login" -> loginDB in let GetODBCInfos source "password" -> pwdDB in let if source ==nil then "" else source -> al in let if loginDB ==nil then "" else loginDB -> lo in let if pwdDB ==nil then "" else pwdDB -> pwd in let SqlCreate _channel al lo pwd -> dbtmp in if dbtmp != nil then /*DB success*/ ( set db = dbtmp; fill_combo comboTable SqlRequest db "GET_TABLES" nil; _SSELcombo comboTable table; _ENcombo comboTable 1; _ENcombo comboUser 1; _ENcombo comboEmail 1; let SqlRequest db "GET_COLUMNS" (SQL_NIL table)::nil -> tmp in ( fill_combo comboUser tmp; fill_combo comboEmail tmp; _SSELcombo comboUser login; _SSELcombo comboEmail email ); 0 ) else /*DB failed*/ nil ); let getDef editeur "List" -> dataDef in set saveML = getInfo dataDef "ML"; 0 ;; /******************************************************************************* change combo table combo -> ObjBox : combo table param -> parameter : not used pos -> I : Position of the chics texte -> S : Text choice ********************************************************************************/ fun cbChangeComboTable (combo, param, pos, texte) = let SqlRequest db "GET_COLUMNS" (SQL_NIL texte)::nil -> tmp in let _GETcombo comboUser -> [_ choiceUser] in let _GETcombo comboEmail -> [_ choiceEmail] in ( _RSTcombo comboUser; _RSTcombo comboEmail; fill_combo comboUser tmp; fill_combo comboEmail tmp; _SSELcombo comboUser choiceUser; _SSELcombo comboEmail choiceEmail; ) ;; /********************************************************************************* connection to the database aliasDB ->S : name of the database win -> Editor : win editor **********************************************************************************/ fun connectionDB (aliasDB, win)= let GetODBCInfos aliasDB "login" -> loginDB in let GetODBCInfos aliasDB "password" -> pwdDB in let if aliasDB ==nil then "" else aliasDB -> al in let if loginDB ==nil then "" else loginDB -> lo in let if pwdDB ==nil then "" else pwdDB -> pwd in let SqlCreate _channel al lo pwd -> dbtmp in if dbtmp != nil then /*DB success*/ ( set db = dbtmp; let _GETcombo comboTable -> [_ choice] in ( _RSTcombo comboTable; fill_combo comboTable SqlRequest db "GET_TABLES" nil; _SSELcombo comboTable choice; _ENcombo comboTable 1; _ENcombo comboUser 1; _ENcombo comboEmail 1; cbChangeComboTable nil nil nil choice ); _DLGMessageBox _channel win (_locEditor "WINDOW_NAME_DBCONNECT" nil) (_locEditor "DBCONNECT_SUCCESS" nil) 0; 0 ) else /*DB failed*/ ( _DLGMessageBox _channel win (_locEditor "WINDOW_NAME_DBCONNECT" nil) (_locEditor "DBCONNECT_FAILURE" nil) 0; _ENcombo comboTable 0; _ENcombo comboUser 0; _ENcombo comboEmail 0; 0 ) ;; /****************************************************************************** call back of the connect button btn -> button : connect button param -> [ObjText Editor ] : Name of the database and editor ******************************************************************************/ fun cbConnect (btn, param) = let param -> [Texte win] in let _GETtext Texte -> tmpAlias in connectionDB tmpAlias win ;; fun cbPro () = let BigToAsc BigInvn BigFromAsc _getpack _checkpack "dms/commtools/mailinglist/mailinglist.conf" BigFromAsc "ed537b937bee0c65" -> s in let if (strlen s)!=9 then nil else [htoi substr s 1 4 htoi substr s 5 4] -> [datedebut periode] in if periode==nil then (_DLGMessageBox _channel nil _locEditor "PRO_WARNING" nil _locEditor "PRO_INVALID_MSG" nil 0;0) else if periode==0 then 1 else let ((time>>1)&0x3fffffff)/43200-datedebut -> x in if x<0 then (_DLGMessageBox _channel nil _locEditor "PRO_WARNING" nil _locEditor "PRO_INVALID_MSG" nil 0;0) else if x<=periode then (_DLGMessageBox _channel nil _locEditor "PRO_WARNING" nil _locEditor "PRO_LIMITED_MSG" (itoa (periode-x))::nil 0;1) else (_DLGMessageBox _channel nil _locEditor "PRO_WARNING" nil _locEditor "PRO_ENDLIMITED_MSG" nil 0;0) ;; /******************************************************************************* Main function called when the editor is starting. The openDMI function must be called at the end in order to load the data if the module has already been edited. s -> S : obsolete (unused) <- I : nothing special *******************************************************************************/ fun IniEditor (s) = set editeur = _StartEditor _channel nil 0 0 400 150 WN_NORMAL EDITOR_NORMAL @cbLoad @cbSave @cbPro; let getEditWin editeur -> editorWin in ( _CRtext _channel editorWin 5 10 170 20 ET_ALIGN_LEFT (_locEditor "SENDERLB" nil); set senderTXT = _CReditText _channel editorWin 180 10 210 20 ET_AHSCROLL|ET_DOWN ""; _CRtext _channel editorWin 5 35 100 40 ET_ALIGN_LEFT (_locEditor "LOGINP-databasena" nil); set dbname = _CReditLine _channel editorWin 130 40 160 20 ET_DOWN|ET_AHSCROLL ""; set ConnectBtn = _CRbutton _channel editorWin 300 40 70 20 0 (_locEditor "DB_CONECTION" nil); _CRtext _channel editorWin 5 70 85 20 ET_ALIGN_LEFT (_locEditor "LOGINP-logintable" nil); set comboTable = _ENcombo _CRcombo _channel editorWin 130 70 160 200 CB_AHSCROLL|CB_DOWN "" 0; _CRtext _channel editorWin 5 95 100 20 ET_ALIGN_LEFT (_locEditor "LOGINP-logincolum" nil); set comboUser = _ENcombo _CRcombo _channel editorWin 130 95 160 200 CB_AHSCROLL|CB_DOWN "" 0; _CRtext _channel editorWin 5 120 85 20 ET_ALIGN_LEFT (_locEditor "LOGINP-emailcolum" nil); set comboEmail = _ENcombo _CRcombo _channel editorWin 130 120 160 200 CB_AHSCROLL|CB_DOWN "" 0; /* callback */ _CBbutton ConnectBtn @cbConnect [dbname editorWin]; _CBcombo comboTable @cbChangeComboTable nil; cbLoad nil; ); 0 ;;