plugins/contacts/symbian/contactsmodel/cntsrv/src/ccntrequest.cpp
changeset 0 876b1a06bc25
equal deleted inserted replaced
-1:000000000000 0:876b1a06bc25
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalTechnology
       
    22  @released 
       
    23 */
       
    24 
       
    25 #include "ccntrequest.h"
       
    26 #include "ccntstatemachine.h"
       
    27 #include "ccntpackager.h"
       
    28 #include <cntitem.h>
       
    29 
       
    30 // CCntRequest 
       
    31 // CCntRequest is the base class for all Request classes that handle external
       
    32 // requests (requests that originate from the CContactDatabase). Internal requests
       
    33 // derive from the CReqInternal class. 
       
    34 // Note 1: All unpacking of objects should be done within Construction.
       
    35 // Note 2: The destruction of request objects is a little unusual.
       
    36 //		   The destruction of requests objects is usually the responsibility of the CStatemachine or in the CRequestStore class.
       
    37 //         The destruction of requests is usually performed using the CCntRequest::CompletePD method. See below
       
    38 // Note 3: Each request has a timeout member - the time for which the request remains valid - and a timeouterror member variable.
       
    39 //		   The iTimeOutError is the error that will be returned to the client in the event of the request timing out. The default 
       
    40 //		   timeout value is KErrNotReady but the CStateMachine can reset this depending on the last action the statemachine attempted
       
    41 // 		   to perform before the request timedout.
       
    42 //		   Timeouts work as follows - the statemachine returns TDeferred indicating it could not process the request in the current state
       
    43 //		   The request is added to the request store, CRequestStore, and the timeout is activated via the CCntRequest::ActivateTimeOutL 		
       
    44 //		   method. There are two possible outcomes:
       
    45 //			1. The state changes, or a contact item is unlocked, and the request is activated and processed by the CStateMachine		
       
    46 //			2. The request times out, CCntRequestTimer::RunL is called and the request is completed with the iTimeOutError error code.
       
    47 
       
    48 /** 
       
    49   Base CCntRequest constructor
       
    50   @param  aSessionId The session from which the request originated
       
    51   @param  aMessage The RMessage from the client
       
    52   @param  aTimeOut The lenght of time in milliseconds for which the request remains valid
       
    53 */
       
    54 
       
    55 CCntRequest::CCntRequest(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut)
       
    56 						:iMessage(aMessage),
       
    57 						 iSessionId(aSessionId), 
       
    58 						 iTimeOut(aTimeOut),
       
    59 						 iTimeOutError(KErrNotReady)
       
    60 	{
       
    61 	ASSERT(aSessionId); // Should never be NULL
       
    62 	// All internal requests do not have a session ID, such requests derive from the CReqInternal
       
    63 	// and NOT from CCntRequest.
       
    64 	}
       
    65 
       
    66 /** 
       
    67   Complete the requests internal iMessage
       
    68 
       
    69   @param  aErrCode The error code with which the message will be completed
       
    70 */
       
    71 void CCntRequest::Complete(TInt aErrCode)
       
    72 	{
       
    73 	iMessage.Complete(aErrCode); 
       
    74 	}
       
    75 
       
    76 CCntRequest::~CCntRequest()
       
    77 	{
       
    78 	delete iTimer;
       
    79 	}
       
    80 
       
    81 /** 
       
    82   Start the timeout 
       
    83   A timer is only ever added when it does not exist and a non-zero timeout value has
       
    84   been specified, because the request may be activated, processed and deferred more than once.
       
    85   The result of request processing could be to add the request to the request queue again. 
       
    86  
       
    87   @param  aReqStore When a times out, the timer access the store to complete the request with
       
    88   	 		a timeout error.
       
    89  */
       
    90 void CCntRequest::ActivateTimeOutL(CRequestStore& aReqStore)
       
    91 	{
       
    92 	if ((iTimer == NULL) && (iTimeOut != 0))
       
    93 		{
       
    94 		iTimer = CCntRequestTimer::NewL(*this, aReqStore);
       
    95 		iTimer->Start();
       
    96 		}
       
    97 	}
       
    98 
       
    99 /**
       
   100   Stop the timeout
       
   101  */
       
   102 void CCntRequest::DeActivateTimeOut()
       
   103 	{
       
   104 	if (iTimer)
       
   105 		{
       
   106 		iTimer->Stop();	
       
   107 		}
       
   108 		
       
   109 	delete iTimer;
       
   110 	iTimer = NULL;
       
   111 	}
       
   112 
       
   113 /**
       
   114   Set the timeout error code
       
   115   Inorder to assure binary compatibility with the original Contacts Model,
       
   116   which did not retry processing client requests, the error code - reason 
       
   117   why an request can not be processed - needs to be stored and returned to
       
   118   to the client if a subsequest/retry to process the request fails.
       
   119   For example if a contact item has been locked by one session, a request
       
   120   to open the contact item by a second session should complete with KErrInUse
       
   121   however if the server has been put into a transaction state by one session,
       
   122   the seconds session request should complete with KErrNotReady 
       
   123   KErrNotReady is the default error timeout value set by the base state CState
       
   124   it is also be set the CCntRequest constructor
       
   125  
       
   126   @param  aError The error code with which the message will be completed if it times out 
       
   127   
       
   128  */ 
       
   129 void CCntRequest::SetTimeOutError(TInt aError)
       
   130 	{
       
   131 	iTimeOutError = aError;
       
   132 	}
       
   133 	
       
   134 /**
       
   135  Get the timeout error code	
       
   136  @return The timeout error code
       
   137 */ 
       
   138 TInt CCntRequest::TimeOutError()const
       
   139 	{
       
   140 	return iTimeOutError;
       
   141 	}
       
   142 
       
   143 
       
   144 /** 
       
   145   Does not complete a RMessage - Internal Request do not contain a RMessage
       
   146   as they don't originate from the client.  Do nothing.
       
   147   @param  aErrorCode Not used
       
   148 */
       
   149 void CReqInternal::Complete(TInt /* aErrorCode*/) 
       
   150 	{
       
   151 	}
       
   152 
       
   153 
       
   154 // Request Helper classes
       
   155 // -----------------------
       
   156 // CCntRequestTimer
       
   157 // CRequestStore
       
   158 
       
   159 /** 
       
   160   CCntRequestTimer constructor
       
   161   CCntRequestTimer is an active object derived from CTimer
       
   162   @param aRequest The request which will timeout
       
   163   @param aReqStore The array that holds the deferred request    
       
   164   				   The request must be removed from the request store after 
       
   165   				   it is completed with an error code.
       
   166 */
       
   167 CCntRequestTimer* CCntRequestTimer::NewL(CCntRequest& aRequest, CRequestStore& aReqStore)
       
   168 	{
       
   169 	CCntRequestTimer* self = new (ELeave) CCntRequestTimer(aRequest, aReqStore);
       
   170 	CleanupStack::PushL(self);
       
   171 	self->ConstructL();
       
   172 	CleanupStack::Pop(self);
       
   173 	return self;
       
   174 	}
       
   175 	
       
   176 	
       
   177 CCntRequestTimer::~CCntRequestTimer()
       
   178 	{
       
   179 	CTimer::Cancel();
       
   180 	}
       
   181 	
       
   182 	
       
   183 CCntRequestTimer::CCntRequestTimer(CCntRequest& aRequest, CRequestStore& aReqStore) 
       
   184 				 : CTimer(CActive::EPriorityIdle), 
       
   185 				 iRequest(aRequest), 
       
   186 				 iReqStore(aReqStore) 
       
   187 	{								  
       
   188 	}
       
   189 
       
   190 
       
   191 void CCntRequestTimer::ConstructL()
       
   192 	{
       
   193 	CTimer::ConstructL();
       
   194 	CActiveScheduler::Add(this);
       
   195 	}
       
   196 
       
   197 void CCntRequestTimer::RunL()
       
   198 	{
       
   199 	// Complete the contact with the timeout error
       
   200 	iRequest.Complete(iRequest.TimeOutError());
       
   201 	CTimer::Cancel();
       
   202 	iReqStore.RemoveD(&iRequest); 
       
   203 	}
       
   204 
       
   205 void CCntRequestTimer::Start()
       
   206 	{ 
       
   207 	CTimer::After(iRequest.TimeOut());
       
   208 	}
       
   209 		
       
   210 void CCntRequestTimer::Stop()
       
   211 	{
       
   212 	CTimer::Cancel();
       
   213 	}
       
   214 
       
   215 
       
   216 
       
   217 
       
   218 /**
       
   219  Object are added when the session requests a Transaction to begin
       
   220  but the database is already in a transaction state for another session
       
   221  There can only ever handle one transaction request - no concurrency!
       
   222 
       
   223  @param aStateMachine The request store calls the statemachine to process the
       
   224  					  request.
       
   225 */ 
       
   226 CRequestStore* CRequestStore::NewL(CCntStateMachine& aStateMachine)
       
   227 	{
       
   228 	CRequestStore* self = new (ELeave) CRequestStore(aStateMachine);
       
   229 	return self;
       
   230 	}
       
   231 
       
   232 CRequestStore::CRequestStore(CCntStateMachine& aStateMachine): 
       
   233 				iStateMachine(aStateMachine)
       
   234 	{
       
   235 	}
       
   236 
       
   237 CRequestStore::~CRequestStore()
       
   238 	{
       
   239 	iStore.ResetAndDestroy();
       
   240 	delete iActive;
       
   241 	}
       
   242 
       
   243 /**
       
   244  Remove the request from the store and delete the request
       
   245  
       
   246  @param aRequest The request that should be removed from the store and deleted
       
   247  				 The Request Store takes ownership of this object
       
   248 */
       
   249 void CRequestStore::RemoveD(CCntRequest* aRequest)
       
   250 	{
       
   251 	TInt index = iStore.Find(aRequest);
       
   252 	if (index > KErrNotFound)
       
   253 		{
       
   254 		iStore.Remove(index);	
       
   255 		}
       
   256 	delete aRequest;
       
   257 	aRequest = NULL;
       
   258 	}
       
   259 
       
   260 
       
   261 /**
       
   262  Append a request to the request store
       
   263 
       
   264  @param aRequest  The request that is to be appended to the store
       
   265 */	
       
   266 void CRequestStore::AppendL(CCntRequest* aRequest)
       
   267 	{
       
   268 	// The heap is safe since the request is appended to the contained store.
       
   269 	// Pop as the stack will be out of sync when the statemachine processes 
       
   270 	// the request.
       
   271 	User::LeaveIfError(iStore.Append(aRequest));
       
   272 	}
       
   273 
       
   274 /** 
       
   275  Get the first request from the store 
       
   276 
       
   277  @return The request a the beginning of the stores array
       
   278  		 Ownership of the request is given to the calling method
       
   279 */
       
   280 CCntRequest* CRequestStore::Request()
       
   281 	{
       
   282 	CCntRequest* request = iStore[KFirstRequest]; 
       
   283 	iStore.Remove(KFirstRequest);
       
   284 	
       
   285 	return request;     // Return ownership
       
   286 	}
       
   287 
       
   288 /**
       
   289  Is there requests in the store
       
   290  
       
   291  @return ETrue if there are no request, EFalse otherwise
       
   292 */
       
   293 TBool CRequestStore::IsEmpty()
       
   294 	{
       
   295 	if (iStore.Count() > 0)
       
   296 		return EFalse;
       
   297 	
       
   298 	return ETrue;
       
   299 	}
       
   300 
       
   301 /**
       
   302   Activate the store.
       
   303   The request store uses the CActiveLoop for callbacks on each iteration 
       
   304   of the CActiveLoop only one request is processed until all
       
   305   requests have been processed.
       
   306  */
       
   307 void CRequestStore::ActivateRequestsL()
       
   308 	{
       
   309 	if (!iActive)
       
   310 		{
       
   311 		iActive = CActiveLoop::NewL();
       
   312 		}
       
   313 	
       
   314 	// Only process the requests in the store when it has been activated.
       
   315 	// Don't process any requests added to the store after it has been activated.
       
   316 	// Requests may be readded to the store & should not be processed twice 
       
   317 	// in the same batch.
       
   318 	// The store may already have been activated. 
       
   319 	if ((!iActive->IsActive()) && (iNoOfRequests == 0))
       
   320 		{
       
   321 		iActive->Register(*this);	
       
   322 		iNoOfRequests = iStore.Count();
       
   323 		}
       
   324 	}
       
   325 
       
   326 /**
       
   327  Process the next request in the store.	
       
   328  If the request has timed out return an error
       
   329  otherwise process the request as normal.
       
   330  
       
   331  @ return ETrue if another step is required, EFalse if this is the last step
       
   332  */
       
   333 TBool CRequestStore::DoStepL()
       
   334 	{
       
   335 	ASSERT(iCurrentRequest == NULL);
       
   336 
       
   337 	iCurrentRequest = Request();
       
   338 	iStateMachine.ProcessRequestL(iCurrentRequest); // ownership transferred
       
   339 	
       
   340 	// ProcessRequestL received ownership of the request, iCurrentRequest can be 
       
   341 	// reset to NULL
       
   342 	iCurrentRequest = NULL;
       
   343 	
       
   344 	--iNoOfRequests;
       
   345 
       
   346 	if (iNoOfRequests == 0) 
       
   347 		{
       
   348 		return EFalse; // The store has tried to process all requests it holds	
       
   349 		}
       
   350 
       
   351 	return ETrue;
       
   352 	}
       
   353 	
       
   354 /** 
       
   355  Error callback from the CActiveLoop class.	
       
   356  
       
   357  @ param aError The error to complete the current request (the request that is
       
   358  				being processed)
       
   359 */
       
   360 void CRequestStore::DoError(TInt aError)
       
   361 	{
       
   362 	// there should always be a current request
       
   363 	ASSERT(iCurrentRequest);
       
   364 	if (iCurrentRequest)
       
   365 		{
       
   366 		iCurrentRequest->Complete(aError);
       
   367 		delete iCurrentRequest;
       
   368 		
       
   369 		iCurrentRequest = NULL;
       
   370 		}
       
   371 	}
       
   372 
       
   373 
       
   374 /** 
       
   375  CReqAsyncOpen constructor
       
   376  Request to open the database asyncronously 
       
   377  
       
   378  @see CCntRequest constructor   
       
   379 */
       
   380 CReqAsyncOpen* CReqAsyncOpen::NewLC(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut)
       
   381 	{
       
   382 	CReqAsyncOpen* self = new (ELeave) CReqAsyncOpen(aSessionId, aMessage, aTimeOut);
       
   383 	CleanupStack::PushL(self);
       
   384 	self->ConstructL();
       
   385 	return self;
       
   386 	}
       
   387 
       
   388 CReqAsyncOpen::CReqAsyncOpen(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut )
       
   389 : CCntRequest(aSessionId, aMessage, aTimeOut)
       
   390 	{
       
   391 	}
       
   392 
       
   393 void CReqAsyncOpen::ConstructL()
       
   394 	{
       
   395 	iMessage.ReadL(0,iFilename);
       
   396 	}
       
   397 
       
   398 /**
       
   399  Get the name of the file that is to be opened
       
   400  The DBManager may change this name. If no name has been passed by the client
       
   401  then the default is set by the manager
       
   402  
       
   403  @return The name of the file that should be opened
       
   404 */ 
       
   405 TDes& CReqAsyncOpen::FileName()
       
   406 	{
       
   407 	return iFilename;
       
   408 	}
       
   409 
       
   410 TAccept CReqAsyncOpen::VisitStateL(CState& aState)
       
   411 	{
       
   412 	return aState.AcceptRequestL(this);
       
   413 	}
       
   414 
       
   415 /**
       
   416  CReqCloseTables constructor
       
   417  Close the database tables
       
   418 
       
   419  @see CCntRequest constructor    
       
   420 */ 
       
   421 CReqCloseTables* CReqCloseTables::NewLC(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut)
       
   422   	{
       
   423   	CReqCloseTables* self = new (ELeave) CReqCloseTables(aSessionId, aMessage, aTimeOut);
       
   424   	CleanupStack::PushL(self);
       
   425   	return self;
       
   426   	};
       
   427   
       
   428 CReqCloseTables::CReqCloseTables(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut)
       
   429   :CCntRequest(aSessionId, aMessage, aTimeOut)
       
   430   	{
       
   431   	}
       
   432   
       
   433   
       
   434 TAccept CReqCloseTables::VisitStateL(CState& aState)
       
   435   	{
       
   436   	return aState.AcceptRequestL(this);
       
   437   	}
       
   438   
       
   439   
       
   440 /** 
       
   441   CReqReOpen 
       
   442   Re Open the database
       
   443   
       
   444   @see CCntRequest constructor    
       
   445 */
       
   446 CReqReOpen* CReqReOpen::NewLC(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut)
       
   447 	{
       
   448 	CReqReOpen* self = new (ELeave) CReqReOpen(aSessionId, aMessage, aTimeOut);
       
   449 	CleanupStack::PushL(self);
       
   450 	return self;
       
   451 	}
       
   452 
       
   453 CReqReOpen::CReqReOpen(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut)
       
   454 :CCntRequest(aSessionId, aMessage, aTimeOut)
       
   455 	{
       
   456 	}
       
   457 
       
   458 TAccept CReqReOpen::VisitStateL(CState& aState)
       
   459 	{
       
   460 	return aState.AcceptRequestL(this);
       
   461 	}
       
   462 
       
   463 
       
   464 /**
       
   465  CReqCancelAsyncOpen 
       
   466  Cancel an asyncronous open request
       
   467  
       
   468  @see CCntRequest constructor    
       
   469 */ 
       
   470 CReqCancelAsyncOpen* CReqCancelAsyncOpen::NewLC(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut)
       
   471 	{
       
   472 	CReqCancelAsyncOpen* self = new (ELeave) CReqCancelAsyncOpen(aSessionId, aMessage, aTimeOut);
       
   473 	CleanupStack::PushL(self);
       
   474 	return self;
       
   475 	}
       
   476 
       
   477 CReqCancelAsyncOpen::CReqCancelAsyncOpen(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut)
       
   478 :CCntRequest(aSessionId, aMessage, aTimeOut)
       
   479 	{
       
   480 	}
       
   481 	
       
   482 TAccept CReqCancelAsyncOpen::VisitStateL(CState& aState)
       
   483 	{
       
   484 	return aState.AcceptRequestL(this);
       
   485 	}
       
   486 
       
   487 
       
   488 
       
   489 /**
       
   490  CReqUpdate 
       
   491  Parent Class for CReqUpdateCnt & CReqCommitCnt
       
   492  
       
   493  @see CCntRequest constructor   
       
   494 */
       
   495 void CReqUpdate::ConstructL(CCntPackager& aPackager)
       
   496 	{
       
   497 	aPackager.SetBufferFromMessageL(iMessage);
       
   498 	iCntItem = aPackager.UnpackCntItemLC();
       
   499 	CleanupStack::Pop(iCntItem);
       
   500 	}
       
   501 
       
   502 CReqUpdate::~CReqUpdate()
       
   503 	{
       
   504 	delete iCntItem;
       
   505 	}
       
   506 
       
   507 CReqUpdate::CReqUpdate(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut)
       
   508 :CCntRequest(aSessionId, aMessage, aTimeOut)
       
   509 	{
       
   510 	}
       
   511 
       
   512 
       
   513 
       
   514 /** CReqUpdateCnt constructor
       
   515  Update a contact item - derived from CReqUpdate. Used in conjunction with CReqReadCnt. 
       
   516  Note: CReqCommitCnt is very similar to CReqUpdateCnt, but CReqCommitCnt is used with CReqOpenCnt
       
   517        and locks the contact. CReqUpdateCnt does not perform locking.
       
   518  
       
   519  @see CCntRequest constructor          
       
   520 */
       
   521 CReqUpdateCnt* CReqUpdateCnt::NewLC(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut, CCntPackager& aPackager)
       
   522 	{
       
   523 	CReqUpdateCnt* self = new (ELeave) CReqUpdateCnt(aSessionId, aMessage, aTimeOut);
       
   524 	CleanupStack::PushL(self);
       
   525 	self->ConstructL(aPackager);
       
   526 	return self;
       
   527 	}
       
   528 
       
   529 CReqUpdateCnt::CReqUpdateCnt(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut)
       
   530 :CReqUpdate(aSessionId, aMessage, aTimeOut)
       
   531 	{
       
   532 	}
       
   533 
       
   534 TAccept CReqUpdateCnt::VisitStateL(CState& aState)
       
   535 	{
       
   536 	return aState.AcceptRequestL(this);
       
   537 	}
       
   538 	
       
   539 	
       
   540 /** 
       
   541  CReqSetSpeedDial constructor
       
   542  Set a speed dial key
       
   543  
       
   544  @see CCntRequest constructor   
       
   545 */ 
       
   546 CReqSetSpeedDial* CReqSetSpeedDial::NewLC(	const TUint aSessionId, 
       
   547 									const RMessage2& aMessage, 
       
   548 									const TInt aTimeOut, 
       
   549 									CContactItemViewDef& aItemViewDef,
       
   550 									CCntServerSpeedDialManager& aSpeedDialManager,
       
   551 									const CCntServerSpeedDialTable& aTable,
       
   552 									MIniFileManager& aIniFileManager)
       
   553 	{
       
   554 	CReqSetSpeedDial* self = new (ELeave) CReqSetSpeedDial(	aSessionId, 
       
   555 															aMessage, 
       
   556 															aTimeOut, 
       
   557 															aItemViewDef,
       
   558 															aSpeedDialManager,
       
   559 															aTable,
       
   560 															aIniFileManager);
       
   561 	CleanupStack::PushL(self);
       
   562 	self->ConstructL();															
       
   563 	return self;
       
   564 	}
       
   565 
       
   566 CReqSetSpeedDial::CReqSetSpeedDial(	const TUint aSessionId, 
       
   567 									const RMessage2& aMessage, 
       
   568 									const TInt aTimeOut, 
       
   569 									CContactItemViewDef& aItemViewDef,
       
   570 									CCntServerSpeedDialManager& aSpeedDialManager,
       
   571 									const CCntServerSpeedDialTable& aTable,
       
   572 									MIniFileManager& aIniFileManager)
       
   573 :CCntRequest(aSessionId, aMessage, aTimeOut), iItemViewDef(&aItemViewDef), iSpeedDialManager(aSpeedDialManager), iTable(aTable), iIniFileManager(aIniFileManager)
       
   574 	{
       
   575 	}
       
   576 	
       
   577 void CReqSetSpeedDial::ConstructL()
       
   578 	{
       
   579 	// Read the message
       
   580 	// Read position
       
   581 	iSpeedDialIndex = iMessage.Int0();
       
   582 	// Read contact id
       
   583 	iContactId = static_cast<TContactItemId> (iMessage.Int1());
       
   584 	// Read Field Index
       
   585 	iTheFieldIndex = iMessage.Int2();	
       
   586 	}
       
   587 
       
   588 TAccept CReqSetSpeedDial::VisitStateL(CState& aState)
       
   589 	{
       
   590 	return aState.AcceptRequestL(this);
       
   591 	}
       
   592 	
       
   593 TInt CReqSetSpeedDial::SpeedDialIndex()
       
   594 	{
       
   595 	return iSpeedDialIndex;
       
   596 	}
       
   597 
       
   598 TContactItemId CReqSetSpeedDial::TheContactId()
       
   599 	{
       
   600 	return iContactId;
       
   601 	}
       
   602 
       
   603 TInt CReqSetSpeedDial::TheFieldIndex()
       
   604 	{
       
   605 	return iTheFieldIndex;	
       
   606 	}
       
   607 		
       
   608 const CContactItemViewDef& CReqSetSpeedDial::ItemViewDef()
       
   609 	{
       
   610 	return *iItemViewDef;
       
   611 	}
       
   612 	
       
   613 CCntServerSpeedDialManager& CReqSetSpeedDial::SpeedDialManager()
       
   614 	{
       
   615 	return iSpeedDialManager;	
       
   616 	}
       
   617 	
       
   618 const CCntServerSpeedDialTable& CReqSetSpeedDial::SpeedDialTable()
       
   619 	{
       
   620 	return iTable;
       
   621 	}
       
   622 	
       
   623 MIniFileManager& CReqSetSpeedDial::IniFileManager()
       
   624 	{
       
   625 	return iIniFileManager;
       
   626 	}
       
   627 
       
   628 /**
       
   629  CReqSetOwnCard constructor
       
   630  Set the own card
       
   631  
       
   632  @see CCntRequest constructor    
       
   633 */ 
       
   634 CReqSetOwnCard* CReqSetOwnCard::NewLC(	const TUint aSessionId, 
       
   635 									const RMessage2& aMessage, 
       
   636 									const TInt aTimeOut,
       
   637 									CCntPackager& aPackager, 
       
   638 									CContactItemViewDef& aItemViewDef,
       
   639 									MIniFileManager& aIniFileManager)
       
   640 	{
       
   641 	CReqSetOwnCard* self = new (ELeave) CReqSetOwnCard(	aSessionId, 
       
   642 														aMessage, 
       
   643 														aTimeOut, 
       
   644 														aItemViewDef,
       
   645 														aIniFileManager);
       
   646 	CleanupStack::PushL(self);
       
   647 	self->ConstructL(aPackager);															
       
   648 	return self;
       
   649 	}
       
   650 
       
   651 CReqSetOwnCard::CReqSetOwnCard(	const TUint aSessionId, 
       
   652 									const RMessage2& aMessage, 
       
   653 									const TInt aTimeOut, 
       
   654 									CContactItemViewDef& aItemViewDef,
       
   655 									MIniFileManager& aIniFileManager)
       
   656 :CReqUpdate(aSessionId, aMessage, aTimeOut), iItemViewDef(&aItemViewDef), iIniFileManager(aIniFileManager)
       
   657 	{
       
   658 	}
       
   659 	
       
   660 
       
   661 
       
   662 TAccept CReqSetOwnCard::VisitStateL(CState& aState)
       
   663 	{
       
   664 	return aState.AcceptRequestL(this);
       
   665 	}
       
   666 	
       
   667 TContactItemId CReqSetOwnCard::TheContactId()
       
   668 	{
       
   669 	return iContactId;
       
   670 	}
       
   671 		
       
   672 const CContactItemViewDef& CReqSetOwnCard::ItemViewDef()
       
   673 	{
       
   674 	return *iItemViewDef;
       
   675 	}
       
   676 	
       
   677 	
       
   678 MIniFileManager& CReqSetOwnCard::IniFileManager()
       
   679 	{
       
   680 	return iIniFileManager;
       
   681 	}
       
   682 	
       
   683 /** 
       
   684  CReqCommitCnt constructor
       
   685  Commit a contact item - used in conjunction with CReqOpenCnt
       
   686  Derived from CReqUpdate, and is very similar to CReqUpdateCnt but also locks the contact item
       
   687  so no other session can modify it.
       
   688  
       
   689  @see CCntRequest constructor   
       
   690 */ 
       
   691 CReqCommitCnt* CReqCommitCnt::NewLC(const TUint aSessionId, 
       
   692 									const RMessage2& aMessage, 
       
   693 									const TInt aTimeOut, 
       
   694 									CCntPackager& aPackager)
       
   695 	{
       
   696 	CReqCommitCnt* self = new (ELeave) CReqCommitCnt(aSessionId, aMessage, aTimeOut);
       
   697 	CleanupStack::PushL(self);
       
   698 	self->ConstructL(aPackager);
       
   699 	return self;
       
   700 	}
       
   701 
       
   702 CReqCommitCnt::CReqCommitCnt(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut)
       
   703 :CReqUpdate(aSessionId, aMessage, aTimeOut)
       
   704 	{
       
   705 	}
       
   706 
       
   707 TAccept CReqCommitCnt::VisitStateL(CState& aState)
       
   708 	{
       
   709 	return aState.AcceptRequestL(this);
       
   710 	}
       
   711 
       
   712 
       
   713 
       
   714 
       
   715 
       
   716 /** CReqRead constructor   
       
   717  Parent class of CReqReadCnt & CReqOpenCnt
       
   718  CReqOpenCnt and CReqReadCnt are very similar 
       
   719  CReqOpenCnt results in the contact item being locked by the session, so no other session
       
   720  can modify the contact item.
       
   721  CReqReadCnt results in no locking.
       
   722  Note: The CRequest::CompleteL method is overridden in this class
       
   723  
       
   724  @see CCntRequest constructor    
       
   725 */ 
       
   726 CReqRead::CReqRead(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut, CCntPackager& aPackager, CContactItemViewDef& aItemViewDef)
       
   727 	:CCntRequest(aSessionId, aMessage, aTimeOut), 
       
   728 	iPackager(aPackager), 
       
   729 	iItemViewDef(&aItemViewDef),
       
   730 	iViewDefCreated(EFalse)
       
   731 	{
       
   732 	}
       
   733 	
       
   734 void CReqRead::ConstructL()
       
   735 	{
       
   736 	if (iMessage.Int3())
       
   737 		{
       
   738 		iPackager.SetBufferFromMessageL(iMessage);
       
   739 		iItemViewDef = iPackager.UnpackCntItemViewDefLC();
       
   740 		iViewDefCreated = ETrue;
       
   741 		iPackager.Clear();
       
   742 		CleanupStack::Pop(iItemViewDef);
       
   743 		}
       
   744 	}
       
   745 
       
   746 CReqRead::~CReqRead()
       
   747 	{
       
   748 	if (iViewDefCreated)	// Required - determine CntItemViewdef was extracted from iMessage
       
   749 		{					// encapsulates ItemViewDef nicely. 
       
   750 		delete iItemViewDef;
       
   751 		}	
       
   752 	}
       
   753 
       
   754 const CContactItemViewDef& CReqRead::ItemViewDef()
       
   755 	{
       
   756 	return *iItemViewDef;
       
   757 	}
       
   758 
       
   759 /** Overridden CompleteL method 
       
   760  Completes the request item by packing the contact item into the RMessage slot
       
   761  and returning it to the client
       
   762  
       
   763  @param aCntItem The contact item that is returned to the client.
       
   764 */ 
       
   765 void CReqRead::CompleteL(const CContactItem& aCntItem)
       
   766 	{
       
   767 	TInt size(0);
       
   768 	TPtr8 cntItemBuff = iPackager.PackL(aCntItem, size); 
       
   769 	// Write data if client buffer is large enough
       
   770 	// otherwise return the required buffer size.
       
   771 	if(iMessage.GetDesMaxLength(1) >= size)
       
   772 		{ 
       
   773 		iMessage.WriteL(1, cntItemBuff); 
       
   774 		Complete(KErrNone);
       
   775 		}
       
   776 	else
       
   777 		{ 
       
   778 		Complete(size);	
       
   779 		}
       
   780 	}
       
   781 	
       
   782 
       
   783 /** CReqOpenCnt constructor
       
   784  Open a Contact Item - derived from CReqRead. 
       
   785  Very similar to CReqReadCnt but also results in the contact item being locked
       
   786 
       
   787  @see CReqRead constructor   
       
   788 */ 
       
   789 CReqOpenCnt* CReqOpenCnt::NewLC(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut, CCntPackager& aPackager, CContactItemViewDef& aItemViewDef)
       
   790 	{
       
   791 	CReqOpenCnt* self = new (ELeave) CReqOpenCnt(aSessionId, aMessage, aTimeOut, aPackager, aItemViewDef);
       
   792 	CleanupStack::PushL(self);
       
   793 	self->ConstructL();
       
   794 	return self;
       
   795 	}
       
   796 
       
   797 CReqOpenCnt::CReqOpenCnt(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut, CCntPackager& aPackager, CContactItemViewDef& aItemViewDef)
       
   798 	:CReqRead(aSessionId, aMessage, aTimeOut, aPackager, aItemViewDef) 
       
   799 	{
       
   800 	}
       
   801 
       
   802 CReqOpenCnt::~CReqOpenCnt()
       
   803 	{
       
   804 	}
       
   805 
       
   806 
       
   807 TAccept CReqOpenCnt::VisitStateL(CState& aState)
       
   808 	{
       
   809 	return aState.AcceptRequestL(this);
       
   810 	}
       
   811 
       
   812 
       
   813 /**
       
   814  CReqReadCnt constructor
       
   815  Read a contact item - derived from CReqRead
       
   816  Very similar to CReqOpenCnt but does not result in locking the contact item
       
   817 
       
   818  @see CReqRead constructor   
       
   819  
       
   820 */ 
       
   821 CReqReadCnt* CReqReadCnt::NewLC(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut, CCntPackager& aPackager, CContactItemViewDef& aItemViewDef)
       
   822 	{
       
   823 	CReqReadCnt* self = new (ELeave) CReqReadCnt(aSessionId, aMessage, aTimeOut, aPackager, aItemViewDef);
       
   824 	CleanupStack::PushL(self);
       
   825 	self->ConstructL();
       
   826 	return self;
       
   827 	}
       
   828 
       
   829 CReqReadCnt::CReqReadCnt(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut, CCntPackager& aPackager, CContactItemViewDef& aItemViewDef)
       
   830 	:CReqRead(aSessionId, aMessage, aTimeOut, aPackager, aItemViewDef) 
       
   831 	{
       
   832 	}
       
   833 
       
   834 CReqReadCnt::~CReqReadCnt()
       
   835 	{
       
   836 	}
       
   837 
       
   838 
       
   839 TAccept CReqReadCnt::VisitStateL(CState& aState)
       
   840 	{
       
   841 	return aState.AcceptRequestL(this);
       
   842 	}
       
   843 	
       
   844 	
       
   845 	
       
   846 /** 
       
   847  CReqDeleteCnt constructor
       
   848  Delete a contact Item
       
   849  
       
   850  @see CCntRequest constructor 
       
   851 */ 
       
   852 CReqDeleteCnt* CReqDeleteCnt::NewLC(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut)
       
   853 	{
       
   854 	CReqDeleteCnt* self = new (ELeave) CReqDeleteCnt(aSessionId, aMessage, aTimeOut);
       
   855 	CleanupStack::PushL(self);
       
   856 	return self;
       
   857 	}
       
   858 
       
   859 CReqDeleteCnt::CReqDeleteCnt(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut)
       
   860 :CCntRequest(aSessionId, aMessage, aTimeOut)
       
   861 	{
       
   862 	}
       
   863 
       
   864 CReqDeleteCnt::~CReqDeleteCnt()
       
   865 	{
       
   866 	}
       
   867 
       
   868 TAccept CReqDeleteCnt::VisitStateL(CState& aState)
       
   869 	{
       
   870 	return aState.AcceptRequestL(this);
       
   871 	}
       
   872 	
       
   873 	
       
   874 	
       
   875 	
       
   876 /** CReqCloseCnt 
       
   877  Close a contact Item - Used in conjunction with CReqOpenCnt to remove the lock on the contact item 
       
   878  without committing.
       
   879  
       
   880  @see CCntRequest constructor
       
   881 */ 
       
   882 CReqCloseCnt* CReqCloseCnt::NewLC(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut)
       
   883 	{
       
   884 	CReqCloseCnt* self = new (ELeave) CReqCloseCnt(aSessionId, aMessage, aTimeOut);
       
   885 	CleanupStack::PushL(self);
       
   886 	return self;
       
   887 	}
       
   888 
       
   889 CReqCloseCnt::CReqCloseCnt(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut)
       
   890 :CCntRequest(aSessionId, aMessage, aTimeOut)
       
   891 	{
       
   892 	}
       
   893 
       
   894 CReqCloseCnt::~CReqCloseCnt()
       
   895 	{
       
   896 	}
       
   897 
       
   898 TAccept CReqCloseCnt::VisitStateL(CState& aState)
       
   899 	{
       
   900 	return aState.AcceptRequestL(this);
       
   901 	}	
       
   902 	
       
   903 /** 
       
   904   CReqCreateCnt constructor
       
   905   Create a contact item, this request is completed with the new contact item id or an error code.
       
   906   
       
   907   @see CCntRequest constructor
       
   908 */ 
       
   909 CReqCreateCnt* CReqCreateCnt::NewLC(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut, CCntPackager& aPackager)
       
   910 	{
       
   911 	CReqCreateCnt* self = new (ELeave) CReqCreateCnt(aSessionId, aMessage, aTimeOut);
       
   912 	CleanupStack::PushL(self);
       
   913 	self->ConstructL(aPackager);
       
   914 	return self;
       
   915 	}
       
   916 
       
   917 CReqCreateCnt::CReqCreateCnt(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut)
       
   918 :CCntRequest(aSessionId, aMessage, aTimeOut)
       
   919 	{
       
   920 	}
       
   921 
       
   922 CReqCreateCnt::~CReqCreateCnt()
       
   923 	{
       
   924 	delete iCntItem;
       
   925 	}
       
   926 
       
   927 TAccept CReqCreateCnt::VisitStateL(CState& aState)
       
   928 	{
       
   929 	#if defined(__PROFILE_DEBUG__)
       
   930 		RDebug::Print(_L("[CNTMODEL] MTD: CCntStateMachine::ProcessRequestL"));
       
   931 	#endif 	
       
   932 	
       
   933 	return aState.AcceptRequestL(this);
       
   934 	}
       
   935 
       
   936 void CReqCreateCnt::ConstructL(CCntPackager& aPackager)
       
   937 	{
       
   938 	aPackager.SetBufferFromMessageL(iMessage);
       
   939 	iCntItem = aPackager.UnpackCntItemLC();
       
   940 	CleanupStack::Pop(iCntItem);
       
   941 	}
       
   942 
       
   943 
       
   944 
       
   945 
       
   946 ///////////////// Database Transactin Request Class implemenations ////////////
       
   947 
       
   948 
       
   949 /** 
       
   950  CReqDbBeginTrans constructor
       
   951  Request to begin a transaction - moves the state machine into a transaction state	
       
   952  
       
   953  @see CCntRequest constructor
       
   954 */
       
   955 CReqDbBeginTrans* CReqDbBeginTrans::NewLC(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut)
       
   956 	{
       
   957 	CReqDbBeginTrans* self = new (ELeave) CReqDbBeginTrans(aSessionId, aMessage, aTimeOut);
       
   958 	CleanupStack::PushL(self);
       
   959 	return self;
       
   960 	}
       
   961 	
       
   962 TAccept CReqDbBeginTrans::VisitStateL(CState& aState)
       
   963 	{
       
   964 	return aState.AcceptRequestL(this);
       
   965 	}
       
   966 
       
   967 
       
   968 	
       
   969 CReqDbBeginTrans::CReqDbBeginTrans(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut)
       
   970 				 :CCntRequest(aSessionId, aMessage, aTimeOut)
       
   971 	{
       
   972 	}
       
   973 
       
   974 /** 
       
   975  CReqDbCommitTrans constructor
       
   976  Request to Commit a transaction	
       
   977  Moves the database out of a transaction state and (usually) into a writable state
       
   978  
       
   979  @see CCntRequest constructor
       
   980  */
       
   981 CReqDbCommitTrans* CReqDbCommitTrans::NewLC(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut)
       
   982 	{
       
   983 	CReqDbCommitTrans* self = new (ELeave) CReqDbCommitTrans(aSessionId, aMessage, aTimeOut);
       
   984 	CleanupStack::PushL(self);
       
   985 	return self;	
       
   986 	}
       
   987 	
       
   988 TAccept CReqDbCommitTrans::VisitStateL(CState& aState)
       
   989 	{
       
   990 	return aState.AcceptRequestL(this);	
       
   991 	}
       
   992 
       
   993 CReqDbCommitTrans::CReqDbCommitTrans(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut)	
       
   994 				  :CCntRequest(aSessionId, aMessage, aTimeOut)
       
   995 
       
   996 	{
       
   997 	}
       
   998 	
       
   999 	
       
  1000 /**
       
  1001  CReqDbRollbackTrans constructor
       
  1002  Request to Rollback a transaction - results in a database recovery 
       
  1003  so it closes and re-opens the database if it has been damaged
       
  1004  
       
  1005  @see CCntRequest constructor 
       
  1006 */ 
       
  1007 CReqDbRollbackTrans* CReqDbRollbackTrans::NewLC(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut)
       
  1008 	{
       
  1009 	CReqDbRollbackTrans* self = new (ELeave) CReqDbRollbackTrans(aSessionId, aMessage, aTimeOut);
       
  1010 	CleanupStack::PushL(self);
       
  1011 	return self;	
       
  1012 	}
       
  1013 	
       
  1014 TAccept CReqDbRollbackTrans::VisitStateL(CState& aState)
       
  1015 	{
       
  1016 	return aState.AcceptRequestL(this);	
       
  1017 	}
       
  1018 
       
  1019 CReqDbRollbackTrans::CReqDbRollbackTrans(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut)
       
  1020 				    :CCntRequest(aSessionId, aMessage, aTimeOut)
       
  1021 	{
       
  1022 	}
       
  1023 
       
  1024 	
       
  1025 /** 
       
  1026  CReqBackupRestoreBegin constructor
       
  1027  Notifys the state machine that a backup/restore is beginning
       
  1028 
       
  1029  @see CCntRequest constructor 
       
  1030 */ 
       
  1031 CReqBackupRestoreBegin* CReqBackupRestoreBegin::NewLC()
       
  1032 	{
       
  1033 	CReqBackupRestoreBegin* self = new (ELeave) CReqBackupRestoreBegin();
       
  1034 	CleanupStack::PushL(self);
       
  1035 	return self;
       
  1036 	}
       
  1037 
       
  1038 TAccept CReqBackupRestoreBegin::VisitStateL(CState& aState)
       
  1039 	{
       
  1040 	return aState.AcceptRequestL(this);
       
  1041 	}
       
  1042 
       
  1043 /**
       
  1044  CReqBackupRestoreEnd constructor
       
  1045  Notifys the state machine that a restore has ended
       
  1046  
       
  1047  @see CCntRequest constructor 
       
  1048  */
       
  1049 CReqBackupRestoreEnd* CReqBackupRestoreEnd::NewLC()
       
  1050 	{
       
  1051 	CReqBackupRestoreEnd* self = new (ELeave) CReqBackupRestoreEnd();
       
  1052 	CleanupStack::PushL(self);
       
  1053 	return self;
       
  1054 	}
       
  1055 
       
  1056 TAccept CReqBackupRestoreEnd::VisitStateL(CState& aState)
       
  1057 	{
       
  1058 	return aState.AcceptRequestL(this);
       
  1059 	}
       
  1060 
       
  1061 
       
  1062 /**
       
  1063  CReqDiskSpaceLow constructor
       
  1064  @see CCntRequest constructor 
       
  1065  */
       
  1066 CReqDiskSpaceLow* CReqDiskSpaceLow::NewLC()
       
  1067 	{
       
  1068 	CReqDiskSpaceLow* self = new (ELeave) CReqDiskSpaceLow();
       
  1069 	CleanupStack::PushL(self);
       
  1070 	return self;
       
  1071 	}
       
  1072 
       
  1073 TAccept CReqDiskSpaceLow::VisitStateL(CState& aState)
       
  1074 	{
       
  1075 	return aState.AcceptRequestL(this);
       
  1076 	}
       
  1077 
       
  1078 
       
  1079 /** 
       
  1080  CReqDiskSpaceNormal constructor
       
  1081  @see CCntRequest constructor
       
  1082 */
       
  1083 CReqDiskSpaceNormal* CReqDiskSpaceNormal::NewLC()
       
  1084 	{
       
  1085 	CReqDiskSpaceNormal* self = new (ELeave) CReqDiskSpaceNormal();
       
  1086 	CleanupStack::PushL(self);
       
  1087 	return self;
       
  1088 	}
       
  1089 
       
  1090 TAccept CReqDiskSpaceNormal::VisitStateL(CState& aState)
       
  1091 	{
       
  1092 	return aState.AcceptRequestL(this);
       
  1093 	}
       
  1094 
       
  1095 
       
  1096 /**
       
  1097  CReqAsyncActivity constructor
       
  1098  @see CCntRequest constructor 
       
  1099  */
       
  1100 CReqAsyncActivity* CReqAsyncActivity::NewLC(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut)
       
  1101 	{
       
  1102 	CReqAsyncActivity* self = new (ELeave) CReqAsyncActivity(aSessionId, aMessage, aTimeOut);
       
  1103 	CleanupStack::PushL(self);
       
  1104 	return self;
       
  1105 	}
       
  1106 
       
  1107 CReqAsyncActivity::CReqAsyncActivity(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut )
       
  1108 : CCntRequest(aSessionId, aMessage, aTimeOut)
       
  1109 	{
       
  1110 	}
       
  1111 
       
  1112 TAccept CReqAsyncActivity::VisitStateL(CState& aState)
       
  1113 	{
       
  1114 	return aState.AcceptRequestL(this);
       
  1115 	}
       
  1116 
       
  1117 
       
  1118 /** 
       
  1119  CReqNoAsyncActivity constructor
       
  1120  @see CCntRequest constructor
       
  1121 */
       
  1122 CReqNoAsyncActivity* CReqNoAsyncActivity::NewLC(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut)
       
  1123 	{
       
  1124 	CReqNoAsyncActivity* self = new (ELeave) CReqNoAsyncActivity(aSessionId, aMessage, aTimeOut);
       
  1125 	CleanupStack::PushL(self);
       
  1126 	return self;
       
  1127 	}
       
  1128 
       
  1129 CReqNoAsyncActivity::CReqNoAsyncActivity(const TUint aSessionId, const RMessage2& aMessage, const TInt aTimeOut )
       
  1130 : CCntRequest(aSessionId, aMessage, aTimeOut)
       
  1131 	{
       
  1132 	}
       
  1133 
       
  1134 TAccept CReqNoAsyncActivity::VisitStateL(CState& aState)
       
  1135 	{
       
  1136 	return aState.AcceptRequestL(this);
       
  1137 	}
       
  1138 
       
  1139 /**
       
  1140   CReqInternalSessionUnlock constructor
       
  1141   CReqInternalSessionUnlock unlocks all remaining locked contact items when
       
  1142   a session closes. It is called from the session class destructor
       
  1143   
       
  1144   @see CCntReqInternal constructor  	
       
  1145 */
       
  1146 CReqInternalSessionUnlock* CReqInternalSessionUnlock::NewLC(TInt aSessionId)
       
  1147 	{
       
  1148 	CReqInternalSessionUnlock* self = new (ELeave) CReqInternalSessionUnlock(aSessionId);
       
  1149 	CleanupStack::PushL(self);
       
  1150 	return self;		
       
  1151 	}
       
  1152 	
       
  1153 TAccept CReqInternalSessionUnlock::VisitStateL(CState& aState)
       
  1154 	{
       
  1155 	return aState.AcceptRequestL(this);		
       
  1156 	}
       
  1157 
       
  1158 	
       
  1159 /////////////////////////CReqInternalAsyncOpen ////////////////////	
       
  1160 // Similar to CReqAsyncOpen but the request originates from inside the server.
       
  1161 CReqInternalAsyncOpen* CReqInternalAsyncOpen::NewLC(const TUint aSessionId, const TDesC& aFileName, TRequestStatus& aStatus)
       
  1162 	{
       
  1163 	CReqInternalAsyncOpen* self = new (ELeave) CReqInternalAsyncOpen(aSessionId, aFileName, aStatus);
       
  1164 	CleanupStack::PushL(self);
       
  1165 	self->ConstructL();
       
  1166 	return self;
       
  1167 	}
       
  1168 	
       
  1169 CReqInternalAsyncOpen::CReqInternalAsyncOpen(const TUint aSessionId, const TDesC& aFileName, TRequestStatus& aStatus)
       
  1170  : CReqAsyncOpen(aSessionId), iStatus(&aStatus)
       
  1171 	{
       
  1172 	iFilename = aFileName;
       
  1173 	}
       
  1174 
       
  1175 void CReqInternalAsyncOpen::ConstructL()
       
  1176 	{
       
  1177 	*iStatus = KRequestPending;	
       
  1178 	}
       
  1179 
       
  1180 void CReqInternalAsyncOpen::Complete(TInt aErrorCode)
       
  1181 	{
       
  1182 	User::RequestComplete(iStatus, aErrorCode);
       
  1183 	}
       
  1184 
       
  1185 /////////////////////////CReqCancelInternalAsyncOpen ////////////////////	
       
  1186 // Similar to CReqCancelAsyncOpen but the request originates from inside the server,
       
  1187 // so there is no need to signal a RMessage that the request has completed
       
  1188 CReqCancelInternalAsyncOpen* CReqCancelInternalAsyncOpen::NewLC(const TUint aSessionId)
       
  1189 	{
       
  1190 	CReqCancelInternalAsyncOpen* self = new (ELeave) CReqCancelInternalAsyncOpen(aSessionId);
       
  1191 	CleanupStack::PushL(self);
       
  1192 	return self;	
       
  1193 	}
       
  1194 	
       
  1195 void CReqCancelInternalAsyncOpen::Complete(TInt /*errorCode*/)
       
  1196 	{
       
  1197 	}
       
  1198