syncmlfw/common/sosserver_clientapi/inc/NSmlClientAPIActiveCallback.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 12 Mar 2010 15:46:48 +0200
branchRCL_3
changeset 11 06f47423ecee
parent 0 b497e44ab2fc
child 23 4af31167ea77
permissions -rw-r--r--
Revision: 201007 Kit: 201008

/*
* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
*		Declaration file for client API's event/progress notifiers
*
*/


#ifndef __CLIENTAPIACTIVECALLBACK_H__
#define __CLIENTAPIACTIVECALLBACK_H__

#include <SyncMLClient.h>
#include <SyncMLObservers.h>

class CSmlActiveEventCallback;
class CSmlActiveProgressCallback;

// 
// container class from event and progress callbacks
// 
class CSmlActiveCallback : public CBase
	{
	public:
		CSmlActiveCallback( RSyncMLSession& aSession );
		~CSmlActiveCallback();
		
		void SetEventObserverL( MSyncMLEventObserver& aObserver );
		void SetProgressObserverL( MSyncMLProgressObserver& aObserver );
		
		void CancelEvent();
		void CancelProgress();
		
		void SendReceive( TInt aCmd, const TIpcArgs& aArgs, TRequestStatus& aStatus ) const;
		void SendReceive( TInt aCmd ) const;
		
	private:
	
		RSyncMLSession&				iSession;
		CSmlActiveEventCallback*	iEventCallback;
		CSmlActiveProgressCallback*	iProgressCallback;
	};


// 
// event callback
// 
class CSmlActiveEventCallback : public CActive
	{
	public:
		static CSmlActiveEventCallback* NewL( const CSmlActiveCallback* aCallback );
		virtual ~CSmlActiveEventCallback();
		
		void SetObserver( MSyncMLEventObserver& aObserver );
		void CancelEvent();
		
		// from CActive
		virtual void DoCancel();
		virtual void RunL();
		
	private:
		void Request();
		void ConstructL();
		CSmlActiveEventCallback( const CSmlActiveCallback* aCallback );
		
	private:
		TBool	iRequesting;
		TPtr8	iBufPtr;
		HBufC8*	iBuf;
		
		MSyncMLEventObserver*		iObserver; // not owned
		const CSmlActiveCallback*	iCallback; // not owned
	};


// 
// progress callback
// 
class CSmlActiveProgressCallback : public CActive
	{
	public:
		static CSmlActiveProgressCallback* NewL( const CSmlActiveCallback* aCallback );
		virtual ~CSmlActiveProgressCallback();
		
		void SetObserver( MSyncMLProgressObserver& aObserver );
		void CancelProgress();
		
		// from CActive
		virtual void DoCancel();
		virtual void RunL();
		
	private:
		void Request();
		void ConstructL();
		CSmlActiveProgressCallback( const CSmlActiveCallback* aCallback );
		
		void NotifyErrorL( RReadStream& aStream ) const;
		void NotifyProgressL( RReadStream& aStream ) const;
		void NotifyModificationsL( RReadStream& aStream );
		
	private:
		TBool	iRequesting;
		TPtr8	iBufPtr;
		HBufC8*	iBuf;
		
		MSyncMLProgressObserver::TSyncMLDataSyncModifications iClientMods;
		MSyncMLProgressObserver::TSyncMLDataSyncModifications iServerMods;
		
		MSyncMLProgressObserver*	iObserver; // not owned
		const CSmlActiveCallback*	iCallback; // not owned
	};


#endif // __CLIENTAPIACTIVECALLBACK_H__