|
1 /* |
|
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Methods for CNcnCRHandler class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "NcnDebug.h" |
|
22 #include "NcnModelBase.h" |
|
23 #include "NcnModel.h" |
|
24 #include "NcnCRHandler.h" |
|
25 #include "CNcnCRRepositoryHandler.h" |
|
26 |
|
27 #include <messagingvariant.hrh> // Local variation flags |
|
28 #include <centralrepository.h> |
|
29 #include <LogsDomainCRKeys.h> |
|
30 #include <NcnListInternalCRKeys.h> |
|
31 #include <NcnListInternalPSKeys.h> |
|
32 #include <messaginginternalcrkeys.h> |
|
33 #include <ProfileEngineSDKCRKeys.h> |
|
34 #include <telincallvolcntrlcrkeys.h> |
|
35 #include <coreapplicationuisdomainpskeys.h> |
|
36 |
|
37 #include <e32property.h> |
|
38 #include "NcnSubscriber.h" |
|
39 #include "MNcnMsgWaitingManager.h" |
|
40 |
|
41 // ================= MEMBER FUNCTIONS ======================= |
|
42 |
|
43 // C++ default constructor can NOT contain any code that |
|
44 // might leave. |
|
45 // |
|
46 CNcnCRHandler::CNcnCRHandler( CNcnModelBase* aModel ) : |
|
47 iModel( aModel ), |
|
48 iLogsSDAssignedOk( EFalse ), iSysApSDAssignedOk( EFalse ) |
|
49 { |
|
50 } |
|
51 |
|
52 // Symbian OS default constructor can leave. |
|
53 void CNcnCRHandler::ConstructL() |
|
54 { |
|
55 iLogsSession = CRepository::NewL( KCRUidLogs ); |
|
56 iNcnSession = CRepository::NewL( KCRUidNcnList ); |
|
57 iMuiuSession = CRepository::NewL( KCRUidMuiuVariation ); |
|
58 iSmumSession = CRepository::NewL( KCRUidSmum ); |
|
59 iProfileSession = CRepository::NewL( KCRUidProfileEngine ); |
|
60 iTelephonySession = CRepository::NewL( KCRUidInCallVolume ); |
|
61 |
|
62 iLogsSDAssignedOk = ETrue; |
|
63 |
|
64 TInt missedCalls = 0; |
|
65 |
|
66 // Get the amount of missed calls. If it is not initialised then initialise it to zero. |
|
67 TInt err = iLogsSession->Get( KLogsNewMissedCalls, missedCalls ); |
|
68 if( err == KErrNotFound || err == KErrUnknown || missedCalls < 0 ) |
|
69 { |
|
70 iLogsSession->Set( KLogsNewMissedCalls, 0 ); |
|
71 } |
|
72 |
|
73 NCN_RDEBUG_INT(_L("CNcnCRHandler::ConstructL : CR Missed Calls:%d" ), missedCalls ); |
|
74 |
|
75 // Request shared data server to notify on missed call variable changes. |
|
76 iLogsNotifyHandler = |
|
77 CNcnCRRepositoryHandler::NewL( *this, *iLogsSession, CCenRepNotifyHandler::EIntKey, KLogsNewMissedCalls ); |
|
78 iLogsNotifyHandler->StartListeningL(); |
|
79 |
|
80 // update missed calls notification |
|
81 iModel->NcnNotifier().SetNotification( |
|
82 MNcnNotifier::ENcnMissedCallsNotification, |
|
83 0 ); |
|
84 |
|
85 // For observing outside command to play sound |
|
86 err = RProperty::Define( KPSUidNcnList, |
|
87 KNcnPlayAlertTone, |
|
88 RProperty::EInt, |
|
89 ECapability_None, |
|
90 ECapabilityWriteUserData ); |
|
91 |
|
92 if ( err == KErrNone ) |
|
93 { |
|
94 RProperty::Set( KPSUidNcnList, KNcnPlayAlertTone, 0 ); |
|
95 } |
|
96 iAlertToneSubscriber = CNcnSubscriber::NewL( *this, KPSUidNcnList, KNcnPlayAlertTone ); |
|
97 iAlertToneSubscriber->Subscribe(); |
|
98 |
|
99 |
|
100 // Add listener for smum events |
|
101 if( iModel->IsSupported( KNcnIdSimCard ) ) |
|
102 { |
|
103 TInt smsInitialisationPhase = 0; //default value, not informative state |
|
104 err = iSmumSession->Get( KSmumSmsStatus, smsInitialisationPhase ); |
|
105 |
|
106 if( err == KErrNone ) |
|
107 { |
|
108 iModel->SetSmsInitialisationState( smsInitialisationPhase ); |
|
109 } |
|
110 |
|
111 if ( !iSmumNotifyHandler ) |
|
112 { |
|
113 //iSmumNotifyHandler = |
|
114 // CCenRepNotifyHandler::NewL( *this, *iSmumSession, CCenRepNotifyHandler::EIntKey, KSmumSmsStatus ); |
|
115 //iSmumNotifyHandler->StartListeningL(); |
|
116 iSmumNotifyHandler = |
|
117 CNcnCRRepositoryHandler::NewL( *this, *iSmumSession, CCenRepNotifyHandler::EIntKey, KSmumSmsStatus ); |
|
118 iSmumNotifyHandler->StartListeningL(); |
|
119 } |
|
120 } |
|
121 |
|
122 // Assign tone listener |
|
123 iMsgToneSubscriber = CNcnSubscriber::NewL( |
|
124 *this, KPSUidCoreApplicationUIs, KCoreAppUIsMessageToneQuit ); |
|
125 iMsgToneSubscriber->Subscribe(); |
|
126 iSysApSDAssignedOk = ETrue; |
|
127 } |
|
128 |
|
129 // Two-phased constructor. |
|
130 CNcnCRHandler* CNcnCRHandler::NewL( CNcnModelBase* aModel ) |
|
131 { |
|
132 CNcnCRHandler* self = new (ELeave) CNcnCRHandler( aModel ); |
|
133 |
|
134 CleanupStack::PushL( self ); |
|
135 self->ConstructL(); |
|
136 CleanupStack::Pop(); |
|
137 |
|
138 return self; |
|
139 } |
|
140 |
|
141 |
|
142 // Destructor |
|
143 CNcnCRHandler::~CNcnCRHandler() |
|
144 { |
|
145 if( iLogsNotifyHandler ) |
|
146 { |
|
147 iLogsNotifyHandler->StopListening(); |
|
148 delete iLogsNotifyHandler; |
|
149 } |
|
150 |
|
151 delete iLogsSession; |
|
152 delete iNcnSession; |
|
153 delete iMuiuSession; |
|
154 |
|
155 if ( iSmumNotifyHandler ) |
|
156 { |
|
157 iSmumNotifyHandler->StopListening(); |
|
158 delete iSmumNotifyHandler; |
|
159 } |
|
160 |
|
161 delete iSmumSession; |
|
162 |
|
163 if ( iMuiuSettingsNotifyHandler ) |
|
164 { |
|
165 iMuiuSettingsNotifyHandler->StopListening(); |
|
166 delete iMuiuSettingsNotifyHandler; |
|
167 } |
|
168 |
|
169 delete iProfileSession; |
|
170 delete iTelephonySession; |
|
171 |
|
172 delete iAlertToneSubscriber; |
|
173 delete iMsgToneSubscriber; |
|
174 } |
|
175 |
|
176 // ---------------------------------------------------- |
|
177 // CNcnCRHandler::HandleRepositoryNotifyInt |
|
178 // ---------------------------------------------------- |
|
179 // |
|
180 void CNcnCRHandler::HandleRepositoryNotifyInt( |
|
181 CRepository& aRepository, |
|
182 const TUint32 aID, |
|
183 const TInt aNewValue ) |
|
184 { |
|
185 // logs repository key changes |
|
186 if( &aRepository == iLogsSession ) |
|
187 { |
|
188 NCN_RDEBUG_INT2(_L("CNcnCRHandler::HandleRepositoryNotifyInt - LOGS repository key change (aID = %d, aNewValue = %d)" ), aID, aNewValue ); |
|
189 |
|
190 // if key was missed calls |
|
191 if( aID == KLogsNewMissedCalls ) |
|
192 { |
|
193 // update amount of missed calls |
|
194 iModel->NcnNotifier().SetNotification( |
|
195 MNcnNotifier::ENcnMissedCallsNotification, |
|
196 aNewValue ); |
|
197 } |
|
198 } |
|
199 // smum repository key changes |
|
200 else if( &aRepository == iSmumSession ) |
|
201 { |
|
202 NCN_RDEBUG_INT2(_L("CNcnCRHandler::HandleRepositoryNotifyInt - SMUM repository key change (aID = %d, aNewValue = %d)" ), aID, aNewValue ); |
|
203 |
|
204 // if key was sms status |
|
205 if( aID == KSmumSmsStatus && iModel->IsSupported( KNcnIdSimCard ) ) |
|
206 { |
|
207 iModel->SetSmsInitialisationState( aNewValue ); |
|
208 } |
|
209 } |
|
210 |
|
211 else |
|
212 { |
|
213 NCN_RDEBUG(_L("CNcnCRHandler::HandleRepositoryNotifyInt - Unknown repository" )); |
|
214 } |
|
215 } |
|
216 |
|
217 // --------------------------------------------------------- |
|
218 // CNcnCRHandler::HandlePropertyChangedL() |
|
219 // Handles the subscribed properties changes. |
|
220 // --------------------------------------------------------- |
|
221 // |
|
222 void CNcnCRHandler::HandlePropertyChangedL( const TUid& aCategory, TInt aKey ) |
|
223 { |
|
224 TInt state = 0; |
|
225 |
|
226 if ( aCategory == KPSUidCoreApplicationUIs && aKey == KCoreAppUIsMessageToneQuit ) |
|
227 { |
|
228 RProperty::Get( KPSUidCoreApplicationUIs, KCoreAppUIsMessageToneQuit, state ); |
|
229 |
|
230 NCN_RDEBUG_INT(_L("CNcnCRHandler::HandlePropertyChangedL - KCoreAppUIsMessageToneQuit changed to %d" ), state ); |
|
231 |
|
232 if( state == ECoreAppUIsStopTonePlaying ) |
|
233 { |
|
234 iModel->StopMsgReceivedTonePlaying(); |
|
235 } |
|
236 } |
|
237 else if ( aCategory == KPSUidNcnList && aKey == KNcnPlayAlertTone ) |
|
238 { |
|
239 RProperty::Get( KPSUidNcnList, KNcnPlayAlertTone, state ); |
|
240 // Check if alert tone asked to be played |
|
241 if( state ) |
|
242 { |
|
243 iModel->PlayAlertToneL( state ); |
|
244 } |
|
245 } |
|
246 } |
|
247 |
|
248 |
|
249 // --------------------------------------------------------- |
|
250 // CNcnCRHandler::ResetMissedCalls |
|
251 // --------------------------------------------------------- |
|
252 // |
|
253 void CNcnCRHandler::ResetMissedCalls() |
|
254 { |
|
255 // Clear all the bits. |
|
256 NCN_RDEBUG(_L("CNcnCRHandler::ResetMissedCalls()" )); |
|
257 if( iLogsSDAssignedOk ) |
|
258 { |
|
259 iLogsSession->Set( KLogsNewMissedCalls, 0 ); |
|
260 } |
|
261 } |
|
262 // --------------------------------------------------------- |
|
263 // CNcnCRHandler::SetSmumFlag( const TInt aNewFlagValue ) |
|
264 // --------------------------------------------------------- |
|
265 // |
|
266 void CNcnCRHandler::SetSmumFlag( const TInt aNewFlagValue ) |
|
267 { |
|
268 iSmumSession->Set( KSmumSmsStatus, aNewFlagValue ); |
|
269 } |
|
270 |
|
271 // --------------------------------------------------------- |
|
272 // CNcnCRHandler::MsgReceivedTonePlaying |
|
273 // --------------------------------------------------------- |
|
274 // |
|
275 void CNcnCRHandler::MsgReceivedTonePlaying( const TUint aPlaying ) |
|
276 { |
|
277 // Through this the System Application can detect whether we are playing |
|
278 // the message received ringing tone or not. |
|
279 NCN_RDEBUG(_L("CNcnCRHandler::MsgReceivedTonePlaying( const TBool aPlaying )")); |
|
280 if( iSysApSDAssignedOk ) |
|
281 { |
|
282 if( aPlaying ) |
|
283 { |
|
284 RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsMessageToneQuit, ECoreAppUIsTonePlaying ); |
|
285 } |
|
286 else |
|
287 { |
|
288 RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsMessageToneQuit, ECoreAppUIsStopTonePlaying ); |
|
289 } |
|
290 } |
|
291 } |
|
292 |
|
293 // --------------------------------------------------------- |
|
294 // CNcnCRHandler::GetString |
|
295 // --------------------------------------------------------- |
|
296 // |
|
297 TInt CNcnCRHandler::GetString( |
|
298 const TUid& aUid, |
|
299 const TUint32 aKey, |
|
300 TDes& aString ) const |
|
301 { |
|
302 // Prepare and get client |
|
303 CRepository* client = NULL; |
|
304 |
|
305 TInt err = GetClientForUid( aUid, client ); |
|
306 |
|
307 // Check if problems with getting the client |
|
308 if( err == KErrNone ) |
|
309 { |
|
310 err = client->Get( aKey, aString ); |
|
311 } |
|
312 |
|
313 // Return result |
|
314 return err; |
|
315 } |
|
316 |
|
317 // --------------------------------------------------------- |
|
318 // CNcnCRHandler::GetPSString |
|
319 // --------------------------------------------------------- |
|
320 // |
|
321 TInt CNcnCRHandler::GetPSString( |
|
322 const TUid& aUid, |
|
323 const TUint32 aKey, |
|
324 TDes& aString ) const |
|
325 { |
|
326 TInt err = RProperty::Get( aUid, aKey, aString ); |
|
327 |
|
328 // Return result |
|
329 return err; |
|
330 } |
|
331 |
|
332 // --------------------------------------------------------- |
|
333 // CNcnCRHandler::GetCRInt |
|
334 // --------------------------------------------------------- |
|
335 // |
|
336 TInt CNcnCRHandler::GetCRInt( |
|
337 const TUid& aUid, |
|
338 const TUint32 aKey, |
|
339 TInt& aValue ) const |
|
340 { |
|
341 // Prepare and get client |
|
342 CRepository* client = NULL; |
|
343 |
|
344 TInt err = GetClientForUid( aUid, client ); |
|
345 |
|
346 // Check if problems with getting the client |
|
347 if( err == KErrNone ) |
|
348 { |
|
349 err = client->Get( aKey, aValue ); |
|
350 } |
|
351 |
|
352 // Return result |
|
353 return err; |
|
354 } |
|
355 |
|
356 // --------------------------------------------------------- |
|
357 // CNcnCRHandler::SetCRInt |
|
358 // --------------------------------------------------------- |
|
359 // |
|
360 TInt CNcnCRHandler::SetCRInt( |
|
361 const TUid& aUid, |
|
362 const TUint32 aKey, |
|
363 const TInt aValue, |
|
364 const TBool /*aSave*/ ) const |
|
365 { |
|
366 // Prepare and get client |
|
367 CRepository* client = NULL; |
|
368 |
|
369 TInt err = GetClientForUid( aUid, client ); |
|
370 |
|
371 // Check if problems with getting the client |
|
372 if( err == KErrNone ) |
|
373 { |
|
374 err = client->Set( aKey, aValue ); |
|
375 } |
|
376 |
|
377 // Return result |
|
378 return err; |
|
379 } |
|
380 |
|
381 // --------------------------------------------------------- |
|
382 // CNcnCRHandler::UpdateMissedCallsNotification |
|
383 // --------------------------------------------------------- |
|
384 // |
|
385 void CNcnCRHandler::UpdateMissedCallsNotification() |
|
386 { |
|
387 TInt missedCalls; |
|
388 TInt err = iLogsSession->Get( KLogsNewMissedCalls, missedCalls ); |
|
389 if( ( err == KErrNone ) && ( missedCalls > 0 ) ) |
|
390 { |
|
391 iModel->NcnNotifier().SetNotification( |
|
392 MNcnNotifier::ENcnMissedCallsNotification, missedCalls ); |
|
393 } |
|
394 } |
|
395 |
|
396 // --------------------------------------------------------- |
|
397 // CNcnCRHandler::GetClientForUid |
|
398 // --------------------------------------------------------- |
|
399 // |
|
400 TInt CNcnCRHandler::GetClientForUid( |
|
401 const TUid& aUid, |
|
402 CRepository*& aClient ) const |
|
403 { |
|
404 TInt error = KErrNone; |
|
405 |
|
406 if( aUid == KCRUidNcnList ) |
|
407 { |
|
408 // Get ncn session |
|
409 aClient = iNcnSession; |
|
410 } |
|
411 else if( aUid == KCRUidProfileEngine ) |
|
412 { |
|
413 // Get default tone |
|
414 aClient = iProfileSession; |
|
415 } |
|
416 else if( aUid == KCRUidInCallVolume ) |
|
417 { |
|
418 // Get default tone |
|
419 aClient = iTelephonySession; |
|
420 } |
|
421 else if ( aUid == KCRUidMuiuVariation ) |
|
422 { |
|
423 aClient = iMuiuSession; |
|
424 } |
|
425 else |
|
426 { |
|
427 // Return error |
|
428 error = KErrNotFound; |
|
429 } |
|
430 |
|
431 return error; |
|
432 } |
|
433 |
|
434 |
|
435 // End of File |