Update main.pas to include sudo password checks messages and password reset (forget) menu option.

This commit is contained in:
Linuxer パスカリス スポシト 2020-01-23 14:04:14 +00:00
parent a168f0d4ac
commit 1a9d22d037
1 changed files with 20 additions and 1 deletions

View File

@ -17,12 +17,14 @@ type
MenuItem1 : TMenuItem;
MenuItem2 : TMenuItem;
MenuItem3 : TMenuItem;
MenuItem4 : TMenuItem;
PopupMenu1 : TPopupMenu;
TrayIcon1 : TTrayIcon;
procedure FormCreate(Sender: TObject);
procedure MenuItem1Click(Sender: TObject);
procedure MenuItem2Click(Sender: TObject);
procedure MenuItem3Click(Sender: TObject);
procedure MenuItem4Click(Sender: TObject);
private
public
@ -32,6 +34,7 @@ type
var
Form1 : TForm1;
S : LongInt;
n : Integer;
HasPassword : Boolean;
Password : String;
@ -44,16 +47,26 @@ implementation
procedure CameraOn;
begin
S := fpsystem(concat('echo ',Password,' | sudo -S modprobe uvcvideo'));
if (S <> 0) then
begin
ShowMessage('Incorrect password');
HasPassword := false;
end;
end;
procedure CameraOff;
begin
S := fpsystem(concat('echo ',Password,' | sudo -S modprobe -r uvcvideo'));
if (S <> 0) then
begin
ShowMessage('Incorrect password');
HasPassword := false;
end;
end;
procedure AskPassword;
begin
Password := PasswordBox('User Input','Please Enter Sudo Password');
Password := PasswordBox('Authorization Needed / User Input','Please Enter Password');
HasPassword := True;
end;
@ -99,5 +112,11 @@ begin
Halt (0);
end;
procedure TForm1.MenuItem4Click(Sender: TObject);
begin
HasPassword := false;
ShowMessage('Password has been forgotten');
end;
end.