|
1 /* |
|
2 * Copyright (c) 2002-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: Class for implementing Call Restrictions Supplementary services |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "svpsupplementaryservices.h" |
|
22 #include "svplogger.h" |
|
23 #include "svpconsts.h" |
|
24 #include <settingsinternalcrkeys.h> |
|
25 |
|
26 // ============================ MEMBER FUNCTIONS =============================== |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CSSCallRestrictionsApp::CSSCallRestrictionsApp |
|
30 // C++ default constructor can NOT contain any code, that |
|
31 // might leave. |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CSVPSupplementaryServices::CSVPSupplementaryServices() |
|
35 { |
|
36 } |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CSVPSupplementaryServices::ConstructL |
|
40 // Symbian 2nd phase constructor can leave. |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 void CSVPSupplementaryServices::ConstructL() |
|
44 { |
|
45 SVPDEBUG1("CSVPSupplementaryServices::ConstructL, Enter"); |
|
46 |
|
47 iRichCallRepository = CRepository::NewL( KCRUidRichCallSettings ); |
|
48 iLogCall = CSVPSSLogCall::NewL(); |
|
49 |
|
50 SVPDEBUG1("CSVPSupplementaryServices::ConstructL, Exit"); |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CSVPSupplementaryServices::NewL |
|
55 // Two-phased constructor. |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CSVPSupplementaryServices* CSVPSupplementaryServices::NewL() |
|
59 { |
|
60 CSVPSupplementaryServices* self = CSVPSupplementaryServices::NewLC(); |
|
61 CleanupStack::Pop( self ); |
|
62 |
|
63 SVPDEBUG1("CSVPSupplementaryServices::NewL, Exit"); |
|
64 return self; |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CSVPSupplementaryServices::NewL |
|
69 // Two-phased constructor. |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CSVPSupplementaryServices* CSVPSupplementaryServices::NewLC() |
|
73 { |
|
74 CSVPSupplementaryServices* self = |
|
75 new( ELeave ) CSVPSupplementaryServices; |
|
76 |
|
77 CleanupStack::PushL( self ); |
|
78 self->ConstructL(); |
|
79 |
|
80 SVPDEBUG1("CSVPSupplementaryServices::NewLC, Exit"); |
|
81 return self; |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CSVPSupplementaryServices::~CSVPSupplementaryServices |
|
86 // Destructor |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 CSVPSupplementaryServices::~CSVPSupplementaryServices() |
|
90 { |
|
91 SVPDEBUG1("CSVPSupplementaryServices::~CSVPSupplementaryServices, Enter"); |
|
92 delete iLogCall; |
|
93 delete iRichCallRepository; |
|
94 SVPDEBUG1("CSVPSupplementaryServices::~CSVPSupplementaryServices, Exit"); |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CSVPSupplementaryServices::CheckRestrictionsL |
|
99 // (other items were commented in a header). |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 TSupplementaryServicesEvent CSVPSupplementaryServices::CheckRestrictionsL( |
|
103 CDesC8Array& aHeaders ) |
|
104 { |
|
105 SVPDEBUG1("CSVPSupplementaryServices:CheckRestrictionsL, Enter"); |
|
106 |
|
107 TInt currentAnonymous( KSVPAnonymousBarringOff ); |
|
108 TInt currentDoNotDisturb( KSVPDoNotDisturbOff ); |
|
109 |
|
110 TInt isAnonymousAddress (0); |
|
111 TInt isAnonymousSecAddress ( 0 ); |
|
112 // Should URI be checked separately too in case there is no display name? |
|
113 TInt isAnonymousAddressWithoutName ( 0 ); |
|
114 TInt isAnonymousSecAddressWithoutName ( 0 ); |
|
115 TInt isAnonymousName8 ( 0 ); |
|
116 |
|
117 TPtrC8 originator = aHeaders.MdcaPoint( KSVPMceArrayIndexOriginator ); |
|
118 |
|
119 TInt cycle ( 0 ); |
|
120 TCheckingState state ( ESVPIdle ); |
|
121 |
|
122 while ( cycle == 0 ) |
|
123 { |
|
124 switch( state ) |
|
125 { |
|
126 |
|
127 case ESVPIdle: |
|
128 // Check from CRepository if anonymous barring is on. Else DnD is on. |
|
129 iRichCallRepository->Get( |
|
130 KRCSEAnonymousCallBlockRule, currentAnonymous ); |
|
131 SVPDEBUG2(" CSVPSupplementaryServices:CheckRestrictionsL AnonymousBarring: %d", |
|
132 currentAnonymous ); |
|
133 iRichCallRepository->Get( KRCSEDoNotDisturb, currentDoNotDisturb ); |
|
134 SVPDEBUG2(" CSVPSupplementaryServices:CheckRestrictionsL DoNotDisturb: %d", |
|
135 currentDoNotDisturb ); |
|
136 |
|
137 if ( KSVPAnonymousBarringOff == currentAnonymous && |
|
138 KSVPDoNotDisturbOff == currentDoNotDisturb ) |
|
139 { |
|
140 state = ESVPAllowingDail; |
|
141 } |
|
142 else if ( KSVPAnonymousBarringOff == currentAnonymous && |
|
143 KSVPDoNotDisturbOn == currentDoNotDisturb ) |
|
144 { |
|
145 state = ESVPMakingCallLog; |
|
146 } |
|
147 else if ( KSVPAnonymousBarringOn == currentAnonymous ) |
|
148 { |
|
149 isAnonymousAddress = originator.Find( KSVPMyAnonymousAddress ); |
|
150 isAnonymousSecAddress = originator.Find( KSVPMyAnonymousSecAddress ); |
|
151 isAnonymousAddressWithoutName = originator.Find( KSVPAnonymousAddressWithoutName ); |
|
152 isAnonymousSecAddressWithoutName = originator.Find( KSVPAnonymousSecAddressWithoutName ); |
|
153 isAnonymousName8 = originator.Find( KSVPAnonymousName8 ); |
|
154 |
|
155 if ( KSVPDoNotDisturbOff == currentDoNotDisturb ) |
|
156 { |
|
157 state = ESVPCheckingAnonymousToDial; |
|
158 } |
|
159 else if ( KSVPDoNotDisturbOn == currentDoNotDisturb ) |
|
160 { |
|
161 state = ESVPCheckingAnonymousToLog; |
|
162 } |
|
163 else |
|
164 { |
|
165 state = ESVPError; |
|
166 } |
|
167 } |
|
168 else |
|
169 { |
|
170 state = ESVPError; |
|
171 } |
|
172 break; |
|
173 |
|
174 case ESVPAllowingDail: |
|
175 iSSEvent = ESVPSSDefault; |
|
176 state = ESVPIdle; |
|
177 cycle = 1; |
|
178 break; |
|
179 |
|
180 case ESVPMakingCallLog: |
|
181 iLogCall->HandleCallLoggingL( originator ); |
|
182 |
|
183 iSSEvent = ESVPSSDoNotDisturb; |
|
184 state = ESVPRejectingCall; |
|
185 break; |
|
186 |
|
187 case ESVPCheckingAnonymousToDial: |
|
188 if( KErrNotFound != isAnonymousAddress || |
|
189 KErrNotFound != isAnonymousSecAddress || |
|
190 KErrNotFound != isAnonymousAddressWithoutName || |
|
191 KErrNotFound != isAnonymousSecAddressWithoutName || |
|
192 KErrNotFound != isAnonymousName8 ) |
|
193 { |
|
194 iSSEvent = ESVPSSAnonymousBarring; |
|
195 state = ESVPRejectingCall; |
|
196 } |
|
197 else |
|
198 { |
|
199 state = ESVPAllowingDail; |
|
200 }; |
|
201 break; |
|
202 |
|
203 case ESVPCheckingAnonymousToLog: |
|
204 if( KErrNotFound != isAnonymousAddress || |
|
205 KErrNotFound != isAnonymousSecAddress || |
|
206 KErrNotFound != isAnonymousAddressWithoutName || |
|
207 KErrNotFound != isAnonymousSecAddressWithoutName || |
|
208 KErrNotFound != isAnonymousName8 ) |
|
209 { |
|
210 iSSEvent = ESVPSSAnonymousBarring; |
|
211 state = ESVPRejectingCall; |
|
212 } |
|
213 else |
|
214 { |
|
215 state = ESVPMakingCallLog; |
|
216 }; |
|
217 break; |
|
218 |
|
219 case ESVPRejectingCall: |
|
220 state = ESVPIdle; |
|
221 cycle = 1; |
|
222 break; |
|
223 |
|
224 case ESVPError: |
|
225 // Collect error situation. Should not come there ever |
|
226 state = ESVPIdle; |
|
227 cycle = 1; |
|
228 break; |
|
229 } |
|
230 } |
|
231 |
|
232 SVPDEBUG2("CSVPSupplementaryServices:CheckRestrictionsL Exit, event: %d", iSSEvent); |
|
233 return iSSEvent; |
|
234 |
|
235 } |
|
236 |
|
237 //End of File |
|
238 |