Merge branch 'nowget' into 'master'

Replace wget with HttpClient

See merge request gambas/gambas!31
This commit is contained in:
Benoît Minisini 2018-08-23 18:04:02 +00:00
commit 60058fd9a5
2 changed files with 12 additions and 28 deletions

View file

@ -12,7 +12,7 @@ Public Const TYPE_SPECIAL As Integer = 6
Public Const TYPE_COMPONENT As Integer = 7
Public Const TYPE_FILE As Integer = 8
Public Enum OFFLINE_NO_NETWORK, OFFLINE_NOT_AVAILABLE, OFFLINE_UP_TO_DATE, OFFLINE_NEW_AVAILABLE, OFFLINE_NO_WGET
Public Enum OFFLINE_NO_NETWORK, OFFLINE_NOT_AVAILABLE, OFFLINE_UP_TO_DATE, OFFLINE_NEW_AVAILABLE
Public $PopupHelpCache As Collection
@ -865,13 +865,9 @@ Public Sub GetOfflineState() As Integer
Dim sDate As String
If Not Desktop.NetworkAvailable Then Return OFFLINE_NO_NETWORK
If Not System.Exist("wget") Then Return OFFLINE_NO_WGET
Inc Application.Busy
Exec ["wget", "-q", "-O", "-", "http://gambaswiki.org/timestamp"] To sTimestamp
sTimestamp = HttpClient.Download("http://gambaswiki.org/timestamp")
Dec Application.Busy
sTimestamp = Trim(sTimestamp)

View file

@ -1183,6 +1183,7 @@ End
Public Sub btnDownloadHelp_Click()
Dim hClient As HttpClient
Dim sMsg As String
Dim sFile As String
Dim sDir As String
@ -1191,22 +1192,9 @@ Public Sub btnDownloadHelp_Click()
Inc Application.Busy
sMsg = Project.RequireProgram(["wget", "tar"])
sMsg = Project.RequireProgram(["tar"])
If sMsg Then Goto FAIL
' Exec ["wget", "-q", "-O", "-", "http://gambaswiki.org/timestamp"] To sTimestamp
' sTimestamp = Trim(sTimestamp)
' If Not sTimestamp Then
' sMsg = ("The documentation is not available at the moment. Try again later.")
' Goto FAIL
' Endif
'
' Try dDate = Stat(MHelp.GetOfflineDir()).LastModified
' If dDate And If Format(dDate, "yyyymmdd") >= sTimestamp Then
' sMsg = ("The documentation is up to date.")
' Goto FAIL
' Endif
sDir = MHelp.GetOfflineDir()
sParentDir = File.Dir(sDir)
@ -1214,9 +1202,14 @@ Public Sub btnDownloadHelp_Click()
sFile = sParentDir &/ "wiki.tar.bz2"
Try Kill sFile
Exec ["wget", "-q", "-O", "-", "http://gambaswiki.org/timestamp"] To sTimestamp
Exec ["wget", "-q", "-O", sFile, "http://gambaswiki.org/gambas-wiki.tar.bz2"] Wait
sTimestamp = HttpClient.Download("http://gambaswiki.org/timestamp")
hClient = New HttpClient As "hClient"
hClient.Async = False
hClient.Timeout = 20
hClient.URL = "http://gambaswiki.org/gambas-wiki.tar.bz2"
hClient.Get([], sFile)
If Not Exist(sFile) Then
sMsg = ("Unable to download documentation.")
Goto FAIL
@ -1271,11 +1264,6 @@ Private Sub UpdateDocumentationState()
lblDocumentation.Foreground = Color.Foreground
btnDownloadHelp.Enabled = False
Case MHelp.OFFLINE_NO_WGET
lblDocumentation.Text = ("'wget' is not found.")
lblDocumentation.Foreground = Color.Foreground
btnDownloadHelp.Enabled = False
Case MHelp.OFFLINE_NEW_AVAILABLE
lblDocumentation.Text = ("A new documentation is available!")
lblDocumentation.Foreground = Color.Red