diff options
-rw-r--r-- | SmartDeviceLink-iOS.podspec | 1 | ||||
-rw-r--r-- | SmartDeviceLink-iOS.xcodeproj/project.pbxproj | 8 | ||||
-rw-r--r-- | SmartDeviceLink.podspec | 1 | ||||
-rw-r--r-- | SmartDeviceLink/SDLFunctionID.m | 1 | ||||
-rw-r--r-- | SmartDeviceLink/SDLRPCFunctionNames.h | 3 | ||||
-rw-r--r-- | SmartDeviceLink/SDLRPCFunctionNames.m | 1 | ||||
-rw-r--r-- | SmartDeviceLink/SDLSubtleAlert.h | 115 | ||||
-rw-r--r-- | SmartDeviceLink/SDLSubtleAlert.m | 130 | ||||
-rw-r--r-- | SmartDeviceLink/SmartDeviceLink.h | 1 |
9 files changed, 261 insertions, 0 deletions
diff --git a/SmartDeviceLink-iOS.podspec b/SmartDeviceLink-iOS.podspec index d1f247ff7..52ab21ce7 100644 --- a/SmartDeviceLink-iOS.podspec +++ b/SmartDeviceLink-iOS.podspec @@ -378,6 +378,7 @@ ss.public_header_files = [ 'SmartDeviceLink/SDLSubscribeVehicleDataResponse.h', 'SmartDeviceLink/SDLSubscribeWaypoints.h', 'SmartDeviceLink/SDLSubscribeWaypointsResponse.h', +'SmartDeviceLink/SDLSubtleAlert.h', 'SmartDeviceLink/SDLSupportedSeat.h', 'SmartDeviceLink/SDLSyncMsgVersion.h', 'SmartDeviceLink/SDLMsgVersion.h', diff --git a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj index 97e696dd1..3e8c4a8ab 100644 --- a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj +++ b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj @@ -1423,6 +1423,8 @@ 888DBAF022D528DE002A0AE2 /* SDLCloseApplicationResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 888DBAEE22D528DE002A0AE2 /* SDLCloseApplicationResponse.m */; }; 888F86FE221DEE200052FE4C /* SDLAsynchronousRPCOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 888F86FD221DEE1F0052FE4C /* SDLAsynchronousRPCOperation.m */; }; 888F8700221DF4880052FE4C /* SDLAsynchronousRPCOperationSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 888F86FF221DF4880052FE4C /* SDLAsynchronousRPCOperationSpec.m */; }; + 889D0B8F24D052FE008AD494 /* SDLSubtleAlert.m in Sources */ = {isa = PBXBuildFile; fileRef = 889D0B8D24D052FD008AD494 /* SDLSubtleAlert.m */; }; + 889D0B9024D052FE008AD494 /* SDLSubtleAlert.h in Headers */ = {isa = PBXBuildFile; fileRef = 889D0B8E24D052FD008AD494 /* SDLSubtleAlert.h */; settings = {ATTRIBUTES = (Public, ); }; }; 889E7BAF249CEE07002E4BE1 /* SubscribeButtonManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 889E7BAD249CEDCF002E4BE1 /* SubscribeButtonManager.swift */; }; 889E7BB2249D0877002E4BE1 /* SubscribeButtonManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 889E7BB1249D0877002E4BE1 /* SubscribeButtonManager.m */; }; 88A098AE2476F0C200A50005 /* SDLSubscribeButtonManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 88A098AC2476F0C200A50005 /* SDLSubscribeButtonManager.h */; }; @@ -3201,6 +3203,8 @@ 888DBAEE22D528DE002A0AE2 /* SDLCloseApplicationResponse.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLCloseApplicationResponse.m; sourceTree = "<group>"; }; 888F86FD221DEE1F0052FE4C /* SDLAsynchronousRPCOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLAsynchronousRPCOperation.m; sourceTree = "<group>"; }; 888F86FF221DF4880052FE4C /* SDLAsynchronousRPCOperationSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLAsynchronousRPCOperationSpec.m; sourceTree = "<group>"; }; + 889D0B8D24D052FD008AD494 /* SDLSubtleAlert.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLSubtleAlert.m; sourceTree = "<group>"; }; + 889D0B8E24D052FD008AD494 /* SDLSubtleAlert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLSubtleAlert.h; sourceTree = "<group>"; }; 889E7BAD249CEDCF002E4BE1 /* SubscribeButtonManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscribeButtonManager.swift; sourceTree = "<group>"; }; 889E7BB0249D0877002E4BE1 /* SubscribeButtonManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SubscribeButtonManager.h; sourceTree = "<group>"; }; 889E7BB1249D0877002E4BE1 /* SubscribeButtonManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SubscribeButtonManager.m; sourceTree = "<group>"; }; @@ -4675,6 +4679,8 @@ 5D61FBC51A84238B00846EE7 /* SDLSubscribeVehicleData.m */, DA9F7E851DCC049900ACAE48 /* SDLSubscribeWayPoints.h */, DA9F7E861DCC049900ACAE48 /* SDLSubscribeWayPoints.m */, + 889D0B8E24D052FD008AD494 /* SDLSubtleAlert.h */, + 889D0B8D24D052FD008AD494 /* SDLSubtleAlert.m */, 5D61FBCA1A84238B00846EE7 /* SDLSyncPData.h */, 5D61FBCB1A84238B00846EE7 /* SDLSyncPData.m */, 5D61FBD21A84238B00846EE7 /* SDLSystemRequest.h */, @@ -7029,6 +7035,7 @@ 5D2F58081D0717D5001085CE /* SDLManagerDelegate.h in Headers */, 5D61FC881A84238C00846EE7 /* SDLDiagnosticMessage.h in Headers */, 5D0A738A203F24320001595D /* SDLSoftButtonObject.h in Headers */, + 889D0B9024D052FE008AD494 /* SDLSubtleAlert.h in Headers */, 5D61FDB31A84238C00846EE7 /* SDLSubscribeVehicleDataResponse.h in Headers */, 5D92935A20B33D4F00FCC775 /* SDLChoiceCell.h in Headers */, 5D61FC961A84238C00846EE7 /* SDLECallConfirmationStatus.h in Headers */, @@ -7678,6 +7685,7 @@ 5D8204271BCEA8A600D0A41B /* SDLPermissionManager.m in Sources */, 5D61FDB21A84238C00846EE7 /* SDLSubscribeVehicleData.m in Sources */, 5D61FC991A84238C00846EE7 /* SDLECallInfo.m in Sources */, + 889D0B8F24D052FE008AD494 /* SDLSubtleAlert.m in Sources */, 5D61FD601A84238C00846EE7 /* SDLRegisterAppInterfaceResponse.m in Sources */, 106982AB24AA3B4700B1F649 /* SDLRPCPermissionStatus.m in Sources */, 5DB996581F268ECB002D8795 /* SDLControlFramePayloadAudioStartServiceAck.m in Sources */, diff --git a/SmartDeviceLink.podspec b/SmartDeviceLink.podspec index 9cc66bd1d..bccefd901 100644 --- a/SmartDeviceLink.podspec +++ b/SmartDeviceLink.podspec @@ -379,6 +379,7 @@ sdefault.public_header_files = [ 'SmartDeviceLink/SDLSubscribeVehicleDataResponse.h', 'SmartDeviceLink/SDLSubscribeWaypoints.h', 'SmartDeviceLink/SDLSubscribeWaypointsResponse.h', +'SmartDeviceLink/SDLSubtleAlert.h', 'SmartDeviceLink/SDLSupportedSeat.h', 'SmartDeviceLink/SDLSyncMsgVersion.h', 'SmartDeviceLink/SDLMsgVersion.h', diff --git a/SmartDeviceLink/SDLFunctionID.m b/SmartDeviceLink/SDLFunctionID.m index 1a3b93bbb..87efa47e5 100644 --- a/SmartDeviceLink/SDLFunctionID.m +++ b/SmartDeviceLink/SDLFunctionID.m @@ -96,6 +96,7 @@ NS_ASSUME_NONNULL_BEGIN @61: SDLRPCFunctionNameDeleteWindow, @62: SDLRPCFunctionNameGetInteriorVehicleDataConsent, @63: SDLRPCFunctionNameReleaseInteriorVehicleDataModule, + @64: SDLRPCFunctionNameSubtleAlert, @32768: SDLRPCFunctionNameOnHMIStatus, @32769: SDLRPCFunctionNameOnAppInterfaceUnregistered, @32770: SDLRPCFunctionNameOnButtonEvent, diff --git a/SmartDeviceLink/SDLRPCFunctionNames.h b/SmartDeviceLink/SDLRPCFunctionNames.h index fce4b61f7..8445ae405 100644 --- a/SmartDeviceLink/SDLRPCFunctionNames.h +++ b/SmartDeviceLink/SDLRPCFunctionNames.h @@ -247,6 +247,9 @@ extern SDLRPCFunctionName const SDLRPCFunctionNameSubscribeVehicleData; /// Function name for a SubscribeWayPoints RPC extern SDLRPCFunctionName const SDLRPCFunctionNameSubscribeWayPoints; +/// Function name for a SubtleAlert RPC +extern SDLRPCFunctionName const SDLRPCFunctionNameSubtleAlert; + /// Function name for a SyncPData RPC extern SDLRPCFunctionName const SDLRPCFunctionNameSyncPData __deprecated; diff --git a/SmartDeviceLink/SDLRPCFunctionNames.m b/SmartDeviceLink/SDLRPCFunctionNames.m index 744922420..8e3c4eb47 100644 --- a/SmartDeviceLink/SDLRPCFunctionNames.m +++ b/SmartDeviceLink/SDLRPCFunctionNames.m @@ -86,6 +86,7 @@ SDLRPCFunctionName const SDLRPCFunctionNameSpeak = @"Speak"; SDLRPCFunctionName const SDLRPCFunctionNameSubscribeButton = @"SubscribeButton"; SDLRPCFunctionName const SDLRPCFunctionNameSubscribeVehicleData = @"SubscribeVehicleData"; SDLRPCFunctionName const SDLRPCFunctionNameSubscribeWayPoints = @"SubscribeWayPoints"; +SDLRPCFunctionName const SDLRPCFunctionNameSubtleAlert = @"SubtleAlert"; SDLRPCFunctionName const SDLRPCFunctionNameSyncPData = @"SyncPData"; SDLRPCFunctionName const SDLRPCFunctionNameSystemRequest = @"SystemRequest"; SDLRPCFunctionName const SDLRPCFunctionNameUnpublishAppService = @"UnpublishAppService"; diff --git a/SmartDeviceLink/SDLSubtleAlert.h b/SmartDeviceLink/SDLSubtleAlert.h new file mode 100644 index 000000000..f34047f24 --- /dev/null +++ b/SmartDeviceLink/SDLSubtleAlert.h @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2020, SmartDeviceLink Consortium, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the SmartDeviceLink Consortium Inc. nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#import "SDLRPCRequest.h" + +@class SDLImage; +@class SDLSoftButton; +@class SDLTTSChunk; + +NS_ASSUME_NONNULL_BEGIN + +/** + * 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. + * + * @since SDL 7.0.0 + */ +@interface SDLSubtleAlert : SDLRPCRequest + +/** + * @param alertText1 - alertText1 + * @param alertText2 - alertText2 + * @param alertIcon - alertIcon + * @param ttsChunks - ttsChunks + * @param duration - duration + * @param softButtons - softButtons + * @param cancelID - cancelID + * @return A SDLSubtleAlert object + */ +- (instancetype)initWithAlertText1:(nullable NSString *)alertText1 alertText2:(nullable NSString *)alertText2 alertIcon:(nullable SDLImage *)alertIcon ttsChunks:(nullable NSArray<SDLTTSChunk *> *)ttsChunks duration:(nullable NSNumber<SDLUInt> *)duration softButtons:(nullable NSArray<SDLSoftButton *> *)softButtons cancelID:(nullable NSNumber<SDLInt> *)cancelID; + +/** + * The first line of the alert text field + * {"default_value": null, "max_length": 500, "min_length": 1} + * + * Optional + */ +@property (nullable, strong, nonatomic) NSString *alertText1; + +/** + * The second line of the alert text field + * {"default_value": null, "max_length": 500, "min_length": 1} + * + * Optional + */ +@property (nullable, strong, nonatomic) NSString *alertText2; + +/** + * Image to be displayed for the corresponding alert. See Image. If omitted on supported displays, no (or the default if applicable) icon should be displayed. + * + * Optional + */ +@property (nullable, strong, nonatomic) SDLImage *alertIcon; + +/** + * An array of text chunks of type TTSChunk. See TTSChunk. The array must have at least one item. + * + * Optional + */ +@property (nullable, strong, nonatomic) NSArray<SDLTTSChunk *> *ttsChunks; + +/** + * Timeout in milliseconds. Typical timeouts are 3-5 seconds. If omitted, timeout is set to 5s. + * {"default_value": 5000, "max_value": 10000, "min_value": 3000} + * + * Optional + */ +@property (nullable, strong, nonatomic) NSNumber<SDLUInt> *duration; + +/** + * App defined SoftButtons. If omitted on supported displays, the displayed alert shall not have any SoftButtons. + * + * Optional + */ +@property (nullable, strong, nonatomic) NSArray<SDLSoftButton *> *softButtons; + +/** + * An ID for this specific alert to allow cancellation through the `CancelInteraction` RPC. + * {"default_value": null, "max_value": null, "min_value": null} + * + * Optional + */ +@property (nullable, strong, nonatomic) NSNumber<SDLInt> *cancelID; + +@end + +NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLSubtleAlert.m b/SmartDeviceLink/SDLSubtleAlert.m new file mode 100644 index 000000000..393f3addd --- /dev/null +++ b/SmartDeviceLink/SDLSubtleAlert.m @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2020, SmartDeviceLink Consortium, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the SmartDeviceLink Consortium Inc. nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#import "SDLSubtleAlert.h" + +#import "NSMutableDictionary+Store.h" +#import "SDLImage.h" +#import "SDLRPCFunctionNames.h" +#import "SDLRPCParameterNames.h" +#import "SDLSoftButton.h" +#import "SDLTTSChunk.h" + +NS_ASSUME_NONNULL_BEGIN + +@implementation SDLSubtleAlert + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +- (instancetype)init { + self = [super initWithName:SDLRPCFunctionNameSubtleAlert]; + if (!self) { + return nil; + } + return self; +} +#pragma clang diagnostic pop + +- (instancetype)initWithAlertText1:(nullable NSString *)alertText1 alertText2:(nullable NSString *)alertText2 alertIcon:(nullable SDLImage *)alertIcon ttsChunks:(nullable NSArray<SDLTTSChunk *> *)ttsChunks duration:(nullable NSNumber<SDLUInt> *)duration softButtons:(nullable NSArray<SDLSoftButton *> *)softButtons cancelID:(nullable NSNumber<SDLInt> *)cancelID { + self = [super init]; + if (!self) { + return nil; + } + self.alertText1 = alertText1; + self.alertText2 = alertText2; + self.alertIcon = alertIcon; + self.ttsChunks = ttsChunks; + self.duration = duration; + self.softButtons = softButtons; + self.cancelID = cancelID; + return self; +} + +- (void)setAlertText1:(nullable NSString *)alertText1 { + [self.parameters sdl_setObject:alertText1 forName:SDLRPCParameterNameAlertText1]; +} + +- (nullable NSString *)alertText1 { + return [self.parameters sdl_objectForName:SDLRPCParameterNameAlertText1 ofClass:NSString.class error:nil]; +} + +- (void)setAlertText2:(nullable NSString *)alertText2 { + [self.parameters sdl_setObject:alertText2 forName:SDLRPCParameterNameAlertText2]; +} + +- (nullable NSString *)alertText2 { + return [self.parameters sdl_objectForName:SDLRPCParameterNameAlertText2 ofClass:NSString.class error:nil]; +} + +- (void)setAlertIcon:(nullable SDLImage *)alertIcon { + [self.parameters sdl_setObject:alertIcon forName:SDLRPCParameterNameAlertIcon]; +} + +- (nullable SDLImage *)alertIcon { + return [self.parameters sdl_objectForName:SDLRPCParameterNameAlertIcon ofClass:SDLImage.class error:nil]; +} + +- (void)setTtsChunks:(nullable NSArray<SDLTTSChunk *> *)ttsChunks { + [self.parameters sdl_setObject:ttsChunks forName:SDLRPCParameterNameTTSChunks]; +} + +- (nullable NSArray<SDLTTSChunk *> *)ttsChunks { + return [self.parameters sdl_objectsForName:SDLRPCParameterNameTTSChunks ofClass:SDLTTSChunk.class error:nil]; +} + +- (void)setDuration:(nullable NSNumber<SDLUInt> *)duration { + [self.parameters sdl_setObject:duration forName:SDLRPCParameterNameDuration]; +} + +- (nullable NSNumber<SDLUInt> *)duration { + return [self.parameters sdl_objectForName:SDLRPCParameterNameDuration ofClass:NSNumber.class error:nil]; +} + +- (void)setSoftButtons:(nullable NSArray<SDLSoftButton *> *)softButtons { + [self.parameters sdl_setObject:softButtons forName:SDLRPCParameterNameSoftButtons]; +} + +- (nullable NSArray<SDLSoftButton *> *)softButtons { + return [self.parameters sdl_objectsForName:SDLRPCParameterNameSoftButtons ofClass:SDLSoftButton.class error:nil]; +} + +- (void)setCancelID:(nullable NSNumber<SDLInt> *)cancelID { + [self.parameters sdl_setObject:cancelID forName:SDLRPCParameterNameCancelID]; +} + +- (nullable NSNumber<SDLInt> *)cancelID { + return [self.parameters sdl_objectForName:SDLRPCParameterNameCancelID ofClass:NSNumber.class error:nil]; +} + +@end + +NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SmartDeviceLink.h b/SmartDeviceLink/SmartDeviceLink.h index 177d60bd7..c1fd0f49c 100644 --- a/SmartDeviceLink/SmartDeviceLink.h +++ b/SmartDeviceLink/SmartDeviceLink.h @@ -73,6 +73,7 @@ FOUNDATION_EXPORT const unsigned char SmartDeviceLinkVersionString[]; #import "SDLSubscribeButton.h" #import "SDLSubscribeVehicleData.h" #import "SDLSubscribeWayPoints.h" +#import "SDLSubtleAlert.h" #import "SDLSyncPData.h" #import "SDLSystemRequest.h" #import "SDLUnpublishAppService.h" |