PECengine/ListLibrary2/ContactListSrc/CPEngContactListSettings.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     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 for contact list settings.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "CPEngContactListSettings.h"
       
    21 #include    "MPEngAttributeList2.h"
       
    22 #include    "PEngContactIdsTools.h"
       
    23 #include    "PEngStorageGlobals.h"
       
    24 #include    "MPEngContactListSettingsManager.h"
       
    25 #include    "CPEngContactListProperty.h"
       
    26 
       
    27 #include    <e32std.h>
       
    28 #include    <s32strm.h>
       
    29 
       
    30 
       
    31 // Minimal size of the store entry for contact list settings
       
    32 // 7 x 4 bytes (32bit) to store
       
    33 static const TInt KListSettingsStoreMinSize = 7 * 4;
       
    34 
       
    35 
       
    36 
       
    37 // ============================ MEMBER FUNCTIONS ===============================
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CPEngContactListSettings::CPEngContactListSettings()
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 CPEngContactListSettings::CPEngContactListSettings(
       
    44     const TPEngContactListBaseSettings& aBaseSettings,
       
    45     MPEngContactListSettingsManager& aManager )
       
    46         : iSettingsManager( aManager ),
       
    47         iBehavior ( aBaseSettings )
       
    48     {
       
    49     }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CPEngContactListSettings::CPEngContactListSettings()
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 CPEngContactListSettings::CPEngContactListSettings(
       
    56     MPEngContactListSettingsManager& aManager )
       
    57         : iSettingsManager( aManager )
       
    58     {
       
    59     }
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // CPEngContactListSettings::ConstructServerL()
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 void CPEngContactListSettings::ConstructServerL( const TDesC& aContactList,
       
    66                                                  const TDesC& aServerName )
       
    67     {
       
    68     iName = aContactList.AllocL();
       
    69     iServerName = aServerName.AllocL();
       
    70     iDisplayName = KNullDesC().AllocL();
       
    71 
       
    72     iSettingsManager.StoreSize() += aContactList.Length() +
       
    73                                     aServerName.Length() + KListSettingsStoreMinSize;
       
    74     }
       
    75 
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CPEngContactListSettings::ConstructL()
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 void CPEngContactListSettings::ConstructL( const TDesC& aContactList )
       
    82     {
       
    83     iName = aContactList.AllocL();
       
    84     iName->Des().Fold();
       
    85     iDisplayName = KNullDesC().AllocL();
       
    86 
       
    87     iSettingsManager.StoreSize() += aContactList.Length() + KListSettingsStoreMinSize;
       
    88     }
       
    89 
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // CPEngContactListSettings::NewLC()
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 CPEngContactListSettings* CPEngContactListSettings::NewLC(
       
    96     const TDesC& aContactList,
       
    97     const TPEngContactListBaseSettings& aBaseSettings,
       
    98     MPEngContactListSettingsManager& aManager )
       
    99     {
       
   100     CPEngContactListSettings* self = new( ELeave )
       
   101     CPEngContactListSettings( aBaseSettings,
       
   102                               aManager );
       
   103 
       
   104     CleanupStack::PushL( self );
       
   105     self->ConstructL( aContactList );
       
   106 
       
   107     return self;
       
   108     }
       
   109 
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // CPEngContactListSettings::NewServerLC()
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 CPEngContactListSettings* CPEngContactListSettings::NewServerLC(
       
   116     const TDesC& aContactList,
       
   117     const TDesC& aServerName,
       
   118     MPEngContactListSettingsManager& aManager )
       
   119     {
       
   120     CPEngContactListSettings* self = new( ELeave ) CPEngContactListSettings(
       
   121         aManager );
       
   122 
       
   123     CleanupStack::PushL( self );
       
   124     self->ConstructServerL( aContactList, aServerName );
       
   125 
       
   126     return self;
       
   127     }
       
   128 
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 // CPEngContactListSettings::NewServerLC()
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 CPEngContactListSettings* CPEngContactListSettings::NewStreamLC(
       
   135     RReadStream& aStream,
       
   136     MPEngContactListSettingsManager& aManager )
       
   137     {
       
   138     CPEngContactListSettings* self = new( ELeave ) CPEngContactListSettings( aManager );
       
   139 
       
   140     CleanupStack::PushL( self );
       
   141     self->InternalizeL( aStream, EPEngStorageBasicPermanent );
       
   142 
       
   143     return self;
       
   144     }
       
   145 
       
   146 
       
   147 // Destructor
       
   148 CPEngContactListSettings::~CPEngContactListSettings()
       
   149     {
       
   150     delete iName;
       
   151     delete iServerName;
       
   152     delete iDisplayName;
       
   153     iProperties.ResetAndDestroy();
       
   154     iSubscriptionAttrs.Reset();
       
   155     }
       
   156 
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 // CPEngContactListSettings::Synchronized()
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 TBool CPEngContactListSettings::Synchronized() const
       
   163     {
       
   164     return Property( KPEngHasBeenSynchronized,
       
   165                      KPEngCntLstPropertyNativeCached );
       
   166     }
       
   167 
       
   168 
       
   169 // -----------------------------------------------------------------------------
       
   170 // CPEngContactListSettings::ListName()
       
   171 // -----------------------------------------------------------------------------
       
   172 //
       
   173 const TDesC& CPEngContactListSettings::Name() const
       
   174     {
       
   175     return *iName;
       
   176     }
       
   177 
       
   178 
       
   179 // -----------------------------------------------------------------------------
       
   180 // CPEngContactListSettings::ServerName()
       
   181 // -----------------------------------------------------------------------------
       
   182 //
       
   183 const TDesC& CPEngContactListSettings::ServerName() const
       
   184     {
       
   185     if ( ( iServerName ) && ( iServerName->Compare( KNullDesC ) != KErrNone ) )
       
   186         {
       
   187         return *iServerName;
       
   188         }
       
   189     // no server name, then it same as local one
       
   190     return *iName;
       
   191     }
       
   192 
       
   193 
       
   194 // -----------------------------------------------------------------------------
       
   195 // CPEngContactListSettings::DisplayName()
       
   196 // -----------------------------------------------------------------------------
       
   197 //
       
   198 TInt CPEngContactListSettings::DisplayName( TPtrC& aDispName ) const
       
   199     {
       
   200     if ( Synchronized()  ||
       
   201          Property( KPEngCntLstSyncMaster, KPEngCntLstPropertyNativePermanent ) )
       
   202         {
       
   203         aDispName.Set( *iDisplayName );
       
   204         return KErrNone;
       
   205         }
       
   206 
       
   207     return KErrNotFound;
       
   208     }
       
   209 
       
   210 
       
   211 // -----------------------------------------------------------------------------
       
   212 // CPEngContactListSettings::SetDisplayNameL()
       
   213 // -----------------------------------------------------------------------------
       
   214 //
       
   215 void CPEngContactListSettings::SetDisplayNameL( const TDesC& aDisplayName )
       
   216     {
       
   217     if ( KErrNone == iDisplayName->Compare( aDisplayName ) )
       
   218         {
       
   219         // nothing to do
       
   220         return;
       
   221         }
       
   222 
       
   223     // update display name
       
   224     HBufC* temp = aDisplayName.AllocL();
       
   225     TInt dif( iDisplayName->Length() - aDisplayName.Length() );
       
   226     delete iDisplayName;
       
   227     iDisplayName = temp;
       
   228     iSettingsManager.StoreSize() += dif;
       
   229 
       
   230     // set update needed flag, stores data internally
       
   231     SetPropertyL( KPEngPropertiesUpdateNeeded,
       
   232                   KPEngCntLstPropertyNativeCached,
       
   233                   ETrue );
       
   234     }
       
   235 
       
   236 
       
   237 // -----------------------------------------------------------------------------
       
   238 // CPEngContactListSettings::IsDefault()
       
   239 // -----------------------------------------------------------------------------
       
   240 //
       
   241 TBool CPEngContactListSettings::IsDefault() const
       
   242     {
       
   243     TInt x( PEngPropertyManager::FindProperty( iProperties,
       
   244                                                KPEngCntLstDefault,
       
   245                                                KPEngCntLstPropertyNativePermanent ) );
       
   246     if ( x == KErrNotFound )
       
   247         {
       
   248         return EFalse;
       
   249         }
       
   250 
       
   251     return iProperties[ x ]->ValueInt();
       
   252     }
       
   253 
       
   254 
       
   255 // -----------------------------------------------------------------------------
       
   256 // CPEngContactListSettings::SubscriptionAttributes()
       
   257 // -----------------------------------------------------------------------------
       
   258 //
       
   259 const RArray<TUint32>& CPEngContactListSettings::SubscriptionAttributes() const
       
   260     {
       
   261     return iSubscriptionAttrs;
       
   262     }
       
   263 
       
   264 
       
   265 // -----------------------------------------------------------------------------
       
   266 // CPEngContactListSettings::SetSubscriptionAttributesL()
       
   267 // -----------------------------------------------------------------------------
       
   268 //
       
   269 TBool CPEngContactListSettings::SetSubscriptionAttributesL(
       
   270     const MPEngAttributeList2& aAttributelist )
       
   271     {
       
   272     TArray<TUint32> attrs( aAttributelist.ListOfAttributes() );
       
   273     return SetSubscriptionAttributesL( attrs );
       
   274     }
       
   275 
       
   276 
       
   277 // -----------------------------------------------------------------------------
       
   278 // CPEngContactListSettings::SetSubscriptionAttributesL()
       
   279 // -----------------------------------------------------------------------------
       
   280 //
       
   281 TBool CPEngContactListSettings::SetSubscriptionAttributesL(
       
   282     const TArray<TUint32>& aAttributelist )
       
   283     {
       
   284     // test if arrays are same
       
   285     TInt count( aAttributelist.Count() );
       
   286     TBool same( iSubscriptionAttrs.Count() == count );
       
   287     if ( same )
       
   288         {
       
   289         for ( TInt x( 0 ) ; x < count ; ++x )
       
   290             {
       
   291             if ( KErrNotFound == iSubscriptionAttrs.Find( aAttributelist[ x ] ) )
       
   292                 {
       
   293                 same = EFalse;
       
   294                 }
       
   295             }
       
   296         }
       
   297 
       
   298 
       
   299     // is update needed?
       
   300     if ( same &&
       
   301          Property( KPEngCntLstSubscribe, KPEngCntLstPropertyNativePermanent ) )
       
   302         {
       
   303         return EFalse;
       
   304         }
       
   305 
       
   306 
       
   307     // 4 bytes per one attribute
       
   308     TInt dif( ( iSubscriptionAttrs.Count() - count ) * 4 );
       
   309     iSubscriptionAttrs.Reset();
       
   310 
       
   311     for ( TInt x( 0 ) ; x < count ; ++x )
       
   312         {
       
   313         iSubscriptionAttrs.AppendL( aAttributelist[ x ] );
       
   314         }
       
   315     iSettingsManager.StoreSize() += dif;
       
   316 
       
   317 
       
   318     // set Subscription property On
       
   319     ActivateSubscriptionL();
       
   320     SetPropertyL( KPEngSubcriptionUpdate,
       
   321                   KPEngCntLstPropertyNativeCached,
       
   322                   ETrue );
       
   323 
       
   324     return ETrue;
       
   325     }
       
   326 
       
   327 
       
   328 // -----------------------------------------------------------------------------
       
   329 // CPEngContactListSettings::ActivateSubscriptionL()
       
   330 // -----------------------------------------------------------------------------
       
   331 //
       
   332 TBool CPEngContactListSettings::ActivateSubscriptionL()
       
   333     {
       
   334 
       
   335     if ( Property( KPEngCntLstSubscribe, KPEngCntLstPropertyNativePermanent ) )
       
   336         {
       
   337         return EFalse;
       
   338         }
       
   339 
       
   340     // set Subscription property On
       
   341     SetPropertyL( KPEngCntLstSubscribe,
       
   342                   KPEngCntLstPropertyNativePermanent,
       
   343                   ETrue );
       
   344 
       
   345     SetPropertyL( KPEngSubcriptionUpdate,
       
   346                   KPEngCntLstPropertyNativeCached,
       
   347                   ETrue );
       
   348     return ETrue;
       
   349     }
       
   350 
       
   351 
       
   352 // -----------------------------------------------------------------------------
       
   353 // CPEngContactListSettings::DeActivateSubscriptionL()
       
   354 // -----------------------------------------------------------------------------
       
   355 //
       
   356 TBool CPEngContactListSettings::DeActivateSubscriptionL()
       
   357     {
       
   358     if ( ! Property( KPEngCntLstSubscribe, KPEngCntLstPropertyNativePermanent ) )
       
   359         {
       
   360         return EFalse;
       
   361         }
       
   362 
       
   363 
       
   364     // set Subscription property Off
       
   365     DeletePropertyL( KPEngCntLstSubscribe,
       
   366                      KPEngCntLstPropertyNativePermanent );
       
   367 
       
   368     SetPropertyL( KPEngSubcriptionUpdate,
       
   369                   KPEngCntLstPropertyNativeCached,
       
   370                   ETrue );
       
   371 
       
   372     return ETrue;
       
   373     }
       
   374 
       
   375 
       
   376 // -----------------------------------------------------------------------------
       
   377 // CPEngContactListSettings::BaseSettings()
       
   378 // -----------------------------------------------------------------------------
       
   379 //
       
   380 const TPEngContactListBaseSettings& CPEngContactListSettings::BaseSettings() const
       
   381     {
       
   382     return iBehavior;
       
   383     }
       
   384 
       
   385 
       
   386 // -----------------------------------------------------------------------------
       
   387 // CPEngContactListSettings::GetProperty()
       
   388 // -----------------------------------------------------------------------------
       
   389 //
       
   390 TInt CPEngContactListSettings::GetProperty( TUint aName,
       
   391                                             TUint aLevel,
       
   392                                             TInt& aValue ) const
       
   393 
       
   394     {
       
   395     return PEngPropertyManager::GetProperty( iProperties,
       
   396                                              aName,
       
   397                                              aLevel,
       
   398                                              aValue );
       
   399     }
       
   400 
       
   401 
       
   402 // -----------------------------------------------------------------------------
       
   403 // CPEngContactListSettings::GetProperty()
       
   404 // -----------------------------------------------------------------------------
       
   405 //
       
   406 TInt CPEngContactListSettings::GetProperty( TUint aName,
       
   407                                             TUint aLevel,
       
   408                                             TPtrC8& aValue ) const
       
   409     {
       
   410     return PEngPropertyManager::GetProperty( iProperties,
       
   411                                              aName,
       
   412                                              aLevel,
       
   413                                              aValue );
       
   414     }
       
   415 
       
   416 
       
   417 // -----------------------------------------------------------------------------
       
   418 // CPEngContactListSettings::GetProperty()
       
   419 // -----------------------------------------------------------------------------
       
   420 //
       
   421 TInt CPEngContactListSettings::GetProperty( TUint aName,
       
   422                                             TUint aLevel,
       
   423                                             TPtrC16& aValue ) const
       
   424     {
       
   425     return PEngPropertyManager::GetProperty( iProperties,
       
   426                                              aName,
       
   427                                              aLevel,
       
   428                                              aValue );
       
   429     }
       
   430 
       
   431 
       
   432 // -----------------------------------------------------------------------------
       
   433 // CPEngContactListSettings::Property()
       
   434 // -----------------------------------------------------------------------------
       
   435 //
       
   436 TInt CPEngContactListSettings::Property( TUint aName,
       
   437                                          TUint aLevel ) const
       
   438     {
       
   439     return PEngPropertyManager::PropertyOrZero( iProperties,
       
   440                                                 aName,
       
   441                                                 aLevel );
       
   442     }
       
   443 
       
   444 
       
   445 // -----------------------------------------------------------------------------
       
   446 // CPEngContactListSettings::SetPropertyL()
       
   447 // -----------------------------------------------------------------------------
       
   448 //
       
   449 void CPEngContactListSettings::SetPropertyL( TUint aName,
       
   450                                              TUint aLevel,
       
   451                                              TInt aValue )
       
   452     {
       
   453     PEngPropertyManager::SetPropertyL( iProperties,
       
   454                                        aName,
       
   455                                        aLevel,
       
   456                                        aValue,
       
   457                                        iSettingsManager.StoreSize() );
       
   458     iSettingsManager.StoreSettingsL();
       
   459     }
       
   460 
       
   461 
       
   462 // -----------------------------------------------------------------------------
       
   463 // CPEngContactListSettings::SetPropertyL()
       
   464 // -----------------------------------------------------------------------------
       
   465 //
       
   466 void CPEngContactListSettings::SetPropertyL( TUint aName,
       
   467                                              TUint aLevel,
       
   468                                              const TDesC8& aValue )
       
   469     {
       
   470     PEngPropertyManager::SetPropertyL( iProperties,
       
   471                                        aName,
       
   472                                        aLevel,
       
   473                                        aValue,
       
   474                                        iSettingsManager.StoreSize() );
       
   475     iSettingsManager.StoreSettingsL();
       
   476     }
       
   477 
       
   478 
       
   479 // -----------------------------------------------------------------------------
       
   480 // CPEngContactListSettings::SetPropertyL()
       
   481 // -----------------------------------------------------------------------------
       
   482 //
       
   483 void CPEngContactListSettings::SetPropertyL( TUint aName,
       
   484                                              TUint aLevel,
       
   485                                              const TDesC16& aValue )
       
   486     {
       
   487     PEngPropertyManager::SetPropertyL( iProperties,
       
   488                                        aName,
       
   489                                        aLevel,
       
   490                                        aValue,
       
   491                                        iSettingsManager.StoreSize() );
       
   492     iSettingsManager.StoreSettingsL();
       
   493     }
       
   494 
       
   495 
       
   496 // -----------------------------------------------------------------------------
       
   497 // CPEngContactListSettings::DeletePropertyL()
       
   498 // -----------------------------------------------------------------------------
       
   499 //
       
   500 void CPEngContactListSettings::DeletePropertyL( TUint aName,
       
   501                                                 TUint aLevel )
       
   502     {
       
   503     if ( PEngPropertyManager::DeletePropertyL( iProperties,
       
   504                                                aName,
       
   505                                                aLevel,
       
   506                                                iSettingsManager.StoreSize() ) )
       
   507         {
       
   508         iSettingsManager.StoreSettingsL();
       
   509         }
       
   510     }
       
   511 
       
   512 
       
   513 
       
   514 // =============================================================================
       
   515 // ===============Functions of main class ======================================
       
   516 // =============================================================================
       
   517 
       
   518 // -----------------------------------------------------------------------------
       
   519 // CPEngContactListSettings::UpdateListServerNameL()
       
   520 // -----------------------------------------------------------------------------
       
   521 //
       
   522 void CPEngContactListSettings::UpdateListServerNameL(
       
   523     const TDesC& aUserName,
       
   524     const TDesC& aDomain )
       
   525     {
       
   526     // allocate buffer as big as we need
       
   527     HBufC* newSrvNameBuf;
       
   528     newSrvNameBuf = HBufC::NewLC( aUserName.Length() +
       
   529                                   iName->Length() +
       
   530                                   aDomain.Length() +
       
   531                                   KPEngWVResourceSeparatorLength );
       
   532     TPtr newSrvName( newSrvNameBuf->Des() );
       
   533     newSrvName.Append( aUserName );
       
   534 
       
   535     // check if first character of the contact list name is '/'
       
   536     if ( KErrNone != iName->Left( 1 ).CompareF( KPEngWVResourceSeparator ) )
       
   537         {
       
   538         newSrvName.Append( KPEngWVResourceSeparator );
       
   539         }
       
   540 
       
   541     newSrvName.Append( *iName );
       
   542     newSrvName.Append( aDomain );
       
   543 
       
   544     delete iServerName;
       
   545     iServerName = newSrvNameBuf;
       
   546     CleanupStack::Pop(); //newSrvNameBuf
       
   547     }
       
   548 
       
   549 
       
   550 // -----------------------------------------------------------------------------
       
   551 // CPEngContactListSettings::DispName()
       
   552 // -----------------------------------------------------------------------------
       
   553 //
       
   554 const TDesC& CPEngContactListSettings::DispName() const
       
   555     {
       
   556     return *iDisplayName;
       
   557     }
       
   558 
       
   559 
       
   560 // -----------------------------------------------------------------------------
       
   561 // CPEngContactListSettings::PushUpdateDisplayNameL()
       
   562 // -----------------------------------------------------------------------------
       
   563 //
       
   564 void CPEngContactListSettings::PushUpdateDisplayNameL( HBufC* aDispName )   // CSI: 60 #
       
   565     {
       
   566     if ( KErrNone == iDisplayName->Compare( *aDispName ) )
       
   567         {
       
   568         delete aDispName;
       
   569         return;
       
   570         }
       
   571 
       
   572     // update display name
       
   573     iSettingsManager.StoreSize() += ( iDisplayName->Length() -
       
   574                                       aDispName->Length() );
       
   575     delete iDisplayName;
       
   576     iDisplayName = aDispName;
       
   577     iSettingsManager.StoreSettingsL();
       
   578     }
       
   579 
       
   580 
       
   581 // -----------------------------------------------------------------------------
       
   582 // CPEngContactListSettings::UpdateListTypeL()
       
   583 // -----------------------------------------------------------------------------
       
   584 //
       
   585 void CPEngContactListSettings::UpdateListTypeL(
       
   586     TPEngContactListType aContactListType )
       
   587     {
       
   588     iBehavior.iContactListType = aContactListType;
       
   589     iSettingsManager.StoreSettingsL();
       
   590     }
       
   591 
       
   592 
       
   593 
       
   594 // -----------------------------------------------------------------------------
       
   595 // CPEngContactListSettings::ExternalizeL()
       
   596 // -----------------------------------------------------------------------------
       
   597 //
       
   598 void CPEngContactListSettings::ExternalizeL( RWriteStream& aStream,
       
   599                                              TInt aStorageType ) const
       
   600     {
       
   601     switch ( aStorageType )
       
   602         {
       
   603         case EPEngStorageBasicPermanent:
       
   604             {
       
   605             // Store permanent part
       
   606 
       
   607             aStream.WriteInt32L( iName->Length() );
       
   608             aStream << *iName;
       
   609             aStream.WriteInt32L( iDisplayName->Length() );
       
   610             aStream << *iDisplayName;
       
   611 
       
   612             if ( iServerName )
       
   613                 {
       
   614                 aStream.WriteInt32L( iServerName->Length() );
       
   615                 aStream << *iServerName;
       
   616                 }
       
   617             else
       
   618                 {
       
   619                 aStream.WriteInt32L( 0 ); // no server name -zero
       
   620                 }
       
   621 
       
   622             aStream.WriteInt32L( iBehavior.iContactListType );
       
   623             aStream.WriteInt32L( iBehavior.iContactListNameAutoUpdate );
       
   624 
       
   625 
       
   626             // subscription attributes
       
   627             TInt attrCount( iSubscriptionAttrs.Count() );
       
   628             aStream.WriteInt32L( attrCount );
       
   629             for ( TInt x ( 0 ) ; x < attrCount ; ++x )
       
   630                 {
       
   631                 aStream.WriteInt32L( iSubscriptionAttrs[ x ] );
       
   632                 }
       
   633 
       
   634 
       
   635             // Detailed properties
       
   636             PEngPropertyManager::ExternalizePropertiesL( iProperties,
       
   637                                                          aStream,
       
   638                                                          aStorageType );
       
   639             break;
       
   640             };
       
   641 
       
   642 
       
   643         case EPEngStorageBasicCached:
       
   644             {
       
   645             // store cached part
       
   646             // Detailed properties
       
   647             PEngPropertyManager::ExternalizePropertiesL( iProperties,
       
   648                                                          aStream,
       
   649                                                          aStorageType );
       
   650             break;
       
   651             }
       
   652 
       
   653 
       
   654         default:
       
   655             {
       
   656             break;
       
   657             }
       
   658         }
       
   659     }
       
   660 
       
   661 
       
   662 // -----------------------------------------------------------------------------
       
   663 // CPEngContactListSettings::InternalizeL()
       
   664 // -----------------------------------------------------------------------------
       
   665 //
       
   666 void CPEngContactListSettings::InternalizeL( RReadStream& aStream,
       
   667                                              TInt aStorageType )
       
   668     {
       
   669     // write asked part
       
   670     switch ( aStorageType )
       
   671         {
       
   672         case EPEngStorageBasicPermanent:
       
   673             {
       
   674             // reset property array
       
   675             iProperties.ResetAndDestroy();
       
   676 
       
   677             // read permanent part
       
   678             delete iName;
       
   679             iName = NULL;
       
   680             TInt length ( aStream.ReadInt32L() );
       
   681             iName = HBufC::NewL( aStream, length );
       
   682             iSettingsManager.StoreSize() += length + 4; // 4 as TInt size
       
   683 
       
   684 
       
   685             delete iDisplayName;
       
   686             iDisplayName = NULL;
       
   687             length = aStream.ReadInt32L();
       
   688             iDisplayName = HBufC::NewL( aStream, length );
       
   689             iSettingsManager.StoreSize() += length + 4; // 4 as TInt size
       
   690 
       
   691 
       
   692             // read server name only if length is greater than 0
       
   693             delete iServerName;
       
   694             iServerName = NULL;
       
   695             length = aStream.ReadInt32L();
       
   696             if ( length > 0 )
       
   697                 {
       
   698                 iServerName = HBufC::NewL( aStream, length );
       
   699                 iSettingsManager.StoreSize() += length + 4; // 4 as TInt size
       
   700                 }
       
   701             else
       
   702                 {
       
   703                 iSettingsManager.StoreSize() += 4; // 4 as TInt size
       
   704                 }
       
   705 
       
   706 
       
   707             iBehavior.iContactListType = static_cast<TPEngContactListType>
       
   708                                          ( aStream.ReadInt32L() );
       
   709 
       
   710             iBehavior.iContactListNameAutoUpdate = aStream.ReadInt32L();
       
   711 
       
   712 
       
   713             // subscription attributes
       
   714             TInt count( aStream.ReadInt32L() );
       
   715             iSubscriptionAttrs.Reset();
       
   716             for ( TInt x ( 0 ) ; x < count ; ++x )
       
   717                 {
       
   718                 iSubscriptionAttrs.AppendL( aStream.ReadInt32L() );
       
   719                 }
       
   720 
       
   721             // type(4), auto update(4), count(4), each attribute 4x
       
   722             // first properties mark(4)
       
   723             iSettingsManager.StoreSize() += ( 16 + 4 * count );
       
   724 
       
   725             // Detailed properties
       
   726             PEngPropertyManager::InternalizePropertiesL( iProperties,
       
   727                                                          aStream,
       
   728                                                          iSettingsManager.StoreSize() );
       
   729             break;
       
   730             };
       
   731 
       
   732 
       
   733         case EPEngStorageBasicCached:
       
   734             {
       
   735             // read cached part
       
   736             // 4 for first property mark
       
   737 
       
   738             iSettingsManager.StoreSize() += 4;
       
   739             // Detailed properties
       
   740             PEngPropertyManager::InternalizePropertiesL( iProperties,
       
   741                                                          aStream,
       
   742                                                          iSettingsManager.StoreSize() );
       
   743             break;
       
   744             }
       
   745 
       
   746 
       
   747         default:
       
   748             {
       
   749             break;
       
   750             }
       
   751         }
       
   752     }
       
   753 
       
   754 //  End of File