blob: 10e553f6cb4802b3b048d69de295b5249ef4fd27 (
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
|
//
// SDLnotificationDispatcher.m
// SmartDeviceLink-iOS
//
// Created by Joel Fischer on 7/7/16.
// Copyright © 2016 smartdevicelink. All rights reserved.
//
#import "SDLNotificationDispatcher.h"
#import "SDLError.h"
#import "SDLNotificationConstants.h"
#import "SDLRPCNotification.h"
#import "SDLRPCNotificationNotification.h"
#import "SDLRPCResponseNotification.h"
NS_ASSUME_NONNULL_BEGIN
@implementation SDLNotificationDispatcher
- (void)postNotificationName:(NSString *)name infoObject:(nullable id)infoObject {
NSDictionary<NSString *, id> *userInfo = nil;
if (infoObject != nil) {
userInfo = @{SDLNotificationUserInfoObject: infoObject};
}
dispatch_async(dispatch_get_main_queue(), ^{
[[NSNotificationCenter defaultCenter] postNotificationName:name object:self userInfo:userInfo];
});
}
- (void)postRPCResponseNotification:(NSString *)name response:(__kindof SDLRPCResponse *)response {
dispatch_async(dispatch_get_main_queue(), ^{
SDLRPCResponseNotification *notification = [[SDLRPCResponseNotification alloc] initWithName:name object:self rpcResponse:response];
[[NSNotificationCenter defaultCenter] postNotification:notification];
});
}
- (void)postRPCNotificationNotification:(NSString *)name notification:(__kindof SDLRPCNotification *)rpcNotification {
dispatch_async(dispatch_get_main_queue(), ^{
SDLRPCNotificationNotification *notification = [[SDLRPCNotificationNotification alloc] initWithName:name object:self rpcNotification:rpcNotification];
[[NSNotificationCenter defaultCenter] postNotification:notification];
});
}
#pragma mark - SDLProxyListener Delegate Methods
- (void)onProxyOpened {
[self postNotificationName:SDLTransportDidConnect infoObject:nil];
}
- (void)onProxyClosed {
[self postNotificationName:SDLTransportDidDisconnect infoObject:nil];
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
- (void)onOnHMIStatus:(SDLOnHMIStatus *)notification {
[self postRPCNotificationNotification:SDLDidChangeHMIStatusNotification notification:notification];
}
- (void)onOnDriverDistraction:(SDLOnDriverDistraction *)notification {
[self postRPCNotificationNotification:SDLDidChangeDriverDistractionStateNotification notification:notification];
}
#pragma mark Optional Methods
- (void)onError:(NSException *)e {
NSError *error = [NSError sdl_lifecycle_unknownRemoteErrorWithDescription:e.name andReason:e.reason];
[self postNotificationName:SDLDidReceiveError infoObject:error];
}
- (void)onReceivedLockScreenIcon:(UIImage *)icon {
[self postNotificationName:SDLDidReceiveLockScreenIcon infoObject:icon];
}
- (void)onAddCommandResponse:(SDLAddCommandResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveAddCommandResponse response:response];
}
- (void)onAddSubMenuResponse:(SDLAddSubMenuResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveAddSubMenuResponse response:response];
}
- (void)onAlertManeuverResponse:(SDLAlertManeuverResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveAlertManeuverResponse response:response];
}
- (void)onAlertResponse:(SDLAlertResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveAlertResponse response:response];
}
- (void)onChangeRegistrationResponse:(SDLChangeRegistrationResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveChangeRegistrationResponse response:response];
}
- (void)onCreateInteractionChoiceSetResponse:(SDLCreateInteractionChoiceSetResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveCreateInteractionChoiceSetResponse response:response];
}
- (void)onDeleteCommandResponse:(SDLDeleteCommandResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveDeleteCommandResponse response:response];
}
- (void)onDeleteFileResponse:(SDLDeleteFileResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveDeleteFileResponse response:response];
}
- (void)onDeleteInteractionChoiceSetResponse:(SDLDeleteInteractionChoiceSetResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveDeleteInteractionChoiceSetResponse response:response];
}
- (void)onDeleteSubMenuResponse:(SDLDeleteSubMenuResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveDeleteSubmenuResponse response:response];
}
- (void)onDiagnosticMessageResponse:(SDLDiagnosticMessageResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveDiagnosticMessageResponse response:response];
}
- (void)onDialNumberResponse:(SDLDialNumberResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveDialNumberResponse response:response];
}
- (void)onEncodedSyncPDataResponse:(SDLEncodedSyncPDataResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveEncodedSyncPDataResponse response:response];
}
- (void)onEndAudioPassThruResponse:(SDLEndAudioPassThruResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveEndAudioPassThruResponse response:response];
}
- (void)onGenericResponse:(SDLGenericResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveGenericResponse response:response];
}
- (void)onGetDTCsResponse:(SDLGetDTCsResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveGetDTCsResponse response:response];
}
- (void)onGetVehicleDataResponse:(SDLGetVehicleDataResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveGetVehicleDataResponse response:response];
}
- (void)onListFilesResponse:(SDLListFilesResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveListFilesResponse response:response];
}
- (void)onPerformAudioPassThruResponse:(SDLPerformAudioPassThruResponse *)response {
[self postRPCResponseNotification:SDLDidReceivePerformAudioPassThruResponse response:response];
}
- (void)onPerformInteractionResponse:(SDLPerformInteractionResponse *)response {
[self postRPCResponseNotification:SDLDidReceivePerformInteractionResponse response:response];
}
- (void)onPutFileResponse:(SDLPutFileResponse *)response {
[self postRPCResponseNotification:SDLDidReceivePutFileResponse response:response];
}
- (void)onReadDIDResponse:(SDLReadDIDResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveReadDIDResponse response:response];
}
- (void)onRegisterAppInterfaceResponse:(SDLRegisterAppInterfaceResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveRegisterAppInterfaceResponse response:response];
}
- (void)onResetGlobalPropertiesResponse:(SDLResetGlobalPropertiesResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveResetGlobalPropertiesResponse response:response];
}
- (void)onScrollableMessageResponse:(SDLScrollableMessageResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveScrollableMessageResponse response:response];
}
- (void)onSendLocationResponse:(SDLSendLocationResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveSendLocationResponse response:response];
}
- (void)onSetAppIconResponse:(SDLSetAppIconResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveSetAppIconResponse response:response];
}
- (void)onSetDisplayLayoutResponse:(SDLSetDisplayLayoutResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveSetDisplayLayoutResponse response:response];
}
- (void)onSetGlobalPropertiesResponse:(SDLSetGlobalPropertiesResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveSetGlobalPropertiesResponse response:response];
}
- (void)onSetMediaClockTimerResponse:(SDLSetMediaClockTimerResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveSetMediaClockTimerResponse response:response];
}
- (void)onShowConstantTBTResponse:(SDLShowConstantTBTResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveShowConstantTBTResponse response:response];
}
- (void)onShowResponse:(SDLShowResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveShowResponse response:response];
}
- (void)onSliderResponse:(SDLSliderResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveSliderResponse response:response];
}
- (void)onSpeakResponse:(SDLSpeakResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveSpeakResponse response:response];
}
- (void)onSubscribeButtonResponse:(SDLSubscribeButtonResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveSubscribeButtonResponse response:response];
}
- (void)onSubscribeVehicleDataResponse:(SDLSubscribeVehicleDataResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveSubscribeVehicleDataResponse response:response];
}
- (void)onSyncPDataResponse:(SDLSyncPDataResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveSyncPDataResponse response:response];
}
- (void)onUpdateTurnListResponse:(SDLUpdateTurnListResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveUpdateTurnListResponse response:response];
}
- (void)onUnregisterAppInterfaceResponse:(SDLUnregisterAppInterfaceResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveUnregisterAppInterfaceResponse response:response];
}
- (void)onUnsubscribeButtonResponse:(SDLUnsubscribeButtonResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveUnsubscribeButtonResponse response:response];
}
- (void)onUnsubscribeVehicleDataResponse:(SDLUnsubscribeVehicleDataResponse *)response {
[self postRPCResponseNotification:SDLDidReceiveUnsubscribeVehicleDataResponse response:response];
}
- (void)onOnAppInterfaceUnregistered:(SDLOnAppInterfaceUnregistered *)notification {
[self postRPCNotificationNotification:SDLDidReceiveAppUnregisteredNotification notification:notification];
}
- (void)onOnAudioPassThru:(SDLOnAudioPassThru *)notification {
[self postRPCNotificationNotification:SDLDidReceiveAudioPassThruNotification notification:notification];
}
- (void)onOnButtonEvent:(SDLOnButtonEvent *)notification {
[self postRPCNotificationNotification:SDLDidReceiveButtonEventNotification notification:notification];
}
- (void)onOnButtonPress:(SDLOnButtonPress *)notification {
[self postRPCNotificationNotification:SDLDidReceiveButtonPressNotification notification:notification];
}
- (void)onOnCommand:(SDLOnCommand *)notification {
[self postRPCNotificationNotification:SDLDidReceiveCommandNotification notification:notification];
}
- (void)onOnEncodedSyncPData:(SDLOnEncodedSyncPData *)notification {
[self postRPCNotificationNotification:SDLDidReceiveEncodedDataNotification notification:notification];
}
- (void)onOnHashChange:(SDLOnHashChange *)notification {
[self postRPCNotificationNotification:SDLDidReceiveNewHashNotification notification:notification];
}
- (void)onOnKeyboardInput:(SDLOnKeyboardInput *)notification {
[self postRPCNotificationNotification:SDLDidReceiveKeyboardInputNotification notification:notification];
}
- (void)onOnLanguageChange:(SDLOnLanguageChange *)notification {
[self postRPCNotificationNotification:SDLDidChangeLanguageNotification notification:notification];
}
- (void)onOnLockScreenNotification:(SDLOnLockScreenStatus *)notification {
[self postRPCNotificationNotification:SDLDidChangeLockScreenStatusNotification notification:notification];
}
- (void)onOnPermissionsChange:(SDLOnPermissionsChange *)notification {
[self postRPCNotificationNotification:SDLDidChangePermissionsNotification notification:notification];
}
- (void)onOnSyncPData:(SDLOnSyncPData *)notification {
[self postRPCNotificationNotification:SDLDidReceiveSystemRequestNotification notification:notification];
}
- (void)onOnSystemRequest:(SDLOnSystemRequest *)notification {
[self postRPCNotificationNotification:SDLDidReceiveSystemRequestNotification notification:notification];
}
- (void)onOnTBTClientState:(SDLOnTBTClientState *)notification {
[self postRPCNotificationNotification:SDLDidChangeTurnByTurnStateNotification notification:notification];
}
- (void)onOnTouchEvent:(SDLOnTouchEvent *)notification {
[self postRPCNotificationNotification:SDLDidReceiveTouchEventNotification notification:notification];
}
- (void)onOnVehicleData:(SDLOnVehicleData *)notification {
[self postRPCNotificationNotification:SDLDidReceiveVehicleDataNotification notification:notification];
}
#pragma clang diagnostic pop
@end
NS_ASSUME_NONNULL_END
|