diff -r dbfb5e38438b -r 305818acdca4 taskswitcher/server/src/tsrunningappserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/taskswitcher/server/src/tsrunningappserver.cpp Mon Sep 13 13:26:33 2010 +0300 @@ -0,0 +1,143 @@ +/* +* Copyright (c) 2009 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: +* +*/ +#include +#include "tstaskmonitorglobals.h" +#include "tsrunningappserver.h" +#include "tsrunningappsession.h" +#include "tsbacksteppingactivation.h" + +#include "tsmodel.h" +#include "tsstorage.h" +#include "tsservicesprovider.h" +#include "tsserializeddataprovider.h" +#include "tsrunningappmodel.h" + +// ----------------------------------------------------------------------------- +/** + * Constructor for performing 1st stage construction + */ +CTsRunningAppServer::CTsRunningAppServer() +: +CServer2(EPriorityStandard) + { + // No implementation required + } + +// ----------------------------------------------------------------------------- +/** + * Destructor. + */ +CTsRunningAppServer::~CTsRunningAppServer() + { + delete iBacksteppingEngine; + delete iStorage; + delete iAppsModel; + delete iServiceProvider; + delete iSerializer; + delete iMonitor; + } + +// ----------------------------------------------------------------------------- +/** + * Two-phased constructor. + */ +CTsRunningAppServer* CTsRunningAppServer::NewLC() + { + CTsRunningAppServer* self = new (ELeave) CTsRunningAppServer(); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +// ----------------------------------------------------------------------------- +/** + * Default constructor for performing 2nd stage construction + */ +void CTsRunningAppServer::ConstructL() + { + StartL(KRunningAppServerName); + iResources = CTsResourceManager::NewL(); + iMonitor = CTsWindowGroupsMonitor::NewL(*iResources); + + iSerializer = CTsSerializedDataProvider::NewL(*this); + + RPointerArray providers; + CleanupClosePushL(providers); + + iAppsModel = CTsRunningAppModel::NewL(*iResources, *iMonitor); + providers.AppendL(iAppsModel); + + CTsServiceProviderConfig *cfg = CTsServiceProviderConfig::NewLC(); + iServiceProvider = CTsServiceProvider::NewL(*cfg); + CleanupStack::PopAndDestroy(cfg); + addProviders(providers, *iServiceProvider); + + iStorage = CTsStorage::NewL(providers.Array()); + iStorage->SetObserver(iSerializer); + CleanupStack::PopAndDestroy(&providers); + + // load initial data + iStorage->DataChanged(); + + TRAP_IGNORE(iBacksteppingEngine = CTsBacksteppingActivation::NewL(*iMonitor);) + } + +// ----------------------------------------------------------------------------- +/** + * Interface implementation + * @see CServer2::NewSessionL(const TVersion&, const RMessage2&) + */ +CSession2* CTsRunningAppServer::NewSessionL( const TVersion & /*aVersion*/, + const RMessage2& /*aMsg*/) const + { + RPointerArray dataStorages; + CleanupClosePushL(dataStorages); + dataStorages.AppendL(const_cast(this)->iAppsModel); + dataStorages.AppendL(const_cast(this)->iStorage); + CSession2* retVal = + CTsRunningAppSession::NewL( *const_cast(this)->iSerializer, + dataStorages.Array()); + CleanupStack::PopAndDestroy(&dataStorages); + return retVal; + } + +// ----------------------------------------------------------------------------- +void CTsRunningAppServer::DataChanged() + { + TAny* currentObserver(0); + TDblQueIter currentItem(iSessionIter); + currentItem.SetToFirst(); + do + { + currentObserver = currentItem++; + if(currentObserver) + { + static_cast(currentObserver)->DataChanged(); + } + } + while(0 != currentObserver); + } + +// ----------------------------------------------------------------------------- +void CTsRunningAppServer::addProviders( RPointerArray &dst, + const CTsServiceProvider& serviceProvider) + { + for ( TInt offset(0); offset < serviceProvider.Count(); ++offset ) + { + dst.Append(&serviceProvider[offset]); + } + }