metadataengine/client/src/mdesessionimpl.cpp
branchRCL_3
changeset 14 646a02f170b9
parent 3 b73a2e62868f
child 15 3cebc1a84278
equal deleted inserted replaced
8:6752808b2036 14:646a02f170b9
    66 	{
    66 	{
    67 	RMdESessionAsyncRequest request = RMdESessionAsyncRequest( 
    67 	RMdESessionAsyncRequest request = RMdESessionAsyncRequest( 
    68 			RMdESessionAsyncRequest::EAddRequest, 
    68 			RMdESessionAsyncRequest::EAddRequest, 
    69 			aBuffer, aResultBuffer, aRequestStatus );
    69 			aBuffer, aResultBuffer, aRequestStatus );
    70 
    70 
    71 	iRequests.Append(request);
    71 	const TInt error = iRequests.Append(request);
       
    72     if( error != KErrNone )
       
    73         {
       
    74         return;
       
    75         }
    72 
    76 
    73 	if( !IsActive() )
    77 	if( !IsActive() )
    74 		{
    78 		{
    75 		iEngineSession.DoAddItemsAsync( *aBuffer, aResultBuffer, 
    79 		iEngineSession.DoAddItemsAsync( *aBuffer, aResultBuffer, 
    76 				iStatus );
    80 				iStatus );
    84 	{
    88 	{
    85 	RMdESessionAsyncRequest request = RMdESessionAsyncRequest( 
    89 	RMdESessionAsyncRequest request = RMdESessionAsyncRequest( 
    86 			RMdESessionAsyncRequest::EUpdateRequest,
    90 			RMdESessionAsyncRequest::EUpdateRequest,
    87 			aBuffer, aResultBuffer, aRequestStatus);
    91 			aBuffer, aResultBuffer, aRequestStatus);
    88 
    92 
    89 	iRequests.Append(request);
    93 	const TInt error = iRequests.Append(request);
       
    94     if( error != KErrNone )
       
    95         {
       
    96         return;
       
    97         }
    90 
    98 
    91 	if( !IsActive() )
    99 	if( !IsActive() )
    92 		{
   100 		{
    93 		iEngineSession.DoUpdateItemsAsync(*aBuffer, aResultBuffer, 
   101 		iEngineSession.DoUpdateItemsAsync(*aBuffer, aResultBuffer, 
    94 				iStatus);
   102 				iStatus);
   102 	{
   110 	{
   103 	RMdESessionAsyncRequest request = RMdESessionAsyncRequest( 
   111 	RMdESessionAsyncRequest request = RMdESessionAsyncRequest( 
   104 			RMdESessionAsyncRequest::ERemoveRequest, 
   112 			RMdESessionAsyncRequest::ERemoveRequest, 
   105 			aBuffer, aResultBuffer, aRequestStatus);
   113 			aBuffer, aResultBuffer, aRequestStatus);
   106 
   114 
   107 	iRequests.Append(request);
   115 	const TInt error = iRequests.Append(request);
       
   116 	if( error != KErrNone )
       
   117 	    {
       
   118 	    return;
       
   119 	    }
   108 
   120 
   109 	if( !IsActive() )
   121 	if( !IsActive() )
   110 		{
   122 		{
   111 		iEngineSession.DoRemoveItemsAsync( *aBuffer, aResultBuffer, 
   123 		iEngineSession.DoRemoveItemsAsync( *aBuffer, aResultBuffer, 
   112 				iStatus );	
   124 				iStatus );	
   222 
   234 
   223 CMdESessionImpl::~CMdESessionImpl()
   235 CMdESessionImpl::~CMdESessionImpl()
   224 	{
   236 	{
   225     // No session errors should be sent during deconstruction to avoid possible double deletion
   237     // No session errors should be sent during deconstruction to avoid possible double deletion
   226     iSessionObserver = NULL;
   238     iSessionObserver = NULL;
   227     
       
   228 	Close();
       
   229 
   239 
   230 	delete iSchemaBuffer;
   240 	delete iSchemaBuffer;
   231 
   241 
   232 	iNotifiers.ResetAndDestroy();
   242 	iNotifiers.ResetAndDestroy();
   233 	iNotifiers.Close();
   243 	iNotifiers.Close();
   251     iAsyncHandler = CMdESessionAsyncHandler::NewL( *this, iSession );    
   261     iAsyncHandler = CMdESessionAsyncHandler::NewL( *this, iSession );    
   252     }
   262     }
   253 
   263 
   254 void CMdESessionImpl::Close()
   264 void CMdESessionImpl::Close()
   255 	{
   265 	{
   256 	iSchemaObserverArray.Reset();
       
   257 	iSchemaObserverArray.Close();
       
   258 	}
   266 	}
   259 
   267 
   260 TInt CMdESessionImpl::NamespaceDefCount() const
   268 TInt CMdESessionImpl::NamespaceDefCount() const
   261 	{
   269 	{
   262 	return iNamespaceDefs.Count();
   270 	return iNamespaceDefs.Count();
  1667 */
  1675 */
  1668 TItemId CMdESessionImpl::AddItemL( CMdEInstanceItem& aItem )
  1676 TItemId CMdESessionImpl::AddItemL( CMdEInstanceItem& aItem )
  1669 	{
  1677 	{
  1670 	RPointerArray<CMdEInstanceItem> items;
  1678 	RPointerArray<CMdEInstanceItem> items;
  1671 	CleanupClosePushL( items );
  1679 	CleanupClosePushL( items );
  1672 	items.Append( &aItem );
  1680 	items.AppendL( &aItem );
  1673 	User::LeaveIfError( AddItemsL( items ) );
  1681 	User::LeaveIfError( AddItemsL( items ) );
  1674 	CleanupStack::PopAndDestroy( &items );
  1682 	CleanupStack::PopAndDestroy( &items );
  1675 	return aItem.Id();
  1683 	return aItem.Id();
  1676 	}
  1684 	}
  1677 
  1685 
  1896 
  1904 
  1897 TItemId CMdESessionImpl::UpdateRelationL( CMdERelation& aRelation ) 
  1905 TItemId CMdESessionImpl::UpdateRelationL( CMdERelation& aRelation ) 
  1898     {
  1906     {
  1899 	RPointerArray<CMdEInstanceItem> items;
  1907 	RPointerArray<CMdEInstanceItem> items;
  1900 	CleanupClosePushL( items );
  1908 	CleanupClosePushL( items );
  1901 	items.Append( &aRelation );
  1909 	items.AppendL( &aRelation );
  1902 	User::LeaveIfError( UpdateItemsL( items ) );
  1910 	User::LeaveIfError( UpdateItemsL( items ) );
  1903 	CleanupStack::PopAndDestroy( &items );
  1911 	CleanupStack::PopAndDestroy( &items );
  1904 	return aRelation.Id();
  1912 	return aRelation.Id();
  1905     }
  1913     }
  1906 
  1914 
  2267 
  2275 
  2268     CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2276     CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2269     notifier->RegisterL( type, &aObserver, aCondition, *namespaceDef );
  2277     notifier->RegisterL( type, &aObserver, aCondition, *namespaceDef );
  2270 
  2278 
  2271     CleanupStack::Pop( notifier );
  2279     CleanupStack::Pop( notifier );
  2272     iNotifiers.Append( notifier );
  2280     iNotifiers.AppendL( notifier );
  2273     
  2281     
  2274     CleanupStack::PopAndDestroy( aCondition );
  2282     CleanupStack::PopAndDestroy( aCondition );
  2275     }
  2283     }
  2276     
  2284     
  2277 void CMdESessionImpl::AddObjectPresentObserverL(
  2285 void CMdESessionImpl::AddObjectPresentObserverL(
  2294     CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2302     CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2295     notifier->RegisterL( EObjectNotifyPresent | EObjectNotifyNotPresent,
  2303     notifier->RegisterL( EObjectNotifyPresent | EObjectNotifyNotPresent,
  2296     		&aObserver, NULL, namespaceDef );
  2304     		&aObserver, NULL, namespaceDef );
  2297 
  2305 
  2298     CleanupStack::Pop( notifier );
  2306     CleanupStack::Pop( notifier );
  2299     iNotifiers.Append( notifier );
  2307     iNotifiers.AppendL( notifier );
  2300 	}
  2308 	}
  2301 
  2309 
  2302 void CMdESessionImpl::AddRelationObserverL( MMdERelationObserver& aObserver,
  2310 void CMdESessionImpl::AddRelationObserverL( MMdERelationObserver& aObserver,
  2303     										CMdECondition* aCondition, 
  2311     										CMdECondition* aCondition, 
  2304     										TUint32 aNotificationType,
  2312     										TUint32 aNotificationType,
  2350     
  2358     
  2351     CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2359     CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2352     notifier->RegisterL( type, &aObserver, aCondition, *namespaceDef );
  2360     notifier->RegisterL( type, &aObserver, aCondition, *namespaceDef );
  2353 
  2361 
  2354     CleanupStack::Pop( notifier );
  2362     CleanupStack::Pop( notifier );
  2355     iNotifiers.Append( notifier );
  2363     iNotifiers.AppendL( notifier );
  2356     
  2364     
  2357     CleanupStack::PopAndDestroy( aCondition );
  2365     CleanupStack::PopAndDestroy( aCondition );
  2358     }
  2366     }
  2359 
  2367 
  2360 void CMdESessionImpl::AddRelationItemObserverL( 
  2368 void CMdESessionImpl::AddRelationItemObserverL( 
  2407 	
  2415 	
  2408 	CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2416 	CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2409 	notifier->RegisterL( type, &aObserver, aCondition, *namespaceDef );
  2417 	notifier->RegisterL( type, &aObserver, aCondition, *namespaceDef );
  2410 	
  2418 	
  2411 	CleanupStack::Pop( notifier );
  2419 	CleanupStack::Pop( notifier );
  2412 	iNotifiers.Append( notifier );
  2420 	iNotifiers.AppendL( notifier );
  2413 	
  2421 	
  2414     CleanupStack::PopAndDestroy( aCondition );
  2422     CleanupStack::PopAndDestroy( aCondition );
  2415 	}
  2423 	}
  2416 
  2424 
  2417 
  2425 
  2436     CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2444     CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2437     notifier->RegisterL( ERelationNotifyPresent | ERelationNotifyNotPresent,
  2445     notifier->RegisterL( ERelationNotifyPresent | ERelationNotifyNotPresent,
  2438     		&aObserver, NULL, namespaceDef );
  2446     		&aObserver, NULL, namespaceDef );
  2439 
  2447 
  2440     CleanupStack::Pop( notifier );
  2448     CleanupStack::Pop( notifier );
  2441     iNotifiers.Append( notifier );
  2449     iNotifiers.AppendL( notifier );
  2442 	}
  2450 	}
  2443 
  2451 
  2444 void CMdESessionImpl::AddEventObserverL( MMdEEventObserver& aObserver,
  2452 void CMdESessionImpl::AddEventObserverL( MMdEEventObserver& aObserver,
  2445     									 CMdECondition* aCondition, 
  2453     									 CMdECondition* aCondition, 
  2446     									 TUint32 aNotificationType,
  2454     									 TUint32 aNotificationType,
  2493 
  2501 
  2494     CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2502     CMdENotifierAO* notifier = CMdENotifierAO::NewLC( *this, iSession );
  2495     notifier->RegisterL( type, &aObserver, aCondition, *namespaceDef );
  2503     notifier->RegisterL( type, &aObserver, aCondition, *namespaceDef );
  2496 
  2504 
  2497     CleanupStack::Pop( notifier );
  2505     CleanupStack::Pop( notifier );
  2498     iNotifiers.Append( notifier );
  2506     iNotifiers.AppendL( notifier );
  2499     
  2507     
  2500     CleanupStack::PopAndDestroy( aCondition );
  2508     CleanupStack::PopAndDestroy( aCondition );
  2501     }
  2509     }
  2502 
  2510 
  2503 void CMdESessionImpl::RemoveObjectObserverL( 
  2511 void CMdESessionImpl::RemoveObjectObserverL(