|
1 /* |
|
2 * Copyright (c) 2006 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: SendUI sending service provider that manages all MTM based |
|
15 * sending services. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #include <smsclnt.h> |
|
22 #include <mtclreg.h> // CClientMtmRegistry |
|
23 #include <msvids.h> |
|
24 #include <StringLoader.h> |
|
25 #include <coemain.h> |
|
26 #include <mtmuibas.h> // CBaseMtmUi |
|
27 #include <mtmuidef.hrh> |
|
28 #include <mtuireg.h> // MTM UI registery |
|
29 #include <MuiuMsvUiServiceUtilities.h> |
|
30 #include <muiumsvuiserviceutilitiesinternal.h> |
|
31 #include <s32mem.h> |
|
32 #include <f32file.h> |
|
33 #include <MtmExtendedCapabilities.hrh> |
|
34 #include <mtmuids.h> |
|
35 #include <eiksrv.h> |
|
36 #include <PhCltTypes.h> |
|
37 #include <btcmtm.h> |
|
38 #include <AiwCommon.hrh> |
|
39 #include <AiwServiceHandler.h> |
|
40 #include <AknWaitDialog.h> // CAknWaitDialog |
|
41 #include <AknGlobalNote.h> |
|
42 #include <AknQueryDialog.h> |
|
43 #include <AknsUtils.h> |
|
44 #include <e32property.h> |
|
45 #include <telremotepartyinformationpskeys.h> |
|
46 #include <mtudcbas.h> |
|
47 #include <Sendnorm.rsg> |
|
48 #include <MsgBioUids.h> // KMsgBioUidVCard, KMsgBioUidVCalendar |
|
49 #include <mtudreg.h> |
|
50 #include <mtud.hrh> // EMtudCommandSendAs |
|
51 #include <featmgr.h> // Feature Manager |
|
52 #include <unieditorconsts.h> |
|
53 #include <unimsventry.h> |
|
54 |
|
55 #include <mcesettingsemailsel.h> |
|
56 #include <CSendingServiceInfo.h> |
|
57 #include <SendUiConsts.h> |
|
58 #include <CMessageData.h> |
|
59 #include <TSendingCapabilities.h> |
|
60 #include <senduisingleton.h> |
|
61 #include <messaginginternalpskeys.h> |
|
62 #include "SendUiOperationWait.h" |
|
63 #include "SendUiLog.h" // Logging |
|
64 #include "genericmtmplugin.h" |
|
65 #include "SendUiFileRightsEngine.h" |
|
66 #include "SendUiDummyMtm.h" |
|
67 #include "CSendUiAttachment.h" |
|
68 #include "GenericMtmPluginUids.hrh" |
|
69 |
|
70 const TInt KSendUiProgressStringSize = 256; |
|
71 const TInt KSendUiRichTextStoreGranularity = 512; |
|
72 // For address information separation (start) |
|
73 const TUint KSendUiMsgAddressStartChar ('<'); |
|
74 // For address information separation (end) |
|
75 const TUint KSendUiMsgAddressEndChar ('>'); |
|
76 |
|
77 const TUint KSendUiFeatureSFI = 0x2; |
|
78 const TUint KSendUiFeatureMMS = 0x4; |
|
79 const TUint KSendUiFeatureSelectableEmail = 0x8; |
|
80 |
|
81 const TUint KSeconds = 1000000; |
|
82 |
|
83 // ======== LOCAL FUNCTIONS ======== |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // Two-phased constructor. |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 CGenericMtmPlugin* CGenericMtmPlugin::NewL( TSendingServiceParams* aParams ) |
|
90 { |
|
91 CGenericMtmPlugin* self = new(ELeave) CGenericMtmPlugin( aParams->iCoeEnv, aParams->iSingleton ); |
|
92 |
|
93 CleanupStack::PushL(self); |
|
94 self->ConstructL(); |
|
95 CleanupStack::Pop(self); |
|
96 |
|
97 return self; |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // Destructor |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 CGenericMtmPlugin::~CGenericMtmPlugin() |
|
105 { |
|
106 iServiceArray.ResetAndDestroy(); |
|
107 iServiceArray.Close(); |
|
108 |
|
109 delete iMtmUi; |
|
110 delete iClientMtm; |
|
111 delete iStore; |
|
112 } |
|
113 |
|
114 |
|
115 // --------------------------------------------------------- |
|
116 // CGenericMtmPlugin::InitializeSendingL |
|
117 // --------------------------------------------------------- |
|
118 // |
|
119 TBool CGenericMtmPlugin::InitializeSendingL( ) |
|
120 { |
|
121 LOGTEXT(_L8("CGenericMtmPlugin::InitializeSendingL >>")); |
|
122 |
|
123 if ( iIsSending ) |
|
124 { |
|
125 LOGTEXT(_L8("CGenericMtmPlugin::Sending canceled, previous sending in progress.")); |
|
126 return EFalse; |
|
127 } |
|
128 |
|
129 // Check if MMC mounted or switched to another MMC |
|
130 TDriveUnit currentDrive = iSingleton.MsvSessionL().CurrentDriveL(); |
|
131 |
|
132 if ( currentDrive != EDriveC ) |
|
133 { |
|
134 TBool storeOnMMC( EFalse ); |
|
135 TRAPD ( error, storeOnMMC = iSingleton.MsvSessionL().MessageStoreDrivePresentL( ) ); |
|
136 if ( !iSingleton.MsvSessionL().DriveContainsStoreL( currentDrive ) || !storeOnMMC || error ) |
|
137 { |
|
138 //Change message store to phones internal memory(EDriveC) |
|
139 MsvUiServiceUtilitiesInternal::ChangeMessageStoreToPhoneL( iSingleton.MsvSessionL() ); |
|
140 } |
|
141 } |
|
142 |
|
143 LOGTEXT(_L8("CGenericMtmPlugin::InitializeSendingL <<")); |
|
144 |
|
145 return ETrue; |
|
146 } |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // Populates given list with the services provided by this plugin. |
|
150 // The ownership of the pointed objects remains. |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CGenericMtmPlugin::PopulateServicesListL( |
|
154 RPointerArray<CSendingServiceInfo>& aList ) |
|
155 { |
|
156 ScanMtmsL( iServiceArray ); |
|
157 |
|
158 TInt i = iServiceArray.Count(); |
|
159 while( i-- ) |
|
160 { |
|
161 aList.Append( iServiceArray[i]); |
|
162 } |
|
163 } |
|
164 |
|
165 // --------------------------------------------------------- |
|
166 // CGenericMtmPlugin::CreateAndSendMessageL |
|
167 // --------------------------------------------------------- |
|
168 // |
|
169 void CGenericMtmPlugin::CreateAndSendMessageL( |
|
170 TUid aMtmUid, |
|
171 const CMessageData* aMessageData, |
|
172 TBool aLaunchEditorEmbedded ) |
|
173 { |
|
174 LOGTEXT(_L8("CGenericMtmPlugin::CreateAndSendMessageL >>")); |
|
175 |
|
176 if ( aMtmUid != KSenduiMtmBtUid && |
|
177 MsvUiServiceUtilities::DiskSpaceBelowCriticalLevelL( |
|
178 iSingleton.MsvSessionL(), 0 ) ) |
|
179 { |
|
180 User::Leave(KErrDiskFull); |
|
181 } |
|
182 |
|
183 TUid tempUid( KNullUid ); |
|
184 if ( aMtmUid == KSenduiMtmSmsUid || |
|
185 aMtmUid == KSenduiMtmMmsUid ) |
|
186 { |
|
187 tempUid = aMtmUid; |
|
188 aMtmUid = KSenduiMtmUniMessageUid; |
|
189 // TODO: Use original MTM for checking attachments? |
|
190 // TODO: Use original MTM for "InitializeSending" (does some |
|
191 // SmartMessaging checks)? |
|
192 } |
|
193 TMsvId service; |
|
194 TBool onlineSharing = EFalse; |
|
195 TBool doContinue = EFalse; |
|
196 |
|
197 iClientMtm = iSingleton.ClientMtmRegistryL().NewMtmL( aMtmUid ); |
|
198 iMtmUi = iSingleton.MtmUiRegistryL().NewMtmUiL( *iClientMtm ); |
|
199 |
|
200 if ( IsSupported( KSendUiFeatureSelectableEmail ) ) |
|
201 { |
|
202 // from OnlineMtm.rss, mtm_type_uid |
|
203 onlineSharing = ( aMtmUid == KSenduiMtmOnlineAlbumUid) ? |
|
204 ETrue : EFalse; |
|
205 service = GetAndValidateServiceL( aMtmUid, aLaunchEditorEmbedded, |
|
206 doContinue ); |
|
207 if( service == KMsvUnkownServiceIndexEntryIdValue && |
|
208 !onlineSharing ) |
|
209 { |
|
210 // cancel pressed on "selecta email account" query |
|
211 return; |
|
212 } |
|
213 } |
|
214 TInt cleanupItems(0); |
|
215 |
|
216 if ( !InitializeSendingL( ) ) |
|
217 { |
|
218 return; |
|
219 } |
|
220 |
|
221 CArrayPtrFlat<CSendUiAttachment>* attachments = NULL; |
|
222 // Get attachments |
|
223 if ( aMessageData ) |
|
224 { |
|
225 attachments = CSendUiAttachment::InitAttachmentArrayLCC( |
|
226 aMessageData->AttachmentArray(), |
|
227 aMessageData->AttachmentHandleArray(), |
|
228 iCoeEnv.FsSession() ); |
|
229 cleanupItems += 2; |
|
230 } |
|
231 |
|
232 // Ensures proper sending state if leave happens. |
|
233 iIsSending = ETrue; |
|
234 CleanupStack::PushL(TCleanupItem(ResetIsSending, (TAny*)&iIsSending)); |
|
235 cleanupItems++; |
|
236 |
|
237 //iClientMtm = iSingleton.ClientMtmRegistryL().NewMtmL( aMtmUid ); |
|
238 //iMtmUi = iSingleton.MtmUiRegistryL().NewMtmUiL( *iClientMtm ); |
|
239 |
|
240 CBaseMtmUiData* mtmUiData = iSingleton.MtmUiDataRegistryL().NewMtmUiDataLayerL( aMtmUid ); |
|
241 CleanupStack::PushL( mtmUiData ); |
|
242 cleanupItems++; |
|
243 |
|
244 if ( aMessageData && |
|
245 !ValidateAttachmentsL( |
|
246 aMtmUid, |
|
247 *mtmUiData, |
|
248 attachments )) |
|
249 { |
|
250 // User canceled sending. |
|
251 CleanupStack::PopAndDestroy( cleanupItems ); // TCleanupItem |
|
252 return; |
|
253 } |
|
254 |
|
255 // Show wait note if needed |
|
256 TBool showWaitNote = EFalse; |
|
257 if ( aMessageData ) |
|
258 { |
|
259 showWaitNote = |
|
260 IsWaitNoteNeededL( aMtmUid, *aMessageData, attachments->Count() ); |
|
261 |
|
262 if ( showWaitNote ) |
|
263 { |
|
264 ShowWaitNoteLC(); |
|
265 cleanupItems++; |
|
266 } |
|
267 } |
|
268 TBool success = EFalse; |
|
269 if ( IsSupported( KSendUiFeatureSelectableEmail ) ) |
|
270 { |
|
271 if ( !onlineSharing ) |
|
272 { |
|
273 if ( doContinue ) |
|
274 { |
|
275 CreateMessageL( aMtmUid, service ); |
|
276 //If doContinue, service already validated to be launched |
|
277 //embedded |
|
278 success = ETrue; |
|
279 } |
|
280 } |
|
281 else |
|
282 { |
|
283 success = CreateMessageL( aMtmUid, aLaunchEditorEmbedded ); |
|
284 } |
|
285 } |
|
286 else |
|
287 { |
|
288 success = CreateMessageL( aMtmUid, aLaunchEditorEmbedded ); |
|
289 } |
|
290 |
|
291 if ( success && tempUid != KNullUid ) |
|
292 { |
|
293 TMsvEntry entry = iClientMtm->Entry().Entry(); |
|
294 TUniMsvEntry::SetCurrentMessageType( |
|
295 entry, |
|
296 tempUid == KSenduiMtmSmsUid |
|
297 ? EUniMessageCurrentTypeSms |
|
298 : EUniMessageCurrentTypeMms ); |
|
299 TUniMsvEntry::SetMessageTypeLocked( entry, ETrue ); |
|
300 iClientMtm->Entry().ChangeL( entry ); |
|
301 } |
|
302 |
|
303 // Set message data |
|
304 if ( aMessageData && success) |
|
305 { |
|
306 SetRecipientsL( aMtmUid, *aMessageData ); |
|
307 SetBodyL( *mtmUiData, *aMessageData, attachments ); |
|
308 |
|
309 if ( attachments->Count() > 0 ) |
|
310 { |
|
311 if ( aMtmUid == KSenduiMtmBtUid ) |
|
312 { |
|
313 // Bluetooth sending over AIW |
|
314 SendBtMessageL( attachments ); |
|
315 CleanupStack::PopAndDestroy( cleanupItems ); // TCleanupItem |
|
316 return; |
|
317 } |
|
318 else |
|
319 { |
|
320 success = AddAttachmentsL( *mtmUiData, attachments ); |
|
321 } |
|
322 } |
|
323 |
|
324 if ( success && ( aMtmUid == KSenduiMtmSmtpUid || |
|
325 aMtmUid == KSenduiMtmMmsUid || |
|
326 aMtmUid == KSenduiMtmUniMessageUid )) |
|
327 { |
|
328 HBufC* subject = aMessageData->Subject().AllocLC(); |
|
329 cleanupItems++; |
|
330 iClientMtm->SetSubjectL( *subject ); |
|
331 } |
|
332 } |
|
333 if ( aMtmUid == KSenduiMtmBtUid ) |
|
334 { |
|
335 success = EFalse; // bluetooth can launch editor only from SendBtMessageL |
|
336 } |
|
337 if ( success ) |
|
338 { |
|
339 TInt attachmentsCount = attachments ? attachments->Count(): 0; |
|
340 LaunchEditorL( attachmentsCount, aLaunchEditorEmbedded ); |
|
341 } |
|
342 |
|
343 CleanupStack::PopAndDestroy( cleanupItems ); // TCleanupItem, attachments |
|
344 LOGTEXT(_L8("CGenericMtmPlugin::CreateAndSendMessageL <<")); |
|
345 } |
|
346 |
|
347 // --------------------------------------------------------- |
|
348 // CGenericMtmPlugin::ServiceProviderId |
|
349 // Returns the id of the service provider. |
|
350 // (other items were commented in a header). |
|
351 // --------------------------------------------------------- |
|
352 // |
|
353 TUid CGenericMtmPlugin::ServiceProviderId() const |
|
354 { |
|
355 return KGenericMtmPlugin; |
|
356 } |
|
357 |
|
358 // ----------------------------------------------------------------------------- |
|
359 // C++ default constructor can NOT contain any code, that |
|
360 // might leave. |
|
361 // ----------------------------------------------------------------------------- |
|
362 // |
|
363 CGenericMtmPlugin::CGenericMtmPlugin( CCoeEnv& aCoeEnv, CSendUiSingleton& aSingleton ) : |
|
364 CSendingService( aCoeEnv, aSingleton ), |
|
365 iSendUiFeatureFlags(0) |
|
366 { |
|
367 } |
|
368 |
|
369 // ----------------------------------------------------------------------------- |
|
370 // ConstructL |
|
371 // Symbian 2nd phase constructor can leave. |
|
372 // ----------------------------------------------------------------------------- |
|
373 // |
|
374 void CGenericMtmPlugin::ConstructL() |
|
375 { |
|
376 iStore = CBufStore::NewL(KSendUiRichTextStoreGranularity); |
|
377 |
|
378 FeatureManager::InitializeLibL(); |
|
379 if ( FeatureManager::FeatureSupported( KFeatureIdSendFileInCall ) ) |
|
380 { |
|
381 iSendUiFeatureFlags |= KSendUiFeatureSFI; |
|
382 } |
|
383 if ( FeatureManager::FeatureSupported( KFeatureIdMMS ) ) |
|
384 { |
|
385 iSendUiFeatureFlags |= KSendUiFeatureMMS; |
|
386 } |
|
387 if ( FeatureManager::FeatureSupported( KFeatureIdSelectableEmail ) ) |
|
388 { |
|
389 iSendUiFeatureFlags |= KSendUiFeatureSelectableEmail; |
|
390 } |
|
391 FeatureManager::UnInitializeLib(); |
|
392 |
|
393 } |
|
394 |
|
395 // --------------------------------------------------------- |
|
396 // Start asyncronous MTM scanning |
|
397 // --------------------------------------------------------- |
|
398 // |
|
399 void CGenericMtmPlugin::ScanMtmsL( RPointerArray<CSendingServiceInfo>& aList ) |
|
400 { |
|
401 TInt regMtmIndex = 0; |
|
402 TInt err; |
|
403 TInt count( iSingleton.MtmUiDataRegistryL().NumRegisteredMtmDlls() ); |
|
404 while ( regMtmIndex < count ) |
|
405 { |
|
406 TUid mtmUid = iSingleton.MtmUiDataRegistryL().MtmTypeUid(regMtmIndex); |
|
407 LOGTEXT3(_L("Loading MTM index %d, id %d"), regMtmIndex, mtmUid ); |
|
408 TRAP( err, LoadMtmL( iSingleton.MtmUiDataRegistryL().MtmTypeUid(regMtmIndex), aList ) ); |
|
409 LOGTEXT2( _L("Loading MTM done, code %d"), err ); |
|
410 regMtmIndex++; |
|
411 } |
|
412 } |
|
413 |
|
414 |
|
415 // --------------------------------------------------------- |
|
416 // ValidateAttachmentsL |
|
417 // --------------------------------------------------------- |
|
418 // |
|
419 TBool CGenericMtmPlugin::ValidateAttachmentsL( |
|
420 TUid aMtmUid, |
|
421 CBaseMtmUiData& aMtmUiData, |
|
422 CArrayPtrFlat<CSendUiAttachment>* aAttachments ) |
|
423 { |
|
424 LOGTEXT(_L8("CGenericMtmPlugin::ValidateAttachmentsL >>")); |
|
425 TBool continueSending = ETrue; |
|
426 |
|
427 // Validate attachments and show query and error note if needed. |
|
428 if ( aAttachments->Count() > 0 ) |
|
429 { |
|
430 CSendUiFileRightsEngine* fileRightsEngine = |
|
431 CSendUiFileRightsEngine::NewLC( iCoeEnv.FsSession() ); |
|
432 if ( aMtmUid == KSenduiMtmPostcardUid && |
|
433 IsPostcardContactLink( aAttachments ) ) |
|
434 { |
|
435 // Postcard special case. ConfirmDrmFileRightsL() fails for contact |
|
436 // link file sent from Phonebook to Postcard. Therefore the check |
|
437 // is bypassed. Postcard treats the special file as a contact link. |
|
438 // Therefore bypassing drm check in this case is not a |
|
439 // vulnerability. |
|
440 } |
|
441 else |
|
442 { |
|
443 fileRightsEngine->ConfirmDrmFileRightsL( aAttachments ); |
|
444 } |
|
445 // Confirm and filter away non-MMS files, if sending via MMS. |
|
446 if ( aMtmUid == KSenduiMtmMmsUid || |
|
447 aMtmUid == KSenduiMtmAudioMessageUid || |
|
448 ( aMtmUid == KSenduiMtmUniMessageUid && |
|
449 IsSupported( KSendUiFeatureMMS ) ) ) |
|
450 { |
|
451 fileRightsEngine->ConfirmMmsValidityL( aAttachments ); |
|
452 } |
|
453 |
|
454 continueSending = fileRightsEngine->ShowDrmAndMmsInfoL(); |
|
455 |
|
456 if ( aAttachments->Count() <= 0 ) |
|
457 { |
|
458 continueSending = EFalse; // No files to send after filtering. |
|
459 } |
|
460 |
|
461 if ( continueSending ) |
|
462 { |
|
463 TInt messageSize = 0; |
|
464 |
|
465 TUid uidQuery = { KUidMsvMtmQuerySupportLinks }; |
|
466 TInt supportsLinks = 0; |
|
467 aMtmUiData.QueryCapability( uidQuery, supportsLinks ); |
|
468 |
|
469 messageSize = fileRightsEngine->CalculateTotalSizeOfFiles( |
|
470 aAttachments, |
|
471 supportsLinks ); |
|
472 |
|
473 if ( aMtmUid != KSenduiMtmBtUid && |
|
474 MsvUiServiceUtilities::DiskSpaceBelowCriticalLevelL( |
|
475 iSingleton.MsvSessionL(), messageSize ) ) |
|
476 { |
|
477 User::Leave(KErrDiskFull); |
|
478 } |
|
479 } |
|
480 CleanupStack::PopAndDestroy( fileRightsEngine ); |
|
481 } |
|
482 LOGTEXT(_L8("CGenericMtmPlugin::ValidateAttachmentsL <<")); |
|
483 return continueSending; |
|
484 } |
|
485 |
|
486 // --------------------------------------------------------- |
|
487 // IsWaitNoteNeededL |
|
488 // --------------------------------------------------------- |
|
489 // |
|
490 TBool CGenericMtmPlugin::IsWaitNoteNeededL( |
|
491 TUid aMtmUid, |
|
492 const CMessageData& aMessageData, |
|
493 TInt aAttachmentCount ) |
|
494 { |
|
495 LOGTEXT(_L8("CGenericMtmPlugin::IsWaitNoteNeededL >>")); |
|
496 if ( aMtmUid != KSenduiMtmIrUid && aMtmUid != KSenduiMtmBtUid ) |
|
497 { |
|
498 return ETrue; |
|
499 } |
|
500 |
|
501 const CRichText* bodyText = aMessageData.BodyText(); |
|
502 const CMessageAddressArray& toAddresses = aMessageData.ToAddressArray(); |
|
503 |
|
504 if ( aAttachmentCount > 0 || |
|
505 ( bodyText && bodyText->DocumentLength() ) || |
|
506 ( toAddresses.Count() > 2 ) ) |
|
507 { |
|
508 LOGTEXT(_L8("CGenericMtmPlugin::IsWaitNoteNeededL <<")); |
|
509 return ETrue; |
|
510 } |
|
511 |
|
512 LOGTEXT(_L8("CGenericMtmPlugin::IsWaitNoteNeededL <<")); |
|
513 |
|
514 return EFalse; |
|
515 } |
|
516 |
|
517 // --------------------------------------------------------- |
|
518 // CGenericMtmPlugin::ShowWaitNoteLC |
|
519 // |
|
520 // (other items were commented in a header). |
|
521 // --------------------------------------------------------- |
|
522 // |
|
523 void CGenericMtmPlugin::ShowWaitNoteLC() |
|
524 { |
|
525 LOGTEXT(_L8("CGenericMtmPlugin::ShowWaitNoteLC >>")); |
|
526 |
|
527 delete iWaitDialog; |
|
528 iWaitDialog = NULL; |
|
529 |
|
530 iWaitDialog = new (ELeave) CAknWaitDialog( |
|
531 reinterpret_cast<CEikDialog**>(&iWaitDialog), ETrue ); |
|
532 |
|
533 CleanupStack::PushL(TCleanupItem(CleanupWaitDialog, (TAny**)&iWaitDialog)); |
|
534 |
|
535 iWaitDialog->ExecuteLD( R_SENDUI_WAIT_NOTE ); |
|
536 LOGTEXT(_L8("CGenericMtmPlugin::ShowWaitNoteLC <<")); |
|
537 } |
|
538 |
|
539 // --------------------------------------------------------- |
|
540 // ResetIsSending |
|
541 // --------------------------------------------------------- |
|
542 // |
|
543 void CGenericMtmPlugin::ResetIsSending(TAny* aAny) |
|
544 { |
|
545 *((TBool*)aAny) = EFalse; |
|
546 } |
|
547 |
|
548 // --------------------------------------------------------- |
|
549 // CGenericMtmPlugin::CleanupWaitDialog |
|
550 // --------------------------------------------------------- |
|
551 // |
|
552 void CGenericMtmPlugin::CleanupWaitDialog(TAny* aAny) |
|
553 { |
|
554 CAknWaitDialog** dialog = (CAknWaitDialog**) aAny; |
|
555 if (dialog && *dialog) |
|
556 { |
|
557 delete *dialog; |
|
558 *dialog = NULL; |
|
559 } |
|
560 } |
|
561 |
|
562 // --------------------------------------------------------- |
|
563 // |
|
564 // --------------------------------------------------------- |
|
565 // |
|
566 void CGenericMtmPlugin::CreateMessageL( |
|
567 TUid& aMtmUid, |
|
568 TMsvId aService |
|
569 ) |
|
570 { |
|
571 |
|
572 LOGTEXT(_L8("CGenericMtmPlugin::CreateMessageL >>")); |
|
573 |
|
574 CMsvEntry* draftEntry = iSingleton.MsvSessionL().GetEntryL( KMsvDraftEntryId ); |
|
575 CleanupStack::PushL( draftEntry ); |
|
576 iClientMtm->SetCurrentEntryL( draftEntry ); // mtm takes ownership |
|
577 CleanupStack::Pop( draftEntry ); |
|
578 |
|
579 iClientMtm->CreateMessageL( aService ); |
|
580 |
|
581 if ( aMtmUid == KSenduiMtmSmtpUid ) |
|
582 { |
|
583 // For mail message: this loads signature. |
|
584 iClientMtm->LoadMessageL(); |
|
585 } |
|
586 |
|
587 LOGTEXT(_L8("CGenericMtmPlugin::CreateMessageL <<")); |
|
588 |
|
589 } |
|
590 TBool CGenericMtmPlugin::CreateMessageL( |
|
591 TUid& aMtmUid, |
|
592 TBool& aLaunchEmbedded ) |
|
593 { |
|
594 LOGTEXT(_L8("CGenericMtmPlugin::CreateMessageL >>")); |
|
595 TBool doContinue; |
|
596 TMsvId service = GetAndValidateServiceL( aMtmUid, aLaunchEmbedded, doContinue ); |
|
597 |
|
598 if ( doContinue ) |
|
599 { |
|
600 CMsvEntry* draftEntry = iSingleton.MsvSessionL().GetEntryL( KMsvDraftEntryId ); |
|
601 CleanupStack::PushL( draftEntry ); |
|
602 iClientMtm->SetCurrentEntryL( draftEntry ); // mtm takes ownership |
|
603 CleanupStack::Pop( draftEntry ); |
|
604 iClientMtm->CreateMessageL( service ); |
|
605 |
|
606 if ( aMtmUid == KSenduiMtmSmtpUid ) |
|
607 { |
|
608 // For emails, this loads signature. |
|
609 iClientMtm->LoadMessageL(); |
|
610 } |
|
611 } |
|
612 LOGTEXT(_L8("CGenericMtmPlugin::CreateMessageL <<")); |
|
613 return doContinue; |
|
614 } |
|
615 |
|
616 // ----------------------------------------------------------------------------- |
|
617 // SetRecipientsL |
|
618 // ----------------------------------------------------------------------------- |
|
619 // |
|
620 void CGenericMtmPlugin::SetRecipientsL( |
|
621 TUid aMtmUid, |
|
622 const CMessageData& aMessageData ) |
|
623 { |
|
624 LOGTEXT(_L8("CGenericMtmPlugin::SetRecipientsL >>")); |
|
625 |
|
626 // Send file in call |
|
627 TPhCltTelephoneNumber callerNumber; |
|
628 TPhCltNameBuffer callerName; |
|
629 // Add "To"-recipients addressees |
|
630 if ( aMessageData.ToAddressArray().Count() > 0 ) |
|
631 { |
|
632 AddAddresseesL( EMsvRecipientTo, aMessageData.ToAddressArray() ); |
|
633 } |
|
634 else if( IsCallOngoing( callerNumber, callerName ) && // Incall situation |
|
635 ( aMtmUid == KSenduiMtmMmsUid || aMtmUid == KSenduiMtmUniMessageUid ) ) |
|
636 { |
|
637 if ( callerName != KNullDesC16) |
|
638 { |
|
639 iClientMtm->AddAddresseeL( callerNumber, callerName ); |
|
640 } |
|
641 else |
|
642 { |
|
643 iClientMtm->AddAddresseeL( callerNumber ); |
|
644 } |
|
645 } |
|
646 |
|
647 // Add "CC"-recipients addressees |
|
648 if ( aMessageData.CcAddressArray().Count() > 0 ) |
|
649 { |
|
650 AddAddresseesL( EMsvRecipientCc, aMessageData.CcAddressArray() ); |
|
651 } |
|
652 |
|
653 // Add "BCC"-recipients addressees |
|
654 if ( aMessageData.BccAddressArray().Count() > 0 ) |
|
655 { |
|
656 AddAddresseesL( EMsvRecipientBcc, aMessageData.BccAddressArray() ); |
|
657 } |
|
658 |
|
659 LOGTEXT(_L8("CGenericMtmPlugin::SetRecipientsL <<")); |
|
660 } |
|
661 |
|
662 // ----------------------------------------------------------------------------- |
|
663 // Add addressees. |
|
664 // ----------------------------------------------------------------------------- |
|
665 // |
|
666 void CGenericMtmPlugin::AddAddresseesL( |
|
667 TMsvRecipientType aRecipientType, |
|
668 const CMessageAddressArray& aAddressees ) |
|
669 { |
|
670 LOGTEXT(_L8("CGenericMtmPlugin::AddAddresseesL >>")); |
|
671 |
|
672 for( TInt i(0) ; i < aAddressees.Count(); i++ ) |
|
673 { |
|
674 if( aAddressees[i]->Address().Length() > 0 ) |
|
675 { |
|
676 // If address has an alias, process it |
|
677 if( aAddressees[i]->Alias().Length() > 0 ) |
|
678 { |
|
679 TPtrC alias = aAddressees[i]->Alias(); |
|
680 |
|
681 // Check if alias contains illegal characters. If it does |
|
682 // remove them. |
|
683 if( ( alias.Locate( KSendUiMsgAddressStartChar ) != KErrNotFound ) || |
|
684 ( alias.Locate( KSendUiMsgAddressEndChar ) != KErrNotFound ) ) |
|
685 { |
|
686 HBufC* aliasNew = alias.AllocLC(); |
|
687 TPtr aliasPtr = aliasNew->Des(); |
|
688 RemoveIllegalChars( aliasPtr ); |
|
689 iClientMtm->AddAddresseeL( |
|
690 aRecipientType, aAddressees[i]->Address(), *aliasNew ); |
|
691 |
|
692 CleanupStack::PopAndDestroy( aliasNew ); |
|
693 } |
|
694 else |
|
695 { |
|
696 iClientMtm->AddAddresseeL( |
|
697 aRecipientType, aAddressees[i]->Address(), alias ); |
|
698 } |
|
699 } |
|
700 else |
|
701 { |
|
702 // Address entry didn't have alias |
|
703 iClientMtm->AddAddresseeL( |
|
704 aRecipientType, aAddressees[i]->Address() ); |
|
705 } |
|
706 } |
|
707 // Done setting one addressee |
|
708 } |
|
709 |
|
710 LOGTEXT(_L8("CGenericMtmPlugin::AddAddresseesL <<")); |
|
711 } |
|
712 |
|
713 // ----------------------------------------------------------------------------- |
|
714 // Add attachments to message. |
|
715 // (other items were commented in a header). |
|
716 // ----------------------------------------------------------------------------- |
|
717 // |
|
718 TBool CGenericMtmPlugin::AddAttachmentsL( CBaseMtmUiData& aMtmUiData, |
|
719 CArrayPtrFlat<CSendUiAttachment>* aAttachments ) |
|
720 { |
|
721 LOGTEXT(_L8("CGenericMtmPlugin::AddAttachmentsL >>")); |
|
722 |
|
723 TInt supportsLinks = 0; |
|
724 aMtmUiData.QueryCapability( TUid::Uid(KUidMsvMtmQuerySupportLinks), supportsLinks ); |
|
725 |
|
726 TBool success(ETrue); |
|
727 // Set linked attachments. (Attachments given as file paths) |
|
728 TInt attachmentCount = aAttachments->Count(); |
|
729 TInt i; |
|
730 for ( i = 0; i < attachmentCount && success ; i++ ) |
|
731 { |
|
732 CSendUiAttachment& attachment = *(aAttachments->At(i )); |
|
733 success = AddAttachmentL( &attachment, supportsLinks ); |
|
734 } |
|
735 |
|
736 LOGTEXT(_L8("CGenericMtmPlugin::AddAttachmentsL <<")); |
|
737 return success; |
|
738 } |
|
739 |
|
740 // ----------------------------------------------------------------------------- |
|
741 // CGenericMtmPlugin::AddAttachmentL |
|
742 // Add attachment to message. |
|
743 // (other items were commented in a header). |
|
744 // ----------------------------------------------------------------------------- |
|
745 // |
|
746 TBool CGenericMtmPlugin::AddAttachmentL( CSendUiAttachment* aAttachment, TInt aSupportsLinks ) |
|
747 { |
|
748 CSendUiOperationWait* waiter = CSendUiOperationWait::NewLC(); |
|
749 // File paths |
|
750 if ( aSupportsLinks && aAttachment->Type() == CSendUiAttachment::EAttachmentPath ) |
|
751 { |
|
752 iClientMtm->AddLinkedAttachmentL( |
|
753 *(aAttachment->Path() ), |
|
754 aAttachment->MimeType(), |
|
755 0, |
|
756 waiter->iStatus ); |
|
757 } |
|
758 else |
|
759 { |
|
760 RFile attachmentFile; |
|
761 User::LeaveIfError( attachmentFile.Duplicate( *(aAttachment->Handle() ) )); |
|
762 CleanupClosePushL( attachmentFile ); |
|
763 |
|
764 // File handle ownership transferred. |
|
765 iClientMtm->AddAttachmentL( |
|
766 attachmentFile, |
|
767 aAttachment->MimeType(), |
|
768 0, |
|
769 waiter->iStatus ); |
|
770 CleanupStack::Pop( &attachmentFile ); |
|
771 } |
|
772 |
|
773 TBool success = waiter->Start( iClientMtm ); |
|
774 |
|
775 CleanupStack::PopAndDestroy( waiter ); |
|
776 return success; |
|
777 } |
|
778 |
|
779 // --------------------------------------------------------- |
|
780 // SetBodyL |
|
781 // --------------------------------------------------------- |
|
782 // |
|
783 void CGenericMtmPlugin::SetBodyL( |
|
784 const CBaseMtmUiData& aMtmUiData, |
|
785 const CMessageData& aMessageData, |
|
786 CArrayPtrFlat<CSendUiAttachment>* aAttachments ) |
|
787 { |
|
788 LOGTEXT(_L8("CGenericMtmPlugin::SetBodyL >>")); |
|
789 __ASSERT_DEBUG( iStore, User::LeaveIfError(KErrNoMemory) ); |
|
790 |
|
791 const CRichText* bodyText = aMessageData.BodyText(); |
|
792 LOGTEXT2( _L("CMessageData bodytext length %d" ), bodyText->DocumentLength() ); |
|
793 |
|
794 if ( !bodyText || !bodyText->DocumentLength() ) |
|
795 { // No body text |
|
796 return; |
|
797 } |
|
798 |
|
799 TInt response; |
|
800 if ( aMtmUiData.QueryCapability( KUidMtmQuerySupportedBody, response ) == KErrNotSupported ) |
|
801 { |
|
802 CSendUiAttachment* atta = CSendUiAttachment::NewLC( *bodyText, iCoeEnv.FsSession() ); |
|
803 aAttachments->AppendL( atta ); |
|
804 CleanupStack::Pop( atta ); |
|
805 return; |
|
806 } |
|
807 |
|
808 CRichText& mtmBody = iClientMtm->Body(); |
|
809 LOGTEXT2( _L("mtm body length %d" ), mtmBody.DocumentLength() ); |
|
810 // Set the picture factory |
|
811 if ( bodyText->PictureFactory() ) |
|
812 { |
|
813 mtmBody.SetPictureFactory( bodyText->PictureFactory(), this ); |
|
814 } |
|
815 |
|
816 // read aMtmBody and add to aSentMessageBody so that possible signature is added. |
|
817 if ( aMtmUiData.Type() == KSenduiMtmSmtpUid && mtmBody.DocumentLength() ) |
|
818 { |
|
819 CRichText* text = CRichText::NewL( |
|
820 static_cast<CEikonEnv&>( iCoeEnv ).SystemParaFormatLayerL(), |
|
821 static_cast<CEikonEnv&>( iCoeEnv ).SystemCharFormatLayerL() ); |
|
822 CleanupStack::PushL( text ); |
|
823 |
|
824 TInt len1 = bodyText->DocumentLength(); |
|
825 TInt len2 = mtmBody.DocumentLength(); |
|
826 |
|
827 HBufC* buf = HBufC::NewLC( len1 ); |
|
828 TPtr ptr = buf->Des(); |
|
829 bodyText->Extract( ptr, 0 ); |
|
830 text->InsertL( 0, *buf ); |
|
831 CleanupStack::PopAndDestroy( buf ); |
|
832 |
|
833 len1 = text->DocumentLength(); |
|
834 text->InsertL (len1, CEditableText::EParagraphDelimiter ); |
|
835 len1 = text->DocumentLength(); |
|
836 text->InsertL( len1, mtmBody.Read( 0, len2 ) ); |
|
837 |
|
838 // Save and restore the rich text |
|
839 TStreamId id = text->StoreL( *iStore ); |
|
840 mtmBody.RestoreL( *iStore, id ); |
|
841 |
|
842 CleanupStack::PopAndDestroy( text ); |
|
843 } |
|
844 else |
|
845 { |
|
846 // Save and restore the rich text |
|
847 TStreamId id = bodyText->StoreL( *iStore ); |
|
848 mtmBody.RestoreL( *iStore, id ); |
|
849 |
|
850 LOGTEXT(_L8("CGenericMtmPlugin::mtm body restored")); |
|
851 } |
|
852 |
|
853 LOGTEXT2( _L("Final Mtm body length %d" ), mtmBody.DocumentLength() ); |
|
854 // Get access to protected data |
|
855 CSendUiDummyMtm* mtm = ( CSendUiDummyMtm* )iClientMtm; |
|
856 |
|
857 mtm->SetCharFormatL( *bodyText->GlobalCharFormatLayer() ); |
|
858 mtm->SetParaFormatL( *bodyText->GlobalParaFormatLayer() ); |
|
859 LOGTEXT(_L8("CGenericMtmPlugin::SetBodyL <<")); |
|
860 } |
|
861 |
|
862 // ----------------------------------------------------------------------------- |
|
863 // CGenericMtmPlugin::LaunchEditorL |
|
864 // |
|
865 // (other items were commented in a header). |
|
866 // ----------------------------------------------------------------------------- |
|
867 // |
|
868 void CGenericMtmPlugin::LaunchEditorL( |
|
869 TInt aAttachmentCount, |
|
870 TBool aLaunchEditorEmbedded ) |
|
871 { |
|
872 LOGTEXT(_L8("CGenericMtmPlugin::LaunchEditorL >>")); |
|
873 // save message. |
|
874 iClientMtm->SaveMessageL(); |
|
875 // set the time and make invisible. |
|
876 iIndexEntry = iClientMtm->Entry().Entry(); |
|
877 iIndexEntry.iDate.UniversalTime(); |
|
878 iIndexEntry.SetVisible( EFalse ); |
|
879 iIndexEntry.SetInPreparation( ETrue ); |
|
880 |
|
881 if ( aAttachmentCount > 0 ) |
|
882 { |
|
883 iIndexEntry.SetAttachment( ETrue ); |
|
884 } |
|
885 else |
|
886 { |
|
887 iIndexEntry.SetAttachment( EFalse ); |
|
888 } |
|
889 |
|
890 iClientMtm->Entry().ChangeL( iIndexEntry ); |
|
891 |
|
892 CSendUiOperationWait* waiter = |
|
893 CSendUiOperationWait::NewLC( EActivePriorityWsEvents+10 ); |
|
894 |
|
895 iClientMtm->SwitchCurrentEntryL( iIndexEntry.Id() ); |
|
896 |
|
897 // Set preferences. |
|
898 |
|
899 TUint preferences = iMtmUi->Preferences(); |
|
900 if ( aLaunchEditorEmbedded ) |
|
901 { |
|
902 preferences |= EMtmUiFlagEditorPreferEmbedded; |
|
903 } |
|
904 else |
|
905 { |
|
906 preferences &= ~EMtmUiFlagEditorPreferEmbedded; |
|
907 preferences |= EMtmUiFlagEditorNoWaitForExit; |
|
908 } |
|
909 |
|
910 iMtmUi->SetPreferences( preferences ); |
|
911 |
|
912 // Remove wait dialog before calling EditL. |
|
913 // Otherwise possible (e.g. settings) dialogs opened by UI MTM may get dimmed. |
|
914 delete iWaitDialog; |
|
915 iWaitDialog = NULL; |
|
916 |
|
917 RProperty integerProperty; |
|
918 |
|
919 TInt err = integerProperty.Attach(KPSUidMsgEditor,KMuiuStandAloneOpenMsgEditors); |
|
920 TInt openeditorcount = 0; |
|
921 err = integerProperty.Get(KPSUidMsgEditor, KMuiuStandAloneOpenMsgEditors, openeditorcount); |
|
922 switch ( err ) |
|
923 { |
|
924 case KErrPermissionDenied: |
|
925 case KErrArgument: |
|
926 { |
|
927 User::Leave( err ); |
|
928 } |
|
929 break; |
|
930 case KErrNotFound: // shoudl be executed only once for every boot cycle |
|
931 { |
|
932 User::LeaveIfError ( |
|
933 RProperty::Define( |
|
934 KPSUidMsgEditor, |
|
935 KMuiuStandAloneOpenMsgEditors, |
|
936 RProperty::EInt, |
|
937 ECapabilityReadDeviceData, |
|
938 ECapabilityWriteDeviceData, |
|
939 0 ) ); |
|
940 } |
|
941 break; |
|
942 case KErrNone: |
|
943 default: |
|
944 break; |
|
945 } |
|
946 |
|
947 if (!aLaunchEditorEmbedded && openeditorcount ) |
|
948 { |
|
949 RProperty property; |
|
950 |
|
951 User::LeaveIfError( property.Attach( KPSUidMuiu,KMuiuSysOpenMsgEditors ) ); |
|
952 TInt openEditors; |
|
953 TInt err = property.Get( openEditors ); |
|
954 CleanupClosePushL( property ); |
|
955 |
|
956 openeditorcount++; |
|
957 integerProperty.Set(KPSUidMsgEditor, KMuiuStandAloneOpenMsgEditors, openeditorcount); |
|
958 property.Set( KPSUidMuiu, KMuiuSysOpenMsgEditors, openEditors ); |
|
959 |
|
960 // wait a second |
|
961 User::After( KSeconds ); |
|
962 CleanupStack::PopAndDestroy( &property ); |
|
963 } |
|
964 else |
|
965 { |
|
966 openeditorcount = 1; |
|
967 integerProperty.Set(KPSUidMsgEditor, KMuiuStandAloneOpenMsgEditors, openeditorcount); |
|
968 } |
|
969 integerProperty.Close(); |
|
970 // Edit the message. |
|
971 CMsvOperation* op = iMtmUi->EditL( waiter->iStatus ); |
|
972 CleanupStack::PushL( op ); |
|
973 TBool success = waiter->Start( op ); |
|
974 if ( success ) |
|
975 { |
|
976 TBuf8<KSendUiProgressStringSize> progressBuf = op->ProgressL(); |
|
977 iMtmUi->DisplayProgressSummary( progressBuf ); |
|
978 } |
|
979 CleanupStack::PopAndDestroy( op ); //op |
|
980 CleanupStack::PopAndDestroy(waiter); // waiter |
|
981 |
|
982 LOGTEXT(_L8("CGenericMtmPlugin::LaunchEditorL <<")); |
|
983 } |
|
984 |
|
985 // --------------------------------------------------------- |
|
986 // StreamStoreL |
|
987 // --------------------------------------------------------- |
|
988 // |
|
989 const CStreamStore& CGenericMtmPlugin::StreamStoreL(TInt) const |
|
990 { |
|
991 return *iStore; |
|
992 } |
|
993 |
|
994 // --------------------------------------------------------- |
|
995 // CGenericMtmPlugin::EmailDefaultServiceL |
|
996 // --------------------------------------------------------- |
|
997 // |
|
998 TMsvId CGenericMtmPlugin::EmailDefaultServiceL() |
|
999 { |
|
1000 TMsvId service = MsvUiServiceUtilitiesInternal::DefaultServiceForMTML( |
|
1001 iSingleton.MsvSessionL(), KSenduiMtmSmtpUid, ETrue); |
|
1002 |
|
1003 if (service == KMsvUnknownServiceIndexEntryId) |
|
1004 { |
|
1005 // Hide wait-note. Email-settings dialog (wizard) status |
|
1006 // pane is dimmed if wait-note is left visible behind settings. |
|
1007 if ( iWaitDialog ) |
|
1008 { |
|
1009 iWaitDialog->MakeVisible( EFalse ); |
|
1010 } |
|
1011 |
|
1012 CAknQueryDialog* dlg = CAknQueryDialog::NewL(CAknQueryDialog::ENoTone); |
|
1013 |
|
1014 if (dlg->ExecuteLD(R_SENDUI_CREATE_MAILBOX_CONFIRMATION_QUERY)) |
|
1015 { |
|
1016 CEikStatusPane* sp = static_cast<CEikonEnv&>( iCoeEnv ).AppUiFactory()->StatusPane(); |
|
1017 CAknContextPane* cp = (CAknContextPane *) |
|
1018 sp->ControlL(TUid::Uid(EEikStatusPaneUidContext)); |
|
1019 |
|
1020 // switch layout (e.g. from phone idle layout is different). |
|
1021 TInt current = sp->CurrentLayoutResId(); |
|
1022 if (current != R_AVKON_STATUS_PANE_LAYOUT_USUAL) |
|
1023 { |
|
1024 sp->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_USUAL); |
|
1025 sp->MakeVisible(ETrue); |
|
1026 } |
|
1027 |
|
1028 iIndexEntry = TMsvEntry(); |
|
1029 iIndexEntry.iMtm = KSenduiMtmSmtpUid; |
|
1030 iIndexEntry.iType.iUid = KUidMsvServiceEntryValue; |
|
1031 iIndexEntry.iDate.UniversalTime(); |
|
1032 |
|
1033 CMsvEntry* centry = iSingleton.MsvSessionL().GetEntryL(KMsvRootIndexEntryId); |
|
1034 CleanupStack::PushL(centry); |
|
1035 |
|
1036 CSendUiOperationWait* waiter = CSendUiOperationWait::NewLC(); |
|
1037 |
|
1038 CMsvOperation* op = |
|
1039 iMtmUi->CreateL( iIndexEntry, *centry, waiter->iStatus ); |
|
1040 CleanupStack::PushL(op); |
|
1041 |
|
1042 waiter->Start( op ); |
|
1043 |
|
1044 CleanupStack::PopAndDestroy( 3, centry ) ; // op, waiter, centry |
|
1045 service = MsvUiServiceUtilitiesInternal::DefaultServiceForMTML( |
|
1046 iSingleton.MsvSessionL(), KSenduiMtmSmtpUid, ETrue); |
|
1047 |
|
1048 if (current != R_AVKON_STATUS_PANE_LAYOUT_USUAL) |
|
1049 { |
|
1050 sp->SwitchLayoutL(current); |
|
1051 sp->MakeVisible(ETrue); |
|
1052 } |
|
1053 |
|
1054 // Display wait note while editor starts |
|
1055 if ( iWaitDialog ) |
|
1056 { |
|
1057 iWaitDialog->MakeVisible( ETrue ); |
|
1058 } |
|
1059 } |
|
1060 } |
|
1061 |
|
1062 if (service == KMsvUnknownServiceIndexEntryId) |
|
1063 { |
|
1064 // User canceled creating mailbox. |
|
1065 // Leaving now pops cleanupstack filled earlier. |
|
1066 User::Leave(KLeaveWithoutAlert); |
|
1067 } |
|
1068 |
|
1069 return service; |
|
1070 } |
|
1071 |
|
1072 // --------------------------------------------------------- |
|
1073 // RemoveIllegalChars < and > characters |
|
1074 // --------------------------------------------------------- |
|
1075 // |
|
1076 void CGenericMtmPlugin::RemoveIllegalChars( TPtr& aCheckedString) |
|
1077 { |
|
1078 TInt stringLength = aCheckedString.Length(); |
|
1079 |
|
1080 while(stringLength--) |
|
1081 { |
|
1082 if ( aCheckedString[stringLength] == KSendUiMsgAddressStartChar || |
|
1083 aCheckedString[stringLength] == KSendUiMsgAddressEndChar) |
|
1084 { |
|
1085 aCheckedString[stringLength] = CEditableText::ESpace; |
|
1086 } |
|
1087 } |
|
1088 aCheckedString.TrimAll(); |
|
1089 } |
|
1090 |
|
1091 // --------------------------------------------------------- |
|
1092 // Checks if the given feature is supported |
|
1093 // --------------------------------------------------------- |
|
1094 // |
|
1095 TBool CGenericMtmPlugin::IsSupported( const TUint& aFeature ) |
|
1096 { |
|
1097 return iSendUiFeatureFlags & aFeature; |
|
1098 } |
|
1099 |
|
1100 // --------------------------------------------------------- |
|
1101 // IsCallOngoing |
|
1102 // --------------------------------------------------------- |
|
1103 // |
|
1104 TBool CGenericMtmPlugin::IsCallOngoing( |
|
1105 TDes& aPhoneNumberString, |
|
1106 TDes& aName ) |
|
1107 { |
|
1108 LOGTEXT(_L8("CGenericMtmPlugin::IsCallOngoing >>")); |
|
1109 |
|
1110 TBool phoneNumberStringFound( EFalse ); |
|
1111 TInt error(KErrNone); |
|
1112 if( IsSupported( KSendUiFeatureSFI ) ) |
|
1113 { |
|
1114 error = RProperty::Get( |
|
1115 KPSUidTelRemotePartyInformation, |
|
1116 KTelCLINumber, |
|
1117 aPhoneNumberString ); |
|
1118 |
|
1119 if( error == KErrNone && aPhoneNumberString != KNullDesC16 ) |
|
1120 { |
|
1121 phoneNumberStringFound = ETrue; |
|
1122 error = RProperty::Get( |
|
1123 KPSUidTelRemotePartyInformation, |
|
1124 KTelCLIName, |
|
1125 aName ); |
|
1126 } |
|
1127 } |
|
1128 LOGTEXT(_L8("CGenericMtmPlugin::IsCallOngoing <<")); |
|
1129 return phoneNumberStringFound; |
|
1130 } |
|
1131 |
|
1132 // --------------------------------------------------------- |
|
1133 // Sends Bluetooth message using AIW |
|
1134 // --------------------------------------------------------- |
|
1135 // |
|
1136 void CGenericMtmPlugin::SendBtMessageL( CArrayPtrFlat<CSendUiAttachment>* aAttachments ) |
|
1137 { |
|
1138 LOGTEXT(_L8("CGenericMtmPlugin::SendBtMessageL >>")); |
|
1139 |
|
1140 TInt i = 0; |
|
1141 |
|
1142 CAiwGenericParamList* paramList = CAiwGenericParamList::NewLC(); |
|
1143 |
|
1144 // Go through attachments |
|
1145 TInt attaCount = aAttachments->Count(); |
|
1146 |
|
1147 while ( i < attaCount ) |
|
1148 { |
|
1149 CSendUiAttachment& attachment = *(aAttachments->At(i)); |
|
1150 |
|
1151 if ( attachment.Type() == CSendUiAttachment::EAttachmentPath ) |
|
1152 { |
|
1153 TAiwGenericParam filePath( EGenericParamFile, *attachment.Path() ); |
|
1154 paramList->AppendL( filePath ); |
|
1155 } |
|
1156 else |
|
1157 { |
|
1158 TAiwGenericParam fileHandle( EGenericParamFile, *attachment.Handle() ); |
|
1159 paramList->AppendL( fileHandle ); |
|
1160 } |
|
1161 i++; |
|
1162 } |
|
1163 CAiwServiceHandler* serviceHandler = CAiwServiceHandler::NewLC(); |
|
1164 serviceHandler->AttachL( R_SENDUI_BASEINTEREST ); |
|
1165 iWaitDialog->MakeVisible(EFalse); |
|
1166 // Give file list to Service Handler |
|
1167 serviceHandler->ExecuteServiceCmdL( |
|
1168 KAiwCmdSend, |
|
1169 *paramList , |
|
1170 serviceHandler->OutParamListL()); |
|
1171 |
|
1172 CleanupStack::PopAndDestroy( 2, paramList ); // serviceHandler, paramList |
|
1173 |
|
1174 LOGTEXT(_L8("CGenericMtmPlugin::SendBtMessageL <<")); |
|
1175 } |
|
1176 |
|
1177 // --------------------------------------------------------- |
|
1178 // Calls MTM UI validate service function |
|
1179 // (other items were commented in a header). |
|
1180 // --------------------------------------------------------- |
|
1181 // |
|
1182 TBool CGenericMtmPlugin::IsValidServiceL() |
|
1183 { |
|
1184 TPckgBuf<TBool> paramPack( ETrue ); |
|
1185 |
|
1186 // This is not actually used. |
|
1187 CMsvEntrySelection* dummySelection = new ( ELeave ) CMsvEntrySelection; |
|
1188 CleanupStack::PushL( dummySelection ); |
|
1189 |
|
1190 iMtmUi->InvokeSyncFunctionL( KMtmUiFunctionValidateService, |
|
1191 *dummySelection, |
|
1192 paramPack ); |
|
1193 |
|
1194 CleanupStack::PopAndDestroy( dummySelection ); |
|
1195 |
|
1196 return ( KErrNone == paramPack() ); |
|
1197 } |
|
1198 |
|
1199 |
|
1200 // --------------------------------------------------------- |
|
1201 // ValidateMtmL |
|
1202 // |
|
1203 // Returns |
|
1204 // |
|
1205 // ETrue, if service supports validate service and service is valid |
|
1206 // ETrue, if service does not support validate service |
|
1207 // EFalse, if service supports validate service, but service is not valid |
|
1208 // --------------------------------------------------------- |
|
1209 // |
|
1210 TBool CGenericMtmPlugin::ValidateMtmL() |
|
1211 { |
|
1212 TBool serviceOk = ETrue; |
|
1213 TInt supportsValidateService = 0; |
|
1214 |
|
1215 const TUid uidQuery = { KUidMsvMtmQuerySupportValidateService }; |
|
1216 |
|
1217 TInt supported = ( KErrNone == iMtmUi->QueryCapability( |
|
1218 uidQuery, supportsValidateService ) ); |
|
1219 |
|
1220 if ( supported && supportsValidateService ) |
|
1221 { |
|
1222 serviceOk = IsValidServiceL(); |
|
1223 } |
|
1224 return serviceOk; |
|
1225 } |
|
1226 |
|
1227 // --------------------------------------------------------- |
|
1228 // GetAndValidateServiceL |
|
1229 // --------------------------------------------------------- |
|
1230 // |
|
1231 TMsvId CGenericMtmPlugin::GetAndValidateServiceL( |
|
1232 TUid& aMtmUid, |
|
1233 TBool aLaunchEmbedded, |
|
1234 TBool& aContinue ) |
|
1235 { |
|
1236 LOGTEXT(_L8("CGenericMtmPlugin::GetAndvalidateServiceL >>")); |
|
1237 aContinue = ETrue; |
|
1238 TMsvId service = KMsvUnknownServiceIndexEntryId; |
|
1239 TUid previousMtmUid( aMtmUid ); |
|
1240 |
|
1241 if (aLaunchEmbedded) |
|
1242 { |
|
1243 if (aMtmUid == KSenduiMtmSmtpUid) |
|
1244 { |
|
1245 if( IsSupported( KSendUiFeatureSelectableEmail ) && |
|
1246 !CMceSettingsEmailSel::ShowSelectEmailDlgL( service, |
|
1247 aMtmUid, iRequiredCapabilities ) ) |
|
1248 { |
|
1249 return KMsvUnknownServiceIndexEntryId; |
|
1250 } |
|
1251 |
|
1252 if ( previousMtmUid != aMtmUid ) |
|
1253 { |
|
1254 delete iMtmUi; iMtmUi = NULL; |
|
1255 delete iClientMtm; iClientMtm = NULL; |
|
1256 |
|
1257 iClientMtm = iSingleton.ClientMtmRegistryL().NewMtmL( aMtmUid ); |
|
1258 iMtmUi = iSingleton.MtmUiRegistryL().NewMtmUiL( *iClientMtm ); |
|
1259 } |
|
1260 |
|
1261 if( service == KMsvUnknownServiceIndexEntryId ) |
|
1262 { |
|
1263 service = EmailDefaultServiceL(); |
|
1264 } |
|
1265 } |
|
1266 else |
|
1267 { |
|
1268 service = MsvUiServiceUtilitiesInternal::DefaultServiceForMTML( |
|
1269 iSingleton.MsvSessionL(), aMtmUid, ETrue); |
|
1270 } |
|
1271 } |
|
1272 else |
|
1273 { |
|
1274 if( IsSupported( KSendUiFeatureSelectableEmail ) && |
|
1275 aMtmUid == KSenduiMtmSmtpUid ) |
|
1276 { |
|
1277 if ( !CMceSettingsEmailSel::ShowSelectEmailDlgL( service, |
|
1278 aMtmUid, iRequiredCapabilities ) ) |
|
1279 { |
|
1280 return KMsvUnknownServiceIndexEntryId; |
|
1281 } |
|
1282 |
|
1283 if ( previousMtmUid != aMtmUid ) |
|
1284 { |
|
1285 delete iMtmUi; iMtmUi = NULL; |
|
1286 delete iClientMtm; iClientMtm = NULL; |
|
1287 |
|
1288 iClientMtm = iSingleton.ClientMtmRegistryL().NewMtmL( aMtmUid ); |
|
1289 iMtmUi = iSingleton.MtmUiRegistryL().NewMtmUiL( *iClientMtm ); |
|
1290 } |
|
1291 |
|
1292 } |
|
1293 else |
|
1294 { |
|
1295 service = MsvUiServiceUtilitiesInternal::DefaultServiceForMTML( |
|
1296 iSingleton.MsvSessionL(), aMtmUid, ETrue); |
|
1297 } |
|
1298 // If stand-alone launch requested and service is not OK, show error note. |
|
1299 // This is mainly for phone idle "New message" function which does not |
|
1300 // like possible settings dialogs hanging around... |
|
1301 if ( !ValidateMtmL() ) |
|
1302 { |
|
1303 CAknGlobalNote* note = CAknGlobalNote::NewL(); |
|
1304 CleanupStack::PushL( note ); |
|
1305 |
|
1306 HBufC* text = NULL; |
|
1307 text = StringLoader::LoadLC( R_SENDUI_SETTINGS_NOT_OK, &iCoeEnv ); |
|
1308 note->ShowNoteL( EAknGlobalErrorNote, *text ); |
|
1309 CleanupStack::PopAndDestroy( 2, note ); // note, stringLoader |
|
1310 aContinue = EFalse; |
|
1311 } |
|
1312 } |
|
1313 LOGTEXT(_L8("CGenericMtmPlugin::GetAndvalidateServiceL <<")); |
|
1314 return service; |
|
1315 } |
|
1316 |
|
1317 // --------------------------------------------------------- |
|
1318 // GetMtmSendingCapabilitiesL |
|
1319 // --------------------------------------------------------- |
|
1320 // |
|
1321 void CGenericMtmPlugin::GetMtmSendingCapabilitiesL( |
|
1322 CBaseMtmUiData& mtmUiData, |
|
1323 TSendingCapabilities& cap ) |
|
1324 { |
|
1325 cap.iFlags = 0; // reset flags.body and message size resets themselves. |
|
1326 TInt response; |
|
1327 // Query capabilities |
|
1328 mtmUiData.QueryCapability( KUidMtmQueryMaxBodySize, cap.iBodySize ); |
|
1329 mtmUiData.QueryCapability( KUidMtmQueryMaxTotalMsgSize, cap.iMessageSize ); |
|
1330 |
|
1331 if ( mtmUiData.QueryCapability( KUidMtmQuerySupportAttachments, response ) == KErrNone ) |
|
1332 { |
|
1333 cap.iFlags |= TSendingCapabilities::ESupportsAttachments; |
|
1334 } |
|
1335 if ( mtmUiData.QueryCapability( KUidMtmQuerySupportedBody, response ) == KErrNone ) |
|
1336 { |
|
1337 cap.iFlags |= TSendingCapabilities::ESupportsBodyText; |
|
1338 } |
|
1339 if ( mtmUiData.QueryCapability( KUidMsvQuerySupportsBioMsg, response ) == KErrNone ) |
|
1340 { |
|
1341 cap.iFlags |= TSendingCapabilities::ESupportsBioSending; |
|
1342 } |
|
1343 if ( mtmUiData.QueryCapability( TUid::Uid( KUidMsvMtmQuerySupportEditor ), response ) == KErrNone ) |
|
1344 { |
|
1345 cap.iFlags |= TSendingCapabilities::ESupportsEditor; |
|
1346 } |
|
1347 } |
|
1348 |
|
1349 // --------------------------------------------------------- |
|
1350 // IsPostcardContactLink |
|
1351 // --------------------------------------------------------- |
|
1352 // |
|
1353 TBool CGenericMtmPlugin::IsPostcardContactLink( const CArrayPtrFlat<CSendUiAttachment>* aAttachments ) |
|
1354 { |
|
1355 _LIT(KFileName, "X-Nokia-PhonebookId_temp"); |
|
1356 |
|
1357 // Check if attachment is a file containing serialized contact |
|
1358 // link. Such attachment is sent by Phonebook to Postcard. The |
|
1359 // special file is recognized by name. |
|
1360 if ( aAttachments->Count() == 0 ) |
|
1361 { |
|
1362 return EFalse; |
|
1363 } |
|
1364 CSendUiAttachment& attachment = *(aAttachments->At(0)); |
|
1365 return attachment.Type() == CSendUiAttachment::EAttachmentPath |
|
1366 && ( attachment.Path()->Right( KFileName().Length() ).Compare( KFileName ) == 0 ); |
|
1367 |
|
1368 } |
|
1369 |
|
1370 // --------------------------------------------------------- |
|
1371 // ValidateAccountL |
|
1372 // --------------------------------------------------------- |
|
1373 // |
|
1374 TBool CGenericMtmPlugin::ValidateAccountL( CBaseMtmUiData& aMtmUiData, TUid aMtmUid ) |
|
1375 { |
|
1376 LOGTEXT2(_L("ValidateAccountL: %d"), aMtmUid.iUid ); |
|
1377 TInt response = 0; |
|
1378 |
|
1379 // Check to see that accounts (if required) have been set up |
|
1380 TMsvId id; |
|
1381 User::LeaveIfError( |
|
1382 iSingleton.MsvSessionL().GetEntry( KMsvRootIndexEntryId, id, iIndexEntry ) ); |
|
1383 |
|
1384 TInt validAccounts = ETrue; |
|
1385 TMsvEntry serviceEntry; |
|
1386 serviceEntry.iType.iUid = KUidMsvServiceEntryValue; |
|
1387 serviceEntry.iMtm = aMtmUid; |
|
1388 |
|
1389 if ( aMtmUiData.CanCreateEntryL( iIndexEntry, serviceEntry, response ) ) |
|
1390 { |
|
1391 CMsvEntrySelection* accounts = |
|
1392 MsvUiServiceUtilities::GetListOfAccountsWithMTML( |
|
1393 iSingleton.MsvSessionL(), aMtmUid, ETrue ); |
|
1394 |
|
1395 if ( accounts->Count() == 0 ) |
|
1396 { |
|
1397 validAccounts = EFalse; |
|
1398 } |
|
1399 |
|
1400 delete accounts; |
|
1401 accounts = NULL; |
|
1402 } |
|
1403 LOGTEXT2(_L("ValidateAccountL result: %d"), validAccounts ); |
|
1404 |
|
1405 return validAccounts; |
|
1406 } |
|
1407 |
|
1408 // --------------------------------------------------------- |
|
1409 // CGenericMtmPlugin::LoadMtmL |
|
1410 // --------------------------------------------------------- |
|
1411 // |
|
1412 void CGenericMtmPlugin::LoadMtmL( |
|
1413 TUid aMtmType, |
|
1414 RPointerArray<CSendingServiceInfo>& aList ) |
|
1415 { |
|
1416 // these mtm's are not needed, because they don't support sending |
|
1417 if (aMtmType == KSenduiMtmImap4Uid || |
|
1418 aMtmType == KSenduiMtmPop3Uid || |
|
1419 aMtmType == KSenduiMtmPushMtm1Uid || |
|
1420 aMtmType == KSenduiMtmPushMtm2Uid || |
|
1421 aMtmType == KSenduiMtmPushMtm3Uid || |
|
1422 aMtmType == KSenduiMtmPushMtmUid || |
|
1423 aMtmType == KSenduiMtmBioUid || |
|
1424 aMtmType == KSenduiMMSNotificationUid || |
|
1425 aMtmType == KSenduiMtmRoUid |
|
1426 ) |
|
1427 { |
|
1428 return ; |
|
1429 } |
|
1430 |
|
1431 TInt err(KErrNone); |
|
1432 |
|
1433 CBaseMtmUiData* uiData = iSingleton.MtmUiDataRegistryL().NewMtmUiDataLayerL( aMtmType ); |
|
1434 CleanupStack::PushL( uiData ); |
|
1435 TInt response = 0; |
|
1436 |
|
1437 err = uiData->QueryCapability(KUidMtmQueryCanSendMsg, response); |
|
1438 |
|
1439 if ( err ) |
|
1440 { |
|
1441 CleanupStack::PopAndDestroy( uiData ); |
|
1442 if ( err == KErrNotSupported ) |
|
1443 { |
|
1444 return; |
|
1445 } |
|
1446 User::Leave( err ); |
|
1447 } |
|
1448 |
|
1449 CSendingServiceInfo* serviceInfo = CSendingServiceInfo::NewLC(); |
|
1450 serviceInfo->SetServiceId( aMtmType ); |
|
1451 |
|
1452 // the MTM can send messages |
|
1453 const CArrayFix<CBaseMtmUiData::TMtmUiFunction>& funcs = |
|
1454 uiData->MtmSpecificFunctions(); |
|
1455 |
|
1456 TInt i = funcs.Count(); |
|
1457 TBool usingPriorityName( EFalse ); |
|
1458 while (i--) |
|
1459 { |
|
1460 CBaseMtmUiData::TMtmUiFunction func(funcs.At(i)); |
|
1461 if ( func.iFunctionId == KMtmUiFunctionSendAs /*func.iFlags & EMtudCommandSendAs */) |
|
1462 { |
|
1463 serviceInfo->SetServiceMenuNameL( func.iCaption ); |
|
1464 } |
|
1465 else if ( func.iFunctionId == KMtmUiMceWriteMessagePopup ) |
|
1466 { |
|
1467 serviceInfo->SetServiceNameL( func.iCaption ); |
|
1468 usingPriorityName = ETrue; |
|
1469 } |
|
1470 else if ( !usingPriorityName && func.iFlags & EMtudCommandTransferSend ) |
|
1471 { |
|
1472 serviceInfo->SetServiceNameL( func.iCaption ); |
|
1473 } |
|
1474 } |
|
1475 |
|
1476 if ( serviceInfo->ServiceMenuName() == KNullDesC ) |
|
1477 { |
|
1478 // no info available for caption - use the human readable name |
|
1479 serviceInfo->SetServiceMenuNameL( iSingleton.MtmUiDataRegistryL().RegisteredMtmDllInfo( aMtmType ).HumanReadableName() ); |
|
1480 } |
|
1481 |
|
1482 if ( serviceInfo->ServiceName() == KNullDesC ) |
|
1483 { |
|
1484 // no info available for caption - use the human readable name |
|
1485 serviceInfo->SetServiceNameL( |
|
1486 iSingleton.MtmUiDataRegistryL().RegisteredMtmDllInfo( aMtmType ).HumanReadableName() ); |
|
1487 } |
|
1488 |
|
1489 TSendingCapabilities cap; |
|
1490 TInt featureFlags; |
|
1491 |
|
1492 serviceInfo->SetServiceProviderId( KGenericMtmPlugin ); |
|
1493 serviceInfo->SetTechnologyTypeId( iSingleton.ClientMtmRegistryL().TechnologyTypeUid( aMtmType ) ); |
|
1494 |
|
1495 GetMtmSendingCapabilitiesL( *uiData, cap ); |
|
1496 |
|
1497 TBool validAccount = ValidateAccountL( *uiData, aMtmType ); |
|
1498 |
|
1499 serviceInfo->SetServiceCapabilities( cap ); |
|
1500 |
|
1501 featureFlags = 0; |
|
1502 if ( !validAccount ) |
|
1503 { |
|
1504 featureFlags |= CSendingServiceInfo::EServiceInValid; |
|
1505 } |
|
1506 |
|
1507 if ( aMtmType == KSenduiMtmSmsUid || aMtmType == KSenduiMtmMmsUid ) |
|
1508 { |
|
1509 featureFlags |= CSendingServiceInfo::EServiceHidden; |
|
1510 } |
|
1511 |
|
1512 |
|
1513 serviceInfo->SetServiceFeatures( featureFlags ); |
|
1514 |
|
1515 aList.Append( serviceInfo ); |
|
1516 CleanupStack::Pop( serviceInfo); |
|
1517 CleanupStack::PopAndDestroy( uiData ); |
|
1518 LOGTEXT2(_L("Service flags: %d"), featureFlags ); |
|
1519 |
|
1520 } |
|
1521 // end of file |