diff -r 000000000000 -r c464cd7e2753 stateproviders/ftustateprovider/src/ftuwizardloaderstate.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stateproviders/ftustateprovider/src/ftuwizardloaderstate.cpp Mon Apr 19 14:01:47 2010 +0300 @@ -0,0 +1,114 @@ +/* +* 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 "ftuwizardloaderstate.h" +#include "ftuwizardprovider.h" +#include "ftucontentservice.h" +#include +#include +#include "ftutest_global.h" + +#include + +// --------------------------------------------------------------------------- +// FtuWizardLoaderState::FtuWizardLoaderState +// --------------------------------------------------------------------------- +// +FtuWizardLoaderState::FtuWizardLoaderState(QState *parent) : + QState(parent), + mWizardProvider(NULL) +{ + mWizardProvider = new FtuWizardProvider(); +} + +// --------------------------------------------------------------------------- +// FtuWizardLoaderState::~FtuWizardLoaderState +// --------------------------------------------------------------------------- +// +FtuWizardLoaderState::~FtuWizardLoaderState() +{ + delete mWizardProvider; +} +// --------------------------------------------------------------------------- +// FtuWizardLoaderState::addWizard +// --------------------------------------------------------------------------- +// +void FtuWizardLoaderState::addWizard(FtuWizard* wizard, bool success) +{ + if(NULL!=wizard) { + qDebug() << "Wizard " << wizard->objectName() << " initialized with " << success; + } + else { + qFatal("void FtuWizardLoaderState::addWizard(FtuWizard* wizard, bool success): Null pointer argument wizard"); + } + + if(wizard && success) + { + content()->appendWizard(wizard); + + // Disconnect the signal, for it is no longer needed. + disconnect(wizard, SIGNAL(wizardInitialized(FtuWizard*, bool)), + this, SLOT(addWizard(FtuWizard*, bool))); + } +} + +// --------------------------------------------------------------------------- +// FtuWizardLoaderState::onEntry +// --------------------------------------------------------------------------- +// +void FtuWizardLoaderState::onEntry(QEvent *event) +{ + QState::onEntry(event); + + QList pluginList; + mWizardProvider->loadFTUPlugins(pluginList); + int size = pluginList.size(); + + if(size > 0) + { + for(int i = 0; i < size; i++) + { + FtuWizard* wizard = pluginList[i]->createWizard(); + if(wizard) + { + + connect(wizard, SIGNAL(wizardInitialized(FtuWizard*, bool)), + this, SLOT(addWizard(FtuWizard*, bool))); + wizard->initializeWizard(); + } + } + } +} + +// --------------------------------------------------------------------------- +// FtuWizardLoaderState::onExit +// --------------------------------------------------------------------------- +// +void FtuWizardLoaderState::onExit(QEvent *event) +{ + QState::onExit(event); +} + +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// +FtuContentService *FtuWizardLoaderState::content() const +{ + return property(FTU_CONTENT_SERVICE_KEY).value(); +} +