connectionutilities/ConnectionDialogs/src/ConnectionInfoKey.cpp
changeset 0 5a93021fdf25
child 41 bbb64eb3bdee
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     1 /*
       
     2 * Copyright (c) 2005 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:  Implementation of class CConnectionInfoKey.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "ConnectionInfoKey.h"
       
    21 #include "ConnectionInfo.h"
       
    22 
       
    23 
       
    24 // ================= MEMBER FUNCTIONS =======================
       
    25 //
       
    26 // ---------------------------------------------------------
       
    27 // CConnectionInfoKey::CConnectionInfoKey()
       
    28 // ---------------------------------------------------------
       
    29 //
       
    30 CConnectionInfoKey::CConnectionInfoKey( TBool aIsWLANFeatureSupported )
       
    31 : TKeyArrayFix( 0, ECmpCollated ),
       
    32   iIsWLANFeatureSupported( aIsWLANFeatureSupported )
       
    33     {
       
    34     }
       
    35 
       
    36 
       
    37 // ---------------------------------------------------------
       
    38 // CConnectionInfoKey::~CConnectionInfoKey()
       
    39 // ---------------------------------------------------------
       
    40 //
       
    41 CConnectionInfoKey::~CConnectionInfoKey()
       
    42     {
       
    43     if ( iIsWLANFeatureSupported )
       
    44         {
       
    45         delete iNameEasyWLAN;
       
    46         }
       
    47     }
       
    48 
       
    49 
       
    50 // ---------------------------------------------------------
       
    51 // CConnectionInfoKey::NewL()
       
    52 // ---------------------------------------------------------
       
    53 //
       
    54 CConnectionInfoKey* CConnectionInfoKey::NewL( TDesC &aNameEasyWLAN )
       
    55     {
       
    56     CConnectionInfoKey* self = new (ELeave) CConnectionInfoKey( ETrue );
       
    57     CleanupStack::PushL( self );
       
    58     self->ConstructL( aNameEasyWLAN );
       
    59     CleanupStack::Pop( self );
       
    60 
       
    61     return self;
       
    62     }
       
    63 
       
    64 
       
    65 // ---------------------------------------------------------
       
    66 // CConnectionInfoKey::ConstructL()
       
    67 // ---------------------------------------------------------
       
    68 //
       
    69 void CConnectionInfoKey::ConstructL( TDesC &aNameEasyWLAN )
       
    70     {
       
    71     iNameEasyWLAN = aNameEasyWLAN.AllocL();
       
    72     }
       
    73 
       
    74 
       
    75 // ---------------------------------------------------------
       
    76 // CConnectionInfoKey::NewL()
       
    77 // ---------------------------------------------------------
       
    78 //
       
    79 CConnectionInfoKey* CConnectionInfoKey::NewL()
       
    80     {
       
    81     CConnectionInfoKey* self = new (ELeave) CConnectionInfoKey( EFalse );
       
    82     CleanupStack::PushL( self );
       
    83     self->ConstructL();
       
    84     CleanupStack::Pop( self );
       
    85 
       
    86     return self;
       
    87     }
       
    88 
       
    89 
       
    90 // ---------------------------------------------------------
       
    91 // CConnectionInfoKey::ConstructL()
       
    92 // ---------------------------------------------------------
       
    93 //
       
    94 void CConnectionInfoKey::ConstructL()
       
    95     {
       
    96     }
       
    97 
       
    98 
       
    99 
       
   100 // ---------------------------------------------------------
       
   101 // CConnectionInfoKey::SetPtr( CArrayPtrFlat<CConnectionInfo>* aPtr )
       
   102 // ---------------------------------------------------------
       
   103 //
       
   104 void CConnectionInfoKey::SetPtr( CArrayPtrFlat<CConnectionInfo>* aPtr )
       
   105     {
       
   106     iPtr = aPtr;
       
   107     }
       
   108 
       
   109 
       
   110 // ---------------------------------------------------------
       
   111 // CConnectionInfoKey::Compare( TInt aLeft, TInt aRight ) const
       
   112 // ---------------------------------------------------------
       
   113 //
       
   114 TInt CConnectionInfoKey::Compare( TInt aLeft, TInt aRight ) const
       
   115     {
       
   116     TInt retval;
       
   117 
       
   118     if ( iIsWLANFeatureSupported &&
       
   119          ! iPtr->At( aLeft )->Name().CompareC( *iNameEasyWLAN ) )
       
   120         {
       
   121         retval = -1;
       
   122         }
       
   123     else if ( iIsWLANFeatureSupported &&
       
   124               ! iPtr->At( aRight )->Name().CompareC( *iNameEasyWLAN ) )
       
   125         {
       
   126         retval = 1;
       
   127         }
       
   128     else
       
   129         {
       
   130         retval = iPtr->At( aLeft )->Name().CompareC( 
       
   131                                                 iPtr->At( aRight )->Name() );
       
   132         }
       
   133 
       
   134     return retval;
       
   135     }
       
   136 
       
   137 
       
   138 // ---------------------------------------------------------
       
   139 // CConnectionInfoKey::At( TInt anIndex ) const
       
   140 // ---------------------------------------------------------
       
   141 //
       
   142 TAny* CConnectionInfoKey::At( TInt anIndex ) const
       
   143     {
       
   144     TDesC16 tem( iPtr->At( anIndex )->Name() );
       
   145     TAny* ptr = ( TAny* )&tem;
       
   146 
       
   147     return ptr;
       
   148     }
       
   149 
       
   150 
       
   151 // End of File