resourcemgmt/powerandmemorynotificationservice/inc/shutdownsess.h
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 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 "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 /**
       
    18  @file
       
    19  @internalTechnology 
       
    20 */
       
    21 
       
    22 #if !defined(SHUTDOWNSESS_H)
       
    23 #define SHUTDOWNSESS_H
       
    24 
       
    25 #include "shutdownsrv.h"
       
    26 class CShutdownTimer;
       
    27 
       
    28 /**
       
    29 This class describes an object, which handles requests, such as of MSaveObserver::TSaveType type.
       
    30 When CServShutdownServer::HandleShutdownEventL() gets called, the CServShutdownServer implementation
       
    31 will notify all registered clients, completing their asynchronous messages 
       
    32 (CServShutdownSession::iPtr), then it will wait until all clients re-register itself and
       
    33 if this is a beginning of a powerdown sequence, the method will store the locales and the HAL
       
    34 properties subsequently switching off the power.
       
    35 */
       
    36 class CServShutdownServer : public CServer2, public MShutdownEventObserver
       
    37 	{
       
    38 public:
       
    39 	IMPORT_C static CServShutdownServer* NewL();
       
    40 	IMPORT_C ~CServShutdownServer();
       
    41 	IMPORT_C void HandlePowerNotifRequest(const RThread& aClient);
       
    42 	IMPORT_C void NotifySave(MSaveObserver::TSaveType aSaveType);
       
    43 	IMPORT_C TBool IsPowerOff() const;
       
    44 	IMPORT_C void CancelPowerOff();
       
    45 	void SwitchOff();
       
    46 #ifdef SYMBIAN_SSM_GRACEFUL_SHUTDOWN
       
    47 	TInt ClientArrayCount();
       
    48 	void ClientArrayL(const RMessage2& aMessage);
       
    49 #endif //SYMBIAN_SSM_GRACEFUL_SHUTDOWN	
       
    50 public:
       
    51 	IMPORT_C virtual void ConstructL();
       
    52 public: // from MShutdownEventObserver
       
    53 	IMPORT_C void HandleShutdownEventL(MSaveObserver::TSaveType aAction,TBool aPowerOff, TPowerState aEvent = EPwStandby);
       
    54 	IMPORT_C CArrayFix<TThreadId>* ClientArrayLC();
       
    55 	IMPORT_C TBool IsClientHung(TThreadId aId) const;
       
    56 	IMPORT_C void GetShutdownState(TBool& aPowerOff, TBool& aAllSessionsHavePendingRequest) const;
       
    57 
       
    58 protected:
       
    59 	IMPORT_C CServShutdownServer(TInt aPriority);
       
    60 private:
       
    61 	TBool AllSessionsHavePendingRequest() const;
       
    62 	void DoSwitchOff();
       
    63 	// from CServer
       
    64 	CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
       
    65 private:
       
    66 	TBool iPowerOff;
       
    67 	TPowerState iPowerEvent;	
       
    68 	CShutdownTimer* iShutdownTimer;	
       
    69 	};
       
    70 
       
    71 /**
       
    72 This class describes a server side session object, which handles reqistration requests
       
    73 of clients, which are interested in power down events.
       
    74 */
       
    75 class CServShutdownSession : public CSession2
       
    76 	{
       
    77 public:
       
    78 	IMPORT_C ~CServShutdownSession();
       
    79 protected:
       
    80 	IMPORT_C CServShutdownSession();
       
    81 	// from CSession
       
    82 	IMPORT_C void ServiceL(const RMessage2& aMessage);
       
    83 public:
       
    84 	static CServShutdownSession* NewL();
       
    85 	TBool HasPendingRequest() const;
       
    86 	void NotifySave(MSaveObserver::TSaveType aSaveType);
       
    87 
       
    88 private:
       
    89 	void RequestNotifyPowerDown(const RMessage2& aMessage);
       
    90 	void RequestNotifyPowerDownCancel();
       
    91 	void DoServiceL(const RMessage2& aMessage, TBool& aCompleteRequest);
       
    92 	void PowerOffL(const RMessage2& aMessage);
       
    93 	void PowerStateL(const RMessage2& aMessage) const;
       
    94 
       
    95 #ifdef SYMBIAN_SSM_GRACEFUL_SHUTDOWN
       
    96 	void HandleShutdownEventL(const RMessage2& aMessage);
       
    97 	void ClientArrayL(const RMessage2& aMessage);
       
    98 	void IsClientHung(const RMessage2& aMessage) const;
       
    99 	void GetShutdownState(const RMessage2& aMessage) const;
       
   100 	void ClientArrayCount(const RMessage2& aMessage) const;
       
   101 #endif //SYMBIAN_SSM_GRACEFUL_SHUTDOWN
       
   102 
       
   103 public:
       
   104 	TThreadId ClientThreadId() const;
       
   105 
       
   106 private:
       
   107 	RMessagePtr2 iPtr;
       
   108 	TInt iCurrentEvent;
       
   109 	TInt iOutstandingEvent;
       
   110 	};
       
   111 
       
   112 
       
   113 #endif// SHUTDOWNSESS_H