metadataengine/client/src/mdenotifierao.cpp
branchRCL_3
changeset 7 3cebc1a84278
parent 6 646a02f170b9
child 9 82c0024438c8
equal deleted inserted replaced
6:646a02f170b9 7:3cebc1a84278
   163 	            DoNotifyObserver(); // notifies the observer about the event with an array of ids
   163 	            DoNotifyObserver(); // notifies the observer about the event with an array of ids
   164 	    		}
   164 	    		}
   165 	        iSession.DoListen( Id(), &iResultSize, iStatus );  // continue listening for events
   165 	        iSession.DoListen( Id(), &iResultSize, iStatus );  // continue listening for events
   166 	        SetActive();
   166 	        SetActive();
   167 	        }
   167 	        }
   168 	    else if ( status & ( /*ERelationItemNotifyAdd | ERelationItemNotifyModify
   168 	    else if ( status & ( ERelationItemNotifyRemove ) ) // a relation was removed
   169 	                         |*/ ERelationItemNotifyRemove ) ) // a relation was removed
       
   170 	    	{
   169 	    	{
   171 	    	if( !iDataBuffer )
   170 	    	if( !iDataBuffer )
   172 	    		{
   171 	    		{
   173 	    		iDataBuffer = CMdCSerializationBuffer::NewL(iResultSize());
   172 	    		iDataBuffer = CMdCSerializationBuffer::NewL(iResultSize());
   174 	    		}
   173 	    		}
   196 	    	{
   195 	    	{
   197 	        DoNotifyObserver(); // notifies the observer about the event with an array of ids
   196 	        DoNotifyObserver(); // notifies the observer about the event with an array of ids
   198 	        iSession.DoListen( Id(), &iResultSize, iStatus ); // continue listening for events
   197 	        iSession.DoListen( Id(), &iResultSize, iStatus ); // continue listening for events
   199 	        SetActive();
   198 	        SetActive();
   200 	    	}
   199 	    	}
       
   200 	    else if ( status & ( EObjectNotifyAddWithUri | EObjectNotifyModifyWithUri
       
   201 	                           | EObjectNotifyRemoveWithUri ) )
       
   202 	        {
       
   203 	        if( !iDataBuffer )
       
   204 	            {
       
   205 	            iDataBuffer = CMdCSerializationBuffer::NewL( iResultSize() );
       
   206 	            }
       
   207 	        else if( iDataBuffer->Buffer().MaxSize() < iResultSize() )
       
   208 	            {
       
   209 	            delete iDataBuffer;
       
   210 	            iDataBuffer = NULL;
       
   211 	            iDataBuffer = CMdCSerializationBuffer::NewL( iResultSize() );
       
   212 	            }
       
   213 	        
       
   214 	        if( iResultSize() )
       
   215 	            {
       
   216 	            iSession.DoGetDataL( *iDataBuffer, Id() ); // reads data to the buffer
       
   217 	            DecodeDataBufferL(); // decodes ids and uri from the data buffer 
       
   218 	            
       
   219 	            delete iDataBuffer;
       
   220 	            iDataBuffer = NULL;
       
   221 	            
       
   222 	            DoNotifyObserver(); // notifies the observer about the event
       
   223 	            }
       
   224 	        iSession.DoListen( Id(), &iResultSize, iStatus );  // continue listening for events
       
   225 	        SetActive();
       
   226 	        }
   201     	}
   227     	}
   202     else
   228     else
   203         {
   229         {
   204         // error in notifier mechanism
   230         // error in notifier mechanism
   205         if( status != KErrServerTerminated )
   231         if( status != KErrServerTerminated )
   325         	{
   351         	{
   326             MMdESchemaObserver* obs = static_cast<MMdESchemaObserver*>( iObserver );
   352             MMdESchemaObserver* obs = static_cast<MMdESchemaObserver*>( iObserver );
   327             obs->HandleSchemaModified();
   353             obs->HandleSchemaModified();
   328         	break;
   354         	break;
   329         	}
   355         	}
   330 
   356         	
       
   357         case EObjectNotifyAddWithUri:
       
   358             {
       
   359             MMdEObjectObserverWithUri* obs = static_cast<MMdEObjectObserverWithUri*>( iObserver );
       
   360             obs->HandleUriObjectNotification( iSessionImpl, ENotifyAdd, iIdArray, iUriArray );
       
   361             iUriArray.ResetAndDestroy();
       
   362             iUriArray.Compress();
       
   363             break;
       
   364             }
       
   365         case EObjectNotifyModifyWithUri:
       
   366             {
       
   367             MMdEObjectObserverWithUri* obs = static_cast<MMdEObjectObserverWithUri*>( iObserver );
       
   368             obs->HandleUriObjectNotification( iSessionImpl, ENotifyModify, iIdArray, iUriArray );
       
   369             iUriArray.ResetAndDestroy();
       
   370             iUriArray.Compress();
       
   371             break;
       
   372             }
       
   373         case EObjectNotifyRemoveWithUri:
       
   374             {
       
   375             MMdEObjectObserverWithUri* obs = static_cast<MMdEObjectObserverWithUri*>( iObserver );
       
   376             obs->HandleUriObjectNotification( iSessionImpl, ENotifyRemove, iIdArray, iUriArray );
       
   377             iUriArray.ResetAndDestroy();
       
   378             iUriArray.Compress();
       
   379             break;
       
   380             }    	
       
   381         	
   331         default:
   382         default:
   332         	// no observer to call - this should be skipped on server side!
   383         	// no observer to call - this should be skipped on server side!
   333         	break;
   384         	break;
   334         }
   385         }
   335     iIdArray.Reset();
   386     iIdArray.Reset();
   353 		TItemId id;
   404 		TItemId id;
   354 		iDataBuffer->ReceiveL( id );
   405 		iDataBuffer->ReceiveL( id );
   355 		iIdArray.AppendL( id );
   406 		iIdArray.AppendL( id );
   356 		}
   407 		}
   357 	}
   408 	}
       
   409 
       
   410 void CMdENotifierAO::DecodeDataBufferL()
       
   411     {    
       
   412     iIdArray.Reset();
       
   413     iUriArray.ResetAndDestroy();
       
   414     
       
   415     iDataBuffer->PositionL( KNoOffset );
       
   416     
       
   417     const TMdCItemIds& itemIds = TMdCItemIds::GetFromBufferL( *iDataBuffer );
       
   418     __ASSERT_DEBUG( iNamespaceDefId == itemIds.iNamespaceDefId, User::Panic( _L("Incorrect namespaceDef from returned items!"), KErrCorrupt ) );
       
   419     
       
   420     // Get IDs
       
   421     iDataBuffer->PositionL( itemIds.iObjectIds.iPtr.iOffset );
       
   422 	iIdArray.ReserveL( itemIds.iObjectIds.iPtr.iCount );
       
   423     for( TUint32 i = 0; i < itemIds.iObjectIds.iPtr.iCount; ++i )
       
   424         {
       
   425         TItemId id;
       
   426         iDataBuffer->ReceiveL( id );
       
   427         iIdArray.AppendL( id );
       
   428         }
       
   429     
       
   430     // Get uri count
       
   431     TUint32 uriCount ( 0 );
       
   432     iDataBuffer->ReceiveL( uriCount );
       
   433     
       
   434     HBufC* uri = NULL;
       
   435     
       
   436     for( TInt i( 0 ); i < uriCount; i++ )
       
   437         {        
       
   438         //Get uri
       
   439         uri = iDataBuffer->ReceiveDes16L();
       
   440         CleanupStack::PushL( uri );
       
   441         iUriArray.AppendL( uri );
       
   442         CleanupStack::Pop( uri );
       
   443         }
       
   444     }
   358 
   445 
   359 void CMdENotifierAO::DecodeRelationItemBufferL()
   446 void CMdENotifierAO::DecodeRelationItemBufferL()
   360 	{
   447 	{
   361     iRelationItemArray.Reset();
   448     iRelationItemArray.Reset();
   362 	iDataBuffer->PositionL( KNoOffset );
   449 	iDataBuffer->PositionL( KNoOffset );
   374     		{
   461     		{
   375     		iRelationItemArray.AppendL( relation );
   462     		iRelationItemArray.AppendL( relation );
   376     		}
   463     		}
   377     	}
   464     	}
   378 	}
   465 	}
       
   466