diff options
Diffstat (limited to 'SmartDeviceLink')
525 files changed, 37597 insertions, 0 deletions
diff --git a/SmartDeviceLink/EAAccessory+SDLProtocols.h b/SmartDeviceLink/EAAccessory+SDLProtocols.h new file mode 100644 index 000000000..417b5b07b --- /dev/null +++ b/SmartDeviceLink/EAAccessory+SDLProtocols.h @@ -0,0 +1,11 @@ +// +// EAAccessory+SyncProtocols.h +// + +#import <ExternalAccessory/ExternalAccessory.h> + +@interface EAAccessory (SDLProtocols) + +- (BOOL)supportsProtocol:(NSString *)protocol; + +@end diff --git a/SmartDeviceLink/EAAccessory+SDLProtocols.m b/SmartDeviceLink/EAAccessory+SDLProtocols.m new file mode 100644 index 000000000..bffeeb829 --- /dev/null +++ b/SmartDeviceLink/EAAccessory+SDLProtocols.m @@ -0,0 +1,19 @@ +// +// EAAccessory+SyncProtocols.m +// + +#import "EAAccessory+SDLProtocols.h" + +@implementation EAAccessory (SDLProtocols) + +- (BOOL)supportsProtocol:(NSString *)protocol { + for (NSString *supportedProtocol in self.protocolStrings) { + if ([supportedProtocol isEqualToString:protocol]) { + return YES; + } + } + + return NO; +} + +@end diff --git a/SmartDeviceLink/EAAccessoryManager+SDLProtocols.h b/SmartDeviceLink/EAAccessoryManager+SDLProtocols.h new file mode 100644 index 000000000..b4b39d943 --- /dev/null +++ b/SmartDeviceLink/EAAccessoryManager+SDLProtocols.h @@ -0,0 +1,11 @@ +// +// EAAccessoryManager+SyncProtocols.h +// + +#import <ExternalAccessory/ExternalAccessory.h> + +@interface EAAccessoryManager (SDLProtocols) + ++ (EAAccessory *)findAccessoryForProtocol:(NSString *)protocol; + +@end diff --git a/SmartDeviceLink/EAAccessoryManager+SDLProtocols.m b/SmartDeviceLink/EAAccessoryManager+SDLProtocols.m new file mode 100644 index 000000000..38b0b2477 --- /dev/null +++ b/SmartDeviceLink/EAAccessoryManager+SDLProtocols.m @@ -0,0 +1,20 @@ +// +// EAAccessoryManager+SyncProtocols.m +// + +#import "EAAccessory+SDLProtocols.h" +#import "EAAccessoryManager+SDLProtocols.h" + +@implementation EAAccessoryManager (SDLProtocols) + ++ (EAAccessory *)findAccessoryForProtocol:(NSString *)protocol { + for (EAAccessory *accessory in [[EAAccessoryManager sharedAccessoryManager] connectedAccessories]) { + if ([accessory supportsProtocol:protocol]) { + return accessory; + } + } + + return nil; +} + +@end diff --git a/SmartDeviceLink/Info.plist b/SmartDeviceLink/Info.plist new file mode 100644 index 000000000..438715f90 --- /dev/null +++ b/SmartDeviceLink/Info.plist @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>en</string> + <key>CFBundleExecutable</key> + <string>$(EXECUTABLE_NAME)</string> + <key>CFBundleIdentifier</key> + <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>$(PRODUCT_NAME)</string> + <key>CFBundlePackageType</key> + <string>FMWK</string> + <key>CFBundleShortVersionString</key> + <string>4.1.2</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>$(CURRENT_PROJECT_VERSION)</string> + <key>NSPrincipalClass</key> + <string></string> +</dict> +</plist> diff --git a/SmartDeviceLink/NSThread+ThreadIndex.h b/SmartDeviceLink/NSThread+ThreadIndex.h new file mode 100644 index 000000000..60459e3e2 --- /dev/null +++ b/SmartDeviceLink/NSThread+ThreadIndex.h @@ -0,0 +1,9 @@ +// +// NSThread+ThreadIndex.h +// + +#import <Foundation/Foundation.h> + +@interface NSThread (ThreadIndex) +- (NSInteger)threadIndex; +@end diff --git a/SmartDeviceLink/NSThread+ThreadIndex.m b/SmartDeviceLink/NSThread+ThreadIndex.m new file mode 100644 index 000000000..89cbbd5c2 --- /dev/null +++ b/SmartDeviceLink/NSThread+ThreadIndex.m @@ -0,0 +1,23 @@ +// +// NSThread+ThreadIndex.m +// + +#import "NSThread+ThreadIndex.h" + +@implementation NSThread (ThreadIndex) + +- (NSInteger)threadIndex { + NSString *description = [self description]; + NSArray *keyValuePairs = [description componentsSeparatedByString:@","]; + for (NSString *keyValuePair in keyValuePairs) { + NSArray *components = [keyValuePair componentsSeparatedByString:@"="]; + NSString *key = components[0]; + key = [key stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + if ([key rangeOfString:@"num"].location != NSNotFound) { + return [components[1] integerValue]; + } + } + return -1; +} + +@end diff --git a/SmartDeviceLink/SDLAbstractProtocol.h b/SmartDeviceLink/SDLAbstractProtocol.h new file mode 100644 index 000000000..01a4c7e9d --- /dev/null +++ b/SmartDeviceLink/SDLAbstractProtocol.h @@ -0,0 +1,31 @@ +// SDLAbstractProtocol.h +// + +@class SDLAbstractTransport; +@class SDLRPCMessage; +@class SDLRPCRequest; + +#import "SDLProtocolListener.h" +#import "SDLTransportDelegate.h" + + +@interface SDLAbstractProtocol : NSObject <SDLTransportDelegate> + +@property (strong) NSString *debugConsoleGroupName; +@property (weak) SDLAbstractTransport *transport; +@property (strong) NSHashTable *protocolDelegateTable; // table of id<SDLProtocolListener> + +// Sending +- (void)sendStartSessionWithType:(SDLServiceType)serviceType; +- (void)sendEndSessionWithType:(SDLServiceType)serviceType; +- (void)sendRPC:(SDLRPCMessage *)message; +- (void)sendRPCRequest:(SDLRPCRequest *)rpcRequest __deprecated_msg(("Use sendRPC: instead")); +- (void)sendHeartbeat __deprecated_msg("Heartbeat is no longer used."); +- (void)sendRawDataStream:(NSInputStream *)inputStream withServiceType:(SDLServiceType)serviceType; +- (void)sendRawData:(NSData *)data withServiceType:(SDLServiceType)serviceType; + +// Recieving +- (void)handleBytesFromTransport:(NSData *)receivedData; +- (void)dispose; + +@end diff --git a/SmartDeviceLink/SDLAbstractProtocol.m b/SmartDeviceLink/SDLAbstractProtocol.m new file mode 100644 index 000000000..ad536761c --- /dev/null +++ b/SmartDeviceLink/SDLAbstractProtocol.m @@ -0,0 +1,77 @@ +// SDLAbstractProtocol.m + +#import "SDLAbstractProtocol.h" + +#import "SDLRPCMessage.h" + + +@implementation SDLAbstractProtocol + +- (instancetype)init { + if (self = [super init]) { + _protocolDelegateTable = [NSHashTable weakObjectsHashTable]; + _debugConsoleGroupName = @"default"; + } + return self; +} + +// Implement in subclasses. +- (void)sendStartSessionWithType:(SDLServiceType)serviceType { + [self doesNotRecognizeSelector:_cmd]; +} + +- (void)sendEndSessionWithType:(SDLServiceType)serviceType { + [self doesNotRecognizeSelector:_cmd]; +} + +- (void)sendRPC:(SDLRPCMessage *)message { + [self doesNotRecognizeSelector:_cmd]; +} + +- (void)sendRPCRequest:(SDLRPCRequest *)rpcRequest { + [self doesNotRecognizeSelector:_cmd]; +} + +- (void)sendHeartbeat { + [self doesNotRecognizeSelector:_cmd]; +} + +- (void)handleBytesFromTransport:(NSData *)receivedData { + [self doesNotRecognizeSelector:_cmd]; +} + +- (void)sendRawDataStream:(NSInputStream *)inputStream withServiceType:(SDLServiceType)serviceType { + [self doesNotRecognizeSelector:_cmd]; +} + +- (void)sendRawData:(NSData *)data withServiceType:(SDLServiceType)serviceType { + [self doesNotRecognizeSelector:_cmd]; +} + +- (void)dispose { + [self doesNotRecognizeSelector:_cmd]; +} + + +#pragma - SDLTransportListener Implementation +- (void)onTransportConnected { + for (id<SDLProtocolListener> listener in self.protocolDelegateTable.allObjects) { + if ([listener respondsToSelector:@selector(onProtocolOpened)]) { + [listener onProtocolOpened]; + } + } +} + +- (void)onTransportDisconnected { + for (id<SDLProtocolListener> listener in self.protocolDelegateTable.allObjects) { + if ([listener respondsToSelector:@selector(onProtocolClosed)]) { + [listener onProtocolClosed]; + } + } +} + +- (void)onDataReceived:(NSData *)receivedData { + [self handleBytesFromTransport:receivedData]; +} + +@end diff --git a/SmartDeviceLink/SDLAbstractTransport.h b/SmartDeviceLink/SDLAbstractTransport.h new file mode 100644 index 000000000..a8a1f61be --- /dev/null +++ b/SmartDeviceLink/SDLAbstractTransport.h @@ -0,0 +1,18 @@ +// SDLAbstractTransport.h + +#import <Foundation/Foundation.h> + +#import "SDLTransportDelegate.h" + +@interface SDLAbstractTransport : NSObject + +@property (weak) id<SDLTransportDelegate> delegate; +@property (strong) NSString *debugConsoleGroupName; + +- (void)connect; +- (void)disconnect; +- (void)sendData:(NSData *)dataToSend; +- (void)dispose; +- (double)retryDelay; + +@end diff --git a/SmartDeviceLink/SDLAbstractTransport.m b/SmartDeviceLink/SDLAbstractTransport.m new file mode 100644 index 000000000..6d7437748 --- /dev/null +++ b/SmartDeviceLink/SDLAbstractTransport.m @@ -0,0 +1,34 @@ +// SDLAbstractTransport.m + +#import "SDLAbstractTransport.h" + +@implementation SDLAbstractTransport + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (void)connect { + [self doesNotRecognizeSelector:_cmd]; +} + +- (void)disconnect { + [self doesNotRecognizeSelector:_cmd]; +} + +- (void)sendData:(NSData *)dataToSend { + [self doesNotRecognizeSelector:_cmd]; +} + +- (void)dispose { + [self doesNotRecognizeSelector:_cmd]; +} + +- (double)retryDelay { + [self doesNotRecognizeSelector:_cmd]; + return 0.0; +} + +@end diff --git a/SmartDeviceLink/SDLAddCommand.h b/SmartDeviceLink/SDLAddCommand.h new file mode 100644 index 000000000..bce12fafd --- /dev/null +++ b/SmartDeviceLink/SDLAddCommand.h @@ -0,0 +1,92 @@ +// SDLAddCommand.h + + +#import "SDLRPCRequest.h" + +@class SDLMenuParams; +@class SDLImage; + + +/** + * This class will add a command to the application's Command Menu SDLMenuParams + * + * A command will be added to the end of the list of elements in + * the Command Menu under the following conditions: + * <li>When a SDLCommand is added with no SDLMenuParams value provided</li> + * <li>When a SDLMenuParams value is provided with a SDLMenuParam.position value + * greater than or equal to the number of menu items currently defined in the + * menu specified by the SDLMenuParam.parentID value</li> + * + * The set of choices which the application builds using SDLAddCommand can be a + * mixture of: + * <li>Choices having only VR synonym definitions, but no SDLMenuParams definitions + * </li> + * <li>Choices having only SDLMenuParams definitions, but no VR synonym definitions + * </li> + * <li>Choices having both SDLMenuParams and VR synonym definitions</li> + * + * HMILevel needs to be FULL, LIMITED or BACKGROUD + * + * @since SDL 1.0 + * + * @see SDLDeleteCommand SDLAddSubMenu SDLDeleteSubMenu + */ +@interface SDLAddCommand : SDLRPCRequest { +} + +/** + * Constructs a new SDLAddCommand object + */ +- (instancetype)init; + +/** + * Constructs a new *SDLAddCommand* object indicated by the dictionary parameter + * + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract A Unique Command ID that identifies the command + * + * @discussion Is returned in an *SDLOnCommand* notification to identify the command selected by the user + * + * Required, Integer, 0 - 2,000,000,000 + */ +@property (strong) NSNumber *cmdID; + +/** + * @abstract a *SDLMenuParams* pointer which will defined the command and how it is added to the Command Menu + * + * @discussion If provided, this will define the command and how it is added to the + * Command Menu + * + * If null, commands will not be accessible through the HMI application menu + * + * Optional + */ +@property (strong) SDLMenuParams *menuParams; + +/** + * @abstract An array of strings to be used as VR synonyms for this command. + * + * @discussion If provided, defines one or more VR phrases the recognition of any of which triggers the *SDLOnCommand* notification with this cmdID + * + * If null, commands will not be accessible by voice commands (when the user hits push-to-talk) + * + * Optional, Array of Strings, Max String length 99 chars, Array size 1 - 100 + */ +@property (strong) NSMutableArray *vrCommands; + +/** + * @abstract Image struct containing a static or dynamic icon + * + * @discussion If provided, defines the image to be be shown along with a command + * + * If omitted on supported displays, no (or the default if applicable) icon will be displayed + * + * Optional + */ +@property (strong) SDLImage *cmdIcon; + +@end diff --git a/SmartDeviceLink/SDLAddCommand.m b/SmartDeviceLink/SDLAddCommand.m new file mode 100644 index 000000000..e9630665e --- /dev/null +++ b/SmartDeviceLink/SDLAddCommand.m @@ -0,0 +1,84 @@ +// SDLAddCommand.m +// + + +#import "SDLAddCommand.h" + +#import "SDLImage.h" +#import "SDLMenuParams.h" +#import "SDLNames.h" + + +@implementation SDLAddCommand + +- (instancetype)init { + if (self = [super initWithName:NAMES_AddCommand]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setCmdID:(NSNumber *)cmdID { + if (cmdID != nil) { + [parameters setObject:cmdID forKey:NAMES_cmdID]; + } else { + [parameters removeObjectForKey:NAMES_cmdID]; + } +} + +- (NSNumber *)cmdID { + return [parameters objectForKey:NAMES_cmdID]; +} + +- (void)setMenuParams:(SDLMenuParams *)menuParams { + if (menuParams != nil) { + [parameters setObject:menuParams forKey:NAMES_menuParams]; + } else { + [parameters removeObjectForKey:NAMES_menuParams]; + } +} + +- (SDLMenuParams *)menuParams { + NSObject *obj = [parameters objectForKey:NAMES_menuParams]; + if (obj == nil || [obj isKindOfClass:SDLMenuParams.class]) { + return (SDLMenuParams *)obj; + } else { + return [[SDLMenuParams alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setVrCommands:(NSMutableArray *)vrCommands { + if (vrCommands != nil) { + [parameters setObject:vrCommands forKey:NAMES_vrCommands]; + } else { + [parameters removeObjectForKey:NAMES_vrCommands]; + } +} + +- (NSMutableArray *)vrCommands { + return [parameters objectForKey:NAMES_vrCommands]; +} + +- (void)setCmdIcon:(SDLImage *)cmdIcon { + if (cmdIcon != nil) { + [parameters setObject:cmdIcon forKey:NAMES_cmdIcon]; + } else { + [parameters removeObjectForKey:NAMES_cmdIcon]; + } +} + +- (SDLImage *)cmdIcon { + NSObject *obj = [parameters objectForKey:NAMES_cmdIcon]; + if (obj == nil || [obj isKindOfClass:SDLImage.class]) { + return (SDLImage *)obj; + } else { + return [[SDLImage alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLAddCommandResponse.h b/SmartDeviceLink/SDLAddCommandResponse.h new file mode 100644 index 000000000..dfa132f6d --- /dev/null +++ b/SmartDeviceLink/SDLAddCommandResponse.h @@ -0,0 +1,18 @@ +// SDLAddCommandResponse.h + + +#import "SDLRPCResponse.h" + + +/** + * SDLAddCommandResponse is sent, when SDLAddCommand has been called + * + * Since <b>SmartDeviceLink 1.0</b> + */ +@interface SDLAddCommandResponse : SDLRPCResponse { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLAddCommandResponse.m b/SmartDeviceLink/SDLAddCommandResponse.m new file mode 100644 index 000000000..3beba9db6 --- /dev/null +++ b/SmartDeviceLink/SDLAddCommandResponse.m @@ -0,0 +1,21 @@ +// SDLAddCommandResponse.m + +#import "SDLAddCommandResponse.h" + +#import "SDLNames.h" + +@implementation SDLAddCommandResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_AddCommand]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLAddSubMenu.h b/SmartDeviceLink/SDLAddSubMenu.h new file mode 100644 index 000000000..0a749b382 --- /dev/null +++ b/SmartDeviceLink/SDLAddSubMenu.h @@ -0,0 +1,66 @@ +// SDLAddSubMenu.h + + +#import "SDLRPCRequest.h" + +/** + * Add a SDLSubMenu to the Command Menu + * <p> + * A SDLSubMenu can only be added to the Top Level Menu (i.e.a SDLSubMenu cannot be + * added to a SDLSubMenu), and may only contain commands as children + * <p> + * <p> + * <b>HMILevel needs to be FULL, LIMITED or BACKGROUD</b> + * </p> + * + * Since <b>SmartDeviceLink 1.0</b><br> + * see SDLDeleteSubMenu SDLAddCommand SDLDeleteCommand + */ +@interface SDLAddSubMenu : SDLRPCRequest { +} + +/** + * Constructs a new SDLAddSubMenu object + */ +- (instancetype)init; +/** + * Constructs a new SDLAddSubMenu object indicated by the dictionary parameter + * <p> + * + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract a Menu ID that identifies a sub menu + * @discussion This value is used in + * <i>SDLAddCommand</i> to which SDLSubMenu is the parent of the command being added + * <p> + */ +@property (strong) NSNumber *menuID; +/** + * @abstract a position of menu + * @discussion An NSNumber pointer representing the position within the items + * of the top level Command Menu. 0 will insert at the front, 1 + * will insert after the first existing element, etc. Position of + * any submenu will always be located before the return and exit + * options + * <p> + * <b>Notes: </b><br/> + * <ul> + * <li> + * Min Value: 0; Max Value: 1000</li> + * <li>If position is greater or equal than the number of items + * on top level, the sub menu will be appended by the end</li> + * <li>If this parameter is omitted, the entry will be added at + * the end of the list</li> + * </ul> + */ +@property (strong) NSNumber *position; +/** + * @abstract a menuName which is displayed representing this submenu item + * @discussion NSString which will be displayed representing this submenu item + */ +@property (strong) NSString *menuName; + +@end diff --git a/SmartDeviceLink/SDLAddSubMenu.m b/SmartDeviceLink/SDLAddSubMenu.m new file mode 100644 index 000000000..f02192b00 --- /dev/null +++ b/SmartDeviceLink/SDLAddSubMenu.m @@ -0,0 +1,57 @@ +// SDLAddSubMenu.m + +#import "SDLAddSubMenu.h" + +#import "SDLNames.h" + +@implementation SDLAddSubMenu + +- (instancetype)init { + if (self = [super initWithName:NAMES_AddSubMenu]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setMenuID:(NSNumber *)menuID { + if (menuID != nil) { + [parameters setObject:menuID forKey:NAMES_menuID]; + } else { + [parameters removeObjectForKey:NAMES_menuID]; + } +} + +- (NSNumber *)menuID { + return [parameters objectForKey:NAMES_menuID]; +} + +- (void)setPosition:(NSNumber *)position { + if (position != nil) { + [parameters setObject:position forKey:NAMES_position]; + } else { + [parameters removeObjectForKey:NAMES_position]; + } +} + +- (NSNumber *)position { + return [parameters objectForKey:NAMES_position]; +} + +- (void)setMenuName:(NSString *)menuName { + if (menuName != nil) { + [parameters setObject:menuName forKey:NAMES_menuName]; + } else { + [parameters removeObjectForKey:NAMES_menuName]; + } +} + +- (NSString *)menuName { + return [parameters objectForKey:NAMES_menuName]; +} + +@end diff --git a/SmartDeviceLink/SDLAddSubMenuResponse.h b/SmartDeviceLink/SDLAddSubMenuResponse.h new file mode 100644 index 000000000..2ea2157d7 --- /dev/null +++ b/SmartDeviceLink/SDLAddSubMenuResponse.h @@ -0,0 +1,16 @@ +// SDLAddSubMenuResponse.h + + +#import "SDLRPCResponse.h" + +/** + * SDLAddSubMenuResponse is sent, when SDLAddSubMenu has been called + * Since <b>SmartDeviceLink 1.0</b> + */ +@interface SDLAddSubMenuResponse : SDLRPCResponse { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLAddSubMenuResponse.m b/SmartDeviceLink/SDLAddSubMenuResponse.m new file mode 100644 index 000000000..5df2745b5 --- /dev/null +++ b/SmartDeviceLink/SDLAddSubMenuResponse.m @@ -0,0 +1,21 @@ +// SDLAddSubMenuResponse.m + +#import "SDLAddSubMenuResponse.h" + +#import "SDLNames.h" + +@implementation SDLAddSubMenuResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_AddSubMenu]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLAirbagStatus.h b/SmartDeviceLink/SDLAirbagStatus.h new file mode 100644 index 000000000..3681795b5 --- /dev/null +++ b/SmartDeviceLink/SDLAirbagStatus.h @@ -0,0 +1,24 @@ +// SDLAirbagStatus.h +// + +#import "SDLRPCMessage.h" + +@class SDLVehicleDataEventStatus; + + +@interface SDLAirbagStatus : SDLRPCStruct { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) SDLVehicleDataEventStatus *driverAirbagDeployed; +@property (strong) SDLVehicleDataEventStatus *driverSideAirbagDeployed; +@property (strong) SDLVehicleDataEventStatus *driverCurtainAirbagDeployed; +@property (strong) SDLVehicleDataEventStatus *passengerAirbagDeployed; +@property (strong) SDLVehicleDataEventStatus *passengerCurtainAirbagDeployed; +@property (strong) SDLVehicleDataEventStatus *driverKneeAirbagDeployed; +@property (strong) SDLVehicleDataEventStatus *passengerSideAirbagDeployed; +@property (strong) SDLVehicleDataEventStatus *passengerKneeAirbagDeployed; + +@end diff --git a/SmartDeviceLink/SDLAirbagStatus.m b/SmartDeviceLink/SDLAirbagStatus.m new file mode 100644 index 000000000..a3ce06689 --- /dev/null +++ b/SmartDeviceLink/SDLAirbagStatus.m @@ -0,0 +1,159 @@ +// SDLAirbagStatus.m + +#import "SDLAirbagStatus.h" + +#import "SDLNames.h" +#import "SDLVehicleDataEventStatus.h" + + +@implementation SDLAirbagStatus + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setDriverAirbagDeployed:(SDLVehicleDataEventStatus *)driverAirbagDeployed { + if (driverAirbagDeployed != nil) { + [store setObject:driverAirbagDeployed forKey:NAMES_driverAirbagDeployed]; + } else { + [store removeObjectForKey:NAMES_driverAirbagDeployed]; + } +} + +- (SDLVehicleDataEventStatus *)driverAirbagDeployed { + NSObject *obj = [store objectForKey:NAMES_driverAirbagDeployed]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +- (void)setDriverSideAirbagDeployed:(SDLVehicleDataEventStatus *)driverSideAirbagDeployed { + if (driverSideAirbagDeployed != nil) { + [store setObject:driverSideAirbagDeployed forKey:NAMES_driverSideAirbagDeployed]; + } else { + [store removeObjectForKey:NAMES_driverSideAirbagDeployed]; + } +} + +- (SDLVehicleDataEventStatus *)driverSideAirbagDeployed { + NSObject *obj = [store objectForKey:NAMES_driverSideAirbagDeployed]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +- (void)setDriverCurtainAirbagDeployed:(SDLVehicleDataEventStatus *)driverCurtainAirbagDeployed { + if (driverCurtainAirbagDeployed != nil) { + [store setObject:driverCurtainAirbagDeployed forKey:NAMES_driverCurtainAirbagDeployed]; + } else { + [store removeObjectForKey:NAMES_driverCurtainAirbagDeployed]; + } +} + +- (SDLVehicleDataEventStatus *)driverCurtainAirbagDeployed { + NSObject *obj = [store objectForKey:NAMES_driverCurtainAirbagDeployed]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +- (void)setPassengerAirbagDeployed:(SDLVehicleDataEventStatus *)passengerAirbagDeployed { + if (passengerAirbagDeployed != nil) { + [store setObject:passengerAirbagDeployed forKey:NAMES_passengerAirbagDeployed]; + } else { + [store removeObjectForKey:NAMES_passengerAirbagDeployed]; + } +} + +- (SDLVehicleDataEventStatus *)passengerAirbagDeployed { + NSObject *obj = [store objectForKey:NAMES_passengerAirbagDeployed]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +- (void)setPassengerCurtainAirbagDeployed:(SDLVehicleDataEventStatus *)passengerCurtainAirbagDeployed { + if (passengerCurtainAirbagDeployed != nil) { + [store setObject:passengerCurtainAirbagDeployed forKey:NAMES_passengerCurtainAirbagDeployed]; + } else { + [store removeObjectForKey:NAMES_passengerCurtainAirbagDeployed]; + } +} + +- (SDLVehicleDataEventStatus *)passengerCurtainAirbagDeployed { + NSObject *obj = [store objectForKey:NAMES_passengerCurtainAirbagDeployed]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +- (void)setDriverKneeAirbagDeployed:(SDLVehicleDataEventStatus *)driverKneeAirbagDeployed { + if (driverKneeAirbagDeployed != nil) { + [store setObject:driverKneeAirbagDeployed forKey:NAMES_driverKneeAirbagDeployed]; + } else { + [store removeObjectForKey:NAMES_driverKneeAirbagDeployed]; + } +} + +- (SDLVehicleDataEventStatus *)driverKneeAirbagDeployed { + NSObject *obj = [store objectForKey:NAMES_driverKneeAirbagDeployed]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +- (void)setPassengerSideAirbagDeployed:(SDLVehicleDataEventStatus *)passengerSideAirbagDeployed { + if (passengerSideAirbagDeployed != nil) { + [store setObject:passengerSideAirbagDeployed forKey:NAMES_passengerSideAirbagDeployed]; + } else { + [store removeObjectForKey:NAMES_passengerSideAirbagDeployed]; + } +} + +- (SDLVehicleDataEventStatus *)passengerSideAirbagDeployed { + NSObject *obj = [store objectForKey:NAMES_passengerSideAirbagDeployed]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +- (void)setPassengerKneeAirbagDeployed:(SDLVehicleDataEventStatus *)passengerKneeAirbagDeployed { + if (passengerKneeAirbagDeployed != nil) { + [store setObject:passengerKneeAirbagDeployed forKey:NAMES_passengerKneeAirbagDeployed]; + } else { + [store removeObjectForKey:NAMES_passengerKneeAirbagDeployed]; + } +} + +- (SDLVehicleDataEventStatus *)passengerKneeAirbagDeployed { + NSObject *obj = [store objectForKey:NAMES_passengerKneeAirbagDeployed]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLAlert.h b/SmartDeviceLink/SDLAlert.h new file mode 100644 index 000000000..59f909caa --- /dev/null +++ b/SmartDeviceLink/SDLAlert.h @@ -0,0 +1,144 @@ +// SDLAlert.h +// + + +#import "SDLRPCRequest.h" + +/** + * Shows an alert which typically consists of text-to-speech message and text on the display. At least either alertText1, alertText2 or TTSChunks need to be provided. + * + * <ul> + * <li>The displayed portion of the SDLAlert, if any, will persist until the + * specified timeout has elapsed, or the SDLAlert is preempted</li> + * <li>An SDLAlert will preempt (abort) any SmartDeviceLink Operation that is in-progress, + * except an already-in-progress SDLAlert</li> + * <li>An SDLAlert cannot be preempted by any SmartDeviceLink Operation</li> + * <li>An SDLAlert can be preempted by a user action (button push)</li> + * <li>An SDLAlert will fail if it is issued while another SDLAlert is in progress</li> + * <li>Although each Alert parameter is optional, in fact each SDLAlert request + * must supply at least one of the following parameters:<br/> + * <ul> + * <li>alertText1</li> + * <li>alertText2</li> + * <li>alertText3</li> + * <li>ttsChunks</li> + * </ul> + * </li> + * </ul> + * <br/> + * <b>HMILevel needs to be FULL or LIMITED.</b><br/> + * <b>If the app has been granted function group Notification the SDLHMILevel can + * also be BACKGROUND</b><br/> + * + * @since SDL 1.0 + */ +@interface SDLAlert : SDLRPCRequest { +} + +/** + * Constructs a new SDLAlert object + */ +- (instancetype)init; + +/** + * Constructs a new SDLAlert object indicated by the dictionary parameter + * + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + + +/** + * @abstract The String to be displayed in the first field of the display during the Alert + * + * @discussion Length is limited to what is indicated in *SDLRegisterAppInterface* response + * + * If omitted, top display line will be cleared + * + * Text is always centered + * + * Optional, Max length 500 chars + */ +@property (strong) NSString *alertText1; + +/** + * @abstract The String to be displayed in the second field of the display during the Alert + * + * @discussion Only permitted if HMI supports a second display line + * + * Length is limited to what is indicated in *SDLRegisterAppInterface* response + * + * If omitted, second display line will be cleared + * + * Text is always centered + * + * Optional, Max length 500 chars + */ +@property (strong) NSString *alertText2; + +/** + * @abstract the String to be displayed in the third field of the display during the Alert + * @discussion Only permitted if HMI supports a third display line + * + * Length is limited to what is indicated in *SDLRegisterAppInterface* response + * + * If omitted, third display line will be cleared + * + * Text is always centered + * + * Optional, Max length 500 chars + */ +@property (strong) NSString *alertText3; + +/** + * @abstract An array which, taken together, specify what is to be spoken to the user + * + * Optional, Array of SDLTTSChunk, Array length 1 - 100 + * + * @see SDLTTSChunk + */ +@property (strong) NSMutableArray *ttsChunks; + +/** + * @abstract The duration of the displayed portion of the alert, in milliseconds. + * + * @discussion After this amount of time has passed, the display fields alertText1 and alertText2 will revert to what was displayed in those fields before the alert began. + * + * Typical timeouts are 3 - 5 seconds + * + * If omitted, the timeout is set to 5 seconds + * + * Optional, Integer, 3000 - 10000 + */ +@property (strong) NSNumber *duration; + +/** + * @abstract Whether the alert tone should be played before the TTS (if any) is spoken. + * + * @discussion If ommitted, no tone is played + * + * Optional, Boolean + */ +@property (strong) NSNumber *playTone; + +/** + * @abstract If supported on the given platform, the alert GUI will include some sort of animation indicating that loading of a feature is progressing. e.g. a spinning wheel or hourglass, etc. + * + * Optional, Boolean + * + * @since SmartDeviceLink 2.0 + */ +@property (strong) NSNumber *progressIndicator; + +/** + * @abstract App defined SoftButtons. + * + * @discussion If omitted on supported displays, the displayed alert shall not have any SoftButtons + * + * Optional, Array of SDLSoftButton, Array size 0 - 4 + * + * @see SDLSoftButton + */ +@property (strong) NSMutableArray *softButtons; + +@end diff --git a/SmartDeviceLink/SDLAlert.m b/SmartDeviceLink/SDLAlert.m new file mode 100644 index 000000000..ddc7fdc3a --- /dev/null +++ b/SmartDeviceLink/SDLAlert.m @@ -0,0 +1,137 @@ +// SDLAlert.m + +#import "SDLAlert.h" + +#import "SDLNames.h" +#import "SDLSoftButton.h" +#import "SDLTTSChunk.h" + +@implementation SDLAlert + +- (instancetype)init { + if (self = [super initWithName:NAMES_Alert]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setAlertText1:(NSString *)alertText1 { + if (alertText1 != nil) { + [parameters setObject:alertText1 forKey:NAMES_alertText1]; + } else { + [parameters removeObjectForKey:NAMES_alertText1]; + } +} + +- (NSString *)alertText1 { + return [parameters objectForKey:NAMES_alertText1]; +} + +- (void)setAlertText2:(NSString *)alertText2 { + if (alertText2 != nil) { + [parameters setObject:alertText2 forKey:NAMES_alertText2]; + } else { + [parameters removeObjectForKey:NAMES_alertText2]; + } +} + +- (NSString *)alertText2 { + return [parameters objectForKey:NAMES_alertText2]; +} + +- (void)setAlertText3:(NSString *)alertText3 { + if (alertText3 != nil) { + [parameters setObject:alertText3 forKey:NAMES_alertText3]; + } else { + [parameters removeObjectForKey:NAMES_alertText3]; + } +} + +- (NSString *)alertText3 { + return [parameters objectForKey:NAMES_alertText3]; +} + +- (void)setTtsChunks:(NSMutableArray *)ttsChunks { + if (ttsChunks != nil) { + [parameters setObject:ttsChunks forKey:NAMES_ttsChunks]; + } else { + [parameters removeObjectForKey:NAMES_ttsChunks]; + } +} + +- (NSMutableArray *)ttsChunks { + NSMutableArray *array = [parameters objectForKey:NAMES_ttsChunks]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLTTSChunk.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLTTSChunk alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +- (void)setDuration:(NSNumber *)duration { + if (duration != nil) { + [parameters setObject:duration forKey:NAMES_duration]; + } else { + [parameters removeObjectForKey:NAMES_duration]; + } +} + +- (NSNumber *)duration { + return [parameters objectForKey:NAMES_duration]; +} + +- (void)setPlayTone:(NSNumber *)playTone { + if (playTone != nil) { + [parameters setObject:playTone forKey:NAMES_playTone]; + } else { + [parameters removeObjectForKey:NAMES_playTone]; + } +} + +- (NSNumber *)playTone { + return [parameters objectForKey:NAMES_playTone]; +} + +- (void)setProgressIndicator:(NSNumber *)progressIndicator { + if (progressIndicator != nil) { + [parameters setObject:progressIndicator forKey:NAMES_progressIndicator]; + } else { + [parameters removeObjectForKey:NAMES_progressIndicator]; + } +} + +- (NSNumber *)progressIndicator { + return [parameters objectForKey:NAMES_progressIndicator]; +} + +- (void)setSoftButtons:(NSMutableArray *)softButtons { + if (softButtons != nil) { + [parameters setObject:softButtons forKey:NAMES_softButtons]; + } else { + [parameters removeObjectForKey:NAMES_softButtons]; + } +} + +- (NSMutableArray *)softButtons { + NSMutableArray *array = [parameters objectForKey:NAMES_softButtons]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLSoftButton.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLSoftButton alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +@end diff --git a/SmartDeviceLink/SDLAlertManeuver.h b/SmartDeviceLink/SDLAlertManeuver.h new file mode 100644 index 000000000..2bb8e12ed --- /dev/null +++ b/SmartDeviceLink/SDLAlertManeuver.h @@ -0,0 +1,19 @@ +// SDLAlertManeuver.h +// + + +#import "SDLRPCRequest.h" + +/** + * @since SmartDeviceLink 1.0 + */ +@interface SDLAlertManeuver : SDLRPCRequest { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) NSMutableArray *ttsChunks; +@property (strong) NSMutableArray *softButtons; + +@end diff --git a/SmartDeviceLink/SDLAlertManeuver.m b/SmartDeviceLink/SDLAlertManeuver.m new file mode 100644 index 000000000..81717506f --- /dev/null +++ b/SmartDeviceLink/SDLAlertManeuver.m @@ -0,0 +1,67 @@ +// SDLAlertManeuver.m +// + + +#import "SDLAlertManeuver.h" + +#import "SDLNames.h" +#import "SDLSoftButton.h" +#import "SDLTTSChunk.h" + +@implementation SDLAlertManeuver + +- (instancetype)init { + if (self = [super initWithName:NAMES_AlertManeuver]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setTtsChunks:(NSMutableArray *)ttsChunks { + if (ttsChunks != nil) { + [parameters setObject:ttsChunks forKey:NAMES_ttsChunks]; + } else { + [parameters removeObjectForKey:NAMES_ttsChunks]; + } +} + +- (NSMutableArray *)ttsChunks { + NSMutableArray *array = [parameters objectForKey:NAMES_ttsChunks]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLTTSChunk.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLTTSChunk alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +- (void)setSoftButtons:(NSMutableArray *)softButtons { + if (softButtons != nil) { + [parameters setObject:softButtons forKey:NAMES_softButtons]; + } else { + [parameters removeObjectForKey:NAMES_softButtons]; + } +} + +- (NSMutableArray *)softButtons { + NSMutableArray *array = [parameters objectForKey:NAMES_softButtons]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLSoftButton.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLSoftButton alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +@end diff --git a/SmartDeviceLink/SDLAlertManeuverResponse.h b/SmartDeviceLink/SDLAlertManeuverResponse.h new file mode 100644 index 000000000..b7d3d6c0a --- /dev/null +++ b/SmartDeviceLink/SDLAlertManeuverResponse.h @@ -0,0 +1,16 @@ +// SDLAlertManeuverResponse.h +// + + +#import "SDLRPCResponse.h" + +/** SDLAlertManeuverResponse is sent, when SDLAlertManeuver has been called. + * @since SmartDeviceLink 1.0 + */ +@interface SDLAlertManeuverResponse : SDLRPCResponse { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLAlertManeuverResponse.m b/SmartDeviceLink/SDLAlertManeuverResponse.m new file mode 100644 index 000000000..5687d3117 --- /dev/null +++ b/SmartDeviceLink/SDLAlertManeuverResponse.m @@ -0,0 +1,22 @@ +// SDLAlertManeuverResponse.m +// + +#import "SDLAlertManeuverResponse.h" + +#import "SDLNames.h" + +@implementation SDLAlertManeuverResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_AlertManeuver]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLAlertResponse.h b/SmartDeviceLink/SDLAlertResponse.h new file mode 100644 index 000000000..81228d34a --- /dev/null +++ b/SmartDeviceLink/SDLAlertResponse.h @@ -0,0 +1,19 @@ +// SDLAlertResponse.h +// + + +#import "SDLRPCResponse.h" + +/** + * Sent after SDLAlert has been sent + * @since SDL 1.0 + */ +@interface SDLAlertResponse : SDLRPCResponse { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) NSNumber *tryAgainTime; + +@end diff --git a/SmartDeviceLink/SDLAlertResponse.m b/SmartDeviceLink/SDLAlertResponse.m new file mode 100644 index 000000000..f55982377 --- /dev/null +++ b/SmartDeviceLink/SDLAlertResponse.m @@ -0,0 +1,34 @@ +// SDLAlertResponse.m +// + +#import "SDLAlertResponse.h" + +#import "SDLNames.h" + +@implementation SDLAlertResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_Alert]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setTryAgainTime:(NSNumber *)tryAgainTime { + if (tryAgainTime != nil) { + [parameters setObject:tryAgainTime forKey:NAMES_tryAgainTime]; + } else { + [parameters removeObjectForKey:NAMES_tryAgainTime]; + } +} + +- (NSNumber *)tryAgainTime { + return [parameters objectForKey:NAMES_tryAgainTime]; +} + +@end diff --git a/SmartDeviceLink/SDLAmbientLightStatus.h b/SmartDeviceLink/SDLAmbientLightStatus.h new file mode 100644 index 000000000..c778c2104 --- /dev/null +++ b/SmartDeviceLink/SDLAmbientLightStatus.h @@ -0,0 +1,26 @@ +// SDLAmbientLightStatus.h +// + + +#import "SDLEnum.h" + +/** + * Reflects the status of the ambient light sensor + * @since SDL 3.0 + */ +@interface SDLAmbientLightStatus : SDLEnum { +} + ++ (SDLAmbientLightStatus *)valueOf:(NSString *)value; ++ (NSArray *)values; + ++ (SDLAmbientLightStatus *)NIGHT; ++ (SDLAmbientLightStatus *)TWILIGHT_1; ++ (SDLAmbientLightStatus *)TWILIGHT_2; ++ (SDLAmbientLightStatus *)TWILIGHT_3; ++ (SDLAmbientLightStatus *)TWILIGHT_4; ++ (SDLAmbientLightStatus *)DAY; ++ (SDLAmbientLightStatus *)UNKNOWN; ++ (SDLAmbientLightStatus *)INVALID; + +@end diff --git a/SmartDeviceLink/SDLAmbientLightStatus.m b/SmartDeviceLink/SDLAmbientLightStatus.m new file mode 100644 index 000000000..7fa21db4a --- /dev/null +++ b/SmartDeviceLink/SDLAmbientLightStatus.m @@ -0,0 +1,100 @@ +// SDLAmbientLightStatus.m +// + +#import "SDLAmbientLightStatus.h" + +SDLAmbientLightStatus *SDLAmbientLightStatus_NIGHT = nil; +SDLAmbientLightStatus *SDLAmbientLightStatus_TWILIGHT_1 = nil; +SDLAmbientLightStatus *SDLAmbientLightStatus_TWILIGHT_2 = nil; +SDLAmbientLightStatus *SDLAmbientLightStatus_TWILIGHT_3 = nil; +SDLAmbientLightStatus *SDLAmbientLightStatus_TWILIGHT_4 = nil; +SDLAmbientLightStatus *SDLAmbientLightStatus_DAY = nil; +SDLAmbientLightStatus *SDLAmbientLightStatus_UNKNOWN = nil; +SDLAmbientLightStatus *SDLAmbientLightStatus_INVALID = nil; + +NSArray *SDLAmbientLightStatus_values = nil; + +@implementation SDLAmbientLightStatus + ++ (SDLAmbientLightStatus *)valueOf:(NSString *)value { + for (SDLAmbientLightStatus *item in SDLAmbientLightStatus.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLAmbientLightStatus_values == nil) { + SDLAmbientLightStatus_values = @[ + SDLAmbientLightStatus.NIGHT, + SDLAmbientLightStatus.TWILIGHT_1, + SDLAmbientLightStatus.TWILIGHT_2, + SDLAmbientLightStatus.TWILIGHT_3, + SDLAmbientLightStatus.TWILIGHT_4, + SDLAmbientLightStatus.DAY, + SDLAmbientLightStatus.UNKNOWN, + SDLAmbientLightStatus.INVALID, + ]; + } + return SDLAmbientLightStatus_values; +} + ++ (SDLAmbientLightStatus *)NIGHT { + if (SDLAmbientLightStatus_NIGHT == nil) { + SDLAmbientLightStatus_NIGHT = [[SDLAmbientLightStatus alloc] initWithValue:@"NIGHT"]; + } + return SDLAmbientLightStatus_NIGHT; +} + ++ (SDLAmbientLightStatus *)TWILIGHT_1 { + if (SDLAmbientLightStatus_TWILIGHT_1 == nil) { + SDLAmbientLightStatus_TWILIGHT_1 = [[SDLAmbientLightStatus alloc] initWithValue:@"TWILIGHT_1"]; + } + return SDLAmbientLightStatus_TWILIGHT_1; +} + ++ (SDLAmbientLightStatus *)TWILIGHT_2 { + if (SDLAmbientLightStatus_TWILIGHT_2 == nil) { + SDLAmbientLightStatus_TWILIGHT_2 = [[SDLAmbientLightStatus alloc] initWithValue:@"TWILIGHT_2"]; + } + return SDLAmbientLightStatus_TWILIGHT_2; +} + ++ (SDLAmbientLightStatus *)TWILIGHT_3 { + if (SDLAmbientLightStatus_TWILIGHT_3 == nil) { + SDLAmbientLightStatus_TWILIGHT_3 = [[SDLAmbientLightStatus alloc] initWithValue:@"TWILIGHT_3"]; + } + return SDLAmbientLightStatus_TWILIGHT_3; +} + ++ (SDLAmbientLightStatus *)TWILIGHT_4 { + if (SDLAmbientLightStatus_TWILIGHT_4 == nil) { + SDLAmbientLightStatus_TWILIGHT_4 = [[SDLAmbientLightStatus alloc] initWithValue:@"TWILIGHT_4"]; + } + return SDLAmbientLightStatus_TWILIGHT_4; +} + ++ (SDLAmbientLightStatus *)DAY { + if (SDLAmbientLightStatus_DAY == nil) { + SDLAmbientLightStatus_DAY = [[SDLAmbientLightStatus alloc] initWithValue:@"DAY"]; + } + return SDLAmbientLightStatus_DAY; +} + ++ (SDLAmbientLightStatus *)UNKNOWN { + if (SDLAmbientLightStatus_UNKNOWN == nil) { + SDLAmbientLightStatus_UNKNOWN = [[SDLAmbientLightStatus alloc] initWithValue:@"UNKNOWN"]; + } + return SDLAmbientLightStatus_UNKNOWN; +} + ++ (SDLAmbientLightStatus *)INVALID { + if (SDLAmbientLightStatus_INVALID == nil) { + SDLAmbientLightStatus_INVALID = [[SDLAmbientLightStatus alloc] initWithValue:@"INVALID"]; + } + return SDLAmbientLightStatus_INVALID; +} + +@end diff --git a/SmartDeviceLink/SDLAppHMIType.h b/SmartDeviceLink/SDLAppHMIType.h new file mode 100644 index 000000000..3aaa45170 --- /dev/null +++ b/SmartDeviceLink/SDLAppHMIType.h @@ -0,0 +1,96 @@ +// SDLAppHMIType.h +// + + +#import "SDLEnum.h" + +/** + * Enumeration listing possible app hmi types. + * + * @since SDL 2.0 + */ +@interface SDLAppHMIType : SDLEnum { +} + +/** + * @abstract Convert String to AppHMIType + * + * @param value The value of the string to get an object for + * + * @return SDLAppHMIType + */ ++ (SDLAppHMIType *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLAppHMIType + * + * @return an array that store all possible SDLAppHMIType + */ ++ (NSArray *)values; + +/** + * @abstract The App will have default rights. + * + * @return SDLAppHMIType with value *DEFAULT* + */ ++ (SDLAppHMIType *)DEFAULT; + +/** + * @abstract Communication type of App + * + * @return SDLAppHMIType with value *COMMUNICATION* + */ ++ (SDLAppHMIType *)COMMUNICATION; + +/** + * @abstract App dealing with Media + * + * @return SDLAppHMIType with value *MEDIA* + */ ++ (SDLAppHMIType *)MEDIA; + +/** + * @abstract Messaging App + * + * @return SDLAppHMIType with value *MESSAGING* + */ ++ (SDLAppHMIType *)MESSAGING; + +/** + * @abstract Navigation App + * + * @return SDLAppHMIType with value *NAVIGATION* + */ ++ (SDLAppHMIType *)NAVIGATION; + +/** + * @abstract Information App + * + * @return SDLAppHMIType with value *INFORMATION* + */ ++ (SDLAppHMIType *)INFORMATION; + +/** + * @abstract App dealing with social media + * + * @return SDLAppHMIType with value *SOCIAL* + */ ++ (SDLAppHMIType *)SOCIAL; + ++ (SDLAppHMIType *)BACKGROUND_PROCESS; + +/** + * @abstract App only for Testing purposes + * + * @return SDLAppHMIType with value *TESTING* + */ ++ (SDLAppHMIType *)TESTING; + +/** + * @abstract System App + * + * @return SDLAppHMIType with value *SYSTEM* + */ ++ (SDLAppHMIType *)SYSTEM; + +@end diff --git a/SmartDeviceLink/SDLAppHMIType.m b/SmartDeviceLink/SDLAppHMIType.m new file mode 100644 index 000000000..f09f3af44 --- /dev/null +++ b/SmartDeviceLink/SDLAppHMIType.m @@ -0,0 +1,119 @@ +// SDLAppHMIType.m +// + + +#import "SDLAppHMIType.h" + +SDLAppHMIType *SDLAppHMIType_DEFAULT = nil; +SDLAppHMIType *SDLAppHMIType_COMMUNICATION = nil; +SDLAppHMIType *SDLAppHMIType_MEDIA = nil; +SDLAppHMIType *SDLAppHMIType_MESSAGING = nil; +SDLAppHMIType *SDLAppHMIType_NAVIGATION = nil; +SDLAppHMIType *SDLAppHMIType_INFORMATION = nil; +SDLAppHMIType *SDLAppHMIType_SOCIAL = nil; +SDLAppHMIType *SDLAppHMIType_BACKGROUND_PROCESS = nil; +SDLAppHMIType *SDLAppHMIType_TESTING = nil; +SDLAppHMIType *SDLAppHMIType_SYSTEM = nil; + +NSArray *SDLAppHMIType_values = nil; + +@implementation SDLAppHMIType + ++ (SDLAppHMIType *)valueOf:(NSString *)value { + for (SDLAppHMIType *item in SDLAppHMIType.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLAppHMIType_values == nil) { + SDLAppHMIType_values = @[ + SDLAppHMIType.DEFAULT, + SDLAppHMIType.COMMUNICATION, + SDLAppHMIType.MEDIA, + SDLAppHMIType.MESSAGING, + SDLAppHMIType.NAVIGATION, + SDLAppHMIType.INFORMATION, + SDLAppHMIType.SOCIAL, + SDLAppHMIType.BACKGROUND_PROCESS, + SDLAppHMIType.TESTING, + SDLAppHMIType.SYSTEM, + ]; + } + return SDLAppHMIType_values; +} + ++ (SDLAppHMIType *)DEFAULT { + if (SDLAppHMIType_DEFAULT == nil) { + SDLAppHMIType_DEFAULT = [[SDLAppHMIType alloc] initWithValue:@"DEFAULT"]; + } + return SDLAppHMIType_DEFAULT; +} + ++ (SDLAppHMIType *)COMMUNICATION { + if (SDLAppHMIType_COMMUNICATION == nil) { + SDLAppHMIType_COMMUNICATION = [[SDLAppHMIType alloc] initWithValue:@"COMMUNICATION"]; + } + return SDLAppHMIType_COMMUNICATION; +} + ++ (SDLAppHMIType *)MEDIA { + if (SDLAppHMIType_MEDIA == nil) { + SDLAppHMIType_MEDIA = [[SDLAppHMIType alloc] initWithValue:@"MEDIA"]; + } + return SDLAppHMIType_MEDIA; +} + ++ (SDLAppHMIType *)MESSAGING { + if (SDLAppHMIType_MESSAGING == nil) { + SDLAppHMIType_MESSAGING = [[SDLAppHMIType alloc] initWithValue:@"MESSAGING"]; + } + return SDLAppHMIType_MESSAGING; +} + ++ (SDLAppHMIType *)NAVIGATION { + if (SDLAppHMIType_NAVIGATION == nil) { + SDLAppHMIType_NAVIGATION = [[SDLAppHMIType alloc] initWithValue:@"NAVIGATION"]; + } + return SDLAppHMIType_NAVIGATION; +} + ++ (SDLAppHMIType *)INFORMATION { + if (SDLAppHMIType_INFORMATION == nil) { + SDLAppHMIType_INFORMATION = [[SDLAppHMIType alloc] initWithValue:@"INFORMATION"]; + } + return SDLAppHMIType_INFORMATION; +} + ++ (SDLAppHMIType *)SOCIAL { + if (SDLAppHMIType_SOCIAL == nil) { + SDLAppHMIType_SOCIAL = [[SDLAppHMIType alloc] initWithValue:@"SOCIAL"]; + } + return SDLAppHMIType_SOCIAL; +} + ++ (SDLAppHMIType *)BACKGROUND_PROCESS { + if (SDLAppHMIType_BACKGROUND_PROCESS == nil) { + SDLAppHMIType_BACKGROUND_PROCESS = [[SDLAppHMIType alloc] initWithValue:@"BACKGROUND_PROCESS"]; + } + return SDLAppHMIType_BACKGROUND_PROCESS; +} + ++ (SDLAppHMIType *)TESTING { + if (SDLAppHMIType_TESTING == nil) { + SDLAppHMIType_TESTING = [[SDLAppHMIType alloc] initWithValue:@"TESTING"]; + } + return SDLAppHMIType_TESTING; +} + ++ (SDLAppHMIType *)SYSTEM { + if (SDLAppHMIType_SYSTEM == nil) { + SDLAppHMIType_SYSTEM = [[SDLAppHMIType alloc] initWithValue:@"SYSTEM"]; + } + return SDLAppHMIType_SYSTEM; +} + +@end diff --git a/SmartDeviceLink/SDLAppInterfaceUnregisteredReason.h b/SmartDeviceLink/SDLAppInterfaceUnregisteredReason.h new file mode 100644 index 000000000..4fce3ba16 --- /dev/null +++ b/SmartDeviceLink/SDLAppInterfaceUnregisteredReason.h @@ -0,0 +1,103 @@ +// SDLAppInterfaceUnregisteredReason.h +// + + +#import "SDLEnum.h" + +/** + * Indicates reason why app interface was unregistered. The application is being disconnected by SDL. + * + * @since SDL 1.0 + */ +@interface SDLAppInterfaceUnregisteredReason : SDLEnum { +} + +/** + * @abstract Convert String to SDLAppInterfaceUnregisteredReason + * + * @param value String value to retrieve the object for + * + * @return SDLAppInterfaceUnregisteredReason + */ ++ (SDLAppInterfaceUnregisteredReason *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLAppInterfaceUnregisteredReason + * + * @return an array that stores all possible SDLAppInterfaceUnregisteredReason + */ ++ (NSArray *)values; + +/** + * @abstract Vehicle ignition turned off. + * + * @return SDLAppInterfaceUnregisteredReason with value *IGNITION_OFF* + */ ++ (SDLAppInterfaceUnregisteredReason *)IGNITION_OFF; + +/** + * @abstract Bluetooth was turned off, causing termination of a necessary Bluetooth connection. + * + * @return SDLAppInterfaceUnregisteredReason with value *BLUETOOTH_OFF* + */ ++ (SDLAppInterfaceUnregisteredReason *)BLUETOOTH_OFF; + +/** + * @abstract USB was disconnected, causing termination of a necessary iAP connection. + * + * @return SDLAppInterfaceUnregisteredReason with value *USB_DISCONNECTED* + */ ++ (SDLAppInterfaceUnregisteredReason *)USB_DISCONNECTED; + +/** + * @abstract Application attempted SmartDeviceLink RPC request while HMILevel = NONE. App must have HMILevel other than NONE to issue RPC requests or get notifications or RPC responses. + * + * @return SDLAppInterfaceUnregisteredReason with value *REQUEST_WHILE_IN_NONE_HMI_LEVEL* + */ ++ (SDLAppInterfaceUnregisteredReason *)REQUEST_WHILE_IN_NONE_HMI_LEVEL; + +/** + * @abstract Either too many -- or too many per unit of time -- requests were made by the application. + * + * @return SDLAppInterfaceUnregisteredReason with value *TOO_MANY_REQUESTS* + */ ++ (SDLAppInterfaceUnregisteredReason *)TOO_MANY_REQUESTS; + +/** + * @abstract The application has issued requests which cause driver distraction rules to be violated. + * + * @return SDLAppInterfaceUnregisteredReason with value *DRIVER_DISTRACTION_VIOLATION* + */ ++ (SDLAppInterfaceUnregisteredReason *)DRIVER_DISTRACTION_VIOLATION; + +/** + * @abstract The user performed a language change on the SDL platform, causing the application to need to be reregistered for the new language. + * + * @return SDLAppInterfaceUnregisteredReason with value *LANGUAGE_CHANGE* + */ ++ (SDLAppInterfaceUnregisteredReason *)LANGUAGE_CHANGE; + +/** + * @abstract The user performed a MASTER RESET on the SDL platform, causing removal of a necessary Bluetooth pairing. + * + * @return SDLAppInterfaceUnregisteredReason with value *MASTER_RESET* + */ ++ (SDLAppInterfaceUnregisteredReason *)MASTER_RESET; + +/** + * @abstract The user restored settings to FACTORY DEFAULTS on the SDL platform. + * + * @return SDLAppInterfaceUnregisteredReason with value *FACTORY_DEFAULTS* + */ ++ (SDLAppInterfaceUnregisteredReason *)FACTORY_DEFAULTS; + +/** + * @abstract The app is not being authorized to be connected to SDL. + * + * @return SDLAppInterfaceUnregisteredReason with value *APP_UNAUTHORIZED* + * + * @since SDL 2.0 + */ ++ (SDLAppInterfaceUnregisteredReason *)APP_UNAUTHORIZED; + +@end diff --git a/SmartDeviceLink/SDLAppInterfaceUnregisteredReason.m b/SmartDeviceLink/SDLAppInterfaceUnregisteredReason.m new file mode 100644 index 000000000..72c19a8f5 --- /dev/null +++ b/SmartDeviceLink/SDLAppInterfaceUnregisteredReason.m @@ -0,0 +1,118 @@ +// SDLAppInterfaceUnregisteredReason.m +// + +#import "SDLAppInterfaceUnregisteredReason.h" + +SDLAppInterfaceUnregisteredReason *SDLAppInterfaceUnregisteredReason_IGNITION_OFF = nil; +SDLAppInterfaceUnregisteredReason *SDLAppInterfaceUnregisteredReason_BLUETOOTH_OFF = nil; +SDLAppInterfaceUnregisteredReason *SDLAppInterfaceUnregisteredReason_USB_DISCONNECTED = nil; +SDLAppInterfaceUnregisteredReason *SDLAppInterfaceUnregisteredReason_REQUEST_WHILE_IN_NONE_HMI_LEVEL = nil; +SDLAppInterfaceUnregisteredReason *SDLAppInterfaceUnregisteredReason_TOO_MANY_REQUESTS = nil; +SDLAppInterfaceUnregisteredReason *SDLAppInterfaceUnregisteredReason_DRIVER_DISTRACTION_VIOLATION = nil; +SDLAppInterfaceUnregisteredReason *SDLAppInterfaceUnregisteredReason_LANGUAGE_CHANGE = nil; +SDLAppInterfaceUnregisteredReason *SDLAppInterfaceUnregisteredReason_MASTER_RESET = nil; +SDLAppInterfaceUnregisteredReason *SDLAppInterfaceUnregisteredReason_FACTORY_DEFAULTS = nil; +SDLAppInterfaceUnregisteredReason *SDLAppInterfaceUnregisteredReason_APP_UNAUTHORIZED = nil; + +NSArray *SDLAppInterfaceUnregisteredReason_values = nil; + +@implementation SDLAppInterfaceUnregisteredReason + ++ (SDLAppInterfaceUnregisteredReason *)valueOf:(NSString *)value { + for (SDLAppInterfaceUnregisteredReason *item in SDLAppInterfaceUnregisteredReason.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLAppInterfaceUnregisteredReason_values == nil) { + SDLAppInterfaceUnregisteredReason_values = @[ + SDLAppInterfaceUnregisteredReason.IGNITION_OFF, + SDLAppInterfaceUnregisteredReason.BLUETOOTH_OFF, + SDLAppInterfaceUnregisteredReason.USB_DISCONNECTED, + SDLAppInterfaceUnregisteredReason.REQUEST_WHILE_IN_NONE_HMI_LEVEL, + SDLAppInterfaceUnregisteredReason.TOO_MANY_REQUESTS, + SDLAppInterfaceUnregisteredReason.DRIVER_DISTRACTION_VIOLATION, + SDLAppInterfaceUnregisteredReason.LANGUAGE_CHANGE, + SDLAppInterfaceUnregisteredReason.MASTER_RESET, + SDLAppInterfaceUnregisteredReason.FACTORY_DEFAULTS, + SDLAppInterfaceUnregisteredReason.APP_UNAUTHORIZED, + ]; + } + return SDLAppInterfaceUnregisteredReason_values; +} + ++ (SDLAppInterfaceUnregisteredReason *)IGNITION_OFF { + if (SDLAppInterfaceUnregisteredReason_IGNITION_OFF == nil) { + SDLAppInterfaceUnregisteredReason_IGNITION_OFF = [[SDLAppInterfaceUnregisteredReason alloc] initWithValue:@"IGNITION_OFF"]; + } + return SDLAppInterfaceUnregisteredReason_IGNITION_OFF; +} + ++ (SDLAppInterfaceUnregisteredReason *)BLUETOOTH_OFF { + if (SDLAppInterfaceUnregisteredReason_BLUETOOTH_OFF == nil) { + SDLAppInterfaceUnregisteredReason_BLUETOOTH_OFF = [[SDLAppInterfaceUnregisteredReason alloc] initWithValue:@"BLUETOOTH_OFF"]; + } + return SDLAppInterfaceUnregisteredReason_BLUETOOTH_OFF; +} + ++ (SDLAppInterfaceUnregisteredReason *)USB_DISCONNECTED { + if (SDLAppInterfaceUnregisteredReason_USB_DISCONNECTED == nil) { + SDLAppInterfaceUnregisteredReason_USB_DISCONNECTED = [[SDLAppInterfaceUnregisteredReason alloc] initWithValue:@"USB_DISCONNECTED"]; + } + return SDLAppInterfaceUnregisteredReason_USB_DISCONNECTED; +} + ++ (SDLAppInterfaceUnregisteredReason *)REQUEST_WHILE_IN_NONE_HMI_LEVEL { + if (SDLAppInterfaceUnregisteredReason_REQUEST_WHILE_IN_NONE_HMI_LEVEL == nil) { + SDLAppInterfaceUnregisteredReason_REQUEST_WHILE_IN_NONE_HMI_LEVEL = [[SDLAppInterfaceUnregisteredReason alloc] initWithValue:@"REQUEST_WHILE_IN_NONE_HMI_LEVEL"]; + } + return SDLAppInterfaceUnregisteredReason_REQUEST_WHILE_IN_NONE_HMI_LEVEL; +} + ++ (SDLAppInterfaceUnregisteredReason *)TOO_MANY_REQUESTS { + if (SDLAppInterfaceUnregisteredReason_TOO_MANY_REQUESTS == nil) { + SDLAppInterfaceUnregisteredReason_TOO_MANY_REQUESTS = [[SDLAppInterfaceUnregisteredReason alloc] initWithValue:@"TOO_MANY_REQUESTS"]; + } + return SDLAppInterfaceUnregisteredReason_TOO_MANY_REQUESTS; +} + ++ (SDLAppInterfaceUnregisteredReason *)DRIVER_DISTRACTION_VIOLATION { + if (SDLAppInterfaceUnregisteredReason_DRIVER_DISTRACTION_VIOLATION == nil) { + SDLAppInterfaceUnregisteredReason_DRIVER_DISTRACTION_VIOLATION = [[SDLAppInterfaceUnregisteredReason alloc] initWithValue:@"DRIVER_DISTRACTION_VIOLATION"]; + } + return SDLAppInterfaceUnregisteredReason_DRIVER_DISTRACTION_VIOLATION; +} + ++ (SDLAppInterfaceUnregisteredReason *)LANGUAGE_CHANGE { + if (SDLAppInterfaceUnregisteredReason_LANGUAGE_CHANGE == nil) { + SDLAppInterfaceUnregisteredReason_LANGUAGE_CHANGE = [[SDLAppInterfaceUnregisteredReason alloc] initWithValue:@"LANGUAGE_CHANGE"]; + } + return SDLAppInterfaceUnregisteredReason_LANGUAGE_CHANGE; +} + ++ (SDLAppInterfaceUnregisteredReason *)MASTER_RESET { + if (SDLAppInterfaceUnregisteredReason_MASTER_RESET == nil) { + SDLAppInterfaceUnregisteredReason_MASTER_RESET = [[SDLAppInterfaceUnregisteredReason alloc] initWithValue:@"MASTER_RESET"]; + } + return SDLAppInterfaceUnregisteredReason_MASTER_RESET; +} + ++ (SDLAppInterfaceUnregisteredReason *)FACTORY_DEFAULTS { + if (SDLAppInterfaceUnregisteredReason_FACTORY_DEFAULTS == nil) { + SDLAppInterfaceUnregisteredReason_FACTORY_DEFAULTS = [[SDLAppInterfaceUnregisteredReason alloc] initWithValue:@"FACTORY_DEFAULTS"]; + } + return SDLAppInterfaceUnregisteredReason_FACTORY_DEFAULTS; +} + ++ (SDLAppInterfaceUnregisteredReason *)APP_UNAUTHORIZED { + if (SDLAppInterfaceUnregisteredReason_APP_UNAUTHORIZED == nil) { + SDLAppInterfaceUnregisteredReason_APP_UNAUTHORIZED = [[SDLAppInterfaceUnregisteredReason alloc] initWithValue:@"APP_UNAUTHORIZED"]; + } + return SDLAppInterfaceUnregisteredReason_APP_UNAUTHORIZED; +} + +@end diff --git a/SmartDeviceLink/SDLAudioPassThruCapabilities.h b/SmartDeviceLink/SDLAudioPassThruCapabilities.h new file mode 100644 index 000000000..96772b62b --- /dev/null +++ b/SmartDeviceLink/SDLAudioPassThruCapabilities.h @@ -0,0 +1,74 @@ +// SDLAudioPassThruCapabilities.h +// + +#import "SDLRPCMessage.h" + +@class SDLAudioType; +@class SDLBitsPerSample; +@class SDLSamplingRate; + + +/** + * Describes different audio type configurations for SDLPerformAudioPassThru, e.g. {8kHz,8-bit,PCM} + * <p><b>Parameter List</b> + * <table border="1" rules="all"> + * <tr> + * <th>Name</th> + * <th>Type</th> + * <th>Description</th> + * <th>SmartDeviceLink Ver. Available</th> + * </tr> + * <tr> + * <td>samplingRate</td> + * <td>SDLSamplingRate * </td> + * <td>Describes the sampling rate for AudioPassThru + * </td> + * <td>SmartDeviceLink 2.0</td> + * </tr> + * <tr> + * <td>bitsPerSample</td> + * <td>SDLBitsPerSample * </td> + * <td>Describes the sample depth in bit for AudioPassThru + * </td> + * <td>SmartDeviceLink 2.0</td> + * </tr> + * <tr> + * <td>audioType</td> + * <td>SDLAudioType * </td> + * <td>Describes the audiotype for AudioPassThru + * </td> + * <td>SmartDeviceLink 2.0</td> + * </tr> + * </table> + * Since <b>SmartDeviceLink 2.0</b> + */ +@interface SDLAudioPassThruCapabilities : SDLRPCStruct { +} + +/** + * Constructs a newly allocated SDLAudioPassThruCapabilities object + */ +- (instancetype)init; +/** + * Constructs a newly allocated SDLAudioPassThruCapabilities object indicated by the Hashtable parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract The sampling rate for AudioPassThru<br> + * + */ +@property (strong) SDLSamplingRate *samplingRate; +/** + * @abstract The sample depth in bit for AudioPassThru<br> + * + */ +@property (strong) SDLBitsPerSample *bitsPerSample; +/** + * @abstract The audiotype for AudioPassThru<br> + * + */ +@property (strong) SDLAudioType *audioType; + +@end diff --git a/SmartDeviceLink/SDLAudioPassThruCapabilities.m b/SmartDeviceLink/SDLAudioPassThruCapabilities.m new file mode 100644 index 000000000..fbb02be84 --- /dev/null +++ b/SmartDeviceLink/SDLAudioPassThruCapabilities.m @@ -0,0 +1,78 @@ +// SDLAudioPassThruCapabilities.m +// + + +#import "SDLAudioPassThruCapabilities.h" + +#import "SDLAudioType.h" +#import "SDLBitsPerSample.h" +#import "SDLNames.h" +#import "SDLSamplingRate.h" + + +@implementation SDLAudioPassThruCapabilities + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setSamplingRate:(SDLSamplingRate *)samplingRate { + if (samplingRate != nil) { + [store setObject:samplingRate forKey:NAMES_samplingRate]; + } else { + [store removeObjectForKey:NAMES_samplingRate]; + } +} + +- (SDLSamplingRate *)samplingRate { + NSObject *obj = [store objectForKey:NAMES_samplingRate]; + if (obj == nil || [obj isKindOfClass:SDLSamplingRate.class]) { + return (SDLSamplingRate *)obj; + } else { + return [SDLSamplingRate valueOf:(NSString *)obj]; + } +} + +- (void)setBitsPerSample:(SDLBitsPerSample *)bitsPerSample { + if (bitsPerSample != nil) { + [store setObject:bitsPerSample forKey:NAMES_bitsPerSample]; + } else { + [store removeObjectForKey:NAMES_bitsPerSample]; + } +} + +- (SDLBitsPerSample *)bitsPerSample { + NSObject *obj = [store objectForKey:NAMES_bitsPerSample]; + if (obj == nil || [obj isKindOfClass:SDLBitsPerSample.class]) { + return (SDLBitsPerSample *)obj; + } else { + return [SDLBitsPerSample valueOf:(NSString *)obj]; + } +} + +- (void)setAudioType:(SDLAudioType *)audioType { + if (audioType != nil) { + [store setObject:audioType forKey:NAMES_audioType]; + } else { + [store removeObjectForKey:NAMES_audioType]; + } +} + +- (SDLAudioType *)audioType { + NSObject *obj = [store objectForKey:NAMES_audioType]; + if (obj == nil || [obj isKindOfClass:SDLAudioType.class]) { + return (SDLAudioType *)obj; + } else { + return [SDLAudioType valueOf:(NSString *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLAudioStreamingState.h b/SmartDeviceLink/SDLAudioStreamingState.h new file mode 100644 index 000000000..3f364495e --- /dev/null +++ b/SmartDeviceLink/SDLAudioStreamingState.h @@ -0,0 +1,52 @@ +// SDLAudioStreamingState.h +// + + +#import "SDLEnum.h" + +/** + * Describes whether or not streaming audio is currently audible to the user. Though provided in every OnHMIStatus notification, this information is only relevant for applications that declare themselves as media apps in RegisterAppInterface + * + * @since SDL 1.0 + */ +@interface SDLAudioStreamingState : SDLEnum { +} + +/** + * @abstract Convert String to SDLAudioStreamingState + * + * @param value The value of the string to get an object for + * + * @return SDLAudioStreamingState + */ ++ (SDLAudioStreamingState *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLAudioStreamingState + * + * @return an array that store all possible SDLAudioStreamingState + */ ++ (NSArray *)values; +/** + * @abstract Currently streaming audio, if any, is audible to user. + * + * @return SDLAudioStreamingState with value of *AUDIBLE* + */ ++ (SDLAudioStreamingState *)AUDIBLE; + +/** + * @abstract Some kind of audio mixing is taking place. Currently streaming audio, if any, is audible to the user at a lowered volume. + * + * @return SDLAudioStreamingState with value of *ATTENUATED* + * + * @since SDL 2.0 + */ ++ (SDLAudioStreamingState *)ATTENUATED; + +/** + * @abstract Currently streaming audio, if any, is not audible to user. made via VR session. + * + * @return SDLAudioStreamingState with value of *NOT_AUDIBLE* + */ ++ (SDLAudioStreamingState *)NOT_AUDIBLE; +@end diff --git a/SmartDeviceLink/SDLAudioStreamingState.m b/SmartDeviceLink/SDLAudioStreamingState.m new file mode 100644 index 000000000..38b8676c3 --- /dev/null +++ b/SmartDeviceLink/SDLAudioStreamingState.m @@ -0,0 +1,56 @@ +// SDLAudioStreamingState.m +// + + +#import "SDLAudioStreamingState.h" + +SDLAudioStreamingState *SDLAudioStreamingState_AUDIBLE = nil; +SDLAudioStreamingState *SDLAudioStreamingState_ATTENUATED = nil; +SDLAudioStreamingState *SDLAudioStreamingState_NOT_AUDIBLE = nil; + +NSArray *SDLAudioStreamingState_values = nil; + +@implementation SDLAudioStreamingState + ++ (SDLAudioStreamingState *)valueOf:(NSString *)value { + for (SDLAudioStreamingState *item in SDLAudioStreamingState.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLAudioStreamingState_values == nil) { + SDLAudioStreamingState_values = @[ + SDLAudioStreamingState.AUDIBLE, + SDLAudioStreamingState.ATTENUATED, + SDLAudioStreamingState.NOT_AUDIBLE, + ]; + } + return SDLAudioStreamingState_values; +} + ++ (SDLAudioStreamingState *)AUDIBLE { + if (SDLAudioStreamingState_AUDIBLE == nil) { + SDLAudioStreamingState_AUDIBLE = [[SDLAudioStreamingState alloc] initWithValue:@"AUDIBLE"]; + } + return SDLAudioStreamingState_AUDIBLE; +} + ++ (SDLAudioStreamingState *)ATTENUATED { + if (SDLAudioStreamingState_ATTENUATED == nil) { + SDLAudioStreamingState_ATTENUATED = [[SDLAudioStreamingState alloc] initWithValue:@"ATTENUATED"]; + } + return SDLAudioStreamingState_ATTENUATED; +} + ++ (SDLAudioStreamingState *)NOT_AUDIBLE { + if (SDLAudioStreamingState_NOT_AUDIBLE == nil) { + SDLAudioStreamingState_NOT_AUDIBLE = [[SDLAudioStreamingState alloc] initWithValue:@"NOT_AUDIBLE"]; + } + return SDLAudioStreamingState_NOT_AUDIBLE; +} + +@end diff --git a/SmartDeviceLink/SDLAudioType.h b/SmartDeviceLink/SDLAudioType.h new file mode 100644 index 000000000..2f1879eea --- /dev/null +++ b/SmartDeviceLink/SDLAudioType.h @@ -0,0 +1,38 @@ +// SDLAudioType.h +// + + +#import "SDLEnum.h" + +/** + Describes different audio type options for PerformAudioPassThru + */ +@interface SDLAudioType : SDLEnum { +} + +/** + * @abstract Convert String to SDLAudioType + * + * @param value The value of the string to get an object for + * + * @return SDLAudioType + */ ++ (SDLAudioType *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLAudioType + * + * @return an array that store all possible SDLAudioType + */ ++ (NSArray *)values; + +/** + * @abstract PCM raw audio + * + * @return SDLAudioType with value of *PCM* + * + * @since SDL 2.0 + */ ++ (SDLAudioType *)PCM; + +@end
\ No newline at end of file diff --git a/SmartDeviceLink/SDLAudioType.m b/SmartDeviceLink/SDLAudioType.m new file mode 100644 index 000000000..5e99123c7 --- /dev/null +++ b/SmartDeviceLink/SDLAudioType.m @@ -0,0 +1,37 @@ +// SDLAudioType.m +// + +#import "SDLAudioType.h" + +SDLAudioType *SDLAudioType_PCM = nil; + +NSArray *SDLAudioType_values = nil; + +@implementation SDLAudioType + ++ (SDLAudioType *)valueOf:(NSString *)value { + for (SDLAudioType *item in SDLAudioType.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLAudioType_values == nil) { + SDLAudioType_values = @[ + SDLAudioType.PCM, + ]; + } + return SDLAudioType_values; +} + ++ (SDLAudioType *)PCM { + if (SDLAudioType_PCM == nil) { + SDLAudioType_PCM = [[SDLAudioType alloc] initWithValue:@"PCM"]; + } + return SDLAudioType_PCM; +} + +@end diff --git a/SmartDeviceLink/SDLBeltStatus.h b/SmartDeviceLink/SDLBeltStatus.h new file mode 100644 index 000000000..d12e42eb7 --- /dev/null +++ b/SmartDeviceLink/SDLBeltStatus.h @@ -0,0 +1,31 @@ +// SDLBeltStatus.h +// + +#import "SDLRPCMessage.h" + +@class SDLVehicleDataEventStatus; + + +@interface SDLBeltStatus : SDLRPCStruct { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) SDLVehicleDataEventStatus *driverBeltDeployed; +@property (strong) SDLVehicleDataEventStatus *passengerBeltDeployed; +@property (strong) SDLVehicleDataEventStatus *passengerBuckleBelted; +@property (strong) SDLVehicleDataEventStatus *driverBuckleBelted; +@property (strong) SDLVehicleDataEventStatus *leftRow2BuckleBelted; +@property (strong) SDLVehicleDataEventStatus *passengerChildDetected; +@property (strong) SDLVehicleDataEventStatus *rightRow2BuckleBelted; +@property (strong) SDLVehicleDataEventStatus *middleRow2BuckleBelted; +@property (strong) SDLVehicleDataEventStatus *middleRow3BuckleBelted; +@property (strong) SDLVehicleDataEventStatus *leftRow3BuckleBelted; +@property (strong) SDLVehicleDataEventStatus *rightRow3BuckleBelted; +@property (strong) SDLVehicleDataEventStatus *leftRearInflatableBelted; +@property (strong) SDLVehicleDataEventStatus *rightRearInflatableBelted; +@property (strong) SDLVehicleDataEventStatus *middleRow1BeltDeployed; +@property (strong) SDLVehicleDataEventStatus *middleRow1BuckleBelted; + +@end diff --git a/SmartDeviceLink/SDLBeltStatus.m b/SmartDeviceLink/SDLBeltStatus.m new file mode 100644 index 000000000..70b54d2bd --- /dev/null +++ b/SmartDeviceLink/SDLBeltStatus.m @@ -0,0 +1,279 @@ +// SDLBeltStatus.m +// + +#import "SDLBeltStatus.h" + +#import "SDLNames.h" +#import "SDLVehicleDataEventStatus.h" + + +@implementation SDLBeltStatus + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setDriverBeltDeployed:(SDLVehicleDataEventStatus *)driverBeltDeployed { + if (driverBeltDeployed != nil) { + [store setObject:driverBeltDeployed forKey:NAMES_driverBeltDeployed]; + } else { + [store removeObjectForKey:NAMES_driverBeltDeployed]; + } +} + +- (SDLVehicleDataEventStatus *)driverBeltDeployed { + NSObject *obj = [store objectForKey:NAMES_driverBeltDeployed]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +- (void)setPassengerBeltDeployed:(SDLVehicleDataEventStatus *)passengerBeltDeployed { + if (passengerBeltDeployed != nil) { + [store setObject:passengerBeltDeployed forKey:NAMES_passengerBeltDeployed]; + } else { + [store removeObjectForKey:NAMES_passengerBeltDeployed]; + } +} + +- (SDLVehicleDataEventStatus *)passengerBeltDeployed { + NSObject *obj = [store objectForKey:NAMES_passengerBeltDeployed]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +- (void)setPassengerBuckleBelted:(SDLVehicleDataEventStatus *)passengerBuckleBelted { + if (passengerBuckleBelted != nil) { + [store setObject:passengerBuckleBelted forKey:NAMES_passengerBuckleBelted]; + } else { + [store removeObjectForKey:NAMES_passengerBuckleBelted]; + } +} + +- (SDLVehicleDataEventStatus *)passengerBuckleBelted { + NSObject *obj = [store objectForKey:NAMES_passengerBuckleBelted]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +- (void)setDriverBuckleBelted:(SDLVehicleDataEventStatus *)driverBuckleBelted { + if (driverBuckleBelted != nil) { + [store setObject:driverBuckleBelted forKey:NAMES_driverBuckleBelted]; + } else { + [store removeObjectForKey:NAMES_driverBuckleBelted]; + } +} + +- (SDLVehicleDataEventStatus *)driverBuckleBelted { + NSObject *obj = [store objectForKey:NAMES_driverBuckleBelted]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +- (void)setLeftRow2BuckleBelted:(SDLVehicleDataEventStatus *)leftRow2BuckleBelted { + if (leftRow2BuckleBelted != nil) { + [store setObject:leftRow2BuckleBelted forKey:NAMES_leftRow2BuckleBelted]; + } else { + [store removeObjectForKey:NAMES_leftRow2BuckleBelted]; + } +} + +- (SDLVehicleDataEventStatus *)leftRow2BuckleBelted { + NSObject *obj = [store objectForKey:NAMES_leftRow2BuckleBelted]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +- (void)setPassengerChildDetected:(SDLVehicleDataEventStatus *)passengerChildDetected { + if (passengerChildDetected != nil) { + [store setObject:passengerChildDetected forKey:NAMES_passengerChildDetected]; + } else { + [store removeObjectForKey:NAMES_passengerChildDetected]; + } +} + +- (SDLVehicleDataEventStatus *)passengerChildDetected { + NSObject *obj = [store objectForKey:NAMES_passengerChildDetected]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +- (void)setRightRow2BuckleBelted:(SDLVehicleDataEventStatus *)rightRow2BuckleBelted { + if (rightRow2BuckleBelted != nil) { + [store setObject:rightRow2BuckleBelted forKey:NAMES_rightRow2BuckleBelted]; + } else { + [store removeObjectForKey:NAMES_rightRow2BuckleBelted]; + } +} + +- (SDLVehicleDataEventStatus *)rightRow2BuckleBelted { + NSObject *obj = [store objectForKey:NAMES_rightRow2BuckleBelted]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +- (void)setMiddleRow2BuckleBelted:(SDLVehicleDataEventStatus *)middleRow2BuckleBelted { + if (middleRow2BuckleBelted != nil) { + [store setObject:middleRow2BuckleBelted forKey:NAMES_middleRow2BuckleBelted]; + } else { + [store removeObjectForKey:NAMES_middleRow2BuckleBelted]; + } +} + +- (SDLVehicleDataEventStatus *)middleRow2BuckleBelted { + NSObject *obj = [store objectForKey:NAMES_middleRow2BuckleBelted]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +- (void)setMiddleRow3BuckleBelted:(SDLVehicleDataEventStatus *)middleRow3BuckleBelted { + if (middleRow3BuckleBelted != nil) { + [store setObject:middleRow3BuckleBelted forKey:NAMES_middleRow3BuckleBelted]; + } else { + [store removeObjectForKey:NAMES_middleRow3BuckleBelted]; + } +} + +- (SDLVehicleDataEventStatus *)middleRow3BuckleBelted { + NSObject *obj = [store objectForKey:NAMES_middleRow3BuckleBelted]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +- (void)setLeftRow3BuckleBelted:(SDLVehicleDataEventStatus *)leftRow3BuckleBelted { + if (leftRow3BuckleBelted != nil) { + [store setObject:leftRow3BuckleBelted forKey:NAMES_leftRow3BuckleBelted]; + } else { + [store removeObjectForKey:NAMES_leftRow3BuckleBelted]; + } +} + +- (SDLVehicleDataEventStatus *)leftRow3BuckleBelted { + NSObject *obj = [store objectForKey:NAMES_leftRow3BuckleBelted]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +- (void)setRightRow3BuckleBelted:(SDLVehicleDataEventStatus *)rightRow3BuckleBelted { + if (rightRow3BuckleBelted != nil) { + [store setObject:rightRow3BuckleBelted forKey:NAMES_rightRow3BuckleBelted]; + } else { + [store removeObjectForKey:NAMES_rightRow3BuckleBelted]; + } +} + +- (SDLVehicleDataEventStatus *)rightRow3BuckleBelted { + NSObject *obj = [store objectForKey:NAMES_rightRow3BuckleBelted]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +- (void)setLeftRearInflatableBelted:(SDLVehicleDataEventStatus *)leftRearInflatableBelted { + if (leftRearInflatableBelted != nil) { + [store setObject:leftRearInflatableBelted forKey:NAMES_leftRearInflatableBelted]; + } else { + [store removeObjectForKey:NAMES_leftRearInflatableBelted]; + } +} + +- (SDLVehicleDataEventStatus *)leftRearInflatableBelted { + NSObject *obj = [store objectForKey:NAMES_leftRearInflatableBelted]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +- (void)setRightRearInflatableBelted:(SDLVehicleDataEventStatus *)rightRearInflatableBelted { + if (rightRearInflatableBelted != nil) { + [store setObject:rightRearInflatableBelted forKey:NAMES_rightRearInflatableBelted]; + } else { + [store removeObjectForKey:NAMES_rightRearInflatableBelted]; + } +} + +- (SDLVehicleDataEventStatus *)rightRearInflatableBelted { + NSObject *obj = [store objectForKey:NAMES_rightRearInflatableBelted]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +- (void)setMiddleRow1BeltDeployed:(SDLVehicleDataEventStatus *)middleRow1BeltDeployed { + if (middleRow1BeltDeployed != nil) { + [store setObject:middleRow1BeltDeployed forKey:NAMES_middleRow1BeltDeployed]; + } else { + [store removeObjectForKey:NAMES_middleRow1BeltDeployed]; + } +} + +- (SDLVehicleDataEventStatus *)middleRow1BeltDeployed { + NSObject *obj = [store objectForKey:NAMES_middleRow1BeltDeployed]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +- (void)setMiddleRow1BuckleBelted:(SDLVehicleDataEventStatus *)middleRow1BuckleBelted { + if (middleRow1BuckleBelted != nil) { + [store setObject:middleRow1BuckleBelted forKey:NAMES_middleRow1BuckleBelted]; + } else { + [store removeObjectForKey:NAMES_middleRow1BuckleBelted]; + } +} + +- (SDLVehicleDataEventStatus *)middleRow1BuckleBelted { + NSObject *obj = [store objectForKey:NAMES_middleRow1BuckleBelted]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLBitsPerSample.h b/SmartDeviceLink/SDLBitsPerSample.h new file mode 100644 index 000000000..9067ce17a --- /dev/null +++ b/SmartDeviceLink/SDLBitsPerSample.h @@ -0,0 +1,45 @@ +// SDLBitsPerSample.h +// + + +#import "SDLEnum.h" + +/** + * Describes different bit depth options for PerformAudioPassThru + * + * @since SDL 2.0 + */ +@interface SDLBitsPerSample : SDLEnum { +} + +/** + * @abstract Convert String to SDLBitsPerSample + * + * @param value The value of the string to get an object for + * + * @return SDLBitsPerSample + */ ++ (SDLBitsPerSample *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLBitsPerSample + * + * @return an array that store all possible SDLBitsPerSample + */ ++ (NSArray *)values; + +/** + * @abstract 8 bits per sample + * + * @return a SDLBitsPerSample with value of *8_BIT* + */ ++ (SDLBitsPerSample *)_8_BIT; + +/** + * @abstract 16 bits per sample + * + * @return a SDLBitsPerSample with value of *16_BIT* + */ ++ (SDLBitsPerSample *)_16_BIT; + +@end diff --git a/SmartDeviceLink/SDLBitsPerSample.m b/SmartDeviceLink/SDLBitsPerSample.m new file mode 100644 index 000000000..e082aff59 --- /dev/null +++ b/SmartDeviceLink/SDLBitsPerSample.m @@ -0,0 +1,47 @@ +// SDLBitsPerSample.m +// + + +#import "SDLBitsPerSample.h" + +SDLBitsPerSample *SDLBitsPerSample_8_BIT = nil; +SDLBitsPerSample *SDLBitsPerSample_16_BIT = nil; + +NSArray *SDLBitsPerSample_values = nil; + +@implementation SDLBitsPerSample + ++ (SDLBitsPerSample *)valueOf:(NSString *)value { + for (SDLBitsPerSample *item in SDLBitsPerSample.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLBitsPerSample_values == nil) { + SDLBitsPerSample_values = @[ + SDLBitsPerSample._8_BIT, + SDLBitsPerSample._16_BIT, + ]; + } + return SDLBitsPerSample_values; +} + ++ (SDLBitsPerSample *)_8_BIT { + if (SDLBitsPerSample_8_BIT == nil) { + SDLBitsPerSample_8_BIT = [[SDLBitsPerSample alloc] initWithValue:@"8_BIT"]; + } + return SDLBitsPerSample_8_BIT; +} + ++ (SDLBitsPerSample *)_16_BIT { + if (SDLBitsPerSample_16_BIT == nil) { + SDLBitsPerSample_16_BIT = [[SDLBitsPerSample alloc] initWithValue:@"16_BIT"]; + } + return SDLBitsPerSample_16_BIT; +} + +@end diff --git a/SmartDeviceLink/SDLBodyInformation.h b/SmartDeviceLink/SDLBodyInformation.h new file mode 100644 index 000000000..1c92243cd --- /dev/null +++ b/SmartDeviceLink/SDLBodyInformation.h @@ -0,0 +1,63 @@ +// SDLBodyInformation.h +// + +#import "SDLRPCMessage.h" + +@class SDLIgnitionStableStatus; +@class SDLIgnitionStatus; + + +/** + * The body information including power modes. + */ +@interface SDLBodyInformation : SDLRPCStruct { +} + +/** + * @abstract Constructs a new SDLBodyInformation object + */ +- (instancetype)init; + +/** + * @abstract Constructs a new SDLBodyInformation object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract References signal "PrkBrkActv_B_Actl". + */ +@property (strong) NSNumber *parkBrakeActive; + +/** + * @abstract References signal "Ignition_Switch_Stable". See IgnitionStableStatus. + */ +@property (strong) SDLIgnitionStableStatus *ignitionStableStatus; + +/** + * @abstract References signal "Ignition_status". See IgnitionStatus. + */ +@property (strong) SDLIgnitionStatus *ignitionStatus; + +/** + * @abstract References signal "DrStatDrv_B_Actl". + */ +@property (strong) NSNumber *driverDoorAjar; + +/** + * @abstract References signal "DrStatPsngr_B_Actl". + */ +@property (strong) NSNumber *passengerDoorAjar; + +/** + * @abstract References signal "DrStatRl_B_Actl". + */ +@property (strong) NSNumber *rearLeftDoorAjar; + +/** + * @abstract References signal "DrStatRr_B_Actl". + */ +@property (strong) NSNumber *rearRightDoorAjar; + +@end diff --git a/SmartDeviceLink/SDLBodyInformation.m b/SmartDeviceLink/SDLBodyInformation.m new file mode 100644 index 000000000..9be7a88d6 --- /dev/null +++ b/SmartDeviceLink/SDLBodyInformation.m @@ -0,0 +1,120 @@ +// SDLBodyInformation.m +// + + +#import "SDLBodyInformation.h" + +#import "SDLIgnitionStableStatus.h" +#import "SDLIgnitionStatus.h" +#import "SDLNames.h" + + +@implementation SDLBodyInformation + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setParkBrakeActive:(NSNumber *)parkBrakeActive { + if (parkBrakeActive != nil) { + [store setObject:parkBrakeActive forKey:NAMES_parkBrakeActive]; + } else { + [store removeObjectForKey:NAMES_parkBrakeActive]; + } +} + +- (NSNumber *)parkBrakeActive { + return [store objectForKey:NAMES_parkBrakeActive]; +} + +- (void)setIgnitionStableStatus:(SDLIgnitionStableStatus *)ignitionStableStatus { + if (ignitionStableStatus != nil) { + [store setObject:ignitionStableStatus forKey:NAMES_ignitionStableStatus]; + } else { + [store removeObjectForKey:NAMES_ignitionStableStatus]; + } +} + +- (SDLIgnitionStableStatus *)ignitionStableStatus { + NSObject *obj = [store objectForKey:NAMES_ignitionStableStatus]; + if (obj == nil || [obj isKindOfClass:SDLIgnitionStableStatus.class]) { + return (SDLIgnitionStableStatus *)obj; + } else { + return [SDLIgnitionStableStatus valueOf:(NSString *)obj]; + } +} + +- (void)setIgnitionStatus:(SDLIgnitionStatus *)ignitionStatus { + if (ignitionStatus != nil) { + [store setObject:ignitionStatus forKey:NAMES_ignitionStatus]; + } else { + [store removeObjectForKey:NAMES_ignitionStatus]; + } +} + +- (SDLIgnitionStatus *)ignitionStatus { + NSObject *obj = [store objectForKey:NAMES_ignitionStatus]; + if (obj == nil || [obj isKindOfClass:SDLIgnitionStatus.class]) { + return (SDLIgnitionStatus *)obj; + } else { + return [SDLIgnitionStatus valueOf:(NSString *)obj]; + } +} + +- (void)setDriverDoorAjar:(NSNumber *)driverDoorAjar { + if (driverDoorAjar != nil) { + [store setObject:driverDoorAjar forKey:NAMES_driverDoorAjar]; + } else { + [store removeObjectForKey:NAMES_driverDoorAjar]; + } +} + +- (NSNumber *)driverDoorAjar { + return [store objectForKey:NAMES_driverDoorAjar]; +} + +- (void)setPassengerDoorAjar:(NSNumber *)passengerDoorAjar { + if (passengerDoorAjar != nil) { + [store setObject:passengerDoorAjar forKey:NAMES_passengerDoorAjar]; + } else { + [store removeObjectForKey:NAMES_passengerDoorAjar]; + } +} + +- (NSNumber *)passengerDoorAjar { + return [store objectForKey:NAMES_passengerDoorAjar]; +} + +- (void)setRearLeftDoorAjar:(NSNumber *)rearLeftDoorAjar { + if (rearLeftDoorAjar != nil) { + [store setObject:rearLeftDoorAjar forKey:NAMES_rearLeftDoorAjar]; + } else { + [store removeObjectForKey:NAMES_rearLeftDoorAjar]; + } +} + +- (NSNumber *)rearLeftDoorAjar { + return [store objectForKey:NAMES_rearLeftDoorAjar]; +} + +- (void)setRearRightDoorAjar:(NSNumber *)rearRightDoorAjar { + if (rearRightDoorAjar != nil) { + [store setObject:rearRightDoorAjar forKey:NAMES_rearRightDoorAjar]; + } else { + [store removeObjectForKey:NAMES_rearRightDoorAjar]; + } +} + +- (NSNumber *)rearRightDoorAjar { + return [store objectForKey:NAMES_rearRightDoorAjar]; +} + +@end diff --git a/SmartDeviceLink/SDLButtonCapabilities.h b/SmartDeviceLink/SDLButtonCapabilities.h new file mode 100644 index 000000000..d84da609a --- /dev/null +++ b/SmartDeviceLink/SDLButtonCapabilities.h @@ -0,0 +1,54 @@ +// SDLButtonCapabilities.h +// + +#import "SDLRPCMessage.h" + +@class SDLButtonName; + + +/** + * Provides information about the capabilities of a SDL HMI button. + * + * @since SDL 1.0 + */ +@interface SDLButtonCapabilities : SDLRPCStruct { +} + +/** + * Constructs a newly allocated SDLButtonCapabilities object + */ +- (instancetype)init; + +/** + * Constructs a newly allocated SDLButtonCapabilities object indicated by the Hashtable parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract The name of the SDL HMI button. + */ +@property (strong) SDLButtonName *name; + +/** + * @abstract A NSNumber value indicates whether the button supports a SHORT press + * + * Required, Boolean + */ +@property (strong) NSNumber *shortPressAvailable; + +/** + * @abstract A NSNumber value indicates whether the button supports a LONG press + * + * Required, Boolean + */ +@property (strong) NSNumber *longPressAvailable; + +/** + * @abstract A NSNumber value indicates whether the button supports "button down" and "button up" + * + * Required, Boolean + */ +@property (strong) NSNumber *upDownAvailable; + +@end diff --git a/SmartDeviceLink/SDLButtonCapabilities.m b/SmartDeviceLink/SDLButtonCapabilities.m new file mode 100644 index 000000000..fbcab54c9 --- /dev/null +++ b/SmartDeviceLink/SDLButtonCapabilities.m @@ -0,0 +1,77 @@ +// SDLButtonCapabilities.m +// + +#import "SDLButtonCapabilities.h" + +#import "SDLButtonName.h" +#import "SDLNames.h" + + +@implementation SDLButtonCapabilities + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setName:(SDLButtonName *)name { + if (name != nil) { + [store setObject:name forKey:NAMES_name]; + } else { + [store removeObjectForKey:NAMES_name]; + } +} + +- (SDLButtonName *)name { + NSObject *obj = [store objectForKey:NAMES_name]; + if (obj == nil || [obj isKindOfClass:SDLButtonName.class]) { + return (SDLButtonName *)obj; + } else { + return [SDLButtonName valueOf:(NSString *)obj]; + } +} + +- (void)setShortPressAvailable:(NSNumber *)shortPressAvailable { + if (shortPressAvailable != nil) { + [store setObject:shortPressAvailable forKey:NAMES_shortPressAvailable]; + } else { + [store removeObjectForKey:NAMES_shortPressAvailable]; + } +} + +- (NSNumber *)shortPressAvailable { + return [store objectForKey:NAMES_shortPressAvailable]; +} + +- (void)setLongPressAvailable:(NSNumber *)longPressAvailable { + if (longPressAvailable != nil) { + [store setObject:longPressAvailable forKey:NAMES_longPressAvailable]; + } else { + [store removeObjectForKey:NAMES_longPressAvailable]; + } +} + +- (NSNumber *)longPressAvailable { + return [store objectForKey:NAMES_longPressAvailable]; +} + +- (void)setUpDownAvailable:(NSNumber *)upDownAvailable { + if (upDownAvailable != nil) { + [store setObject:upDownAvailable forKey:NAMES_upDownAvailable]; + } else { + [store removeObjectForKey:NAMES_upDownAvailable]; + } +} + +- (NSNumber *)upDownAvailable { + return [store objectForKey:NAMES_upDownAvailable]; +} + +@end diff --git a/SmartDeviceLink/SDLButtonEventMode.h b/SmartDeviceLink/SDLButtonEventMode.h new file mode 100644 index 000000000..56cd8683d --- /dev/null +++ b/SmartDeviceLink/SDLButtonEventMode.h @@ -0,0 +1,40 @@ +// SDLButtonEventMode.h +// + + +#import "SDLEnum.h" + +/** + * Indicates whether the button was depressed or released. A BUTTONUP event will always be preceded by a BUTTONDOWN event. + * + * @since SDL 1.0 + */ +@interface SDLButtonEventMode : SDLEnum { +} + +/** + * @abstract Convert String to SDLButtonEventMode + * @param value The value of the string to get an object for + * @return SDLButtonEventMode (BUTTONUP / BUTTONDOWN) + */ ++ (SDLButtonEventMode *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLButtonEventMode + * @return an array that store all possible SDLButtonEventMode + */ ++ (NSArray *)values; + +/** + * @abstract The button was released + * @return a SDLButtonEventMode with value of *BUTTONUP* + */ ++ (SDLButtonEventMode *)BUTTONUP; + +/** + * @abstract The button was depressed + * @return a SDLButtonEventMode with value of *BUTTONDOWN* + */ ++ (SDLButtonEventMode *)BUTTONDOWN; + +@end diff --git a/SmartDeviceLink/SDLButtonEventMode.m b/SmartDeviceLink/SDLButtonEventMode.m new file mode 100644 index 000000000..1dcc13635 --- /dev/null +++ b/SmartDeviceLink/SDLButtonEventMode.m @@ -0,0 +1,47 @@ +// SDLButtonEventMode.m +// + + +#import "SDLButtonEventMode.h" + +SDLButtonEventMode *SDLButtonEventMode_BUTTONUP = nil; +SDLButtonEventMode *SDLButtonEventMode_BUTTONDOWN = nil; + +NSArray *SDLButtonEventMode_values = nil; + +@implementation SDLButtonEventMode + ++ (SDLButtonEventMode *)valueOf:(NSString *)value { + for (SDLButtonEventMode *item in SDLButtonEventMode.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLButtonEventMode_values == nil) { + SDLButtonEventMode_values = @[ + SDLButtonEventMode.BUTTONUP, + SDLButtonEventMode.BUTTONDOWN, + ]; + } + return SDLButtonEventMode_values; +} + ++ (SDLButtonEventMode *)BUTTONUP { + if (SDLButtonEventMode_BUTTONUP == nil) { + SDLButtonEventMode_BUTTONUP = [[SDLButtonEventMode alloc] initWithValue:@"BUTTONUP"]; + } + return SDLButtonEventMode_BUTTONUP; +} + ++ (SDLButtonEventMode *)BUTTONDOWN { + if (SDLButtonEventMode_BUTTONDOWN == nil) { + SDLButtonEventMode_BUTTONDOWN = [[SDLButtonEventMode alloc] initWithValue:@"BUTTONDOWN"]; + } + return SDLButtonEventMode_BUTTONDOWN; +} + +@end diff --git a/SmartDeviceLink/SDLButtonName.h b/SmartDeviceLink/SDLButtonName.h new file mode 100644 index 000000000..519a3c554 --- /dev/null +++ b/SmartDeviceLink/SDLButtonName.h @@ -0,0 +1,152 @@ +// SDLButtonName.h +// + + +#import "SDLEnum.h" + +/** + * Defines logical buttons which, on a given SDL unit, would correspond to + * either physical or soft (touchscreen) buttons. These logical buttons present + * a standard functional abstraction which the developer can rely upon, + * independent of the SDL unit. For example, the developer can rely upon the OK + * button having the same meaning to the user across SDL platforms. + * + * The preset buttons (0-9) can typically be interpreted by the application as + * corresponding to some user-configured choices, though the application is free + * to interpret these button presses as it sees fit. + * + * The application can discover which buttons a given SDL unit implements by + * interrogating the ButtonCapabilities parameter of the + * RegisterAppInterface response. + * + * @since SDL 1.0 + */ +@interface SDLButtonName : SDLEnum { +} + +/** + * @abstract Convert String to SDLButtonName + * + * @param value String value to retrieve the object for + * + * @return SDLButtonName + */ ++ (SDLButtonName *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLButtonName + * + * @return an array that store all possible SDLButtonName + */ ++ (NSArray *)values; + +/** + * @abstract Represents the button usually labeled "OK". A typical use of this button is for the user to press it to make a selection. + * + * @return a SDLButtonName with the value of *OK* + */ ++ (SDLButtonName *)OK; + +/** + * @abstract Represents the seek-left button. A typical use of this button is for the user to scroll to the left through menu choices one menu item per press. + * + * @return a SDLButtonName with the value of *SEEKLEFT* + */ ++ (SDLButtonName *)SEEKLEFT; + +/** + * @abstract Represents the seek-right button. A typical use of this button is for the user to scroll to the right through menu choices one menu item per press. + * + * @return a SDLButtonName with the value of *SEEKRIGHT* + */ ++ (SDLButtonName *)SEEKRIGHT; + +/** + * @abstract Represents a turn of the tuner knob in the clockwise direction one tick. + * + * @return a SDLButtonName with the value of *TUNEUP* + */ ++ (SDLButtonName *)TUNEUP; + +/** + * @abstract Represents a turn of the tuner knob in the counter-clockwise direction one tick. + * + * @return a SDLButtonName with the value of *TUNEDOWN* + */ ++ (SDLButtonName *)TUNEDOWN; + +/** + * @abstract Represents the preset 0 button. + * + * @return a SDLButtonName with the value of *PRESET_0* + */ ++ (SDLButtonName *)PRESET_0; + +/** + * @abstract Represents the preset 1 button. + * + * @return a SDLButtonName with the value of *PRESET_1* + */ ++ (SDLButtonName *)PRESET_1; + +/** + * @abstract Represents the preset 2 button. + * + * @return a SDLButtonName with the value of *PRESET_2* + */ ++ (SDLButtonName *)PRESET_2; + +/** + * @abstract Represents the preset 3 button. + * + * @return a SDLButtonName with the value of *PRESET_3* + */ ++ (SDLButtonName *)PRESET_3; + +/** + * @abstract Represents the preset 4 button. + * + * @return a SDLButtonName with the value of *PRESET_4* + */ ++ (SDLButtonName *)PRESET_4; + +/** + * @abstract Represents the preset 5 button. + * + * @return a SDLButtonName with the value of *PRESET_5* + */ ++ (SDLButtonName *)PRESET_5; + +/** + * @abstract Represents the preset 6 button. + * + * @return a SDLButtonName with the value of *PRESET_6* + */ ++ (SDLButtonName *)PRESET_6; + +/** + * @abstract Represents the preset 7 button. + * + * @return a SDLButtonName with the value of *PRESET_7* + */ ++ (SDLButtonName *)PRESET_7; + +/** + * @abstract Represents the preset 8 button. + * + * @return a SDLButtonName with the value of *PRESET_8* + */ ++ (SDLButtonName *)PRESET_8; + +/** + * @abstract Represents the preset 9 button. + * + * @return a SDLButtonName with the value of *PRESET_9* + */ ++ (SDLButtonName *)PRESET_9; + ++ (SDLButtonName *)CUSTOM_BUTTON; + ++ (SDLButtonName *)SEARCH; + +@end diff --git a/SmartDeviceLink/SDLButtonName.m b/SmartDeviceLink/SDLButtonName.m new file mode 100644 index 000000000..8e0ae3454 --- /dev/null +++ b/SmartDeviceLink/SDLButtonName.m @@ -0,0 +1,182 @@ +// SDLButtonName.m +// + + +#import "SDLButtonName.h" + +SDLButtonName *SDLButtonName_OK = nil; +SDLButtonName *SDLButtonName_SEEKLEFT = nil; +SDLButtonName *SDLButtonName_SEEKRIGHT = nil; +SDLButtonName *SDLButtonName_TUNEUP = nil; +SDLButtonName *SDLButtonName_TUNEDOWN = nil; +SDLButtonName *SDLButtonName_PRESET_0 = nil; +SDLButtonName *SDLButtonName_PRESET_1 = nil; +SDLButtonName *SDLButtonName_PRESET_2 = nil; +SDLButtonName *SDLButtonName_PRESET_3 = nil; +SDLButtonName *SDLButtonName_PRESET_4 = nil; +SDLButtonName *SDLButtonName_PRESET_5 = nil; +SDLButtonName *SDLButtonName_PRESET_6 = nil; +SDLButtonName *SDLButtonName_PRESET_7 = nil; +SDLButtonName *SDLButtonName_PRESET_8 = nil; +SDLButtonName *SDLButtonName_PRESET_9 = nil; +SDLButtonName *SDLButtonName_CUSTOM_BUTTON = nil; +SDLButtonName *SDLButtonName_SEARCH = nil; + +NSArray *SDLButtonName_values = nil; + +@implementation SDLButtonName + ++ (SDLButtonName *)valueOf:(NSString *)value { + for (SDLButtonName *item in SDLButtonName.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLButtonName_values == nil) { + SDLButtonName_values = @[ + SDLButtonName.OK, + SDLButtonName.SEEKLEFT, + SDLButtonName.SEEKRIGHT, + SDLButtonName.TUNEUP, + SDLButtonName.TUNEDOWN, + SDLButtonName.PRESET_0, + SDLButtonName.PRESET_1, + SDLButtonName.PRESET_2, + SDLButtonName.PRESET_3, + SDLButtonName.PRESET_4, + SDLButtonName.PRESET_5, + SDLButtonName.PRESET_6, + SDLButtonName.PRESET_7, + SDLButtonName.PRESET_8, + SDLButtonName.PRESET_9, + SDLButtonName.CUSTOM_BUTTON, + SDLButtonName.SEARCH, + ]; + } + return SDLButtonName_values; +} + ++ (SDLButtonName *)OK { + if (SDLButtonName_OK == nil) { + SDLButtonName_OK = [[SDLButtonName alloc] initWithValue:@"OK"]; + } + return SDLButtonName_OK; +} + ++ (SDLButtonName *)SEEKLEFT { + if (SDLButtonName_SEEKLEFT == nil) { + SDLButtonName_SEEKLEFT = [[SDLButtonName alloc] initWithValue:@"SEEKLEFT"]; + } + return SDLButtonName_SEEKLEFT; +} + ++ (SDLButtonName *)SEEKRIGHT { + if (SDLButtonName_SEEKRIGHT == nil) { + SDLButtonName_SEEKRIGHT = [[SDLButtonName alloc] initWithValue:@"SEEKRIGHT"]; + } + return SDLButtonName_SEEKRIGHT; +} + ++ (SDLButtonName *)TUNEUP { + if (SDLButtonName_TUNEUP == nil) { + SDLButtonName_TUNEUP = [[SDLButtonName alloc] initWithValue:@"TUNEUP"]; + } + return SDLButtonName_TUNEUP; +} + ++ (SDLButtonName *)TUNEDOWN { + if (SDLButtonName_TUNEDOWN == nil) { + SDLButtonName_TUNEDOWN = [[SDLButtonName alloc] initWithValue:@"TUNEDOWN"]; + } + return SDLButtonName_TUNEDOWN; +} + ++ (SDLButtonName *)PRESET_0 { + if (SDLButtonName_PRESET_0 == nil) { + SDLButtonName_PRESET_0 = [[SDLButtonName alloc] initWithValue:@"PRESET_0"]; + } + return SDLButtonName_PRESET_0; +} + ++ (SDLButtonName *)PRESET_1 { + if (SDLButtonName_PRESET_1 == nil) { + SDLButtonName_PRESET_1 = [[SDLButtonName alloc] initWithValue:@"PRESET_1"]; + } + return SDLButtonName_PRESET_1; +} + ++ (SDLButtonName *)PRESET_2 { + if (SDLButtonName_PRESET_2 == nil) { + SDLButtonName_PRESET_2 = [[SDLButtonName alloc] initWithValue:@"PRESET_2"]; + } + return SDLButtonName_PRESET_2; +} + ++ (SDLButtonName *)PRESET_3 { + if (SDLButtonName_PRESET_3 == nil) { + SDLButtonName_PRESET_3 = [[SDLButtonName alloc] initWithValue:@"PRESET_3"]; + } + return SDLButtonName_PRESET_3; +} + ++ (SDLButtonName *)PRESET_4 { + if (SDLButtonName_PRESET_4 == nil) { + SDLButtonName_PRESET_4 = [[SDLButtonName alloc] initWithValue:@"PRESET_4"]; + } + return SDLButtonName_PRESET_4; +} + ++ (SDLButtonName *)PRESET_5 { + if (SDLButtonName_PRESET_5 == nil) { + SDLButtonName_PRESET_5 = [[SDLButtonName alloc] initWithValue:@"PRESET_5"]; + } + return SDLButtonName_PRESET_5; +} + ++ (SDLButtonName *)PRESET_6 { + if (SDLButtonName_PRESET_6 == nil) { + SDLButtonName_PRESET_6 = [[SDLButtonName alloc] initWithValue:@"PRESET_6"]; + } + return SDLButtonName_PRESET_6; +} + ++ (SDLButtonName *)PRESET_7 { + if (SDLButtonName_PRESET_7 == nil) { + SDLButtonName_PRESET_7 = [[SDLButtonName alloc] initWithValue:@"PRESET_7"]; + } + return SDLButtonName_PRESET_7; +} + ++ (SDLButtonName *)PRESET_8 { + if (SDLButtonName_PRESET_8 == nil) { + SDLButtonName_PRESET_8 = [[SDLButtonName alloc] initWithValue:@"PRESET_8"]; + } + return SDLButtonName_PRESET_8; +} + ++ (SDLButtonName *)PRESET_9 { + if (SDLButtonName_PRESET_9 == nil) { + SDLButtonName_PRESET_9 = [[SDLButtonName alloc] initWithValue:@"PRESET_9"]; + } + return SDLButtonName_PRESET_9; +} + ++ (SDLButtonName *)CUSTOM_BUTTON { + if (SDLButtonName_CUSTOM_BUTTON == nil) { + SDLButtonName_CUSTOM_BUTTON = [[SDLButtonName alloc] initWithValue:@"CUSTOM_BUTTON"]; + } + return SDLButtonName_CUSTOM_BUTTON; +} + ++ (SDLButtonName *)SEARCH { + if (SDLButtonName_SEARCH == nil) { + SDLButtonName_SEARCH = [[SDLButtonName alloc] initWithValue:@"SEARCH"]; + } + return SDLButtonName_SEARCH; +} + +@end diff --git a/SmartDeviceLink/SDLButtonPressMode.h b/SmartDeviceLink/SDLButtonPressMode.h new file mode 100644 index 000000000..8aca9c143 --- /dev/null +++ b/SmartDeviceLink/SDLButtonPressMode.h @@ -0,0 +1,45 @@ +// SDLButtonPressMode.h +// + + +#import "SDLEnum.h" + +/** + * Indicates whether this is a LONG or SHORT button press + * + * @since SDL 1.0 + */ +@interface SDLButtonPressMode : SDLEnum { +} + +/** + * @abstract Convert String to SDLButtonPressMode + * + * @param value The value of the string to get an object for + * + * @return SDLButtonPressMode + */ ++ (SDLButtonPressMode *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLButtonPressMode + * + * @return an array that store all possible SDLButtonPressMode + */ ++ (NSArray *)values; + +/** + * @abstract A button was released, after it was pressed for a long time. Actual timing is defined by the head unit and may vary. + * + * @return a SDLButtonPressMode with the value of *LONG* + */ ++ (SDLButtonPressMode *)LONG; + +/** + * @abstract A button was released, after it was pressed for a short time. Actual timing is defined by the head unit and may vary. + * + * @return a SDLButtonPressMode with the value of *SHORT* + */ ++ (SDLButtonPressMode *)SHORT; + +@end diff --git a/SmartDeviceLink/SDLButtonPressMode.m b/SmartDeviceLink/SDLButtonPressMode.m new file mode 100644 index 000000000..15e4c2334 --- /dev/null +++ b/SmartDeviceLink/SDLButtonPressMode.m @@ -0,0 +1,47 @@ +// SDLButtonPressMode.m +// + + +#import "SDLButtonPressMode.h" + +SDLButtonPressMode *SDLButtonPressMode_LONG = nil; +SDLButtonPressMode *SDLButtonPressMode_SHORT = nil; + +NSArray *SDLButtonPressMode_values = nil; + +@implementation SDLButtonPressMode + ++ (SDLButtonPressMode *)valueOf:(NSString *)value { + for (SDLButtonPressMode *item in SDLButtonPressMode.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLButtonPressMode_values == nil) { + SDLButtonPressMode_values = @[ + SDLButtonPressMode.LONG, + SDLButtonPressMode.SHORT, + ]; + } + return SDLButtonPressMode_values; +} + ++ (SDLButtonPressMode *)LONG { + if (SDLButtonPressMode_LONG == nil) { + SDLButtonPressMode_LONG = [[SDLButtonPressMode alloc] initWithValue:@"LONG"]; + } + return SDLButtonPressMode_LONG; +} + ++ (SDLButtonPressMode *)SHORT { + if (SDLButtonPressMode_SHORT == nil) { + SDLButtonPressMode_SHORT = [[SDLButtonPressMode alloc] initWithValue:@"SHORT"]; + } + return SDLButtonPressMode_SHORT; +} + +@end diff --git a/SmartDeviceLink/SDLCarModeStatus.h b/SmartDeviceLink/SDLCarModeStatus.h new file mode 100644 index 000000000..15bb7b284 --- /dev/null +++ b/SmartDeviceLink/SDLCarModeStatus.h @@ -0,0 +1,32 @@ +// SDLCarModeStatus.h +// + + +#import "SDLEnum.h" + +/** Describes the carmode the vehicle is in. + * <b>Since</b> SmartDeviceLink 2.0 + */ +@interface SDLCarModeStatus : SDLEnum { +} + ++ (SDLCarModeStatus *)valueOf:(NSString *)value; + ++ (NSArray *)values; +/** Provides carmode NORMAL to each module. + */ ++ (SDLCarModeStatus *)NORMAL; + +/** Provides carmode FACTORY to each module. + */ ++ (SDLCarModeStatus *)FACTORY; + +/** Provides carmode TRANSPORT to each module. + */ ++ (SDLCarModeStatus *)TRANSPORT; + +/** Provides carmode CRASH to each module. + */ ++ (SDLCarModeStatus *)CRASH; + +@end diff --git a/SmartDeviceLink/SDLCarModeStatus.m b/SmartDeviceLink/SDLCarModeStatus.m new file mode 100644 index 000000000..4f9c03c42 --- /dev/null +++ b/SmartDeviceLink/SDLCarModeStatus.m @@ -0,0 +1,65 @@ +// SDLCarModeStatus.m +// + + +#import "SDLCarModeStatus.h" + +SDLCarModeStatus *SDLCarModeStatus_NORMAL = nil; +SDLCarModeStatus *SDLCarModeStatus_FACTORY = nil; +SDLCarModeStatus *SDLCarModeStatus_TRANSPORT = nil; +SDLCarModeStatus *SDLCarModeStatus_CRASH = nil; + +NSArray *SDLCarModeStatus_values = nil; + +@implementation SDLCarModeStatus + ++ (SDLCarModeStatus *)valueOf:(NSString *)value { + for (SDLCarModeStatus *item in SDLCarModeStatus.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLCarModeStatus_values == nil) { + SDLCarModeStatus_values = @[ + SDLCarModeStatus.NORMAL, + SDLCarModeStatus.FACTORY, + SDLCarModeStatus.TRANSPORT, + SDLCarModeStatus.CRASH, + ]; + } + return SDLCarModeStatus_values; +} + ++ (SDLCarModeStatus *)NORMAL { + if (SDLCarModeStatus_NORMAL == nil) { + SDLCarModeStatus_NORMAL = [[SDLCarModeStatus alloc] initWithValue:@"NORMAL"]; + } + return SDLCarModeStatus_NORMAL; +} + ++ (SDLCarModeStatus *)FACTORY { + if (SDLCarModeStatus_FACTORY == nil) { + SDLCarModeStatus_FACTORY = [[SDLCarModeStatus alloc] initWithValue:@"FACTORY"]; + } + return SDLCarModeStatus_FACTORY; +} + ++ (SDLCarModeStatus *)TRANSPORT { + if (SDLCarModeStatus_TRANSPORT == nil) { + SDLCarModeStatus_TRANSPORT = [[SDLCarModeStatus alloc] initWithValue:@"TRANSPORT"]; + } + return SDLCarModeStatus_TRANSPORT; +} + ++ (SDLCarModeStatus *)CRASH { + if (SDLCarModeStatus_CRASH == nil) { + SDLCarModeStatus_CRASH = [[SDLCarModeStatus alloc] initWithValue:@"CRASH"]; + } + return SDLCarModeStatus_CRASH; +} + +@end diff --git a/SmartDeviceLink/SDLChangeRegistration.h b/SmartDeviceLink/SDLChangeRegistration.h new file mode 100644 index 000000000..4bbc7c234 --- /dev/null +++ b/SmartDeviceLink/SDLChangeRegistration.h @@ -0,0 +1,70 @@ +// SDLChangeRegistration.h +// + + +#import "SDLRPCRequest.h" + +@class SDLLanguage; +@class SDLTTSChunk; + +/** + * If the app recognizes during the app registration that the SDL HMI language (voice/TTS and/or display) does not match the app language, the app will be able (but does not need) to change this registration with changeRegistration prior to app being brought into focus. + * + * Any HMILevel allowed + * + * @since SDL 2.0 + */ +@interface SDLChangeRegistration : SDLRPCRequest { +} + +/** + * Constructs a new SDLChangeRegistration object + */ +- (instancetype)init; + +/** + * Constructs a new SDLChangeRegistration object indicated by the dictionary parameter + * + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract The language the app wants to change to + */ +@property (strong, nonatomic) SDLLanguage *language; + +/** + * @abstract HMI display language + */ +@property (strong, nonatomic) SDLLanguage *hmiDisplayLanguage; + +/** + * Request a new app name registration + * + * Optional, Max string length 100 chars + */ +@property (copy, nonatomic) NSString *appName; + +/** + * Request a new TTSName registration. + * + * Optional, Array of SDLTTSChunk, 1 - 100 elements + */ +@property (copy, nonatomic) NSArray *ttsName; + +/** + * Request a new app short name registration + * + * Optional, Max string length 100 chars + */ +@property (copy, nonatomic) NSString *ngnMediaScreenAppName; + +/** + * Request a new VR synonyms registration + * + * Optional, Array of NSString, 1 - 100 elements, max string length 40 chars + */ +@property (copy, nonatomic) NSArray *vrSynonyms; + +@end diff --git a/SmartDeviceLink/SDLChangeRegistration.m b/SmartDeviceLink/SDLChangeRegistration.m new file mode 100644 index 000000000..00a7de885 --- /dev/null +++ b/SmartDeviceLink/SDLChangeRegistration.m @@ -0,0 +1,106 @@ +// SDLChangeRegistration.m +// + + +#import "SDLChangeRegistration.h" + +#import "SDLLanguage.h" +#import "SDLNames.h" + +@implementation SDLChangeRegistration + +- (instancetype)init { + if (self = [super initWithName:NAMES_ChangeRegistration]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setLanguage:(SDLLanguage *)language { + if (language != nil) { + [parameters setObject:language forKey:NAMES_language]; + } else { + [parameters removeObjectForKey:NAMES_language]; + } +} + +- (SDLLanguage *)language { + NSObject *obj = [parameters objectForKey:NAMES_language]; + if (obj == nil || [obj isKindOfClass:SDLLanguage.class]) { + return (SDLLanguage *)obj; + } else { + return [SDLLanguage valueOf:(NSString *)obj]; + } +} + +- (void)setHmiDisplayLanguage:(SDLLanguage *)hmiDisplayLanguage { + if (hmiDisplayLanguage != nil) { + [parameters setObject:hmiDisplayLanguage forKey:NAMES_hmiDisplayLanguage]; + } else { + [parameters removeObjectForKey:NAMES_hmiDisplayLanguage]; + } +} + +- (SDLLanguage *)hmiDisplayLanguage { + NSObject *obj = [parameters objectForKey:NAMES_hmiDisplayLanguage]; + if (obj == nil || [obj isKindOfClass:SDLLanguage.class]) { + return (SDLLanguage *)obj; + } else { + return [SDLLanguage valueOf:(NSString *)obj]; + } +} + +- (void)setAppName:(NSString *)appName { + if (appName != nil) { + parameters[NAMES_appName] = [appName copy]; + } else { + [parameters removeObjectForKey:NAMES_appName]; + } +} + +- (NSString *)appName { + return [parameters[NAMES_appName] copy]; +} + +- (void)setTtsName:(NSArray *)ttsName { + if (ttsName != nil) { + [parameters setObject:[ttsName copy] forKey:NAMES_ttsName]; + } else { + [parameters removeObjectForKey:NAMES_ttsName]; + } +} + +- (NSArray *)ttsName { + return [parameters[NAMES_ttsName] copy]; +} + +- (void)setNgnMediaScreenAppName:(NSString *)ngnMediaScreenAppName { + if (ngnMediaScreenAppName != nil) { + parameters[NAMES_ngnMediaScreenAppName] = [ngnMediaScreenAppName copy]; + } else { + [parameters removeObjectForKey:NAMES_ngnMediaScreenAppName]; + } +} + +- (NSString *)ngnMediaScreenAppName { + return [parameters[NAMES_ngnMediaScreenAppName] copy]; +} + +- (void)setVrSynonyms:(NSArray *)vrSynonyms { + if (vrSynonyms != nil) { + [parameters setObject:[vrSynonyms copy] forKey:NAMES_vrSynonyms]; + } else { + [parameters removeObjectForKey:NAMES_vrSynonyms]; + } +} + +- (NSArray *)vrSynonyms { + return [parameters[NAMES_vrSynonyms] copy]; +} + +@end diff --git a/SmartDeviceLink/SDLChangeRegistrationResponse.h b/SmartDeviceLink/SDLChangeRegistrationResponse.h new file mode 100644 index 000000000..38709e235 --- /dev/null +++ b/SmartDeviceLink/SDLChangeRegistrationResponse.h @@ -0,0 +1,18 @@ +// SDLChangeRegistrationResponse.h +// + + +#import "SDLRPCResponse.h" + +/** + * SDLChangeRegistrationResponse is sent, when SDLChangeRegistration has been called + * + * @since SDL 2.0 + */ +@interface SDLChangeRegistrationResponse : SDLRPCResponse { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLChangeRegistrationResponse.m b/SmartDeviceLink/SDLChangeRegistrationResponse.m new file mode 100644 index 000000000..710495d2c --- /dev/null +++ b/SmartDeviceLink/SDLChangeRegistrationResponse.m @@ -0,0 +1,23 @@ +// SDLChangeRegistrationResponse.m +// + + +#import "SDLChangeRegistrationResponse.h" + +#import "SDLNames.h" + +@implementation SDLChangeRegistrationResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_ChangeRegistration]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLCharacterSet.h b/SmartDeviceLink/SDLCharacterSet.h new file mode 100644 index 000000000..300afd720 --- /dev/null +++ b/SmartDeviceLink/SDLCharacterSet.h @@ -0,0 +1,39 @@ +// SDLCharacterSet.h +// + + +#import "SDLEnum.h" + +/** + * Character sets supported by SDL. + * + * @since SDL 1.0 + */ +@interface SDLCharacterSet : SDLEnum { +} + +/** + * @abstract Convert String to SDLCharacterSet + * + * @param value The value of the string to get an object for + * + * @return SDLCharacterSet + */ ++ (SDLCharacterSet *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLCharacterSet + * + * @return an array that store all possible SDLCharacterSet + */ ++ (NSArray *)values; + ++ (SDLCharacterSet *)TYPE2SET; + ++ (SDLCharacterSet *)TYPE5SET; + ++ (SDLCharacterSet *)CID1SET; + ++ (SDLCharacterSet *)CID2SET; + +@end diff --git a/SmartDeviceLink/SDLCharacterSet.m b/SmartDeviceLink/SDLCharacterSet.m new file mode 100644 index 000000000..18f00de90 --- /dev/null +++ b/SmartDeviceLink/SDLCharacterSet.m @@ -0,0 +1,65 @@ +// SDLCharacterSet.m +// + + +#import "SDLCharacterSet.h" + +SDLCharacterSet *SDLCharacterSet_TYPE2SET = nil; +SDLCharacterSet *SDLCharacterSet_TYPE5SET = nil; +SDLCharacterSet *SDLCharacterSet_CID1SET = nil; +SDLCharacterSet *SDLCharacterSet_CID2SET = nil; + +NSArray *SDLCharacterSet_values = nil; + +@implementation SDLCharacterSet + ++ (SDLCharacterSet *)valueOf:(NSString *)value { + for (SDLCharacterSet *item in SDLCharacterSet.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLCharacterSet_values == nil) { + SDLCharacterSet_values = @[ + SDLCharacterSet.TYPE2SET, + SDLCharacterSet.TYPE5SET, + SDLCharacterSet.CID1SET, + SDLCharacterSet.CID2SET, + ]; + } + return SDLCharacterSet_values; +} + ++ (SDLCharacterSet *)TYPE2SET { + if (SDLCharacterSet_TYPE2SET == nil) { + SDLCharacterSet_TYPE2SET = [[SDLCharacterSet alloc] initWithValue:@"TYPE2SET"]; + } + return SDLCharacterSet_TYPE2SET; +} + ++ (SDLCharacterSet *)TYPE5SET { + if (SDLCharacterSet_TYPE5SET == nil) { + SDLCharacterSet_TYPE5SET = [[SDLCharacterSet alloc] initWithValue:@"TYPE5SET"]; + } + return SDLCharacterSet_TYPE5SET; +} + ++ (SDLCharacterSet *)CID1SET { + if (SDLCharacterSet_CID1SET == nil) { + SDLCharacterSet_CID1SET = [[SDLCharacterSet alloc] initWithValue:@"CID1SET"]; + } + return SDLCharacterSet_CID1SET; +} + ++ (SDLCharacterSet *)CID2SET { + if (SDLCharacterSet_CID2SET == nil) { + SDLCharacterSet_CID2SET = [[SDLCharacterSet alloc] initWithValue:@"CID2SET"]; + } + return SDLCharacterSet_CID2SET; +} + +@end diff --git a/SmartDeviceLink/SDLChoice.h b/SmartDeviceLink/SDLChoice.h new file mode 100644 index 000000000..478b33b5f --- /dev/null +++ b/SmartDeviceLink/SDLChoice.h @@ -0,0 +1,116 @@ +// SDLChoice.h +// + +#import "SDLRPCMessage.h" + +@class SDLImage; + + +/** + * A choice is an option which a user can select either via the menu or via voice recognition (VR) during an application initiated interaction. + * <p><b> Parameter List</b> + * <table border="1" rules="all"> + * <tr> + * <th>Name</th> + * <th>Type</th> + * <th>Description</th> + * <th>SmartDeviceLink Ver. Available</th> + * </tr> + * <tr> + * <td>choiceID</td> + * <td>NSNumber * </td> + * <td>Application-scoped identifier that uniquely identifies this choice. + * <br/>Min: 0 + * <br/>Max: 65535 + * </td> + * <td>SmartDeviceLink 1.0</td> + * </tr> + * <tr> + * <td>menuName</td> + * <td>NSString * </td> + * <td>Text which appears in menu, representing this choice. + * <br/>Min: 1 + * <br/>Max: 100 + * </td> + * <td>SmartDeviceLink 1.0</td> + * </tr> + * <tr> + * <td>vrCommands</td> + * <td>NSMutableArray *</td> + * <td>An array of strings to be used as VR synonyms for this choice. If this array is provided, it must have at least one non-empty element</td> + * <td>SmartDeviceLink 1.0</td> + * </tr> + * <tr> + * <td>image</td> + * <td>SDLImage * </td> + * <td>Either a static hex icon value or a binary image file name identifier (sent by PutFile).</td> + * <td>SmartDeviceLink 2.0</td> + * </tr> + * </table> + * + * Since <b>SmartDeviceLink 1.0</b><br> + */ +@interface SDLChoice : SDLRPCStruct { +} + +/** + * Constructs a newly allocated SDLChoice object + */ +- (instancetype)init; + +/** + * Constructs a newly allocated SDLChoice object indicated by the dictionary parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract the application-scoped identifier that uniquely identifies this choice + * + * Required, Integer 0 - 65535 + */ +@property (strong) NSNumber *choiceID; + +/** + * @abstract Text which appears in menu, representing this choice + * + * Required, Max string length 500 chars + */ +@property (strong) NSString *menuName; + +/** + * @abstract VR synonyms for this choice + * + * Required, Array of Strings, Array length 1 - 100, Max String length 99 chars + */ +@property (strong) NSMutableArray *vrCommands; + +/** + * @abstract The image of the choice + * + * Optional + */ +@property (strong) SDLImage *image; + +/** + * @abstract Optional secondary text to display; e.g. address of POI in a search result entry + * + * Optional, Max String length 500 chars + */ +@property (strong) NSString *secondaryText; + +/** + * @abstract Optional tertiary text to display; e.g. distance to POI for a search result entry + * + * Optional, Max String length 500 chars + */ +@property (strong) NSString *tertiaryText; + +/** + * @abstract Optional secondary image for choice + * + * Optional + */ +@property (strong) SDLImage *secondaryImage; + +@end diff --git a/SmartDeviceLink/SDLChoice.m b/SmartDeviceLink/SDLChoice.m new file mode 100644 index 000000000..83e1d56ae --- /dev/null +++ b/SmartDeviceLink/SDLChoice.m @@ -0,0 +1,118 @@ +// SDLChoice.m +// + +#import "SDLChoice.h" + +#import "SDLImage.h" +#import "SDLNames.h" + + +@implementation SDLChoice + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setChoiceID:(NSNumber *)choiceID { + if (choiceID != nil) { + [store setObject:choiceID forKey:NAMES_choiceID]; + } else { + [store removeObjectForKey:NAMES_choiceID]; + } +} + +- (NSNumber *)choiceID { + return [store objectForKey:NAMES_choiceID]; +} + +- (void)setMenuName:(NSString *)menuName { + if (menuName != nil) { + [store setObject:menuName forKey:NAMES_menuName]; + } else { + [store removeObjectForKey:NAMES_menuName]; + } +} + +- (NSString *)menuName { + return [store objectForKey:NAMES_menuName]; +} + +- (void)setVrCommands:(NSMutableArray *)vrCommands { + if (vrCommands != nil) { + [store setObject:vrCommands forKey:NAMES_vrCommands]; + } else { + [store removeObjectForKey:NAMES_vrCommands]; + } +} + +- (NSMutableArray *)vrCommands { + return [store objectForKey:NAMES_vrCommands]; +} + +- (void)setImage:(SDLImage *)image { + if (image != nil) { + [store setObject:image forKey:NAMES_image]; + } else { + [store removeObjectForKey:NAMES_image]; + } +} + +- (SDLImage *)image { + NSObject *obj = [store objectForKey:NAMES_image]; + if (obj == nil || [obj isKindOfClass:SDLImage.class]) { + return (SDLImage *)obj; + } else { + return [[SDLImage alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setSecondaryText:(NSString *)secondaryText { + if (secondaryText != nil) { + [store setObject:secondaryText forKey:NAMES_secondaryText]; + } else { + [store removeObjectForKey:NAMES_secondaryText]; + } +} + +- (NSString *)secondaryText { + return [store objectForKey:NAMES_secondaryText]; +} + +- (void)setTertiaryText:(NSString *)tertiaryText { + if (tertiaryText != nil) { + [store setObject:tertiaryText forKey:NAMES_tertiaryText]; + } else { + [store removeObjectForKey:NAMES_tertiaryText]; + } +} + +- (NSString *)tertiaryText { + return [store objectForKey:NAMES_tertiaryText]; +} + +- (void)setSecondaryImage:(SDLImage *)secondaryImage { + if (secondaryImage != nil) { + [store setObject:secondaryImage forKey:NAMES_secondaryImage]; + } else { + [store removeObjectForKey:NAMES_secondaryImage]; + } +} + +- (SDLImage *)secondaryImage { + NSObject *obj = [store objectForKey:NAMES_secondaryImage]; + if (obj == nil || [obj isKindOfClass:SDLImage.class]) { + return (SDLImage *)obj; + } else { + return [[SDLImage alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLClusterModeStatus.h b/SmartDeviceLink/SDLClusterModeStatus.h new file mode 100644 index 000000000..7b745804f --- /dev/null +++ b/SmartDeviceLink/SDLClusterModeStatus.h @@ -0,0 +1,22 @@ +// SDLClusterModeStatus.h +// + +#import "SDLRPCMessage.h" + +@class SDLCarModeStatus; +@class SDLPowerModeQualificationStatus; +@class SDLPowerModeStatus; + + +@interface SDLClusterModeStatus : SDLRPCStruct { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) NSNumber *powerModeActive; +@property (strong) SDLPowerModeQualificationStatus *powerModeQualificationStatus; +@property (strong) SDLCarModeStatus *carModeStatus; +@property (strong) SDLPowerModeStatus *powerModeStatus; + +@end diff --git a/SmartDeviceLink/SDLClusterModeStatus.m b/SmartDeviceLink/SDLClusterModeStatus.m new file mode 100644 index 000000000..ecd2a528b --- /dev/null +++ b/SmartDeviceLink/SDLClusterModeStatus.m @@ -0,0 +1,89 @@ +// SDLClusterModeStatus.m +// + +#import "SDLClusterModeStatus.h" + +#import "SDLCarModeStatus.h" +#import "SDLNames.h" +#import "SDLPowerModeQualificationStatus.h" +#import "SDLPowerModeStatus.h" + + +@implementation SDLClusterModeStatus + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setPowerModeActive:(NSNumber *)powerModeActive { + if (powerModeActive != nil) { + [store setObject:powerModeActive forKey:NAMES_powerModeActive]; + } else { + [store removeObjectForKey:NAMES_powerModeActive]; + } +} + +- (NSNumber *)powerModeActive { + return [store objectForKey:NAMES_powerModeActive]; +} + +- (void)setPowerModeQualificationStatus:(SDLPowerModeQualificationStatus *)powerModeQualificationStatus { + if (powerModeQualificationStatus != nil) { + [store setObject:powerModeQualificationStatus forKey:NAMES_powerModeQualificationStatus]; + } else { + [store removeObjectForKey:NAMES_powerModeQualificationStatus]; + } +} + +- (SDLPowerModeQualificationStatus *)powerModeQualificationStatus { + NSObject *obj = [store objectForKey:NAMES_powerModeQualificationStatus]; + if (obj == nil || [obj isKindOfClass:SDLPowerModeQualificationStatus.class]) { + return (SDLPowerModeQualificationStatus *)obj; + } else { + return [SDLPowerModeQualificationStatus valueOf:(NSString *)obj]; + } +} + +- (void)setCarModeStatus:(SDLCarModeStatus *)carModeStatus { + if (carModeStatus != nil) { + [store setObject:carModeStatus forKey:NAMES_carModeStatus]; + } else { + [store removeObjectForKey:NAMES_carModeStatus]; + } +} + +- (SDLCarModeStatus *)carModeStatus { + NSObject *obj = [store objectForKey:NAMES_carModeStatus]; + if (obj == nil || [obj isKindOfClass:SDLCarModeStatus.class]) { + return (SDLCarModeStatus *)obj; + } else { + return [SDLCarModeStatus valueOf:(NSString *)obj]; + } +} + +- (void)setPowerModeStatus:(SDLPowerModeStatus *)powerModeStatus { + if (powerModeStatus != nil) { + [store setObject:powerModeStatus forKey:NAMES_powerModeStatus]; + } else { + [store removeObjectForKey:NAMES_powerModeStatus]; + } +} + +- (SDLPowerModeStatus *)powerModeStatus { + NSObject *obj = [store objectForKey:NAMES_powerModeStatus]; + if (obj == nil || [obj isKindOfClass:SDLPowerModeStatus.class]) { + return (SDLPowerModeStatus *)obj; + } else { + return [SDLPowerModeStatus valueOf:(NSString *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLCompassDirection.h b/SmartDeviceLink/SDLCompassDirection.h new file mode 100644 index 000000000..cad90cc90 --- /dev/null +++ b/SmartDeviceLink/SDLCompassDirection.h @@ -0,0 +1,76 @@ +// SDLCompassDirection.h +// + + +#import "SDLEnum.h" + +/** + * The list of potential compass directions. + * + * @since SDL 2.0 + */ +@interface SDLCompassDirection : SDLEnum { +} + +/** + * @abstract Convert String to SDLCompassDirection + * @param value The value of the string to get an object for + * @return SDLCompassDirection + */ ++ (SDLCompassDirection *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLCompassDirection + * @return An array that store all possible SDLCompassDirection + */ ++ (NSArray *)values; + +/** + * @abstract Direction North + * @return A SDLCompassDirection with the value of *NORTH* + */ ++ (SDLCompassDirection *)NORTH; + +/** + * @abstract Direction Northwest + * @return A SDLCompassDirection with the value of *NORTHWEST* + */ ++ (SDLCompassDirection *)NORTHWEST; + +/** + * @abstract Direction West + * @return A SDLCompassDirection with the value of *WEST* + */ ++ (SDLCompassDirection *)WEST; + +/** + * @abstract Direction Southwest + * @return A SDLCompassDirection with the value of *SOUTHWEST* + */ ++ (SDLCompassDirection *)SOUTHWEST; + +/** + * @abstract Direction South + * @return A SDLCompassDirection with the value of *SOUTH* + */ ++ (SDLCompassDirection *)SOUTH; + +/** + * @abstract Direction Southeast + * @return A SDLCompassDirection with the value of *SOUTHEAST* + */ ++ (SDLCompassDirection *)SOUTHEAST; + +/** + * @abstract Direction East + * @return A SDLCompassDirection with the value of *EAST* + */ ++ (SDLCompassDirection *)EAST; + +/** + * @abstract Direction Northeast + * @return A SDLCompassDirection with the value of *NORTHEAST* + */ ++ (SDLCompassDirection *)NORTHEAST; + +@end diff --git a/SmartDeviceLink/SDLCompassDirection.m b/SmartDeviceLink/SDLCompassDirection.m new file mode 100644 index 000000000..f1c79fed1 --- /dev/null +++ b/SmartDeviceLink/SDLCompassDirection.m @@ -0,0 +1,101 @@ +// SDLCompassDirection.m +// + + +#import "SDLCompassDirection.h" + +SDLCompassDirection *SDLCompassDirection_NORTH = nil; +SDLCompassDirection *SDLCompassDirection_NORTHWEST = nil; +SDLCompassDirection *SDLCompassDirection_WEST = nil; +SDLCompassDirection *SDLCompassDirection_SOUTHWEST = nil; +SDLCompassDirection *SDLCompassDirection_SOUTH = nil; +SDLCompassDirection *SDLCompassDirection_SOUTHEAST = nil; +SDLCompassDirection *SDLCompassDirection_EAST = nil; +SDLCompassDirection *SDLCompassDirection_NORTHEAST = nil; + +NSArray *SDLCompassDirection_values = nil; + +@implementation SDLCompassDirection + ++ (SDLCompassDirection *)valueOf:(NSString *)value { + for (SDLCompassDirection *item in SDLCompassDirection.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLCompassDirection_values == nil) { + SDLCompassDirection_values = @[ + SDLCompassDirection.NORTH, + SDLCompassDirection.NORTHWEST, + SDLCompassDirection.WEST, + SDLCompassDirection.SOUTHWEST, + SDLCompassDirection.SOUTH, + SDLCompassDirection.SOUTHEAST, + SDLCompassDirection.EAST, + SDLCompassDirection.NORTHEAST, + ]; + } + return SDLCompassDirection_values; +} + ++ (SDLCompassDirection *)NORTH { + if (SDLCompassDirection_NORTH == nil) { + SDLCompassDirection_NORTH = [[SDLCompassDirection alloc] initWithValue:@"NORTH"]; + } + return SDLCompassDirection_NORTH; +} + ++ (SDLCompassDirection *)NORTHWEST { + if (SDLCompassDirection_NORTHWEST == nil) { + SDLCompassDirection_NORTHWEST = [[SDLCompassDirection alloc] initWithValue:@"NORTHWEST"]; + } + return SDLCompassDirection_NORTHWEST; +} + ++ (SDLCompassDirection *)WEST { + if (SDLCompassDirection_WEST == nil) { + SDLCompassDirection_WEST = [[SDLCompassDirection alloc] initWithValue:@"WEST"]; + } + return SDLCompassDirection_WEST; +} + ++ (SDLCompassDirection *)SOUTHWEST { + if (SDLCompassDirection_SOUTHWEST == nil) { + SDLCompassDirection_SOUTHWEST = [[SDLCompassDirection alloc] initWithValue:@"SOUTHWEST"]; + } + return SDLCompassDirection_SOUTHWEST; +} + ++ (SDLCompassDirection *)SOUTH { + if (SDLCompassDirection_SOUTH == nil) { + SDLCompassDirection_SOUTH = [[SDLCompassDirection alloc] initWithValue:@"SOUTH"]; + } + return SDLCompassDirection_SOUTH; +} + ++ (SDLCompassDirection *)SOUTHEAST { + if (SDLCompassDirection_SOUTHEAST == nil) { + SDLCompassDirection_SOUTHEAST = [[SDLCompassDirection alloc] initWithValue:@"SOUTHEAST"]; + } + return SDLCompassDirection_SOUTHEAST; +} + ++ (SDLCompassDirection *)EAST { + if (SDLCompassDirection_EAST == nil) { + SDLCompassDirection_EAST = [[SDLCompassDirection alloc] initWithValue:@"EAST"]; + } + return SDLCompassDirection_EAST; +} + ++ (SDLCompassDirection *)NORTHEAST { + if (SDLCompassDirection_NORTHEAST == nil) { + SDLCompassDirection_NORTHEAST = [[SDLCompassDirection alloc] initWithValue:@"NORTHEAST"]; + } + return SDLCompassDirection_NORTHEAST; +} + +@end diff --git a/SmartDeviceLink/SDLComponentVolumeStatus.h b/SmartDeviceLink/SDLComponentVolumeStatus.h new file mode 100644 index 000000000..8df22663c --- /dev/null +++ b/SmartDeviceLink/SDLComponentVolumeStatus.h @@ -0,0 +1,64 @@ +// SDLComponentVolumeStatus.h +// + + +#import "SDLEnum.h" + +/** + * The volume status of a vehicle component. + * + * @since SDL 2.0 + */ +@interface SDLComponentVolumeStatus : SDLEnum { +} + +/** + * @abstract Convert String to SDLComponentVolumeStatus + * @param value The value of the string to get an object for + * @return SDLComponentVolumeStatus + */ ++ (SDLComponentVolumeStatus *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLComponentVolumeStatus + * @return An array that store all possible SDLComponentVolumeStatus + */ ++ (NSArray *)values; + +/** + * @abstract Unknown SDLComponentVolumeStatus + * @return a SDLComponentVolumeStatus with the value of *UNKNOWN* + */ ++ (SDLComponentVolumeStatus *)UNKNOWN; + +/** + * @abstract Normal SDLComponentVolumeStatus + * @return a SDLComponentVolumeStatus with the value of *NORMAL* + */ ++ (SDLComponentVolumeStatus *)NORMAL; + +/** + * @abstract Low SDLComponentVolumeStatus + * @return a SDLComponentVolumeStatus with the value of *LOW* + */ ++ (SDLComponentVolumeStatus *)LOW; + +/** + * @abstract Fault SDLComponentVolumeStatus + * @return a SDLComponentVolumeStatus with the value of *FAULT* + */ ++ (SDLComponentVolumeStatus *)FAULT; + +/** + * @abstract Alert SDLComponentVolumeStatus + * @return a SDLComponentVolumeStatus with the value of *ALERT* + */ ++ (SDLComponentVolumeStatus *)ALERT; + +/** + * @abstract Not supported SDLComponentVolumeStatus + * @return a SDLComponentVolumeStatus with the value of *NOT_SUPPORTED* + */ ++ (SDLComponentVolumeStatus *)NOT_SUPPORTED; + +@end diff --git a/SmartDeviceLink/SDLComponentVolumeStatus.m b/SmartDeviceLink/SDLComponentVolumeStatus.m new file mode 100644 index 000000000..2e6834fb5 --- /dev/null +++ b/SmartDeviceLink/SDLComponentVolumeStatus.m @@ -0,0 +1,83 @@ +// SDLComponentVolumeStatus.m +// + + +#import "SDLComponentVolumeStatus.h" + +SDLComponentVolumeStatus *SDLComponentVolumeStatus_UNKNOWN = nil; +SDLComponentVolumeStatus *SDLComponentVolumeStatus_NORMAL = nil; +SDLComponentVolumeStatus *SDLComponentVolumeStatus_LOW = nil; +SDLComponentVolumeStatus *SDLComponentVolumeStatus_FAULT = nil; +SDLComponentVolumeStatus *SDLComponentVolumeStatus_ALERT = nil; +SDLComponentVolumeStatus *SDLComponentVolumeStatus_NOT_SUPPORTED = nil; + +NSArray *SDLComponentVolumeStatus_values = nil; + +@implementation SDLComponentVolumeStatus + ++ (SDLComponentVolumeStatus *)valueOf:(NSString *)value { + for (SDLComponentVolumeStatus *item in SDLComponentVolumeStatus.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLComponentVolumeStatus_values == nil) { + SDLComponentVolumeStatus_values = @[ + SDLComponentVolumeStatus.UNKNOWN, + SDLComponentVolumeStatus.NORMAL, + SDLComponentVolumeStatus.LOW, + SDLComponentVolumeStatus.FAULT, + SDLComponentVolumeStatus.ALERT, + SDLComponentVolumeStatus.NOT_SUPPORTED, + ]; + } + return SDLComponentVolumeStatus_values; +} + ++ (SDLComponentVolumeStatus *)UNKNOWN { + if (SDLComponentVolumeStatus_UNKNOWN == nil) { + SDLComponentVolumeStatus_UNKNOWN = [[SDLComponentVolumeStatus alloc] initWithValue:@"UNKNOWN"]; + } + return SDLComponentVolumeStatus_UNKNOWN; +} + ++ (SDLComponentVolumeStatus *)NORMAL { + if (SDLComponentVolumeStatus_NORMAL == nil) { + SDLComponentVolumeStatus_NORMAL = [[SDLComponentVolumeStatus alloc] initWithValue:@"NORMAL"]; + } + return SDLComponentVolumeStatus_NORMAL; +} + ++ (SDLComponentVolumeStatus *)LOW { + if (SDLComponentVolumeStatus_LOW == nil) { + SDLComponentVolumeStatus_LOW = [[SDLComponentVolumeStatus alloc] initWithValue:@"LOW"]; + } + return SDLComponentVolumeStatus_LOW; +} + ++ (SDLComponentVolumeStatus *)FAULT { + if (SDLComponentVolumeStatus_FAULT == nil) { + SDLComponentVolumeStatus_FAULT = [[SDLComponentVolumeStatus alloc] initWithValue:@"FAULT"]; + } + return SDLComponentVolumeStatus_FAULT; +} + ++ (SDLComponentVolumeStatus *)ALERT { + if (SDLComponentVolumeStatus_ALERT == nil) { + SDLComponentVolumeStatus_ALERT = [[SDLComponentVolumeStatus alloc] initWithValue:@"ALERT"]; + } + return SDLComponentVolumeStatus_ALERT; +} + ++ (SDLComponentVolumeStatus *)NOT_SUPPORTED { + if (SDLComponentVolumeStatus_NOT_SUPPORTED == nil) { + SDLComponentVolumeStatus_NOT_SUPPORTED = [[SDLComponentVolumeStatus alloc] initWithValue:@"NOT_SUPPORTED"]; + } + return SDLComponentVolumeStatus_NOT_SUPPORTED; +} + +@end diff --git a/SmartDeviceLink/SDLConsoleController.h b/SmartDeviceLink/SDLConsoleController.h new file mode 100644 index 000000000..5dec97948 --- /dev/null +++ b/SmartDeviceLink/SDLConsoleController.h @@ -0,0 +1,21 @@ +// SDLConsoleController.h +// + +#import <Foundation/Foundation.h> +#import <UIKit/UIKit.h> + +#import "SDLDebugTool.h" + + +@interface SDLConsoleController : UITableViewController <SDLDebugToolConsole> { + NSMutableArray *messageList; + BOOL atBottom; + NSDateFormatter *dateFormatter; +} + +@property (strong, readonly) NSMutableArray *messageList; + +- (instancetype)initWithTableView:(UITableView *)tableView; + + +@end diff --git a/SmartDeviceLink/SDLConsoleController.m b/SmartDeviceLink/SDLConsoleController.m new file mode 100644 index 000000000..bf7f600ec --- /dev/null +++ b/SmartDeviceLink/SDLConsoleController.m @@ -0,0 +1,201 @@ +// SDLConsoleController.m +// + +#import "SDLConsoleController.h" + +#import "SDLJSONEncoder.h" +#import "SDLRPCResponse.h" + + +@implementation SDLConsoleController + +@synthesize messageList; + +- (instancetype)initWithTableView:(UITableView *)tableView { + if (self = [super initWithStyle:UITableViewStylePlain]) { + self.tableView = tableView; + self.tableView.delegate = self; + self.tableView.dataSource = self; + [self viewDidLoad]; + } + return self; +} + + +- (void)append:(id)toAppend { + dispatch_async(dispatch_get_main_queue(), ^{ + //Insert the new data + NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; + + [dictionary setObject:toAppend forKey:@"object"]; + [dictionary setObject:[NSDate date] forKey:@"date"]; + + [messageList addObject:dictionary]; + NSIndexPath *newIndex = [NSIndexPath indexPathForRow:(messageList.count - 1) inSection:0]; + [self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndex] withRowAnimation:UITableViewRowAnimationNone]; + + //If we were at the bottom, scroll to the new bottom. + if (atBottom) { + [self.tableView scrollToRowAtIndexPath:newIndex atScrollPosition:UITableViewScrollPositionBottom animated:YES]; + } + + [self.tableView reloadData]; + }); +} + +- (BOOL)isLastRowVisible { + if (messageList.count == 0) { + return YES; + } else { + NSIndexPath *lastIndex = [NSIndexPath indexPathForRow:(messageList.count - 1) inSection:0]; + + NSArray *visibleRowIndexes = [self.tableView indexPathsForVisibleRows]; + for (NSIndexPath *aPath in visibleRowIndexes) { + if ([aPath compare:lastIndex] == NSOrderedSame) { + return YES; + } + } + } + return NO; +} + + +#pragma mark - +#pragma mark SDLDebugTool Console Delegate + +- (void)logInfo:(NSString *)info { + [self append:info]; +} + +- (void)logException:(NSException *)ex withMessage:(NSString *)message { + [self append:message]; + [self append:[ex description]]; +} + +- (void)logMessage:(SDLRPCMessage *)message { + [self append:message]; +} + + +#pragma mark - +#pragma mark View lifecycle + + +- (void)viewDidLoad { + [SDLDebugTool addConsole:self]; + + [super viewDidLoad]; + + atBottom = YES; + + messageList = [[NSMutableArray alloc] initWithCapacity:100]; + dateFormatter = [[NSDateFormatter alloc] init]; + dateFormatter.dateFormat = @"hh:mm:ss.SSS"; +} + +#pragma mark - +#pragma mark Scroll View Delegate + +- (void)updateWhetherScrolledToBottom { + if ([self isLastRowVisible]) { + atBottom = YES; + } else { + atBottom = NO; + } +} + +- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { + [self updateWhetherScrolledToBottom]; +} + +- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)willDecelerate { + [self updateWhetherScrolledToBottom]; +} + + +#pragma mark - +#pragma mark Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + // Return the number of sections. + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + // Return the number of rows in the section. + return messageList.count; +} + +// Customize the appearance of table view cells. +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + static NSString *CellIdentifier = @"Cell"; + + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; + if (cell == nil) { + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; + } + + NSDictionary *currentDictionary = [messageList objectAtIndex:indexPath.row]; + id msg = [currentDictionary objectForKey:@"object"]; + + NSString *tempdetail = [@"Time: " stringByAppendingString:[dateFormatter stringFromDate:[currentDictionary objectForKey:@"date"]]]; + + if ([msg isKindOfClass:SDLRPCMessage.class]) { + SDLRPCMessage *rpc = msg; + NSString *title = [NSString stringWithFormat:@"%@ (%@)", rpc.name, rpc.messageType]; + + cell.textLabel.text = title; + + if ([rpc.messageType isEqualToString:@"response"]) { + SDLRPCResponse *response = (SDLRPCResponse *)rpc; + + NSString *detail = [NSString stringWithFormat:@"%@ - %@", tempdetail, [response resultCode]]; + cell.detailTextLabel.text = detail; + } else { + cell.detailTextLabel.text = tempdetail; + } + + } else { + cell.textLabel.text = msg; + cell.detailTextLabel.text = tempdetail; + } + + return cell; +} + + +#pragma mark - +#pragma mark Table view delegate + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + NSDictionary *currentDictionary = [messageList objectAtIndex:indexPath.row]; + id obj = [currentDictionary objectForKey:@"object"]; + + NSString *alertText = nil; + if (obj == nil || [obj isKindOfClass:SDLRPCMessage.class]) { + SDLRPCMessage *rpc = obj; + NSDictionary *dictionary = [rpc serializeAsDictionary:2]; + NSError *error = nil; + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dictionary + options:NSJSONWritingPrettyPrinted + error:&error]; + + if (!jsonData) { + alertText = @"Error parsing the JSON."; + } else { + alertText = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; + } + + } else { + alertText = [NSString stringWithFormat:@"%@", [obj description]]; + } + + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"RPCMessage" message:alertText delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; + [alertView show]; + alertView = nil; + + [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; +} + + +@end diff --git a/SmartDeviceLink/SDLCreateInteractionChoiceSet.h b/SmartDeviceLink/SDLCreateInteractionChoiceSet.h new file mode 100644 index 000000000..721f505d7 --- /dev/null +++ b/SmartDeviceLink/SDLCreateInteractionChoiceSet.h @@ -0,0 +1,49 @@ +// SDLCreateInteractionChoiceSet.h +// + + +#import "SDLRPCRequest.h" + +/** + * Creates a Choice Set which can be used in subsequent *SDLPerformInteraction* Operations. + * + * HMILevel needs to be FULL, LIMITED or BACKGROUND + * + * Before a perform interaction is sent you MUST wait for the success from the CreateInteractionChoiceSet RPC. + * + * If you do not wait the system may not recognize the first utterance from the user. + * + * @since SDL 1.0 + * + * @see SDLDeleteInteractionChoiceSet SDLPerformInteraction + */ +@interface SDLCreateInteractionChoiceSet : SDLRPCRequest { +} + +/** + * Constructs a new SDLCreateInteractionChoiceSet object + */ +- (instancetype)init; + +/** + * Constructs a new SDLCreateInteractionChoiceSet object indicated by the dictionary parameter + * + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract A unique ID that identifies the Choice Set + * + * Required, Integer, 0 - 2,000,000,000 + */ +@property (strong) NSNumber *interactionChoiceSetID; + +/** + * @abstract Array of choices, which the user can select by menu or voice recognition + * + * Required, SDLChoice, Array size 1 - 100 + */ +@property (strong) NSMutableArray *choiceSet; + +@end diff --git a/SmartDeviceLink/SDLCreateInteractionChoiceSet.m b/SmartDeviceLink/SDLCreateInteractionChoiceSet.m new file mode 100644 index 000000000..32324d46e --- /dev/null +++ b/SmartDeviceLink/SDLCreateInteractionChoiceSet.m @@ -0,0 +1,57 @@ +// SDLCreateInteractionChoiceSet.m +// + + +#import "SDLCreateInteractionChoiceSet.h" + +#import "SDLChoice.h" +#import "SDLNames.h" + +@implementation SDLCreateInteractionChoiceSet + +- (instancetype)init { + if (self = [super initWithName:NAMES_CreateInteractionChoiceSet]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setInteractionChoiceSetID:(NSNumber *)interactionChoiceSetID { + if (interactionChoiceSetID != nil) { + [parameters setObject:interactionChoiceSetID forKey:NAMES_interactionChoiceSetID]; + } else { + [parameters removeObjectForKey:NAMES_interactionChoiceSetID]; + } +} + +- (NSNumber *)interactionChoiceSetID { + return [parameters objectForKey:NAMES_interactionChoiceSetID]; +} + +- (void)setChoiceSet:(NSMutableArray *)choiceSet { + if (choiceSet != nil) { + [parameters setObject:choiceSet forKey:NAMES_choiceSet]; + } else { + [parameters removeObjectForKey:NAMES_choiceSet]; + } +} + +- (NSMutableArray *)choiceSet { + NSMutableArray *array = [parameters objectForKey:NAMES_choiceSet]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLChoice.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLChoice alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +@end diff --git a/SmartDeviceLink/SDLCreateInteractionChoiceSetResponse.h b/SmartDeviceLink/SDLCreateInteractionChoiceSetResponse.h new file mode 100644 index 000000000..e2d3b76e5 --- /dev/null +++ b/SmartDeviceLink/SDLCreateInteractionChoiceSetResponse.h @@ -0,0 +1,19 @@ +// SDLCreateInteractionChoiceSetResponse.h +// + + +#import "SDLRPCResponse.h" + +/** + * SDLCreateInteractionChoiceSetResponse is sent, when SDLCreateInteractionChoiceSet + * has been called + * + * Since <b>SmartDeviceLink 1.0</b> + */ +@interface SDLCreateInteractionChoiceSetResponse : SDLRPCResponse { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLCreateInteractionChoiceSetResponse.m b/SmartDeviceLink/SDLCreateInteractionChoiceSetResponse.m new file mode 100644 index 000000000..17c2bf3f9 --- /dev/null +++ b/SmartDeviceLink/SDLCreateInteractionChoiceSetResponse.m @@ -0,0 +1,23 @@ +// SDLCreateInteractionChoiceSetResponse.m +// + + +#import "SDLCreateInteractionChoiceSetResponse.h" + +#import "SDLNames.h" + +@implementation SDLCreateInteractionChoiceSetResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_CreateInteractionChoiceSet]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLDIDResult.h b/SmartDeviceLink/SDLDIDResult.h new file mode 100644 index 000000000..a7d0b6c16 --- /dev/null +++ b/SmartDeviceLink/SDLDIDResult.h @@ -0,0 +1,19 @@ +// SDLDIDResult.h +// + +#import "SDLRPCMessage.h" + +@class SDLVehicleDataResultCode; + + +@interface SDLDIDResult : SDLRPCStruct { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) SDLVehicleDataResultCode *resultCode; +@property (strong) NSNumber *didLocation; +@property (strong) NSString *data; + +@end diff --git a/SmartDeviceLink/SDLDIDResult.m b/SmartDeviceLink/SDLDIDResult.m new file mode 100644 index 000000000..be42582e7 --- /dev/null +++ b/SmartDeviceLink/SDLDIDResult.m @@ -0,0 +1,65 @@ +// SDLDIDResult.m +// + +#import "SDLDIDResult.h" + +#import "SDLNames.h" +#import "SDLVehicleDataResultCode.h" + + +@implementation SDLDIDResult + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setResultCode:(SDLVehicleDataResultCode *)resultCode { + if (resultCode != nil) { + [store setObject:resultCode forKey:NAMES_resultCode]; + } else { + [store removeObjectForKey:NAMES_resultCode]; + } +} + +- (SDLVehicleDataResultCode *)resultCode { + NSObject *obj = [store objectForKey:NAMES_resultCode]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResultCode.class]) { + return (SDLVehicleDataResultCode *)obj; + } else { + return [SDLVehicleDataResultCode valueOf:(NSString *)obj]; + } +} + +- (void)setDidLocation:(NSNumber *)didLocation { + if (didLocation != nil) { + [store setObject:didLocation forKey:NAMES_didLocation]; + } else { + [store removeObjectForKey:NAMES_didLocation]; + } +} + +- (NSNumber *)didLocation { + return [store objectForKey:NAMES_didLocation]; +} + +- (void)setData:(NSString *)data { + if (data != nil) { + [store setObject:data forKey:NAMES_data]; + } else { + [store removeObjectForKey:NAMES_data]; + } +} + +- (NSString *)data { + return [store objectForKey:NAMES_data]; +} + +@end diff --git a/SmartDeviceLink/SDLDebugTool.h b/SmartDeviceLink/SDLDebugTool.h new file mode 100644 index 000000000..0e487303b --- /dev/null +++ b/SmartDeviceLink/SDLDebugTool.h @@ -0,0 +1,48 @@ +// SDLDebugTool.h +// + + +#import "SDLDebugToolConsole.h" +#import <Foundation/Foundation.h> + +@class SDLRPCMessage; + + +typedef NS_ENUM(UInt8, SDLDebugType) { + SDLDebugType_Debug = 0, + SDLDebugType_Transport_iAP = 1, + SDLDebugType_Transport_TCP = 2, + SDLDebugType_Protocol = 3, + SDLDebugType_RPC = 4, + SDLDebugType_APP = 5 +}; + +typedef NS_ENUM(UInt8, SDLDebugOutput) { + SDLDebugOutput_All = 0xFF, + SDLDebugOutput_DeviceConsole = 1, + SDLDebugOutput_DebugToolConsole = 2, + SDLDebugOutput_File = 4 +}; + + +@interface SDLDebugTool : NSObject { +} + ++ (void)addConsole:(NSObject<SDLDebugToolConsole> *)console; ++ (void)addConsole:(NSObject<SDLDebugToolConsole> *)console toGroup:(NSString *)groupName; ++ (void)removeConsole:(NSObject<SDLDebugToolConsole> *)console; ++ (void)removeConsole:(NSObject<SDLDebugToolConsole> *)console fromGroup:(NSString *)groupName; ++ (void)logInfo:(NSString *)info; ++ (void)logInfo:(NSString *)info withType:(SDLDebugType)type; ++ (void)logInfo:(NSString *)info withType:(SDLDebugType)type toOutput:(SDLDebugOutput)output; ++ (void)logInfo:(NSString *)info andBinaryData:(NSData *)data withType:(SDLDebugType)type toOutput:(SDLDebugOutput)output; ++ (void)logInfo:(NSString *)info withType:(SDLDebugType)type toOutput:(SDLDebugOutput)output toGroup:(NSString *)consoleGroupName; + ++ (void)enableDebugToLogFile; ++ (void)disableDebugToLogFile; ++ (void)writeToLogFile:(NSString *)info; + ++ (NSString *)stringForDebugType:(SDLDebugType)type; + + +@end diff --git a/SmartDeviceLink/SDLDebugTool.m b/SmartDeviceLink/SDLDebugTool.m new file mode 100644 index 000000000..1f0312c9c --- /dev/null +++ b/SmartDeviceLink/SDLDebugTool.m @@ -0,0 +1,258 @@ +// SDLDebugTool.m +// + +#import "SDLDebugTool.h" +#import "NSThread+ThreadIndex.h" +#import "SDLHexUtility.h" +#import "SDLRPCMessage.h" +#import "SDLSiphonServer.h" + +#define LOG_ERROR_ENABLED + +@interface SDLDebugTool () + +@property (nonatomic, assign) BOOL debugToLogFile; +@property (nonatomic, strong) NSMutableDictionary *namedConsoleSets; +@property (nonatomic, strong) NSDateFormatter *logDateFormatter; +@property (nonatomic, strong) NSFileHandle *logFileHandle; +@property (nonatomic, strong) dispatch_queue_t logQueue; + +@end + + +@implementation SDLDebugTool + +#pragma mark - Lifecycle + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + _debugToLogFile = NO; + _logQueue = dispatch_queue_create("com.sdl.log.file", DISPATCH_QUEUE_SERIAL); + + return self; +} + ++ (SDLDebugTool *)sharedTool { + static SDLDebugTool *sharedTool = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + sharedTool = [[self.class alloc] init]; + }); + + return sharedTool; +} + + +#pragma mark - Console Management + ++ (void)addConsole:(NSObject<SDLDebugToolConsole> *)console { + [self addConsole:console toGroup:@"default"]; +} + +- (void)sdl_addConsole:(NSObject<SDLDebugToolConsole> *)console toGroup:(NSString *)groupName { + // Make sure master dictionary exists + if (self.namedConsoleSets == nil) { + self.namedConsoleSets = [NSMutableDictionary new]; + } + + // Make sure the set to contain this group's elements exists + if ([self.namedConsoleSets objectForKey:groupName] == nil) { + [self.namedConsoleSets setValue:[NSMutableSet new] forKey:groupName]; + } + + // Add the console to the set + [[self.namedConsoleSets valueForKey:groupName] addObject:console]; +} + ++ (void)addConsole:(NSObject<SDLDebugToolConsole> *)console toGroup:(NSString *)groupName { + [[self sharedTool] sdl_addConsole:console toGroup:groupName]; +} + ++ (void)removeConsole:(NSObject<SDLDebugToolConsole> *)console { + [self removeConsole:console fromGroup:@"default"]; +} + ++ (void)removeConsole:(NSObject<SDLDebugToolConsole> *)console fromGroup:(NSString *)groupName { + [[SDLDebugTool getConsoleListenersForGroup:groupName] removeObject:console]; +} + ++ (NSMutableSet *)getConsoleListenersForGroup:(NSString *)groupName { + return [[self sharedTool] sdl_getConsoleListenersForGroup:groupName]; +} + +- (NSMutableSet *)sdl_getConsoleListenersForGroup:(NSString *)groupName { + return [self.namedConsoleSets valueForKey:groupName]; +} + + +#pragma mark - Logging + ++ (void)logInfo:(NSString *)info { + [self logInfo:info withType:SDLDebugType_Debug toOutput:SDLDebugOutput_All toGroup:@"default"]; +} + ++ (void)logInfo:(NSString *)info withType:(SDLDebugType)type { + [self logInfo:info withType:type toOutput:SDLDebugOutput_All toGroup:@"default"]; +} + ++ (void)logInfo:(NSString *)info withType:(SDLDebugType)type toOutput:(SDLDebugOutput)output { + [SDLDebugTool logInfo:info withType:type toOutput:output toGroup:@"default"]; +} + ++ (void)logInfo:(NSString *)info andBinaryData:(NSData *)data withType:(SDLDebugType)type toOutput:(SDLDebugOutput)output { + // convert binary data to string, append the two strings, then pass to usual log method. + NSMutableString *outputString = [[NSMutableString alloc] init]; + if (info) { + [outputString appendString:info]; + } + + if (data) { + @autoreleasepool { + NSString *dataString = [SDLHexUtility getHexString:data]; + if (dataString) { + [outputString appendString:dataString]; + } + } + } + + [SDLDebugTool logInfo:outputString withType:type toOutput:output toGroup:@"default"]; +} + +// The designated logInfo method. All outputs should be performed here. ++ (void)logInfo:(NSString *)info withType:(SDLDebugType)type toOutput:(SDLDebugOutput)output toGroup:(NSString *)consoleGroupName { + // Format the message, prepend the thread id + NSString *outputString = [NSString stringWithFormat:@"[%li] %@", (long)[[NSThread currentThread] threadIndex], info]; + + // Output to the various destinations + + //Output To DeviceConsole + if (output & SDLDebugOutput_DeviceConsole) { + NSLog(@"%@", outputString); + } + + //Output To DebugToolConsoles + if (output & SDLDebugOutput_DebugToolConsole) { + NSSet *consoleListeners = [self getConsoleListenersForGroup:consoleGroupName]; + for (NSObject<SDLDebugToolConsole> *console in consoleListeners) { + [console logInfo:outputString]; + } + } + + //Output To LogFile + if (output & SDLDebugOutput_File) { + [SDLDebugTool writeToLogFile:outputString]; + } + + //Output To Siphon + [SDLSiphonServer init]; + [SDLSiphonServer _siphonNSLogData:outputString]; +} + + +#pragma mark - File Handling + ++ (void)enableDebugToLogFile { + [[self sharedTool] sdl_enableDebugToLogFile]; +} + +- (void)sdl_enableDebugToLogFile { + [SDLDebugTool logInfo:@"Enabling Log File" withType:SDLDebugType_Debug]; + + self.debugToLogFile = YES; + + //Delete Log File If It Exists + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + NSString *documentsDirectory = [paths objectAtIndex:0]; + NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"smartdevicelink.log"]; + + NSFileManager *manager = [NSFileManager defaultManager]; + if ([manager fileExistsAtPath:filePath]) { + [manager removeItemAtPath:filePath error:nil]; + } + + // Create log file + [manager createFileAtPath:filePath contents:nil attributes:nil]; + self.logFileHandle = [NSFileHandle fileHandleForWritingAtPath:filePath]; + [self.logFileHandle seekToEndOfFile]; +} + ++ (void)disableDebugToLogFile { + [[self sharedTool] sdl_disableDebugToLogFile]; +} + +- (void)sdl_disableDebugToLogFile { + self.debugToLogFile = false; +} + ++ (void)writeToLogFile:(NSString *)info { + [[self sharedTool] sdl_writeToLogFile:info]; +} + +- (void)sdl_writeToLogFile:(NSString *)info { + // Warning: do not call any logInfo method from here. recursion of death. + if (!self.debugToLogFile || info == NULL || info.length == 0) { + return; + } + + dispatch_async(self.logQueue, ^{ + // Create timestamp string, add it in front of the message to be logged + NSDate *currentDate = [NSDate date]; + NSString *dateString = [self.logDateFormatter stringFromDate:currentDate]; + NSString *outputString = [dateString stringByAppendingFormat:@": %@\n", info]; + + // File write takes an NSData, so convert string to data. + NSData *dataToLog = [outputString dataUsingEncoding:NSUTF8StringEncoding]; + + if (self.logFileHandle != nil) { + [self.logFileHandle seekToEndOfFile]; + [self.logFileHandle writeData:dataToLog]; + } else { + NSLog(@"SDL ERROR: Unable to log to file. File handle does not exist."); + } + }); +} + +- (NSDateFormatter *)logDateFormatter { + if (_logDateFormatter == nil) { + _logDateFormatter = [[NSDateFormatter alloc] init]; + [_logDateFormatter setDateFormat:@"MM/dd/YY HH:mm:ss.SSS"]; + } + + return _logDateFormatter; +} + + +#pragma mark - Helper Methods + ++ (NSString *)stringForDebugType:(SDLDebugType)debugType { + switch (debugType) { + case SDLDebugType_Debug: + return @"DBG"; + break; + case SDLDebugType_Transport_iAP: + return @"iAP"; + break; + case SDLDebugType_Transport_TCP: + return @"TCP"; + break; + case SDLDebugType_Protocol: + return @"Pro"; + break; + case SDLDebugType_RPC: + return @"RPC"; + break; + case SDLDebugType_APP: + return @"APP"; + break; + + default: + return @"Invalid DebugType"; + break; + } +} + +@end diff --git a/SmartDeviceLink/SDLDebugToolConsole.h b/SmartDeviceLink/SDLDebugToolConsole.h new file mode 100644 index 000000000..75d541e16 --- /dev/null +++ b/SmartDeviceLink/SDLDebugToolConsole.h @@ -0,0 +1,12 @@ +// +// SDLDebugToolConsole.h +// SmartDeviceLink-iOS + +#import <Foundation/Foundation.h> + +@protocol SDLDebugToolConsole <NSObject> + +@required +- (void)logInfo:(NSString *)info; + +@end diff --git a/SmartDeviceLink/SDLDecoder.h b/SmartDeviceLink/SDLDecoder.h new file mode 100644 index 000000000..6328ecf82 --- /dev/null +++ b/SmartDeviceLink/SDLDecoder.h @@ -0,0 +1,11 @@ +// SDLDecoder.h +// + + +#import <Foundation/Foundation.h> + +@protocol SDLDecoder <NSObject> + +- (NSDictionary *)decode:(NSData *)msgBytes; + +@end diff --git a/SmartDeviceLink/SDLDeleteCommand.h b/SmartDeviceLink/SDLDeleteCommand.h new file mode 100644 index 000000000..4f3b74d90 --- /dev/null +++ b/SmartDeviceLink/SDLDeleteCommand.h @@ -0,0 +1,43 @@ +// SDLDeleteCommand.h +// + + +#import "SDLRPCRequest.h" + +/** + * Removes a command from the Command Menu + * <p> + * <b>HMI Status Requirements:</b><br/> + * HMILevel: FULL, LIMITED or BACKGROUND<br/> + * AudioStreamingState: N/A<br/> + * SystemContext: Should not be attempted when VRSESSION or MENU + * </p> + * + * Since <b>SmartDeviceLink 1.0</b><br> + * see SDLAddCommand SDLAddSubMenu SDLDeleteSubMenu + */ +@interface SDLDeleteCommand : SDLRPCRequest { +} + +/** + * Constructs a new SDLDeleteCommand object + */ +- (instancetype)init; +/** + * Constructs a new SDLDeleteCommand object indicated by the NSMutableDictionary + * parameter + * <p> + * + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract the Command ID that identifies the Command to be deleted from Command Menu + * @discussion an NSNumber value representing Command ID + * <p> + * <b>Notes: </b>Min Value: 0; Max Value: 2000000000 + */ +@property (strong) NSNumber *cmdID; + +@end diff --git a/SmartDeviceLink/SDLDeleteCommand.m b/SmartDeviceLink/SDLDeleteCommand.m new file mode 100644 index 000000000..13c51d7ed --- /dev/null +++ b/SmartDeviceLink/SDLDeleteCommand.m @@ -0,0 +1,35 @@ +// SDLDeleteCommand.m +// + + +#import "SDLDeleteCommand.h" + +#import "SDLNames.h" + +@implementation SDLDeleteCommand + +- (instancetype)init { + if (self = [super initWithName:NAMES_DeleteCommand]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setCmdID:(NSNumber *)cmdID { + if (cmdID != nil) { + [parameters setObject:cmdID forKey:NAMES_cmdID]; + } else { + [parameters removeObjectForKey:NAMES_cmdID]; + } +} + +- (NSNumber *)cmdID { + return [parameters objectForKey:NAMES_cmdID]; +} + +@end diff --git a/SmartDeviceLink/SDLDeleteCommandResponse.h b/SmartDeviceLink/SDLDeleteCommandResponse.h new file mode 100644 index 000000000..7f231c8e3 --- /dev/null +++ b/SmartDeviceLink/SDLDeleteCommandResponse.h @@ -0,0 +1,18 @@ +// SDLDeleteCommandResponse.h +// + + +#import "SDLRPCResponse.h" + +/** + * SDLDeleteCommandResponse is sent, when SDLDeleteCommand has been called + * + * Since <b>SmartDeviceLink 1.0</b><br> + */ +@interface SDLDeleteCommandResponse : SDLRPCResponse { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLDeleteCommandResponse.m b/SmartDeviceLink/SDLDeleteCommandResponse.m new file mode 100644 index 000000000..3c3d5b7a7 --- /dev/null +++ b/SmartDeviceLink/SDLDeleteCommandResponse.m @@ -0,0 +1,23 @@ +// SDLDeleteCommandResponse.m +// + + +#import "SDLDeleteCommandResponse.h" + +#import "SDLNames.h" + +@implementation SDLDeleteCommandResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_DeleteCommand]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLDeleteFile.h b/SmartDeviceLink/SDLDeleteFile.h new file mode 100644 index 000000000..325782673 --- /dev/null +++ b/SmartDeviceLink/SDLDeleteFile.h @@ -0,0 +1,36 @@ +// SDLDeleteFile.h +// + + +#import "SDLRPCRequest.h" + +/** + * Used to delete a file resident on the SDL module in the app's local cache. + * Not supported on first generation SDL vehicles + * <p> + * + * Since <b>SmartDeviceLink 2.0</b><br> + * see SDLPutFile SDLListFiles + */ +@interface SDLDeleteFile : SDLRPCRequest { +} + +/** + * Constructs a new SDLDeleteFile object + */ +- (instancetype)init; +/** + * Constructs a new SDLDeleteFile object indicated by the dictionary parameter + * <p> + * + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract a file reference name + * @discussion a String value representing a file reference name + */ +@property (strong) NSString *syncFileName; + +@end diff --git a/SmartDeviceLink/SDLDeleteFile.m b/SmartDeviceLink/SDLDeleteFile.m new file mode 100644 index 000000000..d7a4c18b2 --- /dev/null +++ b/SmartDeviceLink/SDLDeleteFile.m @@ -0,0 +1,35 @@ +// SDLDeleteFile.m +// + + +#import "SDLDeleteFile.h" + +#import "SDLNames.h" + +@implementation SDLDeleteFile + +- (instancetype)init { + if (self = [super initWithName:NAMES_DeleteFile]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setSyncFileName:(NSString *)syncFileName { + if (syncFileName != nil) { + [parameters setObject:syncFileName forKey:NAMES_syncFileName]; + } else { + [parameters removeObjectForKey:NAMES_syncFileName]; + } +} + +- (NSString *)syncFileName { + return [parameters objectForKey:NAMES_syncFileName]; +} + +@end diff --git a/SmartDeviceLink/SDLDeleteFileResponse.h b/SmartDeviceLink/SDLDeleteFileResponse.h new file mode 100644 index 000000000..ee61aa9d0 --- /dev/null +++ b/SmartDeviceLink/SDLDeleteFileResponse.h @@ -0,0 +1,20 @@ +// SDLDeleteFileResponse.h +// + + +#import "SDLRPCResponse.h" + +/** + * Delete File Response is sent, when DeleteFile has been called + * + * Since <b>SmartDeviceLink 2.0</b><br> + */ +@interface SDLDeleteFileResponse : SDLRPCResponse { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) NSNumber *spaceAvailable; + +@end diff --git a/SmartDeviceLink/SDLDeleteFileResponse.m b/SmartDeviceLink/SDLDeleteFileResponse.m new file mode 100644 index 000000000..b94075b39 --- /dev/null +++ b/SmartDeviceLink/SDLDeleteFileResponse.m @@ -0,0 +1,35 @@ +// SDLDeleteFileResponse.m +// + + +#import "SDLDeleteFileResponse.h" + +#import "SDLNames.h" + +@implementation SDLDeleteFileResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_DeleteFile]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setSpaceAvailable:(NSNumber *)spaceAvailable { + if (spaceAvailable != nil) { + [parameters setObject:spaceAvailable forKey:NAMES_spaceAvailable]; + } else { + [parameters removeObjectForKey:NAMES_spaceAvailable]; + } +} + +- (NSNumber *)spaceAvailable { + return [parameters objectForKey:NAMES_spaceAvailable]; +} + +@end diff --git a/SmartDeviceLink/SDLDeleteInteractionChoiceSet.h b/SmartDeviceLink/SDLDeleteInteractionChoiceSet.h new file mode 100644 index 000000000..28058064b --- /dev/null +++ b/SmartDeviceLink/SDLDeleteInteractionChoiceSet.h @@ -0,0 +1,45 @@ +// SDLDeleteInteractionChoiceSet.h +// + + +#import "SDLRPCRequest.h" + +/** + * Deletes an existing Choice Set identified by the parameter + * interactionChoiceSetID. If the specified interactionChoiceSetID is currently + * in use by an active <i> SDLPerformInteraction</i> this call to + * delete the Choice Set will fail returning an IN_USE resultCode + * <p> + * Function Group: Base + * <p> + * <b>HMILevel needs to be FULL, LIMITED or BACKGROUD</b><br/> + * </p> + * + * Since <b>SmartDeviceLink 1.0</b><br> + * see SDLCreateInteractionChoiceSet SDLPerformInteraction + */ +@interface SDLDeleteInteractionChoiceSet : SDLRPCRequest { +} + +/** + * Constructs a new SDLDeleteInteractionChoiceSet object + */ +- (instancetype)init; +/** + * Constructs a new SDLDeleteInteractionChoiceSet object indicated by the + * NSMutableDictionary parameter + * <p> + * + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract a unique ID that identifies the Choice Set + * @discussion a unique ID that identifies the Choice Set + * <p> + * <b>Notes: </b>Min Value: 0; Max Value: 2000000000 + */ +@property (strong) NSNumber *interactionChoiceSetID; + +@end diff --git a/SmartDeviceLink/SDLDeleteInteractionChoiceSet.m b/SmartDeviceLink/SDLDeleteInteractionChoiceSet.m new file mode 100644 index 000000000..fd5d202b1 --- /dev/null +++ b/SmartDeviceLink/SDLDeleteInteractionChoiceSet.m @@ -0,0 +1,35 @@ +// SDLDeleteInteractionChoiceSet.m +// + + +#import "SDLDeleteInteractionChoiceSet.h" + +#import "SDLNames.h" + +@implementation SDLDeleteInteractionChoiceSet + +- (instancetype)init { + if (self = [super initWithName:NAMES_DeleteInteractionChoiceSet]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setInteractionChoiceSetID:(NSNumber *)interactionChoiceSetID { + if (interactionChoiceSetID != nil) { + [parameters setObject:interactionChoiceSetID forKey:NAMES_interactionChoiceSetID]; + } else { + [parameters removeObjectForKey:NAMES_interactionChoiceSetID]; + } +} + +- (NSNumber *)interactionChoiceSetID { + return [parameters objectForKey:NAMES_interactionChoiceSetID]; +} + +@end diff --git a/SmartDeviceLink/SDLDeleteInteractionChoiceSetResponse.h b/SmartDeviceLink/SDLDeleteInteractionChoiceSetResponse.h new file mode 100644 index 000000000..7a5cd4406 --- /dev/null +++ b/SmartDeviceLink/SDLDeleteInteractionChoiceSetResponse.h @@ -0,0 +1,18 @@ +// SDLDeleteInteractionChoiceSetResponse.h +// + + +#import "SDLRPCResponse.h" + +/** + * SDLDeleteInteractionChoiceSetResponse is sent, when SDLDeleteInteractionChoiceSet has been called + * + * Since <b>SmartDeviceLink 1.0</b> + */ +@interface SDLDeleteInteractionChoiceSetResponse : SDLRPCResponse { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLDeleteInteractionChoiceSetResponse.m b/SmartDeviceLink/SDLDeleteInteractionChoiceSetResponse.m new file mode 100644 index 000000000..666a758a1 --- /dev/null +++ b/SmartDeviceLink/SDLDeleteInteractionChoiceSetResponse.m @@ -0,0 +1,23 @@ +// SDLDeleteInteractionChoiceSetResponse.m +// + + +#import "SDLDeleteInteractionChoiceSetResponse.h" + +#import "SDLNames.h" + +@implementation SDLDeleteInteractionChoiceSetResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_DeleteInteractionChoiceSet]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLDeleteSubMenu.h b/SmartDeviceLink/SDLDeleteSubMenu.h new file mode 100644 index 000000000..37c2dc544 --- /dev/null +++ b/SmartDeviceLink/SDLDeleteSubMenu.h @@ -0,0 +1,38 @@ +// SDLDeleteSubMenu.h +// + + +#import "SDLRPCRequest.h" + +/** + * Deletes a submenu from the Command Menu + * <p> + * <b>Notes: </b>When an app deletes a submenu that has child commands, those + * child commands are also deleted + * <p> + * <b>HMILevel needs to be FULL, LIMITED or BACKGROUND</b> + * </p> + * + * Since <b>SmartDeviceLink 1.0</b><br> + * see SDLAddCommand SDLAddSubMenu SDLDeleteCommand + */ +@interface SDLDeleteSubMenu : SDLRPCRequest { +} + +/** + * Constructs a new SDLDeleteSubMenu object + */ +- (instancetype)init; +/** + * Constructs a new SDLDeleteSubMenu object indicated by the dictionary parameter<p> + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract the MenuID that identifies the SDLSubMenu to be delete + * @discussion <b>Notes: </b>Min Value: 0; Max Value: 2000000000 + */ +@property (strong) NSNumber *menuID; + +@end diff --git a/SmartDeviceLink/SDLDeleteSubMenu.m b/SmartDeviceLink/SDLDeleteSubMenu.m new file mode 100644 index 000000000..8727f44d3 --- /dev/null +++ b/SmartDeviceLink/SDLDeleteSubMenu.m @@ -0,0 +1,35 @@ +// SDLDeleteSubMenu.m +// + + +#import "SDLDeleteSubMenu.h" + +#import "SDLNames.h" + +@implementation SDLDeleteSubMenu + +- (instancetype)init { + if (self = [super initWithName:NAMES_DeleteSubMenu]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setMenuID:(NSNumber *)menuID { + if (menuID != nil) { + [parameters setObject:menuID forKey:NAMES_menuID]; + } else { + [parameters removeObjectForKey:NAMES_menuID]; + } +} + +- (NSNumber *)menuID { + return [parameters objectForKey:NAMES_menuID]; +} + +@end diff --git a/SmartDeviceLink/SDLDeleteSubMenuResponse.h b/SmartDeviceLink/SDLDeleteSubMenuResponse.h new file mode 100644 index 000000000..3b32df8f3 --- /dev/null +++ b/SmartDeviceLink/SDLDeleteSubMenuResponse.h @@ -0,0 +1,18 @@ +// SDLDeleteSubMenuResponse.h +// + + +#import "SDLRPCResponse.h" + +/** + * SDLDeleteSubMenuResponse is sent, when SDLDeleteSubMenu has been called + * + * Since <b>SmartDeviceLink 1.0</b> + */ +@interface SDLDeleteSubMenuResponse : SDLRPCResponse { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLDeleteSubMenuResponse.m b/SmartDeviceLink/SDLDeleteSubMenuResponse.m new file mode 100644 index 000000000..b88d9b626 --- /dev/null +++ b/SmartDeviceLink/SDLDeleteSubMenuResponse.m @@ -0,0 +1,23 @@ +// SDLDeleteSubMenuResponse.m +// + + +#import "SDLDeleteSubMenuResponse.h" + +#import "SDLNames.h" + +@implementation SDLDeleteSubMenuResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_DeleteSubMenu]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLDeviceInfo.h b/SmartDeviceLink/SDLDeviceInfo.h new file mode 100644 index 000000000..1bcbdaa27 --- /dev/null +++ b/SmartDeviceLink/SDLDeviceInfo.h @@ -0,0 +1,20 @@ +// SDLDeviceInfo.h +// + +#import "SDLRPCMessage.h" + + +@interface SDLDeviceInfo : SDLRPCStruct { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) NSString *hardware; +@property (strong) NSString *firmwareRev; +@property (strong) NSString *os; +@property (strong) NSString *osVersion; +@property (strong) NSString *carrier; +@property (strong) NSNumber *maxNumberRFCOMMPorts; + +@end diff --git a/SmartDeviceLink/SDLDeviceInfo.m b/SmartDeviceLink/SDLDeviceInfo.m new file mode 100644 index 000000000..134aea629 --- /dev/null +++ b/SmartDeviceLink/SDLDeviceInfo.m @@ -0,0 +1,95 @@ +// SDLDeviceInfo.m +// + +#import "SDLDeviceInfo.h" + +#import "SDLNames.h" + + +@implementation SDLDeviceInfo + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setHardware:(NSString *)hardware { + if (hardware != nil) { + [store setObject:hardware forKey:NAMES_hardware]; + } else { + [store removeObjectForKey:NAMES_hardware]; + } +} + +- (NSString *)hardware { + return [store objectForKey:NAMES_hardware]; +} + +- (void)setFirmwareRev:(NSString *)firmwareRev { + if (firmwareRev != nil) { + [store setObject:firmwareRev forKey:NAMES_firmwareRev]; + } else { + [store removeObjectForKey:NAMES_firmwareRev]; + } +} + +- (NSString *)firmwareRev { + return [store objectForKey:NAMES_firmwareRev]; +} + +- (void)setOs:(NSString *)os { + if (os != nil) { + [store setObject:os forKey:NAMES_os]; + } else { + [store removeObjectForKey:NAMES_os]; + } +} + +- (NSString *)os { + return [store objectForKey:NAMES_os]; +} + +- (void)setOsVersion:(NSString *)osVersion { + if (osVersion != nil) { + [store setObject:osVersion forKey:NAMES_osVersion]; + } else { + [store removeObjectForKey:NAMES_osVersion]; + } +} + +- (NSString *)osVersion { + return [store objectForKey:NAMES_osVersion]; +} + +- (void)setCarrier:(NSString *)carrier { + if (carrier != nil) { + [store setObject:carrier forKey:NAMES_carrier]; + } else { + [store removeObjectForKey:NAMES_carrier]; + } +} + +- (NSString *)carrier { + return [store objectForKey:NAMES_carrier]; +} + +- (void)setMaxNumberRFCOMMPorts:(NSNumber *)maxNumberRFCOMMPorts { + if (maxNumberRFCOMMPorts != nil) { + [store setObject:maxNumberRFCOMMPorts forKey:NAMES_maxNumberRFCOMMPorts]; + } else { + [store removeObjectForKey:NAMES_maxNumberRFCOMMPorts]; + } +} + +- (NSNumber *)maxNumberRFCOMMPorts { + return [store objectForKey:NAMES_maxNumberRFCOMMPorts]; +} + +@end diff --git a/SmartDeviceLink/SDLDeviceLevelStatus.h b/SmartDeviceLink/SDLDeviceLevelStatus.h new file mode 100644 index 000000000..e0cb85aea --- /dev/null +++ b/SmartDeviceLink/SDLDeviceLevelStatus.h @@ -0,0 +1,64 @@ +// SDLDeviceLevelStatus.h +// + + +#import "SDLEnum.h" + +/** + * Reflects the reported battery status of the connected device, if reported. + * + * @since SDL 2.0 + */ +@interface SDLDeviceLevelStatus : SDLEnum { +} + +/** + * Convert String to DeviceLevelStatus + * @param value String + * @return DeviceLevelStatus + */ ++ (SDLDeviceLevelStatus *)valueOf:(NSString *)value; + +/** + @abstract Store the enumeration of all possible SDLDeviceLevelStatus + @return an array that store all possible SDLDeviceLevelStatus + */ ++ (NSArray *)values; + +/** + * @abstract Device battery level is zero bars + * @return a SDLDeviceLevelStatus with value of *ZERO_LEVEL_BARS* + */ ++ (SDLDeviceLevelStatus *)ZERO_LEVEL_BARS; + +/** + * @abstract Device battery level is one bar + * @return a SDLDeviceLevelStatus with value of *ONE_LEVEL_BARS* + */ ++ (SDLDeviceLevelStatus *)ONE_LEVEL_BARS; + +/** + * @abstract Device battery level is two bars + * @return a SDLDeviceLevelStatus with value of *TWO_LEVEL_BARS* + */ ++ (SDLDeviceLevelStatus *)TWO_LEVEL_BARS; + +/** + * @abstract Device battery level is three bars + * @return a SDLDeviceLevelStatus with value of *THREE_LEVEL_BARS* + */ ++ (SDLDeviceLevelStatus *)THREE_LEVEL_BARS; + +/** + * @abstract Device battery level is four bars + * @return a SDLDeviceLevelStatus with value of *FOUR_LEVEL_BARS* + */ ++ (SDLDeviceLevelStatus *)FOUR_LEVEL_BARS; + +/** + * @abstract Device battery level is unknown + * @return a SDLDeviceLevelStatus with value of *NOT_PROVIDED* + */ ++ (SDLDeviceLevelStatus *)NOT_PROVIDED; + +@end diff --git a/SmartDeviceLink/SDLDeviceLevelStatus.m b/SmartDeviceLink/SDLDeviceLevelStatus.m new file mode 100644 index 000000000..5babd37b5 --- /dev/null +++ b/SmartDeviceLink/SDLDeviceLevelStatus.m @@ -0,0 +1,83 @@ +// SDLDeviceLevelStatus.m +// + + +#import "SDLDeviceLevelStatus.h" + +SDLDeviceLevelStatus *SDLDeviceLevelStatus_ZERO_LEVEL_BARS = nil; +SDLDeviceLevelStatus *SDLDeviceLevelStatus_ONE_LEVEL_BARS = nil; +SDLDeviceLevelStatus *SDLDeviceLevelStatus_TWO_LEVEL_BARS = nil; +SDLDeviceLevelStatus *SDLDeviceLevelStatus_THREE_LEVEL_BARS = nil; +SDLDeviceLevelStatus *SDLDeviceLevelStatus_FOUR_LEVEL_BARS = nil; +SDLDeviceLevelStatus *SDLDeviceLevelStatus_NOT_PROVIDED = nil; + +NSArray *SDLDeviceLevelStatus_values = nil; + +@implementation SDLDeviceLevelStatus + ++ (SDLDeviceLevelStatus *)valueOf:(NSString *)value { + for (SDLDeviceLevelStatus *item in SDLDeviceLevelStatus.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLDeviceLevelStatus_values == nil) { + SDLDeviceLevelStatus_values = @[ + SDLDeviceLevelStatus.ZERO_LEVEL_BARS, + SDLDeviceLevelStatus.ONE_LEVEL_BARS, + SDLDeviceLevelStatus.TWO_LEVEL_BARS, + SDLDeviceLevelStatus.THREE_LEVEL_BARS, + SDLDeviceLevelStatus.FOUR_LEVEL_BARS, + SDLDeviceLevelStatus.NOT_PROVIDED, + ]; + } + return SDLDeviceLevelStatus_values; +} + ++ (SDLDeviceLevelStatus *)ZERO_LEVEL_BARS { + if (SDLDeviceLevelStatus_ZERO_LEVEL_BARS == nil) { + SDLDeviceLevelStatus_ZERO_LEVEL_BARS = [[SDLDeviceLevelStatus alloc] initWithValue:@"ZERO_LEVEL_BARS"]; + } + return SDLDeviceLevelStatus_ZERO_LEVEL_BARS; +} + ++ (SDLDeviceLevelStatus *)ONE_LEVEL_BARS { + if (SDLDeviceLevelStatus_ONE_LEVEL_BARS == nil) { + SDLDeviceLevelStatus_ONE_LEVEL_BARS = [[SDLDeviceLevelStatus alloc] initWithValue:@"ONE_LEVEL_BARS"]; + } + return SDLDeviceLevelStatus_ONE_LEVEL_BARS; +} + ++ (SDLDeviceLevelStatus *)TWO_LEVEL_BARS { + if (SDLDeviceLevelStatus_TWO_LEVEL_BARS == nil) { + SDLDeviceLevelStatus_TWO_LEVEL_BARS = [[SDLDeviceLevelStatus alloc] initWithValue:@"TWO_LEVEL_BARS"]; + } + return SDLDeviceLevelStatus_TWO_LEVEL_BARS; +} + ++ (SDLDeviceLevelStatus *)THREE_LEVEL_BARS { + if (SDLDeviceLevelStatus_THREE_LEVEL_BARS == nil) { + SDLDeviceLevelStatus_THREE_LEVEL_BARS = [[SDLDeviceLevelStatus alloc] initWithValue:@"THREE_LEVEL_BARS"]; + } + return SDLDeviceLevelStatus_THREE_LEVEL_BARS; +} + ++ (SDLDeviceLevelStatus *)FOUR_LEVEL_BARS { + if (SDLDeviceLevelStatus_FOUR_LEVEL_BARS == nil) { + SDLDeviceLevelStatus_FOUR_LEVEL_BARS = [[SDLDeviceLevelStatus alloc] initWithValue:@"FOUR_LEVEL_BARS"]; + } + return SDLDeviceLevelStatus_FOUR_LEVEL_BARS; +} + ++ (SDLDeviceLevelStatus *)NOT_PROVIDED { + if (SDLDeviceLevelStatus_NOT_PROVIDED == nil) { + SDLDeviceLevelStatus_NOT_PROVIDED = [[SDLDeviceLevelStatus alloc] initWithValue:@"NOT_PROVIDED"]; + } + return SDLDeviceLevelStatus_NOT_PROVIDED; +} + +@end diff --git a/SmartDeviceLink/SDLDeviceStatus.h b/SmartDeviceLink/SDLDeviceStatus.h new file mode 100644 index 000000000..d8442d438 --- /dev/null +++ b/SmartDeviceLink/SDLDeviceStatus.h @@ -0,0 +1,199 @@ +// SDLDeviceStatus.h +// + +#import "SDLRPCMessage.h" + +@class SDLDeviceLevelStatus; +@class SDLPrimaryAudioSource; + + +/** + * Describes the status related to a connected mobile device or SDL and if or how it is represented in the vehicle. + * + * Parameter List + * <table border="1" rules="all"> + * <tr> + * <th>Name</th> + * <th>Type</th> + * <th>Description</th> + * <th>SmartDeviceLink Ver. Available</th> + * </tr> + * <tr> + * <td>voiceRecOn</td> + * <td>NSNumber * </td> + * <td>Voice recognition is on + * </td> + * <td>SmartDeviceLink 2.0</td> + * </tr> + * <tr> + * <td>btIconOn</td> + * <td>NSNumber * </td> + * <td>Bluetooth connection established + * </td> + * <td>SmartDeviceLink 2.0</td> + * </tr> + * <tr> + * <td>callActive</td> + * <td>NSNumber * </td> + * <td>A call is being active + * </td> + * <td>SmartDeviceLink 2.0</td> + * </tr> + * <tr> + * <td>phoneRoaming</td> + * <td>NSNumber * </td> + * <td>The phone is in roaming mode + * </td> + * <td>SmartDeviceLink 2.0</td> + * </tr> + * <tr> + * <td>textMsgAvailable</td> + * <td>NSNumber * </td> + * <td>A textmessage is available + * </td> + * <td>SmartDeviceLink 2.0</td> + * </tr> + * <tr> + * <td>battLevelStatus</td> + * <td>SDLDeviceLevelStatus * </td> + * <td>Battery level status + * </td> + * <td>SmartDeviceLink 2.0</td> + * </tr> + * <tr> + * <td>stereoAudioOutputMuted</td> + * <td>NSNumber * </td> + * <td>Status of the stereo audio output channel + * </td> + * <td>SmartDeviceLink 2.0</td> + * </tr> + * <tr> + * <td>monoAudioOutputMuted</td> + * <td>NSNumber * </td> + * <td>Status of the mono audio output channel + * </td> + * <td>SmartDeviceLink 2.0</td> + * </tr> + * <tr> + * <td>signalLevelStatus</td> + * <td>SDLDeviceLevelStatus * </td> + * <td>Signal level status + * </td> + * <td>SmartDeviceLink 2.0</td> + * </tr> + * <tr> + * <td>primaryAudioSource</td> + * <td>PrimaryAudioSource * </td> + * <td>Reflects the current primary audio source of SDL (if selected). + * </td> + * <td>SmartDeviceLink 2.0</td> + * </tr> + * <tr> + * <td>eCallEventActive</td> + * <td>NSNumber * </td> + * <td>Reflects, if an eCall event is active + * </td> + * <td>SmartDeviceLink 2.0</td> + * </tr> + * </table> + * @since SDL 2.0 + */ +@interface SDLDeviceStatus : SDLRPCStruct { +} + +/** + * Constructs a newly allocated SDLDeviceStatus object + */ +- (instancetype)init; + +/** + * Constructs a newly allocated SDLDeviceStatus object indicated by the dictionary parameter + * + * @param dict The dictionary to use to construct the object + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract Indicates whether the voice recognition is on or off + * + * Required, Boolean + */ +@property (strong) NSNumber *voiceRecOn; + +/** + * @abstract Indicates whether the bluetooth connection established + * + * Required, Boolean + */ +@property (strong) NSNumber *btIconOn; + +/** + * @abstract Indicates whether a call is being active + * + * Required, Boolean + */ +@property (strong) NSNumber *callActive; + +/** + * @abstract Indicates whether the phone is in roaming mode + * + * Required, Boolean + */ +@property (strong) NSNumber *phoneRoaming; + +/** + * @abstract Indicates whether a textmessage is available + * + * Required, Boolean + */ +@property (strong) NSNumber *textMsgAvailable; + +/** + * @abstract Battery level status + * + * @see SDLDeviceLevelStatus + * + * Required + */ +@property (strong) SDLDeviceLevelStatus *battLevelStatus; + +/** + * @abstract The status of the stereo audio output channel + * + * Required, Boolean + */ +@property (strong) NSNumber *stereoAudioOutputMuted; + +/** + * @abstract The status of the mono audio output channel + * + * Required, Boolean + */ +@property (strong) NSNumber *monoAudioOutputMuted; + +/** + * @abstract Signal level status + * + * @see SDLDeviceLevelStatus + * + * Required + */ +@property (strong) SDLDeviceLevelStatus *signalLevelStatus; + +/** + * @abstract The current primary audio source of SDL (if selected). + * + * @see SDLPrimaryAudioSource + * + * Required + */ +@property (strong) SDLPrimaryAudioSource *primaryAudioSource; + +/** + * @abstract Indicates if an emergency call is active + * + * Required, Boolean + */ +@property (strong) NSNumber *eCallEventActive; + +@end diff --git a/SmartDeviceLink/SDLDeviceStatus.m b/SmartDeviceLink/SDLDeviceStatus.m new file mode 100644 index 000000000..fbe3b4b96 --- /dev/null +++ b/SmartDeviceLink/SDLDeviceStatus.m @@ -0,0 +1,172 @@ +// SDLDeviceStatus.m +// + +#import "SDLDeviceStatus.h" + +#import "SDLDeviceLevelStatus.h" +#import "SDLNames.h" +#import "SDLPrimaryAudioSource.h" + + +@implementation SDLDeviceStatus + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setVoiceRecOn:(NSNumber *)voiceRecOn { + if (voiceRecOn != nil) { + [store setObject:voiceRecOn forKey:NAMES_voiceRecOn]; + } else { + [store removeObjectForKey:NAMES_voiceRecOn]; + } +} + +- (NSNumber *)voiceRecOn { + return [store objectForKey:NAMES_voiceRecOn]; +} + +- (void)setBtIconOn:(NSNumber *)btIconOn { + if (btIconOn != nil) { + [store setObject:btIconOn forKey:NAMES_btIconOn]; + } else { + [store removeObjectForKey:NAMES_btIconOn]; + } +} + +- (NSNumber *)btIconOn { + return [store objectForKey:NAMES_btIconOn]; +} + +- (void)setCallActive:(NSNumber *)callActive { + if (callActive != nil) { + [store setObject:callActive forKey:NAMES_callActive]; + } else { + [store removeObjectForKey:NAMES_callActive]; + } +} + +- (NSNumber *)callActive { + return [store objectForKey:NAMES_callActive]; +} + +- (void)setPhoneRoaming:(NSNumber *)phoneRoaming { + if (phoneRoaming != nil) { + [store setObject:phoneRoaming forKey:NAMES_phoneRoaming]; + } else { + [store removeObjectForKey:NAMES_phoneRoaming]; + } +} + +- (NSNumber *)phoneRoaming { + return [store objectForKey:NAMES_phoneRoaming]; +} + +- (void)setTextMsgAvailable:(NSNumber *)textMsgAvailable { + if (textMsgAvailable != nil) { + [store setObject:textMsgAvailable forKey:NAMES_textMsgAvailable]; + } else { + [store removeObjectForKey:NAMES_textMsgAvailable]; + } +} + +- (NSNumber *)textMsgAvailable { + return [store objectForKey:NAMES_textMsgAvailable]; +} + +- (void)setBattLevelStatus:(SDLDeviceLevelStatus *)battLevelStatus { + if (battLevelStatus != nil) { + [store setObject:battLevelStatus forKey:NAMES_battLevelStatus]; + } else { + [store removeObjectForKey:NAMES_battLevelStatus]; + } +} + +- (SDLDeviceLevelStatus *)battLevelStatus { + NSObject *obj = [store objectForKey:NAMES_battLevelStatus]; + if (obj == nil || [obj isKindOfClass:SDLDeviceLevelStatus.class]) { + return (SDLDeviceLevelStatus *)obj; + } else { + return [SDLDeviceLevelStatus valueOf:(NSString *)obj]; + } +} + +- (void)setStereoAudioOutputMuted:(NSNumber *)stereoAudioOutputMuted { + if (stereoAudioOutputMuted != nil) { + [store setObject:stereoAudioOutputMuted forKey:NAMES_stereoAudioOutputMuted]; + } else { + [store removeObjectForKey:NAMES_stereoAudioOutputMuted]; + } +} + +- (NSNumber *)stereoAudioOutputMuted { + return [store objectForKey:NAMES_stereoAudioOutputMuted]; +} + +- (void)setMonoAudioOutputMuted:(NSNumber *)monoAudioOutputMuted { + if (monoAudioOutputMuted != nil) { + [store setObject:monoAudioOutputMuted forKey:NAMES_monoAudioOutputMuted]; + } else { + [store removeObjectForKey:NAMES_monoAudioOutputMuted]; + } +} + +- (NSNumber *)monoAudioOutputMuted { + return [store objectForKey:NAMES_monoAudioOutputMuted]; +} + +- (void)setSignalLevelStatus:(SDLDeviceLevelStatus *)signalLevelStatus { + if (signalLevelStatus != nil) { + [store setObject:signalLevelStatus forKey:NAMES_signalLevelStatus]; + } else { + [store removeObjectForKey:NAMES_signalLevelStatus]; + } +} + +- (SDLDeviceLevelStatus *)signalLevelStatus { + NSObject *obj = [store objectForKey:NAMES_signalLevelStatus]; + if (obj == nil || [obj isKindOfClass:SDLDeviceLevelStatus.class]) { + return (SDLDeviceLevelStatus *)obj; + } else { + return [SDLDeviceLevelStatus valueOf:(NSString *)obj]; + } +} + +- (void)setPrimaryAudioSource:(SDLPrimaryAudioSource *)primaryAudioSource { + if (primaryAudioSource != nil) { + [store setObject:primaryAudioSource forKey:NAMES_primaryAudioSource]; + } else { + [store removeObjectForKey:NAMES_primaryAudioSource]; + } +} + +- (SDLPrimaryAudioSource *)primaryAudioSource { + NSObject *obj = [store objectForKey:NAMES_primaryAudioSource]; + if (obj == nil || [obj isKindOfClass:SDLPrimaryAudioSource.class]) { + return (SDLPrimaryAudioSource *)obj; + } else { + return [SDLPrimaryAudioSource valueOf:(NSString *)obj]; + } +} + +- (void)setECallEventActive:(NSNumber *)eCallEventActive { + if (eCallEventActive != nil) { + [store setObject:eCallEventActive forKey:NAMES_eCallEventActive]; + } else { + [store removeObjectForKey:NAMES_eCallEventActive]; + } +} + +- (NSNumber *)eCallEventActive { + return [store objectForKey:NAMES_eCallEventActive]; +} + +@end diff --git a/SmartDeviceLink/SDLDiagnosticMessage.h b/SmartDeviceLink/SDLDiagnosticMessage.h new file mode 100644 index 000000000..40ca013f2 --- /dev/null +++ b/SmartDeviceLink/SDLDiagnosticMessage.h @@ -0,0 +1,39 @@ +// SDLDiagnosticMessage.h +// + + +#import "SDLRPCRequest.h" + +/** + * Non periodic vehicle diagnostic request + * + * @since SDL 3.0 + */ +@interface SDLDiagnosticMessage : SDLRPCRequest { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * Name of target ECU + * + * Required, Integer, 0 - 65535 + */ +@property (strong) NSNumber *targetID; + +/** + * Length of message (in bytes) + * + * Required, Integer, 65535 + */ +@property (strong) NSNumber *messageLength; + +/** + * Array of bytes comprising CAN message. + * + * Required, Array of NSNumber (Integers), Array size 1 - 65535, Integer Size 0 - 255 + */ +@property (strong) NSMutableArray *messageData; + +@end diff --git a/SmartDeviceLink/SDLDiagnosticMessage.m b/SmartDeviceLink/SDLDiagnosticMessage.m new file mode 100644 index 000000000..8a45a8650 --- /dev/null +++ b/SmartDeviceLink/SDLDiagnosticMessage.m @@ -0,0 +1,59 @@ +// SDLDiagnosticMessage.m +// + + +#import "SDLDiagnosticMessage.h" + +#import "SDLNames.h" + +@implementation SDLDiagnosticMessage + +- (instancetype)init { + if (self = [super initWithName:NAMES_DiagnosticMessage]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setTargetID:(NSNumber *)targetID { + if (targetID != nil) { + [parameters setObject:targetID forKey:NAMES_targetID]; + } else { + [parameters removeObjectForKey:NAMES_targetID]; + } +} + +- (NSNumber *)targetID { + return [parameters objectForKey:NAMES_targetID]; +} + +- (void)setMessageLength:(NSNumber *)messageLength { + if (messageLength != nil) { + [parameters setObject:messageLength forKey:NAMES_messageLength]; + } else { + [parameters removeObjectForKey:NAMES_messageLength]; + } +} + +- (NSNumber *)messageLength { + return [parameters objectForKey:NAMES_messageLength]; +} + +- (void)setMessageData:(NSMutableArray *)messageData { + if (messageData != nil) { + [parameters setObject:messageData forKey:NAMES_messageData]; + } else { + [parameters removeObjectForKey:NAMES_messageData]; + } +} + +- (NSMutableArray *)messageData { + return [parameters objectForKey:NAMES_messageData]; +} + +@end diff --git a/SmartDeviceLink/SDLDiagnosticMessageResponse.h b/SmartDeviceLink/SDLDiagnosticMessageResponse.h new file mode 100644 index 000000000..4820b893f --- /dev/null +++ b/SmartDeviceLink/SDLDiagnosticMessageResponse.h @@ -0,0 +1,18 @@ +// SDLDiagnosticMessageResponse.h +// + + +#import "SDLRPCResponse.h" + +/** SDLDiagnosticMessageResponse is sent, when SDLDiagnosticMessage has been called. + * Since<b>SmartDeviceLink 3.0</b> + */ +@interface SDLDiagnosticMessageResponse : SDLRPCResponse { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) NSMutableArray *messageDataResult; + +@end diff --git a/SmartDeviceLink/SDLDiagnosticMessageResponse.m b/SmartDeviceLink/SDLDiagnosticMessageResponse.m new file mode 100644 index 000000000..f8215d977 --- /dev/null +++ b/SmartDeviceLink/SDLDiagnosticMessageResponse.m @@ -0,0 +1,34 @@ +// SDLDiagnosticMessageResponse.m +// + +#import "SDLDiagnosticMessageResponse.h" + +#import "SDLNames.h" + +@implementation SDLDiagnosticMessageResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_DiagnosticMessage]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setMessageDataResult:(NSMutableArray *)messageDataResult { + if (messageDataResult != nil) { + [parameters setObject:messageDataResult forKey:NAMES_messageDataResult]; + } else { + [parameters removeObjectForKey:NAMES_messageDataResult]; + } +} + +- (NSMutableArray *)messageDataResult { + return [parameters objectForKey:NAMES_messageDataResult]; +} + +@end diff --git a/SmartDeviceLink/SDLDialNumber.h b/SmartDeviceLink/SDLDialNumber.h new file mode 100644 index 000000000..48cca6a6d --- /dev/null +++ b/SmartDeviceLink/SDLDialNumber.h @@ -0,0 +1,22 @@ +// +// SDLDialNumber.h +// SmartDeviceLink-iOS + +#import "SDLRPCRequest.h" + +/** + This RPC is used to tell the head unit to use bluetooth to dial a phone number using the phone. + + @since SDL 4.0 + */ +@interface SDLDialNumber : SDLRPCRequest + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * Up to 40 character string representing the phone number. All characters stripped except for '0'-'9', '*', '#', ',', ';', and '+' + */ +@property (strong, nonatomic) NSString *number; + +@end diff --git a/SmartDeviceLink/SDLDialNumber.m b/SmartDeviceLink/SDLDialNumber.m new file mode 100644 index 000000000..856f9ad75 --- /dev/null +++ b/SmartDeviceLink/SDLDialNumber.m @@ -0,0 +1,35 @@ +// +// SDLDialNumber.m +// SmartDeviceLink-iOS + +#import "SDLDialNumber.h" + +#import "SDLNames.h" + +@implementation SDLDialNumber + +- (instancetype)init { + if (self = [super initWithName:NAMES_DialNumber]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setNumber:(NSString *)number { + if (number != nil) { + parameters[NAMES_number] = number; + } else { + [parameters removeObjectForKey:NAMES_number]; + } +} + +- (NSString *)number { + return parameters[NAMES_number]; +} + +@end diff --git a/SmartDeviceLink/SDLDialNumberResponse.h b/SmartDeviceLink/SDLDialNumberResponse.h new file mode 100644 index 000000000..454babcf3 --- /dev/null +++ b/SmartDeviceLink/SDLDialNumberResponse.h @@ -0,0 +1,17 @@ +// +// SDLDialNumberResponse.h +// SmartDeviceLink-iOS + +#import "SDLRPCResponse.h" + +/** + Indicates the result, success, or failure of the SDLDialNumber request. + + @since SDL 4.0 + */ +@interface SDLDialNumberResponse : SDLRPCResponse + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLDialNumberResponse.m b/SmartDeviceLink/SDLDialNumberResponse.m new file mode 100644 index 000000000..a0b6dd83e --- /dev/null +++ b/SmartDeviceLink/SDLDialNumberResponse.m @@ -0,0 +1,24 @@ +// +// SDLDialNumberResponse.m +// SmartDeviceLink-iOS + +#import "SDLDialNumberResponse.h" + +#import "SDLNames.h" + + +@implementation SDLDialNumberResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_DialNumber]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLDimension.h b/SmartDeviceLink/SDLDimension.h new file mode 100644 index 000000000..535f93e6e --- /dev/null +++ b/SmartDeviceLink/SDLDimension.h @@ -0,0 +1,51 @@ +// SDLDimension.h +// + + +#import "SDLEnum.h" + +#import <Foundation/Foundation.h> + +/** + * The supported dimensions of the GPS. + * + * @since SDL 2.0 + */ +@interface SDLDimension : SDLEnum { +} + +/** + * Convert String to SDLDimension + * + * @param value The value of the string to get an object for + * + * @return SDLDimension + */ ++ (SDLDimension *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLDimension + * + * @return An array that store all possible SDLDimension + */ ++ (NSArray *)values; + +/** + * @abstract No GPS at all + * @return the dimension with value of *NO_FIX* + */ ++ (SDLDimension *)NO_FIX; + +/** + * @abstract Longitude and latitude of the GPS + * @return the dimension with value of *2D* + */ ++ (SDLDimension *)_2D; + +/** + * @abstract Longitude and latitude and altitude of the GPS + * @return the dimension with value of *3D* + */ ++ (SDLDimension *)_3D; + +@end diff --git a/SmartDeviceLink/SDLDimension.m b/SmartDeviceLink/SDLDimension.m new file mode 100644 index 000000000..81e0114fc --- /dev/null +++ b/SmartDeviceLink/SDLDimension.m @@ -0,0 +1,56 @@ +// SDLDimension.m +// + + +#import "SDLDimension.h" + +SDLDimension *SDLDimension_NO_FIX = nil; +SDLDimension *SDLDimension_2D = nil; +SDLDimension *SDLDimension_3D = nil; + +NSArray *SDLDimension_values = nil; + +@implementation SDLDimension + ++ (SDLDimension *)valueOf:(NSString *)value { + for (SDLDimension *item in SDLDimension.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLDimension_values == nil) { + SDLDimension_values = @[ + SDLDimension.NO_FIX, + SDLDimension._2D, + SDLDimension._3D, + ]; + } + return SDLDimension_values; +} + ++ (SDLDimension *)NO_FIX { + if (SDLDimension_NO_FIX == nil) { + SDLDimension_NO_FIX = [[SDLDimension alloc] initWithValue:@"NO_FIX"]; + } + return SDLDimension_NO_FIX; +} + ++ (SDLDimension *)_2D { + if (SDLDimension_2D == nil) { + SDLDimension_2D = [[SDLDimension alloc] initWithValue:@"2D"]; + } + return SDLDimension_2D; +} + ++ (SDLDimension *)_3D { + if (SDLDimension_3D == nil) { + SDLDimension_3D = [[SDLDimension alloc] initWithValue:@"3D"]; + } + return SDLDimension_3D; +} + +@end diff --git a/SmartDeviceLink/SDLDisplayCapabilities.h b/SmartDeviceLink/SDLDisplayCapabilities.h new file mode 100644 index 000000000..57ebd6719 --- /dev/null +++ b/SmartDeviceLink/SDLDisplayCapabilities.h @@ -0,0 +1,100 @@ +// SDLDisplayCapabilities.h +// + +#import "SDLRPCMessage.h" + +@class SDLDisplayType; +@class SDLScreenParams; + + +/** + * Contains information about the display for the SDL system to which the application is currently connected. + * + * @since SDL 1.0 + */ +@interface SDLDisplayCapabilities : SDLRPCStruct { +} + +/** + * Constructs a newly allocated SDLDisplayCapabilities object + */ +- (instancetype)init; + +/** + * Constructs a newly allocated SDLDisplayCapabilities object indicated by the dictionary parameter + * + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract The type of display + * + * Required + */ +@property (strong) SDLDisplayType *displayType; + +/** + * @abstract An array of SDLTextField structures, each of which describes a field in the HMI which the application can write to using operations such as *SDLShow*, *SDLSetMediaClockTimer*, etc. + * + * @discussion This array of SDLTextField structures identify all the text fields to which the application can write on the current display (identified by SDLDisplayType). + * + * @see SDLTextField + * + * Required, Array of SDLTextField, 1 - 100 objects + */ +@property (strong) NSMutableArray *textFields; + +/** + * @abstract An array of SDLImageField elements + * + * @discussion A set of all fields that support images. + * + * @see SDLImageField + * + * Optional, Array of SDLImageField, 1 - 100 objects + */ +@property (strong) NSMutableArray *imageFields; + +/** + * @abstract An array of SDLMediaClockFormat elements, defining the valid string formats used in specifying the contents of the media clock field + * + * @see SDLMediaClockFormat + * + * Required, Array of SDLMediaClockFormats, 0 - 100 objects + */ +@property (strong) NSMutableArray *mediaClockFormats; + +/** + * @abstract The display's persistent screen supports. + * + * @since SDL 2.0 + * + * Required, Boolean + */ +@property (strong) NSNumber *graphicSupported; + +/** + * @abstract Number of presets the screen supports + * + * @discussion The number of on-screen custom presets available (if any) + * + * Optional, Array of String, max string size 100, 0 - 100 objects + */ +@property (strong) NSMutableArray *templatesAvailable; + +/** + * @abstract A set of all parameters related to a prescribed screen area (e.g. for video / touch input) + * + * Optional + */ +@property (strong) SDLScreenParams *screenParams; + +/** + * @abstract The number of on-screen custom presets available (if any); otherwise omitted + * + * Optional, Integer 1 - 100 + */ +@property (strong) NSNumber *numCustomPresetsAvailable; + +@end diff --git a/SmartDeviceLink/SDLDisplayCapabilities.m b/SmartDeviceLink/SDLDisplayCapabilities.m new file mode 100644 index 000000000..07ae53d62 --- /dev/null +++ b/SmartDeviceLink/SDLDisplayCapabilities.m @@ -0,0 +1,161 @@ +// SDLDisplayCapabilities.m +// + +#import "SDLDisplayCapabilities.h" + +#import "SDLDisplayType.h" +#import "SDLImageField.h" +#import "SDLMediaClockFormat.h" +#import "SDLNames.h" +#import "SDLScreenParams.h" +#import "SDLTextField.h" + + +@implementation SDLDisplayCapabilities + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setDisplayType:(SDLDisplayType *)displayType { + if (displayType != nil) { + [store setObject:displayType forKey:NAMES_displayType]; + } else { + [store removeObjectForKey:NAMES_displayType]; + } +} + +- (SDLDisplayType *)displayType { + NSObject *obj = [store objectForKey:NAMES_displayType]; + if (obj == nil || [obj isKindOfClass:SDLDisplayType.class]) { + return (SDLDisplayType *)obj; + } else { + return [SDLDisplayType valueOf:(NSString *)obj]; + } +} + +- (void)setTextFields:(NSMutableArray *)textFields { + if (textFields != nil) { + [store setObject:textFields forKey:NAMES_textFields]; + } else { + [store removeObjectForKey:NAMES_textFields]; + } +} + +- (NSMutableArray *)textFields { + NSMutableArray *array = [store objectForKey:NAMES_textFields]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLTextField.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLTextField alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +- (void)setImageFields:(NSMutableArray *)imageFields { + if (imageFields != nil) { + [store setObject:imageFields forKey:NAMES_imageFields]; + } else { + [store removeObjectForKey:NAMES_imageFields]; + } +} + +- (NSMutableArray *)imageFields { + NSMutableArray *array = [store objectForKey:NAMES_imageFields]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLImageField.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLImageField alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +- (void)setMediaClockFormats:(NSMutableArray *)mediaClockFormats { + if (mediaClockFormats != nil) { + [store setObject:mediaClockFormats forKey:NAMES_mediaClockFormats]; + } else { + [store removeObjectForKey:NAMES_mediaClockFormats]; + } +} + +- (NSMutableArray *)mediaClockFormats { + NSMutableArray *array = [store objectForKey:NAMES_mediaClockFormats]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLMediaClockFormat.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSString *enumString in array) { + [newList addObject:[SDLMediaClockFormat valueOf:enumString]]; + } + return newList; + } +} + +- (void)setGraphicSupported:(NSNumber *)graphicSupported { + if (graphicSupported != nil) { + [store setObject:graphicSupported forKey:NAMES_graphicSupported]; + } else { + [store removeObjectForKey:NAMES_graphicSupported]; + } +} + +- (NSNumber *)graphicSupported { + return [store objectForKey:NAMES_graphicSupported]; +} + +- (void)setTemplatesAvailable:(NSMutableArray *)templatesAvailable { + if (templatesAvailable != nil) { + [store setObject:templatesAvailable forKey:NAMES_templatesAvailable]; + } else { + [store removeObjectForKey:NAMES_templatesAvailable]; + } +} + +- (NSMutableArray *)templatesAvailable { + return [store objectForKey:NAMES_templatesAvailable]; +} + +- (void)setScreenParams:(SDLScreenParams *)screenParams { + if (screenParams != nil) { + [store setObject:screenParams forKey:NAMES_screenParams]; + } else { + [store removeObjectForKey:NAMES_screenParams]; + } +} + +- (SDLScreenParams *)screenParams { + NSObject *obj = [store objectForKey:NAMES_screenParams]; + if (obj == nil || [obj isKindOfClass:SDLScreenParams.class]) { + return (SDLScreenParams *)obj; + } else { + return [[SDLScreenParams alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setNumCustomPresetsAvailable:(NSNumber *)numCustomPresetsAvailable { + if (numCustomPresetsAvailable != nil) { + [store setObject:numCustomPresetsAvailable forKey:NAMES_numCustomPresetsAvailable]; + } else { + [store removeObjectForKey:NAMES_numCustomPresetsAvailable]; + } +} + +- (NSNumber *)numCustomPresetsAvailable { + return [store objectForKey:NAMES_numCustomPresetsAvailable]; +} + +@end diff --git a/SmartDeviceLink/SDLDisplayType.h b/SmartDeviceLink/SDLDisplayType.h new file mode 100644 index 000000000..3bb2f2b9a --- /dev/null +++ b/SmartDeviceLink/SDLDisplayType.h @@ -0,0 +1,61 @@ +// SDLDisplayType.h +// + + +#import "SDLEnum.h" + +/** + * Identifies the various display types used by SDL. + * + * @since SDL 1.0 + */ +@interface SDLDisplayType : SDLEnum { +} + +/** + * Convert String to SDLDisplayType + * + * @param value The value of the string to get an object for + * + * @return SDLDisplayType + */ ++ (SDLDisplayType *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLDisplayType + * + * @return an array that store all possible SDLDisplayType + */ ++ (NSArray *)values; + +/** + * @abstract This display type provides a 2-line x 20 character "dot matrix" display. + * + * @return SDLDisplayType with value of *CID* + */ ++ (SDLDisplayType *)CID; + ++ (SDLDisplayType *)TYPE2; + ++ (SDLDisplayType *)TYPE5; + +/** + * @abstract This display type provides an 8 inch touchscreen display. + * + * @return SDLDisplayType with value of *NGN* + */ ++ (SDLDisplayType *)NGN; + ++ (SDLDisplayType *)GEN2_8_DMA; + ++ (SDLDisplayType *)GEN2_6_DMA; + ++ (SDLDisplayType *)MFD3; + ++ (SDLDisplayType *)MFD4; + ++ (SDLDisplayType *)MFD5; + ++ (SDLDisplayType *)GEN3_8_INCH; + +@end diff --git a/SmartDeviceLink/SDLDisplayType.m b/SmartDeviceLink/SDLDisplayType.m new file mode 100644 index 000000000..8059aa54b --- /dev/null +++ b/SmartDeviceLink/SDLDisplayType.m @@ -0,0 +1,119 @@ +// SDLDisplayType.m +// + + +#import "SDLDisplayType.h" + +SDLDisplayType *SDLDisplayType_CID = nil; +SDLDisplayType *SDLDisplayType_TYPE2 = nil; +SDLDisplayType *SDLDisplayType_TYPE5 = nil; +SDLDisplayType *SDLDisplayType_NGN = nil; +SDLDisplayType *SDLDisplayType_GEN2_8_DMA = nil; +SDLDisplayType *SDLDisplayType_GEN2_6_DMA = nil; +SDLDisplayType *SDLDisplayType_MFD3 = nil; +SDLDisplayType *SDLDisplayType_MFD4 = nil; +SDLDisplayType *SDLDisplayType_MFD5 = nil; +SDLDisplayType *SDLDisplayType_GEN3_8_INCH = nil; + +NSArray *SDLDisplayType_values = nil; + +@implementation SDLDisplayType + ++ (SDLDisplayType *)valueOf:(NSString *)value { + for (SDLDisplayType *item in SDLDisplayType.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLDisplayType_values == nil) { + SDLDisplayType_values = @[ + SDLDisplayType.CID, + SDLDisplayType.TYPE2, + SDLDisplayType.TYPE5, + SDLDisplayType.NGN, + SDLDisplayType.GEN2_8_DMA, + SDLDisplayType.GEN2_6_DMA, + SDLDisplayType.MFD3, + SDLDisplayType.MFD4, + SDLDisplayType.MFD5, + SDLDisplayType.GEN3_8_INCH, + ]; + } + return SDLDisplayType_values; +} + ++ (SDLDisplayType *)CID { + if (SDLDisplayType_CID == nil) { + SDLDisplayType_CID = [[SDLDisplayType alloc] initWithValue:@"CID"]; + } + return SDLDisplayType_CID; +} + ++ (SDLDisplayType *)TYPE2 { + if (SDLDisplayType_TYPE2 == nil) { + SDLDisplayType_TYPE2 = [[SDLDisplayType alloc] initWithValue:@"TYPE2"]; + } + return SDLDisplayType_TYPE2; +} + ++ (SDLDisplayType *)TYPE5 { + if (SDLDisplayType_TYPE5 == nil) { + SDLDisplayType_TYPE5 = [[SDLDisplayType alloc] initWithValue:@"TYPE5"]; + } + return SDLDisplayType_TYPE5; +} + ++ (SDLDisplayType *)NGN { + if (SDLDisplayType_NGN == nil) { + SDLDisplayType_NGN = [[SDLDisplayType alloc] initWithValue:@"NGN"]; + } + return SDLDisplayType_NGN; +} + ++ (SDLDisplayType *)GEN2_8_DMA { + if (SDLDisplayType_GEN2_8_DMA == nil) { + SDLDisplayType_GEN2_8_DMA = [[SDLDisplayType alloc] initWithValue:@"GEN2_8_DMA"]; + } + return SDLDisplayType_GEN2_8_DMA; +} + ++ (SDLDisplayType *)GEN2_6_DMA { + if (SDLDisplayType_GEN2_6_DMA == nil) { + SDLDisplayType_GEN2_6_DMA = [[SDLDisplayType alloc] initWithValue:@"GEN2_6_DMA"]; + } + return SDLDisplayType_GEN2_6_DMA; +} + ++ (SDLDisplayType *)MFD3 { + if (SDLDisplayType_MFD3 == nil) { + SDLDisplayType_MFD3 = [[SDLDisplayType alloc] initWithValue:@"MFD3"]; + } + return SDLDisplayType_MFD3; +} + ++ (SDLDisplayType *)MFD4 { + if (SDLDisplayType_MFD4 == nil) { + SDLDisplayType_MFD4 = [[SDLDisplayType alloc] initWithValue:@"MFD4"]; + } + return SDLDisplayType_MFD4; +} + ++ (SDLDisplayType *)MFD5 { + if (SDLDisplayType_MFD5 == nil) { + SDLDisplayType_MFD5 = [[SDLDisplayType alloc] initWithValue:@"MFD5"]; + } + return SDLDisplayType_MFD5; +} + ++ (SDLDisplayType *)GEN3_8_INCH { + if (SDLDisplayType_GEN3_8_INCH == nil) { + SDLDisplayType_GEN3_8_INCH = [[SDLDisplayType alloc] initWithValue:@"GEN3_8-INCH"]; + } + return SDLDisplayType_GEN3_8_INCH; +} + +@end diff --git a/SmartDeviceLink/SDLDriverDistractionState.h b/SmartDeviceLink/SDLDriverDistractionState.h new file mode 100644 index 000000000..7143d09d2 --- /dev/null +++ b/SmartDeviceLink/SDLDriverDistractionState.h @@ -0,0 +1,45 @@ +// SDLDriverDistractionState.h +// + + +#import "SDLEnum.h" + +/** + * Enumeration that describes possible states of driver distraction. + * + * @since SDL 1.0 + */ +@interface SDLDriverDistractionState : SDLEnum { +} + +/** + * Convert String to SDLDisplayType + * + * @param value The value of the string to get an object for + * + * @return SDLDisplayType + */ ++ (SDLDriverDistractionState *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLDriverDistractionState + * + * @return an array that store all possible SDLDriverDistractionState + */ ++ (NSArray *)values; + +/** + * @abstract Driver distraction rules are in effect. + * + * @return a SDLDriverDistractionState with value of *DD_ON* + */ ++ (SDLDriverDistractionState *)DD_ON; + +/** + * @abstract Driver distraction rules are NOT in effect. + * + * @return a SDLDriverDistractionState with value of *DD_OFF* + */ ++ (SDLDriverDistractionState *)DD_OFF; + +@end diff --git a/SmartDeviceLink/SDLDriverDistractionState.m b/SmartDeviceLink/SDLDriverDistractionState.m new file mode 100644 index 000000000..c9a6d8714 --- /dev/null +++ b/SmartDeviceLink/SDLDriverDistractionState.m @@ -0,0 +1,47 @@ +// SDLDriverDistractionState.m +// + + +#import "SDLDriverDistractionState.h" + +SDLDriverDistractionState *SDLDriverDistractionState_DD_ON = nil; +SDLDriverDistractionState *SDLDriverDistractionState_DD_OFF = nil; + +NSArray *SDLDriverDistractionState_values = nil; + +@implementation SDLDriverDistractionState + ++ (SDLDriverDistractionState *)valueOf:(NSString *)value { + for (SDLDriverDistractionState *item in SDLDriverDistractionState.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLDriverDistractionState_values == nil) { + SDLDriverDistractionState_values = @[ + SDLDriverDistractionState.DD_ON, + SDLDriverDistractionState.DD_OFF, + ]; + } + return SDLDriverDistractionState_values; +} + ++ (SDLDriverDistractionState *)DD_ON { + if (SDLDriverDistractionState_DD_ON == nil) { + SDLDriverDistractionState_DD_ON = [[SDLDriverDistractionState alloc] initWithValue:@"DD_ON"]; + } + return SDLDriverDistractionState_DD_ON; +} + ++ (SDLDriverDistractionState *)DD_OFF { + if (SDLDriverDistractionState_DD_OFF == nil) { + SDLDriverDistractionState_DD_OFF = [[SDLDriverDistractionState alloc] initWithValue:@"DD_OFF"]; + } + return SDLDriverDistractionState_DD_OFF; +} + +@end diff --git a/SmartDeviceLink/SDLECallConfirmationStatus.h b/SmartDeviceLink/SDLECallConfirmationStatus.h new file mode 100644 index 000000000..46fa78de6 --- /dev/null +++ b/SmartDeviceLink/SDLECallConfirmationStatus.h @@ -0,0 +1,52 @@ +// SDLECallConfirmationStatus.h +// + + +#import "SDLEnum.h" + +/** Reflects the status of the eCall Notification. + *<b>Since</b> SmartDeviceLink 2.0 + <p> + */ +@interface SDLECallConfirmationStatus : SDLEnum { +} + ++ (SDLECallConfirmationStatus *)valueOf:(NSString *)value; ++ (NSArray *)values; + +/** No E-Call signal triggered. + */ + ++ (SDLECallConfirmationStatus *)NORMAL; + +/** An E-Call is being in progress. + */ + ++ (SDLECallConfirmationStatus *)CALL_IN_PROGRESS; + +/** CALL_CANCELLED An E-Call was cancelled by the user. + */ + ++ (SDLECallConfirmationStatus *)CALL_CANCELLED; + +/** The E-Call sequence is completed. + */ + ++ (SDLECallConfirmationStatus *)CALL_COMPLETED; + +/** An E-Call could not be connected. + */ + ++ (SDLECallConfirmationStatus *)CALL_UNSUCCESSFUL; + +/** E-Call is not configured on this vehicle. + */ + ++ (SDLECallConfirmationStatus *)ECALL_CONFIGURED_OFF; + +/** E-Call is considered to be complete without Emergency Operator contact. + */ + ++ (SDLECallConfirmationStatus *)CALL_COMPLETE_DTMF_TIMEOUT; + +@end diff --git a/SmartDeviceLink/SDLECallConfirmationStatus.m b/SmartDeviceLink/SDLECallConfirmationStatus.m new file mode 100644 index 000000000..aae11a791 --- /dev/null +++ b/SmartDeviceLink/SDLECallConfirmationStatus.m @@ -0,0 +1,92 @@ +// SDLECallConfirmationStatus.m +// + + +#import "SDLECallConfirmationStatus.h" + +SDLECallConfirmationStatus *SDLECallConfirmationStatus_NORMAL = nil; +SDLECallConfirmationStatus *SDLECallConfirmationStatus_CALL_IN_PROGRESS = nil; +SDLECallConfirmationStatus *SDLECallConfirmationStatus_CALL_CANCELLED = nil; +SDLECallConfirmationStatus *SDLECallConfirmationStatus_CALL_COMPLETED = nil; +SDLECallConfirmationStatus *SDLECallConfirmationStatus_CALL_UNSUCCESSFUL = nil; +SDLECallConfirmationStatus *SDLECallConfirmationStatus_ECALL_CONFIGURED_OFF = nil; +SDLECallConfirmationStatus *SDLECallConfirmationStatus_CALL_COMPLETE_DTMF_TIMEOUT = nil; + +NSArray *SDLECallConfirmationStatus_values = nil; + +@implementation SDLECallConfirmationStatus + ++ (SDLECallConfirmationStatus *)valueOf:(NSString *)value { + for (SDLECallConfirmationStatus *item in SDLECallConfirmationStatus.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLECallConfirmationStatus_values == nil) { + SDLECallConfirmationStatus_values = @[ + SDLECallConfirmationStatus.NORMAL, + SDLECallConfirmationStatus.CALL_IN_PROGRESS, + SDLECallConfirmationStatus.CALL_CANCELLED, + SDLECallConfirmationStatus.CALL_COMPLETED, + SDLECallConfirmationStatus.CALL_UNSUCCESSFUL, + SDLECallConfirmationStatus.ECALL_CONFIGURED_OFF, + SDLECallConfirmationStatus.CALL_COMPLETE_DTMF_TIMEOUT, + ]; + } + return SDLECallConfirmationStatus_values; +} + ++ (SDLECallConfirmationStatus *)NORMAL { + if (SDLECallConfirmationStatus_NORMAL == nil) { + SDLECallConfirmationStatus_NORMAL = [[SDLECallConfirmationStatus alloc] initWithValue:@"NORMAL"]; + } + return SDLECallConfirmationStatus_NORMAL; +} + ++ (SDLECallConfirmationStatus *)CALL_IN_PROGRESS { + if (SDLECallConfirmationStatus_CALL_IN_PROGRESS == nil) { + SDLECallConfirmationStatus_CALL_IN_PROGRESS = [[SDLECallConfirmationStatus alloc] initWithValue:@"CALL_IN_PROGRESS"]; + } + return SDLECallConfirmationStatus_CALL_IN_PROGRESS; +} + ++ (SDLECallConfirmationStatus *)CALL_CANCELLED { + if (SDLECallConfirmationStatus_CALL_CANCELLED == nil) { + SDLECallConfirmationStatus_CALL_CANCELLED = [[SDLECallConfirmationStatus alloc] initWithValue:@"CALL_CANCELLED"]; + } + return SDLECallConfirmationStatus_CALL_CANCELLED; +} + ++ (SDLECallConfirmationStatus *)CALL_COMPLETED { + if (SDLECallConfirmationStatus_CALL_COMPLETED == nil) { + SDLECallConfirmationStatus_CALL_COMPLETED = [[SDLECallConfirmationStatus alloc] initWithValue:@"CALL_COMPLETED"]; + } + return SDLECallConfirmationStatus_CALL_COMPLETED; +} + ++ (SDLECallConfirmationStatus *)CALL_UNSUCCESSFUL { + if (SDLECallConfirmationStatus_CALL_UNSUCCESSFUL == nil) { + SDLECallConfirmationStatus_CALL_UNSUCCESSFUL = [[SDLECallConfirmationStatus alloc] initWithValue:@"CALL_UNSUCCESSFUL"]; + } + return SDLECallConfirmationStatus_CALL_UNSUCCESSFUL; +} + ++ (SDLECallConfirmationStatus *)ECALL_CONFIGURED_OFF { + if (SDLECallConfirmationStatus_ECALL_CONFIGURED_OFF == nil) { + SDLECallConfirmationStatus_ECALL_CONFIGURED_OFF = [[SDLECallConfirmationStatus alloc] initWithValue:@"ECALL_CONFIGURED_OFF"]; + } + return SDLECallConfirmationStatus_ECALL_CONFIGURED_OFF; +} + ++ (SDLECallConfirmationStatus *)CALL_COMPLETE_DTMF_TIMEOUT { + if (SDLECallConfirmationStatus_CALL_COMPLETE_DTMF_TIMEOUT == nil) { + SDLECallConfirmationStatus_CALL_COMPLETE_DTMF_TIMEOUT = [[SDLECallConfirmationStatus alloc] initWithValue:@"CALL_COMPLETE_DTMF_TIMEOUT"]; + } + return SDLECallConfirmationStatus_CALL_COMPLETE_DTMF_TIMEOUT; +} + +@end diff --git a/SmartDeviceLink/SDLECallInfo.h b/SmartDeviceLink/SDLECallInfo.h new file mode 100644 index 000000000..932cf056a --- /dev/null +++ b/SmartDeviceLink/SDLECallInfo.h @@ -0,0 +1,20 @@ +// SDLECallInfo.h +// + +#import "SDLRPCMessage.h" + +@class SDLVehicleDataNotificationStatus; +@class SDLECallConfirmationStatus; + + +@interface SDLECallInfo : SDLRPCStruct { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) SDLVehicleDataNotificationStatus *eCallNotificationStatus; +@property (strong) SDLVehicleDataNotificationStatus *auxECallNotificationStatus; +@property (strong) SDLECallConfirmationStatus *eCallConfirmationStatus; + +@end diff --git a/SmartDeviceLink/SDLECallInfo.m b/SmartDeviceLink/SDLECallInfo.m new file mode 100644 index 000000000..44046fcd0 --- /dev/null +++ b/SmartDeviceLink/SDLECallInfo.m @@ -0,0 +1,76 @@ +// SDLECallInfo.m +// + +#import "SDLECallInfo.h" + +#import "SDLECallConfirmationStatus.h" +#import "SDLNames.h" +#import "SDLVehicleDataNotificationStatus.h" + + +@implementation SDLECallInfo + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setECallNotificationStatus:(SDLVehicleDataNotificationStatus *)eCallNotificationStatus { + if (eCallNotificationStatus != nil) { + [store setObject:eCallNotificationStatus forKey:NAMES_eCallNotificationStatus]; + } else { + [store removeObjectForKey:NAMES_eCallNotificationStatus]; + } +} + +- (SDLVehicleDataNotificationStatus *)eCallNotificationStatus { + NSObject *obj = [store objectForKey:NAMES_eCallNotificationStatus]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataNotificationStatus.class]) { + return (SDLVehicleDataNotificationStatus *)obj; + } else { + return [SDLVehicleDataNotificationStatus valueOf:(NSString *)obj]; + } +} + +- (void)setAuxECallNotificationStatus:(SDLVehicleDataNotificationStatus *)auxECallNotificationStatus { + if (auxECallNotificationStatus != nil) { + [store setObject:auxECallNotificationStatus forKey:NAMES_auxECallNotificationStatus]; + } else { + [store removeObjectForKey:NAMES_auxECallNotificationStatus]; + } +} + +- (SDLVehicleDataNotificationStatus *)auxECallNotificationStatus { + NSObject *obj = [store objectForKey:NAMES_auxECallNotificationStatus]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataNotificationStatus.class]) { + return (SDLVehicleDataNotificationStatus *)obj; + } else { + return [SDLVehicleDataNotificationStatus valueOf:(NSString *)obj]; + } +} + +- (void)setECallConfirmationStatus:(SDLECallConfirmationStatus *)eCallConfirmationStatus { + if (eCallConfirmationStatus != nil) { + [store setObject:eCallConfirmationStatus forKey:NAMES_eCallConfirmationStatus]; + } else { + [store removeObjectForKey:NAMES_eCallConfirmationStatus]; + } +} + +- (SDLECallConfirmationStatus *)eCallConfirmationStatus { + NSObject *obj = [store objectForKey:NAMES_eCallConfirmationStatus]; + if (obj == nil || [obj isKindOfClass:SDLECallConfirmationStatus.class]) { + return (SDLECallConfirmationStatus *)obj; + } else { + return [SDLECallConfirmationStatus valueOf:(NSString *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLEmergencyEvent.h b/SmartDeviceLink/SDLEmergencyEvent.h new file mode 100644 index 000000000..6dd0c410d --- /dev/null +++ b/SmartDeviceLink/SDLEmergencyEvent.h @@ -0,0 +1,23 @@ +// SDLEmergencyEvent.h +// + +#import "SDLRPCMessage.h" + +@class SDLEmergencyEventType; +@class SDLFuelCutoffStatus; +@class SDLVehicleDataEventStatus; + + +@interface SDLEmergencyEvent : SDLRPCStruct { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) SDLEmergencyEventType *emergencyEventType; +@property (strong) SDLFuelCutoffStatus *fuelCutoffStatus; +@property (strong) SDLVehicleDataEventStatus *rolloverEvent; +@property (strong) NSNumber *maximumChangeVelocity; +@property (strong) SDLVehicleDataEventStatus *multipleEvents; + +@end diff --git a/SmartDeviceLink/SDLEmergencyEvent.m b/SmartDeviceLink/SDLEmergencyEvent.m new file mode 100644 index 000000000..76fca57e2 --- /dev/null +++ b/SmartDeviceLink/SDLEmergencyEvent.m @@ -0,0 +1,106 @@ +// SDLEmergencyEvent.m +// + +#import "SDLEmergencyEvent.h" + +#import "SDLEmergencyEventType.h" +#import "SDLFuelCutoffStatus.h" +#import "SDLNames.h" +#import "SDLVehicleDataEventStatus.h" + + +@implementation SDLEmergencyEvent + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setEmergencyEventType:(SDLEmergencyEventType *)emergencyEventType { + if (emergencyEventType != nil) { + [store setObject:emergencyEventType forKey:NAMES_emergencyEventType]; + } else { + [store removeObjectForKey:NAMES_emergencyEventType]; + } +} + +- (SDLEmergencyEventType *)emergencyEventType { + NSObject *obj = [store objectForKey:NAMES_emergencyEventType]; + if (obj == nil || [obj isKindOfClass:SDLEmergencyEventType.class]) { + return (SDLEmergencyEventType *)obj; + } else { + return [SDLEmergencyEventType valueOf:(NSString *)obj]; + } +} + +- (void)setFuelCutoffStatus:(SDLFuelCutoffStatus *)fuelCutoffStatus { + if (fuelCutoffStatus != nil) { + [store setObject:fuelCutoffStatus forKey:NAMES_fuelCutoffStatus]; + } else { + [store removeObjectForKey:NAMES_fuelCutoffStatus]; + } +} + +- (SDLFuelCutoffStatus *)fuelCutoffStatus { + NSObject *obj = [store objectForKey:NAMES_fuelCutoffStatus]; + if (obj == nil || [obj isKindOfClass:SDLFuelCutoffStatus.class]) { + return (SDLFuelCutoffStatus *)obj; + } else { + return [SDLFuelCutoffStatus valueOf:(NSString *)obj]; + } +} + +- (void)setRolloverEvent:(SDLVehicleDataEventStatus *)rolloverEvent { + if (rolloverEvent != nil) { + [store setObject:rolloverEvent forKey:NAMES_rolloverEvent]; + } else { + [store removeObjectForKey:NAMES_rolloverEvent]; + } +} + +- (SDLVehicleDataEventStatus *)rolloverEvent { + NSObject *obj = [store objectForKey:NAMES_rolloverEvent]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +- (void)setMaximumChangeVelocity:(NSNumber *)maximumChangeVelocity { + if (maximumChangeVelocity != nil) { + [store setObject:maximumChangeVelocity forKey:NAMES_maximumChangeVelocity]; + } else { + [store removeObjectForKey:NAMES_maximumChangeVelocity]; + } +} + +- (NSNumber *)maximumChangeVelocity { + return [store objectForKey:NAMES_maximumChangeVelocity]; +} + +- (void)setMultipleEvents:(SDLVehicleDataEventStatus *)multipleEvents { + if (multipleEvents != nil) { + [store setObject:multipleEvents forKey:NAMES_multipleEvents]; + } else { + [store removeObjectForKey:NAMES_multipleEvents]; + } +} + +- (SDLVehicleDataEventStatus *)multipleEvents { + NSObject *obj = [store objectForKey:NAMES_multipleEvents]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLEmergencyEventType.h b/SmartDeviceLink/SDLEmergencyEventType.h new file mode 100644 index 000000000..1e75b3ee0 --- /dev/null +++ b/SmartDeviceLink/SDLEmergencyEventType.h @@ -0,0 +1,53 @@ +// SDLEmergencyEventType.h +// + + +#import "SDLEnum.h" + +/** Reflects the emergency event status of the vehicle. + *<b> Since:</b> SmartDeviceLink 2.0 + *<p> + */ + +@interface SDLEmergencyEventType : SDLEnum { +} + ++ (SDLEmergencyEventType *)valueOf:(NSString *)value; ++ (NSArray *)values; + +/** No emergency event has happened. + */ + ++ (SDLEmergencyEventType *)NO_EVENT; + +/** Frontal collision has happened. + */ + ++ (SDLEmergencyEventType *)FRONTAL; + +/** Side collision has happened. + */ + ++ (SDLEmergencyEventType *)SIDE; + +/**Rear collision has happened. + */ + ++ (SDLEmergencyEventType *)REAR; + +/** A rollover event has happened. + */ + ++ (SDLEmergencyEventType *)ROLLOVER; + +/** The signal is not supported + */ + ++ (SDLEmergencyEventType *)NOT_SUPPORTED; + +/** Emergency status cannot be determined + */ + ++ (SDLEmergencyEventType *)FAULT; + +@end diff --git a/SmartDeviceLink/SDLEmergencyEventType.m b/SmartDeviceLink/SDLEmergencyEventType.m new file mode 100644 index 000000000..b07979d01 --- /dev/null +++ b/SmartDeviceLink/SDLEmergencyEventType.m @@ -0,0 +1,92 @@ +// SDLEmergencyEventType.m +// + + +#import "SDLEmergencyEventType.h" + +SDLEmergencyEventType *SDLEmergencyEventType_NO_EVENT = nil; +SDLEmergencyEventType *SDLEmergencyEventType_FRONTAL = nil; +SDLEmergencyEventType *SDLEmergencyEventType_SIDE = nil; +SDLEmergencyEventType *SDLEmergencyEventType_REAR = nil; +SDLEmergencyEventType *SDLEmergencyEventType_ROLLOVER = nil; +SDLEmergencyEventType *SDLEmergencyEventType_NOT_SUPPORTED = nil; +SDLEmergencyEventType *SDLEmergencyEventType_FAULT = nil; + +NSArray *SDLEmergencyEventType_values = nil; + +@implementation SDLEmergencyEventType + ++ (SDLEmergencyEventType *)valueOf:(NSString *)value { + for (SDLEmergencyEventType *item in SDLEmergencyEventType.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLEmergencyEventType_values == nil) { + SDLEmergencyEventType_values = @[ + SDLEmergencyEventType.NO_EVENT, + SDLEmergencyEventType.FRONTAL, + SDLEmergencyEventType.SIDE, + SDLEmergencyEventType.REAR, + SDLEmergencyEventType.ROLLOVER, + SDLEmergencyEventType.NOT_SUPPORTED, + SDLEmergencyEventType.FAULT, + ]; + } + return SDLEmergencyEventType_values; +} + ++ (SDLEmergencyEventType *)NO_EVENT { + if (SDLEmergencyEventType_NO_EVENT == nil) { + SDLEmergencyEventType_NO_EVENT = [[SDLEmergencyEventType alloc] initWithValue:@"NO_EVENT"]; + } + return SDLEmergencyEventType_NO_EVENT; +} + ++ (SDLEmergencyEventType *)FRONTAL { + if (SDLEmergencyEventType_FRONTAL == nil) { + SDLEmergencyEventType_FRONTAL = [[SDLEmergencyEventType alloc] initWithValue:@"FRONTAL"]; + } + return SDLEmergencyEventType_FRONTAL; +} + ++ (SDLEmergencyEventType *)SIDE { + if (SDLEmergencyEventType_SIDE == nil) { + SDLEmergencyEventType_SIDE = [[SDLEmergencyEventType alloc] initWithValue:@"SIDE"]; + } + return SDLEmergencyEventType_SIDE; +} + ++ (SDLEmergencyEventType *)REAR { + if (SDLEmergencyEventType_REAR == nil) { + SDLEmergencyEventType_REAR = [[SDLEmergencyEventType alloc] initWithValue:@"REAR"]; + } + return SDLEmergencyEventType_REAR; +} + ++ (SDLEmergencyEventType *)ROLLOVER { + if (SDLEmergencyEventType_ROLLOVER == nil) { + SDLEmergencyEventType_ROLLOVER = [[SDLEmergencyEventType alloc] initWithValue:@"ROLLOVER"]; + } + return SDLEmergencyEventType_ROLLOVER; +} + ++ (SDLEmergencyEventType *)NOT_SUPPORTED { + if (SDLEmergencyEventType_NOT_SUPPORTED == nil) { + SDLEmergencyEventType_NOT_SUPPORTED = [[SDLEmergencyEventType alloc] initWithValue:@"NOT_SUPPORTED"]; + } + return SDLEmergencyEventType_NOT_SUPPORTED; +} + ++ (SDLEmergencyEventType *)FAULT { + if (SDLEmergencyEventType_FAULT == nil) { + SDLEmergencyEventType_FAULT = [[SDLEmergencyEventType alloc] initWithValue:@"FAULT"]; + } + return SDLEmergencyEventType_FAULT; +} + +@end diff --git a/SmartDeviceLink/SDLEncodedSyncPData.h b/SmartDeviceLink/SDLEncodedSyncPData.h new file mode 100644 index 000000000..b3b0276b7 --- /dev/null +++ b/SmartDeviceLink/SDLEncodedSyncPData.h @@ -0,0 +1,15 @@ +// SDLEncodedSyncPData.h +// + + +#import "SDLRPCRequest.h" + +@interface SDLEncodedSyncPData : SDLRPCRequest { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) NSMutableArray *data; + +@end diff --git a/SmartDeviceLink/SDLEncodedSyncPData.m b/SmartDeviceLink/SDLEncodedSyncPData.m new file mode 100644 index 000000000..b44cb7b3e --- /dev/null +++ b/SmartDeviceLink/SDLEncodedSyncPData.m @@ -0,0 +1,35 @@ +// SDLEncodedSyncPData.m +// + + +#import "SDLEncodedSyncPData.h" + +#import "SDLNames.h" + +@implementation SDLEncodedSyncPData + +- (instancetype)init { + if (self = [super initWithName:NAMES_EncodedSyncPData]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setData:(NSMutableArray *)data { + if (data != nil) { + [parameters setObject:data forKey:NAMES_data]; + } else { + [parameters removeObjectForKey:NAMES_data]; + } +} + +- (NSMutableArray *)data { + return [parameters objectForKey:NAMES_data]; +} + +@end diff --git a/SmartDeviceLink/SDLEncodedSyncPDataResponse.h b/SmartDeviceLink/SDLEncodedSyncPDataResponse.h new file mode 100644 index 000000000..7d646ed23 --- /dev/null +++ b/SmartDeviceLink/SDLEncodedSyncPDataResponse.h @@ -0,0 +1,13 @@ +// SDLEncodedSyncPDataResponse.h +// + + +#import "SDLRPCResponse.h" + +@interface SDLEncodedSyncPDataResponse : SDLRPCResponse { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLEncodedSyncPDataResponse.m b/SmartDeviceLink/SDLEncodedSyncPDataResponse.m new file mode 100644 index 000000000..cf899a21b --- /dev/null +++ b/SmartDeviceLink/SDLEncodedSyncPDataResponse.m @@ -0,0 +1,23 @@ +// SDLEncodedSyncPDataResponse.m +// + + +#import "SDLEncodedSyncPDataResponse.h" + +#import "SDLNames.h" + +@implementation SDLEncodedSyncPDataResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_EncodedSyncPData]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLEncoder.h b/SmartDeviceLink/SDLEncoder.h new file mode 100644 index 000000000..911eb95d8 --- /dev/null +++ b/SmartDeviceLink/SDLEncoder.h @@ -0,0 +1,11 @@ +// SDLEncoder.h +// + + +#import <Foundation/Foundation.h> + +@protocol SDLEncoder <NSObject> + +- (NSData *)encodeDictionary:(NSDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLEndAudioPassThru.h b/SmartDeviceLink/SDLEndAudioPassThru.h new file mode 100644 index 000000000..fddde6c13 --- /dev/null +++ b/SmartDeviceLink/SDLEndAudioPassThru.h @@ -0,0 +1,33 @@ +// SDLEndAudioPassThru.h +// + + +#import "SDLRPCRequest.h" + +/** + * When this request is invoked, the audio capture stops + * <p> + * Function Group: AudioPassThru + * <p> + * <b>HMILevel needs to be FULL, LIMITED or BACKGROUND</b> + * </p> + * Since <b>SmartDeviceLink 2.0</b><br> + * see SDLPerformAudioPassThru + */ +@interface SDLEndAudioPassThru : SDLRPCRequest { +} + +/** + * Constructs a new SDLEndAudioPassThru object + */ +- (instancetype)init; +/** + * Constructs a new SDLEndAudioPassThru object indicated by the NSMutableDictionary + * parameter + * <p> + * + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLEndAudioPassThru.m b/SmartDeviceLink/SDLEndAudioPassThru.m new file mode 100644 index 000000000..576287170 --- /dev/null +++ b/SmartDeviceLink/SDLEndAudioPassThru.m @@ -0,0 +1,23 @@ +// SDLEndAudioPassThru.m +// + + +#import "SDLEndAudioPassThru.h" + +#import "SDLNames.h" + +@implementation SDLEndAudioPassThru + +- (instancetype)init { + if (self = [super initWithName:NAMES_EndAudioPassThru]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLEndAudioPassThruResponse.h b/SmartDeviceLink/SDLEndAudioPassThruResponse.h new file mode 100644 index 000000000..e464f5d32 --- /dev/null +++ b/SmartDeviceLink/SDLEndAudioPassThruResponse.h @@ -0,0 +1,18 @@ +// SDLEndAudioPassThruResponse.h +// + + +#import "SDLRPCResponse.h" + +/** + * SDLEndAudioPassThruResponse is sent, when SDLEndAudioPassThru has been called + * + * Since <b>SmartDeviceLink 2.0</b> + */ +@interface SDLEndAudioPassThruResponse : SDLRPCResponse { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLEndAudioPassThruResponse.m b/SmartDeviceLink/SDLEndAudioPassThruResponse.m new file mode 100644 index 000000000..73c3b6336 --- /dev/null +++ b/SmartDeviceLink/SDLEndAudioPassThruResponse.m @@ -0,0 +1,23 @@ +// SDLEndAudioPassThruResponse.m +// + + +#import "SDLEndAudioPassThruResponse.h" + +#import "SDLNames.h" + +@implementation SDLEndAudioPassThruResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_EndAudioPassThru]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLEnum.h b/SmartDeviceLink/SDLEnum.h new file mode 100644 index 000000000..bed0fffa3 --- /dev/null +++ b/SmartDeviceLink/SDLEnum.h @@ -0,0 +1,18 @@ +// SDLEnum.h +// + + +#import <Foundation/Foundation.h> + + +@interface SDLEnum : NSObject { + NSString *value; +} + +- (instancetype)initWithValue:(NSString *)value; + +- (BOOL)isEqualToEnum:(SDLEnum *)object; + +@property (strong, readonly) NSString *value; + +@end diff --git a/SmartDeviceLink/SDLEnum.m b/SmartDeviceLink/SDLEnum.m new file mode 100644 index 000000000..f5ca2db2e --- /dev/null +++ b/SmartDeviceLink/SDLEnum.m @@ -0,0 +1,52 @@ +// SDLEnum.m +// + + +#import "SDLEnum.h" + +@implementation SDLEnum + +@synthesize value; + +- (instancetype)initWithValue:(NSString *)aValue { + if (self = [super init]) { + value = aValue; + } + return self; +} + +- (NSString *)description { + return value; +} + +- (id)debugQuickLookObject { + return value; +} + +- (NSUInteger)hash { + return [self.value hash]; +} + +- (BOOL)isEqual:(id)object { + // Test pointer equality + if (self == object) { + return YES; + } + + // Test class equality, if not equal, value equality doesn't matter + if (![object isMemberOfClass:self.class]) { + return NO; + } + + return [self isEqualToEnum:object]; +} + +- (BOOL)isEqualToEnum:(SDLEnum *)object { + // Test value equality, if it's equal we're good + if ([self.value isEqualToString:object.value]) { + return YES; + } + + return NO; +} +@end diff --git a/SmartDeviceLink/SDLFileType.h b/SmartDeviceLink/SDLFileType.h new file mode 100644 index 000000000..eb4339868 --- /dev/null +++ b/SmartDeviceLink/SDLFileType.h @@ -0,0 +1,87 @@ +// SDLFileType.h +// + + +#import "SDLEnum.h" + +/** + * Enumeration listing possible file types. + * + * @since SDL 2.0 + */ +@interface SDLFileType : SDLEnum { +} + +/** + * @abstract Convert String to SDLFileType + * + * @param value String value to retrieve the object for + * + * @return SDLFileType + */ ++ (SDLFileType *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLFileType + * + * @return an array that store all possible SDLFileType + */ ++ (NSArray *)values; + +/** + * @abstract file type: Bitmap (BMP) + * + * @return SDLFileType with value of *GRAPHIC_BMP* + */ ++ (SDLFileType *)GRAPHIC_BMP; + +/** + * @abstract file type: JPEG + * + * @return SDLFileType with value of *GRAPHIC_JPEG* + */ ++ (SDLFileType *)GRAPHIC_JPEG; + +/** + * @abstract file type: PNG + * + * @return SDLFileType with value of *GRAPHIC_PNG* + */ ++ (SDLFileType *)GRAPHIC_PNG; + +/** + * @abstract file type: WAVE (WAV) + * + * @return SDLFileType with value of *AUDIO_WAVE* + */ ++ (SDLFileType *)AUDIO_WAVE; + +/** + * @abstract file type: MP3 + * + * @return SDLFileType with value of *AUDIO_MP3* + */ ++ (SDLFileType *)AUDIO_MP3; + +/** + * @abstract file type: AAC + * + * @return SDLFileType with value of *AUDIO_AAC* + */ ++ (SDLFileType *)AUDIO_AAC; + +/** + * @abstract file type: BINARY + * + * @return SDLFileType with value of *BINARY* + */ ++ (SDLFileType *)BINARY; + +/** + * @abstract file type: JSON + * + * @return SDLFileType with value of *JSON* + */ ++ (SDLFileType *)JSON; + +@end diff --git a/SmartDeviceLink/SDLFileType.m b/SmartDeviceLink/SDLFileType.m new file mode 100644 index 000000000..f47932e9e --- /dev/null +++ b/SmartDeviceLink/SDLFileType.m @@ -0,0 +1,101 @@ +// SDLFileType.m +// + + +#import "SDLFileType.h" + +SDLFileType *SDLFileType_GRAPHIC_BMP = nil; +SDLFileType *SDLFileType_GRAPHIC_JPEG = nil; +SDLFileType *SDLFileType_GRAPHIC_PNG = nil; +SDLFileType *SDLFileType_AUDIO_WAVE = nil; +SDLFileType *SDLFileType_AUDIO_MP3 = nil; +SDLFileType *SDLFileType_AUDIO_AAC = nil; +SDLFileType *SDLFileType_BINARY = nil; +SDLFileType *SDLFileType_JSON = nil; + +NSArray *SDLFileType_values = nil; + +@implementation SDLFileType + ++ (SDLFileType *)valueOf:(NSString *)value { + for (SDLFileType *item in SDLFileType.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLFileType_values == nil) { + SDLFileType_values = @[ + SDLFileType.GRAPHIC_BMP, + SDLFileType.GRAPHIC_JPEG, + SDLFileType.GRAPHIC_PNG, + SDLFileType.AUDIO_WAVE, + SDLFileType.AUDIO_MP3, + SDLFileType.AUDIO_AAC, + SDLFileType.BINARY, + SDLFileType.JSON, + ]; + } + return SDLFileType_values; +} + ++ (SDLFileType *)GRAPHIC_BMP { + if (SDLFileType_GRAPHIC_BMP == nil) { + SDLFileType_GRAPHIC_BMP = [[SDLFileType alloc] initWithValue:@"GRAPHIC_BMP"]; + } + return SDLFileType_GRAPHIC_BMP; +} + ++ (SDLFileType *)GRAPHIC_JPEG { + if (SDLFileType_GRAPHIC_JPEG == nil) { + SDLFileType_GRAPHIC_JPEG = [[SDLFileType alloc] initWithValue:@"GRAPHIC_JPEG"]; + } + return SDLFileType_GRAPHIC_JPEG; +} + ++ (SDLFileType *)GRAPHIC_PNG { + if (SDLFileType_GRAPHIC_PNG == nil) { + SDLFileType_GRAPHIC_PNG = [[SDLFileType alloc] initWithValue:@"GRAPHIC_PNG"]; + } + return SDLFileType_GRAPHIC_PNG; +} + ++ (SDLFileType *)AUDIO_WAVE { + if (SDLFileType_AUDIO_WAVE == nil) { + SDLFileType_AUDIO_WAVE = [[SDLFileType alloc] initWithValue:@"AUDIO_WAVE"]; + } + return SDLFileType_AUDIO_WAVE; +} + ++ (SDLFileType *)AUDIO_MP3 { + if (SDLFileType_AUDIO_MP3 == nil) { + SDLFileType_AUDIO_MP3 = [[SDLFileType alloc] initWithValue:@"AUDIO_MP3"]; + } + return SDLFileType_AUDIO_MP3; +} + ++ (SDLFileType *)AUDIO_AAC { + if (SDLFileType_AUDIO_AAC == nil) { + SDLFileType_AUDIO_AAC = [[SDLFileType alloc] initWithValue:@"AUDIO_AAC"]; + } + return SDLFileType_AUDIO_AAC; +} + ++ (SDLFileType *)BINARY { + if (SDLFileType_BINARY == nil) { + SDLFileType_BINARY = [[SDLFileType alloc] initWithValue:@"BINARY"]; + } + return SDLFileType_BINARY; +} + ++ (SDLFileType *)JSON { + if (SDLFileType_JSON == nil) { + SDLFileType_JSON = [[SDLFileType alloc] initWithValue:@"JSON"]; + } + return SDLFileType_JSON; +} + +@end diff --git a/SmartDeviceLink/SDLFuelCutoffStatus.h b/SmartDeviceLink/SDLFuelCutoffStatus.h new file mode 100644 index 000000000..df213ff07 --- /dev/null +++ b/SmartDeviceLink/SDLFuelCutoffStatus.h @@ -0,0 +1,50 @@ +// SDLFuelCutoffStatus.h +// + + +#import "SDLEnum.h" + +/** + * Reflects the status of the Restraints Control Module fuel pump cutoff. + * The fuel pump is cut off typically after the vehicle has had a collision. + * + * @since SDL 2.0 + */ +@interface SDLFuelCutoffStatus : SDLEnum { +} + +/** + * @abstract Convert String to SDLFuelCutoffStatus + * + * @param value String value to retrieve the object for + * + * @return SDLFuelCutoffStatus + */ ++ (SDLFuelCutoffStatus *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLFuelCutoffStatus + * + * @return an array that stores all possible SDLFuelCutoffStatus + */ ++ (NSArray *)values; + +/** + * @abstract Fuel is cut off + * @return the fuel cutoff status: *TERMINATE_FUEL* + */ ++ (SDLFuelCutoffStatus *)TERMINATE_FUEL; + +/** + * @abstract Fuel is not cut off + * @return the fuel cutoff status: *NORMAL_OPERATION* + */ ++ (SDLFuelCutoffStatus *)NORMAL_OPERATION; + +/** + * @abstract Status of the fuel pump cannot be determined + * @return the fuel cutoff status: *FAULT* + */ ++ (SDLFuelCutoffStatus *)FAULT; + +@end diff --git a/SmartDeviceLink/SDLFuelCutoffStatus.m b/SmartDeviceLink/SDLFuelCutoffStatus.m new file mode 100644 index 000000000..3bbd92bb8 --- /dev/null +++ b/SmartDeviceLink/SDLFuelCutoffStatus.m @@ -0,0 +1,56 @@ +// SDLFuelCutoffStatus.m +// + + +#import "SDLFuelCutoffStatus.h" + +SDLFuelCutoffStatus *SDLFuelCutoffStatus_TERMINATE_FUEL = nil; +SDLFuelCutoffStatus *SDLFuelCutoffStatus_NORMAL_OPERATION = nil; +SDLFuelCutoffStatus *SDLFuelCutoffStatus_FAULT = nil; + +NSArray *SDLFuelCutoffStatus_values = nil; + +@implementation SDLFuelCutoffStatus + ++ (SDLFuelCutoffStatus *)valueOf:(NSString *)value { + for (SDLFuelCutoffStatus *item in SDLFuelCutoffStatus.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLFuelCutoffStatus_values == nil) { + SDLFuelCutoffStatus_values = @[ + SDLFuelCutoffStatus.TERMINATE_FUEL, + SDLFuelCutoffStatus.NORMAL_OPERATION, + SDLFuelCutoffStatus.FAULT, + ]; + } + return SDLFuelCutoffStatus_values; +} + ++ (SDLFuelCutoffStatus *)TERMINATE_FUEL { + if (SDLFuelCutoffStatus_TERMINATE_FUEL == nil) { + SDLFuelCutoffStatus_TERMINATE_FUEL = [[SDLFuelCutoffStatus alloc] initWithValue:@"TERMINATE_FUEL"]; + } + return SDLFuelCutoffStatus_TERMINATE_FUEL; +} + ++ (SDLFuelCutoffStatus *)NORMAL_OPERATION { + if (SDLFuelCutoffStatus_NORMAL_OPERATION == nil) { + SDLFuelCutoffStatus_NORMAL_OPERATION = [[SDLFuelCutoffStatus alloc] initWithValue:@"NORMAL_OPERATION"]; + } + return SDLFuelCutoffStatus_NORMAL_OPERATION; +} + ++ (SDLFuelCutoffStatus *)FAULT { + if (SDLFuelCutoffStatus_FAULT == nil) { + SDLFuelCutoffStatus_FAULT = [[SDLFuelCutoffStatus alloc] initWithValue:@"FAULT"]; + } + return SDLFuelCutoffStatus_FAULT; +} + +@end diff --git a/SmartDeviceLink/SDLFunctionID.h b/SmartDeviceLink/SDLFunctionID.h new file mode 100644 index 000000000..8bbd1a52a --- /dev/null +++ b/SmartDeviceLink/SDLFunctionID.h @@ -0,0 +1,15 @@ +// SDLFunctionID.h +// + + +#import <Foundation/Foundation.h> + + +@interface SDLFunctionID : NSObject { + NSDictionary *functionIDs; +} + +- (NSString *)getFunctionName:(int)functionID; +- (NSNumber *)getFunctionID:(NSString *)functionName; + +@end diff --git a/SmartDeviceLink/SDLFunctionID.m b/SmartDeviceLink/SDLFunctionID.m new file mode 100644 index 000000000..802ee3df3 --- /dev/null +++ b/SmartDeviceLink/SDLFunctionID.m @@ -0,0 +1,40 @@ +// SDLFunctionID.m +// + + +#import "SDLFunctionID.h" + +#import "SDLNames.h" + +@implementation SDLFunctionID + +- (instancetype)init { + if (self = [super init]) { + functionIDs = [NSDictionary dictionaryWithObjectsAndKeys: + NAMES_reserved, @"0", NAMES_RegisterAppInterface, @"1", NAMES_UnregisterAppInterface, @"2", NAMES_SetGlobalProperties, @"3", NAMES_ResetGlobalProperties, @"4", NAMES_AddCommand, @"5", NAMES_DeleteCommand, @"6", NAMES_AddSubMenu, @"7", NAMES_DeleteSubMenu, @"8", NAMES_CreateInteractionChoiceSet, @"9", NAMES_PerformInteraction, @"10", NAMES_DeleteInteractionChoiceSet, @"11", NAMES_Alert, @"12", NAMES_Show, @"13", NAMES_Speak, @"14", NAMES_SetMediaClockTimer, @"15", NAMES_PerformAudioPassThru, @"16", NAMES_EndAudioPassThru, @"17", NAMES_SubscribeButton, @"18", NAMES_UnsubscribeButton, @"19", NAMES_SubscribeVehicleData, @"20", NAMES_UnsubscribeVehicleData, @"21", NAMES_GetVehicleData, @"22", NAMES_ReadDID, @"23", NAMES_GetDTCs, @"24", NAMES_ScrollableMessage, @"25", NAMES_Slider, @"26", NAMES_ShowConstantTBT, @"27", NAMES_AlertManeuver, @"28", NAMES_UpdateTurnList, @"29", NAMES_ChangeRegistration, @"30", NAMES_GenericResponse, @"31", NAMES_PutFile, @"32", NAMES_DeleteFile, @"33", NAMES_ListFiles, @"34", NAMES_SetAppIcon, @"35", NAMES_SetDisplayLayout, @"36", NAMES_DiagnosticMessage, @"37", NAMES_SystemRequest, @"38", NAMES_SendLocation, @"39", NAMES_DialNumber, @"40", NAMES_OnHMIStatus, @"32768", NAMES_OnAppInterfaceUnregistered, @"32769", NAMES_OnButtonEvent, @"32770", NAMES_OnButtonPress, @"32771", NAMES_OnVehicleData, @"32772", NAMES_OnCommand, @"32773", NAMES_OnTBTClientState, @"32774", NAMES_OnDriverDistraction, @"32775", NAMES_OnPermissionsChange, @"32776", NAMES_OnAudioPassThru, @"32777", NAMES_OnLanguageChange, @"32778", NAMES_OnKeyboardInput, @"32779", NAMES_OnTouchEvent, @"32780", NAMES_OnSystemRequest, @"32781", NAMES_OnHashChange, @"32782", + + NAMES_EncodedSyncPData, + @"65536", + NAMES_SyncPData, + @"65537", + + NAMES_OnEncodedSyncPData, + @"98304", + NAMES_OnSyncPData, + @"98305", + nil]; + } + return self; +} + +- (NSString *)getFunctionName:(int)functionID { + return [functionIDs objectForKey:[NSString stringWithFormat:@"%d", functionID]]; +} + + +- (NSNumber *)getFunctionID:(NSString *)functionName { + return [NSNumber numberWithInt:[[[functionIDs allKeysForObject:functionName] objectAtIndex:0] intValue]]; +} + + +@end diff --git a/SmartDeviceLink/SDLGPSData.h b/SmartDeviceLink/SDLGPSData.h new file mode 100644 index 000000000..cfeebaa41 --- /dev/null +++ b/SmartDeviceLink/SDLGPSData.h @@ -0,0 +1,163 @@ +// SDLGPSData.h +// + +#import "SDLRPCMessage.h" + +@class SDLCompassDirection; +@class SDLDimension; + + +/** + * Describes the GPS data. Not all data will be available on all carlines. + * + * @since SDL 2.0 + */ +@interface SDLGPSData : SDLRPCStruct { +} + +/** + * Constructs a newly allocated SDLGPSData object + */ +- (instancetype)init; + +/** + * Constructs a newly allocated SDLGPSData object indicated by the dictionary parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract longitude degrees + * + * Required, Float, -180 - 180 + */ +@property (strong) NSNumber *longitudeDegrees; + +/** + * @abstract latitude degrees + * + * Required, Float, -90 - 90 + */ +@property (strong) NSNumber *latitudeDegrees; + +/** + * @abstract utc year + * + * Required, Integer, 2010 - 2100 + */ +@property (strong) NSNumber *utcYear; + +/** + * @abstract utc month + * + * Required, Integer, 1 - 12 + */ +@property (strong) NSNumber *utcMonth; + +/** + * @abstract utc day + * + * Required, Integer, 1 - 31 + */ +@property (strong) NSNumber *utcDay; + +/** + * @abstract utc hours + * + * Required, Integer, 0 - 23 + */ +@property (strong) NSNumber *utcHours; + +/** + * @abstract utc minutes + * + * Required, Integer, 0 - 59 + */ +@property (strong) NSNumber *utcMinutes; + +/** + * @abstract utc seconds + * + * Required, Integer, 0 - 59 + */ +@property (strong) NSNumber *utcSeconds; + +/** + * Potential Compass Directions + */ +@property (strong) SDLCompassDirection *compassDirection; + +/** + * @abstract The 3D positional dilution of precision. + * + * @discussion If undefined or unavailable, then value shall be set to 0 + * + * Required, Float, 0.0 - 10.0 + */ +@property (strong) NSNumber *pdop; + +/** + * @abstract The horizontal dilution of precision + * + * @discussion If undefined or unavailable, then value shall be set to 0 + * + * Required, Float, 0.0 - 10.0 + */ +@property (strong) NSNumber *hdop; + +/** + * @abstract the vertical dilution of precision + * + * @discussion If undefined or unavailable, then value shall be set to 0 + * + * Required, Float, 0.0 - 10.0 + */ +@property (strong) NSNumber *vdop; + +/** + * @abstract What the coordinates are based on + * + * @discussion YES, if coordinates are based on satellites. NO, if based on dead reckoning. + * + * Required, Boolean + */ +@property (strong) NSNumber *actual; + +/** + * @abstract The number of satellites in view + * + * Required, Integer, 0 - 31 + */ +@property (strong) NSNumber *satellites; + +/** + * The supported dimensions of the GPS + * + * Required + */ +@property (strong) SDLDimension *dimension; + +/** + * @abstract altitude in meters + * + * Required, Float, -10000.0 - 10000.0 + */ +@property (strong) NSNumber *altitude; + +/** + * @abstract Heading based on the GPS data. + * + * @discussion North is 0, East is 90, etc. Resolution is 0.01 + * + * Required, Float, 0.0 - 359.99 + */ +@property (strong) NSNumber *heading; + +/** + * @abstract speed in KPH + * + * Required, Float, 0.0 - 500.0 + */ +@property (strong) NSNumber *speed; + +@end diff --git a/SmartDeviceLink/SDLGPSData.m b/SmartDeviceLink/SDLGPSData.m new file mode 100644 index 000000000..1cec52112 --- /dev/null +++ b/SmartDeviceLink/SDLGPSData.m @@ -0,0 +1,251 @@ +// SDLGPSData.m +// + +#import "SDLGPSData.h" + +#import "SDLCompassDirection.h" +#import "SDLDimension.h" +#import "SDLNames.h" + + +@implementation SDLGPSData + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setLongitudeDegrees:(NSNumber *)longitudeDegrees { + if (longitudeDegrees != nil) { + [store setObject:longitudeDegrees forKey:NAMES_longitudeDegrees]; + } else { + [store removeObjectForKey:NAMES_longitudeDegrees]; + } +} + +- (NSNumber *)longitudeDegrees { + return [store objectForKey:NAMES_longitudeDegrees]; +} + +- (void)setLatitudeDegrees:(NSNumber *)latitudeDegrees { + if (latitudeDegrees != nil) { + [store setObject:latitudeDegrees forKey:NAMES_latitudeDegrees]; + } else { + [store removeObjectForKey:NAMES_latitudeDegrees]; + } +} + +- (NSNumber *)latitudeDegrees { + return [store objectForKey:NAMES_latitudeDegrees]; +} + +- (void)setUtcYear:(NSNumber *)utcYear { + if (utcYear != nil) { + [store setObject:utcYear forKey:NAMES_utcYear]; + } else { + [store removeObjectForKey:NAMES_utcYear]; + } +} + +- (NSNumber *)utcYear { + return [store objectForKey:NAMES_utcYear]; +} + +- (void)setUtcMonth:(NSNumber *)utcMonth { + if (utcMonth != nil) { + [store setObject:utcMonth forKey:NAMES_utcMonth]; + } else { + [store removeObjectForKey:NAMES_utcMonth]; + } +} + +- (NSNumber *)utcMonth { + return [store objectForKey:NAMES_utcMonth]; +} + +- (void)setUtcDay:(NSNumber *)utcDay { + if (utcDay != nil) { + [store setObject:utcDay forKey:NAMES_utcDay]; + } else { + [store removeObjectForKey:NAMES_utcDay]; + } +} + +- (NSNumber *)utcDay { + return [store objectForKey:NAMES_utcDay]; +} + +- (void)setUtcHours:(NSNumber *)utcHours { + if (utcHours != nil) { + [store setObject:utcHours forKey:NAMES_utcHours]; + } else { + [store removeObjectForKey:NAMES_utcHours]; + } +} + +- (NSNumber *)utcHours { + return [store objectForKey:NAMES_utcHours]; +} + +- (void)setUtcMinutes:(NSNumber *)utcMinutes { + if (utcMinutes != nil) { + [store setObject:utcMinutes forKey:NAMES_utcMinutes]; + } else { + [store removeObjectForKey:NAMES_utcMinutes]; + } +} + +- (NSNumber *)utcMinutes { + return [store objectForKey:NAMES_utcMinutes]; +} + +- (void)setUtcSeconds:(NSNumber *)utcSeconds { + if (utcSeconds != nil) { + [store setObject:utcSeconds forKey:NAMES_utcSeconds]; + } else { + [store removeObjectForKey:NAMES_utcSeconds]; + } +} + +- (NSNumber *)utcSeconds { + return [store objectForKey:NAMES_utcSeconds]; +} + +- (void)setCompassDirection:(SDLCompassDirection *)compassDirection { + if (compassDirection != nil) { + [store setObject:compassDirection forKey:NAMES_compassDirection]; + } else { + [store removeObjectForKey:NAMES_compassDirection]; + } +} + +- (SDLCompassDirection *)compassDirection { + NSObject *obj = [store objectForKey:NAMES_compassDirection]; + if (obj == nil || [obj isKindOfClass:SDLCompassDirection.class]) { + return (SDLCompassDirection *)obj; + } else { + return [SDLCompassDirection valueOf:(NSString *)obj]; + } +} + +- (void)setPdop:(NSNumber *)pdop { + if (pdop != nil) { + [store setObject:pdop forKey:NAMES_pdop]; + } else { + [store removeObjectForKey:NAMES_pdop]; + } +} + +- (NSNumber *)pdop { + return [store objectForKey:NAMES_pdop]; +} + +- (void)setHdop:(NSNumber *)hdop { + if (hdop != nil) { + [store setObject:hdop forKey:NAMES_hdop]; + } else { + [store removeObjectForKey:NAMES_hdop]; + } +} + +- (NSNumber *)hdop { + return [store objectForKey:NAMES_hdop]; +} + +- (void)setVdop:(NSNumber *)vdop { + if (vdop != nil) { + [store setObject:vdop forKey:NAMES_vdop]; + } else { + [store removeObjectForKey:NAMES_vdop]; + } +} + +- (NSNumber *)vdop { + return [store objectForKey:NAMES_vdop]; +} + +- (void)setActual:(NSNumber *)actual { + if (actual != nil) { + [store setObject:actual forKey:NAMES_actual]; + } else { + [store removeObjectForKey:NAMES_actual]; + } +} + +- (NSNumber *)actual { + return [store objectForKey:NAMES_actual]; +} + +- (void)setSatellites:(NSNumber *)satellites { + if (satellites != nil) { + [store setObject:satellites forKey:NAMES_satellites]; + } else { + [store removeObjectForKey:NAMES_satellites]; + } +} + +- (NSNumber *)satellites { + return [store objectForKey:NAMES_satellites]; +} + +- (void)setDimension:(SDLDimension *)dimension { + if (dimension != nil) { + [store setObject:dimension forKey:NAMES_dimension]; + } else { + [store removeObjectForKey:NAMES_dimension]; + } +} + +- (SDLDimension *)dimension { + NSObject *obj = [store objectForKey:NAMES_dimension]; + if (obj == nil || [obj isKindOfClass:SDLDimension.class]) { + return (SDLDimension *)obj; + } else { + return [SDLDimension valueOf:(NSString *)obj]; + } +} + +- (void)setAltitude:(NSNumber *)altitude { + if (altitude != nil) { + [store setObject:altitude forKey:NAMES_altitude]; + } else { + [store removeObjectForKey:NAMES_altitude]; + } +} + +- (NSNumber *)altitude { + return [store objectForKey:NAMES_altitude]; +} + +- (void)setHeading:(NSNumber *)heading { + if (heading != nil) { + [store setObject:heading forKey:NAMES_heading]; + } else { + [store removeObjectForKey:NAMES_heading]; + } +} + +- (NSNumber *)heading { + return [store objectForKey:NAMES_heading]; +} + +- (void)setSpeed:(NSNumber *)speed { + if (speed != nil) { + [store setObject:speed forKey:NAMES_speed]; + } else { + [store removeObjectForKey:NAMES_speed]; + } +} + +- (NSNumber *)speed { + return [store objectForKey:NAMES_speed]; +} + +@end diff --git a/SmartDeviceLink/SDLGenericResponse.h b/SmartDeviceLink/SDLGenericResponse.h new file mode 100644 index 000000000..4d339fb64 --- /dev/null +++ b/SmartDeviceLink/SDLGenericResponse.h @@ -0,0 +1,18 @@ +// SDLGenericResponse.h +// + + +#import "SDLRPCResponse.h" + +/** + * Generic Response is sent, when the name of a received msg cannot be + * retrieved. Only used in case of an error. Currently, only resultCode + * INVALID_DATA is used. + */ +@interface SDLGenericResponse : SDLRPCResponse { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLGenericResponse.m b/SmartDeviceLink/SDLGenericResponse.m new file mode 100644 index 000000000..aff982d8f --- /dev/null +++ b/SmartDeviceLink/SDLGenericResponse.m @@ -0,0 +1,23 @@ +// SDLGenericResponse.m +// + + +#import "SDLGenericResponse.h" + +#import "SDLNames.h" + +@implementation SDLGenericResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_GenericResponse]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLGetDTCs.h b/SmartDeviceLink/SDLGetDTCs.h new file mode 100644 index 000000000..3d38a0079 --- /dev/null +++ b/SmartDeviceLink/SDLGetDTCs.h @@ -0,0 +1,41 @@ +// SDLGetDTCs.h +// + + +#import "SDLRPCRequest.h" + +/** + * This RPC allows to request diagnostic module trouble codes from a certain + * vehicle module + * <p> + * Function Group: ProprietaryData + * <p> + * <b>HMILevel needs to be FULL, LIMITED or BACKGROUND</b> + * <p> + */ +@interface SDLGetDTCs : SDLRPCRequest { +} +/** + * Constructs a new SDLGetDTCs object + */ +- (instancetype)init; +/** + * Constructs a new SDLGetDTCs object indicated by the dictionary parameter + * <p> + * + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; +/** + * @abstract a name of the module to receive the DTC form + * @discussion an NSNumber value representing a name of the module to receive + * the DTC form + * <p> + * <b>Notes: </b>Minvalue:0; Maxvalue:65535 + */ +@property (strong) NSNumber *ecuName; +/** + * @abstract DTC Mask Byte to be sent in diagnostic request to module. NSNumber* dtcMask Minvalue:0; Maxvalue:255 + */ +@property (strong) NSNumber *dtcMask; +@end diff --git a/SmartDeviceLink/SDLGetDTCs.m b/SmartDeviceLink/SDLGetDTCs.m new file mode 100644 index 000000000..cf7db88e5 --- /dev/null +++ b/SmartDeviceLink/SDLGetDTCs.m @@ -0,0 +1,47 @@ +// SDLGetDTCs.m +// + + +#import "SDLGetDTCs.h" + +#import "SDLNames.h" + +@implementation SDLGetDTCs + +- (instancetype)init { + if (self = [super initWithName:NAMES_GetDTCs]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setEcuName:(NSNumber *)ecuName { + if (ecuName != nil) { + [parameters setObject:ecuName forKey:NAMES_ecuName]; + } else { + [parameters removeObjectForKey:NAMES_ecuName]; + } +} + +- (NSNumber *)ecuName { + return [parameters objectForKey:NAMES_ecuName]; +} + +- (void)setDtcMask:(NSNumber *)dtcMask { + if (dtcMask != nil) { + [parameters setObject:dtcMask forKey:NAMES_dtcMask]; + } else { + [parameters removeObjectForKey:NAMES_dtcMask]; + } +} + +- (NSNumber *)dtcMask { + return [parameters objectForKey:NAMES_dtcMask]; +} + +@end diff --git a/SmartDeviceLink/SDLGetDTCsResponse.h b/SmartDeviceLink/SDLGetDTCsResponse.h new file mode 100644 index 000000000..4e0af4a39 --- /dev/null +++ b/SmartDeviceLink/SDLGetDTCsResponse.h @@ -0,0 +1,21 @@ +// SDLGetDTCsResponse.h +// + + +#import "SDLRPCResponse.h" + +/** + * SDLGetDTCsResponse is sent, when SDLGetDTCs has been called + * + * Since <b>SmartDeviceLink 2.0</b> + */ +@interface SDLGetDTCsResponse : SDLRPCResponse { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) NSNumber *ecuHeader; +@property (strong) NSMutableArray *dtc; + +@end diff --git a/SmartDeviceLink/SDLGetDTCsResponse.m b/SmartDeviceLink/SDLGetDTCsResponse.m new file mode 100644 index 000000000..bbf678a78 --- /dev/null +++ b/SmartDeviceLink/SDLGetDTCsResponse.m @@ -0,0 +1,47 @@ +// SDLGetDTCsResponse.m +// + + +#import "SDLGetDTCsResponse.h" + +#import "SDLNames.h" + +@implementation SDLGetDTCsResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_GetDTCs]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setEcuHeader:(NSNumber *)ecuHeader { + if (ecuHeader != nil) { + [parameters setObject:ecuHeader forKey:NAMES_ecuHeader]; + } else { + [parameters removeObjectForKey:NAMES_ecuHeader]; + } +} + +- (NSNumber *)ecuHeader { + return [parameters objectForKey:NAMES_ecuHeader]; +} + +- (void)setDtc:(NSMutableArray *)dtc { + if (dtc != nil) { + [parameters setObject:dtc forKey:NAMES_dtc]; + } else { + [parameters removeObjectForKey:NAMES_dtc]; + } +} + +- (NSMutableArray *)dtc { + return [parameters objectForKey:NAMES_dtc]; +} + +@end diff --git a/SmartDeviceLink/SDLGetVehicleData.h b/SmartDeviceLink/SDLGetVehicleData.h new file mode 100644 index 000000000..df2c1923e --- /dev/null +++ b/SmartDeviceLink/SDLGetVehicleData.h @@ -0,0 +1,140 @@ +// SDLGetVehicleData.h +// + + +#import "SDLRPCRequest.h" + +/** + * Requests surrent values of specific published vehicle data items. + * <p> + * Function Group: Location, VehicleInfo and DrivingChara + * <p> + * <b>HMILevel needs to be FULL, LIMITED or BACKGROUND</b> + * </p> + * + * Since SmartDeviceLink 2.0<br/> + * See SDLSubscribeVehicleData SDLUnsubscribeVehicleData + */ +@interface SDLGetVehicleData : SDLRPCRequest { +} + +/** + * @abstract Constructs a new SDLGetVehicleData object + */ +- (instancetype)init; + +/** + * @abstract Constructs a new SDLGetVehicleData object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract A boolean value. If true, requests Gps data + */ +@property (strong) NSNumber *gps; + +/** + * @abstract A boolean value. If true, requests speed data + */ +@property (strong) NSNumber *speed; + +/** + * @abstract A boolean value. If true, requests rpm data + */ +@property (strong) NSNumber *rpm; + +/** + * @abstract A boolean value. If true, requests FuelLevel data + */ +@property (strong) NSNumber *fuelLevel; + +/** + * @abstract A boolean value. If true, requests fuelLevel_State data + */ +@property (strong) NSNumber *fuelLevel_State; + +/** + * @abstract A boolean value. If true, requests instantFuelConsumption data + */ +@property (strong) NSNumber *instantFuelConsumption; + +/** + * @abstract A boolean value. If true, requests externalTemperature data + */ +@property (strong) NSNumber *externalTemperature; + +/** + * @abstract A boolean value. If true, requests Vehicle Identification Number + */ +@property (strong) NSNumber *vin; + +/** + * @abstract A boolean value. If true, requests Currently selected gear data + */ +@property (strong) NSNumber *prndl; + +/** + * @abstract A boolean value. If true, requests tire pressure status data + */ +@property (strong) NSNumber *tirePressure; + +/** + * @abstract A boolean value. If true, requests odometer data + */ +@property (strong) NSNumber *odometer; + +/** + * @abstract A boolean value. If true, requests belt Status data + */ +@property (strong) NSNumber *beltStatus; + +/** + * @abstract A boolean value. If true, requests body Information data + */ +@property (strong) NSNumber *bodyInformation; + +/** + * @abstract A boolean value. If true, requests device Status data + */ +@property (strong) NSNumber *deviceStatus; + +/** + * @abstract A boolean value. If true, requests driver Braking data + */ +@property (strong) NSNumber *driverBraking; + +/** + * @abstract A boolean value. If true, requests wiper Status data + */ +@property (strong) NSNumber *wiperStatus; + +/** + * @abstract A boolean value. If true, requests Head Lamp Status data + */ +@property (strong) NSNumber *headLampStatus; + +/** + * @abstract A boolean value. If true, requests Engine Torque data + */ +@property (strong) NSNumber *engineTorque; + +/** + * @abstract A boolean value. If true, means the accPedalPosition data has been + * subscribed. + */ +@property (strong) NSNumber *accPedalPosition; + +/** + * @abstract A boolean value. If true, means the steeringWheelAngle data has been + * subscribed. + */ +@property (strong) NSNumber *steeringWheelAngle; +@property (strong) NSNumber *eCallInfo; +@property (strong) NSNumber *airbagStatus; +@property (strong) NSNumber *emergencyEvent; +@property (strong) NSNumber *clusterModeStatus; +@property (strong) NSNumber *myKey; + +@end
\ No newline at end of file diff --git a/SmartDeviceLink/SDLGetVehicleData.m b/SmartDeviceLink/SDLGetVehicleData.m new file mode 100644 index 000000000..ab5d59a19 --- /dev/null +++ b/SmartDeviceLink/SDLGetVehicleData.m @@ -0,0 +1,323 @@ +// SDLGetVehicleData.m +// + + +#import "SDLGetVehicleData.h" + +#import "SDLNames.h" + +@implementation SDLGetVehicleData + +- (instancetype)init { + if (self = [super initWithName:NAMES_GetVehicleData]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setGps:(NSNumber *)gps { + if (gps != nil) { + [parameters setObject:gps forKey:NAMES_gps]; + } else { + [parameters removeObjectForKey:NAMES_gps]; + } +} + +- (NSNumber *)gps { + return [parameters objectForKey:NAMES_gps]; +} + +- (void)setSpeed:(NSNumber *)speed { + if (speed != nil) { + [parameters setObject:speed forKey:NAMES_speed]; + } else { + [parameters removeObjectForKey:NAMES_speed]; + } +} + +- (NSNumber *)speed { + return [parameters objectForKey:NAMES_speed]; +} + +- (void)setRpm:(NSNumber *)rpm { + if (rpm != nil) { + [parameters setObject:rpm forKey:NAMES_rpm]; + } else { + [parameters removeObjectForKey:NAMES_rpm]; + } +} + +- (NSNumber *)rpm { + return [parameters objectForKey:NAMES_rpm]; +} + +- (void)setFuelLevel:(NSNumber *)fuelLevel { + if (fuelLevel != nil) { + [parameters setObject:fuelLevel forKey:NAMES_fuelLevel]; + } else { + [parameters removeObjectForKey:NAMES_fuelLevel]; + } +} + +- (NSNumber *)fuelLevel { + return [parameters objectForKey:NAMES_fuelLevel]; +} + +- (void)setFuelLevel_State:(NSNumber *)fuelLevel_State { + if (fuelLevel_State != nil) { + [parameters setObject:fuelLevel_State forKey:NAMES_fuelLevel_State]; + } else { + [parameters removeObjectForKey:NAMES_fuelLevel_State]; + } +} + +- (NSNumber *)fuelLevel_State { + return [parameters objectForKey:NAMES_fuelLevel_State]; +} + +- (void)setInstantFuelConsumption:(NSNumber *)instantFuelConsumption { + if (instantFuelConsumption != nil) { + [parameters setObject:instantFuelConsumption forKey:NAMES_instantFuelConsumption]; + } else { + [parameters removeObjectForKey:NAMES_instantFuelConsumption]; + } +} + +- (NSNumber *)instantFuelConsumption { + return [parameters objectForKey:NAMES_instantFuelConsumption]; +} + +- (void)setExternalTemperature:(NSNumber *)externalTemperature { + if (externalTemperature != nil) { + [parameters setObject:externalTemperature forKey:NAMES_externalTemperature]; + } else { + [parameters removeObjectForKey:NAMES_externalTemperature]; + } +} + +- (NSNumber *)externalTemperature { + return [parameters objectForKey:NAMES_externalTemperature]; +} + +- (void)setVin:(NSNumber *)vin { + if (vin != nil) { + [parameters setObject:vin forKey:NAMES_vin]; + } else { + [parameters removeObjectForKey:NAMES_vin]; + } +} + +- (NSNumber *)vin { + return [parameters objectForKey:NAMES_vin]; +} + +- (void)setPrndl:(NSNumber *)prndl { + if (prndl != nil) { + [parameters setObject:prndl forKey:NAMES_prndl]; + } else { + [parameters removeObjectForKey:NAMES_prndl]; + } +} + +- (NSNumber *)prndl { + return [parameters objectForKey:NAMES_prndl]; +} + +- (void)setTirePressure:(NSNumber *)tirePressure { + if (tirePressure != nil) { + [parameters setObject:tirePressure forKey:NAMES_tirePressure]; + } else { + [parameters removeObjectForKey:NAMES_tirePressure]; + } +} + +- (NSNumber *)tirePressure { + return [parameters objectForKey:NAMES_tirePressure]; +} + +- (void)setOdometer:(NSNumber *)odometer { + if (odometer != nil) { + [parameters setObject:odometer forKey:NAMES_odometer]; + } else { + [parameters removeObjectForKey:NAMES_odometer]; + } +} + +- (NSNumber *)odometer { + return [parameters objectForKey:NAMES_odometer]; +} + +- (void)setBeltStatus:(NSNumber *)beltStatus { + if (beltStatus != nil) { + [parameters setObject:beltStatus forKey:NAMES_beltStatus]; + } else { + [parameters removeObjectForKey:NAMES_beltStatus]; + } +} + +- (NSNumber *)beltStatus { + return [parameters objectForKey:NAMES_beltStatus]; +} + +- (void)setBodyInformation:(NSNumber *)bodyInformation { + if (bodyInformation != nil) { + [parameters setObject:bodyInformation forKey:NAMES_bodyInformation]; + } else { + [parameters removeObjectForKey:NAMES_bodyInformation]; + } +} + +- (NSNumber *)bodyInformation { + return [parameters objectForKey:NAMES_bodyInformation]; +} + +- (void)setDeviceStatus:(NSNumber *)deviceStatus { + if (deviceStatus != nil) { + [parameters setObject:deviceStatus forKey:NAMES_deviceStatus]; + } else { + [parameters removeObjectForKey:NAMES_deviceStatus]; + } +} + +- (NSNumber *)deviceStatus { + return [parameters objectForKey:NAMES_deviceStatus]; +} + +- (void)setDriverBraking:(NSNumber *)driverBraking { + if (driverBraking != nil) { + [parameters setObject:driverBraking forKey:NAMES_driverBraking]; + } else { + [parameters removeObjectForKey:NAMES_driverBraking]; + } +} + +- (NSNumber *)driverBraking { + return [parameters objectForKey:NAMES_driverBraking]; +} + +- (void)setWiperStatus:(NSNumber *)wiperStatus { + if (wiperStatus != nil) { + [parameters setObject:wiperStatus forKey:NAMES_wiperStatus]; + } else { + [parameters removeObjectForKey:NAMES_wiperStatus]; + } +} + +- (NSNumber *)wiperStatus { + return [parameters objectForKey:NAMES_wiperStatus]; +} + +- (void)setHeadLampStatus:(NSNumber *)headLampStatus { + if (headLampStatus != nil) { + [parameters setObject:headLampStatus forKey:NAMES_headLampStatus]; + } else { + [parameters removeObjectForKey:NAMES_headLampStatus]; + } +} + +- (NSNumber *)headLampStatus { + return [parameters objectForKey:NAMES_headLampStatus]; +} + +- (void)setEngineTorque:(NSNumber *)engineTorque { + if (engineTorque != nil) { + [parameters setObject:engineTorque forKey:NAMES_engineTorque]; + } else { + [parameters removeObjectForKey:NAMES_engineTorque]; + } +} + +- (NSNumber *)engineTorque { + return [parameters objectForKey:NAMES_engineTorque]; +} + +- (void)setAccPedalPosition:(NSNumber *)accPedalPosition { + if (accPedalPosition != nil) { + [parameters setObject:accPedalPosition forKey:NAMES_accPedalPosition]; + } else { + [parameters removeObjectForKey:NAMES_accPedalPosition]; + } +} + +- (NSNumber *)accPedalPosition { + return [parameters objectForKey:NAMES_accPedalPosition]; +} + +- (void)setSteeringWheelAngle:(NSNumber *)steeringWheelAngle { + if (steeringWheelAngle != nil) { + [parameters setObject:steeringWheelAngle forKey:NAMES_steeringWheelAngle]; + } else { + [parameters removeObjectForKey:NAMES_steeringWheelAngle]; + } +} + +- (NSNumber *)steeringWheelAngle { + return [parameters objectForKey:NAMES_steeringWheelAngle]; +} + +- (void)setECallInfo:(NSNumber *)eCallInfo { + if (eCallInfo != nil) { + [parameters setObject:eCallInfo forKey:NAMES_eCallInfo]; + } else { + [parameters removeObjectForKey:NAMES_eCallInfo]; + } +} + +- (NSNumber *)eCallInfo { + return [parameters objectForKey:NAMES_eCallInfo]; +} + +- (void)setAirbagStatus:(NSNumber *)airbagStatus { + if (airbagStatus != nil) { + [parameters setObject:airbagStatus forKey:NAMES_airbagStatus]; + } else { + [parameters removeObjectForKey:NAMES_airbagStatus]; + } +} + +- (NSNumber *)airbagStatus { + return [parameters objectForKey:NAMES_airbagStatus]; +} + +- (void)setEmergencyEvent:(NSNumber *)emergencyEvent { + if (emergencyEvent != nil) { + [parameters setObject:emergencyEvent forKey:NAMES_emergencyEvent]; + } else { + [parameters removeObjectForKey:NAMES_emergencyEvent]; + } +} + +- (NSNumber *)emergencyEvent { + return [parameters objectForKey:NAMES_emergencyEvent]; +} + +- (void)setClusterModeStatus:(NSNumber *)clusterModeStatus { + if (clusterModeStatus != nil) { + [parameters setObject:clusterModeStatus forKey:NAMES_clusterModeStatus]; + } else { + [parameters removeObjectForKey:NAMES_clusterModeStatus]; + } +} + +- (NSNumber *)clusterModeStatus { + return [parameters objectForKey:NAMES_clusterModeStatus]; +} + +- (void)setMyKey:(NSNumber *)myKey { + if (myKey != nil) { + [parameters setObject:myKey forKey:NAMES_myKey]; + } else { + [parameters removeObjectForKey:NAMES_myKey]; + } +} + +- (NSNumber *)myKey { + return [parameters objectForKey:NAMES_myKey]; +} + +@end diff --git a/SmartDeviceLink/SDLGetVehicleDataResponse.h b/SmartDeviceLink/SDLGetVehicleDataResponse.h new file mode 100644 index 000000000..882c09b51 --- /dev/null +++ b/SmartDeviceLink/SDLGetVehicleDataResponse.h @@ -0,0 +1,150 @@ +// SDLGetVehicleDataResponse.h +// + +#import "SDLRPCResponse.h" + +@class SDLAirbagStatus; +@class SDLBeltStatus; +@class SDLBodyInformation; +@class SDLClusterModeStatus; +@class SDLComponentVolumeStatus; +@class SDLDeviceStatus; +@class SDLECallInfo; +@class SDLEmergencyEvent; +@class SDLGPSData; +@class SDLHeadLampStatus; +@class SDLMyKey; +@class SDLPRNDL; +@class SDLTireStatus; +@class SDLVehicleDataEventStatus; +@class SDLWiperStatus; + + +/** + * Get Vehicle Data Response is sent, when SDLGetVehicleData has been called + * + * Since SmartDeviceLink 2.0 + */ +@interface SDLGetVehicleDataResponse : SDLRPCResponse { +} + + +/** + * @abstract Constructs a new SDLGetVehicleDataResponse object + */ +- (instancetype)init; + +/** + * @abstract Constructs a new SDLGetVehicleDataResponse object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + + +/** + * @abstract A SDLGPSData* value. See GPSData. + */ +@property (strong) SDLGPSData *gps; + +/** + * @abstract The vehicle speed in kilometers per hour. + */ +@property (strong) NSNumber *speed; + +/** + * @abstract The number of revolutions per minute of the engine. + */ +@property (strong) NSNumber *rpm; + +/** + * @abstract The fuel level in the tank (percentage) + */ +@property (strong) NSNumber *fuelLevel; + +/** + * @abstract A SDLComponentVolumeStatus* value. The fuel level state. + */ +@property (strong) SDLComponentVolumeStatus *fuelLevel_State; + +/** + * @abstract The instantaneous fuel consumption in microlitres. + */ +@property (strong) NSNumber *instantFuelConsumption; + +/** + * @abstract The external temperature in degrees celsius. + */ +@property (strong) NSNumber *externalTemperature; + +/** + * @abstract The Vehicle Identification Number + */ +@property (strong) NSString *vin; + +/** + * @abstract See PRNDL. + */ +@property (strong) SDLPRNDL *prndl; + +/** + * @abstract A SDLTireStatus* value. See TireStatus. + */ +@property (strong) SDLTireStatus *tirePressure; + +/** + * @abstract Odometer reading in km. + */ +@property (strong) NSNumber *odometer; + +/** + * @abstract A SDLBeltStatus* value. The status of the seat belts. + */ +@property (strong) SDLBeltStatus *beltStatus; + +/** + * @abstract A SDLBodyInformation* value. The body information including power modes. + */ +@property (strong) SDLBodyInformation *bodyInformation; + +/** + * @abstract A SDLDeviceStatus* value. The device status including signal and battery strength. + */ +@property (strong) SDLDeviceStatus *deviceStatus; + +/** + * @abstract A SDLVehicleDataResult* value. The status of the brake pedal. + */ +@property (strong) SDLVehicleDataEventStatus *driverBraking; + +/** + * @abstract A SDLWiperStatus* value. The status of the wipers. + */ +@property (strong) SDLWiperStatus *wiperStatus; + +/** + * @abstract A SDLHeadLampStatus* value. Status of the head lamps. + */ +@property (strong) SDLHeadLampStatus *headLampStatus; + +/** + * @abstract Torque value for engine (in Nm) on non-diesel variants. + */ +@property (strong) NSNumber *engineTorque; + +/** + * @abstract Accelerator pedal position (percentage depressed) + */ +@property (strong) NSNumber *accPedalPosition; + +/** + * @abstract Current angle of the steering wheel (in deg) + */ +@property (strong) NSNumber *steeringWheelAngle; +@property (strong) SDLECallInfo *eCallInfo; +@property (strong) SDLAirbagStatus *airbagStatus; +@property (strong) SDLEmergencyEvent *emergencyEvent; +@property (strong) SDLClusterModeStatus *clusterModeStatus; +@property (strong) SDLMyKey *myKey; + +@end diff --git a/SmartDeviceLink/SDLGetVehicleDataResponse.m b/SmartDeviceLink/SDLGetVehicleDataResponse.m new file mode 100644 index 000000000..7f1bdb351 --- /dev/null +++ b/SmartDeviceLink/SDLGetVehicleDataResponse.m @@ -0,0 +1,414 @@ +// SDLGetVehicleDataResponse.m +// + + +#import "SDLGetVehicleDataResponse.h" + +#import "SDLAirbagStatus.h" +#import "SDLBeltStatus.h" +#import "SDLBodyInformation.h" +#import "SDLClusterModeStatus.h" +#import "SDLComponentVolumeStatus.h" +#import "SDLDeviceStatus.h" +#import "SDLECallInfo.h" +#import "SDLEmergencyEvent.h" +#import "SDLGPSData.h" +#import "SDLHeadLampStatus.h" +#import "SDLMyKey.h" +#import "SDLNames.h" +#import "SDLPRNDL.h" +#import "SDLTireStatus.h" +#import "SDLVehicleDataEventStatus.h" +#import "SDLWiperStatus.h" + + +@implementation SDLGetVehicleDataResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_GetVehicleData]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setGps:(SDLGPSData *)gps { + if (gps != nil) { + [parameters setObject:gps forKey:NAMES_gps]; + } else { + [parameters removeObjectForKey:NAMES_gps]; + } +} + +- (SDLGPSData *)gps { + NSObject *obj = [parameters objectForKey:NAMES_gps]; + if (obj == nil || [obj isKindOfClass:SDLGPSData.class]) { + return (SDLGPSData *)obj; + } else { + return [[SDLGPSData alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setSpeed:(NSNumber *)speed { + if (speed != nil) { + [parameters setObject:speed forKey:NAMES_speed]; + } else { + [parameters removeObjectForKey:NAMES_speed]; + } +} + +- (NSNumber *)speed { + return [parameters objectForKey:NAMES_speed]; +} + +- (void)setRpm:(NSNumber *)rpm { + if (rpm != nil) { + [parameters setObject:rpm forKey:NAMES_rpm]; + } else { + [parameters removeObjectForKey:NAMES_rpm]; + } +} + +- (NSNumber *)rpm { + return [parameters objectForKey:NAMES_rpm]; +} + +- (void)setFuelLevel:(NSNumber *)fuelLevel { + if (fuelLevel != nil) { + [parameters setObject:fuelLevel forKey:NAMES_fuelLevel]; + } else { + [parameters removeObjectForKey:NAMES_fuelLevel]; + } +} + +- (NSNumber *)fuelLevel { + return [parameters objectForKey:NAMES_fuelLevel]; +} + +- (void)setFuelLevel_State:(SDLComponentVolumeStatus *)fuelLevel_State { + if (fuelLevel_State != nil) { + [parameters setObject:fuelLevel_State forKey:NAMES_fuelLevel_State]; + } else { + [parameters removeObjectForKey:NAMES_fuelLevel_State]; + } +} + +- (SDLComponentVolumeStatus *)fuelLevel_State { + NSObject *obj = [parameters objectForKey:NAMES_fuelLevel_State]; + if (obj == nil || [obj isKindOfClass:SDLComponentVolumeStatus.class]) { + return (SDLComponentVolumeStatus *)obj; + } else { + return [SDLComponentVolumeStatus valueOf:(NSString *)obj]; + } +} + +- (void)setInstantFuelConsumption:(NSNumber *)instantFuelConsumption { + if (instantFuelConsumption != nil) { + [parameters setObject:instantFuelConsumption forKey:NAMES_instantFuelConsumption]; + } else { + [parameters removeObjectForKey:NAMES_instantFuelConsumption]; + } +} + +- (NSNumber *)instantFuelConsumption { + return [parameters objectForKey:NAMES_instantFuelConsumption]; +} + +- (void)setExternalTemperature:(NSNumber *)externalTemperature { + if (externalTemperature != nil) { + [parameters setObject:externalTemperature forKey:NAMES_externalTemperature]; + } else { + [parameters removeObjectForKey:NAMES_externalTemperature]; + } +} + +- (NSNumber *)externalTemperature { + return [parameters objectForKey:NAMES_externalTemperature]; +} + +- (void)setVin:(NSString *)vin { + if (vin != nil) { + [parameters setObject:vin forKey:NAMES_vin]; + } else { + [parameters removeObjectForKey:NAMES_vin]; + } +} + +- (NSString *)vin { + return [parameters objectForKey:NAMES_vin]; +} + +- (void)setPrndl:(SDLPRNDL *)prndl { + if (prndl != nil) { + [parameters setObject:prndl forKey:NAMES_prndl]; + } else { + [parameters removeObjectForKey:NAMES_prndl]; + } +} + +- (SDLPRNDL *)prndl { + NSObject *obj = [parameters objectForKey:NAMES_prndl]; + if (obj == nil || [obj isKindOfClass:SDLPRNDL.class]) { + return (SDLPRNDL *)obj; + } else { + return [SDLPRNDL valueOf:(NSString *)obj]; + } +} + +- (void)setTirePressure:(SDLTireStatus *)tirePressure { + if (tirePressure != nil) { + [parameters setObject:tirePressure forKey:NAMES_tirePressure]; + } else { + [parameters removeObjectForKey:NAMES_tirePressure]; + } +} + +- (SDLTireStatus *)tirePressure { + NSObject *obj = [parameters objectForKey:NAMES_tirePressure]; + if (obj == nil || [obj isKindOfClass:SDLTireStatus.class]) { + return (SDLTireStatus *)obj; + } else { + return [[SDLTireStatus alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setOdometer:(NSNumber *)odometer { + if (odometer != nil) { + [parameters setObject:odometer forKey:NAMES_odometer]; + } else { + [parameters removeObjectForKey:NAMES_odometer]; + } +} + +- (NSNumber *)odometer { + return [parameters objectForKey:NAMES_odometer]; +} + +- (void)setBeltStatus:(SDLBeltStatus *)beltStatus { + if (beltStatus != nil) { + [parameters setObject:beltStatus forKey:NAMES_beltStatus]; + } else { + [parameters removeObjectForKey:NAMES_beltStatus]; + } +} + +- (SDLBeltStatus *)beltStatus { + NSObject *obj = [parameters objectForKey:NAMES_beltStatus]; + if (obj == nil || [obj isKindOfClass:SDLBeltStatus.class]) { + return (SDLBeltStatus *)obj; + } else { + return [[SDLBeltStatus alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setBodyInformation:(SDLBodyInformation *)bodyInformation { + if (bodyInformation != nil) { + [parameters setObject:bodyInformation forKey:NAMES_bodyInformation]; + } else { + [parameters removeObjectForKey:NAMES_bodyInformation]; + } +} + +- (SDLBodyInformation *)bodyInformation { + NSObject *obj = [parameters objectForKey:NAMES_bodyInformation]; + if (obj == nil || [obj isKindOfClass:SDLBodyInformation.class]) { + return (SDLBodyInformation *)obj; + } else { + return [[SDLBodyInformation alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setDeviceStatus:(SDLDeviceStatus *)deviceStatus { + if (deviceStatus != nil) { + [parameters setObject:deviceStatus forKey:NAMES_deviceStatus]; + } else { + [parameters removeObjectForKey:NAMES_deviceStatus]; + } +} + +- (SDLDeviceStatus *)deviceStatus { + NSObject *obj = [parameters objectForKey:NAMES_deviceStatus]; + if (obj == nil || [obj isKindOfClass:SDLDeviceStatus.class]) { + return (SDLDeviceStatus *)obj; + } else { + return [[SDLDeviceStatus alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setDriverBraking:(SDLVehicleDataEventStatus *)driverBraking { + if (driverBraking != nil) { + [parameters setObject:driverBraking forKey:NAMES_driverBraking]; + } else { + [parameters removeObjectForKey:NAMES_driverBraking]; + } +} + +- (SDLVehicleDataEventStatus *)driverBraking { + NSObject *obj = [parameters objectForKey:NAMES_driverBraking]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +- (void)setWiperStatus:(SDLWiperStatus *)wiperStatus { + if (wiperStatus != nil) { + [parameters setObject:wiperStatus forKey:NAMES_wiperStatus]; + } else { + [parameters removeObjectForKey:NAMES_wiperStatus]; + } +} + +- (SDLWiperStatus *)wiperStatus { + NSObject *obj = [parameters objectForKey:NAMES_wiperStatus]; + if (obj == nil || [obj isKindOfClass:SDLWiperStatus.class]) { + return (SDLWiperStatus *)obj; + } else { + return [SDLWiperStatus valueOf:(NSString *)obj]; + } +} + +- (void)setHeadLampStatus:(SDLHeadLampStatus *)headLampStatus { + if (headLampStatus != nil) { + [parameters setObject:headLampStatus forKey:NAMES_headLampStatus]; + } else { + [parameters removeObjectForKey:NAMES_headLampStatus]; + } +} + +- (SDLHeadLampStatus *)headLampStatus { + NSObject *obj = [parameters objectForKey:NAMES_headLampStatus]; + if (obj == nil || [obj isKindOfClass:SDLHeadLampStatus.class]) { + return (SDLHeadLampStatus *)obj; + } else { + return [[SDLHeadLampStatus alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setEngineTorque:(NSNumber *)engineTorque { + if (engineTorque != nil) { + [parameters setObject:engineTorque forKey:NAMES_engineTorque]; + } else { + [parameters removeObjectForKey:NAMES_engineTorque]; + } +} + +- (NSNumber *)engineTorque { + return [parameters objectForKey:NAMES_engineTorque]; +} + +- (void)setAccPedalPosition:(NSNumber *)accPedalPosition { + if (accPedalPosition != nil) { + [parameters setObject:accPedalPosition forKey:NAMES_accPedalPosition]; + } else { + [parameters removeObjectForKey:NAMES_accPedalPosition]; + } +} + +- (NSNumber *)accPedalPosition { + return [parameters objectForKey:NAMES_accPedalPosition]; +} + +- (void)setSteeringWheelAngle:(NSNumber *)steeringWheelAngle { + if (steeringWheelAngle != nil) { + [parameters setObject:steeringWheelAngle forKey:NAMES_steeringWheelAngle]; + } else { + [parameters removeObjectForKey:NAMES_steeringWheelAngle]; + } +} + +- (NSNumber *)steeringWheelAngle { + return [parameters objectForKey:NAMES_steeringWheelAngle]; +} + +- (void)setECallInfo:(SDLECallInfo *)eCallInfo { + if (eCallInfo != nil) { + [parameters setObject:eCallInfo forKey:NAMES_eCallInfo]; + } else { + [parameters removeObjectForKey:NAMES_eCallInfo]; + } +} + +- (SDLECallInfo *)eCallInfo { + NSObject *obj = [parameters objectForKey:NAMES_eCallInfo]; + if (obj == nil || [obj isKindOfClass:SDLECallInfo.class]) { + return (SDLECallInfo *)obj; + } else { + return [[SDLECallInfo alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setAirbagStatus:(SDLAirbagStatus *)airbagStatus { + if (airbagStatus != nil) { + [parameters setObject:airbagStatus forKey:NAMES_airbagStatus]; + } else { + [parameters removeObjectForKey:NAMES_airbagStatus]; + } +} + +- (SDLAirbagStatus *)airbagStatus { + NSObject *obj = [parameters objectForKey:NAMES_airbagStatus]; + if (obj == nil || [obj isKindOfClass:SDLAirbagStatus.class]) { + return (SDLAirbagStatus *)obj; + } else { + return [[SDLAirbagStatus alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setEmergencyEvent:(SDLEmergencyEvent *)emergencyEvent { + if (emergencyEvent != nil) { + [parameters setObject:emergencyEvent forKey:NAMES_emergencyEvent]; + } else { + [parameters removeObjectForKey:NAMES_emergencyEvent]; + } +} + +- (SDLEmergencyEvent *)emergencyEvent { + NSObject *obj = [parameters objectForKey:NAMES_emergencyEvent]; + if (obj == nil || [obj isKindOfClass:SDLEmergencyEvent.class]) { + return (SDLEmergencyEvent *)obj; + } else { + return [[SDLEmergencyEvent alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setClusterModeStatus:(SDLClusterModeStatus *)clusterModeStatus { + if (clusterModeStatus != nil) { + [parameters setObject:clusterModeStatus forKey:NAMES_clusterModeStatus]; + } else { + [parameters removeObjectForKey:NAMES_clusterModeStatus]; + } +} + +- (SDLClusterModeStatus *)clusterModeStatus { + NSObject *obj = [parameters objectForKey:NAMES_clusterModeStatus]; + if (obj == nil || [obj isKindOfClass:SDLClusterModeStatus.class]) { + return (SDLClusterModeStatus *)obj; + } else { + return [[SDLClusterModeStatus alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setMyKey:(SDLMyKey *)myKey { + if (myKey != nil) { + [parameters setObject:myKey forKey:NAMES_myKey]; + } else { + [parameters removeObjectForKey:NAMES_myKey]; + } +} + +- (SDLMyKey *)myKey { + NSObject *obj = [parameters objectForKey:NAMES_myKey]; + if (obj == nil || [obj isKindOfClass:SDLMyKey.class]) { + return (SDLMyKey *)obj; + } else { + return [[SDLMyKey alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLGlobalProperty.h b/SmartDeviceLink/SDLGlobalProperty.h new file mode 100644 index 000000000..91302fa6e --- /dev/null +++ b/SmartDeviceLink/SDLGlobalProperty.h @@ -0,0 +1,50 @@ +// SDLGlobalProperty.h +// + + +#import "SDLEnum.h" + +/** + * Properties of a user-initiated VR interaction (i.e. interactions started by the user pressing the PTT button). + * + * @since SDL 1.0 + */ +@interface SDLGlobalProperty : SDLEnum { +} + +/** + * Convert String to SDLGlobalProperty + * @param value The value of the string to get an object for + * @return SDLGlobalProperty + */ ++ (SDLGlobalProperty *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLGlobalProperty + * @return An array that store all possible SDLGlobalProperty + */ ++ (NSArray *)values; + +/** + * @abstract The help prompt to be spoken if the user needs assistance during a user-initiated interaction. + * @return A SDLGlobalProperty with value of *HELPPROMPT* + */ ++ (SDLGlobalProperty *)HELPPROMPT; + +/** + * @abstract The prompt to be spoken if the user-initiated interaction times out waiting for the user's verbal input. + * @return A SDLGlobalProperty with value of *TIMEOUTPROMPT* + */ ++ (SDLGlobalProperty *)TIMEOUTPROMPT; + ++ (SDLGlobalProperty *)VRHELPTITLE; + ++ (SDLGlobalProperty *)VRHELPITEMS; + ++ (SDLGlobalProperty *)MENUNAME; + ++ (SDLGlobalProperty *)MENUICON; + ++ (SDLGlobalProperty *)KEYBOARDPROPERTIES; + +@end
\ No newline at end of file diff --git a/SmartDeviceLink/SDLGlobalProperty.m b/SmartDeviceLink/SDLGlobalProperty.m new file mode 100644 index 000000000..59aa87e7b --- /dev/null +++ b/SmartDeviceLink/SDLGlobalProperty.m @@ -0,0 +1,92 @@ +// SDLGlobalProperty.m +// + + +#import "SDLGlobalProperty.h" + +SDLGlobalProperty *SDLGlobalProperty_HELPPROMPT = nil; +SDLGlobalProperty *SDLGlobalProperty_TIMEOUTPROMPT = nil; +SDLGlobalProperty *SDLGlobalProperty_VRHELPTITLE = nil; +SDLGlobalProperty *SDLGlobalProperty_VRHELPITEMS = nil; +SDLGlobalProperty *SDLGlobalProperty_MENUNAME = nil; +SDLGlobalProperty *SDLGlobalProperty_MENUICON = nil; +SDLGlobalProperty *SDLGlobalProperty_KEYBOARDPROPERTIES = nil; + +NSArray *SDLGlobalProperty_values = nil; + +@implementation SDLGlobalProperty + ++ (SDLGlobalProperty *)valueOf:(NSString *)value { + for (SDLGlobalProperty *item in SDLGlobalProperty.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLGlobalProperty_values == nil) { + SDLGlobalProperty_values = @[ + SDLGlobalProperty.HELPPROMPT, + SDLGlobalProperty.TIMEOUTPROMPT, + SDLGlobalProperty.VRHELPTITLE, + SDLGlobalProperty.VRHELPITEMS, + SDLGlobalProperty.MENUNAME, + SDLGlobalProperty.MENUICON, + SDLGlobalProperty.KEYBOARDPROPERTIES, + ]; + } + return SDLGlobalProperty_values; +} + ++ (SDLGlobalProperty *)HELPPROMPT { + if (SDLGlobalProperty_HELPPROMPT == nil) { + SDLGlobalProperty_HELPPROMPT = [[SDLGlobalProperty alloc] initWithValue:@"HELPPROMPT"]; + } + return SDLGlobalProperty_HELPPROMPT; +} + ++ (SDLGlobalProperty *)TIMEOUTPROMPT { + if (SDLGlobalProperty_TIMEOUTPROMPT == nil) { + SDLGlobalProperty_TIMEOUTPROMPT = [[SDLGlobalProperty alloc] initWithValue:@"TIMEOUTPROMPT"]; + } + return SDLGlobalProperty_TIMEOUTPROMPT; +} + ++ (SDLGlobalProperty *)VRHELPTITLE { + if (SDLGlobalProperty_VRHELPTITLE == nil) { + SDLGlobalProperty_VRHELPTITLE = [[SDLGlobalProperty alloc] initWithValue:@"VRHELPTITLE"]; + } + return SDLGlobalProperty_VRHELPTITLE; +} + ++ (SDLGlobalProperty *)VRHELPITEMS { + if (SDLGlobalProperty_VRHELPITEMS == nil) { + SDLGlobalProperty_VRHELPITEMS = [[SDLGlobalProperty alloc] initWithValue:@"VRHELPITEMS"]; + } + return SDLGlobalProperty_VRHELPITEMS; +} + ++ (SDLGlobalProperty *)MENUNAME { + if (SDLGlobalProperty_MENUNAME == nil) { + SDLGlobalProperty_MENUNAME = [[SDLGlobalProperty alloc] initWithValue:@"MENUNAME"]; + } + return SDLGlobalProperty_MENUNAME; +} + ++ (SDLGlobalProperty *)MENUICON { + if (SDLGlobalProperty_MENUICON == nil) { + SDLGlobalProperty_MENUICON = [[SDLGlobalProperty alloc] initWithValue:@"MENUICON"]; + } + return SDLGlobalProperty_MENUICON; +} + ++ (SDLGlobalProperty *)KEYBOARDPROPERTIES { + if (SDLGlobalProperty_KEYBOARDPROPERTIES == nil) { + SDLGlobalProperty_KEYBOARDPROPERTIES = [[SDLGlobalProperty alloc] initWithValue:@"KEYBOARDPROPERTIES"]; + } + return SDLGlobalProperty_KEYBOARDPROPERTIES; +} + +@end diff --git a/SmartDeviceLink/SDLGlobals.h b/SmartDeviceLink/SDLGlobals.h new file mode 100644 index 000000000..2b6fe2c47 --- /dev/null +++ b/SmartDeviceLink/SDLGlobals.h @@ -0,0 +1,21 @@ +// +// SDLGlobals.h +// SmartDeviceLink-iOS +// +// Created by Joel Fischer on 8/5/15. +// Copyright (c) 2015 smartdevicelink. All rights reserved. +// + +#import <Foundation/Foundation.h> + +#define SDL_SYSTEM_VERSION_LESS_THAN(version) ([[[UIDevice currentDevice] systemVersion] compare:version options:NSNumericSearch] == NSOrderedAscending) + +@interface SDLGlobals : NSObject + +@property (assign, nonatomic, readonly) NSUInteger protocolVersion; +@property (assign, nonatomic, readonly) NSUInteger maxMTUSize; +@property (assign, nonatomic) NSUInteger maxHeadUnitVersion; + ++ (instancetype)globals; + +@end diff --git a/SmartDeviceLink/SDLGlobals.m b/SmartDeviceLink/SDLGlobals.m new file mode 100644 index 000000000..7f122c01e --- /dev/null +++ b/SmartDeviceLink/SDLGlobals.m @@ -0,0 +1,77 @@ +// +// SDLGlobals.m +// SmartDeviceLink-iOS +// +// Created by Joel Fischer on 8/5/15. +// Copyright (c) 2015 smartdevicelink. All rights reserved. +// + +#import "SDLGlobals.h" + +static const NSUInteger maxProxyVersion = 4; + + +@interface SDLGlobals () + +@property (assign, nonatomic) NSUInteger protocolVersion; + +@end + + +@implementation SDLGlobals + ++ (instancetype)globals { + static SDLGlobals *sharedGlobals = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + sharedGlobals = [[SDLGlobals alloc] init]; + }); + + return sharedGlobals; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + _protocolVersion = 1; + _maxHeadUnitVersion = 0; + + return self; +} + + +#pragma mark - Custom Getters / Setters + +- (void)setMaxHeadUnitVersion:(NSUInteger)maxHeadUnitVersion { + self.protocolVersion = MIN(maxHeadUnitVersion, maxProxyVersion); + + _maxHeadUnitVersion = maxHeadUnitVersion; +} + +- (NSUInteger)maxMTUSize { + switch (self.protocolVersion) { + case 1: // fallthrough + case 2: { + // HAX: This was set to 1024 at some point, for an unknown reason. We can't change it because of backward compatibility & validation concerns. The actual MTU for v1/2 is 1500 bytes. + return 1024; + } break; + case 3: // fallthrough + case 4: { + // If the head unit isn't running v3/4, but that's the connection scheme we're using, then we have to know that they could be running an MTU that's not 128k, so we default back to the v1/2 MTU for safety. + if (self.maxHeadUnitVersion > maxProxyVersion) { + return 1024; + } else { + return 131084; + } + } break; + default: { + NSAssert(NO, @"Unknown version number: %@", @(self.protocolVersion)); + return 0; + } + } +} + +@end diff --git a/SmartDeviceLink/SDLHMICapabilities.h b/SmartDeviceLink/SDLHMICapabilities.h new file mode 100644 index 000000000..6a84cec2c --- /dev/null +++ b/SmartDeviceLink/SDLHMICapabilities.h @@ -0,0 +1,26 @@ +// +// SDLHMICapabilities.h +// SmartDeviceLink-iOS + +#import "SDLRPCStruct.h" + +@interface SDLHMICapabilities : SDLRPCStruct + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + Availability of build in Nav. True: Available, False: Not Available + + Boolean value. Optional. + */ +@property (copy, nonatomic) NSNumber *navigation; + +/** + Availability of build in phone. True: Available, False: Not Available + + Boolean value. Optional. + */ +@property (copy, nonatomic) NSNumber *phoneCall; + +@end diff --git a/SmartDeviceLink/SDLHMICapabilities.m b/SmartDeviceLink/SDLHMICapabilities.m new file mode 100644 index 000000000..24b35be25 --- /dev/null +++ b/SmartDeviceLink/SDLHMICapabilities.m @@ -0,0 +1,54 @@ +// +// SDLHMICapabilities.m +// SmartDeviceLink-iOS + +#import "SDLHMICapabilities.h" + +#import "SDLNames.h" + + +@implementation SDLHMICapabilities + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + self = [super initWithDictionary:dict]; + if (!self) { + return nil; + } + + return self; +} + +- (void)setNavigation:(NSNumber *)navigation { + if (navigation != nil) { + store[NAMES_navigation] = navigation; + } else { + [store removeObjectForKey:NAMES_navigation]; + } +} + +- (NSNumber *)navigation { + return store[NAMES_navigation]; +} + +- (void)setPhoneCall:(NSNumber *)phoneCall { + if (phoneCall != nil) { + store[NAMES_phoneCall] = phoneCall; + } else { + [store removeObjectForKey:NAMES_phoneCall]; + } +} + +- (NSNumber *)phoneCall { + return store[NAMES_phoneCall]; +} + +@end diff --git a/SmartDeviceLink/SDLHMILevel.h b/SmartDeviceLink/SDLHMILevel.h new file mode 100644 index 000000000..426217465 --- /dev/null +++ b/SmartDeviceLink/SDLHMILevel.h @@ -0,0 +1,76 @@ +// SDLHMILevel.h +// + + +#import "SDLEnum.h" + +/** + * Specifies current level of the HMI. An HMI level indicates the degree of user interaction possible through the HMI (e.g. TTS only, display only, VR, etc.). The HMI level varies for an application based on the type of display (i.e. Nav or non-Nav) and the user directing "focus" to other applications (e.g. phone, other mobile applications, etc.) + * + * @since SDL 1.0 + */ +@interface SDLHMILevel : SDLEnum { +} + +/** + * Return HMILevel status (FULL, LIMITED, BACKGROUND, NONE) + * + * @param value String value to retrieve the object for + * + * @return Current HMI level + */ ++ (SDLHMILevel *)valueOf:(NSString *)value; + +/** + * Store all possible SDLHMILevel values + * + * @return an array with all possible HMILevel values inside + */ ++ (NSArray *)values; + +/** + * The application has full use of the SDL HMI. The app may output via TTS, display, or streaming audio and may gather input via VR, Menu, and button presses + * + * @return the HMILevel with value of *FULL* + */ ++ (SDLHMILevel *)FULL; + +/** + * This HMI Level is only defined for a media application using an HMI with an 8 inch touchscreen (Nav) system. The application's <i>Show</i> text is displayed and it receives button presses from media-oriented buttons (SEEKRIGHT, SEEKLEFT, TUNEUP, TUNEDOWN, PRESET_0-9) + * + * @return the HMILevel with value of *LIMITED* + */ ++ (SDLHMILevel *)LIMITED; + +/** + * App cannot interact with user via TTS, VR, Display or Button Presses. App can perform the following operations: + * + * @discussion <ul> + * <li>Operation : AddCommand</li> + * <li>Operation : DeleteCommand</li> + * <li>Operation : AddSubMenu</li> + * <li>Operation : DeleteSubMenu</li> + * <li>Operation : CreateInteractionChoiceSet</li> + * <li>Operation : DeleteInteractionChoiceSet</li> + * <li>Operation : SubscribeButton</li> + * <li>Operation : UnsubscribeButton</li> + * <li>Operation : Show</li> + * <li>Operation : UnregisterAppInterface</li> + * <li>Operation : ResetGlobalProperties</li> + * <li>Operation : SetGlobalProperties</li> + * </ul> + * + * @return the HMILevel with value of *BACKGROUND* + */ ++ (SDLHMILevel *)BACKGROUND; + +/** + * Application has been discovered by SDL, but it cannot send any requests or receive any notifications + * + * @discussion An HMILevel of NONE can also mean that the user has exited the application by saying "exit appname" or selecting "exit" from the application's menu. When this happens, the application still has an active interface registration with SDL and all SDL resources the application has created (e.g. Choice Sets, subscriptions, etc.) still exist. But while the HMILevel is NONE, the application cannot send any messages to SYNC, except UnregisterAppInterface + * + * @return the HMILevel with value of *NONE* + */ ++ (SDLHMILevel *)NONE; + +@end diff --git a/SmartDeviceLink/SDLHMILevel.m b/SmartDeviceLink/SDLHMILevel.m new file mode 100644 index 000000000..88b0be5b6 --- /dev/null +++ b/SmartDeviceLink/SDLHMILevel.m @@ -0,0 +1,65 @@ +// SDLHMILevel.m +// + + +#import "SDLHMILevel.h" + +SDLHMILevel *SDLHMILevel_FULL = nil; +SDLHMILevel *SDLHMILevel_LIMITED = nil; +SDLHMILevel *SDLHMILevel_BACKGROUND = nil; +SDLHMILevel *SDLHMILevel_NONE = nil; + +NSArray *SDLHMILevel_values = nil; + +@implementation SDLHMILevel + ++ (SDLHMILevel *)valueOf:(NSString *)value { + for (SDLHMILevel *item in SDLHMILevel.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLHMILevel_values == nil) { + SDLHMILevel_values = @[ + [SDLHMILevel FULL], + [SDLHMILevel LIMITED], + [SDLHMILevel BACKGROUND], + [SDLHMILevel NONE] + ]; + } + return SDLHMILevel_values; +} + ++ (SDLHMILevel *)FULL { + if (SDLHMILevel_FULL == nil) { + SDLHMILevel_FULL = [[SDLHMILevel alloc] initWithValue:@"FULL"]; + } + return SDLHMILevel_FULL; +} + ++ (SDLHMILevel *)LIMITED { + if (SDLHMILevel_LIMITED == nil) { + SDLHMILevel_LIMITED = [[SDLHMILevel alloc] initWithValue:@"LIMITED"]; + } + return SDLHMILevel_LIMITED; +} + ++ (SDLHMILevel *)BACKGROUND { + if (SDLHMILevel_BACKGROUND == nil) { + SDLHMILevel_BACKGROUND = [[SDLHMILevel alloc] initWithValue:@"BACKGROUND"]; + } + return SDLHMILevel_BACKGROUND; +} + ++ (SDLHMILevel *)NONE { + if (SDLHMILevel_NONE == nil) { + SDLHMILevel_NONE = [[SDLHMILevel alloc] initWithValue:@"NONE"]; + } + return SDLHMILevel_NONE; +} + +@end diff --git a/SmartDeviceLink/SDLHMIPermissions.h b/SmartDeviceLink/SDLHMIPermissions.h new file mode 100644 index 000000000..49a7025a7 --- /dev/null +++ b/SmartDeviceLink/SDLHMIPermissions.h @@ -0,0 +1,44 @@ +// SDLHMIPermissions.h +// + + +#import "SDLRPCMessage.h" + +/** + * Defining sets of HMI levels, which are permitted or prohibited for a given RPC. + * + * @since SDL 2.0 + */ +@interface SDLHMIPermissions : SDLRPCStruct { +} + +/** + * Constructs a newly allocated SDLHMIPermissions object + */ +- (instancetype)init; + +/** + * Constructs a newly allocated SDLHMIPermissions object indicated by the dictionary parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract a set of all HMI levels that are permitted for this given RPC + * + * @see SDLHMILevel + * + * Required, Array of SDLHMILevel, Array size 0 - 100 + */ +@property (strong) NSMutableArray *allowed; + +/** + * @abstract a set of all HMI levels that are prohibited for this given RPC + * + * @see SDLHMILevel + * + * Required, Array of SDLHMILevel, Array size 0 - 100 + */ +@property (strong) NSMutableArray *userDisallowed; + +@end diff --git a/SmartDeviceLink/SDLHMIPermissions.m b/SmartDeviceLink/SDLHMIPermissions.m new file mode 100644 index 000000000..29555bf59 --- /dev/null +++ b/SmartDeviceLink/SDLHMIPermissions.m @@ -0,0 +1,66 @@ +// SDLHMIPermissions.m +// + + +#import "SDLHMIPermissions.h" + +#import "SDLHMILevel.h" +#import "SDLNames.h" + +@implementation SDLHMIPermissions + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setAllowed:(NSMutableArray *)allowed { + if (allowed != nil) { + [store setObject:allowed forKey:NAMES_allowed]; + } else { + [store removeObjectForKey:NAMES_allowed]; + } +} + +- (NSMutableArray *)allowed { + NSMutableArray *array = [store objectForKey:NAMES_allowed]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLHMILevel.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSString *enumString in array) { + [newList addObject:[SDLHMILevel valueOf:enumString]]; + } + return newList; + } +} + +- (void)setUserDisallowed:(NSMutableArray *)userDisallowed { + if (userDisallowed != nil) { + [store setObject:userDisallowed forKey:NAMES_userDisallowed]; + } else { + [store removeObjectForKey:NAMES_userDisallowed]; + } +} + +- (NSMutableArray *)userDisallowed { + NSMutableArray *array = [store objectForKey:NAMES_userDisallowed]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLHMILevel.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSString *enumString in array) { + [newList addObject:[SDLHMILevel valueOf:enumString]]; + } + return newList; + } +} + +@end diff --git a/SmartDeviceLink/SDLHMIZoneCapabilities.h b/SmartDeviceLink/SDLHMIZoneCapabilities.h new file mode 100644 index 000000000..d63655bd8 --- /dev/null +++ b/SmartDeviceLink/SDLHMIZoneCapabilities.h @@ -0,0 +1,39 @@ +// SDLHmiZoneCapabilities.h +// + + +#import "SDLEnum.h" + +/** + * Specifies HMI Zones in the vehicle. + * + * @since SDL 1.0 + */ +@interface SDLHMIZoneCapabilities : SDLEnum { +} + +/** + * @abstract SDLHMIZoneCapabilities + * @param value The value of the string to get an object for + * @return SDLHMIZoneCapabilities + */ ++ (SDLHMIZoneCapabilities *)valueOf:(NSString *)value; + +/** + * @abstract store all possible SDLHMIZoneCapabilities values + * @return an array with all possible SDLHMIZoneCapabilities values inside + */ ++ (NSArray *)values; + +/** + * @abstract Indicates HMI available for front seat passengers. + * @return a SDLHMIZoneCapabilities with value of *FRONT* + */ ++ (SDLHMIZoneCapabilities *)FRONT; +/** + * @abstract Indicates HMI available for rear seat passengers. + * @return a SDLHMIZoneCapabilities with value of *BACK* + */ ++ (SDLHMIZoneCapabilities *)BACK; + +@end diff --git a/SmartDeviceLink/SDLHMIZoneCapabilities.m b/SmartDeviceLink/SDLHMIZoneCapabilities.m new file mode 100644 index 000000000..56eacf671 --- /dev/null +++ b/SmartDeviceLink/SDLHMIZoneCapabilities.m @@ -0,0 +1,47 @@ +// SDLHMIZoneCapabilities.m +// + + +#import "SDLHMIZoneCapabilities.h" + +SDLHMIZoneCapabilities *SDLHMIZoneCapabilities_FRONT = nil; +SDLHMIZoneCapabilities *SDLHMIZoneCapabilities_BACK = nil; + +NSArray *SDLHMIZoneCapabilities_values = nil; + +@implementation SDLHMIZoneCapabilities + ++ (SDLHMIZoneCapabilities *)valueOf:(NSString *)value { + for (SDLHMIZoneCapabilities *item in SDLHMIZoneCapabilities.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLHMIZoneCapabilities_values == nil) { + SDLHMIZoneCapabilities_values = @[ + SDLHMIZoneCapabilities.FRONT, + SDLHMIZoneCapabilities.BACK, + ]; + } + return SDLHMIZoneCapabilities_values; +} + ++ (SDLHMIZoneCapabilities *)FRONT { + if (SDLHMIZoneCapabilities_FRONT == nil) { + SDLHMIZoneCapabilities_FRONT = [[SDLHMIZoneCapabilities alloc] initWithValue:@"FRONT"]; + } + return SDLHMIZoneCapabilities_FRONT; +} + ++ (SDLHMIZoneCapabilities *)BACK { + if (SDLHMIZoneCapabilities_BACK == nil) { + SDLHMIZoneCapabilities_BACK = [[SDLHMIZoneCapabilities alloc] initWithValue:@"BACK"]; + } + return SDLHMIZoneCapabilities_BACK; +} + +@end diff --git a/SmartDeviceLink/SDLHeadLampStatus.h b/SmartDeviceLink/SDLHeadLampStatus.h new file mode 100644 index 000000000..cc1586122 --- /dev/null +++ b/SmartDeviceLink/SDLHeadLampStatus.h @@ -0,0 +1,33 @@ +// SDLHeadLampStatus.h +// + +#import "SDLRPCMessage.h" + +@class SDLAmbientLightStatus; + + +/** + * Status of the head lamps + */ +@interface SDLHeadLampStatus : SDLRPCStruct { +} +/** + * @abstract Constructs a new SDLHeadLampStatus object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLHeadLampStatus object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; +/** + * @abstract A boolean value. Status of the low beam lamps. + */ +@property (strong) NSNumber *lowBeamsOn; +/** + * @abstract A boolean value. Status of the high beam lamps. + */ +@property (strong) NSNumber *highBeamsOn; +@property (strong) SDLAmbientLightStatus *ambientLightSensorStatus; +@end
\ No newline at end of file diff --git a/SmartDeviceLink/SDLHeadLampStatus.m b/SmartDeviceLink/SDLHeadLampStatus.m new file mode 100644 index 000000000..44ed87b44 --- /dev/null +++ b/SmartDeviceLink/SDLHeadLampStatus.m @@ -0,0 +1,65 @@ +// SDLHeadLampStatus.m +// + +#import "SDLHeadLampStatus.h" + +#import "SDLAmbientLightStatus.h" +#import "SDLNames.h" + + +@implementation SDLHeadLampStatus + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setLowBeamsOn:(NSNumber *)lowBeamsOn { + if (lowBeamsOn != nil) { + [store setObject:lowBeamsOn forKey:NAMES_lowBeamsOn]; + } else { + [store removeObjectForKey:NAMES_lowBeamsOn]; + } +} + +- (NSNumber *)lowBeamsOn { + return [store objectForKey:NAMES_lowBeamsOn]; +} + +- (void)setHighBeamsOn:(NSNumber *)highBeamsOn { + if (highBeamsOn != nil) { + [store setObject:highBeamsOn forKey:NAMES_highBeamsOn]; + } else { + [store removeObjectForKey:NAMES_highBeamsOn]; + } +} + +- (NSNumber *)highBeamsOn { + return [store objectForKey:NAMES_highBeamsOn]; +} + +- (void)setAmbientLightSensorStatus:(SDLAmbientLightStatus *)ambientLightSensorStatus { + if (ambientLightSensorStatus != nil) { + [store setObject:ambientLightSensorStatus forKey:NAMES_ambientLightSensorStatus]; + } else { + [store removeObjectForKey:NAMES_ambientLightSensorStatus]; + } +} + +- (SDLAmbientLightStatus *)ambientLightSensorStatus { + NSObject *obj = [store objectForKey:NAMES_ambientLightSensorStatus]; + if (obj == nil || [obj isKindOfClass:SDLAmbientLightStatus.class]) { + return (SDLAmbientLightStatus *)obj; + } else { + return [SDLAmbientLightStatus valueOf:(NSString *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLHexUtility.h b/SmartDeviceLink/SDLHexUtility.h new file mode 100644 index 000000000..7b639a7af --- /dev/null +++ b/SmartDeviceLink/SDLHexUtility.h @@ -0,0 +1,13 @@ +// +// SDLHexUtility.h +// SmartDeviceLink +// + +#import <Foundation/Foundation.h> + +@interface SDLHexUtility : NSObject + ++ (NSString *)getHexString:(UInt8 *)bytes length:(NSUInteger)length; ++ (NSString *)getHexString:(NSData *)data; + +@end diff --git a/SmartDeviceLink/SDLHexUtility.m b/SmartDeviceLink/SDLHexUtility.m new file mode 100644 index 000000000..0787d804a --- /dev/null +++ b/SmartDeviceLink/SDLHexUtility.m @@ -0,0 +1,60 @@ +// +// SDLHexUtility.m +// SmartDeviceLink +// + +#import "SDLHexUtility.h" + +@implementation SDLHexUtility + +// Using this function as a fail-safe, because we know this is successful. ++ (NSString *)getHexString:(UInt8 *)bytes length:(NSUInteger)length { + NSMutableString *ret = [NSMutableString stringWithCapacity:(length * 2)]; + for (int i = 0; i < length; i++) { + [ret appendFormat:@"%02X", ((Byte *)bytes)[i]]; + } + + return ret; +} + +static inline char itoh(int i) { + if (i > 9) { + return 'A' + (i - 10); + } + + return '0' + i; +} + +NSString *getHexString(NSData *data) { + NSUInteger length; + unsigned char *buffer, *bytes; + + length = data.length; + bytes = (unsigned char *)data.bytes; + buffer = malloc(length * 2); + + for (NSUInteger i = 0; i < length; i++) { + buffer[i * 2] = itoh((bytes[i] >> 4) & 0xF); + buffer[(i * 2) + 1] = itoh(bytes[i] & 0xF); + } + + NSString *hexString = [[NSString alloc] initWithBytesNoCopy:buffer + length:length * 2 + encoding:NSASCIIStringEncoding + freeWhenDone:YES]; + // HAX: https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/#//apple_ref/occ/instm/NSString/initWithBytesNoCopy:length:encoding:freeWhenDone: + // If there is an error allocating the string, we must free the buffer and fall back to the less performant method. + if (!hexString) { + free(buffer); + hexString = [SDLHexUtility getHexString:bytes length:length]; + } + + return hexString; +} + ++ (NSString *)getHexString:(NSData *)data { + return getHexString(data); +} + + +@end diff --git a/SmartDeviceLink/SDLIAPSession.h b/SmartDeviceLink/SDLIAPSession.h new file mode 100644 index 000000000..d21343894 --- /dev/null +++ b/SmartDeviceLink/SDLIAPSession.h @@ -0,0 +1,27 @@ +// +// SDLIAPSession.h +// + +#import "SDLIAPSessionDelegate.h" +#import <ExternalAccessory/ExternalAccessory.h> +#import <Foundation/Foundation.h> + +@class SDLStreamDelegate; + +typedef void (^SessionCompletionHandler)(BOOL success); + +@interface SDLIAPSession : NSObject + +@property (strong, atomic) EAAccessory *accessory; +@property (strong, atomic) NSString *protocol; +@property (strong, atomic) EASession *easession; +@property (weak) id<SDLIAPSessionDelegate> delegate; +@property (strong, atomic) SDLStreamDelegate *streamDelegate; + +- (instancetype)initWithAccessory:(EAAccessory *)accessory + forProtocol:(NSString *)protocol; + +- (BOOL)start; +- (void)stop; + +@end diff --git a/SmartDeviceLink/SDLIAPSession.m b/SmartDeviceLink/SDLIAPSession.m new file mode 100644 index 000000000..5020b2081 --- /dev/null +++ b/SmartDeviceLink/SDLIAPSession.m @@ -0,0 +1,156 @@ +// +// SDLIAPSession.m +// + +#import "SDLIAPSession.h" +#import "SDLDebugTool.h" +#import "SDLStreamDelegate.h" +#import "SDLTimer.h" + + +@interface SDLIAPSession () + +@property (assign) BOOL isInputStreamOpen; +@property (assign) BOOL isOutputStreamOpen; + +@end + + +@implementation SDLIAPSession + +#pragma mark - Lifecycle + +- (instancetype)initWithAccessory:(EAAccessory *)accessory forProtocol:(NSString *)protocol { + NSString *logMessage = [NSString stringWithFormat:@"SDLIAPSession initWithAccessory:%@ forProtocol:%@", accessory, protocol]; + [SDLDebugTool logInfo:logMessage]; + + self = [super init]; + if (self) { + _delegate = nil; + _accessory = accessory; + _protocol = protocol; + _streamDelegate = nil; + _easession = nil; + _isInputStreamOpen = NO; + _isOutputStreamOpen = NO; + } + return self; +} + + +#pragma mark - Public Stream Lifecycle + +- (BOOL)start { + __weak typeof(self) weakSelf = self; + + NSString *logMessage = [NSString stringWithFormat:@"Opening EASession withAccessory:%@ forProtocol:%@", _accessory.name, _protocol]; + [SDLDebugTool logInfo:logMessage]; + + if ((self.easession = [[EASession alloc] initWithAccessory:_accessory forProtocol:_protocol])) { + __strong typeof(self) strongSelf = weakSelf; + + [SDLDebugTool logInfo:@"Created Session Object"]; + + strongSelf.streamDelegate.streamErrorHandler = [self streamErroredHandler]; + strongSelf.streamDelegate.streamOpenHandler = [self streamOpenedHandler]; + + [strongSelf startStream:weakSelf.easession.outputStream]; + [strongSelf startStream:weakSelf.easession.inputStream]; + + return YES; + + } else { + [SDLDebugTool logInfo:@"Error: Could Not Create Session Object"]; + return NO; + } +} + +- (void)stop { + [self stopStream:self.easession.outputStream]; + [self stopStream:self.easession.inputStream]; + self.easession = nil; +} + + +#pragma mark - Private Stream Lifecycle Helpers + +- (void)startStream:(NSStream *)stream { + stream.delegate = self.streamDelegate; + [stream scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; + [stream open]; +} + +- (void)stopStream:(NSStream *)stream { + // Verify stream is in a state that can be closed. + // (N.B. Closing a stream that has not been opened has very, very bad effects.) + + // When you disconect the cable you get a stream end event and come here but stream is already in closed state. + // Still need to remove from run loop. + + NSUInteger status1 = stream.streamStatus; + if (status1 != NSStreamStatusNotOpen && + status1 != NSStreamStatusClosed) { + [stream close]; + } + + [stream removeFromRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; + [stream setDelegate:nil]; + + NSUInteger status2 = stream.streamStatus; + if (status2 == NSStreamStatusClosed) { + if (stream == [self.easession inputStream]) { + [SDLDebugTool logInfo:@"Input Stream Closed"]; + } else if (stream == [self.easession outputStream]) { + [SDLDebugTool logInfo:@"Output Stream Closed"]; + } + } +} + + +#pragma mark - Stream Handlers + +- (SDLStreamOpenHandler)streamOpenedHandler { + __weak typeof(self) weakSelf = self; + + return ^(NSStream *stream) { + __strong typeof(weakSelf) strongSelf = weakSelf; + + if (stream == [strongSelf.easession outputStream]) { + [SDLDebugTool logInfo:@"Output Stream Opened"]; + strongSelf.isOutputStreamOpen = YES; + } else if (stream == [strongSelf.easession inputStream]) { + [SDLDebugTool logInfo:@"Input Stream Opened"]; + strongSelf.isInputStreamOpen = YES; + } + + // When both streams are open, session initialization is complete. Let the delegate know. + if (strongSelf.isInputStreamOpen && strongSelf.isOutputStreamOpen) { + [strongSelf.delegate onSessionInitializationCompleteForSession:weakSelf]; + } + }; +} + +- (SDLStreamErrorHandler)streamErroredHandler { + __weak typeof(self) weakSelf = self; + + return ^(NSStream *stream) { + __strong typeof(weakSelf) strongSelf = weakSelf; + + [SDLDebugTool logInfo:@"Stream Error"]; + [strongSelf.delegate onSessionStreamsEnded:strongSelf]; + }; +} + + +#pragma mark - Lifecycle Destruction + +- (void)dealloc { + self.delegate = nil; + self.accessory = nil; + self.protocol = nil; + self.streamDelegate = nil; + self.easession = nil; + [SDLDebugTool logInfo:@"SDLIAPSession Dealloc"]; +} + +@end diff --git a/SmartDeviceLink/SDLIAPSessionDelegate.h b/SmartDeviceLink/SDLIAPSessionDelegate.h new file mode 100644 index 000000000..6ec7e189b --- /dev/null +++ b/SmartDeviceLink/SDLIAPSessionDelegate.h @@ -0,0 +1,13 @@ +// +// SDLIAPSessionDelegate.h +// + +#import <Foundation/Foundation.h> +@class SDLIAPSession; + +@protocol SDLIAPSessionDelegate + +- (void)onSessionInitializationCompleteForSession:(SDLIAPSession *)session; +- (void)onSessionStreamsEnded:(SDLIAPSession *)session; + +@end diff --git a/SmartDeviceLink/SDLIAPTransport.h b/SmartDeviceLink/SDLIAPTransport.h new file mode 100644 index 000000000..ff082b9b3 --- /dev/null +++ b/SmartDeviceLink/SDLIAPTransport.h @@ -0,0 +1,15 @@ +// SDLIAPTransport.h +// + +#import <ExternalAccessory/ExternalAccessory.h> + +#import "SDLAbstractTransport.h" +#import "SDLIAPSessionDelegate.h" + + +@interface SDLIAPTransport : SDLAbstractTransport <SDLIAPSessionDelegate> + +@property (strong, atomic) SDLIAPSession *controlSession; +@property (strong, atomic) SDLIAPSession *session; + +@end diff --git a/SmartDeviceLink/SDLIAPTransport.m b/SmartDeviceLink/SDLIAPTransport.m new file mode 100644 index 000000000..5cf4ceb21 --- /dev/null +++ b/SmartDeviceLink/SDLIAPTransport.m @@ -0,0 +1,477 @@ +// SDLIAPTransport.h +// + + +#import <Foundation/Foundation.h> +#import <UIKit/UIKit.h> + +#import "EAAccessoryManager+SDLProtocols.h" +#import "SDLDebugTool.h" +#import "SDLGlobals.h" +#import "SDLIAPSession.h" +#import "SDLIAPTransport.h" +#import "SDLIAPTransport.h" +#import "SDLSiphonServer.h" +#import "SDLStreamDelegate.h" +#import "SDLTimer.h" +#import <CommonCrypto/CommonDigest.h> + + +NSString *const legacyProtocolString = @"com.ford.sync.prot0"; +NSString *const controlProtocolString = @"com.smartdevicelink.prot0"; +NSString *const indexedProtocolStringPrefix = @"com.smartdevicelink.prot"; + +int const createSessionRetries = 1; +int const protocolIndexTimeoutSeconds = 20; +int const streamOpenTimeoutSeconds = 2; + + +@interface SDLIAPTransport () { + dispatch_queue_t _transmit_queue; + BOOL _alreadyDestructed; +} + +@property (assign) int retryCounter; +@property (assign) BOOL sessionSetupInProgress; +@property (strong) SDLTimer *protocolIndexTimer; + +@end + + +@implementation SDLIAPTransport + +- (instancetype)init { + if (self = [super init]) { + _alreadyDestructed = NO; + _session = nil; + _controlSession = nil; + _retryCounter = 0; + _sessionSetupInProgress = NO; + _protocolIndexTimer = nil; + _transmit_queue = dispatch_queue_create("com.sdl.transport.iap.transmit", DISPATCH_QUEUE_SERIAL); + + [self sdl_startEventListening]; + [SDLSiphonServer init]; + } + + [SDLDebugTool logInfo:@"SDLIAPTransport Init"]; + + return self; +} + + +#pragma mark - Notification Subscriptions + +- (void)sdl_startEventListening { + [SDLDebugTool logInfo:@"SDLIAPTransport Listening For Events"]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(sdl_accessoryConnected:) + name:EAAccessoryDidConnectNotification + object:nil]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(sdl_accessoryDisconnected:) + name:EAAccessoryDidDisconnectNotification + object:nil]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(sdl_applicationWillEnterForeground:) + name:UIApplicationWillEnterForegroundNotification + object:nil]; +} + +- (void)sdl_stopEventListening { + [SDLDebugTool logInfo:@"SDLIAPTransport Stopped Listening For Events"]; + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + +#pragma mark - EAAccessory Notifications + +- (void)sdl_accessoryConnected:(NSNotification *)notification { + NSMutableString *logMessage = [NSMutableString stringWithFormat:@"Accessory Connected, Opening in %0.03fs", self.retryDelay]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_Transport_iAP toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + + self.retryCounter = 0; + [self performSelector:@selector(connect) withObject:nil afterDelay:self.retryDelay]; +} + +- (void)sdl_accessoryDisconnected:(NSNotification *)notification { + [SDLDebugTool logInfo:@"Accessory Disconnected Event" withType:SDLDebugType_Transport_iAP toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + + // Only check for the data session, the control session is handled separately + EAAccessory *accessory = [notification.userInfo objectForKey:EAAccessoryKey]; + if (accessory.connectionID == self.session.accessory.connectionID) { + self.sessionSetupInProgress = NO; + [self disconnect]; + [self.delegate onTransportDisconnected]; + } +} + +- (void)sdl_applicationWillEnterForeground:(NSNotification *)notification { + [SDLDebugTool logInfo:@"App Foregrounded Event" withType:SDLDebugType_Transport_iAP toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + self.retryCounter = 0; + [self connect]; +} + + +#pragma mark - Stream Lifecycle + +- (void)connect { + if (!self.session && !self.sessionSetupInProgress) { + self.sessionSetupInProgress = YES; + [self sdl_establishSession]; + } else if (self.session) { + [SDLDebugTool logInfo:@"Session already established."]; + } else { + [SDLDebugTool logInfo:@"Session setup already in progress."]; + } +} + +- (void)disconnect { + [SDLDebugTool logInfo:@"IAP Disconnecting" withType:SDLDebugType_Transport_iAP toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + + // Only disconnect the data session, the control session does not stay open and is handled separately + if (self.session != nil) { + [self.session stop]; + self.session = nil; + } +} + + +#pragma mark - Creating Session Streams + +- (void)sdl_establishSession { + [SDLDebugTool logInfo:@"Attempting To Connect"]; + if (self.retryCounter < createSessionRetries) { + // We should be attempting to connect + self.retryCounter++; + EAAccessory *accessory = nil; + + // Determine if we can start a multi-app session or a legacy (single-app) session + if ((accessory = [EAAccessoryManager findAccessoryForProtocol:controlProtocolString])) { + [self sdl_createIAPControlSessionWithAccessory:accessory]; + } else if ((accessory = [EAAccessoryManager findAccessoryForProtocol:legacyProtocolString])) { + [self sdl_createIAPDataSessionWithAccessory:accessory forProtocol:legacyProtocolString]; + } else { + // No compatible accessory + [SDLDebugTool logInfo:@"No accessory supporting a required sync protocol was found."]; + self.sessionSetupInProgress = NO; + } + } else { + // We are beyond the number of retries allowed + [SDLDebugTool logInfo:@"Create session retries exhausted."]; + self.sessionSetupInProgress = NO; + } +} + +- (void)sdl_createIAPControlSessionWithAccessory:(EAAccessory *)accessory { + [SDLDebugTool logInfo:@"Starting MultiApp Session"]; + self.controlSession = [[SDLIAPSession alloc] initWithAccessory:accessory forProtocol:controlProtocolString]; + + if (self.controlSession) { + self.controlSession.delegate = self; + + if (self.protocolIndexTimer == nil) { + self.protocolIndexTimer = [[SDLTimer alloc] initWithDuration:protocolIndexTimeoutSeconds repeat:NO]; + } else { + [self.protocolIndexTimer cancel]; + } + + __weak typeof(self) weakSelf = self; + void (^elapsedBlock)(void) = ^{ + __strong typeof(weakSelf) strongSelf = weakSelf; + + [SDLDebugTool logInfo:@"Protocol Index Timeout"]; + [strongSelf.controlSession stop]; + strongSelf.controlSession.streamDelegate = nil; + strongSelf.controlSession = nil; + [strongSelf sdl_retryEstablishSession]; + }; + self.protocolIndexTimer.elapsedBlock = elapsedBlock; + + SDLStreamDelegate *controlStreamDelegate = [SDLStreamDelegate new]; + self.controlSession.streamDelegate = controlStreamDelegate; + controlStreamDelegate.streamHasBytesHandler = [self sdl_controlStreamHasBytesHandlerForAccessory:accessory]; + controlStreamDelegate.streamEndHandler = [self sdl_controlStreamEndedHandler]; + controlStreamDelegate.streamErrorHandler = [self sdl_controlStreamErroredHandler]; + + if (![self.controlSession start]) { + [SDLDebugTool logInfo:@"Control Session Failed"]; + self.controlSession.streamDelegate = nil; + self.controlSession = nil; + [self sdl_retryEstablishSession]; + } + } else { + [SDLDebugTool logInfo:@"Failed MultiApp Control SDLIAPSession Initialization"]; + [self sdl_retryEstablishSession]; + } +} + +- (void)sdl_createIAPDataSessionWithAccessory:(EAAccessory *)accessory forProtocol:(NSString *)protocol { + [SDLDebugTool logInfo:@"Starting Data Session"]; + self.session = [[SDLIAPSession alloc] initWithAccessory:accessory forProtocol:protocol]; + if (self.session) { + self.session.delegate = self; + + SDLStreamDelegate *ioStreamDelegate = [[SDLStreamDelegate alloc] init]; + self.session.streamDelegate = ioStreamDelegate; + ioStreamDelegate.streamHasBytesHandler = [self sdl_dataStreamHasBytesHandler]; + ioStreamDelegate.streamEndHandler = [self sdl_dataStreamEndedHandler]; + ioStreamDelegate.streamErrorHandler = [self sdl_dataStreamErroredHandler]; + + if (![self.session start]) { + [SDLDebugTool logInfo:@"Data Session Failed"]; + self.session.streamDelegate = nil; + self.session = nil; + [self sdl_retryEstablishSession]; + } + } else { + [SDLDebugTool logInfo:@"Failed MultiApp Data SDLIAPSession Initialization"]; + [self sdl_retryEstablishSession]; + } +} + +- (void)sdl_retryEstablishSession { + // Current strategy disallows automatic retries. + self.sessionSetupInProgress = NO; +} + +// This gets called after both I/O streams of the session have opened. +- (void)onSessionInitializationCompleteForSession:(SDLIAPSession *)session { + // Control Session Opened + if ([controlProtocolString isEqualToString:session.protocol]) { + [SDLDebugTool logInfo:@"Control Session Established"]; + [self.protocolIndexTimer start]; + } + + // Data Session Opened + if (![controlProtocolString isEqualToString:session.protocol]) { + self.sessionSetupInProgress = NO; + [SDLDebugTool logInfo:@"Data Session Established"]; + [self.delegate onTransportConnected]; + } +} + + +#pragma mark - Session End + +// Retry establishSession on Stream End events only if it was the control session and we haven't already connected on non-control protocol +- (void)onSessionStreamsEnded:(SDLIAPSession *)session { + if (!self.session && [controlProtocolString isEqualToString:session.protocol]) { + [SDLDebugTool logInfo:@"onSessionStreamsEnded"]; + [session stop]; + [self sdl_retryEstablishSession]; + } +} + + +#pragma mark - Data Transmission + +- (void)sendData:(NSData *)data { + dispatch_async(_transmit_queue, ^{ + NSOutputStream *ostream = self.session.easession.outputStream; + NSMutableData *remainder = data.mutableCopy; + + while (remainder.length != 0) { + if (ostream.streamStatus == NSStreamStatusOpen && ostream.hasSpaceAvailable) { + NSInteger bytesWritten = [ostream write:remainder.bytes maxLength:remainder.length]; + + if (bytesWritten == -1) { + [SDLDebugTool logInfo:[NSString stringWithFormat:@"Error: %@", [ostream streamError]] withType:SDLDebugType_Transport_iAP toOutput:SDLDebugOutput_All]; + break; + } + + [remainder replaceBytesInRange:NSMakeRange(0, bytesWritten) withBytes:NULL length:0]; + } + } + }); +} + + +#pragma mark - Stream Handlers +#pragma mark Control Stream + +- (SDLStreamEndHandler)sdl_controlStreamEndedHandler { + __weak typeof(self) weakSelf = self; + + return ^(NSStream *stream) { + __strong typeof(weakSelf) strongSelf = weakSelf; + + [SDLDebugTool logInfo:@"Control Stream Event End"]; + + // End events come in pairs, only perform this once per set. + if (strongSelf.controlSession != nil) { + [strongSelf.protocolIndexTimer cancel]; + [strongSelf.controlSession stop]; + strongSelf.controlSession.streamDelegate = nil; + strongSelf.controlSession = nil; + [strongSelf sdl_retryEstablishSession]; + } + }; +} + +- (SDLStreamHasBytesHandler)sdl_controlStreamHasBytesHandlerForAccessory:(EAAccessory *)accessory { + __weak typeof(self) weakSelf = self; + + return ^(NSInputStream *istream) { + __strong typeof(weakSelf) strongSelf = weakSelf; + + [SDLDebugTool logInfo:@"Control Stream Received Data"]; + + // Read in the stream a single byte at a time + uint8_t buf[1]; + NSUInteger len = [istream read:buf maxLength:1]; + if (len > 0) { + NSString *logMessage = [NSString stringWithFormat:@"Switching to protocol %@", [@(buf[0]) stringValue]]; + [SDLDebugTool logInfo:logMessage]; + + // Destroy the control session + [strongSelf.protocolIndexTimer cancel]; + [strongSelf.controlSession stop]; + strongSelf.controlSession.streamDelegate = nil; + strongSelf.controlSession = nil; + + // Determine protocol string of the data session, then create that data session + NSString *indexedProtocolString = [NSString stringWithFormat:@"%@%@", indexedProtocolStringPrefix, @(buf[0])]; + dispatch_sync(dispatch_get_main_queue(), ^{ + [strongSelf sdl_createIAPDataSessionWithAccessory:accessory forProtocol:indexedProtocolString]; + }); + } + }; +} + +- (SDLStreamErrorHandler)sdl_controlStreamErroredHandler { + __weak typeof(self) weakSelf = self; + + return ^(NSStream *stream) { + __strong typeof(weakSelf) strongSelf = weakSelf; + + [SDLDebugTool logInfo:@"Stream Error"]; + [strongSelf.protocolIndexTimer cancel]; + [strongSelf.controlSession stop]; + strongSelf.controlSession.streamDelegate = nil; + strongSelf.controlSession = nil; + [strongSelf sdl_retryEstablishSession]; + }; +} + + +#pragma mark Data Stream + +- (SDLStreamEndHandler)sdl_dataStreamEndedHandler { + __weak typeof(self) weakSelf = self; + + return ^(NSStream *stream) { + __strong typeof(weakSelf) strongSelf = weakSelf; + + [SDLDebugTool logInfo:@"Data Stream Event End"]; + [strongSelf.session stop]; + strongSelf.session.streamDelegate = nil; + + if (![legacyProtocolString isEqualToString:strongSelf.session.protocol]) { + [strongSelf sdl_retryEstablishSession]; + } + + strongSelf.session = nil; + }; +} + +- (SDLStreamHasBytesHandler)sdl_dataStreamHasBytesHandler { + __weak typeof(self) weakSelf = self; + + return ^(NSInputStream *istream) { + __strong typeof(weakSelf) strongSelf = weakSelf; + + uint8_t buf[[SDLGlobals globals].maxMTUSize]; + while ([istream hasBytesAvailable]) { + NSInteger bytesRead = [istream read:buf maxLength:[SDLGlobals globals].maxMTUSize]; + NSData *dataIn = [NSData dataWithBytes:buf length:bytesRead]; + + if (bytesRead > 0) { + [strongSelf.delegate onDataReceived:dataIn]; + } else { + break; + } + } + }; +} + +- (SDLStreamErrorHandler)sdl_dataStreamErroredHandler { + __weak typeof(self) weakSelf = self; + + return ^(NSStream *stream) { + __strong typeof(weakSelf) strongSelf = weakSelf; + + [SDLDebugTool logInfo:@"Data Stream Error"]; + [strongSelf.session stop]; + strongSelf.session.streamDelegate = nil; + + if (![legacyProtocolString isEqualToString:strongSelf.session.protocol]) { + [strongSelf sdl_retryEstablishSession]; + } + + strongSelf.session = nil; + }; +} + +- (double)retryDelay { + const double min_value = 0.0; + const double max_value = 10.0; + double range_length = max_value - min_value; + + static double delay = 0; + + // HAX: This pull the app name and hashes it in an attempt to provide a more even distribution of retry delays. The evidence that this does so is anecdotal. A more ideal solution would be to use a list of known, installed SDL apps on the phone to try and deterministically generate an even delay. + if (delay == 0) { + NSString *appName = [[NSProcessInfo processInfo] processName]; + if (appName == nil) { + appName = @"noname"; + } + + // Run the app name through an md5 hasher + const char *ptr = [appName UTF8String]; + unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH]; + CC_MD5(ptr, (unsigned int)strlen(ptr), md5Buffer); + + // Generate a string of the hex hash + NSMutableString *output = [NSMutableString stringWithString:@"0x"]; + for (int i = 0; i < 8; i++) { + [output appendFormat:@"%02X", md5Buffer[i]]; + } + + // Transform the string into a number between 0 and 1 + unsigned long long firstHalf; + NSScanner *pScanner = [NSScanner scannerWithString:output]; + [pScanner scanHexLongLong:&firstHalf]; + double hashBasedValueInRange0to1 = ((double)firstHalf) / 0xffffffffffffffff; + + // Transform the number into a number between min and max + delay = ((range_length * hashBasedValueInRange0to1) + min_value); + } + + return delay; +} + + +#pragma mark - Lifecycle Destruction + +- (void)sdl_destructObjects { + if (!_alreadyDestructed) { + _alreadyDestructed = YES; + [self sdl_stopEventListening]; + self.controlSession = nil; + self.session = nil; + self.delegate = nil; + } +} + +- (void)dispose { + [self sdl_destructObjects]; +} + +- (void)dealloc { + [self sdl_destructObjects]; + [SDLDebugTool logInfo:@"SDLIAPTransport Dealloc" withType:SDLDebugType_Transport_iAP toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; +} + +@end diff --git a/SmartDeviceLink/SDLIgnitionStableStatus.h b/SmartDeviceLink/SDLIgnitionStableStatus.h new file mode 100644 index 000000000..96dcdfaa9 --- /dev/null +++ b/SmartDeviceLink/SDLIgnitionStableStatus.h @@ -0,0 +1,42 @@ +// SDLIgnitionStableStatus.h +// + + +#import "SDLEnum.h" + +/** + * Reflects the ignition switch stability. + * + * @since SDL 2.0 + */ +@interface SDLIgnitionStableStatus : SDLEnum { +} + +/** + * @abstract return SDLIgnitionStableStatus + * @param value The value of the string to get an object for + * @return SDLIgnitionStableStatus + */ ++ (SDLIgnitionStableStatus *)valueOf:(NSString *)value; + +/** + * @abstract store all possible SDLIgnitionStableStatus values + * @return an array with all possible SDLIgnitionStableStatus values inside + */ ++ (NSArray *)values; + +/** + * @abstract The current ignition switch status is considered not to be stable. + * @return the Ignition Stable Status with value of *IGNITION_SWITCH_NOT_STABLE* + */ ++ (SDLIgnitionStableStatus *)IGNITION_SWITCH_NOT_STABLE; + +/** + * @abstract The current ignition switch status is considered to be stable. + * @return the Ignition Stable Status with value of *IGNITION_SWITCH_STABLE* + */ ++ (SDLIgnitionStableStatus *)IGNITION_SWITCH_STABLE; + ++ (SDLIgnitionStableStatus *)MISSING_FROM_TRANSMITTER; + +@end diff --git a/SmartDeviceLink/SDLIgnitionStableStatus.m b/SmartDeviceLink/SDLIgnitionStableStatus.m new file mode 100644 index 000000000..868723b32 --- /dev/null +++ b/SmartDeviceLink/SDLIgnitionStableStatus.m @@ -0,0 +1,56 @@ +// SDLIgnitionStableStatus.m +// + + +#import "SDLIgnitionStableStatus.h" + +SDLIgnitionStableStatus *SDLIgnitionStableStatus_IGNITION_SWITCH_NOT_STABLE = nil; +SDLIgnitionStableStatus *SDLIgnitionStableStatus_IGNITION_SWITCH_STABLE = nil; +SDLIgnitionStableStatus *SDLIgnitionStableStatus_MISSING_FROM_TRANSMITTER = nil; + +NSArray *SDLIgnitionStableStatus_values = nil; + +@implementation SDLIgnitionStableStatus + ++ (SDLIgnitionStableStatus *)valueOf:(NSString *)value { + for (SDLIgnitionStableStatus *item in SDLIgnitionStableStatus.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLIgnitionStableStatus_values == nil) { + SDLIgnitionStableStatus_values = @[ + SDLIgnitionStableStatus.IGNITION_SWITCH_NOT_STABLE, + SDLIgnitionStableStatus.IGNITION_SWITCH_STABLE, + SDLIgnitionStableStatus.MISSING_FROM_TRANSMITTER, + ]; + } + return SDLIgnitionStableStatus_values; +} + ++ (SDLIgnitionStableStatus *)IGNITION_SWITCH_NOT_STABLE { + if (SDLIgnitionStableStatus_IGNITION_SWITCH_NOT_STABLE == nil) { + SDLIgnitionStableStatus_IGNITION_SWITCH_NOT_STABLE = [[SDLIgnitionStableStatus alloc] initWithValue:@"IGNITION_SWITCH_NOT_STABLE"]; + } + return SDLIgnitionStableStatus_IGNITION_SWITCH_NOT_STABLE; +} + ++ (SDLIgnitionStableStatus *)IGNITION_SWITCH_STABLE { + if (SDLIgnitionStableStatus_IGNITION_SWITCH_STABLE == nil) { + SDLIgnitionStableStatus_IGNITION_SWITCH_STABLE = [[SDLIgnitionStableStatus alloc] initWithValue:@"IGNITION_SWITCH_STABLE"]; + } + return SDLIgnitionStableStatus_IGNITION_SWITCH_STABLE; +} + ++ (SDLIgnitionStableStatus *)MISSING_FROM_TRANSMITTER { + if (SDLIgnitionStableStatus_MISSING_FROM_TRANSMITTER == nil) { + SDLIgnitionStableStatus_MISSING_FROM_TRANSMITTER = [[SDLIgnitionStableStatus alloc] initWithValue:@"MISSING_FROM_TRANSMITTER"]; + } + return SDLIgnitionStableStatus_MISSING_FROM_TRANSMITTER; +} + +@end diff --git a/SmartDeviceLink/SDLIgnitionStatus.h b/SmartDeviceLink/SDLIgnitionStatus.h new file mode 100644 index 000000000..fadb3f5f4 --- /dev/null +++ b/SmartDeviceLink/SDLIgnitionStatus.h @@ -0,0 +1,64 @@ +// SDLIgnitionStatus.h +// + + +#import "SDLEnum.h" + +/** + * Reflects the status of ignition.. + * + * @since SDL 2.0 + */ +@interface SDLIgnitionStatus : SDLEnum { +} + +/** + * @abstract return SDLIgnitionStatus + * @param value The value of the string to get an object for + * @return SDLIgnitionStatus object + */ ++ (SDLIgnitionStatus *)valueOf:(NSString *)value; + +/** + * @abstract store all possible SDLIgnitionStatus values + * @return an array with all possible SDLIgnitionStatus values inside + */ ++ (NSArray *)values; + +/** + * @abstract Ignition status currently unknown + * @return Ignition Status with value of *UNKNOWN* + */ ++ (SDLIgnitionStatus *)UNKNOWN; + +/** + * @abstract Ignition is off + * @return Ignition Status with value of *OFF* + */ ++ (SDLIgnitionStatus *)OFF; + +/** + * @abstract Ignition is in mode accessory + * @return Ignition Status with value of *ACCESSORY* + */ ++ (SDLIgnitionStatus *)ACCESSORY; + +/** + * @abstract Ignition is in mode run + * @return Ignition Status with value of *RUN* + */ ++ (SDLIgnitionStatus *)RUN; + +/** + * @abstract Ignition is in mode start + * @return Ignition Status with value of *START* + */ ++ (SDLIgnitionStatus *)START; + +/** + * @abstract Signal is invalid + * @return Ignition Status with value of *INVALID* + */ ++ (SDLIgnitionStatus *)INVALID; + +@end diff --git a/SmartDeviceLink/SDLIgnitionStatus.m b/SmartDeviceLink/SDLIgnitionStatus.m new file mode 100644 index 000000000..ff069f0a0 --- /dev/null +++ b/SmartDeviceLink/SDLIgnitionStatus.m @@ -0,0 +1,83 @@ +// SDLIgnitionStatus.m +// + + +#import "SDLIgnitionStatus.h" + +SDLIgnitionStatus *SDLIgnitionStatus_UNKNOWN = nil; +SDLIgnitionStatus *SDLIgnitionStatus_OFF = nil; +SDLIgnitionStatus *SDLIgnitionStatus_ACCESSORY = nil; +SDLIgnitionStatus *SDLIgnitionStatus_RUN = nil; +SDLIgnitionStatus *SDLIgnitionStatus_START = nil; +SDLIgnitionStatus *SDLIgnitionStatus_INVALID = nil; + +NSArray *SDLIgnitionStatus_values = nil; + +@implementation SDLIgnitionStatus + ++ (SDLIgnitionStatus *)valueOf:(NSString *)value { + for (SDLIgnitionStatus *item in SDLIgnitionStatus.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLIgnitionStatus_values == nil) { + SDLIgnitionStatus_values = @[ + SDLIgnitionStatus.UNKNOWN, + SDLIgnitionStatus.OFF, + SDLIgnitionStatus.ACCESSORY, + SDLIgnitionStatus.RUN, + SDLIgnitionStatus.START, + SDLIgnitionStatus.INVALID, + ]; + } + return SDLIgnitionStatus_values; +} + ++ (SDLIgnitionStatus *)UNKNOWN { + if (SDLIgnitionStatus_UNKNOWN == nil) { + SDLIgnitionStatus_UNKNOWN = [[SDLIgnitionStatus alloc] initWithValue:@"UNKNOWN"]; + } + return SDLIgnitionStatus_UNKNOWN; +} + ++ (SDLIgnitionStatus *)OFF { + if (SDLIgnitionStatus_OFF == nil) { + SDLIgnitionStatus_OFF = [[SDLIgnitionStatus alloc] initWithValue:@"OFF"]; + } + return SDLIgnitionStatus_OFF; +} + ++ (SDLIgnitionStatus *)ACCESSORY { + if (SDLIgnitionStatus_ACCESSORY == nil) { + SDLIgnitionStatus_ACCESSORY = [[SDLIgnitionStatus alloc] initWithValue:@"ACCESSORY"]; + } + return SDLIgnitionStatus_ACCESSORY; +} + ++ (SDLIgnitionStatus *)RUN { + if (SDLIgnitionStatus_RUN == nil) { + SDLIgnitionStatus_RUN = [[SDLIgnitionStatus alloc] initWithValue:@"RUN"]; + } + return SDLIgnitionStatus_RUN; +} + ++ (SDLIgnitionStatus *)START { + if (SDLIgnitionStatus_START == nil) { + SDLIgnitionStatus_START = [[SDLIgnitionStatus alloc] initWithValue:@"START"]; + } + return SDLIgnitionStatus_START; +} + ++ (SDLIgnitionStatus *)INVALID { + if (SDLIgnitionStatus_INVALID == nil) { + SDLIgnitionStatus_INVALID = [[SDLIgnitionStatus alloc] initWithValue:@"INVALID"]; + } + return SDLIgnitionStatus_INVALID; +} + +@end diff --git a/SmartDeviceLink/SDLImage.h b/SmartDeviceLink/SDLImage.h new file mode 100644 index 000000000..993107ec3 --- /dev/null +++ b/SmartDeviceLink/SDLImage.h @@ -0,0 +1,42 @@ +// SDLImage.h +// + +#import "SDLRPCMessage.h" + +@class SDLImageType; + + +/** + *Specifies, which image shall be used, e.g. in SDLAlerts or on SDLSoftbuttons provided the display supports it. + * + * @since SDL 2.0 + */ +@interface SDLImage : SDLRPCStruct { +} + +/** + * Constructs a newly allocated SDLImage object + */ +- (instancetype)init; + +/** + * Constructs a newly allocated SDLImage object indicated by the dictionary parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract The static hex icon value or the binary image file name identifier (sent by SDLPutFile) + * + * Required, max length = 65535 + */ +@property (strong) NSString *value; + +/** + * @abstract Describes, whether it is a static or dynamic image + * + * Required + */ +@property (strong) SDLImageType *imageType; + +@end diff --git a/SmartDeviceLink/SDLImage.m b/SmartDeviceLink/SDLImage.m new file mode 100644 index 000000000..ef646f794 --- /dev/null +++ b/SmartDeviceLink/SDLImage.m @@ -0,0 +1,53 @@ +// SDLImage.m +// + +#import "SDLImage.h" + +#import "SDLImageType.h" +#import "SDLNames.h" + + +@implementation SDLImage + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setValue:(NSString *)value { + if (value != nil) { + [store setObject:value forKey:NAMES_value]; + } else { + [store removeObjectForKey:NAMES_value]; + } +} + +- (NSString *)value { + return [store objectForKey:NAMES_value]; +} + +- (void)setImageType:(SDLImageType *)imageType { + if (imageType != nil) { + [store setObject:imageType forKey:NAMES_imageType]; + } else { + [store removeObjectForKey:NAMES_imageType]; + } +} + +- (SDLImageType *)imageType { + NSObject *obj = [store objectForKey:NAMES_imageType]; + if (obj == nil || [obj isKindOfClass:SDLImageType.class]) { + return (SDLImageType *)obj; + } else { + return [SDLImageType valueOf:(NSString *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLImageField.h b/SmartDeviceLink/SDLImageField.h new file mode 100644 index 000000000..eb0942e79 --- /dev/null +++ b/SmartDeviceLink/SDLImageField.h @@ -0,0 +1,20 @@ +// SDLImageField.h +// + +#import "SDLRPCMessage.h" + +@class SDLImageFieldName; +@class SDLImageResolution; + + +@interface SDLImageField : SDLRPCStruct { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) SDLImageFieldName *name; +@property (strong) NSMutableArray *imageTypeSupported; +@property (strong) SDLImageResolution *imageResolution; + +@end diff --git a/SmartDeviceLink/SDLImageField.m b/SmartDeviceLink/SDLImageField.m new file mode 100644 index 000000000..af4f15517 --- /dev/null +++ b/SmartDeviceLink/SDLImageField.m @@ -0,0 +1,81 @@ +// SDLImageField.m +// + +#import "SDLImageField.h" + +#import "SDLFileType.h" +#import "SDLImageFieldName.h" +#import "SDLImageResolution.h" +#import "SDLNames.h" + + +@implementation SDLImageField + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setName:(SDLImageFieldName *)name { + if (name != nil) { + [store setObject:name forKey:NAMES_name]; + } else { + [store removeObjectForKey:NAMES_name]; + } +} + +- (SDLImageFieldName *)name { + NSObject *obj = [store objectForKey:NAMES_name]; + if (obj == nil || [obj isKindOfClass:SDLImageFieldName.class]) { + return (SDLImageFieldName *)obj; + } else { + return [SDLImageFieldName valueOf:(NSString *)obj]; + } +} + +- (void)setImageTypeSupported:(NSMutableArray *)imageTypeSupported { + if (imageTypeSupported != nil) { + [store setObject:imageTypeSupported forKey:NAMES_imageTypeSupported]; + } else { + [store removeObjectForKey:NAMES_imageTypeSupported]; + } +} + +- (NSMutableArray *)imageTypeSupported { + NSMutableArray *array = [store objectForKey:NAMES_imageTypeSupported]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLFileType.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSString *enumString in array) { + [newList addObject:[SDLFileType valueOf:enumString]]; + } + return newList; + } +} + +- (void)setImageResolution:(SDLImageResolution *)imageResolution { + if (imageResolution != nil) { + [store setObject:imageResolution forKey:NAMES_imageResolution]; + } else { + [store removeObjectForKey:NAMES_imageResolution]; + } +} + +- (SDLImageResolution *)imageResolution { + NSObject *obj = [store objectForKey:NAMES_imageResolution]; + if (obj == nil || [obj isKindOfClass:SDLImageResolution.class]) { + return (SDLImageResolution *)obj; + } else { + return [[SDLImageResolution alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLImageFieldName.h b/SmartDeviceLink/SDLImageFieldName.h new file mode 100644 index 000000000..5c63a5a71 --- /dev/null +++ b/SmartDeviceLink/SDLImageFieldName.h @@ -0,0 +1,82 @@ +// SDLImageFieldName.h +// + + +#import "SDLEnum.h" + +/** The name that identifies the filed. + * + * + * @since SmartDeviceLink 3.0 + * + */ +@interface SDLImageFieldName : SDLEnum { +} + ++ (SDLImageFieldName *)valueOf:(NSString *)value; ++ (NSArray *)values; + +/** The image field for SoftButton + * + */ ++ (SDLImageFieldName *)softButtonImage; + +/** The first image field for Choice. + * + */ ++ (SDLImageFieldName *)choiceImage; + +/** The scondary image field for Choice. + * + */ ++ (SDLImageFieldName *)choiceSecondaryImage; + +/** The image field for vrHelpItem. + * + */ ++ (SDLImageFieldName *)vrHelpItem; + +/** The image field for Turn. + * + */ + ++ (SDLImageFieldName *)turnIcon; + +/** The image field for the menu icon in SetGlobalProperties. + * + */ ++ (SDLImageFieldName *)menuIcon; + +/** The image filed for AddCommand. + * + */ + ++ (SDLImageFieldName *)cmdIcon; + +/** The iamage field for the app icon ( set by setAppIcon). + * + */ ++ (SDLImageFieldName *)appIcon; + +/** The image filed for Show. + * + */ ++ (SDLImageFieldName *)graphic; + +/** The primary image field for ShowConstant TBT. + * + */ ++ (SDLImageFieldName *)showConstantTBTIcon; + +/** The secondary image field for ShowConstant TBT. + * + */ ++ (SDLImageFieldName *)showConstantTBTNextTurnIcon; + +/** + * The optional image of a destination / location + * @since SDL 4.0 + */ ++ (SDLImageFieldName *)locationImage; + +@end diff --git a/SmartDeviceLink/SDLImageFieldName.m b/SmartDeviceLink/SDLImageFieldName.m new file mode 100644 index 000000000..7baa57b45 --- /dev/null +++ b/SmartDeviceLink/SDLImageFieldName.m @@ -0,0 +1,137 @@ +// SDLImageFieldName.m +// + + +#import "SDLImageFieldName.h" + +SDLImageFieldName *SDLImageFieldName_softButtonImage = nil; +SDLImageFieldName *SDLImageFieldName_choiceImage = nil; +SDLImageFieldName *SDLImageFieldName_choiceSecondaryImage = nil; +SDLImageFieldName *SDLImageFieldName_vrHelpItem = nil; +SDLImageFieldName *SDLImageFieldName_turnIcon = nil; +SDLImageFieldName *SDLImageFieldName_menuIcon = nil; +SDLImageFieldName *SDLImageFieldName_cmdIcon = nil; +SDLImageFieldName *SDLImageFieldName_appIcon = nil; +SDLImageFieldName *SDLImageFieldName_graphic = nil; +SDLImageFieldName *SDLImageFieldName_showConstantTBTIcon = nil; +SDLImageFieldName *SDLImageFieldName_showConstantTBTNextTurnIcon = nil; +SDLImageFieldName *SDLImageFieldName_locationImage = nil; + +NSArray *SDLImageFieldName_values = nil; + +@implementation SDLImageFieldName + ++ (SDLImageFieldName *)valueOf:(NSString *)value { + for (SDLImageFieldName *item in SDLImageFieldName.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLImageFieldName_values == nil) { + SDLImageFieldName_values = @[ + SDLImageFieldName.softButtonImage, + SDLImageFieldName.choiceImage, + SDLImageFieldName.choiceSecondaryImage, + SDLImageFieldName.vrHelpItem, + SDLImageFieldName.turnIcon, + SDLImageFieldName.menuIcon, + SDLImageFieldName.cmdIcon, + SDLImageFieldName.appIcon, + SDLImageFieldName.graphic, + SDLImageFieldName.showConstantTBTIcon, + SDLImageFieldName.showConstantTBTNextTurnIcon, + SDLImageFieldName.locationImage, + ]; + } + return SDLImageFieldName_values; +} + ++ (SDLImageFieldName *)softButtonImage { + if (SDLImageFieldName_softButtonImage == nil) { + SDLImageFieldName_softButtonImage = [[SDLImageFieldName alloc] initWithValue:@"softButtonImage"]; + } + return SDLImageFieldName_softButtonImage; +} + ++ (SDLImageFieldName *)choiceImage { + if (SDLImageFieldName_choiceImage == nil) { + SDLImageFieldName_choiceImage = [[SDLImageFieldName alloc] initWithValue:@"choiceImage"]; + } + return SDLImageFieldName_choiceImage; +} + ++ (SDLImageFieldName *)choiceSecondaryImage { + if (SDLImageFieldName_choiceSecondaryImage == nil) { + SDLImageFieldName_choiceSecondaryImage = [[SDLImageFieldName alloc] initWithValue:@"choiceSecondaryImage"]; + } + return SDLImageFieldName_choiceSecondaryImage; +} + ++ (SDLImageFieldName *)vrHelpItem { + if (SDLImageFieldName_vrHelpItem == nil) { + SDLImageFieldName_vrHelpItem = [[SDLImageFieldName alloc] initWithValue:@"vrHelpItem"]; + } + return SDLImageFieldName_vrHelpItem; +} + ++ (SDLImageFieldName *)turnIcon { + if (SDLImageFieldName_turnIcon == nil) { + SDLImageFieldName_turnIcon = [[SDLImageFieldName alloc] initWithValue:@"turnIcon"]; + } + return SDLImageFieldName_turnIcon; +} + ++ (SDLImageFieldName *)menuIcon { + if (SDLImageFieldName_menuIcon == nil) { + SDLImageFieldName_menuIcon = [[SDLImageFieldName alloc] initWithValue:@"menuIcon"]; + } + return SDLImageFieldName_menuIcon; +} + ++ (SDLImageFieldName *)cmdIcon { + if (SDLImageFieldName_cmdIcon == nil) { + SDLImageFieldName_cmdIcon = [[SDLImageFieldName alloc] initWithValue:@"cmdIcon"]; + } + return SDLImageFieldName_cmdIcon; +} + ++ (SDLImageFieldName *)appIcon { + if (SDLImageFieldName_appIcon == nil) { + SDLImageFieldName_appIcon = [[SDLImageFieldName alloc] initWithValue:@"appIcon"]; + } + return SDLImageFieldName_appIcon; +} + ++ (SDLImageFieldName *)graphic { + if (SDLImageFieldName_graphic == nil) { + SDLImageFieldName_graphic = [[SDLImageFieldName alloc] initWithValue:@"graphic"]; + } + return SDLImageFieldName_graphic; +} + ++ (SDLImageFieldName *)showConstantTBTIcon { + if (SDLImageFieldName_showConstantTBTIcon == nil) { + SDLImageFieldName_showConstantTBTIcon = [[SDLImageFieldName alloc] initWithValue:@"showConstantTBTIcon"]; + } + return SDLImageFieldName_showConstantTBTIcon; +} + ++ (SDLImageFieldName *)showConstantTBTNextTurnIcon { + if (SDLImageFieldName_showConstantTBTNextTurnIcon == nil) { + SDLImageFieldName_showConstantTBTNextTurnIcon = [[SDLImageFieldName alloc] initWithValue:@"showConstantTBTNextTurnIcon"]; + } + return SDLImageFieldName_showConstantTBTNextTurnIcon; +} + ++ (SDLImageFieldName *)locationImage { + if (SDLImageFieldName_locationImage == nil) { + SDLImageFieldName_locationImage = [[SDLImageFieldName alloc] initWithValue:@"locationImage"]; + } + return SDLImageFieldName_locationImage; +} + +@end diff --git a/SmartDeviceLink/SDLImageResolution.h b/SmartDeviceLink/SDLImageResolution.h new file mode 100644 index 000000000..bae946ab2 --- /dev/null +++ b/SmartDeviceLink/SDLImageResolution.h @@ -0,0 +1,16 @@ +// SDLImageResolution.h +// + + +#import "SDLRPCMessage.h" + +@interface SDLImageResolution : SDLRPCStruct { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) NSNumber *resolutionWidth; +@property (strong) NSNumber *resolutionHeight; + +@end diff --git a/SmartDeviceLink/SDLImageResolution.m b/SmartDeviceLink/SDLImageResolution.m new file mode 100644 index 000000000..7f10116de --- /dev/null +++ b/SmartDeviceLink/SDLImageResolution.m @@ -0,0 +1,47 @@ +// SDLImageResolution.m +// + + +#import "SDLImageResolution.h" + +#import "SDLNames.h" + +@implementation SDLImageResolution + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setResolutionWidth:(NSNumber *)resolutionWidth { + if (resolutionWidth != nil) { + [store setObject:resolutionWidth forKey:NAMES_resolutionWidth]; + } else { + [store removeObjectForKey:NAMES_resolutionWidth]; + } +} + +- (NSNumber *)resolutionWidth { + return [store objectForKey:NAMES_resolutionWidth]; +} + +- (void)setResolutionHeight:(NSNumber *)resolutionHeight { + if (resolutionHeight != nil) { + [store setObject:resolutionHeight forKey:NAMES_resolutionHeight]; + } else { + [store removeObjectForKey:NAMES_resolutionHeight]; + } +} + +- (NSNumber *)resolutionHeight { + return [store objectForKey:NAMES_resolutionHeight]; +} + +@end diff --git a/SmartDeviceLink/SDLImageType.h b/SmartDeviceLink/SDLImageType.h new file mode 100644 index 000000000..2b118a456 --- /dev/null +++ b/SmartDeviceLink/SDLImageType.h @@ -0,0 +1,47 @@ +// SDLImageType.h +// + + +#import "SDLEnum.h" + +/** +* Contains information about the type of image. +* +* @since SDL 2.0 +*/ +@interface SDLImageType : SDLEnum { +} + +/** + * @abstract return SDLImageType (STATIC / DYNAMIC) + * + * @param value The value of the string to get an object for + * + * @return An SDLImageType + */ ++ (SDLImageType *)valueOf:(NSString *)value; + +/** + * @abstract store all possible SDLImageType values + * + * @return An array with all possible SDLImageType values inside + */ ++ (NSArray *)values; + +/** + * @abstract Just the static hex icon value to be used + * + * @return The Image Type with value *STATIC* + */ ++ (SDLImageType *)STATIC; + +/** + * @abstract Binary image file to be used (identifier to be sent by SDLPutFile) + * + * @see SDLPutFile + * + * @return The Image Type with value *DYNAMIC* + */ ++ (SDLImageType *)DYNAMIC; + +@end diff --git a/SmartDeviceLink/SDLImageType.m b/SmartDeviceLink/SDLImageType.m new file mode 100644 index 000000000..878eb1773 --- /dev/null +++ b/SmartDeviceLink/SDLImageType.m @@ -0,0 +1,47 @@ +// SDLImageType.m +// + + +#import "SDLImageType.h" + +SDLImageType *SDLImageType_STATIC = nil; +SDLImageType *SDLImageType_DYNAMIC = nil; + +NSArray *SDLImageType_values = nil; + +@implementation SDLImageType + ++ (SDLImageType *)valueOf:(NSString *)value { + for (SDLImageType *item in SDLImageType.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLImageType_values == nil) { + SDLImageType_values = @[ + SDLImageType.STATIC, + SDLImageType.DYNAMIC, + ]; + } + return SDLImageType_values; +} + ++ (SDLImageType *)STATIC { + if (SDLImageType_STATIC == nil) { + SDLImageType_STATIC = [[SDLImageType alloc] initWithValue:@"STATIC"]; + } + return SDLImageType_STATIC; +} + ++ (SDLImageType *)DYNAMIC { + if (SDLImageType_DYNAMIC == nil) { + SDLImageType_DYNAMIC = [[SDLImageType alloc] initWithValue:@"DYNAMIC"]; + } + return SDLImageType_DYNAMIC; +} + +@end diff --git a/SmartDeviceLink/SDLInteractionMode.h b/SmartDeviceLink/SDLInteractionMode.h new file mode 100644 index 000000000..442d4f8d7 --- /dev/null +++ b/SmartDeviceLink/SDLInteractionMode.h @@ -0,0 +1,56 @@ +// SDLInteractionMode.h +// + + +#import "SDLEnum.h" + +/** + * For application-initiated interactions (SDLPerformInteraction), this specifies the mode by which the user is prompted and by which the user's selection is indicated + * + * @since SDL 1.0 + */ +@interface SDLInteractionMode : SDLEnum { +} + +/** + * @abstract SDLInteractionMode + * @param value The value of the string to get an object for + * @return SDLInteractionMode + */ ++ (SDLInteractionMode *)valueOf:(NSString *)value; + +/** + * @abstract store all possible SDLInteractionMode values + * @return an array with all possible SDLInteractionMode values inside + */ ++ (NSArray *)values; + +/** + * @abstract Interaction Mode : Manual Only + * @discussion This mode causes the interaction to occur only on the display, meaning the choices are presented and selected only via the display. Selections are viewed with the SEEKRIGHT, SEEKLEFT, TUNEUP, TUNEDOWN buttons. User's selection is indicated with the OK button + * + * @return Current Interaction Mode with value of *MANUAL_ONLY* + */ ++ (SDLInteractionMode *)MANUAL_ONLY; + +/** + * @abstract Interaction Mode : VR Only + * @discussion This mode causes the interaction to occur only through TTS and VR. The user is prompted via TTS to select a choice by saying one of the choice's synonyms + * + * @return Current Interaction Mode with value of *VR_ONLY* + */ ++ (SDLInteractionMode *)VR_ONLY; + +/** + * @abstract Interaction Mode : Manual & VR + * @discussion This mode is a combination of MANUAL_ONLY and VR_ONLY, meaning the user is prompted both visually and audibly. The user can make a selection either using the mode described in MANUAL_ONLY or using the mode described in VR_ONLY. + * + * If the user views selections as described in MANUAL_ONLY mode, the interaction becomes strictly, and irreversibly, a MANUAL_ONLY interaction (i.e. the VR session is cancelled, although the interaction itself is still in progress). If the user interacts with the VR session in any way (e.g. speaks a phrase, even if it is not a recognized choice), the interaction becomes strictly, and irreversibly, a VR_ONLY interaction (i.e. the MANUAL_ONLY mode forms of interaction will no longer be honored) + * + * The TriggerSource parameter of the *PerformInteraction* response will indicate which interaction mode the user finally chose to attempt the selection (even if the interaction did not end with a selection being made) + * + * @return Current Interaction Mode with value of *BOTH* + */ ++ (SDLInteractionMode *)BOTH; + +@end diff --git a/SmartDeviceLink/SDLInteractionMode.m b/SmartDeviceLink/SDLInteractionMode.m new file mode 100644 index 000000000..07dc5f7b2 --- /dev/null +++ b/SmartDeviceLink/SDLInteractionMode.m @@ -0,0 +1,56 @@ +// SDLInteractionMode.m +// + + +#import "SDLInteractionMode.h" + +SDLInteractionMode *SDLInteractionMode_MANUAL_ONLY = nil; +SDLInteractionMode *SDLInteractionMode_VR_ONLY = nil; +SDLInteractionMode *SDLInteractionMode_BOTH = nil; + +NSArray *SDLInteractionMode_values = nil; + +@implementation SDLInteractionMode + ++ (SDLInteractionMode *)valueOf:(NSString *)value { + for (SDLInteractionMode *item in SDLInteractionMode.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLInteractionMode_values == nil) { + SDLInteractionMode_values = @[ + SDLInteractionMode.MANUAL_ONLY, + SDLInteractionMode.VR_ONLY, + SDLInteractionMode.BOTH, + ]; + } + return SDLInteractionMode_values; +} + ++ (SDLInteractionMode *)MANUAL_ONLY { + if (SDLInteractionMode_MANUAL_ONLY == nil) { + SDLInteractionMode_MANUAL_ONLY = [[SDLInteractionMode alloc] initWithValue:@"MANUAL_ONLY"]; + } + return SDLInteractionMode_MANUAL_ONLY; +} + ++ (SDLInteractionMode *)VR_ONLY { + if (SDLInteractionMode_VR_ONLY == nil) { + SDLInteractionMode_VR_ONLY = [[SDLInteractionMode alloc] initWithValue:@"VR_ONLY"]; + } + return SDLInteractionMode_VR_ONLY; +} + ++ (SDLInteractionMode *)BOTH { + if (SDLInteractionMode_BOTH == nil) { + SDLInteractionMode_BOTH = [[SDLInteractionMode alloc] initWithValue:@"BOTH"]; + } + return SDLInteractionMode_BOTH; +} + +@end diff --git a/SmartDeviceLink/SDLJingle.h b/SmartDeviceLink/SDLJingle.h new file mode 100644 index 000000000..180ca85ef --- /dev/null +++ b/SmartDeviceLink/SDLJingle.h @@ -0,0 +1,16 @@ +// SDLJingle.h +// + + +#import <Foundation/Foundation.h> + +@interface SDLJingle : NSObject { +} + ++ (NSString *)NEGATIVE_JINGLE; ++ (NSString *)POSITIVE_JINGLE; ++ (NSString *)LISTEN_JINGLE; ++ (NSString *)INITIAL_JINGLE; ++ (NSString *)HELP_JINGLE; + +@end diff --git a/SmartDeviceLink/SDLJingle.m b/SmartDeviceLink/SDLJingle.m new file mode 100644 index 000000000..7484bfabf --- /dev/null +++ b/SmartDeviceLink/SDLJingle.m @@ -0,0 +1,25 @@ +// SDLJingle.m +// + + +#import "SDLJingle.h" + +@implementation SDLJingle + ++ (NSString *)NEGATIVE_JINGLE { + return @"NEGATIVE_JINGLE"; +} ++ (NSString *)POSITIVE_JINGLE { + return @"POSITIVE_JINGLE"; +} ++ (NSString *)LISTEN_JINGLE { + return @"LISTEN_JINGLE"; +} ++ (NSString *)INITIAL_JINGLE { + return @"INITIAL_JINGLE"; +} ++ (NSString *)HELP_JINGLE { + return @"HELP_JINGLE"; +} + +@end diff --git a/SmartDeviceLink/SDLJsonDecoder.h b/SmartDeviceLink/SDLJsonDecoder.h new file mode 100644 index 000000000..4723989db --- /dev/null +++ b/SmartDeviceLink/SDLJsonDecoder.h @@ -0,0 +1,14 @@ +// SDLJsonDecoder.h +// + +#import <Foundation/Foundation.h> + +#import "SDLDecoder.h" + + +@interface SDLJsonDecoder : NSObject <SDLDecoder> { +} + ++ (NSObject<SDLDecoder> *)instance; + +@end diff --git a/SmartDeviceLink/SDLJsonDecoder.m b/SmartDeviceLink/SDLJsonDecoder.m new file mode 100644 index 000000000..0ff561df8 --- /dev/null +++ b/SmartDeviceLink/SDLJsonDecoder.m @@ -0,0 +1,38 @@ +// SDLJsonDecoder.m +// + +#import "SDLJsonDecoder.h" + +#import "SDLDebugTool.h" +#import "SDLNames.h" + + +@implementation SDLJsonDecoder + +static NSObject<SDLDecoder> *jsonDecoderInstance; + ++ (NSObject<SDLDecoder> *)instance { + if (jsonDecoderInstance == nil) { + jsonDecoderInstance = [[SDLJsonDecoder alloc] init]; + } + return jsonDecoderInstance; +} + +- (NSDictionary *)decode:(NSData *)data { + if (data.length == 0) { + [SDLDebugTool logInfo:@"Warning: Decoding JSON data, no JSON to decode" withType:SDLDebugType_Protocol]; + return nil; + } + + NSError *error = nil; + NSDictionary *jsonObject = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error]; + + if (error != nil) { + [SDLDebugTool logInfo:[NSString stringWithFormat:@"Error decoding JSON data: %@", error] withType:SDLDebugType_Protocol]; + return nil; + } + + return jsonObject; +} + +@end diff --git a/SmartDeviceLink/SDLJsonEncoder.h b/SmartDeviceLink/SDLJsonEncoder.h new file mode 100644 index 000000000..680fe5da6 --- /dev/null +++ b/SmartDeviceLink/SDLJsonEncoder.h @@ -0,0 +1,14 @@ +// SDLJsonEncoder.h +// + +#import <Foundation/Foundation.h> + +#import "SDLEncoder.h" + + +@interface SDLJsonEncoder : NSObject <SDLEncoder> { +} + ++ (NSObject<SDLEncoder> *)instance; + +@end diff --git a/SmartDeviceLink/SDLJsonEncoder.m b/SmartDeviceLink/SDLJsonEncoder.m new file mode 100644 index 000000000..dbb2374d9 --- /dev/null +++ b/SmartDeviceLink/SDLJsonEncoder.m @@ -0,0 +1,38 @@ +// SDLJsonEncoder.m +// + +#import "SDLJsonEncoder.h" + +#import "SDLDebugTool.h" +#import "SDLNames.h" + + +@implementation SDLJsonEncoder + +static NSObject<SDLEncoder> *jsonEncoderInstance; + ++ (NSObject<SDLEncoder> *)instance { + if (jsonEncoderInstance == nil) { + jsonEncoderInstance = [[SDLJsonEncoder alloc] init]; + } + return jsonEncoderInstance; +} + +- (NSData *)encodeDictionary:(NSDictionary *)dict { + if (dict == nil) { + [SDLDebugTool logInfo:@"Warning: Encoding dictionary to JSON, no dictionary passed" withType:SDLDebugType_Protocol]; + return nil; + } + + NSError *error = nil; + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:kNilOptions error:&error]; + + if (error != nil) { + [SDLDebugTool logInfo:[NSString stringWithFormat:@"Error encoding JSON data: %@", error] withType:SDLDebugType_Protocol]; + return nil; + } + + return jsonData; +} + +@end diff --git a/SmartDeviceLink/SDLKeyboardEvent.h b/SmartDeviceLink/SDLKeyboardEvent.h new file mode 100644 index 000000000..f0d90530e --- /dev/null +++ b/SmartDeviceLink/SDLKeyboardEvent.h @@ -0,0 +1,45 @@ +// SDLKeyboardEvent.h +// + + +#import "SDLEnum.h" + +/** Enumeration listing possible keyboard events. + * + * @since SmartDeviceLink 3.0 + * + */ +@interface SDLKeyboardEvent : SDLEnum { +} + ++ (SDLKeyboardEvent *)valueOf:(NSString *)value; ++ (NSArray *)values; + +/** The use has pressed the keyboard key (applies to both SINGLE_KEYPRESS and RESEND_CURRENT_ENTRY modes). + * + */ ++ (SDLKeyboardEvent *)KEYPRESS; + +/** The User has finished entering text from the keyboard and submitted the entry. + * + */ + ++ (SDLKeyboardEvent *)ENTRY_SUBMITTED; + +/** The User has pressed the HMI-defined "Cancel" button. + * + */ ++ (SDLKeyboardEvent *)ENTRY_CANCELLED; + + +/** The User has not finished entering text and the keyboard is aborted with the event of higher priority. + * + */ ++ (SDLKeyboardEvent *)ENTRY_ABORTED; + +/** + * @since SDL 4.0 + */ ++ (SDLKeyboardEvent *)ENTRY_VOICE; + +@end diff --git a/SmartDeviceLink/SDLKeyboardEvent.m b/SmartDeviceLink/SDLKeyboardEvent.m new file mode 100644 index 000000000..65a7d8e89 --- /dev/null +++ b/SmartDeviceLink/SDLKeyboardEvent.m @@ -0,0 +1,74 @@ +// SDLKeyboardEvent.m +// + + +#import "SDLKeyboardEvent.h" + +SDLKeyboardEvent *SDLKeyboardEvent_KEYPRESS = nil; +SDLKeyboardEvent *SDLKeyboardEvent_ENTRY_SUBMITTED = nil; +SDLKeyboardEvent *SDLKeyboardEvent_ENTRY_CANCELLED = nil; +SDLKeyboardEvent *SDLKeyboardEvent_ENTRY_ABORTED = nil; +SDLKeyboardEvent *SDLKeyboardEvent_ENTRY_VOICE = nil; + +NSArray *SDLKeyboardEvent_values = nil; + +@implementation SDLKeyboardEvent + ++ (SDLKeyboardEvent *)valueOf:(NSString *)value { + for (SDLKeyboardEvent *item in SDLKeyboardEvent.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLKeyboardEvent_values == nil) { + SDLKeyboardEvent_values = @[ + SDLKeyboardEvent.KEYPRESS, + SDLKeyboardEvent.ENTRY_SUBMITTED, + SDLKeyboardEvent.ENTRY_CANCELLED, + SDLKeyboardEvent.ENTRY_ABORTED, + SDLKeyboardEvent.ENTRY_VOICE, + ]; + } + return SDLKeyboardEvent_values; +} + ++ (SDLKeyboardEvent *)KEYPRESS { + if (SDLKeyboardEvent_KEYPRESS == nil) { + SDLKeyboardEvent_KEYPRESS = [[SDLKeyboardEvent alloc] initWithValue:@"KEYPRESS"]; + } + return SDLKeyboardEvent_KEYPRESS; +} + ++ (SDLKeyboardEvent *)ENTRY_SUBMITTED { + if (SDLKeyboardEvent_ENTRY_SUBMITTED == nil) { + SDLKeyboardEvent_ENTRY_SUBMITTED = [[SDLKeyboardEvent alloc] initWithValue:@"ENTRY_SUBMITTED"]; + } + return SDLKeyboardEvent_ENTRY_SUBMITTED; +} + ++ (SDLKeyboardEvent *)ENTRY_CANCELLED { + if (SDLKeyboardEvent_ENTRY_CANCELLED == nil) { + SDLKeyboardEvent_ENTRY_CANCELLED = [[SDLKeyboardEvent alloc] initWithValue:@"ENTRY_CANCELLED"]; + } + return SDLKeyboardEvent_ENTRY_CANCELLED; +} + ++ (SDLKeyboardEvent *)ENTRY_ABORTED { + if (SDLKeyboardEvent_ENTRY_ABORTED == nil) { + SDLKeyboardEvent_ENTRY_ABORTED = [[SDLKeyboardEvent alloc] initWithValue:@"ENTRY_ABORTED"]; + } + return SDLKeyboardEvent_ENTRY_ABORTED; +} + ++ (SDLKeyboardEvent *)ENTRY_VOICE { + if (SDLKeyboardEvent_ENTRY_VOICE == nil) { + SDLKeyboardEvent_ENTRY_VOICE = [[SDLKeyboardEvent alloc] initWithValue:@"ENTRY_VOICE"]; + } + return SDLKeyboardEvent_ENTRY_VOICE; +} + +@end diff --git a/SmartDeviceLink/SDLKeyboardLayout.h b/SmartDeviceLink/SDLKeyboardLayout.h new file mode 100644 index 000000000..042caf9d0 --- /dev/null +++ b/SmartDeviceLink/SDLKeyboardLayout.h @@ -0,0 +1,33 @@ +// SDLKeyboardLayout.h +// + + +#import "SDLEnum.h" + +/** Enumeration listing possible keyboard layouts + * + *<b>Since</b> SmartDeviceLink 3.0 + * + */ +@interface SDLKeyboardLayout : SDLEnum { +} + ++ (SDLKeyboardLayout *)valueOf:(NSString *)value; ++ (NSArray *)values; +/** QWERTY layout (the name comes from the first six keys<br> appearing on the top left letter row of the keyboard and read from left to right) + * + */ ++ (SDLKeyboardLayout *)QWERTY; + +/** QWERTZ layout (the name comes from the first six keys<br> appearing on the top left letter row of the keyboard and read from left to right) + * + */ ++ (SDLKeyboardLayout *)QWERTZ; + +/** AZERTY layout (the name comes from the first six keys<br> appearing on the top left letter row of the keyboard and read from left to right) + * + */ + ++ (SDLKeyboardLayout *)AZERTY; + +@end diff --git a/SmartDeviceLink/SDLKeyboardLayout.m b/SmartDeviceLink/SDLKeyboardLayout.m new file mode 100644 index 000000000..700bd2622 --- /dev/null +++ b/SmartDeviceLink/SDLKeyboardLayout.m @@ -0,0 +1,56 @@ +// SDLKeyboardLayout.m +// + + +#import "SDLKeyboardLayout.h" + +SDLKeyboardLayout *SDLKeyboardLayout_QWERTY = nil; +SDLKeyboardLayout *SDLKeyboardLayout_QWERTZ = nil; +SDLKeyboardLayout *SDLKeyboardLayout_AZERTY = nil; + +NSArray *SDLKeyboardLayout_values = nil; + +@implementation SDLKeyboardLayout + ++ (SDLKeyboardLayout *)valueOf:(NSString *)value { + for (SDLKeyboardLayout *item in SDLKeyboardLayout.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLKeyboardLayout_values == nil) { + SDLKeyboardLayout_values = @[ + SDLKeyboardLayout.QWERTY, + SDLKeyboardLayout.QWERTZ, + SDLKeyboardLayout.AZERTY, + ]; + } + return SDLKeyboardLayout_values; +} + ++ (SDLKeyboardLayout *)QWERTY { + if (SDLKeyboardLayout_QWERTY == nil) { + SDLKeyboardLayout_QWERTY = [[SDLKeyboardLayout alloc] initWithValue:@"QWERTY"]; + } + return SDLKeyboardLayout_QWERTY; +} + ++ (SDLKeyboardLayout *)QWERTZ { + if (SDLKeyboardLayout_QWERTZ == nil) { + SDLKeyboardLayout_QWERTZ = [[SDLKeyboardLayout alloc] initWithValue:@"QWERTZ"]; + } + return SDLKeyboardLayout_QWERTZ; +} + ++ (SDLKeyboardLayout *)AZERTY { + if (SDLKeyboardLayout_AZERTY == nil) { + SDLKeyboardLayout_AZERTY = [[SDLKeyboardLayout alloc] initWithValue:@"AZERTY"]; + } + return SDLKeyboardLayout_AZERTY; +} + +@end diff --git a/SmartDeviceLink/SDLKeyboardProperties.h b/SmartDeviceLink/SDLKeyboardProperties.h new file mode 100644 index 000000000..8215a8938 --- /dev/null +++ b/SmartDeviceLink/SDLKeyboardProperties.h @@ -0,0 +1,23 @@ +// SDLKeyboardProperties.h +// + +#import "SDLRPCMessage.h" + +@class SDLLanguage; +@class SDLKeyboardLayout; +@class SDLKeypressMode; + + +@interface SDLKeyboardProperties : SDLRPCStruct { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) SDLLanguage *language; +@property (strong) SDLKeyboardLayout *keyboardLayout; +@property (strong) SDLKeypressMode *keypressMode; +@property (strong) NSMutableArray *limitedCharacterList; +@property (strong) NSString *autoCompleteText; + +@end diff --git a/SmartDeviceLink/SDLKeyboardProperties.m b/SmartDeviceLink/SDLKeyboardProperties.m new file mode 100644 index 000000000..896f3a99a --- /dev/null +++ b/SmartDeviceLink/SDLKeyboardProperties.m @@ -0,0 +1,101 @@ +// SDLKeyboardProperties.m +// + +#import "SDLKeyboardProperties.h" + +#import "SDLKeyboardLayout.h" +#import "SDLKeypressMode.h" +#import "SDLLanguage.h" +#import "SDLNames.h" + + +@implementation SDLKeyboardProperties + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setLanguage:(SDLLanguage *)language { + if (language != nil) { + [store setObject:language forKey:NAMES_language]; + } else { + [store removeObjectForKey:NAMES_language]; + } +} + +- (SDLLanguage *)language { + NSObject *obj = [store objectForKey:NAMES_language]; + if (obj == nil || [obj isKindOfClass:SDLLanguage.class]) { + return (SDLLanguage *)obj; + } else { + return [SDLLanguage valueOf:(NSString *)obj]; + } +} + +- (void)setKeyboardLayout:(SDLKeyboardLayout *)keyboardLayout { + if (keyboardLayout != nil) { + [store setObject:keyboardLayout forKey:NAMES_keyboardLayout]; + } else { + [store removeObjectForKey:NAMES_keyboardLayout]; + } +} + +- (SDLKeyboardLayout *)keyboardLayout { + NSObject *obj = [store objectForKey:NAMES_keyboardLayout]; + if (obj == nil || [obj isKindOfClass:SDLKeyboardLayout.class]) { + return (SDLKeyboardLayout *)obj; + } else { + return [SDLKeyboardLayout valueOf:(NSString *)obj]; + } +} + +- (void)setKeypressMode:(SDLKeypressMode *)keypressMode { + if (keypressMode != nil) { + [store setObject:keypressMode forKey:NAMES_keypressMode]; + } else { + [store removeObjectForKey:NAMES_keypressMode]; + } +} + +- (SDLKeypressMode *)keypressMode { + NSObject *obj = [store objectForKey:NAMES_keypressMode]; + if (obj == nil || [obj isKindOfClass:SDLKeypressMode.class]) { + return (SDLKeypressMode *)obj; + } else { + return [SDLKeypressMode valueOf:(NSString *)obj]; + } +} + +- (void)setLimitedCharacterList:(NSMutableArray *)limitedCharacterList { + if (limitedCharacterList != nil) { + [store setObject:limitedCharacterList forKey:NAMES_limitedCharacterList]; + } else { + [store removeObjectForKey:NAMES_limitedCharacterList]; + } +} + +- (NSMutableArray *)limitedCharacterList { + return [store objectForKey:NAMES_limitedCharacterList]; +} + +- (void)setAutoCompleteText:(NSString *)autoCompleteText { + if (autoCompleteText != nil) { + [store setObject:autoCompleteText forKey:NAMES_autoCompleteText]; + } else { + [store removeObjectForKey:NAMES_autoCompleteText]; + } +} + +- (NSString *)autoCompleteText { + return [store objectForKey:NAMES_autoCompleteText]; +} + +@end diff --git a/SmartDeviceLink/SDLKeypressMode.h b/SmartDeviceLink/SDLKeypressMode.h new file mode 100644 index 000000000..1b4ad0fe1 --- /dev/null +++ b/SmartDeviceLink/SDLKeypressMode.h @@ -0,0 +1,35 @@ +// SDLKeypressMode.h +// + + +#import "SDLEnum.h" + +/** Enumeration listing possible keyboard events. + * <p> + * <b>Note:</b> Depending on keypressMode value (from keyboardProperties structure of UI.SetGlobalProperties),<br>HMI must send the onKeyboardInput notification with the following data:<br> + SINGLE_KEYPRESS,QUEUE_KEYPRESSES,RESEND_CURRENT_ENTRY. + * @since SmartDeviceLink 3.0 + * + */ +@interface SDLKeypressMode : SDLEnum { +} + ++ (SDLKeypressMode *)valueOf:(NSString *)value; ++ (NSArray *)values; + +/** SINGLE_KEYPRESS:<br>Each and every User`s keypress must be reported (new notification for every newly entered single symbol). + * + */ ++ (SDLKeypressMode *)SINGLE_KEYPRESS; + +/** QUEUE_KEYPRESSES:<br>The whole entry is reported only after the User submits it (by ‘Search’ button click displayed on touchscreen keyboard) + * + */ ++ (SDLKeypressMode *)QUEUE_KEYPRESSES; + +/** RESEND_CURRENT_ENTRY:<br>The whole entry must be reported each and every time the User makes a new keypress<br> (new notification with all previously entered symbols and a newly entered one appended). + * + */ ++ (SDLKeypressMode *)RESEND_CURRENT_ENTRY; + +@end diff --git a/SmartDeviceLink/SDLKeypressMode.m b/SmartDeviceLink/SDLKeypressMode.m new file mode 100644 index 000000000..9fa0034e7 --- /dev/null +++ b/SmartDeviceLink/SDLKeypressMode.m @@ -0,0 +1,56 @@ +// SDLKeypressMode.m +// + + +#import "SDLKeypressMode.h" + +SDLKeypressMode *SDLKeypressMode_SINGLE_KEYPRESS = nil; +SDLKeypressMode *SDLKeypressMode_QUEUE_KEYPRESSES = nil; +SDLKeypressMode *SDLKeypressMode_RESEND_CURRENT_ENTRY = nil; + +NSArray *SDLKeypressMode_values = nil; + +@implementation SDLKeypressMode + ++ (SDLKeypressMode *)valueOf:(NSString *)value { + for (SDLKeypressMode *item in SDLKeypressMode.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLKeypressMode_values == nil) { + SDLKeypressMode_values = @[ + SDLKeypressMode.SINGLE_KEYPRESS, + SDLKeypressMode.QUEUE_KEYPRESSES, + SDLKeypressMode.RESEND_CURRENT_ENTRY, + ]; + } + return SDLKeypressMode_values; +} + ++ (SDLKeypressMode *)SINGLE_KEYPRESS { + if (SDLKeypressMode_SINGLE_KEYPRESS == nil) { + SDLKeypressMode_SINGLE_KEYPRESS = [[SDLKeypressMode alloc] initWithValue:@"SINGLE_KEYPRESS"]; + } + return SDLKeypressMode_SINGLE_KEYPRESS; +} + ++ (SDLKeypressMode *)QUEUE_KEYPRESSES { + if (SDLKeypressMode_QUEUE_KEYPRESSES == nil) { + SDLKeypressMode_QUEUE_KEYPRESSES = [[SDLKeypressMode alloc] initWithValue:@"QUEUE_KEYPRESSES"]; + } + return SDLKeypressMode_QUEUE_KEYPRESSES; +} + ++ (SDLKeypressMode *)RESEND_CURRENT_ENTRY { + if (SDLKeypressMode_RESEND_CURRENT_ENTRY == nil) { + SDLKeypressMode_RESEND_CURRENT_ENTRY = [[SDLKeypressMode alloc] initWithValue:@"RESEND_CURRENT_ENTRY"]; + } + return SDLKeypressMode_RESEND_CURRENT_ENTRY; +} + +@end diff --git a/SmartDeviceLink/SDLLanguage.h b/SmartDeviceLink/SDLLanguage.h new file mode 100644 index 000000000..38d63746b --- /dev/null +++ b/SmartDeviceLink/SDLLanguage.h @@ -0,0 +1,150 @@ +// SDLLanguage.h +// + + +#import "SDLEnum.h" + +/** + * Specifies the language to be used for TTS, VR, displayed messages/menus + * + * @since SDL 1.0 + */ +@interface SDLLanguage : SDLEnum { +} + +/** + * @abstract Get a Langusge according to a String + * + * @param value The value of the string to get an object for + * + * @return The Language + */ ++ (SDLLanguage *)valueOf:(NSString *)value; + +/** + * @abstract store all possible Language values + * + * @return an array with all possible Language values inside + */ ++ (NSArray *)values; +/*! + @abstract English_US + */ ++ (SDLLanguage *)EN_US; + +/** + @abstract Spanish - Mexico + */ ++ (SDLLanguage *)ES_MX; + +/** + * @abstract French - Canada + */ ++ (SDLLanguage *)FR_CA; + +/** + * @abstract German - Germany + */ ++ (SDLLanguage *)DE_DE; + +/** + * @abstract Spanish - Spain + */ ++ (SDLLanguage *)ES_ES; + +/** + @abstract English - Great Britain + */ ++ (SDLLanguage *)EN_GB; + +/** + * @abstract Russian - Russia + */ ++ (SDLLanguage *)RU_RU; + +/** + * @abstract Turkish - Turkey + */ ++ (SDLLanguage *)TR_TR; + +/** + * @abstract Polish - Poland + */ ++ (SDLLanguage *)PL_PL; + +/** + * @abstract French - France + */ ++ (SDLLanguage *)FR_FR; + +/** + * @abstract Italian - Italy + */ ++ (SDLLanguage *)IT_IT; + +/** + * @abstract Swedish - Sweden + */ ++ (SDLLanguage *)SV_SE; + +/** + * @abstract Portuguese - Portugal + */ ++ (SDLLanguage *)PT_PT; + +/** + * @abstract Dutch (Standard) - Netherlands + */ ++ (SDLLanguage *)NL_NL; + +/** + * @abstract English - Australia + */ ++ (SDLLanguage *)EN_AU; + +/** + * @abstract Mandarin - China + */ ++ (SDLLanguage *)ZH_CN; + +/** + * @abstract Mandarin - Taiwan + */ ++ (SDLLanguage *)ZH_TW; + +/** + * @abstract Japanese - Japan + */ ++ (SDLLanguage *)JA_JP; + +/** + * @abstract Arabic - Saudi Arabia + */ ++ (SDLLanguage *)AR_SA; + +/** + * @abstract Korean - South Korea + */ ++ (SDLLanguage *)KO_KR; + +/** + * @abstract Portuguese - Brazil + */ ++ (SDLLanguage *)PT_BR; + +/** + * @abstract Czech - Czech Republic + */ ++ (SDLLanguage *)CS_CZ; + +/** + * @abstract Danish - Denmark + */ ++ (SDLLanguage *)DA_DK; + +/** + * @abstract Norwegian - Norway + */ ++ (SDLLanguage *)NO_NO; + +@end diff --git a/SmartDeviceLink/SDLLanguage.m b/SmartDeviceLink/SDLLanguage.m new file mode 100644 index 000000000..df43adf4c --- /dev/null +++ b/SmartDeviceLink/SDLLanguage.m @@ -0,0 +1,245 @@ +// SDLLanguage.m +// + + +#import "SDLLanguage.h" + +SDLLanguage *SDLLanguage_EN_US = nil; +SDLLanguage *SDLLanguage_ES_MX = nil; +SDLLanguage *SDLLanguage_FR_CA = nil; +SDLLanguage *SDLLanguage_DE_DE = nil; +SDLLanguage *SDLLanguage_ES_ES = nil; +SDLLanguage *SDLLanguage_EN_GB = nil; +SDLLanguage *SDLLanguage_RU_RU = nil; +SDLLanguage *SDLLanguage_TR_TR = nil; +SDLLanguage *SDLLanguage_PL_PL = nil; +SDLLanguage *SDLLanguage_FR_FR = nil; +SDLLanguage *SDLLanguage_IT_IT = nil; +SDLLanguage *SDLLanguage_SV_SE = nil; +SDLLanguage *SDLLanguage_PT_PT = nil; +SDLLanguage *SDLLanguage_NL_NL = nil; +SDLLanguage *SDLLanguage_EN_AU = nil; +SDLLanguage *SDLLanguage_ZH_CN = nil; +SDLLanguage *SDLLanguage_ZH_TW = nil; +SDLLanguage *SDLLanguage_JA_JP = nil; +SDLLanguage *SDLLanguage_AR_SA = nil; +SDLLanguage *SDLLanguage_KO_KR = nil; +SDLLanguage *SDLLanguage_PT_BR = nil; +SDLLanguage *SDLLanguage_CS_CZ = nil; +SDLLanguage *SDLLanguage_DA_DK = nil; +SDLLanguage *SDLLanguage_NO_NO = nil; + +NSArray *SDLLanguage_values = nil; + +@implementation SDLLanguage + ++ (SDLLanguage *)valueOf:(NSString *)value { + for (SDLLanguage *item in SDLLanguage.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLLanguage_values == nil) { + SDLLanguage_values = @[ + SDLLanguage.EN_US, + SDLLanguage.ES_MX, + SDLLanguage.FR_CA, + SDLLanguage.DE_DE, + SDLLanguage.ES_ES, + SDLLanguage.EN_GB, + SDLLanguage.RU_RU, + SDLLanguage.TR_TR, + SDLLanguage.PL_PL, + SDLLanguage.FR_FR, + SDLLanguage.IT_IT, + SDLLanguage.SV_SE, + SDLLanguage.PT_PT, + SDLLanguage.NL_NL, + SDLLanguage.EN_AU, + SDLLanguage.ZH_CN, + SDLLanguage.ZH_TW, + SDLLanguage.JA_JP, + SDLLanguage.AR_SA, + SDLLanguage.KO_KR, + SDLLanguage.PT_BR, + SDLLanguage.CS_CZ, + SDLLanguage.DA_DK, + SDLLanguage.NO_NO, + ]; + } + return SDLLanguage_values; +} + ++ (SDLLanguage *)EN_US { + if (SDLLanguage_EN_US == nil) { + SDLLanguage_EN_US = [[SDLLanguage alloc] initWithValue:@"EN-US"]; + } + return SDLLanguage_EN_US; +} + ++ (SDLLanguage *)ES_MX { + if (SDLLanguage_ES_MX == nil) { + SDLLanguage_ES_MX = [[SDLLanguage alloc] initWithValue:@"ES-MX"]; + } + return SDLLanguage_ES_MX; +} + ++ (SDLLanguage *)FR_CA { + if (SDLLanguage_FR_CA == nil) { + SDLLanguage_FR_CA = [[SDLLanguage alloc] initWithValue:@"FR-CA"]; + } + return SDLLanguage_FR_CA; +} + ++ (SDLLanguage *)DE_DE { + if (SDLLanguage_DE_DE == nil) { + SDLLanguage_DE_DE = [[SDLLanguage alloc] initWithValue:@"DE-DE"]; + } + return SDLLanguage_DE_DE; +} + ++ (SDLLanguage *)ES_ES { + if (SDLLanguage_ES_ES == nil) { + SDLLanguage_ES_ES = [[SDLLanguage alloc] initWithValue:@"ES-ES"]; + } + return SDLLanguage_ES_ES; +} + ++ (SDLLanguage *)EN_GB { + if (SDLLanguage_EN_GB == nil) { + SDLLanguage_EN_GB = [[SDLLanguage alloc] initWithValue:@"EN-GB"]; + } + return SDLLanguage_EN_GB; +} + ++ (SDLLanguage *)RU_RU { + if (SDLLanguage_RU_RU == nil) { + SDLLanguage_RU_RU = [[SDLLanguage alloc] initWithValue:@"RU-RU"]; + } + return SDLLanguage_RU_RU; +} + ++ (SDLLanguage *)TR_TR { + if (SDLLanguage_TR_TR == nil) { + SDLLanguage_TR_TR = [[SDLLanguage alloc] initWithValue:@"TR-TR"]; + } + return SDLLanguage_TR_TR; +} + ++ (SDLLanguage *)PL_PL { + if (SDLLanguage_PL_PL == nil) { + SDLLanguage_PL_PL = [[SDLLanguage alloc] initWithValue:@"PL-PL"]; + } + return SDLLanguage_PL_PL; +} + ++ (SDLLanguage *)FR_FR { + if (SDLLanguage_FR_FR == nil) { + SDLLanguage_FR_FR = [[SDLLanguage alloc] initWithValue:@"FR-FR"]; + } + return SDLLanguage_FR_FR; +} + ++ (SDLLanguage *)IT_IT { + if (SDLLanguage_IT_IT == nil) { + SDLLanguage_IT_IT = [[SDLLanguage alloc] initWithValue:@"IT-IT"]; + } + return SDLLanguage_IT_IT; +} + ++ (SDLLanguage *)SV_SE { + if (SDLLanguage_SV_SE == nil) { + SDLLanguage_SV_SE = [[SDLLanguage alloc] initWithValue:@"SV-SE"]; + } + return SDLLanguage_SV_SE; +} + ++ (SDLLanguage *)PT_PT { + if (SDLLanguage_PT_PT == nil) { + SDLLanguage_PT_PT = [[SDLLanguage alloc] initWithValue:@"PT-PT"]; + } + return SDLLanguage_PT_PT; +} + ++ (SDLLanguage *)NL_NL { + if (SDLLanguage_NL_NL == nil) { + SDLLanguage_NL_NL = [[SDLLanguage alloc] initWithValue:@"NL-NL"]; + } + return SDLLanguage_NL_NL; +} + ++ (SDLLanguage *)EN_AU { + if (SDLLanguage_EN_AU == nil) { + SDLLanguage_EN_AU = [[SDLLanguage alloc] initWithValue:@"EN-AU"]; + } + return SDLLanguage_EN_AU; +} + ++ (SDLLanguage *)ZH_CN { + if (SDLLanguage_ZH_CN == nil) { + SDLLanguage_ZH_CN = [[SDLLanguage alloc] initWithValue:@"ZH-CN"]; + } + return SDLLanguage_ZH_CN; +} + ++ (SDLLanguage *)ZH_TW { + if (SDLLanguage_ZH_TW == nil) { + SDLLanguage_ZH_TW = [[SDLLanguage alloc] initWithValue:@"ZH-TW"]; + } + return SDLLanguage_ZH_TW; +} + ++ (SDLLanguage *)JA_JP { + if (SDLLanguage_JA_JP == nil) { + SDLLanguage_JA_JP = [[SDLLanguage alloc] initWithValue:@"JA-JP"]; + } + return SDLLanguage_JA_JP; +} + ++ (SDLLanguage *)AR_SA { + if (SDLLanguage_AR_SA == nil) { + SDLLanguage_AR_SA = [[SDLLanguage alloc] initWithValue:@"AR-SA"]; + } + return SDLLanguage_AR_SA; +} + ++ (SDLLanguage *)KO_KR { + if (SDLLanguage_KO_KR == nil) { + SDLLanguage_KO_KR = [[SDLLanguage alloc] initWithValue:@"KO-KR"]; + } + return SDLLanguage_KO_KR; +} + ++ (SDLLanguage *)PT_BR { + if (SDLLanguage_PT_BR == nil) { + SDLLanguage_PT_BR = [[SDLLanguage alloc] initWithValue:@"PT-BR"]; + } + return SDLLanguage_PT_BR; +} + ++ (SDLLanguage *)CS_CZ { + if (SDLLanguage_CS_CZ == nil) { + SDLLanguage_CS_CZ = [[SDLLanguage alloc] initWithValue:@"CS-CZ"]; + } + return SDLLanguage_CS_CZ; +} + ++ (SDLLanguage *)DA_DK { + if (SDLLanguage_DA_DK == nil) { + SDLLanguage_DA_DK = [[SDLLanguage alloc] initWithValue:@"DA-DK"]; + } + return SDLLanguage_DA_DK; +} + ++ (SDLLanguage *)NO_NO { + if (SDLLanguage_NO_NO == nil) { + SDLLanguage_NO_NO = [[SDLLanguage alloc] initWithValue:@"NO-NO"]; + } + return SDLLanguage_NO_NO; +} + +@end diff --git a/SmartDeviceLink/SDLLayoutMode.h b/SmartDeviceLink/SDLLayoutMode.h new file mode 100644 index 000000000..9e0377f40 --- /dev/null +++ b/SmartDeviceLink/SDLLayoutMode.h @@ -0,0 +1,43 @@ +// SDLLayoutMode.h +// + + +#import "SDLEnum.h" + +/** + * For touchscreen interactions, the mode of how the choices are presented. + * + * @since SDL 3.0 + */ +@interface SDLLayoutMode : SDLEnum { +} + ++ (SDLLayoutMode *)valueOf:(NSString *)value; ++ (NSArray *)values; + +/** + * This mode causes the interaction to display the previous set of choices as icons. + */ ++ (SDLLayoutMode *)ICON_ONLY; + +/** + * This mode causes the interaction to display the previous set of choices as icons along with a search field in the HMI. + */ ++ (SDLLayoutMode *)ICON_WITH_SEARCH; + +/** + * This mode causes the interaction to display the previous set of choices as a list. + */ ++ (SDLLayoutMode *)LIST_ONLY; + +/** + * This mode causes the interaction to display the previous set of choices as a list along with a search field in the HMI. + */ ++ (SDLLayoutMode *)LIST_WITH_SEARCH; + +/** + * This mode causes the interaction to immediately display a keyboard entry through the HMI. + */ ++ (SDLLayoutMode *)KEYBOARD; + +@end diff --git a/SmartDeviceLink/SDLLayoutMode.m b/SmartDeviceLink/SDLLayoutMode.m new file mode 100644 index 000000000..343f06a0f --- /dev/null +++ b/SmartDeviceLink/SDLLayoutMode.m @@ -0,0 +1,74 @@ +// SDLLayoutMode.m +// + + +#import "SDLLayoutMode.h" + +SDLLayoutMode *SDLLayoutMode_ICON_ONLY = nil; +SDLLayoutMode *SDLLayoutMode_ICON_WITH_SEARCH = nil; +SDLLayoutMode *SDLLayoutMode_LIST_ONLY = nil; +SDLLayoutMode *SDLLayoutMode_LIST_WITH_SEARCH = nil; +SDLLayoutMode *SDLLayoutMode_KEYBOARD = nil; + +NSArray *SDLLayoutMode_values = nil; + +@implementation SDLLayoutMode + ++ (SDLLayoutMode *)valueOf:(NSString *)value { + for (SDLLayoutMode *item in SDLLayoutMode.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLLayoutMode_values == nil) { + SDLLayoutMode_values = @[ + SDLLayoutMode.ICON_ONLY, + SDLLayoutMode.ICON_WITH_SEARCH, + SDLLayoutMode.LIST_ONLY, + SDLLayoutMode.LIST_WITH_SEARCH, + SDLLayoutMode.KEYBOARD, + ]; + } + return SDLLayoutMode_values; +} + ++ (SDLLayoutMode *)ICON_ONLY { + if (SDLLayoutMode_ICON_ONLY == nil) { + SDLLayoutMode_ICON_ONLY = [[SDLLayoutMode alloc] initWithValue:@"ICON_ONLY"]; + } + return SDLLayoutMode_ICON_ONLY; +} + ++ (SDLLayoutMode *)ICON_WITH_SEARCH { + if (SDLLayoutMode_ICON_WITH_SEARCH == nil) { + SDLLayoutMode_ICON_WITH_SEARCH = [[SDLLayoutMode alloc] initWithValue:@"ICON_WITH_SEARCH"]; + } + return SDLLayoutMode_ICON_WITH_SEARCH; +} + ++ (SDLLayoutMode *)LIST_ONLY { + if (SDLLayoutMode_LIST_ONLY == nil) { + SDLLayoutMode_LIST_ONLY = [[SDLLayoutMode alloc] initWithValue:@"LIST_ONLY"]; + } + return SDLLayoutMode_LIST_ONLY; +} + ++ (SDLLayoutMode *)LIST_WITH_SEARCH { + if (SDLLayoutMode_LIST_WITH_SEARCH == nil) { + SDLLayoutMode_LIST_WITH_SEARCH = [[SDLLayoutMode alloc] initWithValue:@"LIST_WITH_SEARCH"]; + } + return SDLLayoutMode_LIST_WITH_SEARCH; +} + ++ (SDLLayoutMode *)KEYBOARD { + if (SDLLayoutMode_KEYBOARD == nil) { + SDLLayoutMode_KEYBOARD = [[SDLLayoutMode alloc] initWithValue:@"KEYBOARD"]; + } + return SDLLayoutMode_KEYBOARD; +} + +@end diff --git a/SmartDeviceLink/SDLListFiles.h b/SmartDeviceLink/SDLListFiles.h new file mode 100644 index 000000000..8a58d8639 --- /dev/null +++ b/SmartDeviceLink/SDLListFiles.h @@ -0,0 +1,27 @@ +// SDLListFiles.h +// + + +#import "SDLRPCRequest.h" + +/** + * Requests the current list of resident filenames for the registered app. Not + * supported on First generation SDL vehicles + * <p> + * + * Since <b>SmartDeviceLink 2.0</b> + */ +@interface SDLListFiles : SDLRPCRequest { +} +/** + * Constructs a new SDLListFiles object + */ +- (instancetype)init; +/** + * Constructs a new SDLListFiles object indicated by the dictionary parameter + * <p> + * + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; +@end diff --git a/SmartDeviceLink/SDLListFiles.m b/SmartDeviceLink/SDLListFiles.m new file mode 100644 index 000000000..a1110df1b --- /dev/null +++ b/SmartDeviceLink/SDLListFiles.m @@ -0,0 +1,23 @@ +// SDLListFiles.m +// + + +#import "SDLListFiles.h" + +#import "SDLNames.h" + +@implementation SDLListFiles + +- (instancetype)init { + if (self = [super initWithName:NAMES_ListFiles]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLListFilesResponse.h b/SmartDeviceLink/SDLListFilesResponse.h new file mode 100644 index 000000000..fd309770c --- /dev/null +++ b/SmartDeviceLink/SDLListFilesResponse.h @@ -0,0 +1,21 @@ +// SDLListFilesResponse.h +// + + +#import "SDLRPCResponse.h" + +/** + * SDLListFilesResponse is sent, when SDLListFiles has been called + * + * Since <b>SmartDeviceLink 2.0</b> + */ +@interface SDLListFilesResponse : SDLRPCResponse { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) NSMutableArray *filenames; +@property (strong) NSNumber *spaceAvailable; + +@end diff --git a/SmartDeviceLink/SDLListFilesResponse.m b/SmartDeviceLink/SDLListFilesResponse.m new file mode 100644 index 000000000..2d58371d8 --- /dev/null +++ b/SmartDeviceLink/SDLListFilesResponse.m @@ -0,0 +1,47 @@ +// SDLListFilesResponse.m +// + + +#import "SDLListFilesResponse.h" + +#import "SDLNames.h" + +@implementation SDLListFilesResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_ListFiles]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setFilenames:(NSMutableArray *)filenames { + if (filenames != nil) { + [parameters setObject:filenames forKey:NAMES_filenames]; + } else { + [parameters removeObjectForKey:NAMES_filenames]; + } +} + +- (NSMutableArray *)filenames { + return [parameters objectForKey:NAMES_filenames]; +} + +- (void)setSpaceAvailable:(NSNumber *)spaceAvailable { + if (spaceAvailable != nil) { + [parameters setObject:spaceAvailable forKey:NAMES_spaceAvailable]; + } else { + [parameters removeObjectForKey:NAMES_spaceAvailable]; + } +} + +- (NSNumber *)spaceAvailable { + return [parameters objectForKey:NAMES_spaceAvailable]; +} + +@end diff --git a/SmartDeviceLink/SDLLockScreenManager.h b/SmartDeviceLink/SDLLockScreenManager.h new file mode 100644 index 000000000..ee8750e83 --- /dev/null +++ b/SmartDeviceLink/SDLLockScreenManager.h @@ -0,0 +1,21 @@ +// +// SDLLockScreenManager.h +// SmartDeviceLink +// + +#import <Foundation/Foundation.h> + +@class SDLHMILevel; +@class SDLLockScreenStatus; +@class SDLOnLockScreenStatus; + + +@interface SDLLockScreenManager : NSObject + +@property (assign, nonatomic) BOOL userSelected; +@property (assign, nonatomic) BOOL driverDistracted; +@property (strong, nonatomic) SDLHMILevel *hmiLevel; +@property (strong, nonatomic, readonly) SDLLockScreenStatus *lockScreenStatus; +@property (strong, nonatomic, readonly) SDLOnLockScreenStatus *lockScreenStatusNotification; + +@end diff --git a/SmartDeviceLink/SDLLockScreenManager.m b/SmartDeviceLink/SDLLockScreenManager.m new file mode 100644 index 000000000..71bb82369 --- /dev/null +++ b/SmartDeviceLink/SDLLockScreenManager.m @@ -0,0 +1,95 @@ +// +// SDLLockScreenManager.m +// SmartDeviceLink +// + +#import "SDLLockScreenManager.h" + +#import "SDLHMILevel.h" +#import "SDLLockScreenStatus.h" +#import "SDLOnLockScreenStatus.h" + + +@interface SDLLockScreenManager () + +@property (assign, nonatomic) BOOL haveDriverDistractionStatus; + +@end + + +@implementation SDLLockScreenManager + +#pragma mark - Lifecycle + +- (instancetype)init { + self = [super init]; + if (self) { + _userSelected = NO; + _driverDistracted = NO; + _haveDriverDistractionStatus = NO; + } + return self; +} + + +#pragma mark - Getters / Setters +#pragma mark Custom setters + +- (void)setDriverDistracted:(BOOL)driverDistracted { + _driverDistracted = driverDistracted; + _haveDriverDistractionStatus = YES; +} + +- (void)setHmiLevel:(SDLHMILevel *)hmiLevel { + if (_hmiLevel != hmiLevel) { + _hmiLevel = hmiLevel; + } + + if ([hmiLevel isEqualToEnum:[SDLHMILevel FULL]] || [hmiLevel isEqualToEnum:[SDLHMILevel LIMITED]]) { + self.userSelected = YES; + } else if ([hmiLevel isEqualToEnum:[SDLHMILevel NONE]]) { + self.userSelected = NO; + } +} + + +#pragma mark Custom Getters + +- (SDLOnLockScreenStatus *)lockScreenStatusNotification { + SDLOnLockScreenStatus *notification = [[SDLOnLockScreenStatus alloc] init]; + notification.driverDistractionStatus = @(self.driverDistracted); + notification.hmiLevel = self.hmiLevel; + notification.userSelected = @(self.userSelected); + notification.lockScreenStatus = self.lockScreenStatus; + + return notification; +} + +- (SDLLockScreenStatus *)lockScreenStatus { + if (self.hmiLevel == nil || [self.hmiLevel isEqualToEnum:[SDLHMILevel NONE]]) { + // App is not active on the car + return [SDLLockScreenStatus OFF]; + } else if ([self.hmiLevel isEqualToEnum:[SDLHMILevel BACKGROUND]]) { + // App is in the background on the car + // The lockscreen depends entirely on if the user selected the app + if (self.userSelected) { + return [SDLLockScreenStatus REQUIRED]; + } else { + return [SDLLockScreenStatus OFF]; + } + } else if ([self.hmiLevel isEqualToEnum:[SDLHMILevel FULL]] || [self.hmiLevel isEqualToEnum:[SDLHMILevel LIMITED]]) { + // App is in the foreground on the car in some manner + if (self.haveDriverDistractionStatus && !self.driverDistracted) { + // We have the distraction status, and the driver is not distracted + return [SDLLockScreenStatus OPTIONAL]; + } else { + // We don't have the distraction status, and/or the driver is distracted + return [SDLLockScreenStatus REQUIRED]; + } + } else { + // This shouldn't be possible. + return [SDLLockScreenStatus OFF]; + } +} + +@end diff --git a/SmartDeviceLink/SDLLockScreenStatus.h b/SmartDeviceLink/SDLLockScreenStatus.h new file mode 100644 index 000000000..044aa7e3e --- /dev/null +++ b/SmartDeviceLink/SDLLockScreenStatus.h @@ -0,0 +1,24 @@ +// +// SDLLockScreenStatus.h +// SmartDeviceLink +// + + +#import "SDLEnum.h" + +@interface SDLLockScreenStatus : SDLEnum ++ (SDLLockScreenStatus *)valueOf:(NSString *)value; ++ (NSMutableArray *)values; +/** + * LockScreen is Not Required + */ ++ (SDLLockScreenStatus *)OFF; +/** + * LockScreen is Optional + */ ++ (SDLLockScreenStatus *)OPTIONAL; +/** + * LockScreen is Not Required + */ ++ (SDLLockScreenStatus *)REQUIRED; +@end diff --git a/SmartDeviceLink/SDLLockScreenStatus.m b/SmartDeviceLink/SDLLockScreenStatus.m new file mode 100644 index 000000000..8ef8a7d43 --- /dev/null +++ b/SmartDeviceLink/SDLLockScreenStatus.m @@ -0,0 +1,59 @@ +// +// SDLLockScreenStatus.m +// SmartDeviceLink +// + +#import "SDLLockScreenStatus.h" + +@implementation SDLLockScreenStatus + +SDLLockScreenStatus *SDLLockScreenStatus_OFF = nil; +SDLLockScreenStatus *SDLLockScreenStatus_OPTIONAL = nil; +SDLLockScreenStatus *SDLLockScreenStatus_REQUIRED = nil; + +NSArray *SDLLockScreenStatus_values = nil; + + ++ (SDLLockScreenStatus *)valueOf:(NSString *)value { + for (SDLLockScreenStatus *item in SDLLockScreenStatus.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLLockScreenStatus_values == nil) { + SDLLockScreenStatus_values = @[ + SDLLockScreenStatus.OFF, + SDLLockScreenStatus.OPTIONAL, + SDLLockScreenStatus.REQUIRED, + ]; + } + return SDLLockScreenStatus_values; +} + ++ (SDLLockScreenStatus *)OFF { + if (SDLLockScreenStatus_OFF == nil) { + SDLLockScreenStatus_OFF = [[SDLLockScreenStatus alloc] initWithValue:@"OFF"]; + } + return SDLLockScreenStatus_OFF; +} + ++ (SDLLockScreenStatus *)OPTIONAL { + if (SDLLockScreenStatus_OPTIONAL == nil) { + SDLLockScreenStatus_OPTIONAL = [[SDLLockScreenStatus alloc] initWithValue:@"OPTIONAL"]; + } + return SDLLockScreenStatus_OPTIONAL; +} + ++ (SDLLockScreenStatus *)REQUIRED { + if (SDLLockScreenStatus_REQUIRED == nil) { + SDLLockScreenStatus_REQUIRED = [[SDLLockScreenStatus alloc] initWithValue:@"REQUIRED"]; + } + return SDLLockScreenStatus_REQUIRED; +} + + +@end diff --git a/SmartDeviceLink/SDLMaintenanceModeStatus.h b/SmartDeviceLink/SDLMaintenanceModeStatus.h new file mode 100644 index 000000000..cd399e20c --- /dev/null +++ b/SmartDeviceLink/SDLMaintenanceModeStatus.h @@ -0,0 +1,50 @@ +// SDLMaintenanceModeStatus.h +// + + +#import "SDLEnum.h" + +/** + * The SDLMaintenanceModeStatus class. + */ +@interface SDLMaintenanceModeStatus : SDLEnum { +} + +/** + * @abstract Maintenance Mode Status + * @param value The value of the string to get an object for + * @return SDLMaintenanceModeStatus + */ ++ (SDLMaintenanceModeStatus *)valueOf:(NSString *)value; + +/** + * @abstract declare an array that store all possible Maintenance Mode Status inside + * @return the array + */ ++ (NSArray *)values; + +/** + * @abstract Maintenance Mode Status : Normal + * @return the object with value of *NORMAL* + */ ++ (SDLMaintenanceModeStatus *)NORMAL; + +/** + * @abstract Maintenance Mode Status : Near + * @return the object with value of *NEAR* + */ ++ (SDLMaintenanceModeStatus *)NEAR; + +/** + * @abstract Maintenance Mode Status : Active + * @return the object with value of *ACTIVE* + */ ++ (SDLMaintenanceModeStatus *)ACTIVE; + +/** + * @abstract Maintenance Mode Status : Feature not present + * @return the object with value of *FEATURE_NOT_PRESENT* + */ ++ (SDLMaintenanceModeStatus *)FEATURE_NOT_PRESENT; + +@end diff --git a/SmartDeviceLink/SDLMaintenanceModeStatus.m b/SmartDeviceLink/SDLMaintenanceModeStatus.m new file mode 100644 index 000000000..d6e7f8ddd --- /dev/null +++ b/SmartDeviceLink/SDLMaintenanceModeStatus.m @@ -0,0 +1,65 @@ +// SDLMaintenanceModeStatus.m +// + + +#import "SDLMaintenanceModeStatus.h" + +SDLMaintenanceModeStatus *SDLMaintenanceModeStatus_NORMAL = nil; +SDLMaintenanceModeStatus *SDLMaintenanceModeStatus_NEAR = nil; +SDLMaintenanceModeStatus *SDLMaintenanceModeStatus_ACTIVE = nil; +SDLMaintenanceModeStatus *SDLMaintenanceModeStatus_FEATURE_NOT_PRESENT = nil; + +NSArray *SDLMaintenanceModeStatus_values = nil; + +@implementation SDLMaintenanceModeStatus + ++ (SDLMaintenanceModeStatus *)valueOf:(NSString *)value { + for (SDLMaintenanceModeStatus *item in SDLMaintenanceModeStatus.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLMaintenanceModeStatus_values == nil) { + SDLMaintenanceModeStatus_values = @[ + SDLMaintenanceModeStatus.NORMAL, + SDLMaintenanceModeStatus.NEAR, + SDLMaintenanceModeStatus.ACTIVE, + SDLMaintenanceModeStatus.FEATURE_NOT_PRESENT, + ]; + } + return SDLMaintenanceModeStatus_values; +} + ++ (SDLMaintenanceModeStatus *)NORMAL { + if (SDLMaintenanceModeStatus_NORMAL == nil) { + SDLMaintenanceModeStatus_NORMAL = [[SDLMaintenanceModeStatus alloc] initWithValue:@"NORMAL"]; + } + return SDLMaintenanceModeStatus_NORMAL; +} + ++ (SDLMaintenanceModeStatus *)NEAR { + if (SDLMaintenanceModeStatus_NEAR == nil) { + SDLMaintenanceModeStatus_NEAR = [[SDLMaintenanceModeStatus alloc] initWithValue:@"NEAR"]; + } + return SDLMaintenanceModeStatus_NEAR; +} + ++ (SDLMaintenanceModeStatus *)ACTIVE { + if (SDLMaintenanceModeStatus_ACTIVE == nil) { + SDLMaintenanceModeStatus_ACTIVE = [[SDLMaintenanceModeStatus alloc] initWithValue:@"ACTIVE"]; + } + return SDLMaintenanceModeStatus_ACTIVE; +} + ++ (SDLMaintenanceModeStatus *)FEATURE_NOT_PRESENT { + if (SDLMaintenanceModeStatus_FEATURE_NOT_PRESENT == nil) { + SDLMaintenanceModeStatus_FEATURE_NOT_PRESENT = [[SDLMaintenanceModeStatus alloc] initWithValue:@"FEATURE_NOT_PRESENT"]; + } + return SDLMaintenanceModeStatus_FEATURE_NOT_PRESENT; +} + +@end diff --git a/SmartDeviceLink/SDLMediaClockFormat.h b/SmartDeviceLink/SDLMediaClockFormat.h new file mode 100644 index 000000000..12c8b8e16 --- /dev/null +++ b/SmartDeviceLink/SDLMediaClockFormat.h @@ -0,0 +1,154 @@ +// SDLMediaClockFormat.h +// + + +#import "SDLEnum.h" + +/** + * Indicates the format of the time displayed on the connected SDL unit. + * + * Format description follows the following nomenclature: <br> + * Sp = Space <br> + * | = or <br> + * c = character <br> + * + * @since SDL 1.0 + */ +@interface SDLMediaClockFormat : SDLEnum { +} + +/** + * @abstract Media Clock Format + * + * @param value The value of the string to get an object for + * + * @return SDLMediaClockFormat + */ ++ (SDLMediaClockFormat *)valueOf:(NSString *)value; + +/** + * @abstract declare an array that store all possible Media clock formats inside + * + * @return the array + */ ++ (NSArray *)values; + +/** + * @abstract Media clock format: Clock1 + * + * @discussion + * <ul> + * <li>maxHours = 19</li> + * <li>maxMinutes = 59</li> + * <li>maxSeconds = 59</li> + * </ul> + * + * @return The SDLMediaClockFormat object with value *CLOCK1* + */ ++ (SDLMediaClockFormat *)CLOCK1; + +/** + * @abstract Media clock format: Clock2 + * + * @discussion + * <ul> + * <li>maxHours = 59</li> + * <li>maxMinutes = 59</li> + * <li>maxSeconds = 59</li> + * </ul> + * + * @return The SDLMediaClockFormat object with value *CLOCK2* + */ ++ (SDLMediaClockFormat *)CLOCK2; + +/** + * @abstract Media clock format: Clock3 + * + * @discussion + * <ul> + * <li>maxHours = 9</li> + * <li>maxMinutes = 59</li> + * <li>maxSeconds = 59</li> + * </ul> + * + * @since SDL 2.0 + * @return The SDLMediaClockFormat object with value *CLOCK3* + */ ++ (SDLMediaClockFormat *)CLOCK3; + +/** + * @abstract Media clock format: ClockText1 + * + * @discussion + * <ul> + * <li>5 characters possible</li> + * <li>Format: 1|sp c :|sp c c</li> + * <li>1|sp : digit "1" or space</li> + * <li>c : character out of following character set: sp|0-9|[letters, see + * TypeII column in XLS.</li> + * <li>:|sp : colon or space</li> + * <li>used for Type II headunit</li> + * </ul> + * + * @return The SDLMediaClockFormat object with value *CLOCKTEXT1* + */ ++ (SDLMediaClockFormat *)CLOCKTEXT1; + +/** + * @abstract Media clock format: ClockText2 + * + * @discussion + * <ul> + * <li>5 characters possible</li> + * <li>Format: 1|sp c :|sp c c</li> + * <li>1|sp : digit "1" or space</li> + * <li>c : character out of following character set: sp|0-9|[letters, see + * CID column in XLS.</li> + * <li>:|sp : colon or space</li> + * <li>used for CID headunit</li> + * </ul> + * difference between CLOCKTEXT1 and CLOCKTEXT2 is the supported character + * set + * + * @return The SDLMediaClockFormat object with value *CLOCKTEXT2* + */ ++ (SDLMediaClockFormat *)CLOCKTEXT2; + +/** + * @abstract Media clock format: ClockText3 + * + * @discussion + * <ul> + * <li>6 chars possible</li> + * <li>Format: 1|sp c c :|sp c c</li> + * <li>1|sp : digit "1" or space</li> + * <li>c : character out of following character set: sp|0-9|[letters, see + * Type 5 column in XLS].</li> + * <li>:|sp : colon or space</li> + * <li>used for Type V headunit</li> + * </ul> + * difference between CLOCKTEXT1 and CLOCKTEXT2 is the supported character + * set + * + * @return The SDLMediaClockFormat object with value *CLOCKTEXT3* + */ ++ (SDLMediaClockFormat *)CLOCKTEXT3; + +/** + * @abstract Media clock format: ClockText4 + * + * @discussion + * <ul> + * <li>6 chars possible</li> + * <li>Format: c :|sp c c : c c</li> + * <li>:|sp : colon or space</li> + * <li>c : character out of following character set: sp|0-9|[letters]</li> + * <li>used for MFD3/4/5 headunits</li> + * </ul> + * + * @since SDL 2.0 + * @return The SDLMediaClockFormat object with value *CLOCKTEXT4* + */ ++ (SDLMediaClockFormat *)CLOCKTEXT4; + +@end diff --git a/SmartDeviceLink/SDLMediaClockFormat.m b/SmartDeviceLink/SDLMediaClockFormat.m new file mode 100644 index 000000000..20ddb8005 --- /dev/null +++ b/SmartDeviceLink/SDLMediaClockFormat.m @@ -0,0 +1,92 @@ +// SDLMediaClockFormat.m +// + + +#import "SDLMediaClockFormat.h" + +SDLMediaClockFormat *SDLMediaClockFormat_CLOCK1 = nil; +SDLMediaClockFormat *SDLMediaClockFormat_CLOCK2 = nil; +SDLMediaClockFormat *SDLMediaClockFormat_CLOCK3 = nil; +SDLMediaClockFormat *SDLMediaClockFormat_CLOCKTEXT1 = nil; +SDLMediaClockFormat *SDLMediaClockFormat_CLOCKTEXT2 = nil; +SDLMediaClockFormat *SDLMediaClockFormat_CLOCKTEXT3 = nil; +SDLMediaClockFormat *SDLMediaClockFormat_CLOCKTEXT4 = nil; + +NSArray *SDLMediaClockFormat_values = nil; + +@implementation SDLMediaClockFormat + ++ (SDLMediaClockFormat *)valueOf:(NSString *)value { + for (SDLMediaClockFormat *item in SDLMediaClockFormat.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLMediaClockFormat_values == nil) { + SDLMediaClockFormat_values = @[ + SDLMediaClockFormat.CLOCK1, + SDLMediaClockFormat.CLOCK2, + SDLMediaClockFormat.CLOCK3, + SDLMediaClockFormat.CLOCKTEXT1, + SDLMediaClockFormat.CLOCKTEXT2, + SDLMediaClockFormat.CLOCKTEXT3, + SDLMediaClockFormat.CLOCKTEXT4, + ]; + } + return SDLMediaClockFormat_values; +} + ++ (SDLMediaClockFormat *)CLOCK1 { + if (SDLMediaClockFormat_CLOCK1 == nil) { + SDLMediaClockFormat_CLOCK1 = [[SDLMediaClockFormat alloc] initWithValue:@"CLOCK1"]; + } + return SDLMediaClockFormat_CLOCK1; +} + ++ (SDLMediaClockFormat *)CLOCK2 { + if (SDLMediaClockFormat_CLOCK2 == nil) { + SDLMediaClockFormat_CLOCK2 = [[SDLMediaClockFormat alloc] initWithValue:@"CLOCK2"]; + } + return SDLMediaClockFormat_CLOCK2; +} + ++ (SDLMediaClockFormat *)CLOCK3 { + if (SDLMediaClockFormat_CLOCK3 == nil) { + SDLMediaClockFormat_CLOCK3 = [[SDLMediaClockFormat alloc] initWithValue:@"CLOCK3"]; + } + return SDLMediaClockFormat_CLOCK3; +} + ++ (SDLMediaClockFormat *)CLOCKTEXT1 { + if (SDLMediaClockFormat_CLOCKTEXT1 == nil) { + SDLMediaClockFormat_CLOCKTEXT1 = [[SDLMediaClockFormat alloc] initWithValue:@"CLOCKTEXT1"]; + } + return SDLMediaClockFormat_CLOCKTEXT1; +} + ++ (SDLMediaClockFormat *)CLOCKTEXT2 { + if (SDLMediaClockFormat_CLOCKTEXT2 == nil) { + SDLMediaClockFormat_CLOCKTEXT2 = [[SDLMediaClockFormat alloc] initWithValue:@"CLOCKTEXT2"]; + } + return SDLMediaClockFormat_CLOCKTEXT2; +} + ++ (SDLMediaClockFormat *)CLOCKTEXT3 { + if (SDLMediaClockFormat_CLOCKTEXT3 == nil) { + SDLMediaClockFormat_CLOCKTEXT3 = [[SDLMediaClockFormat alloc] initWithValue:@"CLOCKTEXT3"]; + } + return SDLMediaClockFormat_CLOCKTEXT3; +} + ++ (SDLMediaClockFormat *)CLOCKTEXT4 { + if (SDLMediaClockFormat_CLOCKTEXT4 == nil) { + SDLMediaClockFormat_CLOCKTEXT4 = [[SDLMediaClockFormat alloc] initWithValue:@"CLOCKTEXT4"]; + } + return SDLMediaClockFormat_CLOCKTEXT4; +} + +@end diff --git a/SmartDeviceLink/SDLMenuParams.h b/SmartDeviceLink/SDLMenuParams.h new file mode 100644 index 000000000..14f51e390 --- /dev/null +++ b/SmartDeviceLink/SDLMenuParams.h @@ -0,0 +1,56 @@ +// SDLMenuParams.h +// + + +#import "SDLRPCMessage.h" + +/** + * Used when adding a sub menu to an application menu or existing sub menu. + * + * @since SDL 1.0 + */ +@interface SDLMenuParams : SDLRPCStruct { +} + +/** + * Constructs a newly allocated SDLMenuParams object + */ +- (instancetype)init; + +/** + * Constructs a newly allocated SDLMenuParams object indicated by the dictionary parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + + +/** + * @abstract the unique ID of an existing submenu to which a command will be added + * @discussion If this element is not provided, the command will be added to the top level of the Command Menu. + * + * Optional, Integer, 0 - 2,000,000,000 + */ +@property (strong) NSNumber *parentID; + +/** + * @abstract The position within the items of the parent Command Menu + * @discussion 0 will insert at the front, 1 will insert after the first existing element, etc. + * + * Position of any submenu will always be located before the return and exit options. + * + * * If position is greater or equal than the number of items in the parent Command Menu, the sub menu will be appended to the end of that Command Menu. + * + * * If this element is omitted, the entry will be added at the end of the parent menu. + * + * Optional, Integer, 0 - 1000 + */ +@property (strong) NSNumber *position; + +/** + * @abstract the menu name which appears in menu, representing this command + * + * Required, max length 500 characters + */ +@property (strong) NSString *menuName; + +@end diff --git a/SmartDeviceLink/SDLMenuParams.m b/SmartDeviceLink/SDLMenuParams.m new file mode 100644 index 000000000..84fb595a8 --- /dev/null +++ b/SmartDeviceLink/SDLMenuParams.m @@ -0,0 +1,59 @@ +// SDLMenuParams.m +// + + +#import "SDLMenuParams.h" + +#import "SDLNames.h" + +@implementation SDLMenuParams + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setParentID:(NSNumber *)parentID { + if (parentID != nil) { + [store setObject:parentID forKey:NAMES_parentID]; + } else { + [store removeObjectForKey:NAMES_parentID]; + } +} + +- (NSNumber *)parentID { + return [store objectForKey:NAMES_parentID]; +} + +- (void)setPosition:(NSNumber *)position { + if (position != nil) { + [store setObject:position forKey:NAMES_position]; + } else { + [store removeObjectForKey:NAMES_position]; + } +} + +- (NSNumber *)position { + return [store objectForKey:NAMES_position]; +} + +- (void)setMenuName:(NSString *)menuName { + if (menuName != nil) { + [store setObject:menuName forKey:NAMES_menuName]; + } else { + [store removeObjectForKey:NAMES_menuName]; + } +} + +- (NSString *)menuName { + return [store objectForKey:NAMES_menuName]; +} + +@end diff --git a/SmartDeviceLink/SDLMyKey.h b/SmartDeviceLink/SDLMyKey.h new file mode 100644 index 000000000..ff039e582 --- /dev/null +++ b/SmartDeviceLink/SDLMyKey.h @@ -0,0 +1,17 @@ +// SDLMyKey.h +// + +#import "SDLRPCMessage.h" + +@class SDLVehicleDataStatus; + + +@interface SDLMyKey : SDLRPCStruct { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) SDLVehicleDataStatus *e911Override; + +@end diff --git a/SmartDeviceLink/SDLMyKey.m b/SmartDeviceLink/SDLMyKey.m new file mode 100644 index 000000000..ec4e5ef95 --- /dev/null +++ b/SmartDeviceLink/SDLMyKey.m @@ -0,0 +1,41 @@ +// SDLMyKey.m +// + +#import "SDLMyKey.h" + +#import "SDLNames.h" +#import "SDLVehicleDataStatus.h" + + +@implementation SDLMyKey + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setE911Override:(SDLVehicleDataStatus *)e911Override { + if (e911Override != nil) { + [store setObject:e911Override forKey:NAMES_e911Override]; + } else { + [store removeObjectForKey:NAMES_e911Override]; + } +} + +- (SDLVehicleDataStatus *)e911Override { + NSObject *obj = [store objectForKey:NAMES_e911Override]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataStatus.class]) { + return (SDLVehicleDataStatus *)obj; + } else { + return [SDLVehicleDataStatus valueOf:(NSString *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLNames.h b/SmartDeviceLink/SDLNames.h new file mode 100644 index 000000000..84bc142ad --- /dev/null +++ b/SmartDeviceLink/SDLNames.h @@ -0,0 +1,406 @@ +// SDLNames.h +// + + +#define NAMES_accPedalPosition @"accPedalPosition" +#define NAMES_actual @"actual" +#define NAMES_AddCommand @"AddCommand" +#define NAMES_addressLines @"addressLines" +#define NAMES_AddSubMenu @"AddSubMenu" +#define NAMES_airbagStatus @"airbagStatus" +#define NAMES_Alert @"Alert" +#define NAMES_AlertManeuver @"AlertManeuver" +#define NAMES_alertText1 @"alertText1" +#define NAMES_alertText2 @"alertText2" +#define NAMES_alertText3 @"alertText3" +#define NAMES_alignment @"alignment" +#define NAMES_allowed @"allowed" +#define NAMES_altitude @"altitude" +#define NAMES_ambientLightSensorStatus @"ambientLightSensorStatus" +#define NAMES_ambientLightStatus @"ambientLightStatus" +#define NAMES_appHMIType @"appHMIType" +#define NAMES_appID @"appID" +#define NAMES_appName @"appName" +#define NAMES_audioPassThruCapabilities @"audioPassThruCapabilities" +#define NAMES_audioPassThruDisplayText1 @"audioPassThruDisplayText1" +#define NAMES_audioPassThruDisplayText2 @"audioPassThruDisplayText2" +#define NAMES_audioStreamingState @"audioStreamingState" +#define NAMES_audioType @"audioType" +#define NAMES_autoCompleteText @"autoCompleteText" +#define NAMES_auxECallNotificationStatus @"auxECallNotificationStatus" +#define NAMES_battLevelStatus @"battLevelStatus" +#define NAMES_beltStatus @"beltStatus" +#define NAMES_bitsPerSample @"bitsPerSample" +#define NAMES_bodyInformation @"bodyInformation" +#define NAMES_btIconOn @"btIconOn" +#define NAMES_bulkData @"bulkData" +#define NAMES_buttonCapabilities @"buttonCapabilities" +#define NAMES_buttonEventMode @"buttonEventMode" +#define NAMES_buttonName @"buttonName" +#define NAMES_buttonPressMode @"buttonPressMode" +#define NAMES_c @"c" +#define NAMES_callActive @"callActive" +#define NAMES_carModeStatus @"carModeStatus" +#define NAMES_carrier @"carrier" +#define NAMES_ChangeRegistration @"ChangeRegistration" +#define NAMES_characterSet @"characterSet" +#define NAMES_choiceID @"choiceID" +#define NAMES_choiceSet @"choiceSet" +#define NAMES_clusterModes @"clusterModes" +#define NAMES_clusterModeStatus @"clusterModeStatus" +#define NAMES_cmdIcon @"cmdIcon" +#define NAMES_cmdID @"cmdID" +#define NAMES_compassDirection @"compassDirection" +#define NAMES_correlationID @"correlationID" +#define NAMES_CreateInteractionChoiceSet @"CreateInteractionChoiceSet" +#define NAMES_customButtonID @"customButtonID" +#define NAMES_customPresets @"customPresets" +#define NAMES_data @"data" +#define NAMES_dataResult @"dataResult" +#define NAMES_dataType @"dataType" +#define NAMES_DeleteCommand @"DeleteCommand" +#define NAMES_DeleteFile @"DeleteFile" +#define NAMES_DeleteInteractionChoiceSet @"DeleteInteractionChoiceSet" +#define NAMES_DeleteSubMenu @"DeleteSubMenu" +#define NAMES_deviceInfo @"deviceInfo" +#define NAMES_deviceStatus @"deviceStatus" +#define NAMES_DiagnosticMessage @"DiagnosticMessage" +#define NAMES_didLocation @"didLocation" +#define NAMES_didResult @"didResult" +#define NAMES_dimension @"dimension" +#define NAMES_displayCapabilities @"displayCapabilities" +#define NAMES_displayLayout @"displayLayout" +#define NAMES_displayType @"displayType" +#define NAMES_distanceToEmpty @"distanceToEmpty" +#define NAMES_distanceToManeuver @"distanceToManeuver" +#define NAMES_distanceToManeuverScale @"distanceToManeuverScale" +#define NAMES_doublePressAvailable @"doublePressAvailable" +#define NAMES_driverAirbagDeployed @"driverAirbagDeployed" +#define NAMES_driverBeltDeployed @"driverBeltDeployed" +#define NAMES_driverBraking @"driverBraking" +#define NAMES_driverBuckleBelted @"driverBuckleBelted" +#define NAMES_driverCurtainAirbagDeployed @"driverCurtainAirbagDeployed" +#define NAMES_driverDoorAjar @"driverDoorAjar" +#define NAMES_driverKneeAirbagDeployed @"driverKneeAirbagDeployed" +#define NAMES_driverSideAirbagDeployed @"driverSideAirbagDeployed" +#define NAMES_dtc @"dtc" +#define NAMES_dtcMask @"dtcMask" +#define NAMES_duration @"duration" +#define NAMES_e911Override @"e911Override" +#define NAMES_eCallConfirmationStatus @"eCallConfirmationStatus" +#define NAMES_eCallEventActive @"eCallEventActive" +#define NAMES_eCallInfo @"eCallInfo" +#define NAMES_eCallNotificationStatus @"eCallNotificationStatus" +#define NAMES_ecuHeader @"ecuHeader" +#define NAMES_ecuName @"ecuName" +#define NAMES_emergencyEvent @"emergencyEvent" +#define NAMES_emergencyEventType @"emergencyEventType" +#define NAMES_EncodedSyncPData @"EncodedSyncPData" +#define NAMES_EndAudioPassThru @"EndAudioPassThru" +#define NAMES_endTime @"endTime" +#define NAMES_engineTorque @"engineTorque" +#define NAMES_eta @"eta" +#define NAMES_event @"event" +#define NAMES_externalTemperature @"externalTemperature" +#define NAMES_fileName @"fileName" +#define NAMES_filenames @"filenames" +#define NAMES_fileType @"fileType" +#define NAMES_firmwareRev @"firmwareRev" +#define NAMES_fuelCutoffStatus @"fuelCutoffStatus" +#define NAMES_fuelLevel @"fuelLevel" +#define NAMES_fuelLevel_State @"fuelLevel_State" +#define NAMES_fuelMaintenanceMode @"fuelMaintenanceMode" +#define NAMES_GenericResponse @"GenericResponse" +#define NAMES_GetDTCs @"GetDTCs" +#define NAMES_GetVehicleData @"GetVehicleData" +#define NAMES_gps @"gps" +#define NAMES_graphic @"graphic" +#define NAMES_graphicSupported @"graphicSupported" +#define NAMES_hardware @"hardware" +#define NAMES_hashID @"hashID" +#define NAMES_hdop @"hdop" +#define NAMES_heading @"heading" +#define NAMES_headLampStatus @"headLampStatus" +#define NAMES_helpPrompt @"helpPrompt" +#define NAMES_highBeamsOn @"highBeamsOn" +#define NAMES_hmiDisplayLanguage @"hmiDisplayLanguage" +#define NAMES_hmiDisplayLanguageDesired @"hmiDisplayLanguageDesired" +#define NAMES_hmiLevel @"hmiLevel" +#define NAMES_hmiPermissions @"hmiPermissions" +#define NAMES_hmiCapabilities @"hmiCapabilities" +#define NAMES_hmiZoneCapabilities @"hmiZoneCapabilities" +#define NAMES_hours @"hours" +#define NAMES_id @"id" +#define NAMES_ignitionStableStatus @"ignitionStableStatus" +#define NAMES_ignitionStatus @"ignitionStatus" +#define NAMES_image @"image" +#define NAMES_imageFields @"imageFields" +#define NAMES_imageResolution @"imageResolution" +#define NAMES_imageSupported @"imageSupported" +#define NAMES_imageType @"imageType" +#define NAMES_imageTypeSupported @"imageTypeSupported" +#define NAMES_info @"info" +#define NAMES_initialPrompt @"initialPrompt" +#define NAMES_initialText @"initialText" +#define NAMES_innerLeftRear @"innerLeftRear" +#define NAMES_innerRightRear @"innerRightRear" +#define NAMES_instantFuelConsumption @"instantFuelConsumption" +#define NAMES_interactionChoiceSetID @"interactionChoiceSetID" +#define NAMES_interactionChoiceSetIDList @"interactionChoiceSetIDList" +#define NAMES_interactionLayout @"interactionLayout" +#define NAMES_interactionMode @"interactionMode" +#define NAMES_isHighlighted @"isHighlighted" +#define NAMES_isMediaApplication @"isMediaApplication" +#define NAMES_keyboardLayout @"keyboardLayout" +#define NAMES_keyboardProperties @"keyboardProperties" +#define NAMES_keypressMode @"keypressMode" +#define NAMES_language @"language" +#define NAMES_languageDesired @"languageDesired" +#define NAMES_latitudeDegrees @"latitudeDegrees" +#define NAMES_leftFront @"leftFront" +#define NAMES_leftRear @"leftRear" +#define NAMES_leftRearInflatableBelted @"leftRearInflatableBelted" +#define NAMES_leftRow2BuckleBelted @"leftRow2BuckleBelted" +#define NAMES_leftRow3BuckleBelted @"leftRow3BuckleBelted" +#define NAMES_length @"length" +#define NAMES_limitedCharacterList @"limitedCharacterList" +#define NAMES_ListFiles @"ListFiles" +#define NAMES_locationDescription @"locationDescription" +#define NAMES_locationImage @"locationImage" +#define NAMES_locationName @"locationName" +#define NAMES_longitudeDegrees @"longitudeDegrees" +#define NAMES_longPress @"longPress" +#define NAMES_longPressAvailable @"longPressAvailable" +#define NAMES_lowBeamsOn @"lowBeamsOn" +#define NAMES_mainField1 @"mainField1" +#define NAMES_mainField2 @"mainField2" +#define NAMES_mainField3 @"mainField3" +#define NAMES_mainField4 @"mainField4" +#define NAMES_majorVersion @"majorVersion" +#define NAMES_make @"make" +#define NAMES_maneuverComplete @"maneuverComplete" +#define NAMES_manualTextEntry @"manualTextEntry" +#define NAMES_maxDuration @"maxDuration" +#define NAMES_maximumChangeVelocity @"maximumChangeVelocity" +#define NAMES_maxNumberRFCOMMPorts @"maxNumberRFCOMMPorts" +#define NAMES_mediaClock @"mediaClock" +#define NAMES_mediaClockFormats @"mediaClockFormats" +#define NAMES_mediaTrack @"mediaTrack" +#define NAMES_menuIcon @"menuIcon" +#define NAMES_menuID @"menuID" +#define NAMES_menuName @"menuName" +#define NAMES_menuParams @"menuParams" +#define NAMES_menuTitle @"menuTitle" +#define NAMES_messageData @"messageData" +#define NAMES_messageDataResult @"messageDataResult" +#define NAMES_messageLength @"messageLength" +#define NAMES_middleRow1BeltDeployed @"middleRow1BeltDeployed" +#define NAMES_middleRow1BuckleBelted @"middleRow1BuckleBelted" +#define NAMES_middleRow2BuckleBelted @"middleRow2BuckleBelted" +#define NAMES_middleRow3BuckleBelted @"middleRow3BuckleBelted" +#define NAMES_minorVersion @"minorVersion" +#define NAMES_minutes @"minutes" +#define NAMES_model @"model" +#define NAMES_modelYear @"modelYear" +#define NAMES_monoAudioOutputMuted @"monoAudioOutputMuted" +#define NAMES_multipleEvents @"multipleEvents" +#define NAMES_multiTouchAvailable @"multiTouchAvailable" +#define NAMES_muteAudio @"muteAudio" +#define NAMES_myKey @"myKey" +#define NAMES_name @"name" +#define NAMES_navigation @"navigation" +#define NAMES_navigationText @"navigationText" +#define NAMES_navigationText1 @"navigationText1" +#define NAMES_navigationText2 @"navigationText2" +#define NAMES_nextTurnIcon @"nextTurnIcon" +#define NAMES_ngnMediaScreenAppName @"ngnMediaScreenAppName" +#define NAMES_notification @"notification" +#define NAMES_number @"number" +#define NAMES_numCustomPresetsAvailable @"numCustomPresetsAvailable" +#define NAMES_numTicks @"numTicks" +#define NAMES_odometer @"odometer" +#define NAMES_offset @"offset" +#define NAMES_OnAppInterfaceUnregistered @"OnAppInterfaceUnregistered" +#define NAMES_OnAudioPassThru @"OnAudioPassThru" +#define NAMES_OnButtonEvent @"OnButtonEvent" +#define NAMES_OnButtonPress @"OnButtonPress" +#define NAMES_OnCommand @"OnCommand" +#define NAMES_OnDriverDistraction @"OnDriverDistraction" +#define NAMES_OnEncodedSyncPData @"OnEncodedSyncPData" +#define NAMES_OnHashChange @"OnHashChange" +#define NAMES_OnHMIStatus @"OnHMIStatus" +#define NAMES_OnKeyboardInput @"OnKeyboardInput" +#define NAMES_OnLanguageChange @"OnLanguageChange" +#define NAMES_OnPermissionsChange @"OnPermissionsChange" +#define NAMES_onScreenPresetsAvailable @"onScreenPresetsAvailable" +#define NAMES_OnSyncPData @"OnSyncPData" +#define NAMES_OnSystemRequest @"OnSystemRequest" +#define NAMES_OnTBTClientState @"OnTBTClientState" +#define NAMES_OnTouchEvent @"OnTouchEvent" +#define NAMES_OnVehicleData @"OnVehicleData" +#define NAMES_operation_name @"name" +#define NAMES_os @"os" +#define NAMES_osVersion @"osVersion" +#define NAMES_parameterPermissions @"parameterPermissions" +#define NAMES_parameters @"parameters" +#define NAMES_parentID @"parentID" +#define NAMES_parkBrakeActive @"parkBrakeActive" +#define NAMES_passengerAirbagDeployed @"passengerAirbagDeployed" +#define NAMES_passengerBeltDeployed @"passengerBeltDeployed" +#define NAMES_passengerBuckleBelted @"passengerBuckleBelted" +#define NAMES_passengerChildDetected @"passengerChildDetected" +#define NAMES_passengerCurtainAirbagDeployed @"passengerCurtainAirbagDeployed" +#define NAMES_passengerDoorAjar @"passengerDoorAjar" +#define NAMES_passengerKneeAirbagDeployed @"passengerKneeAirbagDeployed" +#define NAMES_passengerSideAirbagDeployed @"passengerSideAirbagDeployed" +#define NAMES_pdop @"pdop" +#define NAMES_PerformAudioPassThru @"PerformAudioPassThru" +#define NAMES_PerformInteraction @"PerformInteraction" +#define NAMES_permissionItem @"permissionItem" +#define NAMES_persistentFile @"persistentFile" +#define NAMES_phoneCall @"phoneCall" +#define NAMES_phoneNumber @"phoneNumber" +#define NAMES_phoneRoaming @"phoneRoaming" +#define NAMES_playTone @"playTone" +#define NAMES_position @"position" +#define NAMES_powerModeActive @"powerModeActive" +#define NAMES_powerModeQualificationStatus @"powerModeQualificationStatus" +#define NAMES_powerModeStatus @"powerModeStatus" +#define NAMES_prerecordedSpeech @"prerecordedSpeech" +#define NAMES_presetBankCapabilities @"presetBankCapabilities" +#define NAMES_pressAvailable @"pressAvailable" +#define NAMES_pressure @"pressure" +#define NAMES_pressureTelltale @"pressureTelltale" +#define NAMES_primaryAudioSource @"primaryAudioSource" +#define NAMES_prndl @"prndl" +#define NAMES_progressIndicator @"progressIndicator" +#define NAMES_properties @"properties" +#define NAMES_PutFile @"PutFile" +#define NAMES_ReadDID @"ReadDID" +#define NAMES_rearLeftDoorAjar @"rearLeftDoorAjar" +#define NAMES_rearRightDoorAjar @"rearRightDoorAjar" +#define NAMES_reason @"reason" +#define NAMES_RegisterAppInterface @"RegisterAppInterface" +#define NAMES_request @"request" +#define NAMES_requestType @"requestType" +#define NAMES_reserved @"reserved" +#define NAMES_ResetGlobalProperties @"ResetGlobalProperties" +#define NAMES_resolution @"resolution" +#define NAMES_resolutionHeight @"resolutionHeight" +#define NAMES_resolutionWidth @"resolutionWidth" +#define NAMES_response @"response" +#define NAMES_result @"result" +#define NAMES_resultCode @"resultCode" +#define NAMES_rightFront @"rightFront" +#define NAMES_rightRear @"rightRear" +#define NAMES_rightRearInflatableBelted @"rightRearInflatableBelted" +#define NAMES_rightRow2BuckleBelted @"rightRow2BuckleBelted" +#define NAMES_rightRow3BuckleBelted @"rightRow3BuckleBelted" +#define NAMES_rolloverEvent @"rolloverEvent" +#define NAMES_rows @"rows" +#define NAMES_rpcName @"rpcName" +#define NAMES_rpm @"rpm" +#define NAMES_samplingRate @"samplingRate" +#define NAMES_satellites @"satellites" +#define NAMES_screenParams @"screenParams" +#define NAMES_ScrollableMessage @"ScrollableMessage" +#define NAMES_scrollableMessageBody @"scrollableMessageBody" +#define NAMES_sdlVersion @"sdlVersion" +#define NAMES_secondaryGraphic @"secondaryGraphic" +#define NAMES_secondaryImage @"secondaryImage" +#define NAMES_secondaryText @"secondaryText" +#define NAMES_seconds @"seconds" +#define NAMES_SendLocation @"SendLocation" +#define NAMES_SetAppIcon @"SetAppIcon" +#define NAMES_SetDisplayLayout @"SetDisplayLayout" +#define NAMES_SetGlobalProperties @"SetGlobalProperties" +#define NAMES_SetMediaClockTimer @"SetMediaClockTimer" +#define NAMES_shortPress @"shortPress" +#define NAMES_shortPressAvailable @"shortPressAvailable" +#define NAMES_Show @"Show" +#define NAMES_ShowConstantTBT @"ShowConstantTBT" +#define NAMES_signalLevelStatus @"signalLevelStatus" +#define NAMES_Slider @"Slider" +#define NAMES_sliderFooter @"sliderFooter" +#define NAMES_sliderHeader @"sliderHeader" +#define NAMES_sliderPosition @"sliderPosition" +#define NAMES_softButtonCapabilities @"softButtonCapabilities" +#define NAMES_softButtonID @"softButtonID" +#define NAMES_softButtons @"softButtons" +#define NAMES_spaceAvailable @"spaceAvailable" +#define NAMES_Speak @"Speak" +#define NAMES_speechCapabilities @"speechCapabilities" +#define NAMES_speed @"speed" +#define NAMES_startTime @"startTime" +#define NAMES_state @"state" +#define NAMES_stateOfCharge @"stateOfCharge" +#define NAMES_status @"status" +#define NAMES_statusBar @"statusBar" +#define NAMES_steeringWheelAngle @"steeringWheelAngle" +#define NAMES_stereoAudioOutputMuted @"stereoAudioOutputMuted" +#define NAMES_Subscribe @"Subscribe" +#define NAMES_SubscribeButton @"SubscribeButton" +#define NAMES_SubscribeVehicleData @"SubscribeVehicleData" +#define NAMES_success @"success" +#define NAMES_supportedDiagModes @"supportedDiagModes" +#define NAMES_syncFileName @"syncFileName" +#define NAMES_syncMsgVersion @"syncMsgVersion" +#define NAMES_SyncPData @"SyncPData" +#define NAMES_systemAction @"systemAction" +#define NAMES_systemContext @"systemContext" +#define NAMES_systemFile @"systemFile" +#define NAMES_SystemRequest @"SystemRequest" +#define NAMES_systemSoftwareVersion @"systemSoftwareVersion" +#define NAMES_DialNumber @"DialNumber" +#define NAMES_targetID @"targetID" +#define NAMES_templatesAvailable @"templatesAvailable" +#define NAMES_tertiaryText @"tertiaryText" +#define NAMES_text @"text" +#define NAMES_textFields @"textFields" +#define NAMES_textMsgAvailable @"textMsgAvailable" +#define NAMES_timeout @"timeout" +#define NAMES_Timeout @"Timeout" +#define NAMES_timeoutPrompt @"timeoutPrompt" +#define NAMES_timeToDestination @"timeToDestination" +#define NAMES_tirePressure @"tirePressure" +#define NAMES_totalDistance @"totalDistance" +#define NAMES_touchEventAvailable @"touchEventAvailable" +#define NAMES_triggerSource @"triggerSource" +#define NAMES_trim @"trim" +#define NAMES_tryAgainTime @"tryAgainTime" +#define NAMES_ts @"ts" +#define NAMES_ttsChunks @"ttsChunks" +#define NAMES_ttsName @"ttsName" +#define NAMES_turnIcon @"turnIcon" +#define NAMES_turnList @"turnList" +#define NAMES_type @"type" +#define NAMES_UnregisterAppInterface @"UnregisterAppInterface" +#define NAMES_Unsubscribe @"Unsubscribe" +#define NAMES_UnsubscribeButton @"UnsubscribeButton" +#define NAMES_UnsubscribeVehicleData @"UnsubscribeVehicleData" +#define NAMES_updateMode @"updateMode" +#define NAMES_UpdateTurnList @"UpdateTurnList" +#define NAMES_upDownAvailable @"upDownAvailable" +#define NAMES_url @"url" +#define NAMES_URL @"URL" +#define NAMES_userDisallowed @"userDisallowed" +#define NAMES_utcDay @"utcDay" +#define NAMES_utcHours @"utcHours" +#define NAMES_utcMinutes @"utcMinutes" +#define NAMES_utcMonth @"utcMonth" +#define NAMES_utcSeconds @"utcSeconds" +#define NAMES_utcYear @"utcYear" +#define NAMES_value @"value" +#define NAMES_vdop @"vdop" +#define NAMES_vehicleType @"vehicleType" +#define NAMES_vin @"vin" +#define NAMES_voiceRecOn @"voiceRecOn" +#define NAMES_vrCapabilities @"vrCapabilities" +#define NAMES_vrCommands @"vrCommands" +#define NAMES_vrHelp @"vrHelp" +#define NAMES_vrHelpTitle @"vrHelpTitle" +#define NAMES_vrSynonyms @"vrSynonyms" +#define NAMES_width @"width" +#define NAMES_wiperStatus @"wiperStatus" +#define NAMES_x @"x" +#define NAMES_y @"y" diff --git a/SmartDeviceLink/SDLObjectWithPriority.h b/SmartDeviceLink/SDLObjectWithPriority.h new file mode 100644 index 000000000..334139d5f --- /dev/null +++ b/SmartDeviceLink/SDLObjectWithPriority.h @@ -0,0 +1,18 @@ +// +// SDLObjectWithPriority.h +// SmartDeviceLink +// + +#import <Foundation/Foundation.h> + + +@interface SDLObjectWithPriority : NSObject + +@property (strong) id object; +@property (assign) NSInteger priority; + +- (instancetype)initWithObject:(id)object priority:(NSInteger)priority NS_DESIGNATED_INITIALIZER; + ++ (instancetype)objectWithObject:(id)object priority:(NSInteger)priority; + +@end diff --git a/SmartDeviceLink/SDLObjectWithPriority.m b/SmartDeviceLink/SDLObjectWithPriority.m new file mode 100644 index 000000000..4dd72091e --- /dev/null +++ b/SmartDeviceLink/SDLObjectWithPriority.m @@ -0,0 +1,31 @@ +// +// SDLObjectWithPriority.m +// SmartDeviceLink +// + +#import "SDLObjectWithPriority.h" + + +@implementation SDLObjectWithPriority + +- (instancetype)initWithObject:(id)object priority:(NSInteger)priority { + self = [super init]; + if (self == nil) { + return nil; + } + + self.object = object; + self.priority = priority; + + return self; +} + +- (instancetype)init { + return [self initWithObject:nil priority:NSIntegerMax]; +} + ++ (instancetype)objectWithObject:(id)object priority:(NSInteger)priority { + return [[self alloc] initWithObject:object priority:priority]; +} + +@end diff --git a/SmartDeviceLink/SDLOnAppInterfaceUnregistered.h b/SmartDeviceLink/SDLOnAppInterfaceUnregistered.h new file mode 100644 index 000000000..59b596f58 --- /dev/null +++ b/SmartDeviceLink/SDLOnAppInterfaceUnregistered.h @@ -0,0 +1,35 @@ +// SDLOnAppInterfaceUnregistered.h +// + +#import "SDLRPCNotification.h" + +@class SDLAppInterfaceUnregisteredReason; + + +/** + * Notifies an application that its interface registration has been terminated. This means that all SDL resources associated with the application are discarded, including the Command Menu, Choice Sets, button subscriptions, etc. + * + * For more information about SDL resources related to an interface registration, see <i>SDLRegisterAppInterface</i>. + * + * @since SDL 1.0 + * @see SDLRegisterAppInterface + */ +@interface SDLOnAppInterfaceUnregistered : SDLRPCNotification { +} + +/** + * Constructs a newly allocated SDLOnAppInterfaceUnregistered object + */ +- (instancetype)init; +/** + * Constructs a newly allocated SDLOnAppInterfaceUnregistered object indicated by the dictionary parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract The reason application's interface was terminated + */ +@property (strong) SDLAppInterfaceUnregisteredReason *reason; + +@end diff --git a/SmartDeviceLink/SDLOnAppInterfaceUnregistered.m b/SmartDeviceLink/SDLOnAppInterfaceUnregistered.m new file mode 100644 index 000000000..5427cf871 --- /dev/null +++ b/SmartDeviceLink/SDLOnAppInterfaceUnregistered.m @@ -0,0 +1,41 @@ +// SDLOnAppInterfaceUnregistered.m +// + +#import "SDLOnAppInterfaceUnregistered.h" + +#import "SDLAppInterfaceUnregisteredReason.h" +#import "SDLNames.h" + + +@implementation SDLOnAppInterfaceUnregistered + +- (instancetype)init { + if (self = [super initWithName:NAMES_OnAppInterfaceUnregistered]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setReason:(SDLAppInterfaceUnregisteredReason *)reason { + if (reason != nil) { + [parameters setObject:reason forKey:NAMES_reason]; + } else { + [parameters removeObjectForKey:NAMES_reason]; + } +} + +- (SDLAppInterfaceUnregisteredReason *)reason { + NSObject *obj = [parameters objectForKey:NAMES_reason]; + if (obj == nil || [obj isKindOfClass:SDLAppInterfaceUnregisteredReason.class]) { + return (SDLAppInterfaceUnregisteredReason *)obj; + } else { + return [SDLAppInterfaceUnregisteredReason valueOf:(NSString *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLOnAudioPassThru.h b/SmartDeviceLink/SDLOnAudioPassThru.h new file mode 100644 index 000000000..f37d4067e --- /dev/null +++ b/SmartDeviceLink/SDLOnAudioPassThru.h @@ -0,0 +1,39 @@ +// SDLOnAudioPassThru.h +// + + +#import "SDLRPCNotification.h" + +/** + * Binary data is in binary part of hybrid msg. + * + * HMI Status Requirements: + * <ul> + * HMILevel: + * <ul> + * <li>BACKGROUND, FULL, LIMITED</li> + * </ul> + * AudioStreamingState: + * <ul> + * <li>TBD</li> + * </ul> + * SystemContext: + * <ul> + * <li>TBD</li> + * </ul> + * </ul> + */ +@interface SDLOnAudioPassThru : SDLRPCNotification { +} + +/** + *Constructs a newly allocated SDLOnAudioPassThru object + */ +- (instancetype)init; + +/** + * Constructs a newly allocated SDLOnAudioPassThru object indicated by the dictionary parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; +@end diff --git a/SmartDeviceLink/SDLOnAudioPassThru.m b/SmartDeviceLink/SDLOnAudioPassThru.m new file mode 100644 index 000000000..e0360e3e4 --- /dev/null +++ b/SmartDeviceLink/SDLOnAudioPassThru.m @@ -0,0 +1,23 @@ +// SDLOnAudioPassThru.m +// + + +#import "SDLOnAudioPassThru.h" + +#import "SDLNames.h" + +@implementation SDLOnAudioPassThru + +- (instancetype)init { + if (self = [super initWithName:NAMES_OnAudioPassThru]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLOnButtonEvent.h b/SmartDeviceLink/SDLOnButtonEvent.h new file mode 100644 index 000000000..0d1fc8afd --- /dev/null +++ b/SmartDeviceLink/SDLOnButtonEvent.h @@ -0,0 +1,81 @@ +// SDLOnButtonEvent.h +// + +#import "SDLRPCNotification.h" + +@class SDLButtonName; +@class SDLButtonEventMode; + + +/** + * Notifies application that user has depressed or released a button to which + * the application has subscribed. + * + * Further information about button events + * and button-presses can be found at SDLSubscribeButton. + * <p> + * </p> + * <b>HMI Status Requirements:</b> + * <ul> + * HMILevel: + * <ul> + * <li>The application will receive <i>SDLOnButtonEvent</i> notifications for all + * subscribed buttons when HMILevel is FULL.</li> + * <li>The application will receive <i>SDLOnButtonEvent</i> notifications for subscribed + * media buttons when HMILevel is LIMITED.</li> + * <li>Media buttons include SEEKLEFT, SEEKRIGHT, TUNEUP, TUNEDOWN, and + * PRESET_0-PRESET_9.</li> + * <li>The application will not receive <i>SDLOnButtonEvent</i> notification when HMILevel + * is BACKGROUND.</li> + * </ul> + * AudioStreamingState: + * <ul> + * <li> Any </li> + * </ul> + * SystemContext: + * <ul> + * <li>MAIN, VR. In MENU, only PRESET buttons. In VR, pressing any subscribable + * button will cancel VR.</li> + * </ul> + * </ul> + * <p> + * + * @see SDLSubscribeButton + * + * @since SDL 1.0 + */ +@interface SDLOnButtonEvent : SDLRPCNotification { +} + +/** + * Constructs a newly allocated SDLOnButtonEvent object + */ +- (instancetype)init; + +/** + * @abstract Constructs a newly allocated SDLOnButtonEvent object indicated by the dictionary parameter + * + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract The name of the button + */ +@property (strong) SDLButtonName *buttonName; + +/** + * @abstract Indicates whether this is an UP or DOWN event + */ +@property (strong) SDLButtonEventMode *buttonEventMode; + +/** + * @abstract If ButtonName is "CUSTOM_BUTTON", this references the integer ID passed by a custom button. (e.g. softButton ID) + * + * @since SDL 2.0 + * + * Optional, Integer, 0 - 65536 + */ +@property (strong) NSNumber *customButtonID; + +@end diff --git a/SmartDeviceLink/SDLOnButtonEvent.m b/SmartDeviceLink/SDLOnButtonEvent.m new file mode 100644 index 000000000..d112d88ea --- /dev/null +++ b/SmartDeviceLink/SDLOnButtonEvent.m @@ -0,0 +1,71 @@ +// SDLOnButtonEvent.m +// + +#import "SDLOnButtonEvent.h" + +#import "SDLButtonEventMode.h" +#import "SDLButtonName.h" +#import "SDLNames.h" + + +@implementation SDLOnButtonEvent + +- (instancetype)init { + if (self = [super initWithName:NAMES_OnButtonEvent]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setButtonName:(SDLButtonName *)buttonName { + if (buttonName != nil) { + [parameters setObject:buttonName forKey:NAMES_buttonName]; + } else { + [parameters removeObjectForKey:NAMES_buttonName]; + } +} + +- (SDLButtonName *)buttonName { + NSObject *obj = [parameters objectForKey:NAMES_buttonName]; + if (obj == nil || [obj isKindOfClass:SDLButtonName.class]) { + return (SDLButtonName *)obj; + } else { + return [SDLButtonName valueOf:(NSString *)obj]; + } +} + +- (void)setButtonEventMode:(SDLButtonEventMode *)buttonEventMode { + if (buttonEventMode != nil) { + [parameters setObject:buttonEventMode forKey:NAMES_buttonEventMode]; + } else { + [parameters removeObjectForKey:NAMES_buttonEventMode]; + } +} + +- (SDLButtonEventMode *)buttonEventMode { + NSObject *obj = [parameters objectForKey:NAMES_buttonEventMode]; + if (obj == nil || [obj isKindOfClass:SDLButtonEventMode.class]) { + return (SDLButtonEventMode *)obj; + } else { + return [SDLButtonEventMode valueOf:(NSString *)obj]; + } +} + +- (void)setCustomButtonID:(NSNumber *)customButtonID { + if (customButtonID != nil) { + [parameters setObject:customButtonID forKey:NAMES_customButtonID]; + } else { + [parameters removeObjectForKey:NAMES_customButtonID]; + } +} + +- (NSNumber *)customButtonID { + return [parameters objectForKey:NAMES_customButtonID]; +} + +@end diff --git a/SmartDeviceLink/SDLOnButtonPress.h b/SmartDeviceLink/SDLOnButtonPress.h new file mode 100644 index 000000000..942dbd583 --- /dev/null +++ b/SmartDeviceLink/SDLOnButtonPress.h @@ -0,0 +1,94 @@ +// SDLOnButtonPress.h +// + +#import "SDLRPCNotification.h" + +@class SDLButtonName; +@class SDLButtonPressMode; + + +/** + * Notifies application of button press events for buttons to which the + * application is subscribed. SDL supports two button press events defined as + * follows: + * + * <ul> + * <li>SHORT - Occurs when a button is depressed, then released within two + * seconds. The event is considered to occur immediately after the button is + * released.</li> + * <li>LONG - Occurs when a button is depressed and held for two seconds or + * more. The event is considered to occur immediately after the two second + * threshold has been crossed, before the button is released</li> + * </ul> + * <b>HMI Status Requirements:</b> + * <ul> + * HMILevel: + * <ul> + * <li>The application will receive OnButtonPress notifications for all + * subscribed buttons when HMILevel is FULL.</li> + * <li>The application will receive OnButtonPress notifications for subscribed + * media buttons when HMILevel is LIMITED.</li> + * <li>Media buttons include SEEKLEFT, SEEKRIGHT, TUNEUP, TUNEDOWN, and + * PRESET_0-PRESET_9.</li> + * <li>The application will not receive OnButtonPress notification when HMILevel + * is BACKGROUND or NONE.</li> + * </ul> + * AudioStreamingState: + * <ul> + * <li> Any </li> + * </ul> + * SystemContext: + * <ul> + * <li>MAIN, VR. In MENU, only PRESET buttons. In VR, pressing any subscribable + * button will cancel VR.</li> + * </ul> + * </ul> + * + * @see SDLSubscribeButton + * @see SDLUnsubscribeButton + * + * @since SDL 1.0 + */ +@interface SDLOnButtonPress : SDLRPCNotification { +} + +/** + * Constructs a newly allocated SDLOnButtonPress object + */ +- (instancetype)init; + +/** + * Constructs a newly allocated SDLOnButtonPress object indicated by the dictionary parameter + * + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract the button's name + * + * @see SDLButtonName + * + * Required + */ +@property (strong) SDLButtonName *buttonName; + +/** + * @abstract Indicates whether this is a LONG or SHORT button press event + * + * @see SDLButtonPressMode + * + * Required + */ +@property (strong) SDLButtonPressMode *buttonPressMode; + +/** + * @abstract If ButtonName is "CUSTOM_BUTTON", this references the integer ID passed by a custom button. (e.g. softButton ID) + * + * @since SDL 2.0 + * + * Optional, Integer 0 - 65536 + */ +@property (strong) NSNumber *customButtonID; + +@end diff --git a/SmartDeviceLink/SDLOnButtonPress.m b/SmartDeviceLink/SDLOnButtonPress.m new file mode 100644 index 000000000..8926b7951 --- /dev/null +++ b/SmartDeviceLink/SDLOnButtonPress.m @@ -0,0 +1,71 @@ +// SDLOnButtonPress.m +// + +#import "SDLOnButtonPress.h" + +#import "SDLButtonName.h" +#import "SDLButtonPressMode.h" +#import "SDLNames.h" + + +@implementation SDLOnButtonPress + +- (instancetype)init { + if (self = [super initWithName:NAMES_OnButtonPress]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setButtonName:(SDLButtonName *)buttonName { + if (buttonName != nil) { + [parameters setObject:buttonName forKey:NAMES_buttonName]; + } else { + [parameters removeObjectForKey:NAMES_buttonName]; + } +} + +- (SDLButtonName *)buttonName { + NSObject *obj = [parameters objectForKey:NAMES_buttonName]; + if (obj == nil || [obj isKindOfClass:SDLButtonName.class]) { + return (SDLButtonName *)obj; + } else { + return [SDLButtonName valueOf:(NSString *)obj]; + } +} + +- (void)setButtonPressMode:(SDLButtonPressMode *)buttonPressMode { + if (buttonPressMode != nil) { + [parameters setObject:buttonPressMode forKey:NAMES_buttonPressMode]; + } else { + [parameters removeObjectForKey:NAMES_buttonPressMode]; + } +} + +- (SDLButtonPressMode *)buttonPressMode { + NSObject *obj = [parameters objectForKey:NAMES_buttonPressMode]; + if (obj == nil || [obj isKindOfClass:SDLButtonPressMode.class]) { + return (SDLButtonPressMode *)obj; + } else { + return [SDLButtonPressMode valueOf:(NSString *)obj]; + } +} + +- (void)setCustomButtonID:(NSNumber *)customButtonID { + if (customButtonID != nil) { + [parameters setObject:customButtonID forKey:NAMES_customButtonID]; + } else { + [parameters removeObjectForKey:NAMES_customButtonID]; + } +} + +- (NSNumber *)customButtonID { + return [parameters objectForKey:NAMES_customButtonID]; +} + +@end diff --git a/SmartDeviceLink/SDLOnCommand.h b/SmartDeviceLink/SDLOnCommand.h new file mode 100644 index 000000000..5d3d3f599 --- /dev/null +++ b/SmartDeviceLink/SDLOnCommand.h @@ -0,0 +1,42 @@ +// SDLOnCommand.h +// + +#import "SDLRPCNotification.h" + +@class SDLTriggerSource; + + +/** + * This is called when a command was selected via VR after pressing the PTT button, or selected from the menu after + * pressing the MENU button. + * + * <b>Note:</b> The sequence of *SDLOnHMIStatus* and *SDLOnCommand* notifications for user-initiated interactions is indeterminate. + * + * @since SDL 1.0 + * @see SDLAddCommand SDLDeleteCommand SDLDeleteSubMenu + */ +@interface SDLOnCommand : SDLRPCNotification { +} + +/** + *Constructs a newly allocated SDLRPCNotification object + */ +- (instancetype)init; + +/** + * Constructs a newly allocated SDLRPCNotification object indicated by the dictionary parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract The command ID of the command the user selected. This is the command ID value provided by the application in the <i>SDLAddCommand</i> operation that created the command. + */ +@property (strong) NSNumber *cmdID; + +/** + * @abstract Indicates whether command was selected via voice or via a menu selection (using the OK button). + */ +@property (strong) SDLTriggerSource *triggerSource; + +@end diff --git a/SmartDeviceLink/SDLOnCommand.m b/SmartDeviceLink/SDLOnCommand.m new file mode 100644 index 000000000..f16023d42 --- /dev/null +++ b/SmartDeviceLink/SDLOnCommand.m @@ -0,0 +1,53 @@ +// SDLOnCommand.m +// + +#import "SDLOnCommand.h" + +#import "SDLNames.h" +#import "SDLTriggerSource.h" + + +@implementation SDLOnCommand + +- (instancetype)init { + if (self = [super initWithName:NAMES_OnCommand]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setCmdID:(NSNumber *)cmdID { + if (cmdID != nil) { + [parameters setObject:cmdID forKey:NAMES_cmdID]; + } else { + [parameters removeObjectForKey:NAMES_cmdID]; + } +} + +- (NSNumber *)cmdID { + return [parameters objectForKey:NAMES_cmdID]; +} + +- (void)setTriggerSource:(SDLTriggerSource *)triggerSource { + if (triggerSource != nil) { + [parameters setObject:triggerSource forKey:NAMES_triggerSource]; + } else { + [parameters removeObjectForKey:NAMES_triggerSource]; + } +} + +- (SDLTriggerSource *)triggerSource { + NSObject *obj = [parameters objectForKey:NAMES_triggerSource]; + if (obj == nil || [obj isKindOfClass:SDLTriggerSource.class]) { + return (SDLTriggerSource *)obj; + } else { + return [SDLTriggerSource valueOf:(NSString *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLOnDriverDistraction.h b/SmartDeviceLink/SDLOnDriverDistraction.h new file mode 100644 index 000000000..d99e57393 --- /dev/null +++ b/SmartDeviceLink/SDLOnDriverDistraction.h @@ -0,0 +1,46 @@ +// SDLOnDriverDistraction.h +// + +#import "SDLRPCNotification.h" + +@class SDLDriverDistractionState; + + +/** + * Notifies the application of the current driver distraction state (whether driver distraction rules are in effect, or + * not). + * + * HMI Status Requirements: + * + * <ul> + * HMILevel: + * <ul><li>Can be sent with FULL, LIMITED or BACKGROUND</li></ul> + * AudioStreamingState: + * <ul><li>Any</li></ul> + * SystemContext: + * <ul><li>Any</li></ul> + * </ul> + * + * @since SDL 1.0 + */ +@interface SDLOnDriverDistraction : SDLRPCNotification { +} + +/** + * Constructs a newly allocated SDLOnDriverDistraction object + */ +- (instancetype)init; + +/** + * Constructs a newly allocated SDLOnDriverDistraction object indicated by the dictionary parameter + * + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract The driver distraction state (i.e. whether driver distraction rules are in effect, or not) + */ +@property (strong) SDLDriverDistractionState *state; + +@end diff --git a/SmartDeviceLink/SDLOnDriverDistraction.m b/SmartDeviceLink/SDLOnDriverDistraction.m new file mode 100644 index 000000000..1a87075b3 --- /dev/null +++ b/SmartDeviceLink/SDLOnDriverDistraction.m @@ -0,0 +1,41 @@ +// SDLOnDriverDistraction.m +// + +#import "SDLOnDriverDistraction.h" + +#import "SDLDriverDistractionState.h" +#import "SDLNames.h" + + +@implementation SDLOnDriverDistraction + +- (instancetype)init { + if (self = [super initWithName:NAMES_OnDriverDistraction]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setState:(SDLDriverDistractionState *)state { + if (state != nil) { + [parameters setObject:state forKey:NAMES_state]; + } else { + [parameters removeObjectForKey:NAMES_state]; + } +} + +- (SDLDriverDistractionState *)state { + NSObject *obj = [parameters objectForKey:NAMES_state]; + if (obj == nil || [obj isKindOfClass:SDLDriverDistractionState.class]) { + return (SDLDriverDistractionState *)obj; + } else { + return [SDLDriverDistractionState valueOf:(NSString *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLOnEncodedSyncPData.h b/SmartDeviceLink/SDLOnEncodedSyncPData.h new file mode 100644 index 000000000..618aaf7d2 --- /dev/null +++ b/SmartDeviceLink/SDLOnEncodedSyncPData.h @@ -0,0 +1,17 @@ +// SDLOnEncodedSyncPData.h +// + +#import "SDLRPCNotification.h" + + +@interface SDLOnEncodedSyncPData : SDLRPCNotification { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) NSMutableArray *data; +@property (strong) NSString *URL; +@property (strong) NSNumber *Timeout; + +@end diff --git a/SmartDeviceLink/SDLOnEncodedSyncPData.m b/SmartDeviceLink/SDLOnEncodedSyncPData.m new file mode 100644 index 000000000..f4aca251a --- /dev/null +++ b/SmartDeviceLink/SDLOnEncodedSyncPData.m @@ -0,0 +1,59 @@ +// SDLOnEncodedSyncPData.m +// + +#import "SDLOnEncodedSyncPData.h" + +#import "SDLNames.h" + + +@implementation SDLOnEncodedSyncPData + +- (instancetype)init { + if (self = [super initWithName:NAMES_OnEncodedSyncPData]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setData:(NSMutableArray *)data { + if (data != nil) { + [parameters setObject:data forKey:NAMES_data]; + } else { + [parameters removeObjectForKey:NAMES_data]; + } +} + +- (NSMutableArray *)data { + return [parameters objectForKey:NAMES_data]; +} + +- (void)setURL:(NSString *)URL { + if (URL != nil) { + [parameters setObject:URL forKey:NAMES_URL]; + } else { + [parameters removeObjectForKey:NAMES_URL]; + } +} + +- (NSString *)URL { + return [parameters objectForKey:NAMES_URL]; +} + +- (void)setTimeout:(NSNumber *)Timeout { + if (Timeout != nil) { + [parameters setObject:Timeout forKey:NAMES_Timeout]; + } else { + [parameters removeObjectForKey:NAMES_Timeout]; + } +} + +- (NSNumber *)Timeout { + return [parameters objectForKey:NAMES_Timeout]; +} + +@end diff --git a/SmartDeviceLink/SDLOnHMIStatus.h b/SmartDeviceLink/SDLOnHMIStatus.h new file mode 100644 index 000000000..c417070d5 --- /dev/null +++ b/SmartDeviceLink/SDLOnHMIStatus.h @@ -0,0 +1,58 @@ +// SDLOnHMIStatus.h +// + +#import "SDLRPCNotification.h" + +@class SDLAudioStreamingState; +@class SDLHMILevel; +@class SDLSystemContext; + + +/** + * Notifies an application that HMI conditions have changed for the application. This indicates whether the application + * can speak phrases, display text, perform interactions, receive button presses and events, stream audio, etc. This + * notification will be sent to the application when there has been a change in any one or several of the indicated + * states (<i>SDLHMILevel</i>, <i>SDLAudioStreamingState</i> or <i>SDLSystemContext</i>) for the application. + * + * All three values are, in principle, independent of each other (though there may be some relationships). A value for + * one parameter should not be interpreted from the value of another parameter. + * + * There are no guarantees about the timeliness or latency of the SDLOnHMIStatus notification. Therefore, for example, + * information such as <i>SDLAudioStreamingState</i> may not indicate that the audio stream became inaudible to the user + * exactly when the SDLOnHMIStatus notification was received. + * + * @since SDL 1.0 + */ +@interface SDLOnHMIStatus : SDLRPCNotification { +} + +/** + *Constructs a newly allocated SDLOnHMIStatus object + */ +- (instancetype)init; + +/** + *<p>Constructs a newly allocated SDLOnHMIStatus object indicated by the dictionary parameter</p> + *@param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract SDLHMILevel in effect for the application + */ +@property (strong) SDLHMILevel *hmiLevel; + +/** + * @abstract Current state of audio streaming for the application. When this parameter has a value of NOT_AUDIBLE, the application must stop streaming audio to SDL. + * + * Informs app whether any currently streaming audio is audible to user (AUDIBLE) or not (NOT_AUDIBLE). A value of NOT_AUDIBLE means that either the application's audio will not be audible to the user, or that the application's audio should not be audible to the user (i.e. some other application on the mobile device may be streaming audio and the application's audio would be blended with that other audio). + */ +@property (strong) SDLAudioStreamingState *audioStreamingState; + +/** + * @abstract the System Context + * @discussion whether a user-initiated interaction is in-progress (VRSESSION or MENU), or not (MAIN) + */ +@property (strong) SDLSystemContext *systemContext; + +@end diff --git a/SmartDeviceLink/SDLOnHMIStatus.m b/SmartDeviceLink/SDLOnHMIStatus.m new file mode 100644 index 000000000..e3dc0d7fc --- /dev/null +++ b/SmartDeviceLink/SDLOnHMIStatus.m @@ -0,0 +1,77 @@ +// SDLOnHMIStatus.m +// + +#import "SDLOnHMIStatus.h" + +#import "SDLAudioStreamingState.h" +#import "SDLHMILevel.h" +#import "SDLNames.h" +#import "SDLSystemContext.h" + + +@implementation SDLOnHMIStatus + +- (instancetype)init { + if (self = [super initWithName:NAMES_OnHMIStatus]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setHmiLevel:(SDLHMILevel *)hmiLevel { + if (hmiLevel != nil) { + [parameters setObject:hmiLevel forKey:NAMES_hmiLevel]; + } else { + [parameters removeObjectForKey:NAMES_hmiLevel]; + } +} + +- (SDLHMILevel *)hmiLevel { + NSObject *obj = [parameters objectForKey:NAMES_hmiLevel]; + if (obj == nil || [obj isKindOfClass:SDLHMILevel.class]) { + return (SDLHMILevel *)obj; + } else { + return [SDLHMILevel valueOf:(NSString *)obj]; + } +} + +- (void)setAudioStreamingState:(SDLAudioStreamingState *)audioStreamingState { + if (audioStreamingState != nil) { + [parameters setObject:audioStreamingState forKey:NAMES_audioStreamingState]; + } else { + [parameters removeObjectForKey:NAMES_audioStreamingState]; + } +} + +- (SDLAudioStreamingState *)audioStreamingState { + NSObject *obj = [parameters objectForKey:NAMES_audioStreamingState]; + if (obj == nil || [obj isKindOfClass:SDLAudioStreamingState.class]) { + return (SDLAudioStreamingState *)obj; + } else { + return [SDLAudioStreamingState valueOf:(NSString *)obj]; + } +} + +- (void)setSystemContext:(SDLSystemContext *)systemContext { + if (systemContext != nil) { + [parameters setObject:systemContext forKey:NAMES_systemContext]; + } else { + [parameters removeObjectForKey:NAMES_systemContext]; + } +} + +- (SDLSystemContext *)systemContext { + NSObject *obj = [parameters objectForKey:NAMES_systemContext]; + if (obj == nil || [obj isKindOfClass:SDLSystemContext.class]) { + return (SDLSystemContext *)obj; + } else { + return [SDLSystemContext valueOf:(NSString *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLOnHashChange.h b/SmartDeviceLink/SDLOnHashChange.h new file mode 100644 index 000000000..4facf1f15 --- /dev/null +++ b/SmartDeviceLink/SDLOnHashChange.h @@ -0,0 +1,15 @@ +// SDLOnHashChange.h +// + + +#import "SDLRPCNotification.h" + +@interface SDLOnHashChange : SDLRPCNotification { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) NSString *hashID; + +@end diff --git a/SmartDeviceLink/SDLOnHashChange.m b/SmartDeviceLink/SDLOnHashChange.m new file mode 100644 index 000000000..b1bfd8c6a --- /dev/null +++ b/SmartDeviceLink/SDLOnHashChange.m @@ -0,0 +1,35 @@ +// SDLOnHashChange.m +// + + +#import "SDLOnHashChange.h" + +#import "SDLNames.h" + +@implementation SDLOnHashChange + +- (instancetype)init { + if (self = [super initWithName:NAMES_OnHashChange]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setHashID:(NSString *)hashID { + if (hashID != nil) { + [parameters setObject:hashID forKey:NAMES_hashID]; + } else { + [parameters removeObjectForKey:NAMES_hashID]; + } +} + +- (NSString *)hashID { + return [parameters objectForKey:NAMES_hashID]; +} + +@end diff --git a/SmartDeviceLink/SDLOnKeyboardInput.h b/SmartDeviceLink/SDLOnKeyboardInput.h new file mode 100644 index 000000000..e976d6c88 --- /dev/null +++ b/SmartDeviceLink/SDLOnKeyboardInput.h @@ -0,0 +1,18 @@ +// SDLOnKeyboardInput.h +// + +#import "SDLRPCNotification.h" + +@class SDLKeyboardEvent; + + +@interface SDLOnKeyboardInput : SDLRPCNotification { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) SDLKeyboardEvent *event; +@property (strong) NSString *data; + +@end diff --git a/SmartDeviceLink/SDLOnKeyboardInput.m b/SmartDeviceLink/SDLOnKeyboardInput.m new file mode 100644 index 000000000..a70a7d06c --- /dev/null +++ b/SmartDeviceLink/SDLOnKeyboardInput.m @@ -0,0 +1,53 @@ +// SDLOnKeyboardInput.m +// + +#import "SDLOnKeyboardInput.h" + +#import "SDLKeyboardEvent.h" +#import "SDLNames.h" + + +@implementation SDLOnKeyboardInput + +- (instancetype)init { + if (self = [super initWithName:NAMES_OnKeyboardInput]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setEvent:(SDLKeyboardEvent *)event { + if (event != nil) { + [parameters setObject:event forKey:NAMES_event]; + } else { + [parameters removeObjectForKey:NAMES_event]; + } +} + +- (SDLKeyboardEvent *)event { + NSObject *obj = [parameters objectForKey:NAMES_event]; + if (obj == nil || [obj isKindOfClass:SDLKeyboardEvent.class]) { + return (SDLKeyboardEvent *)obj; + } else { + return [SDLKeyboardEvent valueOf:(NSString *)obj]; + } +} + +- (void)setData:(NSString *)data { + if (data != nil) { + [parameters setObject:data forKey:NAMES_data]; + } else { + [parameters removeObjectForKey:NAMES_data]; + } +} + +- (NSString *)data { + return [parameters objectForKey:NAMES_data]; +} + +@end diff --git a/SmartDeviceLink/SDLOnLanguageChange.h b/SmartDeviceLink/SDLOnLanguageChange.h new file mode 100644 index 000000000..b794edcd1 --- /dev/null +++ b/SmartDeviceLink/SDLOnLanguageChange.h @@ -0,0 +1,38 @@ +// SDLOnLanguageChange.h +// + +#import "SDLRPCNotification.h" + +@class SDLLanguage; + + +/** + * Provides information to what language the SDL HMI language was changed + * + * @since SDL 2.0 + */ +@interface SDLOnLanguageChange : SDLRPCNotification { +} + +/** + *Constructs a newly allocated SDLOnLanguageChange object + */ +- (instancetype)init; + +/** + * Constructs a newly allocated SDLOnLanguageChange object indicated by the dictionary parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract Current SDL voice engine (VR+TTS) language + */ +@property (strong) SDLLanguage *language; + +/** + * @abstract Current display language + */ +@property (strong) SDLLanguage *hmiDisplayLanguage; + +@end diff --git a/SmartDeviceLink/SDLOnLanguageChange.m b/SmartDeviceLink/SDLOnLanguageChange.m new file mode 100644 index 000000000..216d0c4a5 --- /dev/null +++ b/SmartDeviceLink/SDLOnLanguageChange.m @@ -0,0 +1,58 @@ +// SDLOnLanguageChange.m +// + +#import "SDLOnLanguageChange.h" + +#import "SDLLanguage.h" +#import "SDLNames.h" + + +@implementation SDLOnLanguageChange + +- (instancetype)init { + if (self = [super initWithName:NAMES_OnLanguageChange]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setLanguage:(SDLLanguage *)language { + if (language != nil) { + [parameters setObject:language forKey:NAMES_language]; + } else { + [parameters removeObjectForKey:NAMES_language]; + } +} + +- (SDLLanguage *)language { + NSObject *obj = [parameters objectForKey:NAMES_language]; + if (obj == nil || [obj isKindOfClass:SDLLanguage.class]) { + return (SDLLanguage *)obj; + } else { + return [SDLLanguage valueOf:(NSString *)obj]; + } +} + +- (void)setHmiDisplayLanguage:(SDLLanguage *)hmiDisplayLanguage { + if (hmiDisplayLanguage != nil) { + [parameters setObject:hmiDisplayLanguage forKey:NAMES_hmiDisplayLanguage]; + } else { + [parameters removeObjectForKey:NAMES_hmiDisplayLanguage]; + } +} + +- (SDLLanguage *)hmiDisplayLanguage { + NSObject *obj = [parameters objectForKey:NAMES_hmiDisplayLanguage]; + if (obj == nil || [obj isKindOfClass:SDLLanguage.class]) { + return (SDLLanguage *)obj; + } else { + return [SDLLanguage valueOf:(NSString *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLOnLockScreenStatus.h b/SmartDeviceLink/SDLOnLockScreenStatus.h new file mode 100644 index 000000000..3a4a31452 --- /dev/null +++ b/SmartDeviceLink/SDLOnLockScreenStatus.h @@ -0,0 +1,47 @@ +// +// SDLOnLockScreenStatus.h +// SmartDeviceLink +// + +#import "SDLRPCNotification.h" + +@class SDLHMILevel; +@class SDLLockScreenStatus; + + +/** + * To help prevent driver distraction, any SmartDeviceLink application is required to implement a lockscreen that must be enforced while the application is active on the system while the vehicle is in motion. + * + * This lockscreen must perform the following: + * Limit all application control usability from the mobile device with a full-screen static image overlay or separate view. + * For simplicity, the OnLockScreenStatus RPC will be provided via the onOnLockScreenNotification call back. The call back will include the LockScreenStatus enum which indicates if the lockscreen is required, optional or not required. + * The call back also includes details regarding the current HMI_Status level, driver distraction status and user selection status of the application. + */ +@interface SDLOnLockScreenStatus : SDLRPCNotification + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * <p>Get the current driver distraction status(i.e. whether driver distraction rules are in effect, or not)</p> + * @return String + */ +@property (strong) NSNumber *driverDistractionStatus; +/** + * <p>Get user selection status for the application (has the app been selected via hmi or voice command)</p> + * @return Boolean the current user selection status + */ + +@property (strong) NSNumber *userSelected; +/** + * <p>Get the {@linkplain LockScreenStatus} enumeration, indicating if the lockscreen should be required, optional or off </p> + * @return {@linkplain LockScreenStatus} + */ +@property (strong) SDLLockScreenStatus *lockScreenStatus; +/** + * <p>Get HMILevel in effect for the application</p> + * @return {@linkplain HMILevel} the current HMI Level in effect for the application + */ +@property (strong) SDLHMILevel *hmiLevel; + +@end diff --git a/SmartDeviceLink/SDLOnLockScreenStatus.m b/SmartDeviceLink/SDLOnLockScreenStatus.m new file mode 100644 index 000000000..fc9e39c00 --- /dev/null +++ b/SmartDeviceLink/SDLOnLockScreenStatus.m @@ -0,0 +1,84 @@ +// +// SDLOnLockScreenStatus.m +// SmartDeviceLink +// + +#import "SDLOnLockScreenStatus.h" + +#import "SDLHMILevel.h" +#import "SDLLockScreenStatus.h" + + +@implementation SDLOnLockScreenStatus + +- (instancetype)init { + if (self = [super initWithName:@"OnLockScreenStatus"]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setLockScreenStatus:(SDLLockScreenStatus *)lockScreenStatus { + if (lockScreenStatus != nil) { + [parameters setObject:lockScreenStatus forKey:@"OnLockScreenStatus"]; + } else { + [parameters removeObjectForKey:@"OnLockScreenStatus"]; + } +} + +- (SDLLockScreenStatus *)lockScreenStatus { + NSObject *obj = [parameters objectForKey:@"OnLockScreenStatus"]; + if (obj == nil || [obj isKindOfClass:SDLLockScreenStatus.class]) { + return (SDLLockScreenStatus *)obj; + } else { + return [SDLLockScreenStatus valueOf:(NSString *)obj]; + } +} + +- (void)setHmiLevel:(SDLHMILevel *)hmiLevel { + if (hmiLevel != nil) { + [parameters setObject:hmiLevel forKey:@"hmilevel"]; + } else { + [parameters removeObjectForKey:@"hmilevel"]; + } +} + +- (SDLHMILevel *)hmiLevel { + NSObject *obj = [parameters objectForKey:@"hmilevel"]; + if (obj == nil || [obj isKindOfClass:SDLHMILevel.class]) { + return (SDLHMILevel *)obj; + } else { + return [SDLHMILevel valueOf:(NSString *)obj]; + } +} + +- (void)setUserSelected:(NSNumber *)userSelected { + if (userSelected != nil) { + [parameters setObject:userSelected forKey:@"userselected"]; + } else { + [parameters removeObjectForKey:@"userselected"]; + } +} + +- (NSNumber *)userSelected { + return [parameters objectForKey:@"userselected"]; +} + +- (void)setDriverDistractionStatus:(NSNumber *)driverDistractionStatus { + if (driverDistractionStatus != nil) { + [parameters setObject:driverDistractionStatus forKey:@"driverdistractionstatus"]; + } else { + [parameters removeObjectForKey:@"driverdistractionstatus"]; + } +} + +- (NSNumber *)driverDistractionStatus { + return [parameters objectForKey:@"driverdistractionstatus"]; +} + +@end diff --git a/SmartDeviceLink/SDLOnPermissionsChange.h b/SmartDeviceLink/SDLOnPermissionsChange.h new file mode 100644 index 000000000..267a63a10 --- /dev/null +++ b/SmartDeviceLink/SDLOnPermissionsChange.h @@ -0,0 +1,35 @@ +// SDLOnPermissionsChange.h +// + +#import "SDLRPCNotification.h" + + +/** + * Provides update to app of which sets of functions are available + * + * @since SDL 2.0 + */ +@interface SDLOnPermissionsChange : SDLRPCNotification { +} + +/** + * Constructs a newly allocated SDLOnPermissionsChange object + */ +- (instancetype)init; + +/** + * Constructs a newly allocated SDLOnPermissionsChange object indicated by the dictionary parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract Describes change in permissions for a given set of RPCs + * + * Required, Array of SDLPermissionItem, Array size 0 - 500 + * + * @see SDLPermissionItem + */ +@property (strong) NSMutableArray *permissionItem; + +@end diff --git a/SmartDeviceLink/SDLOnPermissionsChange.m b/SmartDeviceLink/SDLOnPermissionsChange.m new file mode 100644 index 000000000..e80df88c4 --- /dev/null +++ b/SmartDeviceLink/SDLOnPermissionsChange.m @@ -0,0 +1,45 @@ +// SDLOnPermissionsChange.m +// + +#import "SDLOnPermissionsChange.h" + +#import "SDLNames.h" +#import "SDLPermissionItem.h" + + +@implementation SDLOnPermissionsChange + +- (instancetype)init { + if (self = [super initWithName:NAMES_OnPermissionsChange]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setPermissionItem:(NSMutableArray *)permissionItem { + if (permissionItem != nil) { + [parameters setObject:permissionItem forKey:NAMES_permissionItem]; + } else { + [parameters removeObjectForKey:NAMES_permissionItem]; + } +} + +- (NSMutableArray *)permissionItem { + NSMutableArray *array = [parameters objectForKey:NAMES_permissionItem]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLPermissionItem.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLPermissionItem alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +@end diff --git a/SmartDeviceLink/SDLOnSyncPData.h b/SmartDeviceLink/SDLOnSyncPData.h new file mode 100644 index 000000000..8729a881a --- /dev/null +++ b/SmartDeviceLink/SDLOnSyncPData.h @@ -0,0 +1,16 @@ +// SDLOnSyncPData.h +// + + +#import "SDLRPCNotification.h" + +@interface SDLOnSyncPData : SDLRPCNotification { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) NSString *URL; +@property (strong) NSNumber *Timeout; + +@end diff --git a/SmartDeviceLink/SDLOnSyncPData.m b/SmartDeviceLink/SDLOnSyncPData.m new file mode 100644 index 000000000..11fe8a3ac --- /dev/null +++ b/SmartDeviceLink/SDLOnSyncPData.m @@ -0,0 +1,47 @@ +// SDLOnSyncPData.m +// + + +#import "SDLOnSyncPData.h" + +#import "SDLNames.h" + +@implementation SDLOnSyncPData + +- (instancetype)init { + if (self = [super initWithName:NAMES_OnSyncPData]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setURL:(NSString *)URL { + if (URL != nil) { + [parameters setObject:URL forKey:NAMES_URL]; + } else { + [parameters removeObjectForKey:NAMES_URL]; + } +} + +- (NSString *)URL { + return [parameters objectForKey:NAMES_URL]; +} + +- (void)setTimeout:(NSNumber *)Timeout { + if (Timeout != nil) { + [parameters setObject:Timeout forKey:NAMES_Timeout]; + } else { + [parameters removeObjectForKey:NAMES_Timeout]; + } +} + +- (NSNumber *)Timeout { + return [parameters objectForKey:NAMES_Timeout]; +} + +@end diff --git a/SmartDeviceLink/SDLOnSystemRequest.h b/SmartDeviceLink/SDLOnSystemRequest.h new file mode 100644 index 000000000..b590f0650 --- /dev/null +++ b/SmartDeviceLink/SDLOnSystemRequest.h @@ -0,0 +1,23 @@ +// SDLOnSystemRequest.h +// + +#import "SDLRPCNotification.h" + +@class SDLFileType; +@class SDLRequestType; + + +@interface SDLOnSystemRequest : SDLRPCNotification { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) SDLRequestType *requestType; +@property (strong) NSString *url; +@property (strong) NSNumber *timeout; +@property (strong) SDLFileType *fileType; +@property (strong) NSNumber *offset; +@property (strong) NSNumber *length; + +@end diff --git a/SmartDeviceLink/SDLOnSystemRequest.m b/SmartDeviceLink/SDLOnSystemRequest.m new file mode 100644 index 000000000..c5aff7569 --- /dev/null +++ b/SmartDeviceLink/SDLOnSystemRequest.m @@ -0,0 +1,107 @@ +// SDLOnSystemRequest.m +// + +#import "SDLOnSystemRequest.h" + +#import "SDLFileType.h" +#import "SDLNames.h" +#import "SDLRequestType.h" + + +@implementation SDLOnSystemRequest + +- (instancetype)init { + if (self = [super initWithName:NAMES_OnSystemRequest]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setRequestType:(SDLRequestType *)requestType { + if (requestType != nil) { + [parameters setObject:requestType forKey:NAMES_requestType]; + } else { + [parameters removeObjectForKey:NAMES_requestType]; + } +} + +- (SDLRequestType *)requestType { + NSObject *obj = [parameters objectForKey:NAMES_requestType]; + if (obj == nil || [obj isKindOfClass:SDLRequestType.class]) { + return (SDLRequestType *)obj; + } else { + return [SDLRequestType valueOf:(NSString *)obj]; + } +} + +- (void)setUrl:(NSString *)url { + if (url != nil) { + [parameters setObject:url forKey:NAMES_url]; + } else { + [parameters removeObjectForKey:NAMES_url]; + } +} + +- (NSString *)url { + return [parameters objectForKey:NAMES_url]; +} + +- (void)setTimeout:(NSNumber *)timeout { + if (timeout != nil) { + [parameters setObject:timeout forKey:NAMES_timeout]; + } else { + [parameters removeObjectForKey:NAMES_timeout]; + } +} + +- (NSNumber *)timeout { + return [parameters objectForKey:NAMES_timeout]; +} + +- (void)setFileType:(SDLFileType *)fileType { + if (fileType != nil) { + [parameters setObject:fileType forKey:NAMES_fileType]; + } else { + [parameters removeObjectForKey:NAMES_fileType]; + } +} + +- (SDLFileType *)fileType { + NSObject *obj = [parameters objectForKey:NAMES_fileType]; + if (obj == nil || [obj isKindOfClass:SDLFileType.class]) { + return (SDLFileType *)obj; + } else { + return [SDLFileType valueOf:(NSString *)obj]; + } +} + +- (void)setOffset:(NSNumber *)offset { + if (offset != nil) { + [parameters setObject:offset forKey:NAMES_offset]; + } else { + [parameters removeObjectForKey:NAMES_offset]; + } +} + +- (NSNumber *)offset { + return [parameters objectForKey:NAMES_offset]; +} + +- (void)setLength:(NSNumber *)length { + if (length != nil) { + [parameters setObject:length forKey:NAMES_length]; + } else { + [parameters removeObjectForKey:NAMES_length]; + } +} + +- (NSNumber *)length { + return [parameters objectForKey:NAMES_length]; +} + +@end diff --git a/SmartDeviceLink/SDLOnTBTClientState.h b/SmartDeviceLink/SDLOnTBTClientState.h new file mode 100644 index 000000000..8dec001ca --- /dev/null +++ b/SmartDeviceLink/SDLOnTBTClientState.h @@ -0,0 +1,17 @@ +// SDLOnTBTClientState.h +// + +#import "SDLRPCNotification.h" + +@class SDLTBTState; + + +@interface SDLOnTBTClientState : SDLRPCNotification { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) SDLTBTState *state; + +@end diff --git a/SmartDeviceLink/SDLOnTBTClientState.m b/SmartDeviceLink/SDLOnTBTClientState.m new file mode 100644 index 000000000..ee0dc1efc --- /dev/null +++ b/SmartDeviceLink/SDLOnTBTClientState.m @@ -0,0 +1,41 @@ +// SDLOnTBTClientState.m +// + +#import "SDLOnTBTClientState.h" + +#import "SDLNames.h" +#import "SDLTBTState.h" + + +@implementation SDLOnTBTClientState + +- (instancetype)init { + if (self = [super initWithName:NAMES_OnTBTClientState]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setState:(SDLTBTState *)state { + if (state != nil) { + [parameters setObject:state forKey:NAMES_state]; + } else { + [parameters removeObjectForKey:NAMES_state]; + } +} + +- (SDLTBTState *)state { + NSObject *obj = [parameters objectForKey:NAMES_state]; + if (obj == nil || [obj isKindOfClass:SDLTBTState.class]) { + return (SDLTBTState *)obj; + } else { + return [SDLTBTState valueOf:(NSString *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLOnTouchEvent.h b/SmartDeviceLink/SDLOnTouchEvent.h new file mode 100644 index 000000000..68f1fa707 --- /dev/null +++ b/SmartDeviceLink/SDLOnTouchEvent.h @@ -0,0 +1,18 @@ +// SDLOnTouchEvent.h +// + +#import "SDLRPCNotification.h" + +@class SDLTouchType; + + +@interface SDLOnTouchEvent : SDLRPCNotification { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) SDLTouchType *type; +@property (strong) NSMutableArray *event; + +@end diff --git a/SmartDeviceLink/SDLOnTouchEvent.m b/SmartDeviceLink/SDLOnTouchEvent.m new file mode 100644 index 000000000..e73c79603 --- /dev/null +++ b/SmartDeviceLink/SDLOnTouchEvent.m @@ -0,0 +1,63 @@ +// SDLOnTouchEvent.m +// + +#import "SDLOnTouchEvent.h" + +#import "SDLNames.h" +#import "SDLTouchEvent.h" +#import "SDLTouchType.h" + + +@implementation SDLOnTouchEvent + +- (instancetype)init { + if (self = [super initWithName:NAMES_OnTouchEvent]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setType:(SDLTouchType *)type { + if (type != nil) { + [parameters setObject:type forKey:NAMES_type]; + } else { + [parameters removeObjectForKey:NAMES_type]; + } +} + +- (SDLTouchType *)type { + NSObject *obj = [parameters objectForKey:NAMES_type]; + if (obj == nil || [obj isKindOfClass:SDLTouchType.class]) { + return (SDLTouchType *)obj; + } else { + return [SDLTouchType valueOf:(NSString *)obj]; + } +} + +- (void)setEvent:(NSMutableArray *)event { + if (event != nil) { + [parameters setObject:event forKey:NAMES_event]; + } else { + [parameters removeObjectForKey:NAMES_event]; + } +} + +- (NSMutableArray *)event { + NSMutableArray *array = [parameters objectForKey:NAMES_event]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLTouchEvent.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLTouchEvent alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +@end diff --git a/SmartDeviceLink/SDLOnVehicleData.h b/SmartDeviceLink/SDLOnVehicleData.h new file mode 100644 index 000000000..245477e3b --- /dev/null +++ b/SmartDeviceLink/SDLOnVehicleData.h @@ -0,0 +1,150 @@ +// SDLOnVehicleData.h +// + +#import "SDLRPCNotification.h" + +@class SDLAirbagStatus; +@class SDLBeltStatus; +@class SDLBodyInformation; +@class SDLClusterModeStatus; +@class SDLComponentVolumeStatus; +@class SDLDeviceStatus; +@class SDLECallInfo; +@class SDLEmergencyEvent; +@class SDLGPSData; +@class SDLHeadLampStatus; +@class SDLMyKey; +@class SDLPRNDL; +@class SDLTireStatus; +@class SDLVehicleDataEventStatus; +@class SDLWiperStatus; + + +/** + * Request vehicle data. + * + * Since SmartDeviceLink 2.0 + */ +@interface SDLOnVehicleData : SDLRPCNotification { +} + + +/** + * @abstract Constructs a new SDLOnVehicleData object + */ +- (instancetype)init; + +/** + * @abstract Constructs a new SDLOnVehicleData object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract A SDLGPSData* value. See GPSData. + */ +@property (strong) SDLGPSData *gps; + +/** + * @abstract The vehicle speed in kilometers per hour. + */ +@property (strong) NSNumber *speed; + +/** + * @abstract The number of revolutions per minute of the engine. + */ +@property (strong) NSNumber *rpm; + +/** + * @abstract The fuel level in the tank (percentage) + */ +@property (strong) NSNumber *fuelLevel; + +/** + * @abstract A SDLComponentVolumeStatus* value. The fuel level state. + */ +@property (strong) SDLComponentVolumeStatus *fuelLevel_State; + +/** + * @abstract The instantaneous fuel consumption in microlitres. + */ +@property (strong) NSNumber *instantFuelConsumption; + +/** + * @abstract The external temperature in degrees celsius. + */ +@property (strong) NSNumber *externalTemperature; + +/** + * @abstract The Vehicle Identification Number + */ +@property (strong) NSString *vin; + +/** + * @abstract See PRNDL. + */ +@property (strong) SDLPRNDL *prndl; + +/** + * @abstract A SDLTireStatus* value. See TireStatus. + */ +@property (strong) SDLTireStatus *tirePressure; + +/** + * @abstract Odometer reading in km. + */ +@property (strong) NSNumber *odometer; + +/** + * @abstract A SDLBeltStatus* value. The status of the seat belts. + */ +@property (strong) SDLBeltStatus *beltStatus; + +/** + * @abstract A SDLBodyInformation* value. The body information including power modes. + */ +@property (strong) SDLBodyInformation *bodyInformation; + +/** + * @abstract A SDLDeviceStatus* value. The device status including signal and battery strength. + */ +@property (strong) SDLDeviceStatus *deviceStatus; + +/** + * @abstract A SDLVehicleDataResult* value. The status of the brake pedal. + */ +@property (strong) SDLVehicleDataEventStatus *driverBraking; + +/** + * @abstract A SDLWiperStatus* value. The status of the wipers. + */ +@property (strong) SDLWiperStatus *wiperStatus; + +/** + * @abstract A SDLHeadLampStatus* value. Status of the head lamps. + */ +@property (strong) SDLHeadLampStatus *headLampStatus; + +/** + * @abstract Torque value for engine (in Nm) on non-diesel variants. + */ +@property (strong) NSNumber *engineTorque; + +/** + * @abstract Accelerator pedal position (percentage depressed) + */ +@property (strong) NSNumber *accPedalPosition; + +/** + * @abstract Current angle of the steering wheel (in deg) + */ +@property (strong) NSNumber *steeringWheelAngle; +@property (strong) SDLECallInfo *eCallInfo; +@property (strong) SDLAirbagStatus *airbagStatus; +@property (strong) SDLEmergencyEvent *emergencyEvent; +@property (strong) SDLClusterModeStatus *clusterModeStatus; +@property (strong) SDLMyKey *myKey; + + +@end diff --git a/SmartDeviceLink/SDLOnVehicleData.m b/SmartDeviceLink/SDLOnVehicleData.m new file mode 100644 index 000000000..3386ca450 --- /dev/null +++ b/SmartDeviceLink/SDLOnVehicleData.m @@ -0,0 +1,413 @@ +// SDLOnVehicleData.m +// + +#import "SDLOnVehicleData.h" + +#import "SDLAirbagStatus.h" +#import "SDLBeltStatus.h" +#import "SDLBodyInformation.h" +#import "SDLClusterModeStatus.h" +#import "SDLComponentVolumeStatus.h" +#import "SDLDeviceStatus.h" +#import "SDLECallInfo.h" +#import "SDLEmergencyEvent.h" +#import "SDLGPSData.h" +#import "SDLHeadLampStatus.h" +#import "SDLMyKey.h" +#import "SDLNames.h" +#import "SDLPRNDL.h" +#import "SDLTireStatus.h" +#import "SDLVehicleDataEventStatus.h" +#import "SDLWiperStatus.h" + + +@implementation SDLOnVehicleData + +- (instancetype)init { + if (self = [super initWithName:NAMES_OnVehicleData]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setGps:(SDLGPSData *)gps { + if (gps != nil) { + [parameters setObject:gps forKey:NAMES_gps]; + } else { + [parameters removeObjectForKey:NAMES_gps]; + } +} + +- (SDLGPSData *)gps { + NSObject *obj = [parameters objectForKey:NAMES_gps]; + if (obj == nil || [obj isKindOfClass:SDLGPSData.class]) { + return (SDLGPSData *)obj; + } else { + return [[SDLGPSData alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setSpeed:(NSNumber *)speed { + if (speed != nil) { + [parameters setObject:speed forKey:NAMES_speed]; + } else { + [parameters removeObjectForKey:NAMES_speed]; + } +} + +- (NSNumber *)speed { + return [parameters objectForKey:NAMES_speed]; +} + +- (void)setRpm:(NSNumber *)rpm { + if (rpm != nil) { + [parameters setObject:rpm forKey:NAMES_rpm]; + } else { + [parameters removeObjectForKey:NAMES_rpm]; + } +} + +- (NSNumber *)rpm { + return [parameters objectForKey:NAMES_rpm]; +} + +- (void)setFuelLevel:(NSNumber *)fuelLevel { + if (fuelLevel != nil) { + [parameters setObject:fuelLevel forKey:NAMES_fuelLevel]; + } else { + [parameters removeObjectForKey:NAMES_fuelLevel]; + } +} + +- (NSNumber *)fuelLevel { + return [parameters objectForKey:NAMES_fuelLevel]; +} + +- (void)setFuelLevel_State:(SDLComponentVolumeStatus *)fuelLevel_State { + if (fuelLevel_State != nil) { + [parameters setObject:fuelLevel_State forKey:NAMES_fuelLevel_State]; + } else { + [parameters removeObjectForKey:NAMES_fuelLevel_State]; + } +} + +- (SDLComponentVolumeStatus *)fuelLevel_State { + NSObject *obj = [parameters objectForKey:NAMES_fuelLevel_State]; + if (obj == nil || [obj isKindOfClass:SDLComponentVolumeStatus.class]) { + return (SDLComponentVolumeStatus *)obj; + } else { + return [SDLComponentVolumeStatus valueOf:(NSString *)obj]; + } +} + +- (void)setInstantFuelConsumption:(NSNumber *)instantFuelConsumption { + if (instantFuelConsumption != nil) { + [parameters setObject:instantFuelConsumption forKey:NAMES_instantFuelConsumption]; + } else { + [parameters removeObjectForKey:NAMES_instantFuelConsumption]; + } +} + +- (NSNumber *)instantFuelConsumption { + return [parameters objectForKey:NAMES_instantFuelConsumption]; +} + +- (void)setExternalTemperature:(NSNumber *)externalTemperature { + if (externalTemperature != nil) { + [parameters setObject:externalTemperature forKey:NAMES_externalTemperature]; + } else { + [parameters removeObjectForKey:NAMES_externalTemperature]; + } +} + +- (NSNumber *)externalTemperature { + return [parameters objectForKey:NAMES_externalTemperature]; +} + +- (void)setVin:(NSString *)vin { + if (vin != nil) { + [parameters setObject:vin forKey:NAMES_vin]; + } else { + [parameters removeObjectForKey:NAMES_vin]; + } +} + +- (NSString *)vin { + return [parameters objectForKey:NAMES_vin]; +} + +- (void)setPrndl:(SDLPRNDL *)prndl { + if (prndl != nil) { + [parameters setObject:prndl forKey:NAMES_prndl]; + } else { + [parameters removeObjectForKey:NAMES_prndl]; + } +} + +- (SDLPRNDL *)prndl { + NSObject *obj = [parameters objectForKey:NAMES_prndl]; + if (obj == nil || [obj isKindOfClass:SDLPRNDL.class]) { + return (SDLPRNDL *)obj; + } else { + return [SDLPRNDL valueOf:(NSString *)obj]; + } +} + +- (void)setTirePressure:(SDLTireStatus *)tirePressure { + if (tirePressure != nil) { + [parameters setObject:tirePressure forKey:NAMES_tirePressure]; + } else { + [parameters removeObjectForKey:NAMES_tirePressure]; + } +} + +- (SDLTireStatus *)tirePressure { + NSObject *obj = [parameters objectForKey:NAMES_tirePressure]; + if (obj == nil || [obj isKindOfClass:SDLTireStatus.class]) { + return (SDLTireStatus *)obj; + } else { + return [[SDLTireStatus alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setOdometer:(NSNumber *)odometer { + if (odometer != nil) { + [parameters setObject:odometer forKey:NAMES_odometer]; + } else { + [parameters removeObjectForKey:NAMES_odometer]; + } +} + +- (NSNumber *)odometer { + return [parameters objectForKey:NAMES_odometer]; +} + +- (void)setBeltStatus:(SDLBeltStatus *)beltStatus { + if (beltStatus != nil) { + [parameters setObject:beltStatus forKey:NAMES_beltStatus]; + } else { + [parameters removeObjectForKey:NAMES_beltStatus]; + } +} + +- (SDLBeltStatus *)beltStatus { + NSObject *obj = [parameters objectForKey:NAMES_beltStatus]; + if (obj == nil || [obj isKindOfClass:SDLBeltStatus.class]) { + return (SDLBeltStatus *)obj; + } else { + return [[SDLBeltStatus alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setBodyInformation:(SDLBodyInformation *)bodyInformation { + if (bodyInformation != nil) { + [parameters setObject:bodyInformation forKey:NAMES_bodyInformation]; + } else { + [parameters removeObjectForKey:NAMES_bodyInformation]; + } +} + +- (SDLBodyInformation *)bodyInformation { + NSObject *obj = [parameters objectForKey:NAMES_bodyInformation]; + if (obj == nil || [obj isKindOfClass:SDLBodyInformation.class]) { + return (SDLBodyInformation *)obj; + } else { + return [[SDLBodyInformation alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setDeviceStatus:(SDLDeviceStatus *)deviceStatus { + if (deviceStatus != nil) { + [parameters setObject:deviceStatus forKey:NAMES_deviceStatus]; + } else { + [parameters removeObjectForKey:NAMES_deviceStatus]; + } +} + +- (SDLDeviceStatus *)deviceStatus { + NSObject *obj = [parameters objectForKey:NAMES_deviceStatus]; + if (obj == nil || [obj isKindOfClass:SDLDeviceStatus.class]) { + return (SDLDeviceStatus *)obj; + } else { + return [[SDLDeviceStatus alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setDriverBraking:(SDLVehicleDataEventStatus *)driverBraking { + if (driverBraking != nil) { + [parameters setObject:driverBraking forKey:NAMES_driverBraking]; + } else { + [parameters removeObjectForKey:NAMES_driverBraking]; + } +} + +- (SDLVehicleDataEventStatus *)driverBraking { + NSObject *obj = [parameters objectForKey:NAMES_driverBraking]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataEventStatus.class]) { + return (SDLVehicleDataEventStatus *)obj; + } else { + return [SDLVehicleDataEventStatus valueOf:(NSString *)obj]; + } +} + +- (void)setWiperStatus:(SDLWiperStatus *)wiperStatus { + if (wiperStatus != nil) { + [parameters setObject:wiperStatus forKey:NAMES_wiperStatus]; + } else { + [parameters removeObjectForKey:NAMES_wiperStatus]; + } +} + +- (SDLWiperStatus *)wiperStatus { + NSObject *obj = [parameters objectForKey:NAMES_wiperStatus]; + if (obj == nil || [obj isKindOfClass:SDLWiperStatus.class]) { + return (SDLWiperStatus *)obj; + } else { + return [SDLWiperStatus valueOf:(NSString *)obj]; + } +} + +- (void)setHeadLampStatus:(SDLHeadLampStatus *)headLampStatus { + if (headLampStatus != nil) { + [parameters setObject:headLampStatus forKey:NAMES_headLampStatus]; + } else { + [parameters removeObjectForKey:NAMES_headLampStatus]; + } +} + +- (SDLHeadLampStatus *)headLampStatus { + NSObject *obj = [parameters objectForKey:NAMES_headLampStatus]; + if (obj == nil || [obj isKindOfClass:SDLHeadLampStatus.class]) { + return (SDLHeadLampStatus *)obj; + } else { + return [[SDLHeadLampStatus alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setEngineTorque:(NSNumber *)engineTorque { + if (engineTorque != nil) { + [parameters setObject:engineTorque forKey:NAMES_engineTorque]; + } else { + [parameters removeObjectForKey:NAMES_engineTorque]; + } +} + +- (NSNumber *)engineTorque { + return [parameters objectForKey:NAMES_engineTorque]; +} + +- (void)setAccPedalPosition:(NSNumber *)accPedalPosition { + if (accPedalPosition != nil) { + [parameters setObject:accPedalPosition forKey:NAMES_accPedalPosition]; + } else { + [parameters removeObjectForKey:NAMES_accPedalPosition]; + } +} + +- (NSNumber *)accPedalPosition { + return [parameters objectForKey:NAMES_accPedalPosition]; +} + +- (void)setSteeringWheelAngle:(NSNumber *)steeringWheelAngle { + if (steeringWheelAngle != nil) { + [parameters setObject:steeringWheelAngle forKey:NAMES_steeringWheelAngle]; + } else { + [parameters removeObjectForKey:NAMES_steeringWheelAngle]; + } +} + +- (NSNumber *)steeringWheelAngle { + return [parameters objectForKey:NAMES_steeringWheelAngle]; +} + +- (void)setECallInfo:(SDLECallInfo *)eCallInfo { + if (eCallInfo != nil) { + [parameters setObject:eCallInfo forKey:NAMES_eCallInfo]; + } else { + [parameters removeObjectForKey:NAMES_eCallInfo]; + } +} + +- (SDLECallInfo *)eCallInfo { + NSObject *obj = [parameters objectForKey:NAMES_eCallInfo]; + if (obj == nil || [obj isKindOfClass:SDLECallInfo.class]) { + return (SDLECallInfo *)obj; + } else { + return [[SDLECallInfo alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setAirbagStatus:(SDLAirbagStatus *)airbagStatus { + if (airbagStatus != nil) { + [parameters setObject:airbagStatus forKey:NAMES_airbagStatus]; + } else { + [parameters removeObjectForKey:NAMES_airbagStatus]; + } +} + +- (SDLAirbagStatus *)airbagStatus { + NSObject *obj = [parameters objectForKey:NAMES_airbagStatus]; + if (obj == nil || [obj isKindOfClass:SDLAirbagStatus.class]) { + return (SDLAirbagStatus *)obj; + } else { + return [[SDLAirbagStatus alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setEmergencyEvent:(SDLEmergencyEvent *)emergencyEvent { + if (emergencyEvent != nil) { + [parameters setObject:emergencyEvent forKey:NAMES_emergencyEvent]; + } else { + [parameters removeObjectForKey:NAMES_emergencyEvent]; + } +} + +- (SDLEmergencyEvent *)emergencyEvent { + NSObject *obj = [parameters objectForKey:NAMES_emergencyEvent]; + if (obj == nil || [obj isKindOfClass:SDLEmergencyEvent.class]) { + return (SDLEmergencyEvent *)obj; + } else { + return [[SDLEmergencyEvent alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setClusterModeStatus:(SDLClusterModeStatus *)clusterModeStatus { + if (clusterModeStatus != nil) { + [parameters setObject:clusterModeStatus forKey:NAMES_clusterModeStatus]; + } else { + [parameters removeObjectForKey:NAMES_clusterModeStatus]; + } +} + +- (SDLClusterModeStatus *)clusterModeStatus { + NSObject *obj = [parameters objectForKey:NAMES_clusterModeStatus]; + if (obj == nil || [obj isKindOfClass:SDLClusterModeStatus.class]) { + return (SDLClusterModeStatus *)obj; + } else { + return [[SDLClusterModeStatus alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setMyKey:(SDLMyKey *)myKey { + if (myKey != nil) { + [parameters setObject:myKey forKey:NAMES_myKey]; + } else { + [parameters removeObjectForKey:NAMES_myKey]; + } +} + +- (SDLMyKey *)myKey { + NSObject *obj = [parameters objectForKey:NAMES_myKey]; + if (obj == nil || [obj isKindOfClass:SDLMyKey.class]) { + return (SDLMyKey *)obj; + } else { + return [[SDLMyKey alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLPRNDL.h b/SmartDeviceLink/SDLPRNDL.h new file mode 100644 index 000000000..6095d1a82 --- /dev/null +++ b/SmartDeviceLink/SDLPRNDL.h @@ -0,0 +1,143 @@ +// SDLPRNDL.h +// + + +#import "SDLEnum.h" + +/** + * The selected gear the car is in. + * + * @since SDL 2.0 + */ +@interface SDLPRNDL : SDLEnum { +} + +/** + * @abstract get SDLPRNDL according value string + * + * @param value The value of the string to get an object for + * + * @return SDLPRNDL object + */ ++ (SDLPRNDL *)valueOf:(NSString *)value; + +/** + * @abstract declare an array to store all possible SDLPRNDL values + * + * @return the array + */ ++ (NSArray *)values; + +/** + * @abstract Park + * + * @return SDLPRNDL: *PARK* + */ ++ (SDLPRNDL *)PARK; + +/** + * @abstract Reverse gear + * + * @return SDLPRNDL: *REVERSE* + */ ++ (SDLPRNDL *)REVERSE; + +/** + * @abstract No gear + * + * @return SDLPRNDL: *NEUTRAL* + */ ++ (SDLPRNDL *)NEUTRAL; + +/** + * @abstract: Drive gear + * + * @return SDLPRNDL: *DRIVE* + */ ++ (SDLPRNDL *)DRIVE; + +/** + * @abstract Drive Sport mode + * + * @return SDLPRNDL: *SPORT* + */ ++ (SDLPRNDL *)SPORT; + +/** + * @abstract 1st gear hold + * + * @return SDLPRNDL: *LOWGEAR* + */ ++ (SDLPRNDL *)LOWGEAR; + +/** + * @abstract First gear + * + * @return SDLPRNDL: *FIRST* + */ ++ (SDLPRNDL *)FIRST; + +/** + * @abstract Second gear + * + * @return SDLPRNDL: *SECOND* + */ ++ (SDLPRNDL *)SECOND; + +/** + * @abstract Third gear + * + * @return SDLPRNDL: *THIRD* + */ ++ (SDLPRNDL *)THIRD; + +/** + * @abstract Fourth gear + * + * @return SDLPRNDL: *FOURTH* + */ ++ (SDLPRNDL *)FOURTH; + +/** + * @abstract Fifth gear + * + * @return SDLPRNDL: *FIFTH* + */ ++ (SDLPRNDL *)FIFTH; + +/** + * @abstract Sixth gear + * + * @return SDLPRNDL: *SIXTH* + */ ++ (SDLPRNDL *)SIXTH; + +/** + * @abstract Seventh gear + * + * @return SDLPRNDL: *SEVENTH* + */ ++ (SDLPRNDL *)SEVENTH; + +/** + * @abstract Eighth gear + * + * @return SDLPRNDL: *EIGHTH* + */ ++ (SDLPRNDL *)EIGHTH; + +/** + * @abstract Unknown + * + * @return SDLPRNDL: *UNKNOWN* + */ ++ (SDLPRNDL *)UNKNOWN; + +/** + * @abstract Fault + * + * @return SDLPRNDL: *FAULT* + */ ++ (SDLPRNDL *)FAULT; + +@end diff --git a/SmartDeviceLink/SDLPRNDL.m b/SmartDeviceLink/SDLPRNDL.m new file mode 100644 index 000000000..e0588af77 --- /dev/null +++ b/SmartDeviceLink/SDLPRNDL.m @@ -0,0 +1,173 @@ +// SDLPRNDL.m +// + + +#import "SDLPRNDL.h" + +SDLPRNDL *SDLPRNDL_PARK = nil; +SDLPRNDL *SDLPRNDL_REVERSE = nil; +SDLPRNDL *SDLPRNDL_NEUTRAL = nil; +SDLPRNDL *SDLPRNDL_DRIVE = nil; +SDLPRNDL *SDLPRNDL_SPORT = nil; +SDLPRNDL *SDLPRNDL_LOWGEAR = nil; +SDLPRNDL *SDLPRNDL_FIRST = nil; +SDLPRNDL *SDLPRNDL_SECOND = nil; +SDLPRNDL *SDLPRNDL_THIRD = nil; +SDLPRNDL *SDLPRNDL_FOURTH = nil; +SDLPRNDL *SDLPRNDL_FIFTH = nil; +SDLPRNDL *SDLPRNDL_SIXTH = nil; +SDLPRNDL *SDLPRNDL_SEVENTH = nil; +SDLPRNDL *SDLPRNDL_EIGHTH = nil; +SDLPRNDL *SDLPRNDL_UNKNOWN = nil; +SDLPRNDL *SDLPRNDL_FAULT = nil; + +NSArray *SDLPRNDL_values = nil; + +@implementation SDLPRNDL + ++ (SDLPRNDL *)valueOf:(NSString *)value { + for (SDLPRNDL *item in SDLPRNDL.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLPRNDL_values == nil) { + SDLPRNDL_values = @[ + SDLPRNDL.PARK, + SDLPRNDL.REVERSE, + SDLPRNDL.NEUTRAL, + SDLPRNDL.DRIVE, + SDLPRNDL.SPORT, + SDLPRNDL.LOWGEAR, + SDLPRNDL.FIRST, + SDLPRNDL.SECOND, + SDLPRNDL.THIRD, + SDLPRNDL.FOURTH, + SDLPRNDL.FIFTH, + SDLPRNDL.SIXTH, + SDLPRNDL.SEVENTH, + SDLPRNDL.EIGHTH, + SDLPRNDL.UNKNOWN, + SDLPRNDL.FAULT, + ]; + } + return SDLPRNDL_values; +} + ++ (SDLPRNDL *)PARK { + if (SDLPRNDL_PARK == nil) { + SDLPRNDL_PARK = [[SDLPRNDL alloc] initWithValue:@"PARK"]; + } + return SDLPRNDL_PARK; +} + ++ (SDLPRNDL *)REVERSE { + if (SDLPRNDL_REVERSE == nil) { + SDLPRNDL_REVERSE = [[SDLPRNDL alloc] initWithValue:@"REVERSE"]; + } + return SDLPRNDL_REVERSE; +} + ++ (SDLPRNDL *)NEUTRAL { + if (SDLPRNDL_NEUTRAL == nil) { + SDLPRNDL_NEUTRAL = [[SDLPRNDL alloc] initWithValue:@"NEUTRAL"]; + } + return SDLPRNDL_NEUTRAL; +} + ++ (SDLPRNDL *)DRIVE { + if (SDLPRNDL_DRIVE == nil) { + SDLPRNDL_DRIVE = [[SDLPRNDL alloc] initWithValue:@"DRIVE"]; + } + return SDLPRNDL_DRIVE; +} + ++ (SDLPRNDL *)SPORT { + if (SDLPRNDL_SPORT == nil) { + SDLPRNDL_SPORT = [[SDLPRNDL alloc] initWithValue:@"SPORT"]; + } + return SDLPRNDL_SPORT; +} + ++ (SDLPRNDL *)LOWGEAR { + if (SDLPRNDL_LOWGEAR == nil) { + SDLPRNDL_LOWGEAR = [[SDLPRNDL alloc] initWithValue:@"LOWGEAR"]; + } + return SDLPRNDL_LOWGEAR; +} + ++ (SDLPRNDL *)FIRST { + if (SDLPRNDL_FIRST == nil) { + SDLPRNDL_FIRST = [[SDLPRNDL alloc] initWithValue:@"FIRST"]; + } + return SDLPRNDL_FIRST; +} + ++ (SDLPRNDL *)SECOND { + if (SDLPRNDL_SECOND == nil) { + SDLPRNDL_SECOND = [[SDLPRNDL alloc] initWithValue:@"SECOND"]; + } + return SDLPRNDL_SECOND; +} + ++ (SDLPRNDL *)THIRD { + if (SDLPRNDL_THIRD == nil) { + SDLPRNDL_THIRD = [[SDLPRNDL alloc] initWithValue:@"THIRD"]; + } + return SDLPRNDL_THIRD; +} + ++ (SDLPRNDL *)FOURTH { + if (SDLPRNDL_FOURTH == nil) { + SDLPRNDL_FOURTH = [[SDLPRNDL alloc] initWithValue:@"FOURTH"]; + } + return SDLPRNDL_FOURTH; +} + ++ (SDLPRNDL *)FIFTH { + if (SDLPRNDL_FIFTH == nil) { + SDLPRNDL_FIFTH = [[SDLPRNDL alloc] initWithValue:@"FIFTH"]; + } + return SDLPRNDL_FIFTH; +} + ++ (SDLPRNDL *)SIXTH { + if (SDLPRNDL_SIXTH == nil) { + SDLPRNDL_SIXTH = [[SDLPRNDL alloc] initWithValue:@"SIXTH"]; + } + return SDLPRNDL_SIXTH; +} + ++ (SDLPRNDL *)SEVENTH { + if (SDLPRNDL_SEVENTH == nil) { + SDLPRNDL_SEVENTH = [[SDLPRNDL alloc] initWithValue:@"SEVENTH"]; + } + return SDLPRNDL_SEVENTH; +} + ++ (SDLPRNDL *)EIGHTH { + if (SDLPRNDL_EIGHTH == nil) { + SDLPRNDL_EIGHTH = [[SDLPRNDL alloc] initWithValue:@"EIGHTH"]; + } + return SDLPRNDL_EIGHTH; +} + ++ (SDLPRNDL *)UNKNOWN { + if (SDLPRNDL_UNKNOWN == nil) { + SDLPRNDL_UNKNOWN = [[SDLPRNDL alloc] initWithValue:@"UNKNOWN"]; + } + return SDLPRNDL_UNKNOWN; +} + ++ (SDLPRNDL *)FAULT { + if (SDLPRNDL_FAULT == nil) { + SDLPRNDL_FAULT = [[SDLPRNDL alloc] initWithValue:@"FAULT"]; + } + return SDLPRNDL_FAULT; +} + +@end diff --git a/SmartDeviceLink/SDLParameterPermissions.h b/SmartDeviceLink/SDLParameterPermissions.h new file mode 100644 index 000000000..af724d53f --- /dev/null +++ b/SmartDeviceLink/SDLParameterPermissions.h @@ -0,0 +1,39 @@ +// SDLParameterPermissions.h +// + + +#import "SDLRPCMessage.h" + +/** + * Defining sets of parameters, which are permitted or prohibited for a given RPC. + * + * @since SDL 2.0 + */ +@interface SDLParameterPermissions : SDLRPCStruct { +} + +/** + * @abstract Constructs a newly allocated SDLParameterPermissions object + */ +- (instancetype)init; +/** + * @abstract Constructs a newly allocated SDLParameterPermissions object indicated by the dictionary parameter + * + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract A set of all parameters that are permitted for this given RPC. + * + * Required, Array of String, max String length = 100, Array size 0 - 100 + */ +@property (strong) NSMutableArray *allowed; +/** + * @abstract A set of all parameters that are prohibited for this given RPC. + * + * Required, Array of String, max String length = 100, Array size 0 - 100 + */ +@property (strong) NSMutableArray *userDisallowed; + +@end diff --git a/SmartDeviceLink/SDLParameterPermissions.m b/SmartDeviceLink/SDLParameterPermissions.m new file mode 100644 index 000000000..e18d1ec12 --- /dev/null +++ b/SmartDeviceLink/SDLParameterPermissions.m @@ -0,0 +1,47 @@ +// SDLParameterPermissions.m +// + + +#import "SDLParameterPermissions.h" + +#import "SDLNames.h" + +@implementation SDLParameterPermissions + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setAllowed:(NSMutableArray *)allowed { + if (allowed != nil) { + [store setObject:allowed forKey:NAMES_allowed]; + } else { + [store removeObjectForKey:NAMES_allowed]; + } +} + +- (NSMutableArray *)allowed { + return [store objectForKey:NAMES_allowed]; +} + +- (void)setUserDisallowed:(NSMutableArray *)userDisallowed { + if (userDisallowed != nil) { + [store setObject:userDisallowed forKey:NAMES_userDisallowed]; + } else { + [store removeObjectForKey:NAMES_userDisallowed]; + } +} + +- (NSMutableArray *)userDisallowed { + return [store objectForKey:NAMES_userDisallowed]; +} + +@end diff --git a/SmartDeviceLink/SDLPerformAudioPassThru.h b/SmartDeviceLink/SDLPerformAudioPassThru.h new file mode 100644 index 000000000..66dfacf19 --- /dev/null +++ b/SmartDeviceLink/SDLPerformAudioPassThru.h @@ -0,0 +1,104 @@ +// SDLPerformAudioPassThru.h +// + +#import "SDLRPCRequest.h" + +@class SDLSamplingRate; +@class SDLBitsPerSample; +@class SDLAudioType; + + +/** + * This will open an audio pass thru session. By doing so the app can receive + * audio data through the vehicle microphone + * <p> + * Function Group: AudioPassThru + * <p> + * <b>HMILevel needs to be FULL, LIMITED or BACKGROUND</b> + * </p> + * + * <p>Since SmartDeviceLink 2.0</p> + * <p>See SDLEndAudioPassThru</p> + */ +@interface SDLPerformAudioPassThru : SDLRPCRequest { +} + +/** + * @abstract Constructs a new SDLPerformAudioPassThru object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLPerformAudioPassThru object indicated by the NSMutableDictionary + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract initial prompt which will be spoken before opening the audio pass + * thru session by SDL + * @discussion initialPrompt + * a Vector<TTSChunk> value represents the initial prompt which + * will be spoken before opening the audio pass thru session by + * SDL + * <p> + * <b>Notes: </b> + * <ul> + * <li>This is an array of text chunks of type TTSChunk</li> + * <li>The array must have at least one item</li> + * <li>If omitted, then no initial prompt is spoken</li> + * <li>Array Minsize: 1</li> + * <li>Array Maxsize: 100</li> + * </ul> + */ +@property (strong) NSMutableArray *initialPrompt; +/** + * @abstract a line of text displayed during audio capture + * @discussion audioPassThruDisplayText1 + * a String value representing the line of text displayed during + * audio capture + * <p> + * <b>Notes: </b>Maxlength=500 + */ +@property (strong) NSString *audioPassThruDisplayText1; +/** + * @abstract A line of text displayed during audio capture + * @discussion audioPassThruDisplayText2 + * a String value representing the line of text displayed during + * audio capture + * <p> + * <b>Notes: </b>Maxlength=500 + */ +@property (strong) NSString *audioPassThruDisplayText2; +/** + * @abstract A samplingRate + * + * @discussion a SamplingRate value representing a 8 or 16 or 22 or 24 khz + */ +@property (strong) SDLSamplingRate *samplingRate; +/** + * @abstract the maximum duration of audio recording in milliseconds + * + * @discussion maxDuration + * an Integer value representing the maximum duration of audio + * recording in millisecond + * <p> + * <b>Notes: </b>Minvalue:1; Maxvalue:1000000 + */ +@property (strong) NSNumber *maxDuration; +/** + * @abstract the quality the audio is recorded - 8 bit or 16 bit + * + * @discussion a BitsPerSample value representing 8 bit or 16 bit + */ +@property (strong) SDLBitsPerSample *bitsPerSample; +/** + * @abstract an audioType + */ +@property (strong) SDLAudioType *audioType; +/** + * @abstract a Boolean value representing if the current audio source should be + * muted during the APT session<br/> + */ +@property (strong) NSNumber *muteAudio; + +@end diff --git a/SmartDeviceLink/SDLPerformAudioPassThru.m b/SmartDeviceLink/SDLPerformAudioPassThru.m new file mode 100644 index 000000000..67b0f05c3 --- /dev/null +++ b/SmartDeviceLink/SDLPerformAudioPassThru.m @@ -0,0 +1,148 @@ +// SDLPerformAudioPassThru.m +// + + +#import "SDLPerformAudioPassThru.h" + +#import "SDLAudioType.h" +#import "SDLBitsPerSample.h" +#import "SDLNames.h" +#import "SDLSamplingRate.h" +#import "SDLTTSChunk.h" + + +@implementation SDLPerformAudioPassThru + +- (instancetype)init { + if (self = [super initWithName:NAMES_PerformAudioPassThru]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setInitialPrompt:(NSMutableArray *)initialPrompt { + if (initialPrompt != nil) { + [parameters setObject:initialPrompt forKey:NAMES_initialPrompt]; + } else { + [parameters removeObjectForKey:NAMES_initialPrompt]; + } +} + +- (NSMutableArray *)initialPrompt { + NSMutableArray *array = [parameters objectForKey:NAMES_initialPrompt]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLTTSChunk.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLTTSChunk alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +- (void)setAudioPassThruDisplayText1:(NSString *)audioPassThruDisplayText1 { + if (audioPassThruDisplayText1 != nil) { + [parameters setObject:audioPassThruDisplayText1 forKey:NAMES_audioPassThruDisplayText1]; + } else { + [parameters removeObjectForKey:NAMES_audioPassThruDisplayText1]; + } +} + +- (NSString *)audioPassThruDisplayText1 { + return [parameters objectForKey:NAMES_audioPassThruDisplayText1]; +} + +- (void)setAudioPassThruDisplayText2:(NSString *)audioPassThruDisplayText2 { + if (audioPassThruDisplayText2 != nil) { + [parameters setObject:audioPassThruDisplayText2 forKey:NAMES_audioPassThruDisplayText2]; + } else { + [parameters removeObjectForKey:NAMES_audioPassThruDisplayText2]; + } +} + +- (NSString *)audioPassThruDisplayText2 { + return [parameters objectForKey:NAMES_audioPassThruDisplayText2]; +} + +- (void)setSamplingRate:(SDLSamplingRate *)samplingRate { + if (samplingRate != nil) { + [parameters setObject:samplingRate forKey:NAMES_samplingRate]; + } else { + [parameters removeObjectForKey:NAMES_samplingRate]; + } +} + +- (SDLSamplingRate *)samplingRate { + NSObject *obj = [parameters objectForKey:NAMES_samplingRate]; + if (obj == nil || [obj isKindOfClass:SDLSamplingRate.class]) { + return (SDLSamplingRate *)obj; + } else { + return [SDLSamplingRate valueOf:(NSString *)obj]; + } +} + +- (void)setMaxDuration:(NSNumber *)maxDuration { + if (maxDuration != nil) { + [parameters setObject:maxDuration forKey:NAMES_maxDuration]; + } else { + [parameters removeObjectForKey:NAMES_maxDuration]; + } +} + +- (NSNumber *)maxDuration { + return [parameters objectForKey:NAMES_maxDuration]; +} + +- (void)setBitsPerSample:(SDLBitsPerSample *)bitsPerSample { + if (bitsPerSample != nil) { + [parameters setObject:bitsPerSample forKey:NAMES_bitsPerSample]; + } else { + [parameters removeObjectForKey:NAMES_bitsPerSample]; + } +} + +- (SDLBitsPerSample *)bitsPerSample { + NSObject *obj = [parameters objectForKey:NAMES_bitsPerSample]; + if (obj == nil || [obj isKindOfClass:SDLBitsPerSample.class]) { + return (SDLBitsPerSample *)obj; + } else { + return [SDLBitsPerSample valueOf:(NSString *)obj]; + } +} + +- (void)setAudioType:(SDLAudioType *)audioType { + if (audioType != nil) { + [parameters setObject:audioType forKey:NAMES_audioType]; + } else { + [parameters removeObjectForKey:NAMES_audioType]; + } +} + +- (SDLAudioType *)audioType { + NSObject *obj = [parameters objectForKey:NAMES_audioType]; + if (obj == nil || [obj isKindOfClass:SDLAudioType.class]) { + return (SDLAudioType *)obj; + } else { + return [SDLAudioType valueOf:(NSString *)obj]; + } +} + +- (void)setMuteAudio:(NSNumber *)muteAudio { + if (muteAudio != nil) { + [parameters setObject:muteAudio forKey:NAMES_muteAudio]; + } else { + [parameters removeObjectForKey:NAMES_muteAudio]; + } +} + +- (NSNumber *)muteAudio { + return [parameters objectForKey:NAMES_muteAudio]; +} + +@end diff --git a/SmartDeviceLink/SDLPerformAudioPassThruResponse.h b/SmartDeviceLink/SDLPerformAudioPassThruResponse.h new file mode 100644 index 000000000..3d2835114 --- /dev/null +++ b/SmartDeviceLink/SDLPerformAudioPassThruResponse.h @@ -0,0 +1,25 @@ +// SDLPerformAudioPassThruResponse.h +// + + +#import "SDLRPCResponse.h" + +/** + * Perform Audio Pass Thru Response is sent, when PerformAudioPassThru has been called + * + * Since SmartDeviceLink 2.0 + */ +@interface SDLPerformAudioPassThruResponse : SDLRPCResponse { +} + +/** + * @abstract Constructs a new SDLPerformAudioPassThruResponse object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLPerformAudioPassThruResponse object indicated by the dictionary parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLPerformAudioPassThruResponse.m b/SmartDeviceLink/SDLPerformAudioPassThruResponse.m new file mode 100644 index 000000000..ed8a1e614 --- /dev/null +++ b/SmartDeviceLink/SDLPerformAudioPassThruResponse.m @@ -0,0 +1,23 @@ +// SDLPerformAudioPassThruResponse.m +// + + +#import "SDLPerformAudioPassThruResponse.h" + +#import "SDLNames.h" + +@implementation SDLPerformAudioPassThruResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_PerformAudioPassThru]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLPerformInteraction.h b/SmartDeviceLink/SDLPerformInteraction.h new file mode 100644 index 000000000..29f166c96 --- /dev/null +++ b/SmartDeviceLink/SDLPerformInteraction.h @@ -0,0 +1,85 @@ +// SDLPerformInteraction.h +// + + +#import "SDLRPCRequest.h" + +@class SDLInteractionMode; +@class SDLLayoutMode; + + +/** + * Performs an application-initiated interaction in which the user can select a + * {@linkplain Choice} from among the specified Choice Sets. For instance, an + * application may use a PerformInteraction to ask a user to say the name of a + * song to play. The user's response is only valid if it appears in the + * specified Choice Sets and is recognized by SDL + * <p> + * Function Group: Base + * <p> + * <b>HMILevel needs to be FULL</b> + * </p> + * + * Since SmartDeviceLink 1.0<br/> + * See SDLCreateInteractionChoiceSet SDLDeleteInteractionChoiceSet + */ +@interface SDLPerformInteraction : SDLRPCRequest { +} + +/** + * @abstract Constructs a new SDLPerformInteraction object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLPerformInteraction object indicated by the NSMutableDictionary + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract The Text that Displayed when the interaction begins. This text may + * be overlaid by the "Listening" prompt during the interaction. Text is + * displayed on first line of multiline display, and is centered. If text + * does not fit on line, it will be truncated + */ +@property (strong) NSString *initialText; +/** + * @abstract An array of one or more TTSChunks that, taken together, specify + * what is to be spoken to the user at the start of an interaction + */ +@property (strong) NSMutableArray *initialPrompt; +/** + * @abstract The Indicates mode that indicate how user selects interaction + * choice. User can choose either by voice (VR_ONLY), by visual selection + * from the menu (MANUAL_ONLY), or by either mode (BOTH) + */ +@property (strong) SDLInteractionMode *interactionMode; +/** + * @abstract A Vector<Integer> value representing an Array of one or more Choice + * Set IDs + */ +@property (strong) NSMutableArray *interactionChoiceSetIDList; +/** + * @abstract A Vector<TTSChunk> which taken together, specify the help phrase to + * be spoken when the user says "help" during the VR session + */ +@property (strong) NSMutableArray *helpPrompt; +/** + * @abstract An array of TTSChunks which, taken together, specify the phrase to + * be spoken when the listen times out during the VR session + */ +@property (strong) NSMutableArray *timeoutPrompt; +/** + * @abstract An Integer value representing the amount of time, in milliseconds, + * SDL will wait for the user to make a choice (VR or Menu) + */ +@property (strong) NSNumber *timeout; +/** + * @abstract A Voice recognition Help, which is a suggested VR Help Items to + * display on-screen during Perform Interaction + * @since SmartDeviceLink 2.0 + */ +@property (strong) NSMutableArray *vrHelp; +@property (strong) SDLLayoutMode *interactionLayout; + +@end diff --git a/SmartDeviceLink/SDLPerformInteraction.m b/SmartDeviceLink/SDLPerformInteraction.m new file mode 100644 index 000000000..de6c3622f --- /dev/null +++ b/SmartDeviceLink/SDLPerformInteraction.m @@ -0,0 +1,181 @@ +// SDLPerformInteraction.m +// + + +#import "SDLPerformInteraction.h" + +#import "SDLInteractionMode.h" +#import "SDLLayoutMode.h" +#import "SDLNames.h" +#import "SDLTTSChunk.h" +#import "SDLVRHelpItem.h" + +@implementation SDLPerformInteraction + +- (instancetype)init { + if (self = [super initWithName:NAMES_PerformInteraction]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setInitialText:(NSString *)initialText { + if (initialText != nil) { + [parameters setObject:initialText forKey:NAMES_initialText]; + } else { + [parameters removeObjectForKey:NAMES_initialText]; + } +} + +- (NSString *)initialText { + return [parameters objectForKey:NAMES_initialText]; +} + +- (void)setInitialPrompt:(NSMutableArray *)initialPrompt { + if (initialPrompt != nil) { + [parameters setObject:initialPrompt forKey:NAMES_initialPrompt]; + } else { + [parameters removeObjectForKey:NAMES_initialPrompt]; + } +} + +- (NSMutableArray *)initialPrompt { + NSMutableArray *array = [parameters objectForKey:NAMES_initialPrompt]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLTTSChunk.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLTTSChunk alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +- (void)setInteractionMode:(SDLInteractionMode *)interactionMode { + if (interactionMode != nil) { + [parameters setObject:interactionMode forKey:NAMES_interactionMode]; + } else { + [parameters removeObjectForKey:NAMES_interactionMode]; + } +} + +- (SDLInteractionMode *)interactionMode { + NSObject *obj = [parameters objectForKey:NAMES_interactionMode]; + if (obj == nil || [obj isKindOfClass:SDLInteractionMode.class]) { + return (SDLInteractionMode *)obj; + } else { + return [SDLInteractionMode valueOf:(NSString *)obj]; + } +} + +- (void)setInteractionChoiceSetIDList:(NSMutableArray *)interactionChoiceSetIDList { + if (interactionChoiceSetIDList != nil) { + [parameters setObject:interactionChoiceSetIDList forKey:NAMES_interactionChoiceSetIDList]; + } else { + [parameters removeObjectForKey:NAMES_interactionChoiceSetIDList]; + } +} + +- (NSMutableArray *)interactionChoiceSetIDList { + return [parameters objectForKey:NAMES_interactionChoiceSetIDList]; +} + +- (void)setHelpPrompt:(NSMutableArray *)helpPrompt { + if (helpPrompt != nil) { + [parameters setObject:helpPrompt forKey:NAMES_helpPrompt]; + } else { + [parameters removeObjectForKey:NAMES_helpPrompt]; + } +} + +- (NSMutableArray *)helpPrompt { + NSMutableArray *array = [parameters objectForKey:NAMES_helpPrompt]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLTTSChunk.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLTTSChunk alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +- (void)setTimeoutPrompt:(NSMutableArray *)timeoutPrompt { + if (timeoutPrompt != nil) { + [parameters setObject:timeoutPrompt forKey:NAMES_timeoutPrompt]; + } else { + [parameters removeObjectForKey:NAMES_timeoutPrompt]; + } +} + +- (NSMutableArray *)timeoutPrompt { + NSMutableArray *array = [parameters objectForKey:NAMES_timeoutPrompt]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLTTSChunk.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLTTSChunk alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +- (void)setTimeout:(NSNumber *)timeout { + if (timeout != nil) { + [parameters setObject:timeout forKey:NAMES_timeout]; + } else { + [parameters removeObjectForKey:NAMES_timeout]; + } +} + +- (NSNumber *)timeout { + return [parameters objectForKey:NAMES_timeout]; +} + +- (void)setVrHelp:(NSMutableArray *)vrHelp { + if (vrHelp != nil) { + [parameters setObject:vrHelp forKey:NAMES_vrHelp]; + } else { + [parameters removeObjectForKey:NAMES_vrHelp]; + } +} + +- (NSMutableArray *)vrHelp { + NSMutableArray *array = [parameters objectForKey:NAMES_vrHelp]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLVRHelpItem.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLVRHelpItem alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +- (void)setInteractionLayout:(SDLLayoutMode *)interactionLayout { + if (interactionLayout != nil) { + [parameters setObject:interactionLayout forKey:NAMES_interactionLayout]; + } else { + [parameters removeObjectForKey:NAMES_interactionLayout]; + } +} + +- (SDLLayoutMode *)interactionLayout { + NSObject *obj = [parameters objectForKey:NAMES_interactionLayout]; + if (obj == nil || [obj isKindOfClass:SDLLayoutMode.class]) { + return (SDLLayoutMode *)obj; + } else { + return [SDLLayoutMode valueOf:(NSString *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLPerformInteractionResponse.h b/SmartDeviceLink/SDLPerformInteractionResponse.h new file mode 100644 index 000000000..b589f9492 --- /dev/null +++ b/SmartDeviceLink/SDLPerformInteractionResponse.h @@ -0,0 +1,55 @@ +// SDLPerformInteractionResponse.h +// + + +#import "SDLRPCResponse.h" + +@class SDLTriggerSource; + + +/** + * PerformInteraction Response is sent, when SDLPerformInteraction has been called + * + * @since SDL 1.0 + */ +@interface SDLPerformInteractionResponse : SDLRPCResponse { +} + +/** + * @abstract Constructs a new SDLPerformInteractionResponse object + */ +- (instancetype)init; + +/** + * @abstract Constructs a new SDLPerformInteractionResponse object indicated by the dictionary parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract ID of the choice that was selected in response to PerformInteraction. + * + * @discussion Only is valid if general result is "success:true". + * + * Optional, Integer, 0 - 2,000,000,000 + */ +@property (strong) NSNumber *choiceID; + +/** + * @abstract Manually entered text selection, e.g. through keyboard + * + * @discussion Can be returned in lieu of choiceID, depending on trigger source + * + * Optional, Max length 500 chars + */ +@property (strong) NSString *manualTextEntry; + +/** + * @abstract A *SDLTriggerSource* object which will be shown in the HMI + * + * @discussion Only is valid if resultCode is SUCCESS. + */ +@property (strong) SDLTriggerSource *triggerSource; + + +@end diff --git a/SmartDeviceLink/SDLPerformInteractionResponse.m b/SmartDeviceLink/SDLPerformInteractionResponse.m new file mode 100644 index 000000000..ae1c5e14c --- /dev/null +++ b/SmartDeviceLink/SDLPerformInteractionResponse.m @@ -0,0 +1,66 @@ +// SDLPerformInteractionResponse.m +// + + +#import "SDLPerformInteractionResponse.h" + +#import "SDLNames.h" +#import "SDLTriggerSource.h" + + +@implementation SDLPerformInteractionResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_PerformInteraction]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setChoiceID:(NSNumber *)choiceID { + if (choiceID != nil) { + [parameters setObject:choiceID forKey:NAMES_choiceID]; + } else { + [parameters removeObjectForKey:NAMES_choiceID]; + } +} + +- (NSNumber *)choiceID { + return [parameters objectForKey:NAMES_choiceID]; +} + +- (void)setManualTextEntry:(NSString *)manualTextEntry { + if (manualTextEntry != nil) { + [parameters setObject:manualTextEntry forKey:NAMES_manualTextEntry]; + } else { + [parameters removeObjectForKey:NAMES_manualTextEntry]; + } +} + +- (NSString *)manualTextEntry { + return [parameters objectForKey:NAMES_manualTextEntry]; +} + +- (void)setTriggerSource:(SDLTriggerSource *)triggerSource { + if (triggerSource != nil) { + [parameters setObject:triggerSource forKey:NAMES_triggerSource]; + } else { + [parameters removeObjectForKey:NAMES_triggerSource]; + } +} + +- (SDLTriggerSource *)triggerSource { + NSObject *obj = [parameters objectForKey:NAMES_triggerSource]; + if (obj == nil || [obj isKindOfClass:SDLTriggerSource.class]) { + return (SDLTriggerSource *)obj; + } else { + return [SDLTriggerSource valueOf:(NSString *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLPermissionItem.h b/SmartDeviceLink/SDLPermissionItem.h new file mode 100644 index 000000000..a0fe0d580 --- /dev/null +++ b/SmartDeviceLink/SDLPermissionItem.h @@ -0,0 +1,20 @@ +// SDLPermissionItem.h +// + +#import "SDLRPCMessage.h" + +@class SDLHMIPermissions; +@class SDLParameterPermissions; + + +@interface SDLPermissionItem : SDLRPCStruct { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) NSString *rpcName; +@property (strong) SDLHMIPermissions *hmiPermissions; +@property (strong) SDLParameterPermissions *parameterPermissions; + +@end diff --git a/SmartDeviceLink/SDLPermissionItem.m b/SmartDeviceLink/SDLPermissionItem.m new file mode 100644 index 000000000..560094c2e --- /dev/null +++ b/SmartDeviceLink/SDLPermissionItem.m @@ -0,0 +1,71 @@ +// SDLPermissionItem.m +// + +#import "SDLPermissionItem.h" + +#import "SDLHMIPermissions.h" +#import "SDLNames.h" +#import "SDLParameterPermissions.h" + + +@implementation SDLPermissionItem + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setRpcName:(NSString *)rpcName { + if (rpcName != nil) { + [store setObject:rpcName forKey:NAMES_rpcName]; + } else { + [store removeObjectForKey:NAMES_rpcName]; + } +} + +- (NSString *)rpcName { + return [store objectForKey:NAMES_rpcName]; +} + +- (void)setHmiPermissions:(SDLHMIPermissions *)hmiPermissions { + if (hmiPermissions != nil) { + [store setObject:hmiPermissions forKey:NAMES_hmiPermissions]; + } else { + [store removeObjectForKey:NAMES_hmiPermissions]; + } +} + +- (SDLHMIPermissions *)hmiPermissions { + NSObject *obj = [store objectForKey:NAMES_hmiPermissions]; + if (obj == nil || [obj isKindOfClass:SDLHMIPermissions.class]) { + return (SDLHMIPermissions *)obj; + } else { + return [[SDLHMIPermissions alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setParameterPermissions:(SDLParameterPermissions *)parameterPermissions { + if (parameterPermissions != nil) { + [store setObject:parameterPermissions forKey:NAMES_parameterPermissions]; + } else { + [store removeObjectForKey:NAMES_parameterPermissions]; + } +} + +- (SDLParameterPermissions *)parameterPermissions { + NSObject *obj = [store objectForKey:NAMES_parameterPermissions]; + if (obj == nil || [obj isKindOfClass:SDLParameterPermissions.class]) { + return (SDLParameterPermissions *)obj; + } else { + return [[SDLParameterPermissions alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLPermissionStatus.h b/SmartDeviceLink/SDLPermissionStatus.h new file mode 100644 index 000000000..0ac9219ec --- /dev/null +++ b/SmartDeviceLink/SDLPermissionStatus.h @@ -0,0 +1,55 @@ +// SDLPermissionStatus.h +// + + +#import "SDLEnum.h" + +/** + * Enumeration that describes possible permission states of a policy table entry. + * + * @since SDL 2.0 + */ +@interface SDLPermissionStatus : SDLEnum { +} + +/** + * @abstract SDLPermissionStatus + * + * @param value The value of the string to get an object for + * + * @return a SDLPermissionStatus object + */ ++ (SDLPermissionStatus *)valueOf:(NSString *)value; + +/** + * @abstract declare an array to store all possible SDLPermissionStatus values + * @return the array + */ ++ (NSArray *)values; + + +/** + * @abstract permission: allowed + * @return permission status: *ALLOWED* + */ ++ (SDLPermissionStatus *)ALLOWED; + +/** + * @abstract permission: disallowed + * @return permission status: *DISALLOWED* + */ ++ (SDLPermissionStatus *)DISALLOWED; + +/** + * @abstract permission: user disallowed + * @return permission status: *USER_DISALLOWED* + */ ++ (SDLPermissionStatus *)USER_DISALLOWED; + +/** + * @abstract permission: user consent pending + * @return permission status: *USER_CONSENT_PENDING* + */ ++ (SDLPermissionStatus *)USER_CONSENT_PENDING; + +@end diff --git a/SmartDeviceLink/SDLPermissionStatus.m b/SmartDeviceLink/SDLPermissionStatus.m new file mode 100644 index 000000000..179cf2014 --- /dev/null +++ b/SmartDeviceLink/SDLPermissionStatus.m @@ -0,0 +1,65 @@ +// SDLPermissionStatus.m +// + + +#import "SDLPermissionStatus.h" + +SDLPermissionStatus *SDLPermissionStatus_ALLOWED = nil; +SDLPermissionStatus *SDLPermissionStatus_DISALLOWED = nil; +SDLPermissionStatus *SDLPermissionStatus_USER_DISALLOWED = nil; +SDLPermissionStatus *SDLPermissionStatus_USER_CONSENT_PENDING = nil; + +NSArray *SDLPermissionStatus_values = nil; + +@implementation SDLPermissionStatus + ++ (SDLPermissionStatus *)valueOf:(NSString *)value { + for (SDLPermissionStatus *item in SDLPermissionStatus.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLPermissionStatus_values == nil) { + SDLPermissionStatus_values = @[ + SDLPermissionStatus.ALLOWED, + SDLPermissionStatus.DISALLOWED, + SDLPermissionStatus.USER_DISALLOWED, + SDLPermissionStatus.USER_CONSENT_PENDING, + ]; + } + return SDLPermissionStatus_values; +} + ++ (SDLPermissionStatus *)ALLOWED { + if (SDLPermissionStatus_ALLOWED == nil) { + SDLPermissionStatus_ALLOWED = [[SDLPermissionStatus alloc] initWithValue:@"ALLOWED"]; + } + return SDLPermissionStatus_ALLOWED; +} + ++ (SDLPermissionStatus *)DISALLOWED { + if (SDLPermissionStatus_DISALLOWED == nil) { + SDLPermissionStatus_DISALLOWED = [[SDLPermissionStatus alloc] initWithValue:@"DISALLOWED"]; + } + return SDLPermissionStatus_DISALLOWED; +} + ++ (SDLPermissionStatus *)USER_DISALLOWED { + if (SDLPermissionStatus_USER_DISALLOWED == nil) { + SDLPermissionStatus_USER_DISALLOWED = [[SDLPermissionStatus alloc] initWithValue:@"USER_DISALLOWED"]; + } + return SDLPermissionStatus_USER_DISALLOWED; +} + ++ (SDLPermissionStatus *)USER_CONSENT_PENDING { + if (SDLPermissionStatus_USER_CONSENT_PENDING == nil) { + SDLPermissionStatus_USER_CONSENT_PENDING = [[SDLPermissionStatus alloc] initWithValue:@"USER_CONSENT_PENDING"]; + } + return SDLPermissionStatus_USER_CONSENT_PENDING; +} + +@end diff --git a/SmartDeviceLink/SDLPolicyDataParser.h b/SmartDeviceLink/SDLPolicyDataParser.h new file mode 100644 index 000000000..4e005f9fe --- /dev/null +++ b/SmartDeviceLink/SDLPolicyDataParser.h @@ -0,0 +1,31 @@ +// +// PolicyDataParser.h +// + +#import <Foundation/Foundation.h> + +@interface SDLPolicyDataParser : NSObject + +@property (assign) Byte protocolVersion; +@property (assign) BOOL isResponseRequired; +@property (assign) BOOL isHighBandwidth; +@property (assign) BOOL isSigned; +@property (assign) BOOL isEncrypted; +@property (assign) BOOL hasESN; +@property (assign) Byte serviceType; +@property (assign) Byte commandType; +@property (assign) BOOL CPUDestination; +@property (assign) Byte encryptionKeyIndex; +@property (assign) UInt32 payloadSize; +@property (strong) NSData *ESN; +@property (assign) UInt32 moduleMessageId; +@property (assign) UInt32 serverMessageId; +@property (assign) Byte messageStatus; +@property (strong) NSData *initializationVector; +@property (strong) NSData *payload; +@property (strong) NSData *signatureTag; + +- (NSData *)unwrap:(NSData *)wrappedData; +- (void)parsePolicyData:(NSData *)data; + +@end diff --git a/SmartDeviceLink/SDLPolicyDataParser.m b/SmartDeviceLink/SDLPolicyDataParser.m new file mode 100644 index 000000000..e528e4bd4 --- /dev/null +++ b/SmartDeviceLink/SDLPolicyDataParser.m @@ -0,0 +1,140 @@ +// +// PolicyDataParser.m +// + +#import "SDLPolicyDataParser.h" + + +@implementation SDLPolicyDataParser + +- (NSData *)unwrap:(NSData *)wrappedData { + NSData *decodedData = nil; + + @try { + NSError *errorJSONSerialization = nil; + NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:wrappedData options:kNilOptions error:&errorJSONSerialization]; + NSArray *array = dictionary[@"data"]; + NSString *base64EncodedString = array[0]; + + if ([NSData instancesRespondToSelector:@selector(initWithBase64EncodedString:options:)]) { + decodedData = [[NSData alloc] initWithBase64EncodedString:base64EncodedString options:0]; + } else { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + decodedData = [[NSData alloc] initWithBase64Encoding:base64EncodedString]; +#pragma clang diagnostic pop + } + } + @catch (NSException *exception) { + decodedData = nil; + NSLog(@"Error in PolicyDataParser::unwrap()"); + } + + return decodedData; +} + +- (void)parsePolicyData:(NSData *)data { + if (data == nil) { + return; + } + + @try { + Byte *bytes = (Byte *)data.bytes; + + Byte firstByte = bytes[0]; + self.protocolVersion = (firstByte & 0b11100000) >> 5; + self.isResponseRequired = (firstByte & 0b00010000) != 0; + self.isHighBandwidth = (firstByte & 0b00001000) != 0; + self.isSigned = (firstByte & 0b00000100) != 0; + self.isEncrypted = (firstByte & 0b00000010) != 0; + self.hasESN = (firstByte & 0b00000001) != 0; + + self.serviceType = bytes[1]; + + Byte thirdByte = bytes[2]; + self.commandType = (thirdByte & 0b11110000) >> 4; + self.CPUDestination = (thirdByte & 0b00001000) != 0; + self.encryptionKeyIndex = (thirdByte & 0b00000111); + + const int payloadSizeOffset = 3; + if (self.isHighBandwidth) { + self.payloadSize = ntohl(*(UInt32 *)(bytes + payloadSizeOffset)); + } else { + self.payloadSize = ntohs(*(UInt16 *)(bytes + payloadSizeOffset)); + } + + if (self.hasESN) { + int esnOffset = self.isHighBandwidth ? 7 : 5; + self.ESN = [NSData dataWithBytes:(bytes + esnOffset) length:8]; + } + + if (self.isHighBandwidth) { + int moduleMessageIdOffset = 7; + if (self.hasESN) + moduleMessageIdOffset += self.ESN.length; + self.moduleMessageId = ntohl(*(UInt32 *)(bytes + moduleMessageIdOffset)); + + int serverMessageIdOffset = 11; + if (self.hasESN) + serverMessageIdOffset += self.ESN.length; + self.serverMessageId = ntohl(*(UInt32 *)(bytes + serverMessageIdOffset)); + + int messageStatusOffset = 15; + if (self.hasESN) + messageStatusOffset += self.ESN.length; + self.messageStatus = bytes[messageStatusOffset]; + } + + if (self.isEncrypted) { + int ivOffset = 5; + if (self.isHighBandwidth) + ivOffset += 11; + if (self.hasESN) + ivOffset += self.ESN.length; + self.initializationVector = [NSData dataWithBytes:(bytes + ivOffset) length:16]; + } + + int payloadOffset = 5; + if (self.isHighBandwidth) + payloadOffset += 11; + if (self.hasESN) + payloadOffset += self.ESN.length; + if (self.isEncrypted) + payloadOffset += self.initializationVector.length; + self.payload = [NSData dataWithBytes:(bytes + payloadOffset) length:self.payloadSize]; + + if (self.isSigned) { + int signatureTagOffset = (int)data.length - 16; + self.signatureTag = [NSData dataWithBytes:(bytes + signatureTagOffset) length:16]; + } + + } + @catch (NSException *exception) { + NSLog(@"Error in PolicyDataParser::parsePolicyData()"); + } +} + +- (NSString *)description { + NSString *esnString = [[NSString alloc] initWithData:self.ESN encoding:NSUTF8StringEncoding]; + + NSMutableString *descriptionString = [NSMutableString stringWithFormat:@"Ver:%u; ", self.protocolVersion]; + [descriptionString appendFormat:@"RespReq:%u; ", self.isResponseRequired]; + [descriptionString appendFormat:@"HiBnd:%u; ", self.isHighBandwidth]; + [descriptionString appendFormat:@"Sign:%u; ", self.isSigned]; + [descriptionString appendFormat:@"Enc:%u; ", self.isEncrypted]; + [descriptionString appendFormat:@"HasESN:%u; ", self.hasESN]; + [descriptionString appendFormat:@"Svc:%u; ", self.serviceType]; + [descriptionString appendFormat:@"Cmd:%u; ", self.commandType]; + [descriptionString appendFormat:@"CPU:%u; ", self.CPUDestination]; + [descriptionString appendFormat:@"EncKey:%u; ", self.encryptionKeyIndex]; + [descriptionString appendFormat:@"sz:%u; ", (unsigned int)self.payloadSize]; + [descriptionString appendFormat:@"ESN:%@; ", esnString]; + [descriptionString appendFormat:@"mmid:%u; ", (unsigned int)self.moduleMessageId]; + [descriptionString appendFormat:@"smid:%u; ", (unsigned int)self.serverMessageId]; + [descriptionString appendFormat:@"status:%u; ", self.messageStatus]; + [descriptionString appendFormat:@"iv:%@; ", self.initializationVector]; + [descriptionString appendFormat:@"hmac:%@", self.signatureTag]; + return descriptionString; +} + +@end diff --git a/SmartDeviceLink/SDLPowerModeQualificationStatus.h b/SmartDeviceLink/SDLPowerModeQualificationStatus.h new file mode 100644 index 000000000..4e520196b --- /dev/null +++ b/SmartDeviceLink/SDLPowerModeQualificationStatus.h @@ -0,0 +1,18 @@ +// SDLPowerModeQualificationStatus.h +// + + +#import "SDLEnum.h" + +@interface SDLPowerModeQualificationStatus : SDLEnum { +} + ++ (SDLPowerModeQualificationStatus *)valueOf:(NSString *)value; ++ (NSArray *)values; + ++ (SDLPowerModeQualificationStatus *)POWER_MODE_UNDEFINED; ++ (SDLPowerModeQualificationStatus *)POWER_MODE_EVALUATION_IN_PROGRESS; ++ (SDLPowerModeQualificationStatus *)NOT_DEFINED; ++ (SDLPowerModeQualificationStatus *)POWER_MODE_OK; + +@end diff --git a/SmartDeviceLink/SDLPowerModeQualificationStatus.m b/SmartDeviceLink/SDLPowerModeQualificationStatus.m new file mode 100644 index 000000000..d820221e9 --- /dev/null +++ b/SmartDeviceLink/SDLPowerModeQualificationStatus.m @@ -0,0 +1,65 @@ +// SDLPowerModeQualificationStatus.m +// + + +#import "SDLPowerModeQualificationStatus.h" + +SDLPowerModeQualificationStatus *SDLPowerModeQualificationStatus_POWER_MODE_UNDEFINED = nil; +SDLPowerModeQualificationStatus *SDLPowerModeQualificationStatus_POWER_MODE_EVALUATION_IN_PROGRESS = nil; +SDLPowerModeQualificationStatus *SDLPowerModeQualificationStatus_NOT_DEFINED = nil; +SDLPowerModeQualificationStatus *SDLPowerModeQualificationStatus_POWER_MODE_OK = nil; + +NSArray *SDLPowerModeQualificationStatus_values = nil; + +@implementation SDLPowerModeQualificationStatus + ++ (SDLPowerModeQualificationStatus *)valueOf:(NSString *)value { + for (SDLPowerModeQualificationStatus *item in SDLPowerModeQualificationStatus.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLPowerModeQualificationStatus_values == nil) { + SDLPowerModeQualificationStatus_values = @[ + SDLPowerModeQualificationStatus.POWER_MODE_UNDEFINED, + SDLPowerModeQualificationStatus.POWER_MODE_EVALUATION_IN_PROGRESS, + SDLPowerModeQualificationStatus.NOT_DEFINED, + SDLPowerModeQualificationStatus.POWER_MODE_OK, + ]; + } + return SDLPowerModeQualificationStatus_values; +} + ++ (SDLPowerModeQualificationStatus *)POWER_MODE_UNDEFINED { + if (SDLPowerModeQualificationStatus_POWER_MODE_UNDEFINED == nil) { + SDLPowerModeQualificationStatus_POWER_MODE_UNDEFINED = [[SDLPowerModeQualificationStatus alloc] initWithValue:@"POWER_MODE_UNDEFINED"]; + } + return SDLPowerModeQualificationStatus_POWER_MODE_UNDEFINED; +} + ++ (SDLPowerModeQualificationStatus *)POWER_MODE_EVALUATION_IN_PROGRESS { + if (SDLPowerModeQualificationStatus_POWER_MODE_EVALUATION_IN_PROGRESS == nil) { + SDLPowerModeQualificationStatus_POWER_MODE_EVALUATION_IN_PROGRESS = [[SDLPowerModeQualificationStatus alloc] initWithValue:@"POWER_MODE_EVALUATION_IN_PROGRESS"]; + } + return SDLPowerModeQualificationStatus_POWER_MODE_EVALUATION_IN_PROGRESS; +} + ++ (SDLPowerModeQualificationStatus *)NOT_DEFINED { + if (SDLPowerModeQualificationStatus_NOT_DEFINED == nil) { + SDLPowerModeQualificationStatus_NOT_DEFINED = [[SDLPowerModeQualificationStatus alloc] initWithValue:@"NOT_DEFINED"]; + } + return SDLPowerModeQualificationStatus_NOT_DEFINED; +} + ++ (SDLPowerModeQualificationStatus *)POWER_MODE_OK { + if (SDLPowerModeQualificationStatus_POWER_MODE_OK == nil) { + SDLPowerModeQualificationStatus_POWER_MODE_OK = [[SDLPowerModeQualificationStatus alloc] initWithValue:@"POWER_MODE_OK"]; + } + return SDLPowerModeQualificationStatus_POWER_MODE_OK; +} + +@end diff --git a/SmartDeviceLink/SDLPowerModeStatus.h b/SmartDeviceLink/SDLPowerModeStatus.h new file mode 100644 index 000000000..8eb24fdb4 --- /dev/null +++ b/SmartDeviceLink/SDLPowerModeStatus.h @@ -0,0 +1,23 @@ +// SDLPowerModeStatus.h +// + + +#import "SDLEnum.h" + +@interface SDLPowerModeStatus : SDLEnum { +} + ++ (SDLPowerModeStatus *)valueOf:(NSString *)value; ++ (NSArray *)values; + ++ (SDLPowerModeStatus *)KEY_OUT; ++ (SDLPowerModeStatus *)KEY_RECENTLY_OUT; ++ (SDLPowerModeStatus *)KEY_APPROVED_0; ++ (SDLPowerModeStatus *)POST_ACCESORY_0; ++ (SDLPowerModeStatus *)ACCESORY_1; ++ (SDLPowerModeStatus *)POST_IGNITION_1; ++ (SDLPowerModeStatus *)IGNITION_ON_2; ++ (SDLPowerModeStatus *)RUNNING_2; ++ (SDLPowerModeStatus *)CRANK_3; + +@end diff --git a/SmartDeviceLink/SDLPowerModeStatus.m b/SmartDeviceLink/SDLPowerModeStatus.m new file mode 100644 index 000000000..efc46a094 --- /dev/null +++ b/SmartDeviceLink/SDLPowerModeStatus.m @@ -0,0 +1,110 @@ +// SDLPowerModeStatus.m +// + + +#import "SDLPowerModeStatus.h" + +SDLPowerModeStatus *SDLPowerModeStatus_KEY_OUT = nil; +SDLPowerModeStatus *SDLPowerModeStatus_KEY_RECENTLY_OUT = nil; +SDLPowerModeStatus *SDLPowerModeStatus_KEY_APPROVED_0 = nil; +SDLPowerModeStatus *SDLPowerModeStatus_POST_ACCESORY_0 = nil; +SDLPowerModeStatus *SDLPowerModeStatus_ACCESORY_1 = nil; +SDLPowerModeStatus *SDLPowerModeStatus_POST_IGNITION_1 = nil; +SDLPowerModeStatus *SDLPowerModeStatus_IGNITION_ON_2 = nil; +SDLPowerModeStatus *SDLPowerModeStatus_RUNNING_2 = nil; +SDLPowerModeStatus *SDLPowerModeStatus_CRANK_3 = nil; + +NSArray *SDLPowerModeStatus_values = nil; + +@implementation SDLPowerModeStatus + ++ (SDLPowerModeStatus *)valueOf:(NSString *)value { + for (SDLPowerModeStatus *item in SDLPowerModeStatus.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLPowerModeStatus_values == nil) { + SDLPowerModeStatus_values = @[ + SDLPowerModeStatus.KEY_OUT, + SDLPowerModeStatus.KEY_RECENTLY_OUT, + SDLPowerModeStatus.KEY_APPROVED_0, + SDLPowerModeStatus.POST_ACCESORY_0, + SDLPowerModeStatus.ACCESORY_1, + SDLPowerModeStatus.POST_IGNITION_1, + SDLPowerModeStatus.IGNITION_ON_2, + SDLPowerModeStatus.RUNNING_2, + SDLPowerModeStatus.CRANK_3, + ]; + } + return SDLPowerModeStatus_values; +} + ++ (SDLPowerModeStatus *)KEY_OUT { + if (SDLPowerModeStatus_KEY_OUT == nil) { + SDLPowerModeStatus_KEY_OUT = [[SDLPowerModeStatus alloc] initWithValue:@"KEY_OUT"]; + } + return SDLPowerModeStatus_KEY_OUT; +} + ++ (SDLPowerModeStatus *)KEY_RECENTLY_OUT { + if (SDLPowerModeStatus_KEY_RECENTLY_OUT == nil) { + SDLPowerModeStatus_KEY_RECENTLY_OUT = [[SDLPowerModeStatus alloc] initWithValue:@"KEY_RECENTLY_OUT"]; + } + return SDLPowerModeStatus_KEY_RECENTLY_OUT; +} + ++ (SDLPowerModeStatus *)KEY_APPROVED_0 { + if (SDLPowerModeStatus_KEY_APPROVED_0 == nil) { + SDLPowerModeStatus_KEY_APPROVED_0 = [[SDLPowerModeStatus alloc] initWithValue:@"KEY_APPROVED_0"]; + } + return SDLPowerModeStatus_KEY_APPROVED_0; +} + ++ (SDLPowerModeStatus *)POST_ACCESORY_0 { + if (SDLPowerModeStatus_POST_ACCESORY_0 == nil) { + SDLPowerModeStatus_POST_ACCESORY_0 = [[SDLPowerModeStatus alloc] initWithValue:@"POST_ACCESORY_0"]; + } + return SDLPowerModeStatus_POST_ACCESORY_0; +} + ++ (SDLPowerModeStatus *)ACCESORY_1 { + if (SDLPowerModeStatus_ACCESORY_1 == nil) { + SDLPowerModeStatus_ACCESORY_1 = [[SDLPowerModeStatus alloc] initWithValue:@"ACCESORY_1"]; + } + return SDLPowerModeStatus_ACCESORY_1; +} + ++ (SDLPowerModeStatus *)POST_IGNITION_1 { + if (SDLPowerModeStatus_POST_IGNITION_1 == nil) { + SDLPowerModeStatus_POST_IGNITION_1 = [[SDLPowerModeStatus alloc] initWithValue:@"POST_IGNITION_1"]; + } + return SDLPowerModeStatus_POST_IGNITION_1; +} + ++ (SDLPowerModeStatus *)IGNITION_ON_2 { + if (SDLPowerModeStatus_IGNITION_ON_2 == nil) { + SDLPowerModeStatus_IGNITION_ON_2 = [[SDLPowerModeStatus alloc] initWithValue:@"IGNITION_ON_2"]; + } + return SDLPowerModeStatus_IGNITION_ON_2; +} + ++ (SDLPowerModeStatus *)RUNNING_2 { + if (SDLPowerModeStatus_RUNNING_2 == nil) { + SDLPowerModeStatus_RUNNING_2 = [[SDLPowerModeStatus alloc] initWithValue:@"RUNNING_2"]; + } + return SDLPowerModeStatus_RUNNING_2; +} + ++ (SDLPowerModeStatus *)CRANK_3 { + if (SDLPowerModeStatus_CRANK_3 == nil) { + SDLPowerModeStatus_CRANK_3 = [[SDLPowerModeStatus alloc] initWithValue:@"CRANK_3"]; + } + return SDLPowerModeStatus_CRANK_3; +} + +@end diff --git a/SmartDeviceLink/SDLPredefinedLayout.h b/SmartDeviceLink/SDLPredefinedLayout.h new file mode 100644 index 000000000..7d061d449 --- /dev/null +++ b/SmartDeviceLink/SDLPredefinedLayout.h @@ -0,0 +1,34 @@ +// SDLPredefinedLayout.h +// + + +#import "SDLEnum.h" + +@interface SDLPredefinedLayout : SDLEnum { +} + ++ (SDLPredefinedLayout *)valueOf:(NSString *)value; ++ (NSArray *)values; + ++ (SDLPredefinedLayout *)DEFAULT; ++ (SDLPredefinedLayout *)MEDIA; ++ (SDLPredefinedLayout *)NON_MEDIA; ++ (SDLPredefinedLayout *)ONSCREEN_PRESETS; ++ (SDLPredefinedLayout *)NAV_FULLSCREEN_MAP; ++ (SDLPredefinedLayout *)NAV_LIST; ++ (SDLPredefinedLayout *)NAV_KEYBOARD; ++ (SDLPredefinedLayout *)GRAPHIC_WITH_TEXT; ++ (SDLPredefinedLayout *)TEXT_WITH_GRAPHIC; ++ (SDLPredefinedLayout *)TILES_ONLY; ++ (SDLPredefinedLayout *)TEXTBUTTONS_ONLY; ++ (SDLPredefinedLayout *)GRAPHIC_WITH_TILES; ++ (SDLPredefinedLayout *)TILES_WITH_GRAPHIC; ++ (SDLPredefinedLayout *)GRAPHIC_WITH_TEXT_AND_SOFTBUTTONS; ++ (SDLPredefinedLayout *)TEXT_AND_SOFTBUTTONS_WITH_GRAPHIC; ++ (SDLPredefinedLayout *)GRAPHIC_WITH_TEXTBUTTONS; ++ (SDLPredefinedLayout *)TEXTBUTTONS_WITH_GRAPHIC; ++ (SDLPredefinedLayout *)LARGE_GRAPHIC_WITH_SOFTBUTTONS; ++ (SDLPredefinedLayout *)DOUBLE_GRAPHIC_WITH_SOFTBUTTONS; ++ (SDLPredefinedLayout *)LARGE_GRAPHIC_ONLY; + +@end diff --git a/SmartDeviceLink/SDLPredefinedLayout.m b/SmartDeviceLink/SDLPredefinedLayout.m new file mode 100644 index 000000000..57dc2b384 --- /dev/null +++ b/SmartDeviceLink/SDLPredefinedLayout.m @@ -0,0 +1,209 @@ +// SDLPredefinedLayout.m +// + + +#import "SDLPredefinedLayout.h" + +SDLPredefinedLayout *SDLPredefinedLayout_DEFAULT = nil; +SDLPredefinedLayout *SDLPredefinedLayout_MEDIA = nil; +SDLPredefinedLayout *SDLPredefinedLayout_NON_MEDIA = nil; +SDLPredefinedLayout *SDLPredefinedLayout_ONSCREEN_PRESETS = nil; +SDLPredefinedLayout *SDLPredefinedLayout_NAV_FULLSCREEN_MAP = nil; +SDLPredefinedLayout *SDLPredefinedLayout_NAV_LIST = nil; +SDLPredefinedLayout *SDLPredefinedLayout_NAV_KEYBOARD = nil; +SDLPredefinedLayout *SDLPredefinedLayout_GRAPHIC_WITH_TEXT = nil; +SDLPredefinedLayout *SDLPredefinedLayout_TEXT_WITH_GRAPHIC = nil; +SDLPredefinedLayout *SDLPredefinedLayout_TILES_ONLY = nil; +SDLPredefinedLayout *SDLPredefinedLayout_TEXTBUTTONS_ONLY = nil; +SDLPredefinedLayout *SDLPredefinedLayout_GRAPHIC_WITH_TILES = nil; +SDLPredefinedLayout *SDLPredefinedLayout_TILES_WITH_GRAPHIC = nil; +SDLPredefinedLayout *SDLPredefinedLayout_GRAPHIC_WITH_TEXT_AND_SOFTBUTTONS = nil; +SDLPredefinedLayout *SDLPredefinedLayout_TEXT_AND_SOFTBUTTONS_WITH_GRAPHIC = nil; +SDLPredefinedLayout *SDLPredefinedLayout_GRAPHIC_WITH_TEXTBUTTONS = nil; +SDLPredefinedLayout *SDLPredefinedLayout_TEXTBUTTONS_WITH_GRAPHIC = nil; +SDLPredefinedLayout *SDLPredefinedLayout_LARGE_GRAPHIC_WITH_SOFTBUTTONS = nil; +SDLPredefinedLayout *SDLPredefinedLayout_DOUBLE_GRAPHIC_WITH_SOFTBUTTONS = nil; +SDLPredefinedLayout *SDLPredefinedLayout_LARGE_GRAPHIC_ONLY = nil; + +NSArray *SDLPredefinedLayout_values = nil; + +@implementation SDLPredefinedLayout + ++ (SDLPredefinedLayout *)valueOf:(NSString *)value { + for (SDLPredefinedLayout *item in SDLPredefinedLayout.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLPredefinedLayout_values == nil) { + SDLPredefinedLayout_values = @[ + SDLPredefinedLayout.DEFAULT, + SDLPredefinedLayout.MEDIA, + SDLPredefinedLayout.NON_MEDIA, + SDLPredefinedLayout.ONSCREEN_PRESETS, + SDLPredefinedLayout.NAV_FULLSCREEN_MAP, + SDLPredefinedLayout.NAV_LIST, + SDLPredefinedLayout.NAV_KEYBOARD, + SDLPredefinedLayout.GRAPHIC_WITH_TEXT, + SDLPredefinedLayout.TEXT_WITH_GRAPHIC, + SDLPredefinedLayout.TILES_ONLY, + SDLPredefinedLayout.TEXTBUTTONS_ONLY, + SDLPredefinedLayout.GRAPHIC_WITH_TILES, + SDLPredefinedLayout.TILES_WITH_GRAPHIC, + SDLPredefinedLayout.GRAPHIC_WITH_TEXT_AND_SOFTBUTTONS, + SDLPredefinedLayout.TEXT_AND_SOFTBUTTONS_WITH_GRAPHIC, + SDLPredefinedLayout.GRAPHIC_WITH_TEXTBUTTONS, + SDLPredefinedLayout.TEXTBUTTONS_WITH_GRAPHIC, + SDLPredefinedLayout.LARGE_GRAPHIC_WITH_SOFTBUTTONS, + SDLPredefinedLayout.DOUBLE_GRAPHIC_WITH_SOFTBUTTONS, + SDLPredefinedLayout.LARGE_GRAPHIC_ONLY, + ]; + } + return SDLPredefinedLayout_values; +} + ++ (SDLPredefinedLayout *)DEFAULT { + if (SDLPredefinedLayout_DEFAULT == nil) { + SDLPredefinedLayout_DEFAULT = [[SDLPredefinedLayout alloc] initWithValue:@"DEFAULT"]; + } + return SDLPredefinedLayout_DEFAULT; +} + ++ (SDLPredefinedLayout *)MEDIA { + if (SDLPredefinedLayout_MEDIA == nil) { + SDLPredefinedLayout_MEDIA = [[SDLPredefinedLayout alloc] initWithValue:@"MEDIA"]; + } + return SDLPredefinedLayout_MEDIA; +} + ++ (SDLPredefinedLayout *)NON_MEDIA { + if (SDLPredefinedLayout_NON_MEDIA == nil) { + SDLPredefinedLayout_NON_MEDIA = [[SDLPredefinedLayout alloc] initWithValue:@"NON-MEDIA"]; + } + return SDLPredefinedLayout_NON_MEDIA; +} + ++ (SDLPredefinedLayout *)ONSCREEN_PRESETS { + if (SDLPredefinedLayout_ONSCREEN_PRESETS == nil) { + SDLPredefinedLayout_ONSCREEN_PRESETS = [[SDLPredefinedLayout alloc] initWithValue:@"ONSCREEN_PRESETS"]; + } + return SDLPredefinedLayout_ONSCREEN_PRESETS; +} + ++ (SDLPredefinedLayout *)NAV_FULLSCREEN_MAP { + if (SDLPredefinedLayout_NAV_FULLSCREEN_MAP == nil) { + SDLPredefinedLayout_NAV_FULLSCREEN_MAP = [[SDLPredefinedLayout alloc] initWithValue:@"NAV_FULLSCREEN_MAP"]; + } + return SDLPredefinedLayout_NAV_FULLSCREEN_MAP; +} + ++ (SDLPredefinedLayout *)NAV_LIST { + if (SDLPredefinedLayout_NAV_LIST == nil) { + SDLPredefinedLayout_NAV_LIST = [[SDLPredefinedLayout alloc] initWithValue:@"NAV_LIST"]; + } + return SDLPredefinedLayout_NAV_LIST; +} + ++ (SDLPredefinedLayout *)NAV_KEYBOARD { + if (SDLPredefinedLayout_NAV_KEYBOARD == nil) { + SDLPredefinedLayout_NAV_KEYBOARD = [[SDLPredefinedLayout alloc] initWithValue:@"NAV_KEYBOARD"]; + } + return SDLPredefinedLayout_NAV_KEYBOARD; +} + ++ (SDLPredefinedLayout *)GRAPHIC_WITH_TEXT { + if (SDLPredefinedLayout_GRAPHIC_WITH_TEXT == nil) { + SDLPredefinedLayout_GRAPHIC_WITH_TEXT = [[SDLPredefinedLayout alloc] initWithValue:@"GRAPHIC_WITH_TEXT"]; + } + return SDLPredefinedLayout_GRAPHIC_WITH_TEXT; +} + ++ (SDLPredefinedLayout *)TEXT_WITH_GRAPHIC { + if (SDLPredefinedLayout_TEXT_WITH_GRAPHIC == nil) { + SDLPredefinedLayout_TEXT_WITH_GRAPHIC = [[SDLPredefinedLayout alloc] initWithValue:@"TEXT_WITH_GRAPHIC"]; + } + return SDLPredefinedLayout_TEXT_WITH_GRAPHIC; +} + ++ (SDLPredefinedLayout *)TILES_ONLY { + if (SDLPredefinedLayout_TILES_ONLY == nil) { + SDLPredefinedLayout_TILES_ONLY = [[SDLPredefinedLayout alloc] initWithValue:@"TILES_ONLY"]; + } + return SDLPredefinedLayout_TILES_ONLY; +} + ++ (SDLPredefinedLayout *)TEXTBUTTONS_ONLY { + if (SDLPredefinedLayout_TEXTBUTTONS_ONLY == nil) { + SDLPredefinedLayout_TEXTBUTTONS_ONLY = [[SDLPredefinedLayout alloc] initWithValue:@"TEXTBUTTONS_ONLY"]; + } + return SDLPredefinedLayout_TEXTBUTTONS_ONLY; +} + ++ (SDLPredefinedLayout *)GRAPHIC_WITH_TILES { + if (SDLPredefinedLayout_GRAPHIC_WITH_TILES == nil) { + SDLPredefinedLayout_GRAPHIC_WITH_TILES = [[SDLPredefinedLayout alloc] initWithValue:@"GRAPHIC_WITH_TILES"]; + } + return SDLPredefinedLayout_GRAPHIC_WITH_TILES; +} + ++ (SDLPredefinedLayout *)TILES_WITH_GRAPHIC { + if (SDLPredefinedLayout_TILES_WITH_GRAPHIC == nil) { + SDLPredefinedLayout_TILES_WITH_GRAPHIC = [[SDLPredefinedLayout alloc] initWithValue:@"TILES_WITH_GRAPHIC"]; + } + return SDLPredefinedLayout_TILES_WITH_GRAPHIC; +} + ++ (SDLPredefinedLayout *)GRAPHIC_WITH_TEXT_AND_SOFTBUTTONS { + if (SDLPredefinedLayout_GRAPHIC_WITH_TEXT_AND_SOFTBUTTONS == nil) { + SDLPredefinedLayout_GRAPHIC_WITH_TEXT_AND_SOFTBUTTONS = [[SDLPredefinedLayout alloc] initWithValue:@"GRAPHIC_WITH_TEXT_AND_SOFTBUTTONS"]; + } + return SDLPredefinedLayout_GRAPHIC_WITH_TEXT_AND_SOFTBUTTONS; +} + ++ (SDLPredefinedLayout *)TEXT_AND_SOFTBUTTONS_WITH_GRAPHIC { + if (SDLPredefinedLayout_TEXT_AND_SOFTBUTTONS_WITH_GRAPHIC == nil) { + SDLPredefinedLayout_TEXT_AND_SOFTBUTTONS_WITH_GRAPHIC = [[SDLPredefinedLayout alloc] initWithValue:@"TEXT_AND_SOFTBUTTONS_WITH_GRAPHIC"]; + } + return SDLPredefinedLayout_TEXT_AND_SOFTBUTTONS_WITH_GRAPHIC; +} + ++ (SDLPredefinedLayout *)GRAPHIC_WITH_TEXTBUTTONS { + if (SDLPredefinedLayout_GRAPHIC_WITH_TEXTBUTTONS == nil) { + SDLPredefinedLayout_GRAPHIC_WITH_TEXTBUTTONS = [[SDLPredefinedLayout alloc] initWithValue:@"GRAPHIC_WITH_TEXTBUTTONS"]; + } + return SDLPredefinedLayout_GRAPHIC_WITH_TEXTBUTTONS; +} + ++ (SDLPredefinedLayout *)TEXTBUTTONS_WITH_GRAPHIC { + if (SDLPredefinedLayout_TEXTBUTTONS_WITH_GRAPHIC == nil) { + SDLPredefinedLayout_TEXTBUTTONS_WITH_GRAPHIC = [[SDLPredefinedLayout alloc] initWithValue:@"TEXTBUTTONS_WITH_GRAPHIC"]; + } + return SDLPredefinedLayout_TEXTBUTTONS_WITH_GRAPHIC; +} + ++ (SDLPredefinedLayout *)LARGE_GRAPHIC_WITH_SOFTBUTTONS { + if (SDLPredefinedLayout_LARGE_GRAPHIC_WITH_SOFTBUTTONS == nil) { + SDLPredefinedLayout_LARGE_GRAPHIC_WITH_SOFTBUTTONS = [[SDLPredefinedLayout alloc] initWithValue:@"LARGE_GRAPHIC_WITH_SOFTBUTTONS"]; + } + return SDLPredefinedLayout_LARGE_GRAPHIC_WITH_SOFTBUTTONS; +} + ++ (SDLPredefinedLayout *)DOUBLE_GRAPHIC_WITH_SOFTBUTTONS { + if (SDLPredefinedLayout_DOUBLE_GRAPHIC_WITH_SOFTBUTTONS == nil) { + SDLPredefinedLayout_DOUBLE_GRAPHIC_WITH_SOFTBUTTONS = [[SDLPredefinedLayout alloc] initWithValue:@"DOUBLE_GRAPHIC_WITH_SOFTBUTTONS"]; + } + return SDLPredefinedLayout_DOUBLE_GRAPHIC_WITH_SOFTBUTTONS; +} + ++ (SDLPredefinedLayout *)LARGE_GRAPHIC_ONLY { + if (SDLPredefinedLayout_LARGE_GRAPHIC_ONLY == nil) { + SDLPredefinedLayout_LARGE_GRAPHIC_ONLY = [[SDLPredefinedLayout alloc] initWithValue:@"LARGE_GRAPHIC_ONLY"]; + } + return SDLPredefinedLayout_LARGE_GRAPHIC_ONLY; +} + +@end diff --git a/SmartDeviceLink/SDLPrerecordedSpeech.h b/SmartDeviceLink/SDLPrerecordedSpeech.h new file mode 100644 index 000000000..85934237a --- /dev/null +++ b/SmartDeviceLink/SDLPrerecordedSpeech.h @@ -0,0 +1,19 @@ +// SDLPrerecordedSpeech.h +// + + +#import "SDLEnum.h" + +@interface SDLPrerecordedSpeech : SDLEnum { +} + ++ (SDLPrerecordedSpeech *)valueOf:(NSString *)value; ++ (NSArray *)values; + ++ (SDLPrerecordedSpeech *)HELP_JINGLE; ++ (SDLPrerecordedSpeech *)INITIAL_JINGLE; ++ (SDLPrerecordedSpeech *)LISTEN_JINGLE; ++ (SDLPrerecordedSpeech *)POSITIVE_JINGLE; ++ (SDLPrerecordedSpeech *)NEGATIVE_JINGLE; + +@end diff --git a/SmartDeviceLink/SDLPrerecordedSpeech.m b/SmartDeviceLink/SDLPrerecordedSpeech.m new file mode 100644 index 000000000..676645f76 --- /dev/null +++ b/SmartDeviceLink/SDLPrerecordedSpeech.m @@ -0,0 +1,74 @@ +// SDLPrerecordedSpeech.m +// + + +#import "SDLPrerecordedSpeech.h" + +SDLPrerecordedSpeech *SDLPrerecordedSpeech_HELP_JINGLE = nil; +SDLPrerecordedSpeech *SDLPrerecordedSpeech_INITIAL_JINGLE = nil; +SDLPrerecordedSpeech *SDLPrerecordedSpeech_LISTEN_JINGLE = nil; +SDLPrerecordedSpeech *SDLPrerecordedSpeech_POSITIVE_JINGLE = nil; +SDLPrerecordedSpeech *SDLPrerecordedSpeech_NEGATIVE_JINGLE = nil; + +NSArray *SDLPrerecordedSpeech_values = nil; + +@implementation SDLPrerecordedSpeech + ++ (SDLPrerecordedSpeech *)valueOf:(NSString *)value { + for (SDLPrerecordedSpeech *item in SDLPrerecordedSpeech.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLPrerecordedSpeech_values == nil) { + SDLPrerecordedSpeech_values = @[ + SDLPrerecordedSpeech.HELP_JINGLE, + SDLPrerecordedSpeech.INITIAL_JINGLE, + SDLPrerecordedSpeech.LISTEN_JINGLE, + SDLPrerecordedSpeech.POSITIVE_JINGLE, + SDLPrerecordedSpeech.NEGATIVE_JINGLE, + ]; + } + return SDLPrerecordedSpeech_values; +} + ++ (SDLPrerecordedSpeech *)HELP_JINGLE { + if (SDLPrerecordedSpeech_HELP_JINGLE == nil) { + SDLPrerecordedSpeech_HELP_JINGLE = [[SDLPrerecordedSpeech alloc] initWithValue:@"HELP_JINGLE"]; + } + return SDLPrerecordedSpeech_HELP_JINGLE; +} + ++ (SDLPrerecordedSpeech *)INITIAL_JINGLE { + if (SDLPrerecordedSpeech_INITIAL_JINGLE == nil) { + SDLPrerecordedSpeech_INITIAL_JINGLE = [[SDLPrerecordedSpeech alloc] initWithValue:@"INITIAL_JINGLE"]; + } + return SDLPrerecordedSpeech_INITIAL_JINGLE; +} + ++ (SDLPrerecordedSpeech *)LISTEN_JINGLE { + if (SDLPrerecordedSpeech_LISTEN_JINGLE == nil) { + SDLPrerecordedSpeech_LISTEN_JINGLE = [[SDLPrerecordedSpeech alloc] initWithValue:@"LISTEN_JINGLE"]; + } + return SDLPrerecordedSpeech_LISTEN_JINGLE; +} + ++ (SDLPrerecordedSpeech *)POSITIVE_JINGLE { + if (SDLPrerecordedSpeech_POSITIVE_JINGLE == nil) { + SDLPrerecordedSpeech_POSITIVE_JINGLE = [[SDLPrerecordedSpeech alloc] initWithValue:@"POSITIVE_JINGLE"]; + } + return SDLPrerecordedSpeech_POSITIVE_JINGLE; +} + ++ (SDLPrerecordedSpeech *)NEGATIVE_JINGLE { + if (SDLPrerecordedSpeech_NEGATIVE_JINGLE == nil) { + SDLPrerecordedSpeech_NEGATIVE_JINGLE = [[SDLPrerecordedSpeech alloc] initWithValue:@"NEGATIVE_JINGLE"]; + } + return SDLPrerecordedSpeech_NEGATIVE_JINGLE; +} + +@end diff --git a/SmartDeviceLink/SDLPresetBankCapabilities.h b/SmartDeviceLink/SDLPresetBankCapabilities.h new file mode 100644 index 000000000..edf544f8b --- /dev/null +++ b/SmartDeviceLink/SDLPresetBankCapabilities.h @@ -0,0 +1,33 @@ +// SDLPresetBankCapabilities.h +// + + +#import "SDLRPCMessage.h" + +/** + * Contains information about on-screen preset capabilities. + * + * @since SDL 2.0 + */ +@interface SDLPresetBankCapabilities : SDLRPCStruct { +} + +/** + * @abstract Constructs a newly allocated SDLPresetBankCapabilities object + */ +- (instancetype)init; + +/** + * @abstract Constructs a newly allocated SDLPresetBankCapabilities object indicated by the dictionary parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract If Onscreen custom presets are available. + * + * Required, Boolean + */ +@property (strong) NSNumber *onScreenPresetsAvailable; + +@end diff --git a/SmartDeviceLink/SDLPresetBankCapabilities.m b/SmartDeviceLink/SDLPresetBankCapabilities.m new file mode 100644 index 000000000..7654aa61d --- /dev/null +++ b/SmartDeviceLink/SDLPresetBankCapabilities.m @@ -0,0 +1,35 @@ +// SDLPresetBankCapabilities.m +// + + +#import "SDLPresetBankCapabilities.h" + +#import "SDLNames.h" + +@implementation SDLPresetBankCapabilities + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setOnScreenPresetsAvailable:(NSNumber *)onScreenPresetsAvailable { + if (onScreenPresetsAvailable != nil) { + [store setObject:onScreenPresetsAvailable forKey:NAMES_onScreenPresetsAvailable]; + } else { + [store removeObjectForKey:NAMES_onScreenPresetsAvailable]; + } +} + +- (NSNumber *)onScreenPresetsAvailable { + return [store objectForKey:NAMES_onScreenPresetsAvailable]; +} + +@end diff --git a/SmartDeviceLink/SDLPrimaryAudioSource.h b/SmartDeviceLink/SDLPrimaryAudioSource.h new file mode 100644 index 000000000..81e9a2257 --- /dev/null +++ b/SmartDeviceLink/SDLPrimaryAudioSource.h @@ -0,0 +1,72 @@ +// SDLPrimaryAudioSource.h +// + + +#import "SDLEnum.h" + +/** + * Reflects the current primary audio source of SDL (if selected). + * + * @since SDL 2.0 + */ +@interface SDLPrimaryAudioSource : SDLEnum { +} + +/** + * @abstract get SDLPrimaryAudioSource according value string + * + * @param value String value to retrieve the object enum for + * + * @return SDLPrimaryAudioSource object + */ ++ (SDLPrimaryAudioSource *)valueOf:(NSString *)value; + +/** + * @abstract declare an array to store all possible SDLPrimaryAudioSource values + * @return the array + */ ++ (NSArray *)values; + +/** + * @abstract Currently no source selected + * @return the current primary audio source: *NO_SOURCE_SELECTED* + */ ++ (SDLPrimaryAudioSource *)NO_SOURCE_SELECTED; + +/** + * @abstract USB is current source + * @return the current primary audio source: *USB* + */ ++ (SDLPrimaryAudioSource *)USB; + +/** + * @abstract USB2 is current source + * @return the current primary audio source: *USB2* + */ ++ (SDLPrimaryAudioSource *)USB2; + +/** + * @abstract Bluetooth Stereo is current source + * @return the current primary audio source: *BLUETOOTH_STEREO_BTST* + */ ++ (SDLPrimaryAudioSource *)BLUETOOTH_STEREO_BTST; + +/** + * @abstract Line in is current source + * @return the current primary audio source: *LINE_IN* + */ ++ (SDLPrimaryAudioSource *)LINE_IN; + +/** + * @abstract iPod is current source + * @return the current primary audio source: *IPOD* + */ ++ (SDLPrimaryAudioSource *)IPOD; + +/** + * @abstract Mobile app is current source + * @return the current primary audio source: *MOBILE_APP* + */ ++ (SDLPrimaryAudioSource *)MOBILE_APP; + +@end diff --git a/SmartDeviceLink/SDLPrimaryAudioSource.m b/SmartDeviceLink/SDLPrimaryAudioSource.m new file mode 100644 index 000000000..4293411a8 --- /dev/null +++ b/SmartDeviceLink/SDLPrimaryAudioSource.m @@ -0,0 +1,92 @@ +// SDLPrimaryAudioSource.m +// + + +#import "SDLPrimaryAudioSource.h" + +SDLPrimaryAudioSource *SDLPrimaryAudioSource_NO_SOURCE_SELECTED = nil; +SDLPrimaryAudioSource *SDLPrimaryAudioSource_USB = nil; +SDLPrimaryAudioSource *SDLPrimaryAudioSource_USB2 = nil; +SDLPrimaryAudioSource *SDLPrimaryAudioSource_BLUETOOTH_STEREO_BTST = nil; +SDLPrimaryAudioSource *SDLPrimaryAudioSource_LINE_IN = nil; +SDLPrimaryAudioSource *SDLPrimaryAudioSource_IPOD = nil; +SDLPrimaryAudioSource *SDLPrimaryAudioSource_MOBILE_APP = nil; + +NSArray *SDLPrimaryAudioSource_values = nil; + +@implementation SDLPrimaryAudioSource + ++ (SDLPrimaryAudioSource *)valueOf:(NSString *)value { + for (SDLPrimaryAudioSource *item in SDLPrimaryAudioSource.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLPrimaryAudioSource_values == nil) { + SDLPrimaryAudioSource_values = @[ + SDLPrimaryAudioSource.NO_SOURCE_SELECTED, + SDLPrimaryAudioSource.USB, + SDLPrimaryAudioSource.USB2, + SDLPrimaryAudioSource.BLUETOOTH_STEREO_BTST, + SDLPrimaryAudioSource.LINE_IN, + SDLPrimaryAudioSource.IPOD, + SDLPrimaryAudioSource.MOBILE_APP, + ]; + } + return SDLPrimaryAudioSource_values; +} + ++ (SDLPrimaryAudioSource *)NO_SOURCE_SELECTED { + if (SDLPrimaryAudioSource_NO_SOURCE_SELECTED == nil) { + SDLPrimaryAudioSource_NO_SOURCE_SELECTED = [[SDLPrimaryAudioSource alloc] initWithValue:@"NO_SOURCE_SELECTED"]; + } + return SDLPrimaryAudioSource_NO_SOURCE_SELECTED; +} + ++ (SDLPrimaryAudioSource *)USB { + if (SDLPrimaryAudioSource_USB == nil) { + SDLPrimaryAudioSource_USB = [[SDLPrimaryAudioSource alloc] initWithValue:@"USB"]; + } + return SDLPrimaryAudioSource_USB; +} + ++ (SDLPrimaryAudioSource *)USB2 { + if (SDLPrimaryAudioSource_USB2 == nil) { + SDLPrimaryAudioSource_USB2 = [[SDLPrimaryAudioSource alloc] initWithValue:@"USB2"]; + } + return SDLPrimaryAudioSource_USB2; +} + ++ (SDLPrimaryAudioSource *)BLUETOOTH_STEREO_BTST { + if (SDLPrimaryAudioSource_BLUETOOTH_STEREO_BTST == nil) { + SDLPrimaryAudioSource_BLUETOOTH_STEREO_BTST = [[SDLPrimaryAudioSource alloc] initWithValue:@"BLUETOOTH_STEREO_BTST"]; + } + return SDLPrimaryAudioSource_BLUETOOTH_STEREO_BTST; +} + ++ (SDLPrimaryAudioSource *)LINE_IN { + if (SDLPrimaryAudioSource_LINE_IN == nil) { + SDLPrimaryAudioSource_LINE_IN = [[SDLPrimaryAudioSource alloc] initWithValue:@"LINE_IN"]; + } + return SDLPrimaryAudioSource_LINE_IN; +} + ++ (SDLPrimaryAudioSource *)IPOD { + if (SDLPrimaryAudioSource_IPOD == nil) { + SDLPrimaryAudioSource_IPOD = [[SDLPrimaryAudioSource alloc] initWithValue:@"IPOD"]; + } + return SDLPrimaryAudioSource_IPOD; +} + ++ (SDLPrimaryAudioSource *)MOBILE_APP { + if (SDLPrimaryAudioSource_MOBILE_APP == nil) { + SDLPrimaryAudioSource_MOBILE_APP = [[SDLPrimaryAudioSource alloc] initWithValue:@"MOBILE_APP"]; + } + return SDLPrimaryAudioSource_MOBILE_APP; +} + +@end diff --git a/SmartDeviceLink/SDLPrioritizedObjectCollection.h b/SmartDeviceLink/SDLPrioritizedObjectCollection.h new file mode 100644 index 000000000..8cf90c805 --- /dev/null +++ b/SmartDeviceLink/SDLPrioritizedObjectCollection.h @@ -0,0 +1,27 @@ +// +// SDLPrioritizedOutputCollection.h +// SmartDeviceLink +// + +#import <Foundation/Foundation.h> + +@interface SDLPrioritizedObjectCollection : NSObject + +/** + * Add a new object to a push-pop collection. The object will be added in a location based on the priority passed in. + * + * A lower priority number is considered to be "higher". This is because this class is generally used with RPC service numbers, and lower services preempt higher ones. + * + * @param object The object to be added to the priority collection + * @param priority The priority to use when determining the location of the object in the collection. A lower number is considered a higher priority + */ +- (void)addObject:(id)object withPriority:(NSInteger)priority; + +/** + * Retreive the highest priority object from the collection. This also removes the object. + * + * @return The highest priority object retrieved from the collection. + */ +- (id)nextObject; + +@end diff --git a/SmartDeviceLink/SDLPrioritizedObjectCollection.m b/SmartDeviceLink/SDLPrioritizedObjectCollection.m new file mode 100644 index 000000000..637596d14 --- /dev/null +++ b/SmartDeviceLink/SDLPrioritizedObjectCollection.m @@ -0,0 +1,66 @@ +// +// SDLPrioritizedOutputCollection.m +// SmartDeviceLink +// + +#import "SDLPrioritizedObjectCollection.h" +#import "SDLObjectWithPriority.h" + + +@interface SDLPrioritizedObjectCollection () { + NSMutableArray *privateArray; +} +@end + + +@implementation SDLPrioritizedObjectCollection + +- (instancetype)init { + self = [super init]; + if (self) { + privateArray = [NSMutableArray new]; + } + return self; +} + +- (void)addObject:(id)object withPriority:(NSInteger)priority { + if (object == nil || [[NSNull null] isEqual:object]) { + return; + } + + SDLObjectWithPriority *newWrapper = [SDLObjectWithPriority objectWithObject:object priority:priority]; + + @synchronized(privateArray) { + // Find correct place to insert. + // Sorted in descending order. + BOOL lowerPriorityFound = NO; + NSInteger currentCount = privateArray.count; + for (int x = 0; x < currentCount; x++) { + SDLObjectWithPriority *o = privateArray[x]; + if (o.priority <= priority) { + lowerPriorityFound = YES; + [privateArray insertObject:newWrapper atIndex:x]; + break; + } + } + if (!lowerPriorityFound) { + [privateArray addObject:newWrapper]; + } + } +} + +- (instancetype)nextObject { + if (privateArray.count == 0) { + return nil; + } + + SDLObjectWithPriority *obj = nil; + @synchronized(privateArray) { + obj = (SDLObjectWithPriority *)[privateArray lastObject]; + [privateArray removeLastObject]; + } + + return obj.object; +} + +@end diff --git a/SmartDeviceLink/SDLProtocol.h b/SmartDeviceLink/SDLProtocol.h new file mode 100644 index 000000000..9c4505d2d --- /dev/null +++ b/SmartDeviceLink/SDLProtocol.h @@ -0,0 +1,21 @@ +// SDLSmartDeviceLinkProtocol.h +// + +#import "SDLAbstractProtocol.h" +@class SDLProtocolHeader; +@class SDLProtocolRecievedMessageRouter; + + +@interface SDLProtocol : SDLAbstractProtocol <SDLProtocolListener> + +// Sending +- (void)sendStartSessionWithType:(SDLServiceType)serviceType; +- (void)sendEndSessionWithType:(SDLServiceType)serviceType; +- (void)sendRPC:(SDLRPCMessage *)message; +- (void)sendRPCRequest:(SDLRPCRequest *)rpcRequest __deprecated_msg(("Use sendRPC: instead")); +- (void)sendRawData:(NSData *)data withServiceType:(SDLServiceType)serviceType; + +// Recieving +- (void)handleBytesFromTransport:(NSData *)receivedData; + +@end diff --git a/SmartDeviceLink/SDLProtocol.m b/SmartDeviceLink/SDLProtocol.m new file mode 100644 index 000000000..bb6db1814 --- /dev/null +++ b/SmartDeviceLink/SDLProtocol.m @@ -0,0 +1,422 @@ +// SDLProtocol.m +// + + +#import "SDLFunctionID.h" +#import "SDLJsonEncoder.h" + +#import "SDLAbstractTransport.h" +#import "SDLDebugTool.h" +#import "SDLGlobals.h" +#import "SDLPrioritizedObjectCollection.h" +#import "SDLProtocol.h" +#import "SDLProtocolHeader.h" +#import "SDLProtocolMessage.h" +#import "SDLProtocolMessageDisassembler.h" +#import "SDLProtocolReceivedMessageRouter.h" +#import "SDLRPCNotification.h" +#import "SDLRPCPayload.h" +#import "SDLRPCRequest.h" +#import "SDLRPCResponse.h" +#import "SDLTimer.h" +#import "SDLV2ProtocolHeader.h" + + +@interface SDLProtocol () { + UInt32 _messageID; + dispatch_queue_t _receiveQueue; + dispatch_queue_t _sendQueue; + SDLPrioritizedObjectCollection *_prioritizedCollection; + NSMutableDictionary *_sessionIDs; + BOOL _alreadyDestructed; +} + +@property (assign) UInt8 sessionID; +@property (strong) NSMutableData *receiveBuffer; +@property (strong) SDLProtocolReceivedMessageRouter *messageRouter; +@end + + +@implementation SDLProtocol + +- (instancetype)init { + if (self = [super init]) { + _messageID = 0; + _sessionID = 0; + _receiveQueue = dispatch_queue_create("com.sdl.protocol.receive", DISPATCH_QUEUE_SERIAL); + _sendQueue = dispatch_queue_create("com.sdl.protocol.transmit", DISPATCH_QUEUE_SERIAL); + _prioritizedCollection = [[SDLPrioritizedObjectCollection alloc] init]; + _sessionIDs = [NSMutableDictionary new]; + _messageRouter = [[SDLProtocolReceivedMessageRouter alloc] init]; + _messageRouter.delegate = self; + } + + return self; +} + +- (void)sdl_storeSessionID:(UInt8)sessionID forServiceType:(SDLServiceType)serviceType { + _sessionIDs[@(serviceType)] = @(sessionID); +} + +- (void)sdl_removeSessionIdForServiceType:(SDLServiceType)serviceType { + [_sessionIDs removeObjectForKey:@(serviceType)]; +} + +- (UInt8)sdl_retrieveSessionIDforServiceType:(SDLServiceType)serviceType { + NSNumber *number = _sessionIDs[@(serviceType)]; + if (!number) { + NSString *logMessage = [NSString stringWithFormat:@"Warning: Tried to retrieve sessionID for serviceType %i, but no sessionID is saved for that service type.", serviceType]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_Protocol toOutput:SDLDebugOutput_File | SDLDebugOutput_DeviceConsole toGroup:self.debugConsoleGroupName]; + } + + return (number ? [number unsignedCharValue] : 0); +} + +- (void)sendStartSessionWithType:(SDLServiceType)serviceType { + SDLProtocolHeader *header = [SDLProtocolHeader headerForVersion:[SDLGlobals globals].protocolVersion]; + switch (serviceType) { + case SDLServiceType_RPC: { + // Need a different header for starting the RPC service + header = [SDLProtocolHeader headerForVersion:1]; + if ([self sdl_retrieveSessionIDforServiceType:SDLServiceType_RPC]) { + header.sessionID = [self sdl_retrieveSessionIDforServiceType:SDLServiceType_RPC]; + } + } break; + default: { + header.sessionID = self.sessionID; + } break; + } + header.frameType = SDLFrameType_Control; + header.serviceType = serviceType; + header.frameData = SDLFrameData_StartSession; + + SDLProtocolMessage *message = [SDLProtocolMessage messageWithHeader:header andPayload:nil]; + [self sendDataToTransport:message.data withPriority:serviceType]; +} + +- (void)sendEndSessionWithType:(SDLServiceType)serviceType { + SDLProtocolHeader *header = [SDLProtocolHeader headerForVersion:[SDLGlobals globals].protocolVersion]; + header.frameType = SDLFrameType_Control; + header.serviceType = serviceType; + header.frameData = SDLFrameData_EndSession; + header.sessionID = [self sdl_retrieveSessionIDforServiceType:serviceType]; + + SDLProtocolMessage *message = [SDLProtocolMessage messageWithHeader:header andPayload:nil]; + [self sendDataToTransport:message.data withPriority:serviceType]; +} + +- (void)sendRPC:(SDLRPCMessage *)message { + NSParameterAssert(message != nil); + + NSData *jsonData = [[SDLJsonEncoder instance] encodeDictionary:[message serializeAsDictionary:[SDLGlobals globals].protocolVersion]]; + NSData *messagePayload = nil; + + NSString *logMessage = [NSString stringWithFormat:@"%@", message]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + + // Build the message payload. Include the binary header if necessary + // VERSION DEPENDENT CODE + switch ([SDLGlobals globals].protocolVersion) { + case 1: { + // No binary header in version 1 + messagePayload = jsonData; + } break; + case 2: // Fallthrough + case 3: // Fallthrough + case 4: { + // Build a binary header + // Serialize the RPC data into an NSData + SDLRPCPayload *rpcPayload = [[SDLRPCPayload alloc] init]; + rpcPayload.functionID = [[[[SDLFunctionID alloc] init] getFunctionID:[message getFunctionName]] intValue]; + rpcPayload.jsonData = jsonData; + rpcPayload.binaryData = message.bulkData; + + // If it's a request or a response, we need to pull out the correlation ID, so we'll downcast + if ([message isKindOfClass:SDLRPCRequest.class]) { + rpcPayload.rpcType = SDLRPCMessageTypeRequest; + rpcPayload.correlationID = [((SDLRPCRequest *)message).correlationID intValue]; + } else if ([message isKindOfClass:SDLRPCResponse.class]) { + rpcPayload.rpcType = SDLRPCMessageTypeResponse; + rpcPayload.correlationID = [((SDLRPCResponse *)message).correlationID intValue]; + } else if ([message isKindOfClass:[SDLRPCNotification class]]) { + rpcPayload.rpcType = SDLRPCMessageTypeNotification; + } else { + NSAssert(NO, @"Unknown message type attempted to send. Type: %@", [message class]); + return; + } + + messagePayload = rpcPayload.data; + } break; + default: { + NSAssert(NO, @"Attempting to send an RPC based on an unknown version number: %@, message: %@", @([SDLGlobals globals].protocolVersion), message); + } break; + } + + // Build the protocol level header & message + SDLProtocolHeader *header = [SDLProtocolHeader headerForVersion:[SDLGlobals globals].protocolVersion]; + header.frameType = SDLFrameType_Single; + header.serviceType = (message.bulkData.length <= 0) ? SDLServiceType_RPC : SDLServiceType_BulkData; + header.frameData = SDLFrameData_SingleFrame; + header.sessionID = [self sdl_retrieveSessionIDforServiceType:SDLServiceType_RPC]; + header.bytesInPayload = (UInt32)messagePayload.length; + + // V2+ messages need to have message ID property set. + if ([SDLGlobals globals].protocolVersion >= 2) { + [((SDLV2ProtocolHeader *)header) setMessageID:++_messageID]; + } + + + SDLProtocolMessage *protocolMessage = [SDLProtocolMessage messageWithHeader:header andPayload:messagePayload]; + + // See if the message is small enough to send in one transmission. If not, break it up into smaller messages and send. + if (protocolMessage.size < [SDLGlobals globals].maxMTUSize) { + [self logRPCSend:protocolMessage]; + [self sendDataToTransport:protocolMessage.data withPriority:SDLServiceType_RPC]; + } else { + NSArray *messages = [SDLProtocolMessageDisassembler disassemble:protocolMessage withLimit:[SDLGlobals globals].maxMTUSize]; + for (SDLProtocolMessage *smallerMessage in messages) { + [self logRPCSend:smallerMessage]; + [self sendDataToTransport:smallerMessage.data withPriority:SDLServiceType_RPC]; + } + } +} + +// SDLRPCRequest in from app -> SDLProtocolMessage out to transport layer. +- (void)sendRPCRequest:(SDLRPCRequest *)rpcRequest { + [self sendRPC:rpcRequest]; +} + +- (void)logRPCSend:(SDLProtocolMessage *)message { + NSString *logMessage = [NSString stringWithFormat:@"Sending : %@", message]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_Protocol toOutput:SDLDebugOutput_File | SDLDebugOutput_DeviceConsole toGroup:self.debugConsoleGroupName]; +} + +// Use for normal messages +- (void)sendDataToTransport:(NSData *)data withPriority:(NSInteger)priority { + [_prioritizedCollection addObject:data withPriority:priority]; + + dispatch_async(_sendQueue, ^{ + NSData *dataToTransmit = nil; + while (dataToTransmit = (NSData *)[_prioritizedCollection nextObject]) { + [self.transport sendData:dataToTransmit]; + }; + }); +} + +// Turn received bytes into message objects. +- (void)handleBytesFromTransport:(NSData *)receivedData { + // Initialize the receive buffer which will contain bytes while messages are constructed. + if (self.receiveBuffer == nil) { + self.receiveBuffer = [NSMutableData dataWithCapacity:(4 * [SDLGlobals globals].maxMTUSize)]; + } + + // Save the data + [self.receiveBuffer appendData:receivedData]; + + [self processMessages]; +} + +- (void)processMessages { + NSMutableString *logMessage = [[NSMutableString alloc] init]; + UInt8 incomingVersion = [SDLProtocolMessage determineVersion:self.receiveBuffer]; + + // If we have enough bytes, create the header. + SDLProtocolHeader *header = [SDLProtocolHeader headerForVersion:incomingVersion]; + NSUInteger headerSize = header.size; + if (self.receiveBuffer.length >= headerSize) { + [header parse:self.receiveBuffer]; + } else { + return; + } + + // If we have enough bytes, finish building the message. + SDLProtocolMessage *message = nil; + NSUInteger payloadSize = header.bytesInPayload; + NSUInteger messageSize = headerSize + payloadSize; + if (self.receiveBuffer.length >= messageSize) { + NSUInteger payloadOffset = headerSize; + NSUInteger payloadLength = payloadSize; + NSData *payload = [self.receiveBuffer subdataWithRange:NSMakeRange(payloadOffset, payloadLength)]; + message = [SDLProtocolMessage messageWithHeader:header andPayload:payload]; + [logMessage appendFormat:@"message complete. %@", message]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_Protocol toOutput:SDLDebugOutput_File | SDLDebugOutput_DeviceConsole toGroup:self.debugConsoleGroupName]; + } else { + // Need to wait for more bytes. + [logMessage appendFormat:@"header complete. message incomplete, waiting for %ld more bytes. Header:%@", (long)(messageSize - self.receiveBuffer.length), header]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_Protocol toOutput:SDLDebugOutput_File | SDLDebugOutput_DeviceConsole toGroup:self.debugConsoleGroupName]; + return; + } + + // Need to maintain the receiveBuffer, remove the bytes from it which we just processed. + self.receiveBuffer = [[self.receiveBuffer subdataWithRange:NSMakeRange(messageSize, self.receiveBuffer.length - messageSize)] mutableCopy]; + + // Pass on the message to the message router. + dispatch_async(_receiveQueue, ^{ + [self.messageRouter handleReceivedMessage:message]; + }); + + // Call recursively until the buffer is empty or incomplete message is encountered + if (self.receiveBuffer.length > 0) + [self processMessages]; +} + +- (void)sendHeartbeat { + SDLProtocolHeader *header = [SDLProtocolHeader headerForVersion:[SDLGlobals globals].protocolVersion]; + header.frameType = SDLFrameType_Control; + header.serviceType = SDLServiceType_Control; + header.frameData = SDLFrameData_Heartbeat; + header.sessionID = self.sessionID; + SDLProtocolMessage *message = [SDLProtocolMessage messageWithHeader:header andPayload:nil]; + [self sendDataToTransport:message.data withPriority:header.serviceType]; +} + +- (void)sendRawData:(NSData *)data withServiceType:(SDLServiceType)serviceType { + SDLV2ProtocolHeader *header = [[SDLV2ProtocolHeader alloc] initWithVersion:[SDLGlobals globals].protocolVersion]; + header.frameType = SDLFrameType_Single; + header.serviceType = serviceType; + header.sessionID = self.sessionID; + header.bytesInPayload = (UInt32)data.length; + header.messageID = ++_messageID; + + SDLProtocolMessage *message = [SDLProtocolMessage messageWithHeader:header andPayload:data]; + + if (message.size < [SDLGlobals globals].maxMTUSize) { + [self logRPCSend:message]; + [self sendDataToTransport:message.data withPriority:header.serviceType]; + } else { + NSArray *messages = [SDLProtocolMessageDisassembler disassemble:message withLimit:[SDLGlobals globals].maxMTUSize]; + for (SDLProtocolMessage *smallerMessage in messages) { + [self logRPCSend:smallerMessage]; + [self sendDataToTransport:smallerMessage.data withPriority:header.serviceType]; + } + } +} + + +#pragma mark - SDLProtocolListener Implementation +- (void)handleProtocolStartSessionACK:(SDLServiceType)serviceType sessionID:(Byte)sessionID version:(Byte)version { + switch (serviceType) { + case SDLServiceType_RPC: { + self.sessionID = sessionID; + [SDLGlobals globals].maxHeadUnitVersion = version; + } break; + default: + break; + } + + [self sdl_storeSessionID:sessionID forServiceType:serviceType]; + + for (id<SDLProtocolListener> listener in self.protocolDelegateTable.allObjects) { + if ([listener respondsToSelector:@selector(handleProtocolStartSessionACK:sessionID:version:)]) { + [listener handleProtocolStartSessionACK:serviceType sessionID:sessionID version:version]; + } + } +} + +- (void)handleProtocolStartSessionNACK:(SDLServiceType)serviceType { + for (id<SDLProtocolListener> listener in self.protocolDelegateTable.allObjects) { + if ([listener respondsToSelector:@selector(handleProtocolStartSessionNACK:)]) { + [listener handleProtocolStartSessionNACK:serviceType]; + } + } +} + +- (void)handleProtocolEndSessionACK:(SDLServiceType)serviceType { + // Remove the session id + [self sdl_removeSessionIdForServiceType:serviceType]; + + for (id<SDLProtocolListener> listener in self.protocolDelegateTable.allObjects) { + if ([listener respondsToSelector:@selector(handleProtocolEndSessionACK:)]) { + [listener handleProtocolEndSessionACK:serviceType]; + } + } +} + +- (void)handleProtocolEndSessionNACK:(SDLServiceType)serviceType { + for (id<SDLProtocolListener> listener in self.protocolDelegateTable.allObjects) { + if ([listener respondsToSelector:@selector(handleProtocolEndSessionNACK:)]) { + [listener handleProtocolEndSessionNACK:serviceType]; + } + } +} + +- (void)handleHeartbeatForSession:(Byte)session { + // Respond with a heartbeat ACK + SDLProtocolHeader *header = [SDLProtocolHeader headerForVersion:[SDLGlobals globals].protocolVersion]; + header.frameType = SDLFrameType_Control; + header.serviceType = SDLServiceType_Control; + header.frameData = SDLFrameData_HeartbeatACK; + header.sessionID = session; + SDLProtocolMessage *message = [SDLProtocolMessage messageWithHeader:header andPayload:nil]; + [self sendDataToTransport:message.data withPriority:header.serviceType]; + + for (id<SDLProtocolListener> listener in self.protocolDelegateTable.allObjects) { + if ([listener respondsToSelector:@selector(handleHeartbeatForSession:)]) { + [listener handleHeartbeatForSession:session]; + } + } +} + +- (void)handleHeartbeatACK { + for (id<SDLProtocolListener> listener in self.protocolDelegateTable.allObjects) { + if ([listener respondsToSelector:@selector(handleHeartbeatACK)]) { + [listener handleHeartbeatACK]; + } + } +} + +- (void)onProtocolMessageReceived:(SDLProtocolMessage *)msg { + for (id<SDLProtocolListener> listener in self.protocolDelegateTable.allObjects) { + if ([listener respondsToSelector:@selector(onProtocolMessageReceived:)]) { + [listener onProtocolMessageReceived:msg]; + } + } +} + +- (void)onProtocolOpened { + for (id<SDLProtocolListener> listener in self.protocolDelegateTable.allObjects) { + if ([listener respondsToSelector:@selector(onProtocolOpened)]) { + [listener onProtocolOpened]; + } + } +} + +- (void)onProtocolClosed { + for (id<SDLProtocolListener> listener in self.protocolDelegateTable.allObjects) { + if ([listener respondsToSelector:@selector(onProtocolClosed)]) { + [listener onProtocolClosed]; + } + } +} + +- (void)onError:(NSString *)info exception:(NSException *)e { + for (id<SDLProtocolListener> listener in self.protocolDelegateTable.allObjects) { + if ([listener respondsToSelector:@selector(onError:exception:)]) { + [listener onError:info exception:e]; + } + } +} + + +#pragma mark - Lifecycle + +- (void)destructObjects { + if (!_alreadyDestructed) { + _alreadyDestructed = YES; + self.messageRouter.delegate = nil; + self.messageRouter = nil; + self.transport = nil; + self.protocolDelegateTable = nil; + } +} + +- (void)dispose { + [self destructObjects]; +} + +- (void)dealloc { + [self destructObjects]; + [SDLDebugTool logInfo:@"SDLProtocol Dealloc" withType:SDLDebugType_Transport_iAP toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; +} + +@end diff --git a/SmartDeviceLink/SDLProtocolHeader.h b/SmartDeviceLink/SDLProtocolHeader.h new file mode 100644 index 000000000..e99e5d93c --- /dev/null +++ b/SmartDeviceLink/SDLProtocolHeader.h @@ -0,0 +1,61 @@ +// SDLProtocolHeader.h +// + +#import <Foundation/Foundation.h> + + +typedef NS_ENUM(UInt8, SDLFrameType) { + SDLFrameType_Control = 0x00, + SDLFrameType_Single = 0x01, + SDLFrameType_First = 0x02, + SDLFrameType_Consecutive = 0x03 +}; + +typedef NS_ENUM(UInt8, SDLServiceType) { + SDLServiceType_Control = 0x00, + SDLServiceType_RPC = 0x07, + SDLServiceType_Audio = 0x0A, + SDLServiceType_Video = 0x0B, + SDLServiceType_BulkData = 0x0F +}; + +typedef NS_ENUM(UInt8, SDLFrameData) { + SDLFrameData_Heartbeat = 0x00, + SDLFrameData_StartSession = 0x01, + SDLFrameData_StartSessionACK = 0x02, + SDLFrameData_StartSessionNACK = 0x03, + SDLFrameData_EndSession = 0x04, + SDLFrameData_EndSessionACK = 0x05, + SDLFrameData_EndSessionNACK = 0x06, + SDLFrameData_ServiceDataACK = 0xFE, + SDLFrameData_HeartbeatACK = 0xFF, + // If frameType == Single (0x01) + SDLFrameData_SingleFrame = 0x00, + // If frameType == First (0x02) + SDLFrameData_FirstFrame = 0x00, + // If frametype == Consecutive (0x03) + SDLFrameData_ConsecutiveLastFrame = 0x00 +}; + + +@interface SDLProtocolHeader : NSObject <NSCopying> { + UInt8 _version; + NSUInteger _size; +} + +@property (assign, readonly) UInt8 version; +@property (assign, readonly) NSUInteger size; +@property (assign) BOOL compressed; +@property (assign) SDLFrameType frameType; +@property (assign) SDLServiceType serviceType; +@property (assign) SDLFrameData frameData; +@property (assign) UInt8 sessionID; +@property (assign) UInt32 bytesInPayload; + +- (instancetype)init; +- (NSData *)data; +- (void)parse:(NSData *)data; +- (NSString *)description; ++ (SDLProtocolHeader *)headerForVersion:(UInt8)version; + +@end diff --git a/SmartDeviceLink/SDLProtocolHeader.m b/SmartDeviceLink/SDLProtocolHeader.m new file mode 100644 index 000000000..dff874a9d --- /dev/null +++ b/SmartDeviceLink/SDLProtocolHeader.m @@ -0,0 +1,60 @@ +// SDLProtocolHeader.m +// + + +#import "SDLProtocolHeader.h" +#import "SDLV1ProtocolHeader.h" +#import "SDLV2ProtocolHeader.h" + +@implementation SDLProtocolHeader + +@synthesize version = _version; +@synthesize size = _size; + + +- (instancetype)init { + if (self = [super init]) { + _version = 0; + _size = 0; + } + return self; +} + +- (id)copyWithZone:(NSZone *)zone { + [self doesNotRecognizeSelector:_cmd]; + return 0; +} + +- (NSData *)data { + [self doesNotRecognizeSelector:_cmd]; + return nil; +} + +- (void)parse:(NSData *)data { + [self doesNotRecognizeSelector:_cmd]; +} + +- (NSString *)description { + NSString *description = [NSString stringWithFormat:@"<%@: %p>", NSStringFromClass([self class]), self]; + return description; +} + ++ (SDLProtocolHeader *)headerForVersion:(UInt8)version { + // VERSION DEPENDENT CODE + switch (version) { + case 1: { + return [[SDLV1ProtocolHeader alloc] init]; + } break; + case 2: // Fallthrough + case 3: // Fallthrough + case 4: { + return [[SDLV2ProtocolHeader alloc] initWithVersion:version]; + } break; + default: { + NSString *reason = [NSString stringWithFormat:@"The version of header that is being created is unknown: %@", @(version)]; + @throw [NSException exceptionWithName:NSInvalidArgumentException reason:reason userInfo:@{ @"requestedVersion" : @(version) }]; + } break; + } +} + +@end
\ No newline at end of file diff --git a/SmartDeviceLink/SDLProtocolListener.h b/SmartDeviceLink/SDLProtocolListener.h new file mode 100644 index 000000000..3fb1e550f --- /dev/null +++ b/SmartDeviceLink/SDLProtocolListener.h @@ -0,0 +1,23 @@ +// SDLProtocolListener.h +// + +#import "SDLProtocolHeader.h" + +@class SDLProtocolMessage; + + +@protocol SDLProtocolListener <NSObject> + +@optional +- (void)handleProtocolStartSessionACK:(SDLServiceType)serviceType sessionID:(Byte)sessionID version:(Byte)version; +- (void)handleProtocolStartSessionNACK:(SDLServiceType)serviceType; +- (void)handleProtocolEndSessionACK:(SDLServiceType)serviceType; +- (void)handleProtocolEndSessionNACK:(SDLServiceType)serviceType; +- (void)handleHeartbeatForSession:(Byte)session; +- (void)handleHeartbeatACK; +- (void)onProtocolMessageReceived:(SDLProtocolMessage *)msg; +- (void)onProtocolOpened; +- (void)onProtocolClosed; +- (void)onError:(NSString *)info exception:(NSException *)e; + +@end diff --git a/SmartDeviceLink/SDLProtocolMessage.h b/SmartDeviceLink/SDLProtocolMessage.h new file mode 100644 index 000000000..62abd6226 --- /dev/null +++ b/SmartDeviceLink/SDLProtocolMessage.h @@ -0,0 +1,23 @@ +// SDLSmartDeviceLinkProtocolMessage.h +// + +#import <Foundation/Foundation.h> +@class SDLProtocolHeader; + + +@interface SDLProtocolMessage : NSObject + +@property (strong) SDLProtocolHeader *header; +@property (strong) NSData *payload; +@property (strong, readonly) NSData *data; + ++ (id)messageWithHeader:(SDLProtocolHeader *)header andPayload:(NSData *)payload; // Returns a V1 or V2 object + +- (NSUInteger)size; +- (NSString *)description; +- (NSDictionary *)rpcDictionary; // Use for RPC type messages to obtain the data in a dictionary + ++ (UInt8)determineVersion:(NSData *)data; + + +@end diff --git a/SmartDeviceLink/SDLProtocolMessage.m b/SmartDeviceLink/SDLProtocolMessage.m new file mode 100644 index 000000000..f68810123 --- /dev/null +++ b/SmartDeviceLink/SDLProtocolMessage.m @@ -0,0 +1,99 @@ +// SDLProtocolMessage.m +// + + +#import "SDLProtocolMessage.h" +#import "SDLFunctionID.h" +#import "SDLProtocolHeader.h" +#import "SDLRPCPayload.h" +#import "SDLV1ProtocolMessage.h" +#import "SDLV2ProtocolMessage.h" + +@interface SDLProtocolMessage () + +@property (strong) NSMutableData *internalBuffer; + +@end + +@implementation SDLProtocolMessage + +// For use in decoding a stream of bytes. +// Pass in bytes representing message (or beginning of message) +// Looks at and parses first byte to determine version. ++ (UInt8)determineVersion:(NSData *)data { + UInt8 firstByte = ((UInt8 *)data.bytes)[0]; + UInt8 version = firstByte >> 4; + return version; +} + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (NSDictionary *)rpcDictionary { + [self doesNotRecognizeSelector:_cmd]; + return nil; +} + +- (NSUInteger)size { + return (self.header.size + self.payload.length); +} + +- (NSData *)data { + NSMutableData *dataOut = [NSMutableData dataWithCapacity:[self size]]; + [dataOut appendData:self.header.data]; + [dataOut appendData:self.payload]; + + return dataOut; +} + +- (NSString *)description { + // Print the header data. + NSMutableString *description = [[NSMutableString alloc] init]; + [description appendString:self.header.description]; + + // If it's an RPC, provide greater detail + if (((self.header.serviceType == SDLServiceType_RPC) || (self.header.serviceType == SDLServiceType_BulkData)) && (self.header.frameType == SDLFrameType_Single)) { + // version of RPC Message determines how we access the info. + if (self.header.version >= 2) { + SDLRPCPayload *rpcPayload = [SDLRPCPayload rpcPayloadWithData:self.payload]; + if (rpcPayload) { + NSString *functionName = [[[SDLFunctionID alloc] init] getFunctionName:rpcPayload.functionID]; + + UInt8 rpcType = rpcPayload.rpcType; + NSArray *rpcTypeNames = @[ @"Request", @"Response", @"Notification" ]; + NSString *rpcTypeString = nil; + if (rpcType >= 0 && rpcType < rpcTypeNames.count) { + rpcTypeString = rpcTypeNames[rpcType]; + } + [description appendFormat:@" RPC Info: %@ %@", functionName, rpcTypeString]; + } + } else { + // version == 1 + // turn payload (which is JSON string) into dictionary and extract fields of interest. + } + } else { + // Not an RPC, provide generic info. + [description appendFormat:@" Payload: %lu bytes.", (unsigned long)self.payload.length]; + } + + return description; +} + +// Returns a V1 or V2 object ++ (id)messageWithHeader:(SDLProtocolHeader *)header andPayload:(NSData *)payload { + SDLProtocolMessage *newMessage = nil; + + UInt8 version = header.version; + if (version == 1) { + newMessage = [[SDLV1ProtocolMessage alloc] initWithHeader:(SDLProtocolHeader *)header andPayload:(NSData *)payload]; + } else if (version >= 2) { + newMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:(SDLProtocolHeader *)header andPayload:(NSData *)payload]; + } + + return newMessage; +} + +@end diff --git a/SmartDeviceLink/SDLProtocolMessageAssembler.h b/SmartDeviceLink/SDLProtocolMessageAssembler.h new file mode 100644 index 000000000..3c793f441 --- /dev/null +++ b/SmartDeviceLink/SDLProtocolMessageAssembler.h @@ -0,0 +1,22 @@ +// SDLSmartDeviceLinkProtocolMessageAssembler.h +// + +#import <Foundation/Foundation.h> + +@class SDLProtocolMessage; + + +typedef void (^SDLMessageAssemblyCompletionHandler)(BOOL done, SDLProtocolMessage *assembledMessage); + + +@interface SDLProtocolMessageAssembler : NSObject + +@property (assign, readonly) UInt8 sessionID; +@property (assign) UInt32 frameCount; // number of consecutive frames required for reassembly +@property (assign) UInt32 expectedBytes; +@property (strong) NSMutableDictionary *parts; + +- (instancetype)initWithSessionID:(UInt8)sessionID; +- (void)handleMessage:(SDLProtocolMessage *)message withCompletionHandler:(SDLMessageAssemblyCompletionHandler)completionHandler; + +@end diff --git a/SmartDeviceLink/SDLProtocolMessageAssembler.m b/SmartDeviceLink/SDLProtocolMessageAssembler.m new file mode 100644 index 000000000..c41591c51 --- /dev/null +++ b/SmartDeviceLink/SDLProtocolMessageAssembler.m @@ -0,0 +1,94 @@ +// SDLSmartDeviceLinkProtocolMessageAssembler.m +// + +#import "SDLProtocolMessageAssembler.h" + +#import "SDLProtocolHeader.h" +#import "SDLProtocolMessage.h" + +@implementation SDLProtocolMessageAssembler + +- (instancetype)initWithSessionID:(UInt8)sessionID { + if (self = [super init]) { + _sessionID = sessionID; + } + return self; +} + +- (void)handleMessage:(SDLProtocolMessage *)message withCompletionHandler:(SDLMessageAssemblyCompletionHandler)completionHandler { + // Validate input + if (message.header.sessionID != self.sessionID) { + NSLog(@"Error: message part sent to wrong assembler."); + return; + } + + if (self.parts == nil) { + self.parts = [NSMutableDictionary new]; + } + + + // Determine which frame it is and save it. + // Note: frames are numbered 1,2,3, ..., 0 + // Always 0 for last frame. + if (message.header.frameType == SDLFrameType_First) { + // If it's the first-frame, extract the meta-data + self.expectedBytes = NSSwapBigIntToHost(((UInt32 *)message.payload.bytes)[0]); + self.frameCount = NSSwapBigIntToHost(((UInt32 *)message.payload.bytes)[1]); + self.parts[@"firstframe"] = message.payload; + } else if (message.header.frameType == SDLFrameType_Consecutive) { + // Save the frame w/ frame# as the key + NSInteger frameNumber = message.header.frameData; + NSNumber *frameNumberObj = @(frameNumber); + self.parts[frameNumberObj] = message.payload; + } + + + // + // If we have all the parts, assemble it and execute the completion handler. + // + SDLProtocolMessage *assembledMessage = nil; + if (self.parts.count == self.frameCount + 1) { // +1 since we also require the first-frame + + // Create the header + SDLProtocolHeader *header = message.header.copy; + header.frameType = SDLFrameType_Single; + header.frameData = SDLFrameData_SingleFrame; + + + // Create the payload + NSMutableData *payload = [[NSMutableData alloc] init]; + for (unsigned int i = 1; i < self.frameCount; i++) { + NSData *dataToAppend = [self.parts objectForKey:[NSNumber numberWithUnsignedInt:i]]; + [payload appendData:dataToAppend]; + } + // Append the last frame, it has a frame # of 0. + NSData *dataToAppend = [self.parts objectForKey:[NSNumber numberWithUnsignedInt:0]]; + [payload appendData:dataToAppend]; + + // Validation + header.bytesInPayload = (UInt32)payload.length; + if (payload.length != self.expectedBytes) { + NSLog(@"Warning: collected bytes size of %lu not equal to expected size of %i.", (unsigned long)payload.length, (unsigned int)self.expectedBytes); + } + + // Create the message. + assembledMessage = [SDLProtocolMessage messageWithHeader:header andPayload:payload]; + + + // Execute completion handler. + if (completionHandler != nil) { + completionHandler(YES, assembledMessage); + } + + // Done with this data, release it. + self.parts = nil; + + } else { + // Not done, let caller know + if (completionHandler != nil) { + completionHandler(NO, nil); + } + } +} + +@end diff --git a/SmartDeviceLink/SDLProtocolMessageDisassembler.h b/SmartDeviceLink/SDLProtocolMessageDisassembler.h new file mode 100644 index 000000000..10f6f2860 --- /dev/null +++ b/SmartDeviceLink/SDLProtocolMessageDisassembler.h @@ -0,0 +1,13 @@ +// SDLSmartDeviceLinkProtocolMessageDisassembler.h +// + +#import <Foundation/Foundation.h> + +@class SDLProtocolMessage; + + +@interface SDLProtocolMessageDisassembler : NSObject + ++ (NSArray *)disassemble:(SDLProtocolMessage *)protocolMessage withLimit:(NSUInteger)mtu; + +@end diff --git a/SmartDeviceLink/SDLProtocolMessageDisassembler.m b/SmartDeviceLink/SDLProtocolMessageDisassembler.m new file mode 100644 index 000000000..76d722956 --- /dev/null +++ b/SmartDeviceLink/SDLProtocolMessageDisassembler.m @@ -0,0 +1,89 @@ +// SDLProtocolMessageDisassembler.m +// + +#import "SDLProtocolMessageDisassembler.h" +#import "SDLProtocolHeader.h" +#import "SDLProtocolMessage.h" + + +@implementation SDLProtocolMessageDisassembler + + +// Use to break up a large message into a sequence of smaller messages, +// each of which is less than 'mtu' number of bytes total size. ++ (NSArray *)disassemble:(SDLProtocolMessage *)incomingMessage withLimit:(NSUInteger)mtu { + // Questions: + // What message IDs does the current system use? Same messageIDs? Same CorrelationIDs? + // What gets simply copied from incoming header to created headers; and what needs adjustment? + + // How big is the message header? + NSUInteger headerSize = incomingMessage.header.size; + + // The size of the message is too big to send in one chunk. + // So lets break it up. + // Just how big IS this message? + NSUInteger incomingPayloadSize = (incomingMessage.data.length - headerSize); + + // How many messages do we need to create to hold that many bytes? + // Note: this does NOT count the special first message which acts as a descriptor. + NSUInteger numberOfMessagesRequired = ceil((float)incomingPayloadSize / (float)(mtu - headerSize)); + + // And how many data bytes go in each message? + NSUInteger numberOfDataBytesPerMessage = mtu - headerSize; + + // Create the outgoing array to hold the messages we will create. + NSMutableArray *outgoingMessages = [NSMutableArray arrayWithCapacity:numberOfMessagesRequired + 1]; + + + // Create the first message + SDLProtocolHeader *firstFrameHeader = [incomingMessage.header copy]; + firstFrameHeader.frameType = SDLFrameType_First; + + UInt32 payloadData[2]; + payloadData[0] = CFSwapInt32HostToBig((UInt32)incomingMessage.payload.length); + payloadData[1] = CFSwapInt32HostToBig((UInt32)numberOfMessagesRequired); + NSMutableData *firstFramePayload = [NSMutableData dataWithBytes:payloadData length:sizeof(payloadData)]; + firstFrameHeader.bytesInPayload = (UInt32)firstFramePayload.length; + + SDLProtocolMessage *firstMessage = [SDLProtocolMessage messageWithHeader:firstFrameHeader andPayload:firstFramePayload]; + outgoingMessages[0] = firstMessage; + + + // Create the middle messages (the ones carrying the actual data). + for (int n = 0; n < numberOfMessagesRequired - 1; n++) { + // Frame # after 255 must cycle back to 1, not 0. + // A 0 signals last frame. + UInt8 frameNumber = (n % 255) + 1; + + SDLProtocolHeader *nextFrameHeader = [incomingMessage.header copy]; + nextFrameHeader.frameType = SDLFrameType_Consecutive; + nextFrameHeader.frameData = frameNumber; + + NSUInteger offsetOfDataForThisFrame = headerSize + (n * numberOfDataBytesPerMessage); + NSData *nextFramePayload = [incomingMessage.data subdataWithRange:NSMakeRange(offsetOfDataForThisFrame, numberOfDataBytesPerMessage)]; + nextFrameHeader.bytesInPayload = (UInt32)nextFramePayload.length; + + SDLProtocolMessage *nextMessage = [SDLProtocolMessage messageWithHeader:nextFrameHeader andPayload:nextFramePayload]; + outgoingMessages[n + 1] = nextMessage; + } + + + // Create the last message + SDLProtocolHeader *lastFrameHeader = [incomingMessage.header copy]; + lastFrameHeader.frameType = SDLFrameType_Consecutive; + lastFrameHeader.frameData = SDLFrameData_ConsecutiveLastFrame; + + NSUInteger numberOfMessagesCreatedSoFar = numberOfMessagesRequired - 1; + NSUInteger numberOfDataBytesSentSoFar = numberOfMessagesCreatedSoFar * numberOfDataBytesPerMessage; + NSUInteger numberOfDataBytesInLastMessage = incomingPayloadSize - numberOfDataBytesSentSoFar; + NSUInteger offsetOfDataForLastFrame = headerSize + numberOfDataBytesSentSoFar; + NSData *lastFramePayload = [incomingMessage.data subdataWithRange:NSMakeRange(offsetOfDataForLastFrame, numberOfDataBytesInLastMessage)]; + lastFrameHeader.bytesInPayload = (UInt32)lastFramePayload.length; + + SDLProtocolMessage *lastMessage = [SDLProtocolMessage messageWithHeader:lastFrameHeader andPayload:lastFramePayload]; + outgoingMessages[numberOfMessagesRequired] = lastMessage; + + return outgoingMessages; +} + +@end diff --git a/SmartDeviceLink/SDLProtocolReceivedMessageRouter.h b/SmartDeviceLink/SDLProtocolReceivedMessageRouter.h new file mode 100644 index 000000000..cd3e4c9c5 --- /dev/null +++ b/SmartDeviceLink/SDLProtocolReceivedMessageRouter.h @@ -0,0 +1,15 @@ +// SDLProtocolReceivedMessageRouter.h +// + + +#import "SDLProtocolListener.h" +@class SDLProtocolMessage; + + +@interface SDLProtocolReceivedMessageRouter : NSObject + +@property (weak) id<SDLProtocolListener> delegate; + +- (void)handleReceivedMessage:(SDLProtocolMessage *)message; + +@end diff --git a/SmartDeviceLink/SDLProtocolReceivedMessageRouter.m b/SmartDeviceLink/SDLProtocolReceivedMessageRouter.m new file mode 100644 index 000000000..5ea7c6e63 --- /dev/null +++ b/SmartDeviceLink/SDLProtocolReceivedMessageRouter.m @@ -0,0 +1,116 @@ +// SDLProtocolReceivedMessageRouter.m +// + +// This class gets handed the SDLProtocol messages as they are received and decides what happens to them and where they are sent on to. + +#import "SDLProtocolReceivedMessageRouter.h" +#import "SDLDebugTool.h" +#import "SDLProtocolMessage.h" +#import "SDLProtocolMessageAssembler.h" + + +@interface SDLProtocolReceivedMessageRouter () + +@property (assign) BOOL alreadyDestructed; +@property (strong) NSMutableDictionary *messageAssemblers; + +- (void)dispatchProtocolMessage:(SDLProtocolMessage *)message; +- (void)dispatchControlMessage:(SDLProtocolMessage *)message; +- (void)dispatchMultiPartMessage:(SDLProtocolMessage *)message; + +@end + + +@implementation SDLProtocolReceivedMessageRouter + +- (instancetype)init { + if (self = [super init]) { + _alreadyDestructed = NO; + self.messageAssemblers = [NSMutableDictionary dictionaryWithCapacity:2]; + } + return self; +} + +- (void)handleReceivedMessage:(SDLProtocolMessage *)message { + SDLFrameType frameType = message.header.frameType; + + switch (frameType) { + case SDLFrameType_Single: { + [self dispatchProtocolMessage:message]; + } break; + case SDLFrameType_Control: { + [self dispatchControlMessage:message]; + } break; + case SDLFrameType_First: // fallthrough + case SDLFrameType_Consecutive: { + [self dispatchMultiPartMessage:message]; + } break; + default: break; + } +} + +- (void)dispatchProtocolMessage:(SDLProtocolMessage *)message { + [self.delegate onProtocolMessageReceived:message]; +} + +- (void)dispatchControlMessage:(SDLProtocolMessage *)message { + switch (message.header.frameData) { + case SDLFrameData_StartSessionACK: { + [self.delegate handleProtocolStartSessionACK:message.header.serviceType + sessionID:message.header.sessionID + version:message.header.version]; + + } break; + case SDLFrameData_StartSessionNACK: { + [self.delegate handleProtocolStartSessionNACK:message.header.serviceType]; + } break; + case SDLFrameData_EndSessionACK: { + [self.delegate handleProtocolEndSessionACK:message.header.serviceType]; + } break; + case SDLFrameData_EndSessionNACK: { + [self.delegate handleProtocolStartSessionNACK:message.header.serviceType]; + } break; + case SDLFrameData_Heartbeat: { + [self.delegate handleHeartbeatForSession:message.header.sessionID]; + } break; + case SDLFrameData_HeartbeatACK: { + [self.delegate handleHeartbeatACK]; + } break; + default: break; + } +} + +- (void)dispatchMultiPartMessage:(SDLProtocolMessage *)message { + // Pass multipart messages to an assembler and call delegate when done. + NSNumber *sessionID = [NSNumber numberWithUnsignedChar:message.header.sessionID]; + + SDLProtocolMessageAssembler *assembler = self.messageAssemblers[sessionID]; + if (assembler == nil) { + assembler = [[SDLProtocolMessageAssembler alloc] initWithSessionID:message.header.sessionID]; + self.messageAssemblers[sessionID] = assembler; + } + + SDLMessageAssemblyCompletionHandler completionHandler = ^void(BOOL done, SDLProtocolMessage *assembledMessage) { + if (done) { + [self dispatchProtocolMessage:assembledMessage]; + } + }; + [assembler handleMessage:message withCompletionHandler:completionHandler]; +} + +- (void)destructObjects { + if (!self.alreadyDestructed) { + self.alreadyDestructed = YES; + self.delegate = nil; + } +} + +- (void)dispose { + [self destructObjects]; +} + +- (void)dealloc { + [self destructObjects]; +} + +@end diff --git a/SmartDeviceLink/SDLProxy.h b/SmartDeviceLink/SDLProxy.h new file mode 100644 index 000000000..2d86439b7 --- /dev/null +++ b/SmartDeviceLink/SDLProxy.h @@ -0,0 +1,62 @@ +// SDLProxy.h +// + +@class SDLAbstractProtocol; +@class SDLAbstractTransport; +@class SDLProtocol; +@class SDLPutFile; +@class SDLRPCMessage; +@class SDLRPCRequestFactory; +@class SDLStreamingMediaManager; +@class SDLTimer; + +#import "SDLProtocolListener.h" +#import "SDLProxyListener.h" + + +@interface SDLProxy : NSObject <SDLProtocolListener, NSStreamDelegate> { + Byte _version; + Byte _bulkSessionID; + BOOL _isConnected; + BOOL _alreadyDestructed; +} + +@property (strong) SDLAbstractProtocol *protocol; +@property (strong) SDLAbstractTransport *transport; +@property (readonly, copy) NSSet *proxyListeners; +@property (strong) SDLTimer *startSessionTimer; +@property (copy) NSString *debugConsoleGroupName; +@property (readonly, copy) NSString *proxyVersion; +@property (nonatomic, strong, readonly) SDLStreamingMediaManager *streamingMediaManager; + +- (id)initWithTransport:(SDLAbstractTransport *)transport + protocol:(SDLAbstractProtocol *)protocol + delegate:(NSObject<SDLProxyListener> *)delegate; +- (void)dispose; + +- (void)addDelegate:(NSObject<SDLProxyListener> *)delegate; +- (void)removeDelegate:(NSObject<SDLProxyListener> *)delegate; + +- (void)sendRPC:(SDLRPCMessage *)message; +- (void)sendRPCRequest:(SDLRPCMessage *)msg __deprecated_msg("use -sendRPC: instead"); + +- (void)handleRPCDictionary:(NSDictionary *)dictionary; +- (void)handleRpcMessage:(NSDictionary *)msg __deprecated_msg("use -handleRPCDictionary: instead"); + +- (void)handleProtocolMessage:(SDLProtocolMessage *)msgData; + ++ (void)enableSiphonDebug; ++ (void)disableSiphonDebug; + +/** + * Puts data into a file on the module + * @abstract Performs a putFile for a given input stream, performed in chunks, for handling very large files. + * @param inputStream A stream containing the data to put to the module. + * @param putFileRPCRequest A SDLPutFile object containing the parameters for the put(s) + * @discussion The proxy will read from the stream based on the max MTU size and send them in individual putFile requests. + * This may result in multiple responses being received, one for each request. + * Note: the length parameter of the putFileRPCRequest will be ignored. The proxy will substitute the number of bytes read from the stream. + */ +- (void)putFileStream:(NSInputStream *)inputStream withRequest:(SDLPutFile *)putFileRPCRequest; + +@end diff --git a/SmartDeviceLink/SDLProxy.m b/SmartDeviceLink/SDLProxy.m new file mode 100644 index 000000000..73b8399e3 --- /dev/null +++ b/SmartDeviceLink/SDLProxy.m @@ -0,0 +1,758 @@ +// SDLProxy.m + +#import "SDLProxy.h" + +#import <ExternalAccessory/ExternalAccessory.h> +#import <UIKit/UIKit.h> +#import <objc/runtime.h> + +#import "SDLAbstractTransport.h" +#import "SDLAudioStreamingState.h" +#import "SDLDebugTool.h" +#import "SDLEncodedSyncPData.h" +#import "SDLFileType.h" +#import "SDLFunctionID.h" +#import "SDLGlobals.h" +#import "SDLHMILevel.h" +#import "SDLJsonDecoder.h" +#import "SDLJsonEncoder.h" +#import "SDLLanguage.h" +#import "SDLLayoutMode.h" +#import "SDLLockScreenManager.h" +#import "SDLLockScreenManager.h" +#import "SDLNames.h" +#import "SDLOnHMIStatus.h" +#import "SDLOnSystemRequest.h" +#import "SDLPolicyDataParser.h" +#import "SDLPolicyDataParser.h" +#import "SDLProtocol.h" +#import "SDLProtocolMessage.h" +#import "SDLProtocolMessage.h" +#import "SDLPutFile.h" +#import "SDLRPCPayload.h" +#import "SDLRPCPayload.h" +#import "SDLRPCRequestFactory.h" +#import "SDLRPCResponse.h" +#import "SDLRequestType.h" +#import "SDLSiphonServer.h" +#import "SDLStreamingMediaManager.h" +#import "SDLSystemContext.h" +#import "SDLSystemRequest.h" +#import "SDLTimer.h" +#import "SDLURLSession.h" + + +typedef void (^URLSessionTaskCompletionHandler)(NSData *data, NSURLResponse *response, NSError *error); +typedef void (^URLSessionDownloadTaskCompletionHandler)(NSURL *location, NSURLResponse *response, NSError *error); + +NSString *const SDLProxyVersion = @"4.1.2"; +const float startSessionTime = 10.0; +const float notifyProxyClosedDelay = 0.1; +const int POLICIES_CORRELATION_ID = 65535; + + +@interface SDLProxy () { + SDLLockScreenManager *_lsm; +} + +@property (strong, nonatomic) NSMutableSet *mutableProxyListeners; +@property (nonatomic, strong, readwrite) SDLStreamingMediaManager *streamingMediaManager; + +@end + + +@implementation SDLProxy + +#pragma mark - Object lifecycle +- (instancetype)initWithTransport:(SDLAbstractTransport *)transport protocol:(SDLAbstractProtocol *)protocol delegate:(NSObject<SDLProxyListener> *)theDelegate { + if (self = [super init]) { + _debugConsoleGroupName = @"default"; + _lsm = [[SDLLockScreenManager alloc] init]; + _alreadyDestructed = NO; + + _mutableProxyListeners = [NSMutableSet setWithObject:theDelegate]; + _protocol = protocol; + _transport = transport; + _transport.delegate = protocol; + [_protocol.protocolDelegateTable addObject:self]; + _protocol.transport = transport; + + [self.transport connect]; + + [SDLDebugTool logInfo:@"SDLProxy initWithTransport"]; + [[EAAccessoryManager sharedAccessoryManager] registerForLocalNotifications]; + } + + return self; +} + +- (void)destructObjects { + if (!_alreadyDestructed) { + _alreadyDestructed = YES; + + [[NSNotificationCenter defaultCenter] removeObserver:self]; + [[EAAccessoryManager sharedAccessoryManager] unregisterForLocalNotifications]; + + [[SDLURLSession defaultSession] cancelAllTasks]; + + [self.protocol dispose]; + [self.transport dispose]; + + _transport = nil; + _protocol = nil; + _mutableProxyListeners = nil; + } +} + +- (void)dispose { + if (self.transport != nil) { + [self.transport disconnect]; + } + + [self destructObjects]; +} + +- (void)dealloc { + [self destructObjects]; + [SDLDebugTool logInfo:@"SDLProxy Dealloc" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:_debugConsoleGroupName]; +} + +- (void)notifyProxyClosed { + if (_isConnected) { + _isConnected = NO; + [self invokeMethodOnDelegates:@selector(onProxyClosed) withObject:nil]; + } +} + +#pragma mark - Accessors + +- (NSSet *)proxyListeners { + return [self.mutableProxyListeners copy]; +} + +#pragma mark - Methods + +- (void)sendMobileHMIState { + UIApplicationState appState = [UIApplication sharedApplication].applicationState; + SDLOnHMIStatus *HMIStatusRPC = [[SDLOnHMIStatus alloc] init]; + + HMIStatusRPC.audioStreamingState = [SDLAudioStreamingState NOT_AUDIBLE]; + HMIStatusRPC.systemContext = [SDLSystemContext MAIN]; + + switch (appState) { + case UIApplicationStateActive: { + HMIStatusRPC.hmiLevel = [SDLHMILevel FULL]; + } break; + case UIApplicationStateBackground: // Fallthrough + case UIApplicationStateInactive: { + HMIStatusRPC.hmiLevel = [SDLHMILevel BACKGROUND]; + } break; + default: + break; + } + + NSString *log = [NSString stringWithFormat:@"Sending new mobile hmi state: %@", HMIStatusRPC.hmiLevel.value]; + [SDLDebugTool logInfo:log withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + + [self sendRPC:HMIStatusRPC]; +} + + +#pragma mark - Setters / Getters + +- (NSString *)proxyVersion { + return SDLProxyVersion; +} + +- (SDLStreamingMediaManager *)streamingMediaManager { + if (_streamingMediaManager == nil) { + _streamingMediaManager = [[SDLStreamingMediaManager alloc] initWithProtocol:self.protocol]; + [self.protocol.protocolDelegateTable addObject:_streamingMediaManager]; + } + + return _streamingMediaManager; +} + + +#pragma mark - SDLProtocolListener Implementation +- (void)onProtocolOpened { + _isConnected = YES; + [SDLDebugTool logInfo:@"StartSession (request)" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + + [self.protocol sendStartSessionWithType:SDLServiceType_RPC]; + + if (self.startSessionTimer == nil) { + self.startSessionTimer = [[SDLTimer alloc] initWithDuration:startSessionTime repeat:NO]; + __weak typeof(self) weakSelf = self; + self.startSessionTimer.elapsedBlock = ^{ + [SDLDebugTool logInfo:@"Start Session Timeout" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:weakSelf.debugConsoleGroupName]; + [weakSelf performSelector:@selector(notifyProxyClosed) withObject:nil afterDelay:notifyProxyClosedDelay]; + }; + } + [self.startSessionTimer start]; +} + +- (void)onProtocolClosed { + [self notifyProxyClosed]; +} + +- (void)onError:(NSString *)info exception:(NSException *)e { + [self invokeMethodOnDelegates:@selector(onError:) withObject:e]; +} + +- (void)handleProtocolStartSessionACK:(SDLServiceType)serviceType sessionID:(Byte)sessionID version:(Byte)version { + // Turn off the timer, the start session response came back + [self.startSessionTimer cancel]; + + NSString *logMessage = [NSString stringWithFormat:@"StartSession (response)\nSessionId: %d for serviceType %d", sessionID, serviceType]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + + if (serviceType == SDLServiceType_RPC) { + [self invokeMethodOnDelegates:@selector(onProxyOpened) withObject:nil]; + } +} + +- (void)onProtocolMessageReceived:(SDLProtocolMessage *)msgData { + @try { + [self handleProtocolMessage:msgData]; + } @catch (NSException *e) { + NSString *logMessage = [NSString stringWithFormat:@"Proxy: Failed to handle protocol message %@", e]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_Debug toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + } +} + + +#pragma mark - Message sending and recieving +- (void)sendRPC:(SDLRPCMessage *)message { + @try { + [self.protocol sendRPC:message]; + } @catch (NSException *exception) { + NSString *logMessage = [NSString stringWithFormat:@"Proxy: Failed to send RPC message: %@", message.name]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_Debug toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + } +} + +- (void)sendRPCRequest:(SDLRPCMessage *)msg { + if ([msg isKindOfClass:SDLRPCRequest.class]) { + [self sendRPC:msg]; + } +} + +- (void)handleProtocolMessage:(SDLProtocolMessage *)incomingMessage { + // Convert protocol message to dictionary + NSDictionary *rpcMessageAsDictionary = [incomingMessage rpcDictionary]; + [self handleRPCDictionary:rpcMessageAsDictionary]; +} + +- (void)handleRPCDictionary:(NSDictionary *)dict { + SDLRPCMessage *message = [[SDLRPCMessage alloc] initWithDictionary:[dict mutableCopy]]; + NSString *functionName = [message getFunctionName]; + NSString *messageType = [message messageType]; + + // If it's a response, append response + if ([messageType isEqualToString:NAMES_response]) { + BOOL notGenericResponseMessage = ![functionName isEqualToString:@"GenericResponse"]; + if (notGenericResponseMessage) { + functionName = [NSString stringWithFormat:@"%@Response", functionName]; + } + } + + // From the function name, create the corresponding RPCObject and initialize it + NSString *functionClassName = [NSString stringWithFormat:@"SDL%@", functionName]; + SDLRPCMessage *newMessage = [[NSClassFromString(functionClassName) alloc] initWithDictionary:[dict mutableCopy]]; + + // Log the RPC message + NSString *logMessage = [NSString stringWithFormat:@"%@", newMessage]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + + // Intercept and handle several messages ourselves + if ([functionName isEqualToString:NAMES_OnAppInterfaceUnregistered] || [functionName isEqualToString:NAMES_UnregisterAppInterface]) { + [self handleRPCUnregistered:dict]; + } + + if ([functionName isEqualToString:@"RegisterAppInterfaceResponse"]) { + [self handleRegisterAppInterfaceResponse:(SDLRPCResponse *)newMessage]; + } + + if ([functionName isEqualToString:@"EncodedSyncPDataResponse"]) { + [SDLDebugTool logInfo:@"EncodedSyncPData (response)" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + } + + if ([functionName isEqualToString:@"OnEncodedSyncPData"]) { + [self handleSyncPData:newMessage]; + } + + if ([functionName isEqualToString:@"OnSystemRequest"]) { + [self handleSystemRequest:dict]; + } + + if ([functionName isEqualToString:@"SystemRequestResponse"]) { + [self handleSystemRequestResponse:newMessage]; + } + + // Formulate the name of the method to call and invoke the method on the delegate(s) + NSString *handlerName = [NSString stringWithFormat:@"on%@:", functionName]; + SEL handlerSelector = NSSelectorFromString(handlerName); + [self invokeMethodOnDelegates:handlerSelector withObject:newMessage]; + + // When an OnHMIStatus notification comes in, after passing it on (above), generate an "OnLockScreenNotification" + if ([functionName isEqualToString:@"OnHMIStatus"]) { + [self handleAfterHMIStatus:newMessage]; + } + + // When an OnDriverDistraction notification comes in, after passing it on (above), generate an "OnLockScreenNotification" + if ([functionName isEqualToString:@"OnDriverDistraction"]) { + [self handleAfterDriverDistraction:newMessage]; + } +} + +- (void)handleRpcMessage:(NSDictionary *)msg { + [self handleRPCDictionary:msg]; +} + + +#pragma mark - RPC Handlers +- (void)handleRPCUnregistered:(NSDictionary *)messageDictionary { + NSString *logMessage = [NSString stringWithFormat:@"Unregistration forced by module. %@", messageDictionary]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + [self notifyProxyClosed]; +} + +- (void)handleRegisterAppInterfaceResponse:(SDLRPCResponse *)response { + //Print Proxy Version To Console + NSString *logMessage = [NSString stringWithFormat:@"Framework Version: %@", self.proxyVersion]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + if ([SDLGlobals globals].protocolVersion >= 4) { + [self sendMobileHMIState]; + // Send SDL updates to application state + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendMobileHMIState) name:UIApplicationDidBecomeActiveNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendMobileHMIState) name:UIApplicationDidEnterBackgroundNotification object:nil]; + } +} + +- (void)handleSyncPData:(SDLRPCMessage *)message { + // If URL != nil, perform HTTP Post and don't pass the notification to proxy listeners + NSString *logMessage = [NSString stringWithFormat:@"OnEncodedSyncPData (notification)\n%@", message]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + + NSString *urlString = (NSString *)[message getParameters:@"URL"]; + NSDictionary *encodedSyncPData = (NSDictionary *)[message getParameters:@"data"]; + NSNumber *encodedSyncPTimeout = (NSNumber *)[message getParameters:@"Timeout"]; + + if (urlString && encodedSyncPData && encodedSyncPTimeout) { + [self sendEncodedSyncPData:encodedSyncPData toURL:urlString withTimeout:encodedSyncPTimeout]; + } +} + +- (void)handleSystemRequest:(NSDictionary *)dict { + [SDLDebugTool logInfo:@"OnSystemRequest (notification)" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + + SDLOnSystemRequest *systemRequest = [[SDLOnSystemRequest alloc] initWithDictionary:[dict mutableCopy]]; + SDLRequestType *requestType = systemRequest.requestType; + + // Handle the various OnSystemRequest types + if (requestType == [SDLRequestType PROPRIETARY]) { + [self handleSystemRequestProprietary:systemRequest]; + } else if (requestType == [SDLRequestType LOCK_SCREEN_ICON_URL]) { + [self handleSystemRequestLockScreenIconURL:systemRequest]; + } else if (requestType == [SDLRequestType HTTP]) { + [self sdl_handleSystemRequestHTTP:systemRequest]; + } else if (requestType == [SDLRequestType LAUNCH_APP]) { + [self sdl_handleSystemRequestLaunchApp:systemRequest]; + } +} + +- (void)handleSystemRequestResponse:(SDLRPCMessage *)message { + NSString *logMessage = [NSString stringWithFormat:@"SystemRequest (response)\n%@", message]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; +} + + +#pragma mark Handle Post-Invoke of Delegate Methods +- (void)handleAfterHMIStatus:(SDLRPCMessage *)message { + NSString *statusString = (NSString *)[message getParameters:NAMES_hmiLevel]; + SDLHMILevel *hmiLevel = [SDLHMILevel valueOf:statusString]; + _lsm.hmiLevel = hmiLevel; + + SEL callbackSelector = NSSelectorFromString(@"onOnLockScreenNotification:"); + [self invokeMethodOnDelegates:callbackSelector withObject:_lsm.lockScreenStatusNotification]; +} + +- (void)handleAfterDriverDistraction:(SDLRPCMessage *)message { + NSString *stateString = (NSString *)[message getParameters:NAMES_state]; + BOOL state = [stateString isEqualToString:@"DD_ON"] ? YES : NO; + _lsm.driverDistracted = state; + + SEL callbackSelector = NSSelectorFromString(@"onOnLockScreenNotification:"); + [self invokeMethodOnDelegates:callbackSelector withObject:_lsm.lockScreenStatusNotification]; +} + + +#pragma mark OnSystemRequest Handlers +- (void)sdl_handleSystemRequestLaunchApp:(SDLOnSystemRequest *)request { + NSURL *URLScheme = [NSURL URLWithString:request.url]; + if (URLScheme == nil) { + [SDLDebugTool logInfo:[NSString stringWithFormat:@"Launch App failure: invalid URL sent from module: %@", request.url] withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + return; + } + // If system version is less than 9.0 http://stackoverflow.com/a/5337804/1370927 + if (SDL_SYSTEM_VERSION_LESS_THAN(@"9.0")) { + // Return early if we can't openURL because openURL will crash instead of fail silently in < 9.0 + if (![[UIApplication sharedApplication] canOpenURL:URLScheme]) { + return; + } + } + [[UIApplication sharedApplication] openURL:URLScheme]; +} + +- (void)handleSystemRequestProprietary:(SDLOnSystemRequest *)request { + NSDictionary *JSONDictionary = [self validateAndParseSystemRequest:request]; + if (JSONDictionary == nil || request.url == nil) { + return; + } + + NSDictionary *requestData = JSONDictionary[@"HTTPRequest"]; + NSString *bodyString = requestData[@"body"]; + NSData *bodyData = [bodyString dataUsingEncoding:NSUTF8StringEncoding]; + + // Parse and display the policy data. + SDLPolicyDataParser *pdp = [[SDLPolicyDataParser alloc] init]; + NSData *policyData = [pdp unwrap:bodyData]; + if (policyData != nil) { + [pdp parsePolicyData:policyData]; + NSString *logMessage = [NSString stringWithFormat:@"Policy Data from Module\n%@", pdp]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + } + + // Send the HTTP Request + [self uploadForBodyDataDictionary:JSONDictionary + URLString:request.url + completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + NSString *logMessage = nil; + + if (error) { + logMessage = [NSString stringWithFormat:@"OnSystemRequest (HTTP response) = ERROR: %@", error]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + return; + } + + if (data == nil || data.length == 0) { + [SDLDebugTool logInfo:@"OnSystemRequest (HTTP response) failure: no data returned" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + return; + } + + // Show the HTTP response + [SDLDebugTool logInfo:@"OnSystemRequest (HTTP response)" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + + // Create the SystemRequest RPC to send to module. + SDLSystemRequest *request = [[SDLSystemRequest alloc] init]; + request.correlationID = [NSNumber numberWithInt:POLICIES_CORRELATION_ID]; + request.requestType = [SDLRequestType PROPRIETARY]; + request.bulkData = data; + + // Parse and display the policy data. + SDLPolicyDataParser *pdp = [[SDLPolicyDataParser alloc] init]; + NSData *policyData = [pdp unwrap:data]; + if (policyData) { + [pdp parsePolicyData:policyData]; + logMessage = [NSString stringWithFormat:@"Policy Data from Cloud\n%@", pdp]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + } + + // Send and log RPC Request + logMessage = [NSString stringWithFormat:@"SystemRequest (request)\n%@\nData length=%lu", [request serializeAsDictionary:2], (unsigned long)data.length]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + [self sendRPC:request]; + }]; +} + +- (void)handleSystemRequestLockScreenIconURL:(SDLOnSystemRequest *)request { + [[SDLURLSession defaultSession] dataFromURL:[NSURL URLWithString:request.url] + completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + if (error != nil) { + NSString *logMessage = [NSString stringWithFormat:@"OnSystemRequest failure (HTTP response), download task failed: %@", error.localizedDescription]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + return; + } + + UIImage *icon = [UIImage imageWithData:data]; + [self invokeMethodOnDelegates:@selector(onReceivedLockScreenIcon:) withObject:icon]; + }]; +} + +- (void)sdl_handleSystemRequestHTTP:(SDLOnSystemRequest *)request { + if (request.bulkData.length == 0) { + // TODO: not sure how we want to handle http requests that don't have bulk data (maybe as GET?) + return; + } + + [self sdl_uploadData:request.bulkData + toURLString:request.url + completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + NSString *logMessage = nil; + if (error != nil) { + logMessage = [NSString stringWithFormat:@"OnSystemRequest (HTTP response) = ERROR: %@", error.localizedDescription]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + return; + } + + if (data.length == 0) { + [SDLDebugTool logInfo:@"OnSystemRequest (HTTP response) failure: no data returned" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + return; + } + + // Show the HTTP response + NSString *responseLogString = [NSString stringWithFormat:@"OnSystemRequest (HTTP) response: %@", response]; + [SDLDebugTool logInfo:responseLogString withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + + // Create the SystemRequest RPC to send to module. + SDLPutFile *putFile = [[SDLPutFile alloc] init]; + putFile.fileType = [SDLFileType JSON]; + putFile.correlationID = @(POLICIES_CORRELATION_ID); + putFile.syncFileName = @"response_data"; + putFile.bulkData = data; + + // Send and log RPC Request + logMessage = [NSString stringWithFormat:@"SystemRequest (request)\n%@\nData length=%lu", [request serializeAsDictionary:2], (unsigned long)data.length]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + [self sendRPC:putFile]; + }]; +} + +/** + * Determine if the System Request is valid and return it's JSON dictionary, if available. + * + * @param request The system request to parse + * + * @return A parsed JSON dictionary, or nil if it couldn't be parsed + */ +- (NSDictionary *)validateAndParseSystemRequest:(SDLOnSystemRequest *)request { + NSString *urlString = request.url; + SDLFileType *fileType = request.fileType; + + // Validate input + if (urlString == nil || [NSURL URLWithString:urlString] == nil) { + [SDLDebugTool logInfo:@"OnSystemRequest (notification) failure: url is nil" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + return nil; + } + + if (fileType != [SDLFileType JSON]) { + [SDLDebugTool logInfo:@"OnSystemRequest (notification) failure: file type is not JSON" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + return nil; + } + + // Get data dictionary from the bulkData + NSError *error = nil; + NSDictionary *JSONDictionary = [NSJSONSerialization JSONObjectWithData:request.bulkData options:kNilOptions error:&error]; + if (error != nil) { + [SDLDebugTool logInfo:@"OnSystemRequest failure: notification data is not valid JSON." withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + return nil; + } + + return JSONDictionary; +} + +/** + * Start an upload for some data to a web address specified + * + * @param data The data to be passed to the server + * @param urlString The URL the data should be POSTed to + * @param completionHandler A completion handler of what to do when the server responds + */ +- (void)sdl_uploadData:(NSData *_Nonnull)data toURLString:(NSString *_Nonnull)urlString completionHandler:(URLSessionTaskCompletionHandler _Nullable)completionHandler { + // NSURLRequest configuration + NSURL *url = [NSURL URLWithString:urlString]; + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; + [request setValue:@"application/json" forHTTPHeaderField:@"content-type"]; + request.HTTPMethod = @"POST"; + + // Logging + NSString *logMessage = [NSString stringWithFormat:@"OnSystemRequest (HTTP Request) to URL %@", urlString]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + + // Create the upload task + [[SDLURLSession defaultSession] uploadWithURLRequest:request data:data completionHandler:completionHandler]; +} + +/** + * Start an upload for a body data dictionary, this is used by the "proprietary" system request needed for backward compatibility + * + * @param dictionary The system request dictionary that contains the HTTP data to be sent + * @param urlString A string containing the URL to send the upload to + * @param completionHandler A completion handler returning the response from the server to the upload task + */ +- (void)uploadForBodyDataDictionary:(NSDictionary *)dictionary URLString:(NSString *)urlString completionHandler:(URLSessionTaskCompletionHandler)completionHandler { + NSParameterAssert(dictionary != nil); + NSParameterAssert(urlString != nil); + NSParameterAssert(completionHandler != NULL); + + // Extract data from the dictionary + NSDictionary *requestData = dictionary[@"HTTPRequest"]; + NSDictionary *headers = requestData[@"headers"]; + NSString *contentType = headers[@"ContentType"]; + NSTimeInterval timeout = [headers[@"ConnectTimeout"] doubleValue]; + NSString *method = headers[@"RequestMethod"]; + NSString *bodyString = requestData[@"body"]; + NSData *bodyData = [bodyString dataUsingEncoding:NSUTF8StringEncoding]; + + // NSURLRequest configuration + NSURL *url = [NSURL URLWithString:urlString]; + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; + [request setValue:contentType forHTTPHeaderField:@"content-type"]; + request.timeoutInterval = timeout; + request.HTTPMethod = method; + + // Logging + NSString *logMessage = [NSString stringWithFormat:@"OnSystemRequest (HTTP Request) to URL %@", urlString]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + + // Create the upload task + [[SDLURLSession defaultSession] uploadWithURLRequest:request data:bodyData completionHandler:completionHandler]; +} + + +#pragma mark - Delegate management + +- (void)addDelegate:(NSObject<SDLProxyListener> *)delegate { + @synchronized(self.mutableProxyListeners) { + [self.mutableProxyListeners addObject:delegate]; + } +} + +- (void)removeDelegate:(NSObject<SDLProxyListener> *)delegate { + @synchronized(self.mutableProxyListeners) { + [self.mutableProxyListeners removeObject:delegate]; + } +} + +- (void)invokeMethodOnDelegates:(SEL)aSelector withObject:(id)object { + dispatch_async(dispatch_get_main_queue(), ^{ + @autoreleasepool { + for (id<SDLProxyListener> listener in self.proxyListeners) { + if ([listener respondsToSelector:aSelector]) { + // HAX: http://stackoverflow.com/questions/7017281/performselector-may-cause-a-leak-because-its-selector-is-unknown + ((void (*)(id, SEL, id))[(NSObject *)listener methodForSelector:aSelector])(listener, aSelector, object); + } + } + } + }); +} + + +#pragma mark - System Request and SyncP handling + +- (void)sendEncodedSyncPData:(NSDictionary *)encodedSyncPData toURL:(NSString *)urlString withTimeout:(NSNumber *)timeout { + // Configure HTTP URL & Request + NSURL *url = [NSURL URLWithString:urlString]; + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; + request.HTTPMethod = @"POST"; + [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; + request.timeoutInterval = 60; + + // Prepare the data in the required format + NSString *encodedSyncPDataString = [[NSString stringWithFormat:@"%@", encodedSyncPData] componentsSeparatedByString:@"\""][1]; + NSArray *array = [NSArray arrayWithObject:encodedSyncPDataString]; + NSDictionary *dictionary = @{ @"data" : array }; + NSError *JSONSerializationError = nil; + NSData *data = [NSJSONSerialization dataWithJSONObject:dictionary options:kNilOptions error:&JSONSerializationError]; + if (JSONSerializationError) { + NSString *logMessage = [NSString stringWithFormat:@"Error formatting data for HTTP Request. %@", JSONSerializationError]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + return; + } + + // Send the HTTP Request + [[SDLURLSession defaultSession] uploadWithURLRequest:request + data:data + completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + [self syncPDataNetworkRequestCompleteWithData:data response:response error:error]; + }]; + + [SDLDebugTool logInfo:@"OnEncodedSyncPData (HTTP request)" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; +} + +// Handle the OnEncodedSyncPData HTTP Response +- (void)syncPDataNetworkRequestCompleteWithData:(NSData *)data response:(NSURLResponse *)response error:(NSError *)error { + // Sample of response: {"data":["SDLKGLSDKFJLKSjdslkfjslkJLKDSGLKSDJFLKSDJF"]} + [SDLDebugTool logInfo:@"OnEncodedSyncPData (HTTP response)" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + + // Validate response data. + if (data == nil || data.length == 0) { + [SDLDebugTool logInfo:@"OnEncodedSyncPData (HTTP response) failure: no data returned" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + return; + } + + // Convert data to RPCRequest + NSError *JSONConversionError = nil; + NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&JSONConversionError]; + if (!JSONConversionError) { + SDLEncodedSyncPData *request = [[SDLEncodedSyncPData alloc] init]; + request.correlationID = [NSNumber numberWithInt:POLICIES_CORRELATION_ID]; + request.data = [responseDictionary objectForKey:@"data"]; + + [self sendRPC:request]; + } +} + + +#pragma mark - PutFile Streaming +- (void)putFileStream:(NSInputStream *)inputStream withRequest:(SDLPutFile *)putFileRPCRequest { + inputStream.delegate = self; + objc_setAssociatedObject(inputStream, @"SDLPutFile", putFileRPCRequest, OBJC_ASSOCIATION_RETAIN); + objc_setAssociatedObject(inputStream, @"BaseOffset", [putFileRPCRequest offset], OBJC_ASSOCIATION_RETAIN); + + [inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + [inputStream open]; +} + +- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode { + switch (eventCode) { + case NSStreamEventHasBytesAvailable: { + // Grab some bytes from the stream and send them in a SDLPutFile RPC Request + NSUInteger currentStreamOffset = [[stream propertyForKey:NSStreamFileCurrentOffsetKey] unsignedIntegerValue]; + + NSMutableData *buffer = [NSMutableData dataWithLength:[SDLGlobals globals].maxMTUSize]; + NSUInteger nBytesRead = [(NSInputStream *)stream read:(uint8_t *)buffer.mutableBytes maxLength:buffer.length]; + if (nBytesRead > 0) { + NSData *data = [buffer subdataWithRange:NSMakeRange(0, nBytesRead)]; + NSUInteger baseOffset = [(NSNumber *)objc_getAssociatedObject(stream, @"BaseOffset") unsignedIntegerValue]; + NSUInteger newOffset = baseOffset + currentStreamOffset; + + SDLPutFile *putFileRPCRequest = (SDLPutFile *)objc_getAssociatedObject(stream, @"SDLPutFile"); + [putFileRPCRequest setOffset:[NSNumber numberWithUnsignedInteger:newOffset]]; + [putFileRPCRequest setLength:[NSNumber numberWithUnsignedInteger:nBytesRead]]; + [putFileRPCRequest setBulkData:data]; + + [self sendRPC:putFileRPCRequest]; + } + + break; + } + case NSStreamEventEndEncountered: { + // Cleanup the stream + [stream close]; + [stream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + + break; + } + case NSStreamEventErrorOccurred: { + [SDLDebugTool logInfo:@"Stream Event: Error" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + break; + } + default: { + break; + } + } +} + + +#pragma mark - Siphon management ++ (void)enableSiphonDebug { + [SDLSiphonServer enableSiphonDebug]; +} + ++ (void)disableSiphonDebug { + [SDLSiphonServer disableSiphonDebug]; +} + +@end diff --git a/SmartDeviceLink/SDLProxyFactory.h b/SmartDeviceLink/SDLProxyFactory.h new file mode 100644 index 000000000..b3a7ac6a0 --- /dev/null +++ b/SmartDeviceLink/SDLProxyFactory.h @@ -0,0 +1,19 @@ +// SDLProxyFactory.h +// + +#import <Foundation/Foundation.h> + +#import "SDLProxyListener.h" + +@class SDLProxy; + + +@interface SDLProxyFactory : NSObject { +} + ++ (SDLProxy *)buildSDLProxyWithListener:(NSObject<SDLProxyListener> *)listener; + ++ (SDLProxy *)buildSDLProxyWithListener:(NSObject<SDLProxyListener> *)listener + tcpIPAddress:(NSString *)ipaddress + tcpPort:(NSString *)port; +@end diff --git a/SmartDeviceLink/SDLProxyFactory.m b/SmartDeviceLink/SDLProxyFactory.m new file mode 100644 index 000000000..b2320c641 --- /dev/null +++ b/SmartDeviceLink/SDLProxyFactory.m @@ -0,0 +1,37 @@ +// SDLSyncProxyFactory.m +// + +#import "SDLProxyFactory.h" + +#import "SDLDebugTool.h" +#import "SDLIAPTransport.h" +#import "SDLProtocol.h" +#import "SDLProxy.h" +#import "SDLTCPTransport.h" + + +@implementation SDLProxyFactory + ++ (SDLProxy *)buildSDLProxyWithListener:(NSObject<SDLProxyListener> *)delegate { + SDLIAPTransport *transport = [[SDLIAPTransport alloc] init]; + SDLProtocol *protocol = [[SDLProtocol alloc] init]; + SDLProxy *ret = [[SDLProxy alloc] initWithTransport:transport protocol:protocol delegate:delegate]; + + return ret; +} + ++ (SDLProxy *)buildSDLProxyWithListener:(NSObject<SDLProxyListener> *)delegate + tcpIPAddress:(NSString *)ipaddress + tcpPort:(NSString *)port { + SDLTCPTransport *transport = [[SDLTCPTransport alloc] init]; + transport.hostName = ipaddress; + transport.portNumber = port; + + SDLProtocol *protocol = [[SDLProtocol alloc] init]; + + SDLProxy *ret = [[SDLProxy alloc] initWithTransport:transport protocol:protocol delegate:delegate]; + + return ret; +} + +@end
\ No newline at end of file diff --git a/SmartDeviceLink/SDLProxyListener.h b/SmartDeviceLink/SDLProxyListener.h new file mode 100644 index 000000000..60e4d6607 --- /dev/null +++ b/SmartDeviceLink/SDLProxyListener.h @@ -0,0 +1,135 @@ +// SDLProxyListener.h +// + +@import UIKit; + +@class SDLAddCommandResponse; +@class SDLAddSubMenuResponse; +@class SDLAlertManeuverResponse; +@class SDLAlertResponse; +@class SDLChangeRegistrationResponse; +@class SDLCreateInteractionChoiceSetResponse; +@class SDLDeleteCommandResponse; +@class SDLDeleteFileResponse; +@class SDLDeleteInteractionChoiceSetResponse; +@class SDLDeleteSubMenuResponse; +@class SDLDiagnosticMessageResponse; +@class SDLDialNumberResponse; +@class SDLEncodedSyncPDataResponse; +@class SDLEndAudioPassThruResponse; +@class SDLGenericResponse; +@class SDLGetDTCsResponse; +@class SDLGetVehicleDataResponse; +@class SDLListFilesResponse; +@class SDLOnAppInterfaceUnregistered; +@class SDLOnAudioPassThru; +@class SDLOnButtonEvent; +@class SDLOnButtonPress; +@class SDLOnCommand; +@class SDLOnDriverDistraction; +@class SDLOnEncodedSyncPData; +@class SDLOnHashChange; +@class SDLOnHMIStatus; +@class SDLOnLanguageChange; +@class SDLOnLockScreenStatus; +@class SDLOnPermissionsChange; +@class SDLOnSyncPData; +@class SDLOnSystemRequest; +@class SDLOnVehicleData; +@class SDLOnTBTClientState; +@class SDLOnTouchEvent; +@class SDLOnVehicleData; +@class SDLPerformAudioPassThruResponse; +@class SDLPerformInteractionResponse; +@class SDLPutFileResponse; +@class SDLReadDIDResponse; +@class SDLRegisterAppInterfaceResponse; +@class SDLResetGlobalPropertiesResponse; +@class SDLScrollableMessageResponse; +@class SDLSendLocationResponse; +@class SDLSetAppIconResponse; +@class SDLSetDisplayLayoutResponse; +@class SDLSetGlobalPropertiesResponse; +@class SDLSetMediaClockTimerResponse; +@class SDLShowConstantTBTResponse; +@class SDLShowResponse; +@class SDLSliderResponse; +@class SDLSpeakResponse; +@class SDLSubscribeButtonResponse; +@class SDLSubscribeVehicleDataResponse; +@class SDLSyncPDataResponse; +@class SDLUpdateTurnListResponse; +@class SDLUnregisterAppInterfaceResponse; +@class SDLUnsubscribeButtonResponse; +@class SDLUnsubscribeVehicleDataResponse; + + +@protocol SDLProxyListener <NSObject> + +- (void)onOnDriverDistraction:(SDLOnDriverDistraction *)notification; +- (void)onOnHMIStatus:(SDLOnHMIStatus *)notification; +- (void)onProxyClosed; +- (void)onProxyOpened; + +@optional + +- (void)onAddCommandResponse:(SDLAddCommandResponse *)response; +- (void)onAddSubMenuResponse:(SDLAddSubMenuResponse *)response; +- (void)onAlertManeuverResponse:(SDLAlertManeuverResponse *)response; +- (void)onAlertResponse:(SDLAlertResponse *)response; +- (void)onChangeRegistrationResponse:(SDLChangeRegistrationResponse *)response; +- (void)onCreateInteractionChoiceSetResponse:(SDLCreateInteractionChoiceSetResponse *)response; +- (void)onDeleteCommandResponse:(SDLDeleteCommandResponse *)response; +- (void)onDeleteFileResponse:(SDLDeleteFileResponse *)response; +- (void)onDeleteInteractionChoiceSetResponse:(SDLDeleteInteractionChoiceSetResponse *)response; +- (void)onDeleteSubMenuResponse:(SDLDeleteSubMenuResponse *)response; +- (void)onDiagnosticMessageResponse:(SDLDiagnosticMessageResponse *)response; +- (void)onDialNumberResponse:(SDLDialNumberResponse *)response; +- (void)onEncodedSyncPDataResponse:(SDLEncodedSyncPDataResponse *)response; +- (void)onEndAudioPassThruResponse:(SDLEndAudioPassThruResponse *)response; +- (void)onError:(NSException *)e; +- (void)onGenericResponse:(SDLGenericResponse *)response; +- (void)onGetDTCsResponse:(SDLGetDTCsResponse *)response; +- (void)onGetVehicleDataResponse:(SDLGetVehicleDataResponse *)response; +- (void)onListFilesResponse:(SDLListFilesResponse *)response; +- (void)onReceivedLockScreenIcon:(UIImage *)icon; +- (void)onOnAppInterfaceUnregistered:(SDLOnAppInterfaceUnregistered *)notification; +- (void)onOnAudioPassThru:(SDLOnAudioPassThru *)notification; +- (void)onOnButtonEvent:(SDLOnButtonEvent *)notification; +- (void)onOnButtonPress:(SDLOnButtonPress *)notification; +- (void)onOnCommand:(SDLOnCommand *)notification; +- (void)onOnEncodedSyncPData:(SDLOnEncodedSyncPData *)notification; +- (void)onOnHashChange:(SDLOnHashChange *)notification; +- (void)onOnLanguageChange:(SDLOnLanguageChange *)notification; +- (void)onOnLockScreenNotification:(SDLOnLockScreenStatus *)notification; +- (void)onOnPermissionsChange:(SDLOnPermissionsChange *)notification; +- (void)onOnSyncPData:(SDLOnSyncPData *)notification; +- (void)onOnSystemRequest:(SDLOnSystemRequest *)notification; +- (void)onOnTBTClientState:(SDLOnTBTClientState *)notification; +- (void)onOnTouchEvent:(SDLOnTouchEvent *)notification; +- (void)onOnVehicleData:(SDLOnVehicleData *)notification; +- (void)onPerformAudioPassThruResponse:(SDLPerformAudioPassThruResponse *)response; +- (void)onPerformInteractionResponse:(SDLPerformInteractionResponse *)response; +- (void)onPutFileResponse:(SDLPutFileResponse *)response; +- (void)onReadDIDResponse:(SDLReadDIDResponse *)response; +- (void)onRegisterAppInterfaceResponse:(SDLRegisterAppInterfaceResponse *)response; +- (void)onResetGlobalPropertiesResponse:(SDLResetGlobalPropertiesResponse *)response; +- (void)onScrollableMessageResponse:(SDLScrollableMessageResponse *)response; +- (void)onSendLocationResponse:(SDLSendLocationResponse *)response; +- (void)onSetAppIconResponse:(SDLSetAppIconResponse *)response; +- (void)onSetDisplayLayoutResponse:(SDLSetDisplayLayoutResponse *)response; +- (void)onSetGlobalPropertiesResponse:(SDLSetGlobalPropertiesResponse *)response; +- (void)onSetMediaClockTimerResponse:(SDLSetMediaClockTimerResponse *)response; +- (void)onShowConstantTBTResponse:(SDLShowConstantTBTResponse *)response; +- (void)onShowResponse:(SDLShowResponse *)response; +- (void)onSliderResponse:(SDLSliderResponse *)response; +- (void)onSpeakResponse:(SDLSpeakResponse *)response; +- (void)onSubscribeButtonResponse:(SDLSubscribeButtonResponse *)response; +- (void)onSubscribeVehicleDataResponse:(SDLSubscribeVehicleDataResponse *)response; +- (void)onSyncPDataResponse:(SDLSyncPDataResponse *)response; +- (void)onUpdateTurnListResponse:(SDLUpdateTurnListResponse *)response; +- (void)onUnregisterAppInterfaceResponse:(SDLUnregisterAppInterfaceResponse *)response; +- (void)onUnsubscribeButtonResponse:(SDLUnsubscribeButtonResponse *)response; +- (void)onUnsubscribeVehicleDataResponse:(SDLUnsubscribeVehicleDataResponse *)response; + +@end diff --git a/SmartDeviceLink/SDLPutFile.h b/SmartDeviceLink/SDLPutFile.h new file mode 100644 index 000000000..eb7bae2bf --- /dev/null +++ b/SmartDeviceLink/SDLPutFile.h @@ -0,0 +1,80 @@ +// SDLPutFile.h +// + +#import "SDLRPCRequest.h" + +@class SDLFileType; + + +/** + * Used to push a binary data onto the SDL module from a mobile device, such as + * icons and album art + * + * Since SmartDeviceLink 2.0 + * @see SDLDeleteFile + * @see SDLListFiles + */ +@interface SDLPutFile : SDLRPCRequest { +} + +/** + * Constructs a new SDLPutFile object + */ +- (instancetype)init; + +/** + * Constructs a new SDLPutFile object indicated by the dictionary parameter + * + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * A file reference name + * + * Required, maxlength 255 characters + */ +@property (strong) NSString *syncFileName; + +/** + * A FileType value representing a selected file type + * + * Required + */ +@property (strong) SDLFileType *fileType; + +/** + * A value to indicates if the file is meant to persist between + * sessions / ignition cycles. If set to TRUE, then the system will aim to + * persist this file through session / cycles. While files with this + * designation will have priority over others, they are subject to deletion + * by the system at any time. In the event of automatic deletion by the + * system, the app will receive a rejection and have to resend the file. If + * omitted, the value will be set to false + * + * Boolean, Optional, default = NO + */ +@property (strong) NSNumber *persistentFile; + +/** + * Indicates if the file is meant to be passed through core to elsewhere on the system. If set to TRUE, then the system will instead pass the data thru as it arrives to a predetermined area outside of core. + * + * Boolean, Optional, default = NO + */ +@property (strong) NSNumber *systemFile; + +/** + * Offset in bytes for resuming partial data chunks. + * + * Integer, Optional, 0 - 100,000,000,000 + */ +@property (strong) NSNumber *offset; + +/** + * Length in bytes for resuming partial data chunks. If offset is set to 0, then length is the total length of the file to be downloaded + * + * Integer, Optional, 0 - 100,000,000,000 + */ +@property (strong) NSNumber *length; + +@end diff --git a/SmartDeviceLink/SDLPutFile.m b/SmartDeviceLink/SDLPutFile.m new file mode 100644 index 000000000..69d83edcd --- /dev/null +++ b/SmartDeviceLink/SDLPutFile.m @@ -0,0 +1,101 @@ +// SDLPutFile.m +// + +#import "SDLPutFile.h" + +#import "SDLFileType.h" +#import "SDLNames.h" + + +@implementation SDLPutFile + +- (instancetype)init { + if (self = [super initWithName:NAMES_PutFile]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setSyncFileName:(NSString *)syncFileName { + if (syncFileName != nil) { + [parameters setObject:syncFileName forKey:NAMES_syncFileName]; + } else { + [parameters removeObjectForKey:NAMES_syncFileName]; + } +} + +- (NSString *)syncFileName { + return [parameters objectForKey:NAMES_syncFileName]; +} + +- (void)setFileType:(SDLFileType *)fileType { + if (fileType != nil) { + [parameters setObject:fileType forKey:NAMES_fileType]; + } else { + [parameters removeObjectForKey:NAMES_fileType]; + } +} + +- (SDLFileType *)fileType { + NSObject *obj = [parameters objectForKey:NAMES_fileType]; + if (obj == nil || [obj isKindOfClass:SDLFileType.class]) { + return (SDLFileType *)obj; + } else { + return [SDLFileType valueOf:(NSString *)obj]; + } +} + +- (void)setPersistentFile:(NSNumber *)persistentFile { + if (persistentFile != nil) { + [parameters setObject:persistentFile forKey:NAMES_persistentFile]; + } else { + [parameters removeObjectForKey:NAMES_persistentFile]; + } +} + +- (NSNumber *)persistentFile { + return [parameters objectForKey:NAMES_persistentFile]; +} + +- (void)setSystemFile:(NSNumber *)systemFile { + if (systemFile != nil) { + [parameters setObject:systemFile forKey:NAMES_systemFile]; + } else { + [parameters removeObjectForKey:NAMES_systemFile]; + } +} + +- (NSNumber *)systemFile { + return [parameters objectForKey:NAMES_systemFile]; +} + +- (void)setOffset:(NSNumber *)offset { + if (offset != nil) { + [parameters setObject:offset forKey:NAMES_offset]; + } else { + [parameters removeObjectForKey:NAMES_offset]; + } +} + +- (NSNumber *)offset { + return [parameters objectForKey:NAMES_offset]; +} + +- (void)setLength:(NSNumber *)length { + if (length != nil) { + [parameters setObject:length forKey:NAMES_length]; + } else { + [parameters removeObjectForKey:NAMES_length]; + } +} + +- (NSNumber *)length { + return [parameters objectForKey:NAMES_length]; +} + +@end diff --git a/SmartDeviceLink/SDLPutFileResponse.h b/SmartDeviceLink/SDLPutFileResponse.h new file mode 100644 index 000000000..9857607ca --- /dev/null +++ b/SmartDeviceLink/SDLPutFileResponse.h @@ -0,0 +1,24 @@ +// SDLPutFileResponse.h +// + + +#import "SDLRPCResponse.h" + +/** + * Put File Response is sent, when SDLPutFile has been called + * + * Since SmartDeviceLink 2.0 + */ +@interface SDLPutFileResponse : SDLRPCResponse { +} +/** + * @abstract Constructs a new SDLPutFileResponse object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLPutFileResponse object indicated by the dictionary parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; +@property (strong) NSNumber *spaceAvailable; +@end diff --git a/SmartDeviceLink/SDLPutFileResponse.m b/SmartDeviceLink/SDLPutFileResponse.m new file mode 100644 index 000000000..4a956cfbd --- /dev/null +++ b/SmartDeviceLink/SDLPutFileResponse.m @@ -0,0 +1,35 @@ +// SDLPutFileResponse.m +// + + +#import "SDLPutFileResponse.h" + +#import "SDLNames.h" + +@implementation SDLPutFileResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_PutFile]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setSpaceAvailable:(NSNumber *)spaceAvailable { + if (spaceAvailable != nil) { + [parameters setObject:spaceAvailable forKey:NAMES_spaceAvailable]; + } else { + [parameters removeObjectForKey:NAMES_spaceAvailable]; + } +} + +- (NSNumber *)spaceAvailable { + return [parameters objectForKey:NAMES_spaceAvailable]; +} + +@end diff --git a/SmartDeviceLink/SDLRPCMessage.h b/SmartDeviceLink/SDLRPCMessage.h new file mode 100644 index 000000000..fc5f577ef --- /dev/null +++ b/SmartDeviceLink/SDLRPCMessage.h @@ -0,0 +1,25 @@ +// SDLRPCMessage.h +// + +#import "SDLEnum.h" + +#import "SDLRPCStruct.h" + +@interface SDLRPCMessage : SDLRPCStruct { + NSMutableDictionary *function; + NSMutableDictionary *parameters; + NSString *messageType; +} + +- (instancetype)initWithName:(NSString *)name; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; +- (NSString *)getFunctionName; +- (void)setFunctionName:(NSString *)functionName; +- (NSObject *)getParameters:(NSString *)functionName; +- (void)setParameters:(NSString *)functionName value:(NSObject *)value; + +@property (strong) NSData *bulkData; +@property (strong, readonly) NSString *name; +@property (strong, readonly) NSString *messageType; + +@end diff --git a/SmartDeviceLink/SDLRPCMessage.m b/SmartDeviceLink/SDLRPCMessage.m new file mode 100644 index 000000000..be5f95334 --- /dev/null +++ b/SmartDeviceLink/SDLRPCMessage.m @@ -0,0 +1,81 @@ +// SDLRPCMessage.m +// + + +#import "SDLRPCMessage.h" + +#import "SDLNames.h" + + +@implementation SDLRPCMessage + +@synthesize messageType; + +- (instancetype)initWithName:(NSString *)name { + if (self = [super init]) { + function = [[NSMutableDictionary alloc] initWithCapacity:3]; + parameters = [[NSMutableDictionary alloc] init]; + messageType = NAMES_request; + [store setObject:function forKey:messageType]; + [function setObject:parameters forKey:NAMES_parameters]; + [function setObject:name forKey:NAMES_operation_name]; + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + NSEnumerator *enumerator = [store keyEnumerator]; + while (messageType = [enumerator nextObject]) { + if ([messageType isEqualToString:@"bulkData"] == FALSE) { + break; + } + } + + function = [store objectForKey:messageType]; + parameters = [function objectForKey:NAMES_parameters]; + self.bulkData = [dict objectForKey:@"bulkData"]; + } + return self; +} + +- (NSString *)getFunctionName { + return [function objectForKey:NAMES_operation_name]; +} + +- (void)setFunctionName:(NSString *)functionName { + if (functionName != nil) { + [function setObject:functionName forKey:NAMES_operation_name]; + } else { + [function removeObjectForKey:NAMES_operation_name]; + } +} + +- (NSObject *)getParameters:(NSString *)functionName { + return [parameters objectForKey:functionName]; +} + +- (void)setParameters:(NSString *)functionName value:(NSObject *)value { + if (value != nil) { + [parameters setObject:value forKey:functionName]; + } else { + [parameters removeObjectForKey:functionName]; + } +} + +- (void)dealloc { + function = nil; + parameters = nil; +} + +- (NSString *)name { + return [function objectForKey:NAMES_operation_name]; +} + +- (NSString *)description { + NSMutableString *description = [NSMutableString stringWithFormat:@"%@ (%@)\n%@", self.name, self.messageType, self->parameters]; + + return description; +} + +@end diff --git a/SmartDeviceLink/SDLRPCMessageType.h b/SmartDeviceLink/SDLRPCMessageType.h new file mode 100644 index 000000000..35f841687 --- /dev/null +++ b/SmartDeviceLink/SDLRPCMessageType.h @@ -0,0 +1,10 @@ +// SDLRPCMessageType.h +// + +#import <Foundation/Foundation.h> + +typedef NS_ENUM(Byte, SDLRPCMessageType) { + SDLRPCMessageTypeRequest = 0, + SDLRPCMessageTypeResponse, + SDLRPCMessageTypeNotification +}; diff --git a/SmartDeviceLink/SDLRPCNotification.h b/SmartDeviceLink/SDLRPCNotification.h new file mode 100644 index 000000000..05f182b9b --- /dev/null +++ b/SmartDeviceLink/SDLRPCNotification.h @@ -0,0 +1,13 @@ +// SDLRPCNotification.h +// + + +#import "SDLRPCMessage.h" + +@interface SDLRPCNotification : SDLRPCMessage { +} + +- (instancetype)initWithName:(NSString *)name; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLRPCNotification.m b/SmartDeviceLink/SDLRPCNotification.m new file mode 100644 index 000000000..5c2a063dd --- /dev/null +++ b/SmartDeviceLink/SDLRPCNotification.m @@ -0,0 +1,35 @@ +// SDLRPCNotification.m +// + + +#import "SDLRPCNotification.h" + +#import "SDLNames.h" + +@implementation SDLRPCNotification + +- (instancetype)initWithName:(NSString *)name { + self = [super initWithName:name]; + if (!self) { + return nil; + } + + messageType = NAMES_notification; + [store setObject:function forKey:messageType]; + + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + self = [super initWithDictionary:dict]; + if (!self) { + return nil; + } + + messageType = NAMES_notification; + [store setObject:function forKey:messageType]; + + return self; +} + +@end diff --git a/SmartDeviceLink/SDLRPCPayload.h b/SmartDeviceLink/SDLRPCPayload.h new file mode 100644 index 000000000..1a490d956 --- /dev/null +++ b/SmartDeviceLink/SDLRPCPayload.h @@ -0,0 +1,21 @@ +// SDLRPCPayload.h +// + + +#import <Foundation/Foundation.h> + +#import "SDLRPCMessageType.h" + + +@interface SDLRPCPayload : NSObject + +@property (assign) SDLRPCMessageType rpcType; +@property (assign) UInt32 functionID; +@property (assign) UInt32 correlationID; +@property (strong) NSData *jsonData; +@property (strong) NSData *binaryData; + +- (NSData *)data; ++ (id)rpcPayloadWithData:(NSData *)data; + +@end diff --git a/SmartDeviceLink/SDLRPCPayload.m b/SmartDeviceLink/SDLRPCPayload.m new file mode 100644 index 000000000..25a4c9dab --- /dev/null +++ b/SmartDeviceLink/SDLRPCPayload.m @@ -0,0 +1,121 @@ +// SDLRPCPayload.h +// + + +#import "SDLRPCPayload.h" + +const NSUInteger RPC_HEADER_SIZE = 12; + +@implementation SDLRPCPayload + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithData:(NSData *)data { + unsigned long dataLength = data.length; + + if (data == nil || dataLength == 0) { + NSLog(@"Error: data is nil."); + return nil; + } + + if (dataLength < RPC_HEADER_SIZE) { + NSLog(@"Error: insfficient data to form RPC header."); + return nil; + } + + if (self = [self init]) { + @try { + // Setup our pointers for data access + UInt8 *bytePointer = (UInt8 *)data.bytes; + UInt32 *ui32Pointer = (UInt32 *)data.bytes; + + // Extract the parts + UInt8 rpcType = (bytePointer[0] & 0xF0) >> 4; + + self.rpcType = rpcType; + + UInt32 functionID = ui32Pointer[0]; + functionID = CFSwapInt32BigToHost(functionID) & 0x0FFFFFFF; + self.functionID = functionID; + + UInt32 correlationID = ui32Pointer[1]; + correlationID = CFSwapInt32BigToHost(correlationID); + self.correlationID = correlationID; + + UInt32 jsonDataSize = ui32Pointer[2]; + jsonDataSize = CFSwapInt32BigToHost(jsonDataSize); + + NSData *jsonData = nil; + NSUInteger offsetOfJSONData = RPC_HEADER_SIZE; + if (jsonDataSize > 0 && jsonDataSize <= dataLength - RPC_HEADER_SIZE) { + jsonData = [data subdataWithRange:NSMakeRange(offsetOfJSONData, jsonDataSize)]; + } + self.jsonData = jsonData; + + NSData *binaryData = nil; + NSUInteger offsetOfBinaryData = RPC_HEADER_SIZE + jsonDataSize; + NSInteger binaryDataSize = data.length - jsonDataSize - RPC_HEADER_SIZE; + if (binaryDataSize > 0) { + binaryData = [data subdataWithRange:NSMakeRange(offsetOfBinaryData, binaryDataSize)]; + } + self.binaryData = binaryData; + + } @catch (NSException *e) { + // Print exception information + NSLog(@"NSException caught in SDLRPCPayload::initWithData"); + NSLog(@"Name: %@", e.name); + NSLog(@"Reason: %@", e.reason); + NSLog(@"Data: %@", data.debugDescription); + return nil; + } + } + + return self; +} + +- (NSData *)data { + // Header is: + // RPC Type - first 4 bits + // RPC Function ID - next 28 bits + // Correlation ID - next 32 bits + // JSON size - next 32 bits + UInt8 headerBuffer[RPC_HEADER_SIZE]; + *(UInt32 *)&headerBuffer[0] = CFSwapInt32HostToBig(self.functionID); + *(UInt32 *)&headerBuffer[4] = CFSwapInt32HostToBig(self.correlationID); + *(UInt32 *)&headerBuffer[8] = CFSwapInt32HostToBig((UInt32)self.jsonData.length); + UInt8 rpcType = (self.rpcType & 0x0F) << 4; + headerBuffer[0] &= 0x0F; + headerBuffer[0] |= rpcType; + + // Serialize the header, the json data then the binary data + NSMutableData *dataOut = [NSMutableData dataWithCapacity:[self size]]; + [dataOut appendBytes:&headerBuffer length:12]; + [dataOut appendData:self.jsonData]; + [dataOut appendData:self.binaryData]; + + return dataOut; +} + +- (NSUInteger)size { + NSUInteger headerSize = RPC_HEADER_SIZE; + NSUInteger jsonDataSize = self.jsonData.length; + NSUInteger binaryDataSize = self.binaryData.length; + + return (headerSize + jsonDataSize + binaryDataSize); +} + +- (NSString *)description { + NSMutableString *description = [[NSMutableString alloc] init]; + [description appendFormat:@" rpcType:%i, functionID:%i, correlationID:%i, json:%lu bytes, binary:%lu bytes", self.rpcType, (unsigned int)self.functionID, (unsigned int)self.correlationID, (unsigned long)self.jsonData.length, (unsigned long)self.binaryData.length]; + + return description; +} + ++ (id)rpcPayloadWithData:(NSData *)data { + return [[SDLRPCPayload alloc] initWithData:data]; +} +@end diff --git a/SmartDeviceLink/SDLRPCRequest.h b/SmartDeviceLink/SDLRPCRequest.h new file mode 100644 index 000000000..e637eb4bc --- /dev/null +++ b/SmartDeviceLink/SDLRPCRequest.h @@ -0,0 +1,12 @@ +// SDLRPCRequest.h +// + + +#import "SDLRPCMessage.h" + +@interface SDLRPCRequest : SDLRPCMessage { +} + +@property (strong) NSNumber *correlationID; + +@end diff --git a/SmartDeviceLink/SDLRPCRequest.m b/SmartDeviceLink/SDLRPCRequest.m new file mode 100644 index 000000000..48c568c9d --- /dev/null +++ b/SmartDeviceLink/SDLRPCRequest.m @@ -0,0 +1,23 @@ +// SDLRPCRequest.m +// + + +#import "SDLRPCRequest.h" + +#import "SDLNames.h" + +@implementation SDLRPCRequest + +- (NSNumber *)correlationID { + return [function objectForKey:NAMES_correlationID]; +} + +- (void)setCorrelationID:(NSNumber *)corrID { + if (corrID != nil) { + [function setObject:corrID forKey:NAMES_correlationID]; + } else { + [function removeObjectForKey:NAMES_correlationID]; + } +} + +@end diff --git a/SmartDeviceLink/SDLRPCRequestFactory.h b/SmartDeviceLink/SDLRPCRequestFactory.h new file mode 100644 index 000000000..6df474850 --- /dev/null +++ b/SmartDeviceLink/SDLRPCRequestFactory.h @@ -0,0 +1,210 @@ +// SDLRPCRequestFactory.h +// + +#import <Foundation/Foundation.h> + +@class SDLAddCommand; +@class SDLAddSubMenu; +@class SDLAlert; +@class SDLAlertManeuver; +@class SDLAppHMIType; +@class SDLAudioType; +@class SDLBitsPerSample; +@class SDLButtonName; +@class SDLChangeRegistration; +@class SDLCreateInteractionChoiceSet; +@class SDLDeleteCommand; +@class SDLDeleteFile; +@class SDLDeleteInteractionChoiceSet; +@class SDLDeleteSubMenu; +@class SDLDialNumber; +@class SDLEndAudioPassThru; +@class SDLFileType; +@class SDLGetDTCs; +@class SDLGetVehicleData; +@class SDLImage; +@class SDLImageType; +@class SDLInteractionMode; +@class SDLLanguage; +@class SDLListFiles; +@class SDLPerformAudioPassThru; +@class SDLPerformInteraction; +@class SDLPutFile; +@class SDLReadDID; +@class SDLRegisterAppInterface; +@class SDLResetGlobalProperties; +@class SDLSamplingRate; +@class SDLScrollableMessage; +@class SDLSendLocation; +@class SDLSetAppIcon; +@class SDLSetDisplayLayout; +@class SDLSetGlobalProperties; +@class SDLSetMediaClockTimer; +@class SDLShow; +@class SDLShowConstantTBT; +@class SDLSlider; +@class SDLSpeak; +@class SDLSubscribeButton; +@class SDLSubscribeVehicleData; +@class SDLTextAlignment; +@class SDLUnregisterAppInterface; +@class SDLUnsubscribeButton; +@class SDLUnsubscribeVehicleData; +@class SDLUpdateMode; +@class SDLUpdateTurnList; + + +@interface SDLRPCRequestFactory : NSObject { +} + +//***** AddCommand ***** ++ (SDLAddCommand *)buildAddCommandWithID:(NSNumber *)cmdID menuName:(NSString *)menuName parentID:(NSNumber *)parentID position:(NSNumber *)position vrCommands:(NSArray *)vrCommands iconValue:(NSString *)iconValue iconType:(SDLImageType *)iconType correlationID:(NSNumber *)correlationID; + ++ (SDLAddCommand *)buildAddCommandWithID:(NSNumber *)cmdID menuName:(NSString *)menuName vrCommands:(NSArray *)vrCommands correlationID:(NSNumber *)correlationID; + ++ (SDLAddCommand *)buildAddCommandWithID:(NSNumber *)cmdID vrCommands:(NSArray *)vrCommands correlationID:(NSNumber *)correlationID; +//***** + + +//***** AddSubMenu ***** ++ (SDLAddSubMenu *)buildAddSubMenuWithID:(NSNumber *)menuID menuName:(NSString *)menuName position:(NSNumber *)position correlationID:(NSNumber *)correlationID; + ++ (SDLAddSubMenu *)buildAddSubMenuWithID:(NSNumber *)menuID menuName:(NSString *)menuName correlationID:(NSNumber *)correlationID; +//***** + + +//***** Alert ***** ++ (SDLAlert *)buildAlertWithTTS:(NSString *)ttsText alertText1:(NSString *)alertText1 alertText2:(NSString *)alertText2 alertText3:(NSString *)alertText3 playTone:(NSNumber *)playTone duration:(NSNumber *)duration correlationID:(NSNumber *)correlationID; + ++ (SDLAlert *)buildAlertWithTTS:(NSString *)ttsText alertText1:(NSString *)alertText1 alertText2:(NSString *)alertText2 playTone:(NSNumber *)playTone duration:(NSNumber *)duration correlationID:(NSNumber *)correlationID; + ++ (SDLAlert *)buildAlertWithTTS:(NSString *)ttsText playTone:(NSNumber *)playTone correlationID:(NSNumber *) + correlationID; + +//*** ++ (SDLAlert *)buildAlertWithTTSChunks:(NSArray *)ttsChunks alertText1:(NSString *)alertText1 alertText2:(NSString *)alertText2 alertText3:(NSString *)alertText3 playTone:(NSNumber *)playTone duration:(NSNumber *)duration softButtons:(NSArray *)softButtons correlationID:(NSNumber *)correlationID; + ++ (SDLAlert *)buildAlertWithTTSChunks:(NSArray *)ttsChunks playTone:(NSNumber *)playTone correlationID:(NSNumber *)correlationID; + +//*** ++ (SDLAlert *)buildAlertWithAlertText1:(NSString *)alertText1 alertText2:(NSString *)alertText2 alertText3:(NSString *)alertText3 duration:(NSNumber *)duration softButtons:(NSArray *)softButtons correlationID:(NSNumber *)correlationID; + ++ (SDLAlert *)buildAlertWithAlertText1:(NSString *)alertText1 alertText2:(NSString *)alertText2 alertText3:(NSString *)alertText3 duration:(NSNumber *)duration correlationID:(NSNumber *)correlationID; + ++ (SDLAlert *)buildAlertWithAlertText1:(NSString *)alertText1 alertText2:(NSString *)alertText2 duration:(NSNumber *)duration correlationID:(NSNumber *)correlationID; +//***** + ++ (SDLAlertManeuver *)buildAlertManeuverwithTTSchunks:(NSMutableArray *)ttsChunks softButtons:(NSMutableArray *)softButtons correlationID:(NSNumber *)correlationID; + ++ (SDLChangeRegistration *)buildChangeRegistrationWithLanguage:(SDLLanguage *)language hmiDisplayLanguage:(SDLLanguage *)hmiDisplayLanguage correlationID:(NSNumber *)correlationID; + ++ (SDLCreateInteractionChoiceSet *)buildCreateInteractionChoiceSetWithID:(NSNumber *)interactionChoiceSetID choiceSet:(NSArray *)choices correlationID:(NSNumber *)correlationID; + ++ (SDLDeleteCommand *)buildDeleteCommandWithID:(NSNumber *)cmdID correlationID:(NSNumber *)correlationID; + ++ (SDLDeleteFile *)buildDeleteFileWithName:(NSString *)syncFileName correlationID:(NSNumber *)correlationID; + ++ (SDLDialNumber *)buildDialNumberWithNumber:(NSString *)phoneNumber; + ++ (SDLListFiles *)buildListFilesWithCorrelationID:(NSNumber *)correlationID; + ++ (SDLDeleteInteractionChoiceSet *)buildDeleteInteractionChoiceSetWithID:(NSNumber *)interactionChoiceSetID correlationID:(NSNumber *)correlationID; + ++ (SDLDeleteSubMenu *)buildDeleteSubMenuWithID:(NSNumber *)menuID correlationID:(NSNumber *)correlationID; + ++ (SDLEndAudioPassThru *)buildEndAudioPassThruWithCorrelationID:(NSNumber *)correlationID; + ++ (SDLGetDTCs *)buildGetDTCsWithECUName:(NSNumber *)ecuName correlationID:(NSNumber *)correlationID; + ++ (SDLGetVehicleData *)buildGetVehicleDataWithGPS:(NSNumber *)gps speed:(NSNumber *)speed rpm:(NSNumber *)rpm fuelLevel:(NSNumber *)fuelLevel fuelLevelState:(NSNumber *)fuelLevelState instantFuelConsumption:(NSNumber *)instantFuelConsumption externalTemperature:(NSNumber *)externalTemperature vin:(NSNumber *)vin prndl:(NSNumber *)prndl tirePressure:(NSNumber *)tirePressure odometer:(NSNumber *)odometer beltStatus:(NSNumber *)beltStatus bodyInformation:(NSNumber *)bodyInformation deviceStatus:(NSNumber *)deviceStatus driverBraking:(NSNumber *)driverBraking wiperStatus:(NSNumber *)wiperStatus headLampStatus:(NSNumber *)headLampStatus engineTorque:(NSNumber *)engineTorque accPedalPosition:(NSNumber *)accPedalPosition steeringWheelAngle:(NSNumber *)steeringWheelAngle correlationID:(NSNumber *)correlationID; + ++ (SDLPerformAudioPassThru *)buildPerformAudioPassThruWithInitialPrompt:(NSString *)initialPrompt audioPassThruDisplayText1:(NSString *)audioPassThruDisplayText1 audioPassThruDisplayText2:(NSString *)audioPassThruDisplayText2 samplingRate:(SDLSamplingRate *)samplingRate maxDuration:(NSNumber *)maxDuration bitsPerSample:(SDLBitsPerSample *)bitsPerSample audioType:(SDLAudioType *)audioType muteAudio:(NSNumber *)muteAudio correlationID:(NSNumber *)correlationID; + + +//***** PerformInteraction ***** ++ (SDLPerformInteraction *)buildPerformInteractionWithInitialChunks:(NSArray *)initialChunks initialText:(NSString *)initialText interactionChoiceSetIDList:(NSArray *)interactionChoiceSetIDList helpChunks:(NSArray *)helpChunks timeoutChunks:(NSArray *)timeoutChunks interactionMode:(SDLInteractionMode *)interactionMode timeout:(NSNumber *)timeout vrHelp:(NSArray *)vrHelp correlationID:(NSNumber *)correlationID; + +//*** ++ (SDLPerformInteraction *)buildPerformInteractionWithInitialPrompt:(NSString *)initialPrompt initialText:(NSString *)initialText interactionChoiceSetIDList:(NSArray *)interactionChoiceSetIDList helpPrompt:(NSString *)helpPrompt timeoutPrompt:(NSString *)timeoutPrompt interactionMode:(SDLInteractionMode *)interactionMode timeout:(NSNumber *)timeout vrHelp:(NSArray *)vrHelp correlationID:(NSNumber *)correlationID; + ++ (SDLPerformInteraction *)buildPerformInteractionWithInitialPrompt:(NSString *)initialPrompt initialText:(NSString *)initialText interactionChoiceSetID:(NSNumber *)interactionChoiceSetID vrHelp:(NSArray *)vrHelp correlationID:(NSNumber *)correlationID; + ++ (SDLPerformInteraction *)buildPerformInteractionWithInitialPrompt:(NSString *)initialPrompt initialText:(NSString *)initialText interactionChoiceSetIDList:(NSArray *)interactionChoiceSetIDList helpPrompt:(NSString *)helpPrompt timeoutPrompt:(NSString *)timeoutPrompt interactionMode:(SDLInteractionMode *)interactionMode timeout:(NSNumber *)timeout correlationID:(NSNumber *)correlationID; + ++ (SDLPerformInteraction *)buildPerformInteractionWithInitialPrompt:(NSString *)initialPrompt initialText:(NSString *)initialText interactionChoiceSetID:(NSNumber *)interactionChoiceSetID correlationID:(NSNumber *)correlationID; +//***** + ++ (SDLPutFile *)buildPutFileWithFileName:(NSString *)fileName fileType:(SDLFileType *)fileType persistentFile:(NSNumber *)persistentFile correlationId:(NSNumber *)correlationID; ++ (SDLPutFile *)buildPutFileWithFileName:(NSString *)syncFileName fileType:(SDLFileType *)fileType persisistentFile:(NSNumber *)persistentFile correlationID:(NSNumber *)correlationID __deprecated_msg("use buildPutFileWithFileName:fileType:persistentFile:correlationID: instead"); + ++ (SDLReadDID *)buildReadDIDWithECUName:(NSNumber *)ecuName didLocation:(NSArray *)didLocation correlationID:(NSNumber *)correlationID; + +//***** RegisterAppInterface ***** ++ (SDLRegisterAppInterface *)buildRegisterAppInterfaceWithAppName:(NSString *)appName ttsName:(NSMutableArray *)ttsName vrSynonyms:(NSMutableArray *)vrSynonyms isMediaApp:(NSNumber *)isMediaApp languageDesired:(SDLLanguage *)languageDesired hmiDisplayLanguageDesired:(SDLLanguage *)hmiDisplayLanguageDesired appID:(NSString *)appID; + ++ (SDLRegisterAppInterface *)buildRegisterAppInterfaceWithAppName:(NSString *)appName isMediaApp:(NSNumber *)isMediaApp languageDesired:(SDLLanguage *)languageDesired appID:(NSString *)appID; + ++ (SDLRegisterAppInterface *)buildRegisterAppInterfaceWithAppName:(NSString *)appName languageDesired:(SDLLanguage *)laguageDesired appID:(NSString *)appID; +//***** + ++ (SDLResetGlobalProperties *)buildResetGlobalPropertiesWithProperties:(NSArray *)properties correlationID:(NSNumber *)correlationID; + ++ (SDLSendLocation *)buildSendLocationWithLongitude:(NSNumber *)longitude latitude:(NSNumber *)latitude locationName:(NSString *)locationName locationDescription:(NSString *)locationDescription address:(NSArray *)address phoneNumber:(NSString *)phoneNumber image:(SDLImage *)image; + ++ (SDLScrollableMessage *)buildScrollableMessage:(NSString *)scrollableMessageBody timeout:(NSNumber *)timeout softButtons:(NSArray *)softButtons correlationID:(NSNumber *)correlationID; + ++ (SDLSetAppIcon *)buildSetAppIconWithFileName:(NSString *)syncFileName correlationID:(NSNumber *)correlationID; + ++ (SDLSetDisplayLayout *)buildSetDisplayLayout:(NSString *)displayLayout correlationID:(NSNumber *)correlationID; + + +//***** SetGlobalProperties ***** ++ (SDLSetGlobalProperties *)buildSetGlobalPropertiesWithHelpText:(NSString *)helpText timeoutText:(NSString *)timeoutText vrHelpTitle:(NSString *)vrHelpTitle vrHelp:(NSArray *)vrHelp correlationID:(NSNumber *)correlationID; + ++ (SDLSetGlobalProperties *)buildSetGlobalPropertiesWithHelpText:(NSString *)helpText timeoutText:(NSString *)timeoutText correlationID:(NSNumber *)correlationID; +//***** + + +//***** SetMediaClockTimer ***** ++ (SDLSetMediaClockTimer *)buildSetMediaClockTimerWithHours:(NSNumber *)hours minutes:(NSNumber *)minutes seconds:(NSNumber *)seconds updateMode:(SDLUpdateMode *)updateMode correlationID:(NSNumber *)correlationID; + ++ (SDLSetMediaClockTimer *)buildSetMediaClockTimerWithUpdateMode:(SDLUpdateMode *)updateMode correlationID:(NSNumber *)correlationID; +//***** + + +//***** Show ***** ++ (SDLShow *)buildShowWithMainField1:(NSString *)mainField1 mainField2:(NSString *)mainField2 mainField3:(NSString *)mainField3 mainField4:(NSString *)mainField4 statusBar:(NSString *)statusBar mediaClock:(NSString *)mediaClock mediaTrack:(NSString *)mediaTrack alignment:(SDLTextAlignment *)textAlignment graphic:(SDLImage *)graphic softButtons:(NSArray *)softButtons customPresets:(NSArray *)customPresets correlationID:(NSNumber *)correlationID; + ++ (SDLShow *)buildShowWithMainField1:(NSString *)mainField1 mainField2:(NSString *)mainField2 statusBar:(NSString *)statusBar mediaClock:(NSString *)mediaClock mediaTrack:(NSString *)mediaTrack alignment:(SDLTextAlignment *)textAlignment correlationID:(NSNumber *)correlationID; + ++ (SDLShow *)buildShowWithMainField1:(NSString *)mainField1 mainField2:(NSString *)mainField2 alignment:(SDLTextAlignment *)alignment correlationID:(NSNumber *)correlationID; +//***** + + +//***** Slider ***** ++ (SDLSlider *)buildSliderDynamicFooterWithNumTicks:(NSNumber *)numTicks position:(NSNumber *)position sliderHeader:(NSString *)sliderHeader sliderFooter:(NSArray *)sliderFooter timeout:(NSNumber *)timeout correlationID:(NSNumber *)correlationID; + ++ (SDLSlider *)buildSliderStaticFooterWithNumTicks:(NSNumber *)numTicks position:(NSNumber *)position sliderHeader:(NSString *)sliderHeader sliderFooter:(NSString *)sliderFooter timeout:(NSNumber *)timeout correlationID:(NSNumber *)correlationID; +//***** + +//***** Speak ***** ++ (SDLSpeak *)buildSpeakWithTTSChunks:(NSArray *)ttsChunks correlationID:(NSNumber *)correlationID; + +//*** ++ (SDLSpeak *)buildSpeakWithTTS:(NSString *)ttsText correlationID:(NSNumber *)correlationID; +//***** + ++ (SDLSubscribeButton *)buildSubscribeButtonWithName:(SDLButtonName *)buttonName correlationID:(NSNumber *)correlationID; + ++ (SDLSubscribeVehicleData *)buildSubscribeVehicleDataWithGPS:(NSNumber *)gps speed:(NSNumber *)speed rpm:(NSNumber *)rpm fuelLevel:(NSNumber *)fuelLevel fuelLevelState:(NSNumber *)fuelLevelState instantFuelConsumption:(NSNumber *)instantFuelConsumption externalTemperature:(NSNumber *)externalTemperature prndl:(NSNumber *)prndl tirePressure:(NSNumber *)tirePressure odometer:(NSNumber *)odometer beltStatus:(NSNumber *)beltStatus bodyInformation:(NSNumber *)bodyInformation deviceStatus:(NSNumber *)deviceStatus driverBraking:(NSNumber *)driverBraking wiperStatus:(NSNumber *)wiperStatus headLampStatus:(NSNumber *)headLampStatus engineTorque:(NSNumber *)engineTorque accPedalPosition:(NSNumber *)accPedalPosition steeringWheelAngle:(NSNumber *)steeringWheelAngle correlationID:(NSNumber *)correlationID; + ++ (SDLShowConstantTBT *)buildShowConstantTBTWithString:(NSString *)navigationText1 navigationText2:(NSString *)navigationText2 eta:(NSString *)eta timeToDestination:(NSString *)timeToDestination totalDistance:(NSString *)totalDistance turnIcon:(SDLImage *)turnIcon nextTurnIcon:(SDLImage *)nextTurnIcon distanceToManeuver:(NSNumber *)distanceToManeuver distanceToManeuverScale:(NSNumber *)distanceToManeuverScale maneuverComplete:(NSNumber *)maneuverComplete softButtons:(NSMutableArray *)softButtons correlationID:(NSNumber *)correlationID; + ++ (SDLUnregisterAppInterface *)buildUnregisterAppInterfaceWithCorrelationID:(NSNumber *)correlationID; + ++ (SDLUnsubscribeButton *)buildUnsubscribeButtonWithName:(SDLButtonName *)buttonName correlationID:(NSNumber *)correlationID; + ++ (SDLUnsubscribeVehicleData *)buildUnsubscribeVehicleDataWithGPS:(NSNumber *)gps speed:(NSNumber *)speed rpm:(NSNumber *)rpm fuelLevel:(NSNumber *)fuelLevel fuelLevelState:(NSNumber *)fuelLevelState instantFuelConsumption:(NSNumber *)instantFuelConsumption externalTemperature:(NSNumber *)externalTemperature prndl:(NSNumber *)prndl tirePressure:(NSNumber *)tirePressure odometer:(NSNumber *)odometer beltStatus:(NSNumber *)beltStatus bodyInformation:(NSNumber *)bodyInformation deviceStatus:(NSNumber *)deviceStatus driverBraking:(NSNumber *)driverBraking wiperStatus:(NSNumber *)wiperStatus headLampStatus:(NSNumber *)headLampStatus engineTorque:(NSNumber *)engineTorque accPedalPosition:(NSNumber *)accPedalPosition steeringWheelAngle:(NSNumber *)steeringWheelAngle correlationID:(NSNumber *)correlationID; + ++ (SDLUpdateTurnList *)buildUpdateTurnListWithTurnList:(NSMutableArray *)turnList softButtons:(NSMutableArray *)softButtons correlationID:(NSNumber *)correlationID; +@end diff --git a/SmartDeviceLink/SDLRPCRequestFactory.m b/SmartDeviceLink/SDLRPCRequestFactory.m new file mode 100644 index 000000000..44f9848a8 --- /dev/null +++ b/SmartDeviceLink/SDLRPCRequestFactory.m @@ -0,0 +1,689 @@ +// SDLRPCRequestFactory.m +// + +#import "SDLRPCRequestFactory.h" +#import <CoreTelephony/CTCarrier.h> +#import <CoreTelephony/CTTelephonyNetworkInfo.h> +#import <UIKit/UIKit.h> + +#import "SDLAddCommand.h" +#import "SDLAddSubMenu.h" +#import "SDLAlert.h" +#import "SDLAlertManeuver.h" +#import "SDLAppHMIType.h" +#import "SDLChangeRegistration.h" +#import "SDLCreateInteractionChoiceSet.h" +#import "SDLDebugTool.h" +#import "SDLDeleteCommand.h" +#import "SDLDeleteFile.h" +#import "SDLDeleteInteractionChoiceSet.h" +#import "SDLDeleteSubMenu.h" +#import "SDLDeviceInfo.h" +#import "SDLDialNumber.h" +#import "SDLEndAudioPassThru.h" +#import "SDLFileType.h" +#import "SDLGetDTCs.h" +#import "SDLGetVehicleData.h" +#import "SDLImage.h" +#import "SDLInteractionMode.h" +#import "SDLListFiles.h" +#import "SDLMenuParams.h" +#import "SDLPerformAudioPassThru.h" +#import "SDLPerformInteraction.h" +#import "SDLPutFile.h" +#import "SDLReadDID.h" +#import "SDLRegisterAppInterface.h" +#import "SDLResetGlobalProperties.h" +#import "SDLScrollableMessage.h" +#import "SDLSendLocation.h" +#import "SDLSetAppIcon.h" +#import "SDLSetDisplayLayout.h" +#import "SDLSetGlobalProperties.h" +#import "SDLSetMediaClockTimer.h" +#import "SDLShow.h" +#import "SDLShowConstantTBT.h" +#import "SDLSlider.h" +#import "SDLSpeak.h" +#import "SDLSpeechCapabilities.h" +#import "SDLStartTime.h" +#import "SDLSubscribeButton.h" +#import "SDLSubscribeVehicleData.h" +#import "SDLSyncMsgVersion.h" +#import "SDLTTSChunk.h" +#import "SDLTTSChunkFactory.h" +#import "SDLUnregisterAppInterface.h" +#import "SDLUnsubscribeButton.h" +#import "SDLUnsubscribeVehicleData.h" +#import "SDLUpdateTurnList.h" + + +@implementation SDLRPCRequestFactory + +//***** AddCommand ***** ++ (SDLAddCommand *)buildAddCommandWithID:(NSNumber *)cmdID menuName:(NSString *)menuName parentID:(NSNumber *)parentID position:(NSNumber *)position vrCommands:(NSArray *)vrCommands iconValue:(NSString *)iconValue iconType:(SDLImageType *)iconType correlationID:(NSNumber *)correlationID { + SDLAddCommand *msg = [[SDLAddCommand alloc] init]; + msg.correlationID = correlationID; + + msg.cmdID = cmdID; + + if (menuName != nil || parentID != nil || position != nil) { + SDLMenuParams *menuParams = [[SDLMenuParams alloc] init]; + menuParams.menuName = menuName; + menuParams.parentID = parentID; + menuParams.position = position; + msg.menuParams = menuParams; + } + msg.vrCommands = [vrCommands mutableCopy]; + + if (iconValue != nil || iconType != nil) { + SDLImage *icon = [[SDLImage alloc] init]; + icon.value = iconValue; + icon.imageType = iconType; + msg.cmdIcon = icon; + } + + return msg; +} + ++ (SDLAddCommand *)buildAddCommandWithID:(NSNumber *)cmdID menuName:(NSString *)menuName vrCommands:(NSArray *)vrCommands correlationID:(NSNumber *)correlationID { + return [SDLRPCRequestFactory buildAddCommandWithID:cmdID menuName:menuName parentID:nil position:nil vrCommands:vrCommands iconValue:nil iconType:nil correlationID:correlationID]; +} + ++ (SDLAddCommand *)buildAddCommandWithID:(NSNumber *)cmdID vrCommands:(NSArray *)vrCommands correlationID:(NSNumber *)correlationID { + return [SDLRPCRequestFactory buildAddCommandWithID:cmdID menuName:nil vrCommands:vrCommands correlationID:correlationID]; +} +//***** + + +//***** AddSubMenu ***** ++ (SDLAddSubMenu *)buildAddSubMenuWithID:(NSNumber *)menuID menuName:(NSString *)menuName position:(NSNumber *)position correlationID:(NSNumber *)correlationID { + SDLAddSubMenu *msg = [[SDLAddSubMenu alloc] init]; + msg.correlationID = correlationID; + msg.menuID = menuID; + msg.menuName = menuName; + msg.position = position; + return msg; +} + ++ (SDLAddSubMenu *)buildAddSubMenuWithID:(NSNumber *)menuID menuName:(NSString *)menuName correlationID:(NSNumber *)correlationID { + return [SDLRPCRequestFactory buildAddSubMenuWithID:menuID menuName:menuName position:nil correlationID:correlationID]; +} +//***** + + +//***** Alert ***** ++ (SDLAlert *)buildAlertWithTTS:(NSString *)ttsText alertText1:(NSString *)alertText1 alertText2:(NSString *)alertText2 alertText3:(NSString *)alertText3 playTone:(NSNumber *)playTone duration:(NSNumber *)duration correlationID:(NSNumber *)correlationID { + SDLTTSChunk *simpleChunk = [[SDLTTSChunk alloc] init]; + simpleChunk.text = ttsText; + simpleChunk.type = SDLSpeechCapabilities.TEXT; + NSArray *ttsChunks = [NSArray arrayWithObject:simpleChunk]; + + return [SDLRPCRequestFactory buildAlertWithTTSChunks:ttsChunks alertText1:alertText1 alertText2:alertText2 alertText3:alertText3 playTone:playTone duration:duration softButtons:nil correlationID:correlationID]; +} + ++ (SDLAlert *)buildAlertWithTTS:(NSString *)ttsText alertText1:(NSString *)alertText1 alertText2:(NSString *)alertText2 playTone:(NSNumber *)playTone duration:(NSNumber *)duration correlationID:(NSNumber *)correlationID { + return [SDLRPCRequestFactory buildAlertWithTTS:ttsText alertText1:alertText1 alertText2:alertText2 alertText3:nil playTone:playTone duration:duration correlationID:correlationID]; +} + ++ (SDLAlert *)buildAlertWithTTS:(NSString *)ttsText playTone:(NSNumber *)playTone correlationID:(NSNumber *)correlationID { + return [SDLRPCRequestFactory buildAlertWithTTS:ttsText alertText1:nil alertText2:nil alertText3:nil playTone:playTone duration:nil correlationID:correlationID]; +} + +//*** ++ (SDLAlert *)buildAlertWithTTSChunks:(NSArray *)ttsChunks alertText1:(NSString *)alertText1 alertText2:(NSString *)alertText2 alertText3:(NSString *)alertText3 playTone:(NSNumber *)playTone duration:(NSNumber *)duration softButtons:(NSArray *)softButtons correlationID:(NSNumber *)correlationID { + SDLAlert *msg = [[SDLAlert alloc] init]; + msg.correlationID = correlationID; + msg.alertText1 = alertText1; + msg.alertText2 = alertText2; + msg.alertText3 = alertText3; + msg.ttsChunks = [ttsChunks mutableCopy]; + msg.playTone = playTone; + msg.duration = duration; + msg.softButtons = [softButtons mutableCopy]; + return msg; +} + ++ (SDLAlert *)buildAlertWithTTSChunks:(NSArray *)ttsChunks playTone:(NSNumber *)playTone correlationID:(NSNumber *)correlationID { + return [SDLRPCRequestFactory buildAlertWithTTSChunks:ttsChunks alertText1:nil alertText2:nil alertText3:nil playTone:playTone duration:nil softButtons:nil correlationID:correlationID]; +} + +//*** ++ (SDLAlert *)buildAlertWithAlertText1:(NSString *)alertText1 alertText2:(NSString *)alertText2 alertText3:(NSString *)alertText3 duration:(NSNumber *)duration softButtons:(NSMutableArray *)softButtons correlationID:(NSNumber *)correlationID { + return [SDLRPCRequestFactory buildAlertWithTTSChunks:nil alertText1:alertText1 alertText2:alertText2 alertText3:alertText3 playTone:nil duration:duration softButtons:softButtons correlationID:correlationID]; +} + ++ (SDLAlert *)buildAlertWithAlertText1:(NSString *)alertText1 alertText2:(NSString *)alertText2 alertText3:(NSString *)alertText3 duration:(NSNumber *)duration correlationID:(NSNumber *)correlationID { + return [SDLRPCRequestFactory buildAlertWithTTSChunks:nil alertText1:alertText1 alertText2:alertText2 alertText3:alertText3 playTone:nil duration:duration softButtons:nil correlationID:correlationID]; +} + ++ (SDLAlert *)buildAlertWithAlertText1:(NSString *)alertText1 alertText2:(NSString *)alertText2 duration:(NSNumber *)duration correlationID:(NSNumber *)correlationID { + return [SDLRPCRequestFactory buildAlertWithTTSChunks:nil alertText1:alertText1 alertText2:alertText2 alertText3:nil playTone:nil duration:duration softButtons:nil correlationID:correlationID]; +} +//***** + + ++ (SDLAlertManeuver *)buildAlertManeuverwithTTSchunks:(NSMutableArray *)ttsChunks softButtons:(NSMutableArray *)softButtons correlationID:(NSNumber *)correlationID { + SDLAlertManeuver *msg = [[SDLAlertManeuver alloc] init]; + msg.ttsChunks = ttsChunks; + msg.softButtons = softButtons; + msg.correlationID = correlationID; + return msg; +} + ++ (SDLChangeRegistration *)buildChangeRegistrationWithLanguage:(SDLLanguage *)language hmiDisplayLanguage:(SDLLanguage *)hmiDisplayLanguage correlationID:(NSNumber *)correlationID { + SDLChangeRegistration *msg = [[SDLChangeRegistration alloc] init]; + msg.language = language; + msg.hmiDisplayLanguage = hmiDisplayLanguage; + msg.correlationID = correlationID; + + return msg; +} + ++ (SDLCreateInteractionChoiceSet *)buildCreateInteractionChoiceSetWithID:(NSNumber *)interactionChoiceSetID choiceSet:(NSArray *)choices correlationID:(NSNumber *)correlationID { + SDLCreateInteractionChoiceSet *msg = [[SDLCreateInteractionChoiceSet alloc] init]; + msg.interactionChoiceSetID = interactionChoiceSetID; + msg.choiceSet = [choices mutableCopy]; + msg.correlationID = correlationID; + + return msg; +} + ++ (SDLDeleteCommand *)buildDeleteCommandWithID:(NSNumber *)cmdID correlationID:(NSNumber *)correlationID { + SDLDeleteCommand *msg = [[SDLDeleteCommand alloc] init]; + msg.cmdID = cmdID; + msg.correlationID = correlationID; + + return msg; +} + ++ (SDLDeleteFile *)buildDeleteFileWithName:(NSString *)syncFileName correlationID:(NSNumber *)correlationID { + SDLDeleteFile *msg = [[SDLDeleteFile alloc] init]; + msg.syncFileName = syncFileName; + msg.correlationID = correlationID; + + return msg; +} + ++ (SDLDialNumber *)buildDialNumberWithNumber:(NSString *)phoneNumber { + SDLDialNumber *msg = [[SDLDialNumber alloc] init]; + msg.number = phoneNumber; + + return msg; +} + ++ (SDLListFiles *)buildListFilesWithCorrelationID:(NSNumber *)correlationID { + SDLListFiles *msg = [[SDLListFiles alloc] init]; + msg.correlationID = correlationID; + + return msg; +} + ++ (SDLDeleteInteractionChoiceSet *)buildDeleteInteractionChoiceSetWithID:(NSNumber *)interactionChoiceSetID correlationID:(NSNumber *)correlationID { + SDLDeleteInteractionChoiceSet *msg = [[SDLDeleteInteractionChoiceSet alloc] init]; + msg.interactionChoiceSetID = interactionChoiceSetID; + msg.correlationID = correlationID; + + return msg; +} + ++ (SDLDeleteSubMenu *)buildDeleteSubMenuWithID:(NSNumber *)menuID correlationID:(NSNumber *)correlationID { + SDLDeleteSubMenu *msg = [[SDLDeleteSubMenu alloc] init]; + msg.menuID = menuID; + msg.correlationID = correlationID; + + return msg; +} + ++ (SDLEndAudioPassThru *)buildEndAudioPassThruWithCorrelationID:(NSNumber *)correlationID { + SDLEndAudioPassThru *msg = [[SDLEndAudioPassThru alloc] init]; + msg.correlationID = correlationID; + + return msg; +} + ++ (SDLGetDTCs *)buildGetDTCsWithECUName:(NSNumber *)ecuName correlationID:(NSNumber *)correlationID { + SDLGetDTCs *msg = [[SDLGetDTCs alloc] init]; + msg.ecuName = ecuName; + msg.correlationID = correlationID; + + return msg; +} + ++ (SDLGetVehicleData *)buildGetVehicleDataWithGPS:(NSNumber *)gps speed:(NSNumber *)speed rpm:(NSNumber *)rpm fuelLevel:(NSNumber *)fuelLevel fuelLevelState:(NSNumber *)fuelLevelState instantFuelConsumption:(NSNumber *)instantFuelConsumption externalTemperature:(NSNumber *)externalTemperature vin:(NSNumber *)vin prndl:(NSNumber *)prndl tirePressure:(NSNumber *)tirePressure odometer:(NSNumber *)odometer beltStatus:(NSNumber *)beltStatus bodyInformation:(NSNumber *)bodyInformation deviceStatus:(NSNumber *)deviceStatus driverBraking:(NSNumber *)driverBraking wiperStatus:(NSNumber *)wiperStatus headLampStatus:(NSNumber *)headLampStatus engineTorque:(NSNumber *)engineTorque accPedalPosition:(NSNumber *)accPedalPosition steeringWheelAngle:(NSNumber *)steeringWheelAngle correlationID:(NSNumber *)correlationID { + SDLGetVehicleData *msg = [[SDLGetVehicleData alloc] init]; + msg.gps = gps; + msg.speed = speed; + msg.rpm = rpm; + msg.fuelLevel = fuelLevel; + msg.fuelLevel_State = fuelLevelState; + msg.instantFuelConsumption = instantFuelConsumption; + msg.externalTemperature = externalTemperature; + msg.vin = vin; + msg.prndl = prndl; + msg.tirePressure = tirePressure; + msg.odometer = odometer; + msg.beltStatus = beltStatus; + msg.bodyInformation = bodyInformation; + msg.deviceStatus = deviceStatus; + msg.driverBraking = driverBraking; + msg.wiperStatus = wiperStatus; + msg.headLampStatus = headLampStatus; + msg.engineTorque = engineTorque; + msg.accPedalPosition = accPedalPosition; + msg.steeringWheelAngle = steeringWheelAngle; + msg.correlationID = correlationID; + + return msg; +} + ++ (SDLPerformAudioPassThru *)buildPerformAudioPassThruWithInitialPrompt:(NSString *)initialPrompt audioPassThruDisplayText1:(NSString *)audioPassThruDisplayText1 audioPassThruDisplayText2:(NSString *)audioPassThruDisplayText2 samplingRate:(SDLSamplingRate *)samplingRate maxDuration:(NSNumber *)maxDuration bitsPerSample:(SDLBitsPerSample *)bitsPerSample audioType:(SDLAudioType *)audioType muteAudio:(NSNumber *)muteAudio correlationID:(NSNumber *)correlationID { + NSArray *initialChunks = [SDLTTSChunkFactory buildTTSChunksFromSimple:initialPrompt]; + + SDLPerformAudioPassThru *msg = [[SDLPerformAudioPassThru alloc] init]; + msg.initialPrompt = [initialChunks mutableCopy]; + msg.audioPassThruDisplayText1 = audioPassThruDisplayText1; + msg.audioPassThruDisplayText2 = audioPassThruDisplayText2; + msg.samplingRate = samplingRate; + msg.maxDuration = maxDuration; + msg.bitsPerSample = bitsPerSample; + msg.audioType = audioType; + msg.muteAudio = muteAudio; + msg.correlationID = correlationID; + + return msg; +} + + +//***** PerformInteraction ***** ++ (SDLPerformInteraction *)buildPerformInteractionWithInitialChunks:(NSArray *)initialChunks initialText:(NSString *)initialText interactionChoiceSetIDList:(NSArray *)interactionChoiceSetIDList helpChunks:(NSArray *)helpChunks timeoutChunks:(NSArray *)timeoutChunks interactionMode:(SDLInteractionMode *)interactionMode timeout:(NSNumber *)timeout vrHelp:(NSArray *)vrHelp correlationID:(NSNumber *)correlationID { + SDLPerformInteraction *msg = [[SDLPerformInteraction alloc] init]; + msg.initialPrompt = [initialChunks mutableCopy]; + msg.initialText = initialText; + msg.interactionChoiceSetIDList = [interactionChoiceSetIDList mutableCopy]; + msg.helpPrompt = [helpChunks mutableCopy]; + msg.timeoutPrompt = [timeoutChunks mutableCopy]; + msg.interactionMode = interactionMode; + msg.timeout = timeout; + msg.vrHelp = [vrHelp mutableCopy]; + msg.correlationID = correlationID; + + return msg; +} + +//*** ++ (SDLPerformInteraction *)buildPerformInteractionWithInitialPrompt:(NSString *)initialPrompt initialText:(NSString *)initialText interactionChoiceSetIDList:(NSArray *)interactionChoiceSetIDList helpPrompt:(NSString *)helpPrompt timeoutPrompt:(NSString *)timeoutPrompt interactionMode:(SDLInteractionMode *)interactionMode timeout:(NSNumber *)timeout vrHelp:(NSArray *)vrHelp correlationID:(NSNumber *)correlationID { + NSArray *initialChunks = [SDLTTSChunkFactory buildTTSChunksFromSimple:initialPrompt]; + NSArray *helpChunks = [SDLTTSChunkFactory buildTTSChunksFromSimple:helpPrompt]; + NSArray *timeoutChunks = [SDLTTSChunkFactory buildTTSChunksFromSimple:timeoutPrompt]; + + return [SDLRPCRequestFactory buildPerformInteractionWithInitialChunks:initialChunks initialText:initialText interactionChoiceSetIDList:interactionChoiceSetIDList helpChunks:helpChunks timeoutChunks:timeoutChunks interactionMode:interactionMode timeout:timeout vrHelp:vrHelp correlationID:correlationID]; +} + ++ (SDLPerformInteraction *)buildPerformInteractionWithInitialPrompt:(NSString *)initialPrompt initialText:(NSString *)initialText interactionChoiceSetID:(NSNumber *)interactionChoiceSetID vrHelp:(NSArray *)vrHelp correlationID:(NSNumber *)correlationID { + NSArray *interactionChoiceSetIDList = [NSArray arrayWithObject:interactionChoiceSetID]; + NSArray *initialChunks = [SDLTTSChunkFactory buildTTSChunksFromSimple:initialPrompt]; + + return [SDLRPCRequestFactory buildPerformInteractionWithInitialChunks:initialChunks initialText:initialText interactionChoiceSetIDList:interactionChoiceSetIDList helpChunks:nil timeoutChunks:nil interactionMode:SDLInteractionMode.BOTH timeout:nil vrHelp:vrHelp correlationID:correlationID]; +} + ++ (SDLPerformInteraction *)buildPerformInteractionWithInitialPrompt:(NSString *)initialPrompt initialText:(NSString *)initialText interactionChoiceSetIDList:(NSArray *)interactionChoiceSetIDList helpPrompt:(NSString *)helpPrompt timeoutPrompt:(NSString *)timeoutPrompt interactionMode:(SDLInteractionMode *)interactionMode timeout:(NSNumber *)timeout correlationID:(NSNumber *)correlationID { + return [SDLRPCRequestFactory buildPerformInteractionWithInitialPrompt:initialPrompt initialText:initialText interactionChoiceSetIDList:interactionChoiceSetIDList helpPrompt:helpPrompt timeoutPrompt:timeoutPrompt interactionMode:interactionMode timeout:timeout vrHelp:nil correlationID:(NSNumber *)correlationID]; +} + ++ (SDLPerformInteraction *)buildPerformInteractionWithInitialPrompt:(NSString *)initialPrompt initialText:(NSString *)initialText interactionChoiceSetID:(NSNumber *)interactionChoiceSetID correlationID:(NSNumber *)correlationID { + return [SDLRPCRequestFactory buildPerformInteractionWithInitialPrompt:initialPrompt initialText:initialText interactionChoiceSetID:interactionChoiceSetID vrHelp:nil correlationID:correlationID]; +} +//***** + ++ (SDLPutFile *)buildPutFileWithFileName:(NSString *)fileName fileType:(SDLFileType *)fileType persistentFile:(NSNumber *)persistentFile correlationId:(NSNumber *)correlationID { + SDLPutFile *msg = [[SDLPutFile alloc] init]; + msg.syncFileName = fileName; + + msg.fileType = fileType; + msg.persistentFile = persistentFile; + msg.correlationID = correlationID; + + return msg; +} + ++ (SDLPutFile *)buildPutFileWithFileName:(NSString *)syncFileName fileType:(SDLFileType *)fileType persisistentFile:(NSNumber *)persistentFile correlationID:(NSNumber *)correlationID { + return [self buildPutFileWithFileName:syncFileName fileType:fileType persistentFile:persistentFile correlationId:correlationID]; +} + ++ (SDLReadDID *)buildReadDIDWithECUName:(NSNumber *)ecuName didLocation:(NSArray *)didLocation correlationID:(NSNumber *)correlationID { + SDLReadDID *msg = [[SDLReadDID alloc] init]; + msg.ecuName = ecuName; + msg.didLocation = [didLocation mutableCopy]; + msg.correlationID = correlationID; + + return msg; +} + +//***** RegisterAppInterface ***** ++ (SDLRegisterAppInterface *)buildRegisterAppInterfaceWithAppName:(NSString *)appName ttsName:(NSArray *)ttsName vrSynonyms:(NSArray *)vrSynonyms isMediaApp:(NSNumber *)isMediaApp languageDesired:(SDLLanguage *)languageDesired hmiDisplayLanguageDesired:(SDLLanguage *)hmiDisplayLanguageDesired appID:(NSString *)appID { + SDLRegisterAppInterface *msg = [[SDLRegisterAppInterface alloc] init]; + SDLSyncMsgVersion *version = [[SDLSyncMsgVersion alloc] init]; + version.majorVersion = [NSNumber numberWithInt:1]; + version.minorVersion = [NSNumber numberWithInt:0]; + msg.syncMsgVersion = version; + msg.appName = appName; + msg.ttsName = [ttsName mutableCopy]; + msg.ngnMediaScreenAppName = appName; + msg.vrSynonyms = [vrSynonyms mutableCopy]; + msg.isMediaApplication = isMediaApp; + msg.languageDesired = languageDesired; + msg.hmiDisplayLanguageDesired = hmiDisplayLanguageDesired; + msg.appID = appID; + msg.deviceInfo = [self sdl_buildDeviceInfo]; + msg.correlationID = [NSNumber numberWithInt:1]; + + return msg; +} + ++ (SDLDeviceInfo *)sdl_buildDeviceInfo { + SDLDeviceInfo *deviceInfo = [[SDLDeviceInfo alloc] init]; + deviceInfo.hardware = [UIDevice currentDevice].model; + deviceInfo.os = [UIDevice currentDevice].systemName; + deviceInfo.osVersion = [UIDevice currentDevice].systemVersion; + CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init]; + CTCarrier *carrier = netinfo.subscriberCellularProvider; + NSString *carrierName = carrier.carrierName; + deviceInfo.carrier = carrierName; + + return deviceInfo; +} + ++ (SDLRegisterAppInterface *)buildRegisterAppInterfaceWithAppName:(NSString *)appName isMediaApp:(NSNumber *)isMediaApp languageDesired:(SDLLanguage *)languageDesired appID:(NSString *)appID { + NSMutableArray *syns = [NSMutableArray arrayWithObject:appName]; + return [SDLRPCRequestFactory buildRegisterAppInterfaceWithAppName:appName ttsName:nil vrSynonyms:syns isMediaApp:isMediaApp languageDesired:languageDesired hmiDisplayLanguageDesired:languageDesired appID:appID]; +} + ++ (SDLRegisterAppInterface *)buildRegisterAppInterfaceWithAppName:(NSString *)appName languageDesired:(SDLLanguage *)languageDesired appID:(NSString *)appID { + return [SDLRPCRequestFactory buildRegisterAppInterfaceWithAppName:appName isMediaApp:@NO languageDesired:languageDesired appID:appID]; +} +//***** + + ++ (SDLResetGlobalProperties *)buildResetGlobalPropertiesWithProperties:(NSArray *)properties correlationID:(NSNumber *)correlationID { + SDLResetGlobalProperties *msg = [[SDLResetGlobalProperties alloc] init]; + msg.properties = [properties mutableCopy]; + msg.correlationID = correlationID; + + return msg; +} + ++ (SDLScrollableMessage *)buildScrollableMessage:(NSString *)scrollableMessageBody timeout:(NSNumber *)timeout softButtons:(NSArray *)softButtons correlationID:(NSNumber *)correlationID { + SDLScrollableMessage *msg = [[SDLScrollableMessage alloc] init]; + msg.scrollableMessageBody = scrollableMessageBody; + msg.timeout = timeout; + msg.softButtons = [softButtons mutableCopy]; + msg.correlationID = correlationID; + + return msg; +} + ++ (SDLSendLocation *)buildSendLocationWithLongitude:(NSNumber *)longitude latitude:(NSNumber *)latitude locationName:(NSString *)locationName locationDescription:(NSString *)locationDescription address:(NSArray *)address phoneNumber:(NSString *)phoneNumber image:(SDLImage *)image { + SDLSendLocation *msg = [[SDLSendLocation alloc] init]; + msg.longitudeDegrees = longitude; + msg.latitudeDegrees = latitude; + msg.locationName = locationName; + msg.locationDescription = locationDescription; + msg.addressLines = address; + msg.phoneNumber = phoneNumber; + msg.locationImage = image; + + return msg; +} + ++ (SDLSetAppIcon *)buildSetAppIconWithFileName:(NSString *)syncFileName correlationID:(NSNumber *)correlationID { + SDLSetAppIcon *msg = [[SDLSetAppIcon alloc] init]; + msg.syncFileName = syncFileName; + msg.correlationID = correlationID; + + return msg; +} + ++ (SDLSetDisplayLayout *)buildSetDisplayLayout:(NSString *)displayLayout correlationID:(NSNumber *)correlationID { + SDLSetDisplayLayout *msg = [[SDLSetDisplayLayout alloc] init]; + msg.displayLayout = displayLayout; + msg.correlationID = correlationID; + + return msg; +} + + +//***** SetGlobalProperties ***** ++ (SDLSetGlobalProperties *)buildSetGlobalPropertiesWithHelpText:(NSString *)helpText timeoutText:(NSString *)timeoutText vrHelpTitle:(NSString *)vrHelpTitle vrHelp:(NSArray *)vrHelp correlationID:(NSNumber *)correlationID { + SDLSetGlobalProperties *msg = [[SDLSetGlobalProperties alloc] init]; + msg.helpPrompt = [SDLTTSChunkFactory buildTTSChunksFromSimple:helpText]; + msg.timeoutPrompt = [SDLTTSChunkFactory buildTTSChunksFromSimple:timeoutText]; + msg.vrHelpTitle = vrHelpTitle; + msg.vrHelp = [vrHelp mutableCopy]; + msg.correlationID = correlationID; + + return msg; +} + ++ (SDLSetGlobalProperties *)buildSetGlobalPropertiesWithHelpText:(NSString *)helpText timeoutText:(NSString *)timeoutText correlationID:(NSNumber *)correlationID { + SDLSetGlobalProperties *msg = [[SDLSetGlobalProperties alloc] init]; + msg.helpPrompt = [SDLTTSChunkFactory buildTTSChunksFromSimple:helpText]; + msg.timeoutPrompt = [SDLTTSChunkFactory buildTTSChunksFromSimple:timeoutText]; + msg.correlationID = correlationID; + + return msg; +} +//***** + + +//***** SetMediaClockTimer ***** ++ (SDLSetMediaClockTimer *)buildSetMediaClockTimerWithHours:(NSNumber *)hours minutes:(NSNumber *)minutes seconds:(NSNumber *)seconds updateMode:(SDLUpdateMode *)updateMode correlationID:(NSNumber *)correlationID { + SDLSetMediaClockTimer *msg = [[SDLSetMediaClockTimer alloc] init]; + SDLStartTime *startTime = [[SDLStartTime alloc] init]; + startTime.hours = hours; + startTime.minutes = minutes; + startTime.seconds = seconds; + msg.startTime = startTime; + msg.updateMode = updateMode; + msg.correlationID = correlationID; + + return msg; +} + ++ (SDLSetMediaClockTimer *)buildSetMediaClockTimerWithUpdateMode:(SDLUpdateMode *)updateMode correlationID:(NSNumber *)correlationID { + SDLSetMediaClockTimer *msg = [[SDLSetMediaClockTimer alloc] init]; + msg.updateMode = updateMode; + msg.correlationID = correlationID; + + return msg; +} +//***** + + +//***** Show ***** ++ (SDLShow *)buildShowWithMainField1:(NSString *)mainField1 mainField2:(NSString *)mainField2 mainField3:(NSString *)mainField3 mainField4:(NSString *)mainField4 statusBar:(NSString *)statusBar mediaClock:(NSString *)mediaClock mediaTrack:(NSString *)mediaTrack alignment:(SDLTextAlignment *)textAlignment graphic:(SDLImage *)graphic softButtons:(NSArray *)softButtons customPresets:(NSArray *)customPresets correlationID:(NSNumber *)correlationID { + SDLShow *msg = [[SDLShow alloc] init]; + msg.correlationID = correlationID; + msg.mainField1 = mainField1; + msg.mainField2 = mainField2; + msg.mainField3 = mainField3; + msg.mainField4 = mainField4; + msg.statusBar = statusBar; + msg.mediaClock = mediaClock; + msg.mediaTrack = mediaTrack; + msg.alignment = textAlignment; + msg.graphic = graphic; + msg.softButtons = [softButtons mutableCopy]; + msg.customPresets = [customPresets mutableCopy]; + + return msg; +} + ++ (SDLShow *)buildShowWithMainField1:(NSString *)mainField1 mainField2:(NSString *)mainField2 statusBar:(NSString *)statusBar mediaClock:(NSString *)mediaClock mediaTrack:(NSString *)mediaTrack alignment:(SDLTextAlignment *)textAlignment correlationID:(NSNumber *)correlationID { + SDLShow *msg = [[SDLShow alloc] init]; + msg.correlationID = correlationID; + msg.mainField1 = mainField1; + msg.mainField2 = mainField2; + msg.statusBar = statusBar; + msg.mediaClock = mediaClock; + msg.mediaTrack = mediaTrack; + msg.alignment = textAlignment; + + return msg; +} + ++ (SDLShow *)buildShowWithMainField1:(NSString *)mainField1 mainField2:(NSString *)mainField2 alignment:(SDLTextAlignment *)alignment correlationID:(NSNumber *)correlationID { + return [SDLRPCRequestFactory buildShowWithMainField1:mainField1 mainField2:mainField2 statusBar:nil mediaClock:nil mediaTrack:nil alignment:alignment correlationID:correlationID]; +} + ++ (SDLShowConstantTBT *)buildShowConstantTBTWithString:(NSString *)navigationText1 navigationText2:(NSString *)navigationText2 eta:(NSString *)eta timeToDestination:(NSString *)timeToDestination totalDistance:(NSString *)totalDistance turnIcon:(SDLImage *)turnIcon nextTurnIcon:(SDLImage *)nextTurnIcon distanceToManeuver:(NSNumber *)distanceToManeuver distanceToManeuverScale:(NSNumber *)distanceToManeuverScale maneuverComplete:(NSNumber *)maneuverComplete softButtons:(NSMutableArray *)softButtons correlationID:(NSNumber *)correlationID { + SDLShowConstantTBT *msg = [[SDLShowConstantTBT alloc] init]; + msg.navigationText1 = navigationText1; + msg.navigationText2 = navigationText2; + msg.eta = eta; + msg.timeToDestination = timeToDestination; + msg.totalDistance = totalDistance; + msg.turnIcon = turnIcon; + msg.nextTurnIcon = nextTurnIcon; + msg.distanceToManeuver = distanceToManeuver; + msg.distanceToManeuverScale = distanceToManeuverScale; + msg.maneuverComplete = maneuverComplete; + msg.softButtons = [softButtons mutableCopy]; + msg.correlationID = correlationID; + + return msg; +} +//***** + + +//***** Slider ***** ++ (SDLSlider *)buildSliderDynamicFooterWithNumTicks:(NSNumber *)numTicks position:(NSNumber *)position sliderHeader:(NSString *)sliderHeader sliderFooter:(NSArray *)sliderFooter timeout:(NSNumber *)timeout correlationID:(NSNumber *)correlationID { + SDLSlider *msg = [[SDLSlider alloc] init]; + msg.correlationID = correlationID; + msg.numTicks = numTicks; + msg.position = position; + msg.sliderHeader = sliderHeader; + msg.sliderFooter = [sliderFooter mutableCopy]; + msg.timeout = timeout; + + return msg; +} + ++ (SDLSlider *)buildSliderStaticFooterWithNumTicks:(NSNumber *)numTicks position:(NSNumber *)position sliderHeader:(NSString *)sliderHeader sliderFooter:(NSString *)sliderFooter timeout:(NSNumber *)timeout correlationID:(NSNumber *)correlationID { + NSArray *sliderFooters = [NSArray arrayWithObject:sliderFooter]; + + // Populates array with the same footer value for each position + for (UInt32 i = 1; i < numTicks.unsignedIntegerValue; i++) { + sliderFooters = [sliderFooters arrayByAddingObject:sliderFooter]; + } + + return [SDLRPCRequestFactory buildSliderDynamicFooterWithNumTicks:numTicks position:position sliderHeader:sliderHeader sliderFooter:sliderFooters timeout:timeout correlationID:correlationID]; +} +//***** + + +//***** Speak ***** ++ (SDLSpeak *)buildSpeakWithTTSChunks:(NSArray *)ttsChunks correlationID:(NSNumber *)correlationID { + SDLSpeak *msg = [[SDLSpeak alloc] init]; + msg.correlationID = correlationID; + msg.ttsChunks = [ttsChunks mutableCopy]; + + return msg; +} + +//*** ++ (SDLSpeak *)buildSpeakWithTTS:(NSString *)ttsText correlationID:(NSNumber *)correlationID { + SDLTTSChunk *simpleChunk = [[SDLTTSChunk alloc] init]; + simpleChunk.text = ttsText; + simpleChunk.type = SDLSpeechCapabilities.TEXT; + NSArray *ttsChunks = [NSMutableArray arrayWithObject:simpleChunk]; + + return [SDLRPCRequestFactory buildSpeakWithTTSChunks:ttsChunks correlationID:correlationID]; +} +//***** + + ++ (SDLSubscribeButton *)buildSubscribeButtonWithName:(SDLButtonName *)buttonName correlationID:(NSNumber *)correlationID { + SDLSubscribeButton *msg = [[SDLSubscribeButton alloc] init]; + msg.correlationID = correlationID; + msg.buttonName = buttonName; + + return msg; +} + ++ (SDLSubscribeVehicleData *)buildSubscribeVehicleDataWithGPS:(NSNumber *)gps speed:(NSNumber *)speed rpm:(NSNumber *)rpm fuelLevel:(NSNumber *)fuelLevel fuelLevelState:(NSNumber *)fuelLevelState instantFuelConsumption:(NSNumber *)instantFuelConsumption externalTemperature:(NSNumber *)externalTemperature prndl:(NSNumber *)prndl tirePressure:(NSNumber *)tirePressure odometer:(NSNumber *)odometer beltStatus:(NSNumber *)beltStatus bodyInformation:(NSNumber *)bodyInformation deviceStatus:(NSNumber *)deviceStatus driverBraking:(NSNumber *)driverBraking wiperStatus:(NSNumber *)wiperStatus headLampStatus:(NSNumber *)headLampStatus engineTorque:(NSNumber *)engineTorque accPedalPosition:(NSNumber *)accPedalPosition steeringWheelAngle:(NSNumber *)steeringWheelAngle correlationID:(NSNumber *)correlationID { + SDLSubscribeVehicleData *msg = [[SDLSubscribeVehicleData alloc] init]; + msg.gps = gps; + msg.speed = speed; + msg.rpm = rpm; + msg.fuelLevel = fuelLevel; + msg.fuelLevel_State = fuelLevelState; + msg.instantFuelConsumption = instantFuelConsumption; + msg.externalTemperature = externalTemperature; + msg.prndl = prndl; + msg.tirePressure = tirePressure; + msg.odometer = odometer; + msg.beltStatus = beltStatus; + msg.bodyInformation = bodyInformation; + msg.deviceStatus = deviceStatus; + msg.driverBraking = driverBraking; + msg.wiperStatus = wiperStatus; + msg.headLampStatus = headLampStatus; + msg.engineTorque = engineTorque; + msg.accPedalPosition = accPedalPosition; + msg.steeringWheelAngle = steeringWheelAngle; + msg.correlationID = correlationID; + + return msg; +} + ++ (SDLUnregisterAppInterface *)buildUnregisterAppInterfaceWithCorrelationID:(NSNumber *)correlationID { + SDLUnregisterAppInterface *msg = [[SDLUnregisterAppInterface alloc] init]; + msg.correlationID = correlationID; + + return msg; +} + ++ (SDLUnsubscribeButton *)buildUnsubscribeButtonWithName:(SDLButtonName *)buttonName correlationID:(NSNumber *)correlationID { + SDLUnsubscribeButton *msg = [[SDLUnsubscribeButton alloc] init]; + msg.buttonName = buttonName; + msg.correlationID = correlationID; + + return msg; +} + ++ (SDLUnsubscribeVehicleData *)buildUnsubscribeVehicleDataWithGPS:(NSNumber *)gps speed:(NSNumber *)speed rpm:(NSNumber *)rpm fuelLevel:(NSNumber *)fuelLevel fuelLevelState:(NSNumber *)fuelLevelState instantFuelConsumption:(NSNumber *)instantFuelConsumption externalTemperature:(NSNumber *)externalTemperature prndl:(NSNumber *)prndl tirePressure:(NSNumber *)tirePressure odometer:(NSNumber *)odometer beltStatus:(NSNumber *)beltStatus bodyInformation:(NSNumber *)bodyInformation deviceStatus:(NSNumber *)deviceStatus driverBraking:(NSNumber *)driverBraking wiperStatus:(NSNumber *)wiperStatus headLampStatus:(NSNumber *)headLampStatus engineTorque:(NSNumber *)engineTorque accPedalPosition:(NSNumber *)accPedalPosition steeringWheelAngle:(NSNumber *)steeringWheelAngle correlationID:(NSNumber *)correlationID { + SDLUnsubscribeVehicleData *msg = [[SDLUnsubscribeVehicleData alloc] init]; + msg.gps = gps; + msg.speed = speed; + msg.rpm = rpm; + msg.fuelLevel = fuelLevel; + msg.fuelLevel_State = fuelLevelState; + msg.instantFuelConsumption = instantFuelConsumption; + msg.externalTemperature = externalTemperature; + msg.prndl = prndl; + msg.tirePressure = tirePressure; + msg.odometer = odometer; + msg.beltStatus = beltStatus; + msg.bodyInformation = bodyInformation; + msg.deviceStatus = deviceStatus; + msg.driverBraking = driverBraking; + msg.wiperStatus = wiperStatus; + msg.headLampStatus = headLampStatus; + msg.engineTorque = engineTorque; + msg.accPedalPosition = accPedalPosition; + msg.steeringWheelAngle = steeringWheelAngle; + msg.correlationID = correlationID; + + return msg; +} + ++ (SDLUpdateTurnList *)buildUpdateTurnListWithTurnList:(NSMutableArray *)turnList softButtons:(NSMutableArray *)softButtons correlationID:(NSNumber *)correlationID { + SDLUpdateTurnList *msg = [[SDLUpdateTurnList alloc] init]; + msg.turnList = [turnList mutableCopy]; + msg.softButtons = [softButtons mutableCopy]; + msg.correlationID = correlationID; + + return msg; +} + +@end diff --git a/SmartDeviceLink/SDLRPCResponse.h b/SmartDeviceLink/SDLRPCResponse.h new file mode 100644 index 000000000..57bd500f4 --- /dev/null +++ b/SmartDeviceLink/SDLRPCResponse.h @@ -0,0 +1,17 @@ +// SDLRPCResponse.h +// + + +#import "SDLRPCMessage.h" + +@class SDLResult; + +@interface SDLRPCResponse : SDLRPCMessage { +} + +@property (strong) NSNumber *correlationID; +@property (strong) NSNumber *success; +@property (strong) SDLResult *resultCode; +@property (strong) NSString *info; + +@end diff --git a/SmartDeviceLink/SDLRPCResponse.m b/SmartDeviceLink/SDLRPCResponse.m new file mode 100644 index 000000000..606781070 --- /dev/null +++ b/SmartDeviceLink/SDLRPCResponse.m @@ -0,0 +1,89 @@ +// SDLRPCResponse.m +// + + +#import "SDLRPCResponse.h" + +#import "SDLNames.h" +#import "SDLResult.h" + +@implementation SDLRPCResponse + +- (instancetype)initWithName:(NSString *)name { + self = [super initWithName:name]; + if (!self) { + return nil; + } + + messageType = NAMES_response; + [store setObject:function forKey:messageType]; + + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + self = [super initWithDictionary:dict]; + if (!self) { + return nil; + } + + messageType = NAMES_response; + [store setObject:function forKey:messageType]; + + return self; +} + +- (NSNumber *)correlationID { + return [function objectForKey:NAMES_correlationID]; +} + +- (void)setCorrelationID:(NSNumber *)corrID { + if (corrID != nil) { + [function setObject:corrID forKey:NAMES_correlationID]; + } else { + [function removeObjectForKey:NAMES_correlationID]; + } +} + +- (void)setSuccess:(NSNumber *)success { + if (success != nil) { + [parameters setObject:success forKey:NAMES_success]; + } else { + [parameters removeObjectForKey:NAMES_success]; + } +} + +- (NSNumber *)success { + return [parameters objectForKey:NAMES_success]; +} + +- (void)setResultCode:(SDLResult *)resultCode { + if (resultCode != nil) { + [parameters setObject:resultCode forKey:NAMES_resultCode]; + } else { + [parameters removeObjectForKey:NAMES_resultCode]; + } +} + +- (SDLResult *)resultCode { + NSObject *obj = [parameters objectForKey:NAMES_resultCode]; + if (obj == nil || [obj isKindOfClass:SDLResult.class]) { + return (SDLResult *)obj; + } else { + return [SDLResult valueOf:(NSString *)obj]; + } +} + +- (void)setInfo:(NSString *)info { + if (info != nil) { + [parameters setObject:info forKey:NAMES_info]; + } else { + [parameters removeObjectForKey:NAMES_info]; + } +} + +- (NSString *)info { + return [parameters objectForKey:NAMES_info]; +} + +@end diff --git a/SmartDeviceLink/SDLRPCStruct.h b/SmartDeviceLink/SDLRPCStruct.h new file mode 100644 index 000000000..e6b3bcccb --- /dev/null +++ b/SmartDeviceLink/SDLRPCStruct.h @@ -0,0 +1,16 @@ +// +// SDLRPCStruct.h + + +#import <Foundation/Foundation.h> + +@interface SDLRPCStruct : NSObject { + NSMutableDictionary *store; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; +- (instancetype)init; + +- (NSMutableDictionary *)serializeAsDictionary:(Byte)version; + +@end diff --git a/SmartDeviceLink/SDLRPCStruct.m b/SmartDeviceLink/SDLRPCStruct.m new file mode 100644 index 000000000..dd96fff5d --- /dev/null +++ b/SmartDeviceLink/SDLRPCStruct.m @@ -0,0 +1,89 @@ +// +// SDLRPCStruct.m + + +#import "SDLRPCStruct.h" + +#import "SDLEnum.h" +#import "SDLNames.h" + + +@implementation SDLRPCStruct + +- (id)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super init]) { + if (dict != nil) { + store = dict; + } else { + store = [[NSMutableDictionary alloc] init]; + } + } + return self; +} + +- (id)init { + if (self = [super init]) { + store = [[NSMutableDictionary alloc] init]; + } + return self; +} + +- (NSMutableDictionary *)serializeDictionary:(NSDictionary *)dict version:(Byte)version { + NSMutableDictionary *ret = [NSMutableDictionary dictionaryWithCapacity:dict.count]; + for (NSString *key in [dict keyEnumerator]) { + NSObject *value = [dict objectForKey:key]; + if ([value isKindOfClass:SDLRPCStruct.class]) { + [ret setObject:[(SDLRPCStruct *)value serializeAsDictionary:version] forKey:key]; + } else if ([value isKindOfClass:NSDictionary.class]) { + [ret setObject:[self serializeDictionary:(NSDictionary *)value version:version] forKey:key]; + } else if ([value isKindOfClass:NSArray.class]) { + NSArray *arrayVal = (NSArray *)value; + + if (arrayVal.count > 0 && ([[arrayVal objectAtIndex:0] isKindOfClass:SDLRPCStruct.class])) { + NSMutableArray *serializedList = [NSMutableArray arrayWithCapacity:arrayVal.count]; + for (SDLRPCStruct *serializeable in arrayVal) { + [serializedList addObject:[serializeable serializeAsDictionary:version]]; + } + [ret setObject:serializedList forKey:key]; + } else if (arrayVal.count > 0 && ([[arrayVal objectAtIndex:0] isKindOfClass:SDLEnum.class])) { + NSMutableArray *serializedList = [NSMutableArray arrayWithCapacity:arrayVal.count]; + for (SDLEnum *anEnum in arrayVal) { + [serializedList addObject:anEnum.value]; + } + [ret setObject:serializedList forKey:key]; + } else { + [ret setObject:value forKey:key]; + } + } else if ([value isKindOfClass:SDLEnum.class]) { + [ret setObject:((SDLEnum *)value).value forKey:key]; + } else { + [ret setObject:value forKey:key]; + } + } + return ret; +} + +- (NSMutableDictionary *)serializeAsDictionary:(Byte)version { + if (version >= 2) { + NSString *messageType = [[store keyEnumerator] nextObject]; + NSMutableDictionary *function = [store objectForKey:messageType]; + if ([function isKindOfClass:NSMutableDictionary.class]) { + NSMutableDictionary *parameters = [function objectForKey:NAMES_parameters]; + return [self serializeDictionary:parameters version:version]; + } else { + return [self serializeDictionary:store version:version]; + } + } else { + return [self serializeDictionary:store version:version]; + } +} + +- (NSString *)description { + return [store description]; +} + +- (void)dealloc { + store = nil; +} + +@end diff --git a/SmartDeviceLink/SDLReadDID.h b/SmartDeviceLink/SDLReadDID.h new file mode 100644 index 000000000..76df4a592 --- /dev/null +++ b/SmartDeviceLink/SDLReadDID.h @@ -0,0 +1,52 @@ +// SDLReadDID.h +// + + +#import "SDLRPCRequest.h" + +/** + * Non periodic vehicle data read request. This is an RPC to get diagnostics + * data from certain vehicle modules. DIDs of a certain module might differ from + * vehicle type to vehicle type + * <p> + * Function Group: ProprietaryData + * <p> + * <b>HMILevel needs to be FULL, LIMITED or BACKGROUND</b> + * <p> + * + * Since SmartDeviceLink 2.0 + */ +@interface SDLReadDID : SDLRPCRequest { +} + +/** + * @abstract Constructs a new SDLReadDID object + */ +- (instancetype)init; + +/** + * @abstract Constructs a new SDLReadDID object indicated by the dictionary parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract An ID of the vehicle module + * <br/><b>Notes: </b>Minvalue:0; Maxvalue:65535 + */ +@property (strong) NSNumber *ecuName; + +/** + * @abstract Raw data from vehicle data DID location(s) + * <br/>a Vector<Integer> value representing raw data from vehicle + * data DID location(s) + * <p> + * <b>Notes: </b> + * <ul> + * <li>Minvalue:0; Maxvalue:65535</li> + * <li>ArrayMin:0; ArrayMax:1000</li> + * </ul> + */ +@property (strong) NSMutableArray *didLocation; + +@end diff --git a/SmartDeviceLink/SDLReadDID.m b/SmartDeviceLink/SDLReadDID.m new file mode 100644 index 000000000..198d992e0 --- /dev/null +++ b/SmartDeviceLink/SDLReadDID.m @@ -0,0 +1,47 @@ +// SDLReadDID.m +// + + +#import "SDLReadDID.h" + +#import "SDLNames.h" + +@implementation SDLReadDID + +- (instancetype)init { + if (self = [super initWithName:NAMES_ReadDID]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setEcuName:(NSNumber *)ecuName { + if (ecuName != nil) { + [parameters setObject:ecuName forKey:NAMES_ecuName]; + } else { + [parameters removeObjectForKey:NAMES_ecuName]; + } +} + +- (NSNumber *)ecuName { + return [parameters objectForKey:NAMES_ecuName]; +} + +- (void)setDidLocation:(NSMutableArray *)didLocation { + if (didLocation != nil) { + [parameters setObject:didLocation forKey:NAMES_didLocation]; + } else { + [parameters removeObjectForKey:NAMES_didLocation]; + } +} + +- (NSMutableArray *)didLocation { + return [parameters objectForKey:NAMES_didLocation]; +} + +@end diff --git a/SmartDeviceLink/SDLReadDIDResponse.h b/SmartDeviceLink/SDLReadDIDResponse.h new file mode 100644 index 000000000..da1c81573 --- /dev/null +++ b/SmartDeviceLink/SDLReadDIDResponse.h @@ -0,0 +1,20 @@ +// SDLReadDIDResponse.h +// + + +#import "SDLRPCResponse.h" + +/** + * Read DID Response is sent, when ReadDID has been called + * + * Since SmartDeviceLink 2.0 + */ +@interface SDLReadDIDResponse : SDLRPCResponse { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) NSMutableArray *didResult; + +@end diff --git a/SmartDeviceLink/SDLReadDIDResponse.m b/SmartDeviceLink/SDLReadDIDResponse.m new file mode 100644 index 000000000..08c5477f6 --- /dev/null +++ b/SmartDeviceLink/SDLReadDIDResponse.m @@ -0,0 +1,45 @@ +// SDLReadDIDResponse.m +// + + +#import "SDLReadDIDResponse.h" + +#import "SDLDIDResult.h" +#import "SDLNames.h" + +@implementation SDLReadDIDResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_ReadDID]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setDidResult:(NSMutableArray *)didResult { + if (didResult != nil) { + [parameters setObject:didResult forKey:NAMES_didResult]; + } else { + [parameters removeObjectForKey:NAMES_didResult]; + } +} + +- (NSMutableArray *)didResult { + NSMutableArray *array = [parameters objectForKey:NAMES_didResult]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLDIDResult.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLDIDResult alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +@end diff --git a/SmartDeviceLink/SDLRegisterAppInterface.h b/SmartDeviceLink/SDLRegisterAppInterface.h new file mode 100644 index 000000000..be9c1a30b --- /dev/null +++ b/SmartDeviceLink/SDLRegisterAppInterface.h @@ -0,0 +1,217 @@ +// SDLRegisterAppInterface.h +// + +#import "SDLRPCRequest.h" + +@class SDLDeviceInfo; +@class SDLLanguage; +@class SDLSyncMsgVersion; + + +/** + * Registers the application's interface with SDL®, declaring properties of + * the registration, including the messaging interface version, the app name, + * etc. The mobile application must establish its interface registration with + * SDL before any other interaction with SDL® can take place. The + * registration lasts until it is terminated either by the application calling + * the <i> SDLUnregisterAppInterface</i> method, or by SDL® + * sending an <i> SDLOnAppInterfaceUnregistered</i> notification, or + * by loss of the underlying transport connection, or closing of the underlying + * message transmission protocol RPC session + * <p> + * Until the application receives its first <i>SDLOnHMIStatus</i> + * Notification, its HMI Status is assumed to be: <i> + * SDLHMILevel</i>=NONE, <i> + * SDLAudioStreamingState + * </i>=NOT_AUDIBLE, <i> + * SDLSystemContext</i>=MAIN + * <p> + * All SDL® resources which the application creates or uses (e.g. Choice + * Sets, Command Menu, etc.) are associated with the application's interface + * registration. Therefore, when the interface registration ends, the SDL® + * resources associated with the application are disposed of. As a result, even + * though the application itself may continue to run on its host platform (e.g. + * mobile device) after the interface registration terminates, the application + * will not be able to use the SDL® HMI without first establishing a new + * interface registration and re-creating its required SDL® resources. That + * is, SDL® resources created by (or on behalf of) an application do not + * persist beyond the life-span of the interface registration + * <p> + * Resources and settings whose lifespan is tied to the duration of an + * application's interface registration:<br/> + * <ul> + * <li>Choice Sets</li> + * <li>Command Menus (built by successive calls to <i>SDLAddCommand + * </i>)</li> + * <li>Media clock timer display value</li> + * <li>Media clock timer display value</li> + * <li>Media clock timer display value</li> + * </ul> + * <p> + * The autoActivateID is used to grant an application the HMILevel and + * AudioStreamingState it had when it last disconnected + * <p> + * <b>Notes: </b>The autoActivateID parameter, and associated behavior, is + * currently ignored by SDL® + * <p> + * When first calling this method (i.e. first time within life cycle of mobile + * app), an autoActivateID should not be included. After successfully + * registering an interface, an autoActivateID is returned to the mobile + * application for it to use in subsequent connections. If the connection + * between SDL® and the mobile application is lost, such as the vehicle is + * turned off while the application is running, the autoActivateID can then be + * passed in another call to RegisterAppInterface to re-acquire <i> + * SDLHMILevel</i>=FULL + * <p> + * If the application intends to stream audio it is important to indicate so via + * the isMediaApp parameter. When set to true, audio will reliably stream + * without any configuration required by the user. When not set, audio may + * stream, depending on what the user might have manually configured as a media + * source on SDL® + * <p> + * There is no time limit for how long the autoActivateID is "valid" (i.e. would + * confer focus and opt-in) + * <p> + * <b>HMILevel is not defined before registering</b><br/> + * </p> + * + * @since SDL 1.0 + * + * @see SDLUnregisterAppInterface SDLOnAppInterfaceUnregistered + */ +@interface SDLRegisterAppInterface : SDLRPCRequest { +} + +/** + * @abstract Constructs a new SDLRegisterAppInterface object + */ +- (instancetype)init; + +/** + * @abstract Constructs a new SDLRegisterAppInterface object indicated by the dictionary parameter + * + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract The version of the SDL interface + * + * Required + */ +@property (strong) SDLSyncMsgVersion *syncMsgVersion; + +/** + * @abstract The Mobile Application's Name, This name is displayed in the SDL Mobile Applications menu. It also serves as the unique identifier of the application for SmartDeviceLink + * + * @discussion + * <li>Needs to be unique over all applications.</li> + * <li>May not be empty.</li> + * <li>May not start with a new line character.</li> + * <li>May not interfere with any name or synonym of previously registered applications and any predefined blacklist of words (global commands).</li> + * <li>Needs to be unique over all applications. Applications with the same name will be rejected.</li> + * + * Required, Max length 100 chars + */ +@property (strong) NSString *appName; + +/** + * @abstract TTS string for VR recognition of the mobile application name. + * + * @discussion Meant to overcome any failing on speech engine in properly pronouncing / understanding app name. + * <li>Needs to be unique over all applications.</li> + * <li>May not be empty.</li> + * <li>May not start with a new line character.</li> + * + * Optional, Array of SDLTTSChunk, Array size 1 - 100 + * + * @since SDL 2.0 + * @see SDLTTSChunk + */ +@property (strong) NSMutableArray *ttsName; + +/** + * @abstract A String representing an abbreviated version of the mobile application's name (if necessary) that will be displayed on the media screen + * + * @discussion If not provided, the appName is used instead (and will be truncated if too long) + * + * Optional, Max length 100 chars + */ +@property (strong) NSString *ngnMediaScreenAppName; + +/** + * @abstract Defines a additional voice recognition commands + * + * @discussion May not interfere with any app name of previously registered applications and any predefined blacklist of words (global commands) + * + * Optional, Array of Strings, Array length 1 - 100, Max String length 40 + */ +@property (strong) NSMutableArray *vrSynonyms; + +/** + * @abstract Indicates if the application is a media or a non-media application. + * + * @discussion Only media applications will be able to stream audio to head units that is audible outside of the BT media source. + * + * Required, Boolean + */ +@property (strong) NSNumber *isMediaApplication; + +/** + * @abstract A Language enumeration indicating what language the application intends to use for user interaction (TTS and VR). + * + * @discussion If there is a mismatch with the head unit, the app will be able to change this registration with changeRegistration prior to app being brought into focus. + * + * Required + */ +@property (strong) SDLLanguage *languageDesired; + +/** + * @abstract An enumeration indicating what language the application intends to use for user interaction (Display). + * + * @discussion If there is a mismatch with the head unit, the app will be able to change this registration with changeRegistration prior to app being brought into focus. + * + * Required + * + * @since SDL 2.0 + */ +@property (strong) SDLLanguage *hmiDisplayLanguageDesired; + +/** + * @abstract A list of all applicable app types stating which classifications to be given to the app. + * + * Optional, Array of SDLAppHMIType, Array size 1 - 100 + * + * @since SDL 2.0 + * @see SDLAppHMIType + */ +@property (strong) NSMutableArray *appHMIType; + +/** + * @abstract ID used to uniquely identify current state of all app data that can persist through connection cycles (e.g. ignition cycles). + * + * @discussion This registered data (commands, submenus, choice sets, etc.) can be reestablished without needing to explicitly reregister each piece. If omitted, then the previous state of an app's commands, etc. will not be restored. + * + * When sending hashID, all RegisterAppInterface parameters should still be provided (e.g. ttsName, etc.). + * + * Optional, max length 100 chars + */ +@property (strong) NSString *hashID; + +/** + * @abstract Information about the connecting device + * + * Optional + */ +@property (strong) SDLDeviceInfo *deviceInfo; + +/** + * @abstract ID used to validate app with policy table entries + * + * Required, max length 100 + * + * @since SDL 2.0 + */ +@property (strong) NSString *appID; + +@end diff --git a/SmartDeviceLink/SDLRegisterAppInterface.m b/SmartDeviceLink/SDLRegisterAppInterface.m new file mode 100644 index 000000000..318d5dfa7 --- /dev/null +++ b/SmartDeviceLink/SDLRegisterAppInterface.m @@ -0,0 +1,211 @@ +// SDLRegisterAppInterface.m +// + + +#import "SDLRegisterAppInterface.h" + +#import "SDLAppHMIType.h" +#import "SDLDeviceInfo.h" +#import "SDLLanguage.h" +#import "SDLNames.h" +#import "SDLSyncMsgVersion.h" +#import "SDLTTSChunk.h" + + +@implementation SDLRegisterAppInterface + +- (instancetype)init { + if (self = [super initWithName:NAMES_RegisterAppInterface]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setSyncMsgVersion:(SDLSyncMsgVersion *)syncMsgVersion { + if (syncMsgVersion != nil) { + [parameters setObject:syncMsgVersion forKey:NAMES_syncMsgVersion]; + } else { + [parameters removeObjectForKey:NAMES_syncMsgVersion]; + } +} + +- (SDLSyncMsgVersion *)syncMsgVersion { + NSObject *obj = [parameters objectForKey:NAMES_syncMsgVersion]; + if (obj == nil || [obj isKindOfClass:SDLSyncMsgVersion.class]) { + return (SDLSyncMsgVersion *)obj; + } else { + return [[SDLSyncMsgVersion alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setAppName:(NSString *)appName { + if (appName != nil) { + [parameters setObject:appName forKey:NAMES_appName]; + } else { + [parameters removeObjectForKey:NAMES_appName]; + } +} + +- (NSString *)appName { + return [parameters objectForKey:NAMES_appName]; +} + +- (void)setTtsName:(NSMutableArray *)ttsName { + if (ttsName != nil) { + [parameters setObject:ttsName forKey:NAMES_ttsName]; + } else { + [parameters removeObjectForKey:NAMES_ttsName]; + } +} + +- (NSMutableArray *)ttsName { + NSMutableArray *array = [parameters objectForKey:NAMES_ttsName]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLTTSChunk.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLTTSChunk alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +- (void)setNgnMediaScreenAppName:(NSString *)ngnMediaScreenAppName { + if (ngnMediaScreenAppName != nil) { + [parameters setObject:ngnMediaScreenAppName forKey:NAMES_ngnMediaScreenAppName]; + } else { + [parameters removeObjectForKey:NAMES_ngnMediaScreenAppName]; + } +} + +- (NSString *)ngnMediaScreenAppName { + return [parameters objectForKey:NAMES_ngnMediaScreenAppName]; +} + +- (void)setVrSynonyms:(NSMutableArray *)vrSynonyms { + if (vrSynonyms != nil) { + [parameters setObject:vrSynonyms forKey:NAMES_vrSynonyms]; + } else { + [parameters removeObjectForKey:NAMES_vrSynonyms]; + } +} + +- (NSMutableArray *)vrSynonyms { + return [parameters objectForKey:NAMES_vrSynonyms]; +} + +- (void)setIsMediaApplication:(NSNumber *)isMediaApplication { + if (isMediaApplication != nil) { + [parameters setObject:isMediaApplication forKey:NAMES_isMediaApplication]; + } else { + [parameters removeObjectForKey:NAMES_isMediaApplication]; + } +} + +- (NSNumber *)isMediaApplication { + return [parameters objectForKey:NAMES_isMediaApplication]; +} + +- (void)setLanguageDesired:(SDLLanguage *)languageDesired { + if (languageDesired != nil) { + [parameters setObject:languageDesired forKey:NAMES_languageDesired]; + } else { + [parameters removeObjectForKey:NAMES_languageDesired]; + } +} + +- (SDLLanguage *)languageDesired { + NSObject *obj = [parameters objectForKey:NAMES_languageDesired]; + if (obj == nil || [obj isKindOfClass:SDLLanguage.class]) { + return (SDLLanguage *)obj; + } else { + return [SDLLanguage valueOf:(NSString *)obj]; + } +} + +- (void)setHmiDisplayLanguageDesired:(SDLLanguage *)hmiDisplayLanguageDesired { + if (hmiDisplayLanguageDesired != nil) { + [parameters setObject:hmiDisplayLanguageDesired forKey:NAMES_hmiDisplayLanguageDesired]; + } else { + [parameters removeObjectForKey:NAMES_hmiDisplayLanguageDesired]; + } +} + +- (SDLLanguage *)hmiDisplayLanguageDesired { + NSObject *obj = [parameters objectForKey:NAMES_hmiDisplayLanguageDesired]; + if (obj == nil || [obj isKindOfClass:SDLLanguage.class]) { + return (SDLLanguage *)obj; + } else { + return [SDLLanguage valueOf:(NSString *)obj]; + } +} + +- (void)setAppHMIType:(NSMutableArray *)appHMIType { + if (appHMIType != nil) { + [parameters setObject:appHMIType forKey:NAMES_appHMIType]; + } else { + [parameters removeObjectForKey:NAMES_appHMIType]; + } +} + +- (NSMutableArray *)appHMIType { + NSMutableArray *array = [parameters objectForKey:NAMES_appHMIType]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLAppHMIType.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSString *enumString in array) { + [newList addObject:[SDLAppHMIType valueOf:enumString]]; + } + return newList; + } +} + +- (void)setHashID:(NSString *)hashID { + if (hashID != nil) { + [parameters setObject:hashID forKey:NAMES_hashID]; + } else { + [parameters removeObjectForKey:NAMES_hashID]; + } +} + +- (NSString *)hashID { + return [parameters objectForKey:NAMES_hashID]; +} + +- (void)setDeviceInfo:(SDLDeviceInfo *)deviceInfo { + if (deviceInfo != nil) { + [parameters setObject:deviceInfo forKey:NAMES_deviceInfo]; + } else { + [parameters removeObjectForKey:NAMES_deviceInfo]; + } +} + +- (SDLDeviceInfo *)deviceInfo { + NSObject *obj = [parameters objectForKey:NAMES_deviceInfo]; + if (obj == nil || [obj isKindOfClass:SDLDeviceInfo.class]) { + return (SDLDeviceInfo *)obj; + } else { + return [[SDLDeviceInfo alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setAppID:(NSString *)appID { + if (appID != nil) { + [parameters setObject:appID forKey:NAMES_appID]; + } else { + [parameters removeObjectForKey:NAMES_appID]; + } +} + +- (NSString *)appID { + return [parameters objectForKey:NAMES_appID]; +} + +@end diff --git a/SmartDeviceLink/SDLRegisterAppInterfaceResponse.h b/SmartDeviceLink/SDLRegisterAppInterfaceResponse.h new file mode 100644 index 000000000..9bfc0a16a --- /dev/null +++ b/SmartDeviceLink/SDLRegisterAppInterfaceResponse.h @@ -0,0 +1,166 @@ +// SDLRegisterAppInterfaceResponse.h +// + + +#import "SDLRPCResponse.h" + +@class SDLLanguage; +@class SDLDisplayCapabilities; +@class SDLHMICapabilities; +@class SDLPresetBankCapabilities; +@class SDLSyncMsgVersion; +@class SDLVehicleType; + + +/** + * @abstract Register AppInterface Response is sent, when SDLRegisterAppInterface has been called + * + * Since SmartDeviceLink 1.0 + */ +@interface SDLRegisterAppInterfaceResponse : SDLRPCResponse { +} + +/** + * @abstract Constructs a new SDLRegisterAppInterfaceResponse object + */ +- (instancetype)init; + +/** + * Constructs a new SDLRegisterAppInterfaceResponse object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @see SDLSyncMsgVersion + * + * Optional + */ +@property (strong) SDLSyncMsgVersion *syncMsgVersion; + +/** + * The currently active VR+TTS language on Sync. + * + * @see SDLLanguage + * + * Optional + */ +@property (strong) SDLLanguage *language; + +/** + * The currently active display language on Sync + * + * @see SDLLanguage + * @since SmartDeviceLink 2.0 + * + * Optional + */ +@property (strong) SDLLanguage *hmiDisplayLanguage; + +/** + * @see SDLDisplayCapabilities + * + * Optional + */ +@property (strong) SDLDisplayCapabilities *displayCapabilities; + +/** + * @see SDLButtonCapabilities + * + * Optional, Array of length 1 - 100, of SDLButtonCapabilities + */ +@property (strong) NSMutableArray *buttonCapabilities; + +/** + * If returned, the platform supports on-screen SoftButtons + * + * @see SDLSoftButtonCapabilities + * + * Optional, Array of length 1 - 100, of SDLSoftButtonCapabilities + */ +@property (strong) NSMutableArray *softButtonCapabilities; + +/** + * If returned, the platform supports custom on-screen Presets + * + * @see SDLPresetBankCapabilities + * + * Optional + */ +@property (strong) SDLPresetBankCapabilities *presetBankCapabilities; + +/** + * @see SDLHMIZoneCapabilities + * + * Optional, Array of length 1 - 100, of SDLHMIZoneCapabilities + */ +@property (strong) NSMutableArray *hmiZoneCapabilities; + +/** + * @see SDLSpeechCapabilities + * + * Optional, Array of length 1 - 100, of SDLSpeechCapabilities + */ +@property (strong) NSMutableArray *speechCapabilities; + +/** + * @see SDLPrerecordedSpeech + * + * Optional, Array of length 1 - 100, of SDLPrerecordedSpeech + */ +@property (strong) NSMutableArray *prerecordedSpeech; + +/** + * @see SDLVRCapabilities + * + * Optional, Array of length 1 - 100, of SDLVRCapabilities + */ +@property (strong) NSMutableArray *vrCapabilities; + +/** + * @see SDLAudioPassThruCapabilities + * + * Optional, Array of length 1 - 100, of SDLAudioPassThruCapabilities + */ +@property (strong) NSMutableArray *audioPassThruCapabilities; + +/** + * Specifies the vehicle's type + * + * @see SDLVehicleType + * + * Optional, Array of length 1 - 100, of SDLVehicleType + */ +@property (strong) SDLVehicleType *vehicleType; + +/** + * Specifies the white-list of supported diagnostic modes (0x00-0xFF) capable for DiagnosticMessage requests. If a mode outside this list is requested, it will be rejected. + * + * Optional, Array of length 1 - 100, Integer 0 - 255 + */ +@property (strong) NSMutableArray *supportedDiagModes; + +/** + * @see SDLHMICapabilities + * + * Optional + */ +@property (strong) SDLHMICapabilities *hmiCapabilities; + +/** + * The SmartDeviceLink version + * + * Optional, String max length 100 + */ +@property (strong) NSString *sdlVersion; + +/** + * The software version of the system that implements the SmartDeviceLink core + * + * Optional, String max length 100 + */ +@property (strong) NSString *systemSoftwareVersion; + + +@end diff --git a/SmartDeviceLink/SDLRegisterAppInterfaceResponse.m b/SmartDeviceLink/SDLRegisterAppInterfaceResponse.m new file mode 100644 index 000000000..18356c34f --- /dev/null +++ b/SmartDeviceLink/SDLRegisterAppInterfaceResponse.m @@ -0,0 +1,339 @@ +// SDLRegisterAppInterfaceResponse.m +// + + +#import "SDLRegisterAppInterfaceResponse.h" + +#import "SDLAudioPassThruCapabilities.h" +#import "SDLButtonCapabilities.h" +#import "SDLDisplayCapabilities.h" +#import "SDLHMICapabilities.h" +#import "SDLHMIZoneCapabilities.h" +#import "SDLLanguage.h" +#import "SDLNames.h" +#import "SDLPrerecordedSpeech.h" +#import "SDLPresetBankCapabilities.h" +#import "SDLSoftButtonCapabilities.h" +#import "SDLSpeechCapabilities.h" +#import "SDLSyncMsgVersion.h" +#import "SDLVRCapabilities.h" +#import "SDLVehicleType.h" + + +@implementation SDLRegisterAppInterfaceResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_RegisterAppInterface]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setSyncMsgVersion:(SDLSyncMsgVersion *)syncMsgVersion { + if (syncMsgVersion != nil) { + [parameters setObject:syncMsgVersion forKey:NAMES_syncMsgVersion]; + } else { + [parameters removeObjectForKey:NAMES_syncMsgVersion]; + } +} + +- (SDLSyncMsgVersion *)syncMsgVersion { + NSObject *obj = [parameters objectForKey:NAMES_syncMsgVersion]; + if (obj == nil || [obj isKindOfClass:SDLSyncMsgVersion.class]) { + return (SDLSyncMsgVersion *)obj; + } else { + return [[SDLSyncMsgVersion alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setLanguage:(SDLLanguage *)language { + if (language != nil) { + [parameters setObject:language forKey:NAMES_language]; + } else { + [parameters removeObjectForKey:NAMES_language]; + } +} + +- (SDLLanguage *)language { + NSObject *obj = [parameters objectForKey:NAMES_language]; + if (obj == nil || [obj isKindOfClass:SDLLanguage.class]) { + return (SDLLanguage *)obj; + } else { + return [SDLLanguage valueOf:(NSString *)obj]; + } +} + +- (void)setHmiDisplayLanguage:(SDLLanguage *)hmiDisplayLanguage { + if (hmiDisplayLanguage != nil) { + [parameters setObject:hmiDisplayLanguage forKey:NAMES_hmiDisplayLanguage]; + } else { + [parameters removeObjectForKey:NAMES_hmiDisplayLanguage]; + } +} + +- (SDLLanguage *)hmiDisplayLanguage { + NSObject *obj = [parameters objectForKey:NAMES_hmiDisplayLanguage]; + if (obj == nil || [obj isKindOfClass:SDLLanguage.class]) { + return (SDLLanguage *)obj; + } else { + return [SDLLanguage valueOf:(NSString *)obj]; + } +} + +- (void)setDisplayCapabilities:(SDLDisplayCapabilities *)displayCapabilities { + if (displayCapabilities != nil) { + [parameters setObject:displayCapabilities forKey:NAMES_displayCapabilities]; + } else { + [parameters removeObjectForKey:NAMES_displayCapabilities]; + } +} + +- (SDLDisplayCapabilities *)displayCapabilities { + NSObject *obj = [parameters objectForKey:NAMES_displayCapabilities]; + if (obj == nil || [obj isKindOfClass:SDLDisplayCapabilities.class]) { + return (SDLDisplayCapabilities *)obj; + } else { + return [[SDLDisplayCapabilities alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setButtonCapabilities:(NSMutableArray *)buttonCapabilities { + if (buttonCapabilities != nil) { + [parameters setObject:buttonCapabilities forKey:NAMES_buttonCapabilities]; + } else { + [parameters removeObjectForKey:NAMES_buttonCapabilities]; + } +} + +- (NSMutableArray *)buttonCapabilities { + NSMutableArray *array = [parameters objectForKey:NAMES_buttonCapabilities]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLButtonCapabilities.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLButtonCapabilities alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +- (void)setSoftButtonCapabilities:(NSMutableArray *)softButtonCapabilities { + if (softButtonCapabilities != nil) { + [parameters setObject:softButtonCapabilities forKey:NAMES_softButtonCapabilities]; + } else { + [parameters removeObjectForKey:NAMES_softButtonCapabilities]; + } +} + +- (NSMutableArray *)softButtonCapabilities { + NSMutableArray *array = [parameters objectForKey:NAMES_softButtonCapabilities]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLSoftButtonCapabilities.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLSoftButtonCapabilities alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +- (void)setPresetBankCapabilities:(SDLPresetBankCapabilities *)presetBankCapabilities { + if (presetBankCapabilities != nil) { + [parameters setObject:presetBankCapabilities forKey:NAMES_presetBankCapabilities]; + } else { + [parameters removeObjectForKey:NAMES_presetBankCapabilities]; + } +} + +- (SDLPresetBankCapabilities *)presetBankCapabilities { + NSObject *obj = [parameters objectForKey:NAMES_presetBankCapabilities]; + if (obj == nil || [obj isKindOfClass:SDLPresetBankCapabilities.class]) { + return (SDLPresetBankCapabilities *)obj; + } else { + return [[SDLPresetBankCapabilities alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setHmiZoneCapabilities:(NSMutableArray *)hmiZoneCapabilities { + if (hmiZoneCapabilities != nil) { + [parameters setObject:hmiZoneCapabilities forKey:NAMES_hmiZoneCapabilities]; + } else { + [parameters removeObjectForKey:NAMES_hmiZoneCapabilities]; + } +} + +- (NSMutableArray *)hmiZoneCapabilities { + NSMutableArray *array = [parameters objectForKey:NAMES_hmiZoneCapabilities]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLHMIZoneCapabilities.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSString *enumString in array) { + [newList addObject:[SDLHMIZoneCapabilities valueOf:enumString]]; + } + return newList; + } +} + +- (void)setSpeechCapabilities:(NSMutableArray *)speechCapabilities { + if (speechCapabilities != nil) { + [parameters setObject:speechCapabilities forKey:NAMES_speechCapabilities]; + } else { + [parameters removeObjectForKey:NAMES_speechCapabilities]; + } +} + +- (NSMutableArray *)speechCapabilities { + NSMutableArray *array = [parameters objectForKey:NAMES_speechCapabilities]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLSpeechCapabilities.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSString *enumString in array) { + [newList addObject:[SDLSpeechCapabilities valueOf:enumString]]; + } + return newList; + } +} + +- (void)setPrerecordedSpeech:(NSMutableArray *)prerecordedSpeech { + if (prerecordedSpeech != nil) { + [parameters setObject:prerecordedSpeech forKey:NAMES_prerecordedSpeech]; + } else { + [parameters removeObjectForKey:NAMES_prerecordedSpeech]; + } +} + +- (NSMutableArray *)prerecordedSpeech { + NSMutableArray *array = [parameters objectForKey:NAMES_prerecordedSpeech]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLPrerecordedSpeech.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSString *enumString in array) { + [newList addObject:[SDLPrerecordedSpeech valueOf:enumString]]; + } + return newList; + } +} + +- (void)setVrCapabilities:(NSMutableArray *)vrCapabilities { + if (vrCapabilities != nil) { + [parameters setObject:vrCapabilities forKey:NAMES_vrCapabilities]; + } else { + [parameters removeObjectForKey:NAMES_vrCapabilities]; + } +} + +- (NSMutableArray *)vrCapabilities { + NSMutableArray *array = [parameters objectForKey:NAMES_vrCapabilities]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLVRCapabilities.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSString *enumString in array) { + [newList addObject:[SDLVRCapabilities valueOf:enumString]]; + } + return newList; + } +} + +- (void)setAudioPassThruCapabilities:(NSMutableArray *)audioPassThruCapabilities { + if (audioPassThruCapabilities != nil) { + [parameters setObject:audioPassThruCapabilities forKey:NAMES_audioPassThruCapabilities]; + } else { + [parameters removeObjectForKey:NAMES_audioPassThruCapabilities]; + } +} + +- (NSMutableArray *)audioPassThruCapabilities { + NSMutableArray *array = [parameters objectForKey:NAMES_audioPassThruCapabilities]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLAudioPassThruCapabilities.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLAudioPassThruCapabilities alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +- (void)setVehicleType:(SDLVehicleType *)vehicleType { + if (vehicleType != nil) { + [parameters setObject:vehicleType forKey:NAMES_vehicleType]; + } else { + [parameters removeObjectForKey:NAMES_vehicleType]; + } +} + +- (SDLVehicleType *)vehicleType { + NSObject *obj = [parameters objectForKey:NAMES_vehicleType]; + if (obj == nil || [obj isKindOfClass:SDLVehicleType.class]) { + return (SDLVehicleType *)obj; + } else { + return [[SDLVehicleType alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setSupportedDiagModes:(NSMutableArray *)supportedDiagModes { + if (supportedDiagModes != nil) { + [parameters setObject:supportedDiagModes forKey:NAMES_supportedDiagModes]; + } else { + [parameters removeObjectForKey:NAMES_supportedDiagModes]; + } +} + +- (NSMutableArray *)supportedDiagModes { + return [parameters objectForKey:NAMES_supportedDiagModes]; +} + +- (void)setHmiCapabilities:(SDLHMICapabilities *)hmiCapabilities { + if (hmiCapabilities != nil) { + [parameters setObject:hmiCapabilities forKey:NAMES_hmiCapabilities]; + } else { + [parameters removeObjectForKey:NAMES_hmiCapabilities]; + } +} + +- (SDLHMICapabilities *)hmiCapabilities { + NSObject *obj = [parameters objectForKey:NAMES_hmiCapabilities]; + if (obj == nil || [obj isKindOfClass:[SDLHMICapabilities class]]) { + return (SDLHMICapabilities *)obj; + } else { + return [[SDLHMICapabilities alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setSdlVersion:(NSString *)sdlVersion { + if (sdlVersion != nil) { + parameters[NAMES_sdlVersion] = sdlVersion; + } else { + [parameters removeObjectForKey:NAMES_sdlVersion]; + } +} + +- (NSString *)sdlVersion { + return parameters[NAMES_sdlVersion]; +} + +- (void)setSystemSoftwareVersion:(NSString *)systemSoftwareVersion { + if (systemSoftwareVersion != nil) { + parameters[NAMES_systemSoftwareVersion] = systemSoftwareVersion; + } else { + [parameters removeObjectForKey:NAMES_systemSoftwareVersion]; + } +} + +- (NSString *)systemSoftwareVersion { + return parameters[NAMES_systemSoftwareVersion]; +} + +@end diff --git a/SmartDeviceLink/SDLRequestType.h b/SmartDeviceLink/SDLRequestType.h new file mode 100644 index 000000000..a8d631234 --- /dev/null +++ b/SmartDeviceLink/SDLRequestType.h @@ -0,0 +1,34 @@ +// SDLRequestType.h +// + + +#import "SDLEnum.h" + +@interface SDLRequestType : SDLEnum { +} + ++ (SDLRequestType *)valueOf:(NSString *)value; ++ (NSArray *)values; + ++ (SDLRequestType *)HTTP; ++ (SDLRequestType *)FILE_RESUME; ++ (SDLRequestType *)AUTH_REQUEST; ++ (SDLRequestType *)AUTH_CHALLENGE; ++ (SDLRequestType *)AUTH_ACK; ++ (SDLRequestType *)PROPRIETARY; ++ (SDLRequestType *)QUERY_APPS; ++ (SDLRequestType *)LAUNCH_APP; ++ (SDLRequestType *)LOCK_SCREEN_ICON_URL; ++ (SDLRequestType *)TRAFFIC_MESSAGE_CHANNEL; ++ (SDLRequestType *)DRIVER_PROFILE; ++ (SDLRequestType *)VOICE_SEARCH; ++ (SDLRequestType *)NAVIGATION; ++ (SDLRequestType *)PHONE; ++ (SDLRequestType *)CLIMATE; ++ (SDLRequestType *)SETTINGS; ++ (SDLRequestType *)VEHICLE_DIAGNOSTICS; ++ (SDLRequestType *)EMERGENCY; ++ (SDLRequestType *)MEDIA; ++ (SDLRequestType *)FOTA; + +@end diff --git a/SmartDeviceLink/SDLRequestType.m b/SmartDeviceLink/SDLRequestType.m new file mode 100644 index 000000000..7332b9843 --- /dev/null +++ b/SmartDeviceLink/SDLRequestType.m @@ -0,0 +1,210 @@ +// SDLRequestType.m +// + + +#import "SDLRequestType.h" + +SDLRequestType *SDLRequestType_HTTP = nil; +SDLRequestType *SDLRequestType_FILE_RESUME = nil; +SDLRequestType *SDLRequestType_AUTH_REQUEST = nil; +SDLRequestType *SDLRequestType_AUTH_CHALLENGE = nil; +SDLRequestType *SDLRequestType_AUTH_ACK = nil; +SDLRequestType *SDLRequestType_PROPRIETARY = nil; +SDLRequestType *SDLRequestType_QUERY_APPS = nil; +SDLRequestType *SDLRequestType_LAUNCH_APP = nil; +SDLRequestType *SDLRequestType_LOCK_SCREEN_ICON_URL = nil; +SDLRequestType *SDLRequestType_TRAFFIC_MESSAGE_CHANNEL = nil; +SDLRequestType *SDLRequestType_DRIVER_PROFILE = nil; +SDLRequestType *SDLRequestType_VOICE_SEARCH = nil; +SDLRequestType *SDLRequestType_NAVIGATION = nil; +SDLRequestType *SDLRequestType_PHONE = nil; +SDLRequestType *SDLRequestType_CLIMATE = nil; +SDLRequestType *SDLRequestType_SETTINGS = nil; +SDLRequestType *SDLRequestType_VEHICLE_DIAGNOSTICS = nil; +SDLRequestType *SDLRequestType_EMERGENCY = nil; +SDLRequestType *SDLRequestType_MEDIA = nil; +SDLRequestType *SDLRequestType_FOTA = nil; + +NSArray *SDLRequestType_values = nil; + + +@implementation SDLRequestType + ++ (SDLRequestType *)valueOf:(NSString *)value { + for (SDLRequestType *item in SDLRequestType.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLRequestType_values == nil) { + SDLRequestType_values = @[ + [SDLRequestType HTTP], + [SDLRequestType FILE_RESUME], + [SDLRequestType AUTH_REQUEST], + [SDLRequestType AUTH_CHALLENGE], + [SDLRequestType AUTH_ACK], + [SDLRequestType PROPRIETARY], + [SDLRequestType QUERY_APPS], + [SDLRequestType LAUNCH_APP], + [SDLRequestType LOCK_SCREEN_ICON_URL], + [SDLRequestType TRAFFIC_MESSAGE_CHANNEL], + [SDLRequestType DRIVER_PROFILE], + [SDLRequestType VOICE_SEARCH], + [SDLRequestType NAVIGATION], + [SDLRequestType PHONE], + [SDLRequestType CLIMATE], + [SDLRequestType SETTINGS], + [SDLRequestType VEHICLE_DIAGNOSTICS], + [SDLRequestType EMERGENCY], + [SDLRequestType MEDIA], + [SDLRequestType FOTA], + ]; + } + return SDLRequestType_values; +} + ++ (SDLRequestType *)HTTP { + if (SDLRequestType_HTTP == nil) { + SDLRequestType_HTTP = [[SDLRequestType alloc] initWithValue:@"HTTP"]; + } + return SDLRequestType_HTTP; +} + ++ (SDLRequestType *)FILE_RESUME { + if (SDLRequestType_FILE_RESUME == nil) { + SDLRequestType_FILE_RESUME = [[SDLRequestType alloc] initWithValue:@"FILE_RESUME"]; + } + return SDLRequestType_FILE_RESUME; +} + ++ (SDLRequestType *)AUTH_REQUEST { + if (SDLRequestType_AUTH_REQUEST == nil) { + SDLRequestType_AUTH_REQUEST = [[SDLRequestType alloc] initWithValue:@"AUTH_REQUEST"]; + } + return SDLRequestType_AUTH_REQUEST; +} + ++ (SDLRequestType *)AUTH_CHALLENGE { + if (SDLRequestType_AUTH_CHALLENGE == nil) { + SDLRequestType_AUTH_CHALLENGE = [[SDLRequestType alloc] initWithValue:@"AUTH_CHALLENGE"]; + } + return SDLRequestType_AUTH_CHALLENGE; +} + ++ (SDLRequestType *)AUTH_ACK { + if (SDLRequestType_AUTH_ACK == nil) { + SDLRequestType_AUTH_ACK = [[SDLRequestType alloc] initWithValue:@"AUTH_ACK"]; + } + return SDLRequestType_AUTH_ACK; +} + ++ (SDLRequestType *)PROPRIETARY { + if (SDLRequestType_PROPRIETARY == nil) { + SDLRequestType_PROPRIETARY = [[SDLRequestType alloc] initWithValue:@"PROPRIETARY"]; + } + return SDLRequestType_PROPRIETARY; +} + ++ (SDLRequestType *)QUERY_APPS { + if (SDLRequestType_QUERY_APPS == nil) { + SDLRequestType_QUERY_APPS = [[SDLRequestType alloc] initWithValue:@"QUERY_APPS"]; + } + return SDLRequestType_QUERY_APPS; +} + ++ (SDLRequestType *)LAUNCH_APP { + if (SDLRequestType_LAUNCH_APP == nil) { + SDLRequestType_LAUNCH_APP = [[SDLRequestType alloc] initWithValue:@"LAUNCH_APP"]; + } + return SDLRequestType_LAUNCH_APP; +} + ++ (SDLRequestType *)LOCK_SCREEN_ICON_URL { + if (SDLRequestType_LOCK_SCREEN_ICON_URL == nil) { + SDLRequestType_LOCK_SCREEN_ICON_URL = [[SDLRequestType alloc] initWithValue:@"LOCK_SCREEN_ICON_URL"]; + } + return SDLRequestType_LOCK_SCREEN_ICON_URL; +} + ++ (SDLRequestType *)TRAFFIC_MESSAGE_CHANNEL { + if (SDLRequestType_TRAFFIC_MESSAGE_CHANNEL == nil) { + SDLRequestType_TRAFFIC_MESSAGE_CHANNEL = [[SDLRequestType alloc] initWithValue:@"TRAFFIC_MESSAGE_CHANNEL"]; + } + return SDLRequestType_TRAFFIC_MESSAGE_CHANNEL; +} + ++ (SDLRequestType *)DRIVER_PROFILE { + if (SDLRequestType_DRIVER_PROFILE == nil) { + SDLRequestType_DRIVER_PROFILE = [[SDLRequestType alloc] initWithValue:@"DRIVER_PROFILE"]; + } + return SDLRequestType_DRIVER_PROFILE; +} + ++ (SDLRequestType *)VOICE_SEARCH { + if (SDLRequestType_VOICE_SEARCH == nil) { + SDLRequestType_VOICE_SEARCH = [[SDLRequestType alloc] initWithValue:@"VOICE_SEARCH"]; + } + return SDLRequestType_VOICE_SEARCH; +} + ++ (SDLRequestType *)NAVIGATION { + if (SDLRequestType_NAVIGATION == nil) { + SDLRequestType_NAVIGATION = [[SDLRequestType alloc] initWithValue:@"NAVIGATION"]; + } + return SDLRequestType_NAVIGATION; +} + ++ (SDLRequestType *)PHONE { + if (SDLRequestType_PHONE == nil) { + SDLRequestType_PHONE = [[SDLRequestType alloc] initWithValue:@"PHONE"]; + } + return SDLRequestType_PHONE; +} + ++ (SDLRequestType *)CLIMATE { + if (SDLRequestType_CLIMATE == nil) { + SDLRequestType_CLIMATE = [[SDLRequestType alloc] initWithValue:@"CLIMATE"]; + } + return SDLRequestType_CLIMATE; +} + ++ (SDLRequestType *)SETTINGS { + if (SDLRequestType_SETTINGS == nil) { + SDLRequestType_SETTINGS = [[SDLRequestType alloc] initWithValue:@"SETTINGS"]; + } + return SDLRequestType_SETTINGS; +} + ++ (SDLRequestType *)VEHICLE_DIAGNOSTICS { + if (SDLRequestType_VEHICLE_DIAGNOSTICS == nil) { + SDLRequestType_VEHICLE_DIAGNOSTICS = [[SDLRequestType alloc] initWithValue:@"VEHICLE_DIAGNOSTICS"]; + } + return SDLRequestType_VEHICLE_DIAGNOSTICS; +} + ++ (SDLRequestType *)EMERGENCY { + if (SDLRequestType_EMERGENCY == nil) { + SDLRequestType_EMERGENCY = [[SDLRequestType alloc] initWithValue:@"EMERGENCY"]; + } + return SDLRequestType_EMERGENCY; +} + ++ (SDLRequestType *)MEDIA { + if (SDLRequestType_MEDIA == nil) { + SDLRequestType_MEDIA = [[SDLRequestType alloc] initWithValue:@"MEDIA"]; + } + return SDLRequestType_MEDIA; +} + ++ (SDLRequestType *)FOTA { + if (SDLRequestType_FOTA == nil) { + SDLRequestType_FOTA = [[SDLRequestType alloc] initWithValue:@"FOTA"]; + } + return SDLRequestType_FOTA; +} + +@end diff --git a/SmartDeviceLink/SDLResetGlobalProperties.h b/SmartDeviceLink/SDLResetGlobalProperties.h new file mode 100644 index 000000000..f30b59a41 --- /dev/null +++ b/SmartDeviceLink/SDLResetGlobalProperties.h @@ -0,0 +1,43 @@ +// SDLResetGlobalProperties.h +// + + +#import "SDLRPCRequest.h" + +/** + * Resets the passed global properties to their default values as defined by + * SDL + * <p> + * The HELPPROMPT global property default value is generated by SDL consists of + * the first vrCommand of each Command Menu item defined at the moment PTT is + * pressed<br/> + * The TIMEOUTPROMPT global property default value is the same as the HELPPROMPT + * global property default value + * <p> + * <b>HMILevel needs to be FULL, LIMITED or BACKGROUND</b> + * </p> + * + * Since SmartDeviceLink 1.0 + * See SetGlobalProperties + */ +@interface SDLResetGlobalProperties : SDLRPCRequest { +} + +/** + * @abstract Constructs a new SDLResetGlobalProperties object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLResetGlobalProperties object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract An array of one or more GlobalProperty enumeration elements + * indicating which global properties to reset to their default value + */ +@property (strong) NSMutableArray *properties; + +@end diff --git a/SmartDeviceLink/SDLResetGlobalProperties.m b/SmartDeviceLink/SDLResetGlobalProperties.m new file mode 100644 index 000000000..350f96de0 --- /dev/null +++ b/SmartDeviceLink/SDLResetGlobalProperties.m @@ -0,0 +1,45 @@ +// SDLResetGlobalProperties.m +// + + +#import "SDLResetGlobalProperties.h" + +#import "SDLGlobalProperty.h" +#import "SDLNames.h" + +@implementation SDLResetGlobalProperties + +- (instancetype)init { + if (self = [super initWithName:NAMES_ResetGlobalProperties]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setProperties:(NSMutableArray *)properties { + if (properties != nil) { + [parameters setObject:properties forKey:NAMES_properties]; + } else { + [parameters removeObjectForKey:NAMES_properties]; + } +} + +- (NSMutableArray *)properties { + NSMutableArray *array = [parameters objectForKey:NAMES_properties]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLGlobalProperty.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSString *enumString in array) { + [newList addObject:[SDLGlobalProperty valueOf:enumString]]; + } + return newList; + } +} + +@end diff --git a/SmartDeviceLink/SDLResetGlobalPropertiesResponse.h b/SmartDeviceLink/SDLResetGlobalPropertiesResponse.h new file mode 100644 index 000000000..5e576445a --- /dev/null +++ b/SmartDeviceLink/SDLResetGlobalPropertiesResponse.h @@ -0,0 +1,26 @@ +// SDLResetGlobalPropertiesResponse.h +// + + +#import "SDLRPCResponse.h" + +/** + * Reset Global Properties Response is sent, when SDLResetGlobalProperties has been called + * + * Since SmartDeviceLink 1.0 + */ +@interface SDLResetGlobalPropertiesResponse : SDLRPCResponse { +} + +/** + * @abstract Constructs a new SDLResetGlobalPropertiesResponse object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLResetGlobalPropertiesResponse object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLResetGlobalPropertiesResponse.m b/SmartDeviceLink/SDLResetGlobalPropertiesResponse.m new file mode 100644 index 000000000..e43b61a40 --- /dev/null +++ b/SmartDeviceLink/SDLResetGlobalPropertiesResponse.m @@ -0,0 +1,23 @@ +// SDLResetGlobalPropertiesResponse.m +// + + +#import "SDLResetGlobalPropertiesResponse.h" + +#import "SDLNames.h" + +@implementation SDLResetGlobalPropertiesResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_ResetGlobalProperties]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLResult.h b/SmartDeviceLink/SDLResult.h new file mode 100644 index 000000000..f11404c5a --- /dev/null +++ b/SmartDeviceLink/SDLResult.h @@ -0,0 +1,204 @@ +// SDLResult.h +// + + +#import "SDLEnum.h" + +/** + * Defines the possible result codes returned by SDL to the application in a response to a requested operation + * + * @since SDL 1.0 + */ +@interface SDLResult : SDLEnum { +} + +/** + * @abstract get SDLResult according value string + * @param value The value of the string to get an object for + * @return SDLResult object + */ ++ (SDLResult *)valueOf:(NSString *)value; + +/** + @abstract declare an array to store all possible SDLResult values + @return the array + */ ++ (NSArray *)values; + +/** + * @abstract The request succeeded + */ ++ (SDLResult *)SUCCESS; + +/** + * @abstract Result code : Invalid Data + * + * @discussion The data sent is invalid. For example: + * <li>Invalid Json syntax</li> + * <li>Parameters out of bounds (number or enum range)</li> + * <li>Mandatory parameters not provided</li> + * <li>Parameter provided with wrong type</li> + * <li>Invalid characters</li> + * <li>Empty string</li> + */ ++ (SDLResult *)INVALID_DATA; + ++ (SDLResult *)CHAR_LIMIT_EXCEEDED; + +/** + * @abstract The request is not supported by SDL + */ ++ (SDLResult *)UNSUPPORTED_REQUEST; + +/** + * @abstract The system could not process the request because the necessary memory couldn't be allocated + */ ++ (SDLResult *)OUT_OF_MEMORY; + +/** + * @abstract There are too many requests pending (means that the response has not been delivered yet). + * + * @discussion There is a limit of 1000 pending requests at a time. + */ ++ (SDLResult *)TOO_MANY_PENDING_REQUESTS; + +/** + * @abstract One of the provided IDs is not valid. + * @discussion For example: + * <li>CorrelationID</li> + * <li>CommandID</li> + * <li>MenuID</li> + */ ++ (SDLResult *)INVALID_ID; + +/** + * @abstract The provided name or synonym is a duplicate of some already-defined name or synonym. + */ ++ (SDLResult *)DUPLICATE_NAME; + +/** + * There are already too many registered applications. + */ ++ (SDLResult *)TOO_MANY_APPLICATIONS; + +/** + * RegisterApplication has been called again, after a RegisterApplication was successful before. + */ ++ (SDLResult *)APPLICATION_REGISTERED_ALREADY; + +/** + * The Head Unit doesn't support the protocol that is requested by the mobile application. + */ ++ (SDLResult *)UNSUPPORTED_VERSION; + +/** + * The requested language is currently not supported. Might be because of a mismatch of the currently active language on the head unit and the requested language. + */ ++ (SDLResult *)WRONG_LANGUAGE; + +/** + * A command can not be executed because no application has been registered with RegisterApplication. + */ ++ (SDLResult *)APPLICATION_NOT_REGISTERED; + +/** + * The data may not be changed, because it is currently in use. For example when trying to delete a command set that is currently involved in an interaction. + */ ++ (SDLResult *)IN_USE; + +/** + * The user has turned off access to vehicle data, and it is globally unavailable to mobile applications. + */ ++ (SDLResult *)VEHICLE_DATA_NOT_ALLOWED; + +/** + * The requested vehicle data is not available on this vehicle or is not published. + */ ++ (SDLResult *)VEHICLE_DATA_NOT_AVAILABLE; + +/** + * The requested command was rejected, e.g. because mobile app is in background and cannot perform any HMI commands. Or an HMI command (e.g. Speak) is rejected because a higher priority HMI command (e.g. Alert) is playing. + */ ++ (SDLResult *)REJECTED; + +/** + * A command was aborted, for example due to user interaction (e.g. user pressed button). Or an HMI command (e.g. Speak) is aborted because a higher priority HMI command (e.g. Alert) was requested. + */ ++ (SDLResult *)ABORTED; + +/** + * A command was ignored, because the intended result is already in effect. For example, SetMediaClockTimer was used to pause the media clock although the clock is paused already. + */ ++ (SDLResult *)IGNORED; + +/** + * A button that was requested for subscription is not supported under the current system. + */ ++ (SDLResult *)UNSUPPORTED_RESOURCE; + +/** + * A specified file could not be found on the head unit. + */ ++ (SDLResult *)FILE_NOT_FOUND; + +/** + * Provided data is valid but something went wrong in the lower layers. + */ ++ (SDLResult *)GENERIC_ERROR; + +/** + * RPC is not authorized in local policy table. + */ ++ (SDLResult *)DISALLOWED; + +/** + * RPC is included in a functional group explicitly blocked by the user. + */ ++ (SDLResult *)USER_DISALLOWED; + +/** + * Overlay reached the maximum timeout and closed. + */ ++ (SDLResult *)TIMED_OUT; + +/** + * User selected to Cancel Route. + */ ++ (SDLResult *)CANCEL_ROUTE; + +/** + * The RPC (e.g. ReadDID) executed successfully but the data exceeded the platform maximum threshold and thus, only part of the data is available. + */ ++ (SDLResult *)TRUNCATED_DATA; + +/** + * The user interrupted the RPC (e.g. PerformAudioPassThru) and indicated to start over. Note, the app must issue the new RPC. + */ ++ (SDLResult *)RETRY; + +/** + * The RPC (e.g. SubscribeVehicleData) executed successfully but one or more items have a warning or failure. + */ ++ (SDLResult *)WARNINGS; + +/** + * The RPC (e.g. Slider) executed successfully and the user elected to save the current position / value. + */ ++ (SDLResult *)SAVED; + +/** + * The certificate provided during authentication is invalid. + */ ++ (SDLResult *)INVALID_CERT; + +/** + * The certificate provided during authentication is expired. + */ ++ (SDLResult *)EXPIRED_CERT; + +/** + * The provided hash ID does not match the hash of the current set of registered data or the core could not resume the previous data. + */ ++ (SDLResult *)RESUME_FAILED; + +@end diff --git a/SmartDeviceLink/SDLResult.m b/SmartDeviceLink/SDLResult.m new file mode 100644 index 000000000..1ef2806c3 --- /dev/null +++ b/SmartDeviceLink/SDLResult.m @@ -0,0 +1,327 @@ +// SDLResult.m +// + + +#import "SDLResult.h" + +SDLResult *SDLResult_SUCCESS = nil; +SDLResult *SDLResult_INVALID_DATA = nil; +SDLResult *SDLResult_CHAR_LIMIT_EXCEEDED = nil; +SDLResult *SDLResult_UNSUPPORTED_REQUEST = nil; +SDLResult *SDLResult_OUT_OF_MEMORY = nil; +SDLResult *SDLResult_TOO_MANY_PENDING_REQUESTS = nil; +SDLResult *SDLResult_INVALID_ID = nil; +SDLResult *SDLResult_DUPLICATE_NAME = nil; +SDLResult *SDLResult_TOO_MANY_APPLICATIONS = nil; +SDLResult *SDLResult_APPLICATION_REGISTERED_ALREADY = nil; +SDLResult *SDLResult_UNSUPPORTED_VERSION = nil; +SDLResult *SDLResult_WRONG_LANGUAGE = nil; +SDLResult *SDLResult_APPLICATION_NOT_REGISTERED = nil; +SDLResult *SDLResult_IN_USE = nil; +SDLResult *SDLResult_VEHICLE_DATA_NOT_ALLOWED = nil; +SDLResult *SDLResult_VEHICLE_DATA_NOT_AVAILABLE = nil; +SDLResult *SDLResult_REJECTED = nil; +SDLResult *SDLResult_ABORTED = nil; +SDLResult *SDLResult_IGNORED = nil; +SDLResult *SDLResult_UNSUPPORTED_RESOURCE = nil; +SDLResult *SDLResult_FILE_NOT_FOUND = nil; +SDLResult *SDLResult_GENERIC_ERROR = nil; +SDLResult *SDLResult_DISALLOWED = nil; +SDLResult *SDLResult_USER_DISALLOWED = nil; +SDLResult *SDLResult_TIMED_OUT = nil; +SDLResult *SDLResult_CANCEL_ROUTE = nil; +SDLResult *SDLResult_TRUNCATED_DATA = nil; +SDLResult *SDLResult_RETRY = nil; +SDLResult *SDLResult_WARNINGS = nil; +SDLResult *SDLResult_SAVED = nil; +SDLResult *SDLResult_INVALID_CERT = nil; +SDLResult *SDLResult_EXPIRED_CERT = nil; +SDLResult *SDLResult_RESUME_FAILED = nil; + +NSArray *SDLResult_values = nil; + +@implementation SDLResult + ++ (SDLResult *)valueOf:(NSString *)value { + for (SDLResult *item in SDLResult.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLResult_values == nil) { + SDLResult_values = @[ + [SDLResult SUCCESS], + [SDLResult INVALID_DATA], + [SDLResult CHAR_LIMIT_EXCEEDED], + [SDLResult UNSUPPORTED_REQUEST], + [SDLResult OUT_OF_MEMORY], + [SDLResult TOO_MANY_PENDING_REQUESTS], + [SDLResult INVALID_ID], + [SDLResult DUPLICATE_NAME], + [SDLResult TOO_MANY_APPLICATIONS], + [SDLResult APPLICATION_REGISTERED_ALREADY], + [SDLResult UNSUPPORTED_VERSION], + [SDLResult WRONG_LANGUAGE], + [SDLResult APPLICATION_NOT_REGISTERED], + [SDLResult IN_USE], + [SDLResult VEHICLE_DATA_NOT_ALLOWED], + [SDLResult VEHICLE_DATA_NOT_AVAILABLE], + [SDLResult REJECTED], + [SDLResult ABORTED], + [SDLResult IGNORED], + [SDLResult UNSUPPORTED_RESOURCE], + [SDLResult FILE_NOT_FOUND], + [SDLResult GENERIC_ERROR], + [SDLResult DISALLOWED], + [SDLResult USER_DISALLOWED], + [SDLResult TIMED_OUT], + [SDLResult CANCEL_ROUTE], + [SDLResult TRUNCATED_DATA], + [SDLResult RETRY], + [SDLResult WARNINGS], + [SDLResult SAVED], + [SDLResult INVALID_CERT], + [SDLResult EXPIRED_CERT], + [SDLResult RESUME_FAILED], + ]; + } + return SDLResult_values; +} + ++ (SDLResult *)SUCCESS { + if (SDLResult_SUCCESS == nil) { + SDLResult_SUCCESS = [[SDLResult alloc] initWithValue:@"SUCCESS"]; + } + return SDLResult_SUCCESS; +} + ++ (SDLResult *)INVALID_DATA { + if (SDLResult_INVALID_DATA == nil) { + SDLResult_INVALID_DATA = [[SDLResult alloc] initWithValue:@"INVALID_DATA"]; + } + return SDLResult_INVALID_DATA; +} + ++ (SDLResult *)CHAR_LIMIT_EXCEEDED { + if (SDLResult_CHAR_LIMIT_EXCEEDED == nil) { + SDLResult_CHAR_LIMIT_EXCEEDED = [[SDLResult alloc] initWithValue:@"CHAR_LIMIT_EXCEEDED"]; + } + + return SDLResult_CHAR_LIMIT_EXCEEDED; +} + ++ (SDLResult *)UNSUPPORTED_REQUEST { + if (SDLResult_UNSUPPORTED_REQUEST == nil) { + SDLResult_UNSUPPORTED_REQUEST = [[SDLResult alloc] initWithValue:@"UNSUPPORTED_REQUEST"]; + } + return SDLResult_UNSUPPORTED_REQUEST; +} + ++ (SDLResult *)OUT_OF_MEMORY { + if (SDLResult_OUT_OF_MEMORY == nil) { + SDLResult_OUT_OF_MEMORY = [[SDLResult alloc] initWithValue:@"OUT_OF_MEMORY"]; + } + return SDLResult_OUT_OF_MEMORY; +} + ++ (SDLResult *)TOO_MANY_PENDING_REQUESTS { + if (SDLResult_TOO_MANY_PENDING_REQUESTS == nil) { + SDLResult_TOO_MANY_PENDING_REQUESTS = [[SDLResult alloc] initWithValue:@"TOO_MANY_PENDING_REQUESTS"]; + } + return SDLResult_TOO_MANY_PENDING_REQUESTS; +} + ++ (SDLResult *)INVALID_ID { + if (SDLResult_INVALID_ID == nil) { + SDLResult_INVALID_ID = [[SDLResult alloc] initWithValue:@"INVALID_ID"]; + } + return SDLResult_INVALID_ID; +} + ++ (SDLResult *)DUPLICATE_NAME { + if (SDLResult_DUPLICATE_NAME == nil) { + SDLResult_DUPLICATE_NAME = [[SDLResult alloc] initWithValue:@"DUPLICATE_NAME"]; + } + return SDLResult_DUPLICATE_NAME; +} + ++ (SDLResult *)TOO_MANY_APPLICATIONS { + if (SDLResult_TOO_MANY_APPLICATIONS == nil) { + SDLResult_TOO_MANY_APPLICATIONS = [[SDLResult alloc] initWithValue:@"TOO_MANY_APPLICATIONS"]; + } + return SDLResult_TOO_MANY_APPLICATIONS; +} + ++ (SDLResult *)APPLICATION_REGISTERED_ALREADY { + if (SDLResult_APPLICATION_REGISTERED_ALREADY == nil) { + SDLResult_APPLICATION_REGISTERED_ALREADY = [[SDLResult alloc] initWithValue:@"APPLICATION_REGISTERED_ALREADY"]; + } + return SDLResult_APPLICATION_REGISTERED_ALREADY; +} + ++ (SDLResult *)UNSUPPORTED_VERSION { + if (SDLResult_UNSUPPORTED_VERSION == nil) { + SDLResult_UNSUPPORTED_VERSION = [[SDLResult alloc] initWithValue:@"UNSUPPORTED_VERSION"]; + } + return SDLResult_UNSUPPORTED_VERSION; +} + ++ (SDLResult *)WRONG_LANGUAGE { + if (SDLResult_WRONG_LANGUAGE == nil) { + SDLResult_WRONG_LANGUAGE = [[SDLResult alloc] initWithValue:@"WRONG_LANGUAGE"]; + } + return SDLResult_WRONG_LANGUAGE; +} + ++ (SDLResult *)APPLICATION_NOT_REGISTERED { + if (SDLResult_APPLICATION_NOT_REGISTERED == nil) { + SDLResult_APPLICATION_NOT_REGISTERED = [[SDLResult alloc] initWithValue:@"APPLICATION_NOT_REGISTERED"]; + } + return SDLResult_APPLICATION_NOT_REGISTERED; +} + ++ (SDLResult *)IN_USE { + if (SDLResult_IN_USE == nil) { + SDLResult_IN_USE = [[SDLResult alloc] initWithValue:@"IN_USE"]; + } + return SDLResult_IN_USE; +} + ++ (SDLResult *)VEHICLE_DATA_NOT_ALLOWED { + if (SDLResult_VEHICLE_DATA_NOT_ALLOWED == nil) { + SDLResult_VEHICLE_DATA_NOT_ALLOWED = [[SDLResult alloc] initWithValue:@"VEHICLE_DATA_NOT_ALLOWED"]; + } + return SDLResult_VEHICLE_DATA_NOT_ALLOWED; +} + ++ (SDLResult *)VEHICLE_DATA_NOT_AVAILABLE { + if (SDLResult_VEHICLE_DATA_NOT_AVAILABLE == nil) { + SDLResult_VEHICLE_DATA_NOT_AVAILABLE = [[SDLResult alloc] initWithValue:@"VEHICLE_DATA_NOT_AVAILABLE"]; + } + return SDLResult_VEHICLE_DATA_NOT_AVAILABLE; +} + ++ (SDLResult *)REJECTED { + if (SDLResult_REJECTED == nil) { + SDLResult_REJECTED = [[SDLResult alloc] initWithValue:@"REJECTED"]; + } + return SDLResult_REJECTED; +} + ++ (SDLResult *)ABORTED { + if (SDLResult_ABORTED == nil) { + SDLResult_ABORTED = [[SDLResult alloc] initWithValue:@"ABORTED"]; + } + return SDLResult_ABORTED; +} + ++ (SDLResult *)IGNORED { + if (SDLResult_IGNORED == nil) { + SDLResult_IGNORED = [[SDLResult alloc] initWithValue:@"IGNORED"]; + } + return SDLResult_IGNORED; +} + ++ (SDLResult *)UNSUPPORTED_RESOURCE { + if (SDLResult_UNSUPPORTED_RESOURCE == nil) { + SDLResult_UNSUPPORTED_RESOURCE = [[SDLResult alloc] initWithValue:@"UNSUPPORTED_RESOURCE"]; + } + return SDLResult_UNSUPPORTED_RESOURCE; +} + ++ (SDLResult *)FILE_NOT_FOUND { + if (SDLResult_FILE_NOT_FOUND == nil) { + SDLResult_FILE_NOT_FOUND = [[SDLResult alloc] initWithValue:@"FILE_NOT_FOUND"]; + } + return SDLResult_FILE_NOT_FOUND; +} + ++ (SDLResult *)GENERIC_ERROR { + if (SDLResult_GENERIC_ERROR == nil) { + SDLResult_GENERIC_ERROR = [[SDLResult alloc] initWithValue:@"GENERIC_ERROR"]; + } + return SDLResult_GENERIC_ERROR; +} + ++ (SDLResult *)DISALLOWED { + if (SDLResult_DISALLOWED == nil) { + SDLResult_DISALLOWED = [[SDLResult alloc] initWithValue:@"DISALLOWED"]; + } + return SDLResult_DISALLOWED; +} + ++ (SDLResult *)USER_DISALLOWED { + if (SDLResult_USER_DISALLOWED == nil) { + SDLResult_USER_DISALLOWED = [[SDLResult alloc] initWithValue:@"USER_DISALLOWED"]; + } + return SDLResult_USER_DISALLOWED; +} + ++ (SDLResult *)TIMED_OUT { + if (SDLResult_TIMED_OUT == nil) { + SDLResult_TIMED_OUT = [[SDLResult alloc] initWithValue:@"TIMED_OUT"]; + } + return SDLResult_TIMED_OUT; +} + ++ (SDLResult *)CANCEL_ROUTE { + if (SDLResult_CANCEL_ROUTE == nil) { + SDLResult_CANCEL_ROUTE = [[SDLResult alloc] initWithValue:@"CANCEL_ROUTE"]; + } + return SDLResult_CANCEL_ROUTE; +} + ++ (SDLResult *)TRUNCATED_DATA { + if (SDLResult_TRUNCATED_DATA == nil) { + SDLResult_TRUNCATED_DATA = [[SDLResult alloc] initWithValue:@"TRUNCATED_DATA"]; + } + return SDLResult_TRUNCATED_DATA; +} + ++ (SDLResult *)RETRY { + if (SDLResult_RETRY == nil) { + SDLResult_RETRY = [[SDLResult alloc] initWithValue:@"RETRY"]; + } + return SDLResult_RETRY; +} + ++ (SDLResult *)WARNINGS { + if (SDLResult_WARNINGS == nil) { + SDLResult_WARNINGS = [[SDLResult alloc] initWithValue:@"WARNINGS"]; + } + return SDLResult_WARNINGS; +} + ++ (SDLResult *)SAVED { + if (SDLResult_SAVED == nil) { + SDLResult_SAVED = [[SDLResult alloc] initWithValue:@"SAVED"]; + } + return SDLResult_SAVED; +} + ++ (SDLResult *)INVALID_CERT { + if (SDLResult_INVALID_CERT == nil) { + SDLResult_INVALID_CERT = [[SDLResult alloc] initWithValue:@"INVALID_CERT"]; + } + return SDLResult_INVALID_CERT; +} + ++ (SDLResult *)EXPIRED_CERT { + if (SDLResult_EXPIRED_CERT == nil) { + SDLResult_EXPIRED_CERT = [[SDLResult alloc] initWithValue:@"EXPIRED_CERT"]; + } + return SDLResult_EXPIRED_CERT; +} + ++ (SDLResult *)RESUME_FAILED { + if (SDLResult_RESUME_FAILED == nil) { + SDLResult_RESUME_FAILED = [[SDLResult alloc] initWithValue:@"RESUME_FAILED"]; + } + return SDLResult_RESUME_FAILED; +} + +@end diff --git a/SmartDeviceLink/SDLSamplingRate.h b/SmartDeviceLink/SDLSamplingRate.h new file mode 100644 index 000000000..28d3d35dc --- /dev/null +++ b/SmartDeviceLink/SDLSamplingRate.h @@ -0,0 +1,56 @@ +// SDLSamplingRate.h +// + + +#import "SDLEnum.h" + +/** + * Describes different sampling rates for PerformAudioPassThru + * + * @since SDL 2.0 + */ +@interface SDLSamplingRate : SDLEnum { +} + +/** + * @abstract get SDLSamplingRate according value string + * + * @param value The value of the string to get an object for + * + * @return SDLSamplingRate object + */ ++ (SDLSamplingRate *)valueOf:(NSString *)value; + +/** + * @abstract declare an array to store all possible SDLSamplingRate values + * + * @return the array + */ ++ (NSArray *)values; + +/** + * @abstract Sampling rate of 8 kHz + * + * @return SamplingRate of *8KHZ* + */ ++ (SDLSamplingRate *)_8KHZ; +/** + * @abstract Sampling rate of 16 kHz + * + * @return SamplingRate of *16KHZ* + */ ++ (SDLSamplingRate *)_16KHZ; +/** + * @abstract Sampling rate of 22 kHz + * + * @return SamplingRate of *22KHZ* + */ ++ (SDLSamplingRate *)_22KHZ; +/** + * @abstract Sampling rate of 44 kHz + * + * @return SamplingRate of *44KHZ* + */ ++ (SDLSamplingRate *)_44KHZ; + +@end diff --git a/SmartDeviceLink/SDLSamplingRate.m b/SmartDeviceLink/SDLSamplingRate.m new file mode 100644 index 000000000..d0a36d730 --- /dev/null +++ b/SmartDeviceLink/SDLSamplingRate.m @@ -0,0 +1,65 @@ +// SDLSamplingRate.m +// + + +#import "SDLSamplingRate.h" + +SDLSamplingRate *SDLSamplingRate_8KHZ = nil; +SDLSamplingRate *SDLSamplingRate_16KHZ = nil; +SDLSamplingRate *SDLSamplingRate_22KHZ = nil; +SDLSamplingRate *SDLSamplingRate_44KHZ = nil; + +NSArray *SDLSamplingRate_values = nil; + +@implementation SDLSamplingRate + ++ (SDLSamplingRate *)valueOf:(NSString *)value { + for (SDLSamplingRate *item in SDLSamplingRate.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLSamplingRate_values == nil) { + SDLSamplingRate_values = @[ + SDLSamplingRate._8KHZ, + SDLSamplingRate._16KHZ, + SDLSamplingRate._22KHZ, + SDLSamplingRate._44KHZ, + ]; + } + return SDLSamplingRate_values; +} + ++ (SDLSamplingRate *)_8KHZ { + if (SDLSamplingRate_8KHZ == nil) { + SDLSamplingRate_8KHZ = [[SDLSamplingRate alloc] initWithValue:@"8KHZ"]; + } + return SDLSamplingRate_8KHZ; +} + ++ (SDLSamplingRate *)_16KHZ { + if (SDLSamplingRate_16KHZ == nil) { + SDLSamplingRate_16KHZ = [[SDLSamplingRate alloc] initWithValue:@"16KHZ"]; + } + return SDLSamplingRate_16KHZ; +} + ++ (SDLSamplingRate *)_22KHZ { + if (SDLSamplingRate_22KHZ == nil) { + SDLSamplingRate_22KHZ = [[SDLSamplingRate alloc] initWithValue:@"22KHZ"]; + } + return SDLSamplingRate_22KHZ; +} + ++ (SDLSamplingRate *)_44KHZ { + if (SDLSamplingRate_44KHZ == nil) { + SDLSamplingRate_44KHZ = [[SDLSamplingRate alloc] initWithValue:@"44KHZ"]; + } + return SDLSamplingRate_44KHZ; +} + +@end diff --git a/SmartDeviceLink/SDLScreenParams.h b/SmartDeviceLink/SDLScreenParams.h new file mode 100644 index 000000000..c60f6f1d6 --- /dev/null +++ b/SmartDeviceLink/SDLScreenParams.h @@ -0,0 +1,19 @@ +// SDLScreenParams.h +// + +#import "SDLRPCMessage.h" + +@class SDLImageResolution; +@class SDLTouchEventCapabilities; + + +@interface SDLScreenParams : SDLRPCStruct { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) SDLImageResolution *resolution; +@property (strong) SDLTouchEventCapabilities *touchEventAvailable; + +@end diff --git a/SmartDeviceLink/SDLScreenParams.m b/SmartDeviceLink/SDLScreenParams.m new file mode 100644 index 000000000..1debff302 --- /dev/null +++ b/SmartDeviceLink/SDLScreenParams.m @@ -0,0 +1,59 @@ +// SDLScreenParams.m +// + +#import "SDLScreenParams.h" + +#import "SDLImageResolution.h" +#import "SDLNames.h" +#import "SDLTouchEventCapabilities.h" + + +@implementation SDLScreenParams + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setResolution:(SDLImageResolution *)resolution { + if (resolution != nil) { + [store setObject:resolution forKey:NAMES_resolution]; + } else { + [store removeObjectForKey:NAMES_resolution]; + } +} + +- (SDLImageResolution *)resolution { + NSObject *obj = [store objectForKey:NAMES_resolution]; + if (obj == nil || [obj isKindOfClass:SDLImageResolution.class]) { + return (SDLImageResolution *)obj; + } else { + return [[SDLImageResolution alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setTouchEventAvailable:(SDLTouchEventCapabilities *)touchEventAvailable { + if (touchEventAvailable != nil) { + [store setObject:touchEventAvailable forKey:NAMES_touchEventAvailable]; + } else { + [store removeObjectForKey:NAMES_touchEventAvailable]; + } +} + +- (SDLTouchEventCapabilities *)touchEventAvailable { + NSObject *obj = [store objectForKey:NAMES_touchEventAvailable]; + if (obj == nil || [obj isKindOfClass:SDLTouchEventCapabilities.class]) { + return (SDLTouchEventCapabilities *)obj; + } else { + return [[SDLTouchEventCapabilities alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLScrollableMessage.h b/SmartDeviceLink/SDLScrollableMessage.h new file mode 100644 index 000000000..27e894221 --- /dev/null +++ b/SmartDeviceLink/SDLScrollableMessage.h @@ -0,0 +1,56 @@ +// SDLScrollableMessage.h +// + + +#import "SDLRPCRequest.h" + +/** + * Creates a full screen overlay containing a large block of formatted text that + * can be scrolled with up to 8 SoftButtons defined + * <p> + * Function Group: ScrollableMessage + * <p> + * <b>HMILevel needs to be FULL</b> + * <p> + */ +@interface SDLScrollableMessage : SDLRPCRequest { +} + +/** + * @abstract Constructs a new SDLScrollableMessage object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLScrollableMessage object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract A Body of text that can include newlines and tabs + * @discussion A String value representing the Body of text that can include + * newlines and tabs + * <p> + * <b>Notes: </b>Maxlength=500 + */ +@property (strong) NSString *scrollableMessageBody; +/** + * @abstract Gets/Sets an App defined timeout. Indicates how long of a timeout in milliseconds from the + * last action + * @discussion An Integer value representing an App defined timeout in milliseconds + * <p> + * <b>Notes</b>:Minval=0; Maxval=65535;Default=30000 + */ +@property (strong) NSNumber *timeout; +/** + * @abstract Gets/Sets App defined SoftButtons.If omitted on supported displays, only the + * system defined "Close" SoftButton will be displayed + * @discussion A Vector<SoftButton> value representing App defined + * SoftButtons + * <p> + * <b>Notes: </b>Minsize=0, Maxsize=8 + */ +@property (strong) NSMutableArray *softButtons; + +@end diff --git a/SmartDeviceLink/SDLScrollableMessage.m b/SmartDeviceLink/SDLScrollableMessage.m new file mode 100644 index 000000000..5995e7874 --- /dev/null +++ b/SmartDeviceLink/SDLScrollableMessage.m @@ -0,0 +1,69 @@ +// SDLScrollableMessage.m +// + + +#import "SDLScrollableMessage.h" + +#import "SDLNames.h" +#import "SDLSoftButton.h" + +@implementation SDLScrollableMessage + +- (instancetype)init { + if (self = [super initWithName:NAMES_ScrollableMessage]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setScrollableMessageBody:(NSString *)scrollableMessageBody { + if (scrollableMessageBody != nil) { + [parameters setObject:scrollableMessageBody forKey:NAMES_scrollableMessageBody]; + } else { + [parameters removeObjectForKey:NAMES_scrollableMessageBody]; + } +} + +- (NSString *)scrollableMessageBody { + return [parameters objectForKey:NAMES_scrollableMessageBody]; +} + +- (void)setTimeout:(NSNumber *)timeout { + if (timeout != nil) { + [parameters setObject:timeout forKey:NAMES_timeout]; + } else { + [parameters removeObjectForKey:NAMES_timeout]; + } +} + +- (NSNumber *)timeout { + return [parameters objectForKey:NAMES_timeout]; +} + +- (void)setSoftButtons:(NSMutableArray *)softButtons { + if (softButtons != nil) { + [parameters setObject:softButtons forKey:NAMES_softButtons]; + } else { + [parameters removeObjectForKey:NAMES_softButtons]; + } +} + +- (NSMutableArray *)softButtons { + NSMutableArray *array = [parameters objectForKey:NAMES_softButtons]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLSoftButton.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLSoftButton alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +@end diff --git a/SmartDeviceLink/SDLScrollableMessageResponse.h b/SmartDeviceLink/SDLScrollableMessageResponse.h new file mode 100644 index 000000000..e75b157ec --- /dev/null +++ b/SmartDeviceLink/SDLScrollableMessageResponse.h @@ -0,0 +1,26 @@ +// SDLScrollableMessageResponse.h +// + + +#import "SDLRPCResponse.h" + +/** + * Scrollable Message Response is sent, when SDLScrollableMessage has been called + * + * Since SmartDeviceLink 2.0 + */ +@interface SDLScrollableMessageResponse : SDLRPCResponse { +} + +/** + * @abstract Constructs a new SDLScrollableMessageResponse object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLScrollableMessageResponse object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLScrollableMessageResponse.m b/SmartDeviceLink/SDLScrollableMessageResponse.m new file mode 100644 index 000000000..77473f07e --- /dev/null +++ b/SmartDeviceLink/SDLScrollableMessageResponse.m @@ -0,0 +1,23 @@ +// SDLScrollableMessageResponse.m +// + + +#import "SDLScrollableMessageResponse.h" + +#import "SDLNames.h" + +@implementation SDLScrollableMessageResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_ScrollableMessage]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLSendLocation.h b/SmartDeviceLink/SDLSendLocation.h new file mode 100644 index 000000000..cec60c422 --- /dev/null +++ b/SmartDeviceLink/SDLSendLocation.h @@ -0,0 +1,65 @@ +// +// SDLSendLocation.h +// SmartDeviceLink + +#import <Foundation/Foundation.h> + +#import "SDLImage.h" +#import "SDLRPCRequest.h" + + +@interface SDLSendLocation : SDLRPCRequest + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * The longitudinal coordinate of the location. + * + * Float, Required, -180.0 - 180.0 + */ +@property (copy, nonatomic) NSNumber *longitudeDegrees; + +/** + * The latitudinal coordinate of the location. + * + * Float, Required, -90.0 - 90.0 + */ +@property (copy, nonatomic) NSNumber *latitudeDegrees; + +/** + * Name / title of intended location + * + * Optional, Maxlength = 500 char + */ +@property (copy, nonatomic) NSString *locationName; + +/** + * Description of the intended location / establishment + * + * Optional, MaxLength = 500 char + */ +@property (copy, nonatomic) NSString *locationDescription; + +/** + * Array of lines for the location address + * + * Contains String, Optional, Max Array Length = 4, Max String Length = 500 + */ +@property (copy, nonatomic) NSArray *addressLines; + +/** + * Phone number of intended location / establishment + * + * Optional, Max Length = 500 + */ +@property (copy, nonatomic) NSString *phoneNumber; + +/** + * Image / icon of intended location + * + * Optional + */ +@property (strong, nonatomic) SDLImage *locationImage; + +@end diff --git a/SmartDeviceLink/SDLSendLocation.m b/SmartDeviceLink/SDLSendLocation.m new file mode 100644 index 000000000..7bf1c5c70 --- /dev/null +++ b/SmartDeviceLink/SDLSendLocation.m @@ -0,0 +1,119 @@ +// +// SDLSendLocation.m +// SmartDeviceLink + +#import "SDLSendLocation.h" + +#import "SDLNames.h" + + +@implementation SDLSendLocation + +- (instancetype)init { + self = [super initWithName:NAMES_SendLocation]; + if (!self) { + return nil; + } + + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + self = [super initWithDictionary:dict]; + if (!self) { + return nil; + } + + return self; +} + +- (void)setLongitudeDegrees:(NSNumber *)longitudeDegrees { + if (longitudeDegrees != nil) { + parameters[NAMES_longitudeDegrees] = longitudeDegrees; + } else { + [parameters removeObjectForKey:NAMES_longitudeDegrees]; + } +} + +- (NSNumber *)longitudeDegrees { + return parameters[NAMES_longitudeDegrees]; +} + +- (void)setLatitudeDegrees:(NSNumber *)latitudeDegrees { + if (latitudeDegrees != nil) { + parameters[NAMES_latitudeDegrees] = latitudeDegrees; + } else { + [parameters removeObjectForKey:NAMES_latitudeDegrees]; + } +} + +- (NSNumber *)latitudeDegrees { + return parameters[NAMES_latitudeDegrees]; +} + +- (void)setLocationName:(NSString *)locationName { + if (locationName != nil) { + parameters[NAMES_locationName] = locationName; + } else { + [parameters removeObjectForKey:NAMES_locationName]; + } +} + +- (NSString *)locationName { + return parameters[NAMES_locationName]; +} + +- (void)setAddressLines:(NSArray *)addressLines { + if (addressLines != nil) { + parameters[NAMES_addressLines] = addressLines; + } else { + [parameters removeObjectForKey:NAMES_addressLines]; + } +} + +- (NSString *)locationDescription { + return parameters[NAMES_locationDescription]; +} + +- (void)setLocationDescription:(NSString *)locationDescription { + if (locationDescription != nil) { + parameters[NAMES_locationDescription] = locationDescription; + } else { + [parameters removeObjectForKey:NAMES_locationDescription]; + } +} + +- (NSArray *)addressLines { + return parameters[NAMES_addressLines]; +} + +- (void)setPhoneNumber:(NSString *)phoneNumber { + if (phoneNumber != nil) { + parameters[NAMES_phoneNumber] = phoneNumber; + } else { + [parameters removeObjectForKey:NAMES_phoneNumber]; + } +} + +- (NSString *)phoneNumber { + return parameters[NAMES_phoneNumber]; +} + +- (void)setLocationImage:(SDLImage *)locationImage { + if (locationImage != nil) { + parameters[NAMES_locationImage] = locationImage; + } else { + [parameters removeObjectForKey:NAMES_locationImage]; + } +} + +- (SDLImage *)locationImage { + id obj = parameters[NAMES_locationImage]; + if (obj == nil || [obj isKindOfClass:[SDLImage class]]) { + return (SDLImage *)obj; + } else { + return [[SDLImage alloc] initWithDictionary:obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLSendLocationResponse.h b/SmartDeviceLink/SDLSendLocationResponse.h new file mode 100644 index 000000000..39d8a4ba2 --- /dev/null +++ b/SmartDeviceLink/SDLSendLocationResponse.h @@ -0,0 +1,12 @@ +// +// SDLSendLocationResponse.h +// SmartDeviceLink-iOS + +#import "SDLRPCResponse.h" + +@interface SDLSendLocationResponse : SDLRPCResponse + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLSendLocationResponse.m b/SmartDeviceLink/SDLSendLocationResponse.m new file mode 100644 index 000000000..83cde8118 --- /dev/null +++ b/SmartDeviceLink/SDLSendLocationResponse.m @@ -0,0 +1,30 @@ +// +// SDLSendLocationResponse.m +// SmartDeviceLink-iOS + +#import "SDLSendLocationResponse.h" + +#import "SDLNames.h" + + +@implementation SDLSendLocationResponse + +- (instancetype)init { + self = [super initWithName:NAMES_SendLocation]; + if (!self) { + return nil; + } + + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + self = [super initWithDictionary:dict]; + if (!self) { + return nil; + } + + return self; +} + +@end diff --git a/SmartDeviceLink/SDLSetAppIcon.h b/SmartDeviceLink/SDLSetAppIcon.h new file mode 100644 index 000000000..eee61deb5 --- /dev/null +++ b/SmartDeviceLink/SDLSetAppIcon.h @@ -0,0 +1,35 @@ +// SDLSetAppIcon.h +// + + +#import "SDLRPCRequest.h" + +/** + * Used to set existing local file on SDL as the app's icon. Not supported on + * first generation SDL modules. + * <p> + * + * Since SmartDeviceLink 2.0 + */ +@interface SDLSetAppIcon : SDLRPCRequest { +} + +/** + * @abstract Constructs a new SDLSetAppIcon object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLSetAppIcon object indicated by the dictionary parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract A file reference name + * @discussion A String value representing a file reference name + * <p> + * <b>Notes: </b>Maxlength=500 + */ +@property (strong) NSString *syncFileName; + +@end diff --git a/SmartDeviceLink/SDLSetAppIcon.m b/SmartDeviceLink/SDLSetAppIcon.m new file mode 100644 index 000000000..717eeb023 --- /dev/null +++ b/SmartDeviceLink/SDLSetAppIcon.m @@ -0,0 +1,35 @@ +// SDLSetAppIcon.m +// + + +#import "SDLSetAppIcon.h" + +#import "SDLNames.h" + +@implementation SDLSetAppIcon + +- (instancetype)init { + if (self = [super initWithName:NAMES_SetAppIcon]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setSyncFileName:(NSString *)syncFileName { + if (syncFileName != nil) { + [parameters setObject:syncFileName forKey:NAMES_syncFileName]; + } else { + [parameters removeObjectForKey:NAMES_syncFileName]; + } +} + +- (NSString *)syncFileName { + return [parameters objectForKey:NAMES_syncFileName]; +} + +@end diff --git a/SmartDeviceLink/SDLSetAppIconResponse.h b/SmartDeviceLink/SDLSetAppIconResponse.h new file mode 100644 index 000000000..31dd1e6c9 --- /dev/null +++ b/SmartDeviceLink/SDLSetAppIconResponse.h @@ -0,0 +1,16 @@ +// SDLSetAppIconResponse.h +// + + +#import "SDLRPCResponse.h" + +/** SDLSetAppIconResponse is sent, when SDLSetAppIcon has been called. + * Since<b>SmartDeviceLink 2.0</b> + */ +@interface SDLSetAppIconResponse : SDLRPCResponse { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLSetAppIconResponse.m b/SmartDeviceLink/SDLSetAppIconResponse.m new file mode 100644 index 000000000..64c10600f --- /dev/null +++ b/SmartDeviceLink/SDLSetAppIconResponse.m @@ -0,0 +1,23 @@ +// SDLSetAppIconResponse.m +// + + +#import "SDLSetAppIconResponse.h" + +#import "SDLNames.h" + +@implementation SDLSetAppIconResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_SetAppIcon]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLSetDisplayLayout.h b/SmartDeviceLink/SDLSetDisplayLayout.h new file mode 100644 index 000000000..15226a821 --- /dev/null +++ b/SmartDeviceLink/SDLSetDisplayLayout.h @@ -0,0 +1,35 @@ +// SDLSetDisplayLayout.h +// + + +#import "SDLRPCRequest.h" + +/** + * Used to set an alternate display layout. If not sent, default screen for + * given platform will be shown + * + * Since SmartDeviceLink 2.0 + */ +@interface SDLSetDisplayLayout : SDLRPCRequest { +} + +/** + * @abstract Constructs a new SDLSetDisplayLayout object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLSetDisplayLayout object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract A display layout. Predefined or dynamically created screen layout. + * Currently only predefined screen layouts are defined. Predefined layouts + * include: "ONSCREEN_PRESETS" Custom screen containing app-defined onscreen + * presets. Currently defined for GEN2 + */ +@property (strong) NSString *displayLayout; + +@end diff --git a/SmartDeviceLink/SDLSetDisplayLayout.m b/SmartDeviceLink/SDLSetDisplayLayout.m new file mode 100644 index 000000000..ed812f647 --- /dev/null +++ b/SmartDeviceLink/SDLSetDisplayLayout.m @@ -0,0 +1,35 @@ +// SDLSetDisplayLayout.m +// + + +#import "SDLSetDisplayLayout.h" + +#import "SDLNames.h" + +@implementation SDLSetDisplayLayout + +- (instancetype)init { + if (self = [super initWithName:NAMES_SetDisplayLayout]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setDisplayLayout:(NSString *)displayLayout { + if (displayLayout != nil) { + [parameters setObject:displayLayout forKey:NAMES_displayLayout]; + } else { + [parameters removeObjectForKey:NAMES_displayLayout]; + } +} + +- (NSString *)displayLayout { + return [parameters objectForKey:NAMES_displayLayout]; +} + +@end diff --git a/SmartDeviceLink/SDLSetDisplayLayoutResponse.h b/SmartDeviceLink/SDLSetDisplayLayoutResponse.h new file mode 100644 index 000000000..7838ae0a6 --- /dev/null +++ b/SmartDeviceLink/SDLSetDisplayLayoutResponse.h @@ -0,0 +1,29 @@ +// SDLSetDisplayLayoutResponse.h +// + +#import "SDLRPCResponse.h" + +@class SDLDisplayCapabilities; +@class SDLPresetBankCapabilities; + + +/** + * Set Display Layout Response is sent, when SetDisplayLayout has been called + * + * Since SmartDeviceLink 2.0 + */ +@interface SDLSetDisplayLayoutResponse : SDLRPCResponse { +} + +/** + * @abstract Constructs a new SDLSetDisplayLayoutResponse object + */ +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) SDLDisplayCapabilities *displayCapabilities; +@property (strong) NSMutableArray *buttonCapabilities; +@property (strong) NSMutableArray *softButtonCapabilities; +@property (strong) SDLPresetBankCapabilities *presetBankCapabilities; + +@end diff --git a/SmartDeviceLink/SDLSetDisplayLayoutResponse.m b/SmartDeviceLink/SDLSetDisplayLayoutResponse.m new file mode 100644 index 000000000..fde37062e --- /dev/null +++ b/SmartDeviceLink/SDLSetDisplayLayoutResponse.m @@ -0,0 +1,104 @@ +// SDLSetDisplayLayoutResponse.m +// + + +#import "SDLSetDisplayLayoutResponse.h" + +#import "SDLButtonCapabilities.h" +#import "SDLDisplayCapabilities.h" +#import "SDLNames.h" +#import "SDLPresetBankCapabilities.h" +#import "SDLSoftButtonCapabilities.h" + + +@implementation SDLSetDisplayLayoutResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_SetDisplayLayout]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setDisplayCapabilities:(SDLDisplayCapabilities *)displayCapabilities { + if (displayCapabilities != nil) { + [parameters setObject:displayCapabilities forKey:NAMES_displayCapabilities]; + } else { + [parameters removeObjectForKey:NAMES_displayCapabilities]; + } +} + +- (SDLDisplayCapabilities *)displayCapabilities { + NSObject *obj = [parameters objectForKey:NAMES_displayCapabilities]; + if (obj == nil || [obj isKindOfClass:SDLDisplayCapabilities.class]) { + return (SDLDisplayCapabilities *)obj; + } else { + return [[SDLDisplayCapabilities alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setButtonCapabilities:(NSMutableArray *)buttonCapabilities { + if (buttonCapabilities != nil) { + [parameters setObject:buttonCapabilities forKey:NAMES_buttonCapabilities]; + } else { + [parameters removeObjectForKey:NAMES_buttonCapabilities]; + } +} + +- (NSMutableArray *)buttonCapabilities { + NSMutableArray *array = [parameters objectForKey:NAMES_buttonCapabilities]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLButtonCapabilities.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLButtonCapabilities alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +- (void)setSoftButtonCapabilities:(NSMutableArray *)softButtonCapabilities { + if (softButtonCapabilities != nil) { + [parameters setObject:softButtonCapabilities forKey:NAMES_softButtonCapabilities]; + } else { + [parameters removeObjectForKey:NAMES_softButtonCapabilities]; + } +} + +- (NSMutableArray *)softButtonCapabilities { + NSMutableArray *array = [parameters objectForKey:NAMES_softButtonCapabilities]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLSoftButtonCapabilities.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLSoftButtonCapabilities alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +- (void)setPresetBankCapabilities:(SDLPresetBankCapabilities *)presetBankCapabilities { + if (presetBankCapabilities != nil) { + [parameters setObject:presetBankCapabilities forKey:NAMES_presetBankCapabilities]; + } else { + [parameters removeObjectForKey:NAMES_presetBankCapabilities]; + } +} + +- (SDLPresetBankCapabilities *)presetBankCapabilities { + NSObject *obj = [parameters objectForKey:NAMES_presetBankCapabilities]; + if (obj == nil || [obj isKindOfClass:SDLPresetBankCapabilities.class]) { + return (SDLPresetBankCapabilities *)obj; + } else { + return [[SDLPresetBankCapabilities alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLSetGlobalProperties.h b/SmartDeviceLink/SDLSetGlobalProperties.h new file mode 100644 index 000000000..7ad36e8d5 --- /dev/null +++ b/SmartDeviceLink/SDLSetGlobalProperties.h @@ -0,0 +1,96 @@ +// SDLSetGlobalProperties.h +// + +#import "SDLRPCRequest.h" + +@class SDLImage; +@class SDLKeyboardProperties; + + +/** + * Sets value(s) for the specified global property(ies) + * <p> + * Function Group: Base <p> + * <b>HMILevel needs to be FULL, LIMITED or BACKGROUND</b> + * </p> + * + * Since SmartDeviceLink 1.0 + * See SDLResetGlobalProperties + */ +@interface SDLSetGlobalProperties : SDLRPCRequest { +} + +/** + * @abstract Constructs a new SDLSetGlobalProperties object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLSetGlobalProperties object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract Sets a Vector<TTSChunk> for Help Prompt that Array of one or more + * TTSChunk elements specifying the help prompt used in an interaction + * started by PTT + * @discussion helpPrompt + * a Vector<TTSChunk> of one or more TTSChunk elements + * <p> + * <b>Notes: </b> + * <ul> + * <li>Array must have at least one element</li> + * <li>Only optional it timeoutPrompt has been specified</li> + * </ul> + */ +@property (strong) NSMutableArray *helpPrompt; +/** + * @abstract A Vector<TTSChunk> for Timeout Prompt representing Array of one or + * more TTSChunk elements specifying the help prompt used in an interaction + * started by PTT + * + */ +@property (strong) NSMutableArray *timeoutPrompt; +/** + * @abstract Sets a voice recognition Help Title + * + * @discussion A String value representing a voice recognition Help Title + * <p> + * <b>Notes: </b><br/> + * <ul> + * <li>If omitted on supported displays, the default SDL help + * title will be used</li> + * <li>If omitted and one or more vrHelp items are provided, the + * request will be rejected.</li> + * <li>String Maxlength = 500</li> + * </ul> + * @since SmartDeviceLink 2.0 + */ +@property (strong) NSString *vrHelpTitle; +/** + * @abstract Sets the items listed in the VR help screen used in an interaction + * started by PTT + * + * @discussion A Vector value representing items listed in the VR help screen + * used in an interaction started by PTT + * <p> + * <b>Notes: </b><br/> + * <ul> + * <li>If omitted on supported displays, the default SmartDeviceLink VR + * help / What Can I Say? screen will be used</li> + * <li>If the list of VR Help Items contains nonsequential + * positions (e.g. [1,2,4]), the RPC will be rejected</li> + * <li>If omitted and a vrHelpTitle is provided, the request + * will be rejected</li> + * <li>Array Minsize: = 1</li> + * <li>Array Maxsize = 100</li> + * </ul> + * @since SmartDeviceLink 2.0 + */ +@property (strong) NSMutableArray *vrHelp; +@property (strong) NSString *menuTitle; +@property (strong) SDLImage *menuIcon; +@property (strong) SDLKeyboardProperties *keyboardProperties; + +@end diff --git a/SmartDeviceLink/SDLSetGlobalProperties.m b/SmartDeviceLink/SDLSetGlobalProperties.m new file mode 100644 index 000000000..ba9749e3e --- /dev/null +++ b/SmartDeviceLink/SDLSetGlobalProperties.m @@ -0,0 +1,149 @@ +// SDLSetGlobalProperties.m +// + + +#import "SDLSetGlobalProperties.h" + +#import "SDLImage.h" +#import "SDLKeyboardProperties.h" +#import "SDLNames.h" +#import "SDLTTSChunk.h" +#import "SDLVRHelpItem.h" + + +@implementation SDLSetGlobalProperties + +- (instancetype)init { + if (self = [super initWithName:NAMES_SetGlobalProperties]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setHelpPrompt:(NSMutableArray *)helpPrompt { + if (helpPrompt != nil) { + [parameters setObject:helpPrompt forKey:NAMES_helpPrompt]; + } else { + [parameters removeObjectForKey:NAMES_helpPrompt]; + } +} + +- (NSMutableArray *)helpPrompt { + NSMutableArray *array = [parameters objectForKey:NAMES_helpPrompt]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLTTSChunk.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLTTSChunk alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +- (void)setTimeoutPrompt:(NSMutableArray *)timeoutPrompt { + if (timeoutPrompt != nil) { + [parameters setObject:timeoutPrompt forKey:NAMES_timeoutPrompt]; + } else { + [parameters removeObjectForKey:NAMES_timeoutPrompt]; + } +} + +- (NSMutableArray *)timeoutPrompt { + NSMutableArray *array = [parameters objectForKey:NAMES_timeoutPrompt]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLTTSChunk.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLTTSChunk alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +- (void)setVrHelpTitle:(NSString *)vrHelpTitle { + if (vrHelpTitle != nil) { + [parameters setObject:vrHelpTitle forKey:NAMES_vrHelpTitle]; + } else { + [parameters removeObjectForKey:NAMES_vrHelpTitle]; + } +} + +- (NSString *)vrHelpTitle { + return [parameters objectForKey:NAMES_vrHelpTitle]; +} + +- (void)setVrHelp:(NSMutableArray *)vrHelp { + if (vrHelp != nil) { + [parameters setObject:vrHelp forKey:NAMES_vrHelp]; + } else { + [parameters removeObjectForKey:NAMES_vrHelp]; + } +} + +- (NSMutableArray *)vrHelp { + NSMutableArray *array = [parameters objectForKey:NAMES_vrHelp]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLVRHelpItem.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLVRHelpItem alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +- (void)setMenuTitle:(NSString *)menuTitle { + if (menuTitle != nil) { + [parameters setObject:menuTitle forKey:NAMES_menuTitle]; + } else { + [parameters removeObjectForKey:NAMES_menuTitle]; + } +} + +- (NSString *)menuTitle { + return [parameters objectForKey:NAMES_menuTitle]; +} + +- (void)setMenuIcon:(SDLImage *)menuIcon { + if (menuIcon != nil) { + [parameters setObject:menuIcon forKey:NAMES_menuIcon]; + } else { + [parameters removeObjectForKey:NAMES_menuIcon]; + } +} + +- (SDLImage *)menuIcon { + NSObject *obj = [parameters objectForKey:NAMES_menuIcon]; + if (obj == nil || [obj isKindOfClass:SDLImage.class]) { + return (SDLImage *)obj; + } else { + return [[SDLImage alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setKeyboardProperties:(SDLKeyboardProperties *)keyboardProperties { + if (keyboardProperties != nil) { + [parameters setObject:keyboardProperties forKey:NAMES_keyboardProperties]; + } else { + [parameters removeObjectForKey:NAMES_keyboardProperties]; + } +} + +- (SDLKeyboardProperties *)keyboardProperties { + NSObject *obj = [parameters objectForKey:NAMES_keyboardProperties]; + if (obj == nil || [obj isKindOfClass:SDLKeyboardProperties.class]) { + return (SDLKeyboardProperties *)obj; + } else { + return [[SDLKeyboardProperties alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLSetGlobalPropertiesResponse.h b/SmartDeviceLink/SDLSetGlobalPropertiesResponse.h new file mode 100644 index 000000000..131700137 --- /dev/null +++ b/SmartDeviceLink/SDLSetGlobalPropertiesResponse.h @@ -0,0 +1,26 @@ +// SDLSetGlobalPropertiesResponse.h +// + + +#import "SDLRPCResponse.h" + +/** + * Set Global Properties Response is sent, when SDLSetGlobalProperties has been called + * + * Since SmartDeviceLink 1.0 + */ +@interface SDLSetGlobalPropertiesResponse : SDLRPCResponse { +} + +/** + * @abstract Constructs a new SDLSetGlobalPropertiesResponse object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLSetGlobalPropertiesResponse object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLSetGlobalPropertiesResponse.m b/SmartDeviceLink/SDLSetGlobalPropertiesResponse.m new file mode 100644 index 000000000..ff4db22c8 --- /dev/null +++ b/SmartDeviceLink/SDLSetGlobalPropertiesResponse.m @@ -0,0 +1,23 @@ +// SDLSetGlobalPropertiesResponse.m +// + + +#import "SDLSetGlobalPropertiesResponse.h" + +#import "SDLNames.h" + +@implementation SDLSetGlobalPropertiesResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_SetGlobalProperties]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLSetMediaClockTimer.h b/SmartDeviceLink/SDLSetMediaClockTimer.h new file mode 100644 index 000000000..71de56b35 --- /dev/null +++ b/SmartDeviceLink/SDLSetMediaClockTimer.h @@ -0,0 +1,68 @@ +// SDLSetMediaClockTimer.h +// + +#import "SDLRPCRequest.h" + +@class SDLStartTime; +@class SDLUpdateMode; + + +/** + * Sets the media clock/timer value and the update method (e.g.count-up, + * count-down, etc.) + * <p> + * Function Group: Base <p> + * <b>HMILevel needs to be FULL, LIMITIED or BACKGROUND</b> + * </p> + * + * Since SmartDeviceLink 1.0 + */ +@interface SDLSetMediaClockTimer : SDLRPCRequest { +} + +/** + * @abstract Constructs a new SDLSetMediaClockTimer object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLSetMediaClockTimer object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract A Start Time with specifying hour, minute, second values + * + * @discussion A startTime object with specifying hour, minute, second values + * <p> + * <b>Notes: </b> + * <ul> + * <li>If "updateMode" is COUNTUP or COUNTDOWN, this parameter + * must be provided</li> + * <li>Will be ignored for PAUSE/RESUME and CLEAR</li> + * </ul> + */ +@property (strong) SDLStartTime *startTime; +/** + * @abstract An END time of type SDLStartTime, specifying hour, minute, second values + * + * @discussion An SDLStartTime object with specifying hour, minute, second values + */ +@property (strong) SDLStartTime *endTime; +/** + * @abstract The media clock/timer update mode (COUNTUP/COUNTDOWN/PAUSE/RESUME) + * + * @discussion a Enumeration value (COUNTUP/COUNTDOWN/PAUSE/RESUME) + * <p> + * <b>Notes: </b> + * <ul> + * <li>When updateMode is PAUSE, RESUME or CLEAR, the start time value + * is ignored</li> + * <li>When updateMode is RESUME, the timer resumes counting from + * the timer's value when it was paused</li> + * </ul> + */ +@property (strong) SDLUpdateMode *updateMode; + +@end diff --git a/SmartDeviceLink/SDLSetMediaClockTimer.m b/SmartDeviceLink/SDLSetMediaClockTimer.m new file mode 100644 index 000000000..325d0e347 --- /dev/null +++ b/SmartDeviceLink/SDLSetMediaClockTimer.m @@ -0,0 +1,77 @@ +// SDLSetMediaClockTimer.m +// + + +#import "SDLSetMediaClockTimer.h" + +#import "SDLNames.h" +#import "SDLStartTime.h" +#import "SDLUpdateMode.h" + + +@implementation SDLSetMediaClockTimer + +- (instancetype)init { + if (self = [super initWithName:NAMES_SetMediaClockTimer]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setStartTime:(SDLStartTime *)startTime { + if (startTime != nil) { + [parameters setObject:startTime forKey:NAMES_startTime]; + } else { + [parameters removeObjectForKey:NAMES_startTime]; + } +} + +- (SDLStartTime *)startTime { + NSObject *obj = [parameters objectForKey:NAMES_startTime]; + if (obj == nil || [obj isKindOfClass:SDLStartTime.class]) { + return (SDLStartTime *)obj; + } else { + return [[SDLStartTime alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setEndTime:(SDLStartTime *)endTime { + if (endTime != nil) { + [parameters setObject:endTime forKey:NAMES_endTime]; + } else { + [parameters removeObjectForKey:NAMES_endTime]; + } +} + +- (SDLStartTime *)endTime { + NSObject *obj = [parameters objectForKey:NAMES_endTime]; + if (obj == nil || [obj isKindOfClass:SDLStartTime.class]) { + return (SDLStartTime *)obj; + } else { + return [[SDLStartTime alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setUpdateMode:(SDLUpdateMode *)updateMode { + if (updateMode != nil) { + [parameters setObject:updateMode forKey:NAMES_updateMode]; + } else { + [parameters removeObjectForKey:NAMES_updateMode]; + } +} + +- (SDLUpdateMode *)updateMode { + NSObject *obj = [parameters objectForKey:NAMES_updateMode]; + if (obj == nil || [obj isKindOfClass:SDLUpdateMode.class]) { + return (SDLUpdateMode *)obj; + } else { + return [SDLUpdateMode valueOf:(NSString *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLSetMediaClockTimerResponse.h b/SmartDeviceLink/SDLSetMediaClockTimerResponse.h new file mode 100644 index 000000000..ffa6a77ae --- /dev/null +++ b/SmartDeviceLink/SDLSetMediaClockTimerResponse.h @@ -0,0 +1,28 @@ +// SDLSetMediaClockTimerResponse.h +// + + +#import "SDLRPCResponse.h" + +/** + * Set Media Clock Timer Response is sent, when SDLSetMediaClockTimer has been called + * + * Since SmartDeviceLink 1.0 + */ +@interface SDLSetMediaClockTimerResponse : SDLRPCResponse { +} + +/** + * @abstract Constructs a new SDLSetMediaClockTimerResponse object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLSetMediaClockTimerResponse object indicated by the NSMutableDictionary + * parameter + * <p> + * + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLSetMediaClockTimerResponse.m b/SmartDeviceLink/SDLSetMediaClockTimerResponse.m new file mode 100644 index 000000000..098522fbd --- /dev/null +++ b/SmartDeviceLink/SDLSetMediaClockTimerResponse.m @@ -0,0 +1,23 @@ +// SDLSetMediaClockTimerResponse.m +// + + +#import "SDLSetMediaClockTimerResponse.h" + +#import "SDLNames.h" + +@implementation SDLSetMediaClockTimerResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_SetMediaClockTimer]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLShow.h b/SmartDeviceLink/SDLShow.h new file mode 100644 index 000000000..20cf84a92 --- /dev/null +++ b/SmartDeviceLink/SDLShow.h @@ -0,0 +1,233 @@ +// SDLShow.h +// + +#import "SDLRPCRequest.h" + +@class SDLImage; +@class SDLTextAlignment; + + +/** + * Updates the application's display text area, regardless of whether or not + * this text area is visible to the user at the time of the request. The + * application's display text area remains unchanged until updated by subsequent + * calls to Show + * <p> + * The content of the application's display text area is visible to the user + * when the application + * is FULL or LIMITED, and the + * SDLSystemContext=MAIN and no + * SDLAlert is in progress + * <p> + * The Show operation cannot be used to create an animated scrolling screen. To + * avoid distracting the driver, Show commands cannot be issued more than once + * every 4 seconds. Requests made more frequently than this will be rejected + * <p> + * <b>HMILevel needs to be FULL, LIMITED or BACKGROUND</b> + * </p> + * + * Since SmartDeviceLink 1.0 + * See SDLAlert SDLSetMediaClockTimer + */ +@interface SDLShow : SDLRPCRequest { +} + +/** + * @abstract Constructs a new SDLShow object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLShow object indicated by the dictionary parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract The text displayed in a single-line display, or in the upper display + * line in a two-line display + * @discussion The String value representing the text displayed in a + * single-line display, or in the upper display line in a + * two-line display + * <p> + * <b>Notes: </b> + * <ul> + * <li>If this parameter is omitted, the text of mainField1 does + * not change</li> + * <li>If this parameter is an empty string, the field will be + * cleared</li> + * </ul> + */ +@property (strong) NSString *mainField1; +/** + * @abstract The text displayed on the second display line of a two-line display + * + * @discussion The String value representing the text displayed on the second + * display line of a two-line display + * <p> + * <b>Notes: </b> + * <ul> + * <li>If this parameter is omitted, the text of mainField2 does + * not change</li> + * <li>If this parameter is an empty string, the field will be + * cleared</li> + * <li>If provided and the display is a single-line display, the + * parameter is ignored</li> + * <li>Maxlength = 500</li> + * </ul> + */ +@property (strong) NSString *mainField2; +/** + * @abstract The text displayed on the first display line of the second page + * + * @discussion The String value representing the text displayed on the first + * display line of the second page + * <p> + * <b>Notes: </b> + * <ul> + * <li>If this parameter is omitted, the text of mainField3 does + * not change</li> + * <li>If this parameter is an empty string, the field will be + * cleared</li> + * <li>If provided and the display is a single-line display, the + * parameter is ignored</li> + * <li>Maxlength = 500</li> + * </ul> + * @since SmartDeviceLink 2.0 + */ +@property (strong) NSString *mainField3; +/** + * @abstract The text displayed on the second display line of the second page + * + * @discussion The String value representing the text displayed on the second + * display line of the second page + * <p> + * <b>Notes: </b> + * <ul> + * <li>If this parameter is omitted, the text of mainField4 does + * not change</li> + * <li>If this parameter is an empty string, the field will be + * cleared</li> + * <li>If provided and the display is a single-line display, the + * parameter is ignored</li> + * <li>Maxlength = 500</li> + * </ul> + * @since SmartDeviceLink 2.0 + */ +@property (strong) NSString *mainField4; +/** + * @abstract The alignment that Specifies how mainField1 and mainField2 text + * should be aligned on display + * + * @discussion An Enumeration value + * <p> + * <b>Notes: </b> + * <ul> + * <li>Applies only to mainField1 and mainField2 provided on this + * call, not to what is already showing in display</li> + * <li>If this parameter is omitted, text in both mainField1 and + * mainField2 will be centered</li> + * <li>Has no effect with navigation display</li> + * </ul> + */ +@property (strong) SDLTextAlignment *alignment; +/** + * @abstract Text in the Status Bar + * + * @discussion A String representing the text you want to add in the Status + * Bar + * <p> + * <b>Notes: </b><i>The status bar only exists on navigation + * displays</i><br/> + * <ul> + * <li>If this parameter is omitted, the status bar text will + * remain unchanged</li> + * <li>If this parameter is an empty string, the field will be + * cleared</li> + * <li>If provided and the display has no status bar, this + * parameter is ignored</li> + * </ul> + */ +@property (strong) NSString *statusBar; +/** + * @abstract This property is deprecated use SetMediaClockTimer instead. + * <p> The value for the MediaClock field using a format described in the + * MediaClockFormat enumeration + * + * @discussion A String value for the MediaClock + * <p> + * <b>Notes: </b><br/> + * <ul> + * <li>Must be properly formatted as described in the + * MediaClockFormat enumeration</li> + * <li>If a value of five spaces is provided, this will clear + * that field on the display (i.e. the media clock timer field + * will not display anything)</li> + * </ul> + */ +@property (strong) NSString *mediaClock; +/** + * @abstract The text in the track field + * + * @discussion A String value disaplayed in the track field + * <p> + * <b>Notes: </b><br/> + * <ul> + * <li>If parameter is omitted, the track field remains unchanged</li> + * <li>If an empty string is provided, the field will be cleared</li> + * <li>This field is only valid for media applications on navigation displays</li> + * </ul> + */ +@property (strong) NSString *mediaTrack; +/** + * @abstract An image to be shown on supported displays + * + * @discussion The value representing the image shown on supported displays + * <p> + * <b>Notes: </b>If omitted on supported displays, the displayed + * graphic shall not change<br/> + * @since SmartDeviceLink 2.0 + */ +@property (strong) SDLImage *graphic; +/** + * @abstract An image to be shown on supported displays + * + * @discussion The value representing the image shown on supported displays + * <p> + * <b>Notes: </b>If omitted on supported displays, the displayed + * graphic shall not change<br/> + * @since SmartDeviceLink 2.0 + */ +@property (strong) SDLImage *secondaryGraphic; +/** + * @abstract The the Soft buttons defined by the App + * + * @discussion A Vector value represemting the Soft buttons defined by the + * App + * <p> + * <b>Notes: </b><br/> + * <ul> + * <li>If omitted on supported displays, the currently displayed + * SoftButton values will not change</li> + * <li>Array Minsize: 0</li> + * <li>Array Maxsize: 8</li> + * </ul> + * + * @since SmartDeviceLink 2.0 + */ +@property (strong) NSMutableArray *softButtons; +/** + * @abstract The Custom Presets defined by the App + * + * @discussion A Vector value representing the Custom Presets defined by the + * App + * <p> + * <ul> + * <li>If omitted on supported displays, the presets will be shown as not defined</li> + * <li>Array Minsize: 0</li> + * <li>Array Maxsize: 6</li> + * </ul> + * @since SmartDeviceLink 2.0 + */ +@property (strong) NSMutableArray *customPresets; + +@end diff --git a/SmartDeviceLink/SDLShow.m b/SmartDeviceLink/SDLShow.m new file mode 100644 index 000000000..933167159 --- /dev/null +++ b/SmartDeviceLink/SDLShow.m @@ -0,0 +1,195 @@ +// SDLShow.m +// + + +#import "SDLShow.h" + +#import "SDLImage.h" +#import "SDLNames.h" +#import "SDLSoftButton.h" +#import "SDLTextAlignment.h" + + +@implementation SDLShow + +- (instancetype)init { + if (self = [super initWithName:NAMES_Show]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setMainField1:(NSString *)mainField1 { + if (mainField1 != nil) { + [parameters setObject:mainField1 forKey:NAMES_mainField1]; + } else { + [parameters removeObjectForKey:NAMES_mainField1]; + } +} + +- (NSString *)mainField1 { + return [parameters objectForKey:NAMES_mainField1]; +} + +- (void)setMainField2:(NSString *)mainField2 { + if (mainField2 != nil) { + [parameters setObject:mainField2 forKey:NAMES_mainField2]; + } else { + [parameters removeObjectForKey:NAMES_mainField2]; + } +} + +- (NSString *)mainField2 { + return [parameters objectForKey:NAMES_mainField2]; +} + +- (void)setMainField3:(NSString *)mainField3 { + if (mainField3 != nil) { + [parameters setObject:mainField3 forKey:NAMES_mainField3]; + } else { + [parameters removeObjectForKey:NAMES_mainField3]; + } +} + +- (NSString *)mainField3 { + return [parameters objectForKey:NAMES_mainField3]; +} + +- (void)setMainField4:(NSString *)mainField4 { + if (mainField4 != nil) { + [parameters setObject:mainField4 forKey:NAMES_mainField4]; + } else { + [parameters removeObjectForKey:NAMES_mainField4]; + } +} + +- (NSString *)mainField4 { + return [parameters objectForKey:NAMES_mainField4]; +} + +- (void)setAlignment:(SDLTextAlignment *)alignment { + if (alignment != nil) { + [parameters setObject:alignment forKey:NAMES_alignment]; + } else { + [parameters removeObjectForKey:NAMES_alignment]; + } +} + +- (SDLTextAlignment *)alignment { + NSObject *obj = [parameters objectForKey:NAMES_alignment]; + if (obj == nil || [obj isKindOfClass:SDLTextAlignment.class]) { + return (SDLTextAlignment *)obj; + } else { + return [SDLTextAlignment valueOf:(NSString *)obj]; + } +} + +- (void)setStatusBar:(NSString *)statusBar { + if (statusBar != nil) { + [parameters setObject:statusBar forKey:NAMES_statusBar]; + } else { + [parameters removeObjectForKey:NAMES_statusBar]; + } +} + +- (NSString *)statusBar { + return [parameters objectForKey:NAMES_statusBar]; +} + +- (void)setMediaClock:(NSString *)mediaClock { + if (mediaClock != nil) { + [parameters setObject:mediaClock forKey:NAMES_mediaClock]; + } else { + [parameters removeObjectForKey:NAMES_mediaClock]; + } +} + +- (NSString *)mediaClock { + return [parameters objectForKey:NAMES_mediaClock]; +} + +- (void)setMediaTrack:(NSString *)mediaTrack { + if (mediaTrack != nil) { + [parameters setObject:mediaTrack forKey:NAMES_mediaTrack]; + } else { + [parameters removeObjectForKey:NAMES_mediaTrack]; + } +} + +- (NSString *)mediaTrack { + return [parameters objectForKey:NAMES_mediaTrack]; +} + +- (void)setGraphic:(SDLImage *)graphic { + if (graphic != nil) { + [parameters setObject:graphic forKey:NAMES_graphic]; + } else { + [parameters removeObjectForKey:NAMES_graphic]; + } +} + +- (SDLImage *)graphic { + NSObject *obj = [parameters objectForKey:NAMES_graphic]; + if (obj == nil || [obj isKindOfClass:SDLImage.class]) { + return (SDLImage *)obj; + } else { + return [[SDLImage alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setSecondaryGraphic:(SDLImage *)secondaryGraphic { + if (secondaryGraphic != nil) { + [parameters setObject:secondaryGraphic forKey:NAMES_secondaryGraphic]; + } else { + [parameters removeObjectForKey:NAMES_secondaryGraphic]; + } +} + +- (SDLImage *)secondaryGraphic { + NSObject *obj = [parameters objectForKey:NAMES_secondaryGraphic]; + if (obj == nil || [obj isKindOfClass:SDLImage.class]) { + return (SDLImage *)obj; + } else { + return [[SDLImage alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setSoftButtons:(NSMutableArray *)softButtons { + if (softButtons != nil) { + [parameters setObject:softButtons forKey:NAMES_softButtons]; + } else { + [parameters removeObjectForKey:NAMES_softButtons]; + } +} + +- (NSMutableArray *)softButtons { + NSMutableArray *array = [parameters objectForKey:NAMES_softButtons]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLSoftButton.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLSoftButton alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +- (void)setCustomPresets:(NSMutableArray *)customPresets { + if (customPresets != nil) { + [parameters setObject:customPresets forKey:NAMES_customPresets]; + } else { + [parameters removeObjectForKey:NAMES_customPresets]; + } +} + +- (NSMutableArray *)customPresets { + return [parameters objectForKey:NAMES_customPresets]; +} + +@end diff --git a/SmartDeviceLink/SDLShowConstantTBT.h b/SmartDeviceLink/SDLShowConstantTBT.h new file mode 100644 index 000000000..ae5dda108 --- /dev/null +++ b/SmartDeviceLink/SDLShowConstantTBT.h @@ -0,0 +1,33 @@ +// SDLShowConstantTBT.h +// + +#import "SDLRPCRequest.h" + +@class SDLImage; + + +/** This RPC is used to update the user with navigation information<br> + * for the constantly shown screen (base screen),but also for the<br> + * alert type screen. + *<p> + * @since SmartDeviceLink 2.0 + */ +@interface SDLShowConstantTBT : SDLRPCRequest { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) NSString *navigationText1; +@property (strong) NSString *navigationText2; +@property (strong) NSString *eta; +@property (strong) NSString *timeToDestination; +@property (strong) NSString *totalDistance; +@property (strong) SDLImage *turnIcon; +@property (strong) SDLImage *nextTurnIcon; +@property (strong) NSNumber *distanceToManeuver; +@property (strong) NSNumber *distanceToManeuverScale; +@property (strong) NSNumber *maneuverComplete; +@property (strong) NSMutableArray *softButtons; + +@end diff --git a/SmartDeviceLink/SDLShowConstantTBT.m b/SmartDeviceLink/SDLShowConstantTBT.m new file mode 100644 index 000000000..c3f87f071 --- /dev/null +++ b/SmartDeviceLink/SDLShowConstantTBT.m @@ -0,0 +1,177 @@ +// SDLShowConstantTBT.m +// + + +#import "SDLShowConstantTBT.h" + +#import "SDLImage.h" +#import "SDLNames.h" +#import "SDLSoftButton.h" + + +@implementation SDLShowConstantTBT + +- (instancetype)init { + if (self = [super initWithName:NAMES_ShowConstantTBT]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setNavigationText1:(NSString *)navigationText1 { + if (navigationText1 != nil) { + [parameters setObject:navigationText1 forKey:NAMES_navigationText1]; + } else { + [parameters removeObjectForKey:NAMES_navigationText1]; + } +} + +- (NSString *)navigationText1 { + return [parameters objectForKey:NAMES_navigationText1]; +} + +- (void)setNavigationText2:(NSString *)navigationText2 { + if (navigationText2 != nil) { + [parameters setObject:navigationText2 forKey:NAMES_navigationText2]; + } else { + [parameters removeObjectForKey:NAMES_navigationText2]; + } +} + +- (NSString *)navigationText2 { + return [parameters objectForKey:NAMES_navigationText2]; +} + +- (void)setEta:(NSString *)eta { + if (eta != nil) { + [parameters setObject:eta forKey:NAMES_eta]; + } else { + [parameters removeObjectForKey:NAMES_eta]; + } +} + +- (NSString *)eta { + return [parameters objectForKey:NAMES_eta]; +} + +- (void)setTimeToDestination:(NSString *)timeToDestination { + if (timeToDestination != nil) { + [parameters setObject:timeToDestination forKey:NAMES_timeToDestination]; + } else { + [parameters removeObjectForKey:NAMES_timeToDestination]; + } +} + +- (NSString *)timeToDestination { + return [parameters objectForKey:NAMES_timeToDestination]; +} + +- (void)setTotalDistance:(NSString *)totalDistance { + if (totalDistance != nil) { + [parameters setObject:totalDistance forKey:NAMES_totalDistance]; + } else { + [parameters removeObjectForKey:NAMES_totalDistance]; + } +} + +- (NSString *)totalDistance { + return [parameters objectForKey:NAMES_totalDistance]; +} + +- (void)setTurnIcon:(SDLImage *)turnIcon { + if (turnIcon != nil) { + [parameters setObject:turnIcon forKey:NAMES_turnIcon]; + } else { + [parameters removeObjectForKey:NAMES_turnIcon]; + } +} + +- (SDLImage *)turnIcon { + NSObject *obj = [parameters objectForKey:NAMES_turnIcon]; + if (obj == nil || [obj isKindOfClass:SDLImage.class]) { + return (SDLImage *)obj; + } else { + return [[SDLImage alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setNextTurnIcon:(SDLImage *)nextTurnIcon { + if (nextTurnIcon != nil) { + [parameters setObject:nextTurnIcon forKey:NAMES_nextTurnIcon]; + } else { + [parameters removeObjectForKey:NAMES_nextTurnIcon]; + } +} + +- (SDLImage *)nextTurnIcon { + NSObject *obj = [parameters objectForKey:NAMES_nextTurnIcon]; + if (obj == nil || [obj isKindOfClass:SDLImage.class]) { + return (SDLImage *)obj; + } else { + return [[SDLImage alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setDistanceToManeuver:(NSNumber *)distanceToManeuver { + if (distanceToManeuver != nil) { + [parameters setObject:distanceToManeuver forKey:NAMES_distanceToManeuver]; + } else { + [parameters removeObjectForKey:NAMES_distanceToManeuver]; + } +} + +- (NSNumber *)distanceToManeuver { + return [parameters objectForKey:NAMES_distanceToManeuver]; +} + +- (void)setDistanceToManeuverScale:(NSNumber *)distanceToManeuverScale { + if (distanceToManeuverScale != nil) { + [parameters setObject:distanceToManeuverScale forKey:NAMES_distanceToManeuverScale]; + } else { + [parameters removeObjectForKey:NAMES_distanceToManeuverScale]; + } +} + +- (NSNumber *)distanceToManeuverScale { + return [parameters objectForKey:NAMES_distanceToManeuverScale]; +} + +- (void)setManeuverComplete:(NSNumber *)maneuverComplete { + if (maneuverComplete != nil) { + [parameters setObject:maneuverComplete forKey:NAMES_maneuverComplete]; + } else { + [parameters removeObjectForKey:NAMES_maneuverComplete]; + } +} + +- (NSNumber *)maneuverComplete { + return [parameters objectForKey:NAMES_maneuverComplete]; +} + +- (void)setSoftButtons:(NSMutableArray *)softButtons { + if (softButtons != nil) { + [parameters setObject:softButtons forKey:NAMES_softButtons]; + } else { + [parameters removeObjectForKey:NAMES_softButtons]; + } +} + +- (NSMutableArray *)softButtons { + NSMutableArray *array = [parameters objectForKey:NAMES_softButtons]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLSoftButton.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLSoftButton alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +@end diff --git a/SmartDeviceLink/SDLShowConstantTBTResponse.h b/SmartDeviceLink/SDLShowConstantTBTResponse.h new file mode 100644 index 000000000..8396f17a1 --- /dev/null +++ b/SmartDeviceLink/SDLShowConstantTBTResponse.h @@ -0,0 +1,16 @@ +// SDLShowConstantTBTResponse.h +// + + +#import "SDLRPCResponse.h" + +/** SDLShowConstantTBTResponse is sent, when SDLShowConstantTBT has been called. + * Since<b>SmartDeviceLink 2.0</b> + */ +@interface SDLShowConstantTBTResponse : SDLRPCResponse { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLShowConstantTBTResponse.m b/SmartDeviceLink/SDLShowConstantTBTResponse.m new file mode 100644 index 000000000..995b16e1c --- /dev/null +++ b/SmartDeviceLink/SDLShowConstantTBTResponse.m @@ -0,0 +1,23 @@ +// SDLShowConstantTBTResponse.m +// + + +#import "SDLShowConstantTBTResponse.h" + +#import "SDLNames.h" + +@implementation SDLShowConstantTBTResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_ShowConstantTBT]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLShowResponse.h b/SmartDeviceLink/SDLShowResponse.h new file mode 100644 index 000000000..b0d558633 --- /dev/null +++ b/SmartDeviceLink/SDLShowResponse.h @@ -0,0 +1,26 @@ +// SDLShowResponse.h +// + + +#import "SDLRPCResponse.h" + +/** + * Show Response is sent, when Show has been called + * + * Since SmartDeviceLink 1.0 + */ +@interface SDLShowResponse : SDLRPCResponse { +} + +/** + * @abstract Constructs a new SDLShowResponse object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLShowResponse object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLShowResponse.m b/SmartDeviceLink/SDLShowResponse.m new file mode 100644 index 000000000..1ebb5dea9 --- /dev/null +++ b/SmartDeviceLink/SDLShowResponse.m @@ -0,0 +1,23 @@ +// SDLShowResponse.m +// + + +#import "SDLShowResponse.h" + +#import "SDLNames.h" + +@implementation SDLShowResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_Show]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLSingleTireStatus.h b/SmartDeviceLink/SDLSingleTireStatus.h new file mode 100644 index 000000000..897ba1bf8 --- /dev/null +++ b/SmartDeviceLink/SDLSingleTireStatus.h @@ -0,0 +1,33 @@ +// SDLSingleTireStatus.h +// + +#import "SDLRPCMessage.h" + +@class SDLComponentVolumeStatus; + + +/** + * Tire pressure status of a single tire. + * + * @since SmartDeviceLink 2.0 + */ +@interface SDLSingleTireStatus : SDLRPCStruct { +} + +/** + * @abstract Constructs a newly allocated SDLSingleTireStatus object + */ +- (instancetype)init; + +/** + * @abstract Constructs a newly allocated SDLSingleTireStatus object indicated by the dictionary parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract The volume status of a single tire + */ +@property (strong) SDLComponentVolumeStatus *status; + +@end diff --git a/SmartDeviceLink/SDLSingleTireStatus.m b/SmartDeviceLink/SDLSingleTireStatus.m new file mode 100644 index 000000000..87826f32b --- /dev/null +++ b/SmartDeviceLink/SDLSingleTireStatus.m @@ -0,0 +1,41 @@ +// SDLSingleTireStatus.m +// + +#import "SDLSingleTireStatus.h" + +#import "SDLComponentVolumeStatus.h" +#import "SDLNames.h" + + +@implementation SDLSingleTireStatus + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setStatus:(SDLComponentVolumeStatus *)status { + if (status != nil) { + [store setObject:status forKey:NAMES_status]; + } else { + [store removeObjectForKey:NAMES_status]; + } +} + +- (SDLComponentVolumeStatus *)status { + NSObject *obj = [store objectForKey:NAMES_status]; + if (obj == nil || [obj isKindOfClass:SDLComponentVolumeStatus.class]) { + return (SDLComponentVolumeStatus *)obj; + } else { + return [SDLComponentVolumeStatus valueOf:(NSString *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLSiphonServer.h b/SmartDeviceLink/SDLSiphonServer.h new file mode 100644 index 000000000..31033e7eb --- /dev/null +++ b/SmartDeviceLink/SDLSiphonServer.h @@ -0,0 +1,20 @@ +// SDLSiphonServer.h +// + + +#import <Foundation/Foundation.h> + +@interface SDLSiphonServer : NSObject <NSStreamDelegate, NSNetServiceDelegate> { +} + ++ (void)enableSiphonDebug; ++ (void)disableSiphonDebug; ++ (bool)_siphonRawTransportDataFromApp:(const void *)msgBytes msgBytesLength:(int)msgBytesLength; ++ (bool)_siphonRawTransportDataFromSDL:(const void *)msgBytes msgBytesLength:(int)msgBytesLength; ++ (bool)_siphonNSLogData:(NSString *)textToLog; ++ (bool)_siphonFormattedTraceData:(NSString *)traceData; ++ (bool)_siphonIsActive; ++ (void)init; ++ (void)dealloc; + +@end diff --git a/SmartDeviceLink/SDLSiphonServer.m b/SmartDeviceLink/SDLSiphonServer.m new file mode 100644 index 000000000..dbb433424 --- /dev/null +++ b/SmartDeviceLink/SDLSiphonServer.m @@ -0,0 +1,452 @@ +// SDLSiphonServer.m +// + + +/******************************* + * Description: + * This class opens a socket on port 7474. + * The 'sendSiphonData' Function will + * write to the socket that the SDL Relay Sniffer is + * listening on. + ******************************/ + +//#define ZERO_CONFIG //Uncomment when implementing zero-config. +//#define DEBUG_SIPHON //Uncomment to have output to NSLog. + +#import "SDLSiphonServer.h" +#import "SDLDebugTool.h" +#include <CFNetwork/CFNetwork.h> +#include <netinet/in.h> +#include <string.h> +#include <sys/socket.h> +#include <sys/types.h> +#include <unistd.h> + +typedef enum { + fromApp = 0x01, + fromSDL = 0x00, + appLog = 0x02, + formattedTrace = 0x03 +} SiphonDataType; + +const Byte siphonMsgVersionNumber = 1; +volatile int siphonSocket = 0; +NSObject *siphonLock = nil; +CFSocketRef _listeningSocket; +NSNetService *netService = nil; +volatile bool initStarted = false; +bool siphonServerEnabled = false; +bool sendingFormattedTrace = false; +NSDate *startTimeStamp; +int FIRST_PORT_TO_ATTEMPT_CONNECTION = 7474; + +void _closeSiphonSocket(); +bool _sendDataToSiphonSocket(int soc, const void *pData, int dataLength); +bool _sendSiphonData(const void *dataBytes, int dataBytesLength, SiphonDataType siphonDataType); +void _startServerOnPort(int port); +void _stopServer(NSString *reason); + + +@implementation SDLSiphonServer + +// Model currently counts on init being called before any apps call _siphonNSLogData() +// The following is not thread safe (i.e. two threads could create siphon lock), +// but will assume for now that we won't have two transports created in the same proxy. ++ (void)init { + if (initStarted) { + return; + } // end-if + + if (!siphonLock) { + siphonLock = [NSData alloc]; + } // end-if + + @synchronized(siphonLock) { + if (initStarted) { + return; + } + + initStarted = true; + + startTimeStamp = [NSDate date]; + + _closeSiphonSocket(); + + _startServerOnPort(FIRST_PORT_TO_ATTEMPT_CONNECTION); + } +} + ++ (void)enableSiphonDebug { + siphonServerEnabled = true; +} + ++ (void)disableSiphonDebug { + siphonServerEnabled = false; +} + +void _closeSiphonSocket() { +#ifdef DEBUG_SIPHON + NSLog(@"siphon: Resetting siphon socket ..."); +#endif + if (siphonLock) { + @synchronized(siphonLock) { + if (siphonSocket) { + close(siphonSocket); + siphonSocket = 0; + } // end-if + } // end-lock + } // end-if +#ifdef DEBUG_SIPHON + NSLog(@"siphon: siphon socket reset complete"); +#endif +} // end-method + ++ (void)dealloc { +#ifdef ZERO_CONFIG + _stopServer(@"Shutting Down"); +#endif +} + ++ (bool)_siphonIsActive { + if (siphonSocket == 0) { + return NO; + } + return YES; +} + + ++ (bool)_siphonFormattedTraceData:(NSString *)traceData { + if ((traceData == NULL) || (traceData.length == 0)) { + return NO; + } // end-if + + NSData *traceBytes = [traceData dataUsingEncoding:NSUTF8StringEncoding]; + + if (traceBytes == nil) { + return NO; + } // end-if + + bool dataSent = NO; + + sendingFormattedTrace = true; + + dataSent = _sendSiphonData(traceBytes.bytes, (int)traceBytes.length, formattedTrace); + + return dataSent; +} // end-method + ++ (bool)_siphonNSLogData:(NSString *)textToLog { + if ((textToLog == NULL) || (textToLog.length == 0)) { + return NO; + } // end-if + + NSData *textBytes = [textToLog dataUsingEncoding:NSUTF8StringEncoding]; + + if (textBytes == nil) { + return NO; + } // end-if + + bool dataSent = NO; + + dataSent = _sendSiphonData(textBytes.bytes, (int)textBytes.length, appLog); + + return dataSent; +} // end-method + ++ (bool)_siphonRawTransportDataFromApp:(const void *)msgBytes msgBytesLength:(int)msgBytesLength { + if (sendingFormattedTrace) { + return false; + } // end-if + + if (msgBytes == NULL || msgBytesLength == 0) { + return false; + } // end-if + + return _sendSiphonData(msgBytes, msgBytesLength, fromApp); +} + ++ (bool)_siphonRawTransportDataFromSDL:(const void *)msgBytes msgBytesLength:(int)msgBytesLength { + if (sendingFormattedTrace) { + return false; + } // end-if + + if (msgBytes == NULL || msgBytesLength == 0) { + return false; + } // end-if + + return _sendSiphonData(msgBytes, msgBytesLength, fromSDL); +} + +bool _sendSiphonData(const void *dataBytes, int dataBytesLength, SiphonDataType siphonDataType) { + bool wasSent = NO; + + if (dataBytes == NULL || dataBytesLength == 0 || !siphonServerEnabled) { + return false; + } // end-if + + NSDate *currentTime = [NSDate date]; + NSTimeInterval deltaTimeMillis = ([currentTime timeIntervalSinceDate:startTimeStamp] * 1000.0); + uint32_t integerDeltaTimeMillis = ((uint32_t)deltaTimeMillis); + + integerDeltaTimeMillis = htonl(integerDeltaTimeMillis); + + if (siphonLock) { + @synchronized(siphonLock) { + if (siphonSocket) { + Byte sdt = (Byte)siphonDataType; + sdt = (Byte)0x80 | sdt; + uint32_t sizeBytes = htonl(dataBytesLength + sizeof(sdt) + sizeof(integerDeltaTimeMillis) + sizeof(siphonMsgVersionNumber)); + + wasSent = _sendDataToSiphonSocket(siphonSocket, &sizeBytes, sizeof(sizeBytes)); + + if (wasSent) { + wasSent = _sendDataToSiphonSocket(siphonSocket, &sdt, sizeof(sdt)); + } + + if (wasSent) { + wasSent = _sendDataToSiphonSocket(siphonSocket, &siphonMsgVersionNumber, sizeof(siphonMsgVersionNumber)); + } + + if (wasSent) { + wasSent = _sendDataToSiphonSocket(siphonSocket, &integerDeltaTimeMillis, sizeof(integerDeltaTimeMillis)); + } + + if (wasSent) { + wasSent = _sendDataToSiphonSocket(siphonSocket, dataBytes, dataBytesLength); + } + + if (wasSent) { + return YES; + } else { +#ifdef DEBUG_SIPHON + NSLog(@"siphon: failure sending to siphon socket"); +#endif + _closeSiphonSocket(); + return NO; + } // end-if + } else { +#ifdef DEBUG_SIPHON + NSLog(@"siphon: siphon socket is NULL"); +#endif + } // end-if + } //end Synchronized + } // end-if + return NO; + +} // end-method + +bool _sendDataToSiphonSocket(int soc, const void *pData, int dataLength) { + int bytesRemainingToSend = dataLength; + ssize_t bytesSent = 0; + const UInt8 *pd = pData; + + if (pData == NULL || dataLength == 0) { + return false; + } // end-if + + while (bytesRemainingToSend > 0) { + if (soc) { + bytesSent = send(soc, pd, bytesRemainingToSend, 0); + + if (bytesSent == -1) { +#ifdef DEBUG_SIPHON + NSLog(@"siphon: got bytesSent==-1 on send(siphonSocket)"); +#endif + return NO; + } // end-if + + bytesRemainingToSend -= bytesSent; + pd += bytesSent; + } // end-if + + } // end-while + + return YES; + +} // end-method + + +void _serverDidStartOnPort(int port) { +#ifdef DEBUG_SIPHON + NSLog(@"siphon: server started on port: %d", port); +#endif +} + +#ifdef ZERO_CONFIG + +#pragma mark +#pragma mark Server + +- (void)_didSendData:(NSData *)data { +} + +void _serverDidStopWithReason(NSString *reason) { +} + +- (void)_updateStatus:(NSString *)statusString { + NSLog(@"siphon: %@", statusString); +} + +- (void)_SendDidStopWithStatus:(NSString *)statusString { + NSLog(@"siphon: server configured for output"); +} + +- (BOOL)isStarted { + return (netService != nil); +} +#endif + + +void _acceptConnection(int fd) { + if (siphonLock) { + @synchronized(siphonLock) { + int socketOps = 1; + + _closeSiphonSocket(); +#ifdef DEBUG_SIPHON + NSLog(@"siphon: storing newly accepted siphon socket handle %08x ...", fd); +#endif + siphonSocket = fd; + + setsockopt(siphonSocket, SOL_SOCKET, SO_NOSIGPIPE, (void *)&socketOps, sizeof(int)); + [SDLDebugTool logInfo:@"Siphon connected." withType:SDLDebugType_Debug]; + + } // end-lock + } // end-if + return; +} + +static void AcceptCallback(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *data, void *info) { +#ifdef DEBUG_SIPHON + NSLog(@"siphon: accepted siphon connection ..."); +#endif + +#pragma unused(type) + assert(type == kCFSocketAcceptCallBack); +#pragma unused(address) + assert(data != NULL); + +#pragma unused(s) + assert(s == _listeningSocket); + + _acceptConnection(*(int *)data); +} + + +#ifdef ZERO_CONFIG +- (void)netService:(NSNetService *)sender didNotPublish:(NSDictionary *)errorDict { +#pragma unused(sender) + assert(sender == netService); +#pragma unused(errorDict) + + _stopServer(@"Registration failed"); +} +#endif + +void _startServerOnPort(int port) { + BOOL success; + int err; + int fd; + struct sockaddr_in addr; + int const retryLimit = 1000; + + fd = socket(AF_INET, SOCK_STREAM, 0); + success = (fd != -1); + + if (success) { + memset(&addr, 0, sizeof(addr)); + addr.sin_len = sizeof(addr); + addr.sin_family = AF_INET; + + addr.sin_addr.s_addr = INADDR_ANY; + + bool openPortFound = false; + short bindPort = (short)port; + success = false; + for (int retryCount = 0; retryCount < retryLimit && !openPortFound; retryCount++) { + addr.sin_port = htons(bindPort); + err = bind(fd, (const struct sockaddr *)&addr, sizeof(addr)); + if (err == 0) { + openPortFound = true; + success = (err == 0); + port = bindPort; + } else { + bindPort++; + } + } // end-for + } + if (success) { + err = listen(fd, 5); + success = (err == 0); + } + if (success) { + socklen_t addrLen; + + addrLen = sizeof(addr); + err = getsockname(fd, (struct sockaddr *)&addr, &addrLen); + success = (err == 0); + + if (success) { + assert(addrLen == sizeof(addr)); + port = ntohs(addr.sin_port); + } +#ifdef DEBUG_SIPHON + NSLog(@"siphon: my port is %d ", port); +#endif + } + if (success) { + _listeningSocket = CFSocketCreateWithNative( + NULL, + fd, + kCFSocketAcceptCallBack, + AcceptCallback, + NULL); + success = (_listeningSocket != NULL); + + if (success) { + CFRunLoopSourceRef rls; + fd = -1; + rls = CFSocketCreateRunLoopSource(NULL, _listeningSocket, 0); + assert(rls != NULL); + CFRunLoopAddSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode); + CFRelease(rls); + } + } + +#ifdef ZERO_CONFIG + + if (success) { + UIDevice *device = [UIDevice currentDevice]; + ; + NSString *serviceName = [NSString stringWithFormat:@"%@_%d ", device.name, port]; + netService = [[[NSNetService alloc] initWithDomain:@"local." type:@"_sync._tcp." name:serviceName port:port] autorelease]; + success = (netService != nil); + } + if (success) { + [netService publishWithOptions:NSNetServiceNoAutoRename]; + } + + if (success) { + assert(port != 0); + _serverDidStartOnPort(port); + } else { + _stopServer(@"Start failed"); + if (fd != -1) { + assert(startFailed == 0); + } + } + +#endif +} + +void _stopServer(NSString *reason) { +#ifdef ZERO_CONFIG + if (netService != nil) { + [netService stop]; + netService = nil; + } + _serverDidStopWithReason(reason); +#endif +} + +@end diff --git a/SmartDeviceLink/SDLSlider.h b/SmartDeviceLink/SDLSlider.h new file mode 100644 index 000000000..04724d780 --- /dev/null +++ b/SmartDeviceLink/SDLSlider.h @@ -0,0 +1,75 @@ +// SDLSlider.h +// + + +#import "SDLRPCRequest.h" + +/** + * Creates a full screen or pop-up overlay (depending on platform) with a single user controlled slider + * + * HMILevel needs to be FULL + * + * Since SmartDeviceLink 2.0 + */ +@interface SDLSlider : SDLRPCRequest { +} + +/** + * @abstract Constructs a new SDLSlider object + */ +- (instancetype)init; + +/** + * @abstract Constructs a new SDLSlider object indicated by the dictionary parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract Represents a number of selectable items on a horizontal axis + * + * Required, Integer, 2 - 26 + */ +@property (strong) NSNumber *numTicks; + +/** + * @abstract An Initial position of slider control + * + * Required, Integer, 1 - 26 + */ +@property (strong) NSNumber *position; + +/** + * @abstract A text header to display + * + * Rquired, Max length 500 chars + */ +@property (strong) NSString *sliderHeader; + +/** + * @abstract A text footer to display + * + * @discussion For a static text footer, only one footer string shall be provided in the array. + * + * For a dynamic text footer, the number of footer text string in the array must match the numTicks value. + * + * For a dynamic text footer, text array string should correlate with potential slider position index. + * + * If omitted on supported displays, no footer text shall be displayed. + * + * Optional, Array of Strings, Array length 1 - 26, Max string length 500 chars + */ +@property (strong) NSMutableArray *sliderFooter; + +/** + * @abstract An App defined timeout + * + * @discussion Indicates how long of a timeout from the last action (i.e. sliding control resets timeout). + * + * If omitted, the value is set to 10000. + * + * Optional, Integer, 1000 - 65535 + */ +@property (strong) NSNumber *timeout; + +@end diff --git a/SmartDeviceLink/SDLSlider.m b/SmartDeviceLink/SDLSlider.m new file mode 100644 index 000000000..80a56d1aa --- /dev/null +++ b/SmartDeviceLink/SDLSlider.m @@ -0,0 +1,83 @@ +// SDLSlider.m +// + + +#import "SDLSlider.h" + +#import "SDLNames.h" + +@implementation SDLSlider + +- (instancetype)init { + if (self = [super initWithName:NAMES_Slider]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setNumTicks:(NSNumber *)numTicks { + if (numTicks != nil) { + [parameters setObject:numTicks forKey:NAMES_numTicks]; + } else { + [parameters removeObjectForKey:NAMES_numTicks]; + } +} + +- (NSNumber *)numTicks { + return [parameters objectForKey:NAMES_numTicks]; +} + +- (void)setPosition:(NSNumber *)position { + if (position != nil) { + [parameters setObject:position forKey:NAMES_position]; + } else { + [parameters removeObjectForKey:NAMES_position]; + } +} + +- (NSNumber *)position { + return [parameters objectForKey:NAMES_position]; +} + +- (void)setSliderHeader:(NSString *)sliderHeader { + if (sliderHeader != nil) { + [parameters setObject:sliderHeader forKey:NAMES_sliderHeader]; + } else { + [parameters removeObjectForKey:NAMES_sliderHeader]; + } +} + +- (NSString *)sliderHeader { + return [parameters objectForKey:NAMES_sliderHeader]; +} + +- (void)setSliderFooter:(NSMutableArray *)sliderFooter { + if (sliderFooter != nil) { + [parameters setObject:sliderFooter forKey:NAMES_sliderFooter]; + } else { + [parameters removeObjectForKey:NAMES_sliderFooter]; + } +} + +- (NSMutableArray *)sliderFooter { + return [parameters objectForKey:NAMES_sliderFooter]; +} + +- (void)setTimeout:(NSNumber *)timeout { + if (timeout != nil) { + [parameters setObject:timeout forKey:NAMES_timeout]; + } else { + [parameters removeObjectForKey:NAMES_timeout]; + } +} + +- (NSNumber *)timeout { + return [parameters objectForKey:NAMES_timeout]; +} + +@end diff --git a/SmartDeviceLink/SDLSliderResponse.h b/SmartDeviceLink/SDLSliderResponse.h new file mode 100644 index 000000000..5b38b7f0f --- /dev/null +++ b/SmartDeviceLink/SDLSliderResponse.h @@ -0,0 +1,31 @@ +// SDLSliderResponse.h +// + + +#import "SDLRPCResponse.h" + +/** + * Slider Response is sent, when Slider has been called + * + * Since SmartDeviceLink 2.0 + */ +@interface SDLSliderResponse : SDLRPCResponse { +} + +/** + * @abstract Constructs a new SDLSliderResponse object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLSliderResponse object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract The selected position of the slider. + */ +@property (strong) NSNumber *sliderPosition; + +@end diff --git a/SmartDeviceLink/SDLSliderResponse.m b/SmartDeviceLink/SDLSliderResponse.m new file mode 100644 index 000000000..927ad569d --- /dev/null +++ b/SmartDeviceLink/SDLSliderResponse.m @@ -0,0 +1,35 @@ +// SDLSliderResponse.m +// + + +#import "SDLSliderResponse.h" + +#import "SDLNames.h" + +@implementation SDLSliderResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_Slider]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setSliderPosition:(NSNumber *)sliderPosition { + if (sliderPosition != nil) { + [parameters setObject:sliderPosition forKey:NAMES_sliderPosition]; + } else { + [parameters removeObjectForKey:NAMES_sliderPosition]; + } +} + +- (NSNumber *)sliderPosition { + return [parameters objectForKey:NAMES_sliderPosition]; +} + +@end diff --git a/SmartDeviceLink/SDLSoftButton.h b/SmartDeviceLink/SDLSoftButton.h new file mode 100644 index 000000000..db2393ae7 --- /dev/null +++ b/SmartDeviceLink/SDLSoftButton.h @@ -0,0 +1,24 @@ +// SDLSoftButton.h +// + +#import "SDLRPCMessage.h" + +@class SDLImage; +@class SDLSoftButtonType; +@class SDLSystemAction; + + +@interface SDLSoftButton : SDLRPCStruct { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) SDLSoftButtonType *type; +@property (strong) NSString *text; +@property (strong) SDLImage *image; +@property (strong) NSNumber *isHighlighted; +@property (strong) NSNumber *softButtonID; +@property (strong) SDLSystemAction *systemAction; + +@end diff --git a/SmartDeviceLink/SDLSoftButton.m b/SmartDeviceLink/SDLSoftButton.m new file mode 100644 index 000000000..a93ce510c --- /dev/null +++ b/SmartDeviceLink/SDLSoftButton.m @@ -0,0 +1,113 @@ +// SDLSoftButton.m +// + +#import "SDLSoftButton.h" + +#import "SDLImage.h" +#import "SDLNames.h" +#import "SDLSoftButtonType.h" +#import "SDLSystemAction.h" + + +@implementation SDLSoftButton + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setType:(SDLSoftButtonType *)type { + if (type != nil) { + [store setObject:type forKey:NAMES_type]; + } else { + [store removeObjectForKey:NAMES_type]; + } +} + +- (SDLSoftButtonType *)type { + NSObject *obj = [store objectForKey:NAMES_type]; + if (obj == nil || [obj isKindOfClass:SDLSoftButtonType.class]) { + return (SDLSoftButtonType *)obj; + } else { + return [SDLSoftButtonType valueOf:(NSString *)obj]; + } +} + +- (void)setText:(NSString *)text { + if (text != nil) { + [store setObject:text forKey:NAMES_text]; + } else { + [store removeObjectForKey:NAMES_text]; + } +} + +- (NSString *)text { + return [store objectForKey:NAMES_text]; +} + +- (void)setImage:(SDLImage *)image { + if (image != nil) { + [store setObject:image forKey:NAMES_image]; + } else { + [store removeObjectForKey:NAMES_image]; + } +} + +- (SDLImage *)image { + NSObject *obj = [store objectForKey:NAMES_image]; + if (obj == nil || [obj isKindOfClass:SDLImage.class]) { + return (SDLImage *)obj; + } else { + return [[SDLImage alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setIsHighlighted:(NSNumber *)isHighlighted { + if (isHighlighted != nil) { + [store setObject:isHighlighted forKey:NAMES_isHighlighted]; + } else { + [store removeObjectForKey:NAMES_isHighlighted]; + } +} + +- (NSNumber *)isHighlighted { + return [store objectForKey:NAMES_isHighlighted]; +} + +- (void)setSoftButtonID:(NSNumber *)softButtonID { + if (softButtonID != nil) { + [store setObject:softButtonID forKey:NAMES_softButtonID]; + } else { + [store removeObjectForKey:NAMES_softButtonID]; + } +} + +- (NSNumber *)softButtonID { + return [store objectForKey:NAMES_softButtonID]; +} + +- (void)setSystemAction:(SDLSystemAction *)systemAction { + if (systemAction != nil) { + [store setObject:systemAction forKey:NAMES_systemAction]; + } else { + [store removeObjectForKey:NAMES_systemAction]; + } +} + +- (SDLSystemAction *)systemAction { + NSObject *obj = [store objectForKey:NAMES_systemAction]; + if (obj == nil || [obj isKindOfClass:SDLSystemAction.class]) { + return (SDLSystemAction *)obj; + } else { + return [SDLSystemAction valueOf:(NSString *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLSoftButtonCapabilities.h b/SmartDeviceLink/SDLSoftButtonCapabilities.h new file mode 100644 index 000000000..ca9eeb2bf --- /dev/null +++ b/SmartDeviceLink/SDLSoftButtonCapabilities.h @@ -0,0 +1,60 @@ +// SDLSoftButtonCapabilities.h +// + + +#import "SDLRPCMessage.h" + +/** + * Contains information about a SoftButton's capabilities. + * + * @since SDL 2.0 + */ +@interface SDLSoftButtonCapabilities : SDLRPCStruct { +} + +/** + * @abstract Constructs a newly allocated SDLSoftButtonCapabilities object + */ +- (instancetype)init; + +/** + * @abstract Constructs a newly allocated SDLSoftButtonCapabilities object indicated by the dictionary parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract The button supports a short press. + * + * @discussion Whenever the button is pressed short, onButtonPressed(SHORT) will be invoked. + * + * Required, Boolean + */ +@property (strong) NSNumber *shortPressAvailable; + +/** + * @abstract The button supports a LONG press. + * + * @discussion Whenever the button is pressed long, onButtonPressed(LONG) will be invoked. + * + * Required, Boolean + */ +@property (strong) NSNumber *longPressAvailable; + +/** + * @abstract The button supports "button down" and "button up". + * + * @discussion Whenever the button is pressed, onButtonEvent(DOWN) will be invoked. Whenever the button is released, onButtonEvent(UP) will be invoked. + * + * Required, Boolean + */ +@property (strong) NSNumber *upDownAvailable; + +/** + * @abstract The button supports referencing a static or dynamic image. + * + * Required, Boolean + */ +@property (strong) NSNumber *imageSupported; + +@end diff --git a/SmartDeviceLink/SDLSoftButtonCapabilities.m b/SmartDeviceLink/SDLSoftButtonCapabilities.m new file mode 100644 index 000000000..d9a502db1 --- /dev/null +++ b/SmartDeviceLink/SDLSoftButtonCapabilities.m @@ -0,0 +1,71 @@ +// SDLSoftButtonCapabilities.m +// + + +#import "SDLSoftButtonCapabilities.h" + +#import "SDLNames.h" + +@implementation SDLSoftButtonCapabilities + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setShortPressAvailable:(NSNumber *)shortPressAvailable { + if (shortPressAvailable != nil) { + [store setObject:shortPressAvailable forKey:NAMES_shortPressAvailable]; + } else { + [store removeObjectForKey:NAMES_shortPressAvailable]; + } +} + +- (NSNumber *)shortPressAvailable { + return [store objectForKey:NAMES_shortPressAvailable]; +} + +- (void)setLongPressAvailable:(NSNumber *)longPressAvailable { + if (longPressAvailable != nil) { + [store setObject:longPressAvailable forKey:NAMES_longPressAvailable]; + } else { + [store removeObjectForKey:NAMES_longPressAvailable]; + } +} + +- (NSNumber *)longPressAvailable { + return [store objectForKey:NAMES_longPressAvailable]; +} + +- (void)setUpDownAvailable:(NSNumber *)upDownAvailable { + if (upDownAvailable != nil) { + [store setObject:upDownAvailable forKey:NAMES_upDownAvailable]; + } else { + [store removeObjectForKey:NAMES_upDownAvailable]; + } +} + +- (NSNumber *)upDownAvailable { + return [store objectForKey:NAMES_upDownAvailable]; +} + +- (void)setImageSupported:(NSNumber *)imageSupported { + if (imageSupported != nil) { + [store setObject:imageSupported forKey:NAMES_imageSupported]; + } else { + [store removeObjectForKey:NAMES_imageSupported]; + } +} + +- (NSNumber *)imageSupported { + return [store objectForKey:NAMES_imageSupported]; +} + +@end diff --git a/SmartDeviceLink/SDLSoftButtonType.h b/SmartDeviceLink/SDLSoftButtonType.h new file mode 100644 index 000000000..d2b59a8d5 --- /dev/null +++ b/SmartDeviceLink/SDLSoftButtonType.h @@ -0,0 +1,41 @@ +// SDLSoftButtonType.h +// + + +#import "SDLEnum.h" + +/** + SoftButtonType (TEXT / IMAGE / BOTH) + */ +@interface SDLSoftButtonType : SDLEnum { +} + +/** + @abstract get SDLSoftButtonType according value string + @param value NSString + @return SDLSoftButtonType object + */ ++ (SDLSoftButtonType *)valueOf:(NSString *)value; +/** + @abstract declare an array to store all possible SDLSoftButtonType values + @return the array + */ ++ (NSArray *)values; + +/** + @abstract Text kind Softbutton + @return SDLSoftButtonType object with string value *TEXT* + */ ++ (SDLSoftButtonType *)TEXT; +/** + @abstract Image kind Softbutton + @return SDLSoftButtonType object with string value *IMAGE* + */ ++ (SDLSoftButtonType *)IMAGE; +/** + @abstract Both (Text & Image) kind Softbutton + @return SDLSoftButtonType object with string value *BOTH* + */ ++ (SDLSoftButtonType *)BOTH; + +@end diff --git a/SmartDeviceLink/SDLSoftButtonType.m b/SmartDeviceLink/SDLSoftButtonType.m new file mode 100644 index 000000000..9add8edfe --- /dev/null +++ b/SmartDeviceLink/SDLSoftButtonType.m @@ -0,0 +1,56 @@ +// SDLSoftButtonType.m +// + + +#import "SDLSoftButtonType.h" + +SDLSoftButtonType *SDLSoftButtonType_TEXT = nil; +SDLSoftButtonType *SDLSoftButtonType_IMAGE = nil; +SDLSoftButtonType *SDLSoftButtonType_BOTH = nil; + +NSArray *SDLSoftButtonType_values = nil; + +@implementation SDLSoftButtonType + ++ (SDLSoftButtonType *)valueOf:(NSString *)value { + for (SDLSoftButtonType *item in SDLSoftButtonType.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLSoftButtonType_values == nil) { + SDLSoftButtonType_values = @[ + SDLSoftButtonType.TEXT, + SDLSoftButtonType.IMAGE, + SDLSoftButtonType.BOTH, + ]; + } + return SDLSoftButtonType_values; +} + ++ (SDLSoftButtonType *)TEXT { + if (SDLSoftButtonType_TEXT == nil) { + SDLSoftButtonType_TEXT = [[SDLSoftButtonType alloc] initWithValue:@"TEXT"]; + } + return SDLSoftButtonType_TEXT; +} + ++ (SDLSoftButtonType *)IMAGE { + if (SDLSoftButtonType_IMAGE == nil) { + SDLSoftButtonType_IMAGE = [[SDLSoftButtonType alloc] initWithValue:@"IMAGE"]; + } + return SDLSoftButtonType_IMAGE; +} + ++ (SDLSoftButtonType *)BOTH { + if (SDLSoftButtonType_BOTH == nil) { + SDLSoftButtonType_BOTH = [[SDLSoftButtonType alloc] initWithValue:@"BOTH"]; + } + return SDLSoftButtonType_BOTH; +} + +@end diff --git a/SmartDeviceLink/SDLSpeak.h b/SmartDeviceLink/SDLSpeak.h new file mode 100644 index 000000000..8e6eb8e7e --- /dev/null +++ b/SmartDeviceLink/SDLSpeak.h @@ -0,0 +1,64 @@ +// SDLSpeak.h +// + +#import "SDLRPCRequest.h" + +/** + * Speaks a phrase over the vehicle audio system using SDL's TTS (text-to-speech) engine. The provided text to be spoken can be simply a text phrase, or it can consist of phoneme specifications to direct SDL's TTS engine to speak a "speech-sculpted" phrase. + * + * Receipt of the Response indicates the completion of the Speak operation, regardless of how the Speak operation may have completed (i.e. successfully, interrupted, terminated, etc.). + * + * Requesting a new Speak operation while the application has another Speak operation already in progress (i.e. no corresponding Response for that in-progress Speak operation has been received yet) will terminate the in-progress Speak operation (causing its corresponding Response to be sent by SDL) and begin the requested Speak operation + * + * Requesting a new Speak operation while the application has an <i>SDLAlert</i> operation already in progress (i.e. no corresponding Response for that in-progress <i>SDLAlert</i> operation has been received yet) will result in the Speak operation request being rejected (indicated in the Response to the Request) + * + * Requesting a new <i>SDLAlert</i> operation while the application has a Speak operation already in progress (i.e. no corresponding Response for that in-progress Speak operation has been received yet) will terminate the in-progress Speak operation (causing its corresponding Response to be sent by SDL) and begin the requested <i>SDLAlert</i> operation + * + * Requesting a new Speak operation while the application has a <i>SDLPerformInteraction</i> operation already in progress (i.e. no corresponding Response for that in-progress <i>SDLPerformInteraction</i> operation has been received yet) will result in the Speak operation request being rejected (indicated in the Response to the Request) + * + * Requesting a <i>SDLPerformInteraction</i> operation while the application has a Speak operation already in progress (i.e. no corresponding Response for that in-progress Speak operation has been received yet) will terminate the in-progress Speak operation (causing its corresponding Response to be sent by SDL) and begin the requested <i>SDLPerformInteraction</i> operation + * + * HMI Status Requirements: + * <li>HMILevel: FULL, Limited</li> + * <li>AudioStreamingState: Any</li> + * <li>SystemContext: MAIN, MENU, VR</li> + + * <b>Notes:</b> + * <li>When <i>SDLAlert</i> is issued with MENU in effect, <i>SDLAlert</i> is queued and "played" when MENU interaction is completed (i.e. SystemContext reverts to MAIN). When <i>SDLAlert + * </i> is issued with VR in effect, <i>SDLAlert</i> is queued and "played" when VR interaction is completed (i.e. SystemContext reverts to MAIN)</li> + * <li>When both <i>SDLAlert</i> and Speak are queued during MENU or VR, they are "played" back in the order in which they were queued, with all existing rules for "collisions" still in effect</li> + * + * <b>Additional Notes:</b> + * <li>Total character limit depends on platform.</li> + * <li>Chunks are limited to 500 characters; however you can have multiple TTS chunks.</li> + * <li>On old systems there is a total character limit of 500 characters across all chunks. This could vary according to the VCA.</li> + * + * @since SmartDeviceLink 1.0 + * @see SDLAlert + */ +@interface SDLSpeak : SDLRPCRequest { +} + +/** + * @abstract Constructs a new SDLSpeak object + */ +- (instancetype)init; + +/** + * @abstract Constructs a new SDLSpeak object indicated by the dictionary parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract An array of TTSChunk structs which, taken together, specify the phrase to be spoken + * + * @discussion The total length of the phrase composed from the ttsChunks provided must be less than 500 characters or the request will be rejected + * + * Required, Array of SDLTTSChunk, Array size 1 - 100 + * + * @see SDLTTSChunk + */ +@property (strong) NSMutableArray *ttsChunks; + +@end diff --git a/SmartDeviceLink/SDLSpeak.m b/SmartDeviceLink/SDLSpeak.m new file mode 100644 index 000000000..8f19b925b --- /dev/null +++ b/SmartDeviceLink/SDLSpeak.m @@ -0,0 +1,45 @@ +// SDLSpeak.m +// + + +#import "SDLSpeak.h" + +#import "SDLNames.h" +#import "SDLTTSChunk.h" + +@implementation SDLSpeak + +- (instancetype)init { + if (self = [super initWithName:NAMES_Speak]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setTtsChunks:(NSMutableArray *)ttsChunks { + if (ttsChunks != nil) { + [parameters setObject:ttsChunks forKey:NAMES_ttsChunks]; + } else { + [parameters removeObjectForKey:NAMES_ttsChunks]; + } +} + +- (NSMutableArray *)ttsChunks { + NSMutableArray *array = [parameters objectForKey:NAMES_ttsChunks]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLTTSChunk.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLTTSChunk alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +@end diff --git a/SmartDeviceLink/SDLSpeakResponse.h b/SmartDeviceLink/SDLSpeakResponse.h new file mode 100644 index 000000000..2a7eef046 --- /dev/null +++ b/SmartDeviceLink/SDLSpeakResponse.h @@ -0,0 +1,26 @@ +// SDLSpeakResponse.h +// + + +#import "SDLRPCResponse.h" + +/** + * Speak Response is sent, when Speak has been called + * + * Since SmartDeviceLink 1.0 + */ +@interface SDLSpeakResponse : SDLRPCResponse { +} + +/** + * @abstract Constructs a new SDLSpeakResponse object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLSpeakResponse object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLSpeakResponse.m b/SmartDeviceLink/SDLSpeakResponse.m new file mode 100644 index 000000000..dfb8dff33 --- /dev/null +++ b/SmartDeviceLink/SDLSpeakResponse.m @@ -0,0 +1,23 @@ +// SDLSpeakResponse.m +// + + +#import "SDLSpeakResponse.h" + +#import "SDLNames.h" + +@implementation SDLSpeakResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_Speak]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLSpeechCapabilities.h b/SmartDeviceLink/SDLSpeechCapabilities.h new file mode 100644 index 000000000..9529e3fef --- /dev/null +++ b/SmartDeviceLink/SDLSpeechCapabilities.h @@ -0,0 +1,46 @@ +// SDLSpeechCapabilities.h +// + + +#import "SDLEnum.h" + +/* + * Contains information about TTS capabilities on the SDL platform. + * + * @since SDL 1.0 + */ +@interface SDLSpeechCapabilities : SDLEnum { +} + +/** + * @abstract get SDLSpeechCapabilities according value string + * + * @param value The value of the string to get an object for + * + * @return SDLSpeechCapabilities object + */ ++ (SDLSpeechCapabilities *)valueOf:(NSString *)value; + +/** + * @abstract declare an array to store all possible SDLSpeechCapabilities values + * + * @return the array of all possible values + */ ++ (NSArray *)values; + +/** + * @abstract The SDL platform can speak text phrases. + * + * @return SDLSpeechCapabilities of value: *TEXT* + */ ++ (SDLSpeechCapabilities *)TEXT; + ++ (SDLSpeechCapabilities *)SAPI_PHONEMES; + ++ (SDLSpeechCapabilities *)LHPLUS_PHONEMES; + ++ (SDLSpeechCapabilities *)PRE_RECORDED; + ++ (SDLSpeechCapabilities *)SILENCE; + +@end diff --git a/SmartDeviceLink/SDLSpeechCapabilities.m b/SmartDeviceLink/SDLSpeechCapabilities.m new file mode 100644 index 000000000..2018b8321 --- /dev/null +++ b/SmartDeviceLink/SDLSpeechCapabilities.m @@ -0,0 +1,74 @@ +// SDLSpeechCapabilities.m +// + + +#import "SDLSpeechCapabilities.h" + +SDLSpeechCapabilities *SDLSpeechCapabilities_TEXT = nil; +SDLSpeechCapabilities *SDLSpeechCapabilities_SAPI_PHONEMES = nil; +SDLSpeechCapabilities *SDLSpeechCapabilities_LHPLUS_PHONEMES = nil; +SDLSpeechCapabilities *SDLSpeechCapabilities_PRE_RECORDED = nil; +SDLSpeechCapabilities *SDLSpeechCapabilities_SILENCE = nil; + +NSArray *SDLSpeechCapabilities_values = nil; + +@implementation SDLSpeechCapabilities + ++ (SDLSpeechCapabilities *)valueOf:(NSString *)value { + for (SDLSpeechCapabilities *item in SDLSpeechCapabilities.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLSpeechCapabilities_values == nil) { + SDLSpeechCapabilities_values = @[ + SDLSpeechCapabilities.TEXT, + SDLSpeechCapabilities.SAPI_PHONEMES, + SDLSpeechCapabilities.LHPLUS_PHONEMES, + SDLSpeechCapabilities.PRE_RECORDED, + SDLSpeechCapabilities.SILENCE, + ]; + } + return SDLSpeechCapabilities_values; +} + ++ (SDLSpeechCapabilities *)TEXT { + if (SDLSpeechCapabilities_TEXT == nil) { + SDLSpeechCapabilities_TEXT = [[SDLSpeechCapabilities alloc] initWithValue:@"TEXT"]; + } + return SDLSpeechCapabilities_TEXT; +} + ++ (SDLSpeechCapabilities *)SAPI_PHONEMES { + if (SDLSpeechCapabilities_SAPI_PHONEMES == nil) { + SDLSpeechCapabilities_SAPI_PHONEMES = [[SDLSpeechCapabilities alloc] initWithValue:@"SAPI_PHONEMES"]; + } + return SDLSpeechCapabilities_SAPI_PHONEMES; +} + ++ (SDLSpeechCapabilities *)LHPLUS_PHONEMES { + if (SDLSpeechCapabilities_LHPLUS_PHONEMES == nil) { + SDLSpeechCapabilities_LHPLUS_PHONEMES = [[SDLSpeechCapabilities alloc] initWithValue:@"LHPLUS_PHONEMES"]; + } + return SDLSpeechCapabilities_LHPLUS_PHONEMES; +} + ++ (SDLSpeechCapabilities *)PRE_RECORDED { + if (SDLSpeechCapabilities_PRE_RECORDED == nil) { + SDLSpeechCapabilities_PRE_RECORDED = [[SDLSpeechCapabilities alloc] initWithValue:@"PRE_RECORDED"]; + } + return SDLSpeechCapabilities_PRE_RECORDED; +} + ++ (SDLSpeechCapabilities *)SILENCE { + if (SDLSpeechCapabilities_SILENCE == nil) { + SDLSpeechCapabilities_SILENCE = [[SDLSpeechCapabilities alloc] initWithValue:@"SILENCE"]; + } + return SDLSpeechCapabilities_SILENCE; +} + +@end diff --git a/SmartDeviceLink/SDLStartTime.h b/SmartDeviceLink/SDLStartTime.h new file mode 100644 index 000000000..55eb147d6 --- /dev/null +++ b/SmartDeviceLink/SDLStartTime.h @@ -0,0 +1,49 @@ +// SDLStartTime.h +// + + +#import "SDLRPCMessage.h" + +/** + * Describes the hour, minute and second values used to set the media clock. + * + * @since SDL 1.0 + */ +@interface SDLStartTime : SDLRPCStruct { +} + +/** + * @abstract Constructs a newly allocated SDLStartTime object + */ +- (instancetype)init; + +/** + * @abstract Constructs a newly allocated SDLStartTime object indicated by the dictionary parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract The hour of the media clock + * + * @discussion Some display types only support a max value of 19. If out of range, it will be rejected. + * + * Required, Integer, 0 - 59 + */ +@property (strong) NSNumber *hours; + +/** + * @abstract The minute of the media clock + * + * Required, Integer, 0 - 59 + */ +@property (strong) NSNumber *minutes; + +/** + * @abstract The second of the media clock + * + * Required, Integer, 0 - 59 + */ +@property (strong) NSNumber *seconds; + +@end diff --git a/SmartDeviceLink/SDLStartTime.m b/SmartDeviceLink/SDLStartTime.m new file mode 100644 index 000000000..4745bf712 --- /dev/null +++ b/SmartDeviceLink/SDLStartTime.m @@ -0,0 +1,59 @@ +// SDLStartTime.m +// + + +#import "SDLStartTime.h" + +#import "SDLNames.h" + +@implementation SDLStartTime + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setHours:(NSNumber *)hours { + if (hours != nil) { + [store setObject:hours forKey:NAMES_hours]; + } else { + [store removeObjectForKey:NAMES_hours]; + } +} + +- (NSNumber *)hours { + return [store objectForKey:NAMES_hours]; +} + +- (void)setMinutes:(NSNumber *)minutes { + if (minutes != nil) { + [store setObject:minutes forKey:NAMES_minutes]; + } else { + [store removeObjectForKey:NAMES_minutes]; + } +} + +- (NSNumber *)minutes { + return [store objectForKey:NAMES_minutes]; +} + +- (void)setSeconds:(NSNumber *)seconds { + if (seconds != nil) { + [store setObject:seconds forKey:NAMES_seconds]; + } else { + [store removeObjectForKey:NAMES_seconds]; + } +} + +- (NSNumber *)seconds { + return [store objectForKey:NAMES_seconds]; +} + +@end diff --git a/SmartDeviceLink/SDLStreamDelegate.h b/SmartDeviceLink/SDLStreamDelegate.h new file mode 100644 index 000000000..fdd8bfbac --- /dev/null +++ b/SmartDeviceLink/SDLStreamDelegate.h @@ -0,0 +1,22 @@ +// +// SDLStreamDelegate.h + +#import <Foundation/Foundation.h> + +// Convenience typedefs +typedef void (^SDLStreamOpenHandler)(NSStream *stream); +typedef void (^SDLStreamHasBytesHandler)(NSInputStream *istream); +typedef void (^SDLStreamHasSpaceHandler)(NSOutputStream *ostream); +typedef void (^SDLStreamErrorHandler)(NSStream *stream); +typedef void (^SDLStreamEndHandler)(NSStream *stream); + + +@interface SDLStreamDelegate : NSObject <NSStreamDelegate> + +@property (nonatomic, copy) SDLStreamOpenHandler streamOpenHandler; +@property (nonatomic, copy) SDLStreamHasBytesHandler streamHasBytesHandler; +@property (nonatomic, copy) SDLStreamHasSpaceHandler streamHasSpaceHandler; +@property (nonatomic, copy) SDLStreamErrorHandler streamErrorHandler; +@property (nonatomic, copy) SDLStreamEndHandler streamEndHandler; + +@end diff --git a/SmartDeviceLink/SDLStreamDelegate.m b/SmartDeviceLink/SDLStreamDelegate.m new file mode 100644 index 000000000..6c2db6c34 --- /dev/null +++ b/SmartDeviceLink/SDLStreamDelegate.m @@ -0,0 +1,92 @@ +// +// SDLtreamDelegate.m +// + +#import "SDLStreamDelegate.h" +#import "SDLDebugTool.h" + +@interface SDLStreamDelegate () { + dispatch_queue_t _input_stream_queue; +} + +@end + + +@implementation SDLStreamDelegate + +- (instancetype)init { + self = [super init]; + if (self) { + _streamOpenHandler = defaultStreamOpenHandler; + _streamHasBytesHandler = defaultStreamHasBytesHandler; + _streamHasSpaceHandler = defaultStreamHasSpaceHandler; + _streamErrorHandler = defaultStreamErrorHandler; + _streamEndHandler = defaultStreamErrorHandler; + + _input_stream_queue = dispatch_queue_create("com.sdl.streamdelegate.input", DISPATCH_QUEUE_SERIAL); + } + return self; +} + +- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode { + switch (eventCode) { + case NSStreamEventOpenCompleted: { + if (_streamOpenHandler) { + self.streamOpenHandler(stream); + } + break; + } + case NSStreamEventHasBytesAvailable: { + if (_streamHasBytesHandler) { + dispatch_async(_input_stream_queue, ^{ + self.streamHasBytesHandler((NSInputStream *)stream); + }); + } + break; + } + case NSStreamEventHasSpaceAvailable: { + if (_streamHasSpaceHandler) { + self.streamHasSpaceHandler((NSOutputStream *)stream); + } + break; + } + case NSStreamEventErrorOccurred: { + if (_streamErrorHandler) { + self.streamErrorHandler(stream); + } + break; + } + case NSStreamEventEndEncountered: { + if (_streamEndHandler) { + self.streamEndHandler(stream); + } + break; + } + case NSStreamEventNone: + default: { + break; + } + } +} + +SDLStreamOpenHandler defaultStreamOpenHandler = ^(NSStream *stream) { + [SDLDebugTool logInfo:@"Stream Event Open"]; +}; + +SDLStreamHasBytesHandler defaultStreamHasBytesHandler = ^(NSInputStream *istream) { + [SDLDebugTool logInfo:@"Stream Event Has Bytes"]; +}; + +SDLStreamHasSpaceHandler defaultStreamHasSpaceHandler = ^(NSOutputStream *ostream) { + +}; + +SDLStreamErrorHandler defaultStreamErrorHandler = ^(NSStream *stream) { + [SDLDebugTool logInfo:@"Stream Event Error"]; +}; + +SDLStreamEndHandler defaultStreamEndHandler = ^(NSStream *stream) { + [SDLDebugTool logInfo:@"Stream Event End"]; +}; + +@end diff --git a/SmartDeviceLink/SDLStreamingMediaManager.h b/SmartDeviceLink/SDLStreamingMediaManager.h new file mode 100644 index 000000000..05a855e13 --- /dev/null +++ b/SmartDeviceLink/SDLStreamingMediaManager.h @@ -0,0 +1,91 @@ +// +// SDLStreamingDataManager.h +// SmartDeviceLink-iOS +// +// Created by Joel Fischer on 8/11/15. +// Copyright (c) 2015 smartdevicelink. All rights reserved. +// + +#import <Foundation/Foundation.h> +@import VideoToolbox; + +#import "SDLProtocolListener.h" + +@class SDLAbstractProtocol; + + +NS_ASSUME_NONNULL_BEGIN + +typedef NS_ENUM(NSInteger, SDLStreamingVideoError) { + SDLStreamingVideoErrorHeadUnitNACK, + SDLSTreamingVideoErrorInvalidOperatingSystemVersion, + SDLStreamingVideoErrorConfigurationCompressionSessionCreationFailure, + SDLStreamingVideoErrorConfigurationAllocationFailure, + SDLStreamingVideoErrorConfigurationCompressionSessionSetPropertyFailure +}; + +typedef NS_ENUM(NSInteger, SDLStreamingAudioError) { + SDLStreamingAudioErrorHeadUnitNACK +}; + +extern NSString *const SDLErrorDomainStreamingMediaVideo; +extern NSString *const SDLErrorDomainStreamingMediaAudio; + +typedef void (^SDLStreamingStartBlock)(BOOL success, NSError *__nullable error); + + +@interface SDLStreamingMediaManager : NSObject <SDLProtocolListener> + +- (instancetype)initWithProtocol:(SDLAbstractProtocol *)protocol; + +/** + * This method will attempt to start a streaming video session. It will set up iOS's video encoder, and call out to the head unit asking if it will start a video session. + * + * @warning If this method is called on an 8.0 device, it will assert (in debug), or return a failure immediately to your block (in release). + * + * @param startBlock A block that will be called with the result of attempting to start a video session + */ +- (void)startVideoSessionWithStartBlock:(SDLStreamingStartBlock)startBlock; + +/** + * This method will stop a running video session if there is one running. + */ +- (void)stopVideoSession; + +/** + * This method receives raw image data and will run iOS8+'s hardware video encoder to turn the data into a video stream, which will then be passed to the connected head unit. + * + * @param imageBuffer A CVImageBufferRef to be encoded by Video Toolbox + * + * @return Whether or not the data was successfully encoded and sent. + */ +- (BOOL)sendVideoData:(CVImageBufferRef)imageBuffer; + +/** + * This method will attempt to start an audio session + * + * @param startBlock A block that will be called with the result of attempting to start an audio session + */ +- (void)startAudioStreamingWithStartBlock:(SDLStreamingStartBlock)startBlock; + +/** + * This method will stop a running audio session if there is one running. + */ +- (void)stopAudioSession; + +/** + * This method receives PCM audio data and will attempt to send that data across to the head unit for immediate playback + * + * @param pcmAudioData The data in PCM audio format, to be played + * + * @return Whether or not the data was successfully sent. + */ +- (BOOL)sendAudioData:(NSData *)pcmAudioData; + +@property (assign, nonatomic, readonly) BOOL videoSessionConnected; +@property (assign, nonatomic, readonly) BOOL audioSessionConnected; + + +@end + +NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLStreamingMediaManager.m b/SmartDeviceLink/SDLStreamingMediaManager.m new file mode 100644 index 000000000..9b7f5a8ac --- /dev/null +++ b/SmartDeviceLink/SDLStreamingMediaManager.m @@ -0,0 +1,411 @@ +// +// SDLStreamingDataManager.m +// SmartDeviceLink-iOS +// +// Created by Joel Fischer on 8/11/15. +// Copyright (c) 2015 smartdevicelink. All rights reserved. +// + +#import "SDLStreamingMediaManager.h" + +@import UIKit; + +#import "SDLAbstractProtocol.h" +#import "SDLGlobals.h" + + +NSString *const SDLErrorDomainStreamingMediaVideo = @"com.sdl.streamingmediamanager.video"; +NSString *const SDLErrorDomainStreamingMediaAudio = @"com.sdl.streamingmediamanager.audio"; + + +NS_ASSUME_NONNULL_BEGIN + +@interface SDLStreamingMediaManager () + +@property (assign, nonatomic, nullable) VTCompressionSessionRef compressionSession; + +@property (assign, nonatomic) NSUInteger currentFrameNumber; + +@property (assign, nonatomic, readwrite) BOOL videoSessionConnected; +@property (assign, nonatomic, readwrite) BOOL audioSessionConnected; + +@property (weak, nonatomic) SDLAbstractProtocol *protocol; + +@property (copy, nonatomic, nullable) SDLStreamingStartBlock videoStartBlock; +@property (copy, nonatomic, nullable) SDLStreamingStartBlock audioStartBlock; + +@end + + +@implementation SDLStreamingMediaManager + +#pragma mark - Class Lifecycle + +- (instancetype)initWithProtocol:(SDLAbstractProtocol *)protocol { + self = [super init]; + if (!self) { + return nil; + } + + _compressionSession = NULL; + + _currentFrameNumber = 0; + _videoSessionConnected = NO; + _audioSessionConnected = NO; + _protocol = protocol; + + _videoStartBlock = nil; + _audioStartBlock = nil; + + return self; +} + + +#pragma mark - Streaming media lifecycle + +- (void)startVideoSessionWithStartBlock:(SDLStreamingStartBlock)startBlock { + if (SDL_SYSTEM_VERSION_LESS_THAN(@"8.0")) { + NSAssert(NO, @"SDL Video Sessions can only be run on iOS 8+ devices"); + startBlock(NO, [NSError errorWithDomain:SDLErrorDomainStreamingMediaVideo code:SDLSTreamingVideoErrorInvalidOperatingSystemVersion userInfo:nil]); + + return; + } + + + self.videoStartBlock = [startBlock copy]; + + [self.protocol sendStartSessionWithType:SDLServiceType_Video]; +} + +- (void)stopVideoSession { + if (!self.videoSessionConnected) { + return; + } + + [self.protocol sendEndSessionWithType:SDLServiceType_Video]; +} + +- (void)startAudioStreamingWithStartBlock:(SDLStreamingStartBlock)startBlock { + self.audioStartBlock = [startBlock copy]; + + [self.protocol sendStartSessionWithType:SDLServiceType_Audio]; +} + +- (void)stopAudioSession { + if (!self.audioSessionConnected) { + return; + } + + [self.protocol sendEndSessionWithType:SDLServiceType_Audio]; +} + + +#pragma mark - Send media data + +- (BOOL)sendVideoData:(CVImageBufferRef)imageBuffer { + if (!self.videoSessionConnected) { + return NO; + } + + // TODO (Joel F.)[2015-08-17]: Somehow monitor connection to make sure we're not clogging the connection with data. + OSStatus status = VTCompressionSessionEncodeFrame(_compressionSession, imageBuffer, CMTimeMake(self.currentFrameNumber++, 30), kCMTimeInvalid, NULL, (__bridge void *)self, NULL); + + return (status == noErr); +} + +- (BOOL)sendAudioData:(NSData *)pcmAudioData { + if (!self.audioSessionConnected) { + return NO; + } + + dispatch_async([self.class sdl_streamingDataSerialQueue], ^{ + @autoreleasepool { + [self.protocol sendRawData:pcmAudioData withServiceType:SDLServiceType_Audio]; + } + }); + + return YES; +} + + +#pragma mark - SDLProtocolListener Methods + +- (void)handleProtocolStartSessionACK:(SDLServiceType)serviceType sessionID:(Byte)sessionID version:(Byte)version { + switch (serviceType) { + case SDLServiceType_Audio: { + self.audioSessionConnected = YES; + self.audioStartBlock(YES, nil); + self.audioStartBlock = nil; + } break; + case SDLServiceType_Video: { + NSError *error = nil; + BOOL success = [self sdl_configureVideoEncoderWithError:&error]; + + if (!success) { + [self sdl_teardownCompressionSession]; + self.videoStartBlock(NO, error); + self.videoStartBlock = nil; + + return; + } + + self.videoSessionConnected = YES; + self.videoStartBlock(YES, nil); + self.videoStartBlock = nil; + } break; + default: break; + } +} + +- (void)handleProtocolStartSessionNACK:(SDLServiceType)serviceType { + switch (serviceType) { + case SDLServiceType_Audio: { + NSError *error = [NSError errorWithDomain:SDLErrorDomainStreamingMediaAudio code:SDLStreamingAudioErrorHeadUnitNACK userInfo:nil]; + + self.audioStartBlock(NO, error); + self.audioStartBlock = nil; + } break; + case SDLServiceType_Video: { + NSError *error = [NSError errorWithDomain:SDLErrorDomainStreamingMediaVideo code:SDLStreamingVideoErrorHeadUnitNACK userInfo:nil]; + + self.videoStartBlock(NO, error); + self.videoStartBlock = nil; + } break; + default: break; + } +} + +- (void)handleProtocolEndSessionACK:(SDLServiceType)serviceType { + switch (serviceType) { + case SDLServiceType_Audio: { + self.audioSessionConnected = NO; + } break; + case SDLServiceType_Video: { + self.videoSessionConnected = NO; + [self sdl_teardownCompressionSession]; + } break; + default: break; + } +} + +- (void)handleProtocolEndSessionNACK:(SDLServiceType)serviceType { + // TODO (Joel F.)[2015-08-17]: This really, really shouldn't ever happen. Should we assert? Do nothing? We don't have any additional info on why this failed. +} + + +#pragma mark - Video Encoding + +#pragma mark Lifecycle + +- (void)sdl_teardownCompressionSession { + VTCompressionSessionInvalidate(self.compressionSession); + CFRelease(self.compressionSession); +} + + +#pragma mark Callbacks + +void sdl_videoEncoderOutputCallback(void *outputCallbackRefCon, void *sourceFrameRefCon, OSStatus status, VTEncodeInfoFlags infoFlags, CMSampleBufferRef sampleBuffer) { + // If there was an error in the encoding, drop the frame + if (status != noErr) { + NSLog(@"Error encoding video, err=%lld", (int64_t)status); + return; + } + + SDLStreamingMediaManager *mediaManager = (__bridge SDLStreamingMediaManager *)sourceFrameRefCon; + NSData *elementaryStreamData = [mediaManager.class sdl_encodeElementaryStreamWithSampleBuffer:sampleBuffer]; + [mediaManager.protocol sendRawData:elementaryStreamData withServiceType:SDLServiceType_Video]; +} + + +#pragma mark Configuration + +- (BOOL)sdl_configureVideoEncoderWithError:(NSError *__autoreleasing *)error { + OSStatus status; + + // Create a compression session + // TODO (Joel F.)[2015-08-18]: Dimensions should be from the Head Unit + status = VTCompressionSessionCreate(NULL, 640, 480, kCMVideoCodecType_H264, NULL, NULL, NULL, &sdl_videoEncoderOutputCallback, (__bridge void *)self, &_compressionSession); + + if (status != noErr) { + // TODO: Log the error + if (*error != nil) { + *error = [NSError errorWithDomain:SDLErrorDomainStreamingMediaVideo code:SDLStreamingVideoErrorConfigurationCompressionSessionCreationFailure userInfo:@{ @"OSStatus" : @(status) }]; + } + + return NO; + } + + // Set the bitrate of our video compression + int bitRate = 5000; + CFNumberRef bitRateNumRef = CFNumberCreate(NULL, kCFNumberSInt32Type, &bitRate); + if (bitRateNumRef == NULL) { + // TODO: Log & end session + if (*error != nil) { + *error = [NSError errorWithDomain:SDLErrorDomainStreamingMediaVideo code:SDLStreamingVideoErrorConfigurationAllocationFailure userInfo:nil]; + } + + return NO; + } + + status = VTSessionSetProperty(self.compressionSession, kVTCompressionPropertyKey_AverageBitRate, bitRateNumRef); + + // Release our bitrate number + CFRelease(bitRateNumRef); + bitRateNumRef = NULL; + + if (status != noErr) { + // TODO: Log & End session + if (*error != nil) { + *error = [NSError errorWithDomain:SDLErrorDomainStreamingMediaVideo code:SDLStreamingVideoErrorConfigurationCompressionSessionSetPropertyFailure userInfo:@{ @"OSStatus" : @(status) }]; + } + + return NO; + } + + // Set the profile level of the video stream + status = VTSessionSetProperty(self.compressionSession, kVTCompressionPropertyKey_ProfileLevel, kVTProfileLevel_H264_Baseline_AutoLevel); + if (status != noErr) { + if (*error != nil) { + *error = [NSError errorWithDomain:SDLErrorDomainStreamingMediaVideo code:SDLStreamingVideoErrorConfigurationCompressionSessionSetPropertyFailure userInfo:@{ @"OSStatus" : @(status) }]; + } + + return NO; + } + + // Set the session to compress in real time + status = VTSessionSetProperty(self.compressionSession, kVTCompressionPropertyKey_RealTime, kCFBooleanTrue); + if (status != noErr) { + if (*error != nil) { + *error = [NSError errorWithDomain:SDLErrorDomainStreamingMediaVideo code:SDLStreamingVideoErrorConfigurationCompressionSessionSetPropertyFailure userInfo:@{ @"OSStatus" : @(status) }]; + } + + return NO; + } + + // Set the key-frame interval + // TODO: This may be unnecessary, can the encoder do a better job than us? + int interval = 50; + CFNumberRef intervalNumRef = CFNumberCreate(NULL, kCFNumberSInt32Type, &interval); + if (intervalNumRef == NULL) { + if (*error != nil) { + *error = [NSError errorWithDomain:SDLErrorDomainStreamingMediaVideo code:SDLStreamingVideoErrorConfigurationAllocationFailure userInfo:nil]; + } + + return NO; + } + + status = VTSessionSetProperty(self.compressionSession, kVTCompressionPropertyKey_MaxKeyFrameInterval, intervalNumRef); + + CFRelease(intervalNumRef); + intervalNumRef = NULL; + + if (status != noErr) { + if (*error != nil) { + *error = [NSError errorWithDomain:SDLErrorDomainStreamingMediaVideo code:SDLStreamingVideoErrorConfigurationCompressionSessionSetPropertyFailure userInfo:@{ @"OSStatus" : @(status) }]; + } + + return NO; + } + + return YES; +} + +#pragma mark Elementary Stream Formatting + ++ (NSData *)sdl_encodeElementaryStreamWithSampleBuffer:(CMSampleBufferRef)sampleBuffer { + // Creating an elementaryStream: http://stackoverflow.com/questions/28396622/extracting-h264-from-cmblockbuffer + + NSMutableData *elementaryStream = [NSMutableData data]; + BOOL isIFrame = NO; + CFArrayRef attachmentsArray = CMSampleBufferGetSampleAttachmentsArray(sampleBuffer, 0); + + if (CFArrayGetCount(attachmentsArray)) { + CFBooleanRef notSync; + CFDictionaryRef dict = CFArrayGetValueAtIndex(attachmentsArray, 0); + BOOL keyExists = CFDictionaryGetValueIfPresent(dict, + kCMSampleAttachmentKey_NotSync, + (const void **)¬Sync); + + // Find out if the sample buffer contains an I-Frame (sync frame). If so we will write the SPS and PPS NAL units to the elementary stream. + isIFrame = !keyExists || !CFBooleanGetValue(notSync); + } + + // This is the start code that we will write to the elementary stream before every NAL unit + static const size_t startCodeLength = 4; + static const uint8_t startCode[] = {0x00, 0x00, 0x00, 0x01}; + + // Write the SPS and PPS NAL units to the elementary stream before every I-Frame + if (isIFrame) { + CMFormatDescriptionRef description = CMSampleBufferGetFormatDescription(sampleBuffer); + + // Find out how many parameter sets there are + size_t numberOfParameterSets; + CMVideoFormatDescriptionGetH264ParameterSetAtIndex(description, + 0, + NULL, + NULL, + &numberOfParameterSets, + NULL); + + // Write each parameter set to the elementary stream + for (int i = 0; i < numberOfParameterSets; i++) { + const uint8_t *parameterSetPointer; + size_t parameterSetLength; + CMVideoFormatDescriptionGetH264ParameterSetAtIndex(description, + i, + ¶meterSetPointer, + ¶meterSetLength, + NULL, + NULL); + + // Write the parameter set to the elementary stream + [elementaryStream appendBytes:startCode length:startCodeLength]; + [elementaryStream appendBytes:parameterSetPointer length:parameterSetLength]; + } + } + + // Get a pointer to the raw AVCC NAL unit data in the sample buffer + size_t blockBufferLength = 0; + char *bufferDataPointer = NULL; + CMBlockBufferRef blockBufferRef = CMSampleBufferGetDataBuffer(sampleBuffer); + + CMBlockBufferGetDataPointer(blockBufferRef, 0, NULL, &blockBufferLength, &bufferDataPointer); + + // Loop through all the NAL units in the block buffer and write them to the elementary stream with start codes instead of AVCC length headers + size_t bufferOffset = 0; + static const int AVCCHeaderLength = 4; + while (bufferOffset < blockBufferLength - AVCCHeaderLength) { + // Read the NAL unit length + uint32_t NALUnitLength = 0; + memcpy(&NALUnitLength, bufferDataPointer + bufferOffset, AVCCHeaderLength); + + // Convert the length value from Big-endian to Little-endian + NALUnitLength = CFSwapInt32BigToHost(NALUnitLength); + [elementaryStream appendBytes:startCode length:startCodeLength]; + + // Write the NAL unit without the AVCC length header to the elementary stream + [elementaryStream appendBytes:bufferDataPointer + bufferOffset + AVCCHeaderLength length:NALUnitLength]; + + // Move to the next NAL unit in the block buffer + bufferOffset += AVCCHeaderLength + NALUnitLength; + } + + return [elementaryStream copy]; +} + +#pragma mark - Private static singleton variables + ++ (dispatch_queue_t)sdl_streamingDataSerialQueue { + static dispatch_queue_t streamingDataQueue = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + streamingDataQueue = dispatch_queue_create("com.sdl.videoaudiostreaming.encoder", DISPATCH_QUEUE_SERIAL); + }); + + return streamingDataQueue; +} + +@end + +NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLSubscribeButton.h b/SmartDeviceLink/SDLSubscribeButton.h new file mode 100644 index 000000000..a01df2d16 --- /dev/null +++ b/SmartDeviceLink/SDLSubscribeButton.h @@ -0,0 +1,80 @@ +// SDLSubscribeButton.h +// + + +#import "SDLRPCRequest.h" + +@class SDLButtonName; + + +/** + * Establishes a subscription to button notifications for HMI buttons. Buttons + * are not necessarily physical buttons, but can also be "soft" buttons on a + * touch screen, depending on the display in the vehicle. Once subscribed to a + * particular button, an application will receive both + * SDLOnButtonEvent and SDLOnButtonPress notifications + * whenever that button is pressed. The application may also unsubscribe from + * notifications for a button by invoking the SDLUnsubscribeButton + * operation + * <p> + * When a button is depressed, an SDLOnButtonEvent notification is + * sent to the application with a ButtonEventMode of BUTTONDOWN. When that same + * button is released, an SDLOnButtonEvent notification is sent to the + * application with a ButtonEventMode of BUTTONUP + * <p> + * When the duration of a button depression (that is, time between depression + * and release) is less than two seconds, an SDLOnButtonPress + * notification is sent to the application (at the moment the button is + * released) with a ButtonPressMode of SHORT. When the duration is two or more + * seconds, an SDLOnButtonPress notification is sent to the + * application (at the moment the two seconds have elapsed) with a + * ButtonPressMode of LONG + * <p> + * The purpose of SDLOnButtonPress notifications is to allow for + * programmatic detection of long button presses similar to those used to store + * presets while listening to the radio, for example + * <p> + * When a button is depressed and released, the sequence in which notifications + * will be sent to the application is as follows: + * <p> + * For short presses:<br/> + * <ul> + * <li>OnButtonEvent (ButtonEventMode = BUTTONDOWN)</li> + * <li>OnButtonEvent (ButtonEventMode = BUTTONUP)</li> + * <li>OnButtonPress (ButtonPressMode = SHORT)</li> + * </ul> + * <p> + * For long presses:<br/> + * <ul> + * <li>OnButtonEvent (ButtonEventMode = BUTTONDOWN)</li> + * <li>OnButtonEvent (ButtonEventMode = BUTTONUP)</li> + * <li>OnButtonPress (ButtonPressMode = LONG)</li> + * </ul> + * <p> + * <b>HMILevel needs to be FULL, LIMITED or BACKGROUND</b> + * </p> + * + * Since SmartDeviceLink 1.0<br/> + * See SDLUnsubscribeButton + */ +@interface SDLSubscribeButton : SDLRPCRequest { +} + +/** + * @abstract Constructs a new SDLSubscribeButton object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLSubscribeButton object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract The name of the button to subscribe to + * @discussion An enum value, see <i>SDLButtonName</i> + */ +@property (strong) SDLButtonName *buttonName; + +@end diff --git a/SmartDeviceLink/SDLSubscribeButton.m b/SmartDeviceLink/SDLSubscribeButton.m new file mode 100644 index 000000000..58a28a797 --- /dev/null +++ b/SmartDeviceLink/SDLSubscribeButton.m @@ -0,0 +1,42 @@ +// SDLSubscribeButton.m +// + + +#import "SDLSubscribeButton.h" + +#import "SDLButtonName.h" +#import "SDLNames.h" + + +@implementation SDLSubscribeButton + +- (instancetype)init { + if (self = [super initWithName:NAMES_SubscribeButton]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setButtonName:(SDLButtonName *)buttonName { + if (buttonName != nil) { + [parameters setObject:buttonName forKey:NAMES_buttonName]; + } else { + [parameters removeObjectForKey:NAMES_buttonName]; + } +} + +- (SDLButtonName *)buttonName { + NSObject *obj = [parameters objectForKey:NAMES_buttonName]; + if (obj == nil || [obj isKindOfClass:SDLButtonName.class]) { + return (SDLButtonName *)obj; + } else { + return [SDLButtonName valueOf:(NSString *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLSubscribeButtonResponse.h b/SmartDeviceLink/SDLSubscribeButtonResponse.h new file mode 100644 index 000000000..b38eb5a27 --- /dev/null +++ b/SmartDeviceLink/SDLSubscribeButtonResponse.h @@ -0,0 +1,26 @@ +// SDLSubscribeButtonResponse.h +// + + +#import "SDLRPCResponse.h" + +/** + * SubscribeButton Response is sent, when SDLSubscribeButton has been called + * + * Since SmartDeviceLink 1.0 + */ +@interface SDLSubscribeButtonResponse : SDLRPCResponse { +} + +/** + * @abstract Constructs a new SDLSubscribeButtonResponse object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLSubscribeButtonResponse object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLSubscribeButtonResponse.m b/SmartDeviceLink/SDLSubscribeButtonResponse.m new file mode 100644 index 000000000..a70d58ede --- /dev/null +++ b/SmartDeviceLink/SDLSubscribeButtonResponse.m @@ -0,0 +1,23 @@ +// SDLSubscribeButtonResponse.m +// + + +#import "SDLSubscribeButtonResponse.h" + +#import "SDLNames.h" + +@implementation SDLSubscribeButtonResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_SubscribeButton]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLSubscribeVehicleData.h b/SmartDeviceLink/SDLSubscribeVehicleData.h new file mode 100644 index 000000000..e357cd484 --- /dev/null +++ b/SmartDeviceLink/SDLSubscribeVehicleData.h @@ -0,0 +1,139 @@ +// SDLSubscribeVehicleData.h +// + + +#import "SDLRPCRequest.h" + +/** + * Subscribes for specific published vehicle data items. The data will be only + * sent, if it has changed. The application will be notified by the + * onVehicleData notification whenever new data is available. The update rate is + * very much dependent on sensors, vehicle architecture and vehicle type. Be + * also prepared for the situation that a signal is not available on a vehicle + * <p> + * Function Group: Location, VehicleInfo and DrivingChara + * <p> + * <b>HMILevel needs to be FULL, LIMITED or BACKGROUND</b> + * </p> + * + * Since SmartDeviceLink 2.0<br/> + * See SDLUnsubscribeVehicleData SDLGetVehicleData + */ +@interface SDLSubscribeVehicleData : SDLRPCRequest { +} + +/** + * @abstract Constructs a new SDLSubscribeVehicleData object + */ +- (instancetype)init; + +/** + * @abstract Constructs a new SDLSubscribeVehicleData object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract A boolean value. If true, subscribes Gps data + */ +@property (strong) NSNumber *gps; + +/** + * @abstract A boolean value. If true, subscribes speed data + */ +@property (strong) NSNumber *speed; + +/** + * @abstract A boolean value. If true, subscribes rpm data + */ +@property (strong) NSNumber *rpm; + +/** + * @abstract A boolean value. If true, subscribes FuelLevel data + */ +@property (strong) NSNumber *fuelLevel; + +/** + * @abstract A boolean value. If true, subscribes fuelLevel_State data + */ +@property (strong) NSNumber *fuelLevel_State; + +/** + * @abstract A boolean value. If true, subscribes instantFuelConsumption data + */ +@property (strong) NSNumber *instantFuelConsumption; + +/** + * @abstract A boolean value. If true, subscribes externalTemperature data + */ +@property (strong) NSNumber *externalTemperature; + +/** + * @abstract A boolean value. If true, subscribes Currently selected gear data + */ +@property (strong) NSNumber *prndl; + +/** + * @abstract A boolean value. If true, subscribes tire pressure status data + */ +@property (strong) NSNumber *tirePressure; + +/** + * @abstract A boolean value. If true, subscribes odometer data + */ +@property (strong) NSNumber *odometer; + +/** + * @abstract A boolean value. If true, subscribes belt Status data + */ +@property (strong) NSNumber *beltStatus; + +/** + * @abstract A boolean value. If true, subscribes body Information data + */ +@property (strong) NSNumber *bodyInformation; + +/** + * @abstract A boolean value. If true, subscribes device Status data + */ +@property (strong) NSNumber *deviceStatus; + +/** + * @abstract A boolean value. If true, subscribes driver Braking data + */ +@property (strong) NSNumber *driverBraking; + +/** + * @abstract A boolean value. If true, subscribes wiper Status data + */ +@property (strong) NSNumber *wiperStatus; + +/** + * @abstract A boolean value. If true, subscribes Head Lamp Status data + */ +@property (strong) NSNumber *headLampStatus; + +/** + * @abstract A boolean value. If true, subscribes Engine Torque data + */ +@property (strong) NSNumber *engineTorque; + +/** + * @abstract A boolean value. If true, means the accPedalPosition data has been + * subscribed. + */ +@property (strong) NSNumber *accPedalPosition; + +/** + * @abstract A boolean value. If true, means the steeringWheelAngle data has been + * subscribed. + */ +@property (strong) NSNumber *steeringWheelAngle; +@property (strong) NSNumber *eCallInfo; +@property (strong) NSNumber *airbagStatus; +@property (strong) NSNumber *emergencyEvent; +@property (strong) NSNumber *clusterModeStatus; +@property (strong) NSNumber *myKey; + +@end diff --git a/SmartDeviceLink/SDLSubscribeVehicleData.m b/SmartDeviceLink/SDLSubscribeVehicleData.m new file mode 100644 index 000000000..55ec5e9d0 --- /dev/null +++ b/SmartDeviceLink/SDLSubscribeVehicleData.m @@ -0,0 +1,311 @@ +// SDLSubscribeVehicleData.m +// + + +#import "SDLSubscribeVehicleData.h" + +#import "SDLNames.h" + +@implementation SDLSubscribeVehicleData + +- (instancetype)init { + if (self = [super initWithName:NAMES_SubscribeVehicleData]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setGps:(NSNumber *)gps { + if (gps != nil) { + [parameters setObject:gps forKey:NAMES_gps]; + } else { + [parameters removeObjectForKey:NAMES_gps]; + } +} + +- (NSNumber *)gps { + return [parameters objectForKey:NAMES_gps]; +} + +- (void)setSpeed:(NSNumber *)speed { + if (speed != nil) { + [parameters setObject:speed forKey:NAMES_speed]; + } else { + [parameters removeObjectForKey:NAMES_speed]; + } +} + +- (NSNumber *)speed { + return [parameters objectForKey:NAMES_speed]; +} + +- (void)setRpm:(NSNumber *)rpm { + if (rpm != nil) { + [parameters setObject:rpm forKey:NAMES_rpm]; + } else { + [parameters removeObjectForKey:NAMES_rpm]; + } +} + +- (NSNumber *)rpm { + return [parameters objectForKey:NAMES_rpm]; +} + +- (void)setFuelLevel:(NSNumber *)fuelLevel { + if (fuelLevel != nil) { + [parameters setObject:fuelLevel forKey:NAMES_fuelLevel]; + } else { + [parameters removeObjectForKey:NAMES_fuelLevel]; + } +} + +- (NSNumber *)fuelLevel { + return [parameters objectForKey:NAMES_fuelLevel]; +} + +- (void)setFuelLevel_State:(NSNumber *)fuelLevel_State { + if (fuelLevel_State != nil) { + [parameters setObject:fuelLevel_State forKey:NAMES_fuelLevel_State]; + } else { + [parameters removeObjectForKey:NAMES_fuelLevel_State]; + } +} + +- (NSNumber *)fuelLevel_State { + return [parameters objectForKey:NAMES_fuelLevel_State]; +} + +- (void)setInstantFuelConsumption:(NSNumber *)instantFuelConsumption { + if (instantFuelConsumption != nil) { + [parameters setObject:instantFuelConsumption forKey:NAMES_instantFuelConsumption]; + } else { + [parameters removeObjectForKey:NAMES_instantFuelConsumption]; + } +} + +- (NSNumber *)instantFuelConsumption { + return [parameters objectForKey:NAMES_instantFuelConsumption]; +} + +- (void)setExternalTemperature:(NSNumber *)externalTemperature { + if (externalTemperature != nil) { + [parameters setObject:externalTemperature forKey:NAMES_externalTemperature]; + } else { + [parameters removeObjectForKey:NAMES_externalTemperature]; + } +} + +- (NSNumber *)externalTemperature { + return [parameters objectForKey:NAMES_externalTemperature]; +} + +- (void)setPrndl:(NSNumber *)prndl { + if (prndl != nil) { + [parameters setObject:prndl forKey:NAMES_prndl]; + } else { + [parameters removeObjectForKey:NAMES_prndl]; + } +} + +- (NSNumber *)prndl { + return [parameters objectForKey:NAMES_prndl]; +} + +- (void)setTirePressure:(NSNumber *)tirePressure { + if (tirePressure != nil) { + [parameters setObject:tirePressure forKey:NAMES_tirePressure]; + } else { + [parameters removeObjectForKey:NAMES_tirePressure]; + } +} + +- (NSNumber *)tirePressure { + return [parameters objectForKey:NAMES_tirePressure]; +} + +- (void)setOdometer:(NSNumber *)odometer { + if (odometer != nil) { + [parameters setObject:odometer forKey:NAMES_odometer]; + } else { + [parameters removeObjectForKey:NAMES_odometer]; + } +} + +- (NSNumber *)odometer { + return [parameters objectForKey:NAMES_odometer]; +} + +- (void)setBeltStatus:(NSNumber *)beltStatus { + if (beltStatus != nil) { + [parameters setObject:beltStatus forKey:NAMES_beltStatus]; + } else { + [parameters removeObjectForKey:NAMES_beltStatus]; + } +} + +- (NSNumber *)beltStatus { + return [parameters objectForKey:NAMES_beltStatus]; +} + +- (void)setBodyInformation:(NSNumber *)bodyInformation { + if (bodyInformation != nil) { + [parameters setObject:bodyInformation forKey:NAMES_bodyInformation]; + } else { + [parameters removeObjectForKey:NAMES_bodyInformation]; + } +} + +- (NSNumber *)bodyInformation { + return [parameters objectForKey:NAMES_bodyInformation]; +} + +- (void)setDeviceStatus:(NSNumber *)deviceStatus { + if (deviceStatus != nil) { + [parameters setObject:deviceStatus forKey:NAMES_deviceStatus]; + } else { + [parameters removeObjectForKey:NAMES_deviceStatus]; + } +} + +- (NSNumber *)deviceStatus { + return [parameters objectForKey:NAMES_deviceStatus]; +} + +- (void)setDriverBraking:(NSNumber *)driverBraking { + if (driverBraking != nil) { + [parameters setObject:driverBraking forKey:NAMES_driverBraking]; + } else { + [parameters removeObjectForKey:NAMES_driverBraking]; + } +} + +- (NSNumber *)driverBraking { + return [parameters objectForKey:NAMES_driverBraking]; +} + +- (void)setWiperStatus:(NSNumber *)wiperStatus { + if (wiperStatus != nil) { + [parameters setObject:wiperStatus forKey:NAMES_wiperStatus]; + } else { + [parameters removeObjectForKey:NAMES_wiperStatus]; + } +} + +- (NSNumber *)wiperStatus { + return [parameters objectForKey:NAMES_wiperStatus]; +} + +- (void)setHeadLampStatus:(NSNumber *)headLampStatus { + if (headLampStatus != nil) { + [parameters setObject:headLampStatus forKey:NAMES_headLampStatus]; + } else { + [parameters removeObjectForKey:NAMES_headLampStatus]; + } +} + +- (NSNumber *)headLampStatus { + return [parameters objectForKey:NAMES_headLampStatus]; +} + +- (void)setEngineTorque:(NSNumber *)engineTorque { + if (engineTorque != nil) { + [parameters setObject:engineTorque forKey:NAMES_engineTorque]; + } else { + [parameters removeObjectForKey:NAMES_engineTorque]; + } +} + +- (NSNumber *)engineTorque { + return [parameters objectForKey:NAMES_engineTorque]; +} + +- (void)setAccPedalPosition:(NSNumber *)accPedalPosition { + if (accPedalPosition != nil) { + [parameters setObject:accPedalPosition forKey:NAMES_accPedalPosition]; + } else { + [parameters removeObjectForKey:NAMES_accPedalPosition]; + } +} + +- (NSNumber *)accPedalPosition { + return [parameters objectForKey:NAMES_accPedalPosition]; +} + +- (void)setSteeringWheelAngle:(NSNumber *)steeringWheelAngle { + if (steeringWheelAngle != nil) { + [parameters setObject:steeringWheelAngle forKey:NAMES_steeringWheelAngle]; + } else { + [parameters removeObjectForKey:NAMES_steeringWheelAngle]; + } +} + +- (NSNumber *)steeringWheelAngle { + return [parameters objectForKey:NAMES_steeringWheelAngle]; +} + +- (void)setECallInfo:(NSNumber *)eCallInfo { + if (eCallInfo != nil) { + [parameters setObject:eCallInfo forKey:NAMES_eCallInfo]; + } else { + [parameters removeObjectForKey:NAMES_eCallInfo]; + } +} + +- (NSNumber *)eCallInfo { + return [parameters objectForKey:NAMES_eCallInfo]; +} + +- (void)setAirbagStatus:(NSNumber *)airbagStatus { + if (airbagStatus != nil) { + [parameters setObject:airbagStatus forKey:NAMES_airbagStatus]; + } else { + [parameters removeObjectForKey:NAMES_airbagStatus]; + } +} + +- (NSNumber *)airbagStatus { + return [parameters objectForKey:NAMES_airbagStatus]; +} + +- (void)setEmergencyEvent:(NSNumber *)emergencyEvent { + if (emergencyEvent != nil) { + [parameters setObject:emergencyEvent forKey:NAMES_emergencyEvent]; + } else { + [parameters removeObjectForKey:NAMES_emergencyEvent]; + } +} + +- (NSNumber *)emergencyEvent { + return [parameters objectForKey:NAMES_emergencyEvent]; +} + +- (void)setClusterModeStatus:(NSNumber *)clusterModeStatus { + if (clusterModeStatus != nil) { + [parameters setObject:clusterModeStatus forKey:NAMES_clusterModeStatus]; + } else { + [parameters removeObjectForKey:NAMES_clusterModeStatus]; + } +} + +- (NSNumber *)clusterModeStatus { + return [parameters objectForKey:NAMES_clusterModeStatus]; +} + +- (void)setMyKey:(NSNumber *)myKey { + if (myKey != nil) { + [parameters setObject:myKey forKey:NAMES_myKey]; + } else { + [parameters removeObjectForKey:NAMES_myKey]; + } +} + +- (NSNumber *)myKey { + return [parameters objectForKey:NAMES_myKey]; +} + +@end diff --git a/SmartDeviceLink/SDLSubscribeVehicleDataResponse.h b/SmartDeviceLink/SDLSubscribeVehicleDataResponse.h new file mode 100644 index 000000000..0b4f15ca7 --- /dev/null +++ b/SmartDeviceLink/SDLSubscribeVehicleDataResponse.h @@ -0,0 +1,130 @@ +// SDLSubscribeVehicleDataResponse.h +// + +#import "SDLRPCResponse.h" + +@class SDLVehicleDataResult; + + +/** + * Subscribe Vehicle Data Response is sent, when SDLSubscribeVehicleData has been called + * + * Since SmartDeviceLink 2.0 + */ +@interface SDLSubscribeVehicleDataResponse : SDLRPCResponse { +} + +/** + * @abstract Constructs a new SDLSubscribeVehicleDataResponse object + */ +- (instancetype)init; + +/** + * @abstract Constructs a new SDLSubscribeVehicleDataResponse object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + + +/** + * @abstract A SDLVehicleDataResult* value. See GPSData. + */ +@property (strong) SDLVehicleDataResult *gps; + +/** + * @abstract A SDLVehicleDataResult* value. The vehicle speed in kilometers per hour. + */ +@property (strong) SDLVehicleDataResult *speed; + +/** + * @abstract A SDLVehicleDataResult* value. The number of revolutions per minute of the engine. + */ +@property (strong) SDLVehicleDataResult *rpm; + +/** + * @abstract A SDLVehicleDataResult* value. The fuel level in the tank (percentage) + */ +@property (strong) SDLVehicleDataResult *fuelLevel; + +/** + * @abstract A SDLVehicleDataResult* value. The fuel level state. + */ +@property (strong) SDLVehicleDataResult *fuelLevel_State; + +/** + * @abstract A SDLVehicleDataResult* value. The instantaneous fuel consumption in microlitres. + */ +@property (strong) SDLVehicleDataResult *instantFuelConsumption; + +/** + * @abstract A SDLVehicleDataResult* value. The external temperature in degrees celsius. + */ +@property (strong) SDLVehicleDataResult *externalTemperature; + +/** + * @abstract A SDLVehicleDataResult* value. See PRNDL. + */ +@property (strong) SDLVehicleDataResult *prndl; + +/** + * @abstract A SDLVehicleDataResult* value. See TireStatus. + */ +@property (strong) SDLVehicleDataResult *tirePressure; + +/** + * @abstract A SDLVehicleDataResult* value. Odometer in km. + */ +@property (strong) SDLVehicleDataResult *odometer; + +/** + * @abstract A SDLVehicleDataResult* value. The status of the seat belts. + */ +@property (strong) SDLVehicleDataResult *beltStatus; + +/** + * @abstract A SDLVehicleDataResult* value. The body information including power modes. + */ +@property (strong) SDLVehicleDataResult *bodyInformation; + +/** + * @abstract A SDLVehicleDataResult* value. The device status including signal and battery strength. + */ +@property (strong) SDLVehicleDataResult *deviceStatus; + +/** + * @abstract A SDLVehicleDataResult* value. The status of the brake pedal. + */ +@property (strong) SDLVehicleDataResult *driverBraking; + +/** + * @abstract A SDLVehicleDataResult* value. The status of the wipers. + */ +@property (strong) SDLVehicleDataResult *wiperStatus; + +/** + * @abstract A SDLVehicleDataResult* value. Status of the head lamps. + */ +@property (strong) SDLVehicleDataResult *headLampStatus; + +/** + * @abstract A SDLVehicleDataResult* value. Torque value for engine (in Nm) on non-diesel variants. + */ +@property (strong) SDLVehicleDataResult *engineTorque; + +/** + * @abstract A SDLVehicleDataResult* value. Accelerator pedal position (percentage depressed) + */ +@property (strong) SDLVehicleDataResult *accPedalPosition; + +/** + * @abstract A SDLVehicleDataResult* value. Current angle of the steering wheel (in deg) + */ +@property (strong) SDLVehicleDataResult *steeringWheelAngle; +@property (strong) SDLVehicleDataResult *eCallInfo; +@property (strong) SDLVehicleDataResult *airbagStatus; +@property (strong) SDLVehicleDataResult *emergencyEvent; +@property (strong) SDLVehicleDataResult *clusterModes; +@property (strong) SDLVehicleDataResult *myKey; + +@end diff --git a/SmartDeviceLink/SDLSubscribeVehicleDataResponse.m b/SmartDeviceLink/SDLSubscribeVehicleDataResponse.m new file mode 100644 index 000000000..5afa5f1be --- /dev/null +++ b/SmartDeviceLink/SDLSubscribeVehicleDataResponse.m @@ -0,0 +1,433 @@ +// SDLSubscribeVehicleDataResponse.m +// + + +#import "SDLSubscribeVehicleDataResponse.h" + +#import "SDLNames.h" +#import "SDLVehicleDataResult.h" + + +@implementation SDLSubscribeVehicleDataResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_SubscribeVehicleData]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setGps:(SDLVehicleDataResult *)gps { + if (gps != nil) { + [parameters setObject:gps forKey:NAMES_gps]; + } else { + [parameters removeObjectForKey:NAMES_gps]; + } +} + +- (SDLVehicleDataResult *)gps { + NSObject *obj = [parameters objectForKey:NAMES_gps]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setSpeed:(SDLVehicleDataResult *)speed { + if (speed != nil) { + [parameters setObject:speed forKey:NAMES_speed]; + } else { + [parameters removeObjectForKey:NAMES_speed]; + } +} + +- (SDLVehicleDataResult *)speed { + NSObject *obj = [parameters objectForKey:NAMES_speed]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setRpm:(SDLVehicleDataResult *)rpm { + if (rpm != nil) { + [parameters setObject:rpm forKey:NAMES_rpm]; + } else { + [parameters removeObjectForKey:NAMES_rpm]; + } +} + +- (SDLVehicleDataResult *)rpm { + NSObject *obj = [parameters objectForKey:NAMES_rpm]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setFuelLevel:(SDLVehicleDataResult *)fuelLevel { + if (fuelLevel != nil) { + [parameters setObject:fuelLevel forKey:NAMES_fuelLevel]; + } else { + [parameters removeObjectForKey:NAMES_fuelLevel]; + } +} + +- (SDLVehicleDataResult *)fuelLevel { + NSObject *obj = [parameters objectForKey:NAMES_fuelLevel]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setFuelLevel_State:(SDLVehicleDataResult *)fuelLevel_State { + if (fuelLevel_State != nil) { + [parameters setObject:fuelLevel_State forKey:NAMES_fuelLevel_State]; + } else { + [parameters removeObjectForKey:NAMES_fuelLevel_State]; + } +} + +- (SDLVehicleDataResult *)fuelLevel_State { + NSObject *obj = [parameters objectForKey:NAMES_fuelLevel_State]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setInstantFuelConsumption:(SDLVehicleDataResult *)instantFuelConsumption { + if (instantFuelConsumption != nil) { + [parameters setObject:instantFuelConsumption forKey:NAMES_instantFuelConsumption]; + } else { + [parameters removeObjectForKey:NAMES_instantFuelConsumption]; + } +} + +- (SDLVehicleDataResult *)instantFuelConsumption { + NSObject *obj = [parameters objectForKey:NAMES_instantFuelConsumption]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setExternalTemperature:(SDLVehicleDataResult *)externalTemperature { + if (externalTemperature != nil) { + [parameters setObject:externalTemperature forKey:NAMES_externalTemperature]; + } else { + [parameters removeObjectForKey:NAMES_externalTemperature]; + } +} + +- (SDLVehicleDataResult *)externalTemperature { + NSObject *obj = [parameters objectForKey:NAMES_externalTemperature]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setPrndl:(SDLVehicleDataResult *)prndl { + if (prndl != nil) { + [parameters setObject:prndl forKey:NAMES_prndl]; + } else { + [parameters removeObjectForKey:NAMES_prndl]; + } +} + +- (SDLVehicleDataResult *)prndl { + NSObject *obj = [parameters objectForKey:NAMES_prndl]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setTirePressure:(SDLVehicleDataResult *)tirePressure { + if (tirePressure != nil) { + [parameters setObject:tirePressure forKey:NAMES_tirePressure]; + } else { + [parameters removeObjectForKey:NAMES_tirePressure]; + } +} + +- (SDLVehicleDataResult *)tirePressure { + NSObject *obj = [parameters objectForKey:NAMES_tirePressure]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setOdometer:(SDLVehicleDataResult *)odometer { + if (odometer != nil) { + [parameters setObject:odometer forKey:NAMES_odometer]; + } else { + [parameters removeObjectForKey:NAMES_odometer]; + } +} + +- (SDLVehicleDataResult *)odometer { + NSObject *obj = [parameters objectForKey:NAMES_odometer]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setBeltStatus:(SDLVehicleDataResult *)beltStatus { + if (beltStatus != nil) { + [parameters setObject:beltStatus forKey:NAMES_beltStatus]; + } else { + [parameters removeObjectForKey:NAMES_beltStatus]; + } +} + +- (SDLVehicleDataResult *)beltStatus { + NSObject *obj = [parameters objectForKey:NAMES_beltStatus]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setBodyInformation:(SDLVehicleDataResult *)bodyInformation { + if (bodyInformation != nil) { + [parameters setObject:bodyInformation forKey:NAMES_bodyInformation]; + } else { + [parameters removeObjectForKey:NAMES_bodyInformation]; + } +} + +- (SDLVehicleDataResult *)bodyInformation { + NSObject *obj = [parameters objectForKey:NAMES_bodyInformation]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setDeviceStatus:(SDLVehicleDataResult *)deviceStatus { + if (deviceStatus != nil) { + [parameters setObject:deviceStatus forKey:NAMES_deviceStatus]; + } else { + [parameters removeObjectForKey:NAMES_deviceStatus]; + } +} + +- (SDLVehicleDataResult *)deviceStatus { + NSObject *obj = [parameters objectForKey:NAMES_deviceStatus]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setDriverBraking:(SDLVehicleDataResult *)driverBraking { + if (driverBraking != nil) { + [parameters setObject:driverBraking forKey:NAMES_driverBraking]; + } else { + [parameters removeObjectForKey:NAMES_driverBraking]; + } +} + +- (SDLVehicleDataResult *)driverBraking { + NSObject *obj = [parameters objectForKey:NAMES_driverBraking]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setWiperStatus:(SDLVehicleDataResult *)wiperStatus { + if (wiperStatus != nil) { + [parameters setObject:wiperStatus forKey:NAMES_wiperStatus]; + } else { + [parameters removeObjectForKey:NAMES_wiperStatus]; + } +} + +- (SDLVehicleDataResult *)wiperStatus { + NSObject *obj = [parameters objectForKey:NAMES_wiperStatus]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setHeadLampStatus:(SDLVehicleDataResult *)headLampStatus { + if (headLampStatus != nil) { + [parameters setObject:headLampStatus forKey:NAMES_headLampStatus]; + } else { + [parameters removeObjectForKey:NAMES_headLampStatus]; + } +} + +- (SDLVehicleDataResult *)headLampStatus { + NSObject *obj = [parameters objectForKey:NAMES_headLampStatus]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setEngineTorque:(SDLVehicleDataResult *)engineTorque { + if (engineTorque != nil) { + [parameters setObject:engineTorque forKey:NAMES_engineTorque]; + } else { + [parameters removeObjectForKey:NAMES_engineTorque]; + } +} + +- (SDLVehicleDataResult *)engineTorque { + NSObject *obj = [parameters objectForKey:NAMES_engineTorque]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setAccPedalPosition:(SDLVehicleDataResult *)accPedalPosition { + if (accPedalPosition != nil) { + [parameters setObject:accPedalPosition forKey:NAMES_accPedalPosition]; + } else { + [parameters removeObjectForKey:NAMES_accPedalPosition]; + } +} + +- (SDLVehicleDataResult *)accPedalPosition { + NSObject *obj = [parameters objectForKey:NAMES_accPedalPosition]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setSteeringWheelAngle:(SDLVehicleDataResult *)steeringWheelAngle { + if (steeringWheelAngle != nil) { + [parameters setObject:steeringWheelAngle forKey:NAMES_steeringWheelAngle]; + } else { + [parameters removeObjectForKey:NAMES_steeringWheelAngle]; + } +} + +- (SDLVehicleDataResult *)steeringWheelAngle { + NSObject *obj = [parameters objectForKey:NAMES_steeringWheelAngle]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setECallInfo:(SDLVehicleDataResult *)eCallInfo { + if (eCallInfo != nil) { + [parameters setObject:eCallInfo forKey:NAMES_eCallInfo]; + } else { + [parameters removeObjectForKey:NAMES_eCallInfo]; + } +} + +- (SDLVehicleDataResult *)eCallInfo { + NSObject *obj = [parameters objectForKey:NAMES_eCallInfo]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setAirbagStatus:(SDLVehicleDataResult *)airbagStatus { + if (airbagStatus != nil) { + [parameters setObject:airbagStatus forKey:NAMES_airbagStatus]; + } else { + [parameters removeObjectForKey:NAMES_airbagStatus]; + } +} + +- (SDLVehicleDataResult *)airbagStatus { + NSObject *obj = [parameters objectForKey:NAMES_airbagStatus]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setEmergencyEvent:(SDLVehicleDataResult *)emergencyEvent { + if (emergencyEvent != nil) { + [parameters setObject:emergencyEvent forKey:NAMES_emergencyEvent]; + } else { + [parameters removeObjectForKey:NAMES_emergencyEvent]; + } +} + +- (SDLVehicleDataResult *)emergencyEvent { + NSObject *obj = [parameters objectForKey:NAMES_emergencyEvent]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setClusterModes:(SDLVehicleDataResult *)clusterModes { + if (clusterModes != nil) { + [parameters setObject:clusterModes forKey:NAMES_clusterModes]; + } else { + [parameters removeObjectForKey:NAMES_clusterModes]; + } +} + +- (SDLVehicleDataResult *)clusterModes { + NSObject *obj = [parameters objectForKey:NAMES_clusterModes]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setMyKey:(SDLVehicleDataResult *)myKey { + if (myKey != nil) { + [parameters setObject:myKey forKey:NAMES_myKey]; + } else { + [parameters removeObjectForKey:NAMES_myKey]; + } +} + +- (SDLVehicleDataResult *)myKey { + NSObject *obj = [parameters objectForKey:NAMES_myKey]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLSyncMsgVersion.h b/SmartDeviceLink/SDLSyncMsgVersion.h new file mode 100644 index 000000000..98b573eec --- /dev/null +++ b/SmartDeviceLink/SDLSyncMsgVersion.h @@ -0,0 +1,39 @@ +// SDLSyncMsgVersion.h +// + + +#import "SDLRPCMessage.h" + +/** + * Specifies the version number of the SDL V4 interface. This is used by both the application and SDL to declare what interface version each is using. + * + * @since SDL 1.0 + */ +@interface SDLSyncMsgVersion : SDLRPCStruct { +} + +/** + * @abstract Constructs a newly allocated SDLSyncMsgVersion object + */ +- (instancetype)init; + +/** + * @abstract Constructs a newly allocated SDLSyncMsgVersion object indicated by the dictionary parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract The major version indicates versions that is not-compatible to previous versions + * + * Required, Integer, 1 - 10 + */ +@property (strong) NSNumber *majorVersion; +/** + * @abstract The minor version indicates a change to a previous version that should still allow to be run on an older version (with limited functionality) + * + * Required, Integer, 0 - 1000 + */ +@property (strong) NSNumber *minorVersion; + +@end diff --git a/SmartDeviceLink/SDLSyncMsgVersion.m b/SmartDeviceLink/SDLSyncMsgVersion.m new file mode 100644 index 000000000..2d516539e --- /dev/null +++ b/SmartDeviceLink/SDLSyncMsgVersion.m @@ -0,0 +1,50 @@ +// SDLSyncMsgVersion.m +// + + +#import "SDLSyncMsgVersion.h" + +#import "SDLNames.h" + +@implementation SDLSyncMsgVersion + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setMajorVersion:(NSNumber *)majorVersion { + if (majorVersion != nil) { + [store setObject:majorVersion forKey:NAMES_majorVersion]; + } else { + [store removeObjectForKey:NAMES_majorVersion]; + } +} + +- (NSNumber *)majorVersion { + return [store objectForKey:NAMES_majorVersion]; +} + +- (void)setMinorVersion:(NSNumber *)minorVersion { + if (minorVersion != nil) { + [store setObject:minorVersion forKey:NAMES_minorVersion]; + } else { + [store removeObjectForKey:NAMES_minorVersion]; + } +} + +- (NSNumber *)minorVersion { + return [store objectForKey:NAMES_minorVersion]; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"%@.%@", self.majorVersion, self.minorVersion]; +} +@end diff --git a/SmartDeviceLink/SDLSyncPData.h b/SmartDeviceLink/SDLSyncPData.h new file mode 100644 index 000000000..e71ea600d --- /dev/null +++ b/SmartDeviceLink/SDLSyncPData.h @@ -0,0 +1,13 @@ +// SDLSyncPData.h +// + + +#import "SDLRPCRequest.h" + +@interface SDLSyncPData : SDLRPCRequest { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLSyncPData.m b/SmartDeviceLink/SDLSyncPData.m new file mode 100644 index 000000000..c8730a2f1 --- /dev/null +++ b/SmartDeviceLink/SDLSyncPData.m @@ -0,0 +1,23 @@ +// SDLSyncPData.m +// + + +#import "SDLSyncPData.h" + +#import "SDLNames.h" + +@implementation SDLSyncPData + +- (instancetype)init { + if (self = [super initWithName:NAMES_SyncPData]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLSyncPDataResponse.h b/SmartDeviceLink/SDLSyncPDataResponse.h new file mode 100644 index 000000000..25a12b74a --- /dev/null +++ b/SmartDeviceLink/SDLSyncPDataResponse.h @@ -0,0 +1,13 @@ +// SDLSyncPDataResponse.h +// + + +#import "SDLRPCResponse.h" + +@interface SDLSyncPDataResponse : SDLRPCResponse { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLSyncPDataResponse.m b/SmartDeviceLink/SDLSyncPDataResponse.m new file mode 100644 index 000000000..00edf14b1 --- /dev/null +++ b/SmartDeviceLink/SDLSyncPDataResponse.m @@ -0,0 +1,23 @@ +// SDLSyncPDataResponse.m +// + + +#import "SDLSyncPDataResponse.h" + +#import "SDLNames.h" + +@implementation SDLSyncPDataResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_SyncPData]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLSystemAction.h b/SmartDeviceLink/SDLSystemAction.h new file mode 100644 index 000000000..55371e87d --- /dev/null +++ b/SmartDeviceLink/SDLSystemAction.h @@ -0,0 +1,39 @@ +// SDLSystemAction.h +// + + +#import "SDLEnum.h" + +/** + * + * Enumeration that describes system actions that can be triggered. + */ +@interface SDLSystemAction : SDLEnum { +} + +/** + * Convert String to SDLSystemAction + * @param value String + * @return SDLSystemAction + */ ++ (SDLSystemAction *)valueOf:(NSString *)value; +/** + @abstract Store the enumeration of all possible SDLSystemAction + @return an array that store all possible SDLSystemAction + */ ++ (NSArray *)values; + +/** + @abstract Default_Action + */ ++ (SDLSystemAction *)DEFAULT_ACTION; +/** + @abstract Steal_Focus + */ ++ (SDLSystemAction *)STEAL_FOCUS; +/** + @abstract Keep_Context + */ ++ (SDLSystemAction *)KEEP_CONTEXT; + +@end diff --git a/SmartDeviceLink/SDLSystemAction.m b/SmartDeviceLink/SDLSystemAction.m new file mode 100644 index 000000000..15b34b08b --- /dev/null +++ b/SmartDeviceLink/SDLSystemAction.m @@ -0,0 +1,56 @@ +// SDLSystemAction.m +// + + +#import "SDLSystemAction.h" + +SDLSystemAction *SDLSystemAction_DEFAULT_ACTION = nil; +SDLSystemAction *SDLSystemAction_STEAL_FOCUS = nil; +SDLSystemAction *SDLSystemAction_KEEP_CONTEXT = nil; + +NSArray *SDLSystemAction_values = nil; + +@implementation SDLSystemAction + ++ (SDLSystemAction *)valueOf:(NSString *)value { + for (SDLSystemAction *item in SDLSystemAction.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLSystemAction_values == nil) { + SDLSystemAction_values = @[ + SDLSystemAction.DEFAULT_ACTION, + SDLSystemAction.STEAL_FOCUS, + SDLSystemAction.KEEP_CONTEXT, + ]; + } + return SDLSystemAction_values; +} + ++ (SDLSystemAction *)DEFAULT_ACTION { + if (SDLSystemAction_DEFAULT_ACTION == nil) { + SDLSystemAction_DEFAULT_ACTION = [[SDLSystemAction alloc] initWithValue:@"DEFAULT_ACTION"]; + } + return SDLSystemAction_DEFAULT_ACTION; +} + ++ (SDLSystemAction *)STEAL_FOCUS { + if (SDLSystemAction_STEAL_FOCUS == nil) { + SDLSystemAction_STEAL_FOCUS = [[SDLSystemAction alloc] initWithValue:@"STEAL_FOCUS"]; + } + return SDLSystemAction_STEAL_FOCUS; +} + ++ (SDLSystemAction *)KEEP_CONTEXT { + if (SDLSystemAction_KEEP_CONTEXT == nil) { + SDLSystemAction_KEEP_CONTEXT = [[SDLSystemAction alloc] initWithValue:@"KEEP_CONTEXT"]; + } + return SDLSystemAction_KEEP_CONTEXT; +} + +@end diff --git a/SmartDeviceLink/SDLSystemContext.h b/SmartDeviceLink/SDLSystemContext.h new file mode 100644 index 000000000..89e92e420 --- /dev/null +++ b/SmartDeviceLink/SDLSystemContext.h @@ -0,0 +1,70 @@ +// SDLSystemContext.h +// + + +#import "SDLEnum.h" + +/** + * Indicates whether or not a user-initiated interaction is in progress, and if so, in what mode (i.e. MENU or VR). + * + * @since SDL 1.0 + */ +@interface SDLSystemContext : SDLEnum { +} + +/** + * Convert String to SDLSystemContext + * + * @param value String value to retrieve the object for + * + * @return SDLSystemContext + */ ++ (SDLSystemContext *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLSystemContext + * + * @return an array that store all possible SDLSystemContext + */ ++ (NSArray *)values; + +/** + * @abstract No user interaction (user-initiated or app-initiated) is in progress. + * + * @return SDLSystemContext object of value *MAIN* + */ ++ (SDLSystemContext *)MAIN; + +/** + * @abstract VR-oriented, user-initiated or app-initiated interaction is in-progress. + * + * @return SDLSystemContext object of value *VRSESSION* + */ ++ (SDLSystemContext *)VRSESSION; + +/** + * @abstract Menu-oriented, user-initiated or app-initiated interaction is in-progress. + * + * @return SDLSystemContext object of value *MENU* + */ ++ (SDLSystemContext *)MENU; + +/** + * @abstract The app's display HMI is currently being obscured by either a system or other app's overlay. + * + * @return SDLSystemContext object of value *HMI_OBSCURED* + * + * @since SDL 2.0 + */ ++ (SDLSystemContext *)HMI_OBSCURED; + +/** + * @abstract Broadcast only to whichever app has an alert currently being displayed. + * + * @return SDLSystemContext object of value *ALERT* + * + * @since SDL 2.0 + */ ++ (SDLSystemContext *)ALERT; + +@end diff --git a/SmartDeviceLink/SDLSystemContext.m b/SmartDeviceLink/SDLSystemContext.m new file mode 100644 index 000000000..76c5c9f38 --- /dev/null +++ b/SmartDeviceLink/SDLSystemContext.m @@ -0,0 +1,74 @@ +// SDLSystemContext.m +// + + +#import "SDLSystemContext.h" + +SDLSystemContext *SDLSystemContext_MAIN = nil; +SDLSystemContext *SDLSystemContext_VRSESSION = nil; +SDLSystemContext *SDLSystemContext_MENU = nil; +SDLSystemContext *SDLSystemContext_HMI_OBSCURED = nil; +SDLSystemContext *SDLSystemContext_ALERT = nil; + +NSArray *SDLSystemContext_values = nil; + +@implementation SDLSystemContext + ++ (SDLSystemContext *)valueOf:(NSString *)value { + for (SDLSystemContext *item in SDLSystemContext.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLSystemContext_values == nil) { + SDLSystemContext_values = @[ + SDLSystemContext.MAIN, + SDLSystemContext.VRSESSION, + SDLSystemContext.MENU, + SDLSystemContext.HMI_OBSCURED, + SDLSystemContext.ALERT, + ]; + } + return SDLSystemContext_values; +} + ++ (SDLSystemContext *)MAIN { + if (SDLSystemContext_MAIN == nil) { + SDLSystemContext_MAIN = [[SDLSystemContext alloc] initWithValue:@"MAIN"]; + } + return SDLSystemContext_MAIN; +} + ++ (SDLSystemContext *)VRSESSION { + if (SDLSystemContext_VRSESSION == nil) { + SDLSystemContext_VRSESSION = [[SDLSystemContext alloc] initWithValue:@"VRSESSION"]; + } + return SDLSystemContext_VRSESSION; +} + ++ (SDLSystemContext *)MENU { + if (SDLSystemContext_MENU == nil) { + SDLSystemContext_MENU = [[SDLSystemContext alloc] initWithValue:@"MENU"]; + } + return SDLSystemContext_MENU; +} + ++ (SDLSystemContext *)HMI_OBSCURED { + if (SDLSystemContext_HMI_OBSCURED == nil) { + SDLSystemContext_HMI_OBSCURED = [[SDLSystemContext alloc] initWithValue:@"HMI_OBSCURED"]; + } + return SDLSystemContext_HMI_OBSCURED; +} + ++ (SDLSystemContext *)ALERT { + if (SDLSystemContext_ALERT == nil) { + SDLSystemContext_ALERT = [[SDLSystemContext alloc] initWithValue:@"ALERT"]; + } + return SDLSystemContext_ALERT; +} + +@end diff --git a/SmartDeviceLink/SDLSystemRequest.h b/SmartDeviceLink/SDLSystemRequest.h new file mode 100644 index 000000000..479b5d18e --- /dev/null +++ b/SmartDeviceLink/SDLSystemRequest.h @@ -0,0 +1,23 @@ +// SDLSystemRequest.h +// + +#import "SDLRPCRequest.h" + +@class SDLRequestType; + + +/** An asynchronous request from the device; binary data can be included in hybrid part of message for some requests<br> (such as HTTP, Proprietary, or Authentication requests) + * <p> + * @since SmartDeviceLink 3.0 + * + */ +@interface SDLSystemRequest : SDLRPCRequest { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) SDLRequestType *requestType; +@property (strong) NSString *fileName; + +@end diff --git a/SmartDeviceLink/SDLSystemRequest.m b/SmartDeviceLink/SDLSystemRequest.m new file mode 100644 index 000000000..836b44447 --- /dev/null +++ b/SmartDeviceLink/SDLSystemRequest.m @@ -0,0 +1,54 @@ +// SDLSystemRequest.m +// + + +#import "SDLSystemRequest.h" + +#import "SDLNames.h" +#import "SDLRequestType.h" + + +@implementation SDLSystemRequest + +- (instancetype)init { + if (self = [super initWithName:NAMES_SystemRequest]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setRequestType:(SDLRequestType *)requestType { + if (requestType != nil) { + [parameters setObject:requestType forKey:NAMES_requestType]; + } else { + [parameters removeObjectForKey:NAMES_requestType]; + } +} + +- (SDLRequestType *)requestType { + NSObject *obj = [parameters objectForKey:NAMES_requestType]; + if (obj == nil || [obj isKindOfClass:SDLRequestType.class]) { + return (SDLRequestType *)obj; + } else { + return [SDLRequestType valueOf:(NSString *)obj]; + } +} + +- (void)setFileName:(NSString *)fileName { + if (fileName != nil) { + [parameters setObject:fileName forKey:NAMES_fileName]; + } else { + [parameters removeObjectForKey:NAMES_fileName]; + } +} + +- (NSString *)fileName { + return [parameters objectForKey:NAMES_fileName]; +} + +@end diff --git a/SmartDeviceLink/SDLSystemRequestResponse.h b/SmartDeviceLink/SDLSystemRequestResponse.h new file mode 100644 index 000000000..4c99d605f --- /dev/null +++ b/SmartDeviceLink/SDLSystemRequestResponse.h @@ -0,0 +1,16 @@ +// SDLSystemRequestResponse.h +// + + +#import "SDLRPCResponse.h" + +/** SDLSystemRequestResponse is sent, when SDLSystemRequest has been called. + * Since<b>SmartDeviceLink 3.0</b> + */ +@interface SDLSystemRequestResponse : SDLRPCResponse { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLSystemRequestResponse.m b/SmartDeviceLink/SDLSystemRequestResponse.m new file mode 100644 index 000000000..ba563e561 --- /dev/null +++ b/SmartDeviceLink/SDLSystemRequestResponse.m @@ -0,0 +1,23 @@ +// SDLSystemRequestResponse.m +// + + +#import "SDLSystemRequestResponse.h" + +#import "SDLNames.h" + +@implementation SDLSystemRequestResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_SystemRequest]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLTBTState.h b/SmartDeviceLink/SDLTBTState.h new file mode 100644 index 000000000..397f500dd --- /dev/null +++ b/SmartDeviceLink/SDLTBTState.h @@ -0,0 +1,24 @@ +// SDLTBTState.h +// + + +#import "SDLEnum.h" + +@interface SDLTBTState : SDLEnum { +} + ++ (SDLTBTState *)valueOf:(NSString *)value; ++ (NSArray *)values; + ++ (SDLTBTState *)ROUTE_UPDATE_REQUEST; ++ (SDLTBTState *)ROUTE_ACCEPTED; ++ (SDLTBTState *)ROUTE_REFUSED; ++ (SDLTBTState *)ROUTE_CANCELLED; ++ (SDLTBTState *)ETA_REQUEST; ++ (SDLTBTState *)NEXT_TURN_REQUEST; ++ (SDLTBTState *)ROUTE_STATUS_REQUEST; ++ (SDLTBTState *)ROUTE_SUMMARY_REQUEST; ++ (SDLTBTState *)TRIP_STATUS_REQUEST; ++ (SDLTBTState *)ROUTE_UPDATE_REQUEST_TIMEOUT; + +@end diff --git a/SmartDeviceLink/SDLTBTState.m b/SmartDeviceLink/SDLTBTState.m new file mode 100644 index 000000000..0a2a23b8b --- /dev/null +++ b/SmartDeviceLink/SDLTBTState.m @@ -0,0 +1,119 @@ +// SDLTBTState.m +// + + +#import "SDLTBTState.h" + +SDLTBTState *SDLTBTState_ROUTE_UPDATE_REQUEST = nil; +SDLTBTState *SDLTBTState_ROUTE_ACCEPTED = nil; +SDLTBTState *SDLTBTState_ROUTE_REFUSED = nil; +SDLTBTState *SDLTBTState_ROUTE_CANCELLED = nil; +SDLTBTState *SDLTBTState_ETA_REQUEST = nil; +SDLTBTState *SDLTBTState_NEXT_TURN_REQUEST = nil; +SDLTBTState *SDLTBTState_ROUTE_STATUS_REQUEST = nil; +SDLTBTState *SDLTBTState_ROUTE_SUMMARY_REQUEST = nil; +SDLTBTState *SDLTBTState_TRIP_STATUS_REQUEST = nil; +SDLTBTState *SDLTBTState_ROUTE_UPDATE_REQUEST_TIMEOUT = nil; + +NSArray *SDLTBTState_values = nil; + +@implementation SDLTBTState + ++ (SDLTBTState *)valueOf:(NSString *)value { + for (SDLTBTState *item in SDLTBTState.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLTBTState_values == nil) { + SDLTBTState_values = @[ + SDLTBTState.ROUTE_UPDATE_REQUEST, + SDLTBTState.ROUTE_ACCEPTED, + SDLTBTState.ROUTE_REFUSED, + SDLTBTState.ROUTE_CANCELLED, + SDLTBTState.ETA_REQUEST, + SDLTBTState.NEXT_TURN_REQUEST, + SDLTBTState.ROUTE_STATUS_REQUEST, + SDLTBTState.ROUTE_SUMMARY_REQUEST, + SDLTBTState.TRIP_STATUS_REQUEST, + SDLTBTState.ROUTE_UPDATE_REQUEST_TIMEOUT, + ]; + } + return SDLTBTState_values; +} + ++ (SDLTBTState *)ROUTE_UPDATE_REQUEST { + if (SDLTBTState_ROUTE_UPDATE_REQUEST == nil) { + SDLTBTState_ROUTE_UPDATE_REQUEST = [[SDLTBTState alloc] initWithValue:@"ROUTE_UPDATE_REQUEST"]; + } + return SDLTBTState_ROUTE_UPDATE_REQUEST; +} + ++ (SDLTBTState *)ROUTE_ACCEPTED { + if (SDLTBTState_ROUTE_ACCEPTED == nil) { + SDLTBTState_ROUTE_ACCEPTED = [[SDLTBTState alloc] initWithValue:@"ROUTE_ACCEPTED"]; + } + return SDLTBTState_ROUTE_ACCEPTED; +} + ++ (SDLTBTState *)ROUTE_REFUSED { + if (SDLTBTState_ROUTE_REFUSED == nil) { + SDLTBTState_ROUTE_REFUSED = [[SDLTBTState alloc] initWithValue:@"ROUTE_REFUSED"]; + } + return SDLTBTState_ROUTE_REFUSED; +} + ++ (SDLTBTState *)ROUTE_CANCELLED { + if (SDLTBTState_ROUTE_CANCELLED == nil) { + SDLTBTState_ROUTE_CANCELLED = [[SDLTBTState alloc] initWithValue:@"ROUTE_CANCELLED"]; + } + return SDLTBTState_ROUTE_CANCELLED; +} + ++ (SDLTBTState *)ETA_REQUEST { + if (SDLTBTState_ETA_REQUEST == nil) { + SDLTBTState_ETA_REQUEST = [[SDLTBTState alloc] initWithValue:@"ETA_REQUEST"]; + } + return SDLTBTState_ETA_REQUEST; +} + ++ (SDLTBTState *)NEXT_TURN_REQUEST { + if (SDLTBTState_NEXT_TURN_REQUEST == nil) { + SDLTBTState_NEXT_TURN_REQUEST = [[SDLTBTState alloc] initWithValue:@"NEXT_TURN_REQUEST"]; + } + return SDLTBTState_NEXT_TURN_REQUEST; +} + ++ (SDLTBTState *)ROUTE_STATUS_REQUEST { + if (SDLTBTState_ROUTE_STATUS_REQUEST == nil) { + SDLTBTState_ROUTE_STATUS_REQUEST = [[SDLTBTState alloc] initWithValue:@"ROUTE_STATUS_REQUEST"]; + } + return SDLTBTState_ROUTE_STATUS_REQUEST; +} + ++ (SDLTBTState *)ROUTE_SUMMARY_REQUEST { + if (SDLTBTState_ROUTE_SUMMARY_REQUEST == nil) { + SDLTBTState_ROUTE_SUMMARY_REQUEST = [[SDLTBTState alloc] initWithValue:@"ROUTE_SUMMARY_REQUEST"]; + } + return SDLTBTState_ROUTE_SUMMARY_REQUEST; +} + ++ (SDLTBTState *)TRIP_STATUS_REQUEST { + if (SDLTBTState_TRIP_STATUS_REQUEST == nil) { + SDLTBTState_TRIP_STATUS_REQUEST = [[SDLTBTState alloc] initWithValue:@"TRIP_STATUS_REQUEST"]; + } + return SDLTBTState_TRIP_STATUS_REQUEST; +} + ++ (SDLTBTState *)ROUTE_UPDATE_REQUEST_TIMEOUT { + if (SDLTBTState_ROUTE_UPDATE_REQUEST_TIMEOUT == nil) { + SDLTBTState_ROUTE_UPDATE_REQUEST_TIMEOUT = [[SDLTBTState alloc] initWithValue:@"ROUTE_UPDATE_REQUEST_TIMEOUT"]; + } + return SDLTBTState_ROUTE_UPDATE_REQUEST_TIMEOUT; +} + +@end diff --git a/SmartDeviceLink/SDLTCPTransport.h b/SmartDeviceLink/SDLTCPTransport.h new file mode 100644 index 000000000..2c9f55805 --- /dev/null +++ b/SmartDeviceLink/SDLTCPTransport.h @@ -0,0 +1,13 @@ +// SDLTCPTransport.h +// + +#import "SDLAbstractTransport.h" + +@interface SDLTCPTransport : SDLAbstractTransport { + CFSocketRef socket; +} + +@property (strong, atomic) NSString *hostName; +@property (strong, atomic) NSString *portNumber; + +@end diff --git a/SmartDeviceLink/SDLTCPTransport.m b/SmartDeviceLink/SDLTCPTransport.m new file mode 100644 index 000000000..81fc9c555 --- /dev/null +++ b/SmartDeviceLink/SDLTCPTransport.m @@ -0,0 +1,175 @@ +// SDLTCPTransport.m +// + + +#import "SDLTCPTransport.h" +#import "SDLDebugTool.h" +#import "SDLHexUtility.h" +#import <errno.h> +#import <netdb.h> +#import <netinet/in.h> +#import <signal.h> +#import <stdio.h> +#import <sys/socket.h> +#import <sys/types.h> +#import <sys/wait.h> +#import <unistd.h> + + +// C function forward declarations. +int call_socket(const char *hostname, const char *port); +static void TCPCallback(CFSocketRef socket, CFSocketCallBackType type, CFDataRef address, const void *data, void *info); + +@interface SDLTCPTransport () { + BOOL _alreadyDestructed; + dispatch_queue_t _sendQueue; +} + +@end + + +@implementation SDLTCPTransport + +- (instancetype)init { + if (self = [super init]) { + _alreadyDestructed = NO; + _sendQueue = dispatch_queue_create("com.sdl.transport.tcp.transmit", DISPATCH_QUEUE_SERIAL); + [SDLDebugTool logInfo:@"SDLTCPTransport Init" + withType:SDLDebugType_Transport_iAP + toOutput:SDLDebugOutput_All + toGroup:self.debugConsoleGroupName]; + } + + return self; +} + + +- (void)connect { + [SDLDebugTool logInfo:@"Init" withType:SDLDebugType_Transport_TCP]; + + int sock_fd = call_socket([self.hostName UTF8String], [self.portNumber UTF8String]); + if (sock_fd < 0) { + [SDLDebugTool logInfo:@"Server Not Ready, Connection Failed" withType:SDLDebugType_Transport_TCP]; + return; + } + + CFSocketContext socketCtxt = {0, (__bridge void *)(self), NULL, NULL, NULL}; + socket = CFSocketCreateWithNative(kCFAllocatorDefault, sock_fd, kCFSocketDataCallBack | kCFSocketConnectCallBack, (CFSocketCallBack)&TCPCallback, &socketCtxt); + CFRunLoopSourceRef source = CFSocketCreateRunLoopSource(kCFAllocatorDefault, socket, 0); + CFRunLoopRef loop = CFRunLoopGetCurrent(); + CFRunLoopAddSource(loop, source, kCFRunLoopDefaultMode); + CFRelease(source); +} + +- (void)sendData:(NSData *)msgBytes { + dispatch_async(_sendQueue, ^{ + @autoreleasepool { + NSString *byteStr = [SDLHexUtility getHexString:msgBytes]; + [SDLDebugTool logInfo:[NSString stringWithFormat:@"Sent %lu bytes: %@", (unsigned long)msgBytes.length, byteStr] withType:SDLDebugType_Transport_TCP toOutput:SDLDebugOutput_DeviceConsole]; + + CFSocketError e = CFSocketSendData(socket, NULL, (__bridge CFDataRef)msgBytes, 10000); + if (e != kCFSocketSuccess) { + NSString *errorCause = nil; + switch (e) { + case kCFSocketTimeout: + errorCause = @"Socket Timeout Error."; + break; + + case kCFSocketError: + default: + errorCause = @"Socket Error."; + break; + } + + [SDLDebugTool logInfo:[NSString stringWithFormat:@"Socket sendData error: %@", errorCause] withType:SDLDebugType_Transport_TCP toOutput:SDLDebugOutput_DeviceConsole]; + } + } + }); +} + +- (void)destructObjects { + if (!_alreadyDestructed) { + _alreadyDestructed = YES; + if (socket != nil) { + CFSocketInvalidate(socket); + CFRelease(socket); + } + } +} + +- (void)disconnect { + [self dispose]; +} + +- (void)dispose { + [self destructObjects]; +} + +- (void)dealloc { + [self destructObjects]; +} + +@end + +// C functions +int call_socket(const char *hostname, const char *port) { + int status, sock; + struct addrinfo hints; + struct addrinfo *servinfo; + + memset(&hints, 0, sizeof hints); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + + //no host name?, no problem, get local host + if (hostname == nil) { + char localhost[128]; + gethostname(localhost, sizeof localhost); + hostname = (const char *)&localhost; + } + + //getaddrinfo setup + if ((status = getaddrinfo(hostname, port, &hints, &servinfo)) != 0) { + fprintf(stderr, "getaddrinfo error: %s\n", gai_strerror(status)); + return (-1); + } + + //get socket + if ((sock = socket(servinfo->ai_family, servinfo->ai_socktype, servinfo->ai_protocol)) < 0) + return (-1); + + //connect + if (connect(sock, servinfo->ai_addr, servinfo->ai_addrlen) < 0) { + close(sock); + return (-1); + } + + freeaddrinfo(servinfo); // free the linked-list + return (sock); +} + +static void TCPCallback(CFSocketRef socket, CFSocketCallBackType type, CFDataRef address, const void *data, void *info) { + if (kCFSocketConnectCallBack == type) { + SDLTCPTransport *transport = (__bridge SDLTCPTransport *)info; + SInt32 errorNumber = 0; + if (data) { + SInt32 *errorNumberPtr = (SInt32 *)data; + errorNumber = *errorNumberPtr; + } + [transport.delegate onTransportConnected]; + } else if (kCFSocketDataCallBack == type) { + SDLTCPTransport *transport = (__bridge SDLTCPTransport *)info; + + NSMutableString *byteStr = [NSMutableString stringWithCapacity:((int)CFDataGetLength((CFDataRef)data) * 2)]; + for (int i = 0; i < (int)CFDataGetLength((CFDataRef)data); i++) { + [byteStr appendFormat:@"%02X", ((Byte *)(UInt8 *)CFDataGetBytePtr((CFDataRef)data))[i]]; + } + + [SDLDebugTool logInfo:[NSString stringWithFormat:@"Read %d bytes: %@", (int)CFDataGetLength((CFDataRef)data), byteStr] withType:SDLDebugType_Transport_TCP toOutput:SDLDebugOutput_DeviceConsole]; + + [transport.delegate onDataReceived:[NSData dataWithBytes:(UInt8 *)CFDataGetBytePtr((CFDataRef)data) length:(int)CFDataGetLength((CFDataRef)data)]]; + } else { + NSString *logMessage = [NSString stringWithFormat:@"unhandled TCPCallback: %lu", type]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_Transport_TCP toOutput:SDLDebugOutput_DeviceConsole]; + } +} diff --git a/SmartDeviceLink/SDLTTSChunk.h b/SmartDeviceLink/SDLTTSChunk.h new file mode 100644 index 000000000..a304c3d99 --- /dev/null +++ b/SmartDeviceLink/SDLTTSChunk.h @@ -0,0 +1,69 @@ +// SDLTTSChunk.h +// + +#import "SDLRPCMessage.h" + +@class SDLSpeechCapabilities; + + +/** + * Specifies what is to be spoken. This can be simply a text phrase, which SDL will speak according to its own rules. It can also be phonemes from either the Microsoft SAPI phoneme set, or from the LHPLUS phoneme set. It can also be a pre-recorded sound in WAV format (either developer-defined, or provided by the SDL platform). + * + * In SDL, words, and therefore sentences, can be built up from phonemes and are used to explicitly provide the proper pronounciation to the TTS engine. For example, to have SDL pronounce the word "read" as "red", rather than as when it is pronounced like "reed", the developer would use phonemes to express this desired pronounciation. + * + * For more information about phonemes, see <a href="http://en.wikipedia.org/wiki/Phoneme">http://en.wikipedia.org/wiki/Phoneme</a>. + * + * Parameter List + * <table border="1" rules="all"> + * <tr> + * <th>Name</th> + * <th>Type</th> + * <th>Description</th> + * <th>SmartDeviceLink Ver. Available</th> + * </tr> + * <tr> + * <td>text</td> + * <td>String</td> + * <td>Text to be spoken, or a phoneme specification, or the name of a pre-recorded sound. The contents of this field are indicated by the "type" field.</td> + * <td>SmartDeviceLink 1.0</td> + * </tr> + * <tr> + * <td>type</td> + * <td>SpeechCapabilities</td> + * <td>Indicates the type of information in the "text" field (e.g. phrase to be spoken, phoneme specification, name of pre-recorded sound). </td> + * <td>SmartDeviceLink 1.0</td> + * </tr> + * </table> + * + * @since SmartDeviceLink 1.0 + */ +@interface SDLTTSChunk : SDLRPCStruct { +} + +/** + * @abstract Constructs a newly allocated SDLTTSChunk object + */ +- (instancetype)init; + +/** + * @abstract Constructs a newly allocated SDLTTSChunk object indicated by the dictionary parameter + * + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract Text to be spoken, or a phoneme specification, or the name of a pre-recorded sound. The contents of this field are indicated by the "type" field. + * + * Required, Max length 500 + */ +@property (strong) NSString *text; + +/** + * @abstract The type of information in the "text" field (e.g. phrase to be spoken, phoneme specification, name of pre-recorded sound). + * + * Required + */ +@property (strong) SDLSpeechCapabilities *type; + +@end diff --git a/SmartDeviceLink/SDLTTSChunk.m b/SmartDeviceLink/SDLTTSChunk.m new file mode 100644 index 000000000..7e45413eb --- /dev/null +++ b/SmartDeviceLink/SDLTTSChunk.m @@ -0,0 +1,53 @@ +// SDLTTSChunk.m +// + +#import "SDLTTSChunk.h" + +#import "SDLNames.h" +#import "SDLSpeechCapabilities.h" + + +@implementation SDLTTSChunk + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setText:(NSString *)text { + if (text != nil) { + [store setObject:text forKey:NAMES_text]; + } else { + [store removeObjectForKey:NAMES_text]; + } +} + +- (NSString *)text { + return [store objectForKey:NAMES_text]; +} + +- (void)setType:(SDLSpeechCapabilities *)type { + if (type != nil) { + [store setObject:type forKey:NAMES_type]; + } else { + [store removeObjectForKey:NAMES_type]; + } +} + +- (SDLSpeechCapabilities *)type { + NSObject *obj = [store objectForKey:NAMES_type]; + if (obj == nil || [obj isKindOfClass:SDLSpeechCapabilities.class]) { + return (SDLSpeechCapabilities *)obj; + } else { + return [SDLSpeechCapabilities valueOf:(NSString *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLTTSChunkFactory.h b/SmartDeviceLink/SDLTTSChunkFactory.h new file mode 100644 index 000000000..466ae2bae --- /dev/null +++ b/SmartDeviceLink/SDLTTSChunkFactory.h @@ -0,0 +1,16 @@ +// SDLTTSChunkFactory.h +// + +#import <Foundation/Foundation.h> + +@class SDLTTSChunk; +@class SDLSpeechCapabilities; + + +@interface SDLTTSChunkFactory : NSObject { +} + ++ (SDLTTSChunk *)buildTTSChunkForString:(NSString *)text type:(SDLSpeechCapabilities *)type; ++ (NSMutableArray *)buildTTSChunksFromSimple:(NSString *)simple; + +@end diff --git a/SmartDeviceLink/SDLTTSChunkFactory.m b/SmartDeviceLink/SDLTTSChunkFactory.m new file mode 100644 index 000000000..c27983d3a --- /dev/null +++ b/SmartDeviceLink/SDLTTSChunkFactory.m @@ -0,0 +1,27 @@ +// SDLTTSChunkFactory.m +// + +#import "SDLTTSChunkFactory.h" + +#import "SDLSpeechCapabilities.h" +#import "SDLTTSChunk.h" + + +@implementation SDLTTSChunkFactory + ++ (SDLTTSChunk *)buildTTSChunkForString:(NSString *)text type:(SDLSpeechCapabilities *)type { + SDLTTSChunk *ret = [[SDLTTSChunk alloc] init]; + ret.text = text; + ret.type = type; + + return ret; +} + ++ (NSMutableArray *)buildTTSChunksFromSimple:(NSString *)simple { + if (simple == nil) + return nil; + + return [NSMutableArray arrayWithObject:[SDLTTSChunkFactory buildTTSChunkForString:simple type:[SDLSpeechCapabilities TEXT]]]; +} + +@end diff --git a/SmartDeviceLink/SDLTextAlignment.h b/SmartDeviceLink/SDLTextAlignment.h new file mode 100644 index 000000000..0d9913e86 --- /dev/null +++ b/SmartDeviceLink/SDLTextAlignment.h @@ -0,0 +1,52 @@ +// SDLTextAlignment.h +// + + +#import "SDLEnum.h" + +/** + * The list of possible alignments of text in a field. May only work on some display types. + * + * @since SDL 1.0 + */ +@interface SDLTextAlignment : SDLEnum { +} + +/** + * Convert String to SDLTextAlignment + * + * @param value The value of the string to get an object for + * + * @return SDLTextAlignment + */ ++ (SDLTextAlignment *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLTextAlignment + * + * @return an array that store all possible SDLTextAlignment + */ ++ (NSArray *)values; + +/** + * @abstract Text aligned left. + * + * @return A SDLTextAlignment object with value of *LEFT_ALIGNED* + */ ++ (SDLTextAlignment *)LEFT_ALIGNED; + +/** + * @abstract Text aligned right. + * + * @return A SDLTextAlignment object with value of *RIGHT_ALIGNED* + */ ++ (SDLTextAlignment *)RIGHT_ALIGNED; + +/** + * @abstract Text aligned centered. + * + * @return A SDLTextAlignment object with value of *CENTERED* + */ ++ (SDLTextAlignment *)CENTERED; + +@end diff --git a/SmartDeviceLink/SDLTextAlignment.m b/SmartDeviceLink/SDLTextAlignment.m new file mode 100644 index 000000000..30560f4a2 --- /dev/null +++ b/SmartDeviceLink/SDLTextAlignment.m @@ -0,0 +1,56 @@ +// SDLTextAlignment.m +// + + +#import "SDLTextAlignment.h" + +SDLTextAlignment *SDLTextAlignment_LEFT_ALIGNED = nil; +SDLTextAlignment *SDLTextAlignment_RIGHT_ALIGNED = nil; +SDLTextAlignment *SDLTextAlignment_CENTERED = nil; + +NSArray *SDLTextAlignment_values = nil; + +@implementation SDLTextAlignment + ++ (SDLTextAlignment *)valueOf:(NSString *)value { + for (SDLTextAlignment *item in SDLTextAlignment.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLTextAlignment_values == nil) { + SDLTextAlignment_values = @[ + SDLTextAlignment.LEFT_ALIGNED, + SDLTextAlignment.RIGHT_ALIGNED, + SDLTextAlignment.CENTERED, + ]; + } + return SDLTextAlignment_values; +} + ++ (SDLTextAlignment *)LEFT_ALIGNED { + if (SDLTextAlignment_LEFT_ALIGNED == nil) { + SDLTextAlignment_LEFT_ALIGNED = [[SDLTextAlignment alloc] initWithValue:@"LEFT_ALIGNED"]; + } + return SDLTextAlignment_LEFT_ALIGNED; +} + ++ (SDLTextAlignment *)RIGHT_ALIGNED { + if (SDLTextAlignment_RIGHT_ALIGNED == nil) { + SDLTextAlignment_RIGHT_ALIGNED = [[SDLTextAlignment alloc] initWithValue:@"RIGHT_ALIGNED"]; + } + return SDLTextAlignment_RIGHT_ALIGNED; +} + ++ (SDLTextAlignment *)CENTERED { + if (SDLTextAlignment_CENTERED == nil) { + SDLTextAlignment_CENTERED = [[SDLTextAlignment alloc] initWithValue:@"CENTERED"]; + } + return SDLTextAlignment_CENTERED; +} + +@end diff --git a/SmartDeviceLink/SDLTextField.h b/SmartDeviceLink/SDLTextField.h new file mode 100644 index 000000000..7af898fe5 --- /dev/null +++ b/SmartDeviceLink/SDLTextField.h @@ -0,0 +1,106 @@ +// SDLTextField.h +// + +#import "SDLRPCMessage.h" + +@class SDLCharacterSet; +@class SDLTextFieldName; + + +/** + * Struct defining the characteristics of a displayed field on the HMI. + * + * Parameter List + * <table border="1" rules="all"> + * <tr> + * <th>Name</th> + * <th>Type</th> + * <th>Description</th> + * <th>SmartDeviceLink Ver. Available</th> + * </tr> + * <tr> + * <td>name</td> + * <td>TextFieldName</td> + * <td>Enumeration identifying the field. </td> + * <td>SDL 1.0</td> + * </tr> + * <tr> + * <td>characterSet</td> + * <td>CharacterSet</td> + * <td>The character set that is supported in this field. </td> + * <td>SDL 1.0</td> + * </tr> + * <tr> + * <td>width</td> + * <td>Int16</td> + * <td>The number of characters in one row of this field. + * <ul> + * <li>Minvalue="1"</li> + * <li>maxvalue="500"</li> + * </ul> + * </td> + * <td>SDL 1.0</td> + * </tr> + * <tr> + * <td>rows</td> + * <td>Int16</td> + * <td>The number of rows for this text field. + * <ul> + * <li>Minvalue="1"</li> + * <li>maxvalue="3"</li> + * </ul> + * </td> + * <td>SDL 1.0</td> + * </tr> + * </table> + * + * @since SDL 1.0 + */ +@interface SDLTextField : SDLRPCStruct { +} + +/** + * @abstract Constructs a newly allocated SDLTextField object + */ +- (instancetype)init; + +/** + * @abstract Constructs a newly allocated SDLTextField object indicated by the dictionary parameter + * + * @param dict The dictionary to use to construct the object + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract The enumeration identifying the field. + * + * @see SDLTextFieldName + * + * Required + */ +@property (strong) SDLTextFieldName *name; + +/** + * @abstract The character set that is supported in this field. + * + * @see SDLCharacterSet + * + * Required + */ +@property (strong) SDLCharacterSet *characterSet; + +/** + * @abstract The number of characters in one row of this field. + * + * Required, Integer 1 - 500 + */ +@property (strong) NSNumber *width; + +/** + * @abstract The number of rows for this text field. + * + * Required, Integer 1 - 8 + */ +@property (strong) NSNumber *rows; + +@end diff --git a/SmartDeviceLink/SDLTextField.m b/SmartDeviceLink/SDLTextField.m new file mode 100644 index 000000000..926d258f1 --- /dev/null +++ b/SmartDeviceLink/SDLTextField.m @@ -0,0 +1,83 @@ +// SDLTextField.m +// + +#import "SDLTextField.h" + +#import "SDLCharacterSet.h" +#import "SDLNames.h" +#import "SDLTextFieldName.h" + + +@implementation SDLTextField + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setName:(SDLTextFieldName *)name { + if (name != nil) { + [store setObject:name forKey:NAMES_name]; + } else { + [store removeObjectForKey:NAMES_name]; + } +} + +- (SDLTextFieldName *)name { + NSObject *obj = [store objectForKey:NAMES_name]; + if (obj == nil || [obj isKindOfClass:SDLTextFieldName.class]) { + return (SDLTextFieldName *)obj; + } else { + return [SDLTextFieldName valueOf:(NSString *)obj]; + } +} + +- (void)setCharacterSet:(SDLCharacterSet *)characterSet { + if (characterSet != nil) { + [store setObject:characterSet forKey:NAMES_characterSet]; + } else { + [store removeObjectForKey:NAMES_characterSet]; + } +} + +- (SDLCharacterSet *)characterSet { + NSObject *obj = [store objectForKey:NAMES_characterSet]; + if (obj == nil || [obj isKindOfClass:SDLCharacterSet.class]) { + return (SDLCharacterSet *)obj; + } else { + return [SDLCharacterSet valueOf:(NSString *)obj]; + } +} + +- (void)setWidth:(NSNumber *)width { + if (width != nil) { + [store setObject:width forKey:NAMES_width]; + } else { + [store removeObjectForKey:NAMES_width]; + } +} + +- (NSNumber *)width { + return [store objectForKey:NAMES_width]; +} + +- (void)setRows:(NSNumber *)rows { + if (rows != nil) { + [store setObject:rows forKey:NAMES_rows]; + } else { + [store removeObjectForKey:NAMES_rows]; + } +} + +- (NSNumber *)rows { + return [store objectForKey:NAMES_rows]; +} + +@end diff --git a/SmartDeviceLink/SDLTextFieldName.h b/SmartDeviceLink/SDLTextFieldName.h new file mode 100644 index 000000000..8fc4c9def --- /dev/null +++ b/SmartDeviceLink/SDLTextFieldName.h @@ -0,0 +1,267 @@ +// SDLTextFieldName.h +// + + +#import "SDLEnum.h" + +/** + * Names of the text fields that can appear on a SDL display. + * + * @since SDL 1.0 + */ +@interface SDLTextFieldName : SDLEnum { +} + +/** + * Convert String to SDLTextFieldName + * + * @param value String value to retrieve the object for + * + * @return SDLTextFieldName + */ ++ (SDLTextFieldName *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLTextFieldName + * + * @return an array that store all possible SDLTextFieldName + */ ++ (NSArray *)values; + +/** + * @abstract The first line of the first set of main fields of the persistent display. Applies to SDLShow. + * + * @return a SDLTextFieldName with value of *mainField1* + */ ++ (SDLTextFieldName *)mainField1; + +/** + * @abstract The second line of the first set of main fields of the persistent display. Applies to SDLShow. + * + * @return a SDLTextFieldName with value of *mainField2* + * + * @since SDL 2.0 + */ ++ (SDLTextFieldName *)mainField2; + +/** + * @abstract The first line of the second set of main fields of the persistent display. Applies to SDLShow. + * + * @return a SDLTextFieldName with value of *mainField3* + * + * @since SDL 2.0 + */ ++ (SDLTextFieldName *)mainField3; + +/** + * @abstract The second line of the second set of main fields of the persistent display. Applies to SDLShow. + * + * @return a SDLTextFieldName with value of *mainField4* + */ ++ (SDLTextFieldName *)mainField4; + +/** + * @abstract The status bar on the NGN display. Applies to SDLShow. + * + * @return a SDLTextFieldName with value of *statusBar* + */ ++ (SDLTextFieldName *)statusBar; + +/** + * @abstract Text value for MediaClock field. Must be properly formatted according to MediaClockFormat. Applies to SDLShow. + * + * @discussion This field is commonly used to show elapsed or remaining time in an audio track or audio capture. + * + * @return a SDLTextFieldName with value of *mediaClock* + */ ++ (SDLTextFieldName *)mediaClock; + +/** + * @abstract The track field of NGN type ACMs. This field is only available for media applications on a NGN display. Applies to SDLShow. + * + * @discussion This field is commonly used to show the current track number + * + * @return a SDLTextFieldName with value of *mediaTrack* + */ ++ (SDLTextFieldName *)mediaTrack; + +/** + * @abstract The first line of the alert text field. Applies to SDLAlert. + * + * @return a SDLTextFieldName with value of *alertText1* + */ ++ (SDLTextFieldName *)alertText1; + +/** + * @abstract The second line of the alert text field. Applies to SDLAlert. + * + * @return a SDLTextFieldName with value of *alertText2* + * + * @since SDL 2.0 + */ ++ (SDLTextFieldName *)alertText2; + +/** + * @abstract The third line of the alert text field. Applies to SDLAlert. + * + * @return a SDLTextFieldName with value of *alertText3* + * + * @since SDL 2.0 + */ ++ (SDLTextFieldName *)alertText3; + +/** + * @abstract Long form body of text that can include newlines and tabs. Applies to SDLScrollableMessage. + * + * @return a SDLTextFieldName with value of *scrollableMessageBody* + * + * @since SDL 2.0 + */ ++ (SDLTextFieldName *)scrollableMessageBody; + +/** + * @abstract First line suggestion for a user response (in the case of VR enabled interaction). + * + * @return a SDLTextFieldName with value of *initialInteractionText* + * + * @since SDL 2.0 + */ ++ (SDLTextFieldName *)initialInteractionText; + +/** + * @abstract First line of navigation text. + * + * @return a SDLTextFieldName with value of *navigationText1* + * + * @since SDL 2.0 + */ ++ (SDLTextFieldName *)navigationText1; + +/** + * @abstract Second line of navigation text. + * + * @return a SDLTextFieldName with value of *navigationText2* + * + * @since SDL 2.0 + */ ++ (SDLTextFieldName *)navigationText2; + +/** + * @abstract Estimated Time of Arrival time for navigation. + * + * @return a SDLTextFieldName with value of *ETA* + * + * @since SDL 2.0 + */ ++ (SDLTextFieldName *)ETA; + +/** + * @abstract Total distance to destination for navigation. + * + * @return a SDLTextFieldName with value of *totalDistance* + * + * @since SDL 2.0 + */ ++ (SDLTextFieldName *)totalDistance; + +/** + * @abstract First line of text for audio pass thru. + * + * @return a SDLTextFieldName with value of *audioPassThruDisplayText1* + * + * @since SDL 2.0 + */ ++ (SDLTextFieldName *)audioPassThruDisplayText1; + +/** + * @abstract Second line of text for audio pass thru. + * + * @return a SDLTextFieldName with value of *audioPassThruDisplayText2* + * + * @since SDL 2.0 + */ ++ (SDLTextFieldName *)audioPassThruDisplayText2; + +/** + * @abstract Header text for slider. + * + * @return a SDLTextFieldName with value of *sliderHeader* + * + * @since SDL 2.0 + */ ++ (SDLTextFieldName *)sliderHeader; + +/** + * @abstract Footer text for slider + * + * @return a SDLTextFieldName with value of *sliderFooter* + * + * @since SDL 2.0 + */ ++ (SDLTextFieldName *)sliderFooter; + +/** + * Primary text for SDLChoice + * + * @return a SDLTextFieldName with value of *menuName* + */ ++ (SDLTextFieldName *)menuName; + +/** + * Secondary text for SDLChoice + * + * @return a SDLTextFieldName with value of *secondaryText* + */ ++ (SDLTextFieldName *)secondaryText; + +/** + * Tertiary text for SDLChoice + * + * @return a SDLTextFieldName with value of *tertiaryText* + */ ++ (SDLTextFieldName *)tertiaryText; + +/** + * Optional text to label an app menu button (for certain touchscreen platforms) + * + * @return a SDLTextFieldName with value of *menuTitle* + */ ++ (SDLTextFieldName *)menuTitle; + +/** + * Optional name / title of intended location for SDLSendLocation + * + * @return a SDLTextFieldName with value of *locationName* + * + * @since SDL 4.0 + */ ++ (SDLTextFieldName *)locationName; + +/** + * Optional description of intended location / establishment (if applicable) for SDLSendLocation + * + * @return a SDLTextFieldName with value of *locationDescription* + * + * @since SDL 4.0 + */ ++ (SDLTextFieldName *)locationDescription; + +/** + * Optional location address (if applicable) for SDLSendLocation + * + * @return a SDLTextFieldName with value of *addressLines* + * + * @since SDL 4.0 + */ ++ (SDLTextFieldName *)addressLines; + +/** + * Optional hone number of intended location / establishment (if applicable) for SDLSendLocation + * + * @return a SDLTextFieldName with value of *phoneNumber* + * + * @since SDL 4.0 + */ ++ (SDLTextFieldName *)phoneNumber; + +@end diff --git a/SmartDeviceLink/SDLTextFieldName.m b/SmartDeviceLink/SDLTextFieldName.m new file mode 100644 index 000000000..4cc1ac369 --- /dev/null +++ b/SmartDeviceLink/SDLTextFieldName.m @@ -0,0 +1,281 @@ +// SDLTextFieldName.m +// + + +#import "SDLTextFieldName.h" + +SDLTextFieldName *SDLTextFieldName_mainField1 = nil; +SDLTextFieldName *SDLTextFieldName_mainField2 = nil; +SDLTextFieldName *SDLTextFieldName_mainField3 = nil; +SDLTextFieldName *SDLTextFieldName_mainField4 = nil; +SDLTextFieldName *SDLTextFieldName_statusBar = nil; +SDLTextFieldName *SDLTextFieldName_mediaClock = nil; +SDLTextFieldName *SDLTextFieldName_mediaTrack = nil; +SDLTextFieldName *SDLTextFieldName_alertText1 = nil; +SDLTextFieldName *SDLTextFieldName_alertText2 = nil; +SDLTextFieldName *SDLTextFieldName_alertText3 = nil; +SDLTextFieldName *SDLTextFieldName_scrollableMessageBody = nil; +SDLTextFieldName *SDLTextFieldName_initialInteractionText = nil; +SDLTextFieldName *SDLTextFieldName_navigationText1 = nil; +SDLTextFieldName *SDLTextFieldName_navigationText2 = nil; +SDLTextFieldName *SDLTextFieldName_ETA = nil; +SDLTextFieldName *SDLTextFieldName_totalDistance = nil; +SDLTextFieldName *SDLTextFieldName_audioPassThruDisplayText1 = nil; +SDLTextFieldName *SDLTextFieldName_audioPassThruDisplayText2 = nil; +SDLTextFieldName *SDLTextFieldName_sliderHeader = nil; +SDLTextFieldName *SDLTextFieldName_sliderFooter = nil; +SDLTextFieldName *SDLTextFieldName_menuName = nil; +SDLTextFieldName *SDLTextFieldName_secondaryText = nil; +SDLTextFieldName *SDLTextFieldName_tertiaryText = nil; +SDLTextFieldName *SDLTextFieldName_menuTitle = nil; +SDLTextFieldName *SDLTextFieldName_locationName = nil; +SDLTextFieldName *SDLTextFieldName_locationDescription = nil; +SDLTextFieldName *SDLTextFieldName_addressLines = nil; +SDLTextFieldName *SDLTextFieldName_phoneNumber = nil; + +NSArray *SDLTextFieldName_values = nil; + +@implementation SDLTextFieldName + ++ (SDLTextFieldName *)valueOf:(NSString *)value { + for (SDLTextFieldName *item in SDLTextFieldName.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLTextFieldName_values == nil) { + SDLTextFieldName_values = @[ + SDLTextFieldName.mainField1, + SDLTextFieldName.mainField2, + SDLTextFieldName.mainField3, + SDLTextFieldName.mainField4, + SDLTextFieldName.statusBar, + SDLTextFieldName.mediaClock, + SDLTextFieldName.mediaTrack, + SDLTextFieldName.alertText1, + SDLTextFieldName.alertText2, + SDLTextFieldName.alertText3, + SDLTextFieldName.scrollableMessageBody, + SDLTextFieldName.initialInteractionText, + SDLTextFieldName.navigationText1, + SDLTextFieldName.navigationText2, + SDLTextFieldName.ETA, + SDLTextFieldName.totalDistance, + SDLTextFieldName.audioPassThruDisplayText1, + SDLTextFieldName.audioPassThruDisplayText2, + SDLTextFieldName.sliderHeader, + SDLTextFieldName.sliderFooter, + SDLTextFieldName.menuName, + SDLTextFieldName.secondaryText, + SDLTextFieldName.tertiaryText, + SDLTextFieldName.menuTitle, + SDLTextFieldName.locationName, + SDLTextFieldName.locationDescription, + SDLTextFieldName.addressLines, + SDLTextFieldName.phoneNumber, + ]; + } + return SDLTextFieldName_values; +} + ++ (SDLTextFieldName *)mainField1 { + if (SDLTextFieldName_mainField1 == nil) { + SDLTextFieldName_mainField1 = [[SDLTextFieldName alloc] initWithValue:@"mainField1"]; + } + return SDLTextFieldName_mainField1; +} + ++ (SDLTextFieldName *)mainField2 { + if (SDLTextFieldName_mainField2 == nil) { + SDLTextFieldName_mainField2 = [[SDLTextFieldName alloc] initWithValue:@"mainField2"]; + } + return SDLTextFieldName_mainField2; +} + ++ (SDLTextFieldName *)mainField3 { + if (SDLTextFieldName_mainField3 == nil) { + SDLTextFieldName_mainField3 = [[SDLTextFieldName alloc] initWithValue:@"mainField3"]; + } + return SDLTextFieldName_mainField3; +} + ++ (SDLTextFieldName *)mainField4 { + if (SDLTextFieldName_mainField4 == nil) { + SDLTextFieldName_mainField4 = [[SDLTextFieldName alloc] initWithValue:@"mainField4"]; + } + return SDLTextFieldName_mainField4; +} + ++ (SDLTextFieldName *)statusBar { + if (SDLTextFieldName_statusBar == nil) { + SDLTextFieldName_statusBar = [[SDLTextFieldName alloc] initWithValue:@"statusBar"]; + } + return SDLTextFieldName_statusBar; +} + ++ (SDLTextFieldName *)mediaClock { + if (SDLTextFieldName_mediaClock == nil) { + SDLTextFieldName_mediaClock = [[SDLTextFieldName alloc] initWithValue:@"mediaClock"]; + } + return SDLTextFieldName_mediaClock; +} + ++ (SDLTextFieldName *)mediaTrack { + if (SDLTextFieldName_mediaTrack == nil) { + SDLTextFieldName_mediaTrack = [[SDLTextFieldName alloc] initWithValue:@"mediaTrack"]; + } + return SDLTextFieldName_mediaTrack; +} + ++ (SDLTextFieldName *)alertText1 { + if (SDLTextFieldName_alertText1 == nil) { + SDLTextFieldName_alertText1 = [[SDLTextFieldName alloc] initWithValue:@"alertText1"]; + } + return SDLTextFieldName_alertText1; +} + ++ (SDLTextFieldName *)alertText2 { + if (SDLTextFieldName_alertText2 == nil) { + SDLTextFieldName_alertText2 = [[SDLTextFieldName alloc] initWithValue:@"alertText2"]; + } + return SDLTextFieldName_alertText2; +} + ++ (SDLTextFieldName *)alertText3 { + if (SDLTextFieldName_alertText3 == nil) { + SDLTextFieldName_alertText3 = [[SDLTextFieldName alloc] initWithValue:@"alertText3"]; + } + return SDLTextFieldName_alertText3; +} + ++ (SDLTextFieldName *)scrollableMessageBody { + if (SDLTextFieldName_scrollableMessageBody == nil) { + SDLTextFieldName_scrollableMessageBody = [[SDLTextFieldName alloc] initWithValue:@"scrollableMessageBody"]; + } + return SDLTextFieldName_scrollableMessageBody; +} + ++ (SDLTextFieldName *)initialInteractionText { + if (SDLTextFieldName_initialInteractionText == nil) { + SDLTextFieldName_initialInteractionText = [[SDLTextFieldName alloc] initWithValue:@"initialInteractionText"]; + } + return SDLTextFieldName_initialInteractionText; +} + ++ (SDLTextFieldName *)navigationText1 { + if (SDLTextFieldName_navigationText1 == nil) { + SDLTextFieldName_navigationText1 = [[SDLTextFieldName alloc] initWithValue:@"navigationText1"]; + } + return SDLTextFieldName_navigationText1; +} + ++ (SDLTextFieldName *)navigationText2 { + if (SDLTextFieldName_navigationText2 == nil) { + SDLTextFieldName_navigationText2 = [[SDLTextFieldName alloc] initWithValue:@"navigationText2"]; + } + return SDLTextFieldName_navigationText2; +} + ++ (SDLTextFieldName *)ETA { + if (SDLTextFieldName_ETA == nil) { + SDLTextFieldName_ETA = [[SDLTextFieldName alloc] initWithValue:@"ETA"]; + } + return SDLTextFieldName_ETA; +} + ++ (SDLTextFieldName *)totalDistance { + if (SDLTextFieldName_totalDistance == nil) { + SDLTextFieldName_totalDistance = [[SDLTextFieldName alloc] initWithValue:@"totalDistance"]; + } + return SDLTextFieldName_totalDistance; +} + ++ (SDLTextFieldName *)audioPassThruDisplayText1 { + if (SDLTextFieldName_audioPassThruDisplayText1 == nil) { + SDLTextFieldName_audioPassThruDisplayText1 = [[SDLTextFieldName alloc] initWithValue:@"audioPassThruDisplayText1"]; + } + return SDLTextFieldName_audioPassThruDisplayText1; +} + ++ (SDLTextFieldName *)audioPassThruDisplayText2 { + if (SDLTextFieldName_audioPassThruDisplayText2 == nil) { + SDLTextFieldName_audioPassThruDisplayText2 = [[SDLTextFieldName alloc] initWithValue:@"audioPassThruDisplayText2"]; + } + return SDLTextFieldName_audioPassThruDisplayText2; +} + ++ (SDLTextFieldName *)sliderHeader { + if (SDLTextFieldName_sliderHeader == nil) { + SDLTextFieldName_sliderHeader = [[SDLTextFieldName alloc] initWithValue:@"sliderHeader"]; + } + return SDLTextFieldName_sliderHeader; +} + ++ (SDLTextFieldName *)sliderFooter { + if (SDLTextFieldName_sliderFooter == nil) { + SDLTextFieldName_sliderFooter = [[SDLTextFieldName alloc] initWithValue:@"sliderFooter"]; + } + return SDLTextFieldName_sliderFooter; +} + ++ (SDLTextFieldName *)menuName { + if (SDLTextFieldName_menuName == nil) { + SDLTextFieldName_menuName = [[SDLTextFieldName alloc] initWithValue:@"menuName"]; + } + return SDLTextFieldName_menuName; +} + ++ (SDLTextFieldName *)secondaryText { + if (SDLTextFieldName_secondaryText == nil) { + SDLTextFieldName_secondaryText = [[SDLTextFieldName alloc] initWithValue:@"secondaryText"]; + } + return SDLTextFieldName_secondaryText; +} + ++ (SDLTextFieldName *)tertiaryText { + if (SDLTextFieldName_tertiaryText == nil) { + SDLTextFieldName_tertiaryText = [[SDLTextFieldName alloc] initWithValue:@"tertiaryText"]; + } + return SDLTextFieldName_tertiaryText; +} + ++ (SDLTextFieldName *)menuTitle { + if (SDLTextFieldName_menuTitle == nil) { + SDLTextFieldName_menuTitle = [[SDLTextFieldName alloc] initWithValue:@"menuTitle"]; + } + return SDLTextFieldName_menuTitle; +} + ++ (SDLTextFieldName *)locationName { + if (SDLTextFieldName_locationName == nil) { + SDLTextFieldName_locationName = [[SDLTextFieldName alloc] initWithValue:@"locationName"]; + } + return SDLTextFieldName_locationName; +} + ++ (SDLTextFieldName *)locationDescription { + if (SDLTextFieldName_locationDescription == nil) { + SDLTextFieldName_locationDescription = [[SDLTextFieldName alloc] initWithValue:@"locationDescription"]; + } + return SDLTextFieldName_locationDescription; +} + ++ (SDLTextFieldName *)addressLines { + if (SDLTextFieldName_addressLines == nil) { + SDLTextFieldName_addressLines = [[SDLTextFieldName alloc] initWithValue:@"addressLines"]; + } + return SDLTextFieldName_addressLines; +} + ++ (SDLTextFieldName *)phoneNumber { + if (SDLTextFieldName_phoneNumber == nil) { + SDLTextFieldName_phoneNumber = [[SDLTextFieldName alloc] initWithValue:@"phoneNumber"]; + } + return SDLTextFieldName_phoneNumber; +} + +@end diff --git a/SmartDeviceLink/SDLTimer.h b/SmartDeviceLink/SDLTimer.h new file mode 100644 index 000000000..f9f7be3d9 --- /dev/null +++ b/SmartDeviceLink/SDLTimer.h @@ -0,0 +1,19 @@ +// +// SDLTimer.h +// + +#import <Foundation/Foundation.h> + +@interface SDLTimer : NSObject + +@property (nonatomic, copy) void (^elapsedBlock)(void); +@property (nonatomic, copy) void (^canceledBlock)(void); +@property (assign) float duration; + +- (instancetype)init; +- (instancetype)initWithDuration:(float)duration __deprecated; +- (instancetype)initWithDuration:(float)duration repeat:(BOOL)repeat; +- (void)start; +- (void)cancel; + +@end diff --git a/SmartDeviceLink/SDLTimer.m b/SmartDeviceLink/SDLTimer.m new file mode 100644 index 000000000..84ee6e24b --- /dev/null +++ b/SmartDeviceLink/SDLTimer.m @@ -0,0 +1,79 @@ +// +// SDLTimer.m +// + +#import "SDLTimer.h" + + +@interface SDLTimer () + +@property (strong) NSTimer *timer; +@property (assign) BOOL timerRunning; +@property (nonatomic) BOOL repeat; +@end + + +@implementation SDLTimer + +- (instancetype)init { + if (self = [super init]) { + _duration = 0; + _timerRunning = NO; + } + return self; +} + +- (instancetype)initWithDuration:(float)duration { + return [self initWithDuration:duration repeat:NO]; +} + +- (instancetype)initWithDuration:(float)duration repeat:(BOOL)repeat { + self = [super init]; + if (self) { + _duration = duration; + _repeat = repeat; + _timerRunning = NO; + } + return self; +} + +- (void)start { + if (self.duration > 0) { + [self stopAndDestroyTimer]; + self.timer = [NSTimer timerWithTimeInterval:self.duration target:self selector:@selector(timerElapsed) userInfo:nil repeats:self.repeat]; + [[NSRunLoop mainRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes]; + self.timerRunning = YES; + } +} + +- (void)cancel { + [self stopAndDestroyTimer]; + if (self.timerRunning && self.canceledBlock != nil) { + self.timerRunning = NO; + self.canceledBlock(); + } + self.timerRunning = NO; +} + +- (void)timerElapsed { + if (self.repeat == NO) { + [self stopAndDestroyTimer]; + self.timerRunning = NO; + } + if (self.elapsedBlock != nil) { + self.elapsedBlock(); + } +} + +- (void)stopAndDestroyTimer { + if (self.timer != nil) { + [self.timer invalidate]; + self.timer = nil; + } +} + +- (void)dealloc { + [self cancel]; +} + +@end diff --git a/SmartDeviceLink/SDLTimerMode.h b/SmartDeviceLink/SDLTimerMode.h new file mode 100644 index 000000000..f625f6636 --- /dev/null +++ b/SmartDeviceLink/SDLTimerMode.h @@ -0,0 +1,17 @@ +// SDLTimerMode.h +// + + +#import "SDLEnum.h" + +@interface SDLTimerMode : SDLEnum { +} + ++ (SDLTimerMode *)valueOf:(NSString *)value; ++ (NSArray *)values; + ++ (SDLTimerMode *)UP; ++ (SDLTimerMode *)DOWN; ++ (SDLTimerMode *)NONE; + +@end diff --git a/SmartDeviceLink/SDLTimerMode.m b/SmartDeviceLink/SDLTimerMode.m new file mode 100644 index 000000000..5787a2eb4 --- /dev/null +++ b/SmartDeviceLink/SDLTimerMode.m @@ -0,0 +1,56 @@ +// SDLTimerMode.m +// + + +#import "SDLTimerMode.h" + +SDLTimerMode *SDLTimerMode_UP = nil; +SDLTimerMode *SDLTimerMode_DOWN = nil; +SDLTimerMode *SDLTimerMode_NONE = nil; + +NSArray *SDLTimerMode_values = nil; + +@implementation SDLTimerMode + ++ (SDLTimerMode *)valueOf:(NSString *)value { + for (SDLTimerMode *item in SDLTimerMode.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLTimerMode_values == nil) { + SDLTimerMode_values = @[ + SDLTimerMode.UP, + SDLTimerMode.DOWN, + SDLTimerMode.NONE, + ]; + } + return SDLTimerMode_values; +} + ++ (SDLTimerMode *)UP { + if (SDLTimerMode_UP == nil) { + SDLTimerMode_UP = [[SDLTimerMode alloc] initWithValue:@"UP"]; + } + return SDLTimerMode_UP; +} + ++ (SDLTimerMode *)DOWN { + if (SDLTimerMode_DOWN == nil) { + SDLTimerMode_DOWN = [[SDLTimerMode alloc] initWithValue:@"DOWN"]; + } + return SDLTimerMode_DOWN; +} + ++ (SDLTimerMode *)NONE { + if (SDLTimerMode_NONE == nil) { + SDLTimerMode_NONE = [[SDLTimerMode alloc] initWithValue:@"NONE"]; + } + return SDLTimerMode_NONE; +} + +@end diff --git a/SmartDeviceLink/SDLTireStatus.h b/SmartDeviceLink/SDLTireStatus.h new file mode 100644 index 000000000..9ebd68d8e --- /dev/null +++ b/SmartDeviceLink/SDLTireStatus.h @@ -0,0 +1,24 @@ +// SDLTireStatus.h +// + +#import "SDLRPCMessage.h" + +@class SDLSingleTireStatus; +@class SDLWarningLightStatus; + + +@interface SDLTireStatus : SDLRPCStruct { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) SDLWarningLightStatus *pressureTelltale; +@property (strong) SDLSingleTireStatus *leftFront; +@property (strong) SDLSingleTireStatus *rightFront; +@property (strong) SDLSingleTireStatus *leftRear; +@property (strong) SDLSingleTireStatus *rightRear; +@property (strong) SDLSingleTireStatus *innerLeftRear; +@property (strong) SDLSingleTireStatus *innerRightRear; + +@end diff --git a/SmartDeviceLink/SDLTireStatus.m b/SmartDeviceLink/SDLTireStatus.m new file mode 100644 index 000000000..c2768565a --- /dev/null +++ b/SmartDeviceLink/SDLTireStatus.m @@ -0,0 +1,144 @@ +// SDLTireStatus.m +// + +#import "SDLTireStatus.h" + +#import "SDLNames.h" +#import "SDLSingleTireStatus.h" +#import "SDLWarningLightStatus.h" + + +@implementation SDLTireStatus + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setPressureTelltale:(SDLWarningLightStatus *)pressureTelltale { + if (pressureTelltale != nil) { + [store setObject:pressureTelltale forKey:NAMES_pressureTelltale]; + } else { + [store removeObjectForKey:NAMES_pressureTelltale]; + } +} + +- (SDLWarningLightStatus *)pressureTelltale { + NSObject *obj = [store objectForKey:NAMES_pressureTelltale]; + if (obj == nil || [obj isKindOfClass:SDLWarningLightStatus.class]) { + return (SDLWarningLightStatus *)obj; + } else { + return [SDLWarningLightStatus valueOf:(NSString *)obj]; + } +} + +- (void)setLeftFront:(SDLSingleTireStatus *)leftFront { + if (leftFront != nil) { + [store setObject:leftFront forKey:NAMES_leftFront]; + } else { + [store removeObjectForKey:NAMES_leftFront]; + } +} + +- (SDLSingleTireStatus *)leftFront { + NSObject *obj = [store objectForKey:NAMES_leftFront]; + if (obj == nil || [obj isKindOfClass:SDLSingleTireStatus.class]) { + return (SDLSingleTireStatus *)obj; + } else { + return [[SDLSingleTireStatus alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setRightFront:(SDLSingleTireStatus *)rightFront { + if (rightFront != nil) { + [store setObject:rightFront forKey:NAMES_rightFront]; + } else { + [store removeObjectForKey:NAMES_rightFront]; + } +} + +- (SDLSingleTireStatus *)rightFront { + NSObject *obj = [store objectForKey:NAMES_rightFront]; + if (obj == nil || [obj isKindOfClass:SDLSingleTireStatus.class]) { + return (SDLSingleTireStatus *)obj; + } else { + return [[SDLSingleTireStatus alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setLeftRear:(SDLSingleTireStatus *)leftRear { + if (leftRear != nil) { + [store setObject:leftRear forKey:NAMES_leftRear]; + } else { + [store removeObjectForKey:NAMES_leftRear]; + } +} + +- (SDLSingleTireStatus *)leftRear { + NSObject *obj = [store objectForKey:NAMES_leftRear]; + if (obj == nil || [obj isKindOfClass:SDLSingleTireStatus.class]) { + return (SDLSingleTireStatus *)obj; + } else { + return [[SDLSingleTireStatus alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setRightRear:(SDLSingleTireStatus *)rightRear { + if (rightRear != nil) { + [store setObject:rightRear forKey:NAMES_rightRear]; + } else { + [store removeObjectForKey:NAMES_rightRear]; + } +} + +- (SDLSingleTireStatus *)rightRear { + NSObject *obj = [store objectForKey:NAMES_rightRear]; + if (obj == nil || [obj isKindOfClass:SDLSingleTireStatus.class]) { + return (SDLSingleTireStatus *)obj; + } else { + return [[SDLSingleTireStatus alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setInnerLeftRear:(SDLSingleTireStatus *)innerLeftRear { + if (innerLeftRear != nil) { + [store setObject:innerLeftRear forKey:NAMES_innerLeftRear]; + } else { + [store removeObjectForKey:NAMES_innerLeftRear]; + } +} + +- (SDLSingleTireStatus *)innerLeftRear { + NSObject *obj = [store objectForKey:NAMES_innerLeftRear]; + if (obj == nil || [obj isKindOfClass:SDLSingleTireStatus.class]) { + return (SDLSingleTireStatus *)obj; + } else { + return [[SDLSingleTireStatus alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setInnerRightRear:(SDLSingleTireStatus *)innerRightRear { + if (innerRightRear != nil) { + [store setObject:innerRightRear forKey:NAMES_innerRightRear]; + } else { + [store removeObjectForKey:NAMES_innerRightRear]; + } +} + +- (SDLSingleTireStatus *)innerRightRear { + NSObject *obj = [store objectForKey:NAMES_innerRightRear]; + if (obj == nil || [obj isKindOfClass:SDLSingleTireStatus.class]) { + return (SDLSingleTireStatus *)obj; + } else { + return [[SDLSingleTireStatus alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLTouchCoord.h b/SmartDeviceLink/SDLTouchCoord.h new file mode 100644 index 000000000..63515811f --- /dev/null +++ b/SmartDeviceLink/SDLTouchCoord.h @@ -0,0 +1,16 @@ +// SDLTouchCoord.h +// + + +#import "SDLRPCMessage.h" + +@interface SDLTouchCoord : SDLRPCStruct { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) NSNumber *x; +@property (strong) NSNumber *y; + +@end diff --git a/SmartDeviceLink/SDLTouchCoord.m b/SmartDeviceLink/SDLTouchCoord.m new file mode 100644 index 000000000..78895696f --- /dev/null +++ b/SmartDeviceLink/SDLTouchCoord.m @@ -0,0 +1,47 @@ +// SDLTouchCoord.m +// + + +#import "SDLTouchCoord.h" + +#import "SDLNames.h" + +@implementation SDLTouchCoord + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setX:(NSNumber *)x { + if (x != nil) { + [store setObject:x forKey:NAMES_x]; + } else { + [store removeObjectForKey:NAMES_x]; + } +} + +- (NSNumber *)x { + return [store objectForKey:NAMES_x]; +} + +- (void)setY:(NSNumber *)y { + if (y != nil) { + [store setObject:y forKey:NAMES_y]; + } else { + [store removeObjectForKey:NAMES_y]; + } +} + +- (NSNumber *)y { + return [store objectForKey:NAMES_y]; +} + +@end diff --git a/SmartDeviceLink/SDLTouchEvent.h b/SmartDeviceLink/SDLTouchEvent.h new file mode 100644 index 000000000..01af99b98 --- /dev/null +++ b/SmartDeviceLink/SDLTouchEvent.h @@ -0,0 +1,40 @@ +// SDLTouchEvent.h +// + + +#import "SDLRPCMessage.h" + +@interface SDLTouchEvent : SDLRPCStruct { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + A touch's unique identifier. The application can track the current touch events by id. + If a touch event has type begin, the id should be added to the set of touches. + If a touch event has type end, the id should be removed from the set of touches. + + Mandatory, 0-9 + */ +@property (strong) NSNumber *touchEventId; + +/** + The time that the touch was recorded. This number can the time since the beginning of the session or something else as long as the units are in milliseconds. + + The timestamp is used to determined the rate of change of position of a touch. + + The application also uses the time to verify whether two touches, with different ids, are part of a single action by the user. + + If there is only a single timestamp in this array, it is the same for every coordinate in the coordinates array. + + Mandatory, array size 1-1000, contains <NSNumber> size 0-5000000000 + */ +@property (strong) NSMutableArray *timeStamp; + +/** + * Mandatory, array size 1-1000, contains SDLTouchCoord + */ +@property (strong) NSMutableArray *coord; + +@end diff --git a/SmartDeviceLink/SDLTouchEvent.m b/SmartDeviceLink/SDLTouchEvent.m new file mode 100644 index 000000000..e54e8b79e --- /dev/null +++ b/SmartDeviceLink/SDLTouchEvent.m @@ -0,0 +1,69 @@ +// SDLTouchEvent.m +// + + +#import "SDLTouchEvent.h" + +#import "SDLNames.h" +#import "SDLTouchCoord.h" + +@implementation SDLTouchEvent + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setTouchEventId:(NSNumber *)touchEventId { + if (touchEventId != nil) { + [store setObject:touchEventId forKey:NAMES_id]; + } else { + [store removeObjectForKey:NAMES_id]; + } +} + +- (NSNumber *)touchEventId { + return [store objectForKey:NAMES_id]; +} + +- (void)setTimeStamp:(NSMutableArray *)timeStamp { + if (timeStamp != nil) { + [store setObject:timeStamp forKey:NAMES_ts]; + } else { + [store removeObjectForKey:NAMES_ts]; + } +} + +- (NSMutableArray *)timeStamp { + return [store objectForKey:NAMES_ts]; +} + +- (void)setCoord:(NSMutableArray *)coord { + if (coord != nil) { + [store setObject:coord forKey:NAMES_c]; + } else { + [store removeObjectForKey:NAMES_c]; + } +} + +- (NSMutableArray *)coord { + NSMutableArray *array = [store objectForKey:NAMES_c]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLTouchCoord.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLTouchCoord alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +@end diff --git a/SmartDeviceLink/SDLTouchEventCapabilities.h b/SmartDeviceLink/SDLTouchEventCapabilities.h new file mode 100644 index 000000000..6d346d874 --- /dev/null +++ b/SmartDeviceLink/SDLTouchEventCapabilities.h @@ -0,0 +1,17 @@ +// SDLTouchEventCapabilities.h +// + + +#import "SDLRPCMessage.h" + +@interface SDLTouchEventCapabilities : SDLRPCStruct { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) NSNumber *pressAvailable; +@property (strong) NSNumber *multiTouchAvailable; +@property (strong) NSNumber *doublePressAvailable; + +@end diff --git a/SmartDeviceLink/SDLTouchEventCapabilities.m b/SmartDeviceLink/SDLTouchEventCapabilities.m new file mode 100644 index 000000000..4fc71cfec --- /dev/null +++ b/SmartDeviceLink/SDLTouchEventCapabilities.m @@ -0,0 +1,59 @@ +// SDLTouchEventCapabilities.m +// + + +#import "SDLTouchEventCapabilities.h" + +#import "SDLNames.h" + +@implementation SDLTouchEventCapabilities + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setPressAvailable:(NSNumber *)pressAvailable { + if (pressAvailable != nil) { + [store setObject:pressAvailable forKey:NAMES_pressAvailable]; + } else { + [store removeObjectForKey:NAMES_pressAvailable]; + } +} + +- (NSNumber *)pressAvailable { + return [store objectForKey:NAMES_pressAvailable]; +} + +- (void)setMultiTouchAvailable:(NSNumber *)multiTouchAvailable { + if (multiTouchAvailable != nil) { + [store setObject:multiTouchAvailable forKey:NAMES_multiTouchAvailable]; + } else { + [store removeObjectForKey:NAMES_multiTouchAvailable]; + } +} + +- (NSNumber *)multiTouchAvailable { + return [store objectForKey:NAMES_multiTouchAvailable]; +} + +- (void)setDoublePressAvailable:(NSNumber *)doublePressAvailable { + if (doublePressAvailable != nil) { + [store setObject:doublePressAvailable forKey:NAMES_doublePressAvailable]; + } else { + [store removeObjectForKey:NAMES_doublePressAvailable]; + } +} + +- (NSNumber *)doublePressAvailable { + return [store objectForKey:NAMES_doublePressAvailable]; +} + +@end diff --git a/SmartDeviceLink/SDLTouchType.h b/SmartDeviceLink/SDLTouchType.h new file mode 100644 index 000000000..bfbb91fd4 --- /dev/null +++ b/SmartDeviceLink/SDLTouchType.h @@ -0,0 +1,17 @@ +// SDLTouchType.h +// + + +#import "SDLEnum.h" + +@interface SDLTouchType : SDLEnum { +} + ++ (SDLTouchType *)valueOf:(NSString *)value; ++ (NSArray *)values; + ++ (SDLTouchType *)BEGIN; ++ (SDLTouchType *)MOVE; ++ (SDLTouchType *)END; + +@end diff --git a/SmartDeviceLink/SDLTouchType.m b/SmartDeviceLink/SDLTouchType.m new file mode 100644 index 000000000..d834d012d --- /dev/null +++ b/SmartDeviceLink/SDLTouchType.m @@ -0,0 +1,56 @@ +// SDLTouchType.m +// + + +#import "SDLTouchType.h" + +SDLTouchType *SDLTouchType_BEGIN = nil; +SDLTouchType *SDLTouchType_MOVE = nil; +SDLTouchType *SDLTouchType_END = nil; + +NSArray *SDLTouchType_values = nil; + +@implementation SDLTouchType + ++ (SDLTouchType *)valueOf:(NSString *)value { + for (SDLTouchType *item in SDLTouchType.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLTouchType_values == nil) { + SDLTouchType_values = @[ + SDLTouchType.BEGIN, + SDLTouchType.MOVE, + SDLTouchType.END, + ]; + } + return SDLTouchType_values; +} + ++ (SDLTouchType *)BEGIN { + if (SDLTouchType_BEGIN == nil) { + SDLTouchType_BEGIN = [[SDLTouchType alloc] initWithValue:@"BEGIN"]; + } + return SDLTouchType_BEGIN; +} + ++ (SDLTouchType *)MOVE { + if (SDLTouchType_MOVE == nil) { + SDLTouchType_MOVE = [[SDLTouchType alloc] initWithValue:@"MOVE"]; + } + return SDLTouchType_MOVE; +} + ++ (SDLTouchType *)END { + if (SDLTouchType_END == nil) { + SDLTouchType_END = [[SDLTouchType alloc] initWithValue:@"END"]; + } + return SDLTouchType_END; +} + +@end diff --git a/SmartDeviceLink/SDLTransportDelegate.h b/SmartDeviceLink/SDLTransportDelegate.h new file mode 100644 index 000000000..4f4abe33f --- /dev/null +++ b/SmartDeviceLink/SDLTransportDelegate.h @@ -0,0 +1,10 @@ +// SDLTransportDelegate.h +// + +@protocol SDLTransportDelegate <NSObject> + +- (void)onTransportConnected; +- (void)onTransportDisconnected; +- (void)onDataReceived:(NSData *)receivedData; + +@end
\ No newline at end of file diff --git a/SmartDeviceLink/SDLTriggerSource.h b/SmartDeviceLink/SDLTriggerSource.h new file mode 100644 index 000000000..36e646f17 --- /dev/null +++ b/SmartDeviceLink/SDLTriggerSource.h @@ -0,0 +1,46 @@ +// SDLTriggerSource.h +// + + +#import "SDLEnum.h" + +/** + * Indicates whether choice/command was selected via VR or via a menu selection (using SEEKRIGHT/SEEKLEFT, TUNEUP, TUNEDOWN, OK buttons) + * + * @since SDL 1.0 + */ +@interface SDLTriggerSource : SDLEnum { +} + +/** + * Convert String to SDLTriggerSource + * @param value The value of the string to get an object for + * @return SDLTriggerSource + */ ++ (SDLTriggerSource *)valueOf:(NSString *)value; + +/** + @abstract Store the enumeration of all possible SDLTriggerSource + @return an array that store all possible SDLTriggerSource + */ ++ (NSArray *)values; + +/** + * @abstract Selection made via menu + * @return SDLTriggerSource with value of *MENU* + */ ++ (SDLTriggerSource *)MENU; + +/** + * @abstract Selection made via Voice session + * @return SDLTriggerSource with value of *VR* + */ ++ (SDLTriggerSource *)VR; + +/** + * @abstract Selection made via Keyboard + * @return SDLTriggerSource with value of *KEYBOARD* + */ ++ (SDLTriggerSource *)KEYBOARD; + +@end diff --git a/SmartDeviceLink/SDLTriggerSource.m b/SmartDeviceLink/SDLTriggerSource.m new file mode 100644 index 000000000..a56b66c6f --- /dev/null +++ b/SmartDeviceLink/SDLTriggerSource.m @@ -0,0 +1,56 @@ +// SDLTriggerSource.m +// + + +#import "SDLTriggerSource.h" + +SDLTriggerSource *SDLTriggerSource_MENU = nil; +SDLTriggerSource *SDLTriggerSource_VR = nil; +SDLTriggerSource *SDLTriggerSource_KEYBOARD = nil; + +NSArray *SDLTriggerSource_values = nil; + +@implementation SDLTriggerSource + ++ (SDLTriggerSource *)valueOf:(NSString *)value { + for (SDLTriggerSource *item in SDLTriggerSource.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLTriggerSource_values == nil) { + SDLTriggerSource_values = @[ + SDLTriggerSource.MENU, + SDLTriggerSource.VR, + SDLTriggerSource.KEYBOARD, + ]; + } + return SDLTriggerSource_values; +} + ++ (SDLTriggerSource *)MENU { + if (SDLTriggerSource_MENU == nil) { + SDLTriggerSource_MENU = [[SDLTriggerSource alloc] initWithValue:@"MENU"]; + } + return SDLTriggerSource_MENU; +} + ++ (SDLTriggerSource *)VR { + if (SDLTriggerSource_VR == nil) { + SDLTriggerSource_VR = [[SDLTriggerSource alloc] initWithValue:@"VR"]; + } + return SDLTriggerSource_VR; +} + ++ (SDLTriggerSource *)KEYBOARD { + if (SDLTriggerSource_KEYBOARD == nil) { + SDLTriggerSource_KEYBOARD = [[SDLTriggerSource alloc] initWithValue:@"KEYBOARD"]; + } + return SDLTriggerSource_KEYBOARD; +} + +@end diff --git a/SmartDeviceLink/SDLTurn.h b/SmartDeviceLink/SDLTurn.h new file mode 100644 index 000000000..ef2cf9ebe --- /dev/null +++ b/SmartDeviceLink/SDLTurn.h @@ -0,0 +1,18 @@ +// SDLTurn.h +// + +#import "SDLRPCMessage.h" + +@class SDLImage; + + +@interface SDLTurn : SDLRPCStruct { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) NSString *navigationText; +@property (strong) SDLImage *turnIcon; + +@end diff --git a/SmartDeviceLink/SDLTurn.m b/SmartDeviceLink/SDLTurn.m new file mode 100644 index 000000000..875fa2e73 --- /dev/null +++ b/SmartDeviceLink/SDLTurn.m @@ -0,0 +1,53 @@ +// SDLTurn.m +// + +#import "SDLTurn.h" + +#import "SDLImage.h" +#import "SDLNames.h" + + +@implementation SDLTurn + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setNavigationText:(NSString *)navigationText { + if (navigationText != nil) { + [store setObject:navigationText forKey:NAMES_navigationText]; + } else { + [store removeObjectForKey:NAMES_navigationText]; + } +} + +- (NSString *)navigationText { + return [store objectForKey:NAMES_navigationText]; +} + +- (void)setTurnIcon:(SDLImage *)turnIcon { + if (turnIcon != nil) { + [store setObject:turnIcon forKey:NAMES_turnIcon]; + } else { + [store removeObjectForKey:NAMES_turnIcon]; + } +} + +- (SDLImage *)turnIcon { + NSObject *obj = [store objectForKey:NAMES_turnIcon]; + if (obj == nil || [obj isKindOfClass:SDLImage.class]) { + return (SDLImage *)obj; + } else { + return [[SDLImage alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLURLRequestTask.h b/SmartDeviceLink/SDLURLRequestTask.h new file mode 100644 index 000000000..8745f8519 --- /dev/null +++ b/SmartDeviceLink/SDLURLRequestTask.h @@ -0,0 +1,46 @@ +// +// SDLURLRequestTask.h +// SmartDeviceLink-iOS +// +// Created by Joel Fischer on 8/17/15. +// Copyright (c) 2015 smartdevicelink. All rights reserved. +// + +#import <Foundation/Foundation.h> + +@class SDLURLRequestTask; +@class SDLURLSession; + + +typedef void (^SDLURLConnectionRequestCompletionHandler)(NSData *__nullable data, NSURLResponse *__nullable response, NSError *__nullable error); + +typedef NS_ENUM(NSUInteger, SDLURLRequestTaskState) { + SDLURLRequestTaskStateRunning, + SDLURLRequestTaskStateCompleted +}; + + +NS_ASSUME_NONNULL_BEGIN + +@protocol SDLURLRequestTaskDelegate <NSObject> + +- (void)taskDidFinish:(SDLURLRequestTask *)task; + +@end + + +@interface SDLURLRequestTask : NSObject + +@property (weak, nonatomic) id<SDLURLRequestTaskDelegate> delegate; +@property (assign, nonatomic) SDLURLRequestTaskState state; + +- (instancetype)init NS_UNAVAILABLE; +- (instancetype)initWithURLRequest:(NSURLRequest *)request completionHandler:(SDLURLConnectionRequestCompletionHandler)completionHandler NS_DESIGNATED_INITIALIZER; + ++ (instancetype)taskWithURLRequest:(NSURLRequest *)request completionHandler:(SDLURLConnectionRequestCompletionHandler)completionHandler; + +- (void)cancel; + +@end + +NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLURLRequestTask.m b/SmartDeviceLink/SDLURLRequestTask.m new file mode 100644 index 000000000..d1895ac10 --- /dev/null +++ b/SmartDeviceLink/SDLURLRequestTask.m @@ -0,0 +1,110 @@ +// +// SDLURLRequestTask.m +// SmartDeviceLink-iOS +// +// Created by Joel Fischer on 8/17/15. +// Copyright (c) 2015 smartdevicelink. All rights reserved. +// + +#import "SDLURLRequestTask.h" + +#import "SDLURLSession.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface SDLURLRequestTask () <NSURLConnectionDelegate, NSURLConnectionDataDelegate> + +@property (strong, nonatomic) NSURLConnection *connection; +@property (strong, nonatomic, nullable) NSURLResponse *response; +@property (copy, nonatomic) SDLURLConnectionRequestCompletionHandler completionHandler; +@property (strong, nonatomic) NSMutableData *mutableData; + +@end + + +@implementation SDLURLRequestTask + +#pragma mark - Lifecycle + +- (instancetype)init { + NSAssert(NO, @"use initWithURLRequest:completionHandler instead"); + return nil; +} + +- (instancetype)initWithURLRequest:(NSURLRequest *)request completionHandler:(SDLURLConnectionRequestCompletionHandler)completionHandler { + self = [super init]; + if (!self) { + return nil; + } + + _connection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:NO]; + [_connection scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; + [_connection start]; + + _completionHandler = completionHandler; + + _mutableData = [NSMutableData data]; + _response = nil; + _state = SDLURLRequestTaskStateRunning; + + return self; +} + ++ (instancetype)taskWithURLRequest:(NSURLRequest *)request completionHandler:(SDLURLConnectionRequestCompletionHandler)completionHandler { + return [[self alloc] initWithURLRequest:request completionHandler:completionHandler]; +} + +- (void)dealloc { + [_connection cancel]; +} + + +#pragma mark - Data Methods + +- (void)sdl_addData:(NSData *)data { + [self.mutableData appendData:data]; +} + + +#pragma mark - Cancel + +- (void)cancel { + [self.connection cancel]; + [self connection:self.connection didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:kCFURLErrorCancelled userInfo:nil]]; +} + + +#pragma mark - NSURLConnectionDelegate + +- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { + dispatch_async(dispatch_get_main_queue(), ^{ + self.completionHandler(nil, self.response, error); + + self.state = SDLURLRequestTaskStateCompleted; + [self.delegate taskDidFinish:self]; + }); +} + + +#pragma mark - NSURLConnectionDataDelegate + +- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { + [self sdl_addData:data]; +} + +- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { + self.response = response; +} + +- (void)connectionDidFinishLoading:(NSURLConnection *)connection { + dispatch_async(dispatch_get_main_queue(), ^{ + self.completionHandler([self.mutableData copy], self.response, nil); + + self.state = SDLURLRequestTaskStateCompleted; + [self.delegate taskDidFinish:self]; + }); +} + +@end + +NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLURLSession.h b/SmartDeviceLink/SDLURLSession.h new file mode 100644 index 000000000..0d2a22e28 --- /dev/null +++ b/SmartDeviceLink/SDLURLSession.h @@ -0,0 +1,57 @@ +// +// SDLURLConnection.h +// SmartDeviceLink-iOS +// +// Created by Joel Fischer on 8/17/15. +// Copyright (c) 2015 smartdevicelink. All rights reserved. +// + +#import <Foundation/Foundation.h> + + +typedef void (^SDLURLConnectionRequestCompletionHandler)(NSData *__nullable data, NSURLResponse *__nullable response, NSError *__nullable error); + + +NS_ASSUME_NONNULL_BEGIN + +@interface SDLURLSession : NSObject + +@property (assign, nonatomic) NSURLRequestCachePolicy cachePolicy; + +/** + * If any task is started with a request that is at the default timeout (60.0 sec), it will be altered to this connection timeout (by default 45.0 sec). + */ +@property (assign, nonatomic) NSTimeInterval connectionTimeout; + +/** + * Get the default session, a singleton. + * + * @return The default session + */ ++ (instancetype)defaultSession; + +/** + * Retrieves data from a specified URL. Default settings for timeout and cache policy will be used. + * + * @param url An NSURLRequest will be assembled for this URL + * @param completionHandler The completion handler that will be called when the request is complete + */ +- (void)dataFromURL:(NSURL *)url completionHandler:(SDLURLConnectionRequestCompletionHandler)completionHandler; + +/** + * Starts a URL request using data supplied. + * + * @param request An NSURLRequest that provides the URL, cache policy, request method, etc. The HTTPBody data in this request will be ignored + * @param data The data to be uploaded over HTTP + * @param completionHandler The completion handler that will be called when the request is complete + */ +- (void)uploadWithURLRequest:(NSURLRequest *)request data:(NSData *)data completionHandler:(SDLURLConnectionRequestCompletionHandler)completionHandler; + +/** + * Tells all pending requests to cancel + */ +- (void)cancelAllTasks; + +@end + +NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLURLSession.m b/SmartDeviceLink/SDLURLSession.m new file mode 100644 index 000000000..363c6fbad --- /dev/null +++ b/SmartDeviceLink/SDLURLSession.m @@ -0,0 +1,102 @@ +// +// SDLURLConnection.m +// SmartDeviceLink-iOS +// +// Created by Joel Fischer on 8/17/15. +// Copyright (c) 2015 smartdevicelink. All rights reserved. +// + +#import "SDLURLSession.h" + +#import "SDLURLRequestTask.h" + + +NS_ASSUME_NONNULL_BEGIN + +static float DefaultConnectionTimeout = 45.0; + + +@interface SDLURLSession () <SDLURLRequestTaskDelegate> + +@property (strong, nonatomic) NSMutableSet *activeTasks; + +@end + + +@implementation SDLURLSession + + +#pragma mark - Lifecycle + ++ (instancetype)defaultSession { + static SDLURLSession *sharedSession = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + sharedSession = [[self alloc] init]; + }); + + return sharedSession; +} + +- (void)dealloc { + for (SDLURLRequestTask *task in self.activeTasks) { + [task cancel]; + } +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + _cachePolicy = NSURLRequestUseProtocolCachePolicy; + _connectionTimeout = DefaultConnectionTimeout; + + _activeTasks = [NSMutableSet set]; + + return self; +} + + +#pragma mark - URL Request Methods + +- (void)dataFromURL:(NSURL *)url completionHandler:(SDLURLConnectionRequestCompletionHandler)completionHandler { + NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:self.cachePolicy timeoutInterval:self.connectionTimeout]; + + SDLURLRequestTask *task = [[SDLURLRequestTask alloc] initWithURLRequest:request completionHandler:completionHandler]; + task.delegate = self; + + [self.activeTasks addObject:task]; +} + +- (void)uploadWithURLRequest:(NSURLRequest *)request data:(NSData *)data completionHandler:(SDLURLConnectionRequestCompletionHandler)completionHandler { + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + mutableRequest.HTTPBody = data; + mutableRequest.HTTPMethod = @"POST"; + + SDLURLRequestTask *task = [[SDLURLRequestTask alloc] initWithURLRequest:mutableRequest completionHandler:completionHandler]; + task.delegate = self; + + [self.activeTasks addObject:task]; +} + + +#pragma mark - Cancel Methods + +- (void)cancelAllTasks { + for (SDLURLRequestTask *task in self.activeTasks) { + [task cancel]; + } +} + + +#pragma mark - SDLURLRequestTaskDelegate + +- (void)taskDidFinish:(SDLURLRequestTask *)task { + [self.activeTasks removeObject:task]; +} + +@end + +NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLUnregisterAppInterface.h b/SmartDeviceLink/SDLUnregisterAppInterface.h new file mode 100644 index 000000000..d35d40193 --- /dev/null +++ b/SmartDeviceLink/SDLUnregisterAppInterface.h @@ -0,0 +1,36 @@ +// SDLUnregisterAppInterface.h +// + + +#import "SDLRPCRequest.h" + +/** + * Terminates an application's interface registration. This causes SDL® to + * dispose of all resources associated with the application's interface + * registration (e.g. Command Menu items, Choice Sets, button subscriptions, + * etc.) + * <p> + * After the UnregisterAppInterface operation is performed, no other operations + * can be performed until a new app interface registration is established by + * calling <i>{@linkplain RegisterAppInterface}</i> + * <p> + * <b>HMILevel can be FULL, LIMITED, BACKGROUND or NONE</b> + * </p> + * + * See SDLRegisterAppInterface SDLOnAppInterfaceUnregistered + */ +@interface SDLUnregisterAppInterface : SDLRPCRequest { +} + +/** + * @abstract Constructs a new SDLUnregisterAppInterface object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLUnregisterAppInterface object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLUnregisterAppInterface.m b/SmartDeviceLink/SDLUnregisterAppInterface.m new file mode 100644 index 000000000..88039631d --- /dev/null +++ b/SmartDeviceLink/SDLUnregisterAppInterface.m @@ -0,0 +1,23 @@ +// SDLUnregisterAppInterface.m +// + + +#import "SDLUnregisterAppInterface.h" + +#import "SDLNames.h" + +@implementation SDLUnregisterAppInterface + +- (instancetype)init { + if (self = [super initWithName:NAMES_UnregisterAppInterface]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLUnregisterAppInterfaceResponse.h b/SmartDeviceLink/SDLUnregisterAppInterfaceResponse.h new file mode 100644 index 000000000..8ebbb46af --- /dev/null +++ b/SmartDeviceLink/SDLUnregisterAppInterfaceResponse.h @@ -0,0 +1,26 @@ +// SDLUnregisterAppInterfaceResponse.h +// + + +#import "SDLRPCResponse.h" + +/** + * Unregister AppInterface Response is sent, when SDLUnregisterAppInterface has been called + * + * @since SmartDeviceLink 1.0 + */ +@interface SDLUnregisterAppInterfaceResponse : SDLRPCResponse { +} + +/** + * @abstract Constructs a new SDLUnregisterAppInterfaceResponse object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLUnregisterAppInterfaceResponse object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLUnregisterAppInterfaceResponse.m b/SmartDeviceLink/SDLUnregisterAppInterfaceResponse.m new file mode 100644 index 000000000..6bebbe83d --- /dev/null +++ b/SmartDeviceLink/SDLUnregisterAppInterfaceResponse.m @@ -0,0 +1,23 @@ +// SDLUnregisterAppInterfaceResponse.m +// + + +#import "SDLUnregisterAppInterfaceResponse.h" + +#import "SDLNames.h" + +@implementation SDLUnregisterAppInterfaceResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_UnregisterAppInterface]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLUnsubscribeButton.h b/SmartDeviceLink/SDLUnsubscribeButton.h new file mode 100644 index 000000000..bb16f43f5 --- /dev/null +++ b/SmartDeviceLink/SDLUnsubscribeButton.h @@ -0,0 +1,43 @@ +// SDLUnsubscribeButton.h +// + +#import "SDLRPCRequest.h" + +@class SDLButtonName; + + +/** + * Deletes a subscription to button notifications for the specified button. For + * more information about button subscriptions, see SDLSubscribeButton + * <p> + * Application can unsubscribe from a button that is currently being pressed + * (i.e. has not yet been released), but app will not get button event + * <p> + * <b>HMILevel needs to be FULL, LIMITED or BACKGROUND</b> + * <p> + + * @since SmartDeviceLink 1.0<br/> + * See SDLSubscribeButton + */ +@interface SDLUnsubscribeButton : SDLRPCRequest { +} + +/** + * @abstract Constructs a new SDLUnsubscribeButton object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLUnsubscribeButton object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract A name of the button to unsubscribe from + * @discussion An Enumeration value, see <i> + * SDLButtonName</i> + */ +@property (strong) SDLButtonName *buttonName; + +@end diff --git a/SmartDeviceLink/SDLUnsubscribeButton.m b/SmartDeviceLink/SDLUnsubscribeButton.m new file mode 100644 index 000000000..9853fa9da --- /dev/null +++ b/SmartDeviceLink/SDLUnsubscribeButton.m @@ -0,0 +1,42 @@ +// SDLUnsubscribeButton.m +// + + +#import "SDLUnsubscribeButton.h" + +#import "SDLButtonName.h" +#import "SDLNames.h" + + +@implementation SDLUnsubscribeButton + +- (instancetype)init { + if (self = [super initWithName:NAMES_UnsubscribeButton]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setButtonName:(SDLButtonName *)buttonName { + if (buttonName != nil) { + [parameters setObject:buttonName forKey:NAMES_buttonName]; + } else { + [parameters removeObjectForKey:NAMES_buttonName]; + } +} + +- (SDLButtonName *)buttonName { + NSObject *obj = [parameters objectForKey:NAMES_buttonName]; + if (obj == nil || [obj isKindOfClass:SDLButtonName.class]) { + return (SDLButtonName *)obj; + } else { + return [SDLButtonName valueOf:(NSString *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLUnsubscribeButtonResponse.h b/SmartDeviceLink/SDLUnsubscribeButtonResponse.h new file mode 100644 index 000000000..62011539f --- /dev/null +++ b/SmartDeviceLink/SDLUnsubscribeButtonResponse.h @@ -0,0 +1,26 @@ +// SDLUnsubscribeButtonResponse.h +// + + +#import "SDLRPCResponse.h" + +/** + * Unsubscribe Button Response is sent, when SDLUnsubscribeButton has been called + * + * @since SmartDeviceLink 1.0 + */ +@interface SDLUnsubscribeButtonResponse : SDLRPCResponse { +} + +/** + * @abstract Constructs a new SDLUnsubscribeButtonResponse object + */ +- (instancetype)init; +/** + * @abstract Constructs a new SDLUnsubscribeButtonResponse object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLUnsubscribeButtonResponse.m b/SmartDeviceLink/SDLUnsubscribeButtonResponse.m new file mode 100644 index 000000000..a28cf2768 --- /dev/null +++ b/SmartDeviceLink/SDLUnsubscribeButtonResponse.m @@ -0,0 +1,23 @@ +// SDLUnsubscribeButtonResponse.m +// + + +#import "SDLUnsubscribeButtonResponse.h" + +#import "SDLNames.h" + +@implementation SDLUnsubscribeButtonResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_UnsubscribeButton]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLUnsubscribeVehicleData.h b/SmartDeviceLink/SDLUnsubscribeVehicleData.h new file mode 100644 index 000000000..389173256 --- /dev/null +++ b/SmartDeviceLink/SDLUnsubscribeVehicleData.h @@ -0,0 +1,130 @@ +// SDLUnsubscribeVehicleData.h +// + + +#import "SDLRPCRequest.h" + +/** + * This function is used to unsubscribe the notifications from the + * subscribeVehicleData function + * <p> + * Function Group: Location, VehicleInfo and DrivingChara + * <p> + * <b>HMILevel needs to be FULL, LIMITED or BACKGROUND</b> + * </p> + * + * @since SmartDeviceLink 2.0<br/> + * See SDLSubscribeVehicleData SDLGetVehicleData + */ +@interface SDLUnsubscribeVehicleData : SDLRPCRequest { +} + +/** + * @abstract Constructs a new SDLUnsubscribeVehicleData object + */ +- (instancetype)init; + +/** + * @abstract Constructs a new SDLUnsubscribeVehicleData object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract A boolean value. If true, unsubscribes Gps data + */ +@property (strong) NSNumber *gps; + +/** + * @abstract A boolean value. If true, unsubscribes speed data + */ +@property (strong) NSNumber *speed; + +/** + * @abstract A boolean value. If true, unsubscribe data + */ +@property (strong) NSNumber *rpm; + +/** + * @abstract A boolean value. If true, unsubscribes FuelLevel data + */ +@property (strong) NSNumber *fuelLevel; + +/** + * @abstract A boolean value. If true, unsubscribes fuelLevel_State data + */ +@property (strong) NSNumber *fuelLevel_State; + +/** + * @abstract A boolean value. If true, unsubscribes instantFuelConsumption data + */ +@property (strong) NSNumber *instantFuelConsumption; + +/** + * @abstract A boolean value. If true, unsubscribes externalTemperature data + */ +@property (strong) NSNumber *externalTemperature; + +/** + * @abstract A boolean value. If true, unsubscribes Currently selected gear data + */ +@property (strong) NSNumber *prndl; + +/** + * @abstract A boolean value. If true, unsubscribes tire pressure status data + */ +@property (strong) NSNumber *tirePressure; + +/** + * @abstract A boolean value. If true, unsubscribes odometer data + */ +@property (strong) NSNumber *odometer; + +/** + * @abstract A boolean value. If true, unsubscribes belt Status data + */ +@property (strong) NSNumber *beltStatus; + +/** + * @abstract A boolean value. If true, unsubscribes body Information data + */ +@property (strong) NSNumber *bodyInformation; + +/** + * @abstract A boolean value. If true, unsubscribes device Status data + */ +@property (strong) NSNumber *deviceStatus; + +/** + * @abstract A boolean value. If true, unsubscribes driver Braking data + */ +@property (strong) NSNumber *driverBraking; + +/** + * @abstract A boolean value. If true, unsubscribes wiper Status data + */ +@property (strong) NSNumber *wiperStatus; + +/** + * @abstract A boolean value. If true, unsubscribes Head Lamp Status data + */ +@property (strong) NSNumber *headLampStatus; + +/** + * @abstract A boolean value. If true, unsubscribes Engine Torque data + */ +@property (strong) NSNumber *engineTorque; + +/** + * @abstract A boolean value. If true, unsubscribes accPedalPosition data + */ +@property (strong) NSNumber *accPedalPosition; +@property (strong) NSNumber *steeringWheelAngle; +@property (strong) NSNumber *eCallInfo; +@property (strong) NSNumber *airbagStatus; +@property (strong) NSNumber *emergencyEvent; +@property (strong) NSNumber *clusterModeStatus; +@property (strong) NSNumber *myKey; + +@end diff --git a/SmartDeviceLink/SDLUnsubscribeVehicleData.m b/SmartDeviceLink/SDLUnsubscribeVehicleData.m new file mode 100644 index 000000000..11aa044e1 --- /dev/null +++ b/SmartDeviceLink/SDLUnsubscribeVehicleData.m @@ -0,0 +1,311 @@ +// SDLUnsubscribeVehicleData.m +// + + +#import "SDLUnsubscribeVehicleData.h" + +#import "SDLNames.h" + +@implementation SDLUnsubscribeVehicleData + +- (instancetype)init { + if (self = [super initWithName:NAMES_UnsubscribeVehicleData]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setGps:(NSNumber *)gps { + if (gps != nil) { + [parameters setObject:gps forKey:NAMES_gps]; + } else { + [parameters removeObjectForKey:NAMES_gps]; + } +} + +- (NSNumber *)gps { + return [parameters objectForKey:NAMES_gps]; +} + +- (void)setSpeed:(NSNumber *)speed { + if (speed != nil) { + [parameters setObject:speed forKey:NAMES_speed]; + } else { + [parameters removeObjectForKey:NAMES_speed]; + } +} + +- (NSNumber *)speed { + return [parameters objectForKey:NAMES_speed]; +} + +- (void)setRpm:(NSNumber *)rpm { + if (rpm != nil) { + [parameters setObject:rpm forKey:NAMES_rpm]; + } else { + [parameters removeObjectForKey:NAMES_rpm]; + } +} + +- (NSNumber *)rpm { + return [parameters objectForKey:NAMES_rpm]; +} + +- (void)setFuelLevel:(NSNumber *)fuelLevel { + if (fuelLevel != nil) { + [parameters setObject:fuelLevel forKey:NAMES_fuelLevel]; + } else { + [parameters removeObjectForKey:NAMES_fuelLevel]; + } +} + +- (NSNumber *)fuelLevel { + return [parameters objectForKey:NAMES_fuelLevel]; +} + +- (void)setFuelLevel_State:(NSNumber *)fuelLevel_State { + if (fuelLevel_State != nil) { + [parameters setObject:fuelLevel_State forKey:NAMES_fuelLevel_State]; + } else { + [parameters removeObjectForKey:NAMES_fuelLevel_State]; + } +} + +- (NSNumber *)fuelLevel_State { + return [parameters objectForKey:NAMES_fuelLevel_State]; +} + +- (void)setInstantFuelConsumption:(NSNumber *)instantFuelConsumption { + if (instantFuelConsumption != nil) { + [parameters setObject:instantFuelConsumption forKey:NAMES_instantFuelConsumption]; + } else { + [parameters removeObjectForKey:NAMES_instantFuelConsumption]; + } +} + +- (NSNumber *)instantFuelConsumption { + return [parameters objectForKey:NAMES_instantFuelConsumption]; +} + +- (void)setExternalTemperature:(NSNumber *)externalTemperature { + if (externalTemperature != nil) { + [parameters setObject:externalTemperature forKey:NAMES_externalTemperature]; + } else { + [parameters removeObjectForKey:NAMES_externalTemperature]; + } +} + +- (NSNumber *)externalTemperature { + return [parameters objectForKey:NAMES_externalTemperature]; +} + +- (void)setPrndl:(NSNumber *)prndl { + if (prndl != nil) { + [parameters setObject:prndl forKey:NAMES_prndl]; + } else { + [parameters removeObjectForKey:NAMES_prndl]; + } +} + +- (NSNumber *)prndl { + return [parameters objectForKey:NAMES_prndl]; +} + +- (void)setTirePressure:(NSNumber *)tirePressure { + if (tirePressure != nil) { + [parameters setObject:tirePressure forKey:NAMES_tirePressure]; + } else { + [parameters removeObjectForKey:NAMES_tirePressure]; + } +} + +- (NSNumber *)tirePressure { + return [parameters objectForKey:NAMES_tirePressure]; +} + +- (void)setOdometer:(NSNumber *)odometer { + if (odometer != nil) { + [parameters setObject:odometer forKey:NAMES_odometer]; + } else { + [parameters removeObjectForKey:NAMES_odometer]; + } +} + +- (NSNumber *)odometer { + return [parameters objectForKey:NAMES_odometer]; +} + +- (void)setBeltStatus:(NSNumber *)beltStatus { + if (beltStatus != nil) { + [parameters setObject:beltStatus forKey:NAMES_beltStatus]; + } else { + [parameters removeObjectForKey:NAMES_beltStatus]; + } +} + +- (NSNumber *)beltStatus { + return [parameters objectForKey:NAMES_beltStatus]; +} + +- (void)setBodyInformation:(NSNumber *)bodyInformation { + if (bodyInformation != nil) { + [parameters setObject:bodyInformation forKey:NAMES_bodyInformation]; + } else { + [parameters removeObjectForKey:NAMES_bodyInformation]; + } +} + +- (NSNumber *)bodyInformation { + return [parameters objectForKey:NAMES_bodyInformation]; +} + +- (void)setDeviceStatus:(NSNumber *)deviceStatus { + if (deviceStatus != nil) { + [parameters setObject:deviceStatus forKey:NAMES_deviceStatus]; + } else { + [parameters removeObjectForKey:NAMES_deviceStatus]; + } +} + +- (NSNumber *)deviceStatus { + return [parameters objectForKey:NAMES_deviceStatus]; +} + +- (void)setDriverBraking:(NSNumber *)driverBraking { + if (driverBraking != nil) { + [parameters setObject:driverBraking forKey:NAMES_driverBraking]; + } else { + [parameters removeObjectForKey:NAMES_driverBraking]; + } +} + +- (NSNumber *)driverBraking { + return [parameters objectForKey:NAMES_driverBraking]; +} + +- (void)setWiperStatus:(NSNumber *)wiperStatus { + if (wiperStatus != nil) { + [parameters setObject:wiperStatus forKey:NAMES_wiperStatus]; + } else { + [parameters removeObjectForKey:NAMES_wiperStatus]; + } +} + +- (NSNumber *)wiperStatus { + return [parameters objectForKey:NAMES_wiperStatus]; +} + +- (void)setHeadLampStatus:(NSNumber *)headLampStatus { + if (headLampStatus != nil) { + [parameters setObject:headLampStatus forKey:NAMES_headLampStatus]; + } else { + [parameters removeObjectForKey:NAMES_headLampStatus]; + } +} + +- (NSNumber *)headLampStatus { + return [parameters objectForKey:NAMES_headLampStatus]; +} + +- (void)setEngineTorque:(NSNumber *)engineTorque { + if (engineTorque != nil) { + [parameters setObject:engineTorque forKey:NAMES_engineTorque]; + } else { + [parameters removeObjectForKey:NAMES_engineTorque]; + } +} + +- (NSNumber *)engineTorque { + return [parameters objectForKey:NAMES_engineTorque]; +} + +- (void)setAccPedalPosition:(NSNumber *)accPedalPosition { + if (accPedalPosition != nil) { + [parameters setObject:accPedalPosition forKey:NAMES_accPedalPosition]; + } else { + [parameters removeObjectForKey:NAMES_accPedalPosition]; + } +} + +- (NSNumber *)accPedalPosition { + return [parameters objectForKey:NAMES_accPedalPosition]; +} + +- (void)setSteeringWheelAngle:(NSNumber *)steeringWheelAngle { + if (steeringWheelAngle != nil) { + [parameters setObject:steeringWheelAngle forKey:NAMES_steeringWheelAngle]; + } else { + [parameters removeObjectForKey:NAMES_steeringWheelAngle]; + } +} + +- (NSNumber *)steeringWheelAngle { + return [parameters objectForKey:NAMES_steeringWheelAngle]; +} + +- (void)setECallInfo:(NSNumber *)eCallInfo { + if (eCallInfo != nil) { + [parameters setObject:eCallInfo forKey:NAMES_eCallInfo]; + } else { + [parameters removeObjectForKey:NAMES_eCallInfo]; + } +} + +- (NSNumber *)eCallInfo { + return [parameters objectForKey:NAMES_eCallInfo]; +} + +- (void)setAirbagStatus:(NSNumber *)airbagStatus { + if (airbagStatus != nil) { + [parameters setObject:airbagStatus forKey:NAMES_airbagStatus]; + } else { + [parameters removeObjectForKey:NAMES_airbagStatus]; + } +} + +- (NSNumber *)airbagStatus { + return [parameters objectForKey:NAMES_airbagStatus]; +} + +- (void)setEmergencyEvent:(NSNumber *)emergencyEvent { + if (emergencyEvent != nil) { + [parameters setObject:emergencyEvent forKey:NAMES_emergencyEvent]; + } else { + [parameters removeObjectForKey:NAMES_emergencyEvent]; + } +} + +- (NSNumber *)emergencyEvent { + return [parameters objectForKey:NAMES_emergencyEvent]; +} + +- (void)setClusterModeStatus:(NSNumber *)clusterModeStatus { + if (clusterModeStatus != nil) { + [parameters setObject:clusterModeStatus forKey:NAMES_clusterModeStatus]; + } else { + [parameters removeObjectForKey:NAMES_clusterModeStatus]; + } +} + +- (NSNumber *)clusterModeStatus { + return [parameters objectForKey:NAMES_clusterModeStatus]; +} + +- (void)setMyKey:(NSNumber *)myKey { + if (myKey != nil) { + [parameters setObject:myKey forKey:NAMES_myKey]; + } else { + [parameters removeObjectForKey:NAMES_myKey]; + } +} + +- (NSNumber *)myKey { + return [parameters objectForKey:NAMES_myKey]; +} + +@end diff --git a/SmartDeviceLink/SDLUnsubscribeVehicleDataResponse.h b/SmartDeviceLink/SDLUnsubscribeVehicleDataResponse.h new file mode 100644 index 000000000..beb1b93e2 --- /dev/null +++ b/SmartDeviceLink/SDLUnsubscribeVehicleDataResponse.h @@ -0,0 +1,129 @@ +// SDLUnsubscribeVehicleDataResponse.h +// + +#import "SDLRPCResponse.h" + +@class SDLVehicleDataResult; + + +/** + * Unsubscribe Vehicle Data Response is sent, when UnsubscribeVehicleData has been called + * + * @since SmartDeviceLink 2.0 + */ +@interface SDLUnsubscribeVehicleDataResponse : SDLRPCResponse { +} + +/** + * @abstract Constructs a new SDLUnsubscribeVehicleDataResponse object + */ +- (instancetype)init; + +/** + * @abstract Constructs a new SDLUnsubscribeVehicleDataResponse object indicated by the NSMutableDictionary + * parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract A SDLVehicleDataResult* value. See GPSData. + */ +@property (strong) SDLVehicleDataResult *gps; + +/** + * @abstract A SDLVehicleDataResult* value. The vehicle speed in kilometers per hour. + */ +@property (strong) SDLVehicleDataResult *speed; + +/** + * @abstract A SDLVehicleDataResult* value. The number of revolutions per minute of the engine. + */ +@property (strong) SDLVehicleDataResult *rpm; + +/** + * @abstract A SDLVehicleDataResult* value. The fuel level in the tank (percentage) + */ +@property (strong) SDLVehicleDataResult *fuelLevel; + +/** + * @abstract A SDLVehicleDataResult* value. The fuel level state. + */ +@property (strong) SDLVehicleDataResult *fuelLevel_State; + +/** + * @abstract A SDLVehicleDataResult* value. The instantaneous fuel consumption in microlitres. + */ +@property (strong) SDLVehicleDataResult *instantFuelConsumption; + +/** + * @abstract A SDLVehicleDataResult* value. The external temperature in degrees celsius. + */ +@property (strong) SDLVehicleDataResult *externalTemperature; + +/** + * @abstract A SDLVehicleDataResult* value. See PRNDL. + */ +@property (strong) SDLVehicleDataResult *prndl; + +/** + * @abstract A SDLVehicleDataResult* value. See TireStatus. + */ +@property (strong) SDLVehicleDataResult *tirePressure; + +/** + * @abstract A SDLVehicleDataResult* value. Odometer in km. + */ +@property (strong) SDLVehicleDataResult *odometer; + +/** + * @abstract A SDLVehicleDataResult* value. The status of the seat belts. + */ +@property (strong) SDLVehicleDataResult *beltStatus; + +/** + * @abstract A SDLVehicleDataResult* value. The body information including power modes. + */ +@property (strong) SDLVehicleDataResult *bodyInformation; + +/** + * @abstract A SDLVehicleDataResult* value. The device status including signal and battery strength. + */ +@property (strong) SDLVehicleDataResult *deviceStatus; + +/** + * @abstract A SDLVehicleDataResult* value. The status of the brake pedal. + */ +@property (strong) SDLVehicleDataResult *driverBraking; + +/** + * @abstract A SDLVehicleDataResult* value. The status of the wipers. + */ +@property (strong) SDLVehicleDataResult *wiperStatus; + +/** + * @abstract A SDLVehicleDataResult* value. Status of the head lamps. + */ +@property (strong) SDLVehicleDataResult *headLampStatus; + +/** + * @abstract A SDLVehicleDataResult* value. Torque value for engine (in Nm) on non-diesel variants. + */ +@property (strong) SDLVehicleDataResult *engineTorque; + +/** + * @abstract A SDLVehicleDataResult* value. Accelerator pedal position (percentage depressed) + */ +@property (strong) SDLVehicleDataResult *accPedalPosition; + +/** + * @abstract A SDLVehicleDataResult* value. Current angle of the steering wheel (in deg) + */ +@property (strong) SDLVehicleDataResult *steeringWheelAngle; +@property (strong) SDLVehicleDataResult *eCallInfo; +@property (strong) SDLVehicleDataResult *airbagStatus; +@property (strong) SDLVehicleDataResult *emergencyEvent; +@property (strong) SDLVehicleDataResult *clusterModes; +@property (strong) SDLVehicleDataResult *myKey; + +@end diff --git a/SmartDeviceLink/SDLUnsubscribeVehicleDataResponse.m b/SmartDeviceLink/SDLUnsubscribeVehicleDataResponse.m new file mode 100644 index 000000000..ec4916447 --- /dev/null +++ b/SmartDeviceLink/SDLUnsubscribeVehicleDataResponse.m @@ -0,0 +1,433 @@ +// SDLUnsubscribeVehicleDataResponse.m +// + + +#import "SDLUnsubscribeVehicleDataResponse.h" + +#import "SDLNames.h" +#import "SDLVehicleDataResult.h" + + +@implementation SDLUnsubscribeVehicleDataResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_UnsubscribeVehicleData]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setGps:(SDLVehicleDataResult *)gps { + if (gps != nil) { + [parameters setObject:gps forKey:NAMES_gps]; + } else { + [parameters removeObjectForKey:NAMES_gps]; + } +} + +- (SDLVehicleDataResult *)gps { + NSObject *obj = [parameters objectForKey:NAMES_gps]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setSpeed:(SDLVehicleDataResult *)speed { + if (speed != nil) { + [parameters setObject:speed forKey:NAMES_speed]; + } else { + [parameters removeObjectForKey:NAMES_speed]; + } +} + +- (SDLVehicleDataResult *)speed { + NSObject *obj = [parameters objectForKey:NAMES_speed]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setRpm:(SDLVehicleDataResult *)rpm { + if (rpm != nil) { + [parameters setObject:rpm forKey:NAMES_rpm]; + } else { + [parameters removeObjectForKey:NAMES_rpm]; + } +} + +- (SDLVehicleDataResult *)rpm { + NSObject *obj = [parameters objectForKey:NAMES_rpm]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setFuelLevel:(SDLVehicleDataResult *)fuelLevel { + if (fuelLevel != nil) { + [parameters setObject:fuelLevel forKey:NAMES_fuelLevel]; + } else { + [parameters removeObjectForKey:NAMES_fuelLevel]; + } +} + +- (SDLVehicleDataResult *)fuelLevel { + NSObject *obj = [parameters objectForKey:NAMES_fuelLevel]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setFuelLevel_State:(SDLVehicleDataResult *)fuelLevel_State { + if (fuelLevel_State != nil) { + [parameters setObject:fuelLevel_State forKey:NAMES_fuelLevel_State]; + } else { + [parameters removeObjectForKey:NAMES_fuelLevel_State]; + } +} + +- (SDLVehicleDataResult *)fuelLevel_State { + NSObject *obj = [parameters objectForKey:NAMES_fuelLevel_State]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setInstantFuelConsumption:(SDLVehicleDataResult *)instantFuelConsumption { + if (instantFuelConsumption != nil) { + [parameters setObject:instantFuelConsumption forKey:NAMES_instantFuelConsumption]; + } else { + [parameters removeObjectForKey:NAMES_instantFuelConsumption]; + } +} + +- (SDLVehicleDataResult *)instantFuelConsumption { + NSObject *obj = [parameters objectForKey:NAMES_instantFuelConsumption]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setExternalTemperature:(SDLVehicleDataResult *)externalTemperature { + if (externalTemperature != nil) { + [parameters setObject:externalTemperature forKey:NAMES_externalTemperature]; + } else { + [parameters removeObjectForKey:NAMES_externalTemperature]; + } +} + +- (SDLVehicleDataResult *)externalTemperature { + NSObject *obj = [parameters objectForKey:NAMES_externalTemperature]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setPrndl:(SDLVehicleDataResult *)prndl { + if (prndl != nil) { + [parameters setObject:prndl forKey:NAMES_prndl]; + } else { + [parameters removeObjectForKey:NAMES_prndl]; + } +} + +- (SDLVehicleDataResult *)prndl { + NSObject *obj = [parameters objectForKey:NAMES_prndl]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setTirePressure:(SDLVehicleDataResult *)tirePressure { + if (tirePressure != nil) { + [parameters setObject:tirePressure forKey:NAMES_tirePressure]; + } else { + [parameters removeObjectForKey:NAMES_tirePressure]; + } +} + +- (SDLVehicleDataResult *)tirePressure { + NSObject *obj = [parameters objectForKey:NAMES_tirePressure]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setOdometer:(SDLVehicleDataResult *)odometer { + if (odometer != nil) { + [parameters setObject:odometer forKey:NAMES_odometer]; + } else { + [parameters removeObjectForKey:NAMES_odometer]; + } +} + +- (SDLVehicleDataResult *)odometer { + NSObject *obj = [parameters objectForKey:NAMES_odometer]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setBeltStatus:(SDLVehicleDataResult *)beltStatus { + if (beltStatus != nil) { + [parameters setObject:beltStatus forKey:NAMES_beltStatus]; + } else { + [parameters removeObjectForKey:NAMES_beltStatus]; + } +} + +- (SDLVehicleDataResult *)beltStatus { + NSObject *obj = [parameters objectForKey:NAMES_beltStatus]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setBodyInformation:(SDLVehicleDataResult *)bodyInformation { + if (bodyInformation != nil) { + [parameters setObject:bodyInformation forKey:NAMES_bodyInformation]; + } else { + [parameters removeObjectForKey:NAMES_bodyInformation]; + } +} + +- (SDLVehicleDataResult *)bodyInformation { + NSObject *obj = [parameters objectForKey:NAMES_bodyInformation]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setDeviceStatus:(SDLVehicleDataResult *)deviceStatus { + if (deviceStatus != nil) { + [parameters setObject:deviceStatus forKey:NAMES_deviceStatus]; + } else { + [parameters removeObjectForKey:NAMES_deviceStatus]; + } +} + +- (SDLVehicleDataResult *)deviceStatus { + NSObject *obj = [parameters objectForKey:NAMES_deviceStatus]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setDriverBraking:(SDLVehicleDataResult *)driverBraking { + if (driverBraking != nil) { + [parameters setObject:driverBraking forKey:NAMES_driverBraking]; + } else { + [parameters removeObjectForKey:NAMES_driverBraking]; + } +} + +- (SDLVehicleDataResult *)driverBraking { + NSObject *obj = [parameters objectForKey:NAMES_driverBraking]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setWiperStatus:(SDLVehicleDataResult *)wiperStatus { + if (wiperStatus != nil) { + [parameters setObject:wiperStatus forKey:NAMES_wiperStatus]; + } else { + [parameters removeObjectForKey:NAMES_wiperStatus]; + } +} + +- (SDLVehicleDataResult *)wiperStatus { + NSObject *obj = [parameters objectForKey:NAMES_wiperStatus]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setHeadLampStatus:(SDLVehicleDataResult *)headLampStatus { + if (headLampStatus != nil) { + [parameters setObject:headLampStatus forKey:NAMES_headLampStatus]; + } else { + [parameters removeObjectForKey:NAMES_headLampStatus]; + } +} + +- (SDLVehicleDataResult *)headLampStatus { + NSObject *obj = [parameters objectForKey:NAMES_headLampStatus]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setEngineTorque:(SDLVehicleDataResult *)engineTorque { + if (engineTorque != nil) { + [parameters setObject:engineTorque forKey:NAMES_engineTorque]; + } else { + [parameters removeObjectForKey:NAMES_engineTorque]; + } +} + +- (SDLVehicleDataResult *)engineTorque { + NSObject *obj = [parameters objectForKey:NAMES_engineTorque]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setAccPedalPosition:(SDLVehicleDataResult *)accPedalPosition { + if (accPedalPosition != nil) { + [parameters setObject:accPedalPosition forKey:NAMES_accPedalPosition]; + } else { + [parameters removeObjectForKey:NAMES_accPedalPosition]; + } +} + +- (SDLVehicleDataResult *)accPedalPosition { + NSObject *obj = [parameters objectForKey:NAMES_accPedalPosition]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setSteeringWheelAngle:(SDLVehicleDataResult *)steeringWheelAngle { + if (steeringWheelAngle != nil) { + [parameters setObject:steeringWheelAngle forKey:NAMES_steeringWheelAngle]; + } else { + [parameters removeObjectForKey:NAMES_steeringWheelAngle]; + } +} + +- (SDLVehicleDataResult *)steeringWheelAngle { + NSObject *obj = [parameters objectForKey:NAMES_steeringWheelAngle]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setECallInfo:(SDLVehicleDataResult *)eCallInfo { + if (eCallInfo != nil) { + [parameters setObject:eCallInfo forKey:NAMES_eCallInfo]; + } else { + [parameters removeObjectForKey:NAMES_eCallInfo]; + } +} + +- (SDLVehicleDataResult *)eCallInfo { + NSObject *obj = [parameters objectForKey:NAMES_eCallInfo]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setAirbagStatus:(SDLVehicleDataResult *)airbagStatus { + if (airbagStatus != nil) { + [parameters setObject:airbagStatus forKey:NAMES_airbagStatus]; + } else { + [parameters removeObjectForKey:NAMES_airbagStatus]; + } +} + +- (SDLVehicleDataResult *)airbagStatus { + NSObject *obj = [parameters objectForKey:NAMES_airbagStatus]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setEmergencyEvent:(SDLVehicleDataResult *)emergencyEvent { + if (emergencyEvent != nil) { + [parameters setObject:emergencyEvent forKey:NAMES_emergencyEvent]; + } else { + [parameters removeObjectForKey:NAMES_emergencyEvent]; + } +} + +- (SDLVehicleDataResult *)emergencyEvent { + NSObject *obj = [parameters objectForKey:NAMES_emergencyEvent]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setClusterModes:(SDLVehicleDataResult *)clusterModes { + if (clusterModes != nil) { + [parameters setObject:clusterModes forKey:NAMES_clusterModes]; + } else { + [parameters removeObjectForKey:NAMES_clusterModes]; + } +} + +- (SDLVehicleDataResult *)clusterModes { + NSObject *obj = [parameters objectForKey:NAMES_clusterModes]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setMyKey:(SDLVehicleDataResult *)myKey { + if (myKey != nil) { + [parameters setObject:myKey forKey:NAMES_myKey]; + } else { + [parameters removeObjectForKey:NAMES_myKey]; + } +} + +- (SDLVehicleDataResult *)myKey { + NSObject *obj = [parameters objectForKey:NAMES_myKey]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResult.class]) { + return (SDLVehicleDataResult *)obj; + } else { + return [[SDLVehicleDataResult alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLUpdateMode.h b/SmartDeviceLink/SDLUpdateMode.h new file mode 100644 index 000000000..3ff84a2e9 --- /dev/null +++ b/SmartDeviceLink/SDLUpdateMode.h @@ -0,0 +1,57 @@ +// SDLUpdateMode.h +// + + +#import "SDLEnum.h" + +/** + * Specifies what function should be performed on the media clock/counter + * + * @since SDL 1.0 + */ +@interface SDLUpdateMode : SDLEnum { +} + +/** + * Convert String to SDLUpdateMode + * @param value The value of the string to get an object for + * @return SDLUpdateMode + */ ++ (SDLUpdateMode *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLUpdateMode + * @return an array that store all possible SDLUpdateMode + */ ++ (NSArray *)values; + +/** + * @abstract Starts the media clock timer counting upward, in increments of 1 second. + * @return SDLUpdateMode with value of *COUNTUP* + */ ++ (SDLUpdateMode *)COUNTUP; + +/** + * @abstract Starts the media clock timer counting downward, in increments of 1 second. + * @return SDLUpdateMode with value of *COUNTDOWN* + */ ++ (SDLUpdateMode *)COUNTDOWN; + +/** + * @abstract Pauses the media clock timer. + * @return SDLUpdateMode with value of *PAUSE* + */ ++ (SDLUpdateMode *)PAUSE; + +/** + * @abstract Resumes the media clock timer. The timer resumes counting in whatever mode was in effect before pausing (i.e. COUNTUP or COUNTDOWN). + * @return SDLUpdateMode with value of *RESUME* + */ ++ (SDLUpdateMode *)RESUME; + +/** + * @abstract Clear the media clock timer. + */ ++ (SDLUpdateMode *)CLEAR; + +@end diff --git a/SmartDeviceLink/SDLUpdateMode.m b/SmartDeviceLink/SDLUpdateMode.m new file mode 100644 index 000000000..2a2e8c7e5 --- /dev/null +++ b/SmartDeviceLink/SDLUpdateMode.m @@ -0,0 +1,74 @@ +// SDLUpdateMode.m +// + + +#import "SDLUpdateMode.h" + +SDLUpdateMode *SDLUpdateMode_COUNTUP = nil; +SDLUpdateMode *SDLUpdateMode_COUNTDOWN = nil; +SDLUpdateMode *SDLUpdateMode_PAUSE = nil; +SDLUpdateMode *SDLUpdateMode_RESUME = nil; +SDLUpdateMode *SDLUpdateMode_CLEAR = nil; + +NSArray *SDLUpdateMode_values = nil; + +@implementation SDLUpdateMode + ++ (SDLUpdateMode *)valueOf:(NSString *)value { + for (SDLUpdateMode *item in SDLUpdateMode.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLUpdateMode_values == nil) { + SDLUpdateMode_values = @[ + SDLUpdateMode.COUNTUP, + SDLUpdateMode.COUNTDOWN, + SDLUpdateMode.PAUSE, + SDLUpdateMode.RESUME, + SDLUpdateMode.CLEAR, + ]; + } + return SDLUpdateMode_values; +} + ++ (SDLUpdateMode *)COUNTUP { + if (SDLUpdateMode_COUNTUP == nil) { + SDLUpdateMode_COUNTUP = [[SDLUpdateMode alloc] initWithValue:@"COUNTUP"]; + } + return SDLUpdateMode_COUNTUP; +} + ++ (SDLUpdateMode *)COUNTDOWN { + if (SDLUpdateMode_COUNTDOWN == nil) { + SDLUpdateMode_COUNTDOWN = [[SDLUpdateMode alloc] initWithValue:@"COUNTDOWN"]; + } + return SDLUpdateMode_COUNTDOWN; +} + ++ (SDLUpdateMode *)PAUSE { + if (SDLUpdateMode_PAUSE == nil) { + SDLUpdateMode_PAUSE = [[SDLUpdateMode alloc] initWithValue:@"PAUSE"]; + } + return SDLUpdateMode_PAUSE; +} + ++ (SDLUpdateMode *)RESUME { + if (SDLUpdateMode_RESUME == nil) { + SDLUpdateMode_RESUME = [[SDLUpdateMode alloc] initWithValue:@"RESUME"]; + } + return SDLUpdateMode_RESUME; +} + ++ (SDLUpdateMode *)CLEAR { + if (SDLUpdateMode_CLEAR == nil) { + SDLUpdateMode_CLEAR = [[SDLUpdateMode alloc] initWithValue:@"CLEAR"]; + } + return SDLUpdateMode_CLEAR; +} + +@end diff --git a/SmartDeviceLink/SDLUpdateTurnList.h b/SmartDeviceLink/SDLUpdateTurnList.h new file mode 100644 index 000000000..d5d9daf6a --- /dev/null +++ b/SmartDeviceLink/SDLUpdateTurnList.h @@ -0,0 +1,28 @@ +// SDLUpdateTurnList.h +// + + +#import "SDLRPCRequest.h" + +/** Updates the list of next maneuvers, which can be requested by the user pressing the softbutton<br> + * “Turns” on the Navigation base screen. Three softbuttons are predefined by the system: Up, Down, Close. + *<p> + * @since SmartDeviceLink 2.0 + */ +@interface SDLUpdateTurnList : SDLRPCRequest { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * Optional, SDLTurn, 1 - 100 entries + */ +@property (strong) NSMutableArray *turnList; + +/** + * Required, SDLSoftButton, 0 - 1 Entries + */ +@property (strong) NSMutableArray *softButtons; + +@end diff --git a/SmartDeviceLink/SDLUpdateTurnList.m b/SmartDeviceLink/SDLUpdateTurnList.m new file mode 100644 index 000000000..7063c9c29 --- /dev/null +++ b/SmartDeviceLink/SDLUpdateTurnList.m @@ -0,0 +1,67 @@ +// SDLUpdateTurnList.m +// + + +#import "SDLUpdateTurnList.h" + +#import "SDLNames.h" +#import "SDLSoftButton.h" +#import "SDLTurn.h" + +@implementation SDLUpdateTurnList + +- (instancetype)init { + if (self = [super initWithName:NAMES_UpdateTurnList]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setTurnList:(NSMutableArray *)turnList { + if (turnList != nil) { + [parameters setObject:turnList forKey:NAMES_turnList]; + } else { + [parameters removeObjectForKey:NAMES_turnList]; + } +} + +- (NSMutableArray *)turnList { + NSMutableArray *array = [parameters objectForKey:NAMES_turnList]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLTurn.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLTurn alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +- (void)setSoftButtons:(NSMutableArray *)softButtons { + if (softButtons != nil) { + [parameters setObject:softButtons forKey:NAMES_softButtons]; + } else { + [parameters removeObjectForKey:NAMES_softButtons]; + } +} + +- (NSMutableArray *)softButtons { + NSMutableArray *array = [parameters objectForKey:NAMES_softButtons]; + if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLSoftButton.class]) { + return array; + } else { + NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]]; + for (NSDictionary *dict in array) { + [newList addObject:[[SDLSoftButton alloc] initWithDictionary:(NSMutableDictionary *)dict]]; + } + return newList; + } +} + +@end diff --git a/SmartDeviceLink/SDLUpdateTurnListResponse.h b/SmartDeviceLink/SDLUpdateTurnListResponse.h new file mode 100644 index 000000000..c02c912e9 --- /dev/null +++ b/SmartDeviceLink/SDLUpdateTurnListResponse.h @@ -0,0 +1,16 @@ +// SDLUpdateTurnListResponse.h +// + +#import "SDLRPCResponse.h" + + +/** SDLUpdateTurnListResponse is sent, when SDLUpdateTurnList has been called. + * Since<b>SmartDeviceLink 2.0</b> + */ +@interface SDLUpdateTurnListResponse : SDLRPCResponse { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@end diff --git a/SmartDeviceLink/SDLUpdateTurnListResponse.m b/SmartDeviceLink/SDLUpdateTurnListResponse.m new file mode 100644 index 000000000..18e04082b --- /dev/null +++ b/SmartDeviceLink/SDLUpdateTurnListResponse.m @@ -0,0 +1,23 @@ +// SDLUpdateTurnListResponse.m +// + + +#import "SDLUpdateTurnListResponse.h" + +#import "SDLNames.h" + +@implementation SDLUpdateTurnListResponse + +- (instancetype)init { + if (self = [super initWithName:NAMES_UpdateTurnList]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +@end diff --git a/SmartDeviceLink/SDLV1ProtocolHeader.h b/SmartDeviceLink/SDLV1ProtocolHeader.h new file mode 100644 index 000000000..b7fa454f2 --- /dev/null +++ b/SmartDeviceLink/SDLV1ProtocolHeader.h @@ -0,0 +1,14 @@ +// SDLSmartDeviceLinkV1ProtocolHeader.h +// + + +#import "SDLProtocolHeader.h" + +@interface SDLV1ProtocolHeader : SDLProtocolHeader + +- (instancetype)init; +- (NSData *)data; +- (void)parse:(NSData *)data; +- (NSString *)description; + +@end diff --git a/SmartDeviceLink/SDLV1ProtocolHeader.m b/SmartDeviceLink/SDLV1ProtocolHeader.m new file mode 100644 index 000000000..61c976c51 --- /dev/null +++ b/SmartDeviceLink/SDLV1ProtocolHeader.m @@ -0,0 +1,84 @@ +// SDLSmartDeviceLinkV1ProtocolHeader.m +// + + +#import "SDLV1ProtocolHeader.h" + +const int V1PROTOCOL_HEADERSIZE = 8; + +@implementation SDLV1ProtocolHeader + +- (instancetype)init { + if (self = [super init]) { + _version = 1; + _size = V1PROTOCOL_HEADERSIZE; + } + return self; +} + +- (NSData *)data { + // Assembles the properties in the binary header format + Byte headerBytes[V1PROTOCOL_HEADERSIZE] = {0}; + + Byte version = (self.version & 0xF) << 4; // first 4 bits + Byte compressed = (self.compressed ? 1 : 0) << 3; // next 1 bit + Byte frameType = (self.frameType & 0x7); // last 3 bits + + headerBytes[0] = version | compressed | frameType; + headerBytes[1] = self.serviceType; + headerBytes[2] = self.frameData; + headerBytes[3] = self.sessionID; + + // Need to write the larger ints as big-endian. + UInt32 *p = (UInt32 *)&headerBytes[4]; + *p = CFSwapInt32HostToBig(self.bytesInPayload); // swap the byte order + + // Now put it all in an NSData object. + NSData *dataOut = [NSData dataWithBytes:headerBytes length:V1PROTOCOL_HEADERSIZE]; + + return dataOut; +} + +- (id)copyWithZone:(NSZone *)zone { + SDLV1ProtocolHeader *newHeader = [[SDLV1ProtocolHeader allocWithZone:zone] init]; + newHeader.compressed = self.compressed; + newHeader.frameType = self.frameType; + newHeader.serviceType = self.serviceType; + newHeader.frameData = self.frameData; + newHeader.bytesInPayload = self.bytesInPayload; + newHeader.sessionID = self.sessionID; + + return newHeader; +} + +- (void)parse:(NSData *)data { + NSParameterAssert(data != nil); + NSAssert(data.length >= _size, @"Error: insufficient data available to parse V1 header."); + + Byte *bytePointer = (Byte *)data.bytes; + Byte firstByte = bytePointer[0]; + self.compressed = ((firstByte & 8) != 0); + self.frameType = (firstByte & 7); + self.serviceType = bytePointer[1]; + self.frameData = bytePointer[2]; + self.sessionID = bytePointer[3]; + + UInt32 *uintPointer = (UInt32 *)data.bytes; + self.bytesInPayload = CFSwapInt32BigToHost(uintPointer[1]); // Data is coming in in big-endian, so swap it. +} + +- (NSString *)description { + NSMutableString *description = [[NSMutableString alloc] init]; + [description appendFormat:@"Version:%i, compressed:%i, frameType:%i, serviceType:%i, frameData:%i, sessionID:%i, dataSize:%i", + self.version, + self.compressed, + self.frameType, + self.serviceType, + self.frameData, + self.sessionID, + (unsigned int)self.bytesInPayload]; + return description; +} + + +@end diff --git a/SmartDeviceLink/SDLV1ProtocolMessage.h b/SmartDeviceLink/SDLV1ProtocolMessage.h new file mode 100644 index 000000000..39f26e76e --- /dev/null +++ b/SmartDeviceLink/SDLV1ProtocolMessage.h @@ -0,0 +1,14 @@ +// SDLV1ProtocolMessage.h +// + +#import "SDLProtocolMessage.h" + +@class SDLProtocolHeader; + + +@interface SDLV1ProtocolMessage : SDLProtocolMessage + +- (instancetype)initWithHeader:(SDLProtocolHeader *)header andPayload:(NSData *)payload; +- (NSDictionary *)rpcDictionary; + +@end diff --git a/SmartDeviceLink/SDLV1ProtocolMessage.m b/SmartDeviceLink/SDLV1ProtocolMessage.m new file mode 100644 index 000000000..736dd0b13 --- /dev/null +++ b/SmartDeviceLink/SDLV1ProtocolMessage.m @@ -0,0 +1,24 @@ +// SDLV1ProtocolMessage.m +// + +#import "SDLV1ProtocolMessage.h" +#import "SDLJsonDecoder.h" +#import "SDLProtocolHeader.h" + + +@implementation SDLV1ProtocolMessage + +- (instancetype)initWithHeader:(SDLProtocolHeader *)header andPayload:(NSData *)payload { + if (self = [self init]) { + self.header = header; + self.payload = payload; + } + return self; +} + +- (NSDictionary *)rpcDictionary { + NSDictionary *rpcMessageAsDictionary = [[SDLJsonDecoder instance] decode:self.payload]; + return rpcMessageAsDictionary; +} + +@end diff --git a/SmartDeviceLink/SDLV2ProtocolHeader.h b/SmartDeviceLink/SDLV2ProtocolHeader.h new file mode 100644 index 000000000..c7a0d4272 --- /dev/null +++ b/SmartDeviceLink/SDLV2ProtocolHeader.h @@ -0,0 +1,17 @@ +// SDLSmartDeviceLinkV2ProtocolHeader.h +// + + +#import "SDLProtocolHeader.h" + +@interface SDLV2ProtocolHeader : SDLProtocolHeader + +@property (assign) UInt32 messageID; + +- (instancetype)init; +- (instancetype)initWithVersion:(UInt8)version; +- (NSData *)data; +- (void)parse:(NSData *)data; +- (NSString *)description; + +@end diff --git a/SmartDeviceLink/SDLV2ProtocolHeader.m b/SmartDeviceLink/SDLV2ProtocolHeader.m new file mode 100644 index 000000000..42f915cb8 --- /dev/null +++ b/SmartDeviceLink/SDLV2ProtocolHeader.m @@ -0,0 +1,124 @@ +// SDLSmartDeviceLinkV2ProtocolHeader.m +// + + +#import "SDLV2ProtocolHeader.h" + +const int V2PROTOCOL_HEADERSIZE = 12; + + +@interface SDLV2ProtocolHeader () + +@end + + +@implementation SDLV2ProtocolHeader + +- (instancetype)init { + // TODO: Should this be changed to whatever the current version is from SDLGlobals + return [self initWithVersion:2]; +} + +- (instancetype)initWithVersion:(UInt8)version { + if (self = [super init]) { + _version = version; + _size = V2PROTOCOL_HEADERSIZE; + } + return self; +} + +- (NSData *)data { + // Assembles the properties in the binary header format + Byte headerBytes[V2PROTOCOL_HEADERSIZE] = {0}; + + Byte version = (self.version & 0xF) << 4; // first 4 bits + Byte compressed = (self.compressed ? 1 : 0) << 3; // next 1 bit + Byte frameType = (self.frameType & 0x7); // last 3 bits + + headerBytes[0] = version | compressed | frameType; + headerBytes[1] = self.serviceType; + headerBytes[2] = self.frameData; + headerBytes[3] = self.sessionID; + + // Need to write these ints as big-endian. + UInt32 *p = (UInt32 *)&headerBytes[4]; + *p = CFSwapInt32HostToBig(self.bytesInPayload); + + p = (UInt32 *)&headerBytes[8]; + *p = CFSwapInt32HostToBig(self.messageID); + + // Now put it all in an NSData object. + NSData *dataOut = [NSData dataWithBytes:headerBytes length:V2PROTOCOL_HEADERSIZE]; + + return dataOut; +} + +- (id)copyWithZone:(NSZone *)zone { + SDLV2ProtocolHeader *newHeader = [[SDLV2ProtocolHeader allocWithZone:zone] init]; + newHeader->_version = self.version; + newHeader.compressed = self.compressed; + newHeader.frameType = self.frameType; + newHeader.serviceType = self.serviceType; + newHeader.frameData = self.frameData; + newHeader.bytesInPayload = self.bytesInPayload; + newHeader.sessionID = self.sessionID; + newHeader.messageID = self.messageID; + + return newHeader; +} + +- (void)parse:(NSData *)data { + NSParameterAssert(data != nil); + NSAssert(data.length >= _size, @"Error: insufficient data available to parse V2 header."); + + Byte *bytePointer = (Byte *)data.bytes; + Byte firstByte = bytePointer[0]; + self.compressed = ((firstByte & 8) != 0); + self.frameType = (firstByte & 7); + self.serviceType = bytePointer[1]; + self.frameData = bytePointer[2]; + self.sessionID = bytePointer[3]; + + UInt32 *uintPointer = (UInt32 *)data.bytes; + self.bytesInPayload = CFSwapInt32BigToHost(uintPointer[1]); // Data is coming in in big-endian, so swap it. + self.messageID = CFSwapInt32BigToHost(uintPointer[2]); // Data is coming in in big-endian, so swap it. +} + +- (NSString *)description { + NSString *frameTypeString = nil; + if (self.frameType >= 0 && self.frameType <= 3) { + NSArray *frameTypeNames = @[ @"Control", @"Single", @"First", @"Consecutive" ]; + frameTypeString = frameTypeNames[self.frameType]; + } + + + NSString *frameDataString = nil; + if (self.frameType == SDLFrameType_Control) { + if (self.frameData >= 0 && self.frameData <= 5) { + NSArray *controlFrameDataNames = @[ @"Heartbeat", @"StartSession", @"StartSessionACK", @"StartSessionNACK", @"EndSession", @"EndSessionNACK" ]; + frameDataString = controlFrameDataNames[self.frameData]; + } else { + frameDataString = @"Reserved"; + } + } else if (self.frameType == SDLFrameType_Single || self.frameType == SDLFrameType_First) { + frameDataString = @"Reserved"; + } else if (self.frameType == SDLFrameType_Consecutive) { + frameDataString = @"Frame#"; + } + + NSMutableString *description = [[NSMutableString alloc] init]; + [description appendFormat:@"Version:%i, compressed:%i, frameType:%@(%i), serviceType:%i, frameData:%@(%i), sessionID:%i, dataSize:%i, messageID:%i ", + self.version, + self.compressed, + frameTypeString, + self.frameType, + self.serviceType, + frameDataString, + self.frameData, + self.sessionID, + (unsigned int)self.bytesInPayload, + (unsigned int)self.messageID]; + return description; +} + +@end diff --git a/SmartDeviceLink/SDLV2ProtocolMessage.h b/SmartDeviceLink/SDLV2ProtocolMessage.h new file mode 100644 index 000000000..6f9912cf9 --- /dev/null +++ b/SmartDeviceLink/SDLV2ProtocolMessage.h @@ -0,0 +1,15 @@ +// SDLSmartDeviceLinkV2ProtocolMessage.h +// + + +#import "SDLProtocolMessage.h" + +@class SDLProtocolHeader; + + +@interface SDLV2ProtocolMessage : SDLProtocolMessage + +- (instancetype)initWithHeader:(SDLProtocolHeader *)header andPayload:(NSData *)payload; +- (NSDictionary *)rpcDictionary; + +@end diff --git a/SmartDeviceLink/SDLV2ProtocolMessage.m b/SmartDeviceLink/SDLV2ProtocolMessage.m new file mode 100644 index 000000000..683c10335 --- /dev/null +++ b/SmartDeviceLink/SDLV2ProtocolMessage.m @@ -0,0 +1,60 @@ +// SDLSmartDeviceLinkV2ProtocolMessage.m +// + +#import "SDLV2ProtocolMessage.h" +#import "SDLFunctionID.h" +#import "SDLJsonDecoder.h" +#import "SDLNames.h" +#import "SDLProtocolHeader.h" +#import "SDLRPCPayload.h" + + +@implementation SDLV2ProtocolMessage + +- (instancetype)initWithHeader:(SDLProtocolHeader *)header andPayload:(NSData *)payload { + if (self = [self init]) { + self.header = header; + self.payload = payload; + } + return self; +} + +// Convert RPC payload to dictionary (for consumption by RPC layer) +- (NSDictionary *)rpcDictionary { + // Only applicable to RPCs + if ((self.header.serviceType != SDLServiceType_RPC) && (self.header.serviceType != SDLServiceType_BulkData)) { + return nil; + } + + NSMutableDictionary *rpcMessageAsDictionary = [[NSMutableDictionary alloc] init]; + + // Parse the payload as RPC struct + SDLRPCPayload *rpcPayload = [SDLRPCPayload rpcPayloadWithData:self.payload]; + + // Create the inner dictionary with the RPC properties + NSMutableDictionary *innerDictionary = [[NSMutableDictionary alloc] init]; + NSString *functionName = [[[SDLFunctionID alloc] init] getFunctionName:rpcPayload.functionID]; + [innerDictionary setObject:functionName forKey:NAMES_operation_name]; + [innerDictionary setObject:[NSNumber numberWithInt:rpcPayload.correlationID] forKey:NAMES_correlationID]; + + // Get the json data from the struct + if (rpcPayload.jsonData) { + NSDictionary *jsonDictionary = [[SDLJsonDecoder instance] decode:rpcPayload.jsonData]; + if (jsonDictionary) { + [innerDictionary setObject:jsonDictionary forKey:NAMES_parameters]; + } + } + + // Store it in the containing dictionary + UInt8 rpcType = rpcPayload.rpcType; + NSArray *rpcTypeNames = @[ NAMES_request, NAMES_response, NAMES_notification ]; + [rpcMessageAsDictionary setObject:innerDictionary forKey:rpcTypeNames[rpcType]]; + + // The bulk data also goes in the dictionary + if (rpcPayload.binaryData) { + [rpcMessageAsDictionary setObject:rpcPayload.binaryData forKey:NAMES_bulkData]; + } + + return rpcMessageAsDictionary; +} +@end diff --git a/SmartDeviceLink/SDLVehicleDataActiveStatus.h b/SmartDeviceLink/SDLVehicleDataActiveStatus.h new file mode 100644 index 000000000..dbb36b550 --- /dev/null +++ b/SmartDeviceLink/SDLVehicleDataActiveStatus.h @@ -0,0 +1,46 @@ +// SDLVehicleDataActiveStatus.h +// + + +#import "SDLEnum.h" + +/** + Vehicle Data Activity Status + */ +@interface SDLVehicleDataActiveStatus : SDLEnum { +} + +/** + * @abstract Convert String to SDLVehicleDataActiveStatus + * @param value NSString + * @return SDLVehicleDataActiveStatus + */ ++ (SDLVehicleDataActiveStatus *)valueOf:(NSString *)value; + +/** + @abstract return the array that store all possible SDLVehicleDataActiveStatus values + */ ++ (NSArray *)values; + +/** + @abstract SDLVehicleDataActiveStatus : Inactive not confirmed + */ ++ (SDLVehicleDataActiveStatus *)INACTIVE_NOT_CONFIRMED; +/** + @abstract SDLVehicleDataActiveStatus : Inactive confirmed + */ ++ (SDLVehicleDataActiveStatus *)INACTIVE_CONFIRMED; +/** + @abstract SDLVehicleDataActiveStatus : Active not confirmed + */ ++ (SDLVehicleDataActiveStatus *)ACTIVE_NOT_CONFIRMED; +/** + @abstract SDLVehicleDataActiveStatus : Active confirmed + */ ++ (SDLVehicleDataActiveStatus *)ACTIVE_CONFIRMED; +/** + @abstract SDLVehicleDataActiveStatus : Fault + */ ++ (SDLVehicleDataActiveStatus *)FAULT; + +@end diff --git a/SmartDeviceLink/SDLVehicleDataActiveStatus.m b/SmartDeviceLink/SDLVehicleDataActiveStatus.m new file mode 100644 index 000000000..98bf85738 --- /dev/null +++ b/SmartDeviceLink/SDLVehicleDataActiveStatus.m @@ -0,0 +1,74 @@ +// SDLVehicleDataActiveStatus.m +// + + +#import "SDLVehicleDataActiveStatus.h" + +SDLVehicleDataActiveStatus *SDLVehicleDataActiveStatus_INACTIVE_NOT_CONFIRMED = nil; +SDLVehicleDataActiveStatus *SDLVehicleDataActiveStatus_INACTIVE_CONFIRMED = nil; +SDLVehicleDataActiveStatus *SDLVehicleDataActiveStatus_ACTIVE_NOT_CONFIRMED = nil; +SDLVehicleDataActiveStatus *SDLVehicleDataActiveStatus_ACTIVE_CONFIRMED = nil; +SDLVehicleDataActiveStatus *SDLVehicleDataActiveStatus_FAULT = nil; + +NSArray *SDLVehicleDataActiveStatus_values = nil; + +@implementation SDLVehicleDataActiveStatus + ++ (SDLVehicleDataActiveStatus *)valueOf:(NSString *)value { + for (SDLVehicleDataActiveStatus *item in SDLVehicleDataActiveStatus.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLVehicleDataActiveStatus_values == nil) { + SDLVehicleDataActiveStatus_values = @[ + SDLVehicleDataActiveStatus.INACTIVE_NOT_CONFIRMED, + SDLVehicleDataActiveStatus.INACTIVE_CONFIRMED, + SDLVehicleDataActiveStatus.ACTIVE_NOT_CONFIRMED, + SDLVehicleDataActiveStatus.ACTIVE_CONFIRMED, + SDLVehicleDataActiveStatus.FAULT, + ]; + } + return SDLVehicleDataActiveStatus_values; +} + ++ (SDLVehicleDataActiveStatus *)INACTIVE_NOT_CONFIRMED { + if (SDLVehicleDataActiveStatus_INACTIVE_NOT_CONFIRMED == nil) { + SDLVehicleDataActiveStatus_INACTIVE_NOT_CONFIRMED = [[SDLVehicleDataActiveStatus alloc] initWithValue:@"INACTIVE_NOT_CONFIRMED"]; + } + return SDLVehicleDataActiveStatus_INACTIVE_NOT_CONFIRMED; +} + ++ (SDLVehicleDataActiveStatus *)INACTIVE_CONFIRMED { + if (SDLVehicleDataActiveStatus_INACTIVE_CONFIRMED == nil) { + SDLVehicleDataActiveStatus_INACTIVE_CONFIRMED = [[SDLVehicleDataActiveStatus alloc] initWithValue:@"INACTIVE_CONFIRMED"]; + } + return SDLVehicleDataActiveStatus_INACTIVE_CONFIRMED; +} + ++ (SDLVehicleDataActiveStatus *)ACTIVE_NOT_CONFIRMED { + if (SDLVehicleDataActiveStatus_ACTIVE_NOT_CONFIRMED == nil) { + SDLVehicleDataActiveStatus_ACTIVE_NOT_CONFIRMED = [[SDLVehicleDataActiveStatus alloc] initWithValue:@"ACTIVE_NOT_CONFIRMED"]; + } + return SDLVehicleDataActiveStatus_ACTIVE_NOT_CONFIRMED; +} + ++ (SDLVehicleDataActiveStatus *)ACTIVE_CONFIRMED { + if (SDLVehicleDataActiveStatus_ACTIVE_CONFIRMED == nil) { + SDLVehicleDataActiveStatus_ACTIVE_CONFIRMED = [[SDLVehicleDataActiveStatus alloc] initWithValue:@"ACTIVE_CONFIRMED"]; + } + return SDLVehicleDataActiveStatus_ACTIVE_CONFIRMED; +} + ++ (SDLVehicleDataActiveStatus *)FAULT { + if (SDLVehicleDataActiveStatus_FAULT == nil) { + SDLVehicleDataActiveStatus_FAULT = [[SDLVehicleDataActiveStatus alloc] initWithValue:@"FAULT"]; + } + return SDLVehicleDataActiveStatus_FAULT; +} + +@end diff --git a/SmartDeviceLink/SDLVehicleDataEventStatus.h b/SmartDeviceLink/SDLVehicleDataEventStatus.h new file mode 100644 index 000000000..880e4ec2d --- /dev/null +++ b/SmartDeviceLink/SDLVehicleDataEventStatus.h @@ -0,0 +1,58 @@ +// SDLVehicleDataEventStatus.h +// + + +#import "SDLEnum.h" + +/** + * Reflects the status of a vehicle data event; e.g. a seat belt event status. + * + * @since SDL 2.0 + */ +@interface SDLVehicleDataEventStatus : SDLEnum { +} + +/** + * Convert String to SDLVehicleDataEventStatus + * + * @param value The value of the string to get an object for + * + * @return SDLVehicleDataEventStatus + */ ++ (SDLVehicleDataEventStatus *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLVehicleDataEventStatus + * + * @return an array that store all possible SDLVehicleDataEventStatus + */ ++ (NSArray *)values; + +/** + * @return The SDLVehicleDataEventStatus instance with value of *NO_EVENT* + */ ++ (SDLVehicleDataEventStatus *)NO_EVENT; + +/** + * @return The SDLVehicleDataEventStatus instance with value of *NO* + */ ++ (SDLVehicleDataEventStatus *)_NO; + +/** + * @return The SDLVehicleDataEventStatus instance with value of *YES* + */ ++ (SDLVehicleDataEventStatus *)_YES; + +/** + * @abstract Vehicle data event is not supported + * + * @return the SDLVehicleDataEventStatus instance with value of *NOT_SUPPORTED* + */ ++ (SDLVehicleDataEventStatus *)NOT_SUPPORTED; + +/** + * @abstract The SDLVehicleDataEventStatus instance with value of *FAULT* + */ ++ (SDLVehicleDataEventStatus *)FAULT; + +@end diff --git a/SmartDeviceLink/SDLVehicleDataEventStatus.m b/SmartDeviceLink/SDLVehicleDataEventStatus.m new file mode 100644 index 000000000..a27178886 --- /dev/null +++ b/SmartDeviceLink/SDLVehicleDataEventStatus.m @@ -0,0 +1,74 @@ +// SDLVehicleDataEventStatus.m +// + + +#import "SDLVehicleDataEventStatus.h" + +SDLVehicleDataEventStatus *SDLVehicleDataEventStatus_NO_EVENT = nil; +SDLVehicleDataEventStatus *SDLVehicleDataEventStatus_NO = nil; +SDLVehicleDataEventStatus *SDLVehicleDataEventStatus_YES = nil; +SDLVehicleDataEventStatus *SDLVehicleDataEventStatus_NOT_SUPPORTED = nil; +SDLVehicleDataEventStatus *SDLVehicleDataEventStatus_FAULT = nil; + +NSArray *SDLVehicleDataEventStatus_values = nil; + +@implementation SDLVehicleDataEventStatus + ++ (SDLVehicleDataEventStatus *)valueOf:(NSString *)value { + for (SDLVehicleDataEventStatus *item in SDLVehicleDataEventStatus.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLVehicleDataEventStatus_values == nil) { + SDLVehicleDataEventStatus_values = @[ + SDLVehicleDataEventStatus.NO_EVENT, + SDLVehicleDataEventStatus._NO, + SDLVehicleDataEventStatus._YES, + SDLVehicleDataEventStatus.NOT_SUPPORTED, + SDLVehicleDataEventStatus.FAULT, + ]; + } + return SDLVehicleDataEventStatus_values; +} + ++ (SDLVehicleDataEventStatus *)NO_EVENT { + if (SDLVehicleDataEventStatus_NO_EVENT == nil) { + SDLVehicleDataEventStatus_NO_EVENT = [[SDLVehicleDataEventStatus alloc] initWithValue:@"NO_EVENT"]; + } + return SDLVehicleDataEventStatus_NO_EVENT; +} + ++ (SDLVehicleDataEventStatus *)_NO { + if (SDLVehicleDataEventStatus_NO == nil) { + SDLVehicleDataEventStatus_NO = [[SDLVehicleDataEventStatus alloc] initWithValue:@"NO"]; + } + return SDLVehicleDataEventStatus_NO; +} + ++ (SDLVehicleDataEventStatus *)_YES { + if (SDLVehicleDataEventStatus_YES == nil) { + SDLVehicleDataEventStatus_YES = [[SDLVehicleDataEventStatus alloc] initWithValue:@"YES"]; + } + return SDLVehicleDataEventStatus_YES; +} + ++ (SDLVehicleDataEventStatus *)NOT_SUPPORTED { + if (SDLVehicleDataEventStatus_NOT_SUPPORTED == nil) { + SDLVehicleDataEventStatus_NOT_SUPPORTED = [[SDLVehicleDataEventStatus alloc] initWithValue:@"NOT_SUPPORTED"]; + } + return SDLVehicleDataEventStatus_NOT_SUPPORTED; +} + ++ (SDLVehicleDataEventStatus *)FAULT { + if (SDLVehicleDataEventStatus_FAULT == nil) { + SDLVehicleDataEventStatus_FAULT = [[SDLVehicleDataEventStatus alloc] initWithValue:@"FAULT"]; + } + return SDLVehicleDataEventStatus_FAULT; +} + +@end diff --git a/SmartDeviceLink/SDLVehicleDataNotificationStatus.h b/SmartDeviceLink/SDLVehicleDataNotificationStatus.h new file mode 100644 index 000000000..24a3fc372 --- /dev/null +++ b/SmartDeviceLink/SDLVehicleDataNotificationStatus.h @@ -0,0 +1,48 @@ +// SDLVehicleDataNotificationStatus.h +// + + +#import "SDLEnum.h" + +/** + * Reflects the status of a vehicle data notification. + * + * @since SDL 2.0 + */ +@interface SDLVehicleDataNotificationStatus : SDLEnum { +} + +/** + * Convert String to SDLVehicleDataNotificationStatus + * @param value The value of the string to get an object for + * @return SDLVehicleDataNotificationStatus + */ ++ (SDLVehicleDataNotificationStatus *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLVehicleDataNotificationStatus + * @return an array that store all possible SDLVehicleDataNotificationStatus + */ ++ (NSArray *)values; + +/** + * @abstract SDLVehicleDataNotificationStatus: *NOT_SUPPORTED* + */ ++ (SDLVehicleDataNotificationStatus *)NOT_SUPPORTED; + +/** + @abstract SDLVehicleDataNotificationStatus: *NORMAL* + */ ++ (SDLVehicleDataNotificationStatus *)NORMAL; + +/** + @abstract SDLVehicleDataNotificationStatus: *ACTIVE* + */ ++ (SDLVehicleDataNotificationStatus *)ACTIVE; + +/** + @abstract SDLVehicleDataNotificationStatus: *NOT_USED* + */ ++ (SDLVehicleDataNotificationStatus *)NOT_USED; + +@end diff --git a/SmartDeviceLink/SDLVehicleDataNotificationStatus.m b/SmartDeviceLink/SDLVehicleDataNotificationStatus.m new file mode 100644 index 000000000..40d66d163 --- /dev/null +++ b/SmartDeviceLink/SDLVehicleDataNotificationStatus.m @@ -0,0 +1,65 @@ +// SDLVehicleDataNotificationStatus.m +// + + +#import "SDLVehicleDataNotificationStatus.h" + +SDLVehicleDataNotificationStatus *SDLVehicleDataNotificationStatus_NOT_SUPPORTED = nil; +SDLVehicleDataNotificationStatus *SDLVehicleDataNotificationStatus_NORMAL = nil; +SDLVehicleDataNotificationStatus *SDLVehicleDataNotificationStatus_ACTIVE = nil; +SDLVehicleDataNotificationStatus *SDLVehicleDataNotificationStatus_NOT_USED = nil; + +NSArray *SDLVehicleDataNotificationStatus_values = nil; + +@implementation SDLVehicleDataNotificationStatus + ++ (SDLVehicleDataNotificationStatus *)valueOf:(NSString *)value { + for (SDLVehicleDataNotificationStatus *item in SDLVehicleDataNotificationStatus.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLVehicleDataNotificationStatus_values == nil) { + SDLVehicleDataNotificationStatus_values = @[ + SDLVehicleDataNotificationStatus.NOT_SUPPORTED, + SDLVehicleDataNotificationStatus.NORMAL, + SDLVehicleDataNotificationStatus.ACTIVE, + SDLVehicleDataNotificationStatus.NOT_USED, + ]; + } + return SDLVehicleDataNotificationStatus_values; +} + ++ (SDLVehicleDataNotificationStatus *)NOT_SUPPORTED { + if (SDLVehicleDataNotificationStatus_NOT_SUPPORTED == nil) { + SDLVehicleDataNotificationStatus_NOT_SUPPORTED = [[SDLVehicleDataNotificationStatus alloc] initWithValue:@"NOT_SUPPORTED"]; + } + return SDLVehicleDataNotificationStatus_NOT_SUPPORTED; +} + ++ (SDLVehicleDataNotificationStatus *)NORMAL { + if (SDLVehicleDataNotificationStatus_NORMAL == nil) { + SDLVehicleDataNotificationStatus_NORMAL = [[SDLVehicleDataNotificationStatus alloc] initWithValue:@"NORMAL"]; + } + return SDLVehicleDataNotificationStatus_NORMAL; +} + ++ (SDLVehicleDataNotificationStatus *)ACTIVE { + if (SDLVehicleDataNotificationStatus_ACTIVE == nil) { + SDLVehicleDataNotificationStatus_ACTIVE = [[SDLVehicleDataNotificationStatus alloc] initWithValue:@"ACTIVE"]; + } + return SDLVehicleDataNotificationStatus_ACTIVE; +} + ++ (SDLVehicleDataNotificationStatus *)NOT_USED { + if (SDLVehicleDataNotificationStatus_NOT_USED == nil) { + SDLVehicleDataNotificationStatus_NOT_USED = [[SDLVehicleDataNotificationStatus alloc] initWithValue:@"NOT_USED"]; + } + return SDLVehicleDataNotificationStatus_NOT_USED; +} + +@end diff --git a/SmartDeviceLink/SDLVehicleDataResult.h b/SmartDeviceLink/SDLVehicleDataResult.h new file mode 100644 index 000000000..9a03e5d07 --- /dev/null +++ b/SmartDeviceLink/SDLVehicleDataResult.h @@ -0,0 +1,19 @@ +// SDLVehicleDataResult.h +// + +#import "SDLRPCMessage.h" + +@class SDLVehicleDataType; +@class SDLVehicleDataResultCode; + + +@interface SDLVehicleDataResult : SDLRPCStruct { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) SDLVehicleDataType *dataType; +@property (strong) SDLVehicleDataResultCode *resultCode; + +@end diff --git a/SmartDeviceLink/SDLVehicleDataResult.m b/SmartDeviceLink/SDLVehicleDataResult.m new file mode 100644 index 000000000..e395717eb --- /dev/null +++ b/SmartDeviceLink/SDLVehicleDataResult.m @@ -0,0 +1,59 @@ +// SDLVehicleDataResult.m +// + +#import "SDLVehicleDataResult.h" + +#import "SDLNames.h" +#import "SDLVehicleDataResultCode.h" +#import "SDLVehicleDataType.h" + + +@implementation SDLVehicleDataResult + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setDataType:(SDLVehicleDataType *)dataType { + if (dataType != nil) { + [store setObject:dataType forKey:NAMES_dataType]; + } else { + [store removeObjectForKey:NAMES_dataType]; + } +} + +- (SDLVehicleDataType *)dataType { + NSObject *obj = [store objectForKey:NAMES_dataType]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataType.class]) { + return (SDLVehicleDataType *)obj; + } else { + return [SDLVehicleDataType valueOf:(NSString *)obj]; + } +} + +- (void)setResultCode:(SDLVehicleDataResultCode *)resultCode { + if (resultCode != nil) { + [store setObject:resultCode forKey:NAMES_resultCode]; + } else { + [store removeObjectForKey:NAMES_resultCode]; + } +} + +- (SDLVehicleDataResultCode *)resultCode { + NSObject *obj = [store objectForKey:NAMES_resultCode]; + if (obj == nil || [obj isKindOfClass:SDLVehicleDataResultCode.class]) { + return (SDLVehicleDataResultCode *)obj; + } else { + return [SDLVehicleDataResultCode valueOf:(NSString *)obj]; + } +} + +@end diff --git a/SmartDeviceLink/SDLVehicleDataResultCode.h b/SmartDeviceLink/SDLVehicleDataResultCode.h new file mode 100644 index 000000000..162ecff59 --- /dev/null +++ b/SmartDeviceLink/SDLVehicleDataResultCode.h @@ -0,0 +1,71 @@ +// SDLVehicleDataResultCode.h +// + + +#import "SDLEnum.h" + +/** + Vehicle Data Result Code + */ +@interface SDLVehicleDataResultCode : SDLEnum { +} + +/** + * Convert String to SDLVehicleDataResultCode + * @param value String + * @return SDLVehicleDataResultCode + */ ++ (SDLVehicleDataResultCode *)valueOf:(NSString *)value; + +/** + @abstract Store the enumeration of all possible SDLVehicleDataResultCode + @return an array that store all possible SDLVehicleDataResultCode + */ ++ (NSArray *)values; + +/** + * Individual vehicle data item / DTC / DID request or subscription successful + */ ++ (SDLVehicleDataResultCode *)SUCCESS; + +/** + * DTC / DID request successful, however, not all active DTCs or full contents of DID location available + */ ++ (SDLVehicleDataResultCode *)TRUNCATED_DATA; + +/** + * This vehicle data item is not allowed for this app by SDL + */ ++ (SDLVehicleDataResultCode *)DISALLOWED; + +/** + * The user has not granted access to this type of vehicle data item at this time + */ ++ (SDLVehicleDataResultCode *)USER_DISALLOWED; + +/** + * The ECU ID referenced is not a valid ID on the bus / system + */ ++ (SDLVehicleDataResultCode *)INVALID_ID; + +/** + * The requested vehicle data item / DTC / DID is not currently available or responding on the bus / system + */ ++ (SDLVehicleDataResultCode *)VEHICLE_DATA_NOT_AVAILABLE; + +/** + * The vehicle data item is already subscribed + */ ++ (SDLVehicleDataResultCode *)DATA_ALREADY_SUBSCRIBED; + +/** + * The vehicle data item cannot be unsubscribed because it is not currently subscribed + */ ++ (SDLVehicleDataResultCode *)DATA_NOT_SUBSCRIBED; + +/** + * The request for this item is ignored because it is already in progress + */ ++ (SDLVehicleDataResultCode *)IGNORED; + +@end diff --git a/SmartDeviceLink/SDLVehicleDataResultCode.m b/SmartDeviceLink/SDLVehicleDataResultCode.m new file mode 100644 index 000000000..8aa912568 --- /dev/null +++ b/SmartDeviceLink/SDLVehicleDataResultCode.m @@ -0,0 +1,110 @@ +// SDLVehicleDataResultCode.m +// + + +#import "SDLVehicleDataResultCode.h" + +SDLVehicleDataResultCode *SDLVehicleDataResultCode_SUCCESS = nil; +SDLVehicleDataResultCode *SDLVehicleDataResultCode_TRUNCATED_DATA = nil; +SDLVehicleDataResultCode *SDLVehicleDataResultCode_DISALLOWED = nil; +SDLVehicleDataResultCode *SDLVehicleDataResultCode_USER_DISALLOWED = nil; +SDLVehicleDataResultCode *SDLVehicleDataResultCode_INVALID_ID = nil; +SDLVehicleDataResultCode *SDLVehicleDataResultCode_VEHICLE_DATA_NOT_AVAILABLE = nil; +SDLVehicleDataResultCode *SDLVehicleDataResultCode_DATA_ALREADY_SUBSCRIBED = nil; +SDLVehicleDataResultCode *SDLVehicleDataResultCode_DATA_NOT_SUBSCRIBED = nil; +SDLVehicleDataResultCode *SDLVehicleDataResultCode_IGNORED = nil; + +NSArray *SDLVehicleDataResultCode_values = nil; + +@implementation SDLVehicleDataResultCode + ++ (SDLVehicleDataResultCode *)valueOf:(NSString *)value { + for (SDLVehicleDataResultCode *item in SDLVehicleDataResultCode.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLVehicleDataResultCode_values == nil) { + SDLVehicleDataResultCode_values = @[ + SDLVehicleDataResultCode.SUCCESS, + SDLVehicleDataResultCode.TRUNCATED_DATA, + SDLVehicleDataResultCode.DISALLOWED, + SDLVehicleDataResultCode.USER_DISALLOWED, + SDLVehicleDataResultCode.INVALID_ID, + SDLVehicleDataResultCode.VEHICLE_DATA_NOT_AVAILABLE, + SDLVehicleDataResultCode.DATA_ALREADY_SUBSCRIBED, + SDLVehicleDataResultCode.DATA_NOT_SUBSCRIBED, + SDLVehicleDataResultCode.IGNORED, + ]; + } + return SDLVehicleDataResultCode_values; +} + ++ (SDLVehicleDataResultCode *)SUCCESS { + if (SDLVehicleDataResultCode_SUCCESS == nil) { + SDLVehicleDataResultCode_SUCCESS = [[SDLVehicleDataResultCode alloc] initWithValue:@"SUCCESS"]; + } + return SDLVehicleDataResultCode_SUCCESS; +} + ++ (SDLVehicleDataResultCode *)TRUNCATED_DATA { + if (SDLVehicleDataResultCode_TRUNCATED_DATA == nil) { + SDLVehicleDataResultCode_TRUNCATED_DATA = [[SDLVehicleDataResultCode alloc] initWithValue:@"TRUNCATED_DATA"]; + } + return SDLVehicleDataResultCode_TRUNCATED_DATA; +} + ++ (SDLVehicleDataResultCode *)DISALLOWED { + if (SDLVehicleDataResultCode_DISALLOWED == nil) { + SDLVehicleDataResultCode_DISALLOWED = [[SDLVehicleDataResultCode alloc] initWithValue:@"DISALLOWED"]; + } + return SDLVehicleDataResultCode_DISALLOWED; +} + ++ (SDLVehicleDataResultCode *)USER_DISALLOWED { + if (SDLVehicleDataResultCode_USER_DISALLOWED == nil) { + SDLVehicleDataResultCode_USER_DISALLOWED = [[SDLVehicleDataResultCode alloc] initWithValue:@"USER_DISALLOWED"]; + } + return SDLVehicleDataResultCode_USER_DISALLOWED; +} + ++ (SDLVehicleDataResultCode *)INVALID_ID { + if (SDLVehicleDataResultCode_INVALID_ID == nil) { + SDLVehicleDataResultCode_INVALID_ID = [[SDLVehicleDataResultCode alloc] initWithValue:@"INVALID_ID"]; + } + return SDLVehicleDataResultCode_INVALID_ID; +} + ++ (SDLVehicleDataResultCode *)VEHICLE_DATA_NOT_AVAILABLE { + if (SDLVehicleDataResultCode_VEHICLE_DATA_NOT_AVAILABLE == nil) { + SDLVehicleDataResultCode_VEHICLE_DATA_NOT_AVAILABLE = [[SDLVehicleDataResultCode alloc] initWithValue:@"VEHICLE_DATA_NOT_AVAILABLE"]; + } + return SDLVehicleDataResultCode_VEHICLE_DATA_NOT_AVAILABLE; +} + ++ (SDLVehicleDataResultCode *)DATA_ALREADY_SUBSCRIBED { + if (SDLVehicleDataResultCode_DATA_ALREADY_SUBSCRIBED == nil) { + SDLVehicleDataResultCode_DATA_ALREADY_SUBSCRIBED = [[SDLVehicleDataResultCode alloc] initWithValue:@"DATA_ALREADY_SUBSCRIBED"]; + } + return SDLVehicleDataResultCode_DATA_ALREADY_SUBSCRIBED; +} + ++ (SDLVehicleDataResultCode *)DATA_NOT_SUBSCRIBED { + if (SDLVehicleDataResultCode_DATA_NOT_SUBSCRIBED == nil) { + SDLVehicleDataResultCode_DATA_NOT_SUBSCRIBED = [[SDLVehicleDataResultCode alloc] initWithValue:@"DATA_NOT_SUBSCRIBED"]; + } + return SDLVehicleDataResultCode_DATA_NOT_SUBSCRIBED; +} + ++ (SDLVehicleDataResultCode *)IGNORED { + if (SDLVehicleDataResultCode_IGNORED == nil) { + SDLVehicleDataResultCode_IGNORED = [[SDLVehicleDataResultCode alloc] initWithValue:@"IGNORED"]; + } + return SDLVehicleDataResultCode_IGNORED; +} + +@end diff --git a/SmartDeviceLink/SDLVehicleDataStatus.h b/SmartDeviceLink/SDLVehicleDataStatus.h new file mode 100644 index 000000000..e7720c924 --- /dev/null +++ b/SmartDeviceLink/SDLVehicleDataStatus.h @@ -0,0 +1,44 @@ +// SDLVehicleDataStatus.h +// + + +#import "SDLEnum.h" + +/** + * Reflects the status of a binary vehicle data item. + * + * @since SDL 2.0 + */ +@interface SDLVehicleDataStatus : SDLEnum { +} + +/** + * Convert String to SDLVehicleDataStatus + * @param value The value of the string to get an object for + * @return SDLVehicleDataStatus + */ ++ (SDLVehicleDataStatus *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLVehicleDataStatus + * @return an array that store all possible SDLVehicleDataStatus + */ ++ (NSArray *)values; + +/** + * @abstract No data avaliable + * @return SDLVehicleDataStatus: *NO_DATA_EXISTS* + */ ++ (SDLVehicleDataStatus *)NO_DATA_EXISTS; + +/** + * @abstract return SDLVehicleDataStatus: *OFF* + */ ++ (SDLVehicleDataStatus *)OFF; + +/** + * @abstract return SDLVehicleDataStatus: *ON* + */ ++ (SDLVehicleDataStatus *)ON; + +@end diff --git a/SmartDeviceLink/SDLVehicleDataStatus.m b/SmartDeviceLink/SDLVehicleDataStatus.m new file mode 100644 index 000000000..0fe108a1e --- /dev/null +++ b/SmartDeviceLink/SDLVehicleDataStatus.m @@ -0,0 +1,56 @@ +// SDLVehicleDataStatus.m +// + + +#import "SDLVehicleDataStatus.h" + +SDLVehicleDataStatus *SDLVehicleDataStatus_NO_DATA_EXISTS = nil; +SDLVehicleDataStatus *SDLVehicleDataStatus_OFF = nil; +SDLVehicleDataStatus *SDLVehicleDataStatus_ON = nil; + +NSArray *SDLVehicleDataStatus_values = nil; + +@implementation SDLVehicleDataStatus + ++ (SDLVehicleDataStatus *)valueOf:(NSString *)value { + for (SDLVehicleDataStatus *item in SDLVehicleDataStatus.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLVehicleDataStatus_values == nil) { + SDLVehicleDataStatus_values = @[ + SDLVehicleDataStatus.NO_DATA_EXISTS, + SDLVehicleDataStatus.OFF, + SDLVehicleDataStatus.ON, + ]; + } + return SDLVehicleDataStatus_values; +} + ++ (SDLVehicleDataStatus *)NO_DATA_EXISTS { + if (SDLVehicleDataStatus_NO_DATA_EXISTS == nil) { + SDLVehicleDataStatus_NO_DATA_EXISTS = [[SDLVehicleDataStatus alloc] initWithValue:@"NO_DATA_EXISTS"]; + } + return SDLVehicleDataStatus_NO_DATA_EXISTS; +} + ++ (SDLVehicleDataStatus *)OFF { + if (SDLVehicleDataStatus_OFF == nil) { + SDLVehicleDataStatus_OFF = [[SDLVehicleDataStatus alloc] initWithValue:@"OFF"]; + } + return SDLVehicleDataStatus_OFF; +} + ++ (SDLVehicleDataStatus *)ON { + if (SDLVehicleDataStatus_ON == nil) { + SDLVehicleDataStatus_ON = [[SDLVehicleDataStatus alloc] initWithValue:@"ON"]; + } + return SDLVehicleDataStatus_ON; +} + +@end diff --git a/SmartDeviceLink/SDLVehicleDataType.h b/SmartDeviceLink/SDLVehicleDataType.h new file mode 100644 index 000000000..71ec1f4fe --- /dev/null +++ b/SmartDeviceLink/SDLVehicleDataType.h @@ -0,0 +1,159 @@ +// SDLVehicleDataType.h +// + + +#import "SDLEnum.h" + +/** + * Defines the vehicle data types that can be published and/or subscribed to using SDLSubscribeVehicleData + */ +@interface SDLVehicleDataType : SDLEnum { +} + +/** + * Convert String to SDLVehicleDataType + * + * @param value String value to retrieve the object for + * + * @return SDLVehicleDataType + */ ++ (SDLVehicleDataType *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLVehicleDataType + * + * @return an array that store all possible SDLVehicleDataType + */ ++ (NSArray *)values; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_GPS* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_GPS; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_SPEED* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_SPEED; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_RPM* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_RPM; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_FUELLEVEL* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_FUELLEVEL; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_FUELLEVEL_STATE* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_FUELLEVEL_STATE; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_FUELCONSUMPTION* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_FUELCONSUMPTION; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_EXTERNTEMP* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_EXTERNTEMP; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_VIN* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_VIN; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_PRNDL* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_PRNDL; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_TIREPRESSURE* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_TIREPRESSURE; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_ODOMETER* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_ODOMETER; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_BELTSTATUS* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_BELTSTATUS; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_BODYINFO* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_BODYINFO; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_DEVICESTATUS* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_DEVICESTATUS; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_ECALLINFO* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_ECALLINFO; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_AIRBAGSTATUS* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_AIRBAGSTATUS; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_EMERGENCYEVENT* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_EMERGENCYEVENT; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_CLUSTERMODESTATUS* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_CLUSTERMODESTATUS; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_MYKEY* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_MYKEY; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_BRAKING* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_BRAKING; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_WIPERSTATUS* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_WIPERSTATUS; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_HEADLAMPSTATUS* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_HEADLAMPSTATUS; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_BATTVOLTAGE* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_BATTVOLTAGE; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_ENGINETORQUE* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_ENGINETORQUE; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_ACCPEDAL* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_ACCPEDAL; + +/** + * @abstract SDLVehicleDataType: *VEHICLEDATA_STEERINGWHEEL* + */ ++ (SDLVehicleDataType *)VEHICLEDATA_STEERINGWHEEL; + +@end diff --git a/SmartDeviceLink/SDLVehicleDataType.m b/SmartDeviceLink/SDLVehicleDataType.m new file mode 100644 index 000000000..fa5573745 --- /dev/null +++ b/SmartDeviceLink/SDLVehicleDataType.m @@ -0,0 +1,263 @@ +// SDLVehicleDataType.m +// + + +#import "SDLVehicleDataType.h" + +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_GPS = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_SPEED = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_RPM = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_FUELLEVEL = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_FUELLEVEL_STATE = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_FUELCONSUMPTION = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_EXTERNTEMP = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_VIN = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_PRNDL = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_TIREPRESSURE = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_ODOMETER = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_BELTSTATUS = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_BODYINFO = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_DEVICESTATUS = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_ECALLINFO = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_AIRBAGSTATUS = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_EMERGENCYEVENT = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_CLUSTERMODESTATUS = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_MYKEY = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_BRAKING = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_WIPERSTATUS = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_HEADLAMPSTATUS = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_BATTVOLTAGE = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_ENGINETORQUE = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_ACCPEDAL = nil; +SDLVehicleDataType *SDLVehicleDataType_VEHICLEDATA_STEERINGWHEEL = nil; + +NSArray *SDLVehicleDataType_values = nil; + +@implementation SDLVehicleDataType + ++ (SDLVehicleDataType *)valueOf:(NSString *)value { + for (SDLVehicleDataType *item in SDLVehicleDataType.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLVehicleDataType_values == nil) { + SDLVehicleDataType_values = @[ + SDLVehicleDataType.VEHICLEDATA_GPS, + SDLVehicleDataType.VEHICLEDATA_SPEED, + SDLVehicleDataType.VEHICLEDATA_RPM, + SDLVehicleDataType.VEHICLEDATA_FUELLEVEL, + SDLVehicleDataType.VEHICLEDATA_FUELLEVEL_STATE, + SDLVehicleDataType.VEHICLEDATA_FUELCONSUMPTION, + SDLVehicleDataType.VEHICLEDATA_EXTERNTEMP, + SDLVehicleDataType.VEHICLEDATA_VIN, + SDLVehicleDataType.VEHICLEDATA_PRNDL, + SDLVehicleDataType.VEHICLEDATA_TIREPRESSURE, + SDLVehicleDataType.VEHICLEDATA_ODOMETER, + SDLVehicleDataType.VEHICLEDATA_BELTSTATUS, + SDLVehicleDataType.VEHICLEDATA_BODYINFO, + SDLVehicleDataType.VEHICLEDATA_DEVICESTATUS, + SDLVehicleDataType.VEHICLEDATA_ECALLINFO, + SDLVehicleDataType.VEHICLEDATA_AIRBAGSTATUS, + SDLVehicleDataType.VEHICLEDATA_EMERGENCYEVENT, + SDLVehicleDataType.VEHICLEDATA_CLUSTERMODESTATUS, + SDLVehicleDataType.VEHICLEDATA_MYKEY, + SDLVehicleDataType.VEHICLEDATA_BRAKING, + SDLVehicleDataType.VEHICLEDATA_WIPERSTATUS, + SDLVehicleDataType.VEHICLEDATA_HEADLAMPSTATUS, + SDLVehicleDataType.VEHICLEDATA_BATTVOLTAGE, + SDLVehicleDataType.VEHICLEDATA_ENGINETORQUE, + SDLVehicleDataType.VEHICLEDATA_ACCPEDAL, + SDLVehicleDataType.VEHICLEDATA_STEERINGWHEEL, + ]; + } + return SDLVehicleDataType_values; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_GPS { + if (SDLVehicleDataType_VEHICLEDATA_GPS == nil) { + SDLVehicleDataType_VEHICLEDATA_GPS = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_GPS"]; + } + return SDLVehicleDataType_VEHICLEDATA_GPS; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_SPEED { + if (SDLVehicleDataType_VEHICLEDATA_SPEED == nil) { + SDLVehicleDataType_VEHICLEDATA_SPEED = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_SPEED"]; + } + return SDLVehicleDataType_VEHICLEDATA_SPEED; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_RPM { + if (SDLVehicleDataType_VEHICLEDATA_RPM == nil) { + SDLVehicleDataType_VEHICLEDATA_RPM = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_RPM"]; + } + return SDLVehicleDataType_VEHICLEDATA_RPM; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_FUELLEVEL { + if (SDLVehicleDataType_VEHICLEDATA_FUELLEVEL == nil) { + SDLVehicleDataType_VEHICLEDATA_FUELLEVEL = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_FUELLEVEL"]; + } + return SDLVehicleDataType_VEHICLEDATA_FUELLEVEL; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_FUELLEVEL_STATE { + if (SDLVehicleDataType_VEHICLEDATA_FUELLEVEL_STATE == nil) { + SDLVehicleDataType_VEHICLEDATA_FUELLEVEL_STATE = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_FUELLEVEL_STATE"]; + } + return SDLVehicleDataType_VEHICLEDATA_FUELLEVEL_STATE; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_FUELCONSUMPTION { + if (SDLVehicleDataType_VEHICLEDATA_FUELCONSUMPTION == nil) { + SDLVehicleDataType_VEHICLEDATA_FUELCONSUMPTION = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_FUELCONSUMPTION"]; + } + return SDLVehicleDataType_VEHICLEDATA_FUELCONSUMPTION; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_EXTERNTEMP { + if (SDLVehicleDataType_VEHICLEDATA_EXTERNTEMP == nil) { + SDLVehicleDataType_VEHICLEDATA_EXTERNTEMP = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_EXTERNTEMP"]; + } + return SDLVehicleDataType_VEHICLEDATA_EXTERNTEMP; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_VIN { + if (SDLVehicleDataType_VEHICLEDATA_VIN == nil) { + SDLVehicleDataType_VEHICLEDATA_VIN = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_VIN"]; + } + return SDLVehicleDataType_VEHICLEDATA_VIN; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_PRNDL { + if (SDLVehicleDataType_VEHICLEDATA_PRNDL == nil) { + SDLVehicleDataType_VEHICLEDATA_PRNDL = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_PRNDL"]; + } + return SDLVehicleDataType_VEHICLEDATA_PRNDL; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_TIREPRESSURE { + if (SDLVehicleDataType_VEHICLEDATA_TIREPRESSURE == nil) { + SDLVehicleDataType_VEHICLEDATA_TIREPRESSURE = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_TIREPRESSURE"]; + } + return SDLVehicleDataType_VEHICLEDATA_TIREPRESSURE; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_ODOMETER { + if (SDLVehicleDataType_VEHICLEDATA_ODOMETER == nil) { + SDLVehicleDataType_VEHICLEDATA_ODOMETER = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_ODOMETER"]; + } + return SDLVehicleDataType_VEHICLEDATA_ODOMETER; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_BELTSTATUS { + if (SDLVehicleDataType_VEHICLEDATA_BELTSTATUS == nil) { + SDLVehicleDataType_VEHICLEDATA_BELTSTATUS = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_BELTSTATUS"]; + } + return SDLVehicleDataType_VEHICLEDATA_BELTSTATUS; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_BODYINFO { + if (SDLVehicleDataType_VEHICLEDATA_BODYINFO == nil) { + SDLVehicleDataType_VEHICLEDATA_BODYINFO = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_BODYINFO"]; + } + return SDLVehicleDataType_VEHICLEDATA_BODYINFO; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_DEVICESTATUS { + if (SDLVehicleDataType_VEHICLEDATA_DEVICESTATUS == nil) { + SDLVehicleDataType_VEHICLEDATA_DEVICESTATUS = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_DEVICESTATUS"]; + } + return SDLVehicleDataType_VEHICLEDATA_DEVICESTATUS; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_ECALLINFO { + if (SDLVehicleDataType_VEHICLEDATA_ECALLINFO == nil) { + SDLVehicleDataType_VEHICLEDATA_ECALLINFO = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_ECALLINFO"]; + } + return SDLVehicleDataType_VEHICLEDATA_ECALLINFO; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_AIRBAGSTATUS { + if (SDLVehicleDataType_VEHICLEDATA_AIRBAGSTATUS == nil) { + SDLVehicleDataType_VEHICLEDATA_AIRBAGSTATUS = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_AIRBAGSTATUS"]; + } + return SDLVehicleDataType_VEHICLEDATA_AIRBAGSTATUS; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_EMERGENCYEVENT { + if (SDLVehicleDataType_VEHICLEDATA_EMERGENCYEVENT == nil) { + SDLVehicleDataType_VEHICLEDATA_EMERGENCYEVENT = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_EMERGENCYEVENT"]; + } + return SDLVehicleDataType_VEHICLEDATA_EMERGENCYEVENT; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_CLUSTERMODESTATUS { + if (SDLVehicleDataType_VEHICLEDATA_CLUSTERMODESTATUS == nil) { + SDLVehicleDataType_VEHICLEDATA_CLUSTERMODESTATUS = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_CLUSTERMODESTATUS"]; + } + return SDLVehicleDataType_VEHICLEDATA_CLUSTERMODESTATUS; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_MYKEY { + if (SDLVehicleDataType_VEHICLEDATA_MYKEY == nil) { + SDLVehicleDataType_VEHICLEDATA_MYKEY = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_MYKEY"]; + } + return SDLVehicleDataType_VEHICLEDATA_MYKEY; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_BRAKING { + if (SDLVehicleDataType_VEHICLEDATA_BRAKING == nil) { + SDLVehicleDataType_VEHICLEDATA_BRAKING = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_BRAKING"]; + } + return SDLVehicleDataType_VEHICLEDATA_BRAKING; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_WIPERSTATUS { + if (SDLVehicleDataType_VEHICLEDATA_WIPERSTATUS == nil) { + SDLVehicleDataType_VEHICLEDATA_WIPERSTATUS = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_WIPERSTATUS"]; + } + return SDLVehicleDataType_VEHICLEDATA_WIPERSTATUS; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_HEADLAMPSTATUS { + if (SDLVehicleDataType_VEHICLEDATA_HEADLAMPSTATUS == nil) { + SDLVehicleDataType_VEHICLEDATA_HEADLAMPSTATUS = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_HEADLAMPSTATUS"]; + } + return SDLVehicleDataType_VEHICLEDATA_HEADLAMPSTATUS; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_BATTVOLTAGE { + if (SDLVehicleDataType_VEHICLEDATA_BATTVOLTAGE == nil) { + SDLVehicleDataType_VEHICLEDATA_BATTVOLTAGE = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_BATTVOLTAGE"]; + } + return SDLVehicleDataType_VEHICLEDATA_BATTVOLTAGE; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_ENGINETORQUE { + if (SDLVehicleDataType_VEHICLEDATA_ENGINETORQUE == nil) { + SDLVehicleDataType_VEHICLEDATA_ENGINETORQUE = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_ENGINETORQUE"]; + } + return SDLVehicleDataType_VEHICLEDATA_ENGINETORQUE; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_ACCPEDAL { + if (SDLVehicleDataType_VEHICLEDATA_ACCPEDAL == nil) { + SDLVehicleDataType_VEHICLEDATA_ACCPEDAL = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_ACCPEDAL"]; + } + return SDLVehicleDataType_VEHICLEDATA_ACCPEDAL; +} + ++ (SDLVehicleDataType *)VEHICLEDATA_STEERINGWHEEL { + if (SDLVehicleDataType_VEHICLEDATA_STEERINGWHEEL == nil) { + SDLVehicleDataType_VEHICLEDATA_STEERINGWHEEL = [[SDLVehicleDataType alloc] initWithValue:@"VEHICLEDATA_STEERINGWHEEL"]; + } + return SDLVehicleDataType_VEHICLEDATA_STEERINGWHEEL; +} + +@end diff --git a/SmartDeviceLink/SDLVehicleType.h b/SmartDeviceLink/SDLVehicleType.h new file mode 100644 index 000000000..1a934b5eb --- /dev/null +++ b/SmartDeviceLink/SDLVehicleType.h @@ -0,0 +1,62 @@ +// SDLVehicleType.h +// + + +#import "SDLRPCMessage.h" + +/** + * Describes the type of vehicle the mobile phone is connected with. + * + * @since SDL 2.0 + */ +@interface SDLVehicleType : SDLRPCStruct { +} + +/** + * @abstract Constructs a newly allocated SDLVehicleType object + */ +- (instancetype)init; + +/** + * @abstract Constructs a newly allocated SDLVehicleType object indicated by the dictionary parameter + * @param dict The dictionary to use + */ +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +/** + * @abstract The make of the vehicle + * + * @discussion For example, "Ford", "Lincoln", etc. + * + * Optional, Max String length 500 chars + */ +@property (strong) NSString *make; + +/** + * @abstract The model of the vehicle + * + * @discussion For example, "Fiesta", "Focus", etc. + * + * Optional, Max String length 500 chars + */ +@property (strong) NSString *model; + +/** + * @abstract The model year of the vehicle + * + * @discussion For example, "2013" + * + * Optional, Max String length 500 chars + */ +@property (strong) NSString *modelYear; + +/** + * @abstract The trim of the vehicle + * + * @discussion For example, "SE", "SEL" + * + * Optional, Max String length 500 chars + */ +@property (strong) NSString *trim; + +@end diff --git a/SmartDeviceLink/SDLVehicleType.m b/SmartDeviceLink/SDLVehicleType.m new file mode 100644 index 000000000..ebee2de7f --- /dev/null +++ b/SmartDeviceLink/SDLVehicleType.m @@ -0,0 +1,71 @@ +// SDLVehicleType.m +// + + +#import "SDLVehicleType.h" + +#import "SDLNames.h" + +@implementation SDLVehicleType + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setMake:(NSString *)make { + if (make != nil) { + [store setObject:make forKey:NAMES_make]; + } else { + [store removeObjectForKey:NAMES_make]; + } +} + +- (NSString *)make { + return [store objectForKey:NAMES_make]; +} + +- (void)setModel:(NSString *)model { + if (model != nil) { + [store setObject:model forKey:NAMES_model]; + } else { + [store removeObjectForKey:NAMES_model]; + } +} + +- (NSString *)model { + return [store objectForKey:NAMES_model]; +} + +- (void)setModelYear:(NSString *)modelYear { + if (modelYear != nil) { + [store setObject:modelYear forKey:NAMES_modelYear]; + } else { + [store removeObjectForKey:NAMES_modelYear]; + } +} + +- (NSString *)modelYear { + return [store objectForKey:NAMES_modelYear]; +} + +- (void)setTrim:(NSString *)trim { + if (trim != nil) { + [store setObject:trim forKey:NAMES_trim]; + } else { + [store removeObjectForKey:NAMES_trim]; + } +} + +- (NSString *)trim { + return [store objectForKey:NAMES_trim]; +} + +@end diff --git a/SmartDeviceLink/SDLVrCapabilities.h b/SmartDeviceLink/SDLVrCapabilities.h new file mode 100644 index 000000000..0698d272f --- /dev/null +++ b/SmartDeviceLink/SDLVrCapabilities.h @@ -0,0 +1,34 @@ +// SDLVRCapabilities.h +// + + +#import "SDLEnum.h" + +/** + * The VR capabilities of the connected SDL platform. + * + * @since SDL 1.0 + */ +@interface SDLVRCapabilities : SDLEnum { +} + +/** + * Convert String to SDLVRCapabilities + * @param value The value of the string to get an object for + * @return SDLVRCapabilities + */ ++ (SDLVRCapabilities *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLVRCapabilities + * @return an array that store all possible SDLVRCapabilities + */ ++ (NSArray *)values; + +/** + * @abstract The SDL platform is capable of recognizing spoken text in the current language. + * @return an SDLVRCapabilities instance pointer with value of *TEXT* + */ ++ (SDLVRCapabilities *)TEXT; + +@end diff --git a/SmartDeviceLink/SDLVrCapabilities.m b/SmartDeviceLink/SDLVrCapabilities.m new file mode 100644 index 000000000..72c8c39d2 --- /dev/null +++ b/SmartDeviceLink/SDLVrCapabilities.m @@ -0,0 +1,42 @@ +// SDLVRCapabilities.m +// + + +#import "SDLVRCapabilities.h" + +SDLVRCapabilities *SDLVRCapabilities_TEXT = nil; + +NSArray *SDLVRCapabilities_values = nil; + +@implementation SDLVRCapabilities + ++ (SDLVRCapabilities *)valueOf:(NSString *)value { + for (SDLVRCapabilities *item in SDLVRCapabilities.values) { + //NOTE: This was added for Sync Module Compatability, V1 module resturns "Text" and a + // Gen 1.1 module returns "TEXT", the new if statement makes a case insensitive + // check instead to accept both + //if ([item.value isEqualToString:value]) { + if (item.value && [item.value caseInsensitiveCompare:value] == NSOrderedSame) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLVRCapabilities_values == nil) { + SDLVRCapabilities_values = @[ + SDLVRCapabilities.TEXT, + ]; + } + return SDLVRCapabilities_values; +} + ++ (SDLVRCapabilities *)TEXT { + if (SDLVRCapabilities_TEXT == nil) { + SDLVRCapabilities_TEXT = [[SDLVRCapabilities alloc] initWithValue:@"TEXT"]; + } + return SDLVRCapabilities_TEXT; +} + +@end diff --git a/SmartDeviceLink/SDLVrHelpItem.h b/SmartDeviceLink/SDLVrHelpItem.h new file mode 100644 index 000000000..a46c1301b --- /dev/null +++ b/SmartDeviceLink/SDLVrHelpItem.h @@ -0,0 +1,19 @@ +// SDLVRHelpItem.h +// + +#import "SDLRPCMessage.h" + +@class SDLImage; + + +@interface SDLVRHelpItem : SDLRPCStruct { +} + +- (instancetype)init; +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; + +@property (strong) NSString *text; +@property (strong) SDLImage *image; +@property (strong) NSNumber *position; + +@end diff --git a/SmartDeviceLink/SDLVrHelpItem.m b/SmartDeviceLink/SDLVrHelpItem.m new file mode 100644 index 000000000..4ed2c1409 --- /dev/null +++ b/SmartDeviceLink/SDLVrHelpItem.m @@ -0,0 +1,65 @@ +// SDLVRHelpItem.m +// + + +#import "SDLVRHelpItem.h" + +#import "SDLImage.h" +#import "SDLNames.h" + +@implementation SDLVRHelpItem + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + +- (instancetype)initWithDictionary:(NSMutableDictionary *)dict { + if (self = [super initWithDictionary:dict]) { + } + return self; +} + +- (void)setText:(NSString *)text { + if (text != nil) { + [store setObject:text forKey:NAMES_text]; + } else { + [store removeObjectForKey:NAMES_text]; + } +} + +- (NSString *)text { + return [store objectForKey:NAMES_text]; +} + +- (void)setImage:(SDLImage *)image { + if (image != nil) { + [store setObject:image forKey:NAMES_image]; + } else { + [store removeObjectForKey:NAMES_image]; + } +} + +- (SDLImage *)image { + NSObject *obj = [store objectForKey:NAMES_image]; + if (obj == nil || [obj isKindOfClass:SDLImage.class]) { + return (SDLImage *)obj; + } else { + return [[SDLImage alloc] initWithDictionary:(NSMutableDictionary *)obj]; + } +} + +- (void)setPosition:(NSNumber *)position { + if (position != nil) { + [store setObject:position forKey:NAMES_position]; + } else { + [store removeObjectForKey:NAMES_position]; + } +} + +- (NSNumber *)position { + return [store objectForKey:NAMES_position]; +} + +@end diff --git a/SmartDeviceLink/SDLWarningLightStatus.h b/SmartDeviceLink/SDLWarningLightStatus.h new file mode 100644 index 000000000..1176d5371 --- /dev/null +++ b/SmartDeviceLink/SDLWarningLightStatus.h @@ -0,0 +1,52 @@ +// SDLWarningLightStatus.h +// + + +#import "SDLEnum.h" + +/** + * Reflects the status of a cluster instrument warning light. + * + * @since SDL 2.0 + */ +@interface SDLWarningLightStatus : SDLEnum { +} + +/** + * Convert String to SDLWarningLightStatus + * @param value The value of the string to get an object for + * @return SDLWarningLightStatus + */ ++ (SDLWarningLightStatus *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLWarningLightStatus + * @return an array that store all possible SDLWarningLightStatus + */ ++ (NSArray *)values; + +/** + * @abstract Warninglight Off + * @return SDLWarningLightStatus instance with value of *OFF* + */ ++ (SDLWarningLightStatus *)OFF; + +/** + * @abstract Warninglight On + * @return SDLWarningLightStatus instance with value of *ON* + */ ++ (SDLWarningLightStatus *)ON; + +/** + * @abstract Warninglight is flashing + * @return SDLWarningLightStatus instance with value of *FLASH* + */ ++ (SDLWarningLightStatus *)FLASH; + +/** + * @abstract Not used + * @return SDLWarningLightStatus instance with value of *NOT_USED* + */ ++ (SDLWarningLightStatus *)NOT_USED; + +@end diff --git a/SmartDeviceLink/SDLWarningLightStatus.m b/SmartDeviceLink/SDLWarningLightStatus.m new file mode 100644 index 000000000..c9d47a407 --- /dev/null +++ b/SmartDeviceLink/SDLWarningLightStatus.m @@ -0,0 +1,65 @@ +// SDLWarningLightStatus.m +// + + +#import "SDLWarningLightStatus.h" + +SDLWarningLightStatus *SDLWarningLightStatus_OFF = nil; +SDLWarningLightStatus *SDLWarningLightStatus_ON = nil; +SDLWarningLightStatus *SDLWarningLightStatus_FLASH = nil; +SDLWarningLightStatus *SDLWarningLightStatus_NOT_USED = nil; + +NSArray *SDLWarningLightStatus_values = nil; + +@implementation SDLWarningLightStatus + ++ (SDLWarningLightStatus *)valueOf:(NSString *)value { + for (SDLWarningLightStatus *item in SDLWarningLightStatus.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLWarningLightStatus_values == nil) { + SDLWarningLightStatus_values = @[ + SDLWarningLightStatus.OFF, + SDLWarningLightStatus.ON, + SDLWarningLightStatus.FLASH, + SDLWarningLightStatus.NOT_USED, + ]; + } + return SDLWarningLightStatus_values; +} + ++ (SDLWarningLightStatus *)OFF { + if (SDLWarningLightStatus_OFF == nil) { + SDLWarningLightStatus_OFF = [[SDLWarningLightStatus alloc] initWithValue:@"OFF"]; + } + return SDLWarningLightStatus_OFF; +} + ++ (SDLWarningLightStatus *)ON { + if (SDLWarningLightStatus_ON == nil) { + SDLWarningLightStatus_ON = [[SDLWarningLightStatus alloc] initWithValue:@"ON"]; + } + return SDLWarningLightStatus_ON; +} + ++ (SDLWarningLightStatus *)FLASH { + if (SDLWarningLightStatus_FLASH == nil) { + SDLWarningLightStatus_FLASH = [[SDLWarningLightStatus alloc] initWithValue:@"FLASH"]; + } + return SDLWarningLightStatus_FLASH; +} + ++ (SDLWarningLightStatus *)NOT_USED { + if (SDLWarningLightStatus_NOT_USED == nil) { + SDLWarningLightStatus_NOT_USED = [[SDLWarningLightStatus alloc] initWithValue:@"NOT_USED"]; + } + return SDLWarningLightStatus_NOT_USED; +} + +@end diff --git a/SmartDeviceLink/SDLWiperStatus.h b/SmartDeviceLink/SDLWiperStatus.h new file mode 100644 index 000000000..51a7a1f5d --- /dev/null +++ b/SmartDeviceLink/SDLWiperStatus.h @@ -0,0 +1,101 @@ +// SDLWiperStatus.h +// + + +#import "SDLEnum.h" + +/** + * Wiper Status + */ +@interface SDLWiperStatus : SDLEnum { +} + +/** + * Convert String to SDLWiperStatus + * @param value The value of the string to get an object for + * @return SDLWiperStatus + */ ++ (SDLWiperStatus *)valueOf:(NSString *)value; + +/** + * @abstract Store the enumeration of all possible SDLWiperStatus + * @return An array that store all possible SDLWiperStatus + */ ++ (NSArray *)values; + +/** + * @abstract SDLWiperStatus: *OFF* + */ ++ (SDLWiperStatus *)OFF; + +/** + * @abstract SDLWiperStatus: *AUTO_OFF* + */ ++ (SDLWiperStatus *)AUTO_OFF; + +/** + * @abstract SDLWiperStatus: *OFF_MOVING* + */ ++ (SDLWiperStatus *)OFF_MOVING; + +/** + * @abstract SDLWiperStatus: *MAN_INT_OFF* + */ ++ (SDLWiperStatus *)MAN_INT_OFF; + +/** + * @abstract SDLWiperStatus: *MAN_INT_ON* + */ ++ (SDLWiperStatus *)MAN_INT_ON; + +/** + * @abstract SDLWiperStatus: *MAN_LOW* + */ ++ (SDLWiperStatus *)MAN_LOW; + +/** + * @abstract SDLWiperStatus: *MAN_HIGH* + */ ++ (SDLWiperStatus *)MAN_HIGH; + +/** + * @abstract SDLWiperStatus: *MAN_FLICK* + */ ++ (SDLWiperStatus *)MAN_FLICK; + +/** + * @abstract SDLWiperStatus: *WASH* + */ ++ (SDLWiperStatus *)WASH; + +/** + * @abstract SDLWiperStatus: *AUTO_LOW* + */ ++ (SDLWiperStatus *)AUTO_LOW; + +/** + * @abstract SDLWiperStatus: *AUTO_HIGH* + */ ++ (SDLWiperStatus *)AUTO_HIGH; + +/** + * @abstract SDLWiperStatus: *COURTESYWIPE* + */ ++ (SDLWiperStatus *)COURTESYWIPE; + +/** + * @abstract SDLWiperStatus: *AUTO_ADJUST* + */ ++ (SDLWiperStatus *)AUTO_ADJUST; + +/** + * @abstract SDLWiperStatus: *STALLED* + */ ++ (SDLWiperStatus *)STALLED; + +/** + * @abstract SDLWiperStatus: *NO_DATA_EXISTS* + */ ++ (SDLWiperStatus *)NO_DATA_EXISTS; + +@end diff --git a/SmartDeviceLink/SDLWiperStatus.m b/SmartDeviceLink/SDLWiperStatus.m new file mode 100644 index 000000000..d56749a9f --- /dev/null +++ b/SmartDeviceLink/SDLWiperStatus.m @@ -0,0 +1,164 @@ +// SDLWiperStatus.m +// + + +#import "SDLWiperStatus.h" + +SDLWiperStatus *SDLWiperStatus_OFF = nil; +SDLWiperStatus *SDLWiperStatus_AUTO_OFF = nil; +SDLWiperStatus *SDLWiperStatus_OFF_MOVING = nil; +SDLWiperStatus *SDLWiperStatus_MAN_INT_OFF = nil; +SDLWiperStatus *SDLWiperStatus_MAN_INT_ON = nil; +SDLWiperStatus *SDLWiperStatus_MAN_LOW = nil; +SDLWiperStatus *SDLWiperStatus_MAN_HIGH = nil; +SDLWiperStatus *SDLWiperStatus_MAN_FLICK = nil; +SDLWiperStatus *SDLWiperStatus_WASH = nil; +SDLWiperStatus *SDLWiperStatus_AUTO_LOW = nil; +SDLWiperStatus *SDLWiperStatus_AUTO_HIGH = nil; +SDLWiperStatus *SDLWiperStatus_COURTESYWIPE = nil; +SDLWiperStatus *SDLWiperStatus_AUTO_ADJUST = nil; +SDLWiperStatus *SDLWiperStatus_STALLED = nil; +SDLWiperStatus *SDLWiperStatus_NO_DATA_EXISTS = nil; + +NSArray *SDLWiperStatus_values = nil; + +@implementation SDLWiperStatus + ++ (SDLWiperStatus *)valueOf:(NSString *)value { + for (SDLWiperStatus *item in SDLWiperStatus.values) { + if ([item.value isEqualToString:value]) { + return item; + } + } + return nil; +} + ++ (NSArray *)values { + if (SDLWiperStatus_values == nil) { + SDLWiperStatus_values = @[ + SDLWiperStatus.OFF, + SDLWiperStatus.AUTO_OFF, + SDLWiperStatus.OFF_MOVING, + SDLWiperStatus.MAN_INT_OFF, + SDLWiperStatus.MAN_INT_ON, + SDLWiperStatus.MAN_LOW, + SDLWiperStatus.MAN_HIGH, + SDLWiperStatus.MAN_FLICK, + SDLWiperStatus.WASH, + SDLWiperStatus.AUTO_LOW, + SDLWiperStatus.AUTO_HIGH, + SDLWiperStatus.COURTESYWIPE, + SDLWiperStatus.AUTO_ADJUST, + SDLWiperStatus.STALLED, + SDLWiperStatus.NO_DATA_EXISTS, + ]; + } + return SDLWiperStatus_values; +} + ++ (SDLWiperStatus *)OFF { + if (SDLWiperStatus_OFF == nil) { + SDLWiperStatus_OFF = [[SDLWiperStatus alloc] initWithValue:@"OFF"]; + } + return SDLWiperStatus_OFF; +} + ++ (SDLWiperStatus *)AUTO_OFF { + if (SDLWiperStatus_AUTO_OFF == nil) { + SDLWiperStatus_AUTO_OFF = [[SDLWiperStatus alloc] initWithValue:@"AUTO_OFF"]; + } + return SDLWiperStatus_AUTO_OFF; +} + ++ (SDLWiperStatus *)OFF_MOVING { + if (SDLWiperStatus_OFF_MOVING == nil) { + SDLWiperStatus_OFF_MOVING = [[SDLWiperStatus alloc] initWithValue:@"OFF_MOVING"]; + } + return SDLWiperStatus_OFF_MOVING; +} + ++ (SDLWiperStatus *)MAN_INT_OFF { + if (SDLWiperStatus_MAN_INT_OFF == nil) { + SDLWiperStatus_MAN_INT_OFF = [[SDLWiperStatus alloc] initWithValue:@"MAN_INT_OFF"]; + } + return SDLWiperStatus_MAN_INT_OFF; +} + ++ (SDLWiperStatus *)MAN_INT_ON { + if (SDLWiperStatus_MAN_INT_ON == nil) { + SDLWiperStatus_MAN_INT_ON = [[SDLWiperStatus alloc] initWithValue:@"MAN_INT_ON"]; + } + return SDLWiperStatus_MAN_INT_ON; +} + ++ (SDLWiperStatus *)MAN_LOW { + if (SDLWiperStatus_MAN_LOW == nil) { + SDLWiperStatus_MAN_LOW = [[SDLWiperStatus alloc] initWithValue:@"MAN_LOW"]; + } + return SDLWiperStatus_MAN_LOW; +} + ++ (SDLWiperStatus *)MAN_HIGH { + if (SDLWiperStatus_MAN_HIGH == nil) { + SDLWiperStatus_MAN_HIGH = [[SDLWiperStatus alloc] initWithValue:@"MAN_HIGH"]; + } + return SDLWiperStatus_MAN_HIGH; +} + ++ (SDLWiperStatus *)MAN_FLICK { + if (SDLWiperStatus_MAN_FLICK == nil) { + SDLWiperStatus_MAN_FLICK = [[SDLWiperStatus alloc] initWithValue:@"MAN_FLICK"]; + } + return SDLWiperStatus_MAN_FLICK; +} + ++ (SDLWiperStatus *)WASH { + if (SDLWiperStatus_WASH == nil) { + SDLWiperStatus_WASH = [[SDLWiperStatus alloc] initWithValue:@"WASH"]; + } + return SDLWiperStatus_WASH; +} + ++ (SDLWiperStatus *)AUTO_LOW { + if (SDLWiperStatus_AUTO_LOW == nil) { + SDLWiperStatus_AUTO_LOW = [[SDLWiperStatus alloc] initWithValue:@"AUTO_LOW"]; + } + return SDLWiperStatus_AUTO_LOW; +} + ++ (SDLWiperStatus *)AUTO_HIGH { + if (SDLWiperStatus_AUTO_HIGH == nil) { + SDLWiperStatus_AUTO_HIGH = [[SDLWiperStatus alloc] initWithValue:@"AUTO_HIGH"]; + } + return SDLWiperStatus_AUTO_HIGH; +} + ++ (SDLWiperStatus *)COURTESYWIPE { + if (SDLWiperStatus_COURTESYWIPE == nil) { + SDLWiperStatus_COURTESYWIPE = [[SDLWiperStatus alloc] initWithValue:@"COURTESYWIPE"]; + } + return SDLWiperStatus_COURTESYWIPE; +} + ++ (SDLWiperStatus *)AUTO_ADJUST { + if (SDLWiperStatus_AUTO_ADJUST == nil) { + SDLWiperStatus_AUTO_ADJUST = [[SDLWiperStatus alloc] initWithValue:@"AUTO_ADJUST"]; + } + return SDLWiperStatus_AUTO_ADJUST; +} + ++ (SDLWiperStatus *)STALLED { + if (SDLWiperStatus_STALLED == nil) { + SDLWiperStatus_STALLED = [[SDLWiperStatus alloc] initWithValue:@"STALLED"]; + } + return SDLWiperStatus_STALLED; +} + ++ (SDLWiperStatus *)NO_DATA_EXISTS { + if (SDLWiperStatus_NO_DATA_EXISTS == nil) { + SDLWiperStatus_NO_DATA_EXISTS = [[SDLWiperStatus alloc] initWithValue:@"NO_DATA_EXISTS"]; + } + return SDLWiperStatus_NO_DATA_EXISTS; +} + +@end diff --git a/SmartDeviceLink/SmartDeviceLink.h b/SmartDeviceLink/SmartDeviceLink.h new file mode 100644 index 000000000..1bfbcb655 --- /dev/null +++ b/SmartDeviceLink/SmartDeviceLink.h @@ -0,0 +1,275 @@ +// SmartDeviceLink.h +// + +#import <UIKit/UIKit.h> + +//! Project version number for SmartDeviceLink. +FOUNDATION_EXPORT double SmartDeviceLinkVersionNumber; + +//! Project version string for SmartDeviceLink. +FOUNDATION_EXPORT const unsigned char SmartDeviceLinkVersionString[]; + +/**** Utilities *****/ +#import "SDLJingle.h" + +/***** Proxy *****/ +#import "SDLProxy.h" +#import "SDLProxyFactory.h" +#import "SDLProxyListener.h" +#import "SDLStreamingMediaManager.h" +#import "SDLTTSChunkFactory.h" + +/***** Debug *****/ +#import "SDLConsoleController.h" +#import "SDLDebugTool.h" +#import "SDLDebugToolConsole.h" +#import "SDLSiphonServer.h" + +/***** Transport *****/ +#import "SDLAbstractTransport.h" +#import "SDLIAPSessionDelegate.h" +#import "SDLIAPTransport.h" +#import "SDLTCPTransport.h" +#import "SDLTransportDelegate.h" + +/***** Protocol *****/ +#import "SDLAbstractProtocol.h" +#import "SDLProtocol.h" +#import "SDLProtocolListener.h" + +// Header +#import "SDLProtocolHeader.h" + +// Message +#import "SDLProtocolMessage.h" + +/***** RPCs *****/ +// Superclasses +#import "SDLEnum.h" +#import "SDLRPCMessage.h" +#import "SDLRPCNotification.h" +#import "SDLRPCRequest.h" +#import "SDLRPCResponse.h" +#import "SDLRPCStruct.h" + +// Factories +#import "SDLRPCRequestFactory.h" + +// Requests +#import "SDLAddCommand.h" +#import "SDLAddSubMenu.h" +#import "SDLAlert.h" +#import "SDLAlertManeuver.h" +#import "SDLChangeRegistration.h" +#import "SDLCreateInteractionChoiceSet.h" +#import "SDLDeleteCommand.h" +#import "SDLDeleteFile.h" +#import "SDLDeleteInteractionChoiceSet.h" +#import "SDLDeleteSubMenu.h" +#import "SDLDiagnosticMessage.h" +#import "SDLDialNumber.h" +#import "SDLEncodedSyncPData.h" +#import "SDLEndAudioPassThru.h" +#import "SDLGetDTCs.h" +#import "SDLGetVehicleData.h" +#import "SDLListFiles.h" +#import "SDLPerformAudioPassThru.h" +#import "SDLPerformInteraction.h" +#import "SDLPutFile.h" +#import "SDLReadDID.h" +#import "SDLRegisterAppInterface.h" +#import "SDLResetGlobalProperties.h" +#import "SDLScrollableMessage.h" +#import "SDLSendLocation.h" +#import "SDLSetAppIcon.h" +#import "SDLSetDisplayLayout.h" +#import "SDLSetGlobalProperties.h" +#import "SDLSetMediaClockTimer.h" +#import "SDLShow.h" +#import "SDLShowConstantTBT.h" +#import "SDLSlider.h" +#import "SDLSpeak.h" +#import "SDLSubscribeButton.h" +#import "SDLSubscribeVehicleData.h" +#import "SDLSyncPData.h" +#import "SDLUnregisterAppInterface.h" +#import "SDLUnsubscribeButton.h" +#import "SDLUnsubscribeVehicleData.h" +#import "SDLUpdateTurnList.h" + +// Responses +#import "SDLAddCommandResponse.h" +#import "SDLAddSubMenuResponse.h" +#import "SDLAlertManeuverResponse.h" +#import "SDLAlertResponse.h" +#import "SDLChangeRegistrationResponse.h" +#import "SDLCreateInteractionChoiceSetResponse.h" +#import "SDLDeleteCommandResponse.h" +#import "SDLDeleteFileResponse.h" +#import "SDLDeleteInteractionChoiceSetResponse.h" +#import "SDLDeleteSubMenuResponse.h" +#import "SDLDiagnosticMessageResponse.h" +#import "SDLDialNumberResponse.h" +#import "SDLEncodedSyncPDataResponse.h" +#import "SDLEndAudioPassThruResponse.h" +#import "SDLGenericResponse.h" +#import "SDLGetDTCsResponse.h" +#import "SDLGetVehicleDataResponse.h" +#import "SDLListFilesResponse.h" +#import "SDLPerformAudioPassThruResponse.h" +#import "SDLPerformInteractionResponse.h" +#import "SDLPutFileResponse.h" +#import "SDLReadDIDResponse.h" +#import "SDLRegisterAppInterfaceResponse.h" +#import "SDLResetGlobalPropertiesResponse.h" +#import "SDLScrollableMessageResponse.h" +#import "SDLSendLocationResponse.h" +#import "SDLSetAppIconResponse.h" +#import "SDLSetDisplayLayoutResponse.h" +#import "SDLSetGlobalPropertiesResponse.h" +#import "SDLSetMediaClockTimerResponse.h" +#import "SDLShowConstantTBTResponse.h" +#import "SDLShowResponse.h" +#import "SDLSliderResponse.h" +#import "SDLSpeakResponse.h" +#import "SDLSubscribeButtonResponse.h" +#import "SDLSubscribeVehicleDataResponse.h" +#import "SDLSyncPDataResponse.h" +#import "SDLUnregisterAppInterfaceResponse.h" +#import "SDLUnsubscribeButtonResponse.h" +#import "SDLUnsubscribeVehicleDataResponse.h" +#import "SDLUpdateTurnListResponse.h" + +// Notifications +#import "SDLOnAppInterfaceUnregistered.h" +#import "SDLOnAudioPassThru.h" +#import "SDLOnButtonEvent.h" +#import "SDLOnButtonPress.h" +#import "SDLOnCommand.h" +#import "SDLOnDriverDistraction.h" +#import "SDLOnEncodedSyncPData.h" +#import "SDLOnHMIStatus.h" +#import "SDLOnHashChange.h" +#import "SDLOnKeyboardInput.h" +#import "SDLOnLanguageChange.h" +#import "SDLOnLockScreenStatus.h" +#import "SDLOnPermissionsChange.h" +#import "SDLOnSyncPData.h" +#import "SDLOnSystemRequest.h" +#import "SDLOnTBTClientState.h" +#import "SDLOnTouchEvent.h" +#import "SDLOnVehicleData.h" + +// Structs +#import "SDLAirbagStatus.h" +#import "SDLAudioPassThruCapabilities.h" +#import "SDLBeltStatus.h" +#import "SDLBodyInformation.h" +#import "SDLButtonCapabilities.h" +#import "SDLChoice.h" +#import "SDLClusterModeStatus.h" +#import "SDLDIDResult.h" +#import "SDLDeviceInfo.h" +#import "SDLDeviceStatus.h" +#import "SDLDisplayCapabilities.h" +#import "SDLECallInfo.h" +#import "SDLEmergencyEvent.h" +#import "SDLGPSData.h" +#import "SDLHMICapabilities.h" +#import "SDLHMIPermissions.h" +#import "SDLHeadLampStatus.h" +#import "SDLImage.h" +#import "SDLImageField.h" +#import "SDLImageResolution.h" +#import "SDLKeyboardProperties.h" +#import "SDLMenuParams.h" +#import "SDLMyKey.h" +#import "SDLParameterPermissions.h" +#import "SDLPermissionItem.h" +#import "SDLPresetBankCapabilities.h" +#import "SDLScreenParams.h" +#import "SDLSingleTireStatus.h" +#import "SDLSoftButton.h" +#import "SDLSoftButtonCapabilities.h" +#import "SDLStartTime.h" +#import "SDLSyncMsgVersion.h" +#import "SDLTTSChunk.h" +#import "SDLTextField.h" +#import "SDLTireStatus.h" +#import "SDLTouchCoord.h" +#import "SDLTouchEvent.h" +#import "SDLTouchEventCapabilities.h" +#import "SDLTurn.h" +#import "SDLVRHelpItem.h" +#import "SDLVehicleDataResult.h" +#import "SDLVehicleType.h" + +// Enums +#import "SDLAmbientLightStatus.h" +#import "SDLAppHMIType.h" +#import "SDLAppInterfaceUnregisteredReason.h" +#import "SDLAudioStreamingState.h" +#import "SDLAudioType.h" +#import "SDLBitsPerSample.h" +#import "SDLButtonEventMode.h" +#import "SDLButtonName.h" +#import "SDLButtonPressMode.h" +#import "SDLCarModeStatus.h" +#import "SDLCharacterSet.h" +#import "SDLCompassDirection.h" +#import "SDLComponentVolumeStatus.h" +#import "SDLDeviceLevelStatus.h" +#import "SDLDimension.h" +#import "SDLDisplayType.h" +#import "SDLDriverDistractionState.h" +#import "SDLECallConfirmationStatus.h" +#import "SDLEmergencyEventType.h" +#import "SDLFileType.h" +#import "SDLFuelCutoffStatus.h" +#import "SDLGlobalProperty.h" +#import "SDLHMILevel.h" +#import "SDLHMIZoneCapabilities.h" +#import "SDLIgnitionStableStatus.h" +#import "SDLIgnitionStatus.h" +#import "SDLImageFieldName.h" +#import "SDLImageType.h" +#import "SDLInteractionMode.h" +#import "SDLKeyboardEvent.h" +#import "SDLKeyboardLayout.h" +#import "SDLKeypressMode.h" +#import "SDLLanguage.h" +#import "SDLLayoutMode.h" +#import "SDLLockScreenStatus.h" +#import "SDLMaintenanceModeStatus.h" +#import "SDLMediaClockFormat.h" +#import "SDLPRNDL.h" +#import "SDLPermissionStatus.h" +#import "SDLPowerModeQualificationStatus.h" +#import "SDLPowerModeStatus.h" +#import "SDLPredefinedLayout.h" +#import "SDLPrerecordedSpeech.h" +#import "SDLPrimaryAudioSource.h" +#import "SDLRPCMessageType.h" +#import "SDLRequestType.h" +#import "SDLResult.h" +#import "SDLSamplingRate.h" +#import "SDLSoftButtonType.h" +#import "SDLSpeechCapabilities.h" +#import "SDLSystemAction.h" +#import "SDLSystemContext.h" +#import "SDLTBTState.h" +#import "SDLTextAlignment.h" +#import "SDLTextFieldName.h" +#import "SDLTimerMode.h" +#import "SDLTouchType.h" +#import "SDLTriggerSource.h" +#import "SDLUpdateMode.h" +#import "SDLVRCapabilities.h" +#import "SDLVehicleDataActiveStatus.h" +#import "SDLVehicleDataEventStatus.h" +#import "SDLVehicleDataNotificationStatus.h" +#import "SDLVehicleDataResultCode.h" +#import "SDLVehicleDataStatus.h" +#import "SDLVehicleDataType.h" +#import "SDLWarningLightStatus.h" +#import "SDLWiperStatus.h" |