Fixed Reboot.pas for cancellation of Audio Cards Blacklist

This commit is contained in:
Linuxer パスカリス スポシト 2020-02-09 23:59:14 +00:00
parent 94439a3e3f
commit 41b2858f44
1 changed files with 42 additions and 160 deletions

View File

@ -1,160 +1,42 @@
unit Reboot;
{$mode objfpc}{$H+}
{$warnings off}
{$hints off}
// Created at 23th of January 2020, by Linuxer (https://gitlab.com/psposito), from scratch with Free Pascal
// Redesigned and further Developed at 28th of January 2020, by Initial developer
// to provide Camera and Mic status alone with On/Off and Mute/Unmute fuctions
// Developed further for intrusion feeling and logging at 2nd of February 2020, by Initial developer
// Developed for Blacklisting/Whitelisting functions for both camera & audio at 7th of February 2020, by Initial developer
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Unix;
type
{ TForm4 }
TForm4 = class(TForm)
Button1 : TButton;
Button2 : TButton;
ListBox1 : TListBox;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
public
LastAction : byte;
Password : String;
HasPassword : boolean;
end;
var
Form4 : TForm4;
S : LongInt;
FileString : String;
FileDestDir : String;
CmdString : String;
HomeDir : String;
Password : String;
implementation
{$R *.frm}
{ TForm4 }
procedure UndoCameraBlacklist;
begin
CmdString := '';
Password := Form4.Password;
FileDestDir := '/etc/modprobe.d/blacklistuvcvideo.conf';
CmdString := Concat(Concat(Concat('echo ', Password), ' | sudo -S rm -f '), FileDestDir);
S := FpSystem(CmdString);
if (S <> 0) then
begin
ShowMessage('Something went wrong with Undo. Please reverse your last action from the Menu!');
end;
CmdString := '';
end;
procedure UndoCameraWhitelist;
begin
CmdString := '';
Password := Form4.Password;
HomeDir := expandfilename('~/');
FileString := Concat(HomeDir,'.blacklistuvcvideo ');
FileDestDir := '/etc/modprobe.d/blacklistuvcvideo.conf';
CmdString := Concat(Concat(Concat(Concat('echo ', Password), ' | sudo -S cp '), FileString), FileDestDir);
S := FpSystem(CmdString);
if (S <> 0) then
begin
ShowMessage('Something went wrong with Undo. Please reverse your last action from the Menu!');
end;
CmdString := '';
end;
procedure UndoAudioBlacklist;
begin
CmdString := '';
Password := Form4.Password;
FileDestDir := '/etc/modprobe.d/blacklistaudio.conf';
CmdString := Concat(Concat(Concat('echo ', Password), ' | sudo -S rm -f '), FileDestDir);
ShowMessage(CmdString);
S := FpSystem(CmdString);
if (S <> 0) then
begin
ShowMessage('Something went wrong with Undo. Please reverse your last action from the Menu!');
end;
CmdString := '';
end;
procedure UndoAudioWhitelist;
begin
CmdString := '';
Password := Form4.Password;
HomeDir := expandfilename('~/');
FileString := Concat(HomeDir,'.blacklistaudio ');
FileDestDir := '/etc/modprobe.d/blacklistaudio.conf ';
CmdString := Concat(Concat(Concat(Concat('echo ', Password), ' | sudo -S cp '), FileString), FileDestDir);
S := FpSystem(CmdString);
if (S <> 0) then
begin
ShowMessage('Something went wrong with Undo. Please reverse your last Action from the Menu!');
end;
CmdString := '';
end;
procedure UndoLastAction;
var
LastAction : byte;
//LastActionString : Array [0..3] of String;
begin
//LastActionString[0] := 'Camera was Blacklisted';
//LastActionString[1] := 'Camera was Whitelisted';
//LastActionString[2] := 'Audio was Blacklisted';
//LastActionString[3] := 'Audio was Whitelisted';
//LastAction := Form4.LastAction;
Form4.Hide;
if (LastAction = 0) then
begin
UndoCameraBlacklist;
end;
if (LastAction = 1) then
begin
UndoCameraWhitelist;
end;
if (LastAction = 2) then
begin
UndoAudioBlacklist;
end;
if (LastAction = 3) then
begin
UndoAudioWhitelist;
end;
if (S = 0) then
begin
ShowMessage('Your last Action was undone, successfuly!');
end;
Form4.Close;
end;
procedure TForm4.Button2Click(Sender: TObject);
begin
UndoLastAction;
end;
procedure TForm4.Button1Click(Sender: TObject);
begin
FpSystem('reboot');
end;
end.
object Form4: TForm4
Left = 455
Height = 315
Top = 45
Width = 477
Caption = 'Sytem Reboot'
ClientHeight = 315
ClientWidth = 477
DesignTimePPI = 150
Position = poScreenCenter
LCLVersion = '7.0'
object ListBox1: TListBox
Left = 0
Height = 248
Top = 16
Width = 472
Font.Style = [fsBold]
ItemHeight = 0
ParentFont = False
ScrollWidth = 468
TabOrder = 0
TopIndex = -1
end
object Button1: TButton
Left = 56
Height = 39
Top = 272
Width = 117
Caption = 'Reboot'
OnClick = Button1Click
TabOrder = 1
end
object Button2: TButton
Left = 288
Height = 39
Top = 272
Width = 117
Caption = 'Cancel'
OnClick = Button2Click
TabOrder = 2
end
end