TheQwertiest / foo_spider_monkey_panel

foobar2000 component that allows to use JavaScript to create CUI/DUI panels
https://theqwertiest.github.io/foo_spider_monkey_panel/
MIT License
271 stars 21 forks source link

XHR support #23

Open a1waysbeta opened 6 years ago

a1waysbeta commented 6 years ago

Can you add interface HttpRequestEx & ESLyric related functions from wsh plus? Porting a UI (like foobox) to smp requires these two features.

_eslyric_set_text_colornormal _eslyric_set_text_colorhighlight _eslyric_set_backgroundcolor _eslyric_set_textfont _eslyric_set_text_titleformatfallback _eslyric_set_textfallback _eslyric_set_backgroundimage /example windows.NotifyOthers("_eslyric_set_backgroundimage",gdi.CreateImage(44,22)); windows.NotifyOthers("_eslyric_set_backgroundcolor",RGB(25,50,100)); /

TheQwertiest commented 6 years ago

As far as I could find, WshModPlus does not contain such callbacks. It has only one leftover file, which is not even included in the .vcxproj.

Regardless, these callbacks sound very component specific (probably has smth to do with catching messages from ESLyric component), which I'd very like to avoid.

Regarding HttpRequestEx: I took a quick look at the code and it doesn't look like it brings something that ActiveXObject('Microsoft.XMLHTTP') can't achieve. Am I missing something?

smoralis commented 6 years ago

Eslyrics has its own ActiveXObject that can be used in any script for the requested callbacks.

https://www.dropbox.com/s/1voh96segidvnnn/automation.js?dl=0

a1waysbeta commented 6 years ago

Can not return real-time download speed, download progress.

interface IHttpRequestEx { Properties: [r,w]String SavePath;//文件保存路径,默认为%profile_path%\cache

Methods: String Run(url, verb = "GET"); UINT RunAsync(id, url, fn = "", verb = "GET"); }

interface IHttpRequestExCallbackInfo { Properties: [r] UINT Status;//StatusHeadersAvailable = 1 << 0, StatusDataReadComplete = 1 << 1 [r] UINT Error;//不为0时出现错误 [r] UINT ID;//IHttpRequestEx.RunAsync中传入的ID [r] String URL;//当前请求的url [r] String Path;//文件保存路径 [r] UINT Length;//已保存数据大小 [r] UINT ContentLength;//文件总大小,可能为无穷大 [r] double ElapsedTime;//耗时 }

interface IWSHUtils { Methods: [new] IHttpRequestEx CreateHttpRequestEx(window_id); }

//回调函数,状态或数据读取完后调用 //param : info = IHttpRequestExCallbackInfo object function on_http_ex_run_status(info){}

//examples var StatusHeadersAvailable = 1 << 0; var StatusDataReadComplete = 1 << 1;

client = Utils.CreateHttpRequestEx(window.ID); client.SavePath = "D:\Temp";

client.RunAsync(0, "http://this/is/first/one.mp3", "filename"); client.RunAsync(1, "http://second/second.mp4", "filename");

client.AbortAsync(id,url = ""); // url is optional, but is preferred. If there is a url, it will match the url first. If the id is not unique, the first one is cancelled. (Like: 0 1 2 3 work, 0 0 1 2 will not work. If 0012 is downloading at the same time, but only id0 is specified when you cancel, the first 0 is canceled.)

function on_http_ex_run_status(info) { if(info.Status & StatusDataReadComplete)//文件下载完成 { if(info.ID == 0)fb.trace("one.mp3"); else if(info.ID == 1)fb.trace("second.mp4") } else { if(info.ID == 0){ fb.trace(info.ID + “ Downloaded Bytes : ” + info.Length); fb.trace(info.ID + “ Total Bytes : ” + info.ContentLength); } if(info.ID == 1){ fb.trace(info.ID + “ Downloaded Bytes : ” + info.Length); fb.trace(info.ID + “ Total Bytes : ” + info.ContentLength); } } }

TheQwertiest commented 6 years ago

Uhm... But what is the use case scenario? Why would you need to download such big files in panel, that the download progress display is required? =)

a1waysbeta commented 6 years ago

With the web search script, I can download mp3 and so on. Maybe a picture is easier to explain. https://imgur.com/a/MYHX1UR

smoralis commented 6 years ago

Eslyrics has its own ActiveXObject that can be used in any script for the requested callbacks.

https://www.dropbox.com/s/1voh96segidvnnn/automation.js?dl=0

These two methods fail. SetPanelBackgroundImage(IGdiBitmap img, String panel_guid = ""); SetPanelTextFont(IGdiFont, String panel_guid = "");

Error: Spider Monkey Panel v1.0.2 ({3C4F1994-6BC2-43E0-AC4E-DA05C99DD605}) 'ActiveX_Run' failed: ActiveXObject: Parameter 0 type mismatch

File:

Line: 15, Column: 1

Stack trace: @

:15:1

The other methods with UINT or String work.

TheQwertiest commented 6 years ago

These two methods fail.

This is expected behaviour: IGdiBitmap and IGdiFont objects are part of the old WSH/JSP interface (i.e. COM interface), which is no longer available due to the JS engine switch.

SMP can still use COM/ActiveX interface from other dll's, but other dll's can't use SMP in the same way as before: it just does not have a COM interface anymore.

smoralis commented 6 years ago

Thank you for the clarification.

TheQwertiest commented 2 years ago

Download functionality will be implemented with XHR interface in v2

TheQwertiest commented 2 years ago

Note to self: use https://github.com/libcpr/cpr , does not require ossl for https (supports winssl)

TheQwertiest commented 1 year ago

Note to self: alternative lib https://github.com/chmike/CxxUrl