summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLNotificationConstants.h
blob: a2a371d3f0d5b49ede84d516d4ed7d4ccba77508 (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
//
//  SDLNotificationConstants.h
//  SmartDeviceLink-iOS
//
//  Created by Justin Dickow on 9/30/15.
//  Copyright © 2015 smartdevicelink. All rights reserved.
//

#import <Foundation/Foundation.h>

@class SDLOnButtonEvent;
@class SDLOnButtonPress;
@class SDLOnCommand;
@class SDLRPCNotification;
@class SDLRPCResponse;
@class SDLRPCRequest;


NS_ASSUME_NONNULL_BEGIN

// Resolves issue of using Swift 3 and pre-iOS 10 versions due to NSNotificationName unavailability.
#if __IPHONE_OS_VERSION_MAX_ALLOWED <= __IPHONE_9_3
#define NOTIFICATION_TYPEDEF NSString *
#else
#define NOTIFICATION_TYPEDEF NSNotificationName
#endif

typedef NOTIFICATION_TYPEDEF SDLNotificationName;

typedef NSString *SDLNotificationUserInfoKey;

#pragma mark - Blocks

/**
 *  A handler used on SDLPerformAudioPassThru.
 *
 *  @param audioData The audio data contained in the notification.
 */
typedef void (^SDLAudioPassThruHandler)(NSData *__nullable audioData);

/**
 *  A handler used on all RPC requests which fires when the response is received.
 *
 *  @param request  The request which was sent.
 *  @param response The response which was received.
 *  @param error    If sending the request encountered an error, this parameter will not be nil.
 */
typedef void (^SDLResponseHandler)(__kindof SDLRPCRequest *__nullable request, __kindof SDLRPCResponse *__nullable response, NSError *__nullable error);

/**
 A completion handler called after a sequential or simultaneous set of requests have completed sending.

 @param success True if every request succeeded, false if any failed. See the progress handler for more details on failures.
 */
typedef void (^SDLMultipleRequestCompletionHandler)(BOOL success);

/**
 A handler called after each response to a request comes in in a multiple request send.

 @param request The request that received a response
 @param response The response received
 @param error The error that occurred during the request if any occurred.
 @param percentComplete The percentage of requests that have received a response
 @return continueSendingRequests NO to cancel any requests that have not yet been sent. This is really only useful for a sequential send (sendSequentialRequests:progressHandler:completionHandler:). Return YES to continue sending requests.
 */
typedef BOOL (^SDLMultipleSequentialRequestProgressHandler)(__kindof SDLRPCRequest *request, __kindof SDLRPCResponse *__nullable response, NSError *__nullable error, float percentComplete);

/**
 A handler called after each response to a request comes in in a multiple request send.

 @param request The request that received a response
 @param response The response received
 @param error The error that occurred during the request if any occurred.
 @param percentComplete The percentage of requests that have received a response
 */
typedef void (^SDLMultipleAsyncRequestProgressHandler)(__kindof SDLRPCRequest *request, __kindof SDLRPCResponse *__nullable response, NSError *__nullable error, float percentComplete);

/**
 A handler that may optionally be run when an SDLSubscribeButton or SDLSoftButton has a corresponding notification occur.
 
 @warning This only works if you send the RPC using SDLManager.
 @warning Only one of the two parameters will be set for each block call.
 
 @param buttonPress An SDLOnButtonPress object that corresponds to this particular button.
 @param buttonEvent An SDLOnButtonEvent object that corresponds to this particular button.
 */
typedef void (^SDLRPCButtonNotificationHandler)(SDLOnButtonPress *_Nullable buttonPress,  SDLOnButtonEvent *_Nullable buttonEvent);
/**
 A handler that may optionally be run when an SDLAddCommand has a corresponding notification occur.
 
 @warning This only works if you send the RPC using SDLManager.
 
 @param command An SDLOnCommand object that corresponds to this particular SDLAddCommand.
 */
typedef void (^SDLRPCCommandNotificationHandler)(SDLOnCommand *command);

/**
 *  The key used in all SDL NSNotifications to extract the response or notification from the userinfo dictionary.
 */
#pragma mark - Notification info dictionary keys
extern SDLNotificationUserInfoKey const SDLNotificationUserInfoObject;

/**
 *  Some general NSNotification names not associated with any specific RPC response or request.
 */
#pragma mark - General notifications
extern SDLNotificationName const SDLTransportDidDisconnect;
extern SDLNotificationName const SDLTransportDidConnect;
extern SDLNotificationName const SDLTransportConnectError;
extern SDLNotificationName const SDLDidReceiveError;
extern SDLNotificationName const SDLDidReceiveLockScreenIcon;
extern SDLNotificationName const SDLDidBecomeReady;
extern SDLNotificationName const SDLDidUpdateProjectionView;

/**
 *  NSNotification names associated with specific RPC responses.
 */
#pragma mark - RPC responses
extern SDLNotificationName const SDLDidReceiveAddCommandResponse;
extern SDLNotificationName const SDLDidReceiveAddSubMenuResponse;
extern SDLNotificationName const SDLDidReceiveAlertResponse;
extern SDLNotificationName const SDLDidReceiveAlertManeuverResponse;
extern SDLNotificationName const SDLDidReceiveButtonPressResponse;
extern SDLNotificationName const SDLDidReceiveChangeRegistrationResponse;
extern SDLNotificationName const SDLDidReceiveCreateInteractionChoiceSetResponse;
extern SDLNotificationName const SDLDidReceiveDeleteCommandResponse;
extern SDLNotificationName const SDLDidReceiveDeleteFileResponse;
extern SDLNotificationName const SDLDidReceiveDeleteInteractionChoiceSetResponse;
extern SDLNotificationName const SDLDidReceiveDeleteSubmenuResponse;
extern SDLNotificationName const SDLDidReceiveDiagnosticMessageResponse;
extern SDLNotificationName const SDLDidReceiveDialNumberResponse;
extern SDLNotificationName const SDLDidReceiveEncodedSyncPDataResponse;
extern SDLNotificationName const SDLDidReceiveEndAudioPassThruResponse;
extern SDLNotificationName const SDLDidReceiveGenericResponse;
extern SDLNotificationName const SDLDidReceiveGetDTCsResponse;
extern SDLNotificationName const SDLDidReceiveGetInteriorVehicleDataResponse;
extern SDLNotificationName const SDLDidReceiveGetSystemCapabilitiesResponse;
extern SDLNotificationName const SDLDidReceiveGetVehicleDataResponse;
extern SDLNotificationName const SDLDidReceiveGetWaypointsResponse;
extern SDLNotificationName const SDLDidReceiveListFilesResponse;
extern SDLNotificationName const SDLDidReceivePerformAudioPassThruResponse;
extern SDLNotificationName const SDLDidReceivePerformInteractionResponse;
extern SDLNotificationName const SDLDidReceivePutFileResponse;
extern SDLNotificationName const SDLDidReceiveReadDIDResponse;
extern SDLNotificationName const SDLDidReceiveRegisterAppInterfaceResponse;
extern SDLNotificationName const SDLDidReceiveResetGlobalPropertiesResponse;
extern SDLNotificationName const SDLDidReceiveScrollableMessageResponse;
extern SDLNotificationName const SDLDidReceiveSendHapticDataResponse;
extern SDLNotificationName const SDLDidReceiveSendLocationResponse;
extern SDLNotificationName const SDLDidReceiveSetAppIconResponse;
extern SDLNotificationName const SDLDidReceiveSetDisplayLayoutResponse;
extern SDLNotificationName const SDLDidReceiveSetGlobalPropertiesResponse;
extern SDLNotificationName const SDLDidReceiveSetInteriorVehicleDataResponse;
extern SDLNotificationName const SDLDidReceiveSetMediaClockTimerResponse;
extern SDLNotificationName const SDLDidReceiveShowConstantTBTResponse;
extern SDLNotificationName const SDLDidReceiveShowResponse;
extern SDLNotificationName const SDLDidReceiveSliderResponse;
extern SDLNotificationName const SDLDidReceiveSpeakResponse;
extern SDLNotificationName const SDLDidReceiveSubscribeButtonResponse;
extern SDLNotificationName const SDLDidReceiveSubscribeVehicleDataResponse;
extern SDLNotificationName const SDLDidReceiveSubscribeWaypointsResponse;
extern SDLNotificationName const SDLDidReceiveSyncPDataResponse;
extern SDLNotificationName const SDLDidReceiveUpdateTurnListResponse;
extern SDLNotificationName const SDLDidReceiveUnregisterAppInterfaceResponse;
extern SDLNotificationName const SDLDidReceiveUnsubscribeButtonResponse;
extern SDLNotificationName const SDLDidReceiveUnsubscribeVehicleDataResponse;
extern SDLNotificationName const SDLDidReceiveUnsubscribeWaypointsResponse;

/**
 *  NSNotification names associated with specific RPC notifications.
 */
#pragma mark - RPC Notifications
extern SDLNotificationName const SDLDidChangeDriverDistractionStateNotification;
extern SDLNotificationName const SDLDidChangeHMIStatusNotification;
extern SDLNotificationName const SDLDidReceiveAudioPassThruNotification;
extern SDLNotificationName const SDLDidReceiveAppUnregisteredNotification;
extern SDLNotificationName const SDLDidReceiveButtonEventNotification;
extern SDLNotificationName const SDLDidReceiveButtonPressNotification;
extern SDLNotificationName const SDLDidReceiveCommandNotification;
extern SDLNotificationName const SDLDidReceiveEncodedDataNotification;
extern SDLNotificationName const SDLDidReceiveInteriorVehicleDataNotification;
extern SDLNotificationName const SDLDidReceiveKeyboardInputNotification;
extern SDLNotificationName const SDLDidChangeLanguageNotification;
extern SDLNotificationName const SDLDidChangeLockScreenStatusNotification;
extern SDLNotificationName const SDLDidReceiveNewHashNotification;
extern SDLNotificationName const SDLDidReceiveVehicleIconNotification;
extern SDLNotificationName const SDLDidChangePermissionsNotification;
extern SDLNotificationName const SDLDidReceiveRemoteControlStatusNotification;
extern SDLNotificationName const SDLDidReceiveSystemRequestNotification;
extern SDLNotificationName const SDLDidChangeTurnByTurnStateNotification;
extern SDLNotificationName const SDLDidReceiveTouchEventNotification;
extern SDLNotificationName const SDLDidReceiveVehicleDataNotification;
extern SDLNotificationName const SDLDidReceiveWaypointNotification;

@interface SDLNotificationConstants : NSObject

/**
 All of the possible SDL RPC Response notification names

 @return The names
 */
+ (NSArray<SDLNotificationName> *)allResponseNames;

/**
 All of the possible SDL Button event notification names

 @return The names
 */
+ (NSArray<SDLNotificationName> *)allButtonEventNotifications;

@end

NS_ASSUME_NONNULL_END