blob: bfec12164d6170ca4dcc301038339928be7a1d9c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
// SDLAddCommand.m
//
#import "SDLAddCommand.h"
#import "NSMutableDictionary+Store.h"
#import "SDLImage.h"
#import "SDLMenuParams.h"
#import "SDLNames.h"
NS_ASSUME_NONNULL_BEGIN
@implementation SDLAddCommand
- (instancetype)init {
if (self = [super initWithName:SDLNameAddCommand]) {
}
return self;
}
- (instancetype)initWithHandler:(nullable SDLRPCCommandNotificationHandler)handler {
self = [self init];
if (!self) {
return nil;
}
_handler = handler;
return self;
}
- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands handler:(nullable SDLRPCCommandNotificationHandler)handler {
self = [self init];
if (!self) {
return nil;
}
self.cmdID = @(commandId);
self.vrCommands = [vrCommands mutableCopy];
self.handler = handler;
return self;
}
- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands menuName:(NSString *)menuName handler:(SDLRPCCommandNotificationHandler)handler {
self = [self initWithId:commandId vrCommands:vrCommands handler:handler];
if (!self) {
return nil;
}
self.menuParams = [[SDLMenuParams alloc] initWithMenuName:menuName];
return self;
}
- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands menuName:(NSString *)menuName parentId:(UInt32)parentId position:(UInt16)position iconValue:(NSString *)iconValue iconType:(SDLImageType)iconType handler:(nullable SDLRPCCommandNotificationHandler)handler {
self = [self initWithId:commandId vrCommands:vrCommands menuName:menuName handler:handler];
if (!self) {
return nil;
}
self.menuParams.parentID = @(parentId);
self.menuParams.position = @(position);
self.cmdIcon = [[SDLImage alloc] initWithName:iconValue ofType:iconType];
return self;
}
- (void)setCmdID:(NSNumber<SDLInt> *)cmdID {
[parameters sdl_setObject:cmdID forName:SDLNameCommandId];
}
- (NSNumber<SDLInt> *)cmdID {
return [parameters sdl_objectForName:SDLNameCommandId];
}
- (void)setMenuParams:(nullable SDLMenuParams *)menuParams {
[parameters sdl_setObject:menuParams forName:SDLNameMenuParams];
}
- (nullable SDLMenuParams *)menuParams {
return [parameters sdl_objectForName:SDLNameMenuParams ofClass:SDLMenuParams.class];
}
- (void)setVrCommands:(nullable NSArray<NSString *> *)vrCommands {
[parameters sdl_setObject:vrCommands forName:SDLNameVRCommands];
}
- (nullable NSArray<NSString *> *)vrCommands {
return [parameters sdl_objectForName:SDLNameVRCommands];
}
- (void)setCmdIcon:(nullable SDLImage *)cmdIcon {
[parameters sdl_setObject:cmdIcon forName:SDLNameCommandIcon];
}
- (nullable SDLImage *)cmdIcon {
return [parameters sdl_objectForName:SDLNameCommandIcon ofClass:SDLImage.class];
}
-(id)copyWithZone:(nullable NSZone *)zone {
SDLAddCommand *newCommand = [super copyWithZone:zone];
newCommand->_handler = self.handler;
return newCommand;
}
@end
NS_ASSUME_NONNULL_END
|