[DEVELOPMENT ENVIRONMENT]

* NEW: Move the farm servers configuration from the option dialog to its 
  own dialog.
* NEW: The farm servers configuration is accessible from the farm software
  window and from the publishing dialog.
* NEW: Once identified, you can now vote for a software, or remove your 
  vote, by clicking on the star button.
* OPT: Information on farm softwares is cached as much as possible.
* NEW: Add the 'blues' color theme made by Kevin Fishburne.

[FARM SERVER]
* NEW: A ping request.
* BUG: Voting for a software now correctly update the total vote count.

[GB.SETTINGS]
* BUG: Erasing a settings is correctly saved in all cases now.


git-svn-id: svn://localhost/gambas/trunk@6672 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2014-11-24 02:10:00 +00:00
parent a607aaec6f
commit ea4d04ae83
23 changed files with 765 additions and 319 deletions

View file

@ -80,6 +80,10 @@ Public Sub Main()
CheckIdent
Case "/ping"
PrintOK
' Case "/test"
'
' Response.ContentType = "text/plain;charset=utf-8"
@ -653,6 +657,7 @@ Private Sub VoteSoftware()
Dim rSoftware As Result
Dim rVote As Result
Dim iId As Integer
OpenDatabase
@ -660,16 +665,28 @@ Private Sub VoteSoftware()
rSoftware = FindSoftware()
If Not rSoftware Then Return
iId = rSoftware!id
If Request.Exist("clear") Then
Try DB.Delete("vote", "software = &1 AND user = &2", rSoftware!id, $iUser)
Else
rVote = DB.Create("vote")
rVote!software = rSoftware!id
rVote!user = $iUser
Try rVote.Update
Endif
DB.Begin
Select Case Request["vote"]
Case "0"
Try DB.Delete("vote", "software = &1 AND \"user\" = &2", iId, $iUser)
Case Else
rVote = DB.Create("vote")
rVote!software = rSoftware!id
rVote!user = $iUser
Try rVote.Update
End Select
rVote = DB.Exec("SELECT COUNT(*) FROM vote WHERE software = &1", iId)
rSoftware = DB.Edit("software", "id = &1", iId)
rSoftware!vote = rVote[0]
rSoftware.Update
DB.Commit
PrintOK
End
@ -698,8 +715,13 @@ Private Sub SearchSoftware()
aTag = New Integer[]
For Each sTag In Split(Request["tags"])
rTag = DB.Find("name", "cname = &1", Lower(sTag))
If rTag.Available And If Not aTag.Exist(rTag!id) Then aTag.Add(rTag!id)
rTag = DB.Find("name", "cname = &1", Lower(sTag))
If rTag.Available Then
iTag = rTag!id
Else
iTag = -1
Endif
If Not aTag.Exist(rTag!id) Then aTag.Add(rTag!id)
Next
sFilter = String.LCase(Request["filter"])

View file

