diff -r 839377eedc2b -r befca0ec475f videofeeds/clientapi/src/CIptvMyVideosContentUpdateObserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videofeeds/clientapi/src/CIptvMyVideosContentUpdateObserver.cpp Wed Sep 01 12:30:28 2010 +0100 @@ -0,0 +1,140 @@ +/* +* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: Observer for content updates from server.* +*/ + + + + +#include +#include +#include "IptvDebug.h" + +#include "IptvClientServerCommon.h" +#include "RIptvClientSession.h" +#include "CIptvMyVideosContentUpdateObserver.h" +#include "MIptvMyVideosClientObserver.h" + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CIptvMyVideosContentUpdateObserver::CIptvMyVideosContentUpdateObserver() +// --------------------------------------------------------------------------- +// +CIptvMyVideosContentUpdateObserver::CIptvMyVideosContentUpdateObserver( + MIptvMyVideosClientObserver& aClientObserver, + RIptvClientSession& aSession ) + : CActive( EPriorityStandard ), + iClientObserver( aClientObserver ), + iSession( aSession ), + iObserverMsgPtr( static_cast( 0 ), 0 ) + { + CActiveScheduler::Add( this ); + } + +// --------------------------------------------------------------------------- +// CIptvMyVideosContentUpdateObserver::NewL() +// --------------------------------------------------------------------------- +// +CIptvMyVideosContentUpdateObserver* CIptvMyVideosContentUpdateObserver::NewL( + MIptvMyVideosClientObserver& aClientObserver, + RIptvClientSession& aSession ) + { + CIptvMyVideosContentUpdateObserver* self = + new ( ELeave ) CIptvMyVideosContentUpdateObserver( + aClientObserver, aSession ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// CIptvMyVideosContentUpdateObserver::ConstructL() +// --------------------------------------------------------------------------- +// +void CIptvMyVideosContentUpdateObserver::ConstructL() + { + SendObserverRequestL(); + SetActive(); + } + +// --------------------------------------------------------------------------- +// CIptvMyVideosContentUpdateObserver::~CIptvMyVideosContentUpdateObserver() +// --------------------------------------------------------------------------- +// +CIptvMyVideosContentUpdateObserver::~CIptvMyVideosContentUpdateObserver() + { + delete iObserverMsg; + Cancel(); + } + +// --------------------------------------------------------------------------- +// CIptvMyVideosContentUpdateObserver::RunL() +// --------------------------------------------------------------------------- +// +void CIptvMyVideosContentUpdateObserver::RunL() + { + if ( iStatus.Int() == KErrNone ) + { + MIptvMyVideosClientObserver::TIptvContentUpdatedEvent event; + + RDesReadStream stream; + stream.Open( iObserverMsgPtr ); + CleanupClosePushL( stream ); + + event.iEventType = static_cast + ( stream.ReadUint32L() ); + event.iDrive = stream.ReadUint32L(); + event.iFileId = stream.ReadUint32L(); + CleanupStack::PopAndDestroy( &stream ); + + iClientObserver.ContentsUpdated( event ); + + // Only set active if previous completed without error. Otherwise + // we make eternal loop; client sending new messages and server + // completing them instantly with error. + SendObserverRequestL(); + SetActive(); + } + } + +// --------------------------------------------------------------------------- +// CIptvMyVideosContentUpdateObserver::SendObserverRequestL +// --------------------------------------------------------------------------- +// +void CIptvMyVideosContentUpdateObserver::SendObserverRequestL() + { + IPTVLOGSTRING_LOW_LEVEL( + "CIptvMyVideosContentUpdateObserver::SendObserverRequestL" ); + + delete iObserverMsg; + iObserverMsg = NULL; + + iObserverMsg = HBufC8::NewL( KIptvMyVideosObserverRequestSize ); + iObserverMsgPtr.Set( iObserverMsg->Des() ); + + iSession.SendRequest( + EIptvEngineMyVideosContentUpdateReq, + iObserverMsgPtr, + iStatus ); + } + +// --------------------------------------------------------------------------- +// CIptvMyVideosContentUpdateObserver::DoCancel() +// --------------------------------------------------------------------------- +// +void CIptvMyVideosContentUpdateObserver::DoCancel() + { + }