williamr@2: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@2: // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members williamr@2: // which accompanies this distribution, and is available williamr@2: // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: #if !defined(SAVENOTF_H) williamr@2: #define SAVENOTF_H williamr@2: williamr@2: #include williamr@2: #include williamr@2: williamr@2: /** williamr@2: This interface has to be implemented by all clients, which want to be notified about events williamr@2: like shutdown/low memory. When this happens the implementation of MSaveObserver::SaveL() will williamr@2: be called. williamr@2: @see CSaveNotifier williamr@2: @publishedPartner williamr@2: @released williamr@2: */ williamr@2: class MSaveObserver williamr@2: { williamr@2: public: williamr@2: enum TSaveType williamr@2: { williamr@2: ESaveNone, williamr@2: ESaveData, williamr@2: ESaveAll, williamr@2: ESaveQuick, williamr@2: EReleaseRAM, williamr@2: EReleaseDisk, williamr@2: }; williamr@2: public: williamr@2: virtual void SaveL(TSaveType aSaveType)=0; williamr@2: }; williamr@2: williamr@2: /** williamr@2: This class describes a client side session object, handling requests williamr@2: to the shutdown server. williamr@2: @internalComponent williamr@2: */ williamr@2: class RSaveSession : public RSessionBase williamr@2: { williamr@2: public: williamr@2: TInt ConnectL(); williamr@2: void NotifySave(TRequestStatus& aStatus); williamr@2: void NotifySaveCancel(); williamr@2: TInt SwitchOff(MSaveObserver::TSaveType aAction, TBool aPowerOff); williamr@2: TInt ServerPowerState(TBool& aPowerOff); williamr@2: private: williamr@2: TInt StartServerL(); williamr@2: }; williamr@2: williamr@2: /** williamr@2: This class describes an object, which can be used by the clients, which want to be notified williamr@2: about events like powerdown/low memory. The clients have to implement MSaveObserver interface. williamr@2: When a particular event happens, the client's implementation of MSaveObserver::SaveL() will williamr@2: be called. williamr@2: @see MSaveObserver williamr@2: @publishedPartner williamr@2: @released williamr@2: */ williamr@2: class CSaveNotifier : public CActive williamr@2: { williamr@2: friend class CPowerdownClient;//test class williamr@2: friend class CPowerdownClient2;//test class williamr@2: public: williamr@2: IMPORT_C static CSaveNotifier* NewL(MSaveObserver& aObserver); williamr@2: IMPORT_C ~CSaveNotifier(); williamr@2: IMPORT_C void DelayRequeue(); williamr@2: IMPORT_C void Queue(); williamr@2: IMPORT_C void HandleError(TInt /*aError*/); williamr@2: private: williamr@2: IMPORT_C TInt SwitchOff(MSaveObserver::TSaveType aAction, TBool aPowerOff); williamr@2: IMPORT_C TInt ServerPowerState(TBool& aPowerOff); williamr@2: inline CSaveNotifier(MSaveObserver& aObserver); williamr@2: void ConstructL(); williamr@2: void Start(); williamr@2: private: // from CActive williamr@2: void DoCancel(); williamr@2: void RunL(); williamr@2: private: williamr@2: RSaveSession iSaveSession; williamr@2: MSaveObserver& iSaveObserver; williamr@2: TUint iFlags; williamr@2: }; williamr@2: williamr@2: #endif