From 1b53ece9c646272a7cbf47e6c3088cfc1b91a9b4 Mon Sep 17 00:00:00 2001 From: Raymond Date: Sun, 21 Feb 2010 19:36:35 +0000 Subject: [PATCH] Last version for the old update system. + small getpage fix. git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@544 3f818213-9676-44b0-a9b4-5e4c4e03d09d --- trunk/Projects/SAMufasaGUI/testunit.pas | 8 +++- trunk/Projects/SAMufasaGUI/updateform.pas | 43 ++++++++++-------- trunk/Units/MMLAddon/internets.pas | 53 +++++++++++++++-------- 3 files changed, 65 insertions(+), 39 deletions(-) diff --git a/trunk/Projects/SAMufasaGUI/testunit.pas b/trunk/Projects/SAMufasaGUI/testunit.pas index 4feab7d..9d37db1 100644 --- a/trunk/Projects/SAMufasaGUI/testunit.pas +++ b/trunk/Projects/SAMufasaGUI/testunit.pas @@ -43,7 +43,7 @@ uses ColorBox , about, framefunctionlist, ocr, updateform, simbasettings; const - SimbaVersion = 538; + SimbaVersion = 544; type @@ -1681,10 +1681,14 @@ end; procedure TForm1.NewsTimerTimer(Sender: TObject); var s: String; + News : TStringList; {Need it for correct EOL stuff} begin NewsTimer.Enabled:=False; s := GetSimbaNews; - Memo1.Append(s); + News := TStringList.Create; + News.Text:= s; + Memo1.Lines.AddStrings(News); + News.free; end; procedure TForm1.OnLinePSScript(Sender: TObject); diff --git a/trunk/Projects/SAMufasaGUI/updateform.pas b/trunk/Projects/SAMufasaGUI/updateform.pas index 34a8f28..52314c5 100644 --- a/trunk/Projects/SAMufasaGUI/updateform.pas +++ b/trunk/Projects/SAMufasaGUI/updateform.pas @@ -65,10 +65,26 @@ var SimbaUpdateForm: TSimbaUpdateForm; implementation - uses internets, TestUnit, simbasettings,lclintf; +const + SimbaURL = {$IFDEF WINDOWS} + {$IFDEF CPUI386} + 'http://simba.villavu.com/bin/Windows/x86/Stable/' + {$ELSE} + 'http://simba.villavu.com/bin/Windows/x86_64/Stable/' + {$ENDIF} + {$ELSE} + {$IFDEF CPUI386} + 'http://simba.villavu.com/bin/Linux/x86/Stable/' + {$ELSE} + 'http://simba.villavu.com/bin/Linux/x86_64/Stable/' + {$ENDIF} + {$ENDIF}; + + + function TSimbaUpdateForm.CanUpdate: Boolean; begin GetLatestSimbaVersion; @@ -83,24 +99,10 @@ begin if SimbaVersionThread = nil then//Create thread (only if no-other one is already running) begin SimbaVersionThread := TSimbaVersionThread.Create(true); - + SettingsForm.Settings.CreateKey('Settings/Updater/RemoteVersionLink',true); + SettingsForm.Settings.SetKeyValue('Settings/Updater/RemoteVersionLink',SimbaURL + 'Version'); SimbaVersionThread.InputURL := SettingsForm.Settings.GetSetLoadSaveDefaultKeyValueIfNotExists( - 'Settings/Updater/RemoteVersionLink', - {$IFDEF WINDOWS} - {$IFDEF CPUI386} - 'http://simba.villavu.com/bin/Windows/x86/Stable/Version' - {$ELSE} - 'http://simba.villavu.com/bin/Windows/x86_64/Stable/Version' - {$ENDIF} - {$ELSE} - {$IFDEF CPUI386} - 'http://simba.villavu.com/bin/Linux/x86/Stable/Version' - {$ELSE} - 'http://simba.villavu.com/bin/Linux/x86_64/Stable/Version' - {$ENDIF} - {$ENDIF} - , SimbaSettingsFile); - + 'Settings/Updater/RemoteVersionLink',SimbaURL + 'Version',SimbaSettingsFile); SimbaVersionThread.Resume; while SimbaVersionThread.Done = false do//Wait till thread is done begin @@ -195,9 +197,12 @@ begin FCancelling := False; FCancelled := False; + SettingsForm.Settings.CreateKey('Settings/Updater/RemoteLink',true); + SettingsForm.Settings.SetKeyValue('Settings/Updater/RemoteLink',SimbaURL + 'Simba'{$IFDEF WINDOWS} +'.exe'{$ENDIF}); + Updater.FileURL := SettingsForm.Settings.GetSetLoadSaveDefaultKeyValueIfNotExists( 'Settings/Updater/RemoteLink', - 'http://old.villavu.com/merlijn/Simba'{$IFDEF WINDOWS} +'.exe'{$ENDIF}, + SimbaURL + 'Simba'{$IFDEF WINDOWS} +'.exe'{$ENDIF}, SimbaSettingsFile ); diff --git a/trunk/Units/MMLAddon/internets.pas b/trunk/Units/MMLAddon/internets.pas index a085363..66e71f7 100644 --- a/trunk/Units/MMLAddon/internets.pas +++ b/trunk/Units/MMLAddon/internets.pas @@ -50,12 +50,19 @@ uses { OTHER } function GetPage(URL: String): String; var - s: TStringList; -begin - s:=TStringList.Create; - HttpGetText(URL, s); - result := s.Text; - s.Free; + HTTP : THTTPSend; +begin; + HTTP := THTTPSend.Create; + Result := ''; + try + if HTTP.HTTPMethod('GET', URL) then + begin + SetLength(result,HTTP.Document.Size); + HTTP.Document.Read(result[1],length(result)); + end; + finally + HTTP.Free; + end; end; { TMInternet } @@ -125,12 +132,17 @@ begin if not fHandleCookies then HTTPSend.Cookies.Clear; HTTPSend.MimeType := 'text/html'; - if HTTPSend.HTTPMethod('GET',url) then - begin; - SetLength(result,HTTPSend.Document.Size); - HTTPSend.Document.Read(result[1],length(result)); - end else - result := ''; + try + if HTTPSend.HTTPMethod('GET',url) then + begin; + SetLength(result,HTTPSend.Document.Size); + HTTPSend.Document.Read(result[1],length(result)); + end else + result := ''; + except + on e : exception do + Writeln('THTTPClient error: ' + e.message); + end; end; function THTTPClient.PostHTTPPage(Url: string; PostData: string): string; @@ -138,12 +150,17 @@ begin HTTPSend.MimeType := 'application/x-www-form-urlencoded'; HTTPSend.Document.Clear; HTTPSend.Document.Write(Postdata[1],length(postdata)); - if HTTPSend.HTTPMethod('POST',url) then - begin; - SetLength(result,HTTPSend.Document.Size); - HTTPSend.Document.Read(result[1],Length(result)); - end else - result := ''; + try + if HTTPSend.HTTPMethod('POST',url) then + begin; + SetLength(result,HTTPSend.Document.Size); + HTTPSend.Document.Read(result[1],Length(result)); + end else + result := ''; + except + on e : exception do + Writeln('THTTPClient error: ' + e.message); + end; end; function THTTPClient.PostHTTPPage(Url: string): string;