Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a USB device blocking popup. #728

Merged
merged 13 commits into from
Feb 28, 2022
Prev Previous commit
Next Next commit
Add a custom SNTDeviceEvent initializer
  • Loading branch information
tnek committed Feb 25, 2022
commit e1b77639acb54681deaef9526ac1a28f8ead37ad
2 changes: 2 additions & 0 deletions Source/common/SNTDeviceEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

@interface SNTDeviceEvent : NSObject <NSSecureCoding>

- (instancetype)initWithOnName:(NSString *)mntonname fromName:(NSString *)mntfromname;
tnek marked this conversation as resolved.
Show resolved Hide resolved

@property NSString *mntonname;
@property NSString *mntfromname;
@property NSArray<NSString *> *remountArgs;
Expand Down
9 changes: 9 additions & 0 deletions Source/common/SNTDeviceEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ @implementation SNTDeviceEvent
[decoder decodeObjectOfClasses:[NSSet setWithObjects:[NSArray class], [cls class], nil] \
forKey:key]

- (instancetype)initWithOnName:(NSString *)mntonname fromName:(NSString *)mntfromname {
self = [super init];
if (self) {
_mntonname = mntonname;
_mntfromname = mntfromname;
}
return self;
}

+ (BOOL)supportsSecureCoding {
return YES;
}
Expand Down
7 changes: 4 additions & 3 deletions Source/santad/EventProviders/SNTDeviceManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,10 @@ - (void)handleAuthMount:(const es_message_t *)m
return;
}

SNTDeviceEvent *event = [[SNTDeviceEvent alloc] init];
event.mntonname = [NSString stringWithUTF8String:m->event.mount.statfs->f_mntonname];
event.mntfromname = [NSString stringWithUTF8String:m->event.mount.statfs->f_mntfromname];
SNTDeviceEvent *event = [[SNTDeviceEvent alloc]
initWithOnName:[NSString stringWithUTF8String:m->event.mount.statfs->f_mntonname]
fromName:[NSString stringWithUTF8String:m->event.mount.statfs->f_mntfromname]];

BOOL shouldRemount = self.remountArgs != nil && [self.remountArgs count] > 0;

if (shouldRemount) {
Expand Down