-
Notifications
You must be signed in to change notification settings - Fork 0
/
AXRecordController.m
77 lines (69 loc) · 2.34 KB
/
AXRecordController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//
// AXRecordController.m
// AXRecord
//
// Created by Christian Frisson on 05/02/17.
// Copyright © 2017 Christian Frisson and Sylvain Malacria. All rights reserved.
//
#include "AXRecordController.h"
#import "AXElementTracker.h"
#import "AppTracker.h"
#import "DisplaysTracker.h"
#import "WindowTracker.h"
#import "XMLFileAccessMethods.h"
#import "WindowInfoEvent.h"
@implementation AXRecordController{
AXElementTracker* elementTracker;
DisplaysTracker* displaysTracker;
WindowTracker* windowTracker;
AppTracker* appTracker;
XMLFileAccessMethods* xmlFileAccess;
}
-(id)initWithFilename:(NSString *)filename
andElementTrackDelay:(float)elementTrackDelay
andWindowTrackDelay:(float)windowTrackDelay
{
self = [super init];
if(self){
xmlFileAccess = [[XMLFileAccessMethods alloc] initWithFilename:filename];
elementTracker = [[AXElementTracker alloc] initWithDelay:elementTrackDelay andXMLFileAccess:xmlFileAccess];
displaysTracker = [[DisplaysTracker alloc] initWithXMLFileAccess:xmlFileAccess];
[displaysTracker setDisplaysTrackerDelegate:self];
[displaysTracker update];
windowTracker = [[WindowTracker alloc] initWithDelay:windowTrackDelay andXMLFileAccess:xmlFileAccess];
[windowTracker setWindowTrackerDelegate:self];
[windowTracker update];
appTracker= [[AppTracker alloc] initWithXMLFileAccess:xmlFileAccess];
}
return self;
}
-(id)stop {
[appTracker stop];
[displaysTracker stop];
[windowTracker stop];
[elementTracker stop];
[xmlFileAccess close];
appTracker = nil;
displaysTracker = nil;
windowTracker = nil;
elementTracker = nil;
xmlFileAccess = nil;
}
-(void)displaysInfoEventHappened:(DisplaysInfoEvent*)displaysEvent{
NSLog(@"displaysInfoEventHappened");
if(xmlFileAccess){
[xmlFileAccess addXMLElementToFileForDisplaysEvent:displaysEvent];
}
}
-(void)windowInfoEventHappened:(WindowInfoEvent*)windowEvent{
NSLog(@"windowInfoEventHappened");
if(xmlFileAccess){
[xmlFileAccess addXMLElementToFileForWindowEvent:windowEvent];
}
if(windowEvent && [windowEvent eventType] == vnrWindowAppeared ){
NSString* ownerName = [[windowEvent windowInfo] ownerName];
pid_t ownerPID = [[windowEvent windowInfo] ownerPID];
[elementTracker log:ownerPID];
}
}
@end