Added Prerequisites files.
[mplayer-setup-win32.git] / MPUI_Download.nsh
blob67629230924551fd12d196de64a9fe040fbfd297
1 ; ///////////////////////////////////////////////////////////////////////////////
2 ; // MPlayer for Windows - Install Script
3 ; // Copyright (C) 2004-2013 LoRd_MuldeR <MuldeR2@GMX.de>
4 ; //
5 ; // This program is free software; you can redistribute it and/or modify
6 ; // it under the terms of the GNU General Public License as published by
7 ; // the Free Software Foundation; either version 2 of the License, or
8 ; // (at your option) any later version.
9 ; //
10 ; // This program is distributed in the hope that it will be useful,
11 ; // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ; // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 ; // GNU General Public License for more details.
14 ; //
15 ; // You should have received a copy of the GNU General Public License along
16 ; // with this program; if not, write to the Free Software Foundation, Inc.,
17 ; // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 ; //
19 ; // http://www.gnu.org/licenses/gpl-2.0.txt
20 ; ///////////////////////////////////////////////////////////////////////////////
23 !include "LogicLib.nsh"
24 !include "WinMessages.nsh"
25 !include "StdUtils.nsh"
27 !define HWND_TOPMOST -1
29 Var errors
30 Var dl_tmp
32 ; ----------------------------------------------------------------------------
34 !define SetStatus "!insertmacro _SetStatus"
36 !macro _SetStatus text
37         SetDetailsPrint textonly
38         DetailPrint '${text}'
39         SetDetailsPrint listonly
40         Sleep 333
41 !macroend
43 ; ----------------------------------------------------------------------------
45 !define DownloadFile.Get  '!insertmacro _DownloadFile "get" ""'
46 !define DownloadFile.Post '!insertmacro _DownloadFile "post"'
48 !define user_agent "Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20111106 IceCat/7.0.1"
50 !macro _DownloadFile action dl_post status_txt dl_url destfile
51         StrCpy $errors 0
53         ${Do}
54                 ${SetStatus} "${status_txt}"
55                 DetailPrint "$(MPLAYER_LANG_DL_PROGRESS)"
56                 !if "${action}" == "get"
57                         inetc::get /CONNECTTIMEOUT 30 /RECEIVETIMEOUT 30 /CANCELTEXT "$(^CancelBtn)" /USERAGENT "${user_agent}" /SILENT "${dl_url}" "${destfile}" /END
58                 !endif
59                 !if "${action}" == "post"
60                         inetc::post "${dl_post}" /CONNECTTIMEOUT 30 /RECEIVETIMEOUT 30 /CANCELTEXT "$(^CancelBtn)" /USERAGENT "${user_agent}" /CAPTION "${status_txt}" /POPUP "" "${dl_url}" "${destfile}" /END
61                 !endif
62                 Pop $dl_tmp
64                 ${IfThen} "$dl_tmp" == "OK" ${|} ${Break} ${|}
66                 ${If} "$dl_tmp" == "File Open Error"
67                         ${SetStatus} "$(MPLAYER_LANG_DL_FAILED)"
68                         DetailPrint "Error: $dl_tmp"
69                         MessageBox MB_TOPMOST|MB_ICONSTOP "$(MPLAYER_LANG_DL_UPDATE_FAILED)"
70                         Abort "$(MPLAYER_LANG_DL_FAILED)"
71                 ${EndIf}
73                 ${If} "$dl_tmp" == "Cancelled"
74                         ${SetStatus} "$(MPLAYER_LANG_DL_ABORTED)"
75                         DetailPrint "$(MPLAYER_LANG_DL_ERROR): $dl_tmp"
76                         ${IfCmd} MessageBox MB_TOPMOST|MB_RETRYCANCEL|MB_ICONEXCLAMATION "$(MPLAYER_LANG_DL_USER_ABORTED)" IDRETRY ${||} ${Continue} ${|}
77                         MessageBox MB_TOPMOST|MB_ICONSTOP "$(MPLAYER_LANG_DL_UPDATE_FAILED)"
78                         Abort "$(MPLAYER_LANG_DL_FAILED)"
79                 ${EndIf}
81                 IntOp $errors $errors + 3
82                 DetailPrint "$(MPLAYER_LANG_DL_ERROR): $dl_tmp"
84                 ${If} $errors > 5
85                         ${SetStatus} "$(MPLAYER_LANG_DL_FAILED)"
86                         StrCpy $errors 0
87                         ${IfCmd} MessageBox MB_TOPMOST|MB_RETRYCANCEL|MB_ICONEXCLAMATION "$(MPLAYER_LANG_DL_FAILED_MSG) $dl_tmp$\n$(MPLAYER_LANG_DL_RETRY)" IDRETRY ${||} ${Continue} ${|}
88                         MessageBox MB_TOPMOST|MB_ICONSTOP "$(MPLAYER_LANG_DL_UPDATE_FAILED)"
89                         Abort "$(MPLAYER_LANG_DL_FAILED)"
90                 ${Else}
91                         ${SetStatus} "$(MPLAYER_LANG_DL_RESTARTING)"
92                         Sleep 333
93                 ${EndIf}
94         ${Loop}
96         DetailPrint "$(MPLAYER_LANG_DL_SUCCESSFULL)"
97         ${SetStatus} "$(MPLAYER_LANG_DL_COMPELETED)"
98 !macroend