epoc32/include/mmf/common/mmfcontrollerframework.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) 2002-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
#ifndef __MMFCONTROLLERFRAMEWORK_H__
williamr@2
    18
#define __MMFCONTROLLERFRAMEWORK_H__
williamr@2
    19
williamr@2
    20
#include <e32base.h>
williamr@2
    21
#include <e32std.h>
williamr@2
    22
#include <f32file.h>
williamr@2
    23
#include <mmf/common/mmfutilities.h>
williamr@2
    24
#include <mmf/common/mmfcontrollerframeworkbase.h>
williamr@2
    25
#include <mmf/common/mmfipc.h>
williamr@2
    26
williamr@2
    27
// fwd ref
williamr@2
    28
class CMMFControllerImplementationInformation;
williamr@2
    29
class CLogonMonitor;
williamr@2
    30
williamr@2
    31
_LIT(KMMFControllerProxyServerName, "MMFControllerProxyServer-");
williamr@2
    32
williamr@2
    33
/**
williamr@2
    34
@internalComponent
williamr@2
    35
*/
williamr@2
    36
#define KMMFControllerProxyVersion TVersion(7,1,1)
williamr@2
    37
williamr@2
    38
/**
williamr@2
    39
@internalComponent
williamr@2
    40
*/
williamr@2
    41
const TInt KMMFControllerProxyMaxHeapSize = 0x1000000;//16MB
williamr@2
    42
williamr@2
    43
/**
williamr@2
    44
@internalComponent
williamr@2
    45
*/
williamr@2
    46
const TInt KMMFControllerProxyMaxCachedMessages = 10;
williamr@2
    47
williamr@2
    48
/**
williamr@2
    49
@internalComponent
williamr@2
    50
williamr@2
    51
Signals that the message is destined for the controller proxy
williamr@2
    52
*/
williamr@2
    53
const TInt KMMFObjectHandleControllerProxy = -1;
williamr@2
    54
williamr@2
    55
/**
williamr@2
    56
@publishedAll
williamr@2
    57
@released
williamr@2
    58
williamr@2
    59
Signals that the message is destined for the controller
williamr@2
    60
*/
williamr@2
    61
const TInt KMMFObjectHandleController = -2;
williamr@2
    62
williamr@2
    63
/**
williamr@2
    64
@publishedAll
williamr@2
    65
@released
williamr@2
    66
williamr@2
    67
Null, or invalid, object handle
williamr@2
    68
*/
williamr@2
    69
const TInt KMMFObjectHandleNull = 0;
williamr@2
    70
/**
williamr@2
    71
@internalComponent
williamr@2
    72
williamr@2
    73
The first valid object handle.  The MMF Object container will
williamr@2
    74
begin iterating from here when generating object handles.
williamr@2
    75
*/
williamr@2
    76
const TInt KMMFObjectHandleFirstValid = 1;
williamr@2
    77
williamr@2
    78
/**
williamr@2
    79
@internalComponent
williamr@2
    80
*/
williamr@2
    81
const TInt KMmfControllerThreadShutdownTimeout = 20000000;	// 20 seconds
williamr@2
    82
williamr@2
    83
/**
williamr@2
    84
@internalComponent
williamr@2
    85
williamr@2
    86
The UID and messages associated with the controller proxy interface.
williamr@2
    87
*/
williamr@2
    88
const TUid KUidInterfaceMMFControllerProxy = {0x101F77E7};
williamr@2
    89
williamr@2
    90
/**
williamr@2
    91
@internalComponent
williamr@2
    92
williamr@2
    93
Struct to allow RMMFController to pass several parameters to new CControllerProxyServer threads.
williamr@2
    94
*/
williamr@2
    95
struct TControllerProxyServerParams 
williamr@2
    96
	{
williamr@2
    97
	RServer2*	iServer;
williamr@2
    98
	TBool		iUsingSharedHeap;
williamr@2
    99
	};
williamr@2
   100
	
williamr@2
   101
williamr@2
   102
/**
williamr@2
   103
@internalComponent
williamr@2
   104
*/
williamr@2
   105
enum TMMFControllerProxyMessages
williamr@2
   106
	{
williamr@2
   107
	EMMFControllerProxyLoadControllerPluginByUid,
williamr@2
   108
	EMMFControllerProxyReceiveEvents,
williamr@2
   109
	EMMFControllerProxyCancelReceiveEvents
williamr@2
   110
	};
williamr@2
   111
williamr@2
   112
williamr@2
   113
/**
williamr@2
   114
@publishedAll
williamr@2
   115
@released
williamr@2
   116
williamr@2
   117
Describes the destination of a message in the controller framework.
williamr@2
   118
williamr@2
   119
The destination is defined by a UID describing the interface and an integer object handle.
williamr@2
   120
The controller framework uses this information when it receives a message to decide where
williamr@2
   121
to send the message.
williamr@2
   122
williamr@2
   123
The controller plugin and controller proxy use the special constant handles
williamr@2
   124
KMMFObjectHandleControllerProxy and KMMFObjectHandleController for
williamr@2
   125
efficiency.
williamr@2
   126
williamr@2
   127
@since 7.0s
williamr@2
   128
*/
williamr@2
   129
class TMMFMessageDestination
williamr@2
   130
	{
williamr@2
   131
public:
williamr@2
   132
williamr@2
   133
	/**
williamr@2
   134
	Default constructor.
williamr@2
   135
	
williamr@2
   136
	Assigns a null UID to the interface, and a null handle to the handle.
williamr@2
   137
williamr@2
   138
	@since 7.0s
williamr@2
   139
	*/
williamr@2
   140
	IMPORT_C TMMFMessageDestination();
williamr@2
   141
williamr@2
   142
	/**
williamr@2
   143
	Constructor for sending messages to the controller plugin.
williamr@2
   144
williamr@2
   145
	Assigns KMMFObjectHandleController to the destination handle.
williamr@2
   146
williamr@2
   147
	@param  aInterfaceId
williamr@2
   148
	        The UID of the interface of this message destination.
williamr@2
   149
williamr@2
   150
	@since  7.0s
williamr@2
   151
	*/
williamr@2
   152
	IMPORT_C TMMFMessageDestination(TUid aInterfaceId);
williamr@2
   153
williamr@2
   154
	/**
williamr@2
   155
	Full constructor.
williamr@2
   156
	
williamr@2
   157
	@param  aInterfaceId
williamr@2
   158
	        The UID of the interface of this message destination.
williamr@2
   159
	@param  aDestinationHandle
williamr@2
   160
	        The handle of the destination object in the controller framework.
williamr@2
   161
williamr@2
   162
	@since  7.0s
williamr@2
   163
	*/
williamr@2
   164
	IMPORT_C TMMFMessageDestination(TUid aInterfaceId, TInt aDestinationHandle);
williamr@2
   165
williamr@2
   166
	/**
williamr@2
   167
	Copy constructor.
williamr@2
   168
williamr@2
   169
	@param  aOther
williamr@2
   170
	        The TMMFMessageDestination object to be copied.
williamr@2
   171
williamr@2
   172
	@since  7.0s
williamr@2
   173
	*/
williamr@2
   174
	IMPORT_C TMMFMessageDestination(const TMMFMessageDestination& aOther);
williamr@2
   175
williamr@2
   176
	/**
williamr@2
   177
	Returns the UID of the interface of the message destination.
williamr@2
   178
williamr@2
   179
	@return	The interface UID.
williamr@2
   180
williamr@2
   181
	@since 7.0s
williamr@2
   182
	*/
williamr@2
   183
	IMPORT_C TUid InterfaceId() const;
williamr@2
   184
williamr@2
   185
	/**
williamr@2
   186
	Returns the handle of the destination object in the controller framework.
williamr@2
   187
williamr@2
   188
	@return	The destination handle.
williamr@2
   189
williamr@2
   190
	@since 7.0s
williamr@2
   191
	*/
williamr@2
   192
	IMPORT_C TInt DestinationHandle() const;
williamr@2
   193
williamr@2
   194
	/**
williamr@2
   195
	Compares two destinations.
williamr@2
   196
williamr@2
   197
	@param  aOther
williamr@2
   198
	        The object to be compared with this object.
williamr@2
   199
williamr@2
   200
	@return A boolean indicating if the objects are the same. ETrue if the objects are the same, 
williamr@2
   201
	        EFalse if the objects are different.
williamr@2
   202
williamr@2
   203
	@since 7.0s
williamr@2
   204
	*/
williamr@2
   205
	IMPORT_C TBool operator==(const TMMFMessageDestination& aOther) const;
williamr@2
   206
williamr@2
   207
private:
williamr@2
   208
	TUid iInterfaceId;
williamr@2
   209
	TInt iDestinationHandle;
williamr@2
   210
	/**
williamr@2
   211
	This member is internal and not intended for use.
williamr@2
   212
	*/
williamr@2
   213
	TInt iReserved1;
williamr@2
   214
	TInt iReserved2;
williamr@2
   215
	TInt iReserved3;
williamr@2
   216
	};
