camera-control-webcam-switc.../RebootDialog.pas

102 lines
2.4 KiB
Plaintext

unit RebootDialog;
{$mode objfpc}{$H+}
interface
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, TplLabelUnit,
LCLIntf, Logs, 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;
FileString : String;
FileDestDir : String;
CmdString : String;
HomeDir : String;
Password : String;
implementation
{$R *.frm}
{ TForm5 }
procedure SaveLogs;
var
n : Integer;
LogsStringList : TStringlist;
DateString : String;
begin
HomeDir := expandfilename('~/');
DateString := FormatDateTime('DD/MM/YYYY-hh-mm-ss',now);
FileDestDir := Concat(HomeDir,'.cameracontrol-', DateString, '.log');
LogsStringList := TStringList.Create;
LogsStringList.Clear;
n := 0;
while n <= Logs.Form3.StringGrid1.RowCount - 1 do
begin
if Length(Form3.StringGrid1.Rows[n].Strings[0]) > 0 then
LogsStringList.Add(Concat(Form3.StringGrid1.Rows[n].Strings[0],',', Form3.StringGrid1.Rows[n].Strings[1],',', Form3.StringGrid1.Rows[n].Strings[2],',' , Form3.StringGrid1.Rows[n].Strings[3]));
Inc(n);
end;
ShowMessage(LogsStringList.Text);
n:= 0;
while n <= LogsStringList.Count - 1 do
begin
FileString := LogsStringList.Strings[n];
S := FpSystem(Concat('echo ' , FileString, ' >> ', FileDestDir));
Inc(n);
end;
LogsStringList.Free;
end;
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
SaveLogs;
S := FpSystem('reboot');
end;
end.