@ -36,13 +36,6 @@
}
{ Menu5 Menu
}
{ mnuFarm Menu
Action = "software-farm"
Text = ("Software farm") & "..."
Picture = Picture["icon:/small/book"]
}
{ Menu33 Menu
}
{ mnuSave Menu
Action = "save-project"
Text = Shortcut(("Save project"), "S")
@ -419,6 +412,13 @@
}
{ Menu20 Menu
}
{ mnuFarm Menu
Action = "software-farm"
Text = ("Software farm") & "..."
Picture = Picture["icon:/small/book"]
}
{ Menu33 Menu
}
{ mnuShortcut Menu
Action = "shortcut"
Text = Shortcut(("Shortcuts"), "S") & "..."

View file

@ -1,7 +1,7 @@
' Gambas class file
Static Private $aTheme As String[] = ["amethyst", "amber", "emerald", "gambas", "ruby", "sapphire", "visual", "obsidian", "quest", "quick"]
Static Private $aThemeName As String[] = [("Amethyst"), ("Amber"), ("Emerald"), ("Gambas"), ("Ruby"), ("Sapphire"), ("Visual"), ("Obsidian"), ("Quest"), ("Quick")]
Static Private $aTheme As String[] = ["amethyst", "amber", "emerald", "gambas", "ruby", "sapphire", "visual", "obsidian", "quest", "quick", "blues"]
Static Private $aThemeName As String[] = [("Amethyst"), ("Amber"), ("Emerald"), ("Gambas"), ("Ruby"), ("Sapphire"), ("Visual"), ("Obsidian"), ("Quest"), ("Quick"), ("Blues")]
Static Private $aBrowser As String[] = ["konqueror", "rekonq", "firefox", "iceweasel", "epiphany", "seamonkey", "opera", "chromium"]
Static Private $aTerminal As String[] = ["konsole", "gnome-terminal", "Terminal", "lxterminal", "xterm"]
'Static Private $aImageEditor As String[] = ["gimp", "kolourpaint", "krita"]
@ -138,7 +138,6 @@ Public Sub _new()
cmbBrowser.Index = $aBrowser.Find(Settings["/Browser"]) + 1
cmbTerminal.Index = $aTerminal.Find(Settings["/Terminal"]) + 1
panDownloadHelp.Visible = btnOfflineHelp.Value
lstFarm.List = Settings["/Publish/FarmList"]
UpdateFont(txtGlobalFont.Value)
@ -1278,65 +1277,6 @@ Private Sub UpdateDocumentationState()
End
Public Sub lstFarm_Select()
If lstFarm.Text Then
txtFarm.Text = lstFarm.Text
panRegister.Enabled = True
Else
txtFarm.Clear
panRegister.Enabled = False
Endif
End
Public Sub lstFarm_Change()
Settings["/Publish/FarmList"] = lstFarm.List
lstFarm_Select
End
Public Sub btnRegister_Click()
Dim sLogin As String
Dim sPassword As String
Dim sConfirmPassword As String
Dim sEmail As String
Dim hReq As FarmRequest
sLogin = Trim(txtLogin.Text)
If Not sLogin Then
Balloon.Error(("Please enter your login."), txtLogin)
Return
Endif
sPassword = Trim(txtPassword.Text)
If Not sPassword Then
Balloon.Error(("Please enter your password."), txtPassword)
Return
Endif
sConfirmPassword = Trim(txtConfirmPassword.Text)
If sPassword <> sConfirmPassword Then
Balloon.Error(("Confirm password does not match."), txtConfirmPassword)
Return
Endif
sEmail = Trim$(txtMail.Text)
If Not sEmail Or If InStr(sEmail, "@") = 0 Then
ipnOption.Index = 0
Balloon.Error(("Please enter a valid e-mail address."), txtMail)
Return
Endif
hReq = New FarmRequest(lstFarm.Text)
hReq.RegisterUser(sLogin, sPassword, Trim(txtName.Text), sEmail)
hReq.WaitFor(("You have been successfully registered.\n\nYou will receive a confirmation e-mail soon."), ("Unable to register user."))
End
Public Sub Form_Close()
Settings.Save

View file

@ -34,7 +34,7 @@
Arrangement = Arrange.Vertical
Spacing = True
Margin = True
Count = 10
Count = 9
Index = 0
Text = ("Identity")
Picture = Picture["icon:/large/identity"]
@ -941,96 +941,6 @@
}
}
}
Index = 9
Text = ("Publishing")
Picture = Picture["icon:/large/internet"]
{ Label33 Label
MoveScaled(1,1,29,3)
Font = Font["Bold"]
Text = ("Publishing servers")
}
{ lstFarm ListEditor
MoveScaled(1,5,62,21)
Expand = True
}
{ panRegister Panel
MoveScaled(1,31,65,40)
Enabled = False
Arrangement = Arrange.Vertical
Spacing = True
Margin = True
Border = Border.Plain
{ HBox52 HBox
MoveScaled(1,2,62,4)
Spacing = True
{ Label35 Label
MoveScaled(0,0,27,4)
Text = ("Register on")
}
{ txtFarm TextBox
MoveScaled(33,0,24,4)
Expand = True
ReadOnly = True
}
}
{ HBox35 HBox
MoveScaled(1,7,62,4)
Spacing = True
{ Label36 Label
MoveScaled(0,0,27,4)
Text = ("Login")
}
{ txtLogin TextBox
MoveScaled(33,0,24,4)
Expand = True
}
}
{ HBox36 HBox
MoveScaled(1,12,63,4)
Spacing = True
{ Label62 Label
MoveScaled(0,0,27,4)
Text = ("Password")
}
{ txtPassword TextBox
MoveScaled(33,0,24,4)
Expand = True
Password = True
}
}
{ HBox38 HBox
MoveScaled(1,17,62,4)
Spacing = True
{ Label64 Label
MoveScaled(0,0,27,4)
Text = ("Confirm password")
}
{ txtConfirmPassword TextBox
MoveScaled(32,0,24,4)
Expand = True
Password = True
}
}
{ HBox51 HBox
MoveScaled(1,22,62,4)
Spacing = True
{ Label65 Label
MoveScaled(0,0,27,3)
}
{ btnRegister Button
MoveScaled(33,0,23,4)
Text = ("Register") & "..."
Picture = Picture["icon:/small/identity"]
}
}
{ TextLabel1 TextLabel
MoveScaled(1,27,63,12)
Font = Font["Italic"]
Expand = True
Text = ("A confirmation mail will be sent to the e-mail address specified in the <b>Identity</b> panel. Click on the link included in that mail to activate your account.\n<p>\n<b>Your e-mail will not be stored on the publishing server.</b>")
Alignment = Align.Normal
}
}
Index = 0
}
}

View file

@ -2,7 +2,7 @@
Event Change
Public Enum STATE_WAIT, STATE_WAIT_ICON, STATE_WAIT_BACKGROUND, STATE_READY, STATE_ERROR
Public Enum STATE_WAIT_INFO, STATE_WAIT_ICON, STATE_WAIT_BACKGROUND, STATE_READY, STATE_ERROR
Public Const ICON_SIZE As Integer = 32
Public State As Integer
@ -17,7 +17,7 @@ Public Checksum As String
Public Owner As String
Public DownloadCount As Integer
Public VoteCount As Integer
Public YourVote As Boolean
Public YourVote As Integer
Public Icon As Image
Public Background As Image
Public Tags As String[]
@ -25,6 +25,8 @@ Public Tags As String[]
Public ErrorText As String
Private $sFarm As String
Private $hRequest As FarmRequest
Private $hRequestIcon As FarmRequest
Public Sub _new(iId As Integer, sFarm As String) ', sLogin As String, sPassword As String)
@ -34,14 +36,16 @@ Public Sub _new(iId As Integer, sFarm As String) ', sLogin As String, sPassword
End
Public Sub Start()
Dim hRequest As FarmRequest
hRequest = New FarmRequest($sFarm) As "Request"
hRequest.GetSoftware(Id)
Try $hRequest.Abort
$hRequest = New FarmRequest($sFarm) As "Request"
$hRequest.GetSoftware(Id)
hRequest = New FarmRequest($sFarm) As "Request"
hRequest.GetSoftwareIcon(Id)
Try $hRequestIcon.Abort
$hRequestIcon = New FarmRequest($sFarm) As "Request"
$hRequestIcon.GetSoftwareIcon(Id)
State = STATE_WAIT_INFO
End
@ -76,7 +80,11 @@ WAIT_INFO:
Try DownloadCount = CInt(cResult["DownloadCount"])
Try VoteCount = CInt(cResult["VoteCount"])
Owner = UnQuote(cResult["Owner"])
YourVote = cResult["YourVote"] <> "0"
If cResult.Exist("YourVote") Then
YourVote = cResult["YourVote"]
Else
YourVote = -1
Endif
Tags = Split(cResult["Tags"])
State = STATE_WAIT_ICON

