wim/WimServer/src/WimSessionRegistry.cpp
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2003-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:  Registry of WimServer sessions
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "WimSessionRegistry.h"
       
    22 #include    "WimTrace.h"
       
    23 
       
    24 
       
    25 // ============================ MEMBER FUNCTIONS ===============================
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 // C++ default constructor can NOT contain any code, that
       
    29 // might leave.
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 CWimSessionRegistry::CWimSessionRegistry()
       
    33     {
       
    34     _WIMTRACE(_L("WIM | WIMServer | CWimSessionRegistry::CWimSessionRegistry | Begin"));
       
    35     }
       
    36 
       
    37 // Destructor
       
    38 CWimSessionRegistry::~CWimSessionRegistry()
       
    39     {
       
    40     _WIMTRACE(_L("WIM | WIMServer | CWimSessionRegistry::~CWimSessionRegistry | Begin"));
       
    41     iSessions.Close();
       
    42     }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CWimSessionRegistry::NewL
       
    46 // Two-phased constructor.
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 CWimSessionRegistry* CWimSessionRegistry::NewL()
       
    50     {
       
    51     _WIMTRACE(_L("WIM | WIMServer | CWimSessionRegistry::NewL | Begin"));
       
    52     CWimSessionRegistry* self = new( ELeave ) CWimSessionRegistry();
       
    53     CleanupStack::PushL( self );
       
    54     self->ConstructL();
       
    55     CleanupStack::Pop( self );
       
    56     return self;
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CWimSessionRegistry::ConstructL
       
    61 // Symbian 2nd phase constructor can leave.
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 void CWimSessionRegistry::ConstructL()
       
    65     {
       
    66     _WIMTRACE(_L("WIM | WIMServer | CWimSessionRegistry::ConstructL | Begin"));
       
    67     }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CWimSessionRegistry::AddSession
       
    71 // Add session to array
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 void CWimSessionRegistry::AddSessionL( CWimSession* aSession )
       
    75     {
       
    76     _WIMTRACE(_L("WIM | WIMServer | CWimSessionRegistry::AddSessionL | Begin"));
       
    77     iSessions.AppendL( aSession );
       
    78     }
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // CWimSessionRegistry::GetSessionsL
       
    82 // Get array of sessions
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 void CWimSessionRegistry::GetSessionsL( RArray<CWimSession*>& aSessions ) const
       
    86     {
       
    87     _WIMTRACE(_L("WIM | WIMServer | CWimSessionRegistry::GetSessionsL | Begin"));
       
    88     TInt count = iSessions.Count();
       
    89     for( TInt i = 0; i < count; ++i )
       
    90         {
       
    91         aSessions.AppendL( iSessions[ i ] );
       
    92         }
       
    93     }
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // CWimSessionRegistry::RemoveSession
       
    97 // Remove session from array
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 void CWimSessionRegistry::RemoveSession( CWimSession* aSession )
       
   101     {
       
   102     _WIMTRACE(_L("WIM | WIMServer | CWimSessionRegistry::RemoveSession | Begin"));
       
   103 	TInt sessionCount = iSessions.Count();
       
   104     for( TInt i = 0; i < sessionCount; ++i )
       
   105         {
       
   106         if( iSessions[ i ] == aSession )
       
   107             {
       
   108             iSessions.Remove( i );
       
   109             break;
       
   110             }
       
   111         }
       
   112     iSessions.Compress();
       
   113     }
       
   114 
       
   115 // End of File