wvuing/wvuiave/AppSrc/CCAAccessArray.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Access list's array
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "CCAAccessArray.h"
       
    21 #include    "ChatDefinitions.h"
       
    22 #include    "CAUtils.h"
       
    23 #include    "IMUtils.h"
       
    24 #include    "MCAGroupPropertiesPC.h"
       
    25 
       
    26 // The Settings have been moved to Cenrep (also retained in the Resource file),
       
    27 // so the enums for keys and central repository header is added here
       
    28 #include 	"VariantKeys.h"
       
    29 
       
    30 
       
    31 // ================= MEMBER FUNCTIONS =======================
       
    32 
       
    33 // C++ default constructor can NOT contain any code, that
       
    34 // might leave.
       
    35 //
       
    36 CCAAccessArray::CCAAccessArray( MCAGroupPropertiesPC* aGroupPropsPC,
       
    37                                 CDesCArray& aUserList )
       
    38         : iGroupPropertiesPC( aGroupPropsPC ),
       
    39         iAccessList( aUserList )
       
    40     {
       
    41     }
       
    42 
       
    43 // Symbian OS default constructor can leave.
       
    44 void CCAAccessArray::ConstructL()
       
    45     {
       
    46     iLine = HBufC::NewL( KMaxWVIDLength + KMaxTabLength );
       
    47     }
       
    48 
       
    49 // Two-phased constructor.
       
    50 CCAAccessArray* CCAAccessArray::NewL(
       
    51     MCAGroupPropertiesPC* aGroupPropertiesDialogPC,
       
    52     CDesCArray& aUserList )
       
    53     {
       
    54     CCAAccessArray* self = new ( ELeave ) CCAAccessArray(
       
    55         aGroupPropertiesDialogPC, aUserList );
       
    56 
       
    57     CleanupStack::PushL( self );
       
    58     self->ConstructL();
       
    59     CleanupStack::Pop( self );
       
    60 
       
    61     return self;
       
    62     }
       
    63 
       
    64 // Destructor
       
    65 CCAAccessArray::~CCAAccessArray()
       
    66     {
       
    67     delete iLine;
       
    68     }
       
    69 
       
    70 // ---------------------------------------------------------
       
    71 // CCAAccessArray::AppendL( const TDesC16& aPtr )
       
    72 // This method appends descriptor to the accesslist array
       
    73 // (other items were commented in a header).
       
    74 // ---------------------------------------------------------
       
    75 //
       
    76 void CCAAccessArray::AppendL( const TDesC& aPtr )
       
    77     {
       
    78     iAccessList.AppendL( aPtr );
       
    79     }
       
    80 
       
    81 // ---------------------------------------------------------
       
    82 // CCAAccessArray::Delete( TInt aIndex,TInt aCount )
       
    83 // This method deletes items from accesslist
       
    84 // (other items were commented in a header).
       
    85 // ---------------------------------------------------------
       
    86 //
       
    87 void CCAAccessArray::Delete( TInt aIndex, TInt aCount )
       
    88     {
       
    89     __ASSERT_ALWAYS( aIndex >= 0,
       
    90                      User::Panic( KPanicText, EAccessArrayOutOfBounds ) );
       
    91 
       
    92     __ASSERT_ALWAYS( aCount + aIndex <= iAccessList.MdcaCount() ,
       
    93                      User::Panic( KPanicText, EAccessArrayOutOfBounds ) );
       
    94 
       
    95     iAccessList.Delete( aIndex, aCount );
       
    96     }
       
    97 
       
    98 // ---------------------------------------------------------
       
    99 // CCAAccessArray::Reset()
       
   100 // This method resets the access list
       
   101 // (other items were commented in a header).
       
   102 // ---------------------------------------------------------
       
   103 //
       
   104 void CCAAccessArray::Reset()
       
   105     {
       
   106     iAccessList.Reset();
       
   107     }
       
   108 
       
   109 // ---------------------------------------------------------
       
   110 // CCAAccessArray::MdcaCount() const
       
   111 // This method returns number of items in array
       
   112 // (other items were commented in a header).
       
   113 // ---------------------------------------------------------
       
   114 //
       
   115 TInt CCAAccessArray::MdcaCount() const
       
   116     {
       
   117     return iAccessList.MdcaCount();
       
   118     }
       
   119 
       
   120 // ---------------------------------------------------------
       
   121 // CCAAccessArray::MdcaPoint( TInt aIndex ) const
       
   122 // This method returns descriptor for given index
       
   123 // (other items were commented in a header).
       
   124 // ---------------------------------------------------------
       
   125 //
       
   126 TPtrC CCAAccessArray::MdcaPoint( TInt aIndex ) const
       
   127     {
       
   128     __ASSERT_ALWAYS( aIndex >= 0,
       
   129                      User::Panic( KPanicText, EAccessArrayOutOfBounds ) );
       
   130 
       
   131     __ASSERT_ALWAYS( aIndex < iAccessList.MdcaCount() ,
       
   132                      User::Panic( KPanicText, EAccessArrayOutOfBounds ) );
       
   133 
       
   134     TPtrC id( iAccessList.MdcaPoint( aIndex ) );
       
   135 
       
   136     TPtrC idPtr( KNullDesC );
       
   137     TRAP_IGNORE( idPtr.Set( iGroupPropertiesPC->GetIdentificationL( id ) ) );
       
   138 
       
   139     iLine->Des().Copy( idPtr.Left( iLine->Des().MaxLength() ) );
       
   140 
       
   141     TPtr linePtr( iLine->Des() );
       
   142     linePtr.Insert( 0, KTabulator );
       
   143     return iLine->Des();
       
   144     }
       
   145 
       
   146 // ---------------------------------------------------------
       
   147 // CCAAccessArray::RawData( TInt aIndex ) const
       
   148 // This method returns unformatted descriptor from array
       
   149 // (other items were commented in a header).
       
   150 // ---------------------------------------------------------
       
   151 //
       
   152 TPtrC CCAAccessArray::RawData( TInt aIndex ) const
       
   153     {
       
   154     __ASSERT_ALWAYS( aIndex >= 0,
       
   155                      User::Panic( KPanicText, EAccessArrayOutOfBounds ) );
       
   156 
       
   157     __ASSERT_ALWAYS( aIndex < iAccessList.MdcaCount() ,
       
   158                      User::Panic( KPanicText, EAccessArrayOutOfBounds ) );
       
   159 
       
   160     return iAccessList.MdcaPoint( aIndex );
       
   161     }
       
   162 
       
   163 //  End of File