author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:27:34 +0300 | |
branch | RCL_3 |
changeset 77 | da6ac9d688df |
parent 60 | 7fdbb852d323 |
permissions | -rw-r--r-- |
60 | 1 |
/* |
2 |
* Copyright (c) 2002 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: Handles the notifications for voice mail messages |
|
15 |
* : Keeps track about the number of voice mail messages |
|
16 |
* : Has support for alternative line (ALS) |
|
17 |
* |
|
18 |
*/ |
|
19 |
||
20 |
||
21 |
||
22 |
// INCLUDE FILES |
|
23 |
#include <centralrepository.h> |
|
24 |
#include <messagingvariant.hrh> // For CR key handling local variation flags |
|
25 |
#include <centralrepository.h> // For CR key handling |
|
26 |
#include <NcnListInternalCRKeys.h> // For CR key handling |
|
27 |
#include <RSSSettings.h> // For ALS detection |
|
28 |
#include <startupdomainpskeys.h> |
|
29 |
||
30 |
#include "NcnDebug.h" |
|
31 |
#include "NcnCRHandler.h" |
|
32 |
#include "CVoiceMailManager.h" |
|
33 |
#include "CNcnNotifier.h" |
|
34 |
#include "NcnModelBase.h" |
|
35 |
#include "MNcnMsgWaitingManager.h" |
|
36 |
||
37 |
||
38 |
// ----------------------------------------------------------------- |
|
39 |
// CVoiceMailManager::NewL |
|
40 |
// ----------------------------------------------------------------- |
|
41 |
CVoiceMailManager* CVoiceMailManager::NewL( CNcnModelBase& aModel ) |
|
42 |
{ |
|
43 |
CVoiceMailManager* self = new (ELeave) CVoiceMailManager( aModel ); |
|
44 |
||
45 |
CleanupStack::PushL( self ); |
|
46 |
self->ConstructL(); |
|
47 |
CleanupStack::Pop( self ); |
|
48 |
||
49 |
return self; |
|
50 |
} |
|
51 |
||
52 |
// ----------------------------------------------------------------- |
|
53 |
// CVoiceMailManager::~CVoiceMailManager |
|
54 |
// ----------------------------------------------------------------- |
|
55 |
CVoiceMailManager::~CVoiceMailManager() |
|
56 |
{ |
|
57 |
} |
|
58 |
||
59 |
// ----------------------------------------------------------------- |
|
60 |
// CVoiceMailManager::CVoiceMailManager |
|
61 |
// ----------------------------------------------------------------- |
|
62 |
CVoiceMailManager::CVoiceMailManager( CNcnModelBase& aModel ) : |
|
63 |
iIsALSSupported(EFalse), |
|
64 |
iModel( aModel ) |
|
65 |
{ |
|
66 |
// EMPTY |
|
67 |
} |
|
68 |
||
69 |
// ----------------------------------------------------------------- |
|
70 |
// CVoiceMailManager::ConstructL |
|
71 |
// ----------------------------------------------------------------- |
|
72 |
void CVoiceMailManager::ConstructL( ) |
|
73 |
{ |
|
74 |
NCN_RDEBUG( _L("CVoiceMailManager : Constructing") ); |
|
75 |
||
76 |
//Clear soft notifications that might be drawn automatically by avkon |
|
77 |
//TSW Error TWOK-6PNT26 |
|
78 |
ClearVoiceMailSoftNotes(); |
|
77
da6ac9d688df
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
79 |
|
60 | 80 |
//Get SIM change status at the startup. If the SIM will change after |
81 |
//boot-up we get notifed by the Model so no need to subscribe for this key |
|
82 |
//TSW ID EHCN-6NRAZE |
|
83 |
TInt simValue = 0; |
|
84 |
TInt status = RProperty::Get( KPSUidStartup, KPSSimChanged, simValue ); |
|
85 |
NCN_RDEBUG_INT2(_L("CVoiceMailManager : Requested SIM change! status: %d value: %d"), status, simValue ); |
|
86 |
||
87 |
//Handle SIM change in a separate method |
|
88 |
//no need to continue in constructor after this |
|
89 |
if( status == KErrNone && simValue == ESimChanged ) |
|
90 |
{ |
|
91 |
NotifyAboutSIMChange(); |
|
92 |
return; |
|
93 |
} |
|
94 |
||
95 |
//Get the ALS status |
|
96 |
iIsALSSupported = UpdateALSStatus(); |
|
97 |
||
98 |
/////////////////////////////////////////////////////////////////////////////////////// |
|
99 |
// Soft notification must be drawn and the right icon triggered at the boot |
|
100 |
// if there are active voice mail messages waiting |
|
101 |
/////////////////////////////////////////////////////////////////////////////////////// |
|
102 |
} |
|
103 |
||
104 |
// --------------------------------------------------------- |
|
105 |
// CVoiceMailManager::VMReceived |
|
106 |
// Received a voice mail message to line 1 or 2 |
|
107 |
// --------------------------------------------------------- |
|
108 |
// |
|
109 |
void CVoiceMailManager::VMMessageReceived( MNcnMsgWaitingManager::TNcnMessageType aLineType, TUint aAmount ) |
|
110 |
{ |
|
111 |
//Check the value. It must be between 0 - 254 (0xfe) or fuzzy note will be used |
|
112 |
if( aAmount > EVMMaximumNumber ) |
|
113 |
{ |
|
114 |
aAmount = EVMExistsButCountNotKnown; |
|
115 |
} |
|
116 |
||
117 |
//The amount might be an exact value 0-254 or a special value EVMExistsButCountNotKnown |
|
118 |
iModel.MsgWaitingManager().SetMessageCount( aLineType, aAmount, EFalse ); |
|
119 |
||
120 |
//Update notifications |
|
121 |
UpdateVMNotifications(); |
|
122 |
} |
|
123 |
||
124 |
||
125 |
// --------------------------------------------------------- |
|
126 |
// CVoiceMailManager::NotifyAboutSIMChange() |
|
127 |
// SIM has changed so we will need to erase old notes. |
|
128 |
// Model uses this method to notify voice mail manager |
|
129 |
// We also use this in the ConstructL if we notice that |
|
130 |
// the SIM has changed in boot-up |
|
131 |
// --------------------------------------------------------- |
|
132 |
// |
|
133 |
void CVoiceMailManager::NotifyAboutSIMChange() |
|
134 |
{ |
|
135 |
NCN_RDEBUG(_L("CVoiceMailManager::NotifyAboutSIMChange - SIM has changed!")); |
|
136 |
||
137 |
//Get the ALS status. ALS status can change if SIM changes |
|
138 |
iIsALSSupported = UpdateALSStatus(); |
|
139 |
||
140 |
//Update notifications |
|
141 |
UpdateVMNotifications(); |
|
142 |
} |
|
143 |
||
144 |
// --------------------------------------------------------- |
|
145 |
// CVoiceMailManager::HandlePropertyChangedL() |
|
146 |
// Handles the subscribed PS property changes. |
|
147 |
// --------------------------------------------------------- |
|
148 |
// |
|
149 |
void CVoiceMailManager::HandlePropertyChangedL( const TUid& /*aCategory*/, TInt /*aKey*/ ) |
|
150 |
{ |
|
151 |
// Empty |
|
152 |
} |
|
153 |
||
154 |
// --------------------------------------------------------- |
|
155 |
// CVoiceMailManager::ClearVoiceMailSoftNotes |
|
156 |
// In boot-up Avkon automatically draws the soft notes that |
|
157 |
// were present at the time of the shut down. This is not |
|
158 |
// wanted for the voice mails so we manually null them during |
|
159 |
// the boot. |
|
160 |
// --------------------------------------------------------- |
|
161 |
// |
|
162 |
void CVoiceMailManager::ClearVoiceMailSoftNotes() |
|
163 |
{ |
|
164 |
NCN_RDEBUG(_L("CVoiceMailManager::ClearVoiceMailSoftNotes") ); |
|
165 |
iModel.NcnNotifier().SetNotification( MNcnNotifier::ENcnVoiceMailNotification, 0 ); |
|
166 |
iModel.NcnNotifier().SetNotification( MNcnNotifier::ENcnVoiceMailOnLine1Notification, 0 ); |
|
167 |
iModel.NcnNotifier().SetNotification( MNcnNotifier::ENcnVoiceMailOnLine2Notification, 0 ); |
|
168 |
} |
|
169 |
||
170 |
||
171 |
// --------------------------------------------------------- |
|
172 |
// Indication message updates status only for one line at a time. |
|
173 |
// Both lines need to be updated. |
|
174 |
// --------------------------------------------------------- |
|
175 |
// |
|
176 |
void CVoiceMailManager::UpdateNoteAndIndicationWithALS( TInt aVoiceMailsInLine1, TInt aVoiceMailsInLine2 ) |
|
177 |
{ |
|
178 |
//Soft notifications |
|
179 |
NCN_RDEBUG_INT(_L("CVoiceMailManager : %d voice mails in line 1 (ALS supported)"), aVoiceMailsInLine1 ); |
|
180 |
NCN_RDEBUG_INT(_L("CVoiceMailManager : %d voice mails in line 2 (ALS supported)"), aVoiceMailsInLine2 ); |
|
181 |
||
77
da6ac9d688df
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
182 |
iModel.NcnNotifier().SetNotification( MNcnNotifier::ENcnVoiceMailOnLine1Notification, aVoiceMailsInLine1 ); |
da6ac9d688df
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
183 |
iModel.NcnNotifier().SetNotification( MNcnNotifier::ENcnVoiceMailOnLine2Notification, aVoiceMailsInLine2 ); |
da6ac9d688df
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
184 |
|
da6ac9d688df
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
185 |
// Indications |
da6ac9d688df
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
186 |
// SysApp checks ALS support and decides whether to use o_o or O_o (left O full), if ALS supported |
da6ac9d688df
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
187 |
iModel.MsgWaitingManager().SetIndicator( MNcnMsgWaitingManager::ENcnIndicatorVMLine1, aVoiceMailsInLine1 ? ETrue : EFalse ); |
da6ac9d688df
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
188 |
iModel.MsgWaitingManager().SetIndicator( MNcnMsgWaitingManager::ENcnIndicatorVMLine2, aVoiceMailsInLine2 ? ETrue : EFalse ); |
60 | 189 |
} |
190 |
||
191 |
// --------------------------------------------------------- |
|
192 |
// Update soft notification and trigger icon drawing to |
|
193 |
// reflect the current state of the lines |
|
194 |
// --------------------------------------------------------- |
|
195 |
// |
|
196 |
void CVoiceMailManager::UpdateVMNotifications() |
|
197 |
{ |
|
198 |
//We now need a conversion from our internally held voice mail count number |
|
199 |
//to a format that is used in soft notifications. |
|
200 |
// |
|
201 |
||
202 |
if ( !iModel.MsgWaitingManager().ConstructionReady() ) |
|
203 |
{ |
|
204 |
return; |
|
205 |
} |
|
206 |
||
207 |
TUint voiceMailsInLine1 = 0; |
|
208 |
TUint voiceMailsInLine2 = 0; |
|
209 |
||
210 |
//Internally we use value EVMExistsButCountNotKnown to specify a case where the |
|
211 |
//exact count of the voice mails is not know. However, the soft notes are designed |
|
212 |
//so that voice mail strings are either exact or "fuzzy", meaning that the expression |
|
213 |
//used in the string does not imply the exact number. |
|
214 |
//The "fuzzy" string is the singular string in the voice mail's soft note. To |
|
215 |
//use the singular form of the string we need to give voice mail count 1 in case the |
|
216 |
//internal value is EVMExistsButCountNotKnown. |
|
217 |
TBool line1(EFalse); |
|
218 |
TBool line2(EFalse); |
|
219 |
||
220 |
iModel.MsgWaitingManager().GetIndicator( MNcnMsgWaitingManager::ENcnIndicatorVMLine1, line1 ); |
|
221 |
iModel.MsgWaitingManager().GetMessageCount( MNcnMsgWaitingManager::ENcnMessageTypeVMLine1, voiceMailsInLine1 ); |
|
222 |
NCN_RDEBUG_INT2(_L("CVoiceMailManager : line 1 indicator %d, count %d"), line1, voiceMailsInLine1 ); |
|
223 |
||
224 |
if ( line1 && voiceMailsInLine1 == 0) |
|
225 |
{ |
|
226 |
voiceMailsInLine1 = EVMExistsButCountNotKnown; |
|
227 |
} |
|
228 |
||
229 |
iModel.MsgWaitingManager().GetIndicator( MNcnMsgWaitingManager::ENcnIndicatorVMLine2, line2 ); |
|
230 |
iModel.MsgWaitingManager().GetMessageCount( MNcnMsgWaitingManager::ENcnMessageTypeVMLine2, voiceMailsInLine2 ); |
|
231 |
NCN_RDEBUG_INT2(_L("CVoiceMailManager : line 2 indicator %d, count %d"), line2, voiceMailsInLine2 ); |
|
232 |
||
233 |
if ( line2 && voiceMailsInLine2 == 0) |
|
234 |
{ |
|
235 |
voiceMailsInLine2 = EVMExistsButCountNotKnown; |
|
236 |
} |
|
237 |
||
238 |
//The most common case. ALS is not supported in the terminal |
|
239 |
//Notifications show no line information. Only the information in |
|
240 |
//iVoiceMailCountInLine1 matters |
|
241 |
if( iIsALSSupported == EFalse && |
|
242 |
voiceMailsInLine1 > 0) |
|
243 |
{ |
|
244 |
NCN_RDEBUG_INT(_L("CVoiceMailManager : %d voice mails in line 1 (ALS not supported)"), voiceMailsInLine1 ); |
|
245 |
||
77
da6ac9d688df
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
246 |
//Soft notification. The SN must not contain any reference to line numbers |
da6ac9d688df
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
247 |
iModel.NcnNotifier().SetNotification( MNcnNotifier::ENcnVoiceMailNotification, voiceMailsInLine1 ); |
da6ac9d688df
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
248 |
|
da6ac9d688df
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
249 |
// SysApp checks ALS support and decides whether to use o_o or O_o (left O full), if ALS supported |
da6ac9d688df
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
250 |
// ENcnIndicatorVMLine1 is mapped to KDisplayVoicemailActive in CNcnMsgWaitingManager |
da6ac9d688df
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
251 |
iModel.MsgWaitingManager().SetIndicator( MNcnMsgWaitingManager::ENcnIndicatorVMLine1, ETrue ); |
60 | 252 |
} |
253 |
else if( iIsALSSupported == TRUE ) |
|
254 |
{ |
|
255 |
UpdateNoteAndIndicationWithALS( voiceMailsInLine1, voiceMailsInLine2 ); |
|
256 |
} |
|
257 |
||
258 |
//No voice mails waiting. Clear the messages |
|
259 |
else |
|
260 |
{ |
|
261 |
NCN_RDEBUG( _L("CVoiceMailManager : No voice mails in line 1 nor in line 2") ); |
|
262 |
||
263 |
//Clear soft notifications |
|
264 |
ClearVoiceMailSoftNotes(); |
|
265 |
||
266 |
iModel.MsgWaitingManager().SetIndicator( MNcnMsgWaitingManager::ENcnIndicatorVMLine1, EFalse ); |
|
267 |
iModel.MsgWaitingManager().SetIndicator( MNcnMsgWaitingManager::ENcnIndicatorVMLine2, EFalse ); |
|
268 |
} |
|
269 |
} |
|
270 |
||
271 |
// ------------------------------------------------------------------- |
|
272 |
// Find out if alternative line subscription is active in the terminal |
|
273 |
// ------------------------------------------------------------------- |
|
274 |
// |
|
275 |
TBool CVoiceMailManager::UpdateALSStatus() |
|
276 |
{ |
|
277 |
//Open the information settings |
|
278 |
RSSSettings settings; |
|
279 |
TInt status = settings.Open(); |
|
280 |
NCN_RDEBUG_INT( _L("CVoiceMailManager.UpdateALSStatus() : Opened RSSSettings! status %d"), status ); |
|
281 |
||
282 |
//Get the ALS information, |
|
283 |
// ALS is supported, if: |
|
284 |
// 1. supported by the device (ALS PP enabled) |
|
285 |
// 2. CSP enabled and SIM supports alternative service line (line2) |
|
286 |
TInt alsValue = KErrUnknown; |
|
287 |
status = settings.Get( ESSSettingsAls, alsValue ); |
|
288 |
NCN_RDEBUG_INT2( _L("CVoiceMailManager.UpdateALSStatus() : Got ALS info Status: %d Value: %d"), status, alsValue); |
|
289 |
||
290 |
//Close the settings, they are no longer needed |
|
291 |
settings.Close(); |
|
292 |
||
293 |
//Meaning of the ALS values |
|
294 |
// ESSSettingsAlsNotSupported - ALS not supported, always primary line. |
|
295 |
// ESSSettingsAlsPrimary - ALS supported, primary line selected. |
|
296 |
// ESSSettingsAlsAlternate - ALS supported, alternate line selected. |
|
297 |
||
298 |
//Value read OK and ALS not supported |
|
299 |
if( status == KErrNone && alsValue == ESSSettingsAlsNotSupported ) |
|
300 |
{ |
|
301 |
NCN_RDEBUG( _L("ALS value read properly! ALS not supported!") ); |
|
302 |
return EFalse; |
|
303 |
} |
|
304 |
//Value read OK and ALS is supported |
|
305 |
else if( status == KErrNone && |
|
306 |
( alsValue == ESSSettingsAlsPrimary || alsValue == ESSSettingsAlsAlternate ) ) |
|
307 |
{ |
|
308 |
NCN_RDEBUG( _L("ALS value read properly! ALS is supported!") ); |
|
309 |
return ETrue; |
|
310 |
} |
|
311 |
//Default value. ALS not supported. Returned if ALS status can't be read properly! |
|
312 |
else |
|
313 |
{ |
|
314 |
NCN_RDEBUG_INT2( _L("ALS value NOT read properly! Status: %d Value: %d"), status, alsValue ); |
|
315 |
return EFalse; |
|
316 |
} |
|
317 |
} |
|
318 |
// End of File |