diff options
author | lapinskijw <jlapinski.dev@gmail.com> | 2020-06-26 09:13:30 -0400 |
---|---|---|
committer | lapinskijw <jlapinski.dev@gmail.com> | 2020-06-26 09:13:30 -0400 |
commit | 7307251f2593e2b0647eb6832f214ec5ea9f51f1 (patch) | |
tree | c7983cc47009d82694688839c4104b511b1349be | |
parent | 25110876549a4f7dcd01ff67867f13c244f222d2 (diff) | |
download | sdl_ios-7307251f2593e2b0647eb6832f214ec5ea9f51f1.tar.gz |
tried out a few things
-rw-r--r-- | SmartDeviceLink/SDLPermissionFilter.h | 6 | ||||
-rw-r--r-- | SmartDeviceLink/SDLPermissionFilter.m | 6 | ||||
-rw-r--r-- | SmartDeviceLink/SDLPermissionManager.h | 2 | ||||
-rw-r--r-- | SmartDeviceLink/SDLPermissionManager.m | 10 | ||||
-rw-r--r-- | SmartDeviceLinkTests/DevAPISpecs/SDLPermissionsManagerSpec.m | 5 |
5 files changed, 14 insertions, 15 deletions
diff --git a/SmartDeviceLink/SDLPermissionFilter.h b/SmartDeviceLink/SDLPermissionFilter.h index 98ebd704a..b71c01be7 100644 --- a/SmartDeviceLink/SDLPermissionFilter.h +++ b/SmartDeviceLink/SDLPermissionFilter.h @@ -29,7 +29,7 @@ NS_ASSUME_NONNULL_BEGIN /** * The block that will be called on status changes to this filter group. */ -@property (copy, nonatomic, readonly) SDLPermissionElementsChangedHandler permissionsChangedHandler; +@property (copy, nonatomic, readonly) SDLPermissionsChangedHandler handler; /** * All of the permission elements in this filter group. @@ -45,7 +45,7 @@ NS_ASSUME_NONNULL_BEGIN * * @return An instance of `SDLPermissionFilter`. */ -- (instancetype)initWithRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType observer:(SDLPermissionElementsChangedHandler)handler NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType observer:(SDLPermissionsChangedHandler)handler NS_DESIGNATED_INITIALIZER; /** * Create a new permission filter group. @@ -56,7 +56,7 @@ NS_ASSUME_NONNULL_BEGIN * * @return An instance of `SDLPermissionFilter`. */ -+ (instancetype)filterWithRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType observer:(SDLPermissionElementsChangedHandler)handler NS_SWIFT_UNAVAILABLE("Use the initializer"); ++ (instancetype)filterWithRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType observer:(SDLPermissionsChangedHandler)handler NS_SWIFT_UNAVAILABLE("Use the initializer"); /** * Whether the current filter is equivalent with another filter or not. diff --git a/SmartDeviceLink/SDLPermissionFilter.m b/SmartDeviceLink/SDLPermissionFilter.m index 15d3a99b9..5b35977da 100644 --- a/SmartDeviceLink/SDLPermissionFilter.m +++ b/SmartDeviceLink/SDLPermissionFilter.m @@ -23,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN }]; } -- (instancetype)initWithRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType observer:(SDLPermissionElementsChangedHandler)observer { +- (instancetype)initWithRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType observer:(SDLPermissionsChangedHandler)observer { self = [super init]; if (!self) { return nil; @@ -32,12 +32,12 @@ NS_ASSUME_NONNULL_BEGIN _identifier = [NSUUID UUID]; _permissionElements = rpcNames; _groupType = groupType; - _permissionsChangedHandler = observer; + _handler = observer; return self; } -+ (instancetype)filterWithRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType observer:(SDLPermissionElementsChangedHandler)observer { ++ (instancetype)filterWithRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType observer:(SDLPermissionsChangedHandler)observer { return [[self alloc] initWithRPCNames:rpcNames groupType:groupType observer:observer]; } diff --git a/SmartDeviceLink/SDLPermissionManager.h b/SmartDeviceLink/SDLPermissionManager.h index b5d485dac..5639867bf 100644 --- a/SmartDeviceLink/SDLPermissionManager.h +++ b/SmartDeviceLink/SDLPermissionManager.h @@ -89,7 +89,7 @@ NS_ASSUME_NONNULL_BEGIN * * @return A dictionary specifying if the passed in RPC names are currently allowed or not */ -- (NSDictionary<SDLPermissionElement *, NSNumber *> *)statusesOfRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames; +- (NSDictionary<SDLRPCFunctionName, NSNumber *> *)statusesOfRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames; /** * Add an observer for specified RPC names, with a callback that will be called whenever the value changes, as well as immediately with the current status. diff --git a/SmartDeviceLink/SDLPermissionManager.m b/SmartDeviceLink/SDLPermissionManager.m index 3b5bd3017..c1826f460 100644 --- a/SmartDeviceLink/SDLPermissionManager.m +++ b/SmartDeviceLink/SDLPermissionManager.m @@ -133,14 +133,14 @@ NS_ASSUME_NONNULL_BEGIN } - (NSDictionary<SDLPermissionRPCName, NSNumber *> *)statusOfRPCs:(NSArray<SDLPermissionRPCName> *)rpcNames { - return [self sdl_convertPermissionElementsDictionary:[self statusesOfRPCNames:[self sdl_createPermissionElementFromRPCNames:rpcNames]]]; + return [self statusesOfRPCNames:[self sdl_createPermissionElementFromRPCNames:rpcNames]]; } -- (NSDictionary<SDLPermissionElement *, NSNumber *> *)statusesOfRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames { - NSMutableDictionary<SDLPermissionElement *, NSNumber *> *permissionAllowedDict = [NSMutableDictionary dictionary]; +- (NSDictionary<SDLRPCFunctionName, NSNumber *> *)statusesOfRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames { + NSMutableDictionary<SDLRPCFunctionName, NSNumber *> *permissionAllowedDict = [NSMutableDictionary dictionary]; for (SDLPermissionElement *permissionElement in rpcNames) { - permissionAllowedDict[permissionElement] = @([self isRPCNameAllowed:permissionElement.rpcName]); + permissionAllowedDict[permissionElement.rpcName] = @([self isRPCNameAllowed:permissionElement.rpcName]); } return [permissionAllowedDict copy]; @@ -180,7 +180,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)sdl_callFilterObserver:(SDLPermissionFilter *)filter { SDLPermissionGroupStatus permissionStatus = [self groupStatusOfRPCNames:filter.permissionElements]; - NSDictionary<SDLPermissionElement *, NSNumber *> *allowedDict = [self statusesOfRPCNames:filter.permissionElements]; + NSDictionary<SDLRPCFunctionName, NSNumber *> *allowedDict = [self statusesOfRPCNames:filter.permissionElements]; filter.handler(allowedDict, permissionStatus); } diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionsManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionsManagerSpec.m index 9e8cec6dc..77823a799 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionsManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionsManagerSpec.m @@ -410,7 +410,6 @@ fdescribe(@"SDLPermissionsManager", ^{ describe(@"checking the status of RPCs", ^{ __block NSDictionary<SDLPermissionRPCName, NSNumber *> *testResultPermissionStatusDict = nil; - __block NSDictionary<SDLPermissionElement *, NSNumber *> *testResultPermissionElementStatusDict = nil; context(@"with no permissions data", ^{ context(@"deprecated statusOfRPCs: method", ^{ beforeEach(^{ @@ -428,7 +427,7 @@ fdescribe(@"SDLPermissionsManager", ^{ context(@"statusesOfRPCNames: method", ^{ beforeEach(^{ - testResultPermissionElementStatusDict = [testPermissionsManager statusesOfRPCNames:@[testPermissionElementAllAllowed, testPermissionElementDisallowed]]; + testResultPermissionStatusDict = [testPermissionsManager statusesOfRPCNames:@[testPermissionElementAllAllowed, testPermissionElementDisallowed]]; }); it(@"should return correct permission statuses", ^{ @@ -460,7 +459,7 @@ fdescribe(@"SDLPermissionsManager", ^{ [[NSNotificationCenter defaultCenter] postNotification:limitedHMINotification]; [[NSNotificationCenter defaultCenter] postNotification:testPermissionsNotification]; - testResultPermissionElementStatusDict = [testPermissionsManager statusesOfRPCNames:@[testPermissionElementAllAllowed, testPermissionElementDisallowed]]; + testResultPermissionStatusDict = [testPermissionsManager statusesOfRPCNames:@[testPermissionElementAllAllowed, testPermissionElementDisallowed]]; }); it(@"should return correct permission statuses", ^{ |