|
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 "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 @file |
|
18 @publishedPartner |
|
19 WARNING: For internal use ONLY. Compatibility is not guaranteed in future releases. |
|
20 */ |
|
21 |
|
22 #ifndef __EIKALSRV_H__ |
|
23 #define __EIKALSRV_H__ |
|
24 |
|
25 #include <e32base.h> |
|
26 #include <asaltdefs.h> |
|
27 #include <asshddefs.h> |
|
28 |
|
29 class MEikServAlarmFactory; |
|
30 class MEikServAlarm; |
|
31 class CEikServAlarmAlertSession; |
|
32 |
|
33 /** |
|
34 @publishedPartner |
|
35 WARNING: Class for internal use ONLY. Compatibility is not guaranteed in future releases. |
|
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 @publishedPartner |
|
65 WARNING: Class for internal use ONLY. Compatibility is not guaranteed in future releases. |
|
66 */ |
|
67 NONSHARABLE_CLASS(TAlarmResponse) |
|
68 { |
|
69 public: |
|
70 TAlarmResponse (TASAltAlertServerResponse aCode, TAlarmId aId, TTime aTime); |
|
71 TASAltAlertServerResponse ResponseCode () const; |
|
72 TAlarmId AlarmId () const; |
|
73 TTime TimeToSnooze() const; |
|
74 private: |
|
75 TASAltAlertServerResponse iCode; |
|
76 TAlarmId iId; |
|
77 TTime iTime; |
|
78 }; |
|
79 |
|
80 // supposed to be maximum one response in a queue, because client should resubmit request |
|
81 // for response as soon as it receive previous |
|
82 const TInt KAlertResponseQueueSize = 20; |
|
83 |
|
84 /** |
|
85 Represents a session for a client thread on the server-side. |
|
86 @publishedPartner |
|
87 WARNING: Class for internal use ONLY. Compatibility is not guaranteed in future releases. |
|
88 */ |
|
89 NONSHARABLE_CLASS(CEikServAlarmAlertSession) : public CSession2 |
|
90 { |
|
91 public: |
|
92 static CEikServAlarmAlertSession* NewL(MEikServAlarmFactory& aAlarmControlFactory, TInt aMaxAlarms); |
|
93 ~CEikServAlarmAlertSession(); |
|
94 void TaskKeyPressedL(); |
|
95 void HandleSwitchOnEvent(); |
|
96 inline TBool AlarmAlertIsVisible() const; |
|
97 |
|
98 void SetQuietPeriodL(TTime aQuietPeriodEndTime); |
|
99 inline TTime QuietPeriodEndTime() const; |
|
100 void RespondEventL(TASAltAlertServerResponse aCode); |
|
101 void RespondEventL(TASAltAlertServerResponse aCode, TAlarmId aId, TTime aTimeToSnooze = 0); |
|
102 void ClearAllAlarmsL(); |
|
103 private: |
|
104 CEikServAlarmAlertServer* AlarmAlertServer() const; |
|
105 void ConstructL(); |
|
106 virtual void ServiceL(const RMessage2 &aMessage); |
|
107 |
|
108 CEikServAlarmAlertSession(MEikServAlarmFactory& aAlarmControl, TInt aMaxAlarms); |
|
109 void QueueEventL (TASAltAlertServerResponse& aCode,TAlarmId& aId, TTime& aTimeToSnooze); |
|
110 TInt FindAlarm(TAlarmId aAlarmId) const; |
|
111 void DeleteAlarmL(const RMessage2& aMessage); |
|
112 void UpdateVisibility(); |
|
113 private: |
|
114 TBool iVisible; |
|
115 MEikServAlarmFactory& iAlarmControlFactory; |
|
116 TTime iQuietPeriodEndTime; |
|
117 TInt iMaxAlarms; |
|
118 RPointerArray<CEikAlmControlSupervisor> iAlarmSupervisors; |
|
119 RArray <TAlarmResponse> iResponseQueue; |
|
120 RMessage2 iMessage; |
|
121 }; |
|
122 |
|
123 /** WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.*/ |
|
124 inline TBool CEikServAlarmAlertServer::AlarmAlertIsVisible() const |
|
125 { return iSession->AlarmAlertIsVisible(); } |
|
126 |
|
127 /** WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.*/ |
|
128 inline TBool CEikServAlarmAlertSession::AlarmAlertIsVisible() const |
|
129 { return iVisible; } |
|
130 |
|
131 /** WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.*/ |
|
132 inline void CEikServAlarmAlertServer::SessionDied() |
|
133 { iSession = NULL; } |
|
134 |
|
135 /** WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.*/ |
|
136 inline TTime CEikServAlarmAlertSession::QuietPeriodEndTime() const |
|
137 { return iQuietPeriodEndTime; } |
|
138 |
|
139 #endif //__EIKALSRV_H__ |