Skip to content

Commit

Permalink
wizard wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Morvan committed Jul 23, 2018
1 parent a0a67c4 commit 2f77f55
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 26 deletions.
18 changes: 18 additions & 0 deletions waptwizard/uwizard.pas
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ TWizard = class(TForm )
procedure on_button_cancel_click( sender : TObject );
procedure set_buttons_enable( enable : Boolean );
procedure _click_next_async( data : PtrInt );
procedure _setfocus_async( data : PtrInt );



Expand All @@ -74,7 +75,10 @@ TWizard = class(TForm )
procedure show_error( const msg : String ); virtual overload; final;
procedure show_validation_error( ctrl : TControl; msg : String ); virtual; final;



procedure click_next_async();
procedure setFocus_async( wc : TWinControl );


procedure launch_console();
Expand Down Expand Up @@ -376,13 +380,27 @@ procedure TWizard._click_next_async(data: PtrInt);
self.WizardButtonPanel.NextButton.Click;
end;

procedure TWizard._setfocus_async(data: PtrInt);
begin
if data = 0 then
exit;

// todo if
TWinControl(data).SetFocus;
end;


procedure TWizard.click_next_async();
begin
Application.QueueAsyncCall( @_click_next_async, 0 );

end;

procedure TWizard.setFocus_async(wc: TWinControl);
begin
Application.QueueAsyncCall( @_setfocus_async, PtrInt(wc) );
end;

procedure TWizard.launch_console();
var
r : integer;
Expand Down
2 changes: 2 additions & 0 deletions waptwizard/uwizardconfigconsole_server.pas
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ procedure TWizardStepFramePassword.wizard_next(var bCanNext: boolean);
procedure TWizardStepFramePassword.wizard_show();
begin
inherited wizard_show();


self.ed_password_1.SetFocus;
end;

Expand Down
10 changes: 3 additions & 7 deletions waptwizard/uwizardconfigserver.pas
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ TWizardConfigServer = class(TWizard)
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject); override;
procedure FormShow(Sender: TObject);
procedure WizardManagerPageHide(Sender: TObject; Page: TWizardPage);

private

Expand Down Expand Up @@ -68,13 +67,15 @@ procedure TWizardConfigServer.FormCreate(Sender: TObject);
inherited;

FillChar( m_data, sizeof(TWizardConfigServerData), 0 );

m_data.is_enterprise_edition := DMPython.IsEnterpriseEdition;
m_data.check_certificates_validity := '0';
m_data.verify_cert := '0';

end;

procedure TWizardConfigServer.FormShow(Sender: TObject);
begin

end;


Expand Down Expand Up @@ -116,11 +117,6 @@ function TWizardConfigServer.data(): Pointer;
end;


procedure TWizardConfigServer.WizardManagerPageHide(Sender: TObject; Page: TWizardPage);
begin
end;



end.

7 changes: 2 additions & 5 deletions waptwizard/uwizardconfigserver_data.pas
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ TWizardConfigServerData = record
server_certificate : String;
launch_console : boolean;
check_certificates_validity : String;
repo_url : String;
end;
PWizardConfigServerData = ^TWizardConfigServerData;

Expand All @@ -39,8 +40,6 @@ implementation

uses
uwapt_ini,
DCPsha256,
ucrypto_pbkdf2,
uwizardutil,
IniFiles;

