1 /* |
|
2 * Copyright (c) 2009 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: Monitor that observes the calling line identity restriction |
|
15 * setting |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "musclirmonitor.h" |
|
21 #include "muslogger.h" |
|
22 #include "mussesseioninformationapi.h" |
|
23 #include <mmtsy_names.h> |
|
24 #include <e32property.h> |
|
25 |
|
26 const TInt KMaxErrorsBeforeStop = 5; |
|
27 |
|
28 using namespace NMusSessionInformationApi; |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CMusClirMonitor::NewL |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CMusClirMonitor* CMusClirMonitor::NewL() |
|
35 { |
|
36 MUS_LOG( "mus: [CALLMN] -> CMusClirMonitor::NewL" ) |
|
37 |
|
38 CMusClirMonitor* self = new (ELeave) CMusClirMonitor; |
|
39 CleanupStack::PushL( self ); |
|
40 self->ConstructL(); |
|
41 CleanupStack::Pop( self ); |
|
42 MUS_LOG( "mus: [CALLMN] <- CMusClirMonitor::NewL" ) |
|
43 return self; |
|
44 } |
|
45 |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CMusClirMonitor::~CMusClirMonitor |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 CMusClirMonitor::~CMusClirMonitor() |
|
52 { |
|
53 MUS_LOG( "mus: [CALLMN] -> CMusClirMonitor::~CMusClirMonitor" ) |
|
54 |
|
55 Cancel(); |
|
56 delete iTelephony; |
|
57 |
|
58 MUS_LOG( "mus: [CALLMN] <- CMusClirMonitor::~CMusClirMonitor" ) |
|
59 } |
|
60 |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CMusClirMonitor::CMusClirMonitor |
|
64 // Read the parameter's current value |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 CMusClirMonitor::CMusClirMonitor() : |
|
68 CActive( EPriorityNormal ), |
|
69 iTIdentityServiceV1Pckg( iTIdentityServiceV1 ), |
|
70 iAllowed( ETrue ), |
|
71 iErrorCount( 0 ) |
|
72 { |
|
73 MUS_LOG( "mus: [CALLMN] -> CMusClirMonitor::CMusClirMonitor" ) |
|
74 |
|
75 CActiveScheduler::Add( this ); |
|
76 |
|
77 MUS_LOG( "mus: [CALLMN] <- CMusClirMonitor::CMusClirMonitor" ) |
|
78 } |
|
79 |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CMusClirMonitor::ConstructL |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void CMusClirMonitor::ConstructL() |
|
86 { |
|
87 iTelephony = CTelephony::NewL(); |
|
88 ReadClir(); // Read the initial value |
|
89 } |
|
90 |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CMusClirMonitor::RunL |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 void CMusClirMonitor::RunL() |
|
97 { |
|
98 MUS_LOG1( "mus: [CALLMN] -> CMusClirMonitor::RunL iStatus=%d", |
|
99 iStatus.Int() ) |
|
100 |
|
101 if ( iStatus == KErrNone ) |
|
102 { |
|
103 TranslateResult( iTIdentityServiceV1.iIdentityStatus ); |
|
104 iErrorCount = 0; |
|
105 } |
|
106 else |
|
107 { |
|
108 ++iErrorCount; |
|
109 MUS_LOG1( "mus: [CALLMN] Failed, error count(%d)", iErrorCount ) |
|
110 |
|
111 // If reading fails, retry few times |
|
112 if ( iErrorCount <= KMaxErrorsBeforeStop ) |
|
113 { |
|
114 ReadClir(); |
|
115 } |
|
116 } |
|
117 |
|
118 MUS_LOG( "mus: [CALLMN] <- CMusClirMonitor::RunL" ) |
|
119 } |
|
120 |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CMusClirMonitor::DoCancel |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 void CMusClirMonitor::DoCancel() |
|
127 { |
|
128 MUS_LOG( "mus: [CALLMN] -> CMusClirMonitor::DoCancel" ) |
|
129 |
|
130 iTelephony->CancelAsync( CTelephony::EGetIdentityServiceStatusCancel ); |
|
131 |
|
132 MUS_LOG( "mus: [CALLMN] <- CMusClirMonitor::DoCancel" ) |
|
133 } |
|
134 |
|
135 |
|
136 // ----------------------------------------------------------------------------- |
|
137 // CMusClirMonitor::RunError |
|
138 // Ignore errors and continue |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 TInt CMusClirMonitor::RunError( TInt aError ) |
|
142 { |
|
143 MUS_LOG1( "mus: [CALLMN] <-> CMusClirMonitor::RunError aError %d", aError ) |
|
144 aError = KErrNone; // Get rid of "aError is not used" warning in UREL |
|
145 return aError; |
|
146 } |
|
147 |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CMusClirMonitor::ReadClir |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CMusClirMonitor::ReadClir() |
|
154 { |
|
155 MUS_LOG( "mus: [CALLMN] -> CMusClirMonitor::ReadClir" ) |
|
156 |
|
157 if ( !IsActive( )) |
|
158 { |
|
159 CTelephony::TIdentityService condition = |
|
160 CTelephony::EIdServiceCallerRestriction; |
|
161 iTelephony->GetIdentityServiceStatus( iStatus, |
|
162 condition, |
|
163 iTIdentityServiceV1Pckg ); |
|
164 SetActive(); |
|
165 } |
|
166 |
|
167 MUS_LOG( "mus: [CALLMN] <- CMusClirMonitor::ReadClir" ) |
|
168 } |
|
169 |
|
170 |
|
171 // ----------------------------------------------------------------------------- |
|
172 // CMusClirMonitor::TranslateResult |
|
173 // ----------------------------------------------------------------------------- |
|
174 // |
|
175 void |
|
176 CMusClirMonitor::TranslateResult( CTelephony::TIdentityServiceStatus aResult ) |
|
177 { |
|
178 MUS_LOG1( "mus: [CALLMN] -> CMusClirMonitor::TranslateResult aResult=%d", |
|
179 aResult ) |
|
180 |
|
181 switch ( aResult ) |
|
182 { |
|
183 case CTelephony::EIdServiceActivePermanent: |
|
184 case CTelephony::EIdServiceActiveDefaultRestricted: |
|
185 iAllowed = EFalse; |
|
186 break; |
|
187 |
|
188 case CTelephony::EIdServiceActiveDefaultAllowed: |
|
189 case CTelephony::EIdServiceNotProvisioned: |
|
190 iAllowed = ETrue; |
|
191 break; |
|
192 |
|
193 case CTelephony::EIdServiceUnknown: |
|
194 default: |
|
195 ; // retain current value |
|
196 } |
|
197 |
|
198 TMusClirSetting sendNumber( EDoNotSendOwnNumber ); |
|
199 if ( iAllowed ) |
|
200 { |
|
201 sendNumber = ESendOwnNumber; |
|
202 } |
|
203 RProperty::Set( KCategoryUid, KMusClirSetting, sendNumber ); |
|
204 |
|
205 MUS_LOG1( "mus: [CALLMN] <- CMusClirMonitor::TranslateResult allowed=%d", |
|
206 iAllowed ) |
|
207 } |
|
208 |
|
209 // end of file |
|