Subversion Repositories alarming

Compare Revisions

Regard whitespace Rev 6 → Rev 7

/trunk/Delphi Client/DoorAlarmClient.exe
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/Delphi Client/DoorAlarmClientMain.dfm
5477,6 → 5477,42
ExplicitWidth = 232
ExplicitHeight = 168
end
object doorbellPanel: TPanel
Left = 8
Top = 152
Width = 242
Height = 73
Caption = 'DOOR BELL !'
Color = clRed
Font.Charset = DEFAULT_CHARSET
Font.Color = clBlack
Font.Height = -27
Font.Name = 'Tahoma'
Font.Style = []
ParentBackground = False
ParentFont = False
TabOrder = 0
Visible = False
end
object unknownAlarm: TPanel
Left = 8
Top = 152
Width = 242
Height = 73
Caption = 'UNKNOWN'
Color = clRed
Font.Charset = DEFAULT_CHARSET
Font.Color = clBlack
Font.Height = -27
Font.Name = 'Tahoma'
Font.Style = []
ParentBackground = False
ParentFont = False
ParentShowHint = False
ShowHint = True
TabOrder = 1
Visible = False
end
object TrayIcon1: TTrayIcon
PopupMenu = PopupMenu1
Visible = True
5491,6 → 5527,17
AutoCheck = True
Caption = 'Allow muting sound interfaces'
end
object N3: TMenuItem
Caption = '-'
end
object Ignoredoorbell1: TMenuItem
AutoCheck = True
Caption = 'Ignore door bell'
end
object Ignoremotionalert1: TMenuItem
AutoCheck = True
Caption = 'Ignore motion alert'
end
object N1: TMenuItem
Caption = '-'
end
/trunk/Delphi Client/DoorAlarmClientMain.pas
1,6 → 1,7
unit DoorAlarmClientMain;
 
// TODO: make configurable, which actions should be executed (e.g. run programs) when a motion was detected
// 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)
 
interface
 
11,6 → 12,8
JPEG, MJPEGDecoderUnit, IniFiles, Menus;
 
type
TAlarmType = (atUnknown, atMotion, atDoorbell);
 
TForm1 = class(TForm)
Image1: TImage;
TrayIcon1: TTrayIcon;
26,6 → 29,11
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);
52,7 → 60,7
procedure WMQueryEndSession(var Message: TWMQueryEndSession); message WM_QUERYENDSESSION;
procedure StartStream;
procedure StopStream;
procedure DoShowForm;
procedure DoShowForm(AlarmType: TAlarmType);
procedure DoPosition;
procedure StopMusic;
function ControlServerUrl: string;
269,7 → 277,10
 
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;
288,11 → 299,13
 
procedure TForm1.FormHide(Sender: TObject);
begin
if Image2.Visible then
StopStream;
end;
 
procedure TForm1.FormShow(Sender: TObject);
begin
if Image2.Visible then
StartStream;
end;
 
309,6 → 322,7
procedure TForm1.ServerCommandGet(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var
AutoCloseTimerInterval: integer;
AlarmType: TAlarmType;
begin
aResponseInfo.ResponseNo := 200;
aResponseInfo.ContentType := 'text/html';
343,8 → 357,28
CloseTimer.Enabled := true;
end;
 
DoShowForm;
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;
 
// 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;
369,7 → 403,7
Application.Restore;
WindowState := wsNormal;
FormStyle := fsNormal;
DoShowForm;
DoShowForm(atMotion);
end;
 
procedure TForm1.UpdateIPTimerTimer(Sender: TObject);
385,6 → 419,7
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
427,8 → 462,15
Self.Top := Screen.Height - Self.Height - _TaskBarHeight;
end;
 
procedure TForm1.DoShowForm;
procedure TForm1.DoShowForm(AlarmType: TAlarmType);
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;