1,7 → 1,6 |
unit DoorAlarmClientMain; |
|
// TODO: make configurable, which actions should be executed (e.g. run programs) when a motion was detected, with different event sounds etc |
// TODO: ask server to subscribe/unsubscribe to events (doorbell, motion) |
// TODO: make configurable, which actions should be executed (e.g. run programs) when a motion was detected |
|
interface |
|
12,8 → 11,6 |
JPEG, MJPEGDecoderUnit, IniFiles, Menus; |
|
type |
TAlarmType = (atUnknown, atMotion, atDoorbell); |
|
TForm1 = class(TForm) |
Image1: TImage; |
TrayIcon1: TTrayIcon; |
29,11 → 26,6 |
N2: TMenuItem; |
Stopalarm1: TMenuItem; |
Gotocontrolpanelwebsite1: TMenuItem; |
doorbellPanel: TPanel; |
N3: TMenuItem; |
Ignoredoorbell1: TMenuItem; |
Ignoremotionalert1: TMenuItem; |
unknownAlarm: TPanel; |
procedure FormDestroy(Sender: TObject); |
procedure FormCreate(Sender: TObject); |
procedure TrayIcon1Click(Sender: TObject); |
60,7 → 52,7 |
procedure WMQueryEndSession(var Message: TWMQueryEndSession); message WM_QUERYENDSESSION; |
procedure StartStream; |
procedure StopStream; |
procedure DoShowForm(AlarmType: TAlarmType); |
procedure DoShowForm; |
procedure DoPosition; |
procedure StopMusic; |
function ControlServerUrl: string; |
277,10 → 269,7 |
|
DoPosition; |
|
// Question: Should these settings also be saved for the next program session? |
Allowmutingsoundinterface1.Checked := ini.ReadBool('Client', 'AllowMute', false); |
Ignoredoorbell1.Checked := ini.ReadBool('Client', 'IgnoreDoorbell', false); |
Ignoremotionalert1.Checked := ini.ReadBool('Client', 'IgnoreMotion', false); |
|
UpdateIPTimerTimer(UpdateIPTimer); |
UpdateIPTimer.Interval := ini.ReadInteger('Client', 'SubscribeInterval', 30*60) * 1000; |
299,13 → 288,11 |
|
procedure TForm1.FormHide(Sender: TObject); |
begin |
if Image2.Visible then |
StopStream; |
end; |
|
procedure TForm1.FormShow(Sender: TObject); |
begin |
if Image2.Visible then |
StartStream; |
end; |
|
322,7 → 309,6 |
procedure TForm1.ServerCommandGet(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo); |
var |
AutoCloseTimerInterval: integer; |
AlarmType: TAlarmType; |
begin |
aResponseInfo.ResponseNo := 200; |
aResponseInfo.ContentType := 'text/html'; |
357,28 → 343,8 |
CloseTimer.Enabled := true; |
end; |
|
if ARequestInfo.Params.IndexOf('targets=1.3.6.1.4.1.37476.2.4.2.1002' {camera, motion}) >= 0 then |
AlarmType := atMotion |
else if ARequestInfo.Params.IndexOf('targets=1.3.6.1.4.1.37476.2.4.2.2001' {sound, doorbell}) >= 0 then |
AlarmType := atDoorbell |
else |
begin |
// TODO: Make plugin DLLs ? |
AlarmType := atUnknown; |
end; |
DoShowForm; |
|
// Attention: Ignoring these events at the client does not prevent the server |
// doing other actions (e.g. ask Spotify to stop the music on connected devices) |
if Ignoredoorbell1.Checked and (AlarmType = atDoorbell) then Exit; |
if Ignoremotionalert1.Checked and (AlarmType = atMotion) then Exit; |
|
if AlarmType = atUnknown then |
begin |
unknownAlarm.ShowHint := true; |
unknownAlarm.Hint := ARequestInfo.Params.Text; |
end; |
DoShowForm(AlarmType); |
|
if ini.ReadBool('Client', 'AutoPopup', true) then |
begin |
Application.Restore; |
403,7 → 369,7 |
Application.Restore; |
WindowState := wsNormal; |
FormStyle := fsNormal; |
DoShowForm(atMotion); |
DoShowForm; |
end; |
|
procedure TForm1.UpdateIPTimerTimer(Sender: TObject); |
419,7 → 385,6 |
lParamList.Add('ttl='+IntToStr((UpdateIPTimer.Interval div 1000) * 2 + 10)); |
lParamList.Add('targets=1.3.6.1.4.1.37476.2.4.2.0'); // Any |
lParamList.Add('targets=1.3.6.1.4.1.37476.2.4.2.1002'); // Motion, camera |
lParamList.Add('targets=1.3.6.1.4.1.37476.2.4.2.2001'); // Sound, doorbell |
|
idhttp := TIdHTTP.Create(nil); |
try |
462,15 → 427,8 |
Self.Top := Screen.Height - Self.Height - _TaskBarHeight; |
end; |
|
procedure TForm1.DoShowForm(AlarmType: TAlarmType); |
procedure TForm1.DoShowForm; |
begin |
Image1.Visible := AlarmType = atMotion; |
Image2.Visible := AlarmType = atMotion; |
|
// BUGBUG! TODO: This does not work. The panels are not visible for some reason! I just get a white window! |
doorbellPanel.Visible := AlarmType = atDoorbell; |
unknownAlarm.Visible := AlarmType = atUnknown; |
|
if ini.ReadBool('Client', 'AutoReposition', true) then |
begin |
DoPosition; |