View file

@ -0,0 +1,149 @@
' Gambas class file
Private $hIdentity As FarmIdentity
Private $sFarm As String
Public Sub Run(sFarm As String)
$sFarm = sFarm
Me.ShowModal
End
Public Sub Form_Open()
lstFarm.List = FarmIdentity.FarmList
cmbFarm.List = FarmRequest.GetFarms()
cmbFarm.Text = $sFarm
chkRememberPassword.Value = FarmIdentity.RememberPassword
End
Public Sub lstFarm_Change()
FarmIdentity.FarmList = lstFarm.List
cmbFarm.List = FarmRequest.GetFarms()
End
Public Sub btnShowRegister_Click()
Dim sLogin As String
Dim sPassword As String
sLogin = Trim(txtLogin.Text)
If Not sLogin Then
btnCancel_Click
Balloon.Error(("Please enter your login."), txtLogin)
Return
Endif
sPassword = Trim(txtPassword.Text)
If Not sPassword Then
btnCancel_Click
Balloon.Error(("Please enter your password."), txtPassword)
Return
Endif
panIdentity.Hide
panRegister.Show
End
Public Sub btnCancel_Click()
panIdentity.Show
panRegister.Hide
End
Public Sub btnClose_Click()
Dim hReq As FarmRequest
If Trim(txtLogin.Text) Then
hReq = New FarmRequest(cmbFarm.Text)
hReq.CheckAuth(Trim(txtLogin.Text), txtPassword.Text)
If hReq.WaitFor("", "", True) Then
Message.Error(("Authentication failed."))
Return
Endif
Endif
Me.Close
End
Public Sub btnRegister_Click()
Dim sLogin As String
Dim sPassword As String
Dim sConfirmPassword As String
Dim sEmail As String
Dim hReq As FarmRequest
sLogin = Trim(txtLogin.Text)
sPassword = Trim(txtPassword.Text)
sEmail = Trim$(txtMail.Text)
If Not sEmail Or If InStr(sEmail, "@") = 0 Then
Balloon.Error(("Please enter a valid e-mail address."), txtMail)
Return
Endif
sConfirmPassword = Trim(txtConfirmPassword.Text)
If sPassword <> sConfirmPassword Then
Balloon.Error(("Confirm password does not match."), txtConfirmPassword)
Return
Endif
hReq = New FarmRequest(lstFarm.Text)
hReq.RegisterUser(sLogin, sPassword, sEmail)
If Not hReq.WaitFor(("You have been successfully registered.\n\nYou will receive a confirmation e-mail soon."), ("Unable to register user.")) Then
btnCancel_Click
Endif
End
Public Sub cmbFarm_Click()
$hIdentity = New FarmIdentity(cmbFarm.Text)
txtLogin.Text = $hIdentity.Login
txtPassword.Text = $hIdentity.Password
End
Public Sub txtLogin_LostFocus()
$hIdentity.Login = Trim(txtLogin.Text)
End
Public Sub txtPassword_LostFocus()
$hIdentity.Password = txtPassword.Text
End
Public Sub Form_Close()
Settings["/Farm"] = cmbFarm.Text
FarmIdentity.RememberPassword = CBool(chkRememberPassword.Value)
FarmIdentity.SaveSettings
End
Public Sub txtLogin_Activate()
txtPassword.SetFocus
End
Public Sub txtPassword_Activate()
btnClose.Value = True
End

View file

@ -0,0 +1,158 @@
# Gambas Form File 3.0
{ Form Form
MoveScaled(0,0,63,35)
Text = ("Configuration")
Arrangement = Arrange.Vertical
Spacing = True
Margin = True
{ tabConfig TabPanel
MoveScaled(1,1,125,33)
Expand = True
Arrangement = Arrange.Fill
Spacing = True
Count = 2
Index = 0
Text = ("Identity")
{ panIdentity VBox
MoveScaled(1,1,59,27)
Spacing = True
Margin = True
{ HBox1 HBox
MoveScaled(0,0,58,4)
Spacing = True
{ Label5 Label
MoveScaled(0,0,23,4)
Text = ("Server")
}
{ cmbFarm ComboBox
MoveScaled(33,0,24,4)
Expand = True
ReadOnly = True
}
}
{ HBox2 HBox
MoveScaled(0,5,58,4)
Spacing = True
{ Label1 Label
MoveScaled(0,0,23,4)
Text = ("Login")
}
{ txtLogin TextBox
MoveScaled(33,0,24,4)
Expand = True
}
}
{ HBox3 HBox
MoveScaled(0,10,58,4)
Spacing = True
{ Label2 Label
MoveScaled(0,0,23,4)
Text = ("Password")
}
{ txtPassword TextBox
MoveScaled(33,0,24,4)
Expand = True
Password = True
}
}
{ HBox6 HBox
MoveScaled(0,15,58,3)
Spacing = True
{ Label4 Label
MoveScaled(0,0,23,3)
}
{ chkRememberPassword CheckBox
MoveScaled(33,0,25,3)
Expand = True
Text = ("Remember password")
}
}
{ Panel2 Panel
MoveScaled(25,19,7,2)
Expand = True
}
{ HBox5 HBox
MoveScaled(2,22,54,4)
Spacing = True
{ HBox7 HBox
MoveScaled(5,0,2,4)
Expand = True
}
{ btnShowRegister Button
MoveScaled(9,0,23,4)
AutoResize = True
Text = ("Register >>")
Picture = Picture["icon:/small/identity"]
}
{ btnClose Button
MoveScaled(33,0,16,4)
Text = ("Close")
}
}
}
{ panRegister VBox
MoveScaled(61,1,61,28)
Visible = False
Spacing = True
Margin = True
{ HBox4 HBox
MoveScaled(1,1,58,4)
Spacing = True
{ Label3 Label
MoveScaled(0,0,25,4)
Text = ("E-mail")
}
{ txtMail TextBox
MoveScaled(32,0,24,4)
Expand = True
Password = True
}
}
{ HBox38 HBox
MoveScaled(1,6,58,4)
Spacing = True
{ Label64 Label
MoveScaled(0,0,25,4)
Text = ("Confirm password")
}
{ txtConfirmPassword TextBox
MoveScaled(32,0,24,4)
Expand = True
Password = True
}
}
{ TextLabel1 TextLabel
MoveScaled(1,11,59,11)
Font = Font["Italic"]
Expand = True
Text = ("A confirmation mail will be sent to the specified e-mail address. Click on the link included in that mail to activate your account.\n<p>\n<b>Your e-mail will not be stored on the publishing server.</b>")
}
{ HBox51 HBox
MoveScaled(1,23,58,4)
Spacing = True
{ Panel3 Panel
MoveScaled(2,0,3,4)
Expand = True
}
{ btnRegister Button
MoveScaled(16,0,23,4)
AutoResize = True
Text = ("Register") & "..."
Picture = Picture["icon:/small/identity"]
}
{ btnCancel Button
MoveScaled(40,0,16,4)
Text = ("Cancel")
}
}
}
Index = 1
Text = ("Servers")
{ lstFarm ListEditor
MoveScaled(2,2,57,15)
Border = False
}
Index = 0
}
}

