241 { |
241 { |
242 // low priority active obj so that iwait in plugins finish |
242 // low priority active obj so that iwait in plugins finish |
243 iActiveHelper->Cancel(); |
243 iActiveHelper->Cancel(); |
244 iActiveHelper->Start(); |
244 iActiveHelper->Start(); |
245 } |
245 } |
|
246 else if ( iIncludeMessageTextAsync ) |
|
247 { |
|
248 if ( iContainer ) |
|
249 { |
|
250 iContainer->StopAsyncTextFormatter(); |
|
251 } |
|
252 ResetComposer(); |
|
253 iAsyncCallback->Cancel(); // cancel any outstanding callback |
|
254 iAsyncCallback->Set( TCallBack( AsyncExit, this ) ); |
|
255 iAsyncCallback->CallBack(); |
|
256 } |
246 else |
257 else |
247 { |
258 { |
248 DoSafeExit( ESaveDraft ); |
259 DoSafeExit( ESaveDraft ); |
249 |
260 |
250 // cleaning - usefull when application is closed from task switcher |
261 // cleaning - usefull when application is closed from task switcher |
275 // |
286 // |
276 void CNcsComposeView::ChildDoActivateL( const TVwsViewId& aPrevViewId, |
287 void CNcsComposeView::ChildDoActivateL( const TVwsViewId& aPrevViewId, |
277 TUid aCustomMessageId, const TDesC8& aCustomMessage ) |
288 TUid aCustomMessageId, const TDesC8& aCustomMessage ) |
278 { |
289 { |
279 FUNC_LOG; |
290 FUNC_LOG; |
|
291 |
|
292 // needed when "Opening" (replying/forwarding)note is shown and |
|
293 // we receive incoming call- Email application goes to background. |
|
294 // When coming back to application the view is activated and reseted. |
|
295 // That's why we prevent activation and the same is done in ChildDoDeactivate |
|
296 if ( iIncludeMessageTextAsync ) |
|
297 { |
|
298 return; |
|
299 } |
|
300 |
280 if ( !iFirstStartCompleted ) |
301 if ( !iFirstStartCompleted ) |
281 { |
302 { |
282 DoFirstStartL(); |
303 DoFirstStartL(); |
283 } |
304 } |
284 Toolbar()->SetDimmed( ETrue ); |
305 Toolbar()->SetDimmed( ETrue ); |
1878 |
1916 |
1879 CleanupStack::PopAndDestroy( body ); |
1917 CleanupStack::PopAndDestroy( body ); |
1880 } |
1918 } |
1881 |
1919 |
1882 // ----------------------------------------------------------------------------- |
1920 // ----------------------------------------------------------------------------- |
|
1921 // CNcsComposeView::IncludeMessageTextAsyncL() |
|
1922 // |
|
1923 // ----------------------------------------------------------------------------- |
|
1924 // |
|
1925 void CNcsComposeView::IncludeMessageTextAsyncL( TBool aEnsureSpaceInBegin /*= EFalse*/ ) |
|
1926 { |
|
1927 FUNC_LOG; |
|
1928 |
|
1929 __ASSERT_DEBUG( iContainer, Panic( ENcsBasicUi ) ); |
|
1930 |
|
1931 delete iBody; |
|
1932 iBody = NULL; |
|
1933 HBufC* rawBody = GetMessageBodyL(); |
|
1934 |
|
1935 // Ensure there's free space in the beginning of the message if required |
|
1936 if ( aEnsureSpaceInBegin && rawBody->Length() ) |
|
1937 { |
|
1938 TText firstChar = (*rawBody)[0]; |
|
1939 _LIT( KNewLines, "\r\n\x2028\x2029" ); |
|
1940 if ( KNewLines().Locate( firstChar ) == KErrNotFound ) |
|
1941 { |
|
1942 CleanupStack::PushL( rawBody ); |
|
1943 // First character is not a new line character. Insert one. |
|
1944 iBody = HBufC::NewL( rawBody->Length() + KIMSLineFeed().Length() ); |
|
1945 TPtr ptr = iBody->Des(); |
|
1946 ptr.Append( KIMSLineFeed ); |
|
1947 ptr.Append( *rawBody ); |
|
1948 CleanupStack::PopAndDestroy( rawBody ); |
|
1949 rawBody = NULL; |
|
1950 } |
|
1951 } |
|
1952 // If no modifications were needed, then just set body pointer to point |
|
1953 // the rawBody |
|
1954 if ( !iBody ) |
|
1955 { |
|
1956 iBody = rawBody; |
|
1957 rawBody = NULL; |
|
1958 } |
|
1959 // Now we have possibly decorated message text in body pointer and |
|
1960 // in cleanup stack |
|
1961 |
|
1962 // Divide the contents into normal body and the read-only quote fields |
|
1963 // Convert bytes length to words length |
|
1964 TInt readOnlyLength = iNewMessageTextPart->ReadOnlyPartSize() / 2; |
|
1965 //This check is unnecessary, but without that coverity complains |
|
1966 if ( iBody ) |
|
1967 { |
|
1968 TInt modifiableLength = iBody->Length() - readOnlyLength; |
|
1969 |
|
1970 // Remove one newline from the end of the modifiable body if there's |
|
1971 // read-only quote present. This is because the field boundary appears |
|
1972 // as newline on the screen. This newline is added back when saving |
|
1973 // the message. |
|
1974 TInt lfLength = KIMSLineFeed().Length(); |
|
1975 if ( readOnlyLength && modifiableLength >= lfLength && |
|
1976 iBody->Mid( modifiableLength-lfLength, lfLength ) == KIMSLineFeed ) |
|
1977 { |
|
1978 modifiableLength -= lfLength; |
|
1979 } |
|
1980 |
|
1981 iContainer->SetBodyContentAsyncL( iBody->Left( modifiableLength ), |
|
1982 iBody->Right( readOnlyLength ) ); |
|
1983 |
|
1984 // callback: SetBodyContentCompleteL |
|
1985 } |
|
1986 } |
|
1987 |
|
1988 // ----------------------------------------------------------------------------- |
|
1989 // CNcsComposeView::SetBodyContentComplete() |
|
1990 // |
|
1991 // ----------------------------------------------------------------------------- |
|
1992 // |
|
1993 void CNcsComposeView::SetBodyContentComplete() |
|
1994 { |
|
1995 delete iBody; |
|
1996 iBody = NULL; |
|
1997 |
|
1998 if ( iOpeningWaitDialog ) |
|
1999 { |
|
2000 TRAP_IGNORE( iOpeningWaitDialog->ProcessFinishedL() ); |
|
2001 iOpeningWaitDialog = NULL; |
|
2002 } |
|
2003 |
|
2004 iOpeningWaitNoteVisible = EFalse; |
|
2005 iIncludeMessageTextAsync = EFalse; |
|
2006 } |
|
2007 |
|
2008 // ----------------------------------------------------------------------------- |
|
2009 // CNcsComposeView::IsOpeningWaitNoteVisible() |
|
2010 // |
|
2011 // ----------------------------------------------------------------------------- |
|
2012 // |
|
2013 TBool CNcsComposeView::IsOpeningWaitNoteVisible() |
|
2014 { |
|
2015 return iOpeningWaitNoteVisible; |
|
2016 } |
|
2017 |
|
2018 // ----------------------------------------------------------------------------- |
1883 // CNcsComposeView::InitForwardFieldsL() |
2019 // CNcsComposeView::InitForwardFieldsL() |
1884 // |
2020 // |
1885 // ----------------------------------------------------------------------------- |
2021 // ----------------------------------------------------------------------------- |
1886 // |
2022 // |
1887 void CNcsComposeView::InitForwardFieldsL() |
2023 void CNcsComposeView::InitForwardFieldsL() |
2609 // |
2745 // |
2610 void CNcsComposeView::InitReplyOrForwardUiL() |
2746 void CNcsComposeView::InitReplyOrForwardUiL() |
2611 { |
2747 { |
2612 FUNC_LOG; |
2748 FUNC_LOG; |
2613 // Show "Opening" wait note if the message body is large |
2749 // Show "Opening" wait note if the message body is large |
2614 TInt waitNoteId = KErrNotFound; |
2750 iOpeningWaitNoteVisible = EFalse; |
2615 if ( TFsEmailUiUtility::IsMessageBodyLargeL(iOrigMessage) ) |
2751 if ( TFsEmailUiUtility::IsMessageBodyLargeL(iOrigMessage) ) |
2616 { |
2752 { |
2617 waitNoteId = TFsEmailUiUtility::ShowGlobalWaitNoteLC( |
2753 TFsEmailUiUtility::ShowWaitNoteL( iOpeningWaitDialog, |
2618 R_FSE_WAIT_OPENING_TEXT ); |
2754 R_FSE_WAIT_OPENING_TEXT, EFalse, ETrue ); |
2619 } |
2755 iOpeningWaitNoteVisible = ETrue; |
2620 |
2756 } |
|
2757 |
|
2758 // disable this flag if "old style" sync mode is needed |
|
2759 // for including body of text |
|
2760 iIncludeMessageTextAsync = ETrue; |
|
2761 |
2621 if ( iCustomMessageId == TUid::Uid( KEditorCmdReply ) ) |
2762 if ( iCustomMessageId == TUid::Uid( KEditorCmdReply ) ) |
2622 { |
2763 { |
2623 GenerateReplyMessageL( EFalse ); |
2764 GenerateReplyMessageL( EFalse ); |
2624 InitReplyUiL( EFalse ); |
2765 InitReplyUiL( EFalse ); |
2625 } |
2766 } |
2636 else |
2777 else |
2637 { |
2778 { |
2638 // This shouldn't ever happen. Panic in debug builds. |
2779 // This shouldn't ever happen. Panic in debug builds. |
2639 ASSERT( EFalse ); |
2780 ASSERT( EFalse ); |
2640 } |
2781 } |
2641 |
2782 |
2642 // Close the "Opening" wait note if it was shown |
2783 // Close the "Opening" wait note if it was shown |
2643 if ( waitNoteId != KErrNotFound ) |
2784 // and include message text was done synchronously |
2644 { |
2785 if ( !iIncludeMessageTextAsync && iOpeningWaitDialog ) |
2645 CleanupStack::PopAndDestroy( (TAny*)waitNoteId ); |
2786 { |
|
2787 iOpeningWaitDialog->ProcessFinishedL(); |
|
2788 iOpeningWaitDialog = NULL; |
2646 } |
2789 } |
2647 } |
2790 } |
2648 |
2791 |
2649 // ----------------------------------------------------------------------------- |
2792 // ----------------------------------------------------------------------------- |
2650 // CNcsComposeView::GenerateReplyMessageL |
2793 // CNcsComposeView::GenerateReplyMessageL |
2758 { |
2901 { |
2759 FUNC_LOG; |
2902 FUNC_LOG; |
2760 if ( iFirstStartCompleted ) // Safety check |
2903 if ( iFirstStartCompleted ) // Safety check |
2761 { |
2904 { |
2762 InitReplyFieldsL( aReplyAll ); |
2905 InitReplyFieldsL( aReplyAll ); |
2763 IncludeMessageTextL( ETrue ); |
2906 // if flag is set - |
|
2907 // message text will be included asynchronously by calling method |
|
2908 // IncludeMessageTextAsyncL() at the end of view activation or when |
|
2909 // all attachments are downloaded - this is done because formatting |
|
2910 // text in CTextView with method FormatTextL() causes phone |
|
2911 // irresponsive. |
|
2912 if ( !iIncludeMessageTextAsync ) |
|
2913 { |
|
2914 IncludeMessageTextL( ETrue ); |
|
2915 } |
2764 iContainer->SetFocusToMessageFieldL(); |
2916 iContainer->SetFocusToMessageFieldL(); |
2765 } |
2917 } |
2766 } |
2918 } |
2767 |
2919 |
2768 // ----------------------------------------------------------------------------- |
2920 // ----------------------------------------------------------------------------- |
2798 { |
2950 { |
2799 FUNC_LOG; |
2951 FUNC_LOG; |
2800 if ( iFirstStartCompleted ) // Safety check |
2952 if ( iFirstStartCompleted ) // Safety check |
2801 { |
2953 { |
2802 InitForwardFieldsL(); |
2954 InitForwardFieldsL(); |
2803 IncludeMessageTextL( ETrue ); |
2955 // if flag is set - |
|
2956 // message text will be included asynchronously by calling method |
|
2957 // IncludeMessageTextAsyncL() at the end of view activation or when |
|
2958 // all attachments are downloaded - this is done because formatting |
|
2959 // text in CTextView with method FormatTextL() causes phone |
|
2960 // irresponsive. |
|
2961 if ( !iIncludeMessageTextAsync ) |
|
2962 { |
|
2963 IncludeMessageTextL( ETrue ); |
|
2964 } |
2804 iContainer->SetFocusToToField(); |
2965 iContainer->SetFocusToToField(); |
2805 iContainer->SelectAllToFieldTextL(); |
2966 iContainer->SelectAllToFieldTextL(); |
2806 } |
2967 } |
2807 } |
2968 } |
2808 |
2969 |
2969 if ( iFetchWaitDialog && !iFetchDialogCancelled ) |
3130 if ( iFetchWaitDialog && !iFetchDialogCancelled ) |
2970 { |
3131 { |
2971 TRAP_IGNORE( iFetchWaitDialog->ProcessFinishedL() ); |
3132 TRAP_IGNORE( iFetchWaitDialog->ProcessFinishedL() ); |
2972 iFetchWaitDialog = NULL; |
3133 iFetchWaitDialog = NULL; |
2973 } |
3134 } |
|
3135 |
|
3136 if ( iMailFetchingErrCode == KErrNone ) |
|
3137 { |
|
3138 if ( iIncludeMessageTextAsync ) |
|
3139 { |
|
3140 // in case the "Opening" wait note was closed by |
|
3141 // wait note "Retrieving" |
|
3142 if ( !iOpeningWaitDialog && iOpeningWaitNoteVisible ) |
|
3143 { |
|
3144 TRAP_IGNORE( TFsEmailUiUtility::ShowWaitNoteL( iOpeningWaitDialog, |
|
3145 R_FSE_WAIT_OPENING_TEXT, EFalse, ETrue ) ); |
|
3146 } |
|
3147 } |
|
3148 |
|
3149 if ( iViewFullyActivated && iIncludeMessageTextAsync ) |
|
3150 { |
|
3151 // include message body in async way. |
|
3152 // it is done here only if view was already activated |
|
3153 // this mean that attachments were added in async way |
|
3154 // and we couldn't start async including body text |
|
3155 TRAP_IGNORE( IncludeMessageTextAsyncL( ETrue ) ); |
|
3156 } |
|
3157 } |
2974 return result; |
3158 return result; |
2975 } |
3159 } |
2976 |
3160 |
2977 // ----------------------------------------------------------------------------- |
3161 // ----------------------------------------------------------------------------- |
2978 // CNcsComposeView::ExitComposer |
3162 // CNcsComposeView::ExitComposer |