metadataengine/client/src/mdesessionimpl.cpp
changeset 1 acef663c1218
parent 0 c53acadfccc6
child 2 b73a2e62868f
equal deleted inserted replaced
0:c53acadfccc6 1:acef663c1218
   220 	{
   220 	{
   221 	}
   221 	}
   222 
   222 
   223 CMdESessionImpl::~CMdESessionImpl()
   223 CMdESessionImpl::~CMdESessionImpl()
   224 	{
   224 	{
       
   225     // No session errors should be sent during deconstruction to avoid possible double deletion
       
   226     iSessionObserver = NULL;
       
   227     
   225 	Close();
   228 	Close();
   226 
   229 
   227 	delete iSchemaBuffer;
   230 	delete iSchemaBuffer;
   228 
   231 
   229 	iNotifiers.ResetAndDestroy();
   232 	iNotifiers.ResetAndDestroy();
   448 	{
   451 	{
   449 	CheckOpened();
   452 	CheckOpened();
   450 
   453 
   451 	CMdENamespaceDef& defaultNamespaceDef = GetDefaultNamespaceDefL();
   454 	CMdENamespaceDef& defaultNamespaceDef = GetDefaultNamespaceDefL();
   452 
   455 
   453     TInt index = FindNotifier( ESchemaModify, &aObserver, defaultNamespaceDef );
   456     const TInt index = FindNotifier( ESchemaModify, &aObserver, defaultNamespaceDef );
   454     if ( index != KErrNotFound )
   457     if ( index != KErrNotFound )
   455         {
   458         {
   456 	    iNotifiers[index]->Cancel();
   459 	    iNotifiers[index]->Cancel();
   457 	    delete iNotifiers[index];
   460 	    delete iNotifiers[index];
   458 	    iNotifiers[index] = NULL;
   461 	    iNotifiers[index] = NULL;
  1626 	RMdEDataBuffer dataBuffer;
  1629 	RMdEDataBuffer dataBuffer;
  1627 	dataBuffer.SetBufferL( successfulBuffer );
  1630 	dataBuffer.SetBufferL( successfulBuffer );
  1628 	CleanupStack::Pop( successfulBuffer );
  1631 	CleanupStack::Pop( successfulBuffer );
  1629 	CleanupClosePushL( dataBuffer );
  1632 	CleanupClosePushL( dataBuffer );
  1630     
  1633     
  1631     TInt firstItemError = DeserializeIdsL( dataBuffer, NULL, NULL, 
  1634     const TInt firstItemError = DeserializeIdsL( dataBuffer, NULL, NULL, 
  1632     		&aSuccessful );
  1635     		&aSuccessful );
  1633     CleanupStack::PopAndDestroy( &dataBuffer ); // successfulBuffer, buffer
  1636     CleanupStack::PopAndDestroy( &dataBuffer ); // successfulBuffer, buffer
  1634     CleanupStack::PopAndDestroy( buffer ); // successfulBuffer, buffer
  1637     CleanupStack::PopAndDestroy( buffer ); // successfulBuffer, buffer
  1635     return firstItemError;
  1638     return firstItemError;
  1636 	}
  1639 	}
  2091 	dataBuffer.SetBufferL( successfulBuffer );
  2094 	dataBuffer.SetBufferL( successfulBuffer );
  2092 	CleanupStack::Pop( successfulBuffer );
  2095 	CleanupStack::Pop( successfulBuffer );
  2093 	CleanupClosePushL( dataBuffer );
  2096 	CleanupClosePushL( dataBuffer );
  2094 	
  2097 	
  2095     iSession.DoRemoveItemsL( *buffer, *successfulBuffer );
  2098     iSession.DoRemoveItemsL( *buffer, *successfulBuffer );
  2096     TInt firstItemError = DeserializeIdsL( dataBuffer, NULL, 
  2099     const TInt firstItemError = DeserializeIdsL( dataBuffer, NULL, 
  2097     		&aSuccessful );
  2100     		&aSuccessful );
  2098 
  2101 
  2099     CleanupStack::PopAndDestroy( &dataBuffer );
  2102     CleanupStack::PopAndDestroy( &dataBuffer );
  2100     CleanupStack::PopAndDestroy( buffer );
  2103     CleanupStack::PopAndDestroy( buffer );
  2101     
  2104     
  2509     else
  2512     else
  2510     	{
  2513     	{
  2511     	namespaceDef = aNamespaceDef;
  2514     	namespaceDef = aNamespaceDef;
  2512     	}
  2515     	}
  2513 
  2516 
  2514     TInt index = FindNotifier( 
  2517     const TInt index = FindNotifier( 
  2515     		EObjectNotifyAdd | EObjectNotifyModify | EObjectNotifyRemove,
  2518     		EObjectNotifyAdd | EObjectNotifyModify | EObjectNotifyRemove,
  2516     		&aObserver, *namespaceDef );
  2519     		&aObserver, *namespaceDef );
  2517     if ( index != KErrNotFound )
  2520     if ( index != KErrNotFound )
  2518         {
  2521         {
  2519     	iNotifiers[index]->Cancel();
  2522     	iNotifiers[index]->Cancel();
  2531 		MMdEObjectPresentObserver& aObserver)
  2534 		MMdEObjectPresentObserver& aObserver)
  2532 	{
  2535 	{
  2533 	// if namespace is not given get default namespace definition
  2536 	// if namespace is not given get default namespace definition
  2534     CMdENamespaceDef& namespaceDef = GetDefaultNamespaceDefL();
  2537     CMdENamespaceDef& namespaceDef = GetDefaultNamespaceDefL();
  2535 
  2538 
  2536     TInt index = FindNotifier( EObjectNotifyPresent | EObjectNotifyNotPresent,
  2539     const TInt index = FindNotifier( EObjectNotifyPresent | EObjectNotifyNotPresent,
  2537     		&aObserver, namespaceDef );
  2540     		&aObserver, namespaceDef );
  2538     if ( index != KErrNotFound )
  2541     if ( index != KErrNotFound )
  2539         {
  2542         {
  2540     	iNotifiers[index]->Cancel();
  2543     	iNotifiers[index]->Cancel();
  2541     	delete iNotifiers[index];
  2544     	delete iNotifiers[index];
  2560     else
  2563     else
  2561     	{
  2564     	{
  2562     	namespaceDef = aNamespaceDef;
  2565     	namespaceDef = aNamespaceDef;
  2563     	}
  2566     	}
  2564 
  2567 
  2565     TInt index = FindNotifier( 
  2568     const TInt index = FindNotifier( 
  2566     		ERelationNotifyAdd | ERelationNotifyModify | ERelationNotifyRemove,
  2569     		ERelationNotifyAdd | ERelationNotifyModify | ERelationNotifyRemove,
  2567     		&aObserver, *namespaceDef );
  2570     		&aObserver, *namespaceDef );
  2568     if ( index != KErrNotFound )
  2571     if ( index != KErrNotFound )
  2569         {
  2572         {
  2570     	iNotifiers[index]->Cancel();
  2573     	iNotifiers[index]->Cancel();
  2590     else
  2593     else
  2591     	{
  2594     	{
  2592     	namespaceDef = aNamespaceDef;
  2595     	namespaceDef = aNamespaceDef;
  2593     	}
  2596     	}
  2594 
  2597 
  2595     TInt index = FindNotifier( 
  2598     const TInt index = FindNotifier( 
  2596     		/*ERelationItemNotifyAdd | ERelationItemNotifyModify |*/ 
  2599     		/*ERelationItemNotifyAdd | ERelationItemNotifyModify |*/ 
  2597     		ERelationItemNotifyRemove,
  2600     		ERelationItemNotifyRemove,
  2598     		&aObserver, *namespaceDef );
  2601     		&aObserver, *namespaceDef );
  2599     if ( index != KErrNotFound )
  2602     if ( index != KErrNotFound )
  2600         {
  2603         {
  2613 		MMdERelationPresentObserver& aObserver)
  2616 		MMdERelationPresentObserver& aObserver)
  2614 	{
  2617 	{
  2615 	// if namespace is not given get default namespace definition
  2618 	// if namespace is not given get default namespace definition
  2616     CMdENamespaceDef& namespaceDef = GetDefaultNamespaceDefL();
  2619     CMdENamespaceDef& namespaceDef = GetDefaultNamespaceDefL();
  2617 
  2620 
  2618     TInt index = FindNotifier( 
  2621     const TInt index = FindNotifier( 
  2619     		ERelationNotifyPresent | ERelationNotifyNotPresent,
  2622     		ERelationNotifyPresent | ERelationNotifyNotPresent,
  2620     		&aObserver, namespaceDef );
  2623     		&aObserver, namespaceDef );
  2621     if ( index != KErrNotFound )
  2624     if ( index != KErrNotFound )
  2622         {
  2625         {
  2623     	iNotifiers[index]->Cancel();
  2626     	iNotifiers[index]->Cancel();
  2643     else
  2646     else
  2644     	{
  2647     	{
  2645     	namespaceDef = aNamespaceDef;
  2648     	namespaceDef = aNamespaceDef;
  2646     	}
  2649     	}
  2647     
  2650     
  2648     TInt index = FindNotifier( EEventNotifyAdd | EEventNotifyRemove,
  2651     const TInt index = FindNotifier( EEventNotifyAdd | EEventNotifyRemove,
  2649     		&aObserver, *namespaceDef );
  2652     		&aObserver, *namespaceDef );
  2650     if ( index != KErrNotFound )
  2653     if ( index != KErrNotFound )
  2651         {
  2654         {
  2652 	    iNotifiers[index]->Cancel();
  2655 	    iNotifiers[index]->Cancel();
  2653 	    delete iNotifiers[index];
  2656 	    delete iNotifiers[index];
  2674     return KErrNotFound;
  2677     return KErrNotFound;
  2675     }
  2678     }
  2676 
  2679 
  2677 void CMdESessionImpl::NotifierInError( CMdENotifierAO* aNotifier )
  2680 void CMdESessionImpl::NotifierInError( CMdENotifierAO* aNotifier )
  2678     {
  2681     {
  2679     TInt index = iNotifiers.Find( aNotifier );
  2682     const TInt index = iNotifiers.Find( aNotifier );
  2680     delete aNotifier;
  2683     delete aNotifier;
  2681     iNotifiers.Remove( index );
  2684     iNotifiers.Remove( index );
  2682     }
  2685     }
  2683 
  2686 
  2684 void CMdESessionImpl::ImportSchemaL( const TDesC& aFileName )
  2687 void CMdESessionImpl::ImportSchemaL( const TDesC& aFileName )