|
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: Call diverting class. Sets and gets call diverting status. |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // Include Files |
|
21 #include <etelmm.h> |
|
22 #include <e32math.h> |
|
23 #include <e32svr.h> |
|
24 #include <badesca.h> |
|
25 |
|
26 #include <vmnumber.h> |
|
27 #include <centralrepository.h> |
|
28 #include <SettingsInternalCRKeys.h> |
|
29 |
|
30 #include "PsetCallDiverting.h" |
|
31 #include "PsetContainer.h" |
|
32 #include "MPsetDivertObs.h" |
|
33 #include "PsetTelephony.h" |
|
34 #include "PSetPanic.h" |
|
35 #include "PhoneSettingsLogger.h" |
|
36 |
|
37 #include "PSetCallDivertingCreator.h" |
|
38 #include "MCallDiverting.h" |
|
39 |
|
40 // MEMBER FUNCTIONS |
|
41 // --------------------------------------------------------------------------- |
|
42 // First phase constructor |
|
43 // --------------------------------------------------------------------------- |
|
44 EXPORT_C CPsetCallDiverting* CPsetCallDiverting::NewL( MPsetDivertObserver& aObserver, |
|
45 RMobilePhone& aPhone ) |
|
46 { |
|
47 __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::NewL"); |
|
48 CPsetCallDiverting* self = new ( ELeave ) CPsetCallDiverting( aPhone ); |
|
49 CleanupStack::PushL( self ); |
|
50 self->ConstructL( aObserver ); |
|
51 CleanupStack::Pop( self ); |
|
52 __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::NewL"); |
|
53 return self; |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // Destructor. |
|
58 // --------------------------------------------------------------------------- |
|
59 EXPORT_C CPsetCallDiverting::~CPsetCallDiverting() |
|
60 { |
|
61 __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::~CPsetCallDiverting"); |
|
62 iReqObserver = NULL; |
|
63 |
|
64 delete iRepository; |
|
65 |
|
66 delete iDivert; |
|
67 iDivert = NULL; |
|
68 __PHSLOGSTRING("[PHS]<-- CPsetCallDiverting::~CPsetCallDiverting"); |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // Symbian OS constructor |
|
73 // --------------------------------------------------------------------------- |
|
74 void CPsetCallDiverting::ConstructL( MPsetDivertObserver& aObserver ) |
|
75 { |
|
76 __PHSLOGSTRING("[PHS] -->CPsetCallDiverting::ConstructL" ); |
|
77 iDivert= CPSetCallDivertingCreator::CreateCallDivertingL( aObserver, iPhone, this ); |
|
78 iRepository = CRepository::NewL( KCRUidCallForwarding ); |
|
79 __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::ConstructL" ); |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // C++ constructor |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 CPsetCallDiverting::CPsetCallDiverting( RMobilePhone& aPhone ) : |
|
87 iPhone ( aPhone ) |
|
88 { |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // Sets diverting. |
|
93 // --------------------------------------------------------------------------- |
|
94 EXPORT_C void CPsetCallDiverting::SetDivertingL( |
|
95 const TCallDivertSetting& aDivert, |
|
96 TBasicServiceGroups aBsc, TBool /*aVmbx*/ ) |
|
97 { |
|
98 __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::SetDivertingL"); |
|
99 __PHSLOGSTRING1("[PHS] CPsetCallDiverting::SetDivertingL: aDivert.iCondition: %d", aDivert.iCondition ); |
|
100 __PHSLOGSTRING1("[PHS] CPsetCallDiverting::SetDivertingL: aDivert.iStatus: %d", aDivert.iStatus ); |
|
101 __PHSLOGSTRING1("[PHS] CPsetCallDiverting::SetDivertingL: aDivert.iServiceGroup: %d", aDivert.iServiceGroup ); |
|
102 iDivert->SetDivertingL( aDivert, aBsc ); |
|
103 __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::SetDivertingL" ); |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // Request diverting status from network asynhronously. |
|
108 // --------------------------------------------------------------------------- |
|
109 EXPORT_C void CPsetCallDiverting::GetDivertingStatusL( |
|
110 const TServiceGroup aServiceGroup, |
|
111 const TCallDivertingCondition aCondition, |
|
112 TBasicServiceGroups aBsc ) |
|
113 { |
|
114 __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::GetDivertingStatusL" ); |
|
115 __PHSLOGSTRING1("[PHS] CPsetCallDiverting::GetDivertingStatusL: aServiceGroup: %d", aServiceGroup ); |
|
116 __PHSLOGSTRING1("[PHS] CPsetCallDiverting::GetDivertingStatusL: aCondition: %d", aCondition ); |
|
117 __PHSLOGSTRING1("[PHS] CPsetCallDiverting::GetDivertingStatusL: aBsc: %d", aBsc ); |
|
118 iDivert->GetDivertingStatusL( aServiceGroup, aCondition, aBsc ); |
|
119 __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::GetDivertingStatusL" ); |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // Cancels pending request. |
|
124 // --------------------------------------------------------------------------- |
|
125 EXPORT_C TInt CPsetCallDiverting::CancelCurrentRequest() |
|
126 { |
|
127 __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::CancelCurrentRequest" ); |
|
128 TInt err(KErrNone); |
|
129 err = iDivert->CancelCurrentRequest(); |
|
130 __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::CancelCurrentRequest" ); |
|
131 return err; |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // The default (last forwarded-to) numbers can be retrieved through this method. |
|
136 // The amount of available numbers is returned. |
|
137 // Relies on default numbers having right order in shared data. |
|
138 // --------------------------------------------------------------------------- |
|
139 EXPORT_C TInt CPsetCallDiverting::GetDefaultNumbersL( |
|
140 CDesC16ArrayFlat& aDefNumbers ) |
|
141 { |
|
142 __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::GetDefaultNumbersL" ); |
|
143 return iDivert->GetNumbersFromSharedDataL( NULL, aDefNumbers ); |
|
144 } |
|
145 |
|
146 // --------------------------------------------------------------------------- |
|
147 // Sets new default number the the default numbers list, erases the oldest one. |
|
148 // --------------------------------------------------------------------------- |
|
149 EXPORT_C TInt CPsetCallDiverting::SetNewDefaultNumberL( TDes& aNumber ) |
|
150 { |
|
151 __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::SetNewDefaultNumberL" ); |
|
152 TInt retValue(KErrNone); |
|
153 retValue = iDivert->SetNewDefaultNumberL( aNumber ); |
|
154 __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::SetNewDefaultNumberL" ); |
|
155 return retValue; //return value is not used |
|
156 } |
|
157 |
|
158 // --------------------------------------------------------------------------- |
|
159 // Gets the timer value index related to "cfnry" from shared data |
|
160 // In error cases, return default value (30). |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 EXPORT_C TInt CPsetCallDiverting::GetTimerValueL() |
|
164 { |
|
165 __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::GetTimerValueL" ); |
|
166 TInt timerValue(0); |
|
167 timerValue = iDivert->GetTimerValueL(); |
|
168 __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::GetTimerValueL" ); |
|
169 return timerValue; |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------------------------- |
|
173 // Sets the default time for "divert when not answered" to .ini file |
|
174 // --------------------------------------------------------------------------- |
|
175 EXPORT_C TInt CPsetCallDiverting::SetTimerValueL( const TInt& aValue ) |
|
176 { |
|
177 __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::SetTimerValueL" ); |
|
178 TInt retValue(KErrNone); |
|
179 retValue = iDivert->SetTimerValueL( aValue ); |
|
180 __PHSLOGSTRING1("[PHS] <--CPsetCallDiverting::SetTimerValueL: retValue: %d", retValue ); |
|
181 return retValue; |
|
182 } |
|
183 |
|
184 // --------------------------------------------------------------------------- |
|
185 // Swaps the most recently used number to first in the shared data file. |
|
186 // --------------------------------------------------------------------------- |
|
187 EXPORT_C void CPsetCallDiverting::SwapDefaultNumberL( const TInt& aLocation ) |
|
188 { |
|
189 __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::SwapDefaultNumberL" ); |
|
190 iDivert->SwapDefaultNumberL( aLocation ); |
|
191 __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::SwapDefaultNumberL" ); |
|
192 } |
|
193 |
|
194 // --------------------------------------------------------------------------- |
|
195 // Saves fax call diverting number to shareddata. |
|
196 // --------------------------------------------------------------------------- |
|
197 EXPORT_C TInt CPsetCallDiverting::SetUsedDataNumberL( TTelNumber& aNumber ) |
|
198 { |
|
199 __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::SetUsedDataNumberL" ); |
|
200 TInt retValue = KErrNone; |
|
201 retValue = iDivert->SaveKey( KSettingsCFUsedDataNumber, aNumber ); |
|
202 __PHSLOGSTRING1("[PHS] CPsetCallDiverting::SetUsedDataNumberL: aNumber: %S", &aNumber ); |
|
203 __PHSLOGSTRING1("[PHS] CPsetCallDiverting::SetUsedDataNumberL: retValue: %d", retValue ); |
|
204 __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::SetUsedDataNumberL" ); |
|
205 return retValue; |
|
206 } |
|
207 |
|
208 // --------------------------------------------------------------------------- |
|
209 // Returns used number for data call forwardings. |
|
210 // --------------------------------------------------------------------------- |
|
211 EXPORT_C HBufC* CPsetCallDiverting::GetUsedDataNumberLC( ) |
|
212 { |
|
213 __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::GetUsedDataNumberLC" ); |
|
214 TTelNumber readNumber; |
|
215 |
|
216 iRepository->Get( KSettingsCFUsedDataNumber, readNumber ); |
|
217 |
|
218 __PHSLOGSTRING1("[PHS] CPsetCallDiverting::GetUsedDataNumberLC: readNumber: %S", &readNumber ); |
|
219 __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::GetUsedDataNumberLC" ); |
|
220 |
|
221 return readNumber.AllocLC(); |
|
222 } |
|
223 |
|
224 // --------------------------------------------------------------------------- |
|
225 // Saves fax call diverting number to shareddata. |
|
226 // --------------------------------------------------------------------------- |
|
227 EXPORT_C TInt CPsetCallDiverting::SetUsedFaxNumberL( TTelNumber& aNumber ) |
|
228 { |
|
229 __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::SetUsedFaxNumberL" ); |
|
230 TInt retValue = KErrNone; |
|
231 |
|
232 retValue = iDivert->SaveKey( KSettingsCFUsedFaxNumber, aNumber ); |
|
233 |
|
234 __PHSLOGSTRING1("[PHS] CPsetCallDiverting::SetUsedFaxNumberL: aNumber: %S", &aNumber ); |
|
235 __PHSLOGSTRING1("[PHS] CPsetCallDiverting::SetUsedFaxNumberL: retValue: %d", retValue ); |
|
236 __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::SetUsedFaxNumberL" ); |
|
237 |
|
238 return retValue; |
|
239 } |
|
240 |
|
241 // --------------------------------------------------------------------------- |
|
242 // Returns used number for fax call forwardings. |
|
243 // --------------------------------------------------------------------------- |
|
244 EXPORT_C HBufC* CPsetCallDiverting::GetUsedFaxNumberLC() |
|
245 { |
|
246 __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::GetUsedFaxNumberLC" ); |
|
247 TTelNumber readNumber; |
|
248 |
|
249 iRepository->Get( KSettingsCFUsedFaxNumber, readNumber ); |
|
250 |
|
251 __PHSLOGSTRING1("[PHS] CPsetCallDiverting::GetUsedFaxNumberLC: readNumber: %S", &readNumber ); |
|
252 __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::GetUsedFaxNumberLC" ); |
|
253 |
|
254 return readNumber.AllocLC(); |
|
255 } |
|
256 |
|
257 // --------------------------------------------------------------------------- |
|
258 // Sets request observer. |
|
259 // --------------------------------------------------------------------------- |
|
260 // |
|
261 EXPORT_C void CPsetCallDiverting::SetRequestObserver( MPsetRequestObserver* aObs ) |
|
262 { |
|
263 iReqObserver = aObs; |
|
264 } |
|
265 |
|
266 // --------------------------------------------------------------------------- |
|
267 // Queries for voice mail box number |
|
268 // --------------------------------------------------------------------------- |
|
269 // |
|
270 EXPORT_C void CPsetCallDiverting::VoiceMailQueryL( TDes& aTelNumber ) |
|
271 { |
|
272 __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::VoiceMailQueryL" ); |
|
273 RVmbxNumber vmbxConnection; |
|
274 TBool vmbxNrChanged = ETrue; |
|
275 TInt retValue = iDivert->OpenVmbxLC( aTelNumber, vmbxConnection ); |
|
276 __PHSLOGSTRING1("[PHS] CPsetCallDiverting::VoiceMailQueryL: aTelNumber = %S", &aTelNumber ); |
|
277 __PHSLOGSTRING1("[PHS] CPsetCallDiverting::VoiceMailQueryL: retValue = %d", retValue ); |
|
278 |
|
279 if ( retValue == KErrNotFound ) |
|
280 { |
|
281 vmbxNrChanged = vmbxConnection.QueryNumberL( EVmbxNotDefinedQuery, aTelNumber ); |
|
282 } |
|
283 else if ( retValue != KErrNone ) |
|
284 { |
|
285 //Problem with vmbx application, better leave. |
|
286 User::Leave( retValue ); |
|
287 } |
|
288 if ( !vmbxNrChanged ) |
|
289 { |
|
290 User::Leave( KErrCancel ); |
|
291 } |
|
292 CleanupStack::PopAndDestroy(); // vmbxConnection |
|
293 |
|
294 __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::VoiceMailQueryL" ); |
|
295 } |
|
296 |
|
297 // --------------------------------------------------------------------------- |
|
298 // Queries for voice mail box number |
|
299 // --------------------------------------------------------------------------- |
|
300 // |
|
301 EXPORT_C void CPsetCallDiverting::VideoMailQueryL( TDes& aTelNumber ) |
|
302 { |
|
303 __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::VideoMailQueryL" ); |
|
304 RVmbxNumber vmbxConnection; |
|
305 TBool vmbxNrChanged = ETrue; |
|
306 TInt retValue = OpenVideoMailboxLC( aTelNumber, vmbxConnection ); |
|
307 __PHSLOGSTRING1("[PHS] CPsetCallDiverting::VideoMailQueryL: aTelNumber = %S", &aTelNumber ); |
|
308 __PHSLOGSTRING1("[PHS] CPsetCallDiverting::VideoMailQueryL: retValue = %d", retValue ); |
|
309 |
|
310 if ( retValue == KErrNotFound ) |
|
311 { |
|
312 vmbxNrChanged = vmbxConnection.QueryVideoMbxNumberL( EVmbxNotDefinedQuery, aTelNumber ); |
|
313 } |
|
314 else if ( retValue != KErrNone ) |
|
315 { |
|
316 //Problem with vmbx application, better leave. |
|
317 User::Leave( retValue ); |
|
318 } |
|
319 if ( !vmbxNrChanged ) |
|
320 { |
|
321 User::Leave( KErrCancel ); |
|
322 } |
|
323 CleanupStack::PopAndDestroy(); // vmbxConnection |
|
324 |
|
325 __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::VideoMailQueryL" ); |
|
326 } |
|
327 |
|
328 // --------------------------------------------------------------------------- |
|
329 // Opens Vmbx. Leaves vmbx to the stack. |
|
330 // --------------------------------------------------------------------------- |
|
331 // |
|
332 TInt CPsetCallDiverting::OpenVideoMailboxLC( TDes& aTelNumber, RVmbxNumber& aVmbx ) |
|
333 { |
|
334 __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::OpenVideoMailboxLC" ); |
|
335 User::LeaveIfError( aVmbx.Open( iPhone ) ); |
|
336 CleanupClosePushL( aVmbx ); |
|
337 __PHSLOGSTRING("[PHS]<-- CPsetCallDiverting::OpenVideoMailboxLC" ); |
|
338 return aVmbx.GetVideoMbxNumber( aTelNumber ); |
|
339 } |
|
340 |
|
341 // End of File |