|
1 /* |
|
2 * Copyright (c) 2002 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: Implements UI class for mail viewer application. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "MailLog.h" |
|
19 #include "MsgMailDocument.h" |
|
20 #include <MsgMailViewer.rsg> |
|
21 #include "MsgMailViewerAppUi.h" |
|
22 #include "msgmailviewer.hrh" |
|
23 #include "MsgMailViewerDocument.h" |
|
24 #include <MsgMailUIDs.h> // Application UIDs |
|
25 #include "MsgMailViewerAttachmentsDlg.h" |
|
26 #include "MsgMailPreferences.h" |
|
27 #include "MsgMailViewerCharConv.h" |
|
28 #include "MailUtils.h" |
|
29 #include "Msgmailcharactersethandler.h" |
|
30 #include "MsgMailDRMHandler.h" |
|
31 #include "CMailCRHandler.h" |
|
32 #include "CMailViewManager.h" |
|
33 #include "CMailMessage.h" |
|
34 #include "mailmessageutils.h" |
|
35 #include "CMailMessageView.h" |
|
36 #include "cmailoperation.h" |
|
37 #include "cmsgmailviewerfinditemhandler.h" |
|
38 #include "cmsgmailviewerreplytomatcher.h" |
|
39 #include "cmsgmailviewercontactmatcher.h" |
|
40 #include "cmsgmailviewercontactcaller.h" |
|
41 #include <muiu.mbg> |
|
42 #include <avkon.mbg> |
|
43 #include <bautils.h> |
|
44 #include <CMessageData.h> |
|
45 #include <AknsUtils.h> |
|
46 #include <eikrted.h> |
|
47 #include <aknnotewrappers.h> |
|
48 #include <akncontext.h> |
|
49 #include <eikmop.h> // for SupplyMopObject |
|
50 #include <MsgEditorView.h> |
|
51 #include <MsgAddressControl.h> |
|
52 #include <msvuids.h> // KUidMsvFolderEntry |
|
53 #include <MsgFolderSelectionDialog.h> // CMsgFolderSelectionDialog |
|
54 #include <AknWaitDialog.h> |
|
55 #include <miutpars.h> // TImMessageField |
|
56 #include <mmsvattachmentmanager.h> |
|
57 #include <muiumsvuiserviceutilitiesinternal.h> |
|
58 #include <AiwServiceHandler.h> // aiw |
|
59 #include <MuiuMsvProgressReporterOperation.h> // progress note |
|
60 #include <MsgEditorCommon.h> |
|
61 #include <msgeditor.mbg> |
|
62 #include <MsgEditorAppUi.rsg> // resource identifiers |
|
63 #include <MsgAttachmentModel.h> |
|
64 #include <MsgEditorCommon.h> |
|
65 #include <MsgAttachmentInfo.h> |
|
66 #include <MsgEditorAppUi.hrh> |
|
67 #include <messagingvariant.hrh> |
|
68 #include <MsgAttachmentControl.h> |
|
69 #include <StringLoader.h> |
|
70 #include <akntitle.h> |
|
71 #include <akntoolbar.h> |
|
72 #include <hlplch.h> |
|
73 #include <csxhelp/mail.hlp.hrh> |
|
74 #include <SenduiMtmUids.h> |
|
75 #include <sendui.h> |
|
76 #include <data_caging_path_literals.hrh> |
|
77 #include <featmgr.h> |
|
78 #include <msgvoipextension.h> |
|
79 #include <CommonUiInternalCRKeys.h> |
|
80 #include <MsgEditorAppUiExtension.h>// for iMsgEditorAppUiExtension |
|
81 #include <MsgEditorSettingCacheUpdatePlugin.h> |
|
82 #include <akninputblock.h> // CAknInputBlock |
|
83 |
|
84 |
|
85 // LOCAL CONSTANTS |
|
86 const TInt KMSKControlID(3); |
|
87 |
|
88 enum TInternalFlags |
|
89 { |
|
90 EAttachments = KBit0, |
|
91 EUseBaseBodyControl = KBit1 |
|
92 }; |
|
93 |
|
94 |
|
95 // ================= MEMBER FUNCTIONS ======================= |
|
96 // |
|
97 CMsgMailViewerAppUi::CMsgMailViewerAppUi() |
|
98 : iState(0), iCount(0), |
|
99 iResourceLoader(*iCoeEnv), |
|
100 iMsgVoIPExtension(NULL), |
|
101 iParams(EMailUseDefaultNaviPane), |
|
102 iFlags(0), |
|
103 iAttachmentLoadingOn(EFalse), |
|
104 iDefaultDialerState( EFalse ) // Dialer is disabled by default |
|
105 { |
|
106 } |
|
107 |
|
108 // ------------------------------------------------------------------------------ |
|
109 // CMsgMailViewerAppUi::~CMsgMailViewerAppUi() |
|
110 // Destructor |
|
111 // Frees reserved resources |
|
112 // ------------------------------------------------------------------------------ |
|
113 // |
|
114 CMsgMailViewerAppUi::~CMsgMailViewerAppUi() |
|
115 { |
|
116 LOG("~CMsgMailViewerAppUi destructor"); |
|
117 delete iContactCaller; |
|
118 delete iContactMatcher; |
|
119 delete iReplyToMatcher; |
|
120 delete iFindItemHandler; |
|
121 delete iServiceHandler; |
|
122 delete iText; |
|
123 delete iCharSetHandler; |
|
124 iResourceLoader.Close(); |
|
125 delete iViewManager; |
|
126 delete iMsgVoIPExtension; |
|
127 delete iTitle; |
|
128 // iOperationWatcher can not be deleted if dialog is visible |
|
129 if ( iProgressReporter ) |
|
130 { |
|
131 TRAP_IGNORE( iProgressReporter->MakeProgressVisibleL( EFalse ) ); |
|
132 } |
|
133 delete iOperationWatcher; |
|
134 |
|
135 if(iOpeningWaitDialog) |
|
136 { |
|
137 TRAP_IGNORE(iOpeningWaitDialog->ProcessFinishedL()); |
|
138 } |
|
139 |
|
140 LOG("~CMsgMailViewerAppUi destructor end"); |
|
141 } |
|
142 |
|
143 |
|
144 // ------------------------------------------------------------------------------ |
|
145 // CMsgMailViewerAppUi::ConstructL() |
|
146 // Symbian OS constructor |
|
147 // ------------------------------------------------------------------------------ |
|
148 // |
|
149 void CMsgMailViewerAppUi::ConstructL() |
|
150 { |
|
151 LOGHEAP(); |
|
152 LOG("CMsgMailViewerAppUi::ConstructL"); |
|
153 |
|
154 // the implementation of this virtual function must call |
|
155 // CEikAppUi::ConstructL or CEikAppUi::BaseConstructL |
|
156 // before calling any other leaving function |
|
157 CMsgMailAppUi::ConstructL(); |
|
158 |
|
159 //Set us as an observer for the toolbar |
|
160 if ( PopupToolbar() ) |
|
161 { |
|
162 PopupToolbar()->SetToolbarObserver( this ); |
|
163 PopupToolbar()->SetToolbarVisibility( ETrue, EFalse ); |
|
164 } |
|
165 //Create inpu blocker to prevent unwanted exit event when constructing viewer. |
|
166 CAknInputBlock::NewLC(); |
|
167 |
|
168 iViewManager = CMailViewManager::NewL(); |
|
169 iView = CMsgEditorView::NewL(*this, CMsgEditorView::EMsgReadOnly); |
|
170 |
|
171 //Open wait dialog |
|
172 iOpeningWaitDialog = new(ELeave)CAknWaitDialog( |
|
173 (reinterpret_cast<CEikDialog**>(&iOpeningWaitDialog)), ETrue); |
|
174 |
|
175 // safe to call LD even as a member variable, since sets itself to NULL when deleting |
|
176 iOpeningWaitDialog->ExecuteLD(R_VIEWER_WAIT_OPEN_NOTE); // CSI: 50 # see comment above |
|
177 |
|
178 iMsgVoIPExtension = CMsgVoIPExtension::NewL(); |
|
179 |
|
180 MenuBar()->SetContextMenuTitleResourceId(R_MSGMAILVIEWER_CONTEXT_MENUBAR); |
|
181 |
|
182 iFindItemHandler = CMsgMailViewerFindItemHandler::NewL( |
|
183 iView->ItemFinder() ); |
|
184 |
|
185 iServiceHandler = CAiwServiceHandler::NewL(); |
|
186 |
|
187 iContactMatcher = CMsgMailViewerContactMatcher::NewL( *iServiceHandler ); |
|
188 iContactCaller = CMsgMailViewerContactCaller::NewL( *iServiceHandler, |
|
189 *iContactMatcher ); |
|
190 iReplyToMatcher = CMsgMailViewerReplyToMatcher::NewL(*this, *iContactMatcher); |
|
191 |
|
192 #ifdef RD_MSG_NAVIPANE_IMPROVEMENT |
|
193 iNaviPane = static_cast<CAknNavigationControlContainer*> |
|
194 ( StatusPane( )->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) ); |
|
195 #endif //RD_MSG_NAVIPANE_IMPROVEMENT |
|
196 |
|
197 // Reset Dialer's state |
|
198 SetDialerEnabled( iDefaultDialerState ); |
|
199 |
|
200 CleanupStack::PopAndDestroy(); // CAknInputBlock |
|
201 LOG("CMsgMailViewerAppUi::ConstructL -> End"); |
|
202 LOGHEAP(); |
|
203 } |
|
204 |
|
205 // ------------------------------------------------------------------------------ |
|
206 // void CMsgMailViewerAppUi::LaunchViewL |
|
207 // Opens received mail. |
|
208 // ------------------------------------------------------------------------------ |
|
209 // |
|
210 void CMsgMailViewerAppUi::LaunchViewL() |
|
211 { |
|
212 LOGHEAP(); |
|
213 LOG("CMsgMailViewerAppUi::LaunchViewL"); |
|
214 Document()->MailMessage().LoadMessageL(*this); |
|
215 |
|
216 // If mail is in sent folder, then Dialer is enabled |
|
217 iDefaultDialerState = |
|
218 MailMessageUtils::IsOutgoingL( Document()->MailMessage() ); |
|
219 SetDialerEnabled( iDefaultDialerState ); |
|
220 |
|
221 // Dims a delete button from the toolbar if the mail is an attachment mail. |
|
222 if( IsAttachment() ) |
|
223 { |
|
224 if( PopupToolbar() ) |
|
225 { |
|
226 PopupToolbar()->SetItemDimmed( EMsgMailViewerCmdDelete, ETrue, ETrue ); |
|
227 } |
|
228 } |
|
229 |
|
230 LOG("CMsgMailViewerAppUi::LaunchViewL -> End"); |
|
231 LOGHEAP(); |
|
232 } |
|
233 |
|
234 // ------------------------------------------------------------------------------ |
|
235 // CMsgMailViewerAppUi::::DynInitMenuPaneL() |
|
236 // ------------------------------------------------------------------------------ |
|
237 // |
|
238 void CMsgMailViewerAppUi::DynInitMenuPaneL( |
|
239 TInt aResourceId, |
|
240 CEikMenuPane* aMenuPane ) |
|
241 { |
|
242 SetContextBackToMessageL(); |
|
243 |
|
244 CMsgAddressControl* addrCtrl = FocusedOrFirstAddressControl(); |
|
245 iFindItemHandler->DynInitMenuPaneL( aResourceId, |
|
246 aMenuPane, |
|
247 FirstRecipientAddressL( addrCtrl ), |
|
248 FirstRecipientNameL( addrCtrl ), |
|
249 FocusedControlId() ); |
|
250 |
|
251 iContactCaller->DynInitMenuPaneL( aResourceId, |
|
252 aMenuPane, |
|
253 CanMakeCallToContactL() ); |
|
254 |
|
255 switch ( aResourceId ) |
|
256 { |
|
257 case R_MSGMAILVIEWER_OPTIONS_MENU1: |
|
258 { |
|
259 DynInitOptionsMenu1L( *aMenuPane ); |
|
260 break; |
|
261 } |
|
262 case R_MSGMAILVIEWER_OPTIONS_MENU2: |
|
263 { |
|
264 DynInitOptionsMenu2L( *aMenuPane ); |
|
265 break; |
|
266 } |
|
267 |
|
268 case R_MSGMAILVIEWER_REPLY_MENU: |
|
269 { |
|
270 // Hide reply to all if only one recipient |
|
271 aMenuPane->SetItemDimmed( |
|
272 EMsgMailViewerCmdReplyAll, |
|
273 DoHideReplyToAll() ); |
|
274 |
|
275 // Hide reply to sender if from field is empty |
|
276 aMenuPane->SetItemDimmed( |
|
277 EMsgMailViewerCmdReplySender, |
|
278 DoHideReplyToSender() ); |
|
279 |
|
280 // received mail |
|
281 if ( !MailMessageUtils::IsOutgoingL( Document()->MailMessage() ) ) |
|
282 { |
|
283 // unieditor |
|
284 aMenuPane->SetItemDimmed( |
|
285 EMsgMailViewerCmdReplyViaUnified, |
|
286 !ValidateServiceL( KSenduiMtmUniMessageUid ) ); |
|
287 |
|
288 // Reply via Audio msg |
|
289 aMenuPane->SetItemDimmed( |
|
290 EMsgMailViewerCmdReplyViaAudio, |
|
291 !ValidateServiceL( KSenduiMtmAudioMessageUid ) ); |
|
292 } |
|
293 else |
|
294 { |
|
295 // reply to all is visible in sent items |
|
296 aMenuPane->SetItemDimmed(EMsgMailViewerCmdReplyAll, |
|
297 !HasAnyAddressFieldText()); |
|
298 aMenuPane->SetItemDimmed(EMsgMailViewerCmdReplySender, ETrue); |
|
299 } |
|
300 |
|
301 break; |
|
302 } |
|
303 case R_MSGMAILVIEWER_CHARSET_MENU: |
|
304 { |
|
305 iCharSetHandler->SetCharacterSetSubMenuItemsL( |
|
306 *aMenuPane, |
|
307 Document()->Charset()); |
|
308 |
|
309 break; |
|
310 } |
|
311 case R_MSGMAILVIEWER_ZOOM_SUBMENU: |
|
312 { |
|
313 TInt zoomLevel = KErrGeneral; |
|
314 iMsgEditorAppUiExtension-> |
|
315 iSettingCachePlugin.GetValue( KAknLocalZoomLayoutSwitch, zoomLevel ); |
|
316 switch ( zoomLevel ) |
|
317 { |
|
318 case EAknUiZoomAutomatic: |
|
319 aMenuPane->SetItemButtonState( EMsgDispSizeAutomatic, |
|
320 EEikMenuItemSymbolOn ); |
|
321 break; |
|
322 case EAknUiZoomNormal: |
|
323 aMenuPane->SetItemButtonState( EMsgDispSizeNormal, |
|
324 EEikMenuItemSymbolOn ); |
|
325 break; |
|
326 case EAknUiZoomSmall: |
|
327 aMenuPane->SetItemButtonState( EMsgDispSizeSmall, |
|
328 EEikMenuItemSymbolOn ); |
|
329 break; |
|
330 case EAknUiZoomLarge: |
|
331 aMenuPane->SetItemButtonState( EMsgDispSizeLarge, |
|
332 EEikMenuItemSymbolOn ); |
|
333 break; |
|
334 default: |
|
335 ASSERT(0); |
|
336 break; |
|
337 } |
|
338 } |
|
339 break; |
|
340 |
|
341 default: |
|
342 { |
|
343 break; |
|
344 } |
|
345 } |
|
346 |
|
347 // forwart to Plugin |
|
348 MMailMessageView* messageView = iViewManager->ViewPlugin(); |
|
349 if ( messageView ) |
|
350 { |
|
351 messageView->DynInitMenuPaneL(aResourceId, aMenuPane); |
|
352 } |
|
353 } |
|
354 |
|
355 |
|
356 // -------------------------------------------------------------------------------------- |
|
357 // CMsgMailViewerAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
358 // Handles key press events |
|
359 // -------------------------------------------------------------------------------------- |
|
360 // |
|
361 TKeyResponse CMsgMailViewerAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent, |
|
362 TEventCode aType) |
|
363 { |
|
364 // still launching application |
|
365 if ( !Document()->IsLaunched() ) |
|
366 { |
|
367 return EKeyWasConsumed; |
|
368 } |
|
369 |
|
370 if (iView) |
|
371 { |
|
372 switch (aKeyEvent.iCode) |
|
373 { |
|
374 case EKeyLeftArrow: |
|
375 { |
|
376 if ( (iParams & EMailUseDefaultNaviPane) && |
|
377 IsNextMessageAvailableL(EFalse) ) |
|
378 { |
|
379 NextMessageL(EFalse); |
|
380 } |
|
381 break; |
|
382 } |
|
383 case EKeyRightArrow: |
|
384 { |
|
385 if ( (iParams & EMailUseDefaultNaviPane) && |
|
386 IsNextMessageAvailableL(ETrue) ) |
|
387 { |
|
388 NextMessageL(ETrue); |
|
389 } |
|
390 break; |
|
391 } |
|
392 case EKeyBackspace: |
|
393 { |
|
394 // Checks if this mail is an attachment mail. |
|
395 if( !IsAttachment() ) |
|
396 { |
|
397 HandleCommandL(EMsgMailViewerCmdDelete); |
|
398 } |
|
399 break; |
|
400 } |
|
401 case EKeyEnter: |
|
402 { |
|
403 HandleEnterKeyL(); |
|
404 break; |
|
405 } |
|
406 case EKeyYes: |
|
407 { |
|
408 HandleEKeyYesL(); |
|
409 // FALLTROUGH |
|
410 } |
|
411 default: |
|
412 { |
|
413 TKeyResponse consumed = SpecialScrolling( aKeyEvent.iCode ) ? |
|
414 EKeyWasConsumed : iView->OfferKeyEventL(aKeyEvent, aType); |
|
415 if (consumed == EKeyWasNotConsumed) |
|
416 { |
|
417 // forwart to Plugin |
|
418 MMailMessageView* plugin = iViewManager->ViewPlugin(); |
|
419 if (plugin && plugin->HandleKeyEventL( |
|
420 aKeyEvent, aType) == EKeyWasConsumed) |
|
421 { |
|
422 consumed = EKeyWasConsumed; |
|
423 } |
|
424 |
|
425 } |
|
426 return consumed; |
|
427 } |
|
428 |
|
429 } |
|
430 |
|
431 |
|
432 return EKeyWasConsumed; |
|
433 } |
|
434 else |
|
435 { |
|
436 // Just in case base class wants to do something |
|
437 return CMsgMailAppUi::HandleKeyEventL(aKeyEvent, aType); |
|
438 } |
|
439 } |
|
440 |
|
441 // ------------------------------------------------------------------------------ |
|
442 // CMsgMailViewerAppUi::HandleCommandL(TInt aCommand) |
|
443 // Command handler |
|
444 // ------------------------------------------------------------------------------ |
|
445 // |
|
446 void CMsgMailViewerAppUi::HandleCommandL(TInt aCommand) |
|
447 { |
|
448 // still launching application |
|
449 if ( aCommand != EEikCmdExit && !Document()->IsLaunched() ) |
|
450 { |
|
451 return; |
|
452 } |
|
453 TBool isExternalCmd( EFalse ); |
|
454 MAIL_ALLOC_TEST( isExternalCmd = HandleExternalCmdL( aCommand ) ); |
|
455 if ( !isExternalCmd ) |
|
456 { |
|
457 MAIL_ALLOC_TEST( HandleInternalCmdL( aCommand ) ); |
|
458 } |
|
459 } |
|
460 |
|
461 // ----------------------------------------------------------------------------- |
|
462 // CMsgMailViewerAppUi::HandleNaviDecoratorEventL( TInt aEventID ) |
|
463 // Handles the touch-ui related control events for next/previous arrows |
|
464 // ----------------------------------------------------------------------------- |
|
465 // |
|
466 #ifdef RD_SCALABLE_UI_V2 |
|
467 void CMsgMailViewerAppUi::HandleNaviDecoratorEventL( TInt aEventID ) |
|
468 { |
|
469 if ( AknLayoutUtils::PenEnabled() && |
|
470 IsNextMessageAvailableL( aEventID == EAknNaviDecoratorEventRightTabArrow ) ) |
|
471 { |
|
472 NextMessageL( aEventID == EAknNaviDecoratorEventRightTabArrow ); |
|
473 } |
|
474 } |
|
475 |
|
476 #endif // RD_SCALABLE_UI_V2 |
|
477 |
|
478 // ---------------------------------------------------------------------------- |
|
479 // CMsgMailViewerAppUi::DynInitToolbarL |
|
480 // ---------------------------------------------------------------------------- |
|
481 // |
|
482 void CMsgMailViewerAppUi::DynInitToolbarL( TInt /*aResourceId*/, CAknToolbar* /*aToolbar*/ ) |
|
483 { |
|
484 } |
|
485 |
|
486 // ---------------------------------------------------------------------------- |
|
487 // CMsgMailViewerAppUi::OfferToolbarEventL |
|
488 // ---------------------------------------------------------------------------- |
|
489 // |
|
490 void CMsgMailViewerAppUi::OfferToolbarEventL( TInt aCommand ) |
|
491 { |
|
492 HandleCommandL( aCommand ); |
|
493 } |
|
494 |
|
495 // ------------------------------------------------------------------------------ |
|
496 // void CMsgMailViewerAppUi::DoMsgSaveExitL. |
|
497 // ------------------------------------------------------------------------------ |
|
498 // |
|
499 void CMsgMailViewerAppUi::DoMsgSaveExitL() |
|
500 { |
|
501 Exit(); |
|
502 } |
|
503 |
|
504 // ------------------------------------------------------------------------------ |
|
505 // void CMsgMailViewerAppUi::DoDeleteL |
|
506 // Asks confirmation from user and calls DeleteAndExitL |
|
507 // in MsgEditorAppUi which deletes the message and closes mail viewer. |
|
508 // ------------------------------------------------------------------------------ |
|
509 // |
|
510 void CMsgMailViewerAppUi::DoDeleteL() |
|
511 { |
|
512 CMsgMailViewerDocument* doc = Document(); |
|
513 |
|
514 const TMsvId owningService( doc->CurrentEntry().OwningService() ); |
|
515 |
|
516 if ( owningService == KMsvLocalServiceIndexEntryIdValue ) |
|
517 { // local entry |
|
518 if ( MailUtils::ConfirmationQueryL( R_MAIL_QUEST_DELETE_MSG ) ) |
|
519 { |
|
520 DeleteAndExitL(); |
|
521 } |
|
522 return; |
|
523 } |
|
524 // check if operation was canceled |
|
525 if ( !doc->DeleteMessageL() ) |
|
526 { |
|
527 Exit( EAknSoftkeyBack ); |
|
528 } |
|
529 } |
|
530 |
|
531 // ------------------------------------------------------------------------------ |
|
532 // CMsgMailViewerAppUi::HelpContextL |
|
533 // ------------------------------------------------------------------------------ |
|
534 // |
|
535 CArrayFix<TCoeHelpContext>* CMsgMailViewerAppUi::HelpContextL( ) const |
|
536 { |
|
537 CArrayFix<TCoeHelpContext>* helpArray = |
|
538 new( ELeave ) CArrayFixFlat<TCoeHelpContext>( 1 ); |
|
539 CleanupStack::PushL( helpArray ); |
|
540 // This uses the editor's UID, because there's only one help file |
|
541 helpArray->AppendL( TCoeHelpContext( TUid::Uid( KUidMsgMailEditor ), |
|
542 KMAIL_HLP_MAIL_VIEWER() ) ); |
|
543 CleanupStack::Pop( helpArray ); |
|
544 return helpArray; |
|
545 } |
|
546 |
|
547 // ------------------------------------------------------------------------------ |
|
548 // CMsgMailViewerAppUi::AddAttachmentL() |
|
549 // ------------------------------------------------------------------------------ |
|
550 // |
|
551 void CMsgMailViewerAppUi::AddAttachmentL( |
|
552 CMsvAttachment& aAttachmentInfo, |
|
553 TBool aCanBeRemoved ) |
|
554 { |
|
555 if( !iMessageReload ) |
|
556 { |
|
557 CMsgMailViewerDocument* doc = Document(); |
|
558 |
|
559 // Check if attachment is already added. |
|
560 CMsgAttachmentModel& model = doc->AttachmentModel(); |
|
561 TBool duplicate = model.IsIdAttached( aAttachmentInfo.Id() ); |
|
562 if( duplicate ) |
|
563 { |
|
564 // Remove the previous inline attachment. In IMAP email the inline |
|
565 // image does not always have size information included. So it's |
|
566 // replaced with more informative attachment. Inline attachments are |
|
567 // added first so the duplicate is always a regular attachment. |
|
568 for( TInt i = model.NumberOfItems() - 1; i >= 0; --i ) |
|
569 { |
|
570 CMsgAttachmentInfo& info = model.AttachmentInfoAt( i ); |
|
571 if( info.AttachmentId() == aAttachmentInfo.Id() ) |
|
572 { |
|
573 model.DeleteAttachment( i ); |
|
574 break; |
|
575 } |
|
576 } |
|
577 } |
|
578 |
|
579 doc->AddAttachmentL( aAttachmentInfo, aCanBeRemoved ); |
|
580 if ( doc->MailCRHandler()->MailAttachmentField() && !duplicate ) |
|
581 { |
|
582 DoCreateAttachmentControlL(); |
|
583 |
|
584 TParsePtrC fileParser( aAttachmentInfo.AttachmentName() ); |
|
585 AttachmentControl()->AppendAttachmentL( |
|
586 fileParser.NameAndExt() ); |
|
587 } |
|
588 iFlags |= EAttachments; |
|
589 DoUpdateNaviPaneL(); |
|
590 |
|
591 // If attatchment dialog is already opened |
|
592 // update its list also |
|
593 if (iAttachmentdlg) |
|
594 { |
|
595 iAttachmentdlg->UpdateAttatchmentListL(); |
|
596 } |
|
597 } |
|
598 } |
|
599 |
|
600 // ------------------------------------------------------------------------------ |
|
601 // CMsgMailViewerAppUi::AddControlL() |
|
602 // ------------------------------------------------------------------------------ |
|
603 // |
|
604 void CMsgMailViewerAppUi::AddControlL(TInt aControlType) |
|
605 { |
|
606 if(! iView->ControlById( aControlType ) ) |
|
607 { |
|
608 TInt resourceId(0); |
|
609 TInt controlType(0); |
|
610 |
|
611 switch (aControlType) |
|
612 { |
|
613 case EMsgComponentIdTo: |
|
614 { |
|
615 resourceId = R_MAIL_VIEWER_TO; |
|
616 controlType = EMsgAddressControl; |
|
617 break; |
|
618 } |
|
619 case EMsgComponentIdFrom: |
|
620 { |
|
621 resourceId = R_MAIL_VIEWER_FROM; |
|
622 controlType = EMsgAddressControl; |
|
623 break; |
|
624 } |
|
625 case EMsgComponentIdCc: |
|
626 { |
|
627 resourceId = R_MAIL_VIEWER_CC; |
|
628 controlType = EMsgAddressControl; |
|
629 break; |
|
630 } |
|
631 case EMsgComponentIdBcc: |
|
632 { |
|
633 resourceId = R_MAIL_VIEWER_BCC; |
|
634 controlType = EMsgAddressControl; |
|
635 break; |
|
636 } |
|
637 case EMsgComponentIdSubject: |
|
638 { |
|
639 resourceId = R_MAIL_VIEWER_SUBJECT; |
|
640 controlType = EMsgExpandableControl; |
|
641 break; |
|
642 } |
|
643 default: |
|
644 User::Leave(KErrNotSupported); |
|
645 break; |
|
646 } |
|
647 iView->AddControlFromResourceL( |
|
648 resourceId, controlType, |
|
649 iState, EMsgHeader); |
|
650 |
|
651 iState = EMsgAppendControl; |
|
652 } |
|
653 } |
|
654 // ------------------------------------------------------------------------------ |
|
655 // CMsgMailViewerAppUi::AddControlL() |
|
656 // ------------------------------------------------------------------------------ |
|
657 // |
|
658 void CMsgMailViewerAppUi::AddControlL(CCoeControl& aControl) |
|
659 { |
|
660 iViewManager->AddBodyControlL( iView, aControl ); |
|
661 iState = EMsgAppendControl; |
|
662 iFlags &= ~EUseBaseBodyControl; |
|
663 } |
|
664 |
|
665 // ------------------------------------------------------------------------------ |
|
666 // CMsgMailViewerAppUi::AddControlL() |
|
667 // ------------------------------------------------------------------------------ |
|
668 // |
|
669 void CMsgMailViewerAppUi::AddControlL(MMailMsgBaseControl& aControl) |
|
670 { |
|
671 iViewManager->AddBodyControlL( iView, aControl ); |
|
672 iState = EMsgAppendControl; |
|
673 iFlags &= ~EUseBaseBodyControl; |
|
674 } |
|
675 // ------------------------------------------------------------------------------ |
|
676 // CMsgMailViewerAppUi::ParentControl() |
|
677 // ------------------------------------------------------------------------------ |
|
678 // |
|
679 CCoeControl& CMsgMailViewerAppUi::ParentControl() |
|
680 { |
|
681 return *iView; |
|
682 } |
|
683 |
|
684 // ------------------------------------------------------------------------------ |
|
685 // CMsgMailViewerAppUi::StatusPane() |
|
686 // ------------------------------------------------------------------------------ |
|
687 // |
|
688 CEikStatusPane* CMsgMailViewerAppUi::StatusPane() |
|
689 { |
|
690 return CAknAppUi::StatusPane(); |
|
691 } |
|
692 |
|
693 // ------------------------------------------------------------------------------ |
|
694 // CMsgMailViewerAppUi::ShowWaitNoteL() |
|
695 // ------------------------------------------------------------------------------ |
|
696 // |
|
697 void CMsgMailViewerAppUi::ShowWaitNoteL( TBool aCanCancel ) |
|
698 { |
|
699 if (!iWaitDialog) |
|
700 { |
|
701 // safe to call LD even as a member variable, |
|
702 // since sets itself to NULL when deleting |
|
703 iWaitDialog = new(ELeave)CAknWaitDialog( |
|
704 (reinterpret_cast<CEikDialog**>( &iWaitDialog )), ETrue); |
|
705 |
|
706 // safe to call LD even as a member variable, since sets itself to NULL when deleting |
|
707 iWaitDialog->ExecuteLD(R_VIEWER_WAIT_OPEN_DIALOG_NOTE); // CSI: 50 # see comment above |
|
708 iWaitDialog->MakePanelButtonVisible( EAknSoftkeyCancel, aCanCancel ); |
|
709 } |
|
710 } |
|
711 |
|
712 // ------------------------------------------------------------------------------ |
|
713 // CMsgMailViewerAppUi::CloseWaitNote() |
|
714 // ------------------------------------------------------------------------------ |
|
715 // |
|
716 void CMsgMailViewerAppUi::CloseWaitNote() |
|
717 { |
|
718 if (iWaitDialog) |
|
719 { |
|
720 LOG("CloseWaitNote 1"); |
|
721 TRAP_IGNORE(iWaitDialog->ProcessFinishedL()); |
|
722 iWaitDialog = NULL; |
|
723 |
|
724 //If attachment dialog exists notify it |
|
725 if(iAttachmentdlg) |
|
726 { |
|
727 iAttachmentdlg->NotifySizeChanged(); |
|
728 } |
|
729 |
|
730 LOG("CloseWaitNote 2"); |
|
731 } |
|
732 } |
|
733 |
|
734 // ------------------------------------------------------------------------------ |
|
735 // CMsgMailViewerAppUi::ForwardOperationLL() |
|
736 // ------------------------------------------------------------------------------ |
|
737 // |
|
738 void CMsgMailViewerAppUi::ForwardOperationL() |
|
739 { |
|
740 CMsvSingleOpWatcher* opwatcher = CMsvSingleOpWatcher::NewLC( *this ); |
|
741 |
|
742 CMsvProgressReporterOperation* reporter = |
|
743 CMsvProgressReporterOperation::NewL( |
|
744 ( (iFlags & EAttachments) || iAttachmentLoadingOn ), // no delay |
|
745 ETrue, // Show wait animation no progress |
|
746 Document()->Session(), |
|
747 opwatcher->iStatus, |
|
748 EMbmAvkonQgn_note_progress ); |
|
749 opwatcher->SetOperation( reporter ); // Takes ownership |
|
750 iProgressReporter = reporter; |
|
751 reporter->SetCanCancelL( EFalse ); // there is nothing to cancel |
|
752 reporter->SetTitleL( ( (iFlags & EAttachments) || iAttachmentLoadingOn ) ? |
|
753 R_QTN_MAIL_WAIT_FETCH_ATT : |
|
754 R_VIEWER_WAIT_OPENING ); |
|
755 |
|
756 iOperation = Document()->ForwardMailMessageL( |
|
757 *reporter, reporter->RequestStatus(), iAttachmentLoadingOn ); |
|
758 reporter->SetOperationL( iOperation ); // Takes ownership |
|
759 // don't allow cancel before there is something to cancel |
|
760 reporter->SetCanCancelL( ETrue ); |
|
761 |
|
762 CleanupStack::Pop( opwatcher ); |
|
763 iOperationWatcher = opwatcher; |
|
764 } |
|
765 |
|
766 // ------------------------------------------------------------------------------ |
|
767 // CMsgMailViewerAppUi::StartWaitNoteL() |
|
768 // ------------------------------------------------------------------------------ |
|
769 // |
|
770 void CMsgMailViewerAppUi::StartWaitNoteL(/*const TDesC& aText*/) |
|
771 { |
|
772 iAttachmentLoadingOn = ETrue; |
|
773 } |
|
774 // ------------------------------------------------------------------------------ |
|
775 // CMsgMailViewerAppUi::StopWaitNote() |
|
776 // ------------------------------------------------------------------------------ |
|
777 // |
|
778 void CMsgMailViewerAppUi::StopWaitNote() |
|
779 { |
|
780 iAttachmentLoadingOn = EFalse; |
|
781 |
|
782 if (iOperation ) |
|
783 { |
|
784 TRAP_IGNORE( iOperation->SuspendL( EFalse ) ); |
|
785 } |
|
786 CloseWaitNote(); |
|
787 } |
|
788 |
|
789 |
|
790 // ------------------------------------------------------------------------------ |
|
791 // CMsgMailViewerAppUi::SetTitleTextL() |
|
792 // ------------------------------------------------------------------------------ |
|
793 // |
|
794 void CMsgMailViewerAppUi::SetTitleTextL(TInt aResourceId) |
|
795 { |
|
796 CAknTitlePane* titlePane = static_cast<CAknTitlePane *> ( |
|
797 StatusPane()->ControlL(TUid::Uid(EEikStatusPaneUidTitle)) ); |
|
798 |
|
799 TResourceReader reader; |
|
800 iCoeEnv->CreateResourceReaderLC( reader, aResourceId ); |
|
801 titlePane->SetFromResourceL(reader); |
|
802 CleanupStack::PopAndDestroy(); // CSI: 12 # CreateResourceReaderLC |
|
803 } |
|
804 |
|
805 // ------------------------------------------------------------------------------ |
|
806 // CMsgMailViewerAppUi::SetAddressFieldTextL() |
|
807 // ------------------------------------------------------------------------------ |
|
808 // |
|
809 void CMsgMailViewerAppUi::SetAddressFieldTextL( |
|
810 TInt aControlType, CDesCArray& aText) |
|
811 { |
|
812 LOG("CMsgMailViewerAppUi::SetAddressFieldTextL"); |
|
813 CMsgAddressControl* addressControl = AddressControl(aControlType); |
|
814 if (addressControl) |
|
815 { |
|
816 TImMessageField msgField; |
|
817 TInt error = KErrNone; |
|
818 const TInt count(aText.Count()); |
|
819 CMsgRecipientList* recips = CMsgRecipientList::NewL(); |
|
820 CleanupStack::PushL(recips); |
|
821 for (TInt i=0; i < count; i++) |
|
822 { |
|
823 HBufC* address = msgField.GetValidInternetEmailAddressFromString( |
|
824 aText[i]).AllocLC(); |
|
825 HBufC* alias = msgField.GetValidAlias( |
|
826 aText[i], error ).AllocLC(); |
|
827 CMsgRecipientItem* reci = CMsgRecipientItem::NewLC( |
|
828 ( error==KErrNone ) ? *alias : KNullDesC(), *address); |
|
829 reci->SetVerified(ETrue); |
|
830 recips->AppendL(reci); |
|
831 CleanupStack::Pop( reci ); // reci, now owned by the array |
|
832 CleanupStack::PopAndDestroy(2,address); // CSI: 47,12 # alias, address |
|
833 } |
|
834 addressControl->Reset(); |
|
835 if (recips->Count()) |
|
836 { |
|
837 addressControl->AddRecipientsL(*recips); |
|
838 } |
|
839 CleanupStack::PopAndDestroy( recips ); |
|
840 } |
|
841 } |
|
842 |
|
843 // ------------------------------------------------------------------------------ |
|
844 // CMsgMailViewerAppUi::SetAddressFieldTextL() |
|
845 // ------------------------------------------------------------------------------ |
|
846 // |
|
847 void CMsgMailViewerAppUi::SetAddressFieldTextL( |
|
848 TInt aControlType, const TDesC& aText) |
|
849 { |
|
850 CMsgAddressControl* addressControl = AddressControl(aControlType); |
|
851 if (addressControl) |
|
852 { |
|
853 TImMessageField msgField; |
|
854 TInt error = KErrNone; |
|
855 HBufC* address = msgField.GetValidInternetEmailAddressFromString( |
|
856 aText).AllocLC(); |
|
857 HBufC* alias = msgField.GetValidAlias( |
|
858 aText, error).AllocLC(); |
|
859 addressControl->Reset(); |
|
860 |
|
861 // restored recipients don't have contact link, so NULL |
|
862 MVPbkContactLink* link( NULL ); |
|
863 addressControl->AddRecipientL( |
|
864 ( error==KErrNone ) ? *alias : KNullDesC(), *address, ETrue, link ); |
|
865 |
|
866 CleanupStack::PopAndDestroy( 2, address ); // CSI: 47,12 # alias, address |
|
867 } |
|
868 } |
|
869 |
|
870 // ------------------------------------------------------------------------------ |
|
871 // CMsgMailViewerAppUi::SetBodyTextL() |
|
872 // ------------------------------------------------------------------------------ |
|
873 // |
|
874 void CMsgMailViewerAppUi::SetBodyTextL(CRichText& aText) |
|
875 { |
|
876 BodyControl()->Reset(); |
|
877 BodyControl()->SetTextContentL(aText); |
|
878 iFlags |= EUseBaseBodyControl; |
|
879 DoSetAutomaticHighlightL(); |
|
880 BodyControl()->Editor().NotifyNewDocumentL(); |
|
881 } |
|
882 |
|
883 // ------------------------------------------------------------------------------ |
|
884 // CMsgMailViewerAppUi::SetSubjectL |
|
885 // Sets subject text into the subject control. |
|
886 // ------------------------------------------------------------------------------ |
|
887 // |
|
888 void CMsgMailViewerAppUi::SetSubjectL(const TDesC& aText) |
|
889 { |
|
890 CMsgExpandableControl* subjectControl = SubjectControl(); |
|
891 if (subjectControl) |
|
892 { |
|
893 subjectControl->Reset(); |
|
894 subjectControl->SetTextContentL(aText); |
|
895 } |
|
896 } |
|
897 |
|
898 // ------------------------------------------------------------------------------ |
|
899 // CMsgMailViewerAppUi::SetContextBackToMessageL |
|
900 // ------------------------------------------------------------------------------ |
|
901 // |
|
902 void CMsgMailViewerAppUi::SetContextBackToMessageL() |
|
903 { |
|
904 CMsgMailViewerDocument& doc = *Document(); |
|
905 CMailMessage* message = &doc.MailMessage(); |
|
906 |
|
907 //Check that message is created. |
|
908 //It might be null if we are just opening the viewer. |
|
909 if ( !message ) |
|
910 { |
|
911 User::Leave( KErrNotReady); |
|
912 } |
|
913 |
|
914 doc.SetEntryWithoutNotificationL(doc.MailMessage().MessageEntry().Id() ); |
|
915 |
|
916 } |
|
917 |
|
918 // ------------------------------------------------------------------------------ |
|
919 // CMsgMailViewerAppUi::MsgViewRect |
|
920 // ------------------------------------------------------------------------------ |
|
921 // |
|
922 TRect CMsgMailViewerAppUi::MsgViewRect(TInt aPane) |
|
923 { |
|
924 TRect rect(0,0,0,0); |
|
925 |
|
926 switch (aPane) |
|
927 { |
|
928 case 0: |
|
929 rect = MsgEditorCommons::MsgBodyPane(); |
|
930 break; |
|
931 case 1: |
|
932 rect = MsgEditorCommons::MsgDataPane(); |
|
933 break; |
|
934 case 2: // CSI: 47 # switch case |
|
935 rect = MsgEditorCommons::MsgMainPane(); |
|
936 break; |
|
937 case 3: // CSI: 47 # switch case |
|
938 rect = MsgEditorCommons::MsgHeaderPane(); |
|
939 break; |
|
940 default: |
|
941 { |
|
942 // return zero size rect |
|
943 } |
|
944 } |
|
945 return rect; |
|
946 } |
|
947 |
|
948 // ------------------------------------------------------------------------------ |
|
949 // CMsgMailViewerAppUi::AppUiHandleCommandL |
|
950 // ------------------------------------------------------------------------------ |
|
951 // |
|
952 void CMsgMailViewerAppUi::AppUiHandleCommandL(TInt aCommand) |
|
953 { |
|
954 HandleCommandL(aCommand); |
|
955 } |
|
956 |
|
957 // ------------------------------------------------------------------------------ |
|
958 // CMsgMailViewerAppUi::IsNextMessageAvailableL |
|
959 // ------------------------------------------------------------------------------ |
|
960 // |
|
961 TBool CMsgMailViewerAppUi::IsNextMessageAvailableL( TBool aForward ) |
|
962 { |
|
963 return CMsgEditorAppUi::IsNextMessageAvailableL( aForward ); |
|
964 } |
|
965 |
|
966 // ------------------------------------------------------------------------------ |
|
967 // CMsgMailViewerAppUi::NextMessageL |
|
968 // ------------------------------------------------------------------------------ |
|
969 // |
|
970 void CMsgMailViewerAppUi::NextMessageL( TBool aForward ) |
|
971 { |
|
972 CMsgEditorAppUi::NextMessageL( aForward ); |
|
973 } |
|
974 |
|
975 // ------------------------------------------------------------------------------ |
|
976 // CMsgMailViewerAppUi::ViewMessageComplete |
|
977 // ------------------------------------------------------------------------------ |
|
978 // |
|
979 void CMsgMailViewerAppUi::ViewMessageComplete() |
|
980 { |
|
981 // Dismiss "opening" waitnote |
|
982 if( iOpeningWaitDialog ) |
|
983 { |
|
984 TRAP_IGNORE( iOpeningWaitDialog->ProcessFinishedL() ); |
|
985 } |
|
986 } |
|
987 |
|
988 // ------------------------------------------------------------------------------ |
|
989 // CMsgMailViewerAppUi::MessageLoadingL() |
|
990 // ------------------------------------------------------------------------------ |
|
991 // |
|
992 void CMsgMailViewerAppUi::MessageLoadingL(TInt aStatus, CMailMessage& aMessage) |
|
993 { |
|
994 LOG1("CMsgMailViewerAppUi::MessageLoadingL: aStatus:%d", aStatus); |
|
995 iViewManager->MessageLoadL(aStatus, aMessage); |
|
996 |
|
997 if(aStatus == CMailMessage::ELoadEnd) |
|
998 { |
|
999 for(TInt index=0; index<iViewManager->PluginCount(); ++index) |
|
1000 { |
|
1001 MMailMessageView* viewPlugin = iViewManager->ViewPlugin(); |
|
1002 if (viewPlugin) |
|
1003 { |
|
1004 // Load plugin Resource |
|
1005 LoadResourceFileL( viewPlugin->ResourceFile() ); |
|
1006 |
|
1007 TRAPD(error, viewPlugin->ViewMessageL( |
|
1008 aMessage, *this, iParams)); |
|
1009 if (error == KErrNone) |
|
1010 { |
|
1011 break; // success, so break out |
|
1012 } |
|
1013 else |
|
1014 { |
|
1015 // Try to open with next plugin |
|
1016 iResourceLoader.Close(); |
|
1017 iViewManager->RemovePlugin(); |
|
1018 if ( !iViewManager->PluginCount() ) |
|
1019 { |
|
1020 ViewMessageComplete(); |
|
1021 User::LeaveIfError( error ); |
|
1022 } |
|
1023 } |
|
1024 } |
|
1025 } |
|
1026 // Context might be somewhere else that in message itself |
|
1027 SetContextBackToMessageL(); |
|
1028 |
|
1029 iView->ExecuteL(ClientRect(), |
|
1030 GetFirstAddressControl() != NULL |
|
1031 ? GetFirstAddressControl()->ControlId() : |
|
1032 iView->ControlById(EMsgComponentIdSubject) != NULL |
|
1033 ? EMsgComponentIdSubject : EMsgComponentIdNull); |
|
1034 |
|
1035 if ((iParams & EMailUseDefaultNaviPane)) |
|
1036 { |
|
1037 DoUpdateNaviPaneL(); |
|
1038 } |
|
1039 |
|
1040 // observer for Automatic highlight key |
|
1041 Document()->MailCRHandler()->SetNotifyHandlerL(this, |
|
1042 CMailCRHandler::ECommonUiRepository, |
|
1043 CCenRepNotifyHandler::EIntKey, |
|
1044 KCuiAutomaticHighlight); |
|
1045 |
|
1046 DoSetAutomaticHighlightL(); |
|
1047 |
|
1048 LOGHEAP(); |
|
1049 } |
|
1050 } |
|
1051 |
|
1052 // ------------------------------------------------------------------------------ |
|
1053 // CMsgMailViewerAppUi::OpCompleted() |
|
1054 // This method is tailor-made for handling completion of forward operation. |
|
1055 // Other CMsvOperations are taken care by the document class. |
|
1056 // ------------------------------------------------------------------------------ |
|
1057 // |
|
1058 void CMsgMailViewerAppUi::OpCompleted( |
|
1059 CMsvSingleOpWatcher& aOpWatcher, |
|
1060 TInt aCompletionCode ) |
|
1061 { |
|
1062 LOG1("CMsgMailViewerAppUi::OpCompleted:%d", aCompletionCode); |
|
1063 CMsvOperation* op=&aOpWatcher.Operation(); |
|
1064 const TInt status( op->iStatus.Int() ); |
|
1065 |
|
1066 if ( aCompletionCode == EEikCmdExit || aCompletionCode == EAknSoftkeyBack ) |
|
1067 { |
|
1068 // Exit causes leave with KLeaveExit |
|
1069 // Leave is trapped in active sheduler thus iOperationWatcher |
|
1070 // can not be deleted before this call. |
|
1071 |
|
1072 if ( !( iEditorBaseFeatures & EStayInViewerAfterReply ) ) |
|
1073 { |
|
1074 Exit(aCompletionCode); |
|
1075 } |
|
1076 } |
|
1077 |
|
1078 // iOperationWatcher can not be deleted if dialog is visible |
|
1079 if ( iProgressReporter ) |
|
1080 { |
|
1081 TRAP_IGNORE( iProgressReporter->MakeProgressVisibleL( EFalse ) ); |
|
1082 iProgressReporter = NULL; |
|
1083 } |
|
1084 |
|
1085 if ( iOperationWatcher && |
|
1086 iOperationWatcher->Operation().Id()==op->Id() ) |
|
1087 { |
|
1088 LOG("CMsgMailViewerAppUi::OpCompleted: delete iOperationWatcher"); |
|
1089 delete iOperationWatcher; |
|
1090 iOperationWatcher = NULL; |
|
1091 |
|
1092 iOperation = NULL; |
|
1093 } |
|
1094 } |
|
1095 |
|
1096 |
|
1097 // ------------------------------------------------------------------------------ |
|
1098 // From MProgressDialogCallback called when wait note dismissed |
|
1099 // ------------------------------------------------------------------------------ |
|
1100 // |
|
1101 void CMsgMailViewerAppUi::DialogDismissedL( TInt aButtonId ) |
|
1102 { |
|
1103 LOG1( "CMsgMailViewerAppUi::DialogDismissedL %d", |
|
1104 aButtonId ); |
|
1105 |
|
1106 if ( aButtonId == EAknSoftkeyCancel ) |
|
1107 { |
|
1108 delete iAttachmentdlg; |
|
1109 iAttachmentdlg = NULL; |
|
1110 iWaitDialog = NULL; |
|
1111 } |
|
1112 } |
|
1113 |
|
1114 // ------------------------------------------------------------------------------ |
|
1115 // CMsgMailViewerAppUi::BodyTextL() |
|
1116 // ------------------------------------------------------------------------------ |
|
1117 // |
|
1118 CRichText* CMsgMailViewerAppUi::BodyTextL() |
|
1119 { |
|
1120 return Document()->MailMessage().MessageBody(); |
|
1121 } |
|
1122 |
|
1123 // ------------------------------------------------------------------------------ |
|
1124 // void CMsgMailViewerAppUi::DoReplyOrForwardLL() |
|
1125 // Replies or forwards a message a message. |
|
1126 // ------------------------------------------------------------------------------ |
|
1127 // |
|
1128 void CMsgMailViewerAppUi::DoReplyOrForwardL(const TInt aOperation) |
|
1129 { |
|
1130 CMsgMailViewerDocument& doc = *Document(); |
|
1131 |
|
1132 if ( !CheckFFSL( doc.Entry().iSize ) ) |
|
1133 { |
|
1134 return; |
|
1135 } |
|
1136 switch (aOperation) |
|
1137 { |
|
1138 case EMsgMailViewerCmdReplySender: |
|
1139 ReplyL(doc.DefaultMsgFolder(), ETrue); |
|
1140 break; |
|
1141 case EMsgMailViewerCmdReplyAll: |
|
1142 ReplyToAllL(doc.DefaultMsgFolder(), ETrue); |
|
1143 break; |
|
1144 case EMsgMailViewerCmdForward: |
|
1145 { |
|
1146 ForwardOperationL(); |
|
1147 // calls opcompleted when done |
|
1148 return; |
|
1149 } |
|
1150 default: |
|
1151 break; |
|
1152 } |
|
1153 |
|
1154 // check exit setting maintained by base editor (common to all types) |
|
1155 if ( !( iEditorBaseFeatures & EStayInViewerAfterReply ) ) |
|
1156 { |
|
1157 Exit(EAknSoftkeyBack); |
|
1158 } |
|
1159 } |
|
1160 |
|
1161 // ------------------------------------------------------------------------------ |
|
1162 // void CMsgMailViewerAppUi::DoAttachmentL() |
|
1163 // Opens an attachment dialog. |
|
1164 // ------------------------------------------------------------------------------ |
|
1165 // |
|
1166 void CMsgMailViewerAppUi::DoAttachmentL() |
|
1167 { |
|
1168 //Check if iTitle allready exists |
|
1169 if(!iTitle) |
|
1170 { |
|
1171 iTitle = iCoeEnv->AllocReadResourceLC( |
|
1172 R_VIEWER_TITLE_ATTACHMENTS); |
|
1173 |
|
1174 CleanupStack::Pop(iTitle); |
|
1175 } |
|
1176 |
|
1177 CMsgAttachmentModel& attmodel = Document()->AttachmentModel(); |
|
1178 |
|
1179 iAttachmentdlg = CMsgMailViewerAttachmentsDlg::NewL(*iTitle, |
|
1180 attmodel, *Document(), *this ); |
|
1181 |
|
1182 iAttachmentdlg->SetMopParent(this); |
|
1183 |
|
1184 #ifdef RD_SCALABLE_UI_V2 |
|
1185 //Hide toolbar |
|
1186 if ( PopupToolbar() ) |
|
1187 { |
|
1188 DoHideToolbar( ETrue ); |
|
1189 } |
|
1190 #endif // RD_SCALABLE_UI_V2 |
|
1191 |
|
1192 // safe to call LD even as a member variable, since sets itself to NULL when deleting |
|
1193 iAttachmentdlg->ExecuteLD(R_MAIL_VIEWER_ATTACHMENT_DIALOG); // CSI: 50 # see comment above |
|
1194 |
|
1195 LOG("Attachement dialog launchded"); |
|
1196 |
|
1197 if(iAttachmentLoadingOn) |
|
1198 { |
|
1199 ShowWaitNoteL( ETrue ); |
|
1200 if ( iWaitDialog ) |
|
1201 { |
|
1202 iWaitDialog->SetCallback( this ); |
|
1203 } |
|
1204 } |
|
1205 else |
|
1206 { |
|
1207 //Update attachment models fetched-flags |
|
1208 //if we are not currently loading attachments. |
|
1209 if(iAttachmentdlg) |
|
1210 { |
|
1211 iAttachmentdlg->UpdateAttachmentsFetchFlags(); |
|
1212 } |
|
1213 |
|
1214 } |
|
1215 |
|
1216 // Dialer is always enabled in attachment dialog |
|
1217 SetDialerEnabled( ETrue ); |
|
1218 } |
|
1219 |
|
1220 // ------------------------------------------------------------------------------ |
|
1221 // void CMsgMailViewerAppUi::DoMoveL() |
|
1222 // ------------------------------------------------------------------------------ |
|
1223 // |
|
1224 void CMsgMailViewerAppUi::DoMoveL() |
|
1225 { |
|
1226 // Context might be somewhere else that in message itself |
|
1227 SetContextBackToMessageL(); |
|
1228 CMsgMailViewerDocument& doc = *Document(); |
|
1229 |
|
1230 TBool moveMessage(doc.CurrentEntry().OwningService() == |
|
1231 KMsvLocalServiceIndexEntryIdValue); |
|
1232 |
|
1233 // Check that file system has enough free space |
|
1234 TInt size(0); |
|
1235 if ( !moveMessage ) |
|
1236 { |
|
1237 size = doc.Entry().iSize; |
|
1238 } |
|
1239 |
|
1240 if (!CheckFFSL(size)) |
|
1241 { |
|
1242 return; |
|
1243 } |
|
1244 |
|
1245 HBufC* title = moveMessage ? |
|
1246 StringLoader::LoadLC(R_MCE_MOVE_MESSAGES, iCoeEnv) : |
|
1247 StringLoader::LoadLC(R_MCE_COPY_MESSAGES, iCoeEnv); |
|
1248 |
|
1249 TMsvId selFolder(doc.Entry().Parent()); |
|
1250 const TBool select( CMsgFolderSelectionDialog::SelectFolderL( |
|
1251 selFolder, *title) ); |
|
1252 CleanupStack::PopAndDestroy( title ); |
|
1253 |
|
1254 if (select) |
|
1255 { |
|
1256 TMsvId serviceId; |
|
1257 TMsvEntry destEntry; |
|
1258 User::LeaveIfError(doc.Session().GetEntry( |
|
1259 selFolder, serviceId, destEntry)); |
|
1260 const TBool destinationIsRemote( |
|
1261 KMsvLocalServiceIndexEntryIdValue != serviceId); |
|
1262 TMsvEntry srcEntry; |
|
1263 User::LeaveIfError(doc.Session().GetEntry( |
|
1264 doc.Entry().Parent(), serviceId, srcEntry)); |
|
1265 const TBool sourceIsRemote( |
|
1266 KMsvLocalServiceIndexEntryIdValue != serviceId); |
|
1267 |
|
1268 if ( !destinationIsRemote && !sourceIsRemote ) |
|
1269 { |
|
1270 MoveMessageEntryL(selFolder); |
|
1271 } |
|
1272 else |
|
1273 { |
|
1274 // Handle remote entries |
|
1275 doc.MoveRemoteEntryL( |
|
1276 selFolder, srcEntry.Id(), destinationIsRemote ); |
|
1277 } |
|
1278 |
|
1279 Exit(EAknSoftkeyBack); |
|
1280 } |
|
1281 } |
|
1282 |
|
1283 // ------------------------------------------------------------------------------ |
|
1284 // CMsgMailViewerAppUi::DoCreateAttachmentControlL() |
|
1285 // ------------------------------------------------------------------------------ |
|
1286 // |
|
1287 void CMsgMailViewerAppUi::DoCreateAttachmentControlL() |
|
1288 { |
|
1289 // first attachment to be added? |
|
1290 if ( !(iFlags & EAttachments) ) |
|
1291 { |
|
1292 CMsgAttachmentControl* control = |
|
1293 CMsgAttachmentControl::NewL( *iView, *iView ); |
|
1294 CleanupStack::PushL( control ); |
|
1295 iView->AddControlL( control, |
|
1296 EMsgComponentIdAttachment, |
|
1297 EMsgAppendControl, |
|
1298 EMsgHeader ); |
|
1299 CleanupStack::Pop( control ); |
|
1300 } |
|
1301 } |
|
1302 |
|
1303 // ------------------------------------------------------------------------------ |
|
1304 // CMsgMailViewerAppUi::DoMessageInfoL() |
|
1305 // ------------------------------------------------------------------------------ |
|
1306 // |
|
1307 void CMsgMailViewerAppUi::DoMessageInfoL() const |
|
1308 { |
|
1309 Document()->ShowMessageInfoL(); |
|
1310 } |
|
1311 |
|
1312 // ---------------------------------------------------------------------------- |
|
1313 // CMsgMailViewerAppUi::DoHideToolbar() |
|
1314 // ---------------------------------------------------------------------------- |
|
1315 // |
|
1316 void CMsgMailViewerAppUi::DoHideToolbar( const TBool aHide ) |
|
1317 { |
|
1318 #ifdef RD_SCALABLE_UI_V2 |
|
1319 if ( PopupToolbar() ) |
|
1320 { |
|
1321 PopupToolbar()->HideItemsAndDrawOnlyBackground( aHide ); |
|
1322 } |
|
1323 #endif // RD_SCALABLE_UI_V |
|
1324 } |
|
1325 |
|
1326 // ---------------------------------------------------------------------------- |
|
1327 // CMsgMailViewerAppUi::AttachmentDialogExit() |
|
1328 // ---------------------------------------------------------------------------- |
|
1329 // |
|
1330 void CMsgMailViewerAppUi::AttachmentDialogExit() |
|
1331 { |
|
1332 #ifdef RD_SCALABLE_UI_V2 |
|
1333 if ( PopupToolbar() ) |
|
1334 { |
|
1335 PopupToolbar()->SetToolbarObserver( this ); |
|
1336 DoHideToolbar( EFalse ); |
|
1337 } |
|
1338 #endif // RD_SCALABLE_UI_V |
|
1339 |
|
1340 // Reset Dialer back to default when Attachment dialog exits |
|
1341 SetDialerEnabled( iDefaultDialerState ); |
|
1342 // The NaviDecorator has to be moved to a top of NaviPane's stack so that |
|
1343 // the navigation arrows refresh correctly. CMsgViewAttachmentsDialog |
|
1344 // puts an empty NaviDecorator to the top of the stack in constructor and |
|
1345 // pops it in destructor so the empty NaviDecorator is moved back to the |
|
1346 // top of the NaviPane's stack (PushDefaultL). |
|
1347 // If the methods leave there is not much possible to do any post-handling |
|
1348 // so only TRAP_IGNORE is used to trap the methods if they leave. |
|
1349 TRAP_IGNORE( |
|
1350 iNaviPane->PushL( *iNaviDecorator ); |
|
1351 iNaviPane->PushDefaultL()); |
|
1352 } |
|
1353 |
|
1354 // ------------------------------------------------------------------------------ |
|
1355 // CMsgMailViewerAppUi::HasAddressFieldText() |
|
1356 // ------------------------------------------------------------------------------ |
|
1357 // |
|
1358 TBool CMsgMailViewerAppUi::HasAddressFieldText( |
|
1359 CMsgAddressControl* aAddressControl) const |
|
1360 { |
|
1361 if (aAddressControl) |
|
1362 { |
|
1363 CEikRichTextEditor& fromEditor = aAddressControl->Editor(); |
|
1364 if (fromEditor.TextLength() > 0) |
|
1365 { |
|
1366 return ETrue; |
|
1367 } |
|
1368 } |
|
1369 return EFalse; |
|
1370 } |
|
1371 |
|
1372 // ------------------------------------------------------------------------------ |
|
1373 // CMsgMailViewerAppUi::HasAnyAddressFieldText() |
|
1374 // ------------------------------------------------------------------------------ |
|
1375 // |
|
1376 TBool CMsgMailViewerAppUi::HasAnyAddressFieldText() const |
|
1377 { |
|
1378 CMsgAddressControl* addressField = AddressControl(EMsgComponentIdTo); |
|
1379 |
|
1380 TBool hasText(HasAddressFieldText(addressField)); |
|
1381 addressField = AddressControl(EMsgComponentIdFrom); |
|
1382 hasText = hasText || HasAddressFieldText(addressField); |
|
1383 addressField = AddressControl(EMsgComponentIdCc); |
|
1384 hasText = hasText || HasAddressFieldText(addressField); |
|
1385 addressField = AddressControl(EMsgComponentIdBcc); |
|
1386 hasText = hasText || HasAddressFieldText(addressField); |
|
1387 |
|
1388 return hasText; |
|
1389 } |
|
1390 |
|
1391 // ------------------------------------------------------------------------------ |
|
1392 // CMsgMailViewerAppUi::HasValidFromAddress() |
|
1393 // ------------------------------------------------------------------------------ |
|
1394 // |
|
1395 TBool CMsgMailViewerAppUi::HasValidFromAddress() const |
|
1396 { |
|
1397 CImHeader* header = Document()->MailMessage().MessageHeader(); |
|
1398 TImMessageField address; |
|
1399 return address.ValidInternetEmailAddress( header->From() ); |
|
1400 } |
|
1401 |
|
1402 // ------------------------------------------------------------------------------ |
|
1403 // CMsgMailViewerAppUi::FromOrToAddressL() |
|
1404 // Returns KNullDesC if address not found |
|
1405 // ------------------------------------------------------------------------------ |
|
1406 // |
|
1407 const TDesC& CMsgMailViewerAppUi::FromOrToAddressL() const |
|
1408 { |
|
1409 CMsgAddressControl* addressField( NULL ); |
|
1410 if ( !MailMessageUtils::IsOutgoingL( Document()->MailMessage() ) ) |
|
1411 { |
|
1412 addressField = AddressControl( EMsgComponentIdFrom ); |
|
1413 } |
|
1414 else |
|
1415 { |
|
1416 addressField = AddressControl( EMsgComponentIdTo ); |
|
1417 } |
|
1418 return FirstRecipientAddressL( addressField ); |
|
1419 } |
|
1420 |
|
1421 // ------------------------------------------------------------------------------ |
|
1422 // CMsgMailViewerAppUi::HandleEKeyYesL() |
|
1423 // ------------------------------------------------------------------------------ |
|
1424 // |
|
1425 void CMsgMailViewerAppUi::HandleEKeyYesL() |
|
1426 { |
|
1427 const TDesC& address( FromOrToAddressL() ); |
|
1428 |
|
1429 |
|
1430 //Check if call based on email address matching should be done. |
|
1431 //If VoIP is installed the email address shouldn't be matched. |
|
1432 if(CanMakeCallToContactL() && !VoipProfileExistL()) |
|
1433 { |
|
1434 HandleCommandL(EMsgMailViewerCmdCall); |
|
1435 } |
|
1436 else |
|
1437 { |
|
1438 TBool isBodyFocused( FocusedControlId() == EMsgComponentIdBody ); |
|
1439 CItemFinder::TItemType selectionType( |
|
1440 iFindItemHandler->SelectionType( isBodyFocused ) ); |
|
1441 // will contain selection text or KNullDesC if nothing selected |
|
1442 const TDesC& selectionText( |
|
1443 iFindItemHandler->SelectionText( isBodyFocused ) ); |
|
1444 |
|
1445 if ( selectionType == CItemFinder::EPhoneNumber ) |
|
1446 { |
|
1447 |
|
1448 //Create VoIP call if pref send key is PS and |
|
1449 // atleast one VoIP profile. |
|
1450 if ( IsDefaultSendKeyValueVoIPL() && |
|
1451 VoipProfileExistL() ) |
|
1452 { |
|
1453 MsvUiServiceUtilitiesInternal::InternetCallToSenderQueryL( |
|
1454 iView->ItemFinder()-> |
|
1455 CurrentItemExt().iItemDescriptor->Des(), |
|
1456 KNullDesC, ETrue ); |
|
1457 } |
|
1458 //otherwise create CS call |
|
1459 else |
|
1460 { |
|
1461 MsvUiServiceUtilitiesInternal::CallToSenderQueryL( |
|
1462 iView->ItemFinder()-> |
|
1463 CurrentItemExt().iItemDescriptor->Des(), |
|
1464 KNullDesC, |
|
1465 ETrue ); |
|
1466 } |
|
1467 } |
|
1468 else if ( VoipProfileExistL() ) |
|
1469 { |
|
1470 if ( selectionType == CItemFinder::EEmailAddress ) |
|
1471 { |
|
1472 MsvUiServiceUtilitiesInternal::InternetCallServiceL( |
|
1473 address, |
|
1474 Document()->MailMessage().MessageHeader()->From(), |
|
1475 selectionText, |
|
1476 iEikonEnv ); |
|
1477 } |
|
1478 else if ( address.Length() > 0 ) |
|
1479 { //call to sender |
|
1480 MsvUiServiceUtilitiesInternal::InternetCallToSenderQueryL( |
|
1481 address, |
|
1482 KNullDesC, |
|
1483 ETrue ); |
|
1484 } |
|
1485 } |
|
1486 } |
|
1487 |
|
1488 |
|
1489 } |
|
1490 |
|
1491 // ------------------------------------------------------------------------------ |
|
1492 // CMsgMailViewerAppUi::GetRecipientArrayL() |
|
1493 // ------------------------------------------------------------------------------ |
|
1494 // |
|
1495 CMsgRecipientArray* CMsgMailViewerAppUi::GetRecipientArrayL( |
|
1496 CMsgAddressControl* aAddressControl ) const |
|
1497 { |
|
1498 CMsgRecipientArray* array(NULL); // prevent compiler warning |
|
1499 if ( aAddressControl ) |
|
1500 { |
|
1501 array = aAddressControl->GetRecipientsL(); |
|
1502 } |
|
1503 return array; |
|
1504 } |
|
1505 |
|
1506 // ------------------------------------------------------------------------------ |
|
1507 // CMsgMailViewerAppUi::DoConvertToCharsetL() |
|
1508 // ------------------------------------------------------------------------------ |
|
1509 // |
|
1510 void CMsgMailViewerAppUi::DoConvertToCharsetL( TUint aCharset ) |
|
1511 { |
|
1512 CMsgMailViewerDocument& doc = *Document(); |
|
1513 CMailMessage& message = doc.MailMessage(); |
|
1514 message.Cancel(); |
|
1515 |
|
1516 // set override characterset for html message |
|
1517 message.OverrideHtmlMessageCharset( aCharset ); |
|
1518 |
|
1519 // set the wanted character set for plain text message |
|
1520 message.ConvertToCharsetL( aCharset ); |
|
1521 |
|
1522 //Conversion complete, update document character set to current one |
|
1523 doc.SetCharSet( aCharset ); |
|
1524 |
|
1525 //Open wait dialog |
|
1526 delete iOpeningWaitDialog; |
|
1527 iOpeningWaitDialog = NULL; |
|
1528 iOpeningWaitDialog = new(ELeave)CAknWaitDialog( |
|
1529 (reinterpret_cast<CEikDialog**>(&iOpeningWaitDialog)), ETrue ); |
|
1530 // safe to call LD even as a member variable, |
|
1531 // since sets itself to NULL when deleting |
|
1532 iOpeningWaitDialog->ExecuteLD(R_VIEWER_WAIT_OPEN_NOTE); // CSI: 50 # see comment above |
|
1533 |
|
1534 // HTML mail does not need to add temporary attachment when the mail is |
|
1535 // being reloaded (hence we have a flag for it). |
|
1536 // This also prevents the appearance of attachment duplicates when changing |
|
1537 // characte encoding |
|
1538 iMessageReload = ETrue; |
|
1539 |
|
1540 message.LoadMessageL(*this); |
|
1541 } |
|
1542 |
|
1543 |
|
1544 // ------------------------------------------------------------------------------ |
|
1545 // CMsgMailViewerAppUi::DoUpdateNaviPaneL() |
|
1546 // ------------------------------------------------------------------------------ |
|
1547 // |
|
1548 void CMsgMailViewerAppUi::DoUpdateNaviPaneL() |
|
1549 { |
|
1550 #ifdef RD_MSG_NAVIPANE_IMPROVEMENT |
|
1551 if ( !iNaviDecorator ) |
|
1552 { |
|
1553 TMsgEditorMsgPriority priority = EMsgEditorMsgPriorityNormal; |
|
1554 |
|
1555 if ( Document()->MailMessage().MessageEntry().Priority() == EMsvHighPriority ) |
|
1556 { |
|
1557 priority = EMsgEditorMsgPriorityHigh; |
|
1558 } |
|
1559 else if ( Document()->MailMessage().MessageEntry().Priority() == EMsvLowPriority ) |
|
1560 { |
|
1561 priority = EMsgEditorMsgPriorityLow; |
|
1562 } |
|
1563 |
|
1564 CreateViewerNaviPaneL( Document()->Entry().iDate, priority, ETrue ); |
|
1565 } |
|
1566 |
|
1567 // if attachment dialog is visible don't update navi pane. |
|
1568 if( !iAttachmentdlg ) |
|
1569 { |
|
1570 iNaviPane->PushL( *iNaviDecorator ); // <- This has nothing to do with cleanup-stack! |
|
1571 } |
|
1572 |
|
1573 #else |
|
1574 |
|
1575 |
|
1576 |
|
1577 CFbsBitmap* bitmap(NULL); |
|
1578 CFbsBitmap* bitmapMask(NULL); |
|
1579 |
|
1580 // if attachment dialog is visible don't update navi pane. |
|
1581 if(!iAttachmentdlg) |
|
1582 { |
|
1583 if ((iFlags & EAttachments) && |
|
1584 !Document()->MailCRHandler()->MailAttachmentField()) |
|
1585 { |
|
1586 TAknsItemID skinID (KAknsIIDQgnPropFolderMessageTab1); |
|
1587 TInt bitmapID(EMbmMsgeditorQgn_prop_folder_message_tab1); |
|
1588 TInt bitmapMaskID(EMbmMsgeditorQgn_prop_folder_message_tab1_mask); |
|
1589 |
|
1590 AknsUtils::CreateIconLC( AknsUtils::SkinInstance(), |
|
1591 skinID, |
|
1592 bitmap, |
|
1593 bitmapMask, |
|
1594 KMsgEditorMbm, |
|
1595 bitmapID, |
|
1596 bitmapMaskID ); |
|
1597 |
|
1598 // navipane takes ownership of the bitmaps |
|
1599 UpdateNaviPaneL(bitmap, bitmapMask); |
|
1600 CleanupStack::Pop( 2, bitmapMask ); // CSI: 47,12 # bitmap, bitmapMask |
|
1601 } |
|
1602 else |
|
1603 { |
|
1604 TInt bitmapID( 0 ); |
|
1605 TInt bitmapMaskID( 0 ); |
|
1606 const TMsvPriority messagePriority = |
|
1607 Document()->MailMessage().MessageEntry().Priority(); |
|
1608 |
|
1609 if ( messagePriority==EMsvHighPriority ) |
|
1610 { |
|
1611 bitmapID = EMbmMuiuQgn_indi_mce_priority_high; |
|
1612 bitmapMaskID = EMbmMuiuQgn_indi_mce_priority_high_mask; |
|
1613 } |
|
1614 else if ( messagePriority==EMsvLowPriority ) |
|
1615 { |
|
1616 bitmapID = EMbmMuiuQgn_indi_mce_priority_low; |
|
1617 bitmapMaskID = EMbmMuiuQgn_indi_mce_priority_low_mask; |
|
1618 } |
|
1619 |
|
1620 if ( bitmapID ) |
|
1621 { |
|
1622 _LIT(KDirAndMuiuMbmFile,"z:muiu.mbm"); |
|
1623 TParse fileParse; |
|
1624 fileParse.Set( KDirAndMuiuMbmFile, &KDC_APP_BITMAP_DIR, NULL ); |
|
1625 AknsUtils::CreateIconLC( AknsUtils::SkinInstance(), |
|
1626 KAknsIIDQgnPropFolderMessageTab1, |
|
1627 bitmap, |
|
1628 bitmapMask, |
|
1629 fileParse.FullName(), |
|
1630 bitmapID, |
|
1631 bitmapMaskID ); |
|
1632 |
|
1633 // navipane takes ownership of the bitmaps |
|
1634 UpdateNaviPaneL(bitmap, bitmapMask); |
|
1635 CleanupStack::Pop( 2 bitmapMask ); // CSI: 47,12 # bitmap, bitmapMask |
|
1636 } |
|
1637 else |
|
1638 { |
|
1639 UpdateNaviPaneL(bitmap, bitmapMask); |
|
1640 } |
|
1641 } |
|
1642 } |
|
1643 |
|
1644 |
|
1645 |
|
1646 #ifdef RD_SCALABLE_UI_V2 |
|
1647 //Register as observer for decorator events |
|
1648 if( iNaviDecorator ) |
|
1649 { |
|
1650 iNaviDecorator->SetNaviDecoratorObserver( this ); |
|
1651 } |
|
1652 #endif |
|
1653 |
|
1654 |
|
1655 #endif //RD_MSG_NAVIPANE_IMPROVEMENT |
|
1656 } |
|
1657 |
|
1658 // ------------------------------------------------------------------------------ |
|
1659 // CMsgMailViewerAppUi::HandleExternalCmdL() |
|
1660 // Command is offered to external handlers one by one until one of |
|
1661 // them consumes it or no handlers are left. |
|
1662 // ------------------------------------------------------------------------------ |
|
1663 // |
|
1664 TBool CMsgMailViewerAppUi::HandleExternalCmdL( TInt aCommand ) |
|
1665 { |
|
1666 // forwart to Plugin |
|
1667 MMailMessageView* plugin = iViewManager->ViewPlugin(); |
|
1668 if ( plugin ) |
|
1669 { |
|
1670 if (plugin->HandleCommandL(aCommand)) |
|
1671 { |
|
1672 return ETrue; |
|
1673 } |
|
1674 } |
|
1675 |
|
1676 if ( iCharSetHandler ) |
|
1677 { |
|
1678 TUint charSetId; |
|
1679 if ( iCharSetHandler->GetCharacterSetId( aCommand, charSetId ) ) |
|
1680 { |
|
1681 DoConvertToCharsetL( charSetId ); |
|
1682 return ETrue; |
|
1683 } |
|
1684 } |
|
1685 |
|
1686 if ( iFindItemHandler->CanHandleCommand( aCommand ) ) |
|
1687 { |
|
1688 iFindItemHandler->HandleFinderCommandL( aCommand ); |
|
1689 return ETrue; |
|
1690 } |
|
1691 |
|
1692 if ( iContactCaller->CanHandleCommand( aCommand ) ) |
|
1693 { |
|
1694 iContactCaller->CallToContactL( aCommand, FromOrToAddressL() ); |
|
1695 return ETrue; |
|
1696 } |
|
1697 |
|
1698 return EFalse; |
|
1699 } |
|
1700 |
|
1701 // ------------------------------------------------------------------------------ |
|
1702 // CMsgMailViewerAppUi::HandleInternalCmdL() |
|
1703 // ------------------------------------------------------------------------------ |
|
1704 // |
|
1705 void CMsgMailViewerAppUi::HandleInternalCmdL( TInt aCommand ) |
|
1706 { |
|
1707 switch ( aCommand ) |
|
1708 { |
|
1709 case EEikCmdExit: |
|
1710 DoMsgSaveExitL(); |
|
1711 break; |
|
1712 case EAknSoftkeyClear: |
|
1713 //FALLTHROGH |
|
1714 case EMsgMailViewerCmdDelete: |
|
1715 DoDeleteL(); |
|
1716 break; |
|
1717 case EAknSoftkeyBack: |
|
1718 Exit(EAknSoftkeyBack); |
|
1719 break; |
|
1720 case EMsgMailViewerCmdReplySender: |
|
1721 // FALLTHROUGH |
|
1722 case EMsgMailViewerCmdReplyAll: |
|
1723 // FALLTHROUGH |
|
1724 case EMsgMailViewerCmdForward: |
|
1725 DoReplyOrForwardL(aCommand); |
|
1726 break; |
|
1727 case EMsgMailViewerCmdReplyViaUnified: |
|
1728 iReplyToMatcher->CheckMatchesL(KSenduiMtmUniMessageUid, |
|
1729 GetRecipientArrayL(AddressControl( EMsgComponentIdFrom ))); |
|
1730 break; |
|
1731 case EMsgMailViewerCmdReplyViaAudio: |
|
1732 iReplyToMatcher->CheckMatchesL(KSenduiMtmAudioMessageUid, |
|
1733 GetRecipientArrayL(AddressControl( EMsgComponentIdFrom ))); |
|
1734 break; |
|
1735 case EMsgMailViewerCmdAttachments: |
|
1736 DoAttachmentL(); |
|
1737 break; |
|
1738 case EMsgMailViewerCmdMove: |
|
1739 // FALLTHROUGH |
|
1740 case EMsgMailViewerCmdCopy: |
|
1741 DoMoveL(); |
|
1742 break; |
|
1743 case EMsgMailViewerCmdMessageInfo: |
|
1744 DoMessageInfoL(); |
|
1745 break; |
|
1746 case EAknCmdHelp: |
|
1747 // Launch help |
|
1748 HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), |
|
1749 iEikonEnv->EikAppUi()->AppHelpContextL() ); |
|
1750 break; |
|
1751 case EMsgMailViewerCmdRetrieve: |
|
1752 DoRetrieveMessageL(); |
|
1753 break; |
|
1754 case EMsgDispSizeAutomatic: |
|
1755 // FALLTROUGH |
|
1756 case EMsgDispSizeLarge: |
|
1757 // FALLTROUGH |
|
1758 case EMsgDispSizeNormal: |
|
1759 // FALLTROUGH |
|
1760 case EMsgDispSizeSmall: |
|
1761 HandleLocalZoomChangeL( (TMsgCommonCommands)aCommand ); |
|
1762 break; |
|
1763 default: |
|
1764 CMsgMailAppUi::HandleCommandL( aCommand ); |
|
1765 break; |
|
1766 } |
|
1767 } |
|
1768 |
|
1769 // ------------------------------------------------------------------------------ |
|
1770 // CMsgMailViewerAppUi::DoHideReplyToAll() |
|
1771 // ------------------------------------------------------------------------------ |
|
1772 // |
|
1773 TBool CMsgMailViewerAppUi::DoHideReplyToAll() const |
|
1774 { |
|
1775 return !MessageAddresseeCount(); |
|
1776 } |
|
1777 |
|
1778 // ----------------------------------------------------------------------------- |
|
1779 // CMsgMailViewerAppUi::DoHideReplyToSender() |
|
1780 // ----------------------------------------------------------------------------- |
|
1781 // |
|
1782 TBool CMsgMailViewerAppUi::DoHideReplyToSender() const |
|
1783 { |
|
1784 // From has text |
|
1785 CMsgAddressControl* addressField = AddressControl(EMsgComponentIdFrom); |
|
1786 if ( addressField && HasAddressFieldText( addressField ) ) |
|
1787 { |
|
1788 return EFalse; |
|
1789 } |
|
1790 return ETrue; |
|
1791 } |
|
1792 |
|
1793 // ------------------------------------------------------------------------------ |
|
1794 // CMsgMailViewerAppUi::MopSupplyObject(TTypeUid aId) |
|
1795 // Returns a pointer to popup menu. |
|
1796 // ------------------------------------------------------------------------------ |
|
1797 // |
|
1798 TTypeUid::Ptr CMsgMailViewerAppUi::MopSupplyObject(TTypeUid aId) |
|
1799 { |
|
1800 return SupplyMopObject(aId); |
|
1801 } |
|
1802 |
|
1803 // ----------------------------------------------------------------------------- |
|
1804 // CMsgMailViewerAppUi::HandleNotifyInt |
|
1805 // ----------------------------------------------------------------------------- |
|
1806 // |
|
1807 void CMsgMailViewerAppUi::HandleNotifyInt( |
|
1808 TUint32 aId, |
|
1809 TInt aNewValue ) |
|
1810 { |
|
1811 // Notifies changes on KCuiAutomaticHighlight |
|
1812 if (aId == KCuiAutomaticHighlight) |
|
1813 { |
|
1814 TRAP_IGNORE(SetAutomaticHighlightL( aNewValue )); |
|
1815 } |
|
1816 } |
|
1817 |
|
1818 // ----------------------------------------------------------------------------- |
|
1819 // CMsgMailViewerAppUi::HandleNotifyError |
|
1820 // ----------------------------------------------------------------------------- |
|
1821 // |
|
1822 void CMsgMailViewerAppUi::HandleNotifyError( |
|
1823 TUint32 /* aId */, |
|
1824 TInt /* aError */, |
|
1825 CCenRepNotifyHandler* /* aHandler */ ) |
|
1826 { |
|
1827 // Do nothing |
|
1828 LOG("CMsgMailViewerAppUi::HandleNotifyError"); |
|
1829 } |
|
1830 |
|
1831 // ------------------------------------------------------------------------------ |
|
1832 // CMsgMailViewerAppUi::GetCharsetIdL() |
|
1833 // ------------------------------------------------------------------------------ |
|
1834 // |
|
1835 TUint CMsgMailViewerAppUi::GetCharsetIdL() const |
|
1836 { |
|
1837 //If this is a HTML mail then return the charset in html part |
|
1838 if ( Document()->MailMessage().MhtmlPartId() != 0) |
|
1839 { |
|
1840 return Document()->MailMessage().HtmlCharsetIdL(); |
|
1841 } |
|
1842 //else the regular |
|
1843 else |
|
1844 { |
|
1845 return Document()->MailMessage().CharsetIdL(); |
|
1846 } |
|
1847 } |
|
1848 |
|
1849 // ----------------------------------------------------------------------------- |
|
1850 // CMsgMailViewerAppUi::GetFirstAddressControl |
|
1851 // ----------------------------------------------------------------------------- |
|
1852 // |
|
1853 CMsgAddressControl* CMsgMailViewerAppUi::GetFirstAddressControl( |
|
1854 TBool aDirection ) const |
|
1855 { |
|
1856 CMsgAddressControl* addressField( NULL ); |
|
1857 TInt controlId( aDirection ? EMsgComponentIdTo : EMsgComponentIdBcc ); |
|
1858 TInt count( 1 + ( EMsgComponentIdBcc - EMsgComponentIdTo ) ); |
|
1859 for ( TInt i( 0 ); i < count; i++ ) |
|
1860 { |
|
1861 addressField = AddressControl( controlId ); |
|
1862 if ( addressField ) |
|
1863 { // found the first address, stop looping |
|
1864 break; |
|
1865 } |
|
1866 aDirection ? ++controlId : --controlId; |
|
1867 } |
|
1868 return addressField; |
|
1869 } |
|
1870 |
|
1871 // ------------------------------------------------------------------------------ |
|
1872 // CMsgMailViewerAppUi::FirstRecipientAddressL() |
|
1873 // Returns KNullDesC if addresscontrol is NULL or contains no addresses |
|
1874 // ------------------------------------------------------------------------------ |
|
1875 // |
|
1876 const TDesC& CMsgMailViewerAppUi::FirstRecipientAddressL( |
|
1877 CMsgAddressControl* aAddressControl ) const |
|
1878 { |
|
1879 CMsgRecipientArray* array = GetRecipientArrayL( aAddressControl ); |
|
1880 if ( array && array->Count() > 0 ) |
|
1881 { |
|
1882 return ( *( *array )[0]->Address() ); // first address |
|
1883 } |
|
1884 else |
|
1885 { |
|
1886 return KNullDesC(); |
|
1887 } |
|
1888 } |
|
1889 |
|
1890 // ------------------------------------------------------------------------------ |
|
1891 // CMsgMailViewerAppUi::FirstRecipientNameL() |
|
1892 // Returns KNullDesC if addresscontrol is NULL or contains no addresses |
|
1893 // ------------------------------------------------------------------------------ |
|
1894 // |
|
1895 const TDesC& CMsgMailViewerAppUi::FirstRecipientNameL( |
|
1896 CMsgAddressControl* aAddressControl ) const |
|
1897 { |
|
1898 CMsgRecipientArray* array = GetRecipientArrayL( aAddressControl ); |
|
1899 if ( array && array->Count() > 0 ) |
|
1900 { |
|
1901 return ( *( *array )[0]->Name() ); // first name |
|
1902 } |
|
1903 else |
|
1904 { |
|
1905 return KNullDesC(); |
|
1906 } |
|
1907 } |
|
1908 |
|
1909 |
|
1910 // ------------------------------------------------------------------------------ |
|
1911 // CMsgMailViewerAppUi::DoReplyOptionsMenuL() |
|
1912 // ------------------------------------------------------------------------------ |
|
1913 // |
|
1914 void CMsgMailViewerAppUi::DoReplyOptionsMenuL(CEikMenuPane& aMenuPane) |
|
1915 { |
|
1916 if ( HasValidFromAddress() ) |
|
1917 { |
|
1918 if ( MessageAddresseeCount() || |
|
1919 ValidateServiceL( KSenduiMtmMmsUid ) || |
|
1920 ValidateServiceL( KSenduiMtmAudioMessageUid ) || |
|
1921 ValidateServiceL( KSenduiMtmUniMessageUid ) || |
|
1922 MailMessageUtils::IsOutgoingL( Document()->MailMessage() ) ) |
|
1923 { |
|
1924 // Reply with submenu |
|
1925 aMenuPane.SetItemDimmed( |
|
1926 EMsgMailViewerCmdReply, EFalse ); |
|
1927 } |
|
1928 else |
|
1929 { |
|
1930 // Reply to sender |
|
1931 aMenuPane.SetItemDimmed( |
|
1932 EMsgMailViewerCmdReplySender, EFalse ); |
|
1933 } |
|
1934 } |
|
1935 } |
|
1936 |
|
1937 |
|
1938 // ------------------------------------------------------------------------------ |
|
1939 // CMsgMailViewerAppUi::DoReplyViaL() |
|
1940 // ------------------------------------------------------------------------------ |
|
1941 // |
|
1942 void CMsgMailViewerAppUi::DoReplyViaL( TUid aMtmUid, const HBufC* aMatch, const HBufC* aName) |
|
1943 { |
|
1944 CMsgAddressControl* from = AddressControl( EMsgComponentIdFrom ); |
|
1945 CMsgRecipientArray* recs = GetRecipientArrayL( from ); |
|
1946 if ( recs ) |
|
1947 { |
|
1948 CMessageData* messageData = CMessageData::NewL(); |
|
1949 CleanupStack::PushL(messageData); |
|
1950 |
|
1951 if( aMatch ) |
|
1952 { |
|
1953 //We have found matching sender address and that should be used |
|
1954 |
|
1955 if( !aName ) |
|
1956 { |
|
1957 //No alias name found. Just matching address added to messageData. |
|
1958 messageData->AppendToAddressL(*aMatch); |
|
1959 } |
|
1960 else |
|
1961 { |
|
1962 //Both address and alias added to messageData. |
|
1963 messageData->AppendToAddressL(*aMatch, *aName); |
|
1964 } |
|
1965 } |
|
1966 else |
|
1967 { |
|
1968 TInt count( recs->Count() ); |
|
1969 |
|
1970 for (TInt index = 0; index < count; index++) |
|
1971 { |
|
1972 messageData->AppendToAddressL( |
|
1973 *recs->At(index)->Address(), |
|
1974 *recs->At(index)->Name()); |
|
1975 } |
|
1976 } |
|
1977 HBufC* subjectText(NULL); |
|
1978 CMsgExpandableControl* subjectControl = SubjectControl(); |
|
1979 if ( subjectControl ) |
|
1980 { |
|
1981 HBufC* buf = subjectControl->Editor().GetTextInHBufL(); |
|
1982 // editor returns null pointer if subject line is empty, |
|
1983 // we must handle that |
|
1984 if ( !buf ) |
|
1985 { |
|
1986 buf = HBufC::NewL( 0 ); |
|
1987 } |
|
1988 CleanupStack::PushL( buf ); |
|
1989 // base editor provides a service which removes unneeded prefixes |
|
1990 subjectText = CreateSubjectPrefixStringL( *buf, ETrue ); |
|
1991 CleanupStack::PopAndDestroy( buf ); |
|
1992 CleanupStack::PushL( subjectText ); |
|
1993 } |
|
1994 messageData->SetSubjectL( subjectText ); |
|
1995 CleanupStack::PopAndDestroy( subjectText ); |
|
1996 |
|
1997 Document()->SendUiL().CreateAndSendMessageL( |
|
1998 aMtmUid, messageData ); |
|
1999 CleanupStack::PopAndDestroy(messageData); // messageData |
|
2000 |
|
2001 // check exit setting maintained by base editor (common to all types) |
|
2002 if ( !( iEditorBaseFeatures & EStayInViewerAfterReply ) ) |
|
2003 { |
|
2004 Exit(EAknSoftkeyBack); |
|
2005 } |
|
2006 } |
|
2007 } |
|
2008 |
|
2009 // ------------------------------------------------------------------------------ |
|
2010 // CMsgMailViewerAppUi::DoRetrieveMessageL() |
|
2011 // ------------------------------------------------------------------------------ |
|
2012 // |
|
2013 void CMsgMailViewerAppUi::DoRetrieveMessageL() |
|
2014 { |
|
2015 CMsgMailViewerDocument* doc = Document(); |
|
2016 doc->RetrieveMessageL(); |
|
2017 |
|
2018 // Refresh body text. HTML or plain text |
|
2019 doc->MailMessage().LoadMessageL(*this); |
|
2020 } |
|
2021 |
|
2022 // ------------------------------------------------------------------------------ |
|
2023 // CMsgMailViewerAppUi::SetAutomaticHighlightL() |
|
2024 // ------------------------------------------------------------------------------ |
|
2025 // |
|
2026 void CMsgMailViewerAppUi::SetAutomaticHighlightL( TInt aValue ) |
|
2027 { |
|
2028 if ( iFlags & EUseBaseBodyControl ) |
|
2029 { |
|
2030 // content highlight |
|
2031 if ( aValue ) |
|
2032 { // switch ON |
|
2033 iFindItemHandler->SetFindModeL( CItemFinder::EPhoneNumber | |
|
2034 CItemFinder::EUrlAddress | |
|
2035 CItemFinder::EEmailAddress ); |
|
2036 } |
|
2037 else |
|
2038 { // switch OFF |
|
2039 iFindItemHandler->SetFindModeL( CItemFinder::ENoneSelected ); |
|
2040 } |
|
2041 // header highlight |
|
2042 SetAddressControlHighlight( |
|
2043 AddressControl(EMsgComponentIdBcc), aValue ); |
|
2044 SetAddressControlHighlight( |
|
2045 AddressControl(EMsgComponentIdCc), aValue ); |
|
2046 SetAddressControlHighlight( |
|
2047 AddressControl(EMsgComponentIdFrom), aValue ); |
|
2048 SetAddressControlHighlight( |
|
2049 AddressControl(EMsgComponentIdTo), aValue ); |
|
2050 } |
|
2051 } |
|
2052 |
|
2053 // ------------------------------------------------------------------------------ |
|
2054 // CMsgMailViewerAppUi::DoSetAutomaticHighlightL() |
|
2055 // ------------------------------------------------------------------------------ |
|
2056 // |
|
2057 void CMsgMailViewerAppUi::DoSetAutomaticHighlightL() |
|
2058 { |
|
2059 TInt value(0); |
|
2060 TInt crError = Document()->MailCRHandler()->GetCRInt( |
|
2061 KCRUidCommonUi, |
|
2062 KCuiAutomaticHighlight, |
|
2063 value ); |
|
2064 SetAutomaticHighlightL(value); |
|
2065 } |
|
2066 |
|
2067 // ----------------------------------------------------------------------------- |
|
2068 // CMsgMailViewerAppUi::SetAddressControlHighlight |
|
2069 // ----------------------------------------------------------------------------- |
|
2070 // |
|
2071 void CMsgMailViewerAppUi::SetAddressControlHighlight( |
|
2072 CMsgAddressControl* aControl, TInt aValue ) |
|
2073 { |
|
2074 if ( aControl ) |
|
2075 { |
|
2076 aControl->SetAddressFieldAutoHighlight( aValue ); |
|
2077 } |
|
2078 } |
|
2079 |
|
2080 |
|
2081 // ----------------------------------------------------------------------------- |
|
2082 // CMsgMailViewerAppUi::DynInitOptionsMenu1L |
|
2083 // ----------------------------------------------------------------------------- |
|
2084 // |
|
2085 void CMsgMailViewerAppUi::DynInitOptionsMenu1L(CEikMenuPane& aMenuPane) |
|
2086 { |
|
2087 // Reply option |
|
2088 DoReplyOptionsMenuL( aMenuPane ); |
|
2089 |
|
2090 // Hides a Delete option from options menu if opened mail |
|
2091 // is an attachment mail. |
|
2092 if( IsAttachment() ) |
|
2093 { |
|
2094 aMenuPane.SetItemDimmed( EMsgMailViewerCmdDelete, ETrue ); |
|
2095 } |
|
2096 } |
|
2097 |
|
2098 // ----------------------------------------------------------------------------- |
|
2099 // CMsgMailViewerAppUi::DynInitOptionsMenu2L |
|
2100 // ----------------------------------------------------------------------------- |
|
2101 // |
|
2102 void CMsgMailViewerAppUi::DynInitOptionsMenu2L(CEikMenuPane& aMenuPane) |
|
2103 { |
|
2104 CMsgMailViewerDocument* doc = Document(); |
|
2105 |
|
2106 if ( !(iCommonFlags & EWestern) ) |
|
2107 { |
|
2108 if ( !iCharSetHandler ) |
|
2109 { |
|
2110 //Character set handler is now created, it is possible |
|
2111 //that character set changes if the user selects to do so |
|
2112 //Current character set must now be checked |
|
2113 if( Document()->Charset() == 0 ) |
|
2114 { |
|
2115 Document()->SetCharSet( GetCharsetIdL() ); |
|
2116 } |
|
2117 |
|
2118 //Create the character set handler |
|
2119 iCharSetHandler = CMsgMailCharacterSetHandler::NewL( |
|
2120 EMsgMailViewerFirstCharacterSetCmd); |
|
2121 } |
|
2122 iCharSetHandler->SetCharacterSetMenuItemL( aMenuPane ); |
|
2123 } |
|
2124 |
|
2125 // check whether the mail is filtered |
|
2126 if (!Document()->MailMessage().MessageEntry().PartialDownloaded()) |
|
2127 { |
|
2128 aMenuPane.DeleteMenuItem( EMsgMailViewerCmdRetrieve ); |
|
2129 } |
|
2130 |
|
2131 // hide Attachments, if message does not have any |
|
2132 aMenuPane.SetItemDimmed( |
|
2133 EMsgMailViewerCmdAttachments, |
|
2134 !( (iFlags & EAttachments) || iAttachmentLoadingOn ) ); |
|
2135 |
|
2136 if ( doc->MailCRHandler()->MailCopyMoveSupport() ) |
|
2137 { |
|
2138 // show copy or move depending on if message is local or not |
|
2139 if ( doc->CurrentEntry().OwningService() == |
|
2140 KMsvLocalServiceIndexEntryIdValue ) |
|
2141 { |
|
2142 aMenuPane.SetItemDimmed( EMsgMailViewerCmdMove, EFalse ); |
|
2143 } |
|
2144 else |
|
2145 { |
|
2146 aMenuPane.SetItemDimmed( EMsgMailViewerCmdCopy, EFalse ); |
|
2147 } |
|
2148 } |
|
2149 if ( !FeatureManager::FeatureSupported( KFeatureIdHelp )) |
|
2150 { |
|
2151 aMenuPane.SetItemDimmed( EAknCmdHelp, ETrue ); |
|
2152 } |
|
2153 } |
|
2154 |
|
2155 |
|
2156 // ----------------------------------------------------------------------------- |
|
2157 // CMsgMailViewerAppUi::IsDefaultSendKeyValueVoIPL |
|
2158 // ----------------------------------------------------------------------------- |
|
2159 // |
|
2160 TBool CMsgMailViewerAppUi::IsDefaultSendKeyValueVoIPL() const |
|
2161 { |
|
2162 return iMsgVoIPExtension->IsPreferredTelephonyVoIP(); |
|
2163 } |
|
2164 |
|
2165 // ----------------------------------------------------------------------------- |
|
2166 // CMsgMailViewerAppUi::LoadResourceFileL |
|
2167 // ----------------------------------------------------------------------------- |
|
2168 // |
|
2169 void CMsgMailViewerAppUi::LoadResourceFileL(const TDesC& aResourceName) |
|
2170 { |
|
2171 if ( aResourceName.Length() ) |
|
2172 { |
|
2173 TParse* fp = new(ELeave) TParse(); |
|
2174 fp->Set(aResourceName, &KDC_RESOURCE_FILES_DIR, NULL); |
|
2175 TFileName fileName(fp->FullName()); |
|
2176 BaflUtils::NearestLanguageFile( |
|
2177 iEikonEnv->FsSession() ,fileName); |
|
2178 LOG1("CMsgMailViewerAppUi iResourceLoader.Open:%S", |
|
2179 &fileName); |
|
2180 delete fp; |
|
2181 // only one resource can be opened, so close previous |
|
2182 iResourceLoader.Close(); |
|
2183 TInt err = iResourceLoader.Open(fileName); |
|
2184 LOG1("iResourceLoader.Open:%d", err); |
|
2185 } |
|
2186 } |
|
2187 |
|
2188 // ----------------------------------------------------------------------------- |
|
2189 // CMsgMailViewerAppUi::FocusedControlId |
|
2190 // returns EMsgComponentIdNull if nothing focused |
|
2191 // ----------------------------------------------------------------------------- |
|
2192 // |
|
2193 TMsgControlId CMsgMailViewerAppUi::FocusedControlId() const |
|
2194 { |
|
2195 TMsgControlId retVal = EMsgComponentIdNull; |
|
2196 CMsgBaseControl* ctrl = iView->FocusedControl(); |
|
2197 if ( ctrl ) |
|
2198 { |
|
2199 retVal = static_cast<TMsgControlId>( ctrl->ControlId() ); |
|
2200 } |
|
2201 return retVal; |
|
2202 } |
|
2203 |
|
2204 // ----------------------------------------------------------------------------- |
|
2205 // CMsgMailViewerAppUi::ValidateServiceL |
|
2206 // ----------------------------------------------------------------------------- |
|
2207 // |
|
2208 TBool CMsgMailViewerAppUi::ValidateServiceL( TUid aUid ) |
|
2209 { |
|
2210 // return ETrue also when service settings are not set |
|
2211 TSendingCapabilities dummy; |
|
2212 TInt error = Document()->SendUiL().ServiceCapabilitiesL( aUid, dummy ); |
|
2213 return ( error == KErrNone ); |
|
2214 } |
|
2215 |
|
2216 // ----------------------------------------------------------------------------- |
|
2217 // CMsgMailViewerAppUi::VoipProfileExistL |
|
2218 // ----------------------------------------------------------------------------- |
|
2219 // |
|
2220 TBool CMsgMailViewerAppUi::VoipProfileExistL() const |
|
2221 { |
|
2222 return iMsgVoIPExtension->VoIPProfilesExistL(); |
|
2223 } |
|
2224 |
|
2225 // ----------------------------------------------------------------------------- |
|
2226 // CMsgMailViewerAppUi::MessageAddresseeCount |
|
2227 // ----------------------------------------------------------------------------- |
|
2228 // |
|
2229 TInt CMsgMailViewerAppUi::MessageAddresseeCount() const |
|
2230 { |
|
2231 TInt count(0); |
|
2232 CImHeader* header = Document()->MailMessage().MessageHeader(); |
|
2233 ASSERT( header ); |
|
2234 count = header->CcRecipients().Count(); |
|
2235 // Add count only if several to recipients. |
|
2236 count += header->ToRecipients().Count() > 1 ? |
|
2237 header->ToRecipients().Count() : 0; |
|
2238 return count; |
|
2239 } |
|
2240 |
|
2241 // --------------------------------------------------------------------------- |
|
2242 // CMsgMailViewerAppUi::SetMiddleSoftKeyLabelL |
|
2243 // --------------------------------------------------------------------------- |
|
2244 // |
|
2245 void CMsgMailViewerAppUi::SetMiddleSoftKeyLabelL( |
|
2246 const TInt aResourceId, const TInt aCommandId ) |
|
2247 { |
|
2248 CEikButtonGroupContainer* cbaGroup = Cba(); |
|
2249 if ( cbaGroup ) |
|
2250 { |
|
2251 HBufC* middleSKText = StringLoader::LoadLC( aResourceId ); |
|
2252 TPtr mskPtr = middleSKText->Des(); |
|
2253 cbaGroup->AddCommandToStackL( |
|
2254 KMSKControlID, |
|
2255 aCommandId, |
|
2256 mskPtr ); |
|
2257 CleanupStack::PopAndDestroy( middleSKText ); |
|
2258 } |
|
2259 } |
|
2260 |
|
2261 // ----------------------------------------------------------------------------- |
|
2262 // CMsgMailViewerAppUi::RemoveMSKCommands |
|
2263 // ----------------------------------------------------------------------------- |
|
2264 // |
|
2265 void CMsgMailViewerAppUi::RemoveMSKCommands() |
|
2266 { |
|
2267 if ( Cba() ) |
|
2268 { |
|
2269 Cba()->RemoveCommandFromStack( KMSKControlID, EMsgMailViewerCmdAttachments ); |
|
2270 Cba()->RemoveCommandFromStack( KMSKControlID, EAknSoftkeyContextOptions ); |
|
2271 } |
|
2272 } |
|
2273 |
|
2274 // ----------------------------------------------------------------------------- |
|
2275 // CMsgMailViewerAppUi::SpecialScrolling |
|
2276 // ----------------------------------------------------------------------------- |
|
2277 // |
|
2278 TBool CMsgMailViewerAppUi::SpecialScrolling( TUint aKeyCode ) |
|
2279 { |
|
2280 TBool keyConsumed( EFalse ); |
|
2281 // last address is the first when direction is EFalse, may also be NULL |
|
2282 CMsgAddressControl* lastAddressControl( GetFirstAddressControl( EFalse ) ); |
|
2283 if ( aKeyCode == EKeyDownArrow || aKeyCode == EKeyUpArrow ) |
|
2284 { |
|
2285 CMsgBaseControl* focusedControl = iView->FocusedControl(); |
|
2286 if ( focusedControl ) |
|
2287 { |
|
2288 TInt focused( focusedControl->ControlId() ); |
|
2289 if ( aKeyCode == EKeyDownArrow ) |
|
2290 { |
|
2291 // Focus in on last address field?? |
|
2292 if ( lastAddressControl && |
|
2293 focused == lastAddressControl->ControlId() ) |
|
2294 { |
|
2295 // jump directly to atta control |
|
2296 if ( iView->ControlById( EMsgComponentIdAttachment ) ) |
|
2297 { |
|
2298 iView->SetFocus( EMsgComponentIdAttachment ); |
|
2299 keyConsumed = ETrue; |
|
2300 } |
|
2301 // or directly to body |
|
2302 else if ( BodyControl() ) |
|
2303 { |
|
2304 iView->SetFocus( BodyControl()->ControlId() ); |
|
2305 keyConsumed = ETrue; |
|
2306 } |
|
2307 } |
|
2308 } |
|
2309 else |
|
2310 { |
|
2311 // scroll up, and focus is top of the body part |
|
2312 if ( focused == EMsgComponentIdBody && |
|
2313 BodyControl()->IsFocusChangePossible( EMsgFocusUp ) ) |
|
2314 { |
|
2315 // Move focus to atta control |
|
2316 if ( iView->ControlById( EMsgComponentIdAttachment ) ) |
|
2317 { |
|
2318 iView->SetFocus( EMsgComponentIdAttachment ); |
|
2319 keyConsumed = ETrue; |
|
2320 } |
|
2321 // or move to the last address field if one exists |
|
2322 else if ( lastAddressControl ) |
|
2323 { |
|
2324 iView->SetFocus( lastAddressControl->ControlId() ); |
|
2325 keyConsumed = ETrue; |
|
2326 } |
|
2327 } |
|
2328 // scroll up when focus is on the attachment control and |
|
2329 // one address control exists |
|
2330 else if ( focused == EMsgComponentIdAttachment && |
|
2331 lastAddressControl ) |
|
2332 { |
|
2333 // Move focus to last address control |
|
2334 iView->SetFocus( lastAddressControl->ControlId() ); |
|
2335 keyConsumed = ETrue; |
|
2336 } |
|
2337 } |
|
2338 } |
|
2339 } |
|
2340 |
|
2341 return keyConsumed; |
|
2342 } |
|
2343 // ---------------------------------------------------------------------------- |
|
2344 // void CMsgMailViewerAppUi::EditorObserver() |
|
2345 // ---------------------------------------------------------------------------- |
|
2346 // |
|
2347 void CMsgMailViewerAppUi::EditorObserver( TMsgEditorObserverFunc aFunc, |
|
2348 TAny* aArg1, |
|
2349 TAny* aArg2, |
|
2350 TAny* aArg3) |
|
2351 { |
|
2352 if ( aFunc == MMsgEditorObserver::EMsgHandleFocusChange ) |
|
2353 { |
|
2354 ASSERT( aArg1 ); |
|
2355 TMsgControlId controlId = FocusedControlId(); |
|
2356 CMsgBaseControl* focusedControl = iView->FocusedControl(); |
|
2357 |
|
2358 TInt err(0); |
|
2359 |
|
2360 if ( Document()->MailCRHandler()->MailAttachmentField() && |
|
2361 controlId == EMsgComponentIdAttachment && |
|
2362 iLastControlId != EMsgComponentIdAttachment ) |
|
2363 { |
|
2364 RemoveMSKCommands(); |
|
2365 |
|
2366 //Change msk label to "attachments" |
|
2367 TRAP(err, SetMiddleSoftKeyLabelL(R_QTN_MSK_ATTACHMENT, EMsgMailViewerCmdAttachments)); |
|
2368 } |
|
2369 //If last control was atta we must change back to context options menu. |
|
2370 else if( iLastControlId == EMsgComponentIdAttachment && |
|
2371 controlId != EMsgComponentIdAttachment ) |
|
2372 { |
|
2373 RemoveMSKCommands(); |
|
2374 |
|
2375 //Change msk label back to normal (context sensitive menu icon) |
|
2376 TRAP(err, SetMiddleSoftKeyLabelL(R_TEXT_SOFTKEY_OPTION, EAknSoftkeyContextOptions)); |
|
2377 } |
|
2378 |
|
2379 |
|
2380 if(err == KErrNone) |
|
2381 { |
|
2382 //Collect current id, may be EMsgComponentIdNull |
|
2383 iLastControlId = controlId; |
|
2384 } |
|
2385 |
|
2386 } |
|
2387 #ifdef RD_SCALABLE_UI_V2 |
|
2388 else if( aFunc == MMsgEditorObserver::EMsgControlPointerEvent ) |
|
2389 { |
|
2390 if( aArg1 && aArg2 ) |
|
2391 { |
|
2392 TPointerEvent* event = static_cast<TPointerEvent*>( aArg2 ); |
|
2393 CMsgBaseControl* control = static_cast<CMsgBaseControl*>( aArg1 ); |
|
2394 |
|
2395 if ( event->iType == TPointerEvent::EButton1Down ) |
|
2396 { |
|
2397 iFocusedControl = control; |
|
2398 } |
|
2399 else if ( event->iType == TPointerEvent::EButton1Up ) |
|
2400 { |
|
2401 if( control && iFocusedControl == control && |
|
2402 control->ControlId() == EMsgComponentIdAttachment ) |
|
2403 { |
|
2404 //Summon touch functionality |
|
2405 TRAP_IGNORE( DoAttachmentL() ); |
|
2406 } |
|
2407 iFocusedControl = NULL; |
|
2408 } |
|
2409 } |
|
2410 } |
|
2411 #endif |
|
2412 CMsgEditorAppUi::EditorObserver(aFunc, aArg1, aArg2, aArg3); |
|
2413 } |
|
2414 |
|
2415 // -------------------------------------------------------------------------- |
|
2416 // CMsgMailViewerAppUi::CanMakeCallToContactL |
|
2417 // -------------------------------------------------------------------------- |
|
2418 // |
|
2419 TBool CMsgMailViewerAppUi::CanMakeCallToContactL() const |
|
2420 { |
|
2421 TBool retVal( EFalse ); |
|
2422 // We can show call option in following situations. |
|
2423 //From Mail Ui Specification: |
|
2424 //Send key initiates a voice call |
|
2425 //creation functionality for the sender in case |
|
2426 //the focus is in From field, when focus is not in |
|
2427 //a phonenumber or in case the auto-highlight |
|
2428 //functionality is set off. |
|
2429 //Send key is inactive is inactive, |
|
2430 //when message is opened from Sent items |
|
2431 //folder . |
|
2432 |
|
2433 TBool isBodyFocused( FocusedControlId() == EMsgComponentIdBody ); |
|
2434 TBool isFromFocused( FocusedControlId() == EMsgComponentIdFrom ); |
|
2435 |
|
2436 #if defined(__VOIP) && defined(RD_VOIP_REL_2_2) |
|
2437 if ( !MailMessageUtils::IsOutgoingL( Document()->MailMessage() ) && |
|
2438 ( !isBodyFocused ) ) |
|
2439 { |
|
2440 retVal = ETrue; |
|
2441 } |
|
2442 #else |
|
2443 CItemFinder::TItemType selectionType( |
|
2444 iFindItemHandler->SelectionType( isBodyFocused ) ); |
|
2445 |
|
2446 if ( !MailMessageUtils::IsOutgoingL( Document()->MailMessage() ) && |
|
2447 ( isFromFocused || selectionType != CItemFinder::EPhoneNumber ) ) |
|
2448 { |
|
2449 retVal = ETrue; |
|
2450 } |
|
2451 #endif // __VOIP && RD_VOIP_REL_2_2 |
|
2452 |
|
2453 return retVal; |
|
2454 } |
|
2455 |
|
2456 // -------------------------------------------------------------------------- |
|
2457 // CMsgMailViewerAppUi::FocusedOrFirstAddressControl |
|
2458 // This method returns empty string if GetFirstAddressControl() returns NULL |
|
2459 // -------------------------------------------------------------------------- |
|
2460 // |
|
2461 CMsgAddressControl* CMsgMailViewerAppUi::FocusedOrFirstAddressControl() const |
|
2462 { |
|
2463 CMsgAddressControl* addressControl( NULL ); |
|
2464 TInt controlId( FocusedControlId() ); |
|
2465 if ( controlId == EMsgComponentIdTo || |
|
2466 controlId == EMsgComponentIdFrom || |
|
2467 controlId == EMsgComponentIdCc || |
|
2468 controlId == EMsgComponentIdBcc ) |
|
2469 { |
|
2470 addressControl = AddressControl( controlId ); |
|
2471 } |
|
2472 else |
|
2473 { |
|
2474 addressControl = GetFirstAddressControl(); |
|
2475 } |
|
2476 return addressControl; |
|
2477 } |
|
2478 |
|
2479 // -------------------------------------------------------------------------- |
|
2480 // CMsgMailViewerAppUi::IsAttachment |
|
2481 // -------------------------------------------------------------------------- |
|
2482 // |
|
2483 TBool CMsgMailViewerAppUi::IsAttachment() const |
|
2484 { |
|
2485 CMsgMailViewerDocument* doc = Document(); |
|
2486 |
|
2487 TMsvId parentId = doc->Entry().Parent(); |
|
2488 TMsvId serviceId; |
|
2489 TMsvEntry entry; |
|
2490 |
|
2491 // Have to get parent's parent. |
|
2492 doc->Session().GetEntry(parentId, serviceId, entry); |
|
2493 parentId = entry.Parent(); |
|
2494 doc->Session().GetEntry(parentId, serviceId, entry); |
|
2495 |
|
2496 if( entry.Attachment() ) |
|
2497 { |
|
2498 return ETrue; |
|
2499 } |
|
2500 else |
|
2501 { |
|
2502 return EFalse; |
|
2503 } |
|
2504 } |
|
2505 |
|
2506 // -------------------------------------------------------------------------- |
|
2507 // CMsgMailViewerAppUi::HandleEnterKeyL |
|
2508 // Handles enter key events. |
|
2509 // -------------------------------------------------------------------------- |
|
2510 // |
|
2511 void CMsgMailViewerAppUi::HandleEnterKeyL() |
|
2512 { |
|
2513 if( iView ) |
|
2514 { |
|
2515 CMsgBaseControl* focusedCtrl = iView->FocusedControl(); |
|
2516 if( focusedCtrl ) |
|
2517 { |
|
2518 switch( focusedCtrl->ControlId() ) |
|
2519 { |
|
2520 case EMsgComponentIdAttachment: |
|
2521 { |
|
2522 // Open attachment view |
|
2523 DoAttachmentL(); |
|
2524 break; |
|
2525 } |
|
2526 default: |
|
2527 { |
|
2528 // Display context menu |
|
2529 CEikMenuBar* menu = MenuBar(); |
|
2530 if( menu ) |
|
2531 { |
|
2532 menu->TryDisplayContextMenuBarL(); |
|
2533 } |
|
2534 break; |
|
2535 } |
|
2536 } |
|
2537 } |
|
2538 } |
|
2539 } |
|
2540 |
|
2541 // --------------------------------------------------------- |
|
2542 // CMsgMailViewerAppUi::HandleEntryDeletedL |
|
2543 // |
|
2544 // HandleEntryDeletedL is called when the currently open message |
|
2545 // has been deleted by some other messaging client. |
|
2546 // --------------------------------------------------------- |
|
2547 // |
|
2548 void CMsgMailViewerAppUi::HandleEntryDeletedL() |
|
2549 { |
|
2550 //If message has been deleted while same entry is open on viewer |
|
2551 //we need to close viewer and go back to mce. |
|
2552 Exit(EAknSoftkeyBack); |
|
2553 } |
|
2554 |
|
2555 // End of File |