epoc32/include/savenotf.h
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
equal deleted inserted replaced
3:e1b950c65cb4 4:837f303aceeb
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // 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
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #if !defined(SAVENOTF_H)
       
    17 #define SAVENOTF_H
       
    18 
       
    19 #include <e32std.h>
       
    20 #include <e32base.h>
       
    21 
       
    22 /**
       
    23 This interface has to be implemented by all clients, which want to be notified about events
       
    24 like shutdown/low memory. When this happens the implementation of MSaveObserver::SaveL() will
       
    25 be called.
       
    26 @see CSaveNotifier
       
    27 @publishedPartner
       
    28 @released
       
    29 */
       
    30 class MSaveObserver
       
    31 	{
       
    32 public:
       
    33 	enum TSaveType
       
    34 		{
       
    35 		ESaveNone,
       
    36 		ESaveData,
       
    37 		ESaveAll,
       
    38 		ESaveQuick,
       
    39 		EReleaseRAM,
       
    40 		EReleaseDisk,
       
    41 		};
       
    42 public:
       
    43 	virtual void SaveL(TSaveType aSaveType)=0;
       
    44 	};
       
    45 
       
    46 /**
       
    47 This class describes a client side session object, handling requests
       
    48 to the shutdown server.
       
    49 @internalComponent
       
    50 */
       
    51 class RSaveSession : public RSessionBase
       
    52 	{
       
    53 public:
       
    54 	TInt ConnectL();
       
    55 	void NotifySave(TRequestStatus& aStatus);
       
    56 	void NotifySaveCancel();
       
    57     TInt SwitchOff(MSaveObserver::TSaveType aAction, TBool aPowerOff);
       
    58     TInt ServerPowerState(TBool& aPowerOff);
       
    59 private:
       
    60 	TInt StartServerL();
       
    61 	};
       
    62 
       
    63 /**
       
    64 This class describes an object, which can be used by the clients, which want to be notified
       
    65 about events like powerdown/low memory. The clients have to implement MSaveObserver interface.
       
    66 When a particular event happens, the client's implementation of MSaveObserver::SaveL() will
       
    67 be called.
       
    68 @see MSaveObserver
       
    69 @publishedPartner
       
    70 @released 
       
    71 */
       
    72 class CSaveNotifier : public CActive
       
    73 	{
       
    74     friend class CPowerdownClient;//test class
       
    75     friend class CPowerdownClient2;//test class
       
    76 public:
       
    77 	IMPORT_C static CSaveNotifier* NewL(MSaveObserver& aObserver);
       
    78 	IMPORT_C ~CSaveNotifier();
       
    79 	IMPORT_C void DelayRequeue();
       
    80 	IMPORT_C void Queue();
       
    81 	IMPORT_C void HandleError(TInt /*aError*/);
       
    82 private:
       
    83 	IMPORT_C TInt SwitchOff(MSaveObserver::TSaveType aAction, TBool aPowerOff);
       
    84 	IMPORT_C TInt ServerPowerState(TBool& aPowerOff);
       
    85 	inline CSaveNotifier(MSaveObserver& aObserver);
       
    86 	void ConstructL();
       
    87 	void Start();
       
    88 private: // from CActive
       
    89 	void DoCancel();
       
    90 	void RunL();
       
    91 private:
       
    92 	RSaveSession iSaveSession;
       
    93 	MSaveObserver& iSaveObserver;
       
    94 	TUint iFlags;
       
    95 	};
       
    96 
       
    97 #endif