Message Form added for Rebooting after 59 lines of V4L(deleted) reaches... Addition for build
This commit is contained in:
parent
f18ab57c76
commit
dc1373f2e8
|
@ -0,0 +1,59 @@
|
|||
unit RebootDialog;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}
|
||||
cthreads,
|
||||
{$ENDIF}
|
||||
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, TplLabelUnit,
|
||||
LCLIntf, Unix;
|
||||
|
||||
type
|
||||
|
||||
{ TForm5 }
|
||||
|
||||
TForm5 = class(TForm)
|
||||
Button1: TButton;
|
||||
Button2: TButton;
|
||||
ListBox1: TListBox;
|
||||
plURLLabel1: TplURLLabel;
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure Button2Click(Sender: TObject);
|
||||
procedure plURLLabel1Click(Sender: TObject);
|
||||
private
|
||||
|
||||
public
|
||||
|
||||
end;
|
||||
|
||||
var
|
||||
Form5 : TForm5;
|
||||
S : LongInt;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.frm}
|
||||
|
||||
{ TForm5 }
|
||||
|
||||
procedure TForm5.Button2Click(Sender: TObject);
|
||||
begin
|
||||
Form5.Hide;
|
||||
Halt(0);
|
||||
end;
|
||||
|
||||
procedure TForm5.plURLLabel1Click(Sender: TObject);
|
||||
begin
|
||||
OpenUrl('https://gitlab.com/psposito/camera-control-webcam-switch-indicator/-/wikis/Project-History-and-other-Details#found-v4l2-limitations-forcing-for-reboot-when-v4l2-video-on-comes-to-number-60-it-is-mandatory-to-reboot-because-kernel-does-not-generate-more-devices-and-video-capture-is-not-possible');
|
||||
|
||||
end;
|
||||
|
||||
procedure TForm5.Button1Click(Sender: TObject);
|
||||
begin
|
||||
S := FpSystem('reboot');
|
||||
end;
|
||||
|
||||
end.
|
|
@ -0,0 +1,55 @@
|
|||
object Form5: TForm5
|
||||
Left = 455
|
||||
Height = 318
|
||||
Top = 45
|
||||
Width = 474
|
||||
BorderStyle = bsDialog
|
||||
Caption = 'Sytem Reboot'
|
||||
ClientHeight = 318
|
||||
ClientWidth = 474
|
||||
DesignTimePPI = 150
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '7.0'
|
||||
object ListBox1: TListBox
|
||||
Left = 8
|
||||
Height = 216
|
||||
Top = 16
|
||||
Width = 464
|
||||
Font.Style = [fsBold]
|
||||
ItemHeight = 0
|
||||
ParentFont = False
|
||||
ScrollWidth = 462
|
||||
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
|
||||
object plURLLabel1: TplURLLabel
|
||||
Cursor = crHandPoint
|
||||
Left = 72
|
||||
Height = 26
|
||||
Top = 240
|
||||
Width = 324
|
||||
Caption = 'Project''s Wiki - V4L2 Limitations'
|
||||
Font.Color = clBlue
|
||||
Font.Style = [fsUnderline]
|
||||
ParentColor = False
|
||||
ParentFont = False
|
||||
end
|
||||
end
|
|
@ -0,0 +1,6 @@
|
|||
{"version":1,"strings":[
|
||||
{"hash":3882900,"name":"tform5.caption","sourcebytes":[83,121,116,101,109,32,82,101,98,111,111,116],"value":"Sytem Reboot"},
|
||||
{"hash":93034084,"name":"tform5.button1.caption","sourcebytes":[82,101,98,111,111,116],"value":"Reboot"},
|
||||
{"hash":77089212,"name":"tform5.button2.caption","sourcebytes":[67,97,110,99,101,108],"value":"Cancel"},
|
||||
{"hash":259754595,"name":"tform5.plurllabel1.caption","sourcebytes":[80,114,111,106,101,99,116,39,115,32,87,105,107,105,32,45,32,86,52,76,50,32,76,105,109,105,116,97,116,105,111,110,115],"value":"Project's Wiki - V4L2 Limitations"}
|
||||
]}
|
244
main.pas
244
main.pas
|
@ -19,7 +19,7 @@ uses
|
|||
{$ENDIF}
|
||||
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
|
||||
Menus, PopupNotifier, UTF8Process, VpClock, Unix, process, About, Logs,
|
||||
Reboot, DateUtils, LCLTranslator;
|
||||
Reboot, RebootDialog, DateUtils, LCLType, LCLTranslator;
|
||||
|
||||
type
|
||||
|
||||
|
@ -166,6 +166,8 @@ var
|
|||
CameraIcon : byte;
|
||||
MicIcon : byte;
|
||||
FromMain : boolean;
|
||||
OneVideoCard : boolean;
|
||||
RebootNeededFlag : boolean;
|
||||
|
||||
implementation
|
||||
|
||||
|
@ -188,101 +190,7 @@ end;
|
|||
|
||||
procedure SetReleaseNo;
|
||||
begin
|
||||
ReleaseNo := '1.4-1';
|
||||
end;
|
||||
|
||||
procedure GetMicCaptureStatus;
|
||||
var
|
||||
AStringList : TStringList;
|
||||
AProcess : TProcess;
|
||||
begin
|
||||
AProcess := TProcess.Create(nil);
|
||||
AProcess.Executable := '/bin/sh';
|
||||
AProcess.Parameters.Add('-c');
|
||||
AProcess.Parameters.Add('amixer get Capture control');
|
||||
AProcess.Options := AProcess.Options + [poWaitOnExit, poUsePipes];
|
||||
AProcess.Execute;
|
||||
AStringList := TStringList.Create;
|
||||
AStringList.LoadFromStream(AProcess.Output);
|
||||
MicSwitchStr := TrimLeft(RightStr(AStringList.Strings[AstringList.Count-1], 5));
|
||||
if CompareText(MicSwitchStr,'[On]') = 0 then
|
||||
begin
|
||||
isMicOn := true;
|
||||
end
|
||||
//if CompareText(MicSwitchStr,'[Off]') = 0 then
|
||||
else
|
||||
begin
|
||||
isMicOn := false;
|
||||
end;
|
||||
AStringList.Free;
|
||||
AProcess.Free;
|
||||
end;
|
||||
|
||||
procedure GetVideoCards; // VideoCards /dev/ Names
|
||||
var
|
||||
AStringList : TStringList;
|
||||
AProcess : TProcess;
|
||||
Str : String;
|
||||
SubStr : String = '(deleted)';
|
||||
n : integer;
|
||||
m : integer;
|
||||
l : integer;
|
||||
//StrLength : integer;
|
||||
|
||||
begin
|
||||
m := 0;
|
||||
l := 0;
|
||||
//StrLength := 0;
|
||||
|
||||
Str := 'lsof /dev/ ' + '|' + ' grep video'; // Full test command is: lsof /dev | grep video && ls /dev/ | grep v4l
|
||||
AStringList := TStringList.Create;
|
||||
AProcess := TProcess.Create(nil);
|
||||
AProcess.Executable := '/bin/sh';
|
||||
AProcess.Parameters.Add('-c');
|
||||
AProcess.Parameters.Add(Str);
|
||||
AProcess.Options := AProcess.Options + [poWaitOnExit, poUsePipes];
|
||||
AProcess.Execute;
|
||||
AStringList.LoadFromStream(AProcess.Output);
|
||||
V4L2Val := StrToInt(BoolToStr(not DirectoryExists('/dev/v4l/')));
|
||||
if V4L2Val = - 1 then
|
||||
VideoCardsCountNumber := 0
|
||||
else
|
||||
if AstringList.Count = 1 then
|
||||
VideoCardsCountNumber := 1
|
||||
else
|
||||
if AstringList.Count - 1 > 1 then
|
||||
begin
|
||||
for n:= 1 to AStringList.Count - 1 do
|
||||
begin
|
||||
if CompareText(RightStr(AStringList.Strings[n], Length(SubStr)), SubStr) = 0 then
|
||||
Inc(m);
|
||||
//write('m = ');
|
||||
//write(m);
|
||||
if AStringList.Strings[n - 1] <> AStringList.Strings[n] then
|
||||
Inc(l);
|
||||
//write(', l = ');
|
||||
//writeln(l);
|
||||
end;
|
||||
VideoCardsCountNumber := l - m;
|
||||
end;
|
||||
|
||||
//write('VideoCardsCountNumber = ');
|
||||
//writeln(VideoCardsCountNumber);
|
||||
//writeln(m , l);
|
||||
AStringList.Free;
|
||||
AProcess.Free;
|
||||
end;
|
||||
|
||||
procedure GetCameraStatus; // My way because v4l2 sucks and does not provide webcam getstatus method.
|
||||
begin
|
||||
V4L2Val := StrToInt(BoolToStr(not DirectoryExists('/dev/v4l/'))); // If there is another way, please make an issue
|
||||
|
||||
if (VideoCardsCountNumber = 0) and (V4L2Val = -1) then // -> Camera is off
|
||||
CamStatus := 0;
|
||||
if (VideoCardsCountNumber = 0) and (V4L2Val = 0 ) then // -> Camera is On
|
||||
CamStatus := 1;
|
||||
if (VideoCardsCountNumber = 1) and (V4L2Val = 0 ) then // -> Camera is Capturing
|
||||
CamStatus := 2;
|
||||
ReleaseNo := '1.14-1';
|
||||
end;
|
||||
|
||||
procedure PopUpWebcamOn;
|
||||
|
@ -356,6 +264,127 @@ begin
|
|||
Form1.TrayIcon2.Hint := 'Microphone Status & Menu' + LineEnding + 'Microphone is Muted';
|
||||
end;
|
||||
|
||||
procedure GetMicCaptureStatus;
|
||||
var
|
||||
AStringList : TStringList;
|
||||
AProcess : TProcess;
|
||||
begin
|
||||
AProcess := TProcess.Create(nil);
|
||||
AProcess.Executable := '/bin/sh';
|
||||
AProcess.Parameters.Add('-c');
|
||||
AProcess.Parameters.Add('amixer get Capture control');
|
||||
AProcess.Options := AProcess.Options + [poWaitOnExit, poUsePipes];
|
||||
AProcess.Execute;
|
||||
AStringList := TStringList.Create;
|
||||
AStringList.LoadFromStream(AProcess.Output);
|
||||
MicSwitchStr := TrimLeft(RightStr(AStringList.Strings[AstringList.Count-1], 5));
|
||||
if CompareText(MicSwitchStr,'[On]') = 0 then
|
||||
begin
|
||||
isMicOn := true;
|
||||
end
|
||||
//if CompareText(MicSwitchStr,'[Off]') = 0 then
|
||||
else
|
||||
begin
|
||||
isMicOn := false;
|
||||
end;
|
||||
AStringList.Free;
|
||||
AProcess.Free;
|
||||
end;
|
||||
|
||||
procedure RebootNeededDialog;
|
||||
|
||||
begin
|
||||
RebootDialog.Form5.ListBox1.Clear;
|
||||
RebootDialog.Form5.ListBox1.Items.Clear;
|
||||
RebootDialog.Form5.ListBox1.Items.Add('The limit of 59 Hacking preventing On/Off functions');
|
||||
RebootDialog.Form5.ListBox1.Items.Add('has been reached. (Check Link Below)');
|
||||
RebootDialog.Form5.ListBox1.Items.Add('');
|
||||
RebootDialog.Form5.ListBox1.Items.Add('You must Reboot the System in Order to Reset their');
|
||||
RebootDialog.Form5.ListBox1.Items.Add('number, otherwise the application will not be able');
|
||||
RebootDialog.Form5.ListBox1.Items.Add('to provide, any further Actions.');
|
||||
RebootDialog.Form5.ListBox1.Items.Add('');
|
||||
RebootDialog.Form5.ListBox1.Items.Add('Please Save your opened Files & Close Windows');
|
||||
RebootDialog.Form5.ListBox1.Items.Add('');
|
||||
RebootDialog.Form5.ListBox1.Items.Add('Press Reboot or Quit to exit the Application');
|
||||
RebootDialog.Form5.Show;
|
||||
end;
|
||||
|
||||
procedure GetVideoCards; // VideoCards /dev/ Names
|
||||
var
|
||||
AStringList : TStringList;
|
||||
AProcess : TProcess;
|
||||
Str : String;
|
||||
SubStr : String = '(deleted)';
|
||||
n : integer;
|
||||
m : integer;
|
||||
l : integer;
|
||||
//StrLength : integer;
|
||||
|
||||
begin
|
||||
m := 0;
|
||||
l := 0;
|
||||
//StrLength := 0;
|
||||
|
||||
Str := 'lsof /dev/ ' + '|' + ' grep video'; // Full test command is: lsof /dev | grep video && ls /dev/ | grep v4l
|
||||
AStringList := TStringList.Create;
|
||||
AProcess := TProcess.Create(nil);
|
||||
AProcess.Executable := '/bin/sh';
|
||||
AProcess.Parameters.Add('-c');
|
||||
AProcess.Parameters.Add(Str);
|
||||
AProcess.Options := AProcess.Options + [poWaitOnExit, poUsePipes];
|
||||
AProcess.Execute;
|
||||
AStringList.LoadFromStream(AProcess.Output);
|
||||
V4L2Val := StrToInt(BoolToStr(not DirectoryExists('/dev/v4l/')));
|
||||
if V4L2Val = - 1 then
|
||||
VideoCardsCountNumber := 0;
|
||||
|
||||
if AstringList.Count = 0 then
|
||||
VideoCardsCountNumber := 0;
|
||||
|
||||
if (AstringList.Count >= 1) and (AstringList.Count <= 58) then
|
||||
begin
|
||||
for n:= 1 to AStringList.Count - 1 do
|
||||
begin
|
||||
if CompareText(RightStr(AStringList.Strings[n], Length(SubStr)), SubStr) = 0 then
|
||||
Inc(m);
|
||||
//write('m = ');
|
||||
//write(m);
|
||||
if AStringList.Strings[n - 1] <> AStringList.Strings[n] then
|
||||
Inc(l);
|
||||
//write(', l = ');
|
||||
//writeln(l);
|
||||
end;
|
||||
VideoCardsCountNumber := l - m;
|
||||
|
||||
if (AstringList.Count = 1) and (V4L2Val = 0) then
|
||||
VideoCardsCountNumber := 1;
|
||||
|
||||
end;
|
||||
if (AstringList.Count >= 58) then
|
||||
RebootNeededFlag := true;
|
||||
|
||||
//write('VideoCardsCountNumber = ');
|
||||
//writeln(AStringList.Text);
|
||||
//writeln(AstringList.Count, ' ', m, ' ', l, ' ', OneVideoCard);
|
||||
AStringList.Free;
|
||||
AProcess.Free;
|
||||
end;
|
||||
|
||||
procedure GetCameraStatus; // My way because v4l2 sucks and does not provide webcam getstatus method.
|
||||
begin
|
||||
V4L2Val := StrToInt(BoolToStr(not DirectoryExists('/dev/v4l/'))); // If there is another way, please make an issue
|
||||
|
||||
if (VideoCardsCountNumber = 0) and (V4L2Val = -1) then // -> Camera is off
|
||||
CamStatus := 0;
|
||||
if (VideoCardsCountNumber = 0) and (V4L2Val = 0 ) then // -> Camera is On
|
||||
CamStatus := 1;
|
||||
if (VideoCardsCountNumber = 1) and (V4L2Val = 0 ) then // -> Camera is Capturing
|
||||
CamStatus := 2;
|
||||
if (VideoCardsCountNumber = 1) and (V4L2Val = -1 ) then // -> Camera is Capturing
|
||||
CamStatus := 1;
|
||||
end;
|
||||
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
|
||||
begin
|
||||
|
@ -378,6 +407,7 @@ begin
|
|||
PopUpWebcamCaptStatus := false;
|
||||
V4L2Val := StrToInt(BoolToStr(not DirectoryExists('/dev/v4l/')));
|
||||
FromMain := false;
|
||||
RebootNeededFlag := false;
|
||||
|
||||
AdjustBalloonPosition;
|
||||
|
||||
|
@ -460,7 +490,6 @@ begin
|
|||
ImageListCam.GetIcon(2, TrayIcon1.Icon);
|
||||
ImageListMic.GetIcon(MicIcon, TrayIcon2.Icon);
|
||||
ImageListSystem.GetIcon(0, TrayIcon4.Icon);
|
||||
|
||||
FromMain := true;
|
||||
end;
|
||||
|
||||
|
@ -986,6 +1015,12 @@ begin
|
|||
GetVideoCards;
|
||||
GetCameraStatus;
|
||||
|
||||
if RebootNeededFlag = true then
|
||||
begin
|
||||
RebootNeededDialog;
|
||||
RebootNeededFlag := false;
|
||||
end;
|
||||
|
||||
// VideoCardsCountNumber = 0 & V4L2Val = -1 -> CamStatus = 0 -> Camera is off
|
||||
// VideoCardsCountNumber = 0 & V4L2Val = 0 -> CamStatus = 1 -> Camera is On
|
||||
// VideoCardsCountNumber = 1 & V4L2Val = 0 -> CamStatus = 2 -> CameraCapturing
|
||||
|
@ -998,7 +1033,7 @@ begin
|
|||
//
|
||||
//writeln(Str);
|
||||
|
||||
writeln('VidCardsNum = ' + IntToStr(VideoCardsCountNumber), ' CamStatus = ', CamStatus, ' CamSavedStat = ', CamSavedStatus);
|
||||
//writeln('VidCardsNum = ', IntToStr(VideoCardsCountNumber), ' CamStatus = ', CamStatus, ' CamSavedStat = ', CamSavedStatus, ' V4L2Val = ', IntToStr(V4L2Val));
|
||||
|
||||
if ((CamStatus = 1) and (CamSavedStatus = 1) and (CamClicked = true) and (CamClicksCounter= 1)) then // Webcam is On, User Clicked
|
||||
begin
|
||||
|
@ -1051,6 +1086,19 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
//if (VideoCardsCountNumber = 1) and (CamStatus = 2) and (CamSavedStatus = 1) and (V4L2Val = 0) then
|
||||
// begin
|
||||
// ImageListCam1.GetIcon(2, TrayIcon5.Icon);
|
||||
// if (VideoCapt = true) then
|
||||
// begin
|
||||
// PopUpWebcamNotCapturing;
|
||||
// PopUpWebcamNoCapturing;
|
||||
// PopUpWebcamCaptStatus := false;
|
||||
// VideoCapt := false;
|
||||
// CamSavedStatus := 1;
|
||||
// end;
|
||||
// end;
|
||||
|
||||
if ((CamStatus = 0) and (CamSavedStatus <= 2) and (CamClicked = true) and (CamClicksCounter= 1)) then // Webcam disabled, User Clicked
|
||||
begin
|
||||
ImageListCam1.GetIcon(0, TrayIcon5.Icon);
|
||||
|
|
Loading…
Reference in New Issue