Check online for Updates: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
mNo edit summary
 
(16 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{PageAuthor|Jan}}
== Description ==
== Description ==
Let the installer check for newer versions. This function downloads an XML file and queries it for the program version. Useful scenarios are using it with RSS feeds or PAD files. Work in progress!
Let the installer check for newer versions. This function downloads an XML file and queries it for the program version. Useful scenarios are using it with RSS feeds or PAD files. Work in progress!
Line 4: Line 5:
== Syntax ==
== Syntax ==
<highlight-nsis>
<highlight-nsis>
${UpdateXml} [url] [path] $var
${UpdateXml} "[url]" "[path]" $var


"[url]"      ; URL to an XML file
"[url]"      ; URL to an XML file
Line 19: Line 20:
             ;
             ;
$var        ; result, in the above example "information"
$var        ; result, in the above example "information"
---------------------------------------------------------------
${UpdatePad} "[url]" "[local]" $var
"[url]"      ; URL to a PAD file
"[local]"    ; version of the local file
$var        ; result, in the above example "information"
</highlight-nsis>
</highlight-nsis>


== Example ==
== Examples ==
'''Read version from PAD file (XML)'''
'''Read version from XML'''
<highlight-nsis>
<highlight-nsis>
!include "XML.nsh"
!include "OnlineUpdate.nsh"
  !insertmacro "UpdateXml"
Section
${UpdateXml} "http://198.63.208.118/padinfo/padgen.xml" "/XML_DIZ_INFO/Program_Info/Program_Version" $0
${UpdateXml} "http://198.63.208.118/padinfo/padgen.xml" "/XML_DIZ_INFO/Program_Info/Program_Version" $0
MessageBox MB_OK "The latest version of PADGen is $0"
MessageBox MB_OK "The latest version of PADGen is $0"
SectionEnd
</highlight-nsis>
'''Read version from PAD file (XML) and download if newer'''
<highlight-nsis>
!include "WordFunc.nsh"
  !insertmacro "VersionCompare"
!include "XML.nsh"
!include "OnlineUpdate.nsh"
  !insertmacro "UpdateXml"
!define LocalVersion "1.0"
Section
${UpdatePad} "http://198.63.208.118/padinfo/padgen.xml" "${LocalVersion}" $0 ;
StrCmp $0 "" 0 +2
DetailPrint "Update available at $0"
SectionEnd
</highlight-nsis>
</highlight-nsis>


== Download ==
== Download ==
[http://nsis.sourceforge.net/mediawiki/images/3/39/OnlineUpdate-0.1.zip OnlineUpdate-0.1.zip]
<attach>OnlineUpdate-0.2.zip</attach>
 
Required:<br/>
[[XML plug-in]]<br/>
[[VersionCompare]]
 
 
[[Category:Internet Functions]]

Latest revision as of 20:30, 24 July 2008

Author: Jan (talk, contrib)


Description

Let the installer check for newer versions. This function downloads an XML file and queries it for the program version. Useful scenarios are using it with RSS feeds or PAD files. Work in progress!

Syntax

${UpdateXml} "[url]" "[path]" $var
 
"[url]"      ; URL to an XML file
"[path]"     ; path to the version resource in your XML file
             ;
             ; Example:
             ; <XML>
             ;     <A>
             ;        <B>information</B>
             ;     </A>
             ; </XML>
             ;
             ; -> use "/XML/A/B" as path
             ;
$var         ; result, in the above example "information"
 
---------------------------------------------------------------
 
${UpdatePad} "[url]" "[local]" $var
 
"[url]"      ; URL to a PAD file
"[local]"    ; version of the local file
$var         ; result, in the above example "information"

Examples

Read version from XML

!include "XML.nsh"
!include "OnlineUpdate.nsh"
  !insertmacro "UpdateXml"
 
Section
${UpdateXml} "http://198.63.208.118/padinfo/padgen.xml" "/XML_DIZ_INFO/Program_Info/Program_Version" $0
MessageBox MB_OK "The latest version of PADGen is $0"
SectionEnd

Read version from PAD file (XML) and download if newer

!include "WordFunc.nsh"
  !insertmacro "VersionCompare"
!include "XML.nsh"
!include "OnlineUpdate.nsh"
  !insertmacro "UpdateXml"
 
!define LocalVersion "1.0"
 
Section
${UpdatePad} "http://198.63.208.118/padinfo/padgen.xml" "${LocalVersion}" $0 ;
StrCmp $0 "" 0 +2
DetailPrint "Update available at $0"
SectionEnd

Download

OnlineUpdate-0.2.zip (1 KB)

Required:
XML plug-in
VersionCompare