williamr@2
   217
williamr@2
   218
/**
williamr@2
   219
@publishedAll
williamr@2
   220
@released
williamr@2
   221
williamr@2
   222
Package buffer for TMMFMessageDestination
williamr@2
   223
*/
williamr@2
   224
typedef TPckgBuf<TMMFMessageDestination> TMMFMessageDestinationPckg;
williamr@2
   225
williamr@2
   226
williamr@2
   227
/**
williamr@2
   228
@publishedAll
williamr@2
   229
@released
williamr@2
   230
williamr@2
   231
Encapsulation of an RMessage or an RMessage2 to provide protection to controller plugins
williamr@2
   232
from the changes occurring with secure APIs.
williamr@2
   233
williamr@2
   234
Adds required destination information to the message so the controller framework
williamr@2
   235
can determine which object the message is for.
williamr@2
   236
williamr@2
   237
Adds capability to check whether the message has been completed.
williamr@2
   238
williamr@2
   239
Allows two descriptors to be read from the client, and one descriptor to be copied to the client.
williamr@2
   240
williamr@2
   241
@see RMMFControllerProxy::SendSync
williamr@2
   242
@see RMMFControllerProxy::SendAsync
williamr@2
   243
williamr@2
   244
@since 7.0s
williamr@2
   245
*/
williamr@2
   246
