/************************************************** Module FTP Editor part Version: 1.0 Author: Sebastien DENEUX & Julien Zorko Last update: 28/02/2001 FTP Module **************************************************/ typeof editor = Editor;; typeof homeFolder = ObjText;; typeof saveauth = S;; typeof maxSize = ObjText;; typeof FileSize = ObjText;; typeof db= SqlDB ;; /*Data Base*/ typeof dbname=ObjText;; typeof ConnectBtn = ObjButton;; typeof comboTable = ObjBox;; typeof comboUser = 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 editor "ftpAuth" ("allAuth"::saveauth::nil)::nil; setDef editor "Data" ("homeFolder"::(_GETtext homeFolder)::nil):: ("maxSize"::(_GETtext maxSize)::nil):: ("FileSize"::(_GETtext FileSize)::nil):: ("source"::(_GETtext dbname)::nil):: ("table"::(_getSelection comboTable)::nil):: ("login"::(_getSelection comboUser)::nil)::nil; ("action"::"start"::nil):: ("actionC"::"show"::nil):: ("actionC"::"hide"::nil):: ("action"::"edit"::nil):: ("action"::"destroy"::nil):: ("event"::"in"::nil):: ("eventC"::"shown"::nil):: ("eventC"::"hidden"::nil):: ("event"::"out"::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 ) ;; /******************************************************************************* load the parameters for a module instance p -> [[S r1] r1] : the dmi contents editor -> Editor : editor <- I : nothing special *******************************************************************************/ fun cbLoad (p) = let getDef editor "ftpAuth" -> dataDef in let getInfo dataDef "allAuth" -> auth in set saveauth = auth; let getDef editor "Data" -> dataDef in let getInfo dataDef "homeFolder" -> home in let getInfo dataDef "maxSize" -> size in let getInfo dataDef "FileSize" -> file in let getInfo dataDef "source" -> source in let getInfo dataDef "table" -> table in let getInfo dataDef "login" -> login in ( if size == nil then _SETtext maxSize "1000000" else _SETtext maxSize size; if file == nil then _SETtext FileSize "100000" else _SETtext FileSize file; _SETtext homeFolder home; _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; let SqlRequest db "GET_COLUMNS" (SQL_NIL table)::nil -> tmp in ( fill_combo comboUser tmp; _SSELcombo comboUser login ); 0 ) else /*DB failed*/ nil ); 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 ( _RSTcombo comboUser; fill_combo comboUser tmp; _SSELcombo comboUser choiceUser; ) ;; /********************************************************************************* 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; 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; 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 ;; /******************************************************************************* 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 editor = _StartEditor _channel nil nil nil 380 170 WN_NORMAL EDITOR_NORMAL @cbLoad @cbSave nil; let getEditWin editor -> editorWin in ( _CRtext _channel editorWin 5 5 100 20 ET_ALIGN_LEFT (_locEditor "HOME" nil); set homeFolder = _CReditText _channel editorWin 160 5 210 20 ET_AHSCROLL|ET_DOWN ""; _CRtext _channel editorWin 5 30 240 20 ET_ALIGN_LEFT (_locEditor "SIZE" nil); set maxSize = _CReditText _channel editorWin 300 30 70 20 ET_AHSCROLL|ET_DOWN ""; _CRtext _channel editorWin 5 55 240 20 ET_ALIGN_LEFT (_locEditor "FILE" nil); set FileSize = _CReditText _channel editorWin 300 55 70 20 ET_AHSCROLL|ET_DOWN ""; /* acces base de données */ _CRtext _channel editorWin 5 80 100 40 ET_ALIGN_LEFT (_locEditor "LOGINP-databasena" nil); set dbname = _CReditLine _channel editorWin 130 85 160 20 ET_DOWN|ET_AHSCROLL ""; set ConnectBtn = _CRbutton _channel editorWin 300 85 70 20 0 (_locEditor "DB_CONECTION" nil); _CRtext _channel editorWin 5 110 85 20 ET_ALIGN_LEFT (_locEditor "LOGINP-logintable" nil); set comboTable = _ENcombo _CRcombo _channel editorWin 130 110 160 200 CB_AHSCROLL|CB_DOWN "" 0; _CRtext _channel editorWin 5 135 100 20 ET_ALIGN_LEFT (_locEditor "LOGINP-logincolum" nil); set comboUser = _ENcombo _CRcombo _channel editorWin 130 135 160 200 CB_AHSCROLL|CB_DOWN "" 0; /* callback */ _CBbutton ConnectBtn @cbConnect [dbname editorWin]; _CBcombo comboTable @cbChangeComboTable nil; cbLoad nil; ); 0 ;;