diff -r 23b5d6a29cce -r 4785f57bf3d4 homescreenapp/stateplugins/hshomescreenstateplugin/src/hsbackuprestorestate.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/homescreenapp/stateplugins/hshomescreenstateplugin/src/hsbackuprestorestate.cpp Thu May 27 12:46:08 2010 +0300 @@ -0,0 +1,105 @@ +/* +* Copyright (c) 2010 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 +#include +#include +#include +#include "hsdatabase.h" +#include "hsscene.h" +#include "hsbackuprestoreobserver.h" +#include "hsbackuprestorestate.h" +#include "hsscene.h" +#include "hsgui.h" + +/*! + \class HsBackupRestoreState + \ingroup group_hshomescreenstateplugin + \brief Home screen Bacup/Restore state. + + Releases all Home screen data, which will be backed up or restored. +*/ + +/*! + Constructs a new backup/restore state with the given \a parent. +*/ +HsBackupRestoreState::HsBackupRestoreState(QState *parent) + : QState(parent) +{ + connect(this, SIGNAL(entered()), SLOT(action_startListenBURStatus())); + connect(this, SIGNAL(exited()), SLOT(action_stopListenBURStatus())); +} + +/*! + Destroys this backup/restore state. +*/ +HsBackupRestoreState::~HsBackupRestoreState() +{ +} + +/*! + Starts listen backup/restore status and releases Home screen data. +*/ +void HsBackupRestoreState::action_startListenBURStatus() +{ + HsBackupRestoreObserver *backupRestoreObserver = + HsBackupRestoreObserver::instance(); + + connect(backupRestoreObserver, + SIGNAL(event_backupRestoreComplited()), + SIGNAL(event_loadScene())); + + // Close database + mDatabase.reset(HsDatabase::takeInstance()); + mDatabase->close(); + + deleteIdleView(); + + // Delete scene + HsScene *scene = HsScene::instance(); + delete scene; + + backupRestoreObserver->readyForBUR(); +} + +/*! + Stops listen backup/restore status. +*/ +void HsBackupRestoreState::action_stopListenBURStatus() +{ + HsBackupRestoreObserver::instance()->disconnect(this); + + // Open database + HsDatabase::setInstance(mDatabase.data()); + mDatabase.take(); + HsDatabase::instance()->open(); +} + +/*! + Deletes idle view +*/ +void HsBackupRestoreState::deleteIdleView() +{ + // Delete idle view + QScopedPointer idleView(HsGui::takeIdleView()); + + if (idleView){ + idleView->setNavigationAction(0); + HsScene::mainWindow()->removeView(idleView.data()); + } +}