class TMMFMessage
williamr@2
   247
	{
williamr@2
   248
friend class CMMFControllerProxySession;
williamr@2
   249
friend class CMMFDevSoundSession;
williamr@2
   250
public:
williamr@2
   251
williamr@2
   252
	/**
williamr@2
   253
	Copy constructor.
williamr@2
   254
	
williamr@2
   255
	A controller plugin should use this to take a copy of the message when it must wait for some
williamr@2
   256
	other event before completing it.
williamr@2
   257
williamr@2
   258
	@param  aMessage
williamr@2
   259
	        The message object to copy.
williamr@2
   260
williamr@2
   261
	@since 7.0s
williamr@2
   262
	*/
williamr@2
   263
	IMPORT_C TMMFMessage(const TMMFMessage& aMessage);
williamr@2
   264
williamr@2
   265
	/**
williamr@2
   266
	Returns the destination of the message.
williamr@2
   267
williamr@2
   268
	@return	The destination of the message, consisting of a UID defining the interface and the
williamr@2
   269
			handle of the destination object.
williamr@2
   270
williamr@2
   271
	@since	7.0s
williamr@2
   272
	*/
williamr@2
   273
	IMPORT_C const TMMFMessageDestination& Destination();
williamr@2
   274
williamr@2
   275
	/**
williamr@2
   276
	Returns an integer describing the function being called. Equivalent to 
williamr@2
   277
	RMessage::Function().
williamr@2
   278
williamr@2
   279
	@return The function being called over IPC.
williamr@2
   280
williamr@2
   281
	@see    RMessage::Function()
williamr@2
   282
williamr@2
   283
	@since  7.0s
williamr@2
   284
	*/
williamr@2
   285
	IMPORT_C TInt Function();
williamr@2
   286
williamr@2
   287
	/**
williamr@2
   288
	Returns the size of the first descriptor that can be copied over from the client.
williamr@2
   289
	
williamr@2
   290
	Use this to create a descriptor of appropriate size before reading the data from the client.
williamr@2
   291
williamr@2
   292
	@return	The size of data 1.
williamr@2
   293
	@since	7.0s
williamr@2
   294
	*/
williamr@2
   295
	IMPORT_C TInt SizeOfData1FromClient();
williamr@2
   296
williamr@2
   297
	/**
williamr@2
   298
	Copy the first descriptor from the client.
williamr@2
   299
	
williamr@2
   300
	@param  aDes
williamr@2
   301
	        A descriptor defining the area of memory into which the data from the client
williamr@2
   302
	        will be copied. Note, the descriptor must be of sufficient size.
williamr@2
   303
williamr@2
   304
	@return	One of the system-wide error codes. In particular, KErrBadDescriptor will be returned
williamr@2
   305
	        if the client did not provide a valid descriptor.
williamr@2
   306
williamr@2
   307
	@since  7.0s
williamr@2
   308
	*/
williamr@2
   309
	IMPORT_C TInt ReadData1FromClient(TDes8& aDes);
williamr@2
   310
williamr@2
   311
	/**
williamr@2
   312
	Copy the first descriptor from the client.
williamr@2
   313
williamr@2
   314
	This functino can leave with one of the system-wide error codes. In particular, the leave code 
williamr@2
   315
	KErrBadDescriptor will be used if the client did not provide a valid descriptor.
williamr@2
   316
williamr@2
   317
	@param  aDes
williamr@2
   318
	        A descriptor defining the area of memory into which the data from the client
williamr@2
   319
	        will be copied. Note, the descriptor must be of sufficient size.
williamr@2
   320
williamr@2
   321
	@since 7.0s
williamr@2
   322
	*/
williamr@2
   323
	IMPORT_C void ReadData1FromClientL(TDes8& aDes);
williamr@2
   324
williamr@2
   325
williamr@2
   326
	/**
williamr@2
   327
	Returns the size of the second descriptor that can be copied over from the client.
williamr@2
   328
	
williamr@2
   329
	Use this to create a descriptor of appropriate size before reading the data from the client.
williamr@2
   330
williamr@2
   331
	@return The size of data 2.
williamr@2
   332
williamr@2
   333
	@since  7.0s
williamr@2
   334
	*/
williamr@2
   335
	IMPORT_C TInt SizeOfData2FromClient();
williamr@2
   336
williamr@2
   337
	/**
williamr@2
   338
	Copies the second descriptor from the client.
williamr@2
   339
williamr@2
   340
	@param  aDes
williamr@2
   341
	        A descriptor defining the area of memory into which the data from the client
williamr@2
   342
	        will be copied. Note, the descriptor must be of sufficient size.
williamr@2
   343
williamr@2
   344
	@return One of the system-wide error codes. In particular, KErrBadDescriptor will be returned
williamr@2
   345
	        if the client did not provide a valid descriptor.
williamr@2
   346
williamr@2
   347
	@since  7.0s
williamr@2
   348
	*/
williamr@2
   349
	IMPORT_C TInt ReadData2FromClient(TDes8& aDes);
williamr@2
   350
williamr@2
   351
	/**
williamr@2
   352
	Copies the second descriptor from the client.
williamr@2
   353
williamr@2
   354
	This function can leave with one of the system-wide error codes. In particular, the leave code
williamr@2
   355
	KErrBadDescriptor will be used if the client did not provide a valid descriptor.
williamr@2
   356
williamr@2
   357
	@param  aDes
williamr@2
   358
	        A descriptor defining the area of memory into which the data from the client
williamr@2
   359
	        will be copied. Note, the descriptor must be of sufficient size.
williamr@2
   360
williamr@2
   361
	@since  7.0s
williamr@2
   362
	*/
williamr@2
   363
	IMPORT_C void ReadData2FromClientL(TDes8& aDes);
williamr@2
   364
williamr@2
   365
	/**
williamr@2
   366
	Copies data back to the client.
williamr@2
   367
williamr@2
   368
	@param  aDes
williamr@2
   369
	        The data to be copied back to the client.  Note that the client must
williamr@2
   370
	        have already created a descriptor of sufficient size for the data to be
williamr@2
   371
	        copied into.
williamr@2
   372
williamr@2
   373
	@return One of the system-wide error codes. In particular, the error code KErrBadDescriptor will 
williamr@2
   374
	        be returned if the client did not provide a valid descriptor.
williamr@2
   375
williamr@2
   376
	@since  7.0s
williamr@2
   377
	*/
williamr@2
   378
	IMPORT_C TInt WriteDataToClient(const TDesC8& aDes);
williamr@2
   379
williamr@2
   380
	/**
williamr@2
   381
	Copies the data back to the client.
williamr@2
   382
williamr@2
   383
	This function can leave with one of the system-wide error codes. In particular, the leave code
williamr@2
   384
	KErrBadDescriptor will be used if the client did not provide a valid descriptor.
williamr@2
   385
williamr@2
   386
	@param  aDes
williamr@2
   387
	        The data to be copied back to the client. Note that the client must have already
williamr@2
   388
	        created a descriptor of sufficient size for the data to be copied into.
williamr@2
   389
williamr@2
   390
	@since 7.0s
williamr@2
   391
	*/
williamr@2
   392
	IMPORT_C void WriteDataToClientL(const TDesC8& aDes);
williamr@2
   393
williamr@2
   394
	/**
williamr@2
   395
	Signals to the client that its request has been completed.
williamr@2
   396
williamr@2
   397
	Equivalent to RMessage::Complete.
williamr@2
   398
williamr@2
   399
	@param  aReason
williamr@2
   400
	        The result code to be given back to the client.
williamr@2
   401
williamr@2
   402
	@since  7.0s
williamr@2
   403
	*/
williamr@2
   404
	IMPORT_C void Complete(TInt aReason);
williamr@2
   405
	
williamr@2
   406
	IMPORT_C void AdoptFileHandleFromClientL(TInt aFsHandleIndex, TInt aFileHandleIndex, RFile& aFile);
williamr@2
   407
williamr@2
   408
	/**
williamr@2
   409
	Checks whether this message has already been completed.
williamr@2
   410
williamr@2
   411
	@return A boolean indicating if the message has been completed. ETrue if the message has been 
williamr@2
   412
	        completed, EFalse if not.
williamr@2
   413
williamr@2
   414
	@since  7.0s
williamr@2
   415
	*/
williamr@2
   416
	IMPORT_C TBool IsCompleted();
williamr@2
   417
williamr@2
   418
	/**
williamr@2
   419
	Constructs a TMMFMessage from an RMmfIpcMessage.
williamr@2
   420
williamr@2
   421
	@param	aMessage
williamr@2
   422
			The handle to the remote message.
williamr@2
   423
williamr@2
   424
	@since  7.0s
williamr@2
   425
	*/
williamr@2
   426
	IMPORT_C TMMFMessage(const RMmfIpcMessage& aMessage);
williamr@2
   427
williamr@2
   428
	/**
williamr@2
   429
	Gets the destination info from the client.
williamr@2
   430
williamr@2
   431
	@since  7.0s
williamr@2
   432
	*/
williamr@2
   433
	IMPORT_C void FetchDestinationL();
williamr@2
   434
private:
williamr@2
   435
#ifdef __MMF_USE_IPC_V2__
williamr@2
   436
	/**
williamr@2
   437
	The encapsulated message
williamr@2
   438
	*/
williamr@2
   439
	RMessagePtr2 iMessage;
williamr@2
   440
	/**
williamr@2
   441
	The encapsulated function
williamr@2
   442
	*/
williamr@2
   443
	TInt iFunction;
williamr@2
   444
	/**
williamr@2
   445
	Private padding to preserve BC with earlier versions
williamr@2
   446
	*/
williamr@2
   447
	TInt iDummyPadding[6];
williamr@2
   448
#else
williamr@2
   449
	/**
williamr@2
   450
	The RMessage encapsulated by this object.
williamr@2
   451
	*/
williamr@2
   452
	RMessage iMessage;
williamr@2
   453
#endif // __MMF_USE_IPC_V2__
williamr@2
   454
williamr@2
   455
	/**
williamr@2
   456
	The destination of this message.
williamr@2
   457
	*/
williamr@2
   458
	TMMFMessageDestination iDestination;
williamr@2
   459
williamr@2
   460
	/**
williamr@2
   461
	Defines whether this object has yet to be completed.
williamr@2
   462
	*/
williamr@2
   463
	TBool iAmCompleted;
williamr@2
   464
	};
williamr@2
   465
williamr@2
   466
/**
williamr@2
   467
@internalComponent
williamr@2
   468
williamr@2
   469
Mixin class used by CLogonMonitor to inform about its state
williamr@2
   470
williamr@2
   471
@since 9.3
williamr@2
   472
*/
williamr@2
   473
class MLogonMonitorObserver
williamr@2
   474
	{
williamr@2
   475
public:
williamr@2
   476
	/**
williamr@2
   477
	The monitored thread has been terminated.
williamr@2
   478
	*/
williamr@2
   479
	virtual void ThreadTerminated() = 0;
williamr@2
   480
	};
williamr@2
   481
	
williamr@2
   482
/**
williamr@2
   483
@internalComponent
williamr@2
   484
williamr@2
   485
RSessionBase-based client class to handle the creation of the controller thread and
williamr@2
   486
message sending over IPC.
williamr@2
   487
williamr@2
   488
The controller proxy is responsible for sending and recieving messages over IPC; it does not
williamr@2
   489
care exactly what those messages are.
williamr@2
   490
williamr@2
   491
Note the fact that, although this is an internal component, its size cannot be changed because 
williamr@2
   492
it's embedded in a publishedAll class (RMMFController) and the size of the latter would also be
williamr@2
   493
changed raising a binary compatibility problem.
williamr@2
   494
williamr@2
   495
@since 7.0s
williamr@2
   496
*/
williamr@2
   497
