wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlanssidlist.cpp
changeset 0 c40eb8fe8501
equal deleted inserted replaced
-1:000000000000 0:c40eb8fe8501
       
     1 /*
       
     2 * Copyright (c) 2007-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 the License "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:  Class implementing storage for an SSID list.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "wlanssidlist.h"
       
    20 #include "am_debug.h"
       
    21 
       
    22 // ======== MEMBER FUNCTIONS ========
       
    23 
       
    24 // ---------------------------------------------------------------------------
       
    25 // ---------------------------------------------------------------------------
       
    26 //
       
    27 CWlanSsidList::CWlanSsidList(
       
    28     TUint aGranularity ) :
       
    29     iSsidList( aGranularity ),
       
    30     iLinearOrder( &CWlanSsidList::LinearOrder )
       
    31     {
       
    32     }
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 void CWlanSsidList::ConstructL()
       
    38     {
       
    39     }
       
    40 
       
    41 // ---------------------------------------------------------------------------
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 CWlanSsidList* CWlanSsidList::NewL(
       
    45     TUint aGranularity )
       
    46     {
       
    47     CWlanSsidList* self = new (ELeave)CWlanSsidList( aGranularity );
       
    48     CleanupStack::PushL( self );
       
    49     self->ConstructL();
       
    50     CleanupStack::Pop( self );
       
    51     return self;
       
    52     }
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // ---------------------------------------------------------------------------
       
    56 //
       
    57 CWlanSsidList::~CWlanSsidList()
       
    58     {
       
    59     iSsidList.Close();
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 TInt CWlanSsidList::AddSsid(
       
    66     const TWlanSsid& aSsid )
       
    67     {
       
    68     if( !aSsid.Length() )
       
    69         {
       
    70         return KErrArgument;
       
    71         }
       
    72 
       
    73     /**
       
    74      * Silently ignore KErrAlreadyExists since the list may contain
       
    75      * duplicate entries.
       
    76      */
       
    77     TInt ret = iSsidList.InsertInOrder(
       
    78         aSsid,
       
    79         iLinearOrder );
       
    80     if( ret == KErrAlreadyExists )
       
    81         {
       
    82         return KErrNone;
       
    83         }
       
    84 
       
    85     return ret;
       
    86     }
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 TBool CWlanSsidList::IsInList(
       
    92     const TWlanSsid& aSsid ) const
       
    93     {
       
    94     return (iSsidList.FindInOrder(
       
    95         aSsid,
       
    96         iLinearOrder ) >= 0 );
       
    97     }
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 TUint CWlanSsidList::Count() const
       
   103     {
       
   104     return iSsidList.Count();
       
   105     }
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // ---------------------------------------------------------------------------
       
   109 //
       
   110 void CWlanSsidList::ExternalizeL(
       
   111     RWriteStream& aStream) const
       
   112     {
       
   113     aStream.WriteInt32L( iSsidList.Count() );
       
   114     for( TInt idx( 0 ); idx < iSsidList.Count(); ++idx )
       
   115         {
       
   116         aStream.WriteInt8L(
       
   117             iSsidList[idx].Length() );
       
   118         aStream.WriteL(
       
   119             iSsidList[idx] );        
       
   120         }        
       
   121     }
       
   122 
       
   123 // ---------------------------------------------------------------------------
       
   124 // ---------------------------------------------------------------------------
       
   125 //
       
   126 void CWlanSsidList::InternalizeL(
       
   127     RReadStream& aStream )
       
   128     {    
       
   129     TInt count( 
       
   130         aStream.ReadInt32L() );
       
   131     TWlanSsid ssid;
       
   132 
       
   133     for( TInt idx( 0 ); idx < count; ++idx )
       
   134         {
       
   135         aStream.ReadL(
       
   136             ssid, aStream.ReadInt8L() );
       
   137         iSsidList.Append(
       
   138             ssid );
       
   139         }
       
   140     }
       
   141 
       
   142 // ---------------------------------------------------------------------------
       
   143 // ---------------------------------------------------------------------------
       
   144 //
       
   145 TInt CWlanSsidList::LinearOrder(
       
   146     const TWlanSsid& aLeft,
       
   147     const TWlanSsid& aRight )
       
   148     {
       
   149 #if 0
       
   150     TBuf<KWlanMaxSsidLength> leftBuf;
       
   151     TBuf<KWlanMaxSsidLength> rightBuf;
       
   152     leftBuf.Copy( aLeft );
       
   153     rightBuf.Copy( aRight );
       
   154     DEBUG2( "LinearOrder() - aLeft: %S, aRight: %S",
       
   155         &leftBuf, &rightBuf );
       
   156 #endif // 0
       
   157 
       
   158     return aLeft.Compare( aRight );
       
   159     }
       
   160