Expand All @@ -49,21 +48,19 @@ function TWizardConfigServerData_write_ini_waptserver( data : PWizardConfigServe
var
ini : TIniFile;
r : integer;
s : String;
begin
ini := nil;

w.SetValidationDescription( 'Writing wapt server configuration file' );
try

s := PBKDF2( data^.wapt_password, random_alphanum(5), 29000, 32, TDCP_sha256);

// waptserver.ini
ini := TIniFile.Create( 'conf\waptserver.ini' );
ini.WriteString( INI_OPTIONS, INI_DB_NAME, 'wapt');
ini.WriteString( INI_OPTIONS, INI_DB_USER, 'wapt' );
ini.WriteString( INI_OPTIONS, INI_WAPT_USER, 'admin' );
ini.WriteString( INI_OPTIONS, INI_WAPT_PASSWORD, s );
ini.WriteString( INI_OPTIONS, INI_WAPT_PASSWORD, data^.wapt_password );
ini.WriteString( INI_OPTIONS, INI_ALLOW_UNAUTHENTICATED_REGISTRATION, 'True' );
r := Length( Trim(ini.ReadString( INI_OPTIONS, INI_SERVER_UUID, '')) );
if r = 0 then
Expand Down
2 changes: 1 addition & 1 deletion waptwizard/uwizardconfigserver_postsetup.pas
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ procedure TWizardConfigServer_ServerPostSetup.wizard_next(var bCanNext: boolean
exit;

// Write wapt-get.ini
r := TWizardConfigServerData_write_ini_waptserver( data, self.m_wizard );
r := TWizardConfigServerData_write_ini_waptget( data, self.m_wizard );
if r <> 0 then
exit;

Expand Down
29 changes: 16 additions & 13 deletions waptwizard/uwizardconfigserver_server.pas
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ TWizardConfigServer_Server = class( TWizardStepFrame)
implementation

uses
uwizardconfigconsole_data,
DCPsha256,
ucrypto_pbkdf2,
uwizardconfigserver_data,
uwizardutil,
uwizardvalidattion;

Expand Down Expand Up @@ -97,16 +99,18 @@ procedure TWizardConfigServer_Server.wizard_show();
inherited wizard_show();


self.gb_admin_password.TabOrder := 1;
self.m_wizard.WizardButtonPanel.TabOrder := 2;
self.gb_admin_password.TabOrder := 0;
self.m_wizard.WizardButtonPanel.TabOrder := 1;


self.rg_server_url.TabOrder := 0;
self.ed_password_1.TabOrder := 1;
self.ed_password_2.TabOrder := 2;
self.m_wizard.WizardButtonPanel.NextButton.TabOrder := 3;
self.m_wizard.WizardButtonPanel.PreviousButton.TabOrder := 4;
self.m_wizard.WizardButtonPanel.CancelButton.TabOrder := 5;
self.cb_password_visible.TabOrder := 3;

self.m_wizard.WizardButtonPanel.NextButton.TabOrder := 0;
self.m_wizard.WizardButtonPanel.PreviousButton.TabOrder := 1;
self.m_wizard.WizardButtonPanel.CancelButton.TabOrder := 2;

self.ed_password_1.SetFocus;

Expand All @@ -118,7 +122,7 @@ procedure TWizardConfigServer_Server.wizard_next(var bCanNext: boolean);
var
ed : TEdit;
s : String;
data : PWizardConfigConsoleData;
data : PWizardConfigServerData;
begin
bCanNext := false;

Expand All @@ -132,10 +136,12 @@ procedure TWizardConfigServer_Server.wizard_next(var bCanNext: boolean);
end;

s := self.rg_server_url.Items[ self.rg_server_url.ItemIndex ];

data^.wapt_server := 'https://' + s;
data^.repo_url := 'https://' + s + '/wapt' ;
data^.server_certificate := s + '.crt';



// admin password
m_wizard.SetValidationDescription( 'Validating supplied passwords' );
if not wizard_validate_str_length_not_zero( m_wizard, self.ed_password_1, 'Password cannot be empty' ) then
Expand All @@ -149,11 +155,8 @@ procedure TWizardConfigServer_Server.wizard_next(var bCanNext: boolean);
if not wizard_validate_str_password_are_equals( m_wizard, self.ed_password_1.Text, self.ed_password_2.Text, ed ) then
exit;

m_wizard.ClearValidationDescription();


data^.wapt_user := 'admin';
data^.wapt_password := self.ed_password_1.Text;
data^.wapt_user := 'admin';
data^.wapt_password := PBKDF2( self.ed_password_1.Text, random_alphanum(5), 29000, 32, TDCP_sha256);


bCanNext := true;
Expand Down
6 changes: 6 additions & 0 deletions waptwizard/uwizardconfigserver_welcome.pas
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ TTWizardConfigServer_Welcome = class(TWizardStepFrame)

public
// TWizardStepFrame
procedure wizard_show(); override; final;
procedure wizard_next(var bCanNext: boolean); override; final;
end;

Expand All @@ -36,6 +37,11 @@ implementation



procedure TTWizardConfigServer_Welcome.wizard_show();
begin
m_wizard.setFocus_async( m_wizard.WizardButtonPanel.NextButton );
;
end;

procedure TTWizardConfigServer_Welcome.wizard_next(var bCanNext: boolean);
begin
Expand Down

0 comments on commit 2f77f55

Please sign in to comment.