ccservices/cmsservices/contactpresence/src/presenceiconinfo.cpp
branchRCL_3
changeset 63 f4a778e096c2
child 64 c1e8ba0c2b16
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2008 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 presence
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include <e32std.h>
       
    22 
       
    23 #include <CVPbkContactLinkArray.h>
       
    24 #include <CVPbkContactManager.h>
       
    25 #include <MVPbkSingleContactOperationObserver.h>
       
    26 #include <MVPbkStoreContact.h>
       
    27 #include <MVPbkContactOperationBase.h>
       
    28 #include <MVPbkContactLink.h>
       
    29 #include <MVPbkFieldType.h>
       
    30 #include <CVPbkContactFieldIterator.h>
       
    31 #include <MVPbkContactFieldTextData.h>
       
    32 #include <MVPbkContactFieldUriData.h>
       
    33 
       
    34 #include <mcontactpresenceobs.h>
       
    35 
       
    36 #include "mpresencetrafficlights.h"
       
    37 #include "mpresencetrafficlightsobs.h"
       
    38 #include "contactpresence.h"
       
    39 #include "contactstoreaccessor.h"
       
    40 #include "presenceiconinfo.h"
       
    41 #include "presenceiconinfores.h"
       
    42 
       
    43 #ifdef _TEST_MODE
       
    44 #include "testmodeutils.h"
       
    45 #endif
       
    46 
       
    47 
       
    48 // ================= MEMBER FUNCTIONS =======================
       
    49 //
       
    50 
       
    51 // ----------------------------------------------------------
       
    52 // CPresenceIconInfo::CPresenceIconInfo
       
    53 // ----------------------------------------------------------
       
    54 //
       
    55 CPresenceIconInfo::CPresenceIconInfo(
       
    56     CPresenceIconInfoListener& aParent,
       
    57     MContactPresenceObs& aObs,
       
    58     MPresenceTrafficLights& aIcons,
       
    59     TBool aIsSubscription,
       
    60     TInt aOpId )
       
    61     : iParent( aParent), iObs( aObs ),
       
    62     iDestroyedPtr( NULL ),
       
    63     iIcons( aIcons ),
       
    64     iWaiting(ETrue),
       
    65     iInitialization(EFalse), iNotifyPending(EFalse), 
       
    66     iSubscription(aIsSubscription), iOpId(aOpId)
       
    67     {
       
    68     }
       
    69 
       
    70 // ----------------------------------------------------------
       
    71 // CPresenceIconInfo::~CPresenceIconInfo
       
    72 // ----------------------------------------------------------
       
    73 //
       
    74 CPresenceIconInfo::~CPresenceIconInfo()
       
    75     {
       
    76 #ifdef _DEBUG
       
    77     CContactPresence::WriteToLog( _L8( "CPresenceIconInfo::~CPresenceIconInfo this=%d" ),(TInt)this );
       
    78 #endif
       
    79     ResetData();
       
    80     
       
    81     delete iContactLink;
       
    82     iContactLink = NULL;
       
    83 
       
    84     delete iPbkContactLink;
       
    85     iPbkContactLink = NULL;
       
    86     
       
    87     iPendings.Close();
       
    88     iPendings2.ResetAndDestroy();
       
    89     iPendings2.Close();    
       
    90 
       
    91     if ( iDestroyedPtr )
       
    92         {
       
    93         // We are called inside callback
       
    94         *iDestroyedPtr = ETrue;
       
    95         iDestroyedPtr = NULL;
       
    96         }
       
    97     }
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // CPresenceIconInfo::Destroy
       
   101 // -----------------------------------------------------------------------------
       
   102 void CPresenceIconInfo::Destroy()
       
   103     {    
       
   104     if ( iPbkContactLink && IsSubscription() )
       
   105         {         
       
   106         iIcons.UnsubscribeBrandingForContact( iPbkContactLink, this );
       
   107         }
       
   108     else
       
   109         {      
       
   110         }
       
   111     iLink.Deque();
       
   112     delete this;
       
   113     }
       
   114 // ----------------------------------------------------------
       
   115 // CPresenceIconInfo::NewL
       
   116 // ----------------------------------------------------------
       
   117 //
       
   118 CPresenceIconInfo* CPresenceIconInfo::NewL(
       
   119         CPresenceIconInfoListener& aParent,
       
   120         MContactPresenceObs& aObs,
       
   121         const TDesC8& aPackedContactId,
       
   122         MPresenceTrafficLights& aIcons,
       
   123         TBool aIsSubscription,
       
   124         TInt aOpId )
       
   125     {
       
   126     CPresenceIconInfo* self = new (ELeave) CPresenceIconInfo( aParent, aObs, aIcons, aIsSubscription, aOpId );
       
   127     CleanupStack::PushL( self );
       
   128     self->ConstructL(  aPackedContactId );
       
   129     CleanupStack::Pop( self );
       
   130     return self;
       
   131     }
       
   132 
       
   133 // ---------------------------------------------------------------------------
       
   134 // CPresenceIconInfo::ConstructL
       
   135 // ---------------------------------------------------------------------------
       
   136 //
       
   137 void CPresenceIconInfo::ConstructL( const TDesC8& aPackedContactId )
       
   138     {
       
   139 #ifdef _DEBUG
       
   140     CContactPresence::WriteToLog( _L8( "CPresenceIconInfo::ConstructL this=%d" ),(TInt)this );
       
   141 #endif
       
   142     iContactLink = aPackedContactId.AllocL();
       
   143     }
       
   144 
       
   145 // ----------------------------------------------------------
       
   146 // CPresenceIconInfo::ContactLink
       
   147 // ----------------------------------------------------------
       
   148 //
       
   149 TPtrC8 CPresenceIconInfo::ContactLink()
       
   150     {
       
   151     return iContactLink ? iContactLink->Des() : TPtrC8();
       
   152     }
       
   153 
       
   154 // ----------------------------------------------------------
       
   155 // CPresenceIconInfo::StartGetIconInfoL
       
   156 // ----------------------------------------------------------
       
   157 //
       
   158 void CPresenceIconInfo::StartGetIconInfoL(  )
       
   159     {
       
   160 #ifdef _DEBUG
       
   161     CContactPresence::WriteToLog( _L8( "CPresenceIconInfo::StartGetIconInfoL this=%d" ),(TInt)this );
       
   162 #endif    
       
   163     FetchContactL();
       
   164     iWaiting = EFalse;    
       
   165     }
       
   166 
       
   167  // ----------------------------------------------------------
       
   168  // CPresenceIconInfo::FetchContactL
       
   169  //
       
   170  // ----------------------------------------------------------
       
   171  //
       
   172 void CPresenceIconInfo::FetchContactL( )
       
   173      {
       
   174 #ifdef _DEBUG
       
   175      CContactPresence::WriteToLog( _L8( "CPresenceIconInfo::FetchContactL this=%d" ),(TInt)this );
       
   176 #endif
       
   177      ResetData();
       
   178      CVPbkContactLinkArray* lArray = CVPbkContactLinkArray::NewLC(
       
   179              ContactLink() , *(iParent.ContactStoreAccessor()->AccessStoreList()) );
       
   180 
       
   181      iLinkArray = lArray;
       
   182      CleanupStack::Pop();  //lArray
       
   183      
       
   184      if ( !iLinkArray || !iLinkArray->Count() )
       
   185     	 {
       
   186     	 User::Leave( KErrNotFound );
       
   187     	 }
       
   188      iOperation = iParent.ContactStoreAccessor()->AccessContactManager()->RetrieveContactL( iLinkArray->At( 0 ), *this );
       
   189      }
       
   190 
       
   191  // ----------------------------------------------------------
       
   192  // CPresenceIconInfo::ResetData
       
   193  //
       
   194  // ----------------------------------------------------------
       
   195  //
       
   196  void CPresenceIconInfo::ResetData()
       
   197      {
       
   198      delete iLinkArray;
       
   199      iLinkArray = NULL;
       
   200      delete iOperation;
       
   201      iOperation = NULL;
       
   202      }
       
   203 
       
   204  // ----------------------------------------------------------
       
   205  // CPresenceIconInfo::ResetData
       
   206  //
       
   207  // ----------------------------------------------------------
       
   208  //
       
   209  void CPresenceIconInfo::ResetData( MVPbkContactOperationBase& aOperation )
       
   210      {
       
   211      delete iLinkArray;
       
   212      iLinkArray = NULL;
       
   213      if ( iOperation == &aOperation )
       
   214          {
       
   215          delete iOperation;
       
   216          iOperation = NULL;
       
   217          }
       
   218      }
       
   219 
       
   220  // ----------------------------------------------------------
       
   221  // CPresenceIconInfo::VPbkSingleContactOperationComplete
       
   222  //
       
   223  // ----------------------------------------------------------
       
   224  //
       
   225  void CPresenceIconInfo::VPbkSingleContactOperationComplete( 
       
   226      MVPbkContactOperationBase& aOperation,
       
   227      MVPbkStoreContact* aContact )
       
   228      {
       
   229 #ifdef _DEBUG
       
   230      CContactPresence::WriteToLog( _L8( "CPresenceIconInfo::VPbkSingleContactOperationComplete this=%d" ),(TInt)this );
       
   231 #endif
       
   232      iInitialization = ETrue;     
       
   233      ResetData( aOperation );
       
   234        
       
   235      TRAPD( errx, DoVPbkSingleContactOperationCompleteL( aOperation, aContact ));
       
   236      iInitialization = EFalse;       
       
   237      if ( errx )
       
   238          {
       
   239          SendErrorCallback( errx );
       
   240          }
       
   241      else
       
   242          {
       
   243          SendPendingCallback();
       
   244          }
       
   245      return;
       
   246      }
       
   247 
       
   248  // ----------------------------------------------------------
       
   249  // CPresenceIconInfo::DoVPbkSingleContactOperationCompleteL
       
   250  //
       
   251  // ----------------------------------------------------------
       
   252  //
       
   253  void CPresenceIconInfo::DoVPbkSingleContactOperationCompleteL( 
       
   254      MVPbkContactOperationBase& /*aOperation*/,
       
   255      MVPbkStoreContact* aContact )
       
   256      {
       
   257 #ifdef _DEBUG
       
   258      CContactPresence::WriteToLog( _L8( "CPresenceIconInfo::DoVPbkSingleContactOperationComplete this=%d" ),(TInt)this );
       
   259 #endif
       
   260           
       
   261 #ifdef _TEST_MODE     
       
   262      // check if not deleted in callback
       
   263      TBool destroyed( EFalse );
       
   264      iDestroyedPtr = &destroyed; 
       
   265 #endif  
       
   266      
       
   267      aContact->PushL();
       
   268            
       
   269      MVPbkContactLink* cLink = aContact->CreateLinkLC();
       
   270      iPbkContactLink = cLink;
       
   271      CleanupStack::Pop( ); // cLink
       
   272      
       
   273      // get data from db
       
   274      CDesCArrayFlat* identities = FetchContactFieldsLC( aContact );
       
   275           
       
   276      if ( iSubscription )
       
   277          {        
       
   278          // start to subscribe icon info notifications         
       
   279          iIcons.SubscribeBrandingForContactL( iPbkContactLink, identities, this, 0 );           
       
   280          }
       
   281      else
       
   282          {
       
   283          // get service icons once
       
   284          iIcons.GetAllBrandingsForContactL( iPbkContactLink, identities, this, iOpId );                  
       
   285          }
       
   286            
       
   287      CleanupStack::PopAndDestroy( identities );
       
   288      CleanupStack::PopAndDestroy( ); // aContact
       
   289                         
       
   290      // ---------------------------------------------------------             
       
   291 #ifdef _TEST_MODE
       
   292     /**
       
   293      * INTERNAL TEST SUITE
       
   294      */
       
   295                
       
   296      // the Subscribe method above may call callback methods immediately and 
       
   297      // the client may have deleted us.
       
   298      if ( destroyed )
       
   299          {
       
   300          return;
       
   301          } 
       
   302      
       
   303     iDestroyedPtr = NULL;
       
   304     const TInt KTestCase = 3; 
       
   305     if ( TestModeUtils::TestCase() == KTestCase )
       
   306         {
       
   307         User::Leave( KErrGeneral );
       
   308         }
       
   309 #endif
       
   310 // --------------------------------------------------------- 
       
   311              
       
   312      return;
       
   313      }
       
   314 
       
   315  // ----------------------------------------------------------
       
   316  // CPresenceIconInfo::VPbkSingleContactOperationFailed
       
   317  //
       
   318  // ----------------------------------------------------------
       
   319  //
       
   320  void CPresenceIconInfo::VPbkSingleContactOperationFailed( MVPbkContactOperationBase& /*aOperation*/, TInt aError )
       
   321      {
       
   322 #ifdef _DEBUG
       
   323      CContactPresence::WriteToLog( _L8( "CPresenceIconInfo::VPbkSingleContactOperationComplete this=%d" ),(TInt)this );
       
   324 #endif
       
   325      ResetData();
       
   326      SendErrorCallback( aError );
       
   327      }
       
   328 
       
   329  // ----------------------------------------------------------
       
   330  // CPresenceIconInfo::FetchContactFieldsLC
       
   331  //
       
   332  // ----------------------------------------------------------
       
   333  //
       
   334  CDesCArrayFlat* CPresenceIconInfo::FetchContactFieldsLC( MVPbkStoreContact* aContact )
       
   335      {
       
   336 #ifdef _DEBUG
       
   337      CContactPresence::WriteToLog( _L8( "CPresenceIconInfo::FetchContactFieldsLC this=%d" ),(TInt)this );
       
   338 #endif
       
   339      const TInt myCount = sizeof( KPresenceFieldGroup ) / sizeof( KPresenceFieldGroup[0]);
       
   340      CDesCArrayFlat* fieldArray = new ( ELeave ) CDesCArrayFlat( myCount );
       
   341      CleanupStack::PushL( fieldArray );
       
   342      for( TInt i = 0;i < myCount;i++ )
       
   343          {
       
   344          FetchContactFieldL( KPresenceFieldGroup[i], *fieldArray, aContact );
       
   345          }
       
   346      return fieldArray;
       
   347      }
       
   348 
       
   349  // ----------------------------------------------------------
       
   350  // CPresenceIconInfo::FetchContactFieldL
       
   351  //
       
   352  // ----------------------------------------------------------
       
   353  //
       
   354 void CPresenceIconInfo::FetchContactFieldL( TInt aResourceId, CDesCArrayFlat& aArray, MVPbkStoreContact* aContact )
       
   355      {
       
   356 #ifdef _DEBUG
       
   357      CContactPresence::WriteToLog( _L8( "CPresenceIconInfo::FetchContactFieldL this=%d" ),(TInt)this );
       
   358 #endif
       
   359      const MVPbkFieldType* type = iParent.ContactStoreAccessor()->AccessContactManager()->FieldTypes().Find( aResourceId );
       
   360 
       
   361      CVPbkBaseContactFieldTypeIterator* itr = CVPbkBaseContactFieldTypeIterator::NewLC( *type, aContact->Fields() );
       
   362      while ( itr->HasNext() )
       
   363          {
       
   364          const MVPbkBaseContactField* field = itr->Next();
       
   365          if ( aResourceId == R_VPBK_FIELD_TYPE_IMPP )
       
   366              {
       
   367              const MVPbkContactFieldUriData& uri = MVPbkContactFieldUriData::Cast( field->FieldData() );
       
   368              aArray.AppendL( uri.Uri() );
       
   369              }
       
   370          else
       
   371              {
       
   372              const MVPbkContactFieldTextData& text = MVPbkContactFieldTextData::Cast( field->FieldData() );
       
   373              aArray.AppendL( text.Text() );
       
   374              }
       
   375          }
       
   376      CleanupStack::PopAndDestroy( itr );
       
   377      return;
       
   378      }
       
   379 
       
   380 // ----------------------------------------------------------
       
   381 //
       
   382 void CPresenceIconInfo::NewIconForContact(
       
   383     MVPbkContactLink* /*aLink*/,
       
   384     const TDesC8& aBrandId,
       
   385     const TDesC8& aElementId,
       
   386     TInt /*aId*/,
       
   387     TInt /*aBrandLanguage*/ )
       
   388     {
       
   389 #ifdef _DEBUG
       
   390     CContactPresence::WriteToLog( _L8( "CPresenceIconInfo::NewIconForContact this=%d" ),(TInt)this );
       
   391 #endif
       
   392     
       
   393     if ( !iInitialization )
       
   394         {
       
   395 #ifdef _DEBUG
       
   396         CContactPresence::WriteToLog( _L8( "CPresenceIconInfo:: CALLBACK ReceiveIconInfoL this=%d" ),(TInt)this );
       
   397 #endif        
       
   398         TRAP_IGNORE( iObs.ReceiveIconInfoL( ContactLink(), aBrandId, aElementId ));
       
   399         }
       
   400     else
       
   401         {
       
   402         TRAP_IGNORE( AllocatePendingNotifyL( aBrandId, aElementId ));
       
   403         }
       
   404     }
       
   405 
       
   406 // -----------------------------------------------------------------------------    
       
   407 void CPresenceIconInfo::NewIconsForContact( 
       
   408         MVPbkContactLink* aLink, 
       
   409         RPointerArray <MPresenceServiceIconInfo>& aInfoArray,
       
   410         TInt aId )
       
   411     {
       
   412 #ifdef _DEBUG
       
   413     CContactPresence::WriteToLog(_L8("CPresenceIconInfo::NewIconsForContact this=%d"),(TInt)this);
       
   414 #endif 
       
   415     
       
   416     TRAP_IGNORE( DoCopyInfosL( aLink, aInfoArray, aId ));
       
   417     }
       
   418 
       
   419 // ----------------------------------------------------------
       
   420 // CPresenceIconInfo::IsWaiting
       
   421 //
       
   422 // ----------------------------------------------------------
       
   423 //
       
   424 TBool CPresenceIconInfo::IsWaiting()
       
   425     {
       
   426     return iWaiting;
       
   427     }
       
   428 
       
   429 // ----------------------------------------------------------
       
   430 // CPresenceIconInfo::SendErrorCallback
       
   431 //
       
   432 // ----------------------------------------------------------
       
   433 //
       
   434 void CPresenceIconInfo::SendErrorCallback( TInt aError )
       
   435     {
       
   436     TBool destroyed( EFalse );
       
   437     iDestroyedPtr = &destroyed;
       
   438 #ifdef _DEBUG
       
   439     CContactPresence::WriteToLog( _L8( "CPresenceIconInfo:: CALLBACK PresenceSubscribeError this=%d" ),(TInt)this );
       
   440 #endif
       
   441     if ( IsSubscription() )
       
   442         {
       
   443         iObs.PresenceSubscribeError( ContactLink(), aError );        
       
   444         }
       
   445     else
       
   446         {
       
   447         iObs.ErrorOccured( OpId(), aError );
       
   448         }
       
   449     
       
   450     if ( !destroyed )
       
   451         {
       
   452         Destroy();
       
   453         }
       
   454     else
       
   455         {
       
   456         }    
       
   457     }
       
   458 
       
   459 // ----------------------------------------------------------
       
   460 void CPresenceIconInfo::AllocatePendingNotifyL(
       
   461     const TDesC8& aBrandId,
       
   462     const TDesC8& aElementId )
       
   463     {
       
   464 #ifdef _DEBUG
       
   465     CContactPresence::WriteToLog( _L8( "CPresenceIconInfo::AllocatePendingNotifyL this=%d" ),(TInt)this );
       
   466 #endif
       
   467 
       
   468     MContactPresenceInfo* myInfo = NULL;            
       
   469     CPresenceIconInfoRes* res = 
       
   470             CPresenceIconInfoRes::NewL( aBrandId, aElementId, KNullDesC, 0 );
       
   471     myInfo = res;
       
   472     iPendings2.AppendL( res );     
       
   473     iPendings.AppendL( myInfo );       
       
   474     
       
   475     iNotifyPending = ETrue;
       
   476     }
       
   477 
       
   478 // ----------------------------------------------------------
       
   479 void CPresenceIconInfo::SendPendingCallback()
       
   480     {
       
   481     TBool destroyed( EFalse );
       
   482     iDestroyedPtr = &destroyed;    
       
   483     TInt count = iPendings.Count();    
       
   484         
       
   485     if ( iNotifyPending && count )
       
   486         {    
       
   487         CPresenceIconInfoRes* info = iPendings2[0];        
       
   488         if ( IsSubscription() )
       
   489             {
       
   490 #ifdef _DEBUG
       
   491             CContactPresence::WriteToLog( _L8( "CPresenceIconInfo::SendPendingCallback ReceiveIconInfoL CALLBACK this=%d" ),(TInt)this );
       
   492 #endif            
       
   493             TRAP_IGNORE( iObs.ReceiveIconInfoL( ContactLink(), info->BrandId(), info->ElementId() ));            
       
   494             }
       
   495         else
       
   496             {
       
   497 #ifdef _DEBUG            
       
   498             CContactPresence::WriteToLog( _L8( "CPresenceIconInfo::SendPendingCallback ReceiveIconInfosL CALLBACK this=%d" ),(TInt)this );
       
   499 #endif              
       
   500             TRAP_IGNORE( iObs.ReceiveIconInfosL( ContactLink(), iPendings, info->OpId() ));  
       
   501             // This instance is not needed anymore
       
   502             if (!destroyed)
       
   503                 {
       
   504                 Destroy();
       
   505                 }
       
   506                         
       
   507             }         
       
   508         }
       
   509     else if ( iNotifyPending )
       
   510         {
       
   511 #ifdef _DEBUG
       
   512         CContactPresence::WriteToLog( _L8( "CPresenceIconInfo::SendPendingCallback ReceiveIconInfosL CALLBACK this=%d" ),(TInt)this );
       
   513 #endif         
       
   514         // Empty notification
       
   515         TRAP_IGNORE( iObs.ReceiveIconInfosL( ContactLink(), iPendings, iOpId ));  
       
   516         // This instance is not needed anymore
       
   517         if (!destroyed)
       
   518             {
       
   519             Destroy();    
       
   520             }
       
   521         }
       
   522     
       
   523     if ( !destroyed )
       
   524         {
       
   525         iNotifyPending = EFalse;        
       
   526         iPendings2.ResetAndDestroy();        
       
   527         iPendings.Reset();        
       
   528         iDestroyedPtr = NULL;        
       
   529         }
       
   530     else
       
   531         {        
       
   532         }
       
   533     return;
       
   534     }
       
   535 
       
   536 // ----------------------------------------------------------
       
   537 void CPresenceIconInfo::SendEmptyNotification()
       
   538     {
       
   539 
       
   540 #ifdef _DEBUG
       
   541         CContactPresence::WriteToLog( _L8( "CPresenceIconInfo::SendEmptyNotification ReceiveIconInfoL CALLBACK this=%d" ),(TInt)this );
       
   542 #endif  
       
   543     TRAP_IGNORE( iObs.ReceiveIconInfoL( ContactLink(), TPtrC8(), TPtrC8() ));
       
   544     return;
       
   545     }
       
   546 
       
   547 // ----------------------------------------------------------
       
   548 
       
   549 TBool CPresenceIconInfo::IsSubscription()
       
   550     {
       
   551     return iSubscription;
       
   552     }
       
   553 
       
   554 // ----------------------------------------------------------
       
   555 
       
   556 // ----------------------------------------------------------
       
   557 
       
   558 TInt CPresenceIconInfo::OpId()
       
   559     {
       
   560     return iOpId;
       
   561     }
       
   562 
       
   563 
       
   564 
       
   565 // -----------------------------------------------------------------------------    
       
   566 void CPresenceIconInfo::DoCopyInfosL( 
       
   567         MVPbkContactLink* /*aLink*/, 
       
   568         RPointerArray <MPresenceServiceIconInfo>& aInfoArray,
       
   569         TInt aId )
       
   570     {
       
   571 #ifdef _DEBUG
       
   572     CContactPresence::WriteToLog(_L8("CPresenceIconInfo::DoCopyInfosL this=%d"),(TInt)this);
       
   573 #endif 
       
   574     
       
   575     MContactPresenceInfo* myInfo = NULL;  
       
   576         
       
   577     TInt count = aInfoArray.Count();
       
   578     
       
   579     // Empty notification is handled here, i.e. no data in presence cache curently.
       
   580     if ( count == 0 )
       
   581         {
       
   582         iOpId = aId;       
       
   583         }
       
   584     else
       
   585         {
       
   586         // Convert input to other array
       
   587         for ( TInt i = 0; i < count; i++ )
       
   588             {
       
   589             MPresenceServiceIconInfo* inf = aInfoArray[i];
       
   590             CPresenceIconInfoRes* res = 
       
   591                 CPresenceIconInfoRes::NewL( inf->BrandId(), inf->ElementId(), inf->ServiceName(), aId );
       
   592             myInfo = res;
       
   593             iPendings2.AppendL( res );           
       
   594             iPendings.AppendL( myInfo );     
       
   595             }        
       
   596         }
       
   597     
       
   598     if ( !iInitialization )
       
   599         {
       
   600 #ifdef _DEBUG
       
   601         CContactPresence::WriteToLog( _L8( "CPresenceIconInfo:: CALLBACK ReceiveIconInfosL this=%d" ),(TInt)this );
       
   602 #endif
       
   603         TRAP_IGNORE( iObs.ReceiveIconInfosL( ContactLink(), iPendings, aId  ));
       
   604         // This instance is not needed anymore
       
   605         Destroy();
       
   606         }
       
   607     else
       
   608         {
       
   609         iNotifyPending = ETrue;        
       
   610         }    
       
   611     }
       
   612 
       
   613 // ----------------------------------------------------------