ipsservices/ipssosplugin/src/ipsplgmsgswap.cpp
changeset 0 8466d47a6819
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Swapper class for message sorting function
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "emailtrace.h"
       
    20 #include "ipsplgheaders.h"
       
    21 // ---------------------------------------------------------------------------
       
    22 // Basic constructor
       
    23 // ---------------------------------------------------------------------------
       
    24 
       
    25 TIpsPlgMsgSwap::TIpsPlgMsgSwap( CMsvEntry& aFolderEntry )
       
    26     : iFolderEntry(aFolderEntry)
       
    27     {
       
    28     FUNC_LOG;
       
    29     // none
       
    30     }
       
    31 
       
    32 // ---------------------------------------------------------------------------
       
    33 // Swaps the messages inside the folder CMsvEntry instance. 
       
    34 // This is somewhat extreme solution assuming that CMsvEntry returns
       
    35 // references to the actual TMsvEntries (not copies) and that CMsvEntry
       
    36 // does not do any sorting itself.
       
    37 // ---------------------------------------------------------------------------
       
    38 
       
    39 void TIpsPlgMsgSwap::Swap( TInt aLeft, TInt aRight ) const
       
    40     {
       
    41     FUNC_LOG;
       
    42     if ( aLeft == aRight )
       
    43         {
       
    44         return;
       
    45         }
       
    46         
       
    47     TInt childCount( iFolderEntry.Count() );
       
    48     if ( aLeft >= childCount || aRight >= childCount  )
       
    49         {
       
    50         return;
       
    51         }
       
    52         
       
    53     Mem::Swap( (TAny*) &( iFolderEntry[aLeft] ), 
       
    54         (TAny*) &( iFolderEntry[aRight] ), sizeof( TMsvEntry ) );
       
    55     }
       
    56 
       
    57