NONSHARABLE_CLASS(RMMFControllerProxy) : public RMmfSessionBase, public MLogonMonitorObserver
williamr@2
   498
	{
williamr@2
   499
public:
williamr@2
   500
williamr@2
   501
	/**
williamr@2
   502
	Constructor.
williamr@2
   503
	@since 7.0s
williamr@2
   504
	*/
williamr@2
   505
	IMPORT_C RMMFControllerProxy();
williamr@2
   506
williamr@2
   507
	/**
williamr@2
   508
	Create a new thread and load a controller plugin into that thread.
williamr@2
   509
	
williamr@2
   510
	@param  aControllerUid
williamr@2
   511
	        The UID of the controller plugin to be loaded.
williamr@2
   512
	@param	aUseSharedHeap
williamr@2
   513
			If this value is EFalse each controller is created with its own heap. The alternative,
williamr@2
   514
			if the value is ETrue, is that controllers share a special heap with other controllers
williamr@2
   515
			created the same way. Each heap uses a chunk, so this avoids situations where the
williamr@2
   516
			number of chunks per process is limited. The default behaviour is generally to be
williamr@2
   517
			preferred, and should give lower overall memory usage. However, if many controllers are
williamr@2
   518
			to be created for a particular thread, then ETrue should be provided to prevent running
williamr@2
   519
			out of heaps or chunks.
williamr@2
   520
williamr@2
   521
	@return One of the system-wide error codes.
williamr@2
   522
	@since	7.0s
williamr@2
   523
	*/
williamr@2
   524
	IMPORT_C TInt LoadController(TUid aControllerUid, TBool aUseSharedHeap);
williamr@2
   525
williamr@2
   526
	/**
williamr@2
   527
	Create a new thread and load a controller plugin into that thread.
williamr@2
   528
	
williamr@2
   529
	@param  aControllerInfo
williamr@2
   530
	        A reference to a CMMFControllerImplementationInformation object
williamr@2
   531
	        used for determining the controller UID and heap size
williamr@2
   532
	@param	aUseSharedHeap
williamr@2
   533
			If this value is EFalse each controller is created with its own heap. The alternative,
williamr@2
   534
			if the value is ETrue, is that controllers share a special heap with other controllers
williamr@2
   535
			created the same way. Each heap uses a chunk, so this avoids situations where the
williamr@2
   536
			number of chunks per process is limited. The default behaviour is generally to be
williamr@2
   537
			preferred, and should give lower overall memory usage. However, if many controllers are
williamr@2
   538
			to be created for a particular thread, then ETrue should be provided to prevent running
williamr@2
   539
			out of heaps or chunks.
williamr@2
   540
williamr@2
   541
	@return	One of the system-wide error codes.
williamr@2
   542
	@since	7.0s
williamr@2
   543
	*/
williamr@2
   544
	IMPORT_C TInt LoadController(const CMMFControllerImplementationInformation& aControllerInfo, TBool aUseSharedHeap);
williamr@2
   545
williamr@2
   546
	/**
williamr@2
   547
	Create a new thread in another process through Secure DRM Plugin server and load a controller plugin 
williamr@2
   548
	into that thread.  The motivation of this model is to allow applications without DRM capability able 
williamr@2
   549
	to play protected content through MMF.
williamr@2
   550
	
williamr@2
   551
	@param  aControllerUid
williamr@2
   552
	        The UID of the controller plugin to be loaded.
williamr@2
   553
	@param	aUseSharedHeap
williamr@2
   554
			If this value is EFalse each controller is created with its own heap. The alternative,
williamr@2
   555
			if the value is ETrue, is that controllers share a special heap with other controllers
williamr@2
   556
			created the same way. Each heap uses a chunk, so this avoids situations where the
williamr@2
   557
			number of chunks per process is limited. The default behaviour is generally to be
williamr@2
   558
			preferred, and should give lower overall memory usage. However, if many controllers are
williamr@2
   559
			to be created for a particular thread, then ETrue should be provided to prevent running
williamr@2
   560
			out of heaps or chunks.
williamr@2
   561
williamr@2
   562
	@return One of the system-wide error codes.
williamr@2
   563
	*/
williamr@2
   564
	IMPORT_C TInt LoadControllerInSecureDRMProcess(TUid aControllerUid, TBool aUseSharedHeap);
williamr@2
   565
	
williamr@2
   566
	/**
williamr@2
   567
	Create a new thread in another process through Secure DRM Plugin server and load a controller plugin 
williamr@2
   568
	into that thread.  The motivation of this model is to allow applications without DRM capability able 
williamr@2
   569
	to play protected content through MMF.
williamr@2
   570
	
williamr@2
   571
	@param  aControllerInfo
williamr@2
   572
	        A reference to a CMMFControllerImplementationInformation object
williamr@2
   573
	        used for determining the controller UID and heap size
williamr@2
   574
	@param	aUseSharedHeap
williamr@2
   575
			If this value is EFalse each controller is created with its own heap. The alternative,
williamr@2
   576
			if the value is ETrue, is that controllers share a special heap with other controllers
williamr@2
   577
			created the same way. Each heap uses a chunk, so this avoids situations where the
williamr@2
   578
			number of chunks per process is limited. The default behaviour is generally to be
williamr@2
   579
			preferred, and should give lower overall memory usage. However, if many controllers are
williamr@2
   580
			to be created for a particular thread, then ETrue should be provided to prevent running
williamr@2
   581
			out of heaps or chunks.
williamr@2
   582
williamr@2
   583
	@return	One of the system-wide error codes.
williamr@2
   584
	*/
williamr@2
   585
	IMPORT_C TInt LoadControllerInSecureDRMProcess(const CMMFControllerImplementationInformation& aControllerInfo, TBool aUseSharedHeap);
williamr@2
   586
	
williamr@2
   587
	/**
williamr@2
   588
	Delete the controller plugin and close its thread.
williamr@2
   589
	
williamr@2
   590
	Clients must call Close() on the controller proxy, otherwise leaks will occur.
williamr@2
   591
williamr@2
   592
	@since	7.0s
williamr@2
   593
	*/
williamr@2
   594
	IMPORT_C void Close();
williamr@2
   595
williamr@2
   596
	/**
williamr@2
   597
	Send a message synchronously to the controller thread.
williamr@2
   598
williamr@2
   599
	The controller framework will analyze the message to determine its correct destination.
williamr@2
   600
williamr@2
   601
	Note: This method will not return until the controller framework has serviced the command.
williamr@2
   602
williamr@2
   603
	@param  aDestination
williamr@2
   604
	        The destination of the message, consisting of the uid of
williamr@2
   605
	        the interface of this message.
williamr@2
   606
	@param  aFunction
williamr@2
   607
	        The function number to indicate which function is to be called
williamr@2
   608
	        on the interface defined in the aDestination parameter.
williamr@2
   609
	@param  aDataTo1
williamr@2
   610
	        A reference to the first chunk of data to be copied to the controller
williamr@2
   611
	        framework. The exact contents of the data are dependent on the
williamr@2
   612
	        interface being called.  Can be NULL.
williamr@2
   613
	@param  aDataTo2
williamr@2
   614
	        A reference to the second chunk of data to be copied to the controller
williamr@2
   615
	        framework. The exact contents of the data are dependent on the
williamr@2
   616
	        interface being called.  Can be NULL.
williamr@2
   617
	@param  aDataFrom
williamr@2
   618
	        A reference to an area of memory to which the controller framework will
williamr@2
   619
	        write any data to be passed back to the client.  Can't be NULL.
williamr@2
   620
williamr@2
   621
	@return The result of the request.  Exact range of values is dependent on the interface.
williamr@2
   622
	@since	7.0s
williamr@2
   623
	*/
williamr@2
   624
	IMPORT_C TInt SendSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom) const;
williamr@2
   625
williamr@2
   626
	/**
williamr@2
   627
	Send a message synchronously to the controller thread.
williamr@2
   628
williamr@2
   629
	The controller framework will analyze the message to determine its correct destination.
williamr@2
   630
williamr@2
   631
	Note: This method will not return until the controller framework has serviced the command.
williamr@2
   632
williamr@2
   633
	@param  aDestination
williamr@2
   634
	        The destination of the message, consisting of the uid of
williamr@2
   635
	        the interface of this message.
williamr@2
   636
	@param  aFunction
williamr@2
   637
	        The function number to indicate which function is to be called
williamr@2
   638
	        on the interface defined in the aDestination parameter.
williamr@2
   639
	@param  aDataTo1
williamr@2
   640
	        A reference to the first chunk of data to be copied to the controller
williamr@2
   641
	        framework. The exact contents of the data are dependent on the
williamr@2
   642
	        interface being called.  Can be NULL.
williamr@2
   643
	@param  aDataTo2
williamr@2
   644
	        A reference to the second chunk of data to be copied to the controller
williamr@2
   645
	        framework. The exact contents of the data are dependent on the
williamr@2
   646
	        interface being called.  Can be NULL.
williamr@2
   647
williamr@2
   648
	@return The result of the request.  Exact range of values is dependent on the interface.
williamr@2
   649
	@since	7.0s
williamr@2
   650
	*/
williamr@2
   651
	IMPORT_C TInt SendSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2) const;
williamr@2
   652
williamr@2
   653
	/**
williamr@2
   654
	Send a message asynchronously to the controller thread.
williamr@2
   655
	
williamr@2
   656
	The controller framework will analyze the message to determine its correct destination.
williamr@2
   657
williamr@2
   658
	Note: This method will return immediately.  The RunL of the active object owning the
williamr@2
   659
	aStatus parameter will be called when the command is completed by the
williamr@2
   660
	controller framework.
williamr@2
   661
williamr@2
   662
	@param  aDestination
williamr@2
   663
	        The destination of the message, consisting of the uid of
williamr@2
   664
	        the interface of this message.
williamr@2
   665
	@param  aFunction
williamr@2
   666
	        The function number to indicate which function is to be called
williamr@2
   667
	        on the interface defined in the aDestination parameter.
williamr@2
   668
	@param  aDataTo1
williamr@2
   669
	        A reference to the first chunk of data to be copied to the controller
williamr@2
   670
	        framework. The exact contents of the data are dependent on the
williamr@2
   671
	        interface being called.  Can be NULL.
williamr@2
   672
	@param  aDataTo2
williamr@2
   673
	        A reference to the second chunk of data to be copied to the controller
williamr@2
   674
	        framework. The exact contents of the data are dependent on the
williamr@2
   675
	        interface being called.  Can be NULL.
williamr@2
   676
	@param  aDataFrom
williamr@2
   677
	        A reference to an area of memory to which the controller framework will
williamr@2
   678
	        write any data to be passed back to the client.  Can't be NULL.
williamr@2
   679
	@param  aStatus
williamr@2
   680
	        The TRequestStatus of an active object.  This will contain the
williamr@2
   681
	        result of the request on completion.  The exact range of
williamr@2
   682
	        result values is dependent on the interface.
williamr@2
   683
williamr@2
   684
	@since	7.0s
williamr@2
   685
	*/
williamr@2
   686
	IMPORT_C void SendAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction,  const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom, TRequestStatus& aStatus) const;
williamr@2
   687
williamr@2
   688
	/**
williamr@2
   689
	Send a message asynchronously to the controller thread.
williamr@2
   690
	
williamr@2
   691
	The controller framework will analyze the message to determine its correct destination.
williamr@2
   692
	
williamr@2
   693
	Note: This method will return immediately.  The RunL of the active object owning the 
williamr@2
   694
	aStatus parameter will be called when the command is completed by the
williamr@2
   695
	controller framework.
williamr@2
   696
williamr@2
   697
	@param  aDestination
williamr@2
   698
	        The destination of the message, consisting of the uid of
williamr@2
   699
	        the interface of this message.
williamr@2
   700
	@param  aFunction
williamr@2
   701
	        The function number to indicate which function is to be called
williamr@2
   702
	        on the interface defined in the aDestination parameter.
williamr@2
   703
	@param  aDataTo1
williamr@2
   704
	        A reference to the first chunk of data to be copied to the controller
williamr@2
   705
	        framework. The exact contents of the data are dependent on the
williamr@2
   706
	        interface being called.  Can be NULL.
williamr@2
   707
	@param  aDataTo2
williamr@2
   708
	        A reference to the second chunk of data to be copied to the controller
williamr@2
   709
	        framework. The exact contents of the data are dependent on the
williamr@2
   710
	        interface being called.  Can be NULL.
williamr@2
   711
	@param  aStatus
williamr@2
   712
	        The TRequestStatus of an active object.  This will contain the
williamr@2
   713
	        result of the request on completion.  The exact range of
williamr@2
   714
	        result values is dependent on the interface.
williamr@2
   715
williamr@2
   716
	@since	7.0s
williamr@2
   717
	*/
williamr@2
   718
	IMPORT_C void SendAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction,  const TDesC8& aDataTo1, const TDesC8& aDataTo2, TRequestStatus& aStatus) const;
williamr@2
   719
williamr@2
   720
	IMPORT_C TInt SendSync(TInt aFunction, const TIpcArgs& aIpcArgs) const;
williamr@2
   721
	IMPORT_C void SendAsync(TInt aFunction, const TIpcArgs& aIpcArgs, TRequestStatus& aStatus) const;
williamr@2
   722
	/**
williamr@2
   723
	Register to receive events from the controller framework.
williamr@2
   724
	
williamr@2
   725
	Events can be generated at any time, and are generally associated with things that occur
williamr@2
   726
	due to something happening internally within the controller. For example, an event will
williamr@2
   727
	be generated if the controller stops playing due to reaching the end of a file.
williamr@2
   728
williamr@2
   729
	@param  aEvent
williamr@2
   730
	        A reference to a TMMFEventPckg object that must be member data
williamr@2
   731
	        of the active object calling this method.  The details of the event
williamr@2
   732
	        will be copied into this object when an event occurs.
williamr@2
   733
	@param  aStatus
williamr@2
   734
	        The TRequestStatus of the active object calling this method.
williamr@2
   735
williamr@2
   736
	@see	TMMFEvent
williamr@2
   737
	@see	CMMFControllerEventMonitor
williamr@2
   738
	@since	7.0s
williamr@2
   739
	*/
williamr@2
   740
	IMPORT_C void ReceiveEvents(TMMFEventPckg& aEvent, TRequestStatus& aStatus);
williamr@2
   741
williamr@2
   742
	/**
williamr@2
   743
	Cancel a previous registration to receive events from the controller framework.
williamr@2
   744
williamr@2
   745
	This must be called from the DoCancel() method of the active object using the
williamr@2
   746
	ReceiveEvents() API.
williamr@2
   747
williamr@2
   748
	@return One of the standard system-wide error codes.
williamr@2
   749
williamr@2
   750
	@see	TMMFEvent
williamr@2
   751
	@since	7.0s
williamr@2
   752
	*/
williamr@2
   753
	IMPORT_C TInt CancelReceiveEvents();
williamr@2
   754
	
williamr@2
   755
	/**
williamr@2
   756
	Set the priority of the controller's sub thread.
williamr@2
   757
	
williamr@2
   758
	This can be used to increase the responsiveness of the audio plugin to minimise
williamr@2
   759
	any lag in processing. This function should be used with care as it may have knock-on
williamr@2
   760
	effects elsewhere in the system.
williamr@2
   761
	
williamr@2
   762
	@param	aPriority
williamr@2
   763
			The TThreadPriority that the thread should run under.  The default is EPriorityNormal.
williamr@2
   764
	@return	TInt
williamr@2
   765
			A standard error code: KErrNone if successful, KErrNotReady if the thread does not have a
williamr@2
   766
			valid handle.
williamr@2
   767
	*/
williamr@2
   768
	IMPORT_C TInt SetThreadPriority(const TThreadPriority& aPriority) const;
williamr@2
   769
	
williamr@2
   770
	/**
williamr@2
   771
	The controller subthread has been terminated.
williamr@2
   772
	
williamr@2
   773
	This is called by CLogonMonitor when the the thread terminates
williamr@2
   774
	*/
williamr@2
   775
	void ThreadTerminated();
williamr@2
   776
private:
williamr@2
   777
	/**
williamr@2
   778
	Creates the new thread
williamr@2
   779
	*/
williamr@2
   780
	TInt DoCreateSubThread(RServer2* aServer2, TUint aMaxHeapSize, TBool aUseSharedHeap);
williamr@2
   781
williamr@2
   782
	/**
williamr@2
   783
	Determines the maximum heap size required by the selected controller
williamr@2
   784
	*/
williamr@2
   785
	TUint ControllersMaxHeapSizeL(TUid aControllerUid);
williamr@2
   786
williamr@2
   787
	/**
williamr@2
   788
	Load a controller by UID
williamr@2
   789
	
williamr@2
   790
	@param  aControllerUid
williamr@2
   791
	        The UID of the controller plugin to be loaded.
williamr@2
   792
	@param  aControllerInfo
williamr@2
   793
	        A reference to a CMMFControllerImplementationInformation object
williamr@2
   794
	        used for determining the heap size and DRM server supporting state.
williamr@2
   795
	@param	aUseSharedHeap
williamr@2
   796
			If this value is EFalse each controller is created with its own heap. The alternative,
williamr@2
   797
			if the value is ETrue, is that controllers share a special heap with other controllers
williamr@2
   798
			created the same way. Each heap uses a chunk, so this avoids situations where the
williamr@2
   799
			number of chunks per process is limited. The default behaviour is generally to be
williamr@2
   800
			preferred, and should give lower overall memory usage. However, if many controllers are
williamr@2
   801
			to be created for a particular thread, then ETrue should be provided to prevent running
williamr@2
   802
			out of heaps or chunks.
williamr@2
   803
	@param	aNoDRMCap
williamr@2
   804
			The indicator supplied from user used to determine whether the user's process has DRM 
williamr@2
   805
			capability
williamr@2
   806
	@return	TInt
williamr@2
   807
			One of the system-wide error codes.
williamr@2
   808
	*/
williamr@2
   809
	TInt LoadController(TUid aControllerUid, const CMMFControllerImplementationInformation& aControllerInfo, TBool aUseSharedHeap,
williamr@2
   810
						TBool aNoDRMCap = EFalse);
williamr@2
   811
	
williamr@2
   812
	/**
williamr@2
   813
	Release heap - for use when a shared heap has been registered
williamr@2
   814
	*/
williamr@2
   815
	void ReleaseHeap();
williamr@2
   816
williamr@2
   817
	/**
williamr@2
   818
	Create a session to handle situation of playing DRM protected content in
williamr@2
   819
	process with no DRM capability.
williamr@2
   820
	DRM server process will be created, if not yet created. This server is responsible to
williamr@2
   821
	manage and monitor all the MMF Controller servers created as seperate threads belong to 
williamr@2
   822
	DRM server process. Once the new MMF Controller server is running, a MMF Controller server 
williamr@2
   823
	session will be created and the handle is passing back.
williamr@2
   824
	*/
williamr@2
   825
	TInt DoCreateSessionForNoDRMCapClient(TUint aMaxHeapSize, TBool aUseSharedHeap);
williamr@2
   826
	
williamr@2
   827
private:
williamr@2
   828
	enum
williamr@2
   829
		{
williamr@2
   830
		/**
williamr@2
   831
		Shared heap has been opened for this object, and must be closed
williamr@2
   832
		*/
williamr@2
   833
		EFlagOpenedSharedHeap=0x01	
williamr@2
   834
		};
williamr@2
   835
williamr@2
   836
private:
williamr@2
   837
	/**
williamr@2
   838
	The thread in which the controller plugin will run.
williamr@2
   839
	*/
williamr@2
   840
	RThread iSubThread;
williamr@2
   841
	/**
williamr@2
   842
	Used to hold destination for messages from the controller proxy
williamr@2
   843
	(not from clients calling SendSync/SendAsync!!)
williamr@2
   844
	*/
williamr@2
   845
	TMMFMessageDestinationPckg iDestinationPckg;
williamr@2
   846
	/**
williamr@2
   847
	Used to determine the success of a logon.  If the status is not pending, the logon has failed
williamr@2
   848
	and the thread should be closed.
williamr@2
   849
	*/
williamr@2
   850
	CLogonMonitor* iLogonAO;
williamr@2
   851
	/**
williamr@2
   852
	The priority at which the controller plugin thread runs.
williamr@2
   853
	*/
williamr@2
   854
	TThreadPriority iThreadPriority;
williamr@2
   855
	/**
williamr@2
   856
	Flags field
williamr@2
   857
	*/
williamr@2
   858
	TInt iFlags;	
williamr@2
   859
	/**
williamr@2
   860
	This member is internal and not intended for use.
williamr@2
   861
	*/
williamr@2
   862
	TInt iReserved1;
williamr@2
   863
	};
williamr@2
   864
williamr@2
   865
/**
williamr@2
   866
@internalComponent
williamr@2
   867
williamr@2
   868
Used to Kill the controller thread either immediately or after a timeout.
williamr@2
   869
Used by the controller thread on startup to prevent orphaning if no sessions are created to it.
williamr@2
   870
*/
williamr@2
   871
class CMMFControllerProxyShutdown : public CTimer
williamr@2
   872
	{
williamr@2
   873
	enum {EMMFControllerProxyShutdownDelay=1000000};	// 1s
williamr@2
   874
public:
williamr@2
   875
williamr@2
   876
	/**
williamr@2
   877
	Create a new shutdown timer.
williamr@2
   878
williamr@2
   879
	This method can leave with one of the system-wide error codes.
williamr@2
   880
williamr@2
   881
	@since 7.0s
williamr@2
   882
	*/
williamr@2
   883
	static CMMFControllerProxyShutdown* NewL();
williamr@2
   884
williamr@2
   885
	/**
williamr@2
   886
	Start the shutdown timer.  The RunL of this active object will be called after
williamr@2
   887
	EMMFControllerProxyShutdownDelay microseconds.
williamr@2
   888
williamr@2
   889
	@since 7.0s
williamr@2
   890
	*/
williamr@2
   891
	void Start();
williamr@2
   892
williamr@2
   893
	/**
williamr@2
   894
	Shut down the controller thread immediately.
williamr@2
   895
	
williamr@2
   896
	Calls CActiveScheduler::Stop().
williamr@2
   897
williamr@2
   898
	@since 7.0s
williamr@2
   899
	*/
williamr@2
   900
	void ShutdownNow();
williamr@2
   901
private:
williamr@2
   902
	CMMFControllerProxyShutdown();
williamr@2
   903
	void ConstructL();
williamr@2
   904
williamr@2
   905
	/**
williamr@2
   906
	Calls ShutdownNow().
williamr@2
   907
williamr@2
   908
	@since 7.0s
williamr@2
   909
	*/
williamr@2
   910
	void RunL();
williamr@2
   911
	};
williamr@2
   912
williamr@2
   913
williamr@2
   914
/**
williamr@2
   915
@publishedAll
williamr@2
   916
@released
williamr@2
   917
williamr@2
   918
Mixin class to define an object capable of handling an event within the controller framework.
williamr@2
   919
*/
williamr@2
   920
class MAsyncEventHandler
williamr@2
   921
	{
williamr@2
   922
public:
williamr@2
   923
williamr@2
   924
	/**
williamr@2
   925
	Sends an event to the client.
williamr@2
   926
williamr@2
   927
	@param  aEvent
williamr@2
   928
	        The event.
williamr@2
   929
williamr@2
   930
	@since 7.0s
williamr@2
   931
	*/
williamr@2
   932
	virtual TInt SendEventToClient(const TMMFEvent& aEvent) = 0;
williamr@2
   933
	};
williamr@2
   934
williamr@2
   935
/**
williamr@2
   936
@internalComponent
williamr@2
   937
williamr@2
   938
Used to hold on to an TMMFMessage so we can complete it asynchronously to 
williamr@2
   939
send an event to the client.
williamr@2
   940
williamr@2
   941
@since 7.0s
williamr@2
   942
*/
williamr@2
   943
class CMMFEventReceiver : public CBase
williamr@2
   944
	{
williamr@2
   945
public:
williamr@2
   946
williamr@2
   947
	/**
williamr@2
   948
	Constructs a new event receiver.
williamr@2
   949
	
williamr@2
   950
	This method may leave with one of the system-wide error codes.
williamr@2
   951
williamr@2
   952
	@param  aMessage
williamr@2
   953
	        The message to be completed when an event occurs.
williamr@2
   954
williamr@2
   955
	@return A pointer to the newly created event receiver.
williamr@2
   956
williamr@2
   957
	@since  7.0s
williamr@2
   958
	*/
williamr@2
   959
	static CMMFEventReceiver* NewL(const TMMFMessage& aMessage);
williamr@2
   960
williamr@2
   961
	/**
williamr@2
   962
	Destructor.
williamr@2
   963
williamr@2
   964
	Completes the message with KErrCancel if the message hasn't already been completed.
williamr@2
   965
williamr@2
   966
	@since 7.0s
williamr@2
   967
	*/
williamr@2
   968
	~CMMFEventReceiver();
williamr@2
   969
williamr@2
   970
	/**
williamr@2
   971
	Sends an event to the client.
williamr@2
   972
williamr@2
   973
	@param  aEvent
williamr@2
   974
	        The event.
williamr@2
   975
williamr@2
   976
	@since  7.0s
williamr@2
   977
	*/
williamr@2
   978
	void SendEvent(const TMMFEvent& aEvent);
williamr@2
   979
private:
williamr@2
   980
williamr@2
   981
	/**
williamr@2
   982
	Constructor.
williamr@2
   983
williamr@2
   984
	@param  aMessage
williamr@2
   985
	        The message to be completed when an event occurs.
williamr@2
   986
williamr@2
   987
	@since  7.0s
williamr@2
   988
	*/
williamr@2
   989
	CMMFEventReceiver(const TMMFMessage& aMessage);
williamr@2
   990
private:
williamr@2
   991
	/** 
williamr@2
   992
	The message to be completed when an event occurs.
williamr@2
   993
	*/
williamr@2
   994
	TMMFMessage iMessage;
williamr@2
   995
	};
williamr@2
   996
williamr@2
   997
williamr@2
   998
williamr@2
   999
/**
williamr@2
  1000
@internalComponent
williamr@2
  1001
williamr@2
  1002
The controller proxy server.
williamr@2
  1003
williamr@2
  1004
The main server inside the controller thread, responsible for creating and destroying the single
williamr@2
  1005
session used to transmit messages from the client to the server.
williamr@2
  1006
williamr@2
  1007
Every controller plugin runs in its own thread, and has its own controller proxy server.
williamr@2
  1008
williamr@2
  1009
@since 7.0s
williamr@2
  1010
*/
williamr@2
  1011
class CMMFControllerProxyServer : public CMmfIpcServer
williamr@2
  1012
	{
williamr@2
  1013
public:
williamr@2
  1014
	/**
williamr@2
  1015
	Construct the server.
williamr@2
  1016
williamr@2
  1017
	This method may leave with one of the system-wide error codes.
williamr@2
  1018
williamr@2
  1019
	@return The newly created server.
williamr@2
  1020
williamr@2
  1021
	@since  7.0s
williamr@2
  1022
	*/
williamr@2
  1023
	static CMMFControllerProxyServer* NewL(RServer2* aServer2 );
williamr@2
  1024
williamr@2
  1025
	/**
williamr@2
  1026
	Destructor.
williamr@2
  1027
williamr@2
  1028
	@since 7.0s
williamr@2
  1029
	*/
williamr@2
  1030
	~CMMFControllerProxyServer();
williamr@2
  1031
williamr@2
  1032
	/**
williamr@2
  1033
	Static thread function.
williamr@2
  1034
williamr@2
  1035
	The address of this function is passed into RThread::Create.
williamr@2
  1036
williamr@2
  1037
	Unpackages the startup parameters and calls DoStartThreadL().
williamr@2
  1038
williamr@2
  1039
	@param  aAny
williamr@2
  1040
	        A pointer to the packaged startup parameters.
williamr@2
  1041
williamr@2
  1042
	@return One of the system-wide error codes.
williamr@2
  1043
williamr@2
  1044
	@since 7.0s
williamr@2
  1045
	*/
williamr@2
  1046
	IMPORT_C static TInt StartThread(TAny* aParam);
williamr@2
  1047
williamr@2
  1048
	/**
williamr@2
  1049
	Called by the active scheduler when the ServiceL of the session leaves.
williamr@2
  1050
	Completes the message with the error and restarts the server.
williamr@2
  1051
williamr@2
  1052
	@param  aError
williamr@2
  1053
	        The error that the session ServiceL left with.
williamr@2
  1054
williamr@2
  1055
	@return  KErrNone
williamr@2
  1056
	@since 7.0s
williamr@2
  1057
	*/
williamr@2
  1058
	TInt RunError(TInt aError);
williamr@2
  1059
williamr@2
  1060
	/**
williamr@2
  1061
	Signals that the session has been created.
williamr@2
  1062
williamr@2
  1063
	Stops the shutdown timer.
williamr@2
  1064
williamr@2
  1065
	@since 7.0s
williamr@2
  1066
	*/
williamr@2
  1067
	void SessionCreated();
williamr@2
  1068
williamr@2
  1069
	/**
williamr@2
  1070
	Signals that the session has been destroyed.
williamr@2
  1071
	Causes the server to shut down immediately.
williamr@2
  1072
williamr@2
  1073
	@since 7.0s
williamr@2
  1074
	*/
williamr@2
  1075
	void SessionDestroyed();
williamr@2
  1076
private:
williamr@2
  1077
williamr@2
  1078
	/**
williamr@2
  1079
	Thread startup code.
williamr@2
  1080
williamr@2
  1081
	Creates the cleanup stack, installs the active scheduler and creates the server.
williamr@2
  1082
	Once all this is completed successfully, it signals the success back to the client.
williamr@2
  1083
williamr@2
  1084
	This function may leave with one of the system-wide error codes.
williamr@2
  1085
williamr@2
  1086
	@param  aParams
williamr@2
  1087
	        Used to signal startup success back to the client.
williamr@2
  1088
williamr@2
  1089
	@since 7.0s
williamr@2
  1090
	*/
williamr@2
  1091
	static void DoStartThreadL(TAny* aParam);
williamr@2
  1092
williamr@2
  1093
	/**
williamr@2
  1094
	Creates a new session.  Only one session may be created with the ControllerProxyServer.
williamr@2
  1095
williamr@2
  1096
	This function may leave with one of the system-wide error codes.
williamr@2
  1097
williamr@2
  1098
	@param  aVersion
williamr@2
  1099
	        The version number of the session.
williamr@2
  1100
williamr@2
  1101
	@return A pointer to the new session.
williamr@2
  1102
williamr@2
  1103
	@since 7.0s
williamr@2
  1104
	*/
williamr@2
  1105
	CMmfIpcSession* NewSessionL(const TVersion& aVersion) const;
williamr@2
  1106
williamr@2
  1107
	/** 
williamr@2
  1108
	Constructor.
williamr@2
  1109
williamr@2
  1110
	@since 7.0s
williamr@2
  1111
	*/
williamr@2
  1112
	CMMFControllerProxyServer();
williamr@2
  1113
williamr@2
  1114
	/**
williamr@2
  1115
	Second phase constructor.
williamr@2
  1116
williamr@2
  1117
	@since 7.0s
williamr@2
  1118
	*/
williamr@2
  1119
	void ConstructL(RServer2* aServer2);
williamr@2
  1120
	
williamr@2
  1121
	/**
williamr@2
  1122
	Renaming Controller Proxy Server name
williamr@2
  1123
	
williamr@2
  1124
	@since 9.2
williamr@2
  1125
	*/
williamr@2
  1126
	static void RenameControllerProxyThread();
williamr@2
  1127
williamr@2
  1128
private:
williamr@2
  1129
	/** 
williamr@2
  1130
	The timer used to shut down the server in case the client fails to connect a session.
williamr@2
  1131
	*/
williamr@2
  1132
	CMMFControllerProxyShutdown* iShutdownTimer;
williamr@2
  1133
	/** 
williamr@2
  1134
	Indicates whether we have a session connected.  Only one session is allowed to connect to the server.
williamr@2
  1135
	*/
williamr@2
  1136
	TBool iHaveSession;
williamr@2
  1137
	};
williamr@2
  1138
williamr@2
  1139
class CMMFController;
williamr@2
  1140
williamr@2
  1141
/**
williamr@2
  1142
@internalComponent
williamr@2
  1143
williamr@2
  1144
The controller proxy session.
williamr@2
  1145
williamr@2
  1146
Only one session can be connected to a controller proxy server.
williamr@2
  1147
williamr@2
  1148
@since 7.0s
williamr@2
  1149
*/
williamr@2
  1150
class CMMFControllerProxySession : public CMmfIpcSession, public MAsyncEventHandler
williamr@2
  1151
	{
williamr@2
  1152
public:
williamr@2
  1153
williamr@2
  1154
	/**
williamr@2
  1155
	Construct the session.
williamr@2
  1156
williamr@2
  1157
	This method may leave with one of the system-wide error codes.
williamr@2
  1158
williamr@2
  1159
	@return The newly created server.
williamr@2
  1160
williamr@2
  1161
	@since 7.0s
williamr@2
  1162
	*/
williamr@2
  1163
	static CMMFControllerProxySession* NewL();
williamr@2
  1164
williamr@2
  1165
	/**
williamr@2
  1166
	Second phase constructor called by the CServer base class.
williamr@2
  1167
williamr@2
  1168
	This function may leave with one of the system-wide error codes.
williamr@2
  1169
williamr@2
  1170
	@param  aServer
williamr@2
  1171
	        A reference to the server to which this session is attached.
williamr@2
  1172
williamr@2
  1173
	@since  7.0s
williamr@2
  1174
	*/
williamr@2
  1175
	void CreateL(const CMmfIpcServer& aServer);
williamr@2
  1176
williamr@2
  1177
	/**
williamr@2
  1178
	Destructor.
williamr@2
  1179
	*/
williamr@2
  1180
	~CMMFControllerProxySession();
williamr@2
  1181
williamr@2
  1182
	/**
williamr@2
  1183
	Called by the CServer baseclass when a request has been made by the client.
williamr@2
  1184
williamr@2
  1185
	This function may leave with on of the system-wide error codes. If
williamr@2
  1186
	a leave occurs, the message will be automatically completed by the
williamr@2
  1187
	RunError() of the Controller Proxy Server.
williamr@2
  1188
williamr@2
  1189
	@param  aMessage
williamr@2
  1190
	        The request to be handled.  The controller proxy session will create
williamr@2
  1191
	        a TMMFMessage from this, and pass on the request to the controller
williamr@2
  1192
	        base class to handle.
williamr@2
  1193
williamr@2
  1194
	@since	7.0s
williamr@2
  1195
	*/
williamr@2
  1196
	void ServiceL(const RMmfIpcMessage& aMessage);
williamr@2
  1197
williamr@2
  1198
	/**
williamr@2
  1199
	Derived from MAsyncEventHandler.
williamr@2
  1200
williamr@2
  1201
	@see MAsyncEventHandler
williamr@2
  1202
williamr@2
  1203
	@since	7.0s
williamr@2
  1204
	*/
williamr@2
  1205
	TInt SendEventToClient(const TMMFEvent& aEvent);
williamr@2
  1206
private:
williamr@2
  1207
	/**
williamr@2
  1208
	Constructor
williamr@2
  1209
	*/
williamr@2
  1210
	CMMFControllerProxySession();
williamr@2
  1211
williamr@2
  1212
	/**
williamr@2
  1213
	Handle a request from the client to register to receive events from the controller framework.
williamr@2
  1214
williamr@2
  1215
	This function may leave with one of the system-wide error codes.
williamr@2
  1216
williamr@2
  1217
	@param  aMessage
williamr@2
  1218
	        The request to be handled.
williamr@2
  1219
williamr@2
  1220
	@return ETrue if the message is to be completed now, EFalse if the message will be completed 
williamr@2
  1221
	        later.
williamr@2
  1222
	*/
williamr@2
  1223
	TBool ReceiveEventsL(TMMFMessage& aMessage);
williamr@2
  1224
williamr@2
  1225
	/**
williamr@2
  1226
	Handle a request from the client to stop receiving events from the controller framework.
williamr@2
  1227
williamr@2
  1228
	This function may leave with one of the system-wide error codes.
williamr@2
  1229
williamr@2
  1230
	@param  aMessage
williamr@2
  1231
	        The request to be handled.
williamr@2
  1232
williamr@2
  1233
	@return ETrue if the message is to be completed now, EFalse if the message will be completed later.
williamr@2
  1234
	*/
williamr@2
  1235
	TBool CancelReceiveEvents(TMMFMessage& aMessage);
williamr@2
  1236
williamr@2
  1237
	/**
williamr@2
  1238
	Handle a request from the client to load a controller plugin.
williamr@2
  1239
williamr@2
  1240
	This function may leave with one of the system-wide error codes.
williamr@2
  1241
williamr@2
  1242
	@param  aMessage
williamr@2
  1243
	        The request to be handled.
williamr@2
  1244
williamr@2
  1245
	@return ETrue if the message is to be completed now, EFalse if the message will be completed later.
williamr@2
  1246
	*/
williamr@2
  1247
	TBool LoadControllerL(TMMFMessage& aMessage);
williamr@2
  1248
private:
williamr@2
  1249
	/** 
williamr@2
  1250
	The controller plugin. 
williamr@2
  1251
	*/
williamr@2
  1252
	CMMFController* iController;
williamr@2
  1253
	/** 
williamr@2
  1254
	A pointer to the server. 
williamr@2
  1255
	*/
williamr@2
  1256
	CMMFControllerProxyServer* iServer;
williamr@2
  1257
	/** 
williamr@2
  1258
	The event receiver.  Used to send events to the client.
williamr@2
  1259
	*/
williamr@2
  1260
	CMMFEventReceiver* iEventReceiver;
williamr@2
  1261
	/** 
williamr@2
  1262
	The events waiting to be sent to the client.
williamr@2
  1263
	*/
williamr@2
  1264
	RArray<TMMFEvent> iEvents;
williamr@2
  1265
	};
williamr@2
  1266
williamr@2
  1267
williamr@2
  1268
#endif