PECengine/PresenceManager2/SrcAttribute/CPEngPresenceNotifier2Imp.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2004 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:  Notifier implementation to listen presence changes.
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include "CPEngPresenceNotifier2Imp.h"
       
    20 #include "CPEngTrackedPresenceIDCollection.h"
       
    21 #include "CPEngTrackedPresenceIDEntry.h"
       
    22 #include "CPEngNWSessionSlotID2.h"
       
    23 
       
    24 #include "TPEngMDesCArrayAdapter.h"
       
    25 #include "TPEngGenArrayAdapter.h"
       
    26 #include "GenObserverNotifyMediators.h"
       
    27 
       
    28 #include "CPEngNWSessionSlotStorageProxy.h"
       
    29 #include "MPEngPresenceAttrManager.h"
       
    30 #include "PEngAttrLibFactory.h"
       
    31 
       
    32 #include "MPEngStorageManagerWatcher.h"
       
    33 #include "PEngStorageManager.h"
       
    34 
       
    35 #include <CPEngPresenceNotifier2.h>
       
    36 #include <CPEngTrackedPresenceIDs2.h>
       
    37 #include <MPEngPresenceObserver2.h>
       
    38 #include <MPEngPresenceAttrModel2.h>
       
    39 #include "PresenceDebugPrint.h"
       
    40 #include "PEngWVPresenceAttributes2.h"
       
    41 
       
    42 
       
    43 
       
    44 
       
    45 // ============================ MEMBER FUNCTIONS ===============================
       
    46 
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CPEngPresenceNotifier2Imp::NewL()
       
    50 // Two-phased constructor.
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 CPEngPresenceNotifier2Imp* CPEngPresenceNotifier2Imp::NewL(
       
    54     CPEngPresenceNotifier2& aInterface,
       
    55     TInt aPriority,
       
    56     const CPEngNWSessionSlotID2& aNWSessionSlotID )
       
    57     {
       
    58     CPEngPresenceNotifier2Imp* self =
       
    59         new ( ELeave ) CPEngPresenceNotifier2Imp( aInterface, aPriority );
       
    60     CleanupStack::PushL( self );
       
    61     self->ConstructL( aNWSessionSlotID );
       
    62     CleanupStack::Pop( self );
       
    63     return self;
       
    64     }
       
    65 
       
    66 
       
    67 
       
    68 // Destructor
       
    69 CPEngPresenceNotifier2Imp::~CPEngPresenceNotifier2Imp()
       
    70     {
       
    71     iDying = ETrue;
       
    72 
       
    73     Stop();
       
    74 
       
    75 
       
    76     if ( iWatcher )
       
    77         {
       
    78         iWatcher->UnregisterListenSIDsObserver( *this );
       
    79         iWatcher->Close();
       
    80         }
       
    81 
       
    82     if ( iAttrManager )
       
    83         {
       
    84         iAttrManager->Close();
       
    85         }
       
    86 
       
    87     iObsArray.Close();
       
    88     delete iUsedSlot;
       
    89     delete iTrackedPresenceIDs;
       
    90     iTrackedAttributes.Reset();
       
    91     }
       
    92 
       
    93 
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // CPEngPresenceNotifier2Imp::CPEngPresenceNotifier2Imp
       
    97 // C++ default constructor can NOT contain any code, that
       
    98 // might leave.
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 CPEngPresenceNotifier2Imp::CPEngPresenceNotifier2Imp(
       
   102     CPEngPresenceNotifier2& aInterface,
       
   103     TInt aPriority )
       
   104         : iInterface( aInterface ),
       
   105         iCActivePriority( aPriority )
       
   106     {
       
   107     }
       
   108 
       
   109 
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // CPEngPresenceNotifier2Imp::ConstructL()
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 void CPEngPresenceNotifier2Imp::ConstructL(
       
   116     const CPEngNWSessionSlotID2& aNWSessionSlotID )
       
   117     {
       
   118     iUsedSlot = CPEngNWSessionSlotStorageProxy::NewL( aNWSessionSlotID );
       
   119     iWatcher = PEngStorageManager::GetStorageManagerWatcherL( iUsedSlot->BaseId() );
       
   120     iAttrManager = PEngAttrLibFactory::AttributeManagerInstanceL( iUsedSlot->BaseId() );
       
   121 
       
   122 
       
   123     iTrackedPresenceIDs = CPEngTrackedPresenceIDCollection::NewL();
       
   124     }
       
   125 
       
   126 
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CPEngPresenceNotifier2Imp::IsActive()
       
   130 // -----------------------------------------------------------------------------
       
   131 //
       
   132 TBool CPEngPresenceNotifier2Imp::IsActive() const
       
   133     {
       
   134     return iStarted;
       
   135     }
       
   136 
       
   137 
       
   138 // -----------------------------------------------------------------------------
       
   139 // CPEngPresenceNotifier2Imp::Start()
       
   140 // -----------------------------------------------------------------------------
       
   141 //
       
   142 TInt CPEngPresenceNotifier2Imp::Start( const MDesCArray& aPresenceIDs,
       
   143                                        const TArray<TUint32>& aTypes )
       
   144     {
       
   145     //sanity checks to encapsulate notifier behaviour
       
   146     if ( iDying )
       
   147         {
       
   148         //if dying, the notifier restart is silently ignored
       
   149         //because notifier is evidently shutting down
       
   150         return KErrNone;
       
   151         }
       
   152 
       
   153     if ( iStarted )
       
   154         {
       
   155         return KErrInUse;
       
   156         }
       
   157 
       
   158 
       
   159     CDesCArray* sidsList = NULL;
       
   160     TRAPD( err,
       
   161         {
       
   162         //Generate SIDs
       
   163         //Generating ignores duplicate attributes and presence IDs
       
   164         GenerateSidsL( sidsList, aPresenceIDs );
       
   165 
       
   166 
       
   167         //Add the ID & attributes to notify collection
       
   168         //Adding ignores duplicate attributes and presence IDs
       
   169         iTrackedPresenceIDs->AddTrackedIdsL( aPresenceIDs, aTypes );
       
   170 
       
   171 
       
   172         //Cache tracked attribute types
       
   173         //Adding ignores duplicate attributes
       
   174         AddTrackedAttributesL( aTypes );
       
   175 
       
   176 
       
   177         //and register for SID change events
       
   178         iWatcher->RegisterListenSIDsObserverL(
       
   179             *sidsList,
       
   180             *this,
       
   181             MPEngStorageManagerWatcher::EPEngObserverNormalPriority,
       
   182             EFalse );
       
   183         } );
       
   184 
       
   185     delete sidsList;
       
   186 
       
   187     if ( err == KErrNone )
       
   188         {
       
   189         iStarted = ETrue;
       
   190         }
       
   191 
       
   192     else
       
   193         {
       
   194         //Cancel the notification requests
       
   195         iTrackedPresenceIDs->RemoveAllTrackedIds();
       
   196         iWatcher->UnregisterListenSIDsObserver( *this );
       
   197         iTrackedAttributes.Reset();
       
   198         }
       
   199 
       
   200     return err;
       
   201     }
       
   202 
       
   203 
       
   204 // -----------------------------------------------------------------------------
       
   205 // CPEngPresenceNotifier2Imp::Stop()
       
   206 // -----------------------------------------------------------------------------
       
   207 //
       
   208 void CPEngPresenceNotifier2Imp::Stop()
       
   209     {
       
   210     //if not running, nothing to do
       
   211     if ( !iStarted )
       
   212         {
       
   213         return;
       
   214         }
       
   215 
       
   216 
       
   217     // The state must be set to stopped before actual stopping to
       
   218     // prevent unintentional event leaks.
       
   219     iStarted = EFalse;
       
   220 
       
   221     //Cancel the notification requests
       
   222     iWatcher->RestartSIDsObserver( *this );
       
   223 
       
   224     //Reset cached arrays
       
   225     iTrackedPresenceIDs->RemoveAllTrackedIds();
       
   226     iTrackedAttributes.Reset();
       
   227     }
       
   228 
       
   229 
       
   230 
       
   231 // -----------------------------------------------------------------------------
       
   232 // CPEngPresenceNotifier2Imp::Update()
       
   233 // -----------------------------------------------------------------------------
       
   234 //
       
   235 TInt CPEngPresenceNotifier2Imp::Update( const MDesCArray& aPresenceIDs,
       
   236                                         const TArray<TUint32>* aTypes,
       
   237                                         TBool aKeepOldTrackeds )
       
   238     {
       
   239     if ( !iStarted )
       
   240         {
       
   241         return KErrNotReady;
       
   242         }
       
   243 
       
   244     TArray<TUint32> trackedAttributesLocal = iTrackedAttributes.Array();
       
   245     if ( !aTypes )
       
   246         {
       
   247         aTypes = &trackedAttributesLocal;
       
   248         }
       
   249 
       
   250 
       
   251     CDesCArray* sidsList = NULL;
       
   252     TRAPD( err, UpdateWatcherL( sidsList,
       
   253                                 aPresenceIDs,
       
   254                                 *aTypes,
       
   255                                 aKeepOldTrackeds ) );
       
   256 
       
   257     //If there isn't sidsList, the add has failed totally
       
   258     //and there isn't a need to tidy the list or watcher
       
   259     if ( ( err != KErrNone ) && sidsList )
       
   260         {
       
   261         // if aKeepOldTrackeds was not active, no need to clean tracked ids
       
   262         if ( aKeepOldTrackeds )
       
   263             {
       
   264             iTrackedPresenceIDs->RemoveTrackedIds( aPresenceIDs, *aTypes );
       
   265             }
       
   266         iWatcher->RemoveSIDsFromSIDsObserver( *sidsList, *this );
       
   267         }
       
   268 
       
   269     delete sidsList;
       
   270     return err;
       
   271     }
       
   272 
       
   273 
       
   274 
       
   275 // -----------------------------------------------------------------------------
       
   276 // CPEngPresenceNotifier2Imp::Remove()
       
   277 // -----------------------------------------------------------------------------
       
   278 //
       
   279 TInt CPEngPresenceNotifier2Imp::Remove( const TDesC& aPresenceID )
       
   280     {
       
   281     if ( !iStarted )
       
   282         {
       
   283         return KErrNotReady;
       
   284         }
       
   285 
       
   286 
       
   287     const CPEngTrackedPresenceIDEntry* trackedID =
       
   288         iTrackedPresenceIDs->FindTrackedPresenceID( aPresenceID );
       
   289     if ( !trackedID )
       
   290         {
       
   291         return KErrNotFound;
       
   292         }
       
   293 
       
   294 
       
   295     TPEngMDesCArrayAdapter presenceIdAdapter( aPresenceID );
       
   296     CDesCArray* sidsList = NULL;
       
   297     TRAPD( err,
       
   298            GenerateSidsL( sidsList, presenceIdAdapter ) );
       
   299     if ( err != KErrNone )
       
   300         {
       
   301         delete sidsList;
       
   302         return err;
       
   303         }
       
   304 
       
   305 
       
   306     //No exceptions allowed below...
       
   307     iTrackedPresenceIDs->RemoveTrackedIds( presenceIdAdapter );
       
   308     iWatcher->RemoveSIDsFromSIDsObserver( *sidsList, *this );
       
   309     delete sidsList;
       
   310 
       
   311     return KErrNone;
       
   312     }
       
   313 
       
   314 
       
   315 
       
   316 // -----------------------------------------------------------------------------
       
   317 // CPEngPresenceNotifier2Imp::Remove()
       
   318 // -----------------------------------------------------------------------------
       
   319 //
       
   320 TInt CPEngPresenceNotifier2Imp::Remove( TUint32 aType )
       
   321     {
       
   322     if ( !iStarted )
       
   323         {
       
   324         return KErrNotReady;
       
   325         }
       
   326 
       
   327 
       
   328     //Gather first a filtered list of presence ID's that have
       
   329     //attribute as tracked
       
   330     iTrackedPresenceIDs->ResetFilteredList();
       
   331     const TInt trackedCount = iTrackedPresenceIDs->TrackedPresenceIDsCount();
       
   332     for ( TInt trackedIx = 0; trackedIx < trackedCount; trackedIx++ )
       
   333         {
       
   334         const CPEngTrackedPresenceIDEntry& trackedID =
       
   335             iTrackedPresenceIDs->TrackedPresenceID( trackedIx );
       
   336 
       
   337         if ( trackedID.IsOnlyTrackedAttribute( aType ) )
       
   338             {
       
   339             iTrackedPresenceIDs->IncludeToFilteredList( trackedIx );
       
   340             }
       
   341         }
       
   342 
       
   343     //Gather list of SIDs to unregister
       
   344     CDesCArray* sidsList = NULL;
       
   345 
       
   346     const MDesCArray& filteredList = iTrackedPresenceIDs->FilteredList();
       
   347     TPEngGenArrayAdapter< TUint32 > attrTypeAdapter( aType );
       
   348     //if( filteredList.MdcaCount() > 0 )
       
   349         {
       
   350         TRAPD( err,
       
   351                GenerateSidsL( sidsList,
       
   352                               filteredList ) );
       
   353         if ( err != KErrNone )
       
   354             {
       
   355             return err;
       
   356             }
       
   357         }
       
   358 
       
   359 
       
   360     //List of to be removed SIDs gathered -> do the remove
       
   361     //No exceptions allowed below...
       
   362 
       
   363     iTrackedPresenceIDs->RemoveTrackedIds( attrTypeAdapter.Array() );
       
   364     iWatcher->RemoveSIDsFromSIDsObserver( *sidsList, *this );
       
   365     delete sidsList;
       
   366 
       
   367     if ( RemoveTrackedAttributes( attrTypeAdapter.Array() ) )
       
   368         {
       
   369         return KErrNone;
       
   370         }
       
   371 
       
   372     return KErrNotFound;
       
   373     }
       
   374 
       
   375 
       
   376 // -----------------------------------------------------------------------------
       
   377 // CPEngPresenceNotifier2Imp::TrackedPresenceIDs()
       
   378 // -----------------------------------------------------------------------------
       
   379 //
       
   380 CPEngTrackedPresenceIDs2& CPEngPresenceNotifier2Imp::TrackedPresenceIDs()
       
   381     {
       
   382     return iTrackedPresenceIDs->Interface();
       
   383     }
       
   384 
       
   385 
       
   386 // -----------------------------------------------------------------------------
       
   387 // CPEngPresenceNotifier2Imp::AddObserver()
       
   388 // -----------------------------------------------------------------------------
       
   389 //
       
   390 TInt CPEngPresenceNotifier2Imp::AddObserver( MPEngPresenceObserver2& aObserver )
       
   391     {
       
   392     return iObsArray.AddObserver( &aObserver );
       
   393     }
       
   394 
       
   395 
       
   396 // -----------------------------------------------------------------------------
       
   397 // CPEngPresenceNotifier2Imp::RemoveObserver()
       
   398 // -----------------------------------------------------------------------------
       
   399 //
       
   400 TInt CPEngPresenceNotifier2Imp::RemoveObserver( MPEngPresenceObserver2& aObserver )
       
   401     {
       
   402     return iObsArray.RemoveObserver( &aObserver );
       
   403     }
       
   404 
       
   405 
       
   406 // -----------------------------------------------------------------------------
       
   407 // CPEngPresenceNotifier2Imp::HandleSIDsChangeL()
       
   408 // From MPEngSIDChangeObserver
       
   409 // -----------------------------------------------------------------------------
       
   410 //
       
   411 void CPEngPresenceNotifier2Imp::HandleSIDsChangeL( CPtrCArray& aChangedSIDs )
       
   412     {
       
   413     //if not running, don't notify the observers
       
   414     if ( !iStarted )
       
   415         {
       
   416         return;
       
   417         }
       
   418 
       
   419     iTrackedPresenceIDs->ResetPresenceChangeMarks();
       
   420     const TInt sidCount( aChangedSIDs.MdcaCount() );
       
   421 
       
   422     PENG_DP( D_PENG_LIT( "CPEngPresenceNotifier2Imp::HandleSIDsChangeL() - %d attribute SIDs" ),
       
   423              sidCount );
       
   424 
       
   425     for ( TInt sidIx( 0 ); sidIx < sidCount; sidIx++ )
       
   426         {
       
   427         TPtrC sid = aChangedSIDs.MdcaPoint( sidIx );
       
   428         TUint32 attribute = KPEngNullAttributeType;
       
   429         TPtrC presenceId( NULL, 0 );
       
   430         TInt err = iAttrManager->ResolveStoreId( sid, attribute, presenceId );
       
   431 
       
   432         if ( err == KErrNone )
       
   433             {
       
   434             iTrackedPresenceIDs->MarkPresenceChange( presenceId );
       
   435             }
       
   436         }
       
   437 
       
   438     MediateNotify( KErrNone );
       
   439     }
       
   440 
       
   441 
       
   442 
       
   443 
       
   444 // -----------------------------------------------------------------------------
       
   445 // CPEngPresenceNotifier2Imp::HandleSIDNotifyError()
       
   446 // From MPEngSIDChangeObserver
       
   447 // -----------------------------------------------------------------------------
       
   448 //
       
   449 void CPEngPresenceNotifier2Imp::HandleSIDNotifyError( TInt aError )
       
   450     {
       
   451     //if not running, don't notify the observers
       
   452     if ( !iStarted )
       
   453         {
       
   454         return;
       
   455         }
       
   456 
       
   457     iTrackedPresenceIDs->ResetPresenceChangeMarks();
       
   458     MediateNotify( aError );
       
   459     }
       
   460 
       
   461 
       
   462 
       
   463 
       
   464 
       
   465 // -----------------------------------------------------------------------------
       
   466 // CPEngPresenceNotifier2Imp::GenerateSidsL()
       
   467 // -----------------------------------------------------------------------------
       
   468 //
       
   469 void CPEngPresenceNotifier2Imp::GenerateSidsL( CDesCArray*& aGeneratedSids,
       
   470                                                const MDesCArray& aPresenceIDs )
       
   471     {
       
   472     aGeneratedSids = NULL;
       
   473 
       
   474     //Make sure that array granurality never gets to zero
       
   475     TInt granurality = aPresenceIDs.MdcaCount();
       
   476     if ( granurality == 0 )
       
   477         {
       
   478         granurality++;
       
   479         }
       
   480 
       
   481     CDesCArrayFlat* sids = new ( ELeave ) CDesCArrayFlat( granurality );
       
   482     CleanupStack::PushL( sids );
       
   483 
       
   484     const TInt presenceIdCount( aPresenceIDs.MdcaCount() );
       
   485     for ( TInt pIx( 0 ); pIx < presenceIdCount; pIx++ )
       
   486         {
       
   487         TPtrC presenceID( aPresenceIDs.MdcaPoint( pIx ) );
       
   488 
       
   489         // only one attribute to be observed
       
   490         HBufC* theSid = iAttrManager->GenerateStoreIdL( KUidPrAttrOnlineStatus, presenceID );
       
   491         CleanupStack::PushL( theSid );
       
   492 
       
   493         //This checks against duplicate PresenceIDs
       
   494         //==> Ignore duplicates
       
   495         TRAPD( err, sids->InsertIsqL( *theSid ) );
       
   496         if ( err != KErrAlreadyExists )
       
   497             {
       
   498             User::LeaveIfError( err );
       
   499             }
       
   500 
       
   501         CleanupStack::PopAndDestroy( theSid );
       
   502         }
       
   503 
       
   504     CleanupStack::Pop( sids );
       
   505     aGeneratedSids = sids;
       
   506     }
       
   507 
       
   508 
       
   509 // -----------------------------------------------------------------------------
       
   510 // CPEngPresenceNotifier2Imp::AddTrackedAttributesL()
       
   511 // -----------------------------------------------------------------------------
       
   512 //
       
   513 void CPEngPresenceNotifier2Imp::AddTrackedAttributesL( const TArray<TUint32>& aTypes )
       
   514     {
       
   515     const TInt count = aTypes.Count();
       
   516     for ( TInt ix = 0; ix < count; ix++ )
       
   517         {
       
   518         TRAPD( err, iTrackedAttributes.InsertInSignedKeyOrderL( aTypes[ ix ] ) );
       
   519         if ( err != KErrAlreadyExists )
       
   520             {
       
   521             User::LeaveIfError( err );
       
   522             }
       
   523         }
       
   524     }
       
   525 
       
   526 
       
   527 // -----------------------------------------------------------------------------
       
   528 // CPEngPresenceNotifier2Imp::RemoveTrackedAttributes()
       
   529 // -----------------------------------------------------------------------------
       
   530 //
       
   531 TBool CPEngPresenceNotifier2Imp::RemoveTrackedAttributes( const TArray<TUint32>& aTypes )
       
   532     {
       
   533     TBool anyRemoved = EFalse;
       
   534 
       
   535     const TInt count = aTypes.Count();
       
   536     for ( TInt ix = 0; ix < count; ix++ )
       
   537         {
       
   538         TInt index = iTrackedAttributes.FindInSignedKeyOrder( aTypes[ ix ] );
       
   539         if ( index != KErrNotFound )
       
   540             {
       
   541             iTrackedAttributes.Remove( index );
       
   542             anyRemoved = ETrue;
       
   543             }
       
   544         }
       
   545 
       
   546     return anyRemoved;
       
   547     }
       
   548 
       
   549 
       
   550 // -----------------------------------------------------------------------------
       
   551 // CPEngPresenceNotifier2Imp::MediateNotify()
       
   552 // -----------------------------------------------------------------------------
       
   553 //
       
   554 void CPEngPresenceNotifier2Imp::MediateNotify( TInt aError )
       
   555     {
       
   556     TPresenceNotifyMediator eventMediator( iInterface,
       
   557                                            *iTrackedPresenceIDs );
       
   558     if ( aError == KErrNone )
       
   559         {
       
   560         iObsArray.NotifyObservers( eventMediator );
       
   561         }
       
   562     else
       
   563         {
       
   564         iObsArray.NotifyErrorObservers( eventMediator, aError );
       
   565         }
       
   566     }
       
   567 
       
   568 
       
   569 // -----------------------------------------------------------------------------
       
   570 // CPEngPresenceNotifier2Imp::UpdateWatcherL()
       
   571 // -----------------------------------------------------------------------------
       
   572 //
       
   573 void CPEngPresenceNotifier2Imp::UpdateWatcherL(
       
   574     CDesCArray*& aSidsList,
       
   575     const MDesCArray& aPresenceIDs,
       
   576     const TArray<TUint32>& aTypes,
       
   577     TBool aKeepOldTrackeds )
       
   578     {
       
   579     GenerateSidsL( aSidsList, aPresenceIDs );
       
   580 
       
   581     //Update the ID & attributes to notify array
       
   582     // if we should not keep old ones, use temp tracked presence ids
       
   583     CPEngTrackedPresenceIDCollection* trackedIds = NULL;
       
   584     if ( !aKeepOldTrackeds )
       
   585         {
       
   586         trackedIds = CPEngTrackedPresenceIDCollection::NewL();
       
   587         CleanupStack::PushL( trackedIds );
       
   588         trackedIds->AddTrackedIdsL( aPresenceIDs, aTypes );
       
   589         }
       
   590     else
       
   591         {
       
   592         iTrackedPresenceIDs->AddTrackedIdsL( aPresenceIDs, aTypes );
       
   593         }
       
   594 
       
   595     //And update SID change request
       
   596     //aKeepOldTrackeds determines is this add or update
       
   597     iWatcher->RegisterListenSIDsObserverL( *aSidsList,
       
   598                                            *this,
       
   599                                            MPEngStorageManagerWatcher::EPEngObserverNormalPriority,
       
   600                                            aKeepOldTrackeds );
       
   601 
       
   602     if ( trackedIds )
       
   603         {
       
   604         delete iTrackedPresenceIDs;
       
   605         iTrackedPresenceIDs = trackedIds;
       
   606         CleanupStack::Pop( trackedIds );
       
   607         }
       
   608     }
       
   609 
       
   610 
       
   611 // -----------------------------------------------------------------------------
       
   612 // CPEngPresenceNotifier2Imp::TPresenceNotifyMediator::TPresenceNotifyMediator()
       
   613 // -----------------------------------------------------------------------------
       
   614 //
       
   615 CPEngPresenceNotifier2Imp::TPresenceNotifyMediator::TPresenceNotifyMediator(
       
   616     CPEngPresenceNotifier2& aNotifier,
       
   617     CPEngTrackedPresenceIDCollection& aPresenceIds )
       
   618         : iNotifier( aNotifier ),
       
   619         iPresenceIds( aPresenceIds )
       
   620     {
       
   621     }
       
   622 
       
   623 // -----------------------------------------------------------------------------
       
   624 // CPEngPresenceNotifier2Imp::TPresenceNotifyMediator::MediateNotifyL()
       
   625 // -----------------------------------------------------------------------------
       
   626 //
       
   627 void CPEngPresenceNotifier2Imp::TPresenceNotifyMediator::MediateNotifyL(
       
   628     MPEngPresenceObserver2& aObserverToNotify )
       
   629     {
       
   630     iPresenceIds.ResetTrackedEntriesIterators();
       
   631     iPresenceIds.Interface().ResetTrackedIterator();
       
   632     iPresenceIds.Interface().ResetChangedIterator();
       
   633 
       
   634     aObserverToNotify.HandlePresenceChangeL( iNotifier, iPresenceIds.Interface() );
       
   635     }
       
   636 
       
   637 
       
   638 
       
   639 // -----------------------------------------------------------------------------
       
   640 // CPEngPresenceNotifier2Imp::TPresenceNotifyMediator::MediateNotifyError()
       
   641 // -----------------------------------------------------------------------------
       
   642 //
       
   643 void CPEngPresenceNotifier2Imp::TPresenceNotifyMediator::MediateNotifyError(
       
   644     MPEngPresenceObserver2& aObserverToNotify,
       
   645     TInt aLeaveError )
       
   646     {
       
   647     aObserverToNotify.HandlePresenceError( aLeaveError, iNotifier );
       
   648     }
       
   649 
       
   650 
       
   651 
       
   652 // End of File
       
   653 
       
   654 
       
   655