|
1 /* |
|
2 * Copyright (c) 2002 - 2005 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: |
|
15 * Static class to help mtm service queries. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <e32base.h> |
|
24 #include <bldvariant.hrh> // For feature flags |
|
25 #include <msvuids.h> // KUidMsvServiceEntry |
|
26 #include <data_caging_path_literals.hrh> // KDC_RESOURCE_FILES_DIR |
|
27 |
|
28 #include <msvapi.h> |
|
29 #include <msvstd.hrh> |
|
30 #include <msvids.h> |
|
31 #include <mtclreg.h> // CClientMtmRegistry |
|
32 #include <muiu_internal.rsg> |
|
33 #include <bautils.h> |
|
34 #include <AknPhoneNumberGrouping.h> // CAknPhoneNumberGrouping |
|
35 #include "MsgOperationWait.h" // CMsgOperationWait |
|
36 #include <muiumsvuiserviceutilitiesinternal.h> |
|
37 #include "MuiuCallCmd.h" |
|
38 #include "MuiuSendKeyAcceptingQueryDialog.h" |
|
39 #include "MuiuListQueryDialog.h" // CMuiuListQueryDialog |
|
40 #include "MuiuEmailTools.h" |
|
41 #include <centralrepository.h> // link against centralrepository.lib |
|
42 #include <messaginginternalcrkeys.h> // for Central Repository keys |
|
43 #include <CoreApplicationUIsSDKCRKeys.h> |
|
44 #include <telconfigcrkeys.h> // KCRUidTelConfiguration,KTelMatchDigits |
|
45 #include <mmsgenutils.h> |
|
46 #include <msgvoipextension.h> |
|
47 #include <MuiuMsvUiServiceUtilities.h> // MsvUiServiceUtilities |
|
48 #include <featmgr.h> |
|
49 #include <MessagingDomainCRKeys.h> |
|
50 #include <SendUiConsts.h> |
|
51 #include <mtudreg.h> |
|
52 #include <miutset.h> |
|
53 #include <SendUiConsts.h> |
|
54 |
|
55 // CONSTANTS |
|
56 const TInt KDefaultParamValueLength = -1; // Default aCompareLength parameter value |
|
57 // in ComparePhoneNumberL method |
|
58 const TInt KDefaultCompareLength = 7; // Used in ComparePhoneNumberL method |
|
59 // if aCompareLength parameter has default value |
|
60 const TInt KEqualCompareValue = 0; // CompareF returns 0 if phone numbers are equal |
|
61 const TInt KFirstItemInList = 0; |
|
62 const TInt KHotswapWaitInterval = 1000000; // 1 second |
|
63 const TInt KHotswapWaitMax = 7; // 7 number of turns(cycle time KHotswapWaitInterval) |
|
64 _LIT( KDirAndMuiuResFileName,"muiu_internal.rsc" ); |
|
65 |
|
66 |
|
67 |
|
68 // --------------------------------------------------------- |
|
69 // MsvUiServiceUtilitiesInternal::CallToSenderQueryL |
|
70 // |
|
71 // Used when asking from user if calling to sender of the message and dial |
|
72 // if user select "Yes". Check immediately if phone number is valid. If phone number |
|
73 // is not valid then return EFalse and doesn't do nothing. |
|
74 // If parameter "aDialWithoutQueries" is true then call immediately to sender of the message |
|
75 // and doesn't ask nothing from user before it. |
|
76 // Returns: Returns ETrue if the phone number was valid. |
|
77 // |
|
78 // --------------------------------------------------------- |
|
79 // |
|
80 EXPORT_C TBool MsvUiServiceUtilitiesInternal::CallToSenderQueryL( const TDesC& aNumber, |
|
81 const TDesC& aName, |
|
82 TBool aDialWithoutQueries ) |
|
83 { |
|
84 TBool validNumber( EFalse ); //Is phone number valid or not |
|
85 |
|
86 HBufC* buf = HBufC::NewLC( aNumber.Length() ); |
|
87 TPtr bufNumberPtr = buf->Des(); |
|
88 bufNumberPtr = aNumber; |
|
89 validNumber = CommonPhoneParser::ParsePhoneNumber( bufNumberPtr, |
|
90 CommonPhoneParser::EPhoneClientNumber ); |
|
91 if( validNumber ) |
|
92 { |
|
93 if( aDialWithoutQueries ) |
|
94 { |
|
95 //Start dialing and open Calling dialog |
|
96 CMuiuCallCmd* cMuiuCallCmdPtr = CMuiuCallCmd::NewL(); |
|
97 cMuiuCallCmdPtr->ExecuteLD( bufNumberPtr, aName ); |
|
98 } |
|
99 else |
|
100 { |
|
101 CMuiuSendKeyAcceptingQueryDialog* dlg = |
|
102 CMuiuSendKeyAcceptingQueryDialog::NewL( aNumber, |
|
103 aName ); |
|
104 if( dlg->ExecuteLD( R_MUIU_CALLBACK_QUERY ) ) |
|
105 { |
|
106 //Start dialing and open Calling dialog |
|
107 CMuiuCallCmd* cMuiuCallCmdPtr = CMuiuCallCmd::NewL(); |
|
108 cMuiuCallCmdPtr->ExecuteLD( bufNumberPtr, aName ); |
|
109 } |
|
110 } |
|
111 } |
|
112 CleanupStack::PopAndDestroy( buf ); |
|
113 return validNumber; |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------- |
|
117 // MsvUiServiceUtilitiesInternal::CallServiceL |
|
118 // |
|
119 // --------------------------------------------------------- |
|
120 // |
|
121 EXPORT_C TBool MsvUiServiceUtilitiesInternal::CallServiceL( |
|
122 const TDesC& aSenderNumber, |
|
123 const TDesC& aSenderName, |
|
124 const TDesC& aNumberInFocus, |
|
125 CEikonEnv* aEnv ) |
|
126 { |
|
127 TBool validNumber( EFalse ); |
|
128 |
|
129 // Is list query needed |
|
130 if ( aNumberInFocus.Length() && aSenderNumber.Length() ) |
|
131 { |
|
132 // Two numbers, list query is needed |
|
133 HBufC* buf = HBufC::NewLC( aNumberInFocus.Length() ); |
|
134 TPtr bufNumberPtr = buf->Des(); |
|
135 bufNumberPtr = aNumberInFocus; |
|
136 CommonPhoneParser::ParsePhoneNumber( bufNumberPtr, |
|
137 CommonPhoneParser::EPhoneClientNumber ); |
|
138 HBufC* groupedNumber = CAknPhoneNumberGrouping::CreateGroupedPhoneNumberL( bufNumberPtr ); |
|
139 CleanupStack::PushL( groupedNumber ); |
|
140 TPtr groupedNumberPtr = groupedNumber->Des(); |
|
141 |
|
142 // Adding MUIU's resource-file |
|
143 TParse parse; |
|
144 parse.Set(KDirAndMuiuResFileName, &KDC_RESOURCE_FILES_DIR, NULL); |
|
145 TFileName resourceFile(parse.FullName()); |
|
146 |
|
147 if ( !aEnv ) |
|
148 { |
|
149 aEnv = CEikonEnv::Static(); |
|
150 } |
|
151 BaflUtils::NearestLanguageFile( aEnv->FsSession(), resourceFile ); |
|
152 TInt offset = aEnv->AddResourceFileL( resourceFile ); |
|
153 |
|
154 // TRAPD to be sure that resource-file gets also deleted |
|
155 TInt index = 0; |
|
156 TInt commandId( 0 ); |
|
157 TRAPD( err,commandId = LaunchDialogL( groupedNumberPtr, &index ) ); |
|
158 // Removing MUIU's resource-file |
|
159 aEnv->DeleteResourceFile( offset ); |
|
160 CleanupStack::PopAndDestroy( 2, buf ); //groupedNumber, buf |
|
161 User::LeaveIfError( err ); |
|
162 if ( ( commandId == EAknSoftkeyCall ) || ( commandId == EEikBidOk ) ) |
|
163 { |
|
164 if ( index == 0 ) |
|
165 {// number in focus |
|
166 validNumber = CallToSenderQueryL( aNumberInFocus, KNullDesC ); |
|
167 } |
|
168 else |
|
169 {// back to sender |
|
170 validNumber = CallToSenderQueryL( aSenderNumber, aSenderName ); |
|
171 } |
|
172 } |
|
173 } |
|
174 else if ( aSenderNumber.Length() ) |
|
175 { |
|
176 // Sender only, list query is not needed |
|
177 |
|
178 // Launch the normal call query |
|
179 validNumber = CallToSenderQueryL( aSenderNumber, aSenderName, EFalse ); |
|
180 } |
|
181 else if ( aNumberInFocus.Length() ) |
|
182 { |
|
183 // Focused number only, list query is not needed |
|
184 |
|
185 // Launch the normal call query |
|
186 validNumber = CallToSenderQueryL( aNumberInFocus, KNullDesC(), EFalse ); |
|
187 } |
|
188 else |
|
189 { |
|
190 // No numbers |
|
191 validNumber = EFalse; |
|
192 } |
|
193 |
|
194 return validNumber; |
|
195 } |
|
196 |
|
197 // --------------------------------------------------------- |
|
198 // MsvUiServiceUtilitiesInternal::InternetCallToSenderQueryL |
|
199 // |
|
200 // Used when asking from user if calling to sender of the message and dial |
|
201 // if user select "Yes". Assumes allways that Internet call number is valid and |
|
202 // ETrue returned. |
|
203 // If parameter "aDialWithoutQueries" is true then call immediately to sender of |
|
204 // the message and doesn't ask nothing from user before it. |
|
205 // Returns: Returns ETrue. |
|
206 // |
|
207 // --------------------------------------------------------- |
|
208 // |
|
209 EXPORT_C TBool MsvUiServiceUtilitiesInternal::InternetCallToSenderQueryL( const TDesC& aNumber, |
|
210 const TDesC& aName, |
|
211 TBool aDialWithoutQueries ) |
|
212 { |
|
213 //If the SIP URI is not valid then check is the selected number valid CS number. |
|
214 if( aDialWithoutQueries ) |
|
215 { |
|
216 //Start dialing and open Calling dialog |
|
217 CMuiuCallCmd* cMuiuCallCmdPtr = CMuiuCallCmd::NewL(); |
|
218 cMuiuCallCmdPtr->ExecuteLD( aNumber, aName, ETrue ); |
|
219 } |
|
220 else |
|
221 { |
|
222 CMuiuSendKeyAcceptingQueryDialog* dlg = CMuiuSendKeyAcceptingQueryDialog::NewL( aNumber, |
|
223 aName ); |
|
224 if( dlg->ExecuteLD( R_MUIU_CALLBACK_QUERY ) ) |
|
225 { |
|
226 //Start dialing and open Calling dialog |
|
227 CMuiuCallCmd* cMuiuCallCmdPtr = CMuiuCallCmd::NewL(); |
|
228 cMuiuCallCmdPtr->ExecuteLD( aNumber, aName, ETrue ); |
|
229 } |
|
230 } |
|
231 return ETrue; |
|
232 } |
|
233 |
|
234 // --------------------------------------------------------- |
|
235 // MsvUiServiceUtilitiesInternal::InternetCallServiceL |
|
236 // |
|
237 // --------------------------------------------------------- |
|
238 // |
|
239 EXPORT_C TBool MsvUiServiceUtilitiesInternal::InternetCallServiceL( |
|
240 const TDesC& aSenderNumber, |
|
241 const TDesC& aSenderName, |
|
242 const TDesC& aNumberInFocus, |
|
243 CEikonEnv* aEnv ) |
|
244 { |
|
245 TBool validNumber( EFalse ); |
|
246 |
|
247 // Is list query needed |
|
248 if ( aNumberInFocus.Length() && aSenderNumber.Length() ) |
|
249 { |
|
250 // Two numbers, list query is needed |
|
251 HBufC* buf = HBufC::NewLC( aNumberInFocus.Length() ); |
|
252 TPtr bufNumberPtr = buf->Des(); |
|
253 bufNumberPtr = aNumberInFocus; |
|
254 CommonPhoneParser::ParsePhoneNumber( bufNumberPtr, |
|
255 CommonPhoneParser::EPhoneClientNumber ); |
|
256 HBufC* groupedNumber = CAknPhoneNumberGrouping::CreateGroupedPhoneNumberL( bufNumberPtr ); |
|
257 CleanupStack::PushL( groupedNumber ); |
|
258 TPtr groupedNumberPtr = groupedNumber->Des(); |
|
259 |
|
260 // Adding MUIU's resource-file |
|
261 TParse parse; |
|
262 parse.Set(KDirAndMuiuResFileName, &KDC_RESOURCE_FILES_DIR, NULL); |
|
263 TFileName resourceFile(parse.FullName()); |
|
264 |
|
265 if ( !aEnv ) |
|
266 { |
|
267 aEnv = CEikonEnv::Static(); |
|
268 } |
|
269 BaflUtils::NearestLanguageFile( aEnv->FsSession(), resourceFile ); |
|
270 TInt offset = aEnv->AddResourceFileL( resourceFile ); |
|
271 |
|
272 // TRAPD to be sure that resource-file gets also deleted |
|
273 TInt index = 0; |
|
274 TInt commandId( 0 ); |
|
275 TRAPD( err,commandId = LaunchDialogL( groupedNumberPtr, &index ) ); |
|
276 // Removing MUIU's resource-file |
|
277 aEnv->DeleteResourceFile( offset ); |
|
278 CleanupStack::PopAndDestroy( 2, buf ); //groupedNumber, buf |
|
279 User::LeaveIfError( err ); |
|
280 if ( ( commandId == EAknSoftkeyCall ) || ( commandId == EEikBidOk ) ) |
|
281 { |
|
282 if ( index == 0 ) |
|
283 {// number in focus |
|
284 validNumber = InternetCallToSenderQueryL( aNumberInFocus, KNullDesC ); |
|
285 } |
|
286 else |
|
287 { |
|
288 // call CS call to sender |
|
289 validNumber = CallToSenderQueryL( aSenderNumber, aSenderName ); |
|
290 } |
|
291 } |
|
292 } |
|
293 else if ( aSenderNumber.Length() ) |
|
294 { |
|
295 // Sender only, list query is not needed |
|
296 |
|
297 // Launch the normal call query |
|
298 validNumber = InternetCallToSenderQueryL( aSenderNumber, aSenderName, EFalse ); |
|
299 } |
|
300 else if ( aNumberInFocus.Length() ) |
|
301 { |
|
302 // Focused number only, list query is not needed |
|
303 |
|
304 // Launch the normal call query |
|
305 validNumber = InternetCallToSenderQueryL( aNumberInFocus, KNullDesC(), EFalse ); |
|
306 } |
|
307 else |
|
308 { |
|
309 // No numbers |
|
310 validNumber = EFalse; |
|
311 } |
|
312 |
|
313 return validNumber; |
|
314 } |
|
315 |
|
316 |
|
317 // ---------------------------------------------------- |
|
318 // MsvUiServiceUtilitiesInternal::ChangeMessageStoreToPhoneL |
|
319 // ---------------------------------------------------- |
|
320 EXPORT_C void MsvUiServiceUtilitiesInternal::ChangeMessageStoreToPhoneL( CMsvSession& aSession ) |
|
321 { |
|
322 //check if message server is busy |
|
323 TInt outstanding = 1; |
|
324 for ( TInt jj = 0; jj < KHotswapWaitMax && outstanding; jj++ ) |
|
325 { |
|
326 outstanding = aSession.OutstandingOperationsL(); |
|
327 if ( outstanding == 0 ) |
|
328 { |
|
329 // check to see if any mailboxes are open - |
|
330 // otherwise we could miss client side operations |
|
331 CMsvEntry* root=CMsvEntry::NewL( aSession, KMsvRootIndexEntryIdValue, |
|
332 TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) ); |
|
333 CleanupStack::PushL( root ); |
|
334 CMsvEntrySelection* sel=root->ChildrenWithTypeL( KUidMsvServiceEntry ); |
|
335 CleanupStack::PushL( sel ); |
|
336 const TMsvEntry* tentry=NULL; |
|
337 for ( TInt cc=sel->Count(); --cc>=0 && !outstanding; ) |
|
338 { |
|
339 tentry=&( root->ChildDataL( ( *sel )[cc]) ); |
|
340 if ( tentry->Connected() ) |
|
341 { |
|
342 outstanding++; |
|
343 } |
|
344 } |
|
345 |
|
346 CleanupStack::PopAndDestroy( 2, root ); //sel, root |
|
347 } |
|
348 if ( outstanding > 0 ) |
|
349 { |
|
350 User::After( KHotswapWaitInterval ); //wait one second |
|
351 } |
|
352 } |
|
353 |
|
354 CMsgOperationWait* waiter = CMsgOperationWait::NewLC(); |
|
355 CMsvOperation* op = aSession.ChangeDriveL( EDriveC, waiter->iStatus ); |
|
356 CleanupStack::PushL( op ); |
|
357 waiter->Start(); |
|
358 CleanupStack::PopAndDestroy( 2, waiter ); //waiter, op |
|
359 } |
|
360 |
|
361 |
|
362 // ---------------------------------------------------- |
|
363 // MsvUiServiceUtilitiesInternal::MmcDriveInfoL |
|
364 // ---------------------------------------------------- |
|
365 EXPORT_C TBool MsvUiServiceUtilitiesInternal::MmcDriveInfoL( CMsvSession& aSession ) |
|
366 { |
|
367 return aSession.MessageStoreDrivePresentL(); |
|
368 } |
|
369 |
|
370 // --------------------------------------------------------- |
|
371 // MsvUiServiceUtilitiesInternal::DefaultServiceForMTML |
|
372 // --------------------------------------------------------- |
|
373 // |
|
374 EXPORT_C TMsvId MsvUiServiceUtilitiesInternal::DefaultServiceForMTML( |
|
375 CMsvSession& aSession, |
|
376 TUid aMtm, |
|
377 TBool aFindFirstServiceIfNoDefault ) |
|
378 { |
|
379 FeatureManager::InitializeLibL(); |
|
380 TBool selectableEmail = |
|
381 FeatureManager::FeatureSupported( KFeatureIdSelectableEmail ); |
|
382 TBool emailFramework = |
|
383 FeatureManager::FeatureSupported( KFeatureIdFfEmailFramework ); |
|
384 FeatureManager::UnInitializeLib(); |
|
385 TMsvId serviceId = KMsvUnknownServiceIndexEntryId; |
|
386 |
|
387 // Default mailbox is fetched seperately by using the API provided by symbian |
|
388 // If selectableEmail feature is on, get the default email |
|
389 // account from the central repository |
|
390 if ( selectableEmail && !emailFramework && MuiuEmailTools::IsMailMtm( aMtm ) ) |
|
391 { |
|
392 serviceId = MuiuEmailTools::DefaultSendingMailboxL( aSession, aMtm ); |
|
393 |
|
394 if ( serviceId == KMsvUnknownServiceIndexEntryId ) |
|
395 { |
|
396 CRepository* repository = NULL; |
|
397 TRAPD( ret, repository = CRepository::NewL( |
|
398 KCRUidSelectableDefaultEmailSettings ) ); |
|
399 CleanupStack::PushL( repository ); |
|
400 |
|
401 if ( ret == KErrNone ) |
|
402 { |
|
403 TInt entryId; |
|
404 if ( repository->Get( KSelectableDefaultMailAccount , |
|
405 entryId ) != KErrNone ) |
|
406 { |
|
407 serviceId = KMsvUnknownServiceIndexEntryId; |
|
408 } |
|
409 else |
|
410 { |
|
411 serviceId = entryId; |
|
412 } |
|
413 } |
|
414 |
|
415 CleanupStack::PopAndDestroy(); |
|
416 } |
|
417 |
|
418 // Bug workaround, validate that the mailbox exist |
|
419 TMsvEntry mailbox; |
|
420 TMsvId dummyId; |
|
421 |
|
422 if ( aSession.GetEntry( serviceId, dummyId, mailbox ) != KErrNone ) |
|
423 { |
|
424 serviceId = KMsvUnknownServiceIndexEntryId; |
|
425 aFindFirstServiceIfNoDefault = ETrue; |
|
426 } |
|
427 } |
|
428 // if selectable email feature is off, Default mailbox is fetched |
|
429 // seperately by using the API provided by symbian |
|
430 else if ( !selectableEmail && MuiuEmailTools::IsMailMtm( aMtm, ETrue ) ) |
|
431 { |
|
432 // Get service id, which will always be validated |
|
433 serviceId = MuiuEmailTools::DefaultSendingMailboxL( aSession, aMtm ); |
|
434 |
|
435 aFindFirstServiceIfNoDefault &= |
|
436 ( serviceId == KMsvUnknownServiceIndexEntryId ); |
|
437 } |
|
438 // Other mtm's use this path |
|
439 else |
|
440 { |
|
441 CClientMtmRegistry* registry = CClientMtmRegistry::NewL( aSession ); |
|
442 CleanupStack::PushL( registry ); |
|
443 CBaseMtm* mtm = registry->NewMtmL( aMtm ); |
|
444 CleanupStack::PushL( mtm ); |
|
445 TRAPD( error, serviceId = mtm->DefaultServiceL() ); |
|
446 if( error != KErrNone ) |
|
447 { |
|
448 serviceId = KMsvUnknownServiceIndexEntryId; |
|
449 } |
|
450 CleanupStack::PopAndDestroy( 2 ); // registry, mtm |
|
451 registry = NULL; |
|
452 mtm = NULL; |
|
453 } |
|
454 |
|
455 if ( aFindFirstServiceIfNoDefault && |
|
456 serviceId == KMsvUnknownServiceIndexEntryId ) |
|
457 { |
|
458 CMsvEntry* entry = aSession.GetEntryL( KMsvRootIndexEntryIdValue ); |
|
459 CleanupStack::PushL( entry ); |
|
460 CMsvEntrySelection* sel = entry->ChildrenWithMtmL( aMtm ); |
|
461 CleanupStack::PopAndDestroy( entry ); |
|
462 CleanupStack::PushL( sel ); |
|
463 entry = NULL; |
|
464 |
|
465 // Check if mail mtm |
|
466 if ( MuiuEmailTools::IsMailMtm( aMtm, ETrue ) ) |
|
467 { |
|
468 // Mail services needs to be validated, provide the array |
|
469 // of services for validation |
|
470 serviceId = MuiuEmailTools::FindFirstValidMailboxL( |
|
471 aSession, *sel, aMtm ); |
|
472 } |
|
473 else |
|
474 { |
|
475 // Just take the first available service from the list |
|
476 if ( sel->Count() > 0 ) |
|
477 { |
|
478 serviceId = sel->At( 0 ); |
|
479 } |
|
480 } |
|
481 |
|
482 CleanupStack::PopAndDestroy( sel ); |
|
483 sel = NULL; |
|
484 } |
|
485 |
|
486 return serviceId; |
|
487 } |
|
488 |
|
489 |
|
490 // --------------------------------------------------------- |
|
491 // MsvUiServiceUtilitiesInternal::SetDefaultServiceForMTML |
|
492 // --------------------------------------------------------- |
|
493 // |
|
494 EXPORT_C void MsvUiServiceUtilitiesInternal::SetDefaultServiceForMTML( |
|
495 CMsvSession& aSession, |
|
496 TUid aMtm, |
|
497 TMsvId aServiceId ) |
|
498 { |
|
499 FeatureManager::InitializeLibL(); |
|
500 if ( MuiuEmailTools::IsMailMtm( aMtm ) ) |
|
501 { |
|
502 TMsvEntry mailbox; |
|
503 TInt error = MuiuEmailTools::GetMailboxServiceId( |
|
504 aSession, mailbox, aServiceId, ETrue ); |
|
505 |
|
506 if ( error == KErrNone ) |
|
507 { |
|
508 MuiuEmailTools::SetDefaultSendingMailboxL( |
|
509 mailbox.Id() ); |
|
510 } |
|
511 } |
|
512 else if ( FeatureManager::FeatureSupported( KFeatureIdSelectableEmail ) |
|
513 && aMtm != KSenduiMtmSyncMLEmailUid ) |
|
514 { |
|
515 TMsvEntry entry; |
|
516 TMsvId serviceId; |
|
517 |
|
518 User::LeaveIfError( aSession.GetEntry( |
|
519 aServiceId, serviceId, entry ) ); |
|
520 |
|
521 TBool appendEmail = EFalse; |
|
522 |
|
523 if( entry.Visible() ) |
|
524 { |
|
525 appendEmail = ETrue; |
|
526 } |
|
527 else |
|
528 { |
|
529 CMtmUiDataRegistry* uiRegistry = |
|
530 CMtmUiDataRegistry::NewL( aSession ); |
|
531 CleanupStack::PushL( uiRegistry ); |
|
532 if ( uiRegistry->IsPresent( entry.iMtm ) && |
|
533 uiRegistry->IsPresent( KUidMsgTypePOP3 ) ) |
|
534 { |
|
535 if ( uiRegistry->TechnologyTypeUid( entry.iMtm ) == |
|
536 KSenduiTechnologyMailUid ) |
|
537 { |
|
538 appendEmail = ETrue; |
|
539 } |
|
540 } |
|
541 CleanupStack::PopAndDestroy( uiRegistry ); |
|
542 } |
|
543 |
|
544 if ( appendEmail || (MuiuEmailTools::IsMailMtm( aMtm ) ) ) |
|
545 { |
|
546 CRepository* repository = NULL; |
|
547 TRAPD( ret, repository = CRepository::NewL( |
|
548 KCRUidSelectableDefaultEmailSettings ) ); |
|
549 CleanupStack::PushL( repository ); |
|
550 |
|
551 if ( ret == KErrNone ) |
|
552 { |
|
553 TInt entryId = entry.Id(); |
|
554 if ( entry.iMtm == KSenduiMtmPop3Uid || |
|
555 entry.iMtm == KSenduiMtmImap4Uid ) |
|
556 { |
|
557 entryId = entry.iRelatedId; |
|
558 } |
|
559 repository->Set( KSelectableDefaultMailAccount , entryId ); |
|
560 } |
|
561 CleanupStack::PopAndDestroy(); // repository |
|
562 } |
|
563 } |
|
564 else |
|
565 { |
|
566 CClientMtmRegistry* registry = CClientMtmRegistry::NewL( aSession ); |
|
567 CleanupStack::PushL( registry ); |
|
568 CBaseMtm* mtm = registry->NewMtmL( aMtm ); |
|
569 CleanupStack::PushL( mtm ); |
|
570 mtm->ChangeDefaultServiceL( aServiceId ); |
|
571 CleanupStack::PopAndDestroy( mtm ); |
|
572 CleanupStack::PopAndDestroy( registry ); |
|
573 } |
|
574 |
|
575 FeatureManager::UnInitializeLib(); |
|
576 } |
|
577 |
|
578 |
|
579 // --------------------------------------------------------- |
|
580 // MsvUiServiceUtilitiesInternal::IsPhoneOfflineL |
|
581 // --------------------------------------------------------- |
|
582 // |
|
583 EXPORT_C TBool MsvUiServiceUtilitiesInternal::IsPhoneOfflineL() |
|
584 { |
|
585 TInt connAllowed ( 1 ); |
|
586 CRepository* repository ( CRepository::NewL( KCRUidCoreApplicationUIs ) ); |
|
587 TInt err = repository->Get( KCoreAppUIsNetworkConnectionAllowed, connAllowed ); |
|
588 delete repository; |
|
589 repository = NULL; |
|
590 if ( !err && !connAllowed ) |
|
591 { |
|
592 return ETrue; |
|
593 } |
|
594 else |
|
595 { |
|
596 return EFalse; |
|
597 } |
|
598 } |
|
599 |
|
600 // --------------------------------------------------------- |
|
601 // MsvUiServiceUtilitiesInternal::InternetOrVoiceCallServiceL |
|
602 // --------------------------------------------------------- |
|
603 // |
|
604 EXPORT_C TBool MsvUiServiceUtilitiesInternal::InternetOrVoiceCallServiceL( |
|
605 const CMsgVoIPExtension& aVoIPExtension, |
|
606 const TDesC& aSenderAddress, |
|
607 const TDesC& aSenderName, |
|
608 const TDesC& aAddressInFocus, |
|
609 TBool aDialWithoutQueries, |
|
610 CEikonEnv* aEnv ) |
|
611 { |
|
612 if ( !aEnv ) |
|
613 { |
|
614 aEnv = CEikonEnv::Static(); |
|
615 } |
|
616 return InternetOrVoiceCallServiceL( *aEnv, |
|
617 aVoIPExtension, |
|
618 aSenderAddress, |
|
619 aSenderName, |
|
620 ResolveAddressTypeL( aSenderAddress ), |
|
621 aAddressInFocus, |
|
622 ResolveAddressTypeL( aAddressInFocus ), |
|
623 aDialWithoutQueries ); |
|
624 } |
|
625 |
|
626 // --------------------------------------------------------- |
|
627 // MsvUiServiceUtilitiesInternal::InternetOrVoiceCallServiceL |
|
628 // --------------------------------------------------------- |
|
629 // |
|
630 EXPORT_C TBool MsvUiServiceUtilitiesInternal::InternetOrVoiceCallServiceL( |
|
631 CEikonEnv& aEnv, |
|
632 const CMsgVoIPExtension& aVoIPExtension, |
|
633 const TDesC& aSenderAddress, |
|
634 const TDesC& aSenderName, |
|
635 TMuiuAddressType aSenderAddressType, |
|
636 const TDesC& aAddressInFocus, |
|
637 TMuiuAddressType aAddressInFocusTypeType, |
|
638 TBool aDialWithoutQueries ) |
|
639 { |
|
640 FeatureManager::InitializeLibL(); |
|
641 TBool VoIPFeatureSupport = EFalse; |
|
642 //checking If VOIP is enabled |
|
643 if( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) ) |
|
644 { |
|
645 VoIPFeatureSupport = ETrue; |
|
646 } |
|
647 FeatureManager::UnInitializeLib(); |
|
648 |
|
649 if ( aSenderAddressType || aAddressInFocusTypeType ) |
|
650 { |
|
651 // - if voip number is focused then voip call should be possible |
|
652 // even though preferred telephony is set to CS |
|
653 // - Preferred tel not supported in Sawfish |
|
654 if((VoIPFeatureSupport) |
|
655 &&( aVoIPExtension.VoIPProfilesExistL() |
|
656 && aAddressInFocusTypeType == EMuiuAddressTypeEmail) ) |
|
657 { |
|
658 if ( aAddressInFocusTypeType ) |
|
659 { |
|
660 return MsvUiServiceUtilitiesInternal::InternetCallServiceL( |
|
661 aSenderAddress, |
|
662 aSenderName, |
|
663 aAddressInFocus, |
|
664 &aEnv ); |
|
665 } |
|
666 else if ( aSenderAddressType ) |
|
667 { |
|
668 return MsvUiServiceUtilitiesInternal::InternetCallToSenderQueryL( |
|
669 aSenderAddress, |
|
670 aSenderName, |
|
671 aDialWithoutQueries ); |
|
672 } |
|
673 } |
|
674 if((!VoIPFeatureSupport) |
|
675 &&(aVoIPExtension.IsPreferredTelephonyVoIP() |
|
676 && aVoIPExtension.VoIPProfilesExistL()) ) |
|
677 { |
|
678 if ( aAddressInFocusTypeType ) |
|
679 { |
|
680 return MsvUiServiceUtilitiesInternal::InternetCallServiceL( |
|
681 aSenderAddress, |
|
682 aSenderName, |
|
683 aAddressInFocus, |
|
684 &aEnv ); |
|
685 } |
|
686 else if ( aSenderAddressType ) |
|
687 { |
|
688 return MsvUiServiceUtilitiesInternal::InternetCallToSenderQueryL( |
|
689 aSenderAddress, |
|
690 aSenderName, |
|
691 aDialWithoutQueries ); |
|
692 } |
|
693 } |
|
694 else // as first choice try voice call |
|
695 { |
|
696 // Voice call is not possible with email address |
|
697 TPtrC senderAddress = aSenderAddress; |
|
698 TPtrC senderName = aSenderName; |
|
699 TPtrC focusAddress = aAddressInFocus; |
|
700 |
|
701 if ( aSenderAddressType != EMuiuAddressTypePhoneNumber ) |
|
702 { |
|
703 senderAddress.Set( KNullDesC( ) ); |
|
704 senderName.Set( KNullDesC( ) ); |
|
705 } |
|
706 if ( aAddressInFocusTypeType != EMuiuAddressTypePhoneNumber ) |
|
707 { |
|
708 focusAddress.Set( KNullDesC( ) ); |
|
709 } |
|
710 |
|
711 if ( aAddressInFocusTypeType == EMuiuAddressTypePhoneNumber ) |
|
712 { |
|
713 return MsvUiServiceUtilitiesInternal::CallServiceL( |
|
714 senderAddress, |
|
715 senderName, |
|
716 focusAddress, |
|
717 &aEnv ); |
|
718 } |
|
719 else if ( aSenderAddressType == EMuiuAddressTypePhoneNumber ) |
|
720 { |
|
721 return MsvUiServiceUtilitiesInternal::CallToSenderQueryL( |
|
722 senderAddress, |
|
723 senderName, |
|
724 aDialWithoutQueries ); |
|
725 } |
|
726 // else - voice call was not possible. VOIP could still be possible |
|
727 // but it is not tried. After future feature 'contact matching' the code |
|
728 // would change anyway |
|
729 } |
|
730 } |
|
731 return EFalse; |
|
732 } |
|
733 |
|
734 |
|
735 // --------------------------------------------------------- |
|
736 // MsvUiServiceUtilitiesInternal::ResolveAddressTypeL |
|
737 // --------------------------------------------------------- |
|
738 // |
|
739 EXPORT_C TMuiuAddressType MsvUiServiceUtilitiesInternal::ResolveAddressTypeL( |
|
740 const TDesC& aAddress, |
|
741 CommonPhoneParser::TPhoneNumberType aDefaultPhoneNumberType ) |
|
742 { |
|
743 TMuiuAddressType addressType = CommonPhoneParser::IsValidPhoneNumber( |
|
744 aAddress, |
|
745 aDefaultPhoneNumberType ) ? EMuiuAddressTypePhoneNumber : EMuiuAddressTypeNone; |
|
746 if ( addressType == EMuiuAddressTypeNone ) |
|
747 { |
|
748 addressType = MsvUiServiceUtilities::IsValidEmailAddressL( aAddress ) ? |
|
749 EMuiuAddressTypeEmail : EMuiuAddressTypeNone; |
|
750 } |
|
751 return addressType; |
|
752 } |
|
753 |
|
754 |
|
755 // --------------------------------------------------------- |
|
756 // MsvUiServiceUtilitiesInternal::LaunchDialogL |
|
757 // |
|
758 // --------------------------------------------------------- |
|
759 // |
|
760 TInt MsvUiServiceUtilitiesInternal::LaunchDialogL( const TPtr aGroupedNumberPtr, TInt* aIndex ) |
|
761 { |
|
762 TInt commandId( 0 ); |
|
763 CMuiuListQueryDialog* dlg = new (ELeave) CMuiuListQueryDialog( aIndex ); |
|
764 dlg->PrepareLC( R_CALL_TO_SENDER_LIST_QUERY ); |
|
765 (( CDesCArrayFlat* )(( CTextListBoxModel* )dlg->ListBox()->Model())->ItemTextArray())->InsertL( KFirstItemInList, aGroupedNumberPtr ); |
|
766 commandId = dlg->RunLD(); |
|
767 return commandId; |
|
768 } |
|
769 |
|
770 // --------------------------------------------------------- |
|
771 // MsvUiServiceUtilitiesInternal::ConvertUtcToLocalTime |
|
772 // |
|
773 // --------------------------------------------------------- |
|
774 // |
|
775 EXPORT_C void MsvUiServiceUtilitiesInternal::ConvertUtcToLocalTime( TTime& aTime ) |
|
776 { |
|
777 TLocale locale; |
|
778 |
|
779 // Add time difference |
|
780 aTime += locale.UniversalTimeOffset(); |
|
781 if ( locale.QueryHomeHasDaylightSavingOn() ) |
|
782 { |
|
783 // and possible daylight saving time |
|
784 TTimeIntervalHours daylightSaving(1); |
|
785 aTime += daylightSaving; |
|
786 } |
|
787 } |
|
788 |
|
789 |
|
790 // --------------------------------------------------------- |
|
791 // MsvUiServiceUtilitiesInternal::ComparePhoneNumberL |
|
792 // |
|
793 // --------------------------------------------------------- |
|
794 // |
|
795 EXPORT_C TBool MsvUiServiceUtilitiesInternal::ComparePhoneNumberL( |
|
796 const TDesC& aNumber1, const TDesC& aNumber2, TInt aCompareLength ) |
|
797 { |
|
798 if ( aCompareLength == KDefaultParamValueLength ) |
|
799 { |
|
800 // default to 7 |
|
801 aCompareLength = KDefaultCompareLength; |
|
802 CRepository* repository = CRepository::NewL( KCRUidTelConfiguration ); |
|
803 repository->Get( KTelMatchDigits, aCompareLength ); |
|
804 delete repository; |
|
805 } |
|
806 HBufC* number1C = aNumber1.AllocLC(); |
|
807 HBufC* number2C = aNumber2.AllocLC(); |
|
808 TPtr number1 = number1C->Des(); |
|
809 TPtr number2 = number2C->Des(); |
|
810 |
|
811 // Remove "()- " from numbers. |
|
812 if ( !CommonPhoneParser::ParsePhoneNumber( |
|
813 number1, CommonPhoneParser::EPlainPhoneNumber ) ) |
|
814 { |
|
815 CleanupStack::PopAndDestroy( 2 ); // number1C, number2C |
|
816 return EFalse; |
|
817 } |
|
818 |
|
819 if ( !CommonPhoneParser::ParsePhoneNumber( |
|
820 number2, CommonPhoneParser::EPlainPhoneNumber ) ) |
|
821 { |
|
822 CleanupStack::PopAndDestroy( 2 ); // number1C, number2C |
|
823 return EFalse; |
|
824 } |
|
825 |
|
826 // Check if first char is "+" and remove it. |
|
827 // NOTE: Does not handle "#*pPwW" chars, these should cause |
|
828 // "incorrect recipient"-note already earlier. |
|
829 const TChar plus = '+'; |
|
830 |
|
831 TInt res = number1.Locate( plus ); |
|
832 if ( res != KErrNotFound ) |
|
833 { |
|
834 number1.Delete( res, 1 ); |
|
835 } |
|
836 |
|
837 res = number2.Locate( plus ); |
|
838 if ( res != KErrNotFound ) |
|
839 { |
|
840 number2.Delete( res, 1 ); |
|
841 } |
|
842 |
|
843 TInt number1Length = number1.Length(); |
|
844 TInt number2Length = number2.Length(); |
|
845 |
|
846 // Check length. |
|
847 |
|
848 // If both numbers are same length, do not truncate, but compare as is. |
|
849 // case: 040 1234567 and 050 1234567 are different! |
|
850 if ( number1Length != number2Length ) |
|
851 { |
|
852 // If longer than aCompareLength (default = 7) truncate from the beginning. |
|
853 // case: +358 50 1234567 and 050 1234567 are same! |
|
854 // TODO: +358 50 1234567 and 040 1234567 are still different! |
|
855 if ( number1Length > aCompareLength ) |
|
856 { |
|
857 number1.Delete( 0, number1Length - aCompareLength ); |
|
858 } |
|
859 |
|
860 if ( number2Length > aCompareLength ) |
|
861 { |
|
862 number2.Delete( 0, number2Length - aCompareLength ); |
|
863 } |
|
864 } |
|
865 |
|
866 TInt ret = number1.CompareF( number2 ); |
|
867 |
|
868 CleanupStack::PopAndDestroy( 2, number1C ); // number1C, number2C |
|
869 |
|
870 return ( ret == KEqualCompareValue ); |
|
871 } |
|
872 |
|
873 // ---------------------------------------------------------------------------- |
|
874 // MsvUiServiceUtilitiesInternal::OtherEmailMTMExistL() |
|
875 // ---------------------------------------------------------------------------- |
|
876 // |
|
877 EXPORT_C TBool MsvUiServiceUtilitiesInternal::OtherEmailMTMExistL( CMsvSession& aSession, TInt aMailbox ) |
|
878 { |
|
879 CMsvEntry* entry = aSession.GetEntryL( KMsvRootIndexEntryId ); |
|
880 CleanupStack::PushL( entry ); |
|
881 |
|
882 TInt cnt = entry->Count(); |
|
883 if ( cnt != 0 ) |
|
884 { |
|
885 entry->SetSortTypeL( TMsvSelectionOrdering( KMsvGroupByType | KMsvGroupByStandardFolders, EMsvSortByDetailsReverse, EFalse ) ); |
|
886 |
|
887 // Add default item first |
|
888 for (TInt cc = entry->Count(); --cc >= 0; ) |
|
889 { |
|
890 TMsvEntry tentry=(*entry)[cc]; |
|
891 |
|
892 if ( tentry.iType.iUid == KUidMsvServiceEntryValue && tentry.Id() != KMsvLocalServiceIndexEntryIdValue ) |
|
893 { |
|
894 const TBool KnoRelatedId = tentry.iRelatedId == KMsvNullIndexEntryId || tentry.iRelatedId == tentry.Id(); |
|
895 |
|
896 TBool appendEmail = EFalse; |
|
897 |
|
898 if( tentry.Visible() ) |
|
899 { |
|
900 appendEmail = ETrue; |
|
901 } |
|
902 else |
|
903 { |
|
904 CMtmUiDataRegistry* uiRegistry = CMtmUiDataRegistry::NewL(aSession); |
|
905 CleanupStack::PushL(uiRegistry); |
|
906 if ( uiRegistry->IsPresent( tentry.iMtm ) && uiRegistry->IsPresent( KUidMsgTypePOP3 ) ) |
|
907 { |
|
908 if( uiRegistry->TechnologyTypeUid( tentry.iMtm ) == KSenduiTechnologyMailUid ) |
|
909 { |
|
910 appendEmail = ETrue; |
|
911 } |
|
912 } |
|
913 CleanupStack::PopAndDestroy(uiRegistry); |
|
914 } |
|
915 |
|
916 if ( appendEmail || KnoRelatedId ) |
|
917 { |
|
918 if (aMailbox != 0) |
|
919 { |
|
920 if( aMailbox != tentry.Id() && aMailbox != tentry.iRelatedId ) |
|
921 { |
|
922 CleanupStack::PopAndDestroy( entry ); |
|
923 return ETrue; |
|
924 } |
|
925 } |
|
926 else |
|
927 { |
|
928 if( tentry.iMtm != KUidMsgTypePOP3 && tentry.iMtm != KUidMsgTypeIMAP4 |
|
929 && tentry.iMtm != KUidMsgTypeSMTP ) |
|
930 { |
|
931 CleanupStack::PopAndDestroy( entry ); |
|
932 return ETrue; |
|
933 } |
|
934 } |
|
935 } |
|
936 } |
|
937 } |
|
938 } |
|
939 CleanupStack::PopAndDestroy( entry ); |
|
940 return EFalse; |
|
941 } |
|
942 |
|
943 |
|
944 |
|
945 // End of File |