metadataengine/client/src/mdesessionimpl.cpp
changeset 23 33ae025ac1e8
parent 21 50bf9db68373
child 28 c461c7fa72c2
equal deleted inserted replaced
21:50bf9db68373 23:33ae025ac1e8
    39 #include "mdcserializationbuffer.h"
    39 #include "mdcserializationbuffer.h"
    40 #include "mdequerycriteriaserialization.h"
    40 #include "mdequerycriteriaserialization.h"
    41 #include "mdelogiccondition.h"
    41 #include "mdelogiccondition.h"
    42 #include "mdeobjectcondition.h"
    42 #include "mdeobjectcondition.h"
    43 #include "mdscommoninternal.h"
    43 #include "mdscommoninternal.h"
       
    44 
       
    45 // for CleanupResetAndDestroyPushL
       
    46 #include <mmf/common/mmfcontrollerpluginresolver.h>
    44 
    47 
    45 RMdESessionAsyncRequest::RMdESessionAsyncRequest( TRequestType aRequestType, 
    48 RMdESessionAsyncRequest::RMdESessionAsyncRequest( TRequestType aRequestType, 
    46 	CMdCSerializationBuffer* aBuffer, CMdCSerializationBuffer& aResultBuffer,
    49 	CMdCSerializationBuffer* aBuffer, CMdCSerializationBuffer& aResultBuffer,
    47 	TRequestStatus& aRequestStatus) : 
    50 	TRequestStatus& aRequestStatus) : 
    48 	iRequestType(aRequestType), iBuffer(aBuffer), iResultBuffer(&aResultBuffer), 
    51 	iRequestType(aRequestType), iBuffer(aBuffer), iResultBuffer(&aResultBuffer), 
  1838 
  1841 
  1839 void CMdESessionImpl::DeserializeQueryResultL( 
  1842 void CMdESessionImpl::DeserializeQueryResultL( 
  1840 		CMdCSerializationBuffer& aBuffer, 
  1843 		CMdCSerializationBuffer& aBuffer, 
  1841 		RPointerArray<CMdEInstanceItem>& aItems )
  1844 		RPointerArray<CMdEInstanceItem>& aItems )
  1842 	{
  1845 	{
       
  1846     CleanupResetAndDestroyPushL( aItems );
       
  1847     
  1843 	const TMdCItems& items = TMdCItems::GetFromBufferL( aBuffer );
  1848 	const TMdCItems& items = TMdCItems::GetFromBufferL( aBuffer );
  1844 
  1849 
  1845     CMdENamespaceDef& namespaceDef = GetNamespaceDefL( items.iNamespaceDefId );
  1850     CMdENamespaceDef& namespaceDef = GetNamespaceDefL( items.iNamespaceDefId );
  1846 
  1851 
  1847     aItems.ReserveL( items.iObjects.iPtr.iCount + items.iEvents.iPtr.iCount 
  1852     aItems.ReserveL( items.iObjects.iPtr.iCount + items.iEvents.iPtr.iCount 
  1879 					namespaceDef );
  1884 					namespaceDef );
  1880 			aItems.AppendL( relation );
  1885 			aItems.AppendL( relation );
  1881 			CleanupStack::Pop( relation );
  1886 			CleanupStack::Pop( relation );
  1882 			}
  1887 			}
  1883 		}
  1888 		}
       
  1889 	
       
  1890 	CleanupStack::Pop( &aItems );
  1884 	}
  1891 	}
  1885 
  1892 
  1886 TItemId CMdESessionImpl::AddObjectL( CMdEObject& aObject )
  1893 TItemId CMdESessionImpl::AddObjectL( CMdEObject& aObject )
  1887     {
  1894     {
  1888     AddItemL(aObject);
  1895     AddItemL(aObject);
  2274     	}
  2281     	}
  2275 
  2282 
  2276     CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2283     CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2277     notifier->RegisterL( type, &aObserver, aCondition, *namespaceDef );
  2284     notifier->RegisterL( type, &aObserver, aCondition, *namespaceDef );
  2278 
  2285 
       
  2286     iNotifiers.AppendL( notifier );
  2279     CleanupStack::Pop( notifier );
  2287     CleanupStack::Pop( notifier );
  2280     iNotifiers.AppendL( notifier );
       
  2281     
  2288     
  2282     CleanupStack::PopAndDestroy( aCondition );
  2289     CleanupStack::PopAndDestroy( aCondition );
  2283     }
  2290     }
  2284     
  2291     
  2285 void CMdESessionImpl::AddObjectPresentObserverL(
  2292 void CMdESessionImpl::AddObjectPresentObserverL(
  2301 
  2308 
  2302     CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2309     CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2303     notifier->RegisterL( EObjectNotifyPresent | EObjectNotifyNotPresent,
  2310     notifier->RegisterL( EObjectNotifyPresent | EObjectNotifyNotPresent,
  2304     		&aObserver, NULL, namespaceDef );
  2311     		&aObserver, NULL, namespaceDef );
  2305 
  2312 
       
  2313     iNotifiers.AppendL( notifier );
  2306     CleanupStack::Pop( notifier );
  2314     CleanupStack::Pop( notifier );
  2307     iNotifiers.AppendL( notifier );
       
  2308 	}
  2315 	}
  2309 
  2316 
  2310 void CMdESessionImpl::AddRelationObserverL( MMdERelationObserver& aObserver,
  2317 void CMdESessionImpl::AddRelationObserverL( MMdERelationObserver& aObserver,
  2311     										CMdECondition* aCondition, 
  2318     										CMdECondition* aCondition, 
  2312     										TUint32 aNotificationType,
  2319     										TUint32 aNotificationType,
  2357     	}
  2364     	}
  2358     
  2365     
  2359     CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2366     CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2360     notifier->RegisterL( type, &aObserver, aCondition, *namespaceDef );
  2367     notifier->RegisterL( type, &aObserver, aCondition, *namespaceDef );
  2361 
  2368 
       
  2369     iNotifiers.AppendL( notifier );
  2362     CleanupStack::Pop( notifier );
  2370     CleanupStack::Pop( notifier );
  2363     iNotifiers.AppendL( notifier );
       
  2364     
  2371     
  2365     CleanupStack::PopAndDestroy( aCondition );
  2372     CleanupStack::PopAndDestroy( aCondition );
  2366     }
  2373     }
  2367 
  2374 
  2368 void CMdESessionImpl::AddRelationItemObserverL( 
  2375 void CMdESessionImpl::AddRelationItemObserverL( 
  2414 		}
  2421 		}
  2415 	
  2422 	
  2416 	CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2423 	CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2417 	notifier->RegisterL( type, &aObserver, aCondition, *namespaceDef );
  2424 	notifier->RegisterL( type, &aObserver, aCondition, *namespaceDef );
  2418 	
  2425 	
       
  2426 	iNotifiers.AppendL( notifier );
  2419 	CleanupStack::Pop( notifier );
  2427 	CleanupStack::Pop( notifier );
  2420 	iNotifiers.AppendL( notifier );
       
  2421 	
  2428 	
  2422     CleanupStack::PopAndDestroy( aCondition );
  2429     CleanupStack::PopAndDestroy( aCondition );
  2423 	}
  2430 	}
  2424 
  2431 
  2425 
  2432 
  2443     
  2450     
  2444     CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2451     CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2445     notifier->RegisterL( ERelationNotifyPresent | ERelationNotifyNotPresent,
  2452     notifier->RegisterL( ERelationNotifyPresent | ERelationNotifyNotPresent,
  2446     		&aObserver, NULL, namespaceDef );
  2453     		&aObserver, NULL, namespaceDef );
  2447 
  2454 
       
  2455     iNotifiers.AppendL( notifier );
  2448     CleanupStack::Pop( notifier );
  2456     CleanupStack::Pop( notifier );
  2449     iNotifiers.AppendL( notifier );
       
  2450 	}
  2457 	}
  2451 
  2458 
  2452 void CMdESessionImpl::AddEventObserverL( MMdEEventObserver& aObserver,
  2459 void CMdESessionImpl::AddEventObserverL( MMdEEventObserver& aObserver,
  2453     									 CMdECondition* aCondition, 
  2460     									 CMdECondition* aCondition, 
  2454     									 TUint32 aNotificationType,
  2461     									 TUint32 aNotificationType,
  2500     	}
  2507     	}
  2501 
  2508 
  2502     CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2509     CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2503     notifier->RegisterL( type, &aObserver, aCondition, *namespaceDef );
  2510     notifier->RegisterL( type, &aObserver, aCondition, *namespaceDef );
  2504 
  2511 
       
  2512     iNotifiers.AppendL( notifier );
  2505     CleanupStack::Pop( notifier );
  2513     CleanupStack::Pop( notifier );
  2506     iNotifiers.AppendL( notifier );
       
  2507     
  2514     
  2508     CleanupStack::PopAndDestroy( aCondition );
  2515     CleanupStack::PopAndDestroy( aCondition );
  2509     }
  2516     }
  2510 
  2517 
  2511 void CMdESessionImpl::RemoveObjectObserverL( 
  2518 void CMdESessionImpl::RemoveObjectObserverL( 
  2525     const TInt index = FindNotifier( 
  2532     const TInt index = FindNotifier( 
  2526     		EObjectNotifyAdd | EObjectNotifyModify | EObjectNotifyRemove,
  2533     		EObjectNotifyAdd | EObjectNotifyModify | EObjectNotifyRemove,
  2527     		&aObserver, *namespaceDef );
  2534     		&aObserver, *namespaceDef );
  2528     if ( index != KErrNotFound )
  2535     if ( index != KErrNotFound )
  2529         {
  2536         {
  2530     	iNotifiers[index]->Cancel();
       
  2531     	delete iNotifiers[index];
  2537     	delete iNotifiers[index];
  2532     	iNotifiers[index] = NULL;
  2538     	iNotifiers[index] = NULL;
  2533     	iNotifiers.Remove( index );
  2539     	iNotifiers.Remove( index );
  2534     	iNotifiers.Compress();
  2540     	iNotifiers.Compress();
  2535         }
  2541         }
  2547 
  2553 
  2548     const TInt index = FindNotifier( EObjectNotifyPresent | EObjectNotifyNotPresent,
  2554     const TInt index = FindNotifier( EObjectNotifyPresent | EObjectNotifyNotPresent,
  2549     		&aObserver, namespaceDef );
  2555     		&aObserver, namespaceDef );
  2550     if ( index != KErrNotFound )
  2556     if ( index != KErrNotFound )
  2551         {
  2557         {
  2552     	iNotifiers[index]->Cancel();
       
  2553     	delete iNotifiers[index];
  2558     	delete iNotifiers[index];
  2554     	iNotifiers[index] = NULL;
  2559     	iNotifiers[index] = NULL;
  2555     	iNotifiers.Remove( index );
  2560     	iNotifiers.Remove( index );
  2556     	iNotifiers.Compress();
  2561     	iNotifiers.Compress();
  2557         }
  2562         }
  2578     const TInt index = FindNotifier( 
  2583     const TInt index = FindNotifier( 
  2579     		ERelationNotifyAdd | ERelationNotifyModify | ERelationNotifyRemove,
  2584     		ERelationNotifyAdd | ERelationNotifyModify | ERelationNotifyRemove,
  2580     		&aObserver, *namespaceDef );
  2585     		&aObserver, *namespaceDef );
  2581     if ( index != KErrNotFound )
  2586     if ( index != KErrNotFound )
  2582         {
  2587         {
  2583     	iNotifiers[index]->Cancel();
       
  2584     	delete iNotifiers[index];
  2588     	delete iNotifiers[index];
  2585     	iNotifiers[index] = NULL;
  2589     	iNotifiers[index] = NULL;
  2586     	iNotifiers.Remove( index );
  2590     	iNotifiers.Remove( index );
  2587     	iNotifiers.Compress();
  2591     	iNotifiers.Compress();
  2588         }
  2592         }
  2610     		/*ERelationItemNotifyAdd | ERelationItemNotifyModify |*/ 
  2614     		/*ERelationItemNotifyAdd | ERelationItemNotifyModify |*/ 
  2611     		ERelationItemNotifyRemove,
  2615     		ERelationItemNotifyRemove,
  2612     		&aObserver, *namespaceDef );
  2616     		&aObserver, *namespaceDef );
  2613     if ( index != KErrNotFound )
  2617     if ( index != KErrNotFound )
  2614         {
  2618         {
  2615     	iNotifiers[index]->Cancel();
       
  2616     	delete iNotifiers[index];
  2619     	delete iNotifiers[index];
  2617     	iNotifiers[index] = NULL;
  2620     	iNotifiers[index] = NULL;
  2618     	iNotifiers.Remove( index );
  2621     	iNotifiers.Remove( index );
  2619         }
  2622         }
  2620     else
  2623     else
  2632     const TInt index = FindNotifier( 
  2635     const TInt index = FindNotifier( 
  2633     		ERelationNotifyPresent | ERelationNotifyNotPresent,
  2636     		ERelationNotifyPresent | ERelationNotifyNotPresent,
  2634     		&aObserver, namespaceDef );
  2637     		&aObserver, namespaceDef );
  2635     if ( index != KErrNotFound )
  2638     if ( index != KErrNotFound )
  2636         {
  2639         {
  2637     	iNotifiers[index]->Cancel();
       
  2638     	delete iNotifiers[index];
  2640     	delete iNotifiers[index];
  2639     	iNotifiers[index] = NULL;
  2641     	iNotifiers[index] = NULL;
  2640     	iNotifiers.Remove( index );
  2642     	iNotifiers.Remove( index );
  2641     	iNotifiers.Compress();
  2643     	iNotifiers.Compress();
  2642         }
  2644         }
  2662     
  2664     
  2663     const TInt index = FindNotifier( EEventNotifyAdd | EEventNotifyRemove,
  2665     const TInt index = FindNotifier( EEventNotifyAdd | EEventNotifyRemove,
  2664     		&aObserver, *namespaceDef );
  2666     		&aObserver, *namespaceDef );
  2665     if ( index != KErrNotFound )
  2667     if ( index != KErrNotFound )
  2666         {
  2668         {
  2667 	    iNotifiers[index]->Cancel();
       
  2668 	    delete iNotifiers[index];
  2669 	    delete iNotifiers[index];
  2669 	    iNotifiers[index] = NULL;
  2670 	    iNotifiers[index] = NULL;
  2670 	    iNotifiers.Remove( index );
  2671 	    iNotifiers.Remove( index );
  2671         }
  2672         }
  2672     else
  2673     else
  2889 	}
  2890 	}
  2890 
  2891 
  2891 void CMdESessionImpl::GetItemIdL( CMdCSerializationBuffer* aBuffer, 
  2892 void CMdESessionImpl::GetItemIdL( CMdCSerializationBuffer* aBuffer, 
  2892 		RArray<TItemId>& aIdArray )
  2893 		RArray<TItemId>& aIdArray )
  2893 	{
  2894 	{
       
  2895     CleanupClosePushL( aIdArray );
       
  2896     
  2894 	const TMdCItemIds& itemIds = TMdCItemIds::GetFromBufferL( *aBuffer );
  2897 	const TMdCItemIds& itemIds = TMdCItemIds::GetFromBufferL( *aBuffer );
  2895 
  2898 
  2896 	if( itemIds.iObjectIds.iPtr.iCount > 0 ) 
  2899 	if( itemIds.iObjectIds.iPtr.iCount > 0 ) 
  2897 	    {
  2900 	    {
  2898 	    aBuffer->PositionL( itemIds.iObjectIds.iPtr.iOffset );
  2901 	    aBuffer->PositionL( itemIds.iObjectIds.iPtr.iOffset );
  2915 	    {
  2918 	    {
  2916 	    TItemId id;
  2919 	    TItemId id;
  2917 	    aBuffer->ReceiveL( id );
  2920 	    aBuffer->ReceiveL( id );
  2918 	    aIdArray.AppendL( id );
  2921 	    aIdArray.AppendL( id );
  2919 	    }
  2922 	    }
       
  2923 	
       
  2924 	CleanupStack::Pop( &aIdArray );
  2920 	}
  2925 	}
  2921 
  2926 
  2922 void CMdESessionImpl::GetDistinctValuesL( CMdCSerializationBuffer& aBuffer, 
  2927 void CMdESessionImpl::GetDistinctValuesL( CMdCSerializationBuffer& aBuffer, 
  2923 		CDesCArray& aResults )
  2928 		CDesCArray& aResults )
  2924 	{
  2929 	{
  2994         }
  2999         }
  2995 
  3000 
  2996     CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  3001     CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2997     notifier->RegisterL( type, &aObserver, aCondition, *namespaceDef );
  3002     notifier->RegisterL( type, &aObserver, aCondition, *namespaceDef );
  2998 
  3003 
       
  3004     iNotifiers.AppendL( notifier );
  2999     CleanupStack::Pop( notifier );
  3005     CleanupStack::Pop( notifier );
  3000     iNotifiers.Append( notifier );
       
  3001     
  3006     
  3002     CleanupStack::PopAndDestroy( aCondition );
  3007     CleanupStack::PopAndDestroy( aCondition );
  3003     }
  3008     }
  3004 
  3009 
  3005 void CMdESessionImpl::RemoveObjectObserverWithUriL( 
  3010 void CMdESessionImpl::RemoveObjectObserverWithUriL( 
  3019     const TInt index = FindNotifier( 
  3024     const TInt index = FindNotifier( 
  3020             EObjectNotifyAddWithUri | EObjectNotifyModifyWithUri | EObjectNotifyRemoveWithUri,
  3025             EObjectNotifyAddWithUri | EObjectNotifyModifyWithUri | EObjectNotifyRemoveWithUri,
  3021             &aObserver, *namespaceDef );
  3026             &aObserver, *namespaceDef );
  3022     if ( index != KErrNotFound )
  3027     if ( index != KErrNotFound )
  3023         {
  3028         {
  3024         iNotifiers[index]->Cancel();
       
  3025         delete iNotifiers[index];
  3029         delete iNotifiers[index];
  3026         iNotifiers[index] = NULL;
  3030         iNotifiers[index] = NULL;
  3027         iNotifiers.Remove( index );
  3031         iNotifiers.Remove( index );
  3028         iNotifiers.Compress();
  3032         iNotifiers.Compress();
  3029         }
  3033         }