diff -r 000000000000 -r 79c6a41cd166 idlefw/plugins/devicestatus/src/aimulticontentobserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/idlefw/plugins/devicestatus/src/aimulticontentobserver.cpp Thu Dec 17 08:54:17 2009 +0200 @@ -0,0 +1,230 @@ +/* +* Copyright (c) 2006 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: Active Idle Content Observer interface multiplexer +* implementation. +* +*/ + + +#include "aimulticontentobserver.h" +#include "aicontentobserveroptimizer.h" + +CAiMultiContentObserver* CAiMultiContentObserver::NewL() + { + return new(ELeave) CAiMultiContentObserver; + } + + +CAiMultiContentObserver::~CAiMultiContentObserver() + { + iObserverOptimizers.ResetAndDestroy(); + } + + +void CAiMultiContentObserver::AddObserverL(MAiContentObserver& aObserver) + { + TBool foundExisting = EFalse; + + for( TInt i = 0; i < iObserverOptimizers.Count(); ++i ) + { + if ( &(iObserverOptimizers[i]->Observer()) == &aObserver ) + { + foundExisting = ETrue; + break; + } + } + if( !foundExisting ) + { + CAiContentObserverOptimizer *optimizer = + CAiContentObserverOptimizer::NewL( aObserver ); + iObserverOptimizers.AppendL( optimizer ); + } + } + + +TInt CAiMultiContentObserver::StartTransaction( TInt aTxId ) + { + TInt result = KErrNone; + const TInt count = iObserverOptimizers.Count(); + for ( TInt i = 0; i < count; ++i ) + { + const TInt r = iObserverOptimizers[i]->StartTransaction( aTxId ); + + if ( r != KErrNone ) + { + result = r; + } + } + return result; + } + + +TInt CAiMultiContentObserver::Commit( TInt aTxId ) + { + TInt result = KErrNone; + const TInt count = iObserverOptimizers.Count(); + for ( TInt i = 0; i < count; ++i ) + { + const TInt r = iObserverOptimizers[i]->Commit( aTxId ); + + if ( r != KErrNone ) + { + result = r; + } + } + return result; + } + + +TInt CAiMultiContentObserver::CancelTransaction( TInt aTxId ) + { + TInt result = KErrNone; + const TInt count = iObserverOptimizers.Count(); + for ( TInt i = 0; i < count; ++i ) + { + const TInt r = iObserverOptimizers[i]->CancelTransaction( aTxId ); + if ( r != KErrNone ) + { + result = r; + } + } + return result; + } + + +TBool CAiMultiContentObserver::CanPublish( MAiPropertyExtension& aPlugin, + TInt aContent, + TInt aIndex ) + { + const TInt count = iObserverOptimizers.Count(); + for ( TInt i = 0; i < count; ++i ) + { + if( iObserverOptimizers[i]->CanPublish( aPlugin, aContent, aIndex ) ) + { + return ETrue; + } + } + return EFalse; + } + + +TInt CAiMultiContentObserver::Publish( MAiPropertyExtension& aPlugin, + TInt aContent, + TInt aResource, + TInt aIndex ) + { + TInt result = KErrNone; + const TInt count = iObserverOptimizers.Count(); + for ( TInt i = 0; i < count; ++i ) + { + const TInt r = iObserverOptimizers[i]->Publish( aPlugin, aContent, aResource, aIndex ); + if ( r != KErrNone ) + { + result = r; + } + } + return result; + } + + +TInt CAiMultiContentObserver::Publish( MAiPropertyExtension& aPlugin, + TInt aContent, + const TDesC16& aText, + TInt aIndex ) + { + TInt result = KErrNone; + const TInt count = iObserverOptimizers.Count(); + for ( TInt i = 0; i < count; ++i ) + { + const TInt r = iObserverOptimizers[i]->Publish( aPlugin, aContent, aText, aIndex ); + if ( r != KErrNone ) + { + result = r; + } + } + return result; + } + + +TInt CAiMultiContentObserver::Publish( MAiPropertyExtension& aPlugin, + TInt aContent, + const TDesC8& aBuf, + TInt aIndex ) + { + TInt result = KErrNone; + const TInt count = iObserverOptimizers.Count(); + for ( TInt i = 0; i < count; ++i ) + { + const TInt r = iObserverOptimizers[i]->Publish( aPlugin, aContent, aBuf, aIndex ); + if ( r != KErrNone ) + { + result = r; + } + } + return result; + } + + +TInt CAiMultiContentObserver::Publish( MAiPropertyExtension& aPlugin, + TInt aContent, + RFile& aFile, + TInt aIndex ) + { + TInt result = KErrNone; + const TInt count = iObserverOptimizers.Count(); + for ( TInt i = 0; i < count; ++i ) + { + const TInt r = iObserverOptimizers[i]->Publish( aPlugin, aContent, aFile, aIndex ); + if ( r != KErrNone ) + { + result = r; + } + } + return result; + } + + +TInt CAiMultiContentObserver::Clean( MAiPropertyExtension& aPlugin, + TInt aContent, + TInt aIndex ) + { + TInt result = KErrNone; + const TInt count = iObserverOptimizers.Count(); + for ( TInt i = 0; i < count; ++i ) + { + const TInt r = iObserverOptimizers[i]->Clean( aPlugin, aContent, aIndex ); + if ( r != KErrNone ) + { + result = r; + } + } + return result; + } + + +TAny* CAiMultiContentObserver::Extension( TUid /*aUid*/ ) + { + return NULL; + } + +TBool CAiMultiContentObserver::RequiresSubscription( + const TAiPublisherInfo& /*aPublisherInfo*/ ) const + { + return ETrue; + } + +CAiMultiContentObserver::CAiMultiContentObserver() + { + } +