|
1 // Copyright (c) 1999-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 #include "ConsoleAlarmAlertServer.h" |
|
18 #include <asaltdefs.h> |
|
19 #include "ConsoleAlarmAlertSession.h" |
|
20 |
|
21 // The Console Alarm Alert Server is migrated to a secure server in EKA2 |
|
22 #include <e32base.h> |
|
23 |
|
24 const TUint KRangeCount = 1; |
|
25 |
|
26 const TInt KOpCodeRanges[KRangeCount] = |
|
27 { |
|
28 0 // All Op Codes from 0 to KMaxInt should pass. No restrictions |
|
29 }; |
|
30 |
|
31 |
|
32 const TUint8 KElementsIndex[KRangeCount] = |
|
33 { |
|
34 CPolicyServer::EAlwaysPass, //All OP Codes Allways passing no capability required |
|
35 }; |
|
36 |
|
37 |
|
38 const CPolicyServer::TPolicy KConsoleAlarmAlertServerPolicy = |
|
39 { |
|
40 CPolicyServer::EAlwaysPass, //specifies all connect attempts should pass |
|
41 KRangeCount, |
|
42 KOpCodeRanges, |
|
43 KElementsIndex, // what each range is compared to |
|
44 0 //Since we have no specific policy checking |
|
45 }; |
|
46 |
|
47 |
|
48 // |
|
49 // ----> CConsoleAlarmAlertServer (source) |
|
50 // |
|
51 |
|
52 //************************************************************************************* |
|
53 CConsoleAlarmAlertServer::CConsoleAlarmAlertServer() |
|
54 :CPolicyServer(CActive::EPriorityStandard, KConsoleAlarmAlertServerPolicy), iInstructionSet(NULL) |
|
55 , iExtendedMode(EFalse), iMaxAlarms(1), iUserTime(Time::NullTTime()) |
|
56 { |
|
57 } |
|
58 |
|
59 |
|
60 |
|
61 //************************************************************************************* |
|
62 CConsoleAlarmAlertServer::~CConsoleAlarmAlertServer() |
|
63 { |
|
64 delete iAttachment; |
|
65 iObservers[EAlarmObserver].Close(); |
|
66 iObservers[ESoundStartObserver].Close(); |
|
67 iObservers[ESoundStopObserver].Close(); |
|
68 iObservers[EVisibleObserver].Close(); |
|
69 iObservers[EStateObserver].Close(); |
|
70 iObservers[EDeleteObserver].Close(); |
|
71 } |
|
72 |
|
73 |
|
74 //************************************************************************************* |
|
75 void CConsoleAlarmAlertServer::ConstructL() |
|
76 { |
|
77 StartL(KAlarmAlertServerName); |
|
78 __FLOG_CONNECT; |
|
79 __FLOG_CREATE(KLogFile, RFileFlogger::ELogModeOverWrite); |
|
80 _LIT(KStartMsg, "Console Alarm Alert Server started"); |
|
81 __FLOG_INFO1(KStartMsg); |
|
82 __FLOG_CLOSE; |
|
83 } |
|
84 |
|
85 |
|
86 //************************************************************************************* |
|
87 CConsoleAlarmAlertServer* CConsoleAlarmAlertServer::NewLC() |
|
88 { |
|
89 CConsoleAlarmAlertServer* self = new(ELeave) CConsoleAlarmAlertServer(); |
|
90 CleanupStack::PushL(self); |
|
91 self->ConstructL(); |
|
92 return self; |
|
93 } |
|
94 |
|
95 // |
|
96 // |
|
97 // |
|
98 |
|
99 |
|
100 //************************************************************************************* |
|
101 CSession2* CConsoleAlarmAlertServer::NewSessionL(const TVersion& aVersion,const RMessage2& /*aMessage*/) const |
|
102 { |
|
103 const TVersion KServerVersion(KASAltVersionMajor, KASAltVersionMinor, KASAltVersionBuild); |
|
104 if (!User::QueryVersionSupported(KServerVersion, aVersion)) |
|
105 User::Leave(KErrNotSupported); |
|
106 // |
|
107 return CConsoleAlarmAlertSession::NewL((CConsoleAlarmAlertServer*)this); |
|
108 } |
|
109 |
|
110 |
|
111 // |
|
112 // |
|
113 // |
|
114 |
|
115 |
|
116 //************************************************************************************* |
|
117 |
|
118 void CConsoleAlarmAlertServer::SetAttachment(HBufC8* data) |
|
119 { |
|
120 delete iAttachment; |
|
121 iAttachment = data; |
|
122 } |
|
123 |
|
124 |
|
125 |
|
126 /** |
|
127 Adds the observer to the list of observers. |
|
128 |
|
129 @param aIndex type of observer, see CConsoleAlarmAlertServer::TObserverIndex. |
|
130 @param aObserver observer to add. |
|
131 */ |
|
132 |
|
133 void CConsoleAlarmAlertServer::AddObserverL(TObserverIndex aIndex, CConsoleAlarmAlertSession* aObserver) |
|
134 { |
|
135 iObservers[aIndex].AppendL(aObserver); |
|
136 } |
|
137 |
|
138 /** |
|
139 Removes the alarm observer from the list of alarm observers. It is safe to call this method |
|
140 even if the observer isn't registered. It will remove all entries of this observer. |
|
141 |
|
142 @param aIndex type of observer, see CConsoleAlarmAlertServer::TObserverIndex. |
|
143 @param aObserver observer to remove. |
|
144 */ |
|
145 |
|
146 void CConsoleAlarmAlertServer::RemoveObserver(TObserverIndex aIndex, CConsoleAlarmAlertSession* aObserver) |
|
147 { |
|
148 TInt i = iObservers[aIndex].Find(aObserver); |
|
149 |
|
150 while (i != KErrNotFound) |
|
151 { |
|
152 iObservers[aIndex].Remove(i); |
|
153 i = iObservers[aIndex].Find(aObserver); |
|
154 } |
|
155 } |
|
156 |
|
157 /** |
|
158 Notifies all registered alarm observers and then clears the list of registered alarm observers. |
|
159 |
|
160 @param aAlarm alarm this notification is for. |
|
161 @param aFullName owner of alarm. |
|
162 @param aData data attached to the alarm. |
|
163 */ |
|
164 |
|
165 void CConsoleAlarmAlertServer::NotifyAlarmObserversL(const TASShdAlarm& aAlarm, const TFullName& aFullName, const TDes8& aData) |
|
166 { |
|
167 TInt count = iObservers[EAlarmObserver].Count(); |
|
168 |
|
169 for (TInt i = 0; i < count; ++i) |
|
170 { |
|
171 iObservers[EAlarmObserver][i]->NotifyAlarmL(aAlarm, aFullName, aData); |
|
172 } |
|
173 |
|
174 iObservers[EAlarmObserver].Reset(); // Objects not deleted, array 'truncated' |
|
175 } |
|
176 |
|
177 /** |
|
178 Notifies all registered sound start observers and then clears the list of registered sound start observers. |
|
179 |
|
180 @param aId id of alarm this event affects. |
|
181 @param aFilename sound file to play. |
|
182 */ |
|
183 |
|
184 void CConsoleAlarmAlertServer::NotifySoundStartObserversL(const TAlarmId& aId, const TDesC& aFilename) |
|
185 { |
|
186 TInt count = iObservers[ESoundStartObserver].Count(); |
|
187 |
|
188 for (TInt i = 0; i < count; ++i) |
|
189 { |
|
190 iObservers[ESoundStartObserver][i]->NotifySoundStartL(aId, aFilename); |
|
191 } |
|
192 |
|
193 iObservers[ESoundStartObserver].Reset(); // Objects not deleted, array 'truncated' |
|
194 } |
|
195 |
|
196 /** |
|
197 Notifies all registered sound stop observers and then clears the list of registered sound stop observers. |
|
198 |
|
199 @param aId id of alarm this event affects. |
|
200 */ |
|
201 |
|
202 void CConsoleAlarmAlertServer::NotifySoundStopObserversL(const TAlarmId& aId) |
|
203 { |
|
204 TInt count = iObservers[ESoundStopObserver].Count(); |
|
205 |
|
206 for (TInt i = 0; i < count; ++i) |
|
207 { |
|
208 iObservers[ESoundStopObserver][i]->NotifySoundStopL(aId); |
|
209 } |
|
210 |
|
211 iObservers[ESoundStopObserver].Reset(); // Objects not deleted, array 'truncated' |
|
212 } |
|
213 |
|
214 /** |
|
215 Notifies all registered visible observers and then clears the list of registered visible observers. |
|
216 |
|
217 @param aId id of alarm this event affects. |
|
218 @param aVisible visible status of the alarm. |
|
219 */ |
|
220 |
|
221 void CConsoleAlarmAlertServer::NotifyVisibleObserversL(const TAlarmId& aId, const TBool aVisible) |
|
222 { |
|
223 TInt count = iObservers[EVisibleObserver].Count(); |
|
224 |
|
225 for (TInt i = 0; i < count; ++i) |
|
226 { |
|
227 iObservers[EVisibleObserver][i]->NotifyVisibleL(aId, aVisible); |
|
228 } |
|
229 |
|
230 iObservers[EVisibleObserver].Reset(); // Objects not deleted, array 'truncated' |
|
231 } |
|
232 |
|
233 /** |
|
234 Notifies all registered state observers and then clears the list of registered state observers. |
|
235 |
|
236 @param aId id of alarm this event affects. |
|
237 @param aState new state of alarm. |
|
238 */ |
|
239 |
|
240 void CConsoleAlarmAlertServer::NotifyStateObserversL(const TAlarmId& aId, const TInt aState) |
|
241 { |
|
242 TInt count = iObservers[EStateObserver].Count(); |
|
243 |
|
244 for (TInt i = 0; i < count; ++i) |
|
245 { |
|
246 iObservers[EStateObserver][i]->NotifyStateL(aId, aState); |
|
247 } |
|
248 |
|
249 iObservers[EStateObserver].Reset(); // Objects not deleted, array 'truncated' |
|
250 } |
|
251 |
|
252 /** |
|
253 Notifies all registered delete alarm observers and then clears the list of registered delete alarm observers. |
|
254 |
|
255 @param aId id of alarm this event affects. |
|
256 */ |
|
257 |
|
258 void CConsoleAlarmAlertServer::NotifyDeleteObserversL(const TAlarmId& aId) |
|
259 { |
|
260 TInt count = iObservers[EDeleteObserver].Count(); |
|
261 |
|
262 for (TInt i = 0; i < count; ++i) |
|
263 { |
|
264 iObservers[EDeleteObserver][i]->NotifyDeleteL(aId); |
|
265 } |
|
266 |
|
267 iObservers[EDeleteObserver].Reset(); // Objects not deleted, array 'truncated' |
|
268 } |
|
269 |