PECengine/ListLibrary2/ContactListSrc/CPEngContactListModItemContainer.cpp
branchRCL_3
changeset 17 a941bc465d9f
parent 0 094583676ce7
equal deleted inserted replaced
16:6ca72c0fe49a 17:a941bc465d9f
       
     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:  Container of the one contact list item.
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include    "PEngContactIdsTools.h"
       
    20 #include    "CPEngContactListModItemContainer.h"
       
    21 #include    "MPEngContactListModStore.h"
       
    22 #include    "CPEngStoreEntry.h"
       
    23 #include    "CPEngContactListProperty.h"
       
    24 #include    "PEngListLibraryPanics.h"
       
    25 #include    <e32std.h>
       
    26 
       
    27 
       
    28 // CONSTANTS
       
    29 const TInt KIntStreamBytes = 4;
       
    30 
       
    31 
       
    32 // ============================ MEMBER FUNCTIONS ===============================
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CPEngContactListModItemContainer::CPEngContactListModItemContainer()
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 CPEngContactListModItemContainer::CPEngContactListModItemContainer(
       
    39     MPEngContactListModStore& aStoreEntry )
       
    40         : iStoreEntry( aStoreEntry ),
       
    41         iAccessCount( 1 ), // initial access count
       
    42         iSize( aStoreEntry.StoreSizeCount() ),
       
    43         iFresh( EFalse )
       
    44     {
       
    45     // Initial size of numbers stored for managing the item
       
    46     iSize += KIntStreamBytes * 5;
       
    47     }
       
    48 
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // CPEngContactListModItemContainer::ConstructL()
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 void CPEngContactListModItemContainer::ConstructL(
       
    55     const TDesC& aContactId,
       
    56     const TDesC* aNickName )
       
    57     {
       
    58     iContactId = aContactId.AllocL();
       
    59     iSize += aContactId.Length();
       
    60     if ( aNickName )
       
    61         {
       
    62         iNickName = aNickName->AllocL();
       
    63         iSize += aNickName->Length();
       
    64         }
       
    65     }
       
    66 
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CPEngContactListModItemContainer::ConstructNewNickL()
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 void CPEngContactListModItemContainer::ConstructNewNickL(
       
    73     const TDesC& aContactId,
       
    74     const TDesC& aNewNickName )
       
    75     {
       
    76     iContactId = aContactId.AllocL();
       
    77     iSize +=  aContactId.Length();
       
    78     iNewNickName = aNewNickName.AllocL();
       
    79     iSize +=  aNewNickName.Length();
       
    80     }
       
    81 
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // CPEngContactListModItemContainer::NewLC()
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 CPEngContactListModItemContainer* CPEngContactListModItemContainer::NewLC(
       
    88     MPEngContactListModStore& aStoreEntry,
       
    89     const TDesC& aContactId,
       
    90     const TDesC* aNickName )
       
    91     {
       
    92     CPEngContactListModItemContainer* self =
       
    93         new( ELeave ) CPEngContactListModItemContainer( aStoreEntry );
       
    94 
       
    95     CleanupClosePushL( *self );
       
    96     self->ConstructL( aContactId, aNickName );
       
    97 
       
    98     return self;
       
    99     }
       
   100 
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // CPEngContactListModItemContainer::NewNewNickLC()
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 CPEngContactListModItemContainer* CPEngContactListModItemContainer::NewNewNickLC(
       
   107     MPEngContactListModStore& aStoreEntry,
       
   108     const TDesC& aContactId,
       
   109     const TDesC& aNewNickName )
       
   110     {
       
   111     CPEngContactListModItemContainer* self =
       
   112         new( ELeave ) CPEngContactListModItemContainer( aStoreEntry );
       
   113 
       
   114     CleanupClosePushL( *self );
       
   115     self->ConstructNewNickL( aContactId, aNewNickName );
       
   116 
       
   117     return self;
       
   118     }
       
   119 
       
   120 
       
   121 // -----------------------------------------------------------------------------
       
   122 // CPEngContactListModItemContainer::NewLC()
       
   123 // -----------------------------------------------------------------------------
       
   124 //
       
   125 CPEngContactListModItemContainer* CPEngContactListModItemContainer::NewLC(
       
   126     MPEngContactListModStore& aStoreEntry,
       
   127     RReadStream& aStream )
       
   128     {
       
   129     CPEngContactListModItemContainer* self =
       
   130         new( ELeave ) CPEngContactListModItemContainer( aStoreEntry );
       
   131 
       
   132     CleanupClosePushL( *self );
       
   133     self->InternalizeL( aStream, EPEngStorageBasicPermanent );
       
   134 
       
   135     return self;
       
   136     }
       
   137 
       
   138 
       
   139 // Destructor
       
   140 CPEngContactListModItemContainer::~CPEngContactListModItemContainer()
       
   141     {
       
   142     // panic if object is still accessed
       
   143     __ASSERT_DEBUG( iAccessCount == 0 , Panic( ERefAccessedObjectDeleted ) );
       
   144 
       
   145     // decrease size since object is deleted
       
   146     iSize -= KIntStreamBytes * 3;
       
   147     if ( iContactId )
       
   148         {
       
   149         iSize += iContactId->Length();
       
   150         }
       
   151 
       
   152     delete iContactId;
       
   153     delete iNickName;
       
   154     delete iNewNickName;
       
   155 
       
   156     iProperties.ResetAndDestroy();
       
   157     }
       
   158 
       
   159 
       
   160 // -----------------------------------------------------------------------------
       
   161 // CPEngContactListModItemContainer::Id()
       
   162 // -----------------------------------------------------------------------------
       
   163 //
       
   164 const TDesC& CPEngContactListModItemContainer::Id() const
       
   165     {
       
   166     return *iContactId;
       
   167     }
       
   168 
       
   169 
       
   170 // -----------------------------------------------------------------------------
       
   171 // CPEngContactListModItemContainer::NickName()
       
   172 // -----------------------------------------------------------------------------
       
   173 //
       
   174 const TDesC& CPEngContactListModItemContainer::NickName() const
       
   175     {
       
   176     if ( iNewNickName )
       
   177         {
       
   178         return *iNewNickName;
       
   179         }
       
   180 
       
   181     if ( iNickName )
       
   182         {
       
   183         return *iNickName;
       
   184         }
       
   185 
       
   186     return KNullDesC;
       
   187     }
       
   188 
       
   189 
       
   190 // -----------------------------------------------------------------------------
       
   191 // CPEngContactListModItemContainer::UpdateNickNameL()
       
   192 // -----------------------------------------------------------------------------
       
   193 //
       
   194 void CPEngContactListModItemContainer::UpdateNickNameL( const TDesC& aNickName )
       
   195     {
       
   196     TInt size( iNewNickName ? iNewNickName->Length() : KIntStreamBytes * 2 );
       
   197     delete iNewNickName;
       
   198     iNewNickName = NULL;
       
   199 
       
   200     if ( !iNickName || ( KErrNone != iNickName->Compare( aNickName ) ) )
       
   201         {
       
   202         iNewNickName = aNickName.AllocL();
       
   203         size -= iNewNickName->Length();
       
   204         }
       
   205 
       
   206     iSize -= size;
       
   207     iStoreEntry.StoreEntryL();
       
   208     }
       
   209 
       
   210 
       
   211 // -----------------------------------------------------------------------------
       
   212 // CPEngContactListModItemContainer::GetProperty()
       
   213 // -----------------------------------------------------------------------------
       
   214 //
       
   215 TInt CPEngContactListModItemContainer::GetProperty( TUint aName,
       
   216                                                     TUint aLevel,
       
   217                                                     TInt& aValue ) const
       
   218 
       
   219     {
       
   220     return PEngPropertyManager::GetProperty( iProperties,
       
   221                                              aName,
       
   222                                              aLevel,
       
   223                                              aValue );
       
   224     }
       
   225 
       
   226 
       
   227 // -----------------------------------------------------------------------------
       
   228 // CPEngContactListModItemContainer::GetProperty()
       
   229 // -----------------------------------------------------------------------------
       
   230 //
       
   231 TInt CPEngContactListModItemContainer::GetProperty( TUint aName,
       
   232                                                     TUint aLevel,
       
   233                                                     TPtrC8& aValue ) const
       
   234     {
       
   235     return PEngPropertyManager::GetProperty( iProperties,
       
   236                                              aName,
       
   237                                              aLevel,
       
   238                                              aValue );
       
   239     }
       
   240 
       
   241 
       
   242 // -----------------------------------------------------------------------------
       
   243 // CPEngContactListModItemContainer::GetProperty()
       
   244 // -----------------------------------------------------------------------------
       
   245 //
       
   246 TInt CPEngContactListModItemContainer::GetProperty( TUint aName,
       
   247                                                     TUint aLevel,
       
   248                                                     TPtrC16& aValue ) const
       
   249     {
       
   250     return PEngPropertyManager::GetProperty( iProperties,
       
   251                                              aName,
       
   252                                              aLevel,
       
   253                                              aValue );
       
   254     }
       
   255 
       
   256 
       
   257 // -----------------------------------------------------------------------------
       
   258 // CPEngContactListModItemContainer::Property()
       
   259 // -----------------------------------------------------------------------------
       
   260 //
       
   261 TInt CPEngContactListModItemContainer::Property( TUint aName,
       
   262                                                  TUint aLevel ) const
       
   263     {
       
   264     return PEngPropertyManager::PropertyOrZero( iProperties,
       
   265                                                 aName,
       
   266                                                 aLevel );
       
   267     }
       
   268 
       
   269 
       
   270 // -----------------------------------------------------------------------------
       
   271 // CPEngContactListModItemContainer::SetPropertyL()
       
   272 // -----------------------------------------------------------------------------
       
   273 //
       
   274 void CPEngContactListModItemContainer::SetPropertyL( TUint aName,
       
   275                                                      TUint aLevel,
       
   276                                                      TInt aValue )
       
   277     {
       
   278     PEngPropertyManager::SetPropertyL( iProperties,
       
   279                                        aName,
       
   280                                        aLevel,
       
   281                                        aValue,
       
   282                                        iSize );
       
   283     iStoreEntry.StoreEntryL();
       
   284     }
       
   285 
       
   286 
       
   287 // -----------------------------------------------------------------------------
       
   288 // CPEngContactListModItemContainer::SetPropertyL()
       
   289 // -----------------------------------------------------------------------------
       
   290 //
       
   291 void CPEngContactListModItemContainer::SetPropertyL( TUint aName,
       
   292                                                      TUint aLevel,
       
   293                                                      const TDesC8& aValue )
       
   294     {
       
   295     PEngPropertyManager::SetPropertyL( iProperties,
       
   296                                        aName,
       
   297                                        aLevel,
       
   298                                        aValue,
       
   299                                        iSize );
       
   300     iStoreEntry.StoreEntryL();
       
   301     }
       
   302 
       
   303 
       
   304 // -----------------------------------------------------------------------------
       
   305 // CPEngContactListModItemContainer::SetPropertyL()
       
   306 // -----------------------------------------------------------------------------
       
   307 //
       
   308 void CPEngContactListModItemContainer::SetPropertyL( TUint aName,
       
   309                                                      TUint aLevel,
       
   310                                                      const TDesC16& aValue )
       
   311     {
       
   312     PEngPropertyManager::SetPropertyL( iProperties,
       
   313                                        aName,
       
   314                                        aLevel,
       
   315                                        aValue,
       
   316                                        iSize );
       
   317     iStoreEntry.StoreEntryL();
       
   318     }
       
   319 
       
   320 
       
   321 // -----------------------------------------------------------------------------
       
   322 // CPEngContactListModItemContainer::DeletePropertyL()
       
   323 // -----------------------------------------------------------------------------
       
   324 //
       
   325 void CPEngContactListModItemContainer::DeletePropertyL( TUint aName,
       
   326                                                         TUint aLevel )
       
   327     {
       
   328     if ( PEngPropertyManager::DeletePropertyL(
       
   329              iProperties,
       
   330              aName,
       
   331              aLevel,
       
   332              iSize ) )
       
   333         {
       
   334         iStoreEntry.StoreEntryL();
       
   335         }
       
   336     }
       
   337 
       
   338 
       
   339 // -----------------------------------------------------------------------------
       
   340 // CPEngContactListModItemContainer::GetPermanentValue()
       
   341 // -----------------------------------------------------------------------------
       
   342 //
       
   343 TInt CPEngContactListModItemContainer::GetPermanentValue( const TDesC& /*aKey*/,
       
   344                                                           TPtrC8& /*aValue*/ ) const
       
   345     {
       
   346     return KErrNotFound;
       
   347     }
       
   348 
       
   349 
       
   350 // -----------------------------------------------------------------------------
       
   351 // CPEngContactListModItemContainer::GetCachedValue()
       
   352 // -----------------------------------------------------------------------------
       
   353 //
       
   354 TInt CPEngContactListModItemContainer::GetCachedValue( const TDesC& /*aKey*/,
       
   355                                                        TPtrC8& /*aValue*/ ) const
       
   356     {
       
   357     return KErrNotFound;
       
   358     }
       
   359 
       
   360 
       
   361 // -----------------------------------------------------------------------------
       
   362 // CPEngContactListModItemContainer::SetPermanentValueL()
       
   363 // -----------------------------------------------------------------------------
       
   364 //
       
   365 void CPEngContactListModItemContainer::SetPermanentValueL( const TDesC& /*aKey*/,
       
   366                                                            const TDesC8& /*aValue*/ )
       
   367     {
       
   368     User::Leave( KErrNotSupported );
       
   369     }
       
   370 
       
   371 
       
   372 // -----------------------------------------------------------------------------
       
   373 // CPEngContactListModItemContainer::SetCachedValueL()
       
   374 // -----------------------------------------------------------------------------
       
   375 //
       
   376 void CPEngContactListModItemContainer::SetCachedValueL( const TDesC& /*aKey*/,
       
   377                                                         const TDesC8& /*aValue*/ )
       
   378     {
       
   379     User::Leave( KErrNotSupported );
       
   380     }
       
   381 
       
   382 
       
   383 // -----------------------------------------------------------------------------
       
   384 // CPEngContactListModItemContainer::DeletePermanentValueL()
       
   385 // -----------------------------------------------------------------------------
       
   386 //
       
   387 void CPEngContactListModItemContainer::DeletePermanentValueL( const TDesC& /*aKey*/ )
       
   388     {
       
   389     User::Leave( KErrNotSupported );
       
   390     }
       
   391 
       
   392 
       
   393 // -----------------------------------------------------------------------------
       
   394 // CPEngContactListModItemContainer::DeleteCachedValueL()
       
   395 // -----------------------------------------------------------------------------
       
   396 //
       
   397 void CPEngContactListModItemContainer::DeleteCachedValueL( const TDesC& /*aKey*/ )
       
   398     {
       
   399     User::Leave( KErrNotSupported );
       
   400     }
       
   401 
       
   402 
       
   403 // =============================================================================
       
   404 // ===============Functions of main class ======================================
       
   405 // =============================================================================
       
   406 
       
   407 
       
   408 // -----------------------------------------------------------------------------
       
   409 // CPEngContactListModItemContainer::Compare()
       
   410 // -----------------------------------------------------------------------------
       
   411 //
       
   412 TInt CPEngContactListModItemContainer::Compare(
       
   413     const CPEngContactListModItemContainer& aFirst,
       
   414     const CPEngContactListModItemContainer& aSecond )
       
   415     {
       
   416     return NContactIdsTools::CompareContactIds( *( aFirst.iContactId ),
       
   417                                                 *( aSecond.iContactId ) );
       
   418     }
       
   419 
       
   420 
       
   421 // -----------------------------------------------------------------------------
       
   422 // CPEngContactListModItemContainer::Open()
       
   423 // -----------------------------------------------------------------------------
       
   424 //
       
   425 void CPEngContactListModItemContainer::Open( TInt aRefType )
       
   426     {
       
   427     iAccessCount++;
       
   428     iRefDefinitions |= aRefType;
       
   429     }
       
   430 
       
   431 
       
   432 // -----------------------------------------------------------------------------
       
   433 // CPEngContactListModItemContainer::CloseRef()
       
   434 // -----------------------------------------------------------------------------
       
   435 CPEngContactListModItemContainer* CPEngContactListModItemContainer::CloseRef(
       
   436     TInt aRefType /* 0 */ )
       
   437     {
       
   438     iRefDefinitions &= ~aRefType;
       
   439 
       
   440     // access count will be decreased by 1, get pointer
       
   441     CPEngContactListModItemContainer* self = ( iAccessCount - 1 ) ? this : NULL;
       
   442     Close();
       
   443 
       
   444     return self;
       
   445     }
       
   446 
       
   447 
       
   448 // -----------------------------------------------------------------------------
       
   449 // CPEngContactListModItemContainer::RefActive()
       
   450 // -----------------------------------------------------------------------------
       
   451 TBool CPEngContactListModItemContainer::RefActive( TInt aRefType /* 0 */ )
       
   452     {
       
   453     return iRefDefinitions & aRefType;
       
   454     }
       
   455 
       
   456 
       
   457 // -----------------------------------------------------------------------------
       
   458 // CPEngContactListModItemContainer::Close()
       
   459 // -----------------------------------------------------------------------------
       
   460 void CPEngContactListModItemContainer::Close()
       
   461     {
       
   462     --iAccessCount;
       
   463 
       
   464     if ( !iAccessCount )
       
   465         {
       
   466         delete this;
       
   467         }
       
   468     }
       
   469 
       
   470 
       
   471 // -----------------------------------------------------------------------------
       
   472 // CPEngContactListModItemContainer::ExternalizeL()
       
   473 // -----------------------------------------------------------------------------
       
   474 //
       
   475 void CPEngContactListModItemContainer::ExternalizeL( RWriteStream& aStream,
       
   476                                                      TInt aType ) const
       
   477     {
       
   478     switch ( aType )
       
   479         {
       
   480         case EPEngStorageBasicPermanent:
       
   481             {
       
   482             // reference definitions
       
   483             aStream.WriteInt32L( iRefDefinitions );
       
   484             aStream.WriteInt32L( iServerIndex );
       
   485 
       
   486             // WV Id
       
   487             aStream.WriteInt32L( iContactId->Length() );
       
   488             aStream << *iContactId;
       
   489 
       
   490             // nickname
       
   491             if ( iNickName )
       
   492                 {
       
   493                 aStream.WriteInt32L( iNickName->Length() );
       
   494                 aStream << *iNickName;
       
   495                 }
       
   496             else
       
   497                 {
       
   498                 // no nick name, save -1 to signal NULL pointer
       
   499                 aStream.WriteInt32L( -1 );
       
   500                 }
       
   501 
       
   502             //Fresh status
       
   503             aStream.WriteInt32L( iFresh );
       
   504 
       
   505             // Detailed properties
       
   506             PEngPropertyManager::ExternalizePropertiesL( iProperties,
       
   507                                                          aStream,
       
   508                                                          aType );
       
   509             break;
       
   510             }
       
   511 
       
   512 
       
   513         case EPEngStorageBasicCached:
       
   514             {
       
   515             // the new nickname
       
   516             if ( iNewNickName )
       
   517                 {
       
   518                 aStream.WriteInt32L( iNewNickName->Length() );
       
   519                 aStream << *iNewNickName;
       
   520                 }
       
   521             else
       
   522                 {
       
   523                 // no new nickname, save  -1 to signal NULL pointer
       
   524                 aStream.WriteInt32L( -1 );
       
   525                 }
       
   526 
       
   527 
       
   528             // Detailed properties
       
   529             PEngPropertyManager::ExternalizePropertiesL( iProperties,
       
   530                                                          aStream,
       
   531                                                          aType );
       
   532 
       
   533             break;
       
   534             }
       
   535 
       
   536         default:
       
   537             {
       
   538             }
       
   539         }
       
   540     }
       
   541 
       
   542 // -----------------------------------------------------------------------------
       
   543 // CPEngContactListModItemContainer::InternalizeL()
       
   544 // -----------------------------------------------------------------------------
       
   545 //
       
   546 void CPEngContactListModItemContainer::InternalizeL( RReadStream& aStream,
       
   547                                                      TInt aType )
       
   548     {
       
   549     switch ( aType )
       
   550         {
       
   551         case EPEngStorageBasicPermanent:
       
   552             {
       
   553             iProperties.ResetAndDestroy();
       
   554 
       
   555             iRefDefinitions = aStream.ReadInt32L();
       
   556             iServerIndex = aStream.ReadInt32L();
       
   557 
       
   558             // first WV Id
       
   559             TInt size( 2 * KIntStreamBytes );
       
   560             TInt length( aStream.ReadInt32L() );
       
   561             iContactId = HBufC::NewL( aStream, length );
       
   562             size += iContactId->Length();
       
   563 
       
   564             // read nickname
       
   565             length = aStream.ReadInt32L();
       
   566             size += KIntStreamBytes;
       
   567             if ( length != -1 )  // just to signal NULL pointer
       
   568                 {
       
   569                 iNickName = HBufC::NewL( aStream, length );
       
   570                 size += iNickName->Length();
       
   571                 }
       
   572             else
       
   573                 {
       
   574                 iNickName = NULL;
       
   575                 }
       
   576 
       
   577 
       
   578             //Fresh status
       
   579             iFresh = aStream.ReadInt32L();
       
   580 
       
   581 
       
   582             // Detailed properties
       
   583             PEngPropertyManager::InternalizePropertiesL( iProperties,
       
   584                                                          aStream,
       
   585                                                          size );
       
   586 
       
   587             iSize += size;
       
   588             TInt& entrySize = iStoreEntry.StoreSizeCount();
       
   589             entrySize += size;
       
   590             break;
       
   591             }
       
   592 
       
   593 
       
   594         case EPEngStorageBasicCached:
       
   595             {
       
   596             // always 4 numbers stored in the store beside other data
       
   597             TInt size ( 4 * KIntStreamBytes );
       
   598 
       
   599             // New nickname
       
   600             TInt length ( aStream.ReadInt32L() );
       
   601             if ( length != -1 )  // just to signal NULL pointer
       
   602                 {
       
   603                 delete iNewNickName;
       
   604                 iNewNickName = NULL;
       
   605                 iNewNickName = HBufC::NewL( aStream, length );
       
   606                 size += iNewNickName->Length();
       
   607                 }
       
   608             else
       
   609                 {
       
   610                 delete iNewNickName;
       
   611                 iNewNickName = NULL;
       
   612                 }
       
   613 
       
   614             // Detailed properties
       
   615             PEngPropertyManager::InternalizePropertiesL( iProperties,
       
   616                                                          aStream,
       
   617                                                          size );
       
   618 
       
   619             iSize += size;
       
   620             TInt& entrySize = iStoreEntry.StoreSizeCount();
       
   621             entrySize += size;
       
   622             break;
       
   623             }
       
   624 
       
   625         default:
       
   626             {
       
   627             }
       
   628         }
       
   629     }
       
   630 
       
   631 
       
   632 // -----------------------------------------------------------------------------
       
   633 // CPEngContactListModItemContainer::UpdateContactId()
       
   634 // -----------------------------------------------------------------------------
       
   635 //
       
   636 void CPEngContactListModItemContainer::UpdateContactId( HBufC* aId )  // CSI: 60 #
       
   637     {
       
   638     __ASSERT_DEBUG( aId, Panic( ENullParameter ) );
       
   639 
       
   640     iSize -= iContactId->Length();
       
   641     delete iContactId;
       
   642     iContactId = aId;
       
   643     iSize += iContactId->Length();
       
   644     }
       
   645 
       
   646 
       
   647 // -----------------------------------------------------------------------------
       
   648 // CPEngContactListModItemContainer::NewNick()
       
   649 // -----------------------------------------------------------------------------
       
   650 //
       
   651 const HBufC* CPEngContactListModItemContainer::NewNick() const
       
   652     {
       
   653     return iNewNickName;
       
   654     }
       
   655 
       
   656 
       
   657 // -----------------------------------------------------------------------------
       
   658 // CPEngContactListModItemContainer::CurrecntNick()
       
   659 // -----------------------------------------------------------------------------
       
   660 //
       
   661 const HBufC* CPEngContactListModItemContainer::CurrentNick() const
       
   662     {
       
   663     return iNickName;
       
   664     }
       
   665 
       
   666 
       
   667 // -----------------------------------------------------------------------------
       
   668 // CPEngContactListModItemContainer::SetCurrentNickname()
       
   669 // -----------------------------------------------------------------------------
       
   670 //
       
   671 void CPEngContactListModItemContainer::SetCurrentNickname( HBufC* aNickName ) // CSI: 60 #
       
   672     {
       
   673     if ( iNickName )
       
   674         {
       
   675         iSize -= iNickName->Length();
       
   676         delete iNickName;
       
   677         }
       
   678 
       
   679     iNickName = aNickName;
       
   680 
       
   681     if ( iNickName )
       
   682         {
       
   683         iSize += iNickName->Length();
       
   684         }
       
   685     }
       
   686 
       
   687 
       
   688 // -----------------------------------------------------------------------------
       
   689 // CPEngContactListModItemContainer::AdoptCurrentNickAsNew()
       
   690 // -----------------------------------------------------------------------------
       
   691 //
       
   692 void CPEngContactListModItemContainer::AdoptCurrentNickAsNew()
       
   693     {
       
   694     if ( iNewNickName )
       
   695         {
       
   696         iSize -= iNewNickName->Length();
       
   697         delete iNewNickName;
       
   698         }
       
   699     iNewNickName = iNickName;
       
   700     iNickName = NULL;
       
   701     }
       
   702 
       
   703 
       
   704 // -----------------------------------------------------------------------------
       
   705 // CPEngContactListModItemContainer::RollBackNickname()
       
   706 // -----------------------------------------------------------------------------
       
   707 //
       
   708 void CPEngContactListModItemContainer::RollBackNickname()
       
   709     {
       
   710     if ( iNewNickName )
       
   711         {
       
   712         iSize -= iNewNickName->Length();
       
   713         delete iNewNickName;
       
   714         }
       
   715 
       
   716     iNewNickName = NULL;
       
   717     }
       
   718 
       
   719 
       
   720 // -----------------------------------------------------------------------------
       
   721 // CPEngContactListModItemContainer::CommitNickName()
       
   722 // -----------------------------------------------------------------------------
       
   723 //
       
   724 void CPEngContactListModItemContainer::CommitNickName()
       
   725     {
       
   726     if ( iNickName )
       
   727         {
       
   728         iSize -= iNickName->Length();
       
   729         delete iNickName;
       
   730         }
       
   731 
       
   732     iNickName = iNewNickName;
       
   733     iNewNickName = NULL;
       
   734     }
       
   735 
       
   736 
       
   737 // -----------------------------------------------------------------------------
       
   738 // CPEngContactListModItemContainer::ServerIndex()
       
   739 // -----------------------------------------------------------------------------
       
   740 TInt CPEngContactListModItemContainer::ServerIndex() const
       
   741     {
       
   742     return iServerIndex;
       
   743     }
       
   744 
       
   745 
       
   746 // -----------------------------------------------------------------------------
       
   747 // CPEngContactListModItemContainer::SetServerIndex()
       
   748 // -----------------------------------------------------------------------------
       
   749 void CPEngContactListModItemContainer::SetServerIndex( TInt aIndex )
       
   750     {
       
   751     iServerIndex = aIndex;
       
   752     }
       
   753 
       
   754 
       
   755 // -----------------------------------------------------------------------------
       
   756 // CPEngContactListModItemContainer::IsFreshContact()
       
   757 // -----------------------------------------------------------------------------
       
   758 //
       
   759 TBool CPEngContactListModItemContainer::IsFreshContact()
       
   760     {
       
   761     return iFresh;
       
   762     }
       
   763 
       
   764 
       
   765 // -----------------------------------------------------------------------------
       
   766 // CPEngContactListModItemContainer::SetFreshContact()
       
   767 // -----------------------------------------------------------------------------
       
   768 //
       
   769 void CPEngContactListModItemContainer::SetFreshContact( TBool aFresh )
       
   770     {
       
   771     iFresh = aFresh;
       
   772     }
       
   773 
       
   774 
       
   775 //  End of File
       
   776