View file

@ -38,12 +38,12 @@ Public Sub Form_Open()
'
' Endif
cmbFarm.List = FarmRequest.GetFarms()
$bNoRefresh = True
cmbFarm.Index = 0
cmbFarm.List = FarmRequest.GetFarms()
cmbFarm.Text = FarmIdentity.LastFarm
cmbSort.Index = 0
$bNoRefresh = False
LoadSoftware
Reload
End
@ -68,18 +68,18 @@ End
Public Sub cmbSort_Click()
LoadSoftware
Reload
End
Public Sub cmbFarm_Click()
tagFarm.SetFarm(cmbFarm.Text)
LoadSoftware
ReloadFarm
End
Private Sub LoadSoftware()
Public Sub Reload()
Dim hReq As FarmRequest
@ -109,7 +109,7 @@ Public Sub Request_Finished()
Endif
For Each sId In Split(hReq.Result["Result"])
hSoftwareBox = New SoftwareBox(svwFarm, CInt(sId), hReq.Farm)
hSoftwareBox = New SoftwareBox(svwFarm, CInt(sId), hReq.Farm) As "SoftwareBox"
hSoftwareBox.ResizeScaled(48, 18)
Next
@ -119,6 +119,7 @@ End
Public Sub Form_Close()
FarmRequestManager.Clear
FarmIdentity.LastFarm = cmbFarm.Text
Settings.Write(Me)
End
@ -138,7 +139,7 @@ End
Public Sub timLoad_Timer()
LoadSoftware
Reload
End
@ -161,3 +162,25 @@ Public Sub dwgTitle_Draw()
Paint.DrawText(("Gambas Software Farm"), DS, 0, DS * 32, Paint.H, Align.Left)
End
Private Sub ReloadFarm()
Dim hIdentity As FarmIdentity
SoftwareBox.ClearCache(cmbFarm.Text)
hIdentity = New FarmIdentity(cmbFarm.Text)
hIdentity.Init(lblIdentity, picIdentity)
Reload
End
Public Sub btnLogin_Click()
FFarmConfig.Run(cmbFarm.text)
$bNoRefresh = True
cmbFarm.List = FarmRequest.GetFarms()
$bNoRefresh = False
ReloadFarm
End

View file

