From 9019886842efaebf3ed7fa640f317026d4886f57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Wed, 31 Dec 2014 15:44:33 +0000 Subject: [PATCH] [DEVELOPMENT ENVIRONMENT] * BUG: Farm software: Fix software list refreshing and upgrade process. The upgrade process still not work flawlessly. git-svn-id: svn://localhost/gambas/trunk@6783 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- .../gambas3/.src/Project/Farm/CSoftware.class | 46 +++++++++++-------- .../gambas3/.src/Project/Farm/FPublish.class | 29 ++++++++++++ .../gambas3/.src/Project/Farm/FPublish.form | 2 +- .../.src/Project/Farm/FSoftwareFarm.class | 26 +++++------ .../.src/Project/Farm/SoftwareBox.class | 15 ++++-- 5 files changed, 83 insertions(+), 35 deletions(-) diff --git a/app/src/gambas3/.src/Project/Farm/CSoftware.class b/app/src/gambas3/.src/Project/Farm/CSoftware.class index 464017aa7..04f4c694b 100644 --- a/app/src/gambas3/.src/Project/Farm/CSoftware.class +++ b/app/src/gambas3/.src/Project/Farm/CSoftware.class @@ -3,6 +3,8 @@ Event Change Event Screenshot +Static Public InstallAge As Integer = 1 + Public Enum STATE_WAIT = 0, STATE_INFO = 1, STATE_ICON = 2, STATE_READY = 3, STATE_ERROR = 4 Public Const ICON_SIZE As Integer = 32 @@ -13,7 +15,6 @@ Public Id As Integer Public Name As String Public Version As String Public Vendor As String -Public InstalledVersion As String Public UploadDate As Date Public Description As String Public URL As String @@ -40,6 +41,9 @@ Private $hRequestIcon As FarmRequest Private $hRequestScreenshot As FarmRequest Private $bGotScreenshot As Boolean +Private $sInstallVersion As String +Private $iInstallVersionAge As Integer + Static Public Sub ClearCache(Optional sFarm As String) If Not sFarm Then @@ -115,8 +119,6 @@ Public Sub Request_Finished() Version = cResult["Version"] & "." & cResult["Release"] Vendor = UnQuote$(cResult["Vendor"]) - GetInstalledVersion() - UploadDate = FarmRequest.GetDate(cResult["UploadDate"]) Description = UnQuote(cResult["Description"]) URL = UnQuote$(cResult["URL"]) @@ -169,23 +171,27 @@ Public Sub GetInstalledDir() As String End -Private Sub GetInstalledVersion() +Public Sub GetInstallVersion() As String Dim sPath As String Dim sLine As String + If Not IsFinished() Then Return + If $iInstallVersionAge >= InstallAge Then Return $sInstallVersion + + $sInstallVersion = "" sPath = GetInstalledDir() &/ ".project" - If Not Exist(sPath) Then - InstalledVersion = "" - Return + If Exist(sPath) Then + For Each sLine In Split(File.Load(sPath), "\n") + If sLine Begins "Version=" Then + $sInstallVersion = Trim(Mid$(sLine, 9)) + Break + Endif + Next Endif - For Each sLine In Split(File.Load(sPath), "\n") - If sLine Begins "Version=" Then - InstalledVersion = Trim(Mid$(sLine, 9)) - Break - Endif - Next + $iInstallVersionAge = InstallAge + Return $sInstallVersion End @@ -234,14 +240,17 @@ End Public Sub IsInstalled() As Boolean - Return InstalledVersion + Return GetInstallVersion() End Public Sub CanUpgrade() As Boolean + + Dim sVersion As String - If Not InstalledVersion Then Return - Return Comp(Version, InstalledVersion, gb.Natural) > 0 + sVersion = GetInstallVersion() + If Not sVersion Then Return + Return Comp(Version, sVersion, gb.Natural) > 0 End @@ -394,6 +403,7 @@ Public Sub Install(Optional bJustDownload As Boolean) As String Endif + Inc InstallAge Start Return @@ -427,7 +437,7 @@ End Public Sub Uninstall() As String - If Not InstalledVersion Then Return + If Not Me.IsInstalled() Then Return Inc Application.Busy Exec ["rm", "-rf", GetInstalledDir()] Wait @@ -435,6 +445,7 @@ Public Sub Uninstall() As String Try Kill Desktop.DataDir &/ "applications" &/ "gambas-" & LCase(Vendor) & "-" & Name & ".desktop" Dec Application.Busy + Inc InstallAge Start Catch @@ -517,4 +528,3 @@ Catch Return Error.Text End - diff --git a/app/src/gambas3/.src/Project/Farm/FPublish.class b/app/src/gambas3/.src/Project/Farm/FPublish.class index 49084919e..3968727a2 100644 --- a/app/src/gambas3/.src/Project/Farm/FPublish.class +++ b/app/src/gambas3/.src/Project/Farm/FPublish.class @@ -8,6 +8,33 @@ Public Sub Run() As Boolean End +Private Sub FillGambasVersion() + + Dim aVersion As String[] + Dim iMajor As Integer + Dim iMajorMax As Integer + Dim iMinorMax As Integer + Dim iMinor As Integer + + aVersion = Split(System.FullVersion, ".") + + iMajorMax = CInt(aVersion[0]) + iMinorMax = CInt(aVersion[1]) + If CInt(aVersion[2]) >= 90 Then Inc iMinorMax + + iMajor = 3 + iMinor = 3 + + Do + + If iMajor > iMajorMax Or If iMinor > iMinorMax Then Break + cmbGambasVersion.Add(CStr(iMajor) & "." & CStr(iMinor)) + Inc iMinor + + Loop + +End + Public Sub Form_Open() Dim aTag As String[] @@ -27,6 +54,8 @@ Public Sub Form_Open() lblProject.Text = Project.Name & " " & Project.FormatVersion() txtVendor.Text = Project.Vendor + + FillGambasVersion cmbGambasVersion.Text = Project.PublishGambasVersion txtURL.Text = Project.PublishWebSite txtDesc.Text = Project.Description diff --git a/app/src/gambas3/.src/Project/Farm/FPublish.form b/app/src/gambas3/.src/Project/Farm/FPublish.form index 39651ddba..94b66bb53 100644 --- a/app/src/gambas3/.src/Project/Farm/FPublish.form +++ b/app/src/gambas3/.src/Project/Farm/FPublish.form @@ -131,7 +131,7 @@ MoveScaled(31,0,11,4) #Translate = False ReadOnly = True - List = ["", "3.3", "3.4", "3.5", "3.6"] + List = Null } { Panel2 Panel MoveScaled(44,1,5,2) diff --git a/app/src/gambas3/.src/Project/Farm/FSoftwareFarm.class b/app/src/gambas3/.src/Project/Farm/FSoftwareFarm.class index 021fca9c5..c2d8dd6c5 100644 --- a/app/src/gambas3/.src/Project/Farm/FSoftwareFarm.class +++ b/app/src/gambas3/.src/Project/Farm/FSoftwareFarm.class @@ -131,7 +131,6 @@ Public Sub Request_Finished() Dim hSoftwareBox As SoftwareBox Dim aId As String[] Dim sText As String - Dim hSoft As CSoftware spnFarm.Hide @@ -148,13 +147,9 @@ Public Sub Request_Finished() aId = Split(hReq.Result["Result"]) For Each sId In aId - If cmbSort.Index = SORT_INSTALLED Then - hSoft = CSoftware.Get(hReq.Farm, CInt(sId)) - If hSoft.IsFinished() And If Not hSoft.IsInstalled() Then Continue - Endif - hSoftwareBox = New SoftwareBox(svwFarm, CInt(sId), hReq.Farm) As "SoftwareBox" hSoftwareBox.ResizeScaled(48, 18) + hSoftwareBox.Load Next @@ -170,13 +165,18 @@ End Public Sub SoftwareBox_Ready() Dim hSoftwareBox As SoftwareBox = Last + Dim hSoft As CSoftware - If cmbSort.Index = SORT_INSTALLED Then - If Not hSoftwareBox.Software.IsInstalled() Then - hSoftwareBox.Delete - Endif - Endif + hSoft = hSoftwareBox.Software + If cmbSort.Index = SORT_INSTALLED And If Not hSoft.IsInstalled() Then Goto DELETE + If hSoft.IsInstalled() And If Comp(hSoft.Version, hSoft.GetInstallVersion(), gb.Natural) < 0 Then Goto DELETE + Return + +DELETE: + + hSoftwareBox.Delete + End @@ -493,10 +493,10 @@ Public Sub btnInstall_Click() If $hSoft.IsInstalled() Then If $hSoft.CanUpgrade() Then - If Message.Question(Subst(("Do you really want to upgrade &1?"), sName), ("Upgrade"), ("Cancel")) = 1 Then + If Message.Question(Subst(("Do you really want to upgrade to &1?"), sName), ("Upgrade"), ("Cancel")) = 1 Then sErr = $hSoft.Install() If sErr Then - Message.Error(Subst(("Unable to upgrade &1:"), sName) & "\n\n" & sErr) + Message.Error(Subst(("Unable to upgrade to &1:"), sName) & "\n\n" & sErr) Else Message(Subst("&1 has been successfully upgraded.", sName)) Goto REFRESH diff --git a/app/src/gambas3/.src/Project/Farm/SoftwareBox.class b/app/src/gambas3/.src/Project/Farm/SoftwareBox.class index d3cf7ceaf..8afbcddc0 100644 --- a/app/src/gambas3/.src/Project/Farm/SoftwareBox.class +++ b/app/src/gambas3/.src/Project/Farm/SoftwareBox.class @@ -64,12 +64,21 @@ Public Sub _new(iId As Integer, sFarm As String) ', sLogin As String, sPassword $hSoft = CSoftware.Get($sFarm, $iId) Object.Attach($hSoft, Me, "Software") - If $hSoft.State <> CSoftware.STATE_READY Then - Reload - Endif End +Public Sub Load() + + If $hSoft.State <> CSoftware.STATE_READY Then + Reload + Else + Raise Ready + Endif + + +End + + Public Sub Software_Change() $hDrawingArea.Refresh