williamr@2
|
1 |
// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
2 |
// All rights reserved.
|
williamr@2
|
3 |
// This component and the accompanying materials are made available
|
williamr@2
|
4 |
// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
|
williamr@2
|
5 |
// which accompanies this distribution, and is available
|
williamr@2
|
6 |
// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
|
williamr@2
|
7 |
//
|
williamr@2
|
8 |
// Initial Contributors:
|
williamr@2
|
9 |
// Nokia Corporation - initial contribution.
|
williamr@2
|
10 |
//
|
williamr@2
|
11 |
// Contributors:
|
williamr@2
|
12 |
//
|
williamr@2
|
13 |
// Description:
|
williamr@2
|
14 |
// Remote Control client side.
|
williamr@2
|
15 |
//
|
williamr@2
|
16 |
//
|
williamr@2
|
17 |
|
williamr@2
|
18 |
|
williamr@2
|
19 |
|
williamr@2
|
20 |
/**
|
williamr@2
|
21 |
@file
|
williamr@2
|
22 |
@internalComponent
|
williamr@2
|
23 |
*/
|
williamr@2
|
24 |
|
williamr@2
|
25 |
#ifndef REMCONCLIENT_H
|
williamr@2
|
26 |
#define REMCONCLIENT_H
|
williamr@2
|
27 |
|
williamr@2
|
28 |
#include <remcon/clienttype.h>
|
williamr@2
|
29 |
#include <remcon/messagetype.h>
|
williamr@2
|
30 |
#include <remcon/operationinformation.h>
|
williamr@2
|
31 |
|
williamr@2
|
32 |
class TRemConAddress;
|
williamr@2
|
33 |
|
williamr@2
|
34 |
/**
|
williamr@2
|
35 |
The abstract base class for RemCon session handles.
|
williamr@2
|
36 |
*/
|
williamr@2
|
37 |
class RRemCon : public RSessionBase
|
williamr@2
|
38 |
{
|
williamr@2
|
39 |
public:
|
williamr@2
|
40 |
/**
|
williamr@2
|
41 |
Connect the handle to the server.
|
williamr@2
|
42 |
Must be called before all other methods (except Version and Close).
|
williamr@2
|
43 |
@return Error.
|
williamr@2
|
44 |
*/
|
williamr@2
|
45 |
IMPORT_C TInt Connect();
|
williamr@2
|
46 |
|
williamr@2
|
47 |
/**
|
williamr@2
|
48 |
Getter for the version of the server.
|
williamr@2
|
49 |
@return Version of the server.
|
williamr@2
|
50 |
*/
|
williamr@2
|
51 |
IMPORT_C TVersion Version() const;
|
williamr@2
|
52 |
|
williamr@2
|
53 |
/**
|
williamr@2
|
54 |
Sends a message (command or response) to the remote device.
|
williamr@2
|
55 |
@param aStatus TRequestStatus for asynchronous completion.
|
williamr@2
|
56 |
@param aInterfaceUid The UID of the interface to which the message
|
williamr@2
|
57 |
belongs.
|
williamr@2
|
58 |
@param aOperationId The ID of the message. RemCon needs to know this,
|
williamr@2
|
59 |
separately from the arbitrary data, so it can (a) match up any incoming
|
williamr@2
|
60 |
response to this client (if the message is a command), and (b) match this
|
williamr@2
|
61 |
message up to the target (if this message is a response).
|
williamr@2
|
62 |
@param aNumRemotes On success only, the number of remotes the message was
|
williamr@2
|
63 |
successfully sent to (at the bearer level). If the message is a command
|
williamr@2
|
64 |
from a connection-oriented controller, then on success aNumRemotes will be
|
williamr@2
|
65 |
1. [For consistency, this pattern holds if the message is a response, even
|
williamr@2
|
66 |
though the information is redundant.] If the message is a command from a
|
williamr@2
|
67 |
connectionless controller, then aNumRemotes will be zero or more,
|
williamr@2
|
68 |
depending on what the TSP said should be done with the message and how
|
williamr@2
|
69 |
many of the TSP-nominated bearers successfully sent the message.
|
williamr@2
|
70 |
@param aData Data associated with the message.
|
williamr@2
|
71 |
*/
|
williamr@2
|
72 |
IMPORT_C void Send(TRequestStatus& aStatus,
|
williamr@2
|
73 |
TUid aInterfaceUid,
|
williamr@2
|
74 |
TUint aOperationId,
|
williamr@2
|
75 |
TUint& aNumRemotes,
|
williamr@2
|
76 |
TRemConMessageSubType aSubType,
|
williamr@2
|
77 |
const TDesC8& aData = KNullDesC8());
|
williamr@2
|
78 |
|
williamr@2
|
79 |
IMPORT_C TInt SendUnreliable( TUid aInterfaceUid,
|
williamr@2
|
80 |
TUint aOperationId,
|
williamr@2
|
81 |
TRemConMessageSubType aSubType,
|
williamr@2
|
82 |
const TDesC8& aData = KNullDesC8());
|
williamr@2
|
83 |
|
williamr@2
|
84 |
/**
|
williamr@2
|
85 |
Cancels interest in the completion of an outstanding Send operation.
|
williamr@2
|
86 |
@return KErrNone.
|
williamr@2
|
87 |
*/
|
williamr@2
|
88 |
IMPORT_C TInt SendCancel();
|
williamr@2
|
89 |
|
williamr@2
|
90 |
/**
|
williamr@2
|
91 |
Receive a message (command or response) from the remote device. Note that
|
williamr@2
|
92 |
RemCon server queues both commands and responses so that none are ever
|
williamr@2
|
93 |
thrown away just because the client didn't have a Receive outstanding when
|
williamr@2
|
94 |
they arrived.
|
williamr@2
|
95 |
@param aStatus TRequestStatus for asynchronous completion.
|
williamr@2
|
96 |
@param aInterfaceUid The UID of the interface to which the message
|
williamr@2
|
97 |
belongs.
|
williamr@2
|
98 |
@param aOperationId The ID of the message.
|
williamr@2
|
99 |
@param aData Data associated with the message.
|
williamr@2
|
100 |
*/
|
williamr@2
|
101 |
IMPORT_C void Receive(TRequestStatus& aStatus,
|
williamr@2
|
102 |
TUid& aInterfaceUid,
|
williamr@2
|
103 |
TUint& aOperationId,
|
williamr@2
|
104 |
TRemConMessageSubType& aSubType,
|
williamr@2
|
105 |
TDes8& aData);
|
williamr@2
|
106 |
|
williamr@2
|
107 |
/**
|
williamr@2
|
108 |
Cancels interest in the completion of an outstanding Receive operation.
|
williamr@2
|
109 |
@return KErrNone.
|
williamr@2
|
110 |
*/
|
williamr@2
|
111 |
IMPORT_C TInt ReceiveCancel();
|
williamr@2
|
112 |
|
williamr@2
|
113 |
/**
|
williamr@2
|
114 |
Getter for the current set of connections in the system (not just those
|
williamr@2
|
115 |
associated with this session). The client is responsible for cleaning up
|
williamr@2
|
116 |
the collection- the addresses are on the client's heap.
|
williamr@2
|
117 |
@param aConnections A collection of remote addresses, representing all the
|
williamr@2
|
118 |
currently extant connections. Must be empty when this function is called.
|
williamr@2
|
119 |
@return Error.
|
williamr@2
|
120 |
*/
|
williamr@2
|
121 |
IMPORT_C TInt GetConnections(TSglQue<TRemConAddress>& aConnections);
|
williamr@2
|
122 |
|
williamr@2
|
123 |
/**
|
williamr@2
|
124 |
Notification for changes in the set of connections.
|
williamr@2
|
125 |
This completes whenever the set of connections changes in some way.
|
williamr@2
|
126 |
If they wish to know what specifically changed, the client must call
|
williamr@2
|
127 |
GetConnections and do their own analysis of the results from that.
|
williamr@2
|
128 |
Changes to the connection history of the system are logged internally so
|
williamr@2
|
129 |
that the client will not 'miss' any changes by not reposting the
|
williamr@2
|
130 |
notification quickly enough. However, if more than one bearer-level
|
williamr@2
|
131 |
connection change occurs in the server before the notification is reposted
|
williamr@2
|
132 |
by the client, then the following notification completion may 'cover' more
|
williamr@2
|
133 |
than one actual state change.
|
williamr@2
|
134 |
@param aStatus TRequestStatus for asynchronous completion.
|
williamr@2
|
135 |
*/
|
williamr@2
|
136 |
IMPORT_C void NotifyConnectionsChange(TRequestStatus& aStatus);
|
williamr@2
|
137 |
|
williamr@2
|
138 |
/**
|
williamr@2
|
139 |
Cancels interest in the completion of an outstanding
|
williamr@2
|
140 |
NotifyConnectionsChange operation.
|
williamr@2
|
141 |
@return KErrNone.
|
williamr@2
|
142 |
*/
|
williamr@2
|
143 |
IMPORT_C TInt NotifyConnectionsChangeCancel();
|
williamr@2
|
144 |
|
williamr@2
|
145 |
/**
|
williamr@2
|
146 |
Marks the start of heap cell checking in the server's heap. In release
|
williamr@2
|
147 |
builds, just returns KErrNone.
|
williamr@2
|
148 |
@return Error.
|
williamr@2
|
149 |
*/
|
williamr@2
|
150 |
IMPORT_C TInt __DbgMarkHeap();
|
williamr@2
|
151 |
|
williamr@2
|
152 |
/**
|
williamr@2
|
153 |
Checks that the number of allocated cells on the server's heap is correct.
|
williamr@2
|
154 |
The server is panicked if not. In release builds, just returns KErrNone.
|
williamr@2
|
155 |
@param aCount The expected number of allocated heap cells.
|
williamr@2
|
156 |
@return Error.
|
williamr@2
|
157 |
*/
|
williamr@2
|
158 |
IMPORT_C TInt __DbgCheckHeap(TInt aCount);
|
williamr@2
|
159 |
|
williamr@2
|
160 |
/**
|
williamr@2
|
161 |
Marks the end of heap cell checking. Checks that the number of heap cells
|
williamr@2
|
162 |
allocated since the last __DbgMarkHeap() is aCount; the most common value
|
williamr@2
|
163 |
to pass here is zero. In release builds, just returns KErrNone.
|
williamr@2
|
164 |
@param aCount The expected number of allocated heap cells.
|
williamr@2
|
165 |
@return Error.
|
williamr@2
|
166 |
*/
|
williamr@2
|
167 |
IMPORT_C TInt __DbgMarkEnd(TInt aCount);
|
williamr@2
|
168 |
|
williamr@2
|
169 |
/**
|
williamr@2
|
170 |
Simulates memory allocation failure in the server. In release builds, just
|
williamr@2
|
171 |
returns KErrNone.
|
williamr@2
|
172 |
@param aCount The number of allocations after which memory allocation
|
williamr@2
|
173 |
should fail.
|
williamr@2
|
174 |
@return Error.
|
williamr@2
|
175 |
*/
|
williamr@2
|
176 |
IMPORT_C TInt __DbgFailNext(TInt aCount);
|
williamr@2
|
177 |
|
williamr@2
|
178 |
protected:
|
williamr@2
|
179 |
/**
|
williamr@2
|
180 |
Constructor.
|
williamr@2
|
181 |
@param aType The type of the session.
|
williamr@2
|
182 |
*/
|
williamr@2
|
183 |
RRemCon(TRemConClientType aType);
|
williamr@2
|
184 |
|
williamr@2
|
185 |
/** Destructor. */
|
williamr@2
|
186 |
~RRemCon();
|
williamr@2
|
187 |
|
williamr@2
|
188 |
private: // utility
|
williamr@2
|
189 |
TInt DoConnect();
|
williamr@2
|
190 |
TInt SetClientType();
|
williamr@2
|
191 |
|
williamr@2
|
192 |
private: // owned
|
williamr@2
|
193 |
const TRemConClientType iClientType;
|
williamr@2
|
194 |
|
williamr@2
|
195 |
/**
|
williamr@2
|
196 |
Used by Send.
|
williamr@2
|
197 |
*/
|
williamr@2
|
198 |
TPckg<TUint> iNumRemotesPckg;
|
williamr@2
|
199 |
TPckgBuf<TOperationInformation> iOpInfoPckg;
|
williamr@2
|
200 |
|
williamr@2
|
201 |
/**
|
williamr@2
|
202 |
Used by Receive.
|
williamr@2
|
203 |
*/
|
williamr@2
|
204 |
TPckg<TUint> iUidPckg;
|
williamr@2
|
205 |
TPckg<TUint> iOpIdPckg;
|
williamr@2
|
206 |
TPckg<TRemConMessageSubType> iMsgSubTypePckg;
|
williamr@2
|
207 |
};
|
williamr@2
|
208 |
|
williamr@2
|
209 |
/**
|
williamr@2
|
210 |
The concrete session class for RemCon controllers.
|
williamr@2
|
211 |
Controller sessions are connectionless when opened. This means that addressing
|
williamr@2
|
212 |
of commands is done by the Target Selector Plugin (TSP). A controller may
|
williamr@2
|
213 |
alternatively be connection-oriented, which means that addressing of commands
|
williamr@2
|
214 |
is done using a member of the server-side session which specifies a connection
|
williamr@2
|
215 |
to a remote device. [NB Just because a session 'points to' a connection in
|
williamr@2
|
216 |
this way does not means that the connection necessarily exists at the bearer
|
williamr@2
|
217 |
level or at any other level.]
|
williamr@2
|
218 |
To make a controller session connection-oriented, call GoConnectionOriented.
|
williamr@2
|
219 |
On success, the session's remote address member will have been set to the
|
williamr@2
|
220 |
requested remote address.
|
williamr@2
|
221 |
To make a session connectionless again, use GoConnectionless. On success, the
|
williamr@2
|
222 |
remote address member will be null, indicating that the TSP will be used to
|
williamr@2
|
223 |
address our commands.
|
williamr@2
|
224 |
To control bearer-level connections, use ConnectBearer and DisconnectBearer.
|
williamr@2
|
225 |
Note that real connections may, depending on the bearer, be torn down by the
|
williamr@2
|
226 |
remote end outside of our control. Use GetConnections (and the associated
|
williamr@2
|
227 |
notification) to get information about the current state of the real
|
williamr@2
|
228 |
connections. Note however that the client is not _required_ to be interested
|
williamr@2
|
229 |
in this level of control as RemCon is responsible for making sure the required
|
williamr@2
|
230 |
connection exists at the bearer level before sending the message. The level of
|
williamr@2
|
231 |
control mentioned is provided to the client so that it can, for instance,
|
williamr@2
|
232 |
ensure adequate responsiveness of the first command sent.
|
williamr@2
|
233 |
ConnectBearerCancel and DisconnectBearerCancel merely cancel interest in the
|
williamr@2
|
234 |
corresponding request. They do not change the state of the system, bearers,
|
williamr@2
|
235 |
connections, or member data in any other way. They operate as pure Symbian OS
|
williamr@2
|
236 |
asynchronous cancel methods.
|
williamr@2
|
237 |
*/
|
williamr@2
|
238 |
class RRemConController : public RRemCon
|
williamr@2
|
239 |
{
|
williamr@2
|
240 |
public:
|
williamr@2
|
241 |
/** Constructor */
|
williamr@2
|
242 |
IMPORT_C RRemConController();
|
williamr@2
|
243 |
|
williamr@2
|
244 |
/** Destructor */
|
williamr@2
|
245 |
IMPORT_C ~RRemConController();
|
williamr@2
|
246 |
|
williamr@2
|
247 |
/**
|
williamr@2
|
248 |
Makes the session connection-oriented. On success, the given connection
|
williamr@2
|
249 |
data will be used for sending commands.
|
williamr@2
|
250 |
@param aBearerUid The UID of the bearer to use.
|
williamr@2
|
251 |
@param aData Optional bearer-specific connection data.
|
williamr@2
|
252 |
@return Error.
|
williamr@2
|
253 |
*/
|
williamr@2
|
254 |
IMPORT_C TInt GoConnectionOriented(const TRemConAddress& aConnection);
|
williamr@2
|
255 |
|
williamr@2
|
256 |
/**
|
williamr@2
|
257 |
Makes the session connectionless. On success, the TSP will be used for
|
williamr@2
|
258 |
sending commands.
|
williamr@2
|
259 |
@return Error.
|
williamr@2
|
260 |
*/
|
williamr@2
|
261 |
IMPORT_C TInt GoConnectionless();
|
williamr@2
|
262 |
|
williamr@2
|
263 |
/**
|
williamr@2
|
264 |
Establish a bearer-level connection using the information supplied in
|
williamr@2
|
265 |
GoConnectionOriented.
|
williamr@2
|
266 |
@param aStatus Used by the server to indicate completion of the request.
|
williamr@2
|
267 |
*/
|
williamr@2
|
268 |
IMPORT_C void ConnectBearer(TRequestStatus& aStatus);
|
williamr@2
|
269 |
|
williamr@2
|
270 |
/**
|
williamr@2
|
271 |
Cancels interest in the completion of an outstanding ConnectBearer
|
williamr@2
|
272 |
request. Does not affect the state of the bearer-level connection.
|
williamr@2
|
273 |
@return KErrNone.
|
williamr@2
|
274 |
*/
|
williamr@2
|
275 |
IMPORT_C TInt ConnectBearerCancel();
|
williamr@2
|
276 |
|
williamr@2
|
277 |
/**
|
williamr@2
|
278 |
Triggers bearer-level disconnection of the connection specified in
|
williamr@2
|
279 |
GoConnectionOriented.
|
williamr@2
|
280 |
@param aStatus Used by the server to indicate completion of the request.
|
williamr@2
|
281 |
*/
|
williamr@2
|
282 |
IMPORT_C void DisconnectBearer(TRequestStatus& aStatus);
|
williamr@2
|
283 |
|
williamr@2
|
284 |
/**
|
williamr@2
|
285 |
Cancels interest in the completion of an outstanding DisconnectBearer
|
williamr@2
|
286 |
request. Does not affect the state of the bearer-level connection.
|
williamr@2
|
287 |
@return KErrNone.
|
williamr@2
|
288 |
*/
|
williamr@2
|
289 |
IMPORT_C TInt DisconnectBearerCancel();
|
williamr@2
|
290 |
};
|
williamr@2
|
291 |
|
williamr@2
|
292 |
/**
|
williamr@2
|
293 |
The concrete session class for RemCon targets.
|
williamr@2
|
294 |
*/
|
williamr@2
|
295 |
class RRemConTarget : public RRemCon
|
williamr@2
|
296 |
{
|
williamr@2
|
297 |
public:
|
williamr@2
|
298 |
/** Constructor */
|
williamr@2
|
299 |
IMPORT_C RRemConTarget();
|
williamr@2
|
300 |
|
williamr@2
|
301 |
/** Destructor */
|
williamr@2
|
302 |
IMPORT_C ~RRemConTarget();
|
williamr@2
|
303 |
|
williamr@2
|
304 |
/**
|
williamr@2
|
305 |
Tells the server in which APIs the client is interested. The server
|
williamr@2
|
306 |
will only deliver incoming commands of these APIs to the client.
|
williamr@2
|
307 |
@param aNumAPIs The number of APIs to be registered
|
williamr@2
|
308 |
@param aAPIs The concatenation of all the API UIDs.
|
williamr@2
|
309 |
@return The error code returned from the server.
|
williamr@2
|
310 |
*/
|
williamr@2
|
311 |
IMPORT_C TInt RegisterInterestedAPIs(TInt aNumAPIs, const TDesC8& aAPIs);
|
williamr@2
|
312 |
};
|
williamr@2
|
313 |
|
williamr@2
|
314 |
#endif // REMCONCLIENT_H
|