diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2018-09-14 11:19:18 -0400 |
---|---|---|
committer | Joel Fischer <joeljfischer@gmail.com> | 2018-09-14 11:19:18 -0400 |
commit | a228e15e3714bfc1be87d034ba2287b56528299b (patch) | |
tree | 6906e51e8ea4adec8ffdfa690bcceb27fd6088ab | |
parent | 586971bb90cf44bd2d21669c4e227ab65f19553f (diff) | |
download | sdl_ios-a228e15e3714bfc1be87d034ba2287b56528299b.tar.gz |
PlayPause mitigation kind of works
* Restructured internals of converting dictionary to RPC and copying RPCs
-rw-r--r-- | Example Apps/Example ObjC/ProxyManager.m | 14 | ||||
-rw-r--r-- | SmartDeviceLink/NSMutableDictionary+Store.h | 2 | ||||
-rw-r--r-- | SmartDeviceLink/NSMutableDictionary+Store.m | 6 | ||||
-rw-r--r-- | SmartDeviceLink/SDLGlobals.h | 2 | ||||
-rw-r--r-- | SmartDeviceLink/SDLRPCMessage.h | 2 | ||||
-rw-r--r-- | SmartDeviceLink/SDLRPCMessage.m | 15 | ||||
-rw-r--r-- | SmartDeviceLink/SDLRPCStruct.m | 4 | ||||
-rw-r--r-- | SmartDeviceLink/SDLRegisterAppInterfaceResponse.m | 2 |
8 files changed, 32 insertions, 15 deletions
diff --git a/Example Apps/Example ObjC/ProxyManager.m b/Example Apps/Example ObjC/ProxyManager.m index 7facc514e..6b1ede41a 100644 --- a/Example Apps/Example ObjC/ProxyManager.m +++ b/Example Apps/Example ObjC/ProxyManager.m @@ -129,7 +129,7 @@ NS_ASSUME_NONNULL_BEGIN config.ttsName = [SDLTTSChunk textChunksFromString:ExampleAppName]; config.language = SDLLanguageEnUs; config.languagesSupported = @[SDLLanguageEnUs, SDLLanguageFrCa, SDLLanguageEsMx]; - config.appType = SDLAppHMITypeDefault; + config.appType = SDLAppHMITypeMedia; SDLRGBColor *green = [[SDLRGBColor alloc] initWithRed:126 green:188 blue:121]; SDLRGBColor *white = [[SDLRGBColor alloc] initWithRed:249 green:251 blue:254]; @@ -161,11 +161,19 @@ NS_ASSUME_NONNULL_BEGIN - (void)sdlex_showInitialData { if (![self.sdlManager.hmiLevel isEqualToEnum:SDLHMILevelFull]) { return; } - SDLSetDisplayLayout *setDisplayLayout = [[SDLSetDisplayLayout alloc] initWithPredefinedLayout:SDLPredefinedLayoutNonMedia]; - [self.sdlManager sendRequest:setDisplayLayout]; +// SDLSetDisplayLayout *setDisplayLayout = [[SDLSetDisplayLayout alloc] initWithPredefinedLayout:SDLPredefinedLayoutNonMedia]; +// [self.sdlManager sendRequest:setDisplayLayout]; [self sdlex_updateScreen]; self.sdlManager.screenManager.softButtonObjects = [self.buttonManager allScreenSoftButtons]; + + SDLSubscribeButton *subscribeOk = [[SDLSubscribeButton alloc] initWithButtonName:SDLButtonNamePlayPause handler:^(SDLOnButtonPress * _Nullable buttonPress, SDLOnButtonEvent * _Nullable buttonEvent) { + NSLog(@"OK PRESSED"); + }]; + + [self.sdlManager sendRequest:subscribeOk withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { + NSLog(@"OK Request: %@, response: %@, error: %@", request, response, error); + }]; } - (nullable RefreshUIHandler)refreshUIHandler { diff --git a/SmartDeviceLink/NSMutableDictionary+Store.h b/SmartDeviceLink/NSMutableDictionary+Store.h index e4160bc7f..baeb46ca8 100644 --- a/SmartDeviceLink/NSMutableDictionary+Store.h +++ b/SmartDeviceLink/NSMutableDictionary+Store.h @@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN typedef NSString* SDLName SDL_SWIFT_ENUM; typedef NSString* SDLEnum SDL_SWIFT_ENUM; -@interface NSMutableDictionary (Store) +@interface NSDictionary (Store) - (void)sdl_setObject:(NSObject *)object forName:(SDLName)name; - (nullable id)sdl_objectForName:(SDLName)name; diff --git a/SmartDeviceLink/NSMutableDictionary+Store.m b/SmartDeviceLink/NSMutableDictionary+Store.m index cd681bd46..777489b43 100644 --- a/SmartDeviceLink/NSMutableDictionary+Store.m +++ b/SmartDeviceLink/NSMutableDictionary+Store.m @@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN - (nullable id)sdl_objectForName:(SDLName)name ofClass:(Class)classType { NSObject *obj = [self sdl_objectForName:name]; - if (obj == nil || [obj isKindOfClass:classType.class]) { + if (obj == nil || [obj isKindOfClass:classType]) { return obj; } else { return [[classType alloc] initWithDictionary:(NSDictionary *)obj]; @@ -37,12 +37,12 @@ NS_ASSUME_NONNULL_BEGIN NSArray *array = [self sdl_objectForName:name]; if ([array isEqual:[NSNull null]]) { return [NSMutableArray array]; - } else if (array.count < 1 || [array.firstObject isMemberOfClass:classType.class]) { + } else if (array.count < 1 || [array.firstObject isMemberOfClass:classType]) { // It's an array of the actual class type, just return return array; } else { // It's an array of dictionaries, make them into their class type - NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:array.count]; for (NSDictionary<NSString *, id> *dict in array) { [newList addObject:[[classType alloc] initWithDictionary:dict]]; } diff --git a/SmartDeviceLink/SDLGlobals.h b/SmartDeviceLink/SDLGlobals.h index ee5b3a259..84407f11d 100644 --- a/SmartDeviceLink/SDLGlobals.h +++ b/SmartDeviceLink/SDLGlobals.h @@ -28,7 +28,7 @@ extern NSUInteger const SDLV3MTUSize; @property (copy, nonatomic, readonly) NSString *protocolVersion; @property (assign, nonatomic, readonly) NSInteger majorProtocolVersion; -@property (copy, nonatomic) SDLSyncMsgVersion *rpcVersion; +@property (strong, nonatomic) SDLSyncMsgVersion *rpcVersion; @property (copy, nonatomic) NSString *maxHeadUnitVersion; + (instancetype)sharedGlobals; diff --git a/SmartDeviceLink/SDLRPCMessage.h b/SmartDeviceLink/SDLRPCMessage.h index d2c7e02ce..dcc545715 100644 --- a/SmartDeviceLink/SDLRPCMessage.h +++ b/SmartDeviceLink/SDLRPCMessage.h @@ -7,7 +7,7 @@ NS_ASSUME_NONNULL_BEGIN -@interface SDLRPCMessage : SDLRPCStruct { +@interface SDLRPCMessage : SDLRPCStruct <NSCopying> { NSMutableDictionary<NSString *, id> *function; NSMutableDictionary<NSString *, id> *parameters; NSString *messageType; diff --git a/SmartDeviceLink/SDLRPCMessage.m b/SmartDeviceLink/SDLRPCMessage.m index 140762dc2..7ca6b4b56 100644 --- a/SmartDeviceLink/SDLRPCMessage.m +++ b/SmartDeviceLink/SDLRPCMessage.m @@ -34,10 +34,13 @@ NS_ASSUME_NONNULL_BEGIN } } if (messageType != nil) { - function = [[store objectForKey:messageType] mutableCopy]; - parameters = [[function objectForKey:SDLNameParameters] mutableCopy]; + store[messageType] = [store[messageType] mutableCopy]; + function = store[messageType]; + + function[SDLNameParameters] = [function[SDLNameParameters] mutableCopy]; + parameters = function[SDLNameParameters]; } - self.bulkData = [dict objectForKey:SDLNameBulkData]; + self.bulkData = dict[SDLNameBulkData]; } return self; @@ -69,6 +72,12 @@ NS_ASSUME_NONNULL_BEGIN return description; } +- (id)copyWithZone:(nullable NSZone *)zone { + SDLRPCMessage *newMessage = [[self.class allocWithZone:zone] initWithDictionary:self->store]; + + return newMessage; +} + @end NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLRPCStruct.m b/SmartDeviceLink/SDLRPCStruct.m index d6a2d8f70..b0bccaac1 100644 --- a/SmartDeviceLink/SDLRPCStruct.m +++ b/SmartDeviceLink/SDLRPCStruct.m @@ -75,9 +75,9 @@ NS_ASSUME_NONNULL_BEGIN return ret; } --(id)copyWithZone:(nullable NSZone *)zone { +- (id)copyWithZone:(nullable NSZone *)zone { SDLRPCStruct *newStruct = [[[self class] allocWithZone:zone] init]; - newStruct->store = [self->store copy]; + newStruct->store = [self->store mutableCopy]; return newStruct; } diff --git a/SmartDeviceLink/SDLRegisterAppInterfaceResponse.m b/SmartDeviceLink/SDLRegisterAppInterfaceResponse.m index 1033f1b6c..f8b3b626b 100644 --- a/SmartDeviceLink/SDLRegisterAppInterfaceResponse.m +++ b/SmartDeviceLink/SDLRegisterAppInterfaceResponse.m @@ -135,7 +135,7 @@ NS_ASSUME_NONNULL_BEGIN } - (nullable SDLVehicleType *)vehicleType { - return [parameters sdl_objectForName:SDLNameVehicleType ofClass:SDLVehicleType.class]; + return [parameters sdl_objectForName:SDLNameVehicleType ofClass:[SDLVehicleType class]]; } - (void)setSupportedDiagModes:(nullable NSArray<NSNumber<SDLInt> *> *)supportedDiagModes { |