metadataengine/client/src/mdequery.cpp
branchRCL_3
changeset 14 646a02f170b9
parent 0 c53acadfccc6
child 15 3cebc1a84278
equal deleted inserted replaced
8:6752808b2036 14:646a02f170b9
    26 
    26 
    27 
    27 
    28 CMdEQuery::CMdEQuery(TQueryType aType, CMdESession& aSession, CMdENamespaceDef& aNamespaceDef)
    28 CMdEQuery::CMdEQuery(TQueryType aType, CMdESession& aSession, CMdENamespaceDef& aNamespaceDef)
    29         : iQueryId( 0 ), iSession(aSession), iNamespaceDef(aNamespaceDef), iType(aType), 
    29         : iQueryId( 0 ), iSession(aSession), iNamespaceDef(aNamespaceDef), iType(aType), 
    30           iResultMode(EQueryResultModeItem), iState(EStateNew), iError(KErrNone), 
    30           iResultMode(EQueryResultModeItem), iState(EStateNew), iError(KErrNone), 
    31           iObjectResult(NULL), iCountResult(0), iDistinctResults(NULL)
    31           iObjectResult(NULL), iCountResult(0), iDistinctResults(NULL), iDestroyed(EFalse)
    32     {
    32     {
    33     }
    33     }
    34 
    34 
    35 
    35 
    36 void CMdEQuery::QueryConstructL()
    36 void CMdEQuery::QueryConstructL()
    39     }
    39     }
    40 
    40 
    41 
    41 
    42 CMdEQuery::~CMdEQuery()
    42 CMdEQuery::~CMdEQuery()
    43 	{
    43 	{
       
    44     iDestroyed = ETrue;
    44 	Cancel();
    45 	Cancel();
    45   
    46   
    46     // This will destroy the entire conditions tree.
    47     // This will destroy the entire conditions tree.
    47    	delete iConditions;
    48    	delete iConditions;
    48 
    49 
   202 		}
   203 		}
   203     
   204     
   204     if( incomplete || IsComplete() == EFalse )
   205     if( incomplete || IsComplete() == EFalse )
   205     	{
   206     	{
   206     	iState = EStateError;
   207     	iState = EStateError;
   207     	NotifyCompleted( KErrCancel );
   208     	if( !iDestroyed )
       
   209     	    {
       
   210             NotifyCompleted( KErrCancel );
       
   211     	    }
   208     	}
   212     	}
   209     }
   213     }
   210 
   214 
   211 
   215 
   212 EXPORT_C TBool CMdEQuery::IsComplete() const
   216 EXPORT_C TBool CMdEQuery::IsComplete() const
   536     // notifying the base class.
   540     // notifying the base class.
   537     __ASSERT_ALWAYS(iState != EStateSearching, TMdEPanic::Panic(TMdEPanic::EInternal));
   541     __ASSERT_ALWAYS(iState != EStateSearching, TMdEPanic::Panic(TMdEPanic::EInternal));
   538 
   542 
   539     // Update the latest error code.
   543     // Update the latest error code.
   540     iError = aError;
   544     iError = aError;
   541 	for (TInt i = iObservers.Count() - 1; i >= 0; --i)
   545     for (TInt i = iObservers.Count() - 1; i >= 0; --i)
   542 		{
   546         {
   543 		MMdEQueryObserver* observer = iObservers[i];
   547         MMdEQueryObserver* observer = iObservers[i];
   544 		observer->HandleQueryCompleted(*this, aError);
   548         if( observer )
   545 		}
   549             {
       
   550             observer->HandleQueryCompleted(*this, aError);
       
   551             }
       
   552         }
   546     }
   553     }
   547 
   554 
   548 
   555 
   549 EXPORT_C void CMdEQuery::AddObserverL(MMdEQueryObserver& aObserver)
   556 EXPORT_C void CMdEQuery::AddObserverL(MMdEQueryObserver& aObserver)
   550 	{
   557 	{