metadataengine/server/src/mdsnotifier.cpp
branchRCL_3
changeset 7 3cebc1a84278
parent 6 646a02f170b9
child 8 50de4d668bb6
equal deleted inserted replaced
6:646a02f170b9 7:3cebc1a84278
    20 #include "mdcitem.h"
    20 #include "mdcitem.h"
    21 #include "mdsserversession.h"
    21 #include "mdsserversession.h"
    22 #include "mdsnotifycomparator.h"
    22 #include "mdsnotifycomparator.h"
    23 #include "mdslogger.h"
    23 #include "mdslogger.h"
    24 #include "mdcserializationbuffer.h"
    24 #include "mdcserializationbuffer.h"
       
    25 #include "mdsmanipulationengine.h"
    25 #include "mdccommon.pan"
    26 #include "mdccommon.pan"
       
    27 
       
    28 // for CleanupResetAndDestroyPushL
       
    29 #include <mmf/common/mmfcontrollerpluginresolver.h>
    26 
    30 
    27 __USES_LOGGER
    31 __USES_LOGGER
    28 
    32 
    29 // ------------------------------------------------
    33 // ------------------------------------------------
    30 // NewL
    34 // NewL
   123 // TriggerL completes the client message and sends the data size
   127 // TriggerL completes the client message and sends the data size
   124 // ------------------------------------------------
   128 // ------------------------------------------------
   125 //
   129 //
   126 void CMdSNotifier::TEntry::TriggerL(
   130 void CMdSNotifier::TEntry::TriggerL(
   127 	TUint32 aCompleteCode,
   131 	TUint32 aCompleteCode,
   128     const RArray<TItemId>& aIdArray )
   132     const RArray<TItemId>& aIdArray,
       
   133     RPointerArray<HBufC>& aUriArray )
   129     {
   134     {
   130     const TInt remoteSizeMsgSlot = iRemoteSizeMsgSlot;
   135     const TInt remoteSizeMsgSlot = iRemoteSizeMsgSlot;
   131     iRemoteSizeMsgSlot = KErrNotFound;
   136     iRemoteSizeMsgSlot = KErrNotFound;
   132 
   137 
   133     __ASSERT_DEBUG( !iDataBuffer, MMdCCommon::Panic( KErrCorrupt ) );
   138     __ASSERT_DEBUG( !iDataBuffer, MMdCCommon::Panic( KErrCorrupt ) );
   134 
   139 
   135     if(aIdArray.Count())
   140     if( iMessage.IsNull() )
       
   141         {
       
   142         return;
       
   143         }
       
   144     
       
   145     if( aIdArray.Count() )
   136 		{
   146 		{
   137 		iDataBuffer = CopyToBufferL( aIdArray );
   147 		if( iType & ( EObjectNotifyAddWithUri | EObjectNotifyModifyWithUri | EObjectNotifyRemoveWithUri  ) )
       
   148 		    {
       
   149 		    iDataBuffer = CopyToBufferL( aIdArray, aUriArray );
       
   150 		    }
       
   151 		else
       
   152 		    {
       
   153 		    iDataBuffer = CopyToBufferL( aIdArray );
       
   154 		    }
   138 	    iSession.SizeToRemoteL( iMessage, remoteSizeMsgSlot, iDataBuffer->Size());
   155 	    iSession.SizeToRemoteL( iMessage, remoteSizeMsgSlot, iDataBuffer->Size());
   139 		}
   156 		}
   140 	else
   157 	else
   141 		{
   158 		{
   142 	    iSession.SizeToRemoteL( iMessage, remoteSizeMsgSlot, 0);
   159 	    iSession.SizeToRemoteL( iMessage, remoteSizeMsgSlot, 0 );
   143 		}
   160 		}
   144 
   161 
   145     __LOG2( ELogServer, "<- Notify trigger %d (%d)", iId, aCompleteCode );
   162     __LOG2( ELogServer, "<- Notify trigger %d (%d)", iId, aCompleteCode );
   146     iMessage.Complete( aCompleteCode );
   163     iMessage.Complete( aCompleteCode );
   147     }
   164     }
   159     const TInt remoteSizeMsgSlot = iRemoteSizeMsgSlot;
   176     const TInt remoteSizeMsgSlot = iRemoteSizeMsgSlot;
   160     iRemoteSizeMsgSlot = KErrNotFound;
   177     iRemoteSizeMsgSlot = KErrNotFound;
   161 
   178 
   162     __ASSERT_DEBUG( !iDataBuffer, MMdCCommon::Panic( KErrCorrupt ) );
   179     __ASSERT_DEBUG( !iDataBuffer, MMdCCommon::Panic( KErrCorrupt ) );
   163 
   180 
       
   181     if( iMessage.IsNull() )
       
   182         {
       
   183         return;
       
   184         }
       
   185     
   164     if(aRelationIdArray.Count())
   186     if(aRelationIdArray.Count())
   165 		{
   187 		{
   166 		iDataBuffer = CopyItemsToBufferL( aBuffer, aRelationIdArray );
   188 		iDataBuffer = CopyItemsToBufferL( aBuffer, aRelationIdArray );
   167 	    iSession.SizeToRemoteL( iMessage, remoteSizeMsgSlot, iDataBuffer->Size());
   189 	    iSession.SizeToRemoteL( iMessage, remoteSizeMsgSlot, iDataBuffer->Size());
   168 		}
   190 		}
   178 // ------------------------------------------------
   200 // ------------------------------------------------
   179 // TriggerSchemaL sends a schema notification
   201 // TriggerSchemaL sends a schema notification
   180 // ------------------------------------------------
   202 // ------------------------------------------------
   181 //
   203 //
   182 void CMdSNotifier::TEntry::TriggerSchema()
   204 void CMdSNotifier::TEntry::TriggerSchema()
   183     {
   205     {    
       
   206     if( iMessage.IsNull() )
       
   207         {
       
   208         return;
       
   209         }
       
   210     
   184     iRemoteSizeMsgSlot = KErrNotFound;
   211     iRemoteSizeMsgSlot = KErrNotFound;
   185     iMessage.Complete( ESchemaModify );
   212     iMessage.Complete( ESchemaModify );
   186     }
   213     }
   187 
   214 
   188 // ------------------------------------------------
   215 // ------------------------------------------------
   229 		}
   256 		}
   230 
   257 
   231 	CleanupStack::Pop( buffer );
   258 	CleanupStack::Pop( buffer );
   232 	return buffer;	
   259 	return buffer;	
   233 	}
   260 	}
       
   261 
       
   262 // ------------------------------------------------
       
   263 // CopyToBufferL copies ids and uris to buffer
       
   264 // ------------------------------------------------
       
   265 //
       
   266 CMdCSerializationBuffer* CMdSNotifier::TEntry::CopyToBufferL(const RArray<TItemId>& aIdArray,
       
   267                                                                                                   const RPointerArray<HBufC>& aUriArray)
       
   268     {
       
   269     const TUint32 count = aIdArray.Count();
       
   270     const TUint32 uriCount = aUriArray.Count();
       
   271 
       
   272     TInt urisSize = CMdCSerializationBuffer::KRequiredSizeForTUint32;
       
   273 
       
   274     for( TInt i = uriCount - 1; i >=0; i-- )
       
   275         {
       
   276         urisSize += CMdCSerializationBuffer::RequiredSize( *aUriArray[i] );
       
   277         }
       
   278     
       
   279     TInt idsSize( sizeof( TMdCItemIds ) + count * CMdCSerializationBuffer::KRequiredSizeForTItemId );
       
   280     
       
   281     CMdCSerializationBuffer* buffer = CMdCSerializationBuffer::NewLC(
       
   282             urisSize + idsSize );
       
   283     
       
   284     TMdCItemIds itemIds;
       
   285     itemIds.iNamespaceDefId = NamespaceDefId();
       
   286     itemIds.iObjectIds.iPtr.iCount = count;
       
   287     itemIds.iObjectIds.iPtr.iOffset = sizeof(TMdCItemIds);
       
   288     itemIds.SerializeL( *buffer );
       
   289 
       
   290     // Insert IDs
       
   291     for( TInt i = 0; i < count; ++i )
       
   292         {
       
   293         buffer->InsertL( aIdArray[i] );
       
   294         }
       
   295     
       
   296     // Insert uri count
       
   297     buffer->InsertL( uriCount );
       
   298     
       
   299     // Insert uris
       
   300     for( TInt i = 0; i < uriCount; ++i )
       
   301         {
       
   302         // add uri
       
   303         const TDesC& uri =  *aUriArray[i];
       
   304         HBufC* lcUri = HBufC::NewLC( uri.Length() );
       
   305         lcUri->Des().Append( uri );
       
   306         buffer->InsertL( *lcUri );
       
   307         CleanupStack::PopAndDestroy( lcUri ); 
       
   308         lcUri = NULL;
       
   309         }
       
   310 
       
   311     CleanupStack::Pop( buffer );
       
   312     return buffer;  
       
   313     }
   234 
   314 
   235 // ------------------------------------------------
   315 // ------------------------------------------------
   236 // CopyItemsToBufferL copies relation items to buffer
   316 // CopyItemsToBufferL copies relation items to buffer
   237 // ------------------------------------------------
   317 // ------------------------------------------------
   238 //
   318 //
   280 
   360 
   281 // ------------------------------------------------
   361 // ------------------------------------------------
   282 // CacheL caches the notification
   362 // CacheL caches the notification
   283 // ------------------------------------------------
   363 // ------------------------------------------------
   284 //
   364 //
   285 void CMdSNotifier::TEntry::CacheL(TUint32 aCompleteCode, const RArray<TItemId>& aIdArray )
   365 void CMdSNotifier::TEntry::CacheL(TUint32 aCompleteCode, 
       
   366                                                          const RArray<TItemId>& aIdArray, 
       
   367                                                          const RPointerArray<HBufC>& aUriArray)
   286     {
   368     {
   287     if ( aIdArray.Count() <= 0 )
   369     if ( aIdArray.Count() <= 0 )
   288     	{
   370     	{
   289     	return;
   371     	return;
   290     	}
   372     	}
   291 
   373 
   292     CMdCSerializationBuffer* data = CopyToBufferL( aIdArray );
   374     CMdCSerializationBuffer* data( NULL );
       
   375     
       
   376     if( iType & ( EObjectNotifyAddWithUri | EObjectNotifyModifyWithUri | EObjectNotifyRemoveWithUri  ) )
       
   377         {
       
   378         data = CopyToBufferL( aIdArray, aUriArray );
       
   379         }
       
   380     else
       
   381         {
       
   382         data = CopyToBufferL( aIdArray );
       
   383         }
   293     iSession.CacheNotificationL( iId, aCompleteCode, data );
   384     iSession.CacheNotificationL( iId, aCompleteCode, data );
   294     }
   385     }
   295 
   386 
   296 // ------------------------------------------------
   387 // ------------------------------------------------
   297 // CacheRelationItemsL caches the notification
   388 // CacheRelationItemsL caches the notification
   325     const TInt remoteSizeMsgSlot = iRemoteSizeMsgSlot;
   416     const TInt remoteSizeMsgSlot = iRemoteSizeMsgSlot;
   326     iRemoteSizeMsgSlot = KErrNotFound;
   417     iRemoteSizeMsgSlot = KErrNotFound;
   327 
   418 
   328     __ASSERT_DEBUG( !iDataBuffer, MMdCCommon::Panic( KErrCorrupt ) );
   419     __ASSERT_DEBUG( !iDataBuffer, MMdCCommon::Panic( KErrCorrupt ) );
   329 
   420 
       
   421     if( iMessage.IsNull() )
       
   422         {
       
   423         return;
       
   424         }
       
   425     
   330     if( aData )
   426     if( aData )
   331     	{
   427     	{
   332     	iSession.SizeToRemoteL( iMessage, remoteSizeMsgSlot, aData->Size());
   428     	iSession.SizeToRemoteL( iMessage, remoteSizeMsgSlot, aData->Size());
   333     	}
   429     	}
   334 
   430 
   468 // ------------------------------------------------
   564 // ------------------------------------------------
   469 //
   565 //
   470 void CMdSNotifier::NotifyAddedL(CMdCSerializationBuffer& aSerializedItems, 
   566 void CMdSNotifier::NotifyAddedL(CMdCSerializationBuffer& aSerializedItems, 
   471 							    CMdCSerializationBuffer& aSerializedItemIds)
   567 							    CMdCSerializationBuffer& aSerializedItemIds)
   472     {
   568     {
   473     const TInt count = iEntries.Count();
   569     const TBool uriNotify = CheckForNotifier(EObjectNotifyAddWithUri);
   474     
   570     TBool allMatched( EFalse );
   475     for( TInt i = 0; i < count; ++i )
   571     TBool allItemsFetched( EFalse );
       
   572     
       
   573     RArray<TItemId> allItemsIdArray;
       
   574     CleanupClosePushL( allItemsIdArray );
       
   575     RPointerArray<HBufC> allItemsUriArray;
       
   576     CleanupResetAndDestroyPushL( allItemsUriArray );
       
   577     
       
   578     for( TInt i = iEntries.Count() - 1; i >=0; i-- )
   476         {
   579         {
   477         TEntry& e = iEntries[i];
   580         TEntry& e = iEntries[i];
   478 
   581 
   479         if ( ! (e.iType & ( EObjectNotifyAdd | ERelationNotifyAdd | EEventNotifyAdd ) ) )
   582         if ( ! (e.iType & ( EObjectNotifyAdd | ERelationNotifyAdd | EEventNotifyAdd | EObjectNotifyAddWithUri ) ) )
   480         	{
   583         	{
   481         	continue;
   584         	continue;
   482         	}
   585         	}
   483         
   586         
   484         RArray<TItemId> matchingItemIdArray;
   587         RArray<TItemId> matchingItemIdArray;
       
   588         RPointerArray<HBufC> matchingItemUriArray;
   485    		CleanupClosePushL( matchingItemIdArray );
   589    		CleanupClosePushL( matchingItemIdArray );
       
   590    		CleanupResetAndDestroyPushL( matchingItemUriArray );
   486 
   591 
   487 		aSerializedItems.PositionL( KNoOffset );
   592 		aSerializedItems.PositionL( KNoOffset );
   488 		aSerializedItemIds.PositionL( KNoOffset );
   593 		aSerializedItemIds.PositionL( KNoOffset );
   489 
   594 
   490 		const TBool someMatches = iComparator->MatchL( e.NamespaceDefId(), e.iType, e.Condition(), 
   595 		const TBool someMatches = iComparator->MatchL( e.NamespaceDefId(), e.iType, e.Condition(), 
   491 												 aSerializedItems, aSerializedItemIds, 
   596 										    		 aSerializedItems, aSerializedItemIds, 
   492 												 matchingItemIdArray,
   597 											    	 matchingItemIdArray,
   493 												 e.AllowConfidential() );
   598 											    	 allItemsIdArray,
       
   599 												     matchingItemUriArray,
       
   600 												     allItemsUriArray,
       
   601 						     						 e.AllowConfidential(),
       
   602 							     					 uriNotify,
       
   603 								    				 allMatched,
       
   604 								    				 allItemsFetched );
   494 
   605 
   495         if( someMatches ) // check if there is some matches
   606         if( someMatches ) // check if there is some matches
   496             {
   607             {
   497             if( e.IsPending() )
   608             if( e.IsPending() )
   498             	{
   609             	{
       
   610             	TInt err( KErrNone );
   499             	// match found. trigger notifier entry !
   611             	// match found. trigger notifier entry !
   500 	            TRAPD( err, e.TriggerL( EObjectNotifyAdd | ERelationNotifyAdd | EEventNotifyAdd,
   612             	if( allMatched )
   501 	            		matchingItemIdArray ) );
   613             	    {
   502 	            if( err != KErrNone )
   614                     TRAP( err, e.TriggerL( EObjectNotifyAdd | ERelationNotifyAdd | EEventNotifyAdd | EObjectNotifyAddWithUri,
   503 	            	{
   615                             allItemsIdArray, allItemsUriArray ) );  
   504 	            	e.TriggerError( err );
   616             	    }
   505 	            	}
   617             	else
       
   618             	    {
       
   619                     TRAP( err, e.TriggerL( EObjectNotifyAdd | ERelationNotifyAdd | EEventNotifyAdd | EObjectNotifyAddWithUri,
       
   620                             matchingItemIdArray, matchingItemUriArray ) );  
       
   621             	    }
       
   622                 if( err != KErrNone )
       
   623                     {
       
   624                     e.TriggerError( err );
       
   625                     }
   506             	}
   626             	}
   507             else
   627             else
   508             	{
   628             	{
   509             	TRAP_IGNORE( e.CacheL( EObjectNotifyAdd | ERelationNotifyAdd | EEventNotifyAdd,
   629                 if( allMatched )
   510             			matchingItemIdArray ) );
   630                     {
   511             	}
   631                     TRAP_IGNORE( e.CacheL( EObjectNotifyAdd | ERelationNotifyAdd | EEventNotifyAdd | EObjectNotifyAddWithUri,
       
   632                              allItemsIdArray, allItemsUriArray ) );    
       
   633                     }
       
   634                 else
       
   635                     {
       
   636                     TRAP_IGNORE( e.CacheL( EObjectNotifyAdd | ERelationNotifyAdd | EEventNotifyAdd | EObjectNotifyAddWithUri,
       
   637                              matchingItemIdArray, matchingItemUriArray ) );    
       
   638                     }
       
   639             	}
       
   640             // Copy of each uri is made to each client, which will own the returned uri
       
   641             // Thus URI ownership is transferred and original array can be destroyed
       
   642             matchingItemUriArray.ResetAndDestroy();
   512             }
   643             }
   513 
   644 
   514    		CleanupStack::PopAndDestroy( &matchingItemIdArray );
   645    		CleanupStack::PopAndDestroy( 2, &matchingItemIdArray );
   515         }
   646         }
       
   647     CleanupStack::PopAndDestroy( 2, &allItemsIdArray ); // allItemsIdArray, allItemsUriArray
   516     }
   648     }
   517 
   649 
   518 // ------------------------------------------------
   650 // ------------------------------------------------
   519 // NotifyRemoved
   651 // NotifyRemoved
   520 // ------------------------------------------------
   652 // ------------------------------------------------
   521 //
   653 //
   522 void CMdSNotifier::NotifyRemovedL(CMdCSerializationBuffer& aSerializedItemIds, 
   654 void CMdSNotifier::NotifyRemovedL(CMdCSerializationBuffer& aSerializedItemIds, 
   523 								  TBool aItemIsConfidential)
   655 								  TBool aItemIsConfidential,
       
   656 								  RPointerArray<HBufC>& aRemovedItemUriArray,
       
   657 								  CMdSManipulationEngine* aMEngine )
   524     {
   658     {
   525 	aSerializedItemIds.PositionL( KNoOffset );
   659 	aSerializedItemIds.PositionL( KNoOffset );
   526 
   660 
   527 	const TMdCItemIds& itemIds = TMdCItemIds::GetFromBufferL( aSerializedItemIds );
   661 	const TMdCItemIds& itemIds = TMdCItemIds::GetFromBufferL( aSerializedItemIds );
   528 
   662 
   585 	const TInt relationCount( relationIdArray.Count() );
   719 	const TInt relationCount( relationIdArray.Count() );
   586 	if( objectCount != 0 
   720 	if( objectCount != 0 
   587 			|| eventCount != 0 
   721 			|| eventCount != 0 
   588 			|| relationCount != 0 )
   722 			|| relationCount != 0 )
   589 		{
   723 		{
   590 		const TInt entriesCount = iEntries.Count();
   724 		for( TInt i = iEntries.Count() - 1; i >=0; i-- )
   591 	    for( TInt i=0; i < entriesCount; ++i )
       
   592 	        {
   725 	        {
   593 	        TEntry& e = iEntries[i];
   726 	        TEntry& e = iEntries[i];
   594 	        
   727 	        
   595 	        // if namespace definition IDs don't match skip listener entry
   728 	        // if namespace definition IDs don't match skip listener entry
   596 	        if( e.NamespaceDefId() != itemIds.iNamespaceDefId )
   729 	        if( e.NamespaceDefId() != itemIds.iNamespaceDefId )
   601 	        if(aItemIsConfidential && !e.AllowConfidential())
   734 	        if(aItemIsConfidential && !e.AllowConfidential())
   602 	        	{
   735 	        	{
   603 	        	continue;	
   736 	        	continue;	
   604 	        	}
   737 	        	}
   605 
   738 
       
   739 	        RPointerArray<HBufC> uriArray;
       
   740 	        CleanupResetAndDestroyPushL( uriArray );
       
   741 	        
   606 	        if( e.iType & EObjectNotifyRemove && objectCount > 0 )
   742 	        if( e.iType & EObjectNotifyRemove && objectCount > 0 )
   607 	            {
   743 	            {
   608 	            // collect matching object IDs
   744 	            // collect matching object IDs
   609 	            RArray<TItemId> matchingObjectIdArray;
   745 	            RArray<TItemId> matchingObjectIdArray;
   610 				CleanupClosePushL( matchingObjectIdArray );
   746 				CleanupClosePushL( matchingObjectIdArray );
   622 		            	
   758 		            	
   623 		            	if( allMatches )
   759 		            	if( allMatches )
   624 		            		{
   760 		            		{
   625 		            		// all matches so send whole object ID array
   761 		            		// all matches so send whole object ID array
   626 		            		TRAP( err, e.TriggerL( EObjectNotifyRemove, 
   762 		            		TRAP( err, e.TriggerL( EObjectNotifyRemove, 
   627 		            				objectIdArray ) );
   763 		            				objectIdArray, uriArray ) );
   628 		            		}
   764 		            		}
   629 		            	else
   765 		            	else
   630 		            		{
   766 		            		{
   631 		            		TRAP( err, e.TriggerL( EObjectNotifyRemove, 
   767 		            		TRAP( err, e.TriggerL( EObjectNotifyRemove, 
   632 		            				matchingObjectIdArray ) );
   768 		            				matchingObjectIdArray, uriArray ) );
   633 		            		}
   769 		            		}
   634 	
   770 	
   635 		            	if( err != KErrNone )
   771 		            	if( err != KErrNone )
   636 			            	{
   772 			            	{
   637 			            	e.TriggerError( err );
   773 			            	e.TriggerError( err );
   641 	            		{
   777 	            		{
   642 						if( allMatches )
   778 						if( allMatches )
   643 		            		{
   779 		            		{
   644 		            		// all matches so send whole object ID array
   780 		            		// all matches so send whole object ID array
   645 	            			TRAP_IGNORE( e.CacheL( EObjectNotifyRemove, 
   781 	            			TRAP_IGNORE( e.CacheL( EObjectNotifyRemove, 
   646 	            					objectIdArray ) );
   782 	            					objectIdArray, uriArray ) );
   647 		            		}
   783 		            		}
   648 		            	else
   784 		            	else
   649 		            		{
   785 		            		{
   650 		            		TRAP_IGNORE( e.CacheL( EObjectNotifyRemove, 
   786 		            		TRAP_IGNORE( e.CacheL( EObjectNotifyRemove, 
   651 		            				matchingObjectIdArray ) );
   787 		            				matchingObjectIdArray, uriArray ) );
   652 		            		}
   788 		            		}
   653 	            		}
   789 	            		}
   654 	            	}
   790 	            	}
   655 	
   791 	
   656 				CleanupStack::PopAndDestroy( &matchingObjectIdArray );
   792 				CleanupStack::PopAndDestroy( &matchingObjectIdArray );
   657 				}
   793 				}
       
   794 	        else if( e.iType & EObjectNotifyRemoveWithUri && objectCount > 0 )
       
   795                 {
       
   796                 // collect matching object IDs
       
   797                 RArray<TItemId> matchingObjectIdArray;
       
   798                 CleanupClosePushL( matchingObjectIdArray );
       
   799     
       
   800                 const TBool allMatches = iComparator->MatchObjectIdsL( e.Condition(),
       
   801                         objectIdArray, matchingObjectIdArray );
       
   802     
       
   803                 // check is there any matches
       
   804                 if( allMatches || matchingObjectIdArray.Count() > 0 )
       
   805                     {
       
   806                     if(e.IsPending())
       
   807                         {
       
   808                         // Match found. Trigger notifier entry.
       
   809                         TInt err( KErrNone );
       
   810                         
       
   811                         if( allMatches )
       
   812                             {
       
   813                             // all matches so send whole object ID array
       
   814                             TRAP( err, e.TriggerL( EObjectNotifyRemoveWithUri, 
       
   815                                     objectIdArray, aRemovedItemUriArray ) );
       
   816                             }
       
   817                         else
       
   818                             {
       
   819                             aMEngine->GetObjectUrisByIdsL( objectIdArray, uriArray );
       
   820                             TRAP( err, e.TriggerL( EObjectNotifyRemoveWithUri, 
       
   821                                     matchingObjectIdArray, uriArray ) );
       
   822                             }
       
   823     
       
   824                         if( err != KErrNone )
       
   825                             {
       
   826                             e.TriggerError( err );
       
   827                             }
       
   828                         }
       
   829                     else
       
   830                         {
       
   831                         if( allMatches )
       
   832                             {
       
   833                             // all matches so send whole object ID array
       
   834                             TRAP_IGNORE( e.CacheL( EObjectNotifyRemoveWithUri, 
       
   835                                     objectIdArray, aRemovedItemUriArray ) );
       
   836                             }
       
   837                         else
       
   838                             {
       
   839                             aMEngine->GetObjectUrisByIdsL( objectIdArray, uriArray );
       
   840                             TRAP_IGNORE( e.CacheL( EObjectNotifyRemoveWithUri, 
       
   841                                     matchingObjectIdArray, uriArray ) );
       
   842                             }
       
   843                         }
       
   844                     }
       
   845     
       
   846                 CleanupStack::PopAndDestroy( &matchingObjectIdArray );
       
   847                 }
   658 	        else if( ( e.iType & EEventNotifyRemove ) 
   848 	        else if( ( e.iType & EEventNotifyRemove ) 
   659 	        		&& eventCount > 0 )
   849 	        		&& eventCount > 0 )
   660             	{
   850             	{
   661 				// event condition can't contain ID conditions, 
   851 				// event condition can't contain ID conditions, 
   662             	// so get all IDs
   852             	// so get all IDs
   663 	        	if(e.IsPending())
   853 	        	if(e.IsPending())
   664 	        		{
   854 	        		{
   665 	            	// Match found. Trigger notifier entry.
   855 	            	// Match found. Trigger notifier entry.
   666 	            	TRAPD( err, e.TriggerL( EEventNotifyRemove, 
   856 	            	TRAPD( err, e.TriggerL( EEventNotifyRemove, 
   667 	            			eventIdArray ) );
   857 	            			eventIdArray, uriArray ) );
   668 	            	if( err != KErrNone )
   858 	            	if( err != KErrNone )
   669 		            	{
   859 		            	{
   670 		            	e.TriggerError( err );
   860 		            	e.TriggerError( err );
   671 	    	        	}
   861 	    	        	}
   672 	        		}
   862 	        		}
   673 	        	else
   863 	        	else
   674 	        		{
   864 	        		{
   675 	        		TRAP_IGNORE( e.CacheL( EEventNotifyRemove, 
   865 	        		TRAP_IGNORE( e.CacheL( EEventNotifyRemove, 
   676 	        				eventIdArray ) );
   866 	        				eventIdArray, uriArray ) );
   677 	        		}
   867 	        		}
   678             	}
   868             	}
   679 	        else if( ( e.iType & ERelationNotifyRemove ) 
   869 	        else if( ( e.iType & ERelationNotifyRemove ) 
   680 	        		&& relationCount > 0 )
   870 	        		&& relationCount > 0 )
   681             	{
   871             	{
   683             	// so get all IDs
   873             	// so get all IDs
   684 	        	if(e.IsPending())
   874 	        	if(e.IsPending())
   685 	        		{
   875 	        		{
   686 	            	// Match found. Trigger notifier entry.
   876 	            	// Match found. Trigger notifier entry.
   687 	            	TRAPD( err, e.TriggerL( ERelationNotifyRemove, 
   877 	            	TRAPD( err, e.TriggerL( ERelationNotifyRemove, 
   688 	            			relationIdArray ) );
   878 	            			relationIdArray, uriArray ) );
   689 	            	if( err != KErrNone )
   879 	            	if( err != KErrNone )
   690 		            	{
   880 		            	{
   691 		            	e.TriggerError( err );
   881 		            	e.TriggerError( err );
   692 	    	        	}
   882 	    	        	}
   693 	        		}
   883 	        		}
   694 	        	else
   884 	        	else
   695 	        		{
   885 	        		{
   696 	        		TRAP_IGNORE( e.CacheL( ERelationNotifyRemove, 
   886 	        		TRAP_IGNORE( e.CacheL( ERelationNotifyRemove, 
   697 	        				relationIdArray ) );
   887 	        				relationIdArray, uriArray ) );
   698 	        		}
   888 	        		}
   699             	}
   889             	}
       
   890 	        CleanupStack::PopAndDestroy( &uriArray );
   700 	        }
   891 	        }
   701 		}
   892 		}
   702 	CleanupStack::PopAndDestroy( 3, &objectIdArray ); // relationIdArray, eventIdArray, objectIdArray
   893 	CleanupStack::PopAndDestroy( 3, &objectIdArray ); // relationIdArray, eventIdArray, objectIdArray
   703     }
   894     }
   704 
   895 
   707 // ------------------------------------------------
   898 // ------------------------------------------------
   708 //
   899 //
   709 void CMdSNotifier::NotifyModifiedL(CMdCSerializationBuffer& aSerializedItems, 
   900 void CMdSNotifier::NotifyModifiedL(CMdCSerializationBuffer& aSerializedItems, 
   710 							       CMdCSerializationBuffer& aSerializedItemIds)
   901 							       CMdCSerializationBuffer& aSerializedItemIds)
   711     {
   902     {
   712     const TInt count = iEntries.Count();
   903     const TBool uriNotify = CheckForNotifier(EObjectNotifyModifyWithUri);
   713     
   904     TBool allMatched( EFalse );
   714     for( TInt i = 0; i < count; ++i )
   905     TBool allItemsFetched( EFalse );
       
   906 
       
   907     RArray<TItemId> allItemsIdArray;
       
   908     CleanupClosePushL( allItemsIdArray );
       
   909     RPointerArray<HBufC> allItemsUriArray;
       
   910     CleanupResetAndDestroyPushL( allItemsUriArray );
       
   911     
       
   912     for( TInt i = iEntries.Count() - 1; i >=0; i-- )
   715         {
   913         {
   716         TEntry& e = iEntries[i];
   914         TEntry& e = iEntries[i];
   717 
   915 
   718         if ( ! (e.iType & ( EObjectNotifyModify | ERelationNotifyModify ) ) )
   916         if ( ! (e.iType & ( EObjectNotifyModify | ERelationNotifyModify | EObjectNotifyModifyWithUri ) ) )
   719         	{
   917         	{
   720         	continue;
   918         	continue;
   721         	}
   919         	}
   722   
   920   
   723         RArray<TItemId> matchingObjectIdArray;
   921         RArray<TItemId> matchingObjectIdArray;
       
   922         RPointerArray<HBufC> matchingItemUriArray;
   724 		CleanupClosePushL( matchingObjectIdArray );
   923 		CleanupClosePushL( matchingObjectIdArray );
       
   924 		CleanupResetAndDestroyPushL( matchingItemUriArray );
   725 
   925 
   726 		aSerializedItems.PositionL( KNoOffset );
   926 		aSerializedItems.PositionL( KNoOffset );
   727 		aSerializedItemIds.PositionL( KNoOffset );
   927 		aSerializedItemIds.PositionL( KNoOffset );
   728 
   928 
   729 		const TBool someMatches = iComparator->MatchL( e.NamespaceDefId(), 
   929 		const TBool someMatches = iComparator->MatchL( e.NamespaceDefId(), e.iType, e.Condition(), 
   730 				e.iType, e.Condition(), aSerializedItems, aSerializedItemIds, 
   930                                           aSerializedItems, aSerializedItemIds, 
   731 				matchingObjectIdArray, e.AllowConfidential() );
   931                                           matchingObjectIdArray,
       
   932                                           allItemsIdArray,
       
   933                                           matchingItemUriArray,
       
   934                                           allItemsUriArray,
       
   935                                           e.AllowConfidential(),
       
   936                                           uriNotify,
       
   937                                           allMatched,
       
   938                                           allItemsFetched );
   732 
   939 
   733         if( someMatches ) // check if there is some matches
   940         if( someMatches ) // check if there is some matches
   734             {
   941             {
   735             if( e.IsPending() )
   942             if( e.IsPending() )
   736             	{
   943             	{
   737             	// match found. trigger notifier entry !
   944             	TInt err( KErrNone );
   738 	            TRAPD( err, e.TriggerL( EObjectNotifyModify | ERelationNotifyModify,
   945                 // match found. trigger notifier entry !
   739 	            		matchingObjectIdArray ) );
   946                 if( allMatched )
   740 	            if( err != KErrNone )
   947                     {
   741 	            	{
   948                     TRAP( err, e.TriggerL( EObjectNotifyModify | ERelationNotifyModify | EObjectNotifyModifyWithUri,
   742 	            	e.TriggerError( err );
   949                             allItemsIdArray, allItemsUriArray ) );  
   743 	            	}
   950                     }
       
   951                 else
       
   952                     {
       
   953                     TRAP( err, e.TriggerL( EObjectNotifyModify | ERelationNotifyModify | EObjectNotifyModifyWithUri,
       
   954                             matchingObjectIdArray, matchingItemUriArray ) );  
       
   955                     }
       
   956                 if( err != KErrNone )
       
   957                     {
       
   958                     e.TriggerError( err );
       
   959                     }         
   744             	}
   960             	}
   745             else
   961             else
   746             	{
   962             	{
   747             	TRAP_IGNORE( e.CacheL( EObjectNotifyModify | ERelationNotifyModify,
   963                 if( allMatched )
   748             			matchingObjectIdArray ) );
   964                     {
   749             	}
   965                     TRAP_IGNORE( e.CacheL( EObjectNotifyModify | ERelationNotifyModify | EObjectNotifyModifyWithUri,
       
   966                              allItemsIdArray, allItemsUriArray ) );    
       
   967                     }
       
   968                 else
       
   969                     {
       
   970                     TRAP_IGNORE( e.CacheL( EObjectNotifyModify | ERelationNotifyModify | EObjectNotifyModifyWithUri,
       
   971                             matchingObjectIdArray, matchingItemUriArray ) );    
       
   972                     }
       
   973                 }
       
   974             // Copy of each uri is made to each client, which will own the returned uri
       
   975             // Thus URI ownership is transferred and original array can be destroyed
       
   976             matchingItemUriArray.ResetAndDestroy();
   750             }
   977             }
   751 
   978 		CleanupStack::PopAndDestroy( 2, &matchingObjectIdArray );
   752 		CleanupStack::PopAndDestroy( &matchingObjectIdArray );
   979         }
   753         }
   980     CleanupStack::PopAndDestroy( 2, &allItemsIdArray ); // allItemsIdArray, allItemsUriArray
   754     }
   981     }
   755 
   982 
   756 // ------------------------------------------------
   983 // ------------------------------------------------
   757 // NotifyModified
   984 // NotifyModified
   758 // ------------------------------------------------
   985 // ------------------------------------------------
   759 //
   986 //
   760 void CMdSNotifier::NotifyModifiedL(const RArray<TItemId>& aObjectIds)
   987 void CMdSNotifier::NotifyModifiedL(const RArray<TItemId>& aObjectIds,
       
   988                                                          CMdSManipulationEngine* aMEngine)
   761 	{
   989 	{
   762 	if (aObjectIds.Count() == 0)
   990 	if (aObjectIds.Count() == 0)
   763     	{
   991     	{
   764     	return;
   992     	return;
   765     	}
   993     	}
   766 
   994 
   767     const TInt count = iEntries.Count();
   995     TBool allUrisFetched( EFalse );
   768 
   996     RPointerArray<HBufC> allUrisArray;
   769     for( TInt i = 0; i < count; ++i )
   997     CleanupResetAndDestroyPushL( allUrisArray );
       
   998 
       
   999     for( TInt i = iEntries.Count() - 1; i >=0; i-- )
   770         {
  1000         {
   771         TEntry& e = iEntries[i];
  1001         TEntry& e = iEntries[i];
   772 
  1002 
   773         if( e.iType & EObjectNotifyModify )
  1003         if( e.iType & (EObjectNotifyModify | EObjectNotifyModifyWithUri) )
   774             {
  1004             {
   775             // collect matching object IDs
  1005             // collect matching object IDs
   776             RArray<TItemId> matchingObjectIdArray;
  1006             RArray<TItemId> matchingObjectIdArray;
   777 			CleanupClosePushL( matchingObjectIdArray );
  1007 			CleanupClosePushL( matchingObjectIdArray );
   778 
  1008 		    RPointerArray<HBufC> uriArray;
   779                 const TBool allMatches = iComparator->MatchObjectIdsL( e.Condition(),
  1009 		    CleanupResetAndDestroyPushL( uriArray );
       
  1010 
       
  1011             const TBool allMatches = iComparator->MatchObjectIdsL( e.Condition(), 
   780             		aObjectIds, matchingObjectIdArray );
  1012             		aObjectIds, matchingObjectIdArray );
   781 
  1013 
   782 			// check is there any matches
  1014 			// check is there any matches
   783 			if( allMatches || matchingObjectIdArray.Count() > 0 )
  1015 			if( allMatches || matchingObjectIdArray.Count() > 0 )
   784             	{
  1016             	{
   788 	            	TInt err( KErrNone );
  1020 	            	TInt err( KErrNone );
   789 
  1021 
   790 	            	if( allMatches )
  1022 	            	if( allMatches )
   791 	            		{
  1023 	            		{
   792 	            		// all matches so send whole object ID array
  1024 	            		// all matches so send whole object ID array
   793 	            		TRAP( err, e.TriggerL( EObjectNotifyModify, 
  1025 	            		if( e.iType & EObjectNotifyModifyWithUri )
   794 	            				aObjectIds ) );
  1026 	            		    {
       
  1027 	            		    if( !allUrisFetched )
       
  1028 	            		        {
       
  1029 	            		        aMEngine->GetObjectUrisByIdsL( aObjectIds, allUrisArray );
       
  1030 	            		        allUrisFetched = ETrue;
       
  1031 	            		        }
       
  1032 	                        TRAP( err, e.TriggerL( EObjectNotifyModifyWithUri, 
       
  1033 	                                 aObjectIds, allUrisArray ) );
       
  1034 	            		    }
       
  1035 	            		else
       
  1036 	            		    {
       
  1037                             TRAP( err, e.TriggerL( EObjectNotifyModify, 
       
  1038                                      aObjectIds, uriArray ) );
       
  1039 	            		    }
   795 	            		}
  1040 	            		}
   796 	            	else
  1041 	            	else
   797 	            		{
  1042 	            		{
   798 	            		TRAP( err, e.TriggerL( EObjectNotifyModify, 
  1043                         if( e.iType & EObjectNotifyModifyWithUri )
   799 	            				matchingObjectIdArray ) );
  1044                             {
       
  1045                             aMEngine->GetObjectUrisByIdsL( matchingObjectIdArray, uriArray );
       
  1046                             TRAP( err, e.TriggerL( EObjectNotifyModifyWithUri, 
       
  1047                                     matchingObjectIdArray, uriArray ) );
       
  1048                             }
       
  1049                         else
       
  1050                             {
       
  1051                             TRAP( err, e.TriggerL( EObjectNotifyModify, 
       
  1052                                     matchingObjectIdArray, uriArray ) );
       
  1053                             }
   800 	            		}
  1054 	            		}
   801 
       
   802 	            	if( err != KErrNone )
  1055 	            	if( err != KErrNone )
   803 		            	{
  1056 		            	{
   804 		            	e.TriggerError( err );
  1057 		            	e.TriggerError( err );
   805 	    	        	}
  1058 	    	        	}
   806             		}
  1059             		}
   807             	else
  1060             	else
   808             		{
  1061             		{
   809 					if( allMatches )
  1062 					if( allMatches )
   810 	            		{
  1063 	            		{
   811 	            		// all matches so send whole object ID array
  1064                         // all matches so send whole object ID array
   812             			TRAP_IGNORE( e.CacheL( EObjectNotifyModify, 
  1065                         if( e.iType & EObjectNotifyModifyWithUri )
   813             					aObjectIds ) );
  1066                             {
       
  1067                             if( !allUrisFetched )
       
  1068                                 {
       
  1069                                 aMEngine->GetObjectUrisByIdsL( aObjectIds, allUrisArray );
       
  1070                                 allUrisFetched = ETrue;
       
  1071                                 }
       
  1072                             TRAP_IGNORE( e.CacheL( EObjectNotifyModifyWithUri, 
       
  1073                                      aObjectIds, allUrisArray ) );
       
  1074                             }
       
  1075                         else
       
  1076                             {
       
  1077                             TRAP_IGNORE( e.CacheL( EObjectNotifyModify, 
       
  1078                                      aObjectIds, uriArray ) );
       
  1079                             }
   814 	            		}
  1080 	            		}
   815 	            	else
  1081 	            	else
   816 	            		{
  1082 	            		{
   817 	            		TRAP_IGNORE( e.CacheL( EObjectNotifyModify, 
  1083                         if( e.iType & EObjectNotifyModifyWithUri )
   818 	            				matchingObjectIdArray ) );
  1084                             {
       
  1085                             aMEngine->GetObjectUrisByIdsL( matchingObjectIdArray, uriArray );
       
  1086                             TRAP_IGNORE( e.CacheL( EObjectNotifyModifyWithUri, 
       
  1087                                     matchingObjectIdArray, uriArray ) );
       
  1088                             }
       
  1089                         else
       
  1090                             {
       
  1091                             TRAP_IGNORE( e.CacheL( EObjectNotifyModify, 
       
  1092                                     matchingObjectIdArray, uriArray ) );
       
  1093                             }
   819 	            		}
  1094 	            		}
   820             		}
  1095             		}
   821             	}
  1096             	}
   822 
  1097 			CleanupStack::PopAndDestroy( 2, &matchingObjectIdArray ); // matchingObjectIdArray, uriArray
   823 			CleanupStack::PopAndDestroy( &matchingObjectIdArray );
       
   824             }
  1098             }
   825         }
  1099         }
       
  1100     CleanupStack::PopAndDestroy( &allUrisArray );
   826 	}
  1101 	}
   827 
  1102 
   828 // ------------------------------------------------
  1103 // ------------------------------------------------
   829 // NotifyRemoved
  1104 // NotifyRemoved
   830 // ------------------------------------------------
  1105 // ------------------------------------------------
   831 //
  1106 //
   832 void CMdSNotifier::NotifyRemovedL(const RArray<TItemId>& aItemIdArray)
  1107 void CMdSNotifier::NotifyRemovedL(const RArray<TItemId>& aItemIdArray,
       
  1108                                                           CMdSManipulationEngine* aMEngine)
   833 	{
  1109 	{
   834     const TInt entriesCount( iEntries.Count() );
  1110     if (aItemIdArray.Count() == 0)
   835     for( TInt i=0; i<entriesCount; ++i )
  1111         {
       
  1112         return;
       
  1113         }
       
  1114     
       
  1115     RPointerArray<HBufC> uriArray;
       
  1116     CleanupResetAndDestroyPushL( uriArray );
       
  1117     TBool urisFetched( EFalse );
       
  1118 	
       
  1119     for( TInt i = iEntries.Count()- 1; i >=0; i-- )
   836         {
  1120         {
   837         TEntry& e = iEntries[i];
  1121         TEntry& e = iEntries[i];
   838 
  1122 
   839         if( e.iType & EObjectNotifyRemove )
  1123         if( e.iType & EObjectNotifyRemove )
   840         	{
  1124         	{
       
  1125         	RPointerArray<HBufC> nullArray; // For when uris are not needed
       
  1126         	CleanupResetAndDestroyPushL( nullArray );
   841             if( e.IsPending() )
  1127             if( e.IsPending() )
   842             	{
  1128             	{
   843 	            TRAPD( err, e.TriggerL( EObjectNotifyRemove, aItemIdArray ) );
  1129 	            TRAPD( err, e.TriggerL( EObjectNotifyRemove, aItemIdArray, nullArray ) );
   844 	            if( err != KErrNone )
  1130 	            if( err != KErrNone )
   845 	            	{
  1131 	            	{
   846 	            	e.TriggerError( err );
  1132 	            	e.TriggerError( err );
   847 	            	}
  1133 	            	}
   848             	}
  1134             	}
   849             else
  1135             else
   850             	{
  1136             	{
   851             	TRAP_IGNORE( e.CacheL( EObjectNotifyRemove, aItemIdArray ) );
  1137             	TRAP_IGNORE( e.CacheL( EObjectNotifyRemove, aItemIdArray, nullArray ) );
   852             	}
  1138             	}
       
  1139             CleanupStack::PopAndDestroy( &nullArray );
   853         	}
  1140         	}
   854         }
  1141         else if( e.iType & EObjectNotifyRemoveWithUri )
       
  1142             {
       
  1143             if( !urisFetched && aMEngine )
       
  1144                 {
       
  1145                 aMEngine->GetObjectUrisByIdsL( aItemIdArray, uriArray );
       
  1146                 urisFetched = ETrue;
       
  1147                 }
       
  1148             if( e.IsPending() )
       
  1149                 {
       
  1150                 TRAPD( err, e.TriggerL( EObjectNotifyRemoveWithUri, aItemIdArray, uriArray ) );
       
  1151                 if( err != KErrNone )
       
  1152                     {
       
  1153                     e.TriggerError( err );
       
  1154                     }
       
  1155                 }
       
  1156             else
       
  1157                 {
       
  1158                 TRAP_IGNORE( e.CacheL( EObjectNotifyRemoveWithUri, aItemIdArray, uriArray ) );
       
  1159                 }
       
  1160             }
       
  1161         }
       
  1162     CleanupStack::PopAndDestroy( &uriArray );
   855 	}
  1163 	}
   856 
  1164 
   857 // ------------------------------------------------
  1165 // ------------------------------------------------
   858 // NotifyObjectPresent
  1166 // NotifyObjectPresent
   859 // ------------------------------------------------
  1167 // ------------------------------------------------
   863     if (aObjectIds.Count() == 0)
  1171     if (aObjectIds.Count() == 0)
   864     	{
  1172     	{
   865     	return;
  1173     	return;
   866     	}
  1174     	}
   867 
  1175 
   868     const TInt count = iEntries.Count();
  1176     for( TInt i = iEntries.Count() - 1; i >=0; i-- )
   869     
       
   870     for( TInt i = 0; i < count; ++i )
       
   871         {
  1177         {
   872         TEntry& e = iEntries[i];
  1178         TEntry& e = iEntries[i];
   873 
  1179 
   874         // No condition matching, object present changes
  1180         // No condition matching, object present changes
   875         // are always notified to object present observers
  1181         // are always notified to object present observers
   876         if( e.iType & ( EObjectNotifyPresent | EObjectNotifyNotPresent )  )
  1182         if( e.iType & ( EObjectNotifyPresent | EObjectNotifyNotPresent )  )
   877             {
  1183             {
   878             const TMdSObserverNotificationType objectState = 
  1184             const TMdSObserverNotificationType objectState = 
   879             	aPresent ? EObjectNotifyPresent : EObjectNotifyNotPresent;
  1185             	aPresent ? EObjectNotifyPresent : EObjectNotifyNotPresent;
   880 
  1186 
       
  1187             RPointerArray<HBufC> nullArray; // For when uris are not needed
   881             if( e.IsPending() )
  1188             if( e.IsPending() )
   882             	{
  1189             	{
   883             	// match found. trigger notifier entry !
  1190             	// match found. trigger notifier entry !
   884 	            TRAPD( err, e.TriggerL( objectState, aObjectIds ) );
  1191 	            TRAPD( err, e.TriggerL( objectState, aObjectIds, nullArray ) );
   885 	            if( err != KErrNone )
  1192 	            if( err != KErrNone )
   886 	            	{
  1193 	            	{
   887 	            	e.TriggerError( err );
  1194 	            	e.TriggerError( err );
   888 	            	}
  1195 	            	}
   889             	}
  1196             	}
   890             else
  1197             else
   891             	{
  1198             	{
   892             	TRAP_IGNORE( e.CacheL( objectState, aObjectIds ) );
  1199             	TRAP_IGNORE( e.CacheL( objectState, aObjectIds, nullArray ) );
   893             	}
  1200             	}
       
  1201             nullArray.Close();
   894             }
  1202             }
   895         }
  1203         }
   896     }
  1204     }
   897 
  1205 
   898 // ------------------------------------------------
  1206 // ------------------------------------------------
   904     if (aRelationIds.Count() == 0)
  1212     if (aRelationIds.Count() == 0)
   905     	{
  1213     	{
   906     	return;
  1214     	return;
   907     	}
  1215     	}
   908 
  1216 
   909     const TInt count = iEntries.Count();
  1217     for( TInt i = iEntries.Count() - 1; i >=0; i-- )
   910     
       
   911     for( TInt i = 0; i < count; ++i )
       
   912         {
  1218         {
   913         TEntry& e = iEntries[i];
  1219         TEntry& e = iEntries[i];
   914 
  1220 
   915         // No condition matching, relation present changes
  1221         // No condition matching, relation present changes
   916         // are always notified to relation present observers
  1222         // are always notified to relation present observers
   917         if( e.iType & ( ERelationNotifyPresent | ERelationNotifyNotPresent ) )
  1223         if( e.iType & ( ERelationNotifyPresent | ERelationNotifyNotPresent ) )
   918             {
  1224             {
   919             const TMdSObserverNotificationType relationState = 
  1225             const TMdSObserverNotificationType relationState = 
   920             	aPresent ? ERelationNotifyPresent : ERelationNotifyNotPresent;
  1226             	aPresent ? ERelationNotifyPresent : ERelationNotifyNotPresent;
   921 
  1227 
       
  1228             RPointerArray<HBufC> nullArray; // For when uris are not needed
   922             if( e.IsPending() )
  1229             if( e.IsPending() )
   923             	{
  1230             	{
   924             	// match found. trigger notifier entry !
  1231             	// match found. trigger notifier entry !
   925 	            TRAPD( err, e.TriggerL( relationState, aRelationIds ) );
  1232 	            TRAPD( err, e.TriggerL( relationState, aRelationIds, nullArray ) );
   926 	            if( err != KErrNone )
  1233 	            if( err != KErrNone )
   927 	            	{
  1234 	            	{
   928 	            	e.TriggerError( err );
  1235 	            	e.TriggerError( err );
   929 	            	}
  1236 	            	}
   930             	}
  1237             	}
   931             else
  1238             else
   932             	{
  1239             	{
   933             	TRAP_IGNORE( e.CacheL( relationState, aRelationIds ) );
  1240             	TRAP_IGNORE( e.CacheL( relationState, aRelationIds, nullArray ) );
   934             	}
  1241             	}
       
  1242             nullArray.Close();
   935             }
  1243             }
   936         }
  1244         }
   937     }
  1245     }
   938 
  1246 
   939 
  1247 
   941 // NotifySchemaAdded
  1249 // NotifySchemaAdded
   942 // ------------------------------------------------
  1250 // ------------------------------------------------
   943 //
  1251 //
   944 void CMdSNotifier::NotifySchemaAddedL()
  1252 void CMdSNotifier::NotifySchemaAddedL()
   945     {
  1253     {
   946     const TInt count = iEntries.Count();
  1254     for( TInt i = iEntries.Count() - 1; i >=0; i-- )
   947     
       
   948     for( TInt i = 0; i < count; ++i )
       
   949         {
  1255         {
   950         TEntry& e = iEntries[i];
  1256         TEntry& e = iEntries[i];
   951 
  1257 
   952         // No condition matching, schema additions 
  1258         // No condition matching, schema additions 
   953         // are always notified to schema observers
  1259         // are always notified to schema observers
   971 // CheckForNotifier
  1277 // CheckForNotifier
   972 // ------------------------------------------------
  1278 // ------------------------------------------------
   973 //
  1279 //
   974 TBool CMdSNotifier::CheckForNotifier( TUint32 aNotifyTypes )
  1280 TBool CMdSNotifier::CheckForNotifier( TUint32 aNotifyTypes )
   975     {
  1281     {
   976     const TInt count = iEntries.Count();
  1282     for( TInt i = iEntries.Count() - 1; i >=0; i-- )
   977     
       
   978     for( TInt i = 0; i < count; ++i )
       
   979         {
  1283         {
   980         if ( iEntries[i].iType & aNotifyTypes )
  1284         if ( iEntries[i].iType & aNotifyTypes )
   981         	{
  1285         	{
   982         	return ETrue;
  1286         	return ETrue;
   983         	}
  1287         	}
   992 
  1296 
   993 	const TMdCItems& items = TMdCItems::GetFromBufferL( aBuffer );
  1297 	const TMdCItems& items = TMdCItems::GetFromBufferL( aBuffer );
   994 
  1298 
   995 	if( items.iRelations.iPtr.iCount )
  1299 	if( items.iRelations.iPtr.iCount )
   996 		{
  1300 		{
   997 		const TInt entriesCount = iEntries.Count();
  1301 		for( TInt i = iEntries.Count() - 1; i >=0; i-- )
   998 	    for( TInt i = 0; i < entriesCount; ++i )
       
   999 	        {
  1302 	        {
  1000 	        TEntry& e = iEntries[i];
  1303 	        TEntry& e = iEntries[i];
  1001 	        
  1304 	        
  1002 	        // if namespace definition IDs don't match skip listener entry
  1305 	        // if namespace definition IDs don't match skip listener entry
  1003 	        if( e.NamespaceDefId() != items.iNamespaceDefId )
  1306 	        if( e.NamespaceDefId() != items.iNamespaceDefId )