telephonyserverplugins/simatktsy/src/CSatTsyReqHandleStore.cpp
changeset 0 3553901f7fa8
child 19 630d2f34d719
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Name        : CSatTsyReqHandleStore.cpp
       
    15 // Part of     : Common SIM ATK TSY / commonsimatktsy
       
    16 // Implementation of CSatTsyReqHandleStore class member functions.
       
    17 // Version     : 1.0
       
    18 //
       
    19 
       
    20 
       
    21 
       
    22 //  INCLUDE FILES
       
    23 #include "CSatTsyReqHandleStore.h"  // Class header
       
    24 #include "CSatTsy.h"                // Main tsy class header
       
    25 #include "TfLogger.h"               // For TFLOGSTRING
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 // CSatTsyReqHandleStore::NewL
       
    29 // This method is used to create a new instance of CSatTsyReqHandleStore. 
       
    30 // Because the constructor of CSatTsyReqHandleStore class is private, calling 
       
    31 // this method is the only possible way to make new CSatTsyReqHandleStore object.
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CSatTsyReqHandleStore* CSatTsyReqHandleStore::NewL
       
    35         (
       
    36         TInt aNumberOfRequests,      // Number of requests
       
    37         TTsyReqHandle* aFirstElement // Pointer to the first element
       
    38         )
       
    39     {
       
    40     TFLOGSTRING( "CSAT: CSatTsyReqHandleStore::NewL" );
       
    41     CSatTsyReqHandleStore* tsyReqHandleStore = new ( ELeave ) 
       
    42         CSatTsyReqHandleStore();
       
    43  
       
    44     CleanupStack::PushL( tsyReqHandleStore );
       
    45     tsyReqHandleStore->iNumOfRequests = aNumberOfRequests;   
       
    46     tsyReqHandleStore->iReqHandles = aFirstElement;
       
    47 
       
    48     // Check that array is really initialised and reset it at the same time
       
    49     for ( TInt i = 0; i < aNumberOfRequests; i++ )
       
    50         {
       
    51         *( tsyReqHandleStore->iReqHandles + i ) = 0;
       
    52         }
       
    53 
       
    54     CleanupStack::Pop( tsyReqHandleStore );
       
    55     TFLOGSTRING( "CSAT: CSatTsyReqHandleStore::NewL, end of method" );
       
    56     return tsyReqHandleStore;
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CSatTsyReqHandleStore::~CSatTsyReqHandleStore
       
    61 // Destructor. Deletes all entries from the CResponseTimerStore related with 
       
    62 // this handle store
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 CSatTsyReqHandleStore::~CSatTsyReqHandleStore
       
    66         (
       
    67         // None
       
    68         )
       
    69     {
       
    70     TFLOGSTRING( "CSAT: CSatTsyReqHandleStore::~CSatTsyReqHandleStore" );
       
    71     }
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // CSatTsyReqHandleStore::CSatTsyReqHandleStore
       
    75 // Constructor
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 CSatTsyReqHandleStore::CSatTsyReqHandleStore
       
    79         (
       
    80         // None
       
    81         )
       
    82     {
       
    83     TFLOGSTRING( "CSAT: CSatTsyReqHandleStore::CSatTsyReqHandleStore" );
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CSatTsyReqHandleStore::ConstructL
       
    88 // Symbian 2nd phase constructor. 
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 void CSatTsyReqHandleStore::ConstructL
       
    92         ( 
       
    93         // None
       
    94         )
       
    95     {
       
    96     TFLOGSTRING( "CSAT: CSatTsyReqHandleStore::ConstructL" );
       
    97     }
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // CSatTsyReqHandleStore::TsyReqHandle
       
   101 // Returns TSY request handle for given index.
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 TTsyReqHandle CSatTsyReqHandleStore::TsyReqHandle
       
   105         (
       
   106         const TInt aIndex  // TSY req handle index
       
   107         )
       
   108     {
       
   109     TFLOGSTRING( "CSAT: CSatTsyReqHandleStore::TsyReqHandle" );
       
   110     TTsyReqHandle ret( NULL );
       
   111 
       
   112     // Check the bounds
       
   113     if ( ( aIndex >= 0 ) && ( aIndex < iNumOfRequests ) )
       
   114         {
       
   115         ret = *( iReqHandles + aIndex );
       
   116         }
       
   117     else
       
   118         {
       
   119         TFLOGSTRING( "CSAT: CSatTsyReqHandleStore::TsyReqHandle, \
       
   120             Out of bounds" );
       
   121         }
       
   122     return ret;
       
   123     }
       
   124 
       
   125 // -----------------------------------------------------------------------------
       
   126 // CSatTsyReqHandleStore::SetTsyReqHandle
       
   127 // Sets TSY request handle for given index.
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 void CSatTsyReqHandleStore::SetTsyReqHandle
       
   131         (    
       
   132         const TInt            aIndex,         // Index
       
   133         const TTsyReqHandle   aTsyReqHandle   // Request handle
       
   134         )
       
   135     {
       
   136     TFLOGSTRING( "CSAT: CSatTsyReqHandleStore::SetTsyReqHandle" );
       
   137     if ( ( aIndex >= 0 ) && ( aIndex < iNumOfRequests ) )
       
   138         {
       
   139         *( iReqHandles + aIndex ) = aTsyReqHandle;
       
   140         TFLOGSTRING2( "CSAT: CSatTsyReqHandleStore::SetTsyReqHandle, %d saved", 
       
   141             aTsyReqHandle );
       
   142         }
       
   143     else
       
   144         {
       
   145         TFLOGSTRING( "CSAT: CSatTsyReqHandleStore::SetTsyReqHandle,\
       
   146             Request handle not saved" );
       
   147         }
       
   148     }
       
   149 
       
   150 // -----------------------------------------------------------------------------
       
   151 // CSatTsyReqHandleStore::ResetTsyReqHandle
       
   152 // Resets TSY req handle of given index and also returns it. If automatic 
       
   153 // response is in use it deletes the entry for the given index in the 
       
   154 // CResponseTimerStore.
       
   155 // -----------------------------------------------------------------------------
       
   156 //
       
   157 TTsyReqHandle CSatTsyReqHandleStore::ResetTsyReqHandle
       
   158         (    
       
   159         const TInt aIndex   // Index
       
   160         )
       
   161     {
       
   162 
       
   163     TFLOGSTRING( "CSAT: CSatTsyReqHandleStore::ResetTsyReqHandle" );
       
   164     // Req handle was not used.
       
   165     TInt ret = 0;
       
   166 
       
   167     if ( ( aIndex >= 0 ) && ( aIndex < iNumOfRequests ) )
       
   168         {
       
   169         // If req handle is currently used
       
   170         if( *( iReqHandles + aIndex ) != 0 )
       
   171             {
       
   172             // Return deleted req handle
       
   173             ret = *( iReqHandles + aIndex );
       
   174 
       
   175             // Reset req handle
       
   176             *( iReqHandles + aIndex ) = 0;
       
   177             TFLOGSTRING2( "CSAT: CSatTsyReqHandleStore::ResetTsyReqHandle, index \
       
   178             	%d removed", aIndex );
       
   179             }
       
   180         else
       
   181             {
       
   182             TFLOGSTRING("CSAT: CSatTsyReqHandleStore::ResetTsyReqHandle,\
       
   183                 Not in use");
       
   184             }
       
   185         }
       
   186     else
       
   187         {
       
   188         // Do nothing    
       
   189         }
       
   190             
       
   191 	TFLOGSTRING2("CSAT: CSatTsyReqHandleStore::ResetTsyReqHandle \
       
   192 	    reqHandle is :%d", ret ); 
       
   193 		
       
   194     return ret;
       
   195     }
       
   196 
       
   197 //  End of File 
       
   198 
       
   199 
       
   200 
       
   201