wlanutilities/wlansniffer/wlaninfosorting/src/wsfwlaninfosortingdefault.cpp
branchRCL_3
changeset 24 63be7eb3fc78
parent 23 b852595f5cbe
child 25 f28ada11abbf
equal deleted inserted replaced
23:b852595f5cbe 24:63be7eb3fc78
     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 "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 CWsfWlanInfoSortingDefault
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 //  CLASS HEADER
       
    21 #include "wsfwlaninfosortingdefault.h"
       
    22 
       
    23 // INTERNAL INCLUDES
       
    24 #include "wsfwlaninfo.h"
       
    25 
       
    26 
       
    27 /**
       
    28 * Compare result: left-hand item goes first
       
    29 */
       
    30 static const TInt KLeftFirst = -1;
       
    31 
       
    32 /**
       
    33 * Compare result: right-hand item goes first
       
    34 */
       
    35 static const TInt KRightFirst = 1;
       
    36 
       
    37 
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // CWsfWlanInfoSortingDefault::NewLC
       
    41 // ---------------------------------------------------------------------------
       
    42 //    
       
    43 CWsfWlanInfoSortingDefault* CWsfWlanInfoSortingDefault::NewLC()
       
    44 	{
       
    45 	CWsfWlanInfoSortingDefault* thisPtr = 
       
    46 	                                 new (ELeave) CWsfWlanInfoSortingDefault();
       
    47 	CleanupStack::PushL( thisPtr );
       
    48 	thisPtr->ConstructL();
       
    49 	return thisPtr;
       
    50 	}
       
    51 
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // CWsfWlanInfoSortingDefault::NewL
       
    55 // ---------------------------------------------------------------------------
       
    56 //    
       
    57 CWsfWlanInfoSortingDefault* CWsfWlanInfoSortingDefault::NewL()
       
    58 	{
       
    59 	CWsfWlanInfoSortingDefault* thisPtr = NewLC();
       
    60 	CleanupStack::Pop( thisPtr );
       
    61 	return thisPtr;
       
    62 	}
       
    63 
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // CWsfWlanInfoSortingDefault::CWsfWlanInfoSortingDefault
       
    67 // ---------------------------------------------------------------------------
       
    68 //    
       
    69 CWsfWlanInfoSortingDefault::CWsfWlanInfoSortingDefault()
       
    70 	{
       
    71 	}
       
    72 
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // CWsfWlanInfoSortingDefault::~CWsfWlanInfoSortingDefault
       
    76 // ---------------------------------------------------------------------------
       
    77 //    
       
    78 CWsfWlanInfoSortingDefault::~CWsfWlanInfoSortingDefault()
       
    79 	{
       
    80 	}
       
    81 
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // CWsfWlanInfoSortingDefault::ConstructL
       
    85 // ---------------------------------------------------------------------------
       
    86 //    
       
    87 void CWsfWlanInfoSortingDefault::ConstructL()
       
    88 	{
       
    89 	}
       
    90 
       
    91 
       
    92 // ---------------------------------------------------------------------------
       
    93 // CWsfWlanInfoSortingDefault::Compare
       
    94 // ---------------------------------------------------------------------------
       
    95 //    
       
    96 TInt CWsfWlanInfoSortingDefault::Compare( const TWsfWlanInfo& aLeft, 
       
    97                                           const TWsfWlanInfo& aRight )
       
    98 	{
       
    99 	TInt ret( 0 );
       
   100 	
       
   101     // connected goes first 
       
   102  	if ( aLeft.Connected() )
       
   103  	    {
       
   104  	    ret = KLeftFirst;
       
   105  	    }
       
   106  	else if ( aRight.Connected() )
       
   107  	    {
       
   108  	    ret = KRightFirst;
       
   109  	    }
       
   110  	
       
   111  	// then customer favourite networks
       
   112  	else if ( aLeft.BrandId() )
       
   113  	    {
       
   114  	    if ( aRight.BrandId() )
       
   115  	        {
       
   116  	        // smaller brand id first
       
   117  	        ret = aLeft.BrandId() - aRight.BrandId();
       
   118  	        }
       
   119  	    else
       
   120  	        {
       
   121  	        ret = KLeftFirst;
       
   122  	        }
       
   123  	    }
       
   124  	else if ( aRight.BrandId() )
       
   125  	    {
       
   126  	    ret = KRightFirst;
       
   127  	    }
       
   128  	
       
   129  	
       
   130  	// then known networks
       
   131  	else if ( aLeft.Known() && !aRight.Known() )
       
   132  	    {
       
   133  	    ret = KLeftFirst;
       
   134  	    }
       
   135  	else if ( !aLeft.Known() && aRight.Known() )
       
   136  	    {
       
   137  	    ret = KRightFirst;
       
   138  	    }
       
   139  	    
       
   140  	// finally SSID alphabetic order decides
       
   141  	else
       
   142  	    {
       
   143  	    if ( ( aLeft.iNetworkName.Length() ) && 
       
   144  	         ( aRight.iNetworkName.Length() ) )
       
   145  	        {
       
   146  	        ret = aLeft.iNetworkName.CompareC( aRight.iNetworkName );
       
   147  	        }
       
   148  	    else if ( aLeft.iNetworkName.Length() )
       
   149  	        {
       
   150  	        ret = aLeft.iNetworkName.CompareC( aRight.iSsid );
       
   151  	        }
       
   152  	    else if ( aRight.iNetworkName.Length() )
       
   153  	        {
       
   154  	        ret = aLeft.iSsid.CompareC( aRight.iNetworkName );
       
   155  	        }
       
   156         else
       
   157             {
       
   158             ret = aLeft.iSsid.CompareC( aRight.iSsid );
       
   159             }
       
   160  	    }
       
   161  	    
       
   162  	return ret;
       
   163 	}
       
   164 
       
   165 
       
   166 // ---------------------------------------------------------------------------
       
   167 // CWsfWlanInfoSortingDefault::SetupOnRuleMatch
       
   168 // ---------------------------------------------------------------------------
       
   169 //    
       
   170 TBool CWsfWlanInfoSortingDefault::SetupOnRuleMatch( TWsfWlanInfo& 
       
   171                                                                 /*aInfoLeft*/ )
       
   172 	{
       
   173 	// as a default filter - every rules is a match
       
   174 	return ETrue;
       
   175 	}
       
   176 
       
   177 
       
   178 // ---------------------------------------------------------------------------
       
   179 // CWsfWlanInfoSortingDefault::MarkMatchedFilterL
       
   180 // ---------------------------------------------------------------------------
       
   181 //    
       
   182 void CWsfWlanInfoSortingDefault::MarkMatchedFilterL( 
       
   183                                               TWsfWlanInfo& /*aFilterEntry*/ )
       
   184 	{
       
   185 	// we do not modify the contents in default filter...
       
   186 	}
       
   187 
       
   188 
       
   189 // ---------------------------------------------------------------------------
       
   190 // CWsfWlanInfoSortingDefault::EditFilterDefsL
       
   191 // ---------------------------------------------------------------------------
       
   192 //    
       
   193 void CWsfWlanInfoSortingDefault::EditFilterDefsL( 
       
   194                                             CWsfWlanInfoArray& /*aInfoArray*/)
       
   195 	{
       
   196 	// we have hardcoded rules... we don't need editui..
       
   197 	}
       
   198 
       
   199 
       
   200 // ---------------------------------------------------------------------------
       
   201 // CWsfWlanInfoSortingDefault::ReadFilterDefsL
       
   202 // ---------------------------------------------------------------------------
       
   203 //    
       
   204 void CWsfWlanInfoSortingDefault::ReadFilterDefsL()
       
   205 	{
       
   206 	// we have static definitions... nothing to do...
       
   207 	}
       
   208 
       
   209 
       
   210