1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-05 00:45:14 -05:00

Changes in the updater.

git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@356 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
Wizzup? 2010-01-01 15:32:23 +00:00
parent b9fedf3d0b
commit 1e62434a2e
8 changed files with 125 additions and 72 deletions

View File

@ -38,7 +38,7 @@
<CursorPos X="7" Y="124"/>
<TopLine Value="99"/>
<EditorIndex Value="0"/>
<UsageCount Value="120"/>
<UsageCount Value="121"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
@ -271,8 +271,8 @@
<Unit30>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<UnitName Value="updater"/>
<CursorPos X="13" Y="157"/>
<TopLine Value="139"/>
<CursorPos X="18" Y="199"/>
<TopLine Value="174"/>
<EditorIndex Value="4"/>
<UsageCount Value="15"/>
<Loaded Value="True"/>

View File

@ -8,7 +8,7 @@
</Flags>
<MainUnit Value="0"/>
<TargetFileExt Value=""/>
<Title Value="Mufasa Stand Alone"/>
<Title Value="Simba"/>
<UseXPManifest Value="True"/>
<ActiveEditorIndexAtStart Value="12"/>
</General>
@ -282,8 +282,8 @@
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="mmlpsthread"/>
<CursorPos X="1" Y="99"/>
<TopLine Value="67"/>
<CursorPos X="20" Y="193"/>
<TopLine Value="174"/>
<EditorIndex Value="6"/>
<UsageCount Value="202"/>
<Loaded Value="True"/>
@ -603,9 +603,11 @@
</Unit79>
<Unit80>
<Filename Value="../../Units/MMLAddon/PSInc/psdefines.inc"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<UsageCount Value="7"/>
<CursorPos X="55" Y="18"/>
<TopLine Value="2"/>
<EditorIndex Value="13"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit80>
<Unit81>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/math.inc"/>
@ -1433,8 +1435,8 @@
<ComponentName Value="ColourHistoryForm"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="colourhistory"/>
<CursorPos X="71" Y="503"/>
<TopLine Value="486"/>
<CursorPos X="66" Y="23"/>
<TopLine Value="1"/>
<EditorIndex Value="5"/>
<UsageCount Value="200"/>
<Loaded Value="True"/>
@ -1687,7 +1689,7 @@
<UnitName Value="about"/>
<CursorPos X="44" Y="21"/>
<TopLine Value="4"/>
<UsageCount Value="168"/>
<UsageCount Value="171"/>
</Unit235>
<Unit236>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/file.inc"/>
@ -1702,7 +1704,7 @@
<CursorPos X="5" Y="14"/>
<TopLine Value="1"/>
<EditorIndex Value="8"/>
<UsageCount Value="162"/>
<UsageCount Value="165"/>
<Loaded Value="True"/>
</Unit237>
<Unit238>
@ -1712,7 +1714,7 @@
<UnitName Value="debugimageform"/>
<CursorPos X="20" Y="1"/>
<TopLine Value="1"/>
<UsageCount Value="149"/>
<UsageCount Value="152"/>
</Unit238>
<Unit239>
<Filename Value="debugimage.pas"/>
@ -1722,7 +1724,7 @@
<UnitName Value="debugimage"/>
<CursorPos X="66" Y="17"/>
<TopLine Value="1"/>
<UsageCount Value="148"/>
<UsageCount Value="151"/>
</Unit239>
<Unit240>
<Filename Value="debugimage.lrs"/>
@ -1844,7 +1846,7 @@
<UnitName Value="framefunctionlist"/>
<CursorPos X="56" Y="9"/>
<TopLine Value="54"/>
<UsageCount Value="69"/>
<UsageCount Value="72"/>
</Unit257>
<Unit258>
<Filename Value="../../../usr/local/share/lazarus/lcl/comctrls.pp"/>
@ -1899,7 +1901,7 @@
<UnitName Value="simpleanalyzer"/>
<CursorPos X="52" Y="104"/>
<TopLine Value="193"/>
<UsageCount Value="56"/>
<UsageCount Value="59"/>
</Unit265>
<Unit266>
<Filename Value="../../Units/Misc/mPasLex.pas"/>
@ -1955,7 +1957,7 @@
<CursorPos X="59" Y="19"/>
<TopLine Value="1"/>
<EditorIndex Value="10"/>
<UsageCount Value="15"/>
<UsageCount Value="16"/>
<Loaded Value="True"/>
</Unit273>
<Unit274>
@ -1963,7 +1965,7 @@
<CursorPos X="39" Y="4"/>
<TopLine Value="1"/>
<EditorIndex Value="9"/>
<UsageCount Value="15"/>
<UsageCount Value="16"/>
<Loaded Value="True"/>
</Unit274>
<Unit275>
@ -1971,7 +1973,7 @@
<CursorPos X="87" Y="133"/>
<TopLine Value="111"/>
<EditorIndex Value="7"/>
<UsageCount Value="15"/>
<UsageCount Value="16"/>
<Loaded Value="True"/>
</Unit275>
<Unit276>
@ -1985,10 +1987,10 @@
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="updater"/>
<CursorPos X="88" Y="194"/>
<TopLine Value="165"/>
<EditorIndex Value="14"/>
<UsageCount Value="29"/>
<CursorPos X="63" Y="156"/>
<TopLine Value="129"/>
<EditorIndex Value="15"/>
<UsageCount Value="32"/>
<Loaded Value="True"/>
</Unit277>
<Unit278>
@ -1997,10 +1999,10 @@
<ComponentName Value="SimbaUpdateForm"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="updateform"/>
<CursorPos X="6" Y="82"/>
<TopLine Value="69"/>
<CursorPos X="80" Y="91"/>
<TopLine Value="78"/>
<EditorIndex Value="12"/>
<UsageCount Value="24"/>
<UsageCount Value="27"/>
<Loaded Value="True"/>
</Unit278>
<Unit279>
@ -2008,8 +2010,8 @@
<UnitName Value="FileUtil"/>
<CursorPos X="53" Y="95"/>
<TopLine Value="67"/>
<EditorIndex Value="13"/>
<UsageCount Value="10"/>
<EditorIndex Value="14"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit279>
<Unit280>
@ -2051,8 +2053,8 @@
<UnitName Value="UnixUtils"/>
<CursorPos X="17" Y="62"/>
<TopLine Value="56"/>
<EditorIndex Value="15"/>
<UsageCount Value="10"/>
<EditorIndex Value="16"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit285>
<Unit286>
@ -2068,7 +2070,7 @@
<UsageCount Value="10"/>
</Unit287>
</Units>
<JumpHistory Count="8" HistoryIndex="7">
<JumpHistory Count="14" HistoryIndex="13">
<Position1>
<Filename Value="updateform.pas"/>
<Caret Line="37" Column="29" TopLine="19"/>
@ -2101,6 +2103,30 @@
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="194" Column="89" TopLine="177"/>
</Position8>
<Position9>
<Filename Value="updateform.pas"/>
<Caret Line="9" Column="28" TopLine="1"/>
</Position9>
<Position10>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="138" Column="70" TopLine="125"/>
</Position10>
<Position11>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="193" Column="20" TopLine="174"/>
</Position11>
<Position12>
<Filename Value="../../Units/MMLAddon/PSInc/psdefines.inc"/>
<Caret Line="27" Column="12" TopLine="2"/>
</Position12>
<Position13>
<Filename Value="updateform.pas"/>
<Caret Line="9" Column="28" TopLine="1"/>
</Position13>
<Position14>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="169" Column="15" TopLine="151"/>
</Position14>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>

View File

@ -30,14 +30,11 @@ uses
cthreads, cmem,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, LResources, testunit, colourhistory, About, internets, debugimage,
Forms, testunit, colourhistory, About, internets, debugimage,
framefunctionlist, simpleanalyzer, updater, updateform;
{$IFDEF WINDOWS}{$R project1.rc}{$ENDIF}
begin
{$I project1.lrs}
Application.Title:='Mufasa Stand Alone';
Application.Title:='Simba';
Application.Initialize;
Application.CreateForm(TForm1, Form1);

View File

@ -3,6 +3,7 @@ object SimbaUpdateForm: TSimbaUpdateForm
Height = 391
Top = 242
Width = 467
ActiveControl = UpdateButton
Caption = 'SimbaUpdateForm'
ClientHeight = 391
ClientWidth = 467

View File

@ -2,19 +2,19 @@
LazarusResources.Add('TSimbaUpdateForm','FORMDATA',[
'TPF0'#16'TSimbaUpdateForm'#15'SimbaUpdateForm'#4'Left'#3#131#1#6'Height'#3
+#135#1#3'Top'#3#242#0#5'Width'#3#211#1#7'Caption'#6#15'SimbaUpdateForm'#12'C'
+'lientHeight'#3#135#1#11'ClientWidth'#3#211#1#10'LCLVersion'#6#6'0.9.29'#0#12
+'TProgressBar'#16'DownloadProgress'#4'Left'#2#24#6'Height'#2#28#3'Top'#2'H'#5
+'Width'#3#157#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#6'Smooth'#9#8
+'TabOrder'#2#0#0#0#7'TButton'#12'UpdateButton'#4'Left'#2#24#6'Height'#2#25#3
+'Top'#2' '#5'Width'#3#157#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#7
+'Caption'#6#7'Update!'#7'OnClick'#7#17'UpdateButtonClick'#8'TabOrder'#2#1#0#0
+#7'TButton'#8'OkButton'#4'Left'#3'j'#1#6'Height'#2#25#3'Top'#3'X'#1#5'Width'
+#2'K'#7'Anchors'#11#7'akRight'#8'akBottom'#0#7'Caption'#6#2'Ok'#7'OnClick'#7
+#13'OkButtonClick'#8'TabOrder'#2#2#0#0#7'TButton'#12'CancelButton'#4'Left'#2
+#24#6'Height'#2#25#3'Top'#3'X'#1#5'Width'#2'K'#7'Anchors'#11#6'akLeft'#8'akB'
+'ottom'#0#7'Caption'#6#6'Cancel'#7'OnClick'#7#17'CancelButtonClick'#8'TabOrd'
+'er'#2#3#0#0#5'TMemo'#9'UpdateLog'#4'Left'#2#24#6'Height'#3#199#0#3'Top'#3
+#128#0#5'Width'#3#157#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#8'akBott'
+'om'#0#8'TabOrder'#2#4#0#0#0
+#135#1#3'Top'#3#242#0#5'Width'#3#211#1#13'ActiveControl'#7#12'UpdateButton'#7
+'Caption'#6#15'SimbaUpdateForm'#12'ClientHeight'#3#135#1#11'ClientWidth'#3
+#211#1#10'LCLVersion'#6#6'0.9.29'#0#12'TProgressBar'#16'DownloadProgress'#4
+'Left'#2#24#6'Height'#2#28#3'Top'#2'H'#5'Width'#3#157#1#7'Anchors'#11#5'akTo'
+'p'#6'akLeft'#7'akRight'#0#6'Smooth'#9#8'TabOrder'#2#0#0#0#7'TButton'#12'Upd'
+'ateButton'#4'Left'#2#24#6'Height'#2#25#3'Top'#2' '#5'Width'#3#157#1#7'Ancho'
+'rs'#11#5'akTop'#6'akLeft'#7'akRight'#0#7'Caption'#6#7'Update!'#7'OnClick'#7
+#17'UpdateButtonClick'#8'TabOrder'#2#1#0#0#7'TButton'#8'OkButton'#4'Left'#3
+'j'#1#6'Height'#2#25#3'Top'#3'X'#1#5'Width'#2'K'#7'Anchors'#11#7'akRight'#8
+'akBottom'#0#7'Caption'#6#2'Ok'#7'OnClick'#7#13'OkButtonClick'#8'TabOrder'#2
+#2#0#0#7'TButton'#12'CancelButton'#4'Left'#2#24#6'Height'#2#25#3'Top'#3'X'#1
+#5'Width'#2'K'#7'Anchors'#11#6'akLeft'#8'akBottom'#0#7'Caption'#6#6'Cancel'#7
+'OnClick'#7#17'CancelButtonClick'#8'TabOrder'#2#3#0#0#5'TMemo'#9'UpdateLog'#4
+'Left'#2#24#6'Height'#3#199#0#3'Top'#3#128#0#5'Width'#3#157#1#7'Anchors'#11#5
+'akTop'#6'akLeft'#7'akRight'#8'akBottom'#0#8'TabOrder'#2#4#0#0#0
]);

View File

@ -82,12 +82,16 @@ procedure TSimbaUpdateForm.PerformUpdate;
begin
Updater := TMMLFileDownloader.Create;
FCancelling := False;
FCancelled := False;
// Make this a setting later
Updater.FileURL := 'http://old.villavu.com/merlijn/Simba';
Updater.FileURL := 'http://old.villavu.com/merlijn/Simba'{$IFDEF WINDOWS} +'.exe'{$ENDIF};
// Dynamic
Updater.ReplacementFile := 'Simba';
Updater.ReplacementFile := ApplicationName{$IFDEF WINDOWS} +'.exe'{$ENDIF};
Updater.OnBeat := @Self.OnUpdateBeat;
Self.UpdateLog.Lines.Add('Starting download of ' + Updater.FileURL + ' ...');
@ -103,6 +107,7 @@ begin
FCancelling := False;
FCancelled := True;
Self.UpdateLog.Lines.Add('Download stopped ...');
// more detailed info
writeln('EXCEPTION IN UPDATEFORM: We either hit Cancel, or something went wrong with files');
end;
Self.UpdateLog.Lines.Add('Done ...');

View File

@ -26,6 +26,7 @@ PSScript.Defines.Add('CPU386');
{$ENDIF }
PSScript.Defines.Add('MUFASA');
PSScript.Defines.Add('COGAT');
PSScript.Defines.Add('SIMBA');
PSScript.Defines.Add('RAYMONDPOWNS');
{$IFDEF MSWINDOWS }
PSScript.Defines.Add('MSWINDOWS');

View File

@ -5,7 +5,10 @@ unit updater;
interface
uses
Classes, SysUtils, httpsend,blcksock;
Classes, SysUtils, httpsend,blcksock
{$IFDEF LINUX}
,unixutils // for chmod
{$ENDIF};
type
{ TMMLUpdateThread = class(TThread)
@ -14,7 +17,7 @@ type
destructor Destroy; override;
end; }
TMemory = pointer;
TFunctionBoolean = function: boolean;
TMMLFunctionBoolean = function: boolean of object;
TMMLFileDownloader = class(TObject)
@ -25,8 +28,8 @@ type
HTTPSend: THTTPSend;
FFileSize: Integer;
FDownloaded: Boolean;
FOnChange: TFunctionBoolean;
FOnBeat: TFunctionBoolean;
FOnChange: TMMLFunctionBoolean;
FOnBeat: TMMLFunctionBoolean;
public
constructor Create;
@ -53,10 +56,10 @@ type
{ If either of these events return "True", an exception is thrown
and the download is cancelled. This way we can easily `cancel'
a download. }
property OnChange: TFunctionBoolean read FOnChange write FOnChange;
property OnChange: TMMLFunctionBoolean read FOnChange write FOnChange;
{ Called every 50ms }
property OnBeat: TFunctionBoolean read FOnBeat write FOnBeat;
property OnBeat: TMMLFunctionBoolean read FOnBeat write FOnBeat;
function GetPercentage: Integer;
private
@ -105,7 +108,7 @@ procedure TMMLFileDownloader.OnHeartBeat(Sender: TObject);
begin
if Assigned(FOnBeat) then
if FOnBeat() then
raise Exception.Create('OnChange event called for a quit');
raise Exception.Create('OnBeat event called for a quit');
end;
procedure TMMLFileDownloader.OnMonitor(Sender: TObject; Writing: Boolean;
@ -122,7 +125,6 @@ begin
if Assigned(FOnChange) then
if FOnChange() then
raise Exception.Create('OnChange event called for a quit');
// writeln('Percent done: ' + IntToStr(GetPercentage));
end;
function TMMLFileDownloader.GetPercentage: Integer;
@ -165,25 +167,48 @@ begin
FDownloaded := True;
except
writeln('DownloadAndSave: Exception Occured');
Result := False;
end;
HTTPSend.Free;
Response.Free;
end;
if not result then
Raise Exception.Create('Throwing it so we can catch it later');
end;
function TMMLFileDownloader.Replace: Boolean;
begin
{ Change to messages + Exit(False) instead of exceptions? }
if not Downloaded then
raise Exception.Create('Nothing downloaded');
begin
writeln('Nothing downloaded');
exit(False);
// raise Exception.Create('Nothing downloaded');
end;
if FReplacementFile = '' then
raise Exception.Create('ReplacementFile not set');
begin
writeln('ReplacementFile not se');
exit(False);
//raise Exception.Create('ReplacementFile not set');
end;
if not FileExists(FReplacementFile) then
begin
writeln('ReplacementFile not found');
exit(False);
raise Exception.Create('ReplacementFile not found');
end;
if not FileExists(FReplacementFile+ '_') then
begin
writeln('ReplacementFile + _ not found');
exit(False);
raise Exception.Create('ReplacementFile + _ not found');
end;
RenameFile(FReplacementFile, FReplacementFile+'_old_');
RenameFile(FReplacementFile+'_', FReplacementFile);
DeleteFile(FReplacementFile+'_old_');
{$IFDEF LINUX}
Chmod(FReplacementFile, PermissionBits[0] or PermissionBits[1] or PermissionBits[2]);
{$ENDIF}
end;
constructor TMMLFileDownloader.Create;
@ -194,16 +219,14 @@ begin
FDownloaded := False;
FReplacementFile:='';
FFileURL := '';
FOnChange := nil;
FOnBeat := nil;
end;
destructor TMMLFileDownloader.Destroy;
begin
inherited;
end;