PECengine/ListLibrary2/ContactListSrc/CPEngContactListModBase.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:  Contact list model implementation
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include    "CPEngContactListModBase.h"
       
    20 
       
    21 #include    "CPEngContactListModItemContainer.h"
       
    22 #include    "CPEngContactListModChangeMonitor.h"
       
    23 #include    "CPEngContactListSettings.h"
       
    24 #include    "MPEngContactListSettingsManager.h"
       
    25 #include    "MPEngAttributeList2.h"
       
    26 #include    "MPEngStorageManager.h"
       
    27 #include    "PEngListLibraryPanics.h"
       
    28 #include    "PEngContactIdsTools.h"
       
    29 #include    "PresenceDebugPrint.h"
       
    30 
       
    31 #include    <e32std.h>
       
    32 #include    <bamdesca.h>
       
    33 
       
    34 
       
    35 
       
    36 // CONSTANTS
       
    37 
       
    38 // 1001 -  initial version
       
    39 // 1002 -  store of the delta and monitor have now length of wv IDs,
       
    40 static const TInt KListStoreVersion = 1002;
       
    41 
       
    42 
       
    43 // Minimal size of the store entry for contact list model
       
    44 // count of permanent,cached, and 2 change monitor arrays
       
    45 static const TInt KListStoreMinSize = 16;
       
    46 
       
    47 
       
    48 
       
    49 // ============================ MEMBER FUNCTIONS ===============================
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CPEngContactListModBase::CPEngContactListModBase()
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 CPEngContactListModBase::CPEngContactListModBase(
       
    56     CPEngContactListSettings& aListSettings,
       
    57     MPEngContactListSettingsManager& aCntLstSettingsManager )
       
    58         : CPEngStoreEntry( StoreTypeForListType( aListSettings.BaseSettings().iContactListType ) ),
       
    59         iAccessCount( 1 ), // set initial access count to 1
       
    60         iSettings( &aListSettings ),
       
    61         iCntLstSettingsManager ( aCntLstSettingsManager )
       
    62     {
       
    63     iSize = KListStoreMinSize;
       
    64     }
       
    65 
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CPEngContactListModBase::ConstructL()
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 void CPEngContactListModBase::ConstructL( MPEngStorageManager& aStorageManager )
       
    72     {
       
    73     iStorageId = iSettings->Name().AllocL();
       
    74     iStorageId->Des().Fold();
       
    75     BaseConstructL( aStorageManager );      // CSI: 9 #
       
    76 
       
    77     iChangesMonitor = CPEngContactListModChangeMonitor::NewL( *this );
       
    78 
       
    79     iStorageManager->RetrieveL( *this );
       
    80 
       
    81     iCntLstSettingsManager.AddContactListSettingsObserverL( this );
       
    82     }
       
    83 
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CPEngContactListModBase::NewL()
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 CPEngContactListModBase* CPEngContactListModBase::NewL(
       
    90     CPEngContactListSettings& aListSettings,
       
    91     MPEngStorageManager& aStorageManager,
       
    92     MPEngContactListSettingsManager& aCntLstSettingsManager )
       
    93     {
       
    94     CPEngContactListModBase* self = NewLC( aListSettings,
       
    95                                            aStorageManager,
       
    96                                            aCntLstSettingsManager );
       
    97 
       
    98     CleanupStack::Pop();
       
    99     return self;
       
   100     }
       
   101 
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CPEngContactListModBase::NewL()
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 CPEngContactListModBase* CPEngContactListModBase::NewLC(
       
   108     CPEngContactListSettings& aListSettings,
       
   109     MPEngStorageManager& aStorageManager,
       
   110     MPEngContactListSettingsManager& aCntLstSettingsManager )
       
   111     {
       
   112     PENG_DP( D_PENG_LIT( "CPEngContactListModBase::NewLC() - %S" ),
       
   113              &aListSettings.Name() ) ;
       
   114 
       
   115     CPEngContactListModBase* self = new ( ELeave )
       
   116     CPEngContactListModBase( aListSettings,
       
   117                              aCntLstSettingsManager );
       
   118 
       
   119     CleanupClosePushL( *self );
       
   120     self->ConstructL( aStorageManager );
       
   121 
       
   122     return self;
       
   123     }
       
   124 
       
   125 
       
   126 // Destructor
       
   127 CPEngContactListModBase::~CPEngContactListModBase()
       
   128     {
       
   129     PENG_DP( D_PENG_LIT( "CPEngContactListModBase::~CPEngContactListModBase" ) ) ;
       
   130 
       
   131     // panic if object is still accessed
       
   132     __ASSERT_DEBUG( iAccessCount == 0 , Panic( ERefAccessedObjectDeleted ) );
       
   133 
       
   134 
       
   135     iCntLstSettingsManager.RemoveContactListSettingsObserver( this );
       
   136     iCntLstSettingsManager.RemoveModel( this );
       
   137 
       
   138     ResetLocalView();
       
   139     ResetNetworkView();
       
   140 
       
   141     iServerOrder.Reset();
       
   142 
       
   143     delete iChangesMonitor;
       
   144     delete iStorageId;
       
   145     }
       
   146 
       
   147 
       
   148 
       
   149 // =============================================================================
       
   150 // ===============Functions of MPEngContactListAdvance class ===================
       
   151 // =============================================================================
       
   152 
       
   153 // -----------------------------------------------------------------------------
       
   154 // CPEngContactListModBase::ContactItemAdvance()
       
   155 // -----------------------------------------------------------------------------
       
   156 //
       
   157 MPEngContactItemAdvance& CPEngContactListModBase::ContactItemAdvance(
       
   158     TInt aIndex,
       
   159     TPEngContactListView aView )
       
   160     {
       
   161     switch ( aView )
       
   162         {
       
   163         case EPEngCntListLocalView:
       
   164             {
       
   165             return *( iLocalView[ aIndex ] );
       
   166             }
       
   167 
       
   168         case EPEngCntListNetworkView:
       
   169             {
       
   170             return *( iNetworkView[ aIndex ] );
       
   171             }
       
   172 
       
   173         default:
       
   174             {
       
   175             Panic( EWrongViewId );
       
   176             return *( iNetworkView[ aIndex ] );
       
   177             }
       
   178         }
       
   179     }
       
   180 
       
   181 
       
   182 
       
   183 // =============================================================================
       
   184 // ===============Functions of MPEngContactList2 class =========================
       
   185 // =============================================================================
       
   186 
       
   187 // -----------------------------------------------------------------------------
       
   188 // CPEngContactListModBase::AddContactL()
       
   189 // -----------------------------------------------------------------------------
       
   190 //
       
   191 TInt CPEngContactListModBase::AddContactL( const TDesC& aContact,
       
   192                                            const TDesC& aNickName )
       
   193     {
       
   194     PENG_DP( D_PENG_LIT( "CPEngContactListModBase::AddIdL: %S, : %S" ),
       
   195              &this->StorageId(), &aContact );
       
   196 
       
   197     LeaveIfListUpdateInProgressL();
       
   198     iChangesMonitor->Reset();
       
   199 
       
   200     // Check if contact exists in the local list view
       
   201     TInt pos( KErrNotFound );
       
   202     if ( KErrNotFound != DoFindContact( iLocalView, aContact, pos ) )
       
   203         {
       
   204         // Contact already exists, leave
       
   205         User::Leave( KErrAlreadyExists );
       
   206         }
       
   207 
       
   208     // does contact exists in the network view
       
   209     TInt index ( DoFindContact( iNetworkView, aContact ) );
       
   210     if ( index != KErrNotFound )
       
   211         {
       
   212         // contact already exist on the network, it was probably removed
       
   213         // and now it is added, update nick name and reference
       
   214         iNetworkView[ index ]->UpdateNickNameL( aNickName );
       
   215         iLocalView.InsertL( iNetworkView[ index ], pos );
       
   216         iLocalView[ pos ]->Open( CPEngContactListModItemContainer::ELocalRef );
       
   217         }
       
   218 
       
   219     else
       
   220         {
       
   221         // Contact does not exist in any view, add it to the local one
       
   222         CPEngContactListModItemContainer* contact =
       
   223             CPEngContactListModItemContainer::NewNewNickLC( *this,
       
   224                                                             aContact,
       
   225                                                             aNickName );
       
   226 
       
   227         contact->SetFreshContact( ETrue );
       
   228         iLocalView.InsertL( contact, pos );
       
   229         iLocalView[ pos ]->Open( CPEngContactListModItemContainer::ELocalRef );
       
   230         CleanupStack::PopAndDestroy(); // contact
       
   231         }
       
   232 
       
   233 
       
   234     StoreContactListL();
       
   235     return pos;
       
   236     }
       
   237 
       
   238 
       
   239 // -----------------------------------------------------------------------------
       
   240 // CPEngContactListModBase::RemoveContactL()
       
   241 // -----------------------------------------------------------------------------
       
   242 //
       
   243 void CPEngContactListModBase::RemoveContactL( const TDesC& aContact )
       
   244     {
       
   245     PENG_DP( D_PENG_LIT( "CPEngContactListModBase::RemoveIdL - %S : %S " ),
       
   246              &this->StorageId(), &aContact );
       
   247 
       
   248     LeaveIfListUpdateInProgressL();
       
   249     iChangesMonitor->Reset();
       
   250 
       
   251     // does contact exist in the local view?
       
   252     TInt pos( DoFindContact( iLocalView, aContact ) );
       
   253     if ( pos == KErrNotFound )
       
   254         {
       
   255         // nothing to delete
       
   256         return;
       
   257         }
       
   258 
       
   259 
       
   260     iLocalView[ pos ]->CloseRef( CPEngContactListModItemContainer::ELocalRef );
       
   261     iLocalView.Remove( pos );
       
   262 
       
   263     StoreContactListL();
       
   264     }
       
   265 
       
   266 
       
   267 // -----------------------------------------------------------------------------
       
   268 // CPEngContactListModBase::FindContact()
       
   269 // -----------------------------------------------------------------------------
       
   270 //
       
   271 TInt CPEngContactListModBase::FindContact( const TDesC& aContact,
       
   272                                            TPEngContactListView aView ) const
       
   273     {
       
   274     switch ( aView )
       
   275         {
       
   276         case EPEngCntListLocalView:
       
   277             {
       
   278             return DoFindContact( iLocalView, aContact );
       
   279             }
       
   280 
       
   281         case EPEngCntListNetworkView:
       
   282             {
       
   283             return DoFindContact( iNetworkView, aContact );
       
   284             }
       
   285 
       
   286         case EPEngAddedContacts:
       
   287             {
       
   288             const TDesC& domain = iCntLstSettingsManager.UserDomain();
       
   289             return iChangesMonitor->FindContactIdInAdded( aContact, domain );
       
   290             }
       
   291 
       
   292         case EPEngRemovedContacts:
       
   293             {
       
   294             const TDesC& domain = iCntLstSettingsManager.UserDomain();
       
   295             return iChangesMonitor->FindContactIdInRemoved( aContact, domain );
       
   296             }
       
   297 
       
   298         default:
       
   299             {
       
   300             Panic( EWrongViewId );
       
   301             return KErrNotFound;
       
   302             }
       
   303         }
       
   304     }
       
   305 
       
   306 
       
   307 // -----------------------------------------------------------------------------
       
   308 // CPEngContactListModBase::Count()
       
   309 // -----------------------------------------------------------------------------
       
   310 //
       
   311 TInt CPEngContactListModBase::Count( TPEngContactListView aView ) const
       
   312     {
       
   313     switch ( aView )
       
   314         {
       
   315         case EPEngCntListLocalView:
       
   316             {
       
   317             return iLocalView.Count();
       
   318             }
       
   319 
       
   320         case EPEngCntListNetworkView:
       
   321             {
       
   322             return iNetworkView.Count();
       
   323             }
       
   324 
       
   325         case EPEngAddedContacts:
       
   326             {
       
   327             return iChangesMonitor->CountAddedContactIds();
       
   328             }
       
   329 
       
   330         case EPEngRemovedContacts:
       
   331             {
       
   332             return iChangesMonitor->CountRemovedContactIds();
       
   333             }
       
   334 
       
   335         default:
       
   336             {
       
   337             Panic( EWrongViewId );
       
   338             return 0;
       
   339             }
       
   340         }
       
   341     }
       
   342 
       
   343 
       
   344 // -----------------------------------------------------------------------------
       
   345 // CPEngContactListModBase::ContactItem()
       
   346 // -----------------------------------------------------------------------------
       
   347 //
       
   348 MPEngContactItem& CPEngContactListModBase::ContactItem( TInt aIndex,
       
   349                                                         TPEngContactListView aView )
       
   350     {
       
   351     return ContactItemAdvance( aIndex, aView );
       
   352     }
       
   353 
       
   354 
       
   355 // -----------------------------------------------------------------------------
       
   356 // CPEngContactListModBase::ContactItem()
       
   357 // -----------------------------------------------------------------------------
       
   358 //
       
   359 const MPEngContactItem& CPEngContactListModBase::ContactItem(
       
   360     TInt aIndex,
       
   361     TPEngContactListView aView ) const
       
   362     {
       
   363     switch ( aView )
       
   364         {
       
   365         case EPEngCntListLocalView:
       
   366             {
       
   367             return *( iLocalView[ aIndex ] );
       
   368             }
       
   369 
       
   370         case EPEngCntListNetworkView:
       
   371             {
       
   372             return *( iNetworkView[ aIndex ] );
       
   373             }
       
   374 
       
   375         default:
       
   376             {
       
   377             Panic( EWrongViewId );
       
   378             return *( iNetworkView[ aIndex ] );
       
   379             }
       
   380         }
       
   381     }
       
   382 
       
   383 
       
   384 // -----------------------------------------------------------------------------
       
   385 // CPEngContactListModBase::RemovedContacts()
       
   386 // -----------------------------------------------------------------------------
       
   387 //
       
   388 const MDesCArray& CPEngContactListModBase::RemovedContacts( ) const
       
   389     {
       
   390     return iChangesMonitor->RemovedContactIds();
       
   391     }
       
   392 
       
   393 
       
   394 // -----------------------------------------------------------------------------
       
   395 // CPEngContactListModBase::AddedContacts()
       
   396 // -----------------------------------------------------------------------------
       
   397 //
       
   398 const MDesCArray& CPEngContactListModBase::AddedContacts( ) const
       
   399     {
       
   400     return iChangesMonitor->AddedContactIds();
       
   401     }
       
   402 
       
   403 
       
   404 // -----------------------------------------------------------------------------
       
   405 // CPEngContactListModBase::ListProperties()
       
   406 // -----------------------------------------------------------------------------
       
   407 //
       
   408 MPEngContactListProperties& CPEngContactListModBase::ListProperties()
       
   409     {
       
   410     return *iSettings;
       
   411     }
       
   412 
       
   413 
       
   414 // -----------------------------------------------------------------------------
       
   415 // CPEngContactListModBase::RemoveAllContactIdsL()
       
   416 // -----------------------------------------------------------------------------
       
   417 //
       
   418 void CPEngContactListModBase::RemoveAllContactsL()
       
   419     {
       
   420     // reset local view and leave only network view
       
   421     ResetLocalView();
       
   422     StoreContactListL();
       
   423     }
       
   424 
       
   425 
       
   426 // -----------------------------------------------------------------------------
       
   427 // CPEngContactListModBase::SuspendUpdateNotification()
       
   428 // -----------------------------------------------------------------------------
       
   429 //
       
   430 void CPEngContactListModBase::SuspendUpdateNotification()
       
   431     {
       
   432     BufferServerSideNotifications();
       
   433     }
       
   434 
       
   435 
       
   436 // -----------------------------------------------------------------------------
       
   437 // CPEngContactListModBase::ReleaseUpdateNotification()
       
   438 // -----------------------------------------------------------------------------
       
   439 //
       
   440 void CPEngContactListModBase::ReleaseUpdateNotification()
       
   441     {
       
   442     ReleaseServerSideBuffering();
       
   443     }
       
   444 
       
   445 
       
   446 // -----------------------------------------------------------------------------
       
   447 // CPEngContactListModBase::RollBackAllChangesL()
       
   448 // -----------------------------------------------------------------------------
       
   449 //
       
   450 TInt CPEngContactListModBase::RollBackAllChangesL()
       
   451     {
       
   452     LeaveIfListUpdateInProgressL();
       
   453 
       
   454     RollbackL();
       
   455 
       
   456     return KErrNone;
       
   457     }
       
   458 
       
   459 
       
   460 // -----------------------------------------------------------------------------
       
   461 // CPEngContactListModBase::UpdateInProgress()
       
   462 // -----------------------------------------------------------------------------
       
   463 //
       
   464 TBool CPEngContactListModBase::UpdateInProgress() const
       
   465     {
       
   466     return iStorageManager->Locked( *this, EStorageLockLevelHigh );
       
   467     }
       
   468 
       
   469 
       
   470 // -----------------------------------------------------------------------------
       
   471 // CPEngContactListModBase::UpdateInProgress()
       
   472 // -----------------------------------------------------------------------------
       
   473 //
       
   474 TBool CPEngContactListModBase::UpdateRequired() const
       
   475     {
       
   476     TInt countLoc( iLocalView.Count() );
       
   477     TInt countNet( iNetworkView.Count() );
       
   478     if ( countLoc != countNet )
       
   479         {
       
   480         return ETrue;
       
   481         }
       
   482     for ( TInt x( 0 ) ; x < countLoc ; ++x )
       
   483         {
       
   484         if ( ( KErrNotFound == iNetworkView.Find( iLocalView[ x ] ) )
       
   485              ||
       
   486              ( iLocalView[ x ]->NewNick() )
       
   487            )
       
   488             {
       
   489             return ETrue;
       
   490             }
       
   491         }
       
   492     for ( TInt i( 0 ) ; i < countNet ; ++i )
       
   493         {
       
   494         if  ( KErrNotFound == iLocalView.Find( iNetworkView[ i ] ) )
       
   495             {
       
   496             return ETrue;
       
   497             }
       
   498         }
       
   499     return EFalse;
       
   500     }
       
   501 
       
   502 
       
   503 
       
   504 // =============================================================================
       
   505 // ===============Functions of CPEngStoreEntry class ===========================
       
   506 // =============================================================================
       
   507 
       
   508 // -----------------------------------------------------------------------------
       
   509 // CPEngContactListModBase::ExternalizeL()
       
   510 // -----------------------------------------------------------------------------
       
   511 //
       
   512 void CPEngContactListModBase::ExternalizeL( RWriteStream& aStream,
       
   513                                             TPEngStorageType aStorageType ) const
       
   514     {
       
   515     // what is the type of the list, if it is not mixed store all at once
       
   516     if ( EPEngMixedCachedVersionCon == StorageType() )
       
   517         {
       
   518         // whole list is cached, store it all
       
   519         ExternalizeContactsL( aStream, EPEngStorageBasicPermanent );
       
   520         ExternalizeContactsL( aStream, EPEngStorageBasicCached );
       
   521         iChangesMonitor->ExternalizeArrayL( aStream );
       
   522         return;
       
   523         }
       
   524 
       
   525 
       
   526     // write asked part
       
   527     switch ( aStorageType )
       
   528         {
       
   529         case EPEngStorageBasicPermanent:
       
   530             {
       
   531             // first write version of the storage
       
   532             aStream.WriteInt32L( KListStoreVersion );
       
   533 
       
   534             // store permanent part of the contact list
       
   535             ExternalizeContactsL( aStream, aStorageType );
       
   536             break;
       
   537             };
       
   538 
       
   539 
       
   540         case EPEngStorageBasicCached:
       
   541             {
       
   542             // store cached part of the contact list
       
   543             ExternalizeContactsL( aStream, aStorageType );
       
   544             iChangesMonitor->ExternalizeArrayL( aStream );
       
   545             break;
       
   546             }
       
   547 
       
   548 
       
   549         default:
       
   550             {
       
   551             break;
       
   552             }
       
   553         }
       
   554     }
       
   555 
       
   556 
       
   557 // -----------------------------------------------------------------------------
       
   558 // CPEngContactListModBase::InternalizeL()
       
   559 // -----------------------------------------------------------------------------
       
   560 //
       
   561 void CPEngContactListModBase::InternalizeL( RReadStream& aStream,
       
   562                                             TPEngStorageType aStorageType )
       
   563     {
       
   564     // what is the type of the list, if it is not mixed read all at once
       
   565     if ( EPEngMixedCachedVersionCon == StorageType() )
       
   566         {
       
   567         // whole list is cached, retrieve it once
       
   568         Reset();
       
   569         InternalizePermanentContactsL( aStream );
       
   570         InternalizeCachedContactsL( aStream );
       
   571         iChangesMonitor->InternalizeArrayL( aStream );
       
   572         return;
       
   573         }
       
   574 
       
   575 
       
   576     // read offered part
       
   577     switch ( aStorageType )
       
   578         {
       
   579         case EPEngStorageBasicPermanent:
       
   580             {
       
   581             // read permanent part of the contact list
       
   582             // fist check version
       
   583             Reset();
       
   584             if ( KListStoreVersion != aStream.ReadInt32L() )
       
   585                 {
       
   586                 // Version is wrong, remove file from store and reset
       
   587                 iStorageManager->Delete( *this );
       
   588                 return;
       
   589                 }
       
   590 
       
   591             // now internalize all permanent parts
       
   592             InternalizePermanentContactsL( aStream );
       
   593             break;
       
   594             }
       
   595 
       
   596 
       
   597         case EPEngStorageBasicCached:
       
   598             {
       
   599             // read cached part of the contact list
       
   600             InternalizeCachedContactsL( aStream );
       
   601             iChangesMonitor->InternalizeArrayL( aStream );
       
   602             break;
       
   603             }
       
   604 
       
   605 
       
   606         default:
       
   607             {
       
   608             break;
       
   609             }
       
   610         }
       
   611     }
       
   612 
       
   613 
       
   614 // -----------------------------------------------------------------------------
       
   615 // CPEngContactListModBase::StorageId()
       
   616 // -----------------------------------------------------------------------------
       
   617 //
       
   618 const TDesC& CPEngContactListModBase::StorageId() const
       
   619     {
       
   620     return *iStorageId;
       
   621     }
       
   622 
       
   623 
       
   624 // -----------------------------------------------------------------------------
       
   625 // CPEngContactListModBase::EntrySize()
       
   626 // -----------------------------------------------------------------------------
       
   627 //
       
   628 TUint32 CPEngContactListModBase::EntrySize() const
       
   629     {
       
   630     return iSize;
       
   631     }
       
   632 
       
   633 
       
   634 
       
   635 // =============================================================================
       
   636 // ===============Functions of MPEngSIDChangeObserver ==========================
       
   637 // =============================================================================
       
   638 
       
   639 // -----------------------------------------------------------------------------
       
   640 // CPEngContactListModBase::HandleSIDsChangeL()
       
   641 // -----------------------------------------------------------------------------
       
   642 //
       
   643 void CPEngContactListModBase::HandleSIDsChangeL( CPtrCArray& /* aChangedSIDs */ )
       
   644     {
       
   645     TInt err( iStorageManager->RetrieveL( *this ) );
       
   646     if ( err == KErrNotFound )
       
   647         {
       
   648         Reset();
       
   649         return;
       
   650         }
       
   651 
       
   652     if ( err != KErrNone )
       
   653         {
       
   654         iStorageManager->Delete( *this );
       
   655         }
       
   656     }
       
   657 
       
   658 
       
   659 // -----------------------------------------------------------------------------
       
   660 // CPEngContactListModBase::HandleSIDNotifyError()
       
   661 // -----------------------------------------------------------------------------
       
   662 //
       
   663 void CPEngContactListModBase::HandleSIDNotifyError( TInt /* aError */ )
       
   664     {
       
   665     Reset();
       
   666     }
       
   667 
       
   668 
       
   669 
       
   670 // =============================================================================
       
   671 // ===============Functions of MPEngContactListModStore ========================
       
   672 // =============================================================================
       
   673 
       
   674 // -----------------------------------------------------------------------------
       
   675 // CPEngContactListModBase::StoreSizeCount()
       
   676 // -----------------------------------------------------------------------------
       
   677 //
       
   678 TInt& CPEngContactListModBase::StoreSizeCount()
       
   679     {
       
   680     return iSize;
       
   681     }
       
   682 
       
   683 
       
   684 // -----------------------------------------------------------------------------
       
   685 // CPEngContactListModBase::StoreEntryL()
       
   686 // -----------------------------------------------------------------------------
       
   687 //
       
   688 void CPEngContactListModBase::StoreEntryL()
       
   689     {
       
   690     StoreL();
       
   691     }
       
   692 
       
   693 
       
   694 
       
   695 
       
   696 // =============================================================================
       
   697 // ===============Functions of MPEngContactListSettingsObserver class ==========
       
   698 // =============================================================================
       
   699 
       
   700 // -----------------------------------------------------------------------------
       
   701 // CPEngContactListModBase::RefreshSettingsReference()
       
   702 // -----------------------------------------------------------------------------
       
   703 //
       
   704 void CPEngContactListModBase::RefreshSettingsReference()
       
   705     {
       
   706     iSettings = iCntLstSettingsManager.ContactListSettingsOrNull( StorageId() );
       
   707     }
       
   708 
       
   709 
       
   710 
       
   711 // =============================================================================
       
   712 // ===============Functions of main class ======================================
       
   713 // =============================================================================
       
   714 
       
   715 // -----------------------------------------------------------------------------
       
   716 // CPEngContactListModBase::StoreTypeForListType()
       
   717 // -----------------------------------------------------------------------------
       
   718 //
       
   719 TPEngStorageType CPEngContactListModBase::StoreTypeForListType(
       
   720     TPEngContactListType aListType )
       
   721     {
       
   722     return ( aListType == EPEngCachedContactList ) ? EPEngMixedCachedVersionCon :
       
   723            EPEngMixedPermanentCachedVersionCon;
       
   724     }
       
   725 
       
   726 
       
   727 // -----------------------------------------------------------------------------
       
   728 // CPEngContactListModBase::Open()
       
   729 // -----------------------------------------------------------------------------
       
   730 //
       
   731 void CPEngContactListModBase::Open()
       
   732     {
       
   733     iAccessCount++;
       
   734     }
       
   735 
       
   736 
       
   737 // -----------------------------------------------------------------------------
       
   738 // CPEngContactListModBase::Close()
       
   739 // -----------------------------------------------------------------------------
       
   740 //
       
   741 void CPEngContactListModBase::Close()
       
   742     {
       
   743     iAccessCount--;
       
   744 
       
   745     if ( iAccessCount == 0 )
       
   746         {
       
   747         delete this;
       
   748         }
       
   749     }
       
   750 
       
   751 
       
   752 // -----------------------------------------------------------------------------
       
   753 // CPEngContactListModBase::StoreContactListL()
       
   754 // -----------------------------------------------------------------------------
       
   755 //
       
   756 void CPEngContactListModBase::StoreContactListL()
       
   757     {
       
   758     TRAPD( err, iStorageManager->StoreL( *this ) ) ;
       
   759     if ( err != KErrNone )
       
   760         {
       
   761         if ( err == KErrDiskFull )
       
   762             {
       
   763             if ( KErrNotFound == iStorageManager->RetrieveL( *this ) )
       
   764                 {
       
   765                 Reset();
       
   766                 }
       
   767             }
       
   768 
       
   769         User::Leave( err );
       
   770         }
       
   771     }
       
   772 
       
   773 
       
   774 // -----------------------------------------------------------------------------
       
   775 // CPEngContactListModBase::FillAddNickListL()
       
   776 // -----------------------------------------------------------------------------
       
   777 //
       
   778 void CPEngContactListModBase::FillAddNickListL(
       
   779     RPointerArray<CPEngContactListModItemContainer>& aAddNickList )
       
   780     {
       
   781     TInt count( iLocalView.Count() );
       
   782     for ( TInt x( 0 ) ; x < count ; ++x )
       
   783         {
       
   784         if ( ( KErrNotFound == iNetworkView.Find( iLocalView[ x ] ) ) ||
       
   785              ( iLocalView[ x ]->NewNick() ) )
       
   786             {
       
   787             aAddNickList.AppendL( iLocalView[ x ] );
       
   788             }
       
   789         }
       
   790     }
       
   791 
       
   792 
       
   793 // -----------------------------------------------------------------------------
       
   794 // CPEngContactListModBase::FillRemoveNickListL()
       
   795 // -----------------------------------------------------------------------------
       
   796 //
       
   797 void CPEngContactListModBase::FillRemoveNickListL(
       
   798     RPointerArray<CPEngContactListModItemContainer>& aRemoveNickList )
       
   799     {
       
   800     TInt count( iNetworkView.Count() );
       
   801     for ( TInt x( 0 ) ; x < count ; ++x )
       
   802         {
       
   803         if ( KErrNotFound == iLocalView.Find( iNetworkView[ x ] ) )
       
   804             {
       
   805             aRemoveNickList.AppendL( iNetworkView[ x ] );
       
   806             }
       
   807         }
       
   808     }
       
   809 
       
   810 
       
   811 // -----------------------------------------------------------------------------
       
   812 // CPEngContactListModBase::CommitAddContactsL()
       
   813 // -----------------------------------------------------------------------------
       
   814 //
       
   815 void CPEngContactListModBase::CommitAddContactsL()
       
   816     {
       
   817     TInt count( iLocalView.Count() );
       
   818     for ( TInt x( 0 ) ; x < count ; ++x )
       
   819         {
       
   820         iLocalView[ x ]->CommitNickName();
       
   821         iLocalView[ x ]->SetFreshContact( EFalse );
       
   822 
       
   823         if ( KErrNotFound == iNetworkView.Find( iLocalView[ x ] ) )
       
   824             {
       
   825             TInt pos( KErrNotFound );
       
   826             CPEngContactListModItemContainer* cnt = iLocalView[ x ];
       
   827             DoFindContact( iNetworkView, cnt->Id(), pos );
       
   828 
       
   829             iNetworkView.InsertL( cnt, pos );
       
   830             cnt->Open( CPEngContactListModItemContainer::ENetworkRef ); // CSI: 65 #
       
   831 
       
   832             // no order, add to the end
       
   833             cnt->SetServerIndex( iServerOrder.Count() );
       
   834             iServerOrder.AppendL( cnt );
       
   835 
       
   836             // add contact also to the added
       
   837             iChangesMonitor->InsertAddedContactIdL( cnt->Id() );
       
   838             }
       
   839         }
       
   840 
       
   841     StoreL();
       
   842     }
       
   843 
       
   844 
       
   845 // -----------------------------------------------------------------------------
       
   846 // CPEngContactListModBase::CommitRemoveContactsL()
       
   847 // -----------------------------------------------------------------------------
       
   848 //
       
   849 void CPEngContactListModBase::CommitRemoveContactsL()
       
   850     {
       
   851     for ( TInt x( iNetworkView.Count() - 1 ) ; x >= 0 ; --x )
       
   852         {
       
   853         if ( KErrNotFound == iLocalView.Find( iNetworkView[ x ] ) )
       
   854             {
       
   855             CPEngContactListModItemContainer* contact = iNetworkView[ x ];
       
   856 
       
   857             // cache the index that's being removed
       
   858             TInt serverIndex = contact->ServerIndex();
       
   859 
       
   860             // add contact also to the removed
       
   861             iChangesMonitor->InsertRemovedContactIdL( contact->Id() );
       
   862 
       
   863             // remove from the network ordered
       
   864             // let it panic, if not found
       
   865             // arrays should be always in sync
       
   866             iServerOrder.Remove( iServerOrder.Find( contact ) );
       
   867 
       
   868             contact->CloseRef( CPEngContactListModItemContainer::ENetworkRef );
       
   869 
       
   870             iNetworkView.Remove( x );
       
   871 
       
   872             // and reorganize iNetworkView's server indexes
       
   873             ReorganizeServerIndexOrder( serverIndex );
       
   874             }
       
   875         }
       
   876 
       
   877     StoreL();
       
   878     }
       
   879 
       
   880 
       
   881 // -----------------------------------------------------------------------------
       
   882 // CPEngContactListModBase::RollbackL()
       
   883 // -----------------------------------------------------------------------------
       
   884 //
       
   885 void CPEngContactListModBase::RollbackL()
       
   886     {
       
   887     // reset local list and add there items from the network one
       
   888     ResetLocalView();
       
   889 
       
   890     TInt count( iNetworkView.Count() );
       
   891     for ( TInt x( 0 ) ; x < count ; ++x )
       
   892         {
       
   893         iLocalView.AppendL( iNetworkView[ x ] );
       
   894         iNetworkView[ x ]->Open( CPEngContactListModItemContainer::ELocalRef );
       
   895         iNetworkView[ x ]->RollBackNickname();
       
   896         }
       
   897 
       
   898     StoreContactListL();
       
   899     }
       
   900 
       
   901 
       
   902 // -----------------------------------------------------------------------------
       
   903 // CPEngContactListModBase::FindContactInAll()
       
   904 // -----------------------------------------------------------------------------
       
   905 //
       
   906 CPEngContactListModItemContainer* CPEngContactListModBase::FindContactInAll(
       
   907     const TDesC& aContact )
       
   908     {
       
   909     TInt index ( DoFindContact( iLocalView, aContact ) );
       
   910     if ( index != KErrNotFound )
       
   911         {
       
   912         return iLocalView[ index ];
       
   913         }
       
   914 
       
   915     index = DoFindContact( iNetworkView, aContact );
       
   916     if ( index != KErrNotFound )
       
   917         {
       
   918         return iNetworkView[ index ];
       
   919         }
       
   920 
       
   921     return NULL;
       
   922     }
       
   923 
       
   924 
       
   925 // -----------------------------------------------------------------------------
       
   926 // CPEngContactListModBase::ContactExistsOnServer()
       
   927 // -----------------------------------------------------------------------------
       
   928 //
       
   929 TBool CPEngContactListModBase::ContactExistsOnServer(
       
   930     CPEngContactListModItemContainer& aContact )
       
   931     {
       
   932     return aContact.RefActive( CPEngContactListModItemContainer::ENetworkRef );
       
   933     }
       
   934 
       
   935 
       
   936 // -----------------------------------------------------------------------------
       
   937 // CPEngContactListModBase::AdoptNewContactsL()
       
   938 // -----------------------------------------------------------------------------
       
   939 //
       
   940 void CPEngContactListModBase::AdoptNewContactsL(
       
   941     RPointerArray<CPEngContactListModItemContainer>& aContacts )
       
   942     {
       
   943     ResetLocalView();
       
   944     ResetNetworkView();
       
   945 
       
   946     TInt count = aContacts.Count();
       
   947     for ( TInt ii( 0 ) ; ii < count ; ++ii )
       
   948         {
       
   949         // take always first in array
       
   950         CPEngContactListModItemContainer* cnt = aContacts[ 0 ];
       
   951         iLocalView.AppendL( cnt );
       
   952         cnt->Open( CPEngContactListModItemContainer::ELocalRef );   // CSI: 65 #
       
   953         iNetworkView.AppendL( cnt );
       
   954         cnt->Open( CPEngContactListModItemContainer::ENetworkRef ); // CSI: 65 #
       
   955         iServerOrder.AppendL( NULL );
       
   956         aContacts.Remove( 0 );
       
   957         cnt->Close();
       
   958         }
       
   959 
       
   960 
       
   961     RestoreServerOrderedArray();
       
   962     StoreL();
       
   963     }
       
   964 
       
   965 
       
   966 // -----------------------------------------------------------------------------
       
   967 // CPEngContactListModBase::AdoptNetworkViewL()
       
   968 // -----------------------------------------------------------------------------
       
   969 //
       
   970 void CPEngContactListModBase::AdoptNetworkViewL(
       
   971     RPointerArray<CPEngContactListModItemContainer>& aContacts )
       
   972     {
       
   973     ResetNetworkView();
       
   974 
       
   975     TInt count( aContacts.Count() );
       
   976     for ( TInt x( 0 ) ; x < count ; ++x )
       
   977         {
       
   978         // take always first in array
       
   979         CPEngContactListModItemContainer* cnt = aContacts[ 0 ];
       
   980         iNetworkView.AppendL( cnt );
       
   981         cnt->Open( CPEngContactListModItemContainer::ENetworkRef );     // CSI: 65 #
       
   982         iServerOrder.AppendL( NULL );
       
   983         aContacts.Remove( 0 );
       
   984         cnt->Close();
       
   985         }
       
   986 
       
   987     RestoreServerOrderedArray();
       
   988     StoreL();
       
   989     }
       
   990 
       
   991 
       
   992 // -----------------------------------------------------------------------------
       
   993 // CPEngContactListModBase::RemoveBadContactL()
       
   994 // -----------------------------------------------------------------------------
       
   995 //
       
   996 void CPEngContactListModBase::RemoveBadContactL( const TDesC& aContact )
       
   997     {
       
   998     iChangesMonitor->InsertRemovedContactIdL( aContact );
       
   999     iChangesMonitor->RemoveAddedContactId( aContact );
       
  1000 
       
  1001     CPEngContactListModItemContainer* cnt = FindContactInAll( aContact );
       
  1002 
       
  1003 
       
  1004     if ( cnt && cnt->RefActive( CPEngContactListModItemContainer::ENetworkRef ) )
       
  1005         {
       
  1006         TInt serverIndex = cnt->ServerIndex();
       
  1007 
       
  1008         iNetworkView.Remove( iNetworkView.Find( cnt ) );
       
  1009         cnt = cnt->CloseRef( CPEngContactListModItemContainer::ENetworkRef );
       
  1010         iServerOrder.Remove( iServerOrder.Find( cnt ) );
       
  1011 
       
  1012         // and reorganize iNetworkView's server indexes
       
  1013         ReorganizeServerIndexOrder( serverIndex );
       
  1014         }
       
  1015 
       
  1016 
       
  1017     if ( cnt && cnt->RefActive( CPEngContactListModItemContainer::ELocalRef ) )
       
  1018         {
       
  1019         iLocalView.Remove( iLocalView.Find( cnt ) );
       
  1020         cnt->CloseRef( CPEngContactListModItemContainer::ELocalRef );
       
  1021         }
       
  1022 
       
  1023     StoreL();
       
  1024     }
       
  1025 
       
  1026 
       
  1027 
       
  1028 // -----------------------------------------------------------------------------
       
  1029 // CPEngContactListModBase::Reset()
       
  1030 // -----------------------------------------------------------------------------
       
  1031 //
       
  1032 void CPEngContactListModBase::Reset()
       
  1033     {
       
  1034     ResetLocalView();
       
  1035     ResetNetworkView();
       
  1036     iChangesMonitor->Reset();
       
  1037 
       
  1038     iSize = KListStoreMinSize;
       
  1039     }
       
  1040 
       
  1041 
       
  1042 // -----------------------------------------------------------------------------
       
  1043 // CPEngContactListModBase::ResetLocalView()
       
  1044 // -----------------------------------------------------------------------------
       
  1045 //
       
  1046 void CPEngContactListModBase::ResetLocalView()
       
  1047     {
       
  1048     TInt count( iLocalView.Count() );
       
  1049     for ( TInt x( 0 ) ; x < count ; ++x )
       
  1050         {
       
  1051         iLocalView[ x ]->CloseRef( CPEngContactListModItemContainer::ELocalRef );
       
  1052         }
       
  1053 
       
  1054     iLocalView.Reset();
       
  1055     }
       
  1056 
       
  1057 
       
  1058 // -----------------------------------------------------------------------------
       
  1059 // CPEngContactListModBase::ResetNetworkView()
       
  1060 // -----------------------------------------------------------------------------
       
  1061 //
       
  1062 void CPEngContactListModBase::ResetNetworkView()
       
  1063     {
       
  1064     TInt count( iNetworkView.Count() );
       
  1065     for ( TInt x( 0 ) ; x < count ; ++x )
       
  1066         {
       
  1067         iNetworkView[ x ]->CloseRef( CPEngContactListModItemContainer::ENetworkRef );
       
  1068         }
       
  1069 
       
  1070     iNetworkView.Reset();
       
  1071     iServerOrder.Reset();
       
  1072     }
       
  1073 
       
  1074 
       
  1075 // -----------------------------------------------------------------------------
       
  1076 // CPEngContactListModBase::LeaveIfListUpdateInProgressL()
       
  1077 // -----------------------------------------------------------------------------
       
  1078 //
       
  1079 void CPEngContactListModBase::LeaveIfListUpdateInProgressL() const
       
  1080     {
       
  1081     if ( UpdateInProgress() )
       
  1082         {
       
  1083         User::Leave( KErrInUse );
       
  1084         }
       
  1085     }
       
  1086 
       
  1087 
       
  1088 
       
  1089 // -----------------------------------------------------------------------------
       
  1090 // CPEngContactListModBase::ChangeMonitor()
       
  1091 // -----------------------------------------------------------------------------
       
  1092 //
       
  1093 CPEngContactListModChangeMonitor& CPEngContactListModBase::ChangeMonitor()
       
  1094     {
       
  1095     return *iChangesMonitor;
       
  1096     }
       
  1097 
       
  1098 
       
  1099 // -----------------------------------------------------------------------------
       
  1100 // CPEngContactListModBase::Settings()
       
  1101 // -----------------------------------------------------------------------------
       
  1102 //
       
  1103 CPEngContactListSettings& CPEngContactListModBase::Settings()
       
  1104     {
       
  1105     return *iSettings;
       
  1106     }
       
  1107 
       
  1108 
       
  1109 // -----------------------------------------------------------------------------
       
  1110 // CPEngContactListModBase::ServerOrderedContacts()
       
  1111 // -----------------------------------------------------------------------------
       
  1112 //
       
  1113 const RPointerArray<CPEngContactListModItemContainer>&
       
  1114 CPEngContactListModBase::ServerOrderedContacts() const
       
  1115     {
       
  1116     return iServerOrder;
       
  1117     }
       
  1118 
       
  1119 
       
  1120 // -----------------------------------------------------------------------------
       
  1121 // CPEngContactListModBase::DoFindContact()
       
  1122 // -----------------------------------------------------------------------------
       
  1123 //
       
  1124 TInt CPEngContactListModBase::DoFindContact(
       
  1125     const RPointerArray<CPEngContactListModItemContainer>& aArray,
       
  1126     const TDesC& aContact,
       
  1127     TInt& aIndex,
       
  1128     TBool aFirstPrefered /* EFalse */ ) const
       
  1129     {
       
  1130     const TDesC& domain = iCntLstSettingsManager.UserDomain();
       
  1131     TInt high( aArray.Count() );
       
  1132 
       
  1133 
       
  1134     if ( !high ||
       
  1135          ( aFirstPrefered && 0 > NContactIdsTools::CompareContactIds( aContact,
       
  1136                                                                       aArray[ 0 ]->Id(),
       
  1137                                                                       domain ) ) )
       
  1138         {
       
  1139         aIndex = 0;
       
  1140         return KErrNotFound;
       
  1141         }
       
  1142 
       
  1143 
       
  1144     TInt low( 0 );
       
  1145     TInt ret( KErrNotFound );
       
  1146     while ( high > low )
       
  1147         {
       
  1148         TInt inx = ( low + high ) >> 1;
       
  1149         TInt k ( NContactIdsTools::CompareContactIds( aContact,
       
  1150                                                       aArray[ inx ]->Id(),
       
  1151                                                       domain ) );
       
  1152         if ( k == 0 )
       
  1153             {
       
  1154             aIndex = inx;
       
  1155             return KErrNone;
       
  1156             }
       
  1157         else if ( k > 0 )
       
  1158             low = inx + 1;
       
  1159         else
       
  1160             high = inx;
       
  1161         }
       
  1162     aIndex = high;
       
  1163     return ret;
       
  1164     }
       
  1165 
       
  1166 
       
  1167 // -----------------------------------------------------------------------------
       
  1168 // CPEngContactListModBase::DoFindContact()
       
  1169 // -----------------------------------------------------------------------------
       
  1170 //
       
  1171 TInt CPEngContactListModBase::DoFindContact(
       
  1172     const RPointerArray<CPEngContactListModItemContainer>& aArray,
       
  1173     const TDesC& aContact ) const
       
  1174     {
       
  1175     TInt index( KErrNotFound );
       
  1176     TInt err( DoFindContact( aArray, aContact, index ) );
       
  1177     if ( err != KErrNotFound )
       
  1178         {
       
  1179         return index;
       
  1180         }
       
  1181 
       
  1182     return KErrNotFound;
       
  1183     }
       
  1184 
       
  1185 
       
  1186 // -----------------------------------------------------------------------------
       
  1187 // CPEngContactListModBase::ExternalizeContactsL()
       
  1188 // -----------------------------------------------------------------------------
       
  1189 //
       
  1190 void CPEngContactListModBase::ExternalizeContactsL( RWriteStream& aStream,
       
  1191                                                     TPEngStorageType aStorageType ) const
       
  1192     {
       
  1193     TInt count( iLocalView.Count() );
       
  1194     for ( TInt x( 0 ) ; x < count  ; ++x )
       
  1195         {
       
  1196         aStream.WriteInt32L( KErrNone );
       
  1197         iLocalView[ x ]->ExternalizeL( aStream, aStorageType );
       
  1198         }
       
  1199 
       
  1200     count = iNetworkView.Count();
       
  1201     for ( TInt y( 0 ) ; y < count ; ++y )
       
  1202         {
       
  1203         if ( !iNetworkView[ y ]->RefActive( CPEngContactListModItemContainer::ELocalRef ) )
       
  1204             {
       
  1205             aStream.WriteInt32L( KErrNone );
       
  1206             iNetworkView[ y ]->ExternalizeL( aStream, aStorageType );
       
  1207             }
       
  1208         }
       
  1209 
       
  1210     aStream.WriteInt32L( KErrNotFound );
       
  1211     }
       
  1212 
       
  1213 
       
  1214 // -----------------------------------------------------------------------------
       
  1215 // CPEngContactListModBase::InternalizePermanentContactsL()
       
  1216 // -----------------------------------------------------------------------------
       
  1217 //
       
  1218 void CPEngContactListModBase::InternalizePermanentContactsL( RReadStream& aStream )
       
  1219     {
       
  1220     CPEngContactListModItemContainer* contact = NULL;
       
  1221 
       
  1222     while ( KErrNone == aStream.ReadInt32L() )
       
  1223         {
       
  1224         contact = CPEngContactListModItemContainer::NewLC( *this, aStream );
       
  1225 
       
  1226         if ( contact->RefActive( CPEngContactListModItemContainer::ELocalRef ) )
       
  1227             {
       
  1228             iLocalView.AppendL( contact );
       
  1229             contact->Open( CPEngContactListModItemContainer::ELocalRef ); // CSI: 65 #
       
  1230             }
       
  1231 
       
  1232         if ( contact->RefActive( CPEngContactListModItemContainer::ENetworkRef ) )
       
  1233             {
       
  1234             iNetworkView.AppendL( contact );
       
  1235             contact->Open( CPEngContactListModItemContainer::ENetworkRef ); // CSI: 65 #
       
  1236             iServerOrder.AppendL( NULL );
       
  1237             }
       
  1238 
       
  1239         CleanupStack::PopAndDestroy(); // contact
       
  1240         }
       
  1241 
       
  1242     RestoreServerOrderedArray();
       
  1243     }
       
  1244 
       
  1245 
       
  1246 // -----------------------------------------------------------------------------
       
  1247 // CPEngContactListModBase::InternalizeCachedContactsL()
       
  1248 // -----------------------------------------------------------------------------
       
  1249 //
       
  1250 void CPEngContactListModBase::InternalizeCachedContactsL( RReadStream& aStream )
       
  1251     {
       
  1252     TInt count( iLocalView.Count() );
       
  1253     for ( TInt x( 0 ) ; x < count ; ++x )
       
  1254         {
       
  1255         aStream.ReadInt32L(); // KErrNone
       
  1256         iLocalView[ x ]->InternalizeL( aStream, EPEngStorageBasicCached );
       
  1257         }
       
  1258 
       
  1259     count = iNetworkView.Count();
       
  1260     for ( TInt y( 0 ) ; y < count ; ++y )
       
  1261         {
       
  1262         if ( ! iNetworkView[ y ]->RefActive( CPEngContactListModItemContainer::ELocalRef ) )
       
  1263             {
       
  1264             aStream.ReadInt32L(); // KErrNone
       
  1265             iNetworkView[ y ]->InternalizeL( aStream, EPEngStorageBasicCached );
       
  1266             }
       
  1267         }
       
  1268 
       
  1269     aStream.ReadInt32L(); // KErrNotFound
       
  1270     }
       
  1271 
       
  1272 
       
  1273 // -----------------------------------------------------------------------------
       
  1274 // CPEngContactListModBase::RestoreServerOrderedArray()
       
  1275 // -----------------------------------------------------------------------------
       
  1276 //
       
  1277 void CPEngContactListModBase::RestoreServerOrderedArray()
       
  1278     {
       
  1279     TInt count( iNetworkView.Count() );
       
  1280     for ( TInt x( 0 ) ; x < count ; ++x )
       
  1281         {
       
  1282         CPEngContactListModItemContainer* contact = iNetworkView[ x ];
       
  1283         __ASSERT_DEBUG( count > contact->ServerIndex() , Panic( ERefServerOrderedArrayNotFilled ) );
       
  1284         iServerOrder[ contact->ServerIndex() ] = contact;
       
  1285         }
       
  1286     }
       
  1287 
       
  1288 
       
  1289 // -----------------------------------------------------------------------------
       
  1290 // CPEngContactListModBase::ReorganizeServerIndexOrder()
       
  1291 // -----------------------------------------------------------------------------
       
  1292 //
       
  1293 void CPEngContactListModBase::ReorganizeServerIndexOrder( TInt aIndex )
       
  1294     {
       
  1295     TInt networkViewCount( iNetworkView.Count() );
       
  1296 
       
  1297     for ( TInt ii( 0 ) ; ii < networkViewCount; ii++ )
       
  1298         {
       
  1299         TInt srvIndex( iNetworkView[ii]->ServerIndex() );
       
  1300         if ( srvIndex > aIndex )
       
  1301             {
       
  1302             srvIndex--;
       
  1303             iNetworkView[ii]->SetServerIndex( srvIndex );
       
  1304             }
       
  1305         }
       
  1306     }
       
  1307 
       
  1308 
       
  1309 
       
  1310 //  End of File
       
  1311 
       
  1312 
       
  1313 
       
  1314 
       
  1315 
       
  1316 
       
  1317 
       
  1318 
       
  1319 
       
  1320 
       
  1321 
       
  1322 
       
  1323 
       
  1324 
       
  1325 
       
  1326 
       
  1327 
       
  1328