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