epoc32/include/mw/uikon/eikalsrv.h
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 2fe1408b6811
child 4 837f303aceeb
equal deleted inserted replaced
2:2fe1408b6811 3:e1b950c65cb4
       
     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 
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21 */
       
    22 
       
    23 #ifndef __EIKALSRV_H__
       
    24 #define __EIKALSRV_H__
       
    25 
       
    26 #include <e32base.h>
       
    27 #include <asaltdefs.h>
       
    28 #include <asshddefs.h>
       
    29 
       
    30 class MEikServAlarmFactory;
       
    31 class MEikServAlarm;
       
    32 class CEikServAlarmAlertSession;
       
    33 
       
    34 /** 
       
    35 @internalComponent
       
    36 */
       
    37 NONSHARABLE_CLASS(CEikServAlarmAlertServer) : public CPolicyServer
       
    38 	{
       
    39 public:
       
    40 	IMPORT_C static CEikServAlarmAlertServer* NewL(MEikServAlarmFactory* aAlarmControlFactory);
       
    41 	IMPORT_C static CEikServAlarmAlertServer* NewL(MEikServAlarmFactory* aAlarmControlFactory, TInt aMaxAlarms);
       
    42 	~CEikServAlarmAlertServer();
       
    43 	IMPORT_C void HandleSwitchOnEvent();
       
    44 	IMPORT_C void TaskKeyPressedL();
       
    45 	inline TBool AlarmAlertIsVisible() const;
       
    46 	inline void SessionDied();
       
    47 	IMPORT_C void SetQuietPeriodL(TTime aQuietPeriodEndTime);
       
    48 	IMPORT_C void ClearAllAlarmsL();	
       
    49 public: // from CPolicyServer
       
    50 	CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
       
    51 private:
       
    52 	CEikServAlarmAlertServer(TInt aPriority, MEikServAlarmFactory& aAlarmControlFactory,  TInt aMaxAlarms);
       
    53 private:
       
    54 	CEikServAlarmAlertSession* iSession; // iSession does not *own* what it points to
       
    55 	MEikServAlarmFactory& iAlarmControlFactory;
       
    56 	TInt iMaxAlarms;
       
    57 	};
       
    58 
       
    59 
       
    60 class CEikAlmControlSupervisor;
       
    61 
       
    62 /** 
       
    63 Helper class for CEikServAlarmAlertSession. Holds response data for queuing
       
    64 @internalComponent
       
    65 */
       
    66 NONSHARABLE_CLASS(TAlarmResponse)
       
    67 	{
       
    68 public:	
       
    69 	TAlarmResponse (TASAltAlertServerResponse  aCode,  TAlarmId aId, TTime aTime);
       
    70 	TASAltAlertServerResponse ResponseCode () const;
       
    71 	TAlarmId AlarmId () const;
       
    72 	TTime TimeToSnooze() const;
       
    73 private:
       
    74 	TASAltAlertServerResponse  iCode;
       
    75 	TAlarmId iId;
       
    76 	TTime iTime;
       
    77 	};
       
    78 	
       
    79 // supposed to be maximum one response in a queue, because client should resubmit request 
       
    80 // for response as soon	as it receive previous 
       
    81 const TInt KAlertResponseQueueSize = 20;	
       
    82 
       
    83 /**
       
    84 Represents a session for a client thread on the server-side.
       
    85 @internalComponent 
       
    86 */
       
    87 NONSHARABLE_CLASS(CEikServAlarmAlertSession) : public CSession2
       
    88 	{
       
    89 public:
       
    90 	static CEikServAlarmAlertSession* NewL(MEikServAlarmFactory& aAlarmControlFactory, TInt aMaxAlarms);
       
    91 	~CEikServAlarmAlertSession();
       
    92 	void TaskKeyPressedL();
       
    93 	void HandleSwitchOnEvent();
       
    94 	inline TBool AlarmAlertIsVisible() const;
       
    95 
       
    96 	void SetQuietPeriodL(TTime aQuietPeriodEndTime);
       
    97 	inline TTime QuietPeriodEndTime() const; 
       
    98 	void RespondEventL(TASAltAlertServerResponse aCode);
       
    99 	void RespondEventL(TASAltAlertServerResponse aCode, TAlarmId aId, TTime aTimeToSnooze = 0);
       
   100 	void ClearAllAlarmsL();
       
   101 private:
       
   102 	CEikServAlarmAlertServer* AlarmAlertServer() const;
       
   103 	void ConstructL();
       
   104 	virtual void ServiceL(const RMessage2 &aMessage);
       
   105 
       
   106 	CEikServAlarmAlertSession(MEikServAlarmFactory& aAlarmControl, TInt aMaxAlarms);
       
   107 	void QueueEventL (TASAltAlertServerResponse&  aCode,TAlarmId& aId, TTime& aTimeToSnooze);
       
   108 	TInt FindAlarm(TAlarmId aAlarmId) const;
       
   109 	void DeleteAlarmL(const RMessage2& aMessage);
       
   110 	void UpdateVisibility();
       
   111 private:
       
   112 	TBool iVisible;
       
   113 	MEikServAlarmFactory& iAlarmControlFactory;
       
   114 	TTime iQuietPeriodEndTime;
       
   115 	TInt iMaxAlarms;
       
   116 	RPointerArray<CEikAlmControlSupervisor> iAlarmSupervisors;
       
   117 	RArray <TAlarmResponse> iResponseQueue;
       
   118 	RMessage2 iMessage;
       
   119 	};
       
   120 
       
   121 inline TBool CEikServAlarmAlertServer::AlarmAlertIsVisible() const 
       
   122 	{ return iSession->AlarmAlertIsVisible(); }
       
   123 
       
   124 inline TBool CEikServAlarmAlertSession::AlarmAlertIsVisible() const 
       
   125 	{ return iVisible; }
       
   126 
       
   127 inline void CEikServAlarmAlertServer::SessionDied() 
       
   128 	{ iSession = NULL; }
       
   129 
       
   130 inline TTime CEikServAlarmAlertSession::QuietPeriodEndTime() const 
       
   131 	{ return iQuietPeriodEndTime; }
       
   132 
       
   133 #endif //__EIKALSRV_H__