@ -11,7 +11,7 @@
Background = &H3398C3&
}
{ Panel1 VBox
MoveScaled(1,11,97,17)
MoveScaled(1,11,97,23)
Spacing = True
Margin = True
{ panFilter Panel
@ -23,31 +23,54 @@
Text = ("Farm")
}
{ cmbFarm ComboBox
MoveScaled(11,0,29,4)
MoveScaled(15,0,29,4)
ReadOnly = True
}
{ Label1 Label
MoveScaled(41,0,8,4)
AutoResize = True
Text = ("Show")
}
{ cmbSort ComboBox
MoveScaled(48,0,25,4)
ReadOnly = True
List = [("Most recent"), ("Most downloaded"), ("Most popular"), ("Installed")]
}
{ Panel3 Panel
MoveScaled(74,0,1,4)
MoveScaled(46,0,1,4)
Expand = True
}
{ panUser Panel
MoveScaled(48,0,22,4)
Expand = True
Arrangement = Arrange.Horizontal
Spacing = True
Invert = True
{ Panel6 Panel
MoveScaled(19,0,2,4)
}
{ lblIdentity Label
MoveScaled(7,0,9,4)
Font = Font["Bold"]
AutoResize = True
}
{ picIdentity PictureBox
MoveScaled(2,0,4,4)
Picture = Picture["icon:/medium/identity"]
Alignment = Align.Center
}
}
{ btnLogin Button
MoveScaled(77,0,15,4)
AutoResize = True
Text = ("Connect") & "..."
Text = ("Configure") & "..."
}
}
{ HBox1 HBox
MoveScaled(2,6,93,4)
Spacing = True
{ Label1 Label
MoveScaled(0,0,11,4)
Text = ("Show")
}
{ cmbSort ComboBox
MoveScaled(15,0,25,4)
ReadOnly = True
List = [("Most recent"), ("Most downloaded"), ("Most popular"), ("Installed")]
}
}
{ Panel4 HPanel
MoveScaled(2,6,94,5)
MoveScaled(2,11,94,5)
Spacing = True
{ Label3 Label
MoveScaled(0,0,11,4)
@ -59,7 +82,7 @@
}
}
{ Panel5 HPanel
MoveScaled(2,12,94,4)
MoveScaled(2,17,94,4)
Spacing = True
{ Label4 Label
MoveScaled(0,0,11,4)
@ -79,15 +102,14 @@
}
}
}
{ Separator1 Separator
MoveScaled(44,35,17,0)
}
{ timLoad #Timer
#MoveScaled(87,35)
Delay = 500
}
{ svwFarm ScrollView
MoveScaled(3,45,90,37)
Background = Color.TextBackground
Foreground = Color.TextForeground
Expand = True
Arrangement = Arrange.Row
Spacing = True

View file

@ -0,0 +1,116 @@
' Gambas class file
Static Property FarmList As String[]
Static Property RememberPassword As Boolean
Static Property LastFarm As String
Property Login As String
Property Password As String
Static Private $hSettings As Settings
Static Private $cPassword As New Collection
Private $sFarm As String
Static Public Sub _init()
$hSettings = New Settings("gambas3-farm")
End
Public Sub _new(sFarm As String)
$sFarm = sFarm
End
Private Function Login_Read() As String
Return $hSettings[$sFarm &/ "Login"]
End
Private Sub Login_Write(Value As String)
$hSettings[$sFarm &/ "Login"] = Value
$hSettings.Save
End
Static Private Function RememberPassword_Read() As Boolean
Return $hSettings["/RememberPassword", False]
End
Static Private Sub RememberPassword_Write(Value As Boolean)
$hSettings["/RememberPassword"] = Value
$hSettings.Save
End
Private Function Password_Read() As String
If $hSettings["/RememberPassword", False] Then $cPassword[$sFarm] = Desktop.Passwords["/Farm" &/ $sFarm]
Return $cPassword[$sFarm]
End
Private Sub Password_Write(Value As String)
$cPassword[$sFarm] = Value
If $hSettings["/RememberPassword", False] Then Try Desktop.Passwords["/Farm" &/ $sFarm] = Value
End
Static Private Function FarmList_Read() As String[]
Dim aDefault As New String[]
Return $hSettings["/FarmList", aDefault]
End
Static Private Sub FarmList_Write(Value As String[])
$hSettings["/FarmList"] = Value
$hSettings.Save
End
Static Public Sub SaveSettings()
$hSettings.Save
End
Static Private Function LastFarm_Read() As String
Return $hSettings["/LastFarm", "gambaswiki.org"]
End
Static Private Sub LastFarm_Write(Value As String)
$hSettings["/LastFarm"] = Value
$hSettings.Save
End
Public Sub Init(hLabel As Label, hPic As Control)
If Me.Login And If Me.Password Then
hLabel.Text = Me.Login
hLabel.Font.Bold = True
hLabel.Font.Italic = False
hPic.Show
Else
hLabel.Text = ("Anonymous")
hLabel.Font.Bold = False
hLabel.Font.Italic = True
hPic.Hide
Endif
End

View file

@ -3,8 +3,6 @@
Event Finished
Public Farm As String
Public Login As String
Public Password As String
Public ErrorText As String
Public Result As Collection
Public ResultFile As String
@ -13,12 +11,13 @@ Private $sTitle As String
Private $hForm As HttpForm
Private $bUseProgress As Boolean
Private $bFile As Boolean
Private $bFinished As Boolean
Static Public Sub GetFarms() As String[]
Dim aFarm As String[]
aFarm = Settings["/Publish/FarmList"]
aFarm = FarmIdentity.FarmList
If Not aFarm Then aFarm = New String[]
If Not aFarm.Exist("gambaswiki.org") Then
aFarm.Add("gambaswiki.org", 0)
@ -42,12 +41,18 @@ Static Public Sub GetDate(sDate As String) As Date
End
Public Sub _new(sFarm As String, Optional sLogin As String, sPassword As String)
Public Sub _new(sFarm As String)
Dim hIdentity As FarmIdentity
Farm = sFarm
Login = sLogin
Password = sPassword
hIdentity = New FarmIdentity(sFarm)
$hForm = New HttpForm As "Request"
$hForm["login"] = hIdentity.Login
$hForm["password"] = hIdentity.Password
End
@ -63,6 +68,7 @@ Public Sub Request_Error()
ErrorText = $hForm.ErrorText
Result = Null
ResultFile = ""
$bFinished = True
Raise Finished
End
@ -72,6 +78,7 @@ Public Sub Request_Cancel()
ErrorText = ""
Result = Null
ResultFile = ""
$bFinished = True
Raise Finished
End
@ -83,6 +90,8 @@ Public Sub Request_Finished()
Dim iPos As Integer
Dim sResult As String
$bFinished = True
If $bFile Then
ResultFile = Temp$()
File.Save(ResultFile, $hForm.Peek())
@ -107,6 +116,7 @@ Public Sub Request_Finished()
If iPos = 0 Then Continue
Result[Trim(Left(sLine, iPos - 1))] = Trim(Mid$(sLine, iPos + 1))
Next
Raise Finished
End
@ -129,7 +139,7 @@ Catch
End
Public Sub RegisterUser(sLogin As String, sPassword As String, sFullName As String, sEmail As String)
Public Sub RegisterUser(sLogin As String, sPassword As String, sEmail As String)
$sTitle = ("Register user")
$bUseProgress = False
@ -137,7 +147,6 @@ Public Sub RegisterUser(sLogin As String, sPassword As String, sFullName As Stri
$hForm.URL = "http://" & Farm &/ "farm/register"
$hForm.Add("login", sLogin)
$hForm.Add("password", sPassword)
$hForm.Add("name", sFullName)
$hForm.Add("email", sEmail)
FarmRequestManager.Add($hForm)
@ -154,11 +163,21 @@ Public Sub HasFailed() As Boolean
End
Public Sub WaitFor(Optional sGood As String, sBad As String) As Boolean
Public Sub WaitFor(Optional sGood As String, sBad As String, Optional bNoWindow As Boolean) As Boolean
Dim bFail As Boolean
FFarmRequest.Run($hForm, $sTitle, $bUseProgress)
If bNoWindow Then
Inc Application.Busy
Do
Sleep 0.05
If $bFinished Then Break
Wait
Loop
Dec Application.Busy
Else
FFarmRequest.Run($hForm, $sTitle, $bUseProgress)
Endif
bFail = HasFailed()
@ -203,8 +222,8 @@ Public Sub PublishSoftware(sScreenshot As String, sGambasVersion As String, aTag
'$sBadMsg = ("Unable to publish project.")
$hForm.URL = "http://" & Farm &/ "/farm/publish"
$hForm.Add("login", Login)
$hForm.Add("password", Password)
'$hForm.Add("login", Login)
'$hForm.Add("password", Password)
$hForm.Add("name", Project.Name)
$hForm.Add("version", Project.MajorVersion * 10000 + Project.MinorVersion)
$hForm.Add("release", Project.ReleaseVersion)
@ -248,3 +267,28 @@ Public Sub SearchSoftware(sSort As String, sFilter As String, aTag As String[])
FarmRequestManager.Add($hForm)
End
Public Sub CheckAuth(sLogin As String, sPassword As String)
$hForm.URL = "http://" & Farm &/ "farm/ident"
$hForm["login"] = sLogin
$hForm["password"] = sPassword
FarmRequestManager.Add($hForm)
End
Public Sub VoteForSoftware(iId As Integer, iVote As Integer)
$hForm.URL = "http://" & Farm &/ "farm/vote"
$hForm["id"] = CStr(iId)
$hForm["vote"] = CStr(iVote)
FarmRequestManager.Add($hForm)
End
Public Sub Abort()
FarmRequestManager.Remove($hForm)
End

View file

@ -64,7 +64,7 @@ End
Public Sub Button_Click()
Dim hParent As CTagEditor = Me.Parent.Parent
Dim hParent As CTagEditor = Me.Parent.Parent.Parent
Me.Delete
hParent._RaiseChange()

View file

@ -22,7 +22,7 @@ Public Sub btnPublish_Click()
Dim hReq As FarmRequest
hReq = New FarmRequest(GetFarm(), txtLogin.Text, txtPassword.Text)
hReq = New FarmRequest(GetFarm())
hReq.PublishSoftware(txtScreenshot.Text, cmbGambasVersion.Text, tagEditor.GetTags(), lstRequire.List, txtURL.Text)
hReq.WaitFor(("The project has been successfully published."), ("Unable to publish project."))
@ -44,7 +44,6 @@ Public Sub Form_Open()
Settings.Read(Me)
cmbFarm.List = FarmRequest.GetFarms()
chkRememberPassword.Value = Settings["/Publish/RememberPassword", False]
cmbFarm.Text = Settings["/Publish/Farm"]
cmbFarm.Index = 0
@ -63,7 +62,6 @@ Public Sub Form_Close()
Settings.Write(Me)
Settings["/Publish/Farm"] = cmbFarm.Text
Settings["/Publish/RememberPassword"] = CBool(chkRememberPassword.Value)
Project.PublishTags = tagEditor.GetTags()
Project.PublishDependencies = lstRequire.List
@ -82,25 +80,19 @@ End
Public Sub cmbFarm_Click()
txtLogin.Text = Settings["/Publish" &/ cmbFarm.Text &/ "Login"]
If chkRememberPassword.Value Then
Try txtPassword.Text = Desktop.Passwords["/Publish" &/ cmbFarm.Text]
Endif
Dim hIdentity As FarmIdentity
tagEditor.SetFarm(cmbFarm.Text)
End
Public Sub txtLogin_LostFocus()
Settings["/Publish" &/ cmbFarm.Text &/ "Login"] = txtLogin.Text
End
Public Sub txtPassword_LostFocus()
If cmbFarm.Text And If chkRememberPassword.Value Then
Try Desktop.Passwords["/Publish" &/ cmbFarm.Text] = txtPassword.Text
Endif
hIdentity = New FarmIdentity(cmbFarm.Text)
hIdentity.Init(lblIdentity, picIdentity)
End
Public Sub btnConfig_Click()
FFarmConfig.Run(cmbFarm.Text)
cmbFarm_Click
End

View file

@ -1,22 +1,17 @@
# Gambas Form File 3.0
{ Form Form
MoveScaled(0,0,88,86)
MoveScaled(0,0,71,74)
Text = ("Publish project")
Icon = Picture["icon:/medium/internet"]
Arrangement = Arrange.Vertical
{ Panel3 Panel
MoveScaled(1,1,62,24)
MoveScaled(1,1,69,11)
Arrangement = Arrange.Vertical
Spacing = True
Margin = True
{ Label9 Label
MoveScaled(0,0,13,3)
Font = Font["Bold"]
Text = ("Identity")
}
{ HBox1 HBox
MoveScaled(0,4,58,4)
MoveScaled(0,0,58,4)
Spacing = True
{ Label5 Label
MoveScaled(0,0,30,4)
@ -29,54 +24,43 @@
}
}
{ HBox2 HBox
MoveScaled(0,9,58,4)
MoveScaled(0,5,67,4)
Spacing = True
{ Label1 Label
MoveScaled(0,0,30,4)
Text = ("Login")
Text = ("Identity")
}
{ txtLogin TextBox
MoveScaled(33,0,24,4)
{ HBox3 HBox
MoveScaled(33,0,16,4)
Expand = True
Spacing = True
{ picIdentity PictureBox
MoveScaled(1,0,4,4)
Picture = Picture["icon:/medium/identity"]
Alignment = Align.Center
}
{ lblIdentity Label
MoveScaled(6,0,8,4)
Expand = True
}
}
}
{ HBox3 HBox
MoveScaled(0,14,58,4)
Spacing = True
{ Label2 Label
MoveScaled(0,0,30,4)
Text = ("Password")
}
{ txtPassword TextBox
MoveScaled(33,0,24,4)
Expand = True
Password = True
}
}
{ HBox6 HBox
MoveScaled(0,19,58,3)
Spacing = True
{ Label4 Label
MoveScaled(0,0,30,3)
}
{ chkRememberPassword CheckBox
MoveScaled(33,0,25,3)
Expand = True
Text = ("Remember password")
{ btnConfig Button
MoveScaled(50,0,16,4)
Text = ("Configure") & "..."
}
}
}
{ Separator2 Separator
MoveScaled(0,26,28,0)
MoveScaled(0,13,28,0)
}
{ Panel1 Panel
MoveScaled(2,27,59,49)
MoveScaled(1,19,69,46)
Expand = True
Arrangement = Arrange.Vertical
Spacing = True
Margin = True
{ HBox5 HBox
MoveScaled(0,0,58,4)
MoveScaled(0,1,58,4)
Spacing = True
{ Label3 Label
MoveScaled(0,0,30,4)
@ -90,7 +74,7 @@
}
}
{ HBox7 HBox
MoveScaled(0,5,58,4)
MoveScaled(0,6,58,4)
Spacing = True
{ Label8 Label
MoveScaled(0,0,30,4)
@ -108,7 +92,7 @@
}
}
{ HBox8 HBox
MoveScaled(0,10,58,4)
MoveScaled(0,11,58,4)
Spacing = True
{ Label10 Label
MoveScaled(0,0,30,4)
@ -120,34 +104,34 @@
}
}
{ Label6 Label
MoveScaled(0,18,14,4)
MoveScaled(0,15,14,4)
Font = Font["Bold"]
Text = ("Tags")
}
{ tagEditor CTagEditor
MoveScaled(0,22,58,10)
MoveScaled(0,19,58,10)
Expand = True
}
{ Label7 Label
MoveScaled(0,33,19,4)
MoveScaled(0,30,19,4)
Font = Font["Bold"]
Text = ("Dependencies")
}
{ lstRequire ListEditor
MoveScaled(1,37,57,11)
MoveScaled(1,34,57,11)
Expand = True
Moveable = False
}
}
{ Separator1 Separator
MoveScaled(1,78,28,0)
MoveScaled(1,66,28,0)
}
{ HBox4 HBox
MoveScaled(1,79,68,6)
MoveScaled(1,67,68,6)
Spacing = True
Margin = True
{ Panel4 Panel
MoveScaled(10,2,4,2)
MoveScaled(26,3,4,2)
Expand = True
}
{ btnPublish Button

View file

@ -11,6 +11,8 @@ Static Private $hImageVoteOff As Image
Static Private $hImageInstall As Image
Static Private $hImageInstallOff As Image
Static Private $cCache As New Collection
Property Read Id As Integer
Private $hDrawingArea As DrawingArea
@ -20,19 +22,18 @@ Private panAction As Panel
Private btnVote As ToolButton
Private btnInstall As ToolButton
Private lblURL As URLLabel
Private $sFarm As String
Static Public Sub ClearCache(sFarm As String)
$cCache[sFarm] = Null
End
Public Sub _new(iId As Integer, sFarm As String) ', sLogin As String, sPassword As String)
Me.Foreground = Color.TextForeground
$hDrawingArea = New DrawingArea(Me) As "DrawingArea"
$hSpinner = New Spinner($hDrawingArea)
$hSpinner.Start
$hSoft = New CSoftware(iId, sFarm) As "Software"
If Not $hImageVote Then
$hImageVote = Picture["icon:/22/bookmark"].Image
$hImageVoteOff = $hImageVote.Copy().Desaturate()
@ -40,6 +41,15 @@ Public Sub _new(iId As Integer, sFarm As String) ', sLogin As String, sPassword
$hImageInstallOff = $hImageInstall.Copy().Desaturate()
Endif
Me.Foreground = Color.TextForeground
$sFarm = sFarm
$hDrawingArea = New DrawingArea(Me) As "DrawingArea"
$hSpinner = New Spinner($hDrawingArea)
$hSpinner.Hide
panAction = New Panel(Me)
panAction.Spacing = True
panAction.Invert = True
@ -58,7 +68,29 @@ Public Sub _new(iId As Integer, sFarm As String) ', sLogin As String, sPassword
btnInstall.Font.Grade = 1
btnInstall.AutoResize = True
$hSoft.Start
If Not $cCache.Exist(sFarm) Then $cCache[sFarm] = New Collection
$hSoft = $cCache[sFarm][iId]
If Not $hSoft Then
$hSoft = New CSoftware(iId, sFarm) As "Software"
$cCache[sFarm][iId] = $hSoft
Reload
Else
Object.Attach($hSoft, Me, "Software")
UpdateButtons
Raise Ready
Endif
End
Private Sub UpdateButtons()
btnInstall.Picture = $hImageInstallOff.Picture
btnInstall.Text = CStr($hSoft.DownloadCount)
btnVote.Picture = If($hSoft.YourVote = 1, $hImageVote.Picture, $hImageVoteOff.Picture)
btnVote.Text = CStr($hSoft.VoteCount)
btnVote.Enabled = $hSoft.YourVote >= 0
End
@ -72,10 +104,7 @@ Public Sub Software_Change()
If $hSoft.State = CSoftware.STATE_READY Then
btnInstall.Picture = $hImageInstallOff.Picture
btnInstall.Text = CStr($hSoft.DownloadCount)
btnVote.Picture = $hImageVoteOff.Picture
btnVote.Text = CStr($hSoft.VoteCount)
UpdateButtons
If $hSoft.URL Then
lblURL = New URLLabel($hDrawingArea)
@ -110,7 +139,7 @@ Public Sub DrawingArea_Draw()
Dim iCol As Integer
Dim sText As String
If $hSoft.State = CSoftware.STATE_WAIT Then Return
If $hSoft.State < CSoftware.STATE_READY Then Return
W = Paint.W
H = Paint.H
@ -216,9 +245,24 @@ Public Sub btnInstall_Click()
End
Private Sub Reload()
$hSpinner.Show
$hSoft.Start
'$hDrawingArea.Refresh
End
Public Sub btnVote_Click()
Dim hReq As FarmRequest
Raise Vote
hReq = New FarmRequest($sFarm)
hReq.VoteForSoftware($hSoft.Id, If($hSoft.YourVote = 1, 0, 1))
If Not hReq.WaitFor(, ("Unable to vote"), True) Then
$cCache[$sFarm][$hSoft.Id] = Null
FSoftwareFarm.Reload
Endif
End

View file

@ -0,0 +1,20 @@
[Theme]
Background="#143250"
Normal="#BFBFBF"
Keyword="#80CEFF"
Datatype="#0094F0"
Function="#FFFFFF"
Operator="#F0AB4A,Bold"
Symbol="#BFBFBF"
Number="#D96D6D"
String="#FFFF80"
Comment="#3F7F3F"
Help="#BFBFBF,Bold"
Preprocessor="#B94B4B,Bold"
Breakpoint="#BF4749"
Current="#5F5FBF"
Selection="#1F5F97"
Highlight="#001F5F"
CurrentLine="#00376F"
Error="#D96D6D"

View file

@ -15,8 +15,8 @@ Path="gb.desktop.gambas"
[OpenFile]
File[1]=".src/Desktop.class:84.12"
Active=1
File[2]=".src/_Desktop_Passwords.class:0.0"
Active=2
File[2]=".src/_Desktop_Passwords.class:80.46"
Count=5
File[3]=".src/Main.module:61.0"
File[4]="xdg-utils/xdg-open:343.37"

View file

@ -6,13 +6,15 @@ Public Sub Main()
Dim sSlot As String
Dim sKey As String
hSettings = New Settings("~/.config/gambas3/gambas3.conf")
hSettings = New Settings("~/.config/gambas3/gambas3-farm.conf")
hSettings["localhost/Login"] = ""
For Each sSlot In hSettings.Keys
Print "["; sSlot; "]"
For Each sKey In hSettings.Keys[sSlot]
Print sKey
Print sKey; "="; hSettings[sSlot &/ sKey]
Next
Next

View file

@ -132,6 +132,7 @@ Public Sub Save()
Dim sTemp As String
Dim hLock As File
Dim cModify As Collection
Dim sSlot As String
If Not $bModify Then Return
@ -155,14 +156,20 @@ Public Sub Save()
cSave = $cSlot
cModify = $cModify
Load
For Each cSlot In cSave
For Each vVal In cSlot
sKey = cSave.Key &/ cSlot.Key
If cModify.Exist(cSave.Key) Or If cModify.Exist(sKey) Then
Me[sKey] = vVal
Endif
Next
For Each cModify
sKey = cModify.Key
sSlot = GetSlot(sKey)
sKey = File.Name(sKey)
Me[sSlot &/ sKey] = cSave[sSlot][sKey]
Next
' For Each cSlot In cSave
' For Each vVal In cSlot
' sKey = cSave.Key &/ cSlot.Key
' If cModify.Exist(cSave.Key) Or If cModify.Exist(sKey) Then
' Me[sKey] = vVal
' Endif
' Next
' Next
Endif

View file

@ -1,5 +1,5 @@
# Gambas Project File 3.0
# Compiled with Gambas 3.4.0
# Compiled with Gambas 3.6.90
Title=Maps
Startup=FMain
Icon=.hidden/mapview.png
@ -8,8 +8,9 @@ VersionFile=1
Component=gb.image
Component=gb.gui
Component=gb.form
Component=gb.map
Component=gb.net
Component=gb.net.curl
Component=gb.map
TabSize=2
Packager=1
Tags=MapView

View file

@ -1,5 +1,5 @@
# Gambas Project File 3.0
# Compiled with Gambas 3.6.0
# Compiled with Gambas 3.6.90
Title=Wizard example
Startup=FMain
Icon=wizard.png
@ -15,3 +15,5 @@ TabSize=2
Translate=1
Language=de
Packager=1
GambasVersion=3.4
WebSite=http://gambaswiki.org

View file

@ -15,3 +15,4 @@ TabSize=2
Translate=1
Language=en
Packager=1
Tags=Painting,Example,Drawing

View file

@ -1,5 +1,5 @@
# Gambas Project File 3.0
# Compiled with Gambas 3.5.90
# Compiled with Gambas 3.6.90
Title=GambasGears
Startup=Module1
Icon=gears.png
@ -17,3 +17,4 @@ Vendor=Princeton
Address=benoit@localhost
License=General Public Licence
Packager=1
Tags=Example,OpenGL