epoc32/include/remconinterfaceselector.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
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
//
williamr@2
    15
williamr@2
    16
williamr@2
    17
williamr@2
    18
/**
williamr@2
    19
 @file
williamr@2
    20
 @publishedAll
williamr@2
    21
 @released
williamr@2
    22
*/
williamr@2
    23
williamr@2
    24
#ifndef REMCONINTERFACESELECTOR_H
williamr@2
    25
#define REMCONINTERFACESELECTOR_H
williamr@2
    26
williamr@2
    27
#include <e32base.h>
williamr@2
    28
#include <remcon/messagetype.h>
williamr@2
    29
#include <remcon/clienttype.h>
williamr@2
    30
#include <remcon/remconclient.h>
williamr@2
    31
#include <remcon/remconinterfaceif.h>
williamr@2
    32
#include <remconaddress.h>
williamr@2
    33
williamr@2
    34
class CRemConInterfaceBase;
williamr@2
    35
class CReceiver;
williamr@2
    36
class MRemConErrorObserver;
williamr@2
    37
williamr@2
    38
// Panic information
williamr@2
    39
_LIT(KRemConIfSelPanicCat, "RemConIfSel");
williamr@2
    40
enum 
williamr@2
    41
	{
williamr@2
    42
	/** The client has given a bad message type. */
williamr@2
    43
	ERemConIfSelBadMessageType = 0,
williamr@2
    44
williamr@2
    45
	/** The client has already called OpenTargetL successfully.
williamr@2
    46
		
williamr@2
    47
	This is no longer an illegal condition and so the panic will never
williamr@2
    48
	be raised.
williamr@2
    49
	*/
williamr@2
    50
	ERemConIfSelTargetSessionAlreadyExists = 1,
williamr@2
    51
williamr@2
    52
	/** The client has already called OpenControllerL successfully.
williamr@2
    53
		
williamr@2
    54
	This is no longer an illegal condition and so the panic will never
williamr@2
    55
	be raised.
williamr@2
    56
	*/
williamr@2
    57
	ERemConIfSelControllerSessionAlreadyExists = 2,
williamr@2
    58
williamr@2
    59
	/** The client has created (and registered) an outer layer interface of a 
williamr@2
    60
	type which is already registered. */
williamr@2
    61
	ERemConIfSelInterfaceOfThatTypeAlreadyRegistered = 3,
williamr@2
    62
	
williamr@2
    63
	/** The client has not offended- there is a defect in some layer of the 
williamr@2
    64
	Remote Control system. */
williamr@2
    65
	ERemConIfSelInternalError = 4,
williamr@2
    66
williamr@2
    67
	/** An outer-layer interface has been instantiated (and registered with 
williamr@2
    68
	the intermediate layer) after OpenControllerL or OpenTargetL has been 
williamr@2
    69
	successfully called. */
williamr@2
    70
	ERemConIfSelTardyInterfaceRegistration = 5,
williamr@2
    71
williamr@2
    72
	/** OpenControllerL has not successfully been called before using an API 
williamr@2
    73
	which expects a controller session to have been created. */
williamr@2
    74
	ERemConIfSelNoControllerSession = 6,
williamr@2
    75
williamr@2
    76
	/** OpenTargetL has not successfully been called before using an API which 
williamr@2
    77
	expects a target session to have been created. */
williamr@2
    78
	ERemConIfSelNoTargetSession = 7,
williamr@2
    79
williamr@2
    80
	/** Neither OpenControllerL not OpenTargetL has been successfully called 
williamr@2
    81
	before using an API which expects either a controller or a target session 
williamr@2
    82
	to have been created. */
williamr@2
    83
	ERemConIfSelNoSession = 8,
williamr@2
    84
williamr@2
    85
	/** An outer layer DLL has instantiated CRemConInterfaceBase with an 
williamr@2
    86
	illegal client type. */
williamr@2
    87
	ERemConIfSelUndefinedClientType = 9,
williamr@2
    88
williamr@2
    89
	/** An implementation of CRemConInterfaceBase::GetInterface does not 
williamr@2
    90
	provide an implementation of MRemConInterfaceIf. */
williamr@2
    91
	ERemConIfSelNoInterfaceImplementation = 10,
williamr@2
    92
	};
williamr@2
    93
williamr@2
    94
/**
williamr@2
    95
CRemConInterfaceSelector is only instantiable via its NewL function. It is not 
williamr@2
    96
derivable.
williamr@2
    97
*/
williamr@2
    98
NONSHARABLE_CLASS(CRemConInterfaceSelector) : public CBase
williamr@2
    99
	{
williamr@2
   100
public: 
williamr@2
   101
	/**
williamr@2
   102
	Factory method.
williamr@2
   103
	@return Ownership of a new CRemConInterfaceSelector.
williamr@2
   104
	*/
williamr@2
   105
	IMPORT_C static CRemConInterfaceSelector* NewL();
williamr@2
   106
williamr@2
   107
	/** Destructor. */
williamr@2
   108
	IMPORT_C ~CRemConInterfaceSelector();
williamr@2
   109
williamr@2
   110
public:
williamr@2
   111
	/**
williamr@2
   112
	Register the interface with the selector. This is called by the 
williamr@2
   113
	interface's BaseConstructL. Takes ownership of aInterface.
williamr@2
   114
	 This function is not to be called outside of remconinterfacebase.dll. It is available for compatibility with previous
williamr@2
   115
	 versions, but it is intended to be called only by CRemConInterfaceBase::BaseConstructL.
williamr@2
   116
	 CRemConInterfaceBase-derived classes should indirectly perform a RegisterInterfaceL, by calling
williamr@2
   117
	 CRemConInterfaceBase::BaseConstructL from their construction functions.
williamr@2
   118
	@param aInterface The interface.
williamr@2
   119
	*/
williamr@2
   120
	IMPORT_C void RegisterInterfaceL(CRemConInterfaceBase& aInterface);
williamr@2
   121
	
williamr@2
   122
	/** 
williamr@2
   123
	Register an error observer.  This is provided to allow the client to
williamr@2
   124
	discover when an error has occurred passively.
williamr@2
   125
	
williamr@2
   126
	@param aObserver An error observer to be notified on a passive error.
williamr@2
   127
					 NULL to stop receiving notifications.
williamr@2
   128
	*/
williamr@2
   129
	IMPORT_C void RegisterErrorObserver(MRemConErrorObserver* aObserver);
williamr@2
   130
williamr@2
   131
	/**
williamr@2
   132
	Opens a controller session to RemCon. The session is connectionless until 
williamr@2
   133
	such time as GoConnectionOriented may be called.
williamr@2
   134
	@leave KErrInUse If a controller session is already open.
williamr@2
   135
	*/
williamr@2
   136
	IMPORT_C void OpenControllerL();
williamr@2
   137
williamr@2
   138
	/**
williamr@2
   139
	Makes the controller session (which must already exist- use 
williamr@2
   140
	OpenControllerL) connection-oriented.
williamr@2
   141
	@param aConnection The remote to talk to. 
williamr@2
   142
	*/
williamr@2
   143
	IMPORT_C void GoConnectionOrientedL(const TRemConAddress& aConnection);
williamr@2
   144
williamr@2
   145
	/**
williamr@2
   146
	Makes the controller session (which must already exist- use 
williamr@2
   147
	OpenControllerL) connectionless.
williamr@2
   148
	*/
williamr@2
   149
	IMPORT_C void GoConnectionlessL();
williamr@2
   150
williamr@2
   151
	/**
williamr@2
   152
	Brings up a bearer-level connection.
williamr@2
   153
	The controller session must already exist (use OpenControllerL) and 
williamr@2
   154
	be connection-oriented.
williamr@2
   155
	@param aStatus TRequestStatus for asynchronous completion.
williamr@2
   156
	*/
williamr@2
   157
	IMPORT_C void ConnectBearer(TRequestStatus& aStatus);
williamr@2
   158
williamr@2
   159
	/**
williamr@2
   160
	Cancels interest in the completion of a ConnectBearer request.
williamr@2
   161
	@return KErrNone.
williamr@2
   162
	*/
williamr@2
   163
	IMPORT_C TInt ConnectBearerCancel();
williamr@2
   164
williamr@2
   165
	/**
williamr@2
   166
	Destroys a bearer-level connection. 
williamr@2
   167
	The controller session must already exist (use OpenControllerL) and be 
williamr@2
   168
	connection-oriented.
williamr@2
   169
	@param aStatus TRequestStatus for asynchronous completion.
williamr@2
   170
	*/
williamr@2
   171
	IMPORT_C void DisconnectBearer(TRequestStatus& aStat);
williamr@2
   172
williamr@2
   173
	/**
williamr@2
   174
	Cancels interest in the completion of a DisconnectBearer request.
williamr@2
   175
	@return KErrNone.
williamr@2
   176
	*/
williamr@2
   177
	IMPORT_C TInt DisconnectBearerCancel();
williamr@2
   178
williamr@2
   179
	/**
williamr@2
   180
	Opens a target session to RemCon.
williamr@2
   181
	@leave KErrInUse If a target session is already open.
williamr@2
   182
	*/
williamr@2
   183
	IMPORT_C void OpenTargetL();
williamr@2
   184
williamr@2
   185
	/**
williamr@2
   186
	Sends a message to the remote device(s).
williamr@2
   187
	There should be only one command and response outstanding at any one time.
williamr@2
   188
	Send cannot be called again until aStatus is completed.
williamr@2
   189
	@panic RemConClient 4 If a send is already outstanding
williamr@2
   190
	@param aStatus TRequestStatus for asynchronous completion.
williamr@2
   191
	@param aInterfaceUid The UID of the concrete (outer-layer) interface 
williamr@2
   192
	sending the message.
williamr@2
   193
	@param aOperationId The interface-specific operation identifier.
williamr@2
   194
	@param aNumRemotes On success, the number of remotes the message was 
williamr@2
   195
	successfully sent to.
williamr@2
   196
	@param aMsgType Whether the message is a command or a response.
williamr@2
   197
	@param aData Any associated message data in interface-specific format.
williamr@2
   198
	*/
williamr@2
   199
	IMPORT_C void Send(TRequestStatus& aStatus, 
williamr@2
   200
		TUid aInterfaceUid,
williamr@2
   201
		TUint aOperationId, 
williamr@2
   202
		TUint& aNumRemotes,
williamr@2
   203
		TRemConMessageType aMsgType,
williamr@2
   204
		const TDesC8& aData = KNullDesC8());
williamr@2
   205
williamr@2
   206
	/**
williamr@2
   207
	Sends a message to the remote device(s).
williamr@2
   208
	@param aStatus TRequestStatus for asynchronous completion.
williamr@2
   209
	@param aInterfaceUid The UID of the concrete (outer-layer) interface 
williamr@2
   210
	sending the message.
williamr@2
   211
	@param aOperationId The interface-specific operation identifier.
williamr@2
   212
	@param aNumRemotes On success, the number of remotes the message was 
williamr@2
   213
	successfully sent to.
williamr@2
   214
	@param aMsgType Whether the message is a command or a response.
williamr@2
   215
	@param aMsgSubType The subtype of the command of response
williamr@2
   216
	@param aData Any associated message data in interface-specific format.
williamr@2
   217
	*/
williamr@2
   218
	IMPORT_C void Send(TRequestStatus& aStatus, 
williamr@2
   219
		TUid aInterfaceUid,
williamr@2
   220
		TUint aOperationId, 
williamr@2
   221
		TUint& aNumRemotes,
williamr@2
   222
		TRemConMessageType aMsgType,
williamr@2
   223
		TRemConMessageSubType aMsgSubType,
williamr@2
   224
		const TDesC8& aData = KNullDesC8());
williamr@2
   225
williamr@2
   226
	
williamr@2
   227
	/**
williamr@2
   228
	@internalTechnology
williamr@2
   229
	Sends a message to the remote device(s), without waiting for the send to complete
williamr@2
   230
	@param aInterfaceUid The UID of the concrete (outer-layer) interface 
williamr@2
   231
	sending the message.
williamr@2
   232
	@param aOperationId The interface-specific operation identifier.
williamr@2
   233
	@param aMsgType Whether the message is a command or a response.
williamr@2
   234
	@param aData Any associated message data in interface-specific format.
williamr@2
   235
	*/
williamr@2
   236
	IMPORT_C TInt SendUnreliable(
williamr@2
   237
		TUid aInterfaceUid,
williamr@2
   238
		TUint aOperationId, 
williamr@2
   239
		TRemConMessageType aMsgType,
williamr@2
   240
		const TDesC8& aData = KNullDesC8());
williamr@2
   241
	
williamr@2
   242
	/**
williamr@2
   243
	@internalTechnology
williamr@2
   244
	Sends a message to the remote device(s), without waiting for the send to complete
williamr@2
   245
	@param aInterfaceUid The UID of the concrete (outer-layer) interface 
williamr@2
   246
	sending the message.
williamr@2
   247
	@param aOperationId The interface-specific operation identifier.
williamr@2
   248
	@param aMsgType Whether the message is a command or a response.
williamr@2
   249
	@param aMsgSubType The subtype of the command of response
williamr@2
   250
	@param aData Any associated message data in interface-specific format.
williamr@2
   251
	*/
williamr@2
   252
	IMPORT_C TInt SendUnreliable(
williamr@2
   253
		TUid aInterfaceUid,
williamr@2
   254
		TUint aOperationId, 
williamr@2
   255
		TRemConMessageType aMsgType,
williamr@2
   256
		TRemConMessageSubType aMsgSubType,
williamr@2
   257
		const TDesC8& aData = KNullDesC8());
williamr@2
   258
	
williamr@2
   259
	/**
williamr@2
   260
	Cancels interest in the completion of a Send request.
williamr@2
   261
	@param aMsgType The type of the message, the completion of the send of 
williamr@2
   262
	which we are not interested in. This is needed because a single 
williamr@2
   263
	CRemConInterfaceSelector may have two sends outstanding at once, one on 
williamr@2
   264
	a controller session and another on a target session.
williamr@2
   265
	@return KErrNone.
williamr@2
   266
	*/
williamr@2
   267
	IMPORT_C TInt SendCancel(TRemConMessageType aMsgType);
williamr@2
   268
williamr@2
   269
	/**
williamr@2
   270
	Only called internally, by the Active Object which sucks messages out of 
williamr@2
   271
	RemCon. Note that the message type is not given- it is interpolated from 
williamr@2
   272
	the type of the session doing the receiving.
williamr@2
   273
	@param aInterfaceUid Interface UID of the new message.
williamr@2
   274
	@param aOperationId Operation ID of the new message.
williamr@2
   275
	@param aData Data associated with the new message.
williamr@2
   276
	@param aType The type of session which received the message (from which 
williamr@2
   277
	the type of the message can be interpolated).
williamr@2
   278
	*/
williamr@2
   279
	void ReceiveComplete(TUid aInterfaceUid, 
williamr@2
   280
		TUint aOperationId, 
williamr@2
   281
		TRemConMessageSubType aMsgSubType,
williamr@2
   282
		const TDesC8& aData,
williamr@2
   283
		TRemConClientType aType);
williamr@2
   284
williamr@2
   285
	/**
williamr@2
   286
	Only called internally, by the Active Object which sucks messages out of 
williamr@2
   287
	RemCon.  This is called in the case of a session error.
williamr@2
   288
	
williamr@2
   289
	@param The error that has occurred.  If this is KErrServerTerminated, the
williamr@2
   290
		   error is fatal and the session must be restarted before any new 
williamr@2
   291
		   messages can be received.
williamr@2
   292
	*/
williamr@2
   293
	void Error(TInt aError);
williamr@2
   294
williamr@2
   295
	/**
williamr@2
   296
	Getter for the current set of connections in the system (not just those 
williamr@2
   297
	associated with this session). The client is responsible for cleaning up 
williamr@2
   298
	aConnections- the addresses will be on the heap.
williamr@2
   299
	@param aConnections A collection of remote addresses, representing all the 
williamr@2
   300
	currently extant connections.
williamr@2
   301
	@return Error.
williamr@2
   302
	*/
williamr@2
   303
	IMPORT_C TInt GetConnections(TSglQue<TRemConAddress>& aConnections);
williamr@2
   304
williamr@2
   305
	/**
williamr@2
   306
	Notification for changes in the set of connections.
williamr@2
   307
	@param aStatus TRequestStatus for asynchronous completion.
williamr@2
   308
	*/
williamr@2
   309
	IMPORT_C void NotifyConnectionsChange(TRequestStatus& aStatus);
williamr@2
   310
williamr@2
   311
	/**
williamr@2
   312
	Cancels interest in the completion of an outstanding 
williamr@2
   313
	NotifyConnectionsChange operation.
williamr@2
   314
	@return KErrNone.
williamr@2
   315
	*/
williamr@2
   316
	IMPORT_C TInt NotifyConnectionsChangeCancel();
williamr@2
   317
	
williamr@2
   318
	/**
williamr@2
   319
	To determine if a target session has been opened.
williamr@2
   320
	@return EFalse if no session has been opened, ETrue otherwise.
williamr@2
   321
	*/
williamr@2
   322
	IMPORT_C TBool TargetOpened() const;
williamr@2
   323
williamr@2
   324
	/**
williamr@2
   325
	To determine if a controller session has been opened.
williamr@2
   326
	@return EFalse if no session has been opened, ETrue otherwise.
williamr@2
   327
	*/	
williamr@2
   328
	IMPORT_C TBool ControllerOpened() const;
williamr@2
   329
williamr@2
   330
private:
williamr@2
   331
	CRemConInterfaceSelector();
williamr@2
   332
williamr@2
   333
private: // utility
williamr@2
   334
	void AssertSession(RRemCon* aSess, TInt aPanicCode) const;
williamr@2
   335
	TInt TryToReconnect();
williamr@2
   336
williamr@2
   337
private: // owned
williamr@2
   338
	RPointerArray<CRemConInterfaceBase> iInterfaces;
williamr@2
   339
williamr@2
   340
	RRemConController iControllerSession;
williamr@2
   341
	RRemConTarget iTargetSession;
williamr@2
   342
williamr@2
   343
	CReceiver* iTargetReceiver;
williamr@2
   344
	CReceiver* iControllerReceiver;
williamr@2
   345
williamr@2
   346
	/** For all registered interfaces, this is the size of the biggest 
williamr@2
   347
	operation-associated data lump. */
williamr@2
   348
	TUint iMaxDataLength;
williamr@2
   349
williamr@2
   350
	// The session to use for NotifyConnectionsChange and 
williamr@2
   351
	// NotifyConnectionsChangeCancel. It doesn't matter which we use- just one 
williamr@2
   352
	// that's connected will do. The only interesting bit is that the session 
williamr@2
   353
	// we called NotifyConnectionsChange on should be the one we call 
williamr@2
   354
	// NotifyConnectionsChangeCancel on, but as sessions are only closed when 
williamr@2
   355
	// 'this' comes down that's not a complication.
williamr@2
   356
	RRemCon* iNotificationSession;
williamr@2
   357
	
williamr@2
   358
	TRemConAddress iAddress;
williamr@2
   359
williamr@2
   360
private: // unowned	
williamr@2
   361
	MRemConErrorObserver* iErrorObserver;
williamr@2
   362
	};
williamr@2
   363
williamr@2
   364
#endif // REMCONINTERFACESELECTOR_H