25 #define REMCONINTERFACESELECTOR_H |
23 #define REMCONINTERFACESELECTOR_H |
26 |
24 |
27 #include <e32base.h> |
25 #include <e32base.h> |
28 #include <remcon/messagetype.h> |
26 #include <remcon/messagetype.h> |
29 #include <remcon/clienttype.h> |
27 #include <remcon/clienttype.h> |
30 #include <remcon/remconclient.h> |
28 #include <remcon/playertype.h> |
31 #include <remcon/remconinterfaceif.h> |
29 #include <remcon/remconinterfaceif.h> |
32 #include <remconaddress.h> |
30 #include <remconaddress.h> |
33 |
31 |
34 class CRemConInterfaceBase; |
32 class CRemConInterfaceBase; |
|
33 class CBulkReceiver; |
35 class CReceiver; |
34 class CReceiver; |
36 class MRemConErrorObserver; |
35 class MRemConErrorObserver; |
|
36 class RRemConInterfaceFeatures; |
|
37 class RSpecificThreadCallBack; |
|
38 class CRemConInterfaceDetailsArray; |
|
39 class RNestableLock; |
|
40 class RRemConController; |
|
41 class RRemConTarget; |
|
42 class RRemConBulk; |
|
43 class RRemCon; |
37 |
44 |
38 // Panic information |
45 // Panic information |
39 _LIT(KRemConIfSelPanicCat, "RemConIfSel"); |
46 _LIT(KRemConIfSelPanicCat, "RemConIfSel"); |
40 enum |
47 enum |
41 { |
48 { |
117 CRemConInterfaceBase::BaseConstructL from their construction functions. |
128 CRemConInterfaceBase::BaseConstructL from their construction functions. |
118 @param aInterface The interface. |
129 @param aInterface The interface. |
119 */ |
130 */ |
120 IMPORT_C void RegisterInterfaceL(CRemConInterfaceBase& aInterface); |
131 IMPORT_C void RegisterInterfaceL(CRemConInterfaceBase& aInterface); |
121 |
132 |
|
133 /** |
|
134 Register the interface with the selector. This is called by the |
|
135 interface's BaseConstructL. Takes ownership of aInterface. |
|
136 This function is not to be called outside of remconinterfacebase.dll. It is available for compatibility with previous |
|
137 versions, but it is intended to be called only by CRemConInterfaceBase::BaseConstructL. |
|
138 CRemConInterfaceBase-derived classes should indirectly perform a RegisterInterfaceL, by calling |
|
139 CRemConInterfaceBase::BaseConstructL from their construction functions. |
|
140 @param aInterface The interface. |
|
141 @param aRemConInterfaceFeatures The operation IDs of the interface. Ownership is retained by the caller. Any necessary |
|
142 data will be copied by the interface selector. |
|
143 */ |
|
144 void RegisterInterfaceL(CRemConInterfaceBase& aInterface, RRemConInterfaceFeatures& aRemConInterfaceFeatures); |
122 /** |
145 /** |
123 Register an error observer. This is provided to allow the client to |
146 Register an error observer. This is provided to allow the client to |
124 discover when an error has occurred passively. |
147 discover when an error has occurred passively. |
125 |
148 |
126 @param aObserver An error observer to be notified on a passive error. |
149 @param aObserver An error observer to be notified on a passive error. |
180 Opens a target session to RemCon. |
203 Opens a target session to RemCon. |
181 @leave KErrInUse If a target session is already open. |
204 @leave KErrInUse If a target session is already open. |
182 */ |
205 */ |
183 IMPORT_C void OpenTargetL(); |
206 IMPORT_C void OpenTargetL(); |
184 |
207 |
|
208 /** |
|
209 Opens a target session to RemCon. |
|
210 @param aPlayerType The type of player |
|
211 @param aPlayerSubType The sub-type of the player |
|
212 @param aPlayerName The name of the player in UTF-8. |
|
213 @leave KErrInUse If a target session is already open. |
|
214 */ |
|
215 IMPORT_C void OpenTargetL(TPlayerType aPlayerType, TPlayerSubType aPlayerSubType, const TDesC8& aPlayerName); |
185 /** |
216 /** |
186 Sends a message to the remote device(s). |
217 Sends a message to the remote device(s). |
187 There should be only one command and response outstanding at any one time. |
218 There should be only one command and response outstanding at any one time. |
188 Send cannot be called again until aStatus is completed. |
219 Send cannot be called again until aStatus is completed. |
189 @panic RemConClient 4 If a send is already outstanding |
220 @panic RemConClient 4 If a send is already outstanding |
221 TUint& aNumRemotes, |
252 TUint& aNumRemotes, |
222 TRemConMessageType aMsgType, |
253 TRemConMessageType aMsgType, |
223 TRemConMessageSubType aMsgSubType, |
254 TRemConMessageSubType aMsgSubType, |
224 const TDesC8& aData = KNullDesC8()); |
255 const TDesC8& aData = KNullDesC8()); |
225 |
256 |
226 |
257 /** |
227 /** |
258 Sends a |
228 @internalTechnology |
259 */ |
|
260 IMPORT_C void SendNotify(TRequestStatus& aStatus, |
|
261 TUid aInterfaceUid, |
|
262 TUint aOperationId, |
|
263 TRemConMessageType aMsgType, |
|
264 TRemConMessageSubType aMsgSubType, |
|
265 const TDesC8& aData = KNullDesC8()); |
|
266 |
|
267 /** |
|
268 This method is for internal sub-system use only and should be not be used otherwise. |
229 Sends a message to the remote device(s), without waiting for the send to complete |
269 Sends a message to the remote device(s), without waiting for the send to complete |
230 @param aInterfaceUid The UID of the concrete (outer-layer) interface |
270 @param aInterfaceUid The UID of the concrete (outer-layer) interface |
231 sending the message. |
271 sending the message. |
232 @param aOperationId The interface-specific operation identifier. |
272 @param aOperationId The interface-specific operation identifier. |
233 @param aMsgType Whether the message is a command or a response. |
273 @param aMsgType Whether the message is a command or a response. |
263 CRemConInterfaceSelector may have two sends outstanding at once, one on |
303 CRemConInterfaceSelector may have two sends outstanding at once, one on |
264 a controller session and another on a target session. |
304 a controller session and another on a target session. |
265 @return KErrNone. |
305 @return KErrNone. |
266 */ |
306 */ |
267 IMPORT_C TInt SendCancel(TRemConMessageType aMsgType); |
307 IMPORT_C TInt SendCancel(TRemConMessageType aMsgType); |
268 |
308 |
|
309 /** |
|
310 This method is for internal sub-system use only and should be not be used otherwise. |
|
311 Sends a message to the remote device(s) through the bulk path. |
|
312 There should be only one response outstanding at any one time. |
|
313 Send cannot be called again until aStatus is completed. |
|
314 @panic RemConClient 4 If a send is already outstanding |
|
315 @param aStatus TRequestStatus for asynchronous completion. |
|
316 @param aInterfaceUid The UID of the concrete (outer-layer) interface |
|
317 sending the message. |
|
318 @param aOperationId The interface-specific operation identifier. |
|
319 @param aData Any associated message data in interface-specific format. |
|
320 */ |
|
321 IMPORT_C void SendBulk(TRequestStatus& aStatus, |
|
322 TUid aInterfaceUid, |
|
323 TUint aOperationId, |
|
324 const TDesC8& aData = KNullDesC8()); |
|
325 |
|
326 /** |
|
327 This method is for internal sub-system use only and should be not be used otherwise. |
|
328 Sends a message to the remote device(s) through the bulk path, without |
|
329 waiting for the send to complete. |
|
330 @param aInterfaceUid The UID of the concrete (outer-layer) interface |
|
331 sending the message. |
|
332 @param aOperationId The interface-specific operation identifier. |
|
333 @param aData Any associated message data in interface-specific format. |
|
334 */ |
|
335 IMPORT_C TInt SendBulkUnreliable( |
|
336 TUid aInterfaceUid, |
|
337 TUint aOperationId, |
|
338 const TDesC8& aData = KNullDesC8()); |
|
339 |
|
340 /** |
|
341 This method is for internal sub-system use only and should be not be used otherwise. |
|
342 Cancels interest in the completion of a BulkSend request. |
|
343 @return KErrNone. |
|
344 */ |
|
345 IMPORT_C TInt SendBulkCancel(); |
|
346 |
|
347 /** |
|
348 Only called internally, by the Active Object which sucks messages out of |
|
349 RemCon. Note that the message type is not given- it is interpolated from |
|
350 the type of the session doing the receiving. |
|
351 @param aInterfaceUid Interface UID of the new message. |
|
352 @param aOperationId Operation ID of the new message. |
|
353 @param aMsgSubType The message subtype. |
|
354 @param aRemoteAddress The address of the remote which sent the message. |
|
355 @param aData Data associated with the new message. |
|
356 @param aType The type of session which received the message (from which |
|
357 the type of the message can be interpolated). |
|
358 */ |
|
359 void ReceiveComplete(TUid aInterfaceUid, |
|
360 TUint aOperationId, |
|
361 TRemConMessageSubType aMsgSubType, |
|
362 const TRemConAddress& aRemoteAddress, |
|
363 const TDesC8& aData, |
|
364 TRemConClientType aType); |
|
365 |
269 /** |
366 /** |
270 Only called internally, by the Active Object which sucks messages out of |
367 Only called internally, by the Active Object which sucks messages out of |
271 RemCon. Note that the message type is not given- it is interpolated from |
368 RemCon. Note that the message type is not given- it is interpolated from |
272 the type of the session doing the receiving. |
369 the type of the session doing the receiving. |
273 @param aInterfaceUid Interface UID of the new message. |
370 @param aInterfaceUid Interface UID of the new message. |
274 @param aOperationId Operation ID of the new message. |
371 @param aOperationId Operation ID of the new message. |
275 @param aData Data associated with the new message. |
372 @param aData Data associated with the new message. |
276 @param aType The type of session which received the message (from which |
373 */ |
277 the type of the message can be interpolated). |
374 void BulkReceiveComplete(TUid aInterfaceUid, |
278 */ |
375 TUint aOperationId, |
279 void ReceiveComplete(TUid aInterfaceUid, |
376 const TDesC8& aData); |
280 TUint aOperationId, |
|
281 TRemConMessageSubType aMsgSubType, |
|
282 const TDesC8& aData, |
|
283 TRemConClientType aType); |
|
284 |
377 |
285 /** |
378 /** |
286 Only called internally, by the Active Object which sucks messages out of |
379 Only called internally, by the Active Object which sucks messages out of |
287 RemCon. This is called in the case of a session error. |
380 RemCon. This is called in the case of a session error. |
288 |
381 |
289 @param The error that has occurred. If this is KErrServerTerminated, the |
382 @param The error that has occurred. If this is KErrServerTerminated, the |
290 error is fatal and the session must be restarted before any new |
383 error is fatal and the session must be restarted before any new |
291 messages can be received. |
384 messages can be received. |
292 */ |
385 */ |
293 void Error(TInt aError); |
386 void Error(TInt aError); |
|
387 |
|
388 /** |
|
389 Only called internally, by the Active Object which sucks messages out of |
|
390 RemCon Bulk Server. This is called in the case of a session error. |
|
391 |
|
392 @param The error that has occurred. If this is KErrServerTerminated, the |
|
393 error is fatal and the session must be restarted before any new |
|
394 messages can be received. |
|
395 */ |
|
396 void BulkError(TInt aError); |
|
397 |
|
398 /** |
|
399 Only called internally, by the Active Object which sucks messages out of |
|
400 RemCon (bulk server). |
|
401 */ |
|
402 void BulkSessionConnectL(); |
294 |
403 |
295 /** |
404 /** |
296 Getter for the current set of connections in the system (not just those |
405 Getter for the current set of connections in the system (not just those |
297 associated with this session). The client is responsible for cleaning up |
406 associated with this session). The client is responsible for cleaning up |
298 aConnections- the addresses will be on the heap. |
407 aConnections- the addresses will be on the heap. |
327 */ |
436 */ |
328 IMPORT_C TBool ControllerOpened() const; |
437 IMPORT_C TBool ControllerOpened() const; |
329 |
438 |
330 private: |
439 private: |
331 CRemConInterfaceSelector(); |
440 CRemConInterfaceSelector(); |
|
441 void ConstructL(); |
332 |
442 |
333 private: // utility |
443 private: // utility |
334 void AssertSession(RRemCon* aSess, TInt aPanicCode) const; |
444 void AssertSession(RRemCon* aSess, TInt aPanicCode) const; |
335 TInt TryToReconnect(); |
445 TInt TryToReconnect(); |
|
446 TInt TryToReconnectBulk(); |
|
447 void OpenTargetCommonL(); |
|
448 void RegisterInterfaceCommonL(CRemConInterfaceBase& aInterface, const TDesC8& aFeatures); |
|
449 void RegisterInterestedApisL(TRemConClientType aType); |
|
450 |
|
451 void EstablishBulkThreadBindingL(); |
|
452 |
|
453 static TInt StaticBulkCleanup(TAny* aSelf); |
|
454 void BulkCleanup(); |
|
455 TBool BulkOpened() const; |
336 |
456 |
337 private: // owned |
457 private: // owned |
338 RPointerArray<CRemConInterfaceBase> iInterfaces; |
458 CRemConInterfaceDetailsArray* iInterfaces; |
339 |
459 |
340 RRemConController iControllerSession; |
460 RRemConController* iControllerSession; |
341 RRemConTarget iTargetSession; |
461 RRemConTarget* iTargetSession; |
|
462 RRemConBulk* iBulkSession; |
342 |
463 |
343 CReceiver* iTargetReceiver; |
464 CReceiver* iTargetReceiver; |
344 CReceiver* iControllerReceiver; |
465 CReceiver* iControllerReceiver; |
|
466 CBulkReceiver* iBulkReceiver; |
345 |
467 |
346 /** For all registered interfaces, this is the size of the biggest |
468 /** For all registered interfaces, this is the size of the biggest |
347 operation-associated data lump. */ |
469 operation-associated data lump. */ |
348 TUint iMaxDataLength; |
470 TUint iControlMaxDataLength; |
|
471 TUint iBulkMaxDataLength; |
349 |
472 |
350 // The session to use for NotifyConnectionsChange and |
473 // The session to use for NotifyConnectionsChange and |
351 // NotifyConnectionsChangeCancel. It doesn't matter which we use- just one |
474 // NotifyConnectionsChangeCancel. It doesn't matter which we use- just one |
352 // that's connected will do. The only interesting bit is that the session |
475 // that's connected will do. The only interesting bit is that the session |
353 // we called NotifyConnectionsChange on should be the one we call |
476 // we called NotifyConnectionsChange on should be the one we call |
354 // NotifyConnectionsChangeCancel on, but as sessions are only closed when |
477 // NotifyConnectionsChangeCancel on, but as sessions are only closed when |
355 // 'this' comes down that's not a complication. |
478 // 'this' comes down that's not a complication. |
356 RRemCon* iNotificationSession; |
479 RRemCon* iNotificationSession; |
357 |
480 |
358 TRemConAddress iAddress; |
481 TRemConAddress iAddress; |
359 |
482 |
|
483 RHeap* iBulkHeap; |
|
484 RThread iBulkThread; |
|
485 RHeap* iSharedThreadHeap; |
|
486 RSpecificThreadCallBack* iBulkCleanupCall; |
|
487 RNestableLock* iLock; |
360 private: // unowned |
488 private: // unowned |
361 MRemConErrorObserver* iErrorObserver; |
489 MRemConErrorObserver* iErrorObserver; |
362 }; |
490 }; |
363 |
491 |
364 #endif // REMCONINTERFACESELECTOR_H |
492 #endif // REMCONINTERFACESELECTOR_H |