/* ----------------------------------------------------------------------------- This source file is part of OpenSpace3D For the latest info, see http://www.openspace3d.com Copyright (c) 2021 I-maginer This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/copyleft/lesser.txt ----------------------------------------------------------------------------- */ var sDefaultDownloadPath = "tmp/onlinefiles/dl/";; var sConfigPath = "tmp/onlinefiles/";; struct OFDLUnit = [ OFDLU_element : VUIListElement, OFDLU_sLabel : S, OFDLU_sValue : S, OFDLU_iDepth : I, OFDLU_lChildren : [OFDLUnit r1] ] mkOFDLUnit;; struct PlugOnlineFile = [ POF_instance : PInstance, POF_sServeur : S, POF_sDlPath : S, POF_sFilesMask : S, POF_sTitle : S, POF_sConfPath : S, POF_bEditServer : I, POF_bShowLocalFiles : I, POF_dlgstr : VUIDlg, POF_liststr : VUIList, POF_editstr : VUIelement, POF_lList : [OFDLUnit r1], POF_selected : VUIListElement, POF_sPos : S, POF_iOpacity : I, POF_httpReq : ObjCURL, POF_iUrlMode : I, POF_bDownloading : I ] mkPlugOnlineFile;; proto updateDialogSize = fun [PlugOnlineFile] I;; proto addElement = fun [PlugOnlineFile OFDLUnit S S I] OFDLUnit;; proto clearList = fun [PlugOnlineFile] I;; proto createDialog = fun [S PlugOnlineFile] I;; fun getLocalFiles(obstr)= getFilesFromDir obstr.POF_sDlPath obstr.POF_sFilesMask::nil;; fun isFileInList(l, file)= if (l == nil) then 0 else ( let l -> [f n] in let getPathFile f "" -> [_ fname] in if (!strcmp fname file) then 1 else isFileInList n file; );; fun fillLocalFiles(obstr)= let getLocalFiles obstr -> lfiles in ( while (lfiles != nil) do ( let hd lfiles -> file in let getPathFile file "" -> [_ fname] in addElement obstr nil fname file 0; set lfiles = tl lfiles; ); ); 0;; fun getOs3dpakApi(baseurl)= if (!strIsUrl baseurl) then nil else ( if (!strcmp "os3dpak.php?list" (substr baseurl ((strlen baseurl) - 16) 16)) then baseurl else if (!strcmp "os3dpak.php" (substr baseurl ((strlen baseurl) - 11) 11)) then strcat baseurl "?list" else if (!strcmp "/" (substr baseurl ((strlen baseurl) - 1) 1)) then strcat baseurl "os3dpak.php?list" else strcat baseurl "/os3dpak.php?list"; );; fun extEqual(mask, file)= let !strcmp (hd mask) "*.*" -> all in let getFileExt file -> ext in if (!all && (mask != nil) && !(isExtInListi mask ext)) then 0 else 1;; //TODO file ext check fun cbGetWebFileList(url, data, p)= let p -> [obstr ourl] in ( set obstr.POF_httpReq = nil; if ((data != nil) && ((strfindi "404 File not found" data 0) == nil)) then // valid output ( let getLocalFiles obstr -> lfiles in ( let utf8tostr data -> data in let XMLloadString data -> htmlstr in let XMLgetMarkByValue htmlstr "body" -> bodystr in let XMLgetMarkByValueFromMark bodystr "h1" -> h1str in let XMLgetData h1str -> title in if ((bodystr != nil) ) then ( let XMLgetMarkByValueFromMark bodystr "ul" -> ulstr in let if (ulstr == nil) then bodystr else ulstr -> ulstr in let XMLgetMarksByValueFromMark ulstr "a" -> lastr in if (lastr != nil) then ( while (lastr != nil) do ( let hd lastr -> astr in let XMLgetParam astr "href" -> link in let strtrim XMLgetData astr -> fname in let if ((fname == nil) || (!strcmp fname "")) then let getPathFile link "" -> [_ bname] in bname else let getPathFile fname "" -> [_ bname] in bname -> fname in if (!strcmpi link "/") || (!strcmpi fname "..") || (!strcmpi link "../") || ((strfindi "Parent Directory" fname 0) != nil) || (!extEqual obstr.POF_sFilesMask::nil fname) then nil else ( let webtostr fname -> scname in let if (strIsUrl link) then link else strcat ourl fname -> furl in let strcat obstr.POF_sDlPath scname -> localf in ( addElement obstr nil scname furl 0; set lfiles = remove_string_from_list lfiles localf; ); ); set lastr = tl lastr; ); 0; ) else ( let XMLgetMarkByValueFromMark bodystr "table" -> tablestr in let XMLgetMarksByValueFromMark tablestr "tr" -> llistr in ( while (llistr != nil) do ( let hd llistr -> listr in let XMLgetMarkByValueFromMark listr "th" -> thstr in let XMLgetMarkByValueFromMark listr "a" -> astr in let XMLgetParam astr "href" -> link in let strtrim XMLgetData astr -> fname in let if ((fname == nil) || (!strcmp fname "")) then let getPathFile link "" -> [_ bname] in bname else let getPathFile fname "" -> [_ bname] in bname -> fname in if (thstr != nil) || (!strcmpi link "/") || (!strcmpi fname "..") || (!strcmpi link "../") || ((strfindi "Parent Directory" fname 0) != nil) || (!extEqual obstr.POF_sFilesMask::nil fname) then nil else ( let webtostr fname -> scname in let if (strIsUrl link) then link else strcat ourl fname -> furl in let strcat obstr.POF_sDlPath scname -> localf in ( addElement obstr nil scname furl 0; set lfiles = remove_string_from_list lfiles localf; ); ); set llistr = tl llistr; ); ); 0; ); if (!obstr.POF_bShowLocalFiles) then nil else while (lfiles != nil) do ( let hd lfiles -> fpath in let getPathFile fpath "" -> [_ fname] in addElement obstr nil fname fpath 0; set lfiles = tl lfiles; ); set obstr.POF_iUrlMode = 1; ) else ( SendPluginEvent obstr.POF_instance "Error" strcat url (locDef "OS3DONLINEFILES_C0004" " failed or bad response!") nil; addLogMessage strcatn "Online files PlugIT : "::url::" "::(locDef "OS3DONLINEFILES_C0004" " failed or bad response!")::"\n"::data::nil; if (!obstr.POF_bShowLocalFiles) then nil else fillLocalFiles obstr; set obstr.POF_iUrlMode = 0; ); ); 0; ) else ( SendPluginEvent obstr.POF_instance "Error" strcat url (locDef "OS3DONLINEFILES_C0004" " failed or bad response!") nil; addLogMessage strcatn "Online files PlugIT : "::url::" "::(locDef "OS3DONLINEFILES_C0004" " failed or bad response!")::nil; if (!obstr.POF_bShowLocalFiles) then nil else fillLocalFiles obstr; set obstr.POF_iUrlMode = 0; 0; ); updateDialogSize obstr; ); 0;; fun getHttpFileList(url, obstr)= let if (nth_char url ((strlen url)-1)) == '/ then url else strcat url "/" -> url in let url /*strcatn url::"?C=N&F=0&P="::obstr.POF_sFilesMask::nil*/ -> lurl in set obstr.POF_httpReq = getUrl lurl nil mkfun3 @cbGetWebFileList [obstr url]; 0;; fun cbGetOs3dApiContent(url, data, p)= let p -> [obstr ourl] in ( set obstr.POF_httpReq = nil; clearList obstr; let readCSVdataWithTitle data "," -> [titles lcont] in if ((data != nil) && (!strcmp (hd titles) "Filename")) then // valid output ( let getLocalFiles obstr -> lfiles in ( while (lcont != nil) do ( let hd lcont -> [fname [furl [fsize [fmd5 _]]]] in let strcat obstr.POF_sDlPath fname -> localf in let _filemd5 (_checkpack localf) -> lmd5 in ( //addLogMessage strcatn "File: "::fname::" local: "::lmd5::" dist: "::fmd5::nil; if (!strcmp fmd5 lmd5) then addElement obstr nil fname localf 0 else addElement obstr nil fname furl 0; set lfiles = remove_string_from_list lfiles localf; ); set lcont = tl lcont; ); if (!obstr.POF_bShowLocalFiles) then nil else while (lfiles != nil) do ( let hd lfiles -> fpath in let getPathFile fpath "" -> [_ fname] in addElement obstr nil fname fpath 0; set lfiles = tl lfiles; ); ); set obstr.POF_iUrlMode = 2; updateDialogSize obstr; 0; ) else ( if (obstr.POF_iUrlMode != 0) then ( SendPluginEvent obstr.POF_instance "Error" strcat url (locDef "OS3DONLINEFILES_C0004" " failed or bad response!") nil; addLogMessage strcatn "Online files PlugIT : "::url::(locDef "OS3DONLINEFILES_C0004" " failed or bad response!")::nil; if (!obstr.POF_bShowLocalFiles) then nil else fillLocalFiles obstr; updateDialogSize obstr; 0; ) else ( getHttpFileList ourl obstr; 0; ); ); ); 0;; fun cbIsConnected(testurl, p, rc) = let p -> [obstr url] in ( if (obstr.POF_httpReq == nil) then nil else ( killHttpRequest obstr.POF_httpReq; set obstr.POF_httpReq = nil; if (!obstr.POF_bDownloading) then nil else ( set obstr.POF_bDownloading = 0; SendPluginEvent obstr.POF_instance "Download aborted" nil nil; ); ); if (rc == 1) then // Active Internet Connection detected ( if (obstr.POF_iUrlMode == 1) then ( getHttpFileList url obstr; 0; ) else ( set obstr.POF_httpReq = getUrl getOs3dpakApi url nil mkfun3 @cbGetOs3dApiContent [obstr url]; 0; ); ) // No Active Internet Connection detected else ( SendPluginEvent obstr.POF_instance "Error" "No internet connection found!" nil; addLogMessage "Online files PlugIT : no internet connection found!"; if (!obstr.POF_bShowLocalFiles) then nil else fillLocalFiles obstr; 0; ) );; fun cbFileDownloaded(file, wfile, obstr)= let _WtoP wfile -> tmpfile in let _fileSize tmpfile -> size in if (size == 0) then ( set obstr.POF_bDownloading = 0; SendPluginEvent obstr.POF_instance "Error" (locDef "OS3DONLINEFILES_C0005" "The file is empty!") nil; 0; ) else ( set obstr.POF_bDownloading = 0; SendPluginEvent obstr.POF_instance "File ready" _PtoScol _WtoP wfile nil; 0; ); set obstr.POF_httpReq = nil; 0;; fun cbFileWebDownloaded(file, wfile, p)= let p -> [obstr tagfile tagcont] in let _WtoP wfile -> tmpfile in let _fileSize tmpfile -> size in ( if (size == 0) then ( set obstr.POF_bDownloading = 0; SendPluginEvent obstr.POF_instance "Error" (locDef "OS3DONLINEFILES_C0005" "The file is empty!") nil; 0; ) else ( set obstr.POF_bDownloading = 0; _storepack tagcont tagfile; SendPluginEvent obstr.POF_instance "File ready" _PtoScol _WtoP wfile nil; 0; ); set obstr.POF_httpReq = nil; ); 0;; fun cbFileInfos(url, tag, length, p)= let p -> [obstr localf] in ( if (obstr.POF_httpReq == nil) then nil else ( killHttpRequest obstr.POF_httpReq; set obstr.POF_httpReq = nil; ); //bad response if ((tag == nil) && (length == nil)) then ( SendPluginEvent obstr.POF_instance "Error" nil nil; set obstr.POF_bDownloading = 0; 0; ) else ( let strcat localf ".tag" -> tagfile in let strcatn tag::" "::(itoa length)::nil -> tagcont in if (((_checkpack localf) != nil) && (!strcmp (_getpack _checkpack tagfile) tagcont)) then ( set obstr.POF_bDownloading = 0; SendPluginEvent obstr.POF_instance "File ready" localf nil; 0; ) else ( let _getmodifypack localf -> wfile in let _createpack "" wfile -> _ in //force empty set obstr.POF_httpReq = downloadFileW url wfile mkfun3 @cbFileWebDownloaded [obstr tagfile tagcont]; 0; ); ); ); 0;; fun downloadOnlineFile(obstr, name, url)= set obstr.POF_bDownloading = 1; if ((strfind "os3dpak.php?dl=" url 0) != nil) then ( let strcat obstr.POF_sDlPath name -> localf in let _getmodifypack localf -> wfile in let _createpack "" wfile -> _ in //force empty set obstr.POF_httpReq = downloadFileW url wfile mkfun3 @cbFileDownloaded obstr; ) else ( let getPathFile url "" -> [dir file] in let strcat obstr.POF_sDlPath file -> localf in set obstr.POF_httpReq = getUrlContentInfos url mkfun4 @cbFileInfos [obstr localf]; ); 0;; fun cbRefresh(inst, from, action, param, reply, obstr)= let _DMSreadParam param obstr.POF_sServeur -> url in checkInternetConnection nil @cbIsConnected [obstr url]; 0;; fun cbAbortDownload(inst, from, action, param, reply, obstr)= if ((obstr.POF_httpReq == nil) || (!obstr.POF_bDownloading)) then nil else ( killHttpRequest obstr.POF_httpReq; set obstr.POF_httpReq = nil; set obstr.POF_bDownloading = 0; SendPluginEvent obstr.POF_instance "Download aborted" nil nil; ); 0;; fun cbSetUrl(inst, from, action, param, reply, obstr)= if (!(strIsUrl param)) then nil else ( set obstr.POF_sServeur = param; _storepack obstr.POF_sServeur obstr.POF_sConfPath; checkInternetConnection nil @cbIsConnected [obstr obstr.POF_sServeur]; ); 0;; /////////// INTERACE ///////////// fun getWidth(obstr, lunits, font)= let 350 -> width in let [10 0] -> [ow oh] in let hd lunits -> unitstr in let ow * unitstr.OFDLU_iDepth -> offset in ( while (lunits != nil) do ( let hd lunits -> unitstr in let VUIgetTextSize font unitstr.OFDLU_sLabel 0 iVUITEXT_HALIGNLEFT|iVUITEXT_VALIGNCENTER -> [tw th] in if (unitstr.OFDLU_lChildren == nil) then set width = max width (tw + 10 + offset) else let getWidth obstr unitstr.OFDLU_lChildren font -> childrenWidth in set width = max (max width (24 + tw + 10 + offset)) childrenWidth; set lunits = tl lunits; ); width; );; fun updateDialogSize(obstr)= let V3DgetSessionView c3dXsession -> viewstr in ( VUIupdateListElementsCoords obstr.POF_liststr obstr.POF_liststr.VUIL_lListElts obstr.POF_liststr.VUIL_tScroll; let VUIgetThemeDef (getThemeFromInstance obstr.POF_instance) "dialogBox" -> defstr in let VUIgetFontFromInterface VUIgetThemeFont defstr "label" -> lbfontstr in let [10 0] -> [ow oh] in let getWidth obstr obstr.POF_lList lbfontstr -> sw in let obstr.POF_liststr.VUIL_tMargin -> [mx my] in let VUIgetListFullContentSize obstr.POF_liststr 1 -> [tw th] in let max 30 th + 25 + if (obstr.POF_bEditServer) then 40 else 0 -> sh in let VUIgetViewSize viewstr -> [cvw cvh] in let VUIcomputeDialogBoxSize viewstr (getThemeFromInstance obstr.POF_instance) (VUIgetElementText obstr.POF_dlgstr.VUIDLG_title) (VUIgetElementText obstr.POF_dlgstr.VUIDLG_frame) (if (obstr.POF_dlgstr.VUIDLG_okBtn == nil && obstr.POF_dlgstr.VUIDLG_cancelBtn == nil) then 0 else 1) -> [tlw tlh _ _ btnh] in let [(cvw - 20 - 30) (cvh - 30 - btnh - tlh)] -> [maxvw maxvh] in let [(min (max (max sw tlw) 400) maxvw) (min (max sh 80) maxvh)] -> [ttw tth] in let [ttw + 30 tth + btnh + tlh] -> [nw nh] in ( VUIsetElementSize obstr.POF_dlgstr.VUIDLG_title [100.0 (itof tlh)] nil; VUIsetElementSize obstr.POF_dlgstr.VUIDLG_frame nil [1 1 (-20) (-(10 + tlh + 10 + btnh))]; VUIsetElementPos obstr.POF_dlgstr.VUIDLG_frame [0.0 (itof (10 + tlh))] nil nil; VUIsetContainerSize obstr.POF_dlgstr.VUIDLG_container [(itof nw) (itof nh)] nil; ); ); 0;; fun cbDlgThemeUpdate(constr, obstr)= updateDialogSize obstr;; fun cbSetTitle(inst, from, action, param, reply, obstr)= set obstr.POF_sTitle = if (param == nil) || (!strcmp (strtrim param) "") then nil else strtrim param; if (obstr.POF_dlgstr == nil) then nil else ( VUIsetDialogTitle obstr.POF_dlgstr obstr.POF_sTitle; updateDialogSize obstr; ); 0;; fun findUnitInList(list, label)= let hd list -> unitstr in ( while (list != nil && (strcmpi unitstr.OFDLU_sLabel label) != 0) do ( set list = tl list; set unitstr = hd list; ); unitstr; );; fun addElement(obstr, parent, label, value, depth)= let mkOFDLUnit[nil label value depth nil] -> newunit in ( if parent == nil then set obstr.POF_lList = lcat obstr.POF_lList newunit::nil else set parent.OFDLU_lChildren = lcat parent.OFDLU_lChildren newunit::nil; if obstr.POF_dlgstr == nil then nil else let VUIaddListElement obstr.POF_liststr parent.OFDLU_element label value 1 -> newelem in set newunit.OFDLU_element = newelem; newunit; );; fun cbClickDlgButton(dlgstr, state, obstr)= set obstr.POF_dlgstr = nil; if (state) then ( if ((obstr.POF_selected == nil) || (obstr.POF_selected.VUILE_sParam == nil) || (!strcmp obstr.POF_selected.VUILE_sParam "")) then ( createDialog nil obstr; ) else if (strIsUrl obstr.POF_selected.VUILE_sParam) then ( SendPluginEvent obstr.POF_instance "Hidden" nil nil; SendPluginEvent obstr.POF_instance "Downloading" obstr.POF_selected.VUILE_sValue nil; downloadOnlineFile obstr obstr.POF_selected.VUILE_sValue obstr.POF_selected.VUILE_sParam; ) else ( SendPluginEvent obstr.POF_instance "Hidden" nil nil; SendPluginEvent obstr.POF_instance "File ready" obstr.POF_selected.VUILE_sParam nil; ); ) else ( SendPluginEvent obstr.POF_instance "Hidden" nil nil; SendPluginEvent obstr.POF_instance "Cancelled" nil nil; ); 0;; fun cbListSelect(liststr, lselected, obstr)= let hd lselected -> selectedstr in set obstr.POF_selected = selectedstr; 0;; fun getAlign(param)= let [1 1] -> align in let [0.0 0.0] -> pos in let strextr param -> lp in let hd lp -> lp in let 0 -> nb in ( while ((lp != nil) && (nb < 2)) do ( let hd lp -> flag in if (!strcmpi flag "top") then ( mutate align <- [_ 0]; mutate pos <- [_ 10.0]; ) else if (!strcmpi flag "bottom") then ( mutate align <- [_ 2]; mutate pos <- [_ 10.0]; ) else if (!strcmpi flag "left") then ( mutate align <- [0 _]; mutate pos <- [10.0 _]; ) else if (!strcmpi flag "right") then ( mutate align <- [2 _]; mutate pos <- [10.0 _]; ) else nil; set lp = tl lp; set nb = nb + 1; ); [pos align]; );; fun fillList(liststr, parentstr, lunits, unfold)= while (lunits != nil) do ( let hd lunits -> unitstr in let VUIaddListElement liststr parentstr unitstr.OFDLU_sLabel unitstr.OFDLU_sValue 1 -> newelem in ( set unitstr.OFDLU_element = newelem; fillList liststr newelem unitstr.OFDLU_lChildren unfold; if (!unfold || newelem.VUILE_children == nil) then nil else VUIunfoldListElement newelem 1; ); set lunits = tl lunits; ); 0;; fun cbValidateServer(eltstr, text, state, obstr)= if ((!state) || (!strcmp (strtrim text) "")) then nil else ( let if !(strIsUrl text) then strcat "http://" text else text -> text in set obstr.POF_sServeur = text; _storepack obstr.POF_sServeur obstr.POF_sConfPath; VUIsetElementTextContent eltstr obstr.POF_sServeur; set obstr.POF_iUrlMode = 0; checkInternetConnection nil @cbIsConnected [obstr obstr.POF_sServeur]; ); 0;; fun cbFocusedServer(eltstr, state, obstr)= let VUIgetElementText eltstr -> text in if (state || (!strcmp obstr.POF_sServeur text)) then nil else cbValidateServer eltstr text 1 obstr; 0;; fun createDialog(param, obstr)= let V3DgetSessionView c3dXsession -> viewstr in let VUIgetThemeDef (getThemeFromInstance obstr.POF_instance) "dialogBox" -> defstr in let VUIgetThemeFont defstr "label" -> fontstr in let VUIgetFontFromInterface fontstr -> lbfontstr in let if (strcmpi obstr.POF_sTitle "") == 0 then nil else obstr.POF_sTitle -> title in let [10 0] -> [ow oh] in let max 400 getWidth obstr obstr.POF_lList lbfontstr -> width in let locDef "OS3DONLINEFILES_C0003" "Server URL" -> serverlabel in let if (obstr.POF_bEditServer) then VUIgetTextSize lbfontstr serverlabel 0 iVUITEXT_HALIGNLEFT|iVUITEXT_VALIGNTOP else [0 0] -> [tw th] in let max 80 (200 + th + 10) -> height in let if (obstr.POF_bEditServer) then 30 else 0 -> edth in let VUIcreateDialogExt viewstr obstr.POF_instance.INST_groupstr.GRP_project.PRJ_vuiGroup [width height] title (locDef "OS3DONLINEFILES_C0001" "Ok") (locDef "OS3DONLINEFILES_C0002" "Cancel") obstr.POF_iOpacity (V3DgetVrMode viewstr) (mkfun3 @cbClickDlgButton obstr) "dialogBox" -> dlgstr in let VUIgetDialogFrame dlgstr -> framestr in let VUIgetElementContainer framestr -> contstr in let VUIcreateFrame contstr framestr [0.0 0.0] [(itof (tw + 10)) 0.0] [0 0 0 0 0 0 0 0] [0 0] -> serverlabelstr in let if (obstr.POF_bEditServer) then VUIcreateEditTextExt contstr framestr [itof (tw + 10) 0.0] [100.0 (itof edth)] [0 0 1 0 0 0 (-(tw + 10)) 0] [0 0] nil [10 5] obstr.POF_sServeur 0 "common/editText" else nil -> editstr in let if (obstr.POF_bEditServer) then (edth + 10) else 0 -> ylist in let VUIcreateListExt contstr framestr [0.0 itof ylist] [100.0 100.0] [0 0 1 1 0 0 0 (-ylist)] [0 0] [5 5] 0 [ow oh] "list" -> liststr in ( VUIsetElementText serverlabelstr fontstr serverlabel [0 0] [tw 0] [5 5] iVUITEXT_HALIGNLEFT|iVUITEXT_VALIGNTOP VUI_TextAutoHeight 1; fillList liststr nil obstr.POF_lList 0; VUIsetListCbSelect liststr mkfun3 @cbListSelect obstr; VUIsetElementCbValidate editstr mkfun4 @cbValidateServer obstr; VUIsetElementCbFocused editstr mkfun3 @cbFocusedServer obstr; let if (!strcmp "" (strtrim param)) || param == nil then getAlign obstr.POF_sPos else getAlign param -> [pos align] in VUIsetContainerPos contstr pos align nil; set obstr.POF_dlgstr = dlgstr; set obstr.POF_liststr = liststr; set obstr.POF_selected = nil; VUIsetContainerThemeCallback contstr mkfun2 @cbDlgThemeUpdate obstr; VUIsetContainerClear contstr 0; if (obstr.POF_lList == nil) then nil else updateDialogSize obstr; VUIshowDialog dlgstr 1; checkInternetConnection nil @cbIsConnected [obstr obstr.POF_sServeur]; ); 0;; fun clearList(obstr)= VUIclearList obstr.POF_liststr; set obstr.POF_lList = nil; 0;; fun cbVrChange(inst, viewstr, state, obstr)= if obstr.POF_dlgstr == nil then nil else ( VUIdestroyDialogBox obstr.POF_dlgstr; createDialog nil obstr; ); 0;; fun cbShow(inst, from, action, param, reply, obstr)= if obstr.POF_dlgstr != nil then nil else ( createDialog param obstr; SendPluginEvent inst "Shown" nil nil; ); 0;; fun cbHide(inst, from, action, param, reply, obstr)= if obstr.POF_dlgstr == nil then nil else ( VUIdestroyDialogBox obstr.POF_dlgstr; set obstr.POF_dlgstr = nil; SendPluginEvent inst "Hidden" nil nil; ); 0;; fun cbClearList(inst, from, action, param, reply, obstr)= clearList obstr; if (obstr.POF_dlgstr == nil) then nil else updateDialogSize obstr; 0;; fun deleteOb(inst, obstr)= if (obstr.POF_httpReq == nil) then nil else ( killHttpRequest obstr.POF_httpReq; set obstr.POF_httpReq = nil; ); VUIdestroyDialogBox obstr.POF_dlgstr; 0;; fun newOb(inst)= let getPluginInstanceParam inst "title" -> title in let if (title == nil) then "" else title -> title in let getPluginInstanceParam inst "url" -> url in let if (url == nil) then "http://" else url -> url in let atoi (getPluginInstanceParam inst "editsrv") -> editsrv in let if (editsrv == nil) then 1 else editsrv -> editsrv in let atoi (getPluginInstanceParam inst "showlocal") -> showlocal in let if (showlocal == nil) then 1 else showlocal -> showlocal in let getPluginInstanceParam inst "mask" -> mask in let if (mask == nil) || (!strcmp mask "") then "*.*" else mask -> mask in let atoi (getPluginInstanceParam inst "show") -> show in let if (show == nil) then 1 else show -> show in let atoi (getPluginInstanceParam inst "valign") -> valign in let if valign == nil then 1 else valign -> valign in let atoi (getPluginInstanceParam inst "halign") -> halign in let if halign == nil then 1 else halign -> halign in let if (valign == 0) then "top" else if (valign == 2) then "bottom" else "center" -> vpos in let if (halign == 0) then "left" else if (halign == 2) then "right" else "center" -> hpos in let atoi (getPluginInstanceParam inst "opacity") -> opacity in let if (opacity == nil) then 100 else opacity -> opacity in let strcatn sConfigPath::(getPluginInstanceFullname inst)::".conf"::nil -> confpath in let mkPlugOnlineFile [inst url sDefaultDownloadPath mask title confpath editsrv showlocal nil nil nil nil nil (strcatn vpos::" "::hpos::nil) opacity nil 0 0] -> obstr in ( //editor mode enable cache on player if (iPluginMode == 1) then nil else _cacheActivate; if ((_checkpack confpath) == nil) then nil else set obstr.POF_sServeur = _getpack (_checkpack confpath); if (!show) then nil else cbShow inst nil nil nil nil obstr; PluginRegisterAction inst "Show" mkfun6 @cbShow obstr; PluginRegisterAction inst "Hide" mkfun6 @cbHide obstr; PluginRegisterAction inst "Set url" mkfun6 @cbSetUrl obstr; PluginRegisterAction inst "Refresh" mkfun6 @cbRefresh obstr; PluginRegisterAction inst "Abort download" mkfun6 @cbAbortDownload obstr; setPluginInstanceCbVrModeChanged inst mkfun4 @cbVrChange obstr; setPluginInstanceCbDel inst mkfun2 @deleteOb obstr; ); 0;; fun IniPlug(file)= PlugRegister @newOb nil; setPluginEditor @dynamicedit; 0;;