summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLSoftButton.m
blob: 201144f20ed3686919baa40d4a9c27575ce7506c (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
113
114
115
116
117
118
119
120
121
122
123
124
//  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)initWithHandler:(SDLRPCNotificationHandler)handler {
    self = [self init];
    if (!self) {
        return nil;
    }

    _handler = handler;

    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