uiservicetab/vimpstengine/src/cvimpstenginerequestmapper.cpp
changeset 0 5e5d6b214f4f
child 9 9fdee5e1da30
equal deleted inserted replaced
-1:000000000000 0:5e5d6b214f4f
       
     1 /*
       
     2 * Copyright (c) 2008 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: Request mapper for VIMSTEngine
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 
       
    20 #include "cvimpstenginerequestmapper.h"
       
    21 
       
    22 #include "cvimpstenginerequest.h"
       
    23 #include "vimpstdebugtrace.h"
       
    24 
       
    25 // ---------------------------------------------------------
       
    26 // CVIMPSTEngineRequestMapper::two phase constructor
       
    27 // 
       
    28 // ---------------------------------------------------------	
       
    29 CVIMPSTEngineRequestMapper* CVIMPSTEngineRequestMapper:: NewL()
       
    30 	{
       
    31 	CVIMPSTEngineRequestMapper* self = CVIMPSTEngineRequestMapper::NewLC();
       
    32 	CleanupStack::Pop( self );
       
    33 	return self;
       
    34 	}
       
    35 
       
    36 // ---------------------------------------------------------
       
    37 // CVIMPSTEngineRequestMapper::NewLC
       
    38 // 
       
    39 // ---------------------------------------------------------	
       
    40 CVIMPSTEngineRequestMapper* CVIMPSTEngineRequestMapper::NewLC()
       
    41 	{
       
    42 	CVIMPSTEngineRequestMapper* self = new (ELeave) CVIMPSTEngineRequestMapper();
       
    43 	CleanupStack::PushL( self );
       
    44 	return self;	
       
    45 	}
       
    46 
       
    47 // ---------------------------------------------------------
       
    48 // CVIMPSTEngineRequestMapper::~CVIMPSTEngineRequestMapper
       
    49 // 
       
    50 // ---------------------------------------------------------	
       
    51 CVIMPSTEngineRequestMapper::~CVIMPSTEngineRequestMapper()
       
    52 	{
       
    53 	iRequestArray.ResetAndDestroy();	
       
    54 	}
       
    55 
       
    56 
       
    57 // ---------------------------------------------------------
       
    58 // CVIMPSTEngineRequestMapper::CVIMPSTEngineRequestMapper
       
    59 // 
       
    60 // ---------------------------------------------------------	
       
    61 CVIMPSTEngineRequestMapper::CVIMPSTEngineRequestMapper()
       
    62 	{
       
    63 		
       
    64 	}
       
    65 
       
    66 // ---------------------------------------------------------
       
    67 // CVIMPSTEngineRequestMapper::CreateRequestL
       
    68 // 
       
    69 // ---------------------------------------------------------	
       
    70 CVIMPSTEngineRequest* CVIMPSTEngineRequestMapper::CreateRequestL
       
    71 											(TXIMPRequestId& aRequestId, 
       
    72 											TBool aIsWait, TXimpOperation aType)
       
    73 	{
       
    74 	CVIMPSTEngineRequest* req = CVIMPSTEngineRequest::NewL(aRequestId,aType );
       
    75 	CleanupStack::PushL(req);	
       
    76 	TInt status( iRequestArray.Append( req ) );
       
    77 	User::LeaveIfError( status );
       
    78 		
       
    79 	if(aIsWait)
       
    80 		{
       
    81 		req->StartWait();	
       
    82 		}
       
    83 
       
    84 
       
    85 	CleanupStack::Pop(req);
       
    86 	return req;
       
    87 	}
       
    88 
       
    89 // ---------------------------------------------------------
       
    90 // CVIMPSTEngineRequestMapper::FindRequestId
       
    91 // 
       
    92 // ---------------------------------------------------------		
       
    93 CVIMPSTEngineRequest* CVIMPSTEngineRequestMapper::FindRequestId(const TXIMPRequestId& aRequestId )
       
    94 	{
       
    95 	TInt count = iRequestArray.Count() ;
       
    96 	TXIMPRequestId reqId ;
       
    97 	CVIMPSTEngineRequest *req = NULL;
       
    98 	for (TInt i=0; i < count; i++)
       
    99 		{
       
   100 		req = iRequestArray[i] ;
       
   101 		
       
   102 		reqId = req->GetRequestId() ;
       
   103 		
       
   104 		if( aRequestId == reqId )			
       
   105 			{
       
   106 			break ;
       
   107 			}
       
   108 		}
       
   109 	return req ;
       
   110 	}
       
   111 
       
   112 // ---------------------------------------------------------
       
   113 // CVIMPSTEngineRequestMapper::RemoveRequestId
       
   114 // 
       
   115 // ---------------------------------------------------------		
       
   116 void CVIMPSTEngineRequestMapper::RemoveRequestId(const TXIMPRequestId& aRequestId )
       
   117     {
       
   118     TInt count = iRequestArray.Count() ;
       
   119     for (TInt i=0; i < count; i++)
       
   120         {
       
   121         if( iRequestArray[i]->GetRequestId() == aRequestId)         
       
   122             {
       
   123             delete iRequestArray[i];
       
   124             iRequestArray[i] = NULL;
       
   125             iRequestArray.Remove( i );
       
   126             iRequestArray.Compress();
       
   127             break ;
       
   128             }
       
   129         }
       
   130     }
       
   131 
       
   132 	
       
   133 // end of file