summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLManager.h
blob: 1e3438b161dab257be77304aa800349014224f4e (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


#import "SDLNotificationConstants.h"

#import "SDLAudioStreamingState.h"
#import "SDLHMILevel.h"
#import "SDLLanguage.h"
#import "SDLSystemContext.h"

@class SDLConfiguration;
@class SDLFileManager;
@class SDLLifecycleConfiguration;
@class SDLLockScreenConfiguration;
@class SDLPermissionManager;
@class SDLProxy;
@class SDLPutFile;
@class SDLRegisterAppInterfaceResponse;
@class SDLRPCNotification;
@class SDLRPCRequest;
@class SDLRPCResponse;
@class SDLStreamingMediaManager;

@protocol SDLManagerDelegate;


NS_ASSUME_NONNULL_BEGIN

typedef void (^SDLManagerReadyBlock)(BOOL success, NSError *_Nullable error);


@interface SDLManager : NSObject

/**
 *  The configuration the manager was set up with.
 */
@property (copy, nonatomic, readonly) SDLConfiguration *configuration;

/**
 *  The current HMI level of the running app.
 */
@property (copy, nonatomic, readonly) SDLHMILevel hmiLevel;

/**
 *  The current audio streaming state of the running app.
 */
@property (copy, nonatomic, readonly) SDLAudioStreamingState audioStreamingState;

/**
 *  The current system context of the running app.
 */
@property (copy, nonatomic, readonly) SDLSystemContext systemContext;

/**
 *  The file manager to be used by the running app.
 */
@property (strong, nonatomic, readonly) SDLFileManager *fileManager;

/**
 *  The permission manager monitoring RPC permissions.
 */
@property (strong, nonatomic, readonly) SDLPermissionManager *permissionManager;

/**
 *  The streaming media manager to be used for starting video sessions.
 */
@property (strong, nonatomic, readonly, nullable) SDLStreamingMediaManager *streamManager;

/**
 *  The response of a register call after it has been received.
 */
@property (strong, nonatomic, readonly, nullable) SDLRegisterAppInterfaceResponse *registerResponse;

/**
 *  The manager's delegate.
 */
@property (weak, nonatomic, nullable) id<SDLManagerDelegate> delegate;

/**
 * Deprecated internal proxy object. This should only be accessed when the Manager is READY. This property may go to nil at any time.
 * The only reason to use this is to access the `putFileStream:withRequest:` method. All other functionality exists on managers in 4.3. This will be removed in 5.0 and the functionality replicated on `SDLFileManager`.
 */
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
@property (strong, nonatomic, readonly, nullable) SDLProxy *proxy;
#pragma clang diagnostic pop


#pragma mark Lifecycle

/**
 *  Initialize the manager with a configuration. Call `startWithHandler` to begin waiting for a connection.
 *
 *  @param configuration Your app's unique configuration for setup.
 *  @param delegate An optional delegate to be notified of hmi level changes and startup and shutdown. It is recommended that you implement this.
 *
 *  @return An instance of SDLManager
 */
- (instancetype)initWithConfiguration:(SDLConfiguration *)configuration delegate:(nullable id<SDLManagerDelegate>)delegate NS_DESIGNATED_INITIALIZER;

/**
 *  Start the manager, which will tell it to start looking for a connection. Once one does, it will automatically run the setup process and call the readyBlock when done.
 *
 *  @param readyHandler The block called when the manager is ready to be used or an error occurs while attempting to become ready.
 */
- (void)startWithReadyHandler:(SDLManagerReadyBlock)readyHandler NS_SWIFT_NAME(start(readyHandler:));

/**
 *  Stop the manager, it will disconnect if needed and no longer look for a connection. You probably don't need to call this method ever.
 *  
 *  If you do call this method, you must wait for SDLManagerDelegate's managerDidDisconnect callback to call startWithReadyHandler:.
 */
- (void)stop;


#pragma mark Manually Send RPC Requests

/**
 *  Send an RPC request and don't bother with the response or error. If you need the response or error, call sendRequest:withCompletionHandler: instead.
 *
 *  @param request The RPC request to send
 */
- (void)sendRequest:(SDLRPCRequest *)request;

/**
 *  Send an RPC request and set a completion handler that will be called with the response when the response returns.
 *
 *  @param request The RPC request to send
 *  @param handler The handler that will be called when the response returns
 */
- (void)sendRequest:(SDLRPCRequest *)request withResponseHandler:(nullable SDLResponseHandler)handler NS_SWIFT_NAME(send(request:responseHandler:));

@end

NS_ASSUME_NONNULL_END