SRL Archive - Reflection Development

Simba Reflection Installer


Wizzup?

2010-06-24 17:05:28

I placed the Reflection snapshots here:

http://wizzup.org/static/srl/srl_refl_version
http://wizzup.org/static/srl/srlref.tar.bz2

Currently Reflection.simba and everything in Core is copied. If anything else needs to be in there, please let me know.

Used this repository: http://simbareflection.googlecode.com/svn/trunk/

Updated every hour.

For the actual installer example code, see this extension: http://git.villavu.com/?p=simba.git;a=blob;f=Extensions/srl.sex

Cheers

MylesMadness

2010-06-24 17:32:07

program ReflectionUpdater; //Yes I stoled srl.sex stuff.  So what?!  Wait would that be considered rape? >.<
var
MainMenuItem, MenuCheck, MenuUpdate,AutoUpdate : TMenuItem;
started: Boolean;
Timer : TTimer;
Updating : boolean;


function GetNumbers(const str : string) : string;
var
i : integer;
begin;
for i := 1 to length(str) do
case str[i] of
'0'..'9': result := result + str[i];
end;
end;

procedure GetVersionS(out RefOnline, RefLocal: integer);
begin
RefOnline := strtointdef(GetNumbers(getpage('http://wizzup.org/static/srl/srl_refl_version')),-1);
RefLocal := StrToIntDef(Settings.GetKeyValueDef('RefVersion','-1'),-1);
end;

Function UpdateRef : boolean;
var
LocalR, OnlineR, i: integer;
Contents : String;
DeContents : string;
Failed : Boolean;
begin
Result := false;
if Updating then
exit;
Updating := True;
GetVersionS(OnlineR,LocalR);
Result := True;
if (OnlineR > LocalR) then
begin
Writeln('Reflection is outdated, updating now!');
Contents := getpage('http://wizzup.org/static/srl/srlref.tar.bz2');
Failed := True;
if DecompressBZip2(Contents,DeContents,4096) then
if UnTarEx(DeContents,IncludePath,true) then
Failed := False;
if not Failed then
Settings.SetKeyValue('RefVersion',inttostr(OnlineR));
if Result then
Result := Failed;
if not Failed then
Writeln('Succesfully updated your Reflection!');
end;
Updating := False;
end;

procedure OnRefCheckClick(Sender: TObject);
var
LocalR,OnlineR: integer;
begin
GetVersionS(OnlineR, LocalR);
if (OnlineR > LocalR) then
Writeln('A new Reflection version is available');
end;

procedure SetAutoUpdate(Sender: TObject);
begin
AutoUpdate.Checked := not AutoUpdate.Checked;
Timer.Enabled := AutoUpdate.Checked;
end;
procedure OnRefUpdateClick(Sender: TObject);
begin
UpdateRef;
end;

procedure OnUpdateTimer(Sender: TObject);
begin;
Timer.Interval := 30 * 60 * 1000; //Every half hour
UpdateRef;
end;

procedure Init;
begin;
MainMenuItem := TMenuItem.Create(Simba_MainMenu);
MainMenuItem.Caption := 'Reflection';
Simba_MainMenu.Items.Add(MainMenuItem);

MenuCheck := TMenuItem.Create(MainMenuItem);
MenuCheck.Caption := 'Check for new Reflection';
MenuCheck.OnClick := @OnRefUpdateClick;
MainMenuItem.Add(MenuCheck);

MenuUpdate := TMenuItem.Create(MainMenuItem);
MenuUpdate.Caption := 'Update Reflection';
MenuUpdate.OnClick := @OnRefUpdateClick;
MainMenuItem.Add(MenuUpdate);

AutoUpdate := TMenuItem.Create(MainMenuItem);
AutoUpdate.Caption := 'Automatically update';
AutoUpdate.OnClick := @SetAutoUpdate;
AutoUpdate.Checked := LowerCase(Settings.GetKeyValueDef('AutoUpdate','True')) = 'true';
MainMenuItem.Add(AutoUpdate);

Timer := TTimer.Create(Simba);
Timer.Interval := 5000;
Timer.OnTimer := @OnUpdateTimer;
Timer.Enabled :=AutoUpdate.Checked;

started := True;
end;

procedure Free;
begin
if (started) then
Timer.Enabled := False;
end;

procedure Attach;
begin;
Writeln('From now on, you shall be alerted when your Reflection include is out of date!');
MainMenuItem.Visible := True;
Timer.Enabled := AutoUpdate.Checked;
end;

Procedure Detach;
begin
Timer.Enabled := False;
MainMenuItem.Visible := False;
end;

function GetName : string;
begin;
result := 'Reflection Updater';
end;

function GetVersion : string;
begin;
result := '1.0';
end;
begin
end.
Theres the file all written, but the tar.bz really should be named reflection

Wizzup?

2010-06-24 17:33:49

From: MylesMadness
Theres the file all written


See if it works for you? ;)

MylesMadness

2010-06-24 17:35:06

It worked but the folder is named incorrectly

Wizzup?

2010-06-24 17:37:37

From: MylesMadness
It worked but the folder is named incorrectly


`srlref'?

MylesMadness

2010-06-24 17:38:31

It should be named "Reflection" so that it could be the same as most reflection installs

Wizzup?

2010-06-24 17:40:36

Try now?

MylesMadness

2010-06-24 17:41:52

Perfect

Nava2

2010-06-24 20:12:25

Thank you Wizzup, perhaps we could distribute the extention with The Simba installer?

Wizzup?

2010-06-25 07:26:42

Possible, but it's more likely it will be available through the upcoming script manager. It will also allow installing extension[s|packs].

fre

2010-06-25 07:47:35

Reflection is outdated for now, right?

MylesMadness

2010-06-25 13:55:37

From: fre
Reflection is outdated for now, right?
yes

Wizzup?

2010-07-15 12:10:45

Please update against: http://git.villavu.com/?p=simba.git;a=blob;f=Extensions/srl.sex;h=65b36f19e6177e215f7ca58872d1fafaa26aaec4;hb=3358e8806d3380a0fce191346141d785f7a01ef5

Once updated, I will add it to the Simba repos and it will be included in the Simba Installer.

MylesMadness

2010-07-15 12:50:10

program ReflectionUpdater;
var
MainMenuItem, MenuCheck, MenuUpdate,AutoUpdate : TMenuItem;
started: Boolean;
Timer : TTimer;
Updating : boolean;
LocalR,OnlineR: Integer;

F: TForm;
Memo: TMemo;
but: TButton;


function GetNumbers(const str : string) : string;
var
i : integer;
begin;
for i := 1 to length(str) do
case str[i] of
'0'..'9': result := result + str[i];
end;
end;

procedure GetOnlineVersion(out RefVersion : integer);
begin
RefVersion := strtointdef(GetNumbers(getpage('http://wizzup.org/static/srl/srl_refl_version')),-1);
end;

procedure GetLocalVersion(out RefVersion : integer);
begin
RefVersion := StrToIntDef(Settings.GetKeyValueDef('RefVersion','-1'),-1);
end;


function UpdateRef: boolean;
var
Contents : String;
DeContents : string;
Failed : boolean;
begin
Memo.Lines.Add('Downloading Reflection...');
Contents := GetPage('http://wizzup.org/static/srl/srlref.tar.bz2');
Failed := True;
Memo.Lines.Add('Uncompressing Reflection...');
if DecompressBZip2(Contents,DeContents,4096) then
if UnTarEx(DeContents,IncludePath,true) then
Failed := False;
if not Failed then
Settings.SetKeyValue('RefVersion',inttostr(OnlineR));
if Result then
Result := Failed;
if not Failed then
begin
Memo.Lines.Add('Succesfully updated your Reflection!');
Writeln('Succesfully updated your Reflection!');
end;
end;

procedure DoUpdate(Sender: TObject);
begin
if LocalR < OnlineR then
begin
Memo.Lines.Add('Reflection update. Old version: ' + IntToStr(LocalR) +
' New version: ' + IntToStr(OnlineR));
UpdateRef;
end;
F.ModalResult := mrOk;
end;


function Update : boolean;
var
OpenForm: Boolean;
begin
Result := false;
if Updating then
Exit;
Updating := True;

GetLocalVersion(LocalR);
GetOnlineVersion(OnlineR);

if (LocalR < OnlineR) then
begin
case MessageDlg('Reflection Updater', 'Updates are available. '+
'Do you want to open the Updater now?',
mtConfirmation, [mbNo,mbYes],0) of
mrYes : OpenForm := True;
else
OpenForm := False;
end;
if not OpenForm then
begin
Updating := False;
Exit;
end;
Result := True;
f.ShowModal;
end else
begin
MessageDlg('Reflection Updater', 'No Reflection update' ,mtConfirmation, [mbYes],0);
writeln('No Reflection update');
end;

Updating := False;

end;

procedure OnReflectionCheckClick(Sender: TObject);
var
LocalR,OnlineR : integer;
begin
GetLocalVersion(LocalR);
GetOnlineVersion(OnlineR);

if (LocalR < OnlineR) then
begin
Writeln('A new Reflection version is available');
Update;
end;
end;

procedure SetAutoUpdate(Sender: TObject);
begin
AutoUpdate.Checked := not AutoUpdate.Checked;
Timer.Enabled := AutoUpdate.Checked;
if LowerCase(Settings.GetKeyValueDef('AutoUpdate','True')) = 'true' then
Settings.SetKeyValue('AutoUpdate', 'False')
else
Settings.SetKeyValue('AutoUpdate', 'True');
end;

procedure OnReflectionUpdateClick(Sender: TObject);
begin
Update;
end;

procedure OnUpdateTimer(Sender: TObject);
begin;
Timer.Interval := 30 * 60 * 1000; //Every half hour
Update;
end;

procedure Init;
begin;
MainMenuItem := TMenuItem.Create(Simba_MainMenu);
MainMenuItem.Caption := 'Reflection';
Simba_MainMenu.Items.Add(MainMenuItem);

MenuCheck := TMenuItem.Create(MainMenuItem);
MenuCheck.Caption := 'Check for new Reflection';
MenuCheck.OnClick := @OnReflectionCheckClick;
MainMenuItem.Add(MenuCheck);

MenuUpdate := TMenuItem.Create(MainMenuItem);
MenuUpdate.Caption := 'Update Reflection';
MenuUpdate.OnClick := @OnReflectionUpdateClick;
MainMenuItem.Add(MenuUpdate);

AutoUpdate := TMenuItem.Create(MainMenuItem);
AutoUpdate.Caption := 'Automatically update';
AutoUpdate.OnClick := @SetAutoUpdate;
AutoUpdate.Checked := LowerCase(Settings.GetKeyValueDef('AutoUpdate','True')) = 'true';
MainMenuItem.Add(AutoUpdate);

Timer := TTimer.Create(Simba);
Timer.Interval := 5000;
Timer.OnTimer := @OnUpdateTimer;
Timer.Enabled :=AutoUpdate.Checked;

F := TForm.Create(nil);
With F Do
begin
Visible := False;
Width := 300;
Height := 300;
BorderStyle := bsSingle;
Caption := 'Reflection Updater - Updates Available';
end;

but := TButton.Create(F);

with but do
begin
Parent := F;
Left := 10;
Top := 10;
Caption := 'Update';
Width := 280;

OnClick := @DoUpdate;
end;

Memo := TMemo.Create(F);

with Memo do
begin
Parent := F;
Left := 10;
Top := 40;
Width := 280;
Height := 250;
end;

started := True;
end;

procedure Free;
begin
if (started) then
Timer.Enabled := False;//Freeing the components is not needed, as they will be freed upon the freeing of Simba.
if F <> nil then
F.Free;
end;

procedure Attach;
begin;
Writeln('From now on, you shall be alerted as to when your Reflection is out of date!');
MainMenuItem.Visible := True;
Timer.Enabled := AutoUpdate.Checked;
end;

Procedure Detach;
begin
Timer.Enabled := False;
MainMenuItem.Visible := False;
end;

function GetName : string;
begin;
result := 'Reflection Updater';
end;

function GetVersion : string;
begin;
result := '1.0';
end;

begin
end.

Wizzup?

2010-07-15 14:26:41

Pushed to git

Sir R. M8gic1an

2010-07-16 14:50:48


program ReflectionUpdater;

const
INCLUDE_NAME = 'Reflection';
ONLINE_VERSION_URL = 'http://wizzup.org/static/srl/srl_refl_version';
CONTENTS_URL = 'http://wizzup.org/static/srl/srlref.tar.bz2';
VAR_NAME = 'RefVersion';

var
MainMenuItem, MenuCheck, MenuUpdate,AutoUpdate : TMenuItem;
started: Boolean;
Timer : TTimer;
Updating : boolean;
LocalR,OnlineR: Integer;

F: TForm;
Memo: TMemo;
but: TButton;


function GetNumbers(const str : string) : string;
var
i : integer;
begin;
for i := 1 to length(str) do
case str[i] of
'0'..'9': result := result + str[i];
end;
end;

procedure GetOnlineVersion(out RefVersion : integer);
begin
RefVersion := strtointdef(GetNumbers(getpage(ONLINE_VERSION_URL)),-1);
end;

procedure GetLocalVersion(out RefVersion : integer);
begin
RefVersion := StrToIntDef(Settings.GetKeyValueDef(VAR_NAME,'-1'),-1);
end;


function UpdateRef: boolean;
var
Contents : String;
DeContents : string;
Failed : boolean;
begin
Memo.Lines.Add('Downloading' + INCLUDE_NAME + '...');
Contents := GetPage(CONTENTS_URL);
Failed := True;
Memo.Lines.Add('Uncompressing ' + INCLUDE_NAME + '...');
if DecompressBZip2(Contents,DeContents,4096) then
if UnTarEx(DeContents,IncludePath,true) then
Failed := False;
if not Failed then
Settings.SetKeyValue(VAR_NAME,inttostr(OnlineR));
if Result then
Result := Failed;
if not Failed then
begin
Memo.Lines.Add('Succesfully updated your ' + INCLUDE_NAME + '!');
Writeln('Succesfully updated your ' + INCLUDE_NAME + '!');
end;
end;

procedure DoUpdate(Sender: TObject);
begin
if LocalR < OnlineR then
begin
Memo.Lines.Add(INCLUDE_NAME + ' updated. Old version: ' + IntToStr(LocalR) +
' New version: ' + IntToStr(OnlineR));
UpdateRef;
end;
F.ModalResult := mrOk;
end;


function Update : boolean;
var
OpenForm: Boolean;
begin
Result := false;
if Updating then
Exit;
Updating := True;

GetLocalVersion(LocalR);
GetOnlineVersion(OnlineR);

if (LocalR < OnlineR) then
begin
case MessageDlg(INCLUDE_NAME + ' Updater', 'Updates are available. '+
'Do you want to open the Updater now?',
mtConfirmation, [mbNo,mbYes],0) of
mrYes : OpenForm := True;
else
OpenForm := False;
end;
if not OpenForm then
begin
Updating := False;
Exit;
end;
Result := True;
f.ShowModal;
end else
begin
MessageDlg(INCLUDE_NAME + ' Updater', 'No ' + INCLUDE_NAME + ' updates' ,mtConfirmation, [mbYes],0);
writeln('No ' + INCLUDE_NAME + ' update');
end;

Updating := False;

end;

procedure OnReflectionCheckClick(Sender: TObject);
var
LocalR,OnlineR : integer;
begin
GetLocalVersion(LocalR);
GetOnlineVersion(OnlineR);

if (LocalR < OnlineR) then
begin
Writeln('A new ' + INCLUDE_NAME + ' version is available');
Update;
end;
end;

procedure SetAutoUpdate(Sender: TObject);
begin
AutoUpdate.Checked := not AutoUpdate.Checked;
Timer.Enabled := AutoUpdate.Checked;
if LowerCase(Settings.GetKeyValueDef('AutoUpdate','True')) = 'true' then
Settings.SetKeyValue('AutoUpdate', 'False')
else
Settings.SetKeyValue('AutoUpdate', 'True');
end;

procedure OnReflectionUpdateClick(Sender: TObject);
begin
Update;
end;

procedure OnUpdateTimer(Sender: TObject);
begin;
Timer.Interval := 30 * 60 * 1000; //Every half hour
Update;
end;

procedure Init;
begin;
MainMenuItem := TMenuItem.Create(Simba_MainMenu);
MainMenuItem.Caption := INCLUDE_NAME;
Simba_MainMenu.Items.Add(MainMenuItem);

MenuCheck := TMenuItem.Create(MainMenuItem);
MenuCheck.Caption := 'Check for new ' + INCLUDE_NAME;
MenuCheck.OnClick := @OnReflectionCheckClick;
MainMenuItem.Add(MenuCheck);

MenuUpdate := TMenuItem.Create(MainMenuItem);
MenuUpdate.Caption := 'Update ' + INCLUDE_NAME;
MenuUpdate.OnClick := @OnReflectionUpdateClick;
MainMenuItem.Add(MenuUpdate);

AutoUpdate := TMenuItem.Create(MainMenuItem);
AutoUpdate.Caption := 'Automatically update';
AutoUpdate.OnClick := @SetAutoUpdate;
AutoUpdate.Checked := LowerCase(Settings.GetKeyValueDef('AutoUpdate','True')) = 'true';
MainMenuItem.Add(AutoUpdate);

Timer := TTimer.Create(Simba);
Timer.Interval := 5000;
Timer.OnTimer := @OnUpdateTimer;
Timer.Enabled :=AutoUpdate.Checked;

F := TForm.Create(nil);
With F Do
begin
Visible := False;
Width := 300;
Height := 300;
BorderStyle := bsSingle;
Caption := INCLUDE_NAME + ' Updater - Updates Available';
end;

but := TButton.Create(F);

with but do
begin
Parent := F;
Left := 10;
Top := 10;
Caption := 'Update';
Width := 280;

OnClick := @DoUpdate;
end;

Memo := TMemo.Create(F);

with Memo do
begin
Parent := F;
Left := 10;
Top := 40;
Width := 280;
Height := 250;
end;

started := True;
end;

procedure Free;
begin
if (started) then
Timer.Enabled := False;//Freeing the components is not needed, as they will be freed upon the freeing of Simba.
if F <> nil then
F.Free;
end;

procedure Attach;
begin;
Writeln('From now on, you shall be alerted as to when your Reflection is out of date!');
MainMenuItem.Visible := True;
Timer.Enabled := AutoUpdate.Checked;
end;

Procedure Detach;
begin
Timer.Enabled := False;
MainMenuItem.Visible := False;
end;

function GetName : string;
begin;
result := INCLUDE_NAME + ' Updater';
end;

function GetVersion : string;
begin;
result := '1.0';
end;

begin
end.

Modded it to use constants. Will make it easier to convert it into any include updater :)

~RM

Wizzup?

2010-07-17 05:47:45

From: Rasta Magician

program ReflectionUpdater;

const
INCLUDE_NAME = 'Reflection';
ONLINE_VERSION_URL = 'http://wizzup.org/static/srl/srl_refl_version';
CONTENTS_URL = 'http://wizzup.org/static/srl/srlref.tar.bz2';
VAR_NAME = 'RefVersion';

var
MainMenuItem, MenuCheck, MenuUpdate,AutoUpdate : TMenuItem;
started: Boolean;
Timer : TTimer;
Updating : boolean;
LocalR,OnlineR: Integer;

F: TForm;
Memo: TMemo;
but: TButton;


function GetNumbers(const str : string) : string;
var
i : integer;
begin;
for i := 1 to length(str) do
case str[i] of
'0'..'9': result := result + str[i];
end;
end;

procedure GetOnlineVersion(out RefVersion : integer);
begin
RefVersion := strtointdef(GetNumbers(getpage(ONLINE_VERSION_URL)),-1);
end;

procedure GetLocalVersion(out RefVersion : integer);
begin
RefVersion := StrToIntDef(Settings.GetKeyValueDef(VAR_NAME,'-1'),-1);
end;


function UpdateRef: boolean;
var
Contents : String;
DeContents : string;
Failed : boolean;
begin
Memo.Lines.Add('Downloading' + INCLUDE_NAME + '...');
Contents := GetPage(CONTENTS_URL);
Failed := True;
Memo.Lines.Add('Uncompressing ' + INCLUDE_NAME + '...');
if DecompressBZip2(Contents,DeContents,4096) then
if UnTarEx(DeContents,IncludePath,true) then
Failed := False;
if not Failed then
Settings.SetKeyValue(VAR_NAME,inttostr(OnlineR));
if Result then
Result := Failed;
if not Failed then
begin
Memo.Lines.Add('Succesfully updated your ' + INCLUDE_NAME + '!');
Writeln('Succesfully updated your ' + INCLUDE_NAME + '!');
end;
end;

procedure DoUpdate(Sender: TObject);
begin
if LocalR < OnlineR then
begin
Memo.Lines.Add(INCLUDE_NAME + ' updated. Old version: ' + IntToStr(LocalR) +
' New version: ' + IntToStr(OnlineR));
UpdateRef;
end;
F.ModalResult := mrOk;
end;


function Update : boolean;
var
OpenForm: Boolean;
begin
Result := false;
if Updating then
Exit;
Updating := True;

GetLocalVersion(LocalR);
GetOnlineVersion(OnlineR);

if (LocalR < OnlineR) then
begin
case MessageDlg(INCLUDE_NAME + ' Updater', 'Updates are available. '+
'Do you want to open the Updater now?',
mtConfirmation, [mbNo,mbYes],0) of
mrYes : OpenForm := True;
else
OpenForm := False;
end;
if not OpenForm then
begin
Updating := False;
Exit;
end;
Result := True;
f.ShowModal;
end else
begin
MessageDlg(INCLUDE_NAME + ' Updater', 'No ' + INCLUDE_NAME + ' updates' ,mtConfirmation, [mbYes],0);
writeln('No ' + INCLUDE_NAME + ' update');
end;

Updating := False;

end;

procedure OnReflectionCheckClick(Sender: TObject);
var
LocalR,OnlineR : integer;
begin
GetLocalVersion(LocalR);
GetOnlineVersion(OnlineR);

if (LocalR < OnlineR) then
begin
Writeln('A new ' + INCLUDE_NAME + ' version is available');
Update;
end;
end;

procedure SetAutoUpdate(Sender: TObject);
begin
AutoUpdate.Checked := not AutoUpdate.Checked;
Timer.Enabled := AutoUpdate.Checked;
if LowerCase(Settings.GetKeyValueDef('AutoUpdate','True')) = 'true' then
Settings.SetKeyValue('AutoUpdate', 'False')
else
Settings.SetKeyValue('AutoUpdate', 'True');
end;

procedure OnReflectionUpdateClick(Sender: TObject);
begin
Update;
end;

procedure OnUpdateTimer(Sender: TObject);
begin;
Timer.Interval := 30 * 60 * 1000; //Every half hour
Update;
end;

procedure Init;
begin;
MainMenuItem := TMenuItem.Create(Simba_MainMenu);
MainMenuItem.Caption := INCLUDE_NAME;
Simba_MainMenu.Items.Add(MainMenuItem);

MenuCheck := TMenuItem.Create(MainMenuItem);
MenuCheck.Caption := 'Check for new ' + INCLUDE_NAME;
MenuCheck.OnClick := @OnReflectionCheckClick;
MainMenuItem.Add(MenuCheck);

MenuUpdate := TMenuItem.Create(MainMenuItem);
MenuUpdate.Caption := 'Update ' + INCLUDE_NAME;
MenuUpdate.OnClick := @OnReflectionUpdateClick;
MainMenuItem.Add(MenuUpdate);

AutoUpdate := TMenuItem.Create(MainMenuItem);
AutoUpdate.Caption := 'Automatically update';
AutoUpdate.OnClick := @SetAutoUpdate;
AutoUpdate.Checked := LowerCase(Settings.GetKeyValueDef('AutoUpdate','True')) = 'true';
MainMenuItem.Add(AutoUpdate);

Timer := TTimer.Create(Simba);
Timer.Interval := 5000;
Timer.OnTimer := @OnUpdateTimer;
Timer.Enabled :=AutoUpdate.Checked;

F := TForm.Create(nil);
With F Do
begin
Visible := False;
Width := 300;
Height := 300;
BorderStyle := bsSingle;
Caption := INCLUDE_NAME + ' Updater - Updates Available';
end;

but := TButton.Create(F);

with but do
begin
Parent := F;
Left := 10;
Top := 10;
Caption := 'Update';
Width := 280;

OnClick := @DoUpdate;
end;

Memo := TMemo.Create(F);

with Memo do
begin
Parent := F;
Left := 10;
Top := 40;
Width := 280;
Height := 250;
end;

started := True;
end;

procedure Free;
begin
if (started) then
Timer.Enabled := False;//Freeing the components is not needed, as they will be freed upon the freeing of Simba.
if F <> nil then
F.Free;
end;

procedure Attach;
begin;
Writeln('From now on, you shall be alerted as to when your Reflection is out of date!');
MainMenuItem.Visible := True;
Timer.Enabled := AutoUpdate.Checked;
end;

Procedure Detach;
begin
Timer.Enabled := False;
MainMenuItem.Visible := False;
end;

function GetName : string;
begin;
result := INCLUDE_NAME + ' Updater';
end;

function GetVersion : string;
begin;
result := '1.0';
end;

begin
end.

Modded it to use constants. Will make it easier to convert it into any include updater :)

~RM


Could you also perhaps do this to the one in git? I changed a bit in Myles version.

Sir R. M8gic1an

2010-07-20 16:29:28

I would suggest having four separate ones.

One for Pluggins,
One for SRL,
One for Ref,
One for MSI.

We can load them up as records, and we can even just run through an array, checking and updating the whole thing.

Otherwise I don't really find it worth it.

We can always have settings to only update X

~RM

Wizzup?

2010-07-20 16:41:21

The idea is that SRL / Plugins is the core stuff you need, and Reflection is additional. :)

Sir R. M8gic1an

2010-07-21 08:36:09

From: Wizzup?
The idea is that SRL / Plugins is the core stuff you need, and Reflection is additional. :)


[php]
const
UpdateSRL = true;
UpdatePlugins = true;
UpdateReflection = false;
[/php]

Simba -> Extensions -> SRL.sex -> Settings
- - UpdateSRL: true
- - UpdatePlugins: true
- - UpdateReflection: false

That would fit, no? Easier to manage as well.

~RM

Wizzup?

2010-07-21 09:03:33

Sure… If you make it we can put it in 1.0

MylesMadness

2010-07-21 15:31:51

From: Rasta Magician
[php]
const
UpdateSRL = true;
UpdatePlugins = true;
UpdateReflection = false;
[/php]

Simba -> Extensions -> SRL.sex -> Settings
- - UpdateSRL: true
- - UpdatePlugins: true
- - UpdateReflection: false

That would fit, no? Easier to manage as well.

~RM
I started to do this. Didn't finish though.

program SRLUpdater;
var
MainMenuItem, MenuCheck, MenuUpdate,AutoUpdate : TMenuItem;
started: Boolean;
Timer : TTimer;
Updating : boolean;
LocalP,LocalS,LocalR,OnlineP,OnlineS,OnlineR: Integer;

F: TForm;
Memo: TMemo;
but: TButton;


function GetNumbers(const str : string) : string;
var
i : integer;
begin;
for i := 1 to length(str) do
case str[i] of
'0'..'9': result := result + str[i];
end;
end;

procedure GetOnlineVersion(out PluginsVersion,SRLVersion,RefVersion : integer);
begin
PluginsVersion := strtointdef(GetNumbers(getpage('http://wizzup.org/static/srl/plugins_version')),-1);
SRLVersion := strtointdef(GetNumbers(getpage('http://wizzup.org/static/srl/srl_version')),-1);
RefVersion := strtointdef(GetNumbers(getpage('http://wizzup.org/static/srl/srl_refl_version')),-1);
end;

procedure GetLocalVersion(out PluginsVersion,SRLVersion,RefVersion : integer);
begin
PluginsVersion := StrToIntDef(Settings.GetKeyValueDef('PluginsVersion','-1'),-1);
SRLVersion := StrToIntDef(Settings.GetKeyValueDef('SRLVersion','-1'),-1);
RefVersion := StrToIntDef(Settings.GetKeyValueDef('RefVersion','-1'),-1);
end;

function UpdatePlugins: Boolean;
var
I : integer;
Contents : String;
DeContents : string;
Files : TStringArray;
Failed,OverWrite : boolean;
begin
Memo.Lines.Add('Downloading the plugins...');
Contents := GetPage('http://wizzup.org/static/srl/simba_plugins.tar.bz2');
Memo.Lines.Add('Uncompressing the plugins...');
Failed := True;
if DecompressBZip2(Contents,DeContents,4096) then
if ForceDirectories(IncludePath + 'SRL/SimbaPlugins/') then
if UnTarEx(DeContents,IncludePath + 'SRL/SimbaPlugins/',true) then
begin;
Files := GetFiles(IncludePath + 'SRL/SimbaPlugins/','dll');
for i := 0 to high(Files) do
if FileExists(PluginPath + Files[i]) then
OverWrite := True;
if OverWrite then
begin;
case MessageDlg('SRL Updater', 'Do you want to overwrite the plugins?' ,mtConfirmation, [mbNo,mbYes],0) of
mrYes : Failed := not UnTarEx(DeContents,PluginPath,True)
else
Failed := not UnTarEx(DeContents,PluginPath,false);
end;
Writeln('A restart is necessary to activate the new plugins.');
end else
Failed := not UnTarEx(DeContents,PluginPath,false);
end;
if Failed then
begin
Writeln('Failed to update the plugins');
Memo.Lines.Add('Failed to update the plugins');
end
else
begin
Writeln('Succesfully updated your plugins.');
Memo.Lines.Add('Succesfully updated your plugins.');
end;
DeContents := '';
Contents := '';
Result := Failed;
if not Failed then
Settings.SetKeyValue('PluginsVersion',inttostr(OnlineP));
end;

function UpdateSRL: boolean;
var
Contents : String;
DeContents : string;
Failed : boolean;
begin
Memo.Lines.Add('Downloading SRL...');
Contents := GetPage('http://wizzup.org/static/srl/srl.tar.bz2');
Failed := True;
Memo.Lines.Add('Uncompressing SRL...');
if DecompressBZip2(Contents,DeContents,4096) then
if UnTarEx(DeContents,IncludePath,true) then
Failed := False;
if not Failed then
Settings.SetKeyValue('SRLVersion',inttostr(OnlineS));
if Result then
Result := Failed;
if not Failed then
begin
Memo.Lines.Add('Succesfully updated your SRL!');
Writeln('Succesfully updated your SRL!');
end;
end;

function UpdateRef: boolean;
var
Contents : String;
DeContents : string;
Failed : boolean;
begin
Memo.Lines.Add('Downloading Reflection...');
Contents := GetPage('http://wizzup.org/static/srl/srlref.tar.bz2');
Failed := True;
Memo.Lines.Add('Uncompressing Reflection...');
if DecompressBZip2(Contents,DeContents,4096) then
if UnTarEx(DeContents,IncludePath,true) then
Failed := False;
if not Failed then
Settings.SetKeyValue('RefVersion',inttostr(OnlineR));
if Result then
Result := Failed;
if not Failed then
begin
Memo.Lines.Add('Succesfully updated your Reflection!');
Writeln('Succesfully updated your Reflection!');
end;
end;

procedure DoUpdate(Sender: TObject);
begin
if LocalP < OnlineP then
begin
Memo.Lines.Add('Plugins update. Old version: ' + IntToStr(LocalP) +
' New version: ' + IntToStr(OnlineP));
UpdatePlugins;
end;
if LocalS < OnlineS then
begin
Memo.Lines.Add('SRL update. Old version: ' + IntToStr(LocalS) +
' New version: ' + IntToStr(OnlineS));
UpdateSRL;
end;
if LocalR < OnlineR then
begin
Memo.Lines.Add('Reflection update. Old version: ' + IntToStr(LocalR) +
' New version: ' + IntToStr(OnlineR));
UpdateRef;
end;
F.ModalResult := mrOk;
end;


function Update : boolean;
var
OpenForm: Boolean;
begin
Result := false;
if Updating then
Exit;
Updating := True;


if (LocalP < OnlineP) or (LocalS < OnlineS) then
begin
case MessageDlg('SRL Updater', 'Updates are available. '+
'Do you want to open the Updater now?',
mtConfirmation, [mbNo,mbYes],0) of
mrYes : OpenForm := True;
else
OpenForm := False;
end;
if not OpenForm then
begin
Updating := False;
Exit;
end;
Result := True;
f.ShowModal;
end else
begin
writeln('No SRL update / Plugins update available!');
end;

Updating := False;

end;

procedure OnSRLCheckClick(Sender: TObject);
var
LocalP,LocalS,OnlineP,OnlineS : integer;
begin
GetLocalVersion(LocalP,LocalS,LocalR);
GetOnlineVersion(OnlineP,OnlineS,OnlineR);
if (OnlineP > LocalP) or (OnlineS > LocalS) or (OnlineR > LocalR) then
begin;
Writeln('A new SRL version is available');
Update;
end;
end;

procedure SetAutoUpdate(Sender: TObject);
begin
AutoUpdate.Checked := not AutoUpdate.Checked;
Timer.Enabled := AutoUpdate.Checked;
if LowerCase(Settings.GetKeyValueDef('AutoUpdate','True')) = 'true' then
Settings.SetKeyValue('AutoUpdate', 'False')
else
Settings.SetKeyValue('AutoUpdate', 'True');
end;

procedure OnSRLUpdateClick(Sender: TObject);
begin
GetLocalVersion(LocalP,LocalS,LocalR);
GetOnlineVersion(OnlineP,OnlineS,OnlineR);
if (OnlineP =< LocalP) or (OnlineS =< LocalS) or (OnlineR =< LocalR) then
MessageDlg('SRL Updater', 'No SRL update / Plugins update available!', mtConfirmation, [mbYes], 0)
else
Update;
end;

procedure OnSRLSettingsClick(Sender: TObject);
begin
end;

procedure OnUpdateTimer(Sender: TObject);
begin;
Timer.Interval := 30 * 60 * 1000; //Every half hour
GetLocalVersion(LocalP,LocalS,LocalR);
GetOnlineVersion(OnlineP,OnlineS,OnlineR);
Update;
end;

procedure Init;
begin;
MainMenuItem := TMenuItem.Create(Simba_MainMenu);
MainMenuItem.Caption := 'SRL';
Simba_MainMenu.Items.Add(MainMenuItem);

MenuCheck := TMenuItem.Create(MainMenuItem);
MenuCheck.Caption := 'Check for new SRL';
MenuCheck.OnClick := @OnSRLCheckClick;
MainMenuItem.Add(MenuCheck);

MenuUpdate := TMenuItem.Create(MainMenuItem);
MenuUpdate.Caption := 'Update SRL';
MenuUpdate.OnClick := @OnSRLUpdateClick;
MainMenuItem.Add(MenuUpdate);

AutoUpdate := TMenuItem.Create(MainMenuItem);
AutoUpdate.Caption := 'Automatically update';
AutoUpdate.OnClick := @SetAutoUpdate;
AutoUpdate.Checked := LowerCase(Settings.GetKeyValueDef('AutoUpdate','True')) = 'true';
MainMenuItem.Add(AutoUpdate);

MenuSettings := TMenuItem.Create(MainMenuItem);
MenuSettings.Caption := 'Settings';
MenuSettings.OnClick := @OnSRLSettingsClick;
MenuSettings.Add(MenuUpdate);

Timer := TTimer.Create(Simba);
Timer.Interval := 5000;
Timer.OnTimer := @OnUpdateTimer;
Timer.Enabled :=AutoUpdate.Checked;

F := TForm.Create(nil);
With F Do
begin
Visible := False;
Width := 300;
Height := 300;
BorderStyle := bsSingle;
Caption := 'SRL Updater - Updates Available';
end;

but := TButton.Create(F);

with but do
begin
Parent := F;
Left := 10;
Top := 10;
Caption := 'Update';
Width := 280;

OnClick := @DoUpdate;
end;

Memo := TMemo.Create(F);

with Memo do
begin
Parent := F;
Left := 10;
Top := 40;
Width := 280;
Height := 250;
end;

started := True;
end;

procedure Free;
begin
if (started) then
Timer.Enabled := False;//Freeing the components is not needed, as they will be freed upon the freeing of Simba.
if F <> nil then
F.Free;
end;

procedure Attach;
begin;
Writeln('From now on, you shall be alerted as to when your SRL is out of date!');
MainMenuItem.Visible := True;
Timer.Enabled := AutoUpdate.Checked;
end;

Procedure Detach;
begin
Timer.Enabled := False;
MainMenuItem.Visible := False;
end;

function GetName : string;
begin;
result := 'SRL Updater';
end;

function GetVersion : string;
begin;
result := '1.0';
end;

begin
end.

Sir R. M8gic1an

2010-07-23 05:25:39

This is more along the lines of what I meant:


program SRLUpdater;

type
TInclude = Record
name : String;
varName : String;
reposURL : String;
localV : integer;
onlineV : integer;
outdated : boolean;
end;

var
MainMenuItem, MenuCheck, MenuUpdate,AutoUpdate : TMenuItem;
started: Boolean;
Timer : TTimer;
Updating : boolean;
LocalP,LocalS,LocalR,OnlineP,OnlineS,OnlineR: Integer;

F: TForm;
Memo: TMemo;
but: TButton;

Includes: array of TInclude;

const
I_SRL = 0;
I_Pluggins = 1;
I_Ref = 2;

Procedure LoadIncludes;
var
i: integer;
begin
SetLength(Includes, 3);

with Includes[I_SRL] do
begin
name := 'SRL';
varName := 'SRLVersion';
reposURL := 'http://wizzup.org/static/srl/srl.tar.bz2';
onlineV := strtointdef(GetNumbers(getpage('http://wizzup.org/static/srl/srl_version')),-1);
end;

with Includes[I_Pluggins] do
begin
name := 'Pluggins';
varName := 'PlugginsVersion';
reposURL := 'http://wizzup.org/static/srl/simba_plugins.tar.bz2';
onlineV := strtointdef(GetNumbers(getpage('http://wizzup.org/static/srl/plugins_version')),-1);
end;

with Includes[I_Ref] do
begin
name := 'Reflection';
varName := 'RefVersion';
reposURL := 'http://wizzup.org/static/srl/srlref.tar.bz2';
onlineV := strtointdef(GetNumbers(getpage('http://wizzup.org/static/srl/srl_refl_version')),-1);
end;

for i := High(Includes) DownTo 0 do
begin
localV := StrToIntDef(Settings.GetKeyValueDef(Includes[i].varName, '-1'), -1);

if Includes[i].onlineV > Includes[i].localV then
Includes[i].outdated := true;

end;

end;

function GetNumbers(const str : string) : string;
var
i : integer;
begin;
for i := 1 to length(str) do
case str[i] of
'0'..'9': result := result + str[i];
end;
end;

function UpdatePlugins: Boolean;
var
I : integer;
Contents : String;
DeContents : string;
Files : TStringArray;
Failed,OverWrite : boolean;
begin
Memo.Lines.Add('Downloading the plugins...');
Contents := GetPage('http://wizzup.org/static/srl/simba_plugins.tar.bz2');
Memo.Lines.Add('Uncompressing the plugins...');
Failed := True;
if DecompressBZip2(Contents,DeContents,4096) then
if ForceDirectories(IncludePath + 'SRL/SimbaPlugins/') then
if UnTarEx(DeContents,IncludePath + 'SRL/SimbaPlugins/',true) then
begin;
Files := GetFiles(IncludePath + 'SRL/SimbaPlugins/','dll');
for i := 0 to high(Files) do
if FileExists(PluginPath + Files[i]) then
OverWrite := True;
if OverWrite then
begin;
case MessageDlg('SRL Updater', 'Do you want to overwrite the plugins?' ,mtConfirmation, [mbNo,mbYes],0) of
mrYes : Failed := not UnTarEx(DeContents,PluginPath,True)
else
Failed := not UnTarEx(DeContents,PluginPath,false);
end;
Writeln('A restart is necessary to activate the new plugins.');
end else
Failed := not UnTarEx(DeContents,PluginPath,false);
end;
if Failed then
begin
Writeln('Failed to update the plugins');
Memo.Lines.Add('Failed to update the plugins');
end
else
begin
Writeln('Succesfully updated your plugins.');
Memo.Lines.Add('Succesfully updated your plugins.');
end;
DeContents := '';
Contents := '';
Result := Failed;
if not Failed then
Settings.SetKeyValue('PluginsVersion',inttostr(OnlineP));
end;

function UpdateSRL: boolean;
var
Contents : String;
DeContents : string;
Failed : boolean;
begin
Memo.Lines.Add('Downloading SRL...');
Contents := GetPage('http://wizzup.org/static/srl/srl.tar.bz2');
Failed := True;
Memo.Lines.Add('Uncompressing SRL...');
if DecompressBZip2(Contents,DeContents,4096) then
if UnTarEx(DeContents,IncludePath,true) then
Failed := False;
if not Failed then
Settings.SetKeyValue('SRLVersion',inttostr(OnlineS));
if Result then
Result := Failed;
if not Failed then
begin
Memo.Lines.Add('Succesfully updated your SRL!');
Writeln('Succesfully updated your SRL!');
end;
end;

function UpdateRef: boolean;
var
Contents : String;
DeContents : string;
Failed : boolean;
begin
Memo.Lines.Add('Downloading Reflection...');
Contents := GetPage('http://wizzup.org/static/srl/srlref.tar.bz2');
Failed := True;
Memo.Lines.Add('Uncompressing Reflection...');
if DecompressBZip2(Contents,DeContents,4096) then
if UnTarEx(DeContents,IncludePath,true) then
Failed := False;
if not Failed then
Settings.SetKeyValue('RefVersion',inttostr(OnlineR));
if Result then
Result := Failed;
if not Failed then
begin
Memo.Lines.Add('Succesfully updated your Reflection!');
Writeln('Succesfully updated your Reflection!');
end;
end;

procedure DoUpdate(Sender: TObject);
begin
if LocalP < OnlineP then
begin
Memo.Lines.Add('Plugins update. Old version: ' + IntToStr(LocalP) +
' New version: ' + IntToStr(OnlineP));
UpdatePlugins;
end;
if LocalS < OnlineS then
begin
Memo.Lines.Add('SRL update. Old version: ' + IntToStr(LocalS) +
' New version: ' + IntToStr(OnlineS));
UpdateSRL;
end;
if LocalR < OnlineR then
begin
Memo.Lines.Add('Reflection update. Old version: ' + IntToStr(LocalR) +
' New version: ' + IntToStr(OnlineR));
UpdateRef;
end;
F.ModalResult := mrOk;
end;


function Update : boolean;
var
OpenForm: Boolean;
begin
Result := false;
if Updating then
Exit;
Updating := True;


if (LocalP < OnlineP) or (LocalS < OnlineS) then
begin
case MessageDlg('SRL Updater', 'Updates are available. '+
'Do you want to open the Updater now?',
mtConfirmation, [mbNo,mbYes],0) of
mrYes : OpenForm := True;
else
OpenForm := False;
end;
if not OpenForm then
begin
Updating := False;
Exit;
end;
Result := True;
f.ShowModal;
end else
begin
writeln('No SRL update / Plugins update available!');
end;

Updating := False;

end;

procedure OnSRLCheckClick(Sender: TObject);
var
LocalP,LocalS,OnlineP,OnlineS : integer;
begin
GetLocalVersion(LocalP,LocalS,LocalR);
GetOnlineVersion(OnlineP,OnlineS,OnlineR);
if (OnlineP > LocalP) or (OnlineS > LocalS) or (OnlineR > LocalR) then
begin;
Writeln('A new SRL version is available');
Update;
end;
end;

procedure SetAutoUpdate(Sender: TObject);
begin
AutoUpdate.Checked := not AutoUpdate.Checked;
Timer.Enabled := AutoUpdate.Checked;
if LowerCase(Settings.GetKeyValueDef('AutoUpdate','True')) = 'true' then
Settings.SetKeyValue('AutoUpdate', 'False')
else
Settings.SetKeyValue('AutoUpdate', 'True');
end;

procedure OnSRLUpdateClick(Sender: TObject);
begin
GetLocalVersion(LocalP,LocalS,LocalR);
GetOnlineVersion(OnlineP,OnlineS,OnlineR);
if (OnlineP =< LocalP) or (OnlineS =< LocalS) or (OnlineR =< LocalR) then
MessageDlg('SRL Updater', 'No SRL update / Plugins update available!', mtConfirmation, [mbYes], 0)
else
Update;
end;

procedure OnSRLSettingsClick(Sender: TObject);
begin
end;

procedure OnUpdateTimer(Sender: TObject);
begin;
Timer.Interval := 30 * 60 * 1000; //Every half hour
GetLocalVersion(LocalP,LocalS,LocalR);
GetOnlineVersion(OnlineP,OnlineS,OnlineR);
Update;
end;

procedure Init;
begin;
MainMenuItem := TMenuItem.Create(Simba_MainMenu);
MainMenuItem.Caption := 'SRL';
Simba_MainMenu.Items.Add(MainMenuItem);

MenuCheck := TMenuItem.Create(MainMenuItem);
MenuCheck.Caption := 'Check for new SRL';
MenuCheck.OnClick := @OnSRLCheckClick;
MainMenuItem.Add(MenuCheck);

MenuUpdate := TMenuItem.Create(MainMenuItem);
MenuUpdate.Caption := 'Update SRL';
MenuUpdate.OnClick := @OnSRLUpdateClick;
MainMenuItem.Add(MenuUpdate);

AutoUpdate := TMenuItem.Create(MainMenuItem);
AutoUpdate.Caption := 'Automatically update';
AutoUpdate.OnClick := @SetAutoUpdate;
AutoUpdate.Checked := LowerCase(Settings.GetKeyValueDef('AutoUpdate','True')) = 'true';
MainMenuItem.Add(AutoUpdate);

MenuSettings := TMenuItem.Create(MainMenuItem);
MenuSettings.Caption := 'Settings';
MenuSettings.OnClick := @OnSRLSettingsClick;
MenuSettings.Add(MenuUpdate);

Timer := TTimer.Create(Simba);
Timer.Interval := 5000;
Timer.OnTimer := @OnUpdateTimer;
Timer.Enabled :=AutoUpdate.Checked;

F := TForm.Create(nil);
With F Do
begin
Visible := False;
Width := 300;
Height := 300;
BorderStyle := bsSingle;
Caption := 'SRL Updater - Updates Available';
end;

but := TButton.Create(F);

with but do
begin
Parent := F;
Left := 10;
Top := 10;
Caption := 'Update';
Width := 280;

OnClick := @DoUpdate;
end;

Memo := TMemo.Create(F);

with Memo do
begin
Parent := F;
Left := 10;
Top := 40;
Width := 280;
Height := 250;
end;

started := True;
end;

procedure Free;
begin
if (started) then
Timer.Enabled := False;//Freeing the components is not needed, as they will be freed upon the freeing of Simba.
if F <> nil then
F.Free;
end;

procedure Attach;
begin;
Writeln('From now on, you shall be alerted as to when your SRL is out of date!');
MainMenuItem.Visible := True;
Timer.Enabled := AutoUpdate.Checked;
end;

Procedure Detach;
begin
Timer.Enabled := False;
MainMenuItem.Visible := False;
end;

function GetName : string;
begin;
result := 'SRL Updater';
end;

function GetVersion : string;
begin;
result := '1.0';
end;

begin
end.

Do notice that it's not finished, as I was on my way to something else :p

(I only did the records part, as it was the main idea behind my thought. With those, there's no need for code repetition.)

~RM

MylesMadness

2010-07-23 15:13:19

program SRLUpdater;

type
TInclude = Record
name : String;
varName : String;
reposURL : String;
localV : integer;
onlineV : integer;
outdated : boolean;
end;

var
MainMenuItem, MenuCheck, MenuUpdate,AutoUpdate : TMenuItem;
started: Boolean;
Timer : TTimer;
Updating : boolean;

F: TForm;
Memo: TMemo;
but: TButton;

Includes: array of TInclude;

const
I_SRL = 0;
I_Pluggins = 1;
I_Ref = 2;

function GetNumbers(const str : string) : string;
var
i : integer;
begin;
for i := 1 to length(str) do
case str[i] of
'0'..'9': result := result + str[i];
end;
end;

Procedure LoadIncludes;
var
i: integer;
begin
SetLength(Includes, 3);

with Includes[I_SRL] do
begin
name := 'SRL';
varName := 'SRLVersion';
reposURL := 'http://wizzup.org/static/srl/srl.tar.bz2';
onlineV := strtointdef(GetNumbers(getpage('http://wizzup.org/static/srl/srl_version')),-1);
end;

with Includes[I_Pluggins] do
begin
name := 'Pluggins';
varName := 'PlugginsVersion';
reposURL := 'http://wizzup.org/static/srl/simba_plugins.tar.bz2';
onlineV := strtointdef(GetNumbers(getpage('http://wizzup.org/static/srl/plugins_version')),-1);
end;

with Includes[I_Ref] do
begin
name := 'Reflection';
varName := 'RefVersion';
reposURL := 'http://wizzup.org/static/srl/srlref.tar.bz2';
onlineV := strtointdef(GetNumbers(getpage('http://wizzup.org/static/srl/srl_refl_version')),-1);
end;

for i := High(Includes) DownTo 0 do
begin
includes[I].localV := StrToIntDef(Settings.GetKeyValueDef(Includes[i].varName, '-1'), -1);

if Includes[i].onlineV > Includes[i].localV then
Includes[i].outdated := true;
end;
end;

function UpdatePlugins: Boolean;
var
I : integer;
Contents : String;
DeContents : string;
Files : TStringArray;
Failed,OverWrite : boolean;
begin
Memo.Lines.Add('Downloading ' + Includes[I_Pluggins].name +'...');
Contents := GetPage(Includes[I_Pluggins].reposURL);
Failed := True;
Memo.Lines.Add('Uncompressing ' + Includes[I_Pluggins].name +'...');
if DecompressBZip2(Contents,DeContents,4096) then
if ForceDirectories(IncludePath + 'SRL/SimbaPlugins/') then
if UnTarEx(DeContents,IncludePath + 'SRL/SimbaPlugins/',true) then
begin;
Files := GetFiles(IncludePath + 'SRL/SimbaPlugins/','dll');
for i := 0 to high(Files) do
if FileExists(PluginPath + Files[i]) then
OverWrite := True;
if OverWrite then
begin;
case MessageDlg('SRL Updater', 'Do you want to overwrite the plugins?' ,mtConfirmation, [mbNo,mbYes],0) of
mrYes : Failed := not UnTarEx(DeContents,PluginPath,True)
else
Failed := not UnTarEx(DeContents,PluginPath,false);
end;
Writeln('A restart is necessary to activate the new plugins.');
end else
Failed := not UnTarEx(DeContents,PluginPath,false);
end;
if Failed then
begin
Writeln('Failed to update the plugins');
Memo.Lines.Add('Failed to update the plugins');
end
else
begin
Writeln('Succesfully updated your plugins.');
Memo.Lines.Add('Succesfully updated your plugins.');
end;
DeContents := '';
Contents := '';
Result := Failed;
if not Failed then
Settings.SetKeyValue('PluginsVersion',inttostr(Includes[I_Pluggins].OnlineV));
end;

Function UpdateInclude(Which:Integer):Boolean;
begin
Memo.Lines.Add('Downloading ' + Includes[Which].name +'...');
Contents := GetPage(Includes[Which].reposURL);
Failed := True;
Memo.Lines.Add('Uncompressing ' + Includes[Which].name +'...');
if DecompressBZip2(Contents,DeContents,4096) then
if UnTarEx(DeContents,IncludePath,true) then
Failed := False;
if not Failed then
Settings.SetKeyValue(Includes[Which].varName, inttostr(Includes[Which].OnlineV));
if Result then
Result := Failed;
if not Failed then
begin
Memo.Lines.Add('Succesfully updated your ' + Includes[Which].name +'!');
Writeln('Succesfully updated your ' + Includes[Which].name +'!');
end;
end;

procedure DoUpdate(Sender: TObject);
begin
if Includes[I_Pluggins].localV < Includes[I_Pluggins].OnlineV then
begin
Memo.Lines.Add('Plugins update. Old version: ' + IntToStr(Includes[I_Pluggins].localV) +
' New version: ' + IntToStr(Includes[I_Pluggins].OnlineV));
UpdatePlugins;
end;
if Includes[I_SRL].localV < Includes[I_SRL].OnlineV then
begin
Memo.Lines.Add('SRL update. Old version: ' + IntToStr(Includes[I_SRL].LocalV) +
' New version: ' + IntToStr(Includes[I_SRL].OnlineV));
UpdateInclude(I_SRL);
end;
if Includes[I_Ref].localV < Includes[I_Ref].OnlineV then
begin
Memo.Lines.Add('Reflection update. Old version: ' + IntToStr(Includes[I_Ref].LocalV) +
' New version: ' + IntToStr(Includes[I_Ref].OnlineV));
UpdateInclude(I_Ref);
end;
F.ModalResult := mrOk;
end;


function Update : boolean;
var
OpenForm: Boolean;
begin
Result := false;
if Updating then
Exit;
Updating := True;


if (Includes[I_SRL].outdated) or (Includes[I_Pluggins].outdated) or (Includes[I_Ref].outdated) then
begin
case MessageDlg('SRL Updater', 'Updates are available. '+
'Do you want to open the Updater now?',
mtConfirmation, [mbNo,mbYes],0) of
mrYes : OpenForm := True;
else
OpenForm := False;
end;
if not OpenForm then
begin
Updating := False;
Exit;
end;
Result := True;
f.ShowModal;
end else
begin
writeln('No SRL update / Plugins update available!');
end;

Updating := False;

end;

procedure OnSRLCheckClick(Sender: TObject);
begin
if (Includes[I_SRL].outdated) or (Includes[I_Pluggins].outdated) or (Includes[I_Ref].outdated) then
begin;
Writeln('A new SRL version is available');
Update;
end;
end;

procedure SetAutoUpdate(Sender: TObject);
begin
AutoUpdate.Checked := not AutoUpdate.Checked;
Timer.Enabled := AutoUpdate.Checked;
if LowerCase(Settings.GetKeyValueDef('AutoUpdate','True')) = 'true' then
Settings.SetKeyValue('AutoUpdate', 'False')
else
Settings.SetKeyValue('AutoUpdate', 'True');
end;

procedure OnSRLUpdateClick(Sender: TObject);
begin
if (Includes[I_SRL].outdated) or (Includes[I_Pluggins].outdated) or (Includes[I_Ref].outdated) then
MessageDlg('SRL Updater', 'No SRL update / Plugins update available!', mtConfirmation, [mbYes], 0)
else
Update;
end;

procedure OnSRLSettingsClick(Sender: TObject);
begin
end;

procedure OnUpdateTimer(Sender: TObject);
begin;
Timer.Interval := 30 * 60 * 1000; //Every half hour
Update;
end;

procedure Init;
begin;
MainMenuItem := TMenuItem.Create(Simba_MainMenu);
MainMenuItem.Caption := 'SRL';
Simba_MainMenu.Items.Add(MainMenuItem);

MenuCheck := TMenuItem.Create(MainMenuItem);
MenuCheck.Caption := 'Check for new SRL';
MenuCheck.OnClick := @OnSRLCheckClick;
MainMenuItem.Add(MenuCheck);

MenuUpdate := TMenuItem.Create(MainMenuItem);
MenuUpdate.Caption := 'Update SRL';
MenuUpdate.OnClick := @OnSRLUpdateClick;
MainMenuItem.Add(MenuUpdate);

AutoUpdate := TMenuItem.Create(MainMenuItem);
AutoUpdate.Caption := 'Automatically update';
AutoUpdate.OnClick := @SetAutoUpdate;
AutoUpdate.Checked := LowerCase(Settings.GetKeyValueDef('AutoUpdate','True')) = 'true';
MainMenuItem.Add(AutoUpdate);

MenuSettings := TMenuItem.Create(MainMenuItem);
MenuSettings.Caption := 'Settings';
MenuSettings.OnClick := @OnSRLSettingsClick;
MenuSettings.Add(MenuUpdate);

Timer := TTimer.Create(Simba);
Timer.Interval := 5000;
Timer.OnTimer := @OnUpdateTimer;
Timer.Enabled :=AutoUpdate.Checked;

F := TForm.Create(nil);
With F Do
begin
Visible := False;
Width := 300;
Height := 300;
BorderStyle := bsSingle;
Caption := 'SRL Updater - Updates Available';
end;

but := TButton.Create(F);

with but do
begin
Parent := F;
Left := 10;
Top := 10;
Caption := 'Update';
Width := 280;

OnClick := @DoUpdate;
end;

Memo := TMemo.Create(F);

with Memo do
begin
Parent := F;
Left := 10;
Top := 40;
Width := 280;
Height := 250;
end;

started := True;
end;

procedure Free;
begin
if (started) then
Timer.Enabled := False;//Freeing the components is not needed, as they will be freed upon the freeing of Simba.
if F <> nil then
F.Free;
end;

procedure Attach;
begin;
Writeln('From now on, you shall be alerted as to when your SRL is out of date!');
MainMenuItem.Visible := True;
Timer.Enabled := AutoUpdate.Checked;
end;

Procedure Detach;
begin
Timer.Enabled := False;
MainMenuItem.Visible := False;
end;

function GetName : string;
begin;
result := 'SRL Updater';
end;

function GetVersion : string;
begin;
result := '1.0';
end;

begin
end.
Moar updates. I think all that needs to be done now is the form itself, checking if it wants to be updated based on the form, and if wanted combining my updateincludes and and updatepluggins functions

Wizzup?

2010-08-11 08:12:47

So who is up to this task? ^

varadinn

2010-08-13 17:34:03

up to the task of doing what Wizzup?

Wizzup?

2010-08-14 06:44:14

Finishing the updater for SRL, Reflection (and MSI). There are currently three different ones, and we'd like to have them all combined into one updater.

MylesMadness

2010-08-27 17:29:43

program SRLUpdater;

type
TInclude = Record
name : String;
varName : String;
reposURL : String;
localV : integer;
onlineV : integer;
outdated : boolean;
end;

var
MainMenuItem, MenuCheck, MenuUpdate,AutoUpdate : TMenuItem;
started: Boolean;
Timer : TTimer;
Updating, NeedSomeUpdating: boolean;

F: TForm;
Memo: TMemo;
but: TButton;

Includes: array of TInclude;

const
I_SRL = 0;
I_Pluggins = 1;
I_Ref = 2;

function GetNumbers(const str : string) : string;
var
i : integer;
begin;
for i := 1 to length(str) do
case str[i] of
'0'..'9': result := result + str[i];
end;
end;

Procedure LoadIncludes;
var
i: integer;
begin
SetLength(Includes, 3);

with Includes[I_SRL] do
begin
name := 'SRL';
varName := 'SRLVersion';
reposURL := 'http://wizzup.org/static/srl/srl.tar.bz2';
onlineV := strtointdef(GetNumbers(getpage('http://wizzup.org/static/srl/srl_version')),-1);
end;

with Includes[I_Pluggins] do
begin
name := 'Pluggins';
varName := 'PlugginsVersion';
reposURL := 'http://wizzup.org/static/srl/simba_plugins.tar.bz2';
onlineV := strtointdef(GetNumbers(getpage('http://wizzup.org/static/srl/plugins_version')),-1);
end;

with Includes[I_Ref] do
begin
name := 'Reflection';
varName := 'RefVersion';
reposURL := 'http://wizzup.org/static/srl/srlref.tar.bz2';
onlineV := strtointdef(GetNumbers(getpage('http://wizzup.org/static/srl/srl_refl_version')),-1);
end;

for i := High(Includes) DownTo 0 do
begin
includes[I].localV := StrToIntDef(Settings.GetKeyValueDef(Includes[i].varName, '-1'), -1);

if Includes[i].onlineV > Includes[i].localV then
begin
NeedSomeUpdating := true;
Includes[i].outdated := true;
end;
end;
end;



function UpdatePlugins: Boolean;
var
I : integer;
Contents : String;
DeContents : string;
Files : TStringArray;
Failed,OverWrite : boolean;
begin
Memo.Lines.Add('Downloading ' + Includes[I_Pluggins].name +'...');
Contents := GetPage(Includes[I_Pluggins].reposURL);
Failed := True;
Memo.Lines.Add('Uncompressing ' + Includes[I_Pluggins].name +'...');
if DecompressBZip2(Contents,DeContents,4096) then
if ForceDirectories(IncludePath + 'SRL/SimbaPlugins/') then
if UnTarEx(DeContents,IncludePath + 'SRL/SimbaPlugins/',true) then
begin;
Files := GetFiles(IncludePath + 'SRL/SimbaPlugins/','dll');
for i := 0 to high(Files) do
if FileExists(PluginPath + Files[i]) then
OverWrite := True;
if OverWrite then
begin;
case MessageDlg('SRL Updater', 'Do you want to overwrite the plugins?' ,mtConfirmation, [mbNo,mbYes],0) of
mrYes : Failed := not UnTarEx(DeContents,PluginPath,True)
else
Failed := not UnTarEx(DeContents,PluginPath,false);
end;
Writeln('A restart is necessary to activate the new plugins.');
end else
Failed := not UnTarEx(DeContents,PluginPath,false);
end;
if Failed then
begin
Writeln('Failed to update the plugins');
Memo.Lines.Add('Failed to update the plugins');
end
else
begin
Writeln('Succesfully updated your plugins.');
Memo.Lines.Add('Succesfully updated your plugins.');
end;
DeContents := '';
Contents := '';
Result := Failed;
if not Failed then
Settings.SetKeyValue('PluginsVersion',inttostr(Includes[I_Pluggins].OnlineV));
end;

Function UpdateInclude(Which:Integer):Boolean;
var
Contents : String;
DeContents : string;
Failed: boolean;
begin
Memo.Lines.Add('Downloading ' + Includes[Which].name +'...');
Contents := GetPage(Includes[Which].reposURL);
Failed := True;
Memo.Lines.Add('Uncompressing ' + Includes[Which].name +'...');
if DecompressBZip2(Contents,DeContents,4096) then
if UnTarEx(DeContents,IncludePath,true) then
Failed := False;
if not Failed then
Settings.SetKeyValue(Includes[Which].varName, inttostr(Includes[Which].OnlineV));
if Result then
Result := Failed;
if not Failed then
begin
Memo.Lines.Add('Succesfully updated your ' + Includes[Which].name +'!');
Writeln('Succesfully updated your ' + Includes[Which].name +'!');
end;
end;

procedure DoUpdate(Sender: TObject);
var
I:integer;
begin
if Includes[I_Pluggins].outdated then
begin
Memo.Lines.Add('Plugins update. Old version: ' + IntToStr(Includes[I_Pluggins].localV) +
' New version: ' + IntToStr(Includes[I_Pluggins].OnlineV));
UpdatePlugins;
end;
for I:=0 to high(Includes) do
begin
if Includes[I].outdated then
begin
Memo.Lines.Add(Includes[I].name+' update. Old version: ' + IntToStr(Includes[I].LocalV) +
' New version: ' + IntToStr(Includes[I].OnlineV));
UpdateInclude(I);
end;
end;
F.ModalResult := mrOk;
end;


function Update : boolean;
var
OpenForm: Boolean;
begin
Result := false;
if Updating then
Exit;
Updating := True;


if NeedSomeUpdating then
begin
case MessageDlg('SRL Updater', 'Updates are available. '+
'Do you want to open the Updater now?',
mtConfirmation, [mbNo,mbYes],0) of
mrYes : OpenForm := True;
else
OpenForm := False;
end;
if not OpenForm then
begin
Updating := False;
Exit;
end;
Result := True;
f.ShowModal;
end else
begin
writeln('No SRL update / Plugins update available!');
end;

Updating := False;

end;

procedure OnSRLCheckClick(Sender: TObject);
begin
if NeedSomeUpdating then
begin;
Writeln('A new SRL version is available');
Update;
end;
end;

procedure SetAutoUpdate(Sender: TObject);
begin
AutoUpdate.Checked := not AutoUpdate.Checked;
Timer.Enabled := AutoUpdate.Checked;
if LowerCase(Settings.GetKeyValueDef('AutoUpdate','True')) = 'true' then
Settings.SetKeyValue('AutoUpdate', 'False')
else
Settings.SetKeyValue('AutoUpdate', 'True');
end;

procedure OnSRLUpdateClick(Sender: TObject);
begin
if NeedSomeUpdating then
MessageDlg('SRL Updater', 'No SRL update / Plugins update available!', mtConfirmation, [mbYes], 0)
else
Update;
end;

procedure OnSRLSettingsClick(Sender: TObject);
begin
end;

procedure OnUpdateTimer(Sender: TObject);
begin;
Timer.Interval := 30 * 60 * 1000; //Every half hour
Update;
end;

procedure Init;
begin;
MainMenuItem := TMenuItem.Create(Simba_MainMenu);
MainMenuItem.Caption := 'SRL';
Simba_MainMenu.Items.Add(MainMenuItem);

MenuCheck := TMenuItem.Create(MainMenuItem);
MenuCheck.Caption := 'Check for new SRL';
MenuCheck.OnClick := @OnSRLCheckClick;
MainMenuItem.Add(MenuCheck);

MenuUpdate := TMenuItem.Create(MainMenuItem);
MenuUpdate.Caption := 'Update SRL';
MenuUpdate.OnClick := @OnSRLUpdateClick;
MainMenuItem.Add(MenuUpdate);

AutoUpdate := TMenuItem.Create(MainMenuItem);
AutoUpdate.Caption := 'Automatically update';
AutoUpdate.OnClick := @SetAutoUpdate;
AutoUpdate.Checked := LowerCase(Settings.GetKeyValueDef('AutoUpdate','True')) = 'true';
MainMenuItem.Add(AutoUpdate);

Timer := TTimer.Create(Simba);
Timer.Interval := 5000;
Timer.OnTimer := @OnUpdateTimer;
Timer.Enabled :=AutoUpdate.Checked;

F := TForm.Create(nil);
With F Do
begin
Visible := False;
Width := 300;
Height := 300;
BorderStyle := bsSingle;
Caption := 'SRL Updater - Updates Available';
end;

but := TButton.Create(F);

with but do
begin
Parent := F;
Left := 10;
Top := 10;
Caption := 'Update';
Width := 280;

OnClick := @DoUpdate;
end;

Memo := TMemo.Create(F);

with Memo do
begin
Parent := F;
Left := 10;
Top := 40;
Width := 280;
Height := 250;
end;

started := True;
end;

procedure Free;
begin
if (started) then
Timer.Enabled := False;//Freeing the components is not needed, as they will be freed upon the freeing of Simba.
{if F <> nil then
F.Free;}
end;

procedure Attach;
begin;
Writeln('From now on, you shall be alerted as to when your SRL is out of date!');
MainMenuItem.Visible := True;
Timer.Enabled := AutoUpdate.Checked;
end;

Procedure Detach;
begin
Timer.Enabled := False;
MainMenuItem.Visible := False;
end;

function GetName : string;
begin;
result := 'SRL Updater';
end;

function GetVersion : string;
begin;
result := '1.0';
end;

begin
end.
I think I broke it. No idea what is wrong but its pretty much done, I think

Wizzup?

2010-09-04 18:31:32

I'm sorry. I lost the other thread. You did post a working one later on, right?