Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Adding AppInfo Struct to RegisterAppInterface #431

Merged
merged 7 commits into from Aug 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions SmartDeviceLink-iOS.xcodeproj/project.pbxproj
Expand Up @@ -237,6 +237,8 @@
1680B11C1A9CD7AD00DBD79E /* SDLProtocolMessageAssemblerSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 1680B1101A9CD7AD00DBD79E /* SDLProtocolMessageAssemblerSpec.m */; };
1680B11D1A9CD7AD00DBD79E /* SDLProtocolMessageDisassemblerSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 1680B1111A9CD7AD00DBD79E /* SDLProtocolMessageDisassemblerSpec.m */; };
1680B11E1A9CD7AD00DBD79E /* SDLProtocolReceivedMessageRouterSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 1680B1121A9CD7AD00DBD79E /* SDLProtocolReceivedMessageRouterSpec.m */; };
332A914F1CED9CC60043824C /* SDLAppInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 332A913D1CED87F80043824C /* SDLAppInfo.m */; };
332A91501CED9CF10043824C /* SDLAppInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 332A913C1CED87F80043824C /* SDLAppInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };
5D0218F61A8E79C400D1BF62 /* ConnectionTCPTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D0218F51A8E79C400D1BF62 /* ConnectionTCPTableViewController.m */; };
5D0218F91A8E7A7300D1BF62 /* ConnectionTCPTableViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5D0218F71A8E7A7300D1BF62 /* ConnectionTCPTableViewController.storyboard */; };
5D0218FC1A8E7E1700D1BF62 /* ConnectionContainerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D0218FB1A8E7E1700D1BF62 /* ConnectionContainerViewController.m */; };
Expand Down Expand Up @@ -791,6 +793,7 @@
DA4353E91D2721680099B8C4 /* DispatchTimerSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4353E61D2721680099B8C4 /* DispatchTimerSpec.m */; };
DA4353EA1D2721680099B8C4 /* SDLTouchManagerSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4353E71D2721680099B8C4 /* SDLTouchManagerSpec.m */; };
DA4353EB1D2721680099B8C4 /* SDLTouchSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4353E81D2721680099B8C4 /* SDLTouchSpec.m */; };
DA96C0661D4D4F730022F520 /* SDLAppInfoSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA96C0651D4D4F730022F520 /* SDLAppInfoSpec.m */; };
DAC572571D1067270004288B /* SDLTouchManager.h in Headers */ = {isa = PBXBuildFile; fileRef = DAC572551D1067270004288B /* SDLTouchManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
DAC572581D1067270004288B /* SDLTouchManager.m in Sources */ = {isa = PBXBuildFile; fileRef = DAC572561D1067270004288B /* SDLTouchManager.m */; };
DAC5725B1D10B81E0004288B /* SDLTouch.m in Sources */ = {isa = PBXBuildFile; fileRef = DAC572591D10B81E0004288B /* SDLTouch.m */; };
Expand Down Expand Up @@ -1114,6 +1117,8 @@
1680B1101A9CD7AD00DBD79E /* SDLProtocolMessageAssemblerSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLProtocolMessageAssemblerSpec.m; sourceTree = "<group>"; };
1680B1111A9CD7AD00DBD79E /* SDLProtocolMessageDisassemblerSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLProtocolMessageDisassemblerSpec.m; sourceTree = "<group>"; };
1680B1121A9CD7AD00DBD79E /* SDLProtocolReceivedMessageRouterSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLProtocolReceivedMessageRouterSpec.m; sourceTree = "<group>"; };
332A913C1CED87F80043824C /* SDLAppInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLAppInfo.h; sourceTree = "<group>"; };
332A913D1CED87F80043824C /* SDLAppInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLAppInfo.m; sourceTree = "<group>"; };
5D0218F41A8E79C400D1BF62 /* ConnectionTCPTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ConnectionTCPTableViewController.h; path = SmartDeviceLink_Example/Classes/ConnectionTCPTableViewController.h; sourceTree = SOURCE_ROOT; };
5D0218F51A8E79C400D1BF62 /* ConnectionTCPTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ConnectionTCPTableViewController.m; path = SmartDeviceLink_Example/Classes/ConnectionTCPTableViewController.m; sourceTree = SOURCE_ROOT; };
5D0218F81A8E7A7300D1BF62 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = SmartDeviceLink_Example/Base.lproj/ConnectionTCPTableViewController.storyboard; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -1685,6 +1690,7 @@
DA4353E61D2721680099B8C4 /* DispatchTimerSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DispatchTimerSpec.m; path = UtilitiesSpecs/Touches/DispatchTimerSpec.m; sourceTree = "<group>"; };
DA4353E71D2721680099B8C4 /* SDLTouchManagerSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLTouchManagerSpec.m; path = UtilitiesSpecs/Touches/SDLTouchManagerSpec.m; sourceTree = "<group>"; };
DA4353E81D2721680099B8C4 /* SDLTouchSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLTouchSpec.m; path = UtilitiesSpecs/Touches/SDLTouchSpec.m; sourceTree = "<group>"; };
DA96C0651D4D4F730022F520 /* SDLAppInfoSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLAppInfoSpec.m; sourceTree = "<group>"; };
DAC572551D1067270004288B /* SDLTouchManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLTouchManager.h; sourceTree = "<group>"; };
DAC572561D1067270004288B /* SDLTouchManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLTouchManager.m; sourceTree = "<group>"; };
DAC572591D10B81E0004288B /* SDLTouch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLTouch.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1973,6 +1979,7 @@
isa = PBXGroup;
children = (
162E828F1A9BDE8A00906325 /* SDLAirbagStatusSpec.m */,
DA96C0651D4D4F730022F520 /* SDLAppInfoSpec.m */,
162E82901A9BDE8A00906325 /* SDLAudioPassThruCapabilitiesSpec.m */,
162E82911A9BDE8A00906325 /* SDLBeltStatusSpec.m */,
162E82921A9BDE8A00906325 /* SDLBodyInformationSpec.m */,
Expand Down Expand Up @@ -2457,6 +2464,8 @@
children = (
5D61FA481A84238A00846EE7 /* SDLAirbagStatus.h */,
5D61FA491A84238A00846EE7 /* SDLAirbagStatus.m */,
332A913C1CED87F80043824C /* SDLAppInfo.h */,
332A913D1CED87F80043824C /* SDLAppInfo.m */,
5D61FA581A84238A00846EE7 /* SDLAudioPassThruCapabilities.h */,
5D61FA591A84238A00846EE7 /* SDLAudioPassThruCapabilities.m */,
5D61FA5E1A84238A00846EE7 /* SDLBeltStatus.h */,
Expand Down Expand Up @@ -3283,6 +3292,7 @@
5D61FCA01A84238C00846EE7 /* SDLEncodedSyncPDataResponse.h in Headers */,
5D61FD271A84238C00846EE7 /* SDLPerformAudioPassThruResponse.h in Headers */,
5D61FD251A84238C00846EE7 /* SDLPerformAudioPassThru.h in Headers */,
332A91501CED9CF10043824C /* SDLAppInfo.h in Headers */,
5D61FDA71A84238C00846EE7 /* SDLSpeakResponse.h in Headers */,
5D61FD771A84238C00846EE7 /* SDLSamplingRate.h in Headers */,
5D61FCBB1A84238C00846EE7 /* SDLGPSData.h in Headers */,
Expand Down Expand Up @@ -3478,6 +3488,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
332A914F1CED9CC60043824C /* SDLAppInfo.m in Sources */,
5DCC19A51B822804004FFAD9 /* SDLURLRequestTask.m in Sources */,
5D61FC561A84238C00846EE7 /* SDLButtonName.m in Sources */,
5D61FCC21A84238C00846EE7 /* SDLHMILevel.m in Sources */,
Expand Down Expand Up @@ -3993,6 +4004,7 @@
DACBA1DE1D22D642002356F8 /* SDLTouchType.m in Sources */,
1680B1181A9CD7AD00DBD79E /* SDLV1ProtocolMessageSpec.m in Sources */,
162E82EC1A9BDE8B00906325 /* SDLLockScreenStatusSpec.m in Sources */,
DA96C0661D4D4F730022F520 /* SDLAppInfoSpec.m in Sources */,
162E832F1A9BDE8B00906325 /* SDLGetDTCsSpec.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
12 changes: 12 additions & 0 deletions SmartDeviceLink/SDLAppInfo.h
@@ -0,0 +1,12 @@
// SDLAppInfo.h
//

#import "SDLRPCStruct.h"

@interface SDLAppInfo : SDLRPCStruct

@property (strong) NSString *appDisplayName;
@property (strong) NSString *appBundleID;
@property (strong) NSString *appVersion;

@end
45 changes: 45 additions & 0 deletions SmartDeviceLink/SDLAppInfo.m
@@ -0,0 +1,45 @@
// SDLAppInfo.m
//

#import "SDLAppInfo.h"
#import "SDLNames.h"

@implementation SDLAppInfo

- (void)setAppDisplayName:(NSString *)appDisplayName {
if (appDisplayName != nil) {
[store setObject:appDisplayName forKey:NAMES_appDisplayName];
} else {
[store removeObjectForKey:NAMES_appDisplayName];
}
}

- (NSString *)appDisplayName {
return [store objectForKey:NAMES_appDisplayName];
}

- (void)setAppBundleID:(NSString *)appBundleID {
if (appBundleID != nil) {
[store setObject:appBundleID forKey:NAMES_appBundleID];
} else {
[store removeObjectForKey:NAMES_appBundleID];
}
}

- (NSString *)appBundleID {
return [store objectForKey:NAMES_appBundleID];
}

- (void)setAppVersion:(NSString *)appVersion {
if (appVersion != nil) {
[store setObject:appVersion forKey:NAMES_appVersion];
} else {
[store removeObjectForKey:NAMES_appVersion];
}
}

- (NSString *)appVersion {
return [store objectForKey:NAMES_appVersion];
}

@end
4 changes: 4 additions & 0 deletions SmartDeviceLink/SDLNames.h
Expand Up @@ -18,9 +18,13 @@
#define NAMES_altitude @"altitude"
#define NAMES_ambientLightSensorStatus @"ambientLightSensorStatus"
#define NAMES_ambientLightStatus @"ambientLightStatus"
#define NAMES_appBundleID @"appBundleID"
#define NAMES_appHMIType @"appHMIType"
#define NAMES_appID @"appID"
#define NAMES_appInfo @"appInfo"
#define NAMES_appName @"appName"
#define NAMES_appDisplayName @"appDisplayName"
#define NAMES_appVersion @"appVersion"
#define NAMES_audioPassThruCapabilities @"audioPassThruCapabilities"
#define NAMES_audioPassThruDisplayText1 @"audioPassThruDisplayText1"
#define NAMES_audioPassThruDisplayText2 @"audioPassThruDisplayText2"
Expand Down
16 changes: 15 additions & 1 deletion SmartDeviceLink/SDLRPCRequestFactory.m
Expand Up @@ -11,6 +11,7 @@
#import "SDLAlert.h"
#import "SDLAlertManeuver.h"
#import "SDLAppHMIType.h"
#import "SDLAppInfo.h"
#import "SDLChangeRegistration.h"
#import "SDLCreateInteractionChoiceSet.h"
#import "SDLDebugTool.h"
Expand Down Expand Up @@ -55,7 +56,9 @@
#import "SDLUnsubscribeButton.h"
#import "SDLUnsubscribeVehicleData.h"
#import "SDLUpdateTurnList.h"
#import "SDLAppInfo.h"

static NSString* const SDLBundleShortVersionStringKey = @"CFBundleShortVersionString";

@implementation SDLRPCRequestFactory

Expand Down Expand Up @@ -376,7 +379,9 @@ + (SDLRegisterAppInterface *)buildRegisterAppInterfaceWithAppName:(NSString *)ap
msg.appID = appID;
msg.deviceInfo = [self sdl_buildDeviceInfo];
msg.correlationID = [NSNumber numberWithInt:1];

SDLAppInfo* appInfo = [self sdl_buildAppInfo];
appInfo.appDisplayName = appName;
msg.appInfo = appInfo;
return msg;
}

Expand All @@ -393,6 +398,15 @@ + (SDLDeviceInfo *)sdl_buildDeviceInfo {
return deviceInfo;
}

+ (SDLAppInfo*)sdl_buildAppInfo {
SDLAppInfo* appInfo = [[SDLAppInfo alloc] init];
NSBundle* mainBundle = [NSBundle mainBundle];
NSDictionary* bundleDictionary = mainBundle.infoDictionary;
appInfo.appVersion = bundleDictionary[SDLBundleShortVersionStringKey];
appInfo.appBundleID = mainBundle.bundleIdentifier;
return appInfo;
}

+ (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];
Expand Down
9 changes: 8 additions & 1 deletion SmartDeviceLink/SDLRegisterAppInterface.h
Expand Up @@ -6,7 +6,7 @@
@class SDLDeviceInfo;
@class SDLLanguage;
@class SDLSyncMsgVersion;

@class SDLAppInfo;

/**
* Registers the application's interface with SDL&reg;, declaring properties of
Expand Down Expand Up @@ -214,4 +214,11 @@
*/
@property (strong) NSString *appID;

/**
* @abstract Information about the application running
*
* Optional
*/
@property (strong) SDLAppInfo *appInfo;

@end
18 changes: 18 additions & 0 deletions SmartDeviceLink/SDLRegisterAppInterface.m
Expand Up @@ -5,6 +5,7 @@
#import "SDLRegisterAppInterface.h"

#import "SDLAppHMIType.h"
#import "SDLAppInfo.h"
#import "SDLDeviceInfo.h"
#import "SDLLanguage.h"
#import "SDLNames.h"
Expand Down Expand Up @@ -208,4 +209,21 @@ - (NSString *)appID {
return [parameters objectForKey:NAMES_appID];
}

- (void)setAppInfo:(SDLAppInfo *)appInfo {
if (appInfo != nil) {
[parameters setObject:appInfo forKey:NAMES_appInfo];
} else {
[parameters removeObjectForKey:NAMES_appInfo];
}
}

- (SDLAppInfo *)appInfo {
NSObject *obj = [parameters objectForKey:NAMES_appInfo];
if (obj == nil || [obj isKindOfClass:SDLAppInfo.class]) {
return (SDLAppInfo *)obj;
} else {
return [[SDLAppInfo alloc] initWithDictionary:(NSMutableDictionary *)obj];
}
}

@end
1 change: 1 addition & 0 deletions SmartDeviceLink/SmartDeviceLink.h
Expand Up @@ -164,6 +164,7 @@ FOUNDATION_EXPORT const unsigned char SmartDeviceLinkVersionString[];

// Structs
#import "SDLAirbagStatus.h"
#import "SDLAppInfo.h"
#import "SDLAudioPassThruCapabilities.h"
#import "SDLBeltStatus.h"
#import "SDLBodyInformation.h"
Expand Down
Expand Up @@ -7,6 +7,7 @@

#import <Quick/Quick.h>
#import <Nimble/Nimble.h>
#import <OCMock/OCMock.h>

#import "SmartDeviceLink.h"

Expand Down Expand Up @@ -481,6 +482,11 @@

describe(@"BuildRegisterAppInterface Tests", ^ {
it(@"Should build correctly", ^ {
// Mock the infomation that will be pulled from the mainBundle.
id bundleMock = OCMPartialMock([NSBundle mainBundle]);
OCMStub([bundleMock infoDictionary]).andReturn(@{@"CFBundleShortVersionString" : @"1.2.3.4"});
OCMStub([bundleMock bundleIdentifier]).andReturn(@"com.register.test");

NSMutableArray *ttsName = [NSMutableArray arrayWithArray:@[[[SDLTTSChunk alloc] init]]];
NSMutableArray *synonyms = [NSMutableArray arrayWithArray:@[@"Q", @"W", @"E", @"R"]];
SDLRegisterAppInterface* message = [SDLRPCRequestFactory buildRegisterAppInterfaceWithAppName:@"Interface" ttsName:ttsName vrSynonyms:synonyms
Expand All @@ -491,6 +497,10 @@
expect(message.syncMsgVersion.majorVersion).to(equal(@1));
expect(message.syncMsgVersion.minorVersion).to(equal(@0));

expect(message.appInfo.appBundleID).to(equal(@"com.register.test"));
expect(message.appInfo.appDisplayName).to(equal(@"Interface"));
expect(message.appInfo.appVersion).to(equal(@"1.2.3.4"));

expect(message.appName).to(equal(@"Interface"));
expect(message.ttsName).to(equal(ttsName));
expect(message.ngnMediaScreenAppName).to(equal(@"Interface"));
Expand All @@ -510,6 +520,10 @@
expect(message.syncMsgVersion.majorVersion).to(equal(@1));
expect(message.syncMsgVersion.minorVersion).to(equal(@0));

expect(message.appInfo.appBundleID).to(equal(@"com.register.test"));
expect(message.appInfo.appDisplayName).to(equal(@"Register App Interface"));
expect(message.appInfo.appVersion).to(equal(@"1.2.3.4"));

expect(message.appName).to(equal(@"Register App Interface"));
expect(message.ttsName).to(beNil());
expect(message.ngnMediaScreenAppName).to(equal(@"Register App Interface"));
Expand All @@ -529,6 +543,10 @@
expect(message.syncMsgVersion.majorVersion).to(equal(@1));
expect(message.syncMsgVersion.minorVersion).to(equal(@0));

expect(message.appInfo.appBundleID).to(equal(@"com.register.test"));
expect(message.appInfo.appDisplayName).to(equal(@"..."));
expect(message.appInfo.appVersion).to(equal(@"1.2.3.4"));

expect(message.appName).to(equal(@"..."));
expect(message.ttsName).to(beNil());
expect(message.ngnMediaScreenAppName).to(equal(@"..."));
Expand Down
Expand Up @@ -9,6 +9,7 @@
#import <Nimble/Nimble.h>

#import "SDLAppHMIType.h"
#import "SDLAppInfo.h"
#import "SDLDeviceInfo.h"
#import "SDLLanguage.h"
#import "SDLNames.h"
Expand All @@ -22,6 +23,7 @@
SDLSyncMsgVersion* version = [[SDLSyncMsgVersion alloc] init];
SDLTTSChunk* chunk = [[SDLTTSChunk alloc] init];
SDLDeviceInfo* info = [[SDLDeviceInfo alloc] init];
SDLAppInfo* appInfo = [[SDLAppInfo alloc] init];

describe(@"Getter/Setter Tests", ^ {
it(@"Should set and get correctly", ^ {
Expand All @@ -39,6 +41,7 @@
testRequest.hashID = @"gercd35grw2";
testRequest.deviceInfo = info;
testRequest.appID = @"123456789";
testRequest.appInfo = appInfo;

expect(testRequest.syncMsgVersion).to(equal(version));
expect(testRequest.appName).to(equal(@"app56"));
Expand All @@ -52,6 +55,7 @@
expect(testRequest.hashID).to(equal(@"gercd35grw2"));
expect(testRequest.deviceInfo).to(equal(info));
expect(testRequest.appID).to(equal(@"123456789"));
expect(testRequest.appInfo).to(equal(appInfo));
});

it(@"Should get correctly when initialized", ^ {
Expand All @@ -68,7 +72,8 @@
NAMES_appHMIType:[@[[SDLAppHMIType MESSAGING], [SDLAppHMIType INFORMATION]] copy],
NAMES_hashID:@"gercd35grw2",
NAMES_deviceInfo:info,
NAMES_appID:@"123456789"},
NAMES_appID:@"123456789",
NAMES_appInfo:appInfo},
NAMES_operation_name:NAMES_RegisterAppInterface}} mutableCopy];
SDLRegisterAppInterface* testRequest = [[SDLRegisterAppInterface alloc] initWithDictionary:dict];

Expand All @@ -84,6 +89,7 @@
expect(testRequest.hashID).to(equal(@"gercd35grw2"));
expect(testRequest.deviceInfo).to(equal(info));
expect(testRequest.appID).to(equal(@"123456789"));
expect(testRequest.appInfo).to(equal(appInfo));
});

it(@"Should return nil if not set", ^ {
Expand All @@ -101,6 +107,7 @@
expect(testRequest.hashID).to(beNil());
expect(testRequest.deviceInfo).to(beNil());
expect(testRequest.appID).to(beNil());
expect(testRequest.appInfo).to(beNil());
});
});

Expand Down