From 5161f3acf0dd48896ae5ae75d5a008b4cad9c465 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Thu, 2 Nov 2017 12:20:25 +0000 Subject: [PATCH] nsinstall: add notify dialog to show downloading progress; TODO (not for me): change 'nsinstall' icon to 'netsurf' git-svn-id: svn://kolibrios.org@7106 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/network/netsurf/build.bat | 2 + programs/network/netsurf/notify.asm | 147 +++++++++++++++++++++++++ programs/network/netsurf/nsinstall.asm | 56 +++++++++- 3 files changed, 200 insertions(+), 5 deletions(-) create mode 100644 programs/network/netsurf/build.bat create mode 100644 programs/network/netsurf/notify.asm diff --git a/programs/network/netsurf/build.bat b/programs/network/netsurf/build.bat new file mode 100644 index 0000000000..eca2d12d37 --- /dev/null +++ b/programs/network/netsurf/build.bat @@ -0,0 +1,2 @@ +fasm nsinstall.asm nsinstall +pause \ No newline at end of file diff --git a/programs/network/netsurf/notify.asm b/programs/network/netsurf/notify.asm new file mode 100644 index 0000000000..b005794185 --- /dev/null +++ b/programs/network/netsurf/notify.asm @@ -0,0 +1,147 @@ +NOTIFY_RUN: + + ;; Make param + stdcall string.copy, sz_quote, params + stdcall string.copy, filelist_first, current_filename + call make_text + stdcall string.concatenate, sz_quote, params + stdcall string.concatenate, sz_flags, params +;; RUN NOTIFY + mcall 70, fi_launch + + ;; CONVERT PID TO STR + mov ebx, 10 + mov ecx, 0 + @@: + mov edx, 0 + div ebx + push edx + inc ecx + cmpne eax, 0, @b + + mov ebx, ctrl.name + @@: + pop eax + add al, "0" + mov [ebx], al + inc ebx + loop @b + + ;; ADD POSTFIX TO STR + mov dword [ebx + 0], "-NOT" + mov dword [ebx + 4], "IFY" + + ;; OPEN CONTROLLER (0x08 + 0x01 -- CREATE AND READ/WRITE) + mcall 68, 22, ctrl.name, 2048, 0x09 + mov [ctrl.addr], eax + + ;; WAIT UNTIL CONTROLLER BECOMES READY TO USE + add eax, NTCTRL_READY + @@: + mcall 5, 1 + cmpe byte [eax], 0, @b + + ;; CONFIG PBAR + mov eax, [ctrl.addr] + add eax, NTCTRL_PBAR_MAX + mov dword [eax], 55 + + mov eax, [ctrl.addr] + add eax, NTCTRL_PBAR_CUR + mov dword [eax], 0 + + mov eax, [ctrl.addr] + add eax, NTCTRL_APPLY_PBAR + mov byte [eax], 1 + + ret + + + + + + + + +NOTIFY_CHANGE: + + ;; CHANGE TIMER + inc dword [timer] + mov ebx, dword [timer] + + ;; SEND TIMER TO PBAR + mov eax, [ctrl.addr] + add eax, NTCTRL_PBAR_CUR + mov dword [eax], ebx + + ;; APPLY PBAR + mov eax, [ctrl.addr] + add eax, NTCTRL_APPLY_PBAR + mov byte [eax], 1 + + ;; CNANGE TEXT + mov byte [params], 0 + call make_text + + ;; SEND TEXT TO NOTIFY + mov eax, [ctrl.addr] + add eax, NTCTRL_TEXT + stdcall string.copy, params, eax + + ;; APPLY NEW TEXT + mov eax, [ctrl.addr] + add eax, NTCTRL_APPLY_TEXT + mov byte [eax], 1 + + ret + + + + + + + +EXIT: + ;; CHANGE ICON + mov eax, [ctrl.addr] + add eax, NTCTRL_ICON + mov byte [eax], 4 + + ;; APPLY NEW ICON + mov eax, [ctrl.addr] + add eax, NTCTRL_APPLY_ICON + mov byte [eax], 1 + + ;; CNANGE TEXT + mov byte [params], 0 + stdcall string.concatenate, sz_final_text, params + + ;; SEND TEXT TO NOTIFY + mov eax, [ctrl.addr] + add eax, NTCTRL_TEXT + stdcall string.copy, params, eax + + ;; APPLY NEW TEXT + mov eax, [ctrl.addr] + add eax, NTCTRL_APPLY_TEXT + mov byte [eax], 1 + + mcall 5, 300 + + mcall 70, fileopen + + ;; CLOSE NOTIFY + mov eax, [ctrl.addr] + add eax, NTCTRL_CLOSE + mov byte [eax], 1 + + mcall -1 + +;------------------------------------------------------------------------------- + make_text: + stdcall string.concatenate, sz_text, params + stdcall string.concatenate, sz_sec_line_start, params + stdcall string.concatenate, current_filename, params + + ret +;------------------------------------------------------------------------------- \ No newline at end of file diff --git a/programs/network/netsurf/nsinstall.asm b/programs/network/netsurf/nsinstall.asm index 995b4e4692..4f9c38b06a 100644 --- a/programs/network/netsurf/nsinstall.asm +++ b/programs/network/netsurf/nsinstall.asm @@ -34,6 +34,10 @@ include '../../proc32.inc' include '../../dll.inc' include '../../debug-fdo.inc' include '../../develop/libraries/http/http.inc' +include '../../notify.inc' +include '../../string.inc' + +include 'notify.asm' virtual at 0 http_msg http_msg @@ -106,11 +110,11 @@ proc get_file_over_http targeturl, targetfilename .file_error: DEBUGF 1, "file_erroR with eax = %u!", eax - mcall -1 + call EXIT .http_error: DEBUGF 1, "http_erroR!" - mcall -1 + call EXIT .http_transfer_done: ;; Write any remaining bytes from the http buffer into the file @@ -158,7 +162,7 @@ proc make_new_folder newfolder jz .success DEBUGF 1, "Failed to create folder: %s\n", [newfolder] - mcall -1 + call EXIT .success: popa @@ -167,6 +171,7 @@ endp START: mcall 68, 11 ; init heap + call NOTIFY_RUN ; load libraries stdcall dll.Load, @IMPORT @@ -225,6 +230,9 @@ START: ;; current_filename is now set to the name of the file ;; current_url is now set to the name of the file we will get after download DEBUGF 2, "Fetching : %s", current_filename + pusha + call NOTIFY_CHANGE + popa stdcall get_file_over_http, current_url, current_filename DEBUGF 2, "...DONE!\n" jmp .get_next_file @@ -233,12 +241,12 @@ START: DEBUGF 2, "-------------------------\n" DEBUGF 2, "NETSURF INSTALLED. Enjoy!\n" DEBUGF 2, "-------------------------\n" - mcall -1 + call EXIT ;; Inform user that all files are done .all_files_done_error: DEBUGF 1, "FATAL ERROR: FAILED.\n", eax - mcall -1 + call EXIT ;--------------------------------------------------------------------- ; Data area @@ -262,6 +270,10 @@ dirname_res_icons db '/tmp0/1/res/icons', 0 url db 'www.ashmew2.me/',0 +; I don't know why NOTIFY_CHANGE doesn't work for the first file +; so I use this small shit to fix it at NOTIFY_RUN phase +filelist_first db '/tmp0/1/netsurf-kolibrios', 0 + filelist db 'netsurf-kolibrios', 0 db 'netsurf-kolibrios.map', 0 db 'res/adblock.css', 0 @@ -340,4 +352,38 @@ write_to_file dd 3 socketdata rb 4096 current_url rb URLMAXLEN current_filename rb FILENAMEMAXLEN + +;===================================================================== +; NOTIFY DATA +timer dd 0 +params rb 256 +ctrl: + .name rb 32 + .addr rd 1 +rb 2048 + + sz_text: + db "Netsurf installer ", 0 + sz_quote: + db "'", 0 + sz_sec_line_start: + db 10, "Fetching:",10, 0 + sz_flags: + db "Ddcpt", 0 + + sz_final_text: + db "Netsurf installer",10,"Download complete.",10,"Enjoy!",0 + + fi_launch: + dd 7, 0, params, 0, 0 + db "@notify", 0 + +fileopen dd 7 + dd 0 ; flags + dd 0 ; parameters + dd 0 ; reserved + dd 0 ; reserved + db "/tmp0/1/netsurf-kolibrios", 0 ; path +;===================================================================== + I_END: