Inetc plug-in: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
 
(41 intermediate revisions by 16 users not shown)
Line 1: Line 1:
{{PageAuthor|Takhir}}
{{PageAuthor|Takhir}}


== Links =={http://filesmy.com/2H968H}
== Links ==


Download:<br>
Download:<br>
<attach>Inetc.zip</attach> (Unicode and ANSI)<br>
<attach>Inetc.zip</attach><br>


[http://forums.winamp.com/showthread.php?threadid=198596 Forum thread]


[http://forums.winamp.com/showthread.php?threadid=198596 Forum thread]
[https://github.com/DigitalMediaServer/NSIS-INetC-plugin/releases INetC fork with custom colors and modern popup]


== Description ==http://bit.ly/fwS7yf=Download Link-
== Description ==


Internet client plug-in for files download and upload. Based on the InetLoad plug-in. Network implementation uses MS WinInet API, supports http/https and ftp protocols. Plugin has better proxy support compared to NSISdl plug-in. Command line may include few URL/File pairs to be transfered. If server or proxy login/password are not set in the script, it displays IE-style authentication dialog (except silent mode). Plug-in supports 3 "transfer in progress" display modes:
Internet client plug-in for files download and upload. Based on the [[InetLoad plug-in]]. Network implementation uses MS WinInet API, supports http/https and ftp protocols. Plugin has better proxy support compared to [[NSISdl plug-in]]. Command line may include few URL/File pairs to be transferred. If server or proxy login/password are not set in the script, it displays IE-style authentication dialog (except silent mode). Plug-in supports 3 "transfer in progress" display modes:


# old NSISdl style - additional embedded progress bar and text on the INSTFILES page;
# old NSISdl style - additional embedded progress bar and text on the INSTFILES page;
Line 17: Line 18:
# BANNER mode with simple popup window.
# BANNER mode with simple popup window.


Plug-in recognizes Installer's Silent mode and this case hides any output (this feature requires NSIS 2.03 or later). Program implements simple re-get functionality - host reconnect and download from current position after short pause. While program depends on IE settings, it changes current IE mode to online. NSISdl code fragment was used for progress bar displaying in the "old style" mode.
Plug-in recognizes Installer's Silent mode and in this case hides any output (this feature requires NSIS 2.03 or later). Program implements simple re-get functionality - host reconnect and download from current position after short pause. While program depends on IE settings, it changes current IE mode to online. NSISdl code fragment was used for progress bar displaying in the "old style" mode.
For ftp use "host/path" for file location relative to user's home dir and  
For ftp use "host/path" for file location relative to user's home dir and "host//path" for absolute path.
"host//path" for absolute path.


== Command line=Download Link=http://bit.ly/fwS7yf
== Commands ==


Plug-in DLL functions (entry points): get, post, head, put
Plug-in DLL functions (entry points): [[#get|get]], [[#post|post]], [[#head|head]], [[#put|put]].


=== get DLL Function ===Download Link=http://bit.ly/fwS7yf
=== get ===


<highlight-nsis>inetc::get [/PROXY IP:PORT] [/USERNAME PROXY_LOGIN /PASSWORD PROXY_PASSWD]
<highlight-nsis>inetc::get [/PROXY IP:PORT] [/USERNAME PROXY_LOGIN /PASSWORD PROXY_PASSWD]
  [/NOPROXY] [/NOCANCEL] [/TIMEOUT INT_MS] [/SILENT] [/CAPTION TEXT]
  [/NOPROXY] [/NOCANCEL] [/CONNECTTIMEOUT TO_SEC] [/RECEIVETIMEOUT TO_SEC] [/SILENT] [/WEAKSECURITY]
[/RESUME RETRY_QUESTION] [/POPUP HOST_ALIAS | /BANNER TEXT] [/CANCELTEXT CANCEL_TEXT]
[/CAPTION TEXT] [/NOCOOKIES] [/RESUME RETRY_QUESTION] [/POPUP HOST_ALIAS | /BANNER TEXT]  
[/QUESTION CANCEL_QUESTION] [/USER_AGENT USER_AGENT_TEXT] [/HEADER HEADER_TEXT]
[/CANCELTEXT CANCEL_TEXT] [/QUESTION CANCEL_QUESTION] [/USERAGENT USER_AGENT_TEXT]  
[/TRANSLATE LANG_PARAMS]
[/HEADER HEADER_TEXT] [/TRANSLATE LANG_PARAMS] [/TOSTACK | /TOSTACKCONV]
  URL1 local_file1 [URL2 local_file2 [...]] [/END]</highlight-nsis>
  URL1 local_file1 [URL2 local_file2 [...]] [/END]</highlight-nsis>
This call returns "OK" string if successful, error description string if failed (see included InetLoad.cpp file for a full set of status strings). Usage and result processing samples are included to the package.
This call returns "OK" string if successful, error description string if failed (see included InetLoad.cpp file for a full set of status strings). Usage and result processing samples are included to the package.
Line 44: Line 44:
: Proxy password (http only).  For server (http/ftp) authentication it is possible to use URL encoded name and password, for example <nowiki>http://username:password@nsis.sourceforge.net</nowiki>.
: Proxy password (http only).  For server (http/ftp) authentication it is possible to use URL encoded name and password, for example <nowiki>http://username:password@nsis.sourceforge.net</nowiki>.


;/NOPROXY
; /NOPROXY
: Disables proxy settings for this connection (if any)
: Disables proxy settings for this connection (if any)


;/NOCANCEL
; /NOCANCEL
: Prevents download from being interrupted by user (locks Esc, Alt-F4, Cancel handling)
: Prevents download from being interrupted by user (locks Esc, Alt-F4, Cancel handling)


; /TIMEOUT
; /CONNECTTIMEOUT -
: Sets INTERNET_OPTION_CONNECT_TIMEOUT, milliseconds, default - IE current parameter value.
:Sets INTERNET_OPTION_CONNECT_TIMEOUT, seconds, default - IE current parameter value.
 
; /RECEIVETIMEOUT -
:Sets INTERNET_OPTION_RECEIVE_TIMEOUT, seconds, default - IE current parameter value.  


; /SILENT
; /SILENT
: Key hides plug-in' output (both popup dialog and embedded progress bar). Not required if 'SilentInstall silent' mode was defined in script (NSIS 2.03 or later).
: Key hides plug-in' output (both popup dialog and embedded progress bar). Not required if 'SilentInstall silent' mode was defined in script (NSIS 2.03 or later).
; /WEAKSECURITY
: Ignore unknown and revoked certificates


; /RESUME
; /RESUME
Line 79: Line 85:
; /HEADER
; /HEADER
: Adds or replaces http request header. Common HEADER_TEXT format is "header: value".  
: Adds or replaces http request header. Common HEADER_TEXT format is "header: value".  
; /NOCOOKIES
: Removes cookies from http request
; /TOSTACK
: Outputs the post/get/head response to the NSIS stack rather than to the file (specify an empty string for local_file1, local_file2 etc.)
; /TOSTACKCONV
: Outputs the post/get/head response to the NSIS stack while converting character encodings:
: ASCII -> Unicode for the Unicode plug-in build
: Unicode -> ASCII for the ASCII plug-in build


; /END
; /END
Line 86: Line 103:
: Allows translating plug-in text in the POPUP or "old style" (NSISdl) modes (see Readme for parameters). In the BANNER mode text is also customizable.
: Allows translating plug-in text in the POPUP or "old style" (NSISdl) modes (see Readme for parameters). In the BANNER mode text is also customizable.


=== post DLL Function ===
=== post ===


<highlight-nsis>inetc::post TEXT2POST [/PROXY IP:PORT] [/USERNAME PROXY_LOGIN  /PASSWORD PROXY_PASSWD]
<highlight-nsis>inetc::post TEXT2POST [/PROXY IP:PORT] [/USERNAME PROXY_LOGIN  /PASSWORD PROXY_PASSWD]
  [/NOPROXY] [/NOCANCEL] [/TIMEOUT INT_MS] [/SILENT] [/FILE]  
  [/NOPROXY] [/NOCANCEL] [/CONNECTTIMEOUT TO_SEC]  [/RECEIVETIMEOUT TO_SEC] [/SILENT] [/WEAKSECURITY]
  [/CAPTION TEXT] [/POPUP HOST_ALIAS | /BANNER TEXT] [/CANCELTEXT CANCEL_TEXT]
  [/FILE] [/CAPTION TEXT] [/NOCOOKIES] [/POPUP HOST_ALIAS | /BANNER TEXT]
[/USER_AGENT USER_AGENT_TEXT] [/TRANSLATE LANG_PARAMS]
[/CANCELTEXT CANCEL_TEXT] [/USERAGENT USER_AGENT_TEXT] [/TRANSLATE LANG_PARAMS]
[/TOSTACK | /TOSTACKCONV]
  URL1 local_file1 [URL2 local_file2 [...]] [/END]</highlight-nsis>
  URL1 local_file1 [URL2 local_file2 [...]] [/END]</highlight-nsis>
Sets POST http mode and defines text string or file name to be used in the POST (http only). Disables auto re-get. No char replaces used (%20 and others). /FILE option allows to send TEXT2POST file content to server, additional 'Filename:' header added to request this case.  
Sets POST http mode and defines text string or file name to be used in the POST (http only). Disables auto re-get. No char replaces used (%20 and others). /FILE option allows to send TEXT2POST file content to server, an additional 'Filename:' header is added to request in this case.


=== head DLL Function ===Download Link=http://bit.ly/fwS7yf
=== head ===


The same as get, but requests http headers only. Writes raw headers to file.
The same as get, but requests http headers only. Writes raw headers to file.


=== put DLL Function ===
=== put ===


<highlight-nsis>inetc::put [/PROXY IP:PORT] [/USERNAME PROXY_LOGIN /PASSWORD PROXY_PASSWD] [/NOPROXY]
<highlight-nsis>inetc::put [/PROXY IP:PORT] [/USERNAME PROXY_LOGIN /PASSWORD PROXY_PASSWD] [/NOPROXY]
  [/NOCANCEL] [/TIMEOUT INT_MS] [/SILENT] [/CAPTION TEXT] [/POPUP HOST_ALIAS | /BANNER TEXT]  
  [/NOCANCEL] [/CONNECTTIMEOUT TO_SEC]  [/RECEIVETIMEOUT TO_SEC] [/SILENT] [/WEAKSECURITY] [/CAPTION TEXT]
[/CANCELTEXT CANCEL_TEXT] [/USER_AGENT USER_AGENT_TEXT] [/TRANSLATE LANG_PARAMS]
[/POPUP HOST_ALIAS | /BANNER TEXT] [/CANCELTEXT CANCEL_TEXT] [/USERAGENT USER_AGENT_TEXT]
[/TRANSLATE LANG_PARAMS] [/NOCOOKIES]
  URL1 local_file1 [URL2 local_file2 [...]] [/END]</highlight-nsis>
  URL1 local_file1 [URL2 local_file2 [...]] [/END]</highlight-nsis>
Return value and parameters (if applicable) are the same as for previous entry point.
Return value and parameters (if applicable) are the same as for previous entry point.


== Examples ==Download Link=http://bit.ly/fwS7yf
== Examples ==


<highlight-nsis>
<highlight-nsis>
inetc::get "http://dl.zvuki.ru/6306/mp3/12.mp3" "$EXEDIR\12.mp3" \
inetc::put "http://dl.zvuki.ru/6306/mp3/12.mp3" "$EXEDIR\12.mp3" \
               "ftp://dl.zvuki.ru/6306/mp3/11.mp3" "$EXEDIR\11.mp3"
               "ftp://dl.zvuki.ru/6306/mp3/11.mp3" "$EXEDIR\11.mp3" /END
Pop $0
Pop $0
</highlight-nsis>
</highlight-nsis>
Line 118: Line 137:
inetc::put /BANNER "Cameron Diaz upload in progress..." \
inetc::put /BANNER "Cameron Diaz upload in progress..." \
"http://www.dreamgirlswallpaper.co.uk/fiveyearsonline/wallpaper/Cameron_Diaz/camerond09big.JPG" \
"http://www.dreamgirlswallpaper.co.uk/fiveyearsonline/wallpaper/Cameron_Diaz/camerond09big.JPG" \
"$EXEDIR\cd.jpg"
"$EXEDIR\cd.jpg" /END
   Pop $0
   Pop $0
   StrCmp $0 "OK" dlok
   StrCmp $0 "OK" dlok
Line 128: Line 147:


<highlight-nsis>
<highlight-nsis>
;installer window restoring after silent calls from .onGUIInit
; Following attribute also can restore installer Window
;by Edward Marshall & Jonathan Beddoes
; BGGradient 000000 000080 FFFFFF
;temporarily makes the installer window topmost so that inetc doesn't drop our focus
</highlight-nsis>
== Credits ==


Function .onGUIInit
Many thanks to Backland who offered a simple way to fix NSISdl mode crashes, added 'center parent' function, offers few nice design ideas and spent a lot of time testing the plug-in.


  ; Get window handle of installer into register 0.
* v1.0.4.4 by Stuart '[[User:Afrow UK|Afrow UK]]' Welch
  ; This only works in onGUIInit! (so you still can't silently call inetc from onInit)
* v1.0.5.0..v1.0.5.3 by [[User:Anders|Anders]]
  StrCpy $0 $HWNDPARENT


  ; Make window always-on-top. Yes, this is bad but we are only doing it temporarily!
See Contrib\inetc\inetc.cpp for changes.
  ; This prevents inetc's hidden dialog from getting foreground precedence over the installer.
  ; This must be done before any inetc calls.
  ; -1 = HWND_TOPMOST, 3 = SWP_NOSIZE|SWP_NOMOVE
  System::Call "user32::SetWindowPos(i r0, i -1, i 0, i 0, i 0, i 0, i 3)"
 
  ; Now do whatever you want with inetc.
  inetc::head /silent "http://ineum.narod.ru/spr_2006.htm" "$EXEDIR\head.txt"
 
  ; Now set the installer window back to normal (not always-on-top).
  ; -2 = HWND_NOTOPMOST, 3 = SWP_NOSIZE|SWP_NOMOVE
  System::Call "user32::SetWindowPos(i r0, i -2, i 0, i 0, i 0, i 0, i 3)"
 
FunctionEnd
</highlight-nsis>
<highlight-nsis>
; Following attribute also can restore installer Window
; BGGradient 000000 000080 FFFFFF
</highlight-nsis>
== Credits ==Download Link=http://bit.ly/fwS7yf


Many thanks to Backland who offered a simple way to fix NSISdl mode crashes, added 'center parent' function, offers few nice design ideas and spent a lot of time testing the plug-in.


[[Category:Plugins]]
[[Category:Plugins]]

Latest revision as of 23:25, 1 October 2018

Author: Takhir (talk, contrib)


Links

Download:
Inetc.zip (81 KB)

Forum thread

INetC fork with custom colors and modern popup

Description

Internet client plug-in for files download and upload. Based on the InetLoad plug-in. Network implementation uses MS WinInet API, supports http/https and ftp protocols. Plugin has better proxy support compared to NSISdl plug-in. Command line may include few URL/File pairs to be transferred. If server or proxy login/password are not set in the script, it displays IE-style authentication dialog (except silent mode). Plug-in supports 3 "transfer in progress" display modes:

  1. old NSISdl style - additional embedded progress bar and text on the INSTFILES page;
  2. POPUP dialog mode with detailed info;
  3. BANNER mode with simple popup window.

Plug-in recognizes Installer's Silent mode and in this case hides any output (this feature requires NSIS 2.03 or later). Program implements simple re-get functionality - host reconnect and download from current position after short pause. While program depends on IE settings, it changes current IE mode to online. NSISdl code fragment was used for progress bar displaying in the "old style" mode. For ftp use "host/path" for file location relative to user's home dir and "host//path" for absolute path.

Commands

Plug-in DLL functions (entry points): get, post, head, put.

get

inetc::get [/PROXY IP:PORT] [/USERNAME PROXY_LOGIN /PASSWORD PROXY_PASSWD]
 [/NOPROXY] [/NOCANCEL] [/CONNECTTIMEOUT TO_SEC] [/RECEIVETIMEOUT TO_SEC] [/SILENT] [/WEAKSECURITY]
 [/CAPTION TEXT] [/NOCOOKIES] [/RESUME RETRY_QUESTION] [/POPUP HOST_ALIAS | /BANNER TEXT] 
 [/CANCELTEXT CANCEL_TEXT] [/QUESTION CANCEL_QUESTION] [/USERAGENT USER_AGENT_TEXT] 
 [/HEADER HEADER_TEXT] [/TRANSLATE LANG_PARAMS] [/TOSTACK | /TOSTACKCONV]
 URL1 local_file1 [URL2 local_file2 [...]] [/END]

This call returns "OK" string if successful, error description string if failed (see included InetLoad.cpp file for a full set of status strings). Usage and result processing samples are included to the package.

/PROXY
Overwrites current proxy settings, not required in most cases. IE settings will be used by default.
/USERNAME
Proxy username (http only).
/PASSWORD
Proxy password (http only). For server (http/ftp) authentication it is possible to use URL encoded name and password, for example http://username:password@nsis.sourceforge.net.
/NOPROXY
Disables proxy settings for this connection (if any)
/NOCANCEL
Prevents download from being interrupted by user (locks Esc, Alt-F4, Cancel handling)
/CONNECTTIMEOUT -
Sets INTERNET_OPTION_CONNECT_TIMEOUT, seconds, default - IE current parameter value.
/RECEIVETIMEOUT -
Sets INTERNET_OPTION_RECEIVE_TIMEOUT, seconds, default - IE current parameter value.
/SILENT
Key hides plug-in' output (both popup dialog and embedded progress bar). Not required if 'SilentInstall silent' mode was defined in script (NSIS 2.03 or later).
/WEAKSECURITY
Ignore unknown and revoked certificates
/RESUME
On the permanent connection/transfer error instead of exit first displays message box with "resume download" question. Useful for dial-up connections and big files - allows user to restore connection and resume download. Default is "Your internet connection seems to have dropped out!\nPlease reconnect and click Retry to resume downloading...".
/CAPTION
Defines caption text for /BANNER mode, caption prefix (left of '-') for /POPUP mode and caption for RESUME MessageBox. Default is "InetLoad plug-in" if not set or "".
/POPUP
This mode displays detailed download dialog instead of embedded progress bar. Also useful in .onInit function (i.e. not in Section). If HOST_ALIAS is not "", text will replace URL in the dialog - this allows to hide real URL (including password).
/BANNER
Displays simple popup dialog (MSI Banner mode) and sets dialog TEXT (up to 3 lines using $\n).
/CANCELTEXT
Text for the Cancel button in the NSISdl mode. Default is NSIS dialog Cancel button text (current lang).
/QUESTION
Text for the optional MessageBox if user tries to cancel download. If /QUESTION "" was used default "Are you sure that you want to stop download?" will be substituted.
/USERAGENT
UserAgent http request header value. Default is "NSIS_Inetc (Mozilla)".
/HEADER
Adds or replaces http request header. Common HEADER_TEXT format is "header: value".
/NOCOOKIES
Removes cookies from http request
/TOSTACK
Outputs the post/get/head response to the NSIS stack rather than to the file (specify an empty string for local_file1, local_file2 etc.)
/TOSTACKCONV
Outputs the post/get/head response to the NSIS stack while converting character encodings:
ASCII -> Unicode for the Unicode plug-in build
Unicode -> ASCII for the ASCII plug-in build
/END
Allows to limit plug-in stack reading (optional, required if you stores other vars in the stack).
/TRANSLATE
Allows translating plug-in text in the POPUP or "old style" (NSISdl) modes (see Readme for parameters). In the BANNER mode text is also customizable.

post

inetc::post TEXT2POST [/PROXY IP:PORT] [/USERNAME PROXY_LOGIN  /PASSWORD PROXY_PASSWD]
 [/NOPROXY] [/NOCANCEL] [/CONNECTTIMEOUT TO_SEC]  [/RECEIVETIMEOUT TO_SEC] [/SILENT] [/WEAKSECURITY]
 [/FILE] [/CAPTION TEXT] [/NOCOOKIES] [/POPUP HOST_ALIAS | /BANNER TEXT]
 [/CANCELTEXT CANCEL_TEXT] [/USERAGENT USER_AGENT_TEXT] [/TRANSLATE LANG_PARAMS]
 [/TOSTACK | /TOSTACKCONV]
 URL1 local_file1 [URL2 local_file2 [...]] [/END]

Sets POST http mode and defines text string or file name to be used in the POST (http only). Disables auto re-get. No char replaces used (%20 and others). /FILE option allows to send TEXT2POST file content to server, an additional 'Filename:' header is added to request in this case.

head

The same as get, but requests http headers only. Writes raw headers to file.

put

inetc::put [/PROXY IP:PORT] [/USERNAME PROXY_LOGIN /PASSWORD PROXY_PASSWD] [/NOPROXY]
 [/NOCANCEL] [/CONNECTTIMEOUT TO_SEC]  [/RECEIVETIMEOUT TO_SEC] [/SILENT] [/WEAKSECURITY] [/CAPTION TEXT]
 [/POPUP HOST_ALIAS | /BANNER TEXT] [/CANCELTEXT CANCEL_TEXT] [/USERAGENT USER_AGENT_TEXT]
 [/TRANSLATE LANG_PARAMS] [/NOCOOKIES]
 URL1 local_file1 [URL2 local_file2 [...]] [/END]

Return value and parameters (if applicable) are the same as for previous entry point.

Examples

inetc::put "http://dl.zvuki.ru/6306/mp3/12.mp3" "$EXEDIR\12.mp3" \
               "ftp://dl.zvuki.ru/6306/mp3/11.mp3" "$EXEDIR\11.mp3" /END
Pop $0
inetc::put /BANNER "Cameron Diaz upload in progress..." \
"http://www.dreamgirlswallpaper.co.uk/fiveyearsonline/wallpaper/Cameron_Diaz/camerond09big.JPG" \
"$EXEDIR\cd.jpg" /END
  Pop $0
  StrCmp $0 "OK" dlok
  MessageBox MB_OK|MB_ICONEXCLAMATION "http upload Error, click OK to abort installation" /SD IDOK
  Abort
dlok:
  ...
; Following attribute also can restore installer Window
; BGGradient 000000 000080 FFFFFF

Credits

Many thanks to Backland who offered a simple way to fix NSISdl mode crashes, added 'center parent' function, offers few nice design ideas and spent a lot of time testing the plug-in.

See Contrib\inetc\inetc.cpp for changes.