emailuis/emailui/src/FreestyleEmailUiUtilities.cpp
branchRCL_3
changeset 20 efd4f1afd43e
parent 18 6b8f3b30d0ec
equal deleted inserted replaced
18:6b8f3b30d0ec 20:efd4f1afd43e
   234         // Close open file handle.
   234         // Close open file handle.
   235         iFileHandle.Close();
   235         iFileHandle.Close();
   236         iHandleOpen = EFalse;
   236         iHandleOpen = EFalse;
   237         }
   237         }
   238     MAknServerAppExitObserver::HandleServerAppExit( aReason );
   238     MAknServerAppExitObserver::HandleServerAppExit( aReason );
   239     
   239 
   240     // Get current AppUi.
   240     // Get current AppUi.
   241     CFreestyleEmailUiAppUi* appUi = (CFreestyleEmailUiAppUi*)CCoeEnv::Static()->AppUi();
   241     CFreestyleEmailUiAppUi* appUi = (CFreestyleEmailUiAppUi*)CCoeEnv::Static()->AppUi();
   242     if( appUi->EmbeddedApp() )
   242     if( appUi->EmbeddedApp() )
   243         {
   243         {
   244         // Set embedded application flag to false when embedded application exit.
   244         // Set embedded application flag to false when embedded application exit.
   245         appUi->SetEmbeddedApp( EFalse );
   245         appUi->SetEmbeddedApp( EFalse );
   246         }
   246         }
   247     
   247 
   248     // if email editor is not started from embedded app.
   248     // if email editor is not started from embedded app.
   249     if( !appUi->EditorStartedFromEmbeddedApp() )
   249     if( !appUi->EditorStartedFromEmbeddedApp() )
   250         {
   250         {
   251         // Do not set embedded app to previous app.
   251         // Do not set embedded app to previous app.
   252         appUi->SetEmbeddedAppToPreviousApp( EFalse );
   252         appUi->SetEmbeddedAppToPreviousApp( EFalse );
   519 // -----------------------------------------------------------------------------
   519 // -----------------------------------------------------------------------------
   520 // TFsEmailUiUtility::ShowDiscreetInfoNoteL
   520 // TFsEmailUiUtility::ShowDiscreetInfoNoteL
   521 // -----------------------------------------------------------------------------
   521 // -----------------------------------------------------------------------------
   522 void TFsEmailUiUtility::ShowDiscreetInfoNoteL( TInt aResourceStringId )
   522 void TFsEmailUiUtility::ShowDiscreetInfoNoteL( TInt aResourceStringId )
   523     {
   523     {
   524     FUNC_LOG;   
   524     FUNC_LOG;
   525     HBufC* noteText = StringLoader::LoadLC( aResourceStringId );
   525     HBufC* noteText = StringLoader::LoadLC( aResourceStringId );
   526     ShowDiscreetInfoNoteL( *noteText );
   526     ShowDiscreetInfoNoteL( *noteText );
   527     CleanupStack::PopAndDestroy( noteText );
   527     CleanupStack::PopAndDestroy( noteText );
   528     }
   528     }
   529 
   529 
   530 // -----------------------------------------------------------------------------
   530 // -----------------------------------------------------------------------------
   531 // TFsEmailUiUtility::ShowDiscreetInfoNoteL
   531 // TFsEmailUiUtility::ShowDiscreetInfoNoteL
   532 // -----------------------------------------------------------------------------
   532 // -----------------------------------------------------------------------------
   533 void TFsEmailUiUtility::ShowDiscreetInfoNoteL( const TDesC& aNoteText )
   533 void TFsEmailUiUtility::ShowDiscreetInfoNoteL( const TDesC& aNoteText )
   534     {
   534     {
   535     FUNC_LOG;   
   535     FUNC_LOG;
   536     //create a host of dummy parameters in order to change the popup duration flag...
   536     //create a host of dummy parameters in order to change the popup duration flag...
   537     const TDesC& dummyText = KNullDesC;
   537     const TDesC& dummyText = KNullDesC;
   538     CGulIcon* dummyIcon = NULL;
   538     CGulIcon* dummyIcon = NULL;
   539     const TAknsItemID& dummySkinId = KAknsIIDNone;
   539     const TAknsItemID& dummySkinId = KAknsIIDNone;
   540     const TDesC& dummyBitmapFile = KNullDesC;
   540     const TDesC& dummyBitmapFile = KNullDesC;
   541     const TInt dummyBitmapId = 0;
   541     const TInt dummyBitmapId = 0;
   542     const TInt dummyMaskId = 0;
   542     const TInt dummyMaskId = 0;
   543     
   543 
   544     //Set timeout flag
   544     //Set timeout flag
   545     TInt flags = 0;
   545     TInt flags = 0;
   546     flags |= KAknDiscreetPopupDurationLong;
   546     flags |= KAknDiscreetPopupDurationLong;
   547     
   547 
   548     CAknDiscreetPopup::ShowLocalPopupL( aNoteText, 
   548     CAknDiscreetPopup::ShowLocalPopupL( aNoteText,
   549                                         dummyText, 
   549                                         dummyText,
   550                                         dummyIcon, 
   550                                         dummyIcon,
   551                                         dummySkinId,
   551                                         dummySkinId,
   552                                         dummyBitmapFile, 
   552                                         dummyBitmapFile,
   553                                         dummyBitmapId, 
   553                                         dummyBitmapId,
   554                                         dummyMaskId, 
   554                                         dummyMaskId,
   555                                         flags);
   555                                         flags);
   556     }
   556     }
   557 
   557 
   558 // -----------------------------------------------------------------------------
   558 // -----------------------------------------------------------------------------
   559 // TFsEmailUiUtility::ShowWaitNoteL
   559 // TFsEmailUiUtility::ShowWaitNoteL
   702 // TFsEmailUiUtility::ShowFileSavedToFolderNoteL
   702 // TFsEmailUiUtility::ShowFileSavedToFolderNoteL
   703 // -----------------------------------------------------------------------------
   703 // -----------------------------------------------------------------------------
   704 void TFsEmailUiUtility::ShowFilesSavedToFolderNoteL( TInt aCount )
   704 void TFsEmailUiUtility::ShowFilesSavedToFolderNoteL( TInt aCount )
   705     {
   705     {
   706     FUNC_LOG;
   706     FUNC_LOG;
   707     if ( !iDownloadSave || iSaveSelect ) 
   707     if ( !iDownloadSave || iSaveSelect )
   708         { 
   708         {
   709 	    if ( aCount == 1 )
   709 	    if ( aCount == 1 )
   710 	        {
   710 	        {
   711 	        HBufC* noteText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_ONE_ATTACHMENT_SAVED );
   711 	        HBufC* noteText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_ONE_ATTACHMENT_SAVED );
   712 	        ShowDiscreetInfoNoteL( *noteText );
   712 	        ShowDiscreetInfoNoteL( *noteText );
   713 	        CleanupStack::PopAndDestroy( noteText );
   713 	        CleanupStack::PopAndDestroy( noteText );
   717 	        HBufC* noteText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_MULTIPLE_ATTACHMENT_SAVED, aCount );
   717 	        HBufC* noteText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_MULTIPLE_ATTACHMENT_SAVED, aCount );
   718 	        ShowDiscreetInfoNoteL( *noteText );
   718 	        ShowDiscreetInfoNoteL( *noteText );
   719 	        CleanupStack::PopAndDestroy( noteText );
   719 	        CleanupStack::PopAndDestroy( noteText );
   720 	        }
   720 	        }
   721         }
   721         }
   722     TFsEmailUiUtility::SetSaveSelect( ETrue ); 
   722     TFsEmailUiUtility::SetSaveSelect( ETrue );
   723     TFsEmailUiUtility::SetDownloadSave( EFalse ); 
   723     TFsEmailUiUtility::SetDownloadSave( EFalse );
   724     }
   724     }
   725 
   725 
   726 void TFsEmailUiUtility::SetDownloadSave( TBool aValue )
   726 void TFsEmailUiUtility::SetDownloadSave( TBool aValue )
   727     {
   727     {
   728     FUNC_LOG;
   728     FUNC_LOG;
   840                 aAttachmentPart.GetFolderId(),
   840                 aAttachmentPart.GetFolderId(),
   841                 aAttachmentPart.GetPartId(),
   841                 aAttachmentPart.GetPartId(),
   842                 EFSMsgDataEnvelope ) );
   842                 EFSMsgDataEnvelope ) );
   843 
   843 
   844         // If we still have no message, then try to convert the attachment file to message object (Activesync case).
   844         // If we still have no message, then try to convert the attachment file to message object (Activesync case).
   845         if ( !message ) 
   845         if ( !message )
   846             {
   846             {
   847             // This takes some time so we show a wait dialog.
   847             // This takes some time so we show a wait dialog.
   848             if ( iOpeningWaitNote )
   848             if ( iOpeningWaitNote )
   849                 {
   849                 {
   850                 iOpeningWaitNote->ProcessFinishedL();
   850                 iOpeningWaitNote->ProcessFinishedL();
   864             }
   864             }
   865 
   865 
   866         // Open message to viewer if we got it. Otherwise continue with the standard file opening logic.
   866         // Open message to viewer if we got it. Otherwise continue with the standard file opening logic.
   867         if ( message )
   867         if ( message )
   868             {
   868             {
   869             // Check that the embedded message has text body part or html body part. 
   869             // Check that the embedded message has text body part or html body part.
   870             // Otherwise we cannot display it viewer and needs to be handled as a normal attachment.
   870             // Otherwise we cannot display it viewer and needs to be handled as a normal attachment.
   871             
   871 
   872             CFSMailMessagePart* htmlPart = message->HtmlBodyPartL();
   872             CFSMailMessagePart* htmlPart = message->HtmlBodyPartL();
   873             CFSMailMessagePart* textPart = message->PlainTextBodyPartL();
   873             CFSMailMessagePart* textPart = message->PlainTextBodyPartL();
   874             
   874 
   875             if ( htmlPart || textPart  )
   875             if ( htmlPart || textPart  )
   876                 {
   876                 {
   877                 THtmlViewerActivationData htmlData; 
   877                 THtmlViewerActivationData htmlData;
   878                 htmlData.iActivationDataType = THtmlViewerActivationData::EmbeddedEmailMessage;
   878                 htmlData.iActivationDataType = THtmlViewerActivationData::EmbeddedEmailMessage;
   879                 htmlData.iMailBoxId = aAttachmentPart.GetMailBoxId();
   879                 htmlData.iMailBoxId = aAttachmentPart.GetMailBoxId();
   880                 htmlData.iFolderId = aAttachmentPart.GetFolderId();
   880                 htmlData.iFolderId = aAttachmentPart.GetFolderId();
   881                 htmlData.iMessageId = aAttachmentPart.GetPartId();
   881                 htmlData.iMessageId = aAttachmentPart.GetPartId();
   882                 // ownership of message gets transfered to html viewer.
   882                 // ownership of message gets transfered to html viewer.
   883                 htmlData.iEmbeddedMessage = message;
   883                 htmlData.iEmbeddedMessage = message;
   884                 htmlData.iEmbeddedMessageMode = ETrue;
   884                 htmlData.iEmbeddedMessageMode = ETrue;
   885                 TPckgBuf<THtmlViewerActivationData> pckgData( htmlData );
   885                 TPckgBuf<THtmlViewerActivationData> pckgData( htmlData );
   886                 
   886 
   887                 appUi->EnterFsEmailViewL( HtmlViewerId, KStartViewerWithEmbeddedMsgPtr, pckgData );
   887                 appUi->EnterFsEmailViewL( HtmlViewerId, KStartViewerWithEmbeddedMsgPtr, pckgData );
   888                 openedAsMessage = ETrue;
   888                 openedAsMessage = ETrue;
   889                 }
   889                 }
   890             else
   890             else
   891                 {
   891                 {
   892                 //delete message object owned by us.
   892                 //delete message object owned by us.
   893                 delete message;
   893                 delete message;
   894                 }
   894                 }
   895             
   895 
   896             if( htmlPart )
   896             if( htmlPart )
   897                 {
   897                 {
   898                 delete htmlPart;
   898                 delete htmlPart;
   899                 }
   899                 }
   900             if( textPart )
   900             if( textPart )
   901                 {
   901                 {
   902                 delete textPart;
   902                 delete textPart;
   903                 }
   903                 }
   904             
   904 
   905             }
   905             }
   906         }
   906         }
   907 
   907 
   908     // Normal attachment file opening
   908     // Normal attachment file opening
   909     if ( !openedAsMessage )
   909     if ( !openedAsMessage )
  1229     TInt semiColonPos( aMimeType.Locate(';') );
  1229     TInt semiColonPos( aMimeType.Locate(';') );
  1230     if( semiColonPos != KErrNotFound )
  1230     if( semiColonPos != KErrNotFound )
  1231     	{
  1231     	{
  1232     	mimeType.Set( aMimeType.Left(semiColonPos) );
  1232     	mimeType.Set( aMimeType.Left(semiColonPos) );
  1233     	}
  1233     	}
  1234     
  1234 
  1235 	if ( !mimeType.CompareF(KPdfMimeString) )
  1235 	if ( !mimeType.CompareF(KPdfMimeString) )
  1236 		{
  1236 		{
  1237 		fileType = EPdfType;
  1237 		fileType = EPdfType;
  1238 		}
  1238 		}
  1239 	else if ( !mimeType.CompareF(KDocMimeString) ||
  1239 	else if ( !mimeType.CompareF(KDocMimeString) ||
  2328     return aMsgPtr->GetToRecipients().Count() + aMsgPtr->GetCCRecipients().Count();
  2328     return aMsgPtr->GetToRecipients().Count() + aMsgPtr->GetCCRecipients().Count();
  2329     }
  2329     }
  2330 
  2330 
  2331 // -----------------------------------------------------------------------------
  2331 // -----------------------------------------------------------------------------
  2332 // TFsEmailUiUtility::CountRecipientsSmart
  2332 // TFsEmailUiUtility::CountRecipientsSmart
  2333 // Calculates recipient count from To and Cc recipient as well as tries to 
  2333 // Calculates recipient count from To and Cc recipient as well as tries to
  2334 // see if the message is sent via message list.
  2334 // see if the message is sent via message list.
  2335 // -----------------------------------------------------------------------------
  2335 // -----------------------------------------------------------------------------
  2336 TInt TFsEmailUiUtility::CountRecipientsSmart( CFreestyleEmailUiAppUi& aAppUi, CFSMailMessage* aMsgPtr )
  2336 TInt TFsEmailUiUtility::CountRecipientsSmart( CFreestyleEmailUiAppUi& aAppUi, CFSMailMessage* aMsgPtr )
  2337     {
  2337     {
  2338     FUNC_LOG;
  2338     FUNC_LOG;
  2339     TInt numRecipients( CountRecepients( aMsgPtr ) );
  2339     TInt numRecipients( CountRecepients( aMsgPtr ) );
  2340     if ( numRecipients == 1 )
  2340     if ( numRecipients == 1 )
  2341         {
  2341         {
  2342         CFSMailBox* mailBox = NULL;
  2342         CFSMailBox* mailBox = NULL;
  2343         
  2343 
  2344         TRAPD( error, mailBox = aAppUi.GetMailClient()->GetMailBoxByUidL( aMsgPtr->GetMailBoxId() ) );
  2344         TRAPD( error, mailBox = aAppUi.GetMailClient()->GetMailBoxByUidL( aMsgPtr->GetMailBoxId() ) );
  2345         
  2345 
  2346         if (mailBox && !error)
  2346         if (mailBox && !error)
  2347             {
  2347             {
  2348             //check if the malbox ownmailaddress is same as the recipients email address. If not, then assume that the
  2348             //check if the malbox ownmailaddress is same as the recipients email address. If not, then assume that the
  2349             //email is a distribution list and we need to inc num of Recipients so that "Reply ALL" option appears in UI.
  2349             //email is a distribution list and we need to inc num of Recipients so that "Reply ALL" option appears in UI.
  2350             if ( aMsgPtr->GetToRecipients().Count() )
  2350             if ( aMsgPtr->GetToRecipients().Count() )
  2367                     {
  2367                     {
  2368                     numRecipients++;
  2368                     numRecipients++;
  2369                     }
  2369                     }
  2370                 }
  2370                 }
  2371             }
  2371             }
  2372         
  2372 
  2373         delete mailBox;
  2373         delete mailBox;
  2374         }
  2374         }
  2375     
  2375 
  2376     return numRecipients;
  2376     return numRecipients;
  2377     }
  2377     }
  2378 
  2378 
  2379 // -----------------------------------------------------------------------------
  2379 // -----------------------------------------------------------------------------
  2380 // TFsEmailUiUtility::IsMessageBodyLargeL
  2380 // TFsEmailUiUtility::IsMessageBodyLargeL
  2445 				textureId = EMessageCalInvitation;
  2445 				textureId = EMessageCalInvitation;
  2446 				}
  2446 				}
  2447 			}
  2447 			}
  2448         // <cmail>
  2448         // <cmail>
  2449 		TBool cancellationMsg = EFalse;
  2449 		TBool cancellationMsg = EFalse;
  2450 		TRAP_IGNORE( cancellationMsg = IsMrCancellationMsgL( aMsgPtr ) );
  2450 		//TRAP_IGNORE( cancellationMsg = IsMrCancellationMsgL( aMsgPtr ) );
  2451 		if ( cancellationMsg )
  2451 		if ( cancellationMsg )
  2452 		    {
  2452 		    {
  2453 		    textureId = EMessageCalInvitationCancelled;
  2453 		    textureId = EMessageCalInvitationCancelled;
  2454 		    }
  2454 		    }
  2455         // </cmail>
  2455         // </cmail>
  2602 				textureId = EMessageCalInvitationRead;
  2602 				textureId = EMessageCalInvitationRead;
  2603 				}
  2603 				}
  2604 			}
  2604 			}
  2605 		// <cmail>
  2605 		// <cmail>
  2606 		TBool cancellationMsg = EFalse;
  2606 		TBool cancellationMsg = EFalse;
  2607 		TRAP_IGNORE( cancellationMsg = IsMrCancellationMsgL( aMsgPtr ) );
  2607 		//TRAP_IGNORE( cancellationMsg = IsMrCancellationMsgL( aMsgPtr ) );
  2608 		if ( cancellationMsg )
  2608 		if ( cancellationMsg )
  2609 		    {
  2609 		    {
  2610             textureId = EMessageCalInvitationCancelled;
  2610             textureId = EMessageCalInvitationCancelled;
  2611             }
  2611             }
  2612         // </cmail>
  2612         // </cmail>
  2807             {
  2807             {
  2808             TBuf<256> mailbox;
  2808             TBuf<256> mailbox;
  2809             mailbox.Num(aMailBox.Id());
  2809             mailbox.Num(aMailBox.Id());
  2810 
  2810 
  2811             TBuf<256> str;
  2811             TBuf<256> str;
  2812             str.Copy(_L("<"));    
  2812             str.Copy(_L("<"));
  2813             str.Append(mailbox);
  2813             str.Append(mailbox);
  2814             str.Append(_L(">"));    
  2814             str.Append(_L(">"));
  2815 
  2815 
  2816             TBuf<256> stored;
  2816             TBuf<256> stored;
  2817             TUint32 key(KCMailMailboxesWithNewMail);
  2817             TUint32 key(KCMailMailboxesWithNewMail);
  2818             repository->Get( key, stored );
  2818             repository->Get( key, stored );
  2819     
  2819 
  2820             TInt result = stored.Find(str);
  2820             TInt result = stored.Find(str);
  2821     
  2821 
  2822             if (aIconOn)
  2822             if (aIconOn)
  2823                 {
  2823                 {
  2824                 if (result < 0) // Not found
  2824                 if (result < 0) // Not found
  2825                     {
  2825                     {
  2826                     stored.Append(str);
  2826                     stored.Append(str);
  2837                 }
  2837                 }
  2838             }
  2838             }
  2839         delete repository;
  2839         delete repository;
  2840         }
  2840         }
  2841 	}
  2841 	}
  2842 	
  2842 
  2843 // -----------------------------------------------------------------------------
  2843 // -----------------------------------------------------------------------------
  2844 // TFsEmailUiUtility::DisplayMsgsMovedNoteL
  2844 // TFsEmailUiUtility::DisplayMsgsMovedNoteL
  2845 // -----------------------------------------------------------------------------
  2845 // -----------------------------------------------------------------------------
  2846 void TFsEmailUiUtility::DisplayMsgsMovedNoteL( TInt aMsgCount, const TFSMailMsgId aDestinationFolderId,
  2846 void TFsEmailUiUtility::DisplayMsgsMovedNoteL( TInt aMsgCount, const TFSMailMsgId aDestinationFolderId,
  2847 										   	   TBool /*aIsWaitingNote*/ )
  2847 										   	   TBool /*aIsWaitingNote*/ )