--- a/harvester/client/src/harvesterclientao.cpp Tue Jul 06 14:44:37 2010 +0300
+++ b/harvester/client/src/harvesterclientao.cpp Wed Aug 18 10:12:07 2010 +0300
@@ -17,6 +17,7 @@
#include "harvesterclientao.h"
+#include "harvesternotificationqueue.h"
#include "harvestercommon.h"
#include "harvesterlog.h"
#include "mdsutils.h"
@@ -30,12 +31,13 @@
// NewL
// ---------------------------------------------------------------------------
//
-CHarvesterClientAO* CHarvesterClientAO::NewL( RHarvesterClient& aHarvesterClient )
+CHarvesterClientAO* CHarvesterClientAO::NewL( RHarvesterClient& aHarvesterClient,
+ CHarvesterNotificationQueue* aNotificationQueue )
{
WRITELOG( "CHarvesterClientAO::NewL()" );
OstTrace0( TRACE_NORMAL, CHARVESTERCLIENTAO_NEWL, "CHarvesterClientAO::NewL" );
- CHarvesterClientAO* self = new (ELeave) CHarvesterClientAO( aHarvesterClient );
+ CHarvesterClientAO* self = new (ELeave) CHarvesterClientAO( aHarvesterClient, aNotificationQueue );
CleanupStack::PushL( self );
self->ConstructL();
CleanupStack::Pop( self );
@@ -52,6 +54,9 @@
WRITELOG( "CHarvesterClientAO::~CHarvesterClientAO()" );
Cancel();
+
+ delete iURI;
+ iURI = NULL;
}
// ---------------------------------------------------------------------------
@@ -59,10 +64,14 @@
// First-phase C++ constructor
// ---------------------------------------------------------------------------
//
-CHarvesterClientAO::CHarvesterClientAO( RHarvesterClient& aHarvesterClient )
+CHarvesterClientAO::CHarvesterClientAO( RHarvesterClient& aHarvesterClient,
+ CHarvesterNotificationQueue* aNotificationQueue )
: CActive( CActive::EPriorityStandard ),
iObserver( NULL ),
- iHarvesterClient( aHarvesterClient )
+ iHarvesterClient( aHarvesterClient ),
+ iNotificationQueue( aNotificationQueue ),
+ iURI( NULL ),
+ iRequestComplete( EFalse )
{
OstTrace0( TRACE_NORMAL, DUP1_CHARVESTERCLIENTAO_CHARVESTERCLIENTAO, "CHarvesterClientAO::CHarvesterClientAO" );
@@ -94,25 +103,6 @@
}
// ---------------------------------------------------------------------------
-// RemoveObserver
-// ---------------------------------------------------------------------------
-//
-void CHarvesterClientAO::RemoveObserver( MHarvestObserver* aObserver )
- {
- WRITELOG( "CHarvesterClientAO::RemoveObserver()" );
- OstTrace0( TRACE_NORMAL, CHARVESTERCLIENTAO_REMOVEOBSERVER, "CHarvesterClientAO::RemoveObserver" );
-
- if ( aObserver == iObserver )
- {
- if ( iObserver )
- {
- WRITELOG( "CHarvesterClientAO::RemoveObserver() - deleting observer" );
- iObserver = NULL;
- }
- }
- }
-
-// ---------------------------------------------------------------------------
// DoCancel
// ---------------------------------------------------------------------------
//
@@ -120,20 +110,33 @@
{
WRITELOG( "CHarvesterClientAO::DoCancel()" );
OstTrace0( TRACE_NORMAL, CHARVESTERCLIENTAO_DOCANCEL, "CHarvesterClientAO::DoCancel" );
-
+ iRequestComplete = ETrue;
}
// ---------------------------------------------------------------------------
// Active
// ---------------------------------------------------------------------------
//
-void CHarvesterClientAO::Active()
+void CHarvesterClientAO::Active( TDesC& aUri )
{
- if (!IsActive())
- {
- iHarvesterClient.RegisterHarvestComplete(iURI, iStatus);
- SetActive();
- }
+ WRITELOG( "CHarvesterClientAO::Active()");
+ if( iObserver && !IsActive() )
+ {
+ delete iURI;
+ iURI = NULL;
+ iURI = aUri.Alloc();
+ if( iURI )
+ {
+ TPtr16 uri( iURI->Des() );
+ iHarvesterClient.RegisterHarvestComplete( uri, iStatus );
+ SetActive();
+ }
+ else if( iObserver )
+ {
+ iObserver->HarvestingComplete( aUri, KErrCompletion );
+ iRequestComplete = ETrue;
+ }
+ }
}
// ---------------------------------------------------------------------------
@@ -144,8 +147,9 @@
{
WRITELOG( "CHarvesterClientAO::RunL()" );
OstTrace0( TRACE_NORMAL, CHARVESTERCLIENTAO_RUNL, "CHarvesterClientAO::RunL" );
+
+ iNotificationQueue->Cleanup( EFalse );
-
const TInt status = iStatus.Int();
if ( status < KErrNone )
@@ -154,17 +158,16 @@
}
// Callback to client process
- if ( iObserver )
+ if ( iObserver && iURI )
{
- WRITELOG( "CHarvesterClientAO::RunL() - ECompleteRequest - calling callback" );
- iObserver->HarvestingComplete( iURI, status );
+ WRITELOG( "CHarvesterClientAO::RunL() - Request complete - calling callback" );
+ TPtrC16 uri( iURI->Des() );
+ iObserver->HarvestingComplete( uri, status );
}
- // if the request was not canceled or server is not terminated, Activating AO again
- if ( status != KErrCancel && status != KErrServerTerminated )
- {
- Active();
- }
+ delete iURI;
+ iURI = NULL;
+ iRequestComplete = ETrue;
}
// ---------------------------------------------------------------------------
@@ -179,5 +182,18 @@
{
WRITELOG1( "CHarvesterClientAO::RunError(), errorcode: %d", aError );
+ iNotificationQueue->Cleanup( EFalse );
+ iRequestComplete = ETrue;
+
return KErrNone;
}
+
+// ---------------------------------------------------------------------------
+// RequestComplete
+// ---------------------------------------------------------------------------
+//
+TBool CHarvesterClientAO::RequestComplete()
+ {
+ return iRequestComplete;
+ }
+