summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLProxy.h
blob: 237823baacfff511197ab097b4c2641df324612e (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
//  SDLProxy.h
//

@class SDLEncryptionLifecycleManager;
@class SDLProtocol;
@class SDLPutFile;
@class SDLRPCMessage;
@class SDLSecondaryTransportManager;
@class SDLStreamingMediaManager;
@class SDLTimer;

#import "SDLProtocolListener.h"
#import "SDLProxyListener.h"
#import "SDLSecurityType.h"
#import "SDLTransportType.h"

NS_ASSUME_NONNULL_BEGIN

@interface SDLProxy : NSObject <SDLProtocolListener, NSStreamDelegate> {
    Byte _version;
    Byte _bulkSessionID;
    BOOL _isConnected;
}

/**
 *  The protocol that handles sending and receiving messages from Core.
 */
@property (nullable, strong, nonatomic) SDLProtocol *protocol;

/**
 *  The transport type used to connect the app to Core.
 */
@property (nullable, strong, nonatomic) id<SDLTransportType> transport;

/**
 *  A set of all subscribers.
 */
@property (readonly, copy, nonatomic) NSSet<NSObject<SDLProxyListener> *> *proxyListeners;

/**
 *  Closes an open session if no start service ACK message received from Core within a given amount of time.
 */
@property (strong, nonatomic) SDLTimer *startSessionTimer;

/**
 *  The proxy version number.
 */
@property (readonly, copy, nonatomic) NSString *proxyVersion;

/**
 *  Convenience init.
 *
 *  @param transport                   The type of network connection
 *  @param delegate                    The subscriber
 *  @param secondaryTransportManager   The secondary transport manager
 *  @return                            A SDLProxy object
 */
- (id)initWithTransport:(id<SDLTransportType>)transport delegate:(id<SDLProxyListener>)delegate secondaryTransportManager:(nullable SDLSecondaryTransportManager *)secondaryTransportManager;

/**
 *  Creates a SDLProxy object with an iap (USB / Bluetooth) transport network connection.
 *
 *  @param delegate                    The subscriber
 *  @param secondaryTransportManager   The secondary transport manager
 *  @return                            A SDLProxy object
 */
+ (SDLProxy *)iapProxyWithListener:(id<SDLProxyListener>)delegate secondaryTransportManager:(nullable SDLSecondaryTransportManager *)secondaryTransportManager __deprecated_msg("Use iapProxyWithListener:secondaryTransportManager:encryptionLifecycleManager: instead");

/**
 *  Creates a SDLProxy object with a TCP (WiFi) transport network connection.
 *
 *  @param delegate                    The subscriber
 *  @param ipaddress                   The IP address of Core
 *  @param port                        The port address of Core
 *  @param secondaryTransportManager   The secondary transport manager
 *  @return                            A SDLProxy object
 */
+ (SDLProxy *)tcpProxyWithListener:(id<SDLProxyListener>)delegate tcpIPAddress:(NSString *)ipaddress tcpPort:(NSString *)port secondaryTransportManager:(nullable SDLSecondaryTransportManager *)secondaryTransportManager __deprecated_msg("Use tcpProxyWithListener:tcpIPAddress:tcpPort:secondaryTransportManager:encryptionLifecycleManager: instead");

/**
 *  Creates a SDLProxy object with an iap (USB / Bluetooth) transport network connection.
 *
 *  @param delegate                    The subscriber
 *  @param secondaryTransportManager   The secondary transport manager
 *  @param encryptionLifecycleManager  The encryption life cycle manager
 *  @return                            A SDLProxy object
 */
+ (SDLProxy *)iapProxyWithListener:(id<SDLProxyListener>)delegate secondaryTransportManager:(nullable SDLSecondaryTransportManager *)secondaryTransportManager encryptionLifecycleManager:(SDLEncryptionLifecycleManager *)encryptionLifecycleManager;

/**
 *  Creates a SDLProxy object with a TCP (WiFi) transport network connection.
 *
 *  @param delegate                    The subscriber
 *  @param ipaddress                   The IP address of Core
 *  @param port                        The port address of Core
 *  @param secondaryTransportManager   The secondary transport manager
 *  @param encryptionLifecycleManager  The encryption life cycle manager
 *  @return                            A SDLProxy object
 */
+ (SDLProxy *)tcpProxyWithListener:(id<SDLProxyListener>)delegate tcpIPAddress:(NSString *)ipaddress tcpPort:(NSString *)port secondaryTransportManager:(nullable SDLSecondaryTransportManager *)secondaryTransportManager encryptionLifecycleManager:(SDLEncryptionLifecycleManager *)encryptionLifecycleManager;

/**
 *  Adds a delegate.
 *
 *  @param delegate The delegate to add
 */
- (void)addDelegate:(NSObject<SDLProxyListener> *)delegate;

/**
 *  Removes a delegate.
 *
 *  @param delegate The delegate to remove
 */
- (void)removeDelegate:(NSObject<SDLProxyListener> *)delegate;

/**
 *  Sends a RPC to Core.
 *
 *  @param message A SDLRPCMessage object
 */
- (void)sendRPC:(SDLRPCMessage *)message;

/**
 * Parses a dictionary object and notifies the subscribed delegates of the messages sent by Core. Some messages are also intercepted and handled by the library.
 *
 *  @param dictionary The message data
 */
- (void)handleRPCDictionary:(NSDictionary<NSString *, id> *)dictionary;

/**
 *  Parses a SDLProtocolMessage object and notifies the subscribed delegates of the messages sent by Core. Some messages are also intercepted and handled by the library.
 *
 *  @param msgData The message data
 */
- (void)handleProtocolMessage:(SDLProtocolMessage *)msgData;

/**
 *  Adds the security manangers needed to send encrypted data.
 *
 *  @param securityManagerClasses  The security manager classes
 *  @param appId                   The app's id
 */
- (void)addSecurityManagers:(NSArray<Class> *)securityManagerClasses forAppId:(NSString *)appId;

/**
 *  Puts data into a file on the module. Performs a putFile for a given input stream, performed in chunks, for handling very large files.
 *
 *  @param inputStream A stream containing the data to put to the module.
 *  @param putFileRPCRequest A SDLPutFile object containing the parameters for the put(s)
 *
 *  @discussion: The proxy will read from the stream based on the max MTU size and send them in individual putFile requests. This may result in multiple responses being received, one for each request.
 *  @note: The length parameter of the putFileRPCRequest will be ignored. The proxy will substitute the number of bytes read from the stream.
 */
- (void)putFileStream:(NSInputStream *)inputStream withRequest:(SDLPutFile *)putFileRPCRequest;

@end

NS_ASSUME_NONNULL_END