harvester/client/src/harvesterclientao.cpp
branchRCL_3
changeset 47 b73252188534
parent 46 63c982fb92f2
child 49 f23c07ec56e2
equal deleted inserted replaced
46:63c982fb92f2 47:b73252188534
    95 
    95 
    96 // ---------------------------------------------------------------------------
    96 // ---------------------------------------------------------------------------
    97 // RemoveObserver
    97 // RemoveObserver
    98 // ---------------------------------------------------------------------------
    98 // ---------------------------------------------------------------------------
    99 //	
    99 //	
   100 void CHarvesterClientAO::RemoveObserver( MHarvestObserver* aObserver )
   100 void CHarvesterClientAO::RemoveObserver( MHarvestObserver* /*aObserver*/ )
   101 	{
   101 	{
   102 	WRITELOG( "CHarvesterClientAO::RemoveObserver()" );
   102 	WRITELOG( "CHarvesterClientAO::RemoveObserver()" );
   103 	OstTrace0( TRACE_NORMAL, CHARVESTERCLIENTAO_REMOVEOBSERVER, "CHarvesterClientAO::RemoveObserver" );
   103     if ( iObserver )
   104 	
   104         {
   105 	if ( aObserver == iObserver )
   105         WRITELOG( "CHarvesterClientAO::RemoveObserver() - deleting observer" );
   106 		{
   106         iObserver = NULL;
   107 		if ( iObserver )
   107         }
   108 			{
   108     
   109 			WRITELOG( "CHarvesterClientAO::RemoveObserver() - deleting observer" );
   109     Cancel();
   110 			iObserver = NULL;
       
   111 			}
       
   112 		}
       
   113 	}
   110 	}
   114 
   111 
   115 // ---------------------------------------------------------------------------
   112 // ---------------------------------------------------------------------------
   116 // DoCancel
   113 // DoCancel
   117 // ---------------------------------------------------------------------------
   114 // ---------------------------------------------------------------------------
   118 //
   115 //
   119 void CHarvesterClientAO::DoCancel()
   116 void CHarvesterClientAO::DoCancel()
   120 	{
   117 	{
   121 	WRITELOG( "CHarvesterClientAO::DoCancel()" );
   118 	WRITELOG( "CHarvesterClientAO::DoCancel()" );
   122 	OstTrace0( TRACE_NORMAL, CHARVESTERCLIENTAO_DOCANCEL, "CHarvesterClientAO::DoCancel" );
   119 	OstTrace0( TRACE_NORMAL, CHARVESTERCLIENTAO_DOCANCEL, "CHarvesterClientAO::DoCancel" );
   123 	
   120 	iHarvesterClient.UnregisterHarvestComplete();
   124 	}
   121 	}
   125 	
   122 	
   126 // ---------------------------------------------------------------------------
   123 // ---------------------------------------------------------------------------
   127 // Active
   124 // Active
   128 // ---------------------------------------------------------------------------
   125 // ---------------------------------------------------------------------------
   129 //
   126 //
   130 void CHarvesterClientAO::Active()
   127 void CHarvesterClientAO::Active()
   131 	{	
   128 	{	
   132 	if (!IsActive())
   129 	if ( iObserver && !IsActive())
   133 		{
   130 		{
   134 		iHarvesterClient.RegisterHarvestComplete(iURI, iStatus);
   131 		iHarvesterClient.RegisterHarvestComplete(iURI, iStatus);
   135 		SetActive();
   132 		SetActive();
   136 		}
   133 		}
   137 	}
   134 	}
   142 //
   139 //
   143 void CHarvesterClientAO::RunL()
   140 void CHarvesterClientAO::RunL()
   144 	{
   141 	{
   145 	WRITELOG( "CHarvesterClientAO::RunL()" );
   142 	WRITELOG( "CHarvesterClientAO::RunL()" );
   146 	OstTrace0( TRACE_NORMAL, CHARVESTERCLIENTAO_RUNL, "CHarvesterClientAO::RunL" );
   143 	OstTrace0( TRACE_NORMAL, CHARVESTERCLIENTAO_RUNL, "CHarvesterClientAO::RunL" );
   147 	
       
   148 
   144 
   149 	const TInt status = iStatus.Int();
   145 	const TInt status = iStatus.Int();
   150 	
   146 	
   151     if ( status < KErrNone )
   147     if ( status < KErrNone )
   152         {
   148         {
   159 		WRITELOG( "CHarvesterClientAO::RunL() - ECompleteRequest - calling callback" );
   155 		WRITELOG( "CHarvesterClientAO::RunL() - ECompleteRequest - calling callback" );
   160 		iObserver->HarvestingComplete( iURI, status );
   156 		iObserver->HarvestingComplete( iURI, status );
   161 		}
   157 		}
   162 	
   158 	
   163 	// if the request was not canceled or server is not terminated, Activating AO again
   159 	// if the request was not canceled or server is not terminated, Activating AO again
   164 	if ( status != KErrCancel && status != KErrServerTerminated )
   160 	if ( status != KErrCancel && status != KErrServerTerminated && iObserver )
   165 		{
   161 		{
   166 		Active();
   162 		Active();
   167 		}
   163 		}
   168 	}
   164 	}
   169 	
   165