emailuis/emailui/src/ncscomposeview.cpp
branchRCL_3
changeset 80 726fba06891a
parent 73 c8382f7b54ef
equal deleted inserted replaced
73:c8382f7b54ef 80:726fba06891a
    35 #include <AknUtils.h>
    35 #include <AknUtils.h>
    36 #include <FreestyleEmailUi.rsg>
    36 #include <FreestyleEmailUi.rsg>
    37 #include <freestyleemailui.mbg>
    37 #include <freestyleemailui.mbg>
    38 #include <aknstyluspopupmenu.h>
    38 #include <aknstyluspopupmenu.h>
    39 
    39 
    40 #include <wlaninternalpskeys.h>
       
    41 #include "ncscomposeview.h"
    40 #include "ncscomposeview.h"
    42 #include "ncscomposeviewcontainer.h"
    41 #include "ncscomposeviewcontainer.h"
    43 #include "ncsconstants.h"
    42 #include "ncsconstants.h"
    44 #include "ncsutility.h"
    43 #include "ncsutility.h"
    45 #include "ncsemailaddressobject.h"
    44 #include "ncsemailaddressobject.h"
    85     : CFsEmailUiViewBase( aSendAttachmentControlGroup, aAppUi ),
    84     : CFsEmailUiViewBase( aSendAttachmentControlGroup, aAppUi ),
    86      iMailClient( aMailClient ), iOrigMessage( NULL ), iNewMessage( NULL ),
    85      iMailClient( aMailClient ), iOrigMessage( NULL ), iNewMessage( NULL ),
    87      iMsvSession( aMsvSession ), iEnv( aEnv ),
    86      iMsvSession( aMsvSession ), iEnv( aEnv ),
    88      iFakeSyncGoingOn(EFalse), iFetchDialogCancelled(EFalse),
    87      iFakeSyncGoingOn(EFalse), iFetchDialogCancelled(EFalse),
    89      iExecutingDoExitL( EFalse ),
    88      iExecutingDoExitL( EFalse ),
    90      iMessageTextPartModified( EFalse ), iMessageModified( EFalse ), 
    89      iMessageTextPartModified( EFalse ), iMessageModified( EFalse )
    91      iIncludeMessageTextAsync( EFalse ), iChildActivationState( EChildActivationDeactivated )
    90     {
    92     {
    91     FUNC_LOG;
    93     FUNC_LOG; 
       
    94 
    92 
    95     iAttachmentListSaveDraft = EFalse;
    93     iAttachmentListSaveDraft = EFalse;
    96 
    94 
    97     }
    95     }
    98 
    96 
   288 //
   286 //
   289 void CNcsComposeView::ChildDoActivateL( const TVwsViewId& aPrevViewId,
   287 void CNcsComposeView::ChildDoActivateL( const TVwsViewId& aPrevViewId,
   290     TUid aCustomMessageId, const TDesC8& aCustomMessage )
   288     TUid aCustomMessageId, const TDesC8& aCustomMessage )
   291     {
   289     {
   292     FUNC_LOG;
   290     FUNC_LOG;
   293     iChildActivationState = EChildActivationStarted;
   291     
   294     // needed when "Opening" (replying/forwarding)note is shown and 
   292     // needed when "Opening" (replying/forwarding)note is shown and 
   295     // we receive incoming call- Email application goes to background.
   293     // we receive incoming call- Email application goes to background.
   296     // When coming back to application the view is activated and reseted.
   294     // When coming back to application the view is activated and reseted.
   297     // That's why we prevent activation and the same is done in ChildDoDeactivate
   295     // That's why we prevent activation and the same is done in ChildDoDeactivate
   298     if ( iIncludeMessageTextAsync )
   296     if ( iIncludeMessageTextAsync )
   345     // but in case contacts action menu was used within FsEmail, this doesn' 
   343     // but in case contacts action menu was used within FsEmail, this doesn' 
   346     // work. It doesn't hurt to call this again even if it was already called
   344     // work. It doesn't hurt to call this again even if it was already called
   347     // once from BaseView.
   345     // once from BaseView.
   348     if ( iLaunchParams.iActivatedExternally )
   346     if ( iLaunchParams.iActivatedExternally )
   349         {
   347         {
   350         //notify Contact details view to close on external activation
   348         iAppUi.ViewActivatedExternallyL( Id() );
   351         CFSEmailUiContactHandler* contactHandler = NULL; // not owned
       
   352         CFsDelayedLoader* delLoader = CFsDelayedLoader::InstanceL(); // not owned
       
   353         if( delLoader )
       
   354             {
       
   355             contactHandler = delLoader->GetContactHandlerL();
       
   356             
       
   357             if( contactHandler && aPrevViewId.iViewUid == contactHandler->GetDetailsViewUid() )
       
   358                 {
       
   359                 contactHandler->CloseContactDetailsL();
       
   360                 }
       
   361             iAppUi.ViewActivatedExternallyL( Id() );
       
   362             }
       
   363         }
   349         }
   364 
   350 
   365     // Try to get the mailbox by other means if using launch parameters failed
   351     // Try to get the mailbox by other means if using launch parameters failed
   366     if ( !iMailBox )
   352     if ( !iMailBox )
   367         {
   353         {
   446         iContainer->SetMskL();
   432         iContainer->SetMskL();
   447         iViewReady = ETrue;
   433         iViewReady = ETrue;
   448         Toolbar()->SetDimmed( EFalse );
   434         Toolbar()->SetDimmed( EFalse );
   449         RefreshToolbar();
   435         RefreshToolbar();
   450         iContainer->ActivateL();
   436         iContainer->ActivateL();
   451 
   437         }
   452         
   438         
   453     // if there is a embedded app in FSEmail.
   439     // if there is a embedded app in FSEmail.
   454     if( iAppUi.EmbeddedApp() )
   440     if( iAppUi.EmbeddedApp() )
   455             {
   441         {
   456             // Set email editor started from embedded app flag to true 
   442         // Set email editor started from embedded app flag to true 
   457             // so that we can switch view correct when sent email.
   443         // so that we can switch view correct when sent email.
   458             iAppUi.SetEditorStartedFromEmbeddedApp( ETrue );
   444         iAppUi.SetEditorStartedFromEmbeddedApp( ETrue );
   459         
   445         
   460         RWsSession rwsSession;
   446         RWsSession rwsSession;
   461             User::LeaveIfError( rwsSession.Connect() );
   447         User::LeaveIfError( rwsSession.Connect() );
   462             CleanupClosePushL( rwsSession );
   448         CleanupClosePushL( rwsSession );
   463         
   449         
   464         // Simulate a back key to exit embedded app 
   450         // Simulate a back key to exit embedded app 
   465             // so that email editor could show on the top level.
   451         // so that email editor could show on the top level.
   466             TKeyEvent KeyEvent = TKeyEvent();
   452         TKeyEvent KeyEvent = TKeyEvent();
   467             // this is neccesary for photogalery image viewer (don't remove)
   453         // this is neccesary for photogalery image viewer (don't remove)
   468             KeyEvent.iScanCode = EStdKeyUpArrow;
   454         KeyEvent.iScanCode = EStdKeyUpArrow;
   469             rwsSession.SimulateKeyEvent( KeyEvent );
   455         rwsSession.SimulateKeyEvent( KeyEvent );
   470             KeyEvent.iCode = EKeyCBA2;
   456         KeyEvent.iCode = EKeyCBA2;
   471             rwsSession.SimulateKeyEvent( KeyEvent );
   457         rwsSession.SimulateKeyEvent( KeyEvent );
   472 
   458 
   473         rwsSession.Close();
   459         rwsSession.Close();
   474             CleanupStack::PopAndDestroy( &rwsSession );
   460         CleanupStack::PopAndDestroy( &rwsSession );
   475             }
   461         }
   476     
   462     
   477     if ( iIncludeMessageTextAsync )
   463     if ( iIncludeMessageTextAsync )
   478             {
   464     	{
   479             // including message body in async way
   465 		// including message body in async way
   480             IncludeMessageTextAsyncL( ETrue );
   466 		IncludeMessageTextAsyncL( ETrue );
   481             }
   467     	}
   482 
   468     
   483         iViewFullyActivated = ETrue;
   469     iViewFullyActivated = ETrue;
   484         iChildActivationState = EChildActivationProcessed;
       
   485         
   470         
   486     TIMESTAMP( "Editor launched" );
   471     TIMESTAMP( "Editor launched" );
   487         return; // ok
       
   488         }
       
   489 // problems with init close the view asynchronously
       
   490     iViewFullyActivated = EFalse;
       
   491     iChildActivationState = EChildActivationExitRequired;
       
   492 //    iFakeSyncGoingOn = EFalse; iExecutingDoExitL = EFalse;
       
   493     iActiveHelper->Start(); // calls AsyncExit()
       
   494     TIMESTAMP( "Editor NOT launched" );
       
   495     return;
       
   496     }
   472     }
   497 
   473 
   498 // -----------------------------------------------------------------------------
   474 // -----------------------------------------------------------------------------
   499 // Initialises toolbar items.
   475 // Initialises toolbar items.
   500 // -----------------------------------------------------------------------------
   476 // -----------------------------------------------------------------------------
   817     // is deactivated.
   793     // is deactivated.
   818     if ( !iAppUi.AppUiExitOngoing() )
   794     if ( !iAppUi.AppUiExitOngoing() )
   819         {
   795         {
   820         SaveAndCleanPreviousMessage();
   796         SaveAndCleanPreviousMessage();
   821         }
   797         }
   822     
   798 
   823     iChildActivationState = EChildActivationDeactivated ;
       
   824     
       
   825     }
   799     }
   826 
   800 
   827 // -----------------------------------------------------------------------------
   801 // -----------------------------------------------------------------------------
   828 // CNcsComposeView::DynInitMenuPaneL()
   802 // CNcsComposeView::DynInitMenuPaneL()
   829 // -----------------------------------------------------------------------------
   803 // -----------------------------------------------------------------------------
   965 
   939 
   966         switch( aCommand )
   940         switch( aCommand )
   967             {
   941             {
   968             case ENcsCmdSend:
   942             case ENcsCmdSend:
   969                 {
   943                 {
   970                 // Set focus on body of message need for correct 
       
   971                 // MSK setting for CAknConfirmationNote dialog. 
       
   972                 iContainer->SetFocusToMessageFieldL();
       
   973                 
       
   974                 // Show query if the Subject field is empty
   944                 // Show query if the Subject field is empty
   975                 if ( iContainer->IsSubjectFieldEmpty() )
   945                 if ( iContainer->IsSubjectFieldEmpty() )
   976                     {
   946                     {
   977                     TInt answer = TFsEmailUiUtility::ShowConfirmationQueryL(
   947                     TInt answer = TFsEmailUiUtility::ShowConfirmationQueryL(
   978                             R_FREESTYLE_EMAIL_QUERY_NO_SUBJECT );
   948                             R_FREESTYLE_EMAIL_QUERY_NO_SUBJECT );
   987                 TRAPD( error, DoSendL() );
   957                 TRAPD( error, DoSendL() );
   988                 if ( !error )
   958                 if ( !error )
   989                     {
   959                     {
   990                     // Sending successful
   960                     // Sending successful
   991                     HBufC* confMessage = NULL;
   961                     HBufC* confMessage = NULL;
   992                     if ( !TFsEmailUiUtility::IsOfflineModeL() || WLANConnectionActive() )
   962                     if ( !TFsEmailUiUtility::IsOfflineModeL() )
   993                         {
   963                         {
   994                         // when sync status is currently ONLINE
   964                         // when sync status is currently ONLINE
   995                         confMessage = StringLoader::LoadLC( 
   965                         confMessage = StringLoader::LoadLC( 
   996                                 R_FREESTYLE_EMAIL_CONFIRM_NOTE_SENDING_QUEUED );
   966                                 R_FREESTYLE_EMAIL_CONFIRM_NOTE_SENDING_QUEUED );
   997                         }
   967                         }
  1087            	 	SetAttachmentLabelContentL();
  1057            	 	SetAttachmentLabelContentL();
  1088             	}
  1058             	}
  1089                 break;
  1059                 break;
  1090             case ENcsCmdPriorityHigh:
  1060             case ENcsCmdPriorityHigh:
  1091             	{
  1061             	{
  1092             	if ( iNewMessage )
  1062             	iNewMessage->ResetFlag( EFSMsgFlag_Low );
  1093             	    {
  1063             	iNewMessage->SetFlag( EFSMsgFlag_Important );
  1094                     iNewMessage->ResetFlag( EFSMsgFlag_Low );
  1064             	iNewMessage->SaveMessageL();
  1095                     iNewMessage->SetFlag( EFSMsgFlag_Important );
  1065                 iMessageModified = EFalse;
  1096                     iNewMessage->SaveMessageL();
  1066             	iStatusPaneIndicators->SetPriorityFlag( EMsgPriorityHigh );
  1097                     iMessageModified = EFalse;
       
  1098                     iStatusPaneIndicators->SetPriorityFlag( EMsgPriorityHigh );
       
  1099             	    }
       
  1100             	}
  1067             	}
  1101                 break;
  1068                 break;
  1102         	case ENcsCmdPriorityNormal:
  1069         	case ENcsCmdPriorityNormal:
  1103     	    	{
  1070     	    	{
  1104     	    	if ( iNewMessage )
  1071             	iNewMessage->ResetFlag( EFSMsgFlag_Low );
  1105     	    	    {
  1072             	iNewMessage->ResetFlag( EFSMsgFlag_Important );
  1106                     iNewMessage->ResetFlag( EFSMsgFlag_Low );
  1073             	iNewMessage->SaveMessageL();
  1107                     iNewMessage->ResetFlag( EFSMsgFlag_Important );
  1074                 iMessageModified = EFalse;
  1108                     iNewMessage->SaveMessageL();
  1075             	iStatusPaneIndicators->SetPriorityFlag( EMsgPriorityNormal );
  1109                     iMessageModified = EFalse;
       
  1110                     iStatusPaneIndicators->SetPriorityFlag( EMsgPriorityNormal );
       
  1111     	    	    }
       
  1112     	    	}
  1076     	    	}
  1113                 break;
  1077                 break;
  1114         	case ENcsCmdPriorityLow:
  1078         	case ENcsCmdPriorityLow:
  1115     	    	{
  1079     	    	{
  1116     	    	if ( iNewMessage )
  1080             	iNewMessage->ResetFlag( EFSMsgFlag_Important );
  1117     	    	    {
  1081             	iNewMessage->SetFlag( EFSMsgFlag_Low );
  1118                     iNewMessage->ResetFlag( EFSMsgFlag_Important );
  1082             	iNewMessage->SaveMessageL();
  1119                     iNewMessage->SetFlag( EFSMsgFlag_Low );
  1083                 iMessageModified = EFalse;
  1120                     iNewMessage->SaveMessageL();
  1084             	iStatusPaneIndicators->SetPriorityFlag( EMsgPriorityLow );
  1121                     iMessageModified = EFalse;
       
  1122                     iStatusPaneIndicators->SetPriorityFlag( EMsgPriorityLow );
       
  1123     	    	    }
       
  1124     	    	}
  1085     	    	}
  1125                 break;
  1086                 break;
  1126             case ENcsCmdShowCc:
  1087             case ENcsCmdShowCc:
  1127                 {
  1088                 {
  1128                 iContainer->SetCcFieldVisibleL( ETrue );
  1089                 iContainer->SetCcFieldVisibleL( ETrue );
  1205     	 		iContainer->ClosePopupContactListL();
  1166     	 		iContainer->ClosePopupContactListL();
  1206                 }
  1167                 }
  1207                 break;
  1168                 break;
  1208             case EAknSoftkeyClose:
  1169             case EAknSoftkeyClose:
  1209                 {
  1170                 {
  1210                 if ( !iAddingAttachmentDialogOpened )
  1171                 DoSafeExit();
  1211                     DoSafeExit();
       
  1212                 }
  1172                 }
  1213                 break;
  1173                 break;
  1214             case ENcsCmdExit:
  1174             case ENcsCmdExit:
  1215                 {
  1175                 {
  1216                 TIMESTAMP( "Exit selected from editor" );
  1176                 TIMESTAMP( "Exit selected from editor" );
  1241     if ( iContainer->AreAddressFieldsEmpty() )
  1201     if ( iContainer->AreAddressFieldsEmpty() )
  1242         {
  1202         {
  1243         User::Leave( KErrNotFound );
  1203         User::Leave( KErrNotFound );
  1244         }
  1204         }
  1245 
  1205 
  1246     TRAPD( commitErr, CommitL( ETrue, EAllFields, ETrue ) );
  1206     CommitL( ETrue, EAllFields, ETrue );
  1247     if ( KErrNone != commitErr )
       
  1248         {
       
  1249         iMailSendFailed = ETrue;
       
  1250         User::Leave( commitErr );
       
  1251         }
       
  1252 
  1207 
  1253     TRAPD(r, iMailBox->SendMessageL( *iNewMessage ) );
  1208     TRAPD(r, iMailBox->SendMessageL( *iNewMessage ) );
  1254     if ( KErrNone != r )
  1209     if ( KErrNone != r )
  1255         {
  1210         {
  1256         iMailSendFailed = ETrue;
  1211         iMailSendFailed = ETrue;
  1729         iNewMessage->SaveMessageL();
  1684         iNewMessage->SaveMessageL();
  1730         iMessageModified = EFalse;
  1685         iMessageModified = EFalse;
  1731         TFsEmailUiUtility::CreatePlainTextPartL( 
  1686         TFsEmailUiUtility::CreatePlainTextPartL( 
  1732                 *iNewMessage, iNewMessageTextPart );
  1687                 *iNewMessage, iNewMessageTextPart );
  1733         InitFieldsL();
  1688         InitFieldsL();
  1734         IncludeMessageTextL();
  1689         TBool spaceInBegin = ETrue;
       
  1690         IncludeMessageTextL(spaceInBegin);
  1735         AttachmentsListControl()->Model()->Clear();
  1691         AttachmentsListControl()->Model()->Clear();
  1736         GetAttachmentsFromMailL();
  1692         GetAttachmentsFromMailL();
  1737         SetAttachmentLabelContentL();
  1693         SetAttachmentLabelContentL();
  1738         iAttachmentListSaveDraft = ETrue;
  1694         iAttachmentListSaveDraft = ETrue;
  1739 
  1695 
  1821 void CNcsComposeView::HandleDynamicVariantSwitchL(
  1777 void CNcsComposeView::HandleDynamicVariantSwitchL(
  1822     CFsEmailUiViewBase::TDynamicSwitchType aType )
  1778     CFsEmailUiViewBase::TDynamicSwitchType aType )
  1823 	{
  1779 	{
  1824     FUNC_LOG;
  1780     FUNC_LOG;
  1825 
  1781 
  1826     if ( iFirstStartCompleted && iContainer && !iExecutingDoExitL )
  1782     if ( iFirstStartCompleted && iContainer )
  1827         {
  1783         {
  1828         if ( aType == CFsEmailUiViewBase::EScreenLayoutChanged )
  1784         if ( aType == CFsEmailUiViewBase::EScreenLayoutChanged )
  1829             {
  1785             {
  1830             iContainer->HandleLayoutChangeL();
  1786             iContainer->HandleLayoutChangeL();
  1831             }
  1787             }
  1838             }
  1794             }
  1839         }
  1795         }
  1840 
  1796 
  1841 	}
  1797 	}
  1842 
  1798 
  1843 // ---------------------------------------------------------------------------
       
  1844 // CNcsComposeView::FadeOut()
       
  1845 // enables hiding toolbar on different view -> DoActivate()  
       
  1846 // which is earlier than -> CFsEmailUiViewBase::DoDeactivate() 
       
  1847 // -----------------------------------------------------------------------------
       
  1848 //
       
  1849 void CNcsComposeView::FadeOut( TBool aDirectionOut )
       
  1850     {
       
  1851     if ( aDirectionOut && Toolbar()->IsShown() )
       
  1852         {
       
  1853         HideToolbar();
       
  1854         }
       
  1855     else if ( ! ( aDirectionOut || Toolbar()->IsShown() ) )
       
  1856         {
       
  1857         ShowToolbar();
       
  1858         }
       
  1859     }
       
  1860 // -----------------------------------------------------------------------------
  1799 // -----------------------------------------------------------------------------
  1861 // CNcsComposeView::InitReplyFieldsL()
  1800 // CNcsComposeView::InitReplyFieldsL()
  1862 // Initialises the reply fields from the reply message created by the plug-in.
  1801 // Initialises the reply fields from the reply message created by the plug-in.
  1863 // -----------------------------------------------------------------------------
  1802 // -----------------------------------------------------------------------------
  1864 //
  1803 //
  2285             break;
  2224             break;
  2286         default:
  2225         default:
  2287             break;
  2226             break;
  2288         }
  2227         }
  2289 
  2228 
  2290 	if ( iNewMessage )
  2229     if ( commitToField )
       
  2230         {
       
  2231         RPointerArray<CFSMailAddress>& recipients = 
       
  2232             iNewMessage->GetToRecipients();
       
  2233         recipients.ResetAndDestroy();
       
  2234         NcsUtility::ConvertAddressArrayL(
       
  2235             iContainer->GetToFieldAddressesL( aParseAddresses ), recipients );
       
  2236         }
       
  2237 
       
  2238     if ( commitCcField )
       
  2239         {
       
  2240         RPointerArray<CFSMailAddress>& recipients = 
       
  2241             iNewMessage->GetCCRecipients();
       
  2242         recipients.ResetAndDestroy();
       
  2243         NcsUtility::ConvertAddressArrayL( 
       
  2244             iContainer->GetCcFieldAddressesL( aParseAddresses ), recipients );
       
  2245         }
       
  2246 
       
  2247     if ( commitBccField )
       
  2248         {
       
  2249         RPointerArray<CFSMailAddress>& recipients = 
       
  2250             iNewMessage->GetBCCRecipients();
       
  2251         recipients.ResetAndDestroy();
       
  2252         NcsUtility::ConvertAddressArrayL( 
       
  2253             iContainer->GetBccFieldAddressesL( aParseAddresses ), recipients );
       
  2254         }
       
  2255 
       
  2256 	if ( commitSubjectField )
  2291 	    {
  2257 	    {
  2292         if ( commitToField )
  2258 	    // get subject from UI to MSG object
  2293             {
  2259 	    HBufC* subject = iContainer->GetSubjectLC();
  2294             RPointerArray<CFSMailAddress>& recipients = 
  2260 	    TPtr ptr = subject->Des();
  2295                 iNewMessage->GetToRecipients();
  2261 		// replace new line characters with spaces as Subject is normally
  2296             recipients.ResetAndDestroy();
  2262 	    // one line only
  2297             NcsUtility::ConvertAddressArrayL(
  2263 	    AknTextUtils::ReplaceCharacters( 
  2298                 iContainer->GetToFieldAddressesL( aParseAddresses ), recipients );
  2264 	            ptr, KLineSeparators, KReplacementChar );
  2299             }
  2265 	    iNewMessage->SetSubject( *subject );
  2300     
  2266 	    CleanupStack::PopAndDestroy( subject );
  2301         if ( commitCcField )
       
  2302             {
       
  2303             RPointerArray<CFSMailAddress>& recipients = 
       
  2304                 iNewMessage->GetCCRecipients();
       
  2305             recipients.ResetAndDestroy();
       
  2306             NcsUtility::ConvertAddressArrayL( 
       
  2307                 iContainer->GetCcFieldAddressesL( aParseAddresses ), recipients );
       
  2308             }
       
  2309     
       
  2310         if ( commitBccField )
       
  2311             {
       
  2312             RPointerArray<CFSMailAddress>& recipients = 
       
  2313                 iNewMessage->GetBCCRecipients();
       
  2314             recipients.ResetAndDestroy();
       
  2315             NcsUtility::ConvertAddressArrayL( 
       
  2316                 iContainer->GetBccFieldAddressesL( aParseAddresses ), recipients );
       
  2317             }
       
  2318 
       
  2319         if ( commitSubjectField )
       
  2320             {
       
  2321             // get subject from UI to MSG object
       
  2322             HBufC* subject = iContainer->GetSubjectLC();
       
  2323             TPtr ptr = subject->Des();
       
  2324             // replace new line characters with spaces as Subject is normally
       
  2325             // one line only
       
  2326             AknTextUtils::ReplaceCharacters( 
       
  2327                     ptr, KLineSeparators, KReplacementChar );
       
  2328             iNewMessage->SetSubject( *subject );
       
  2329             CleanupStack::PopAndDestroy( subject );
       
  2330             }
       
  2331         }
       
  2332     else // iNewMessage is still NULL
       
  2333         {
       
  2334         User::Leave( KErrNotFound );
       
  2335         }
       
  2336 	
       
  2337 	if ( iNewMessageTextPart )
       
  2338 	    {
       
  2339         if ( commitBodyField )
       
  2340             {
       
  2341             HBufC* body = iContainer->GetBodyContentLC();
       
  2342             TPtr bodyPtr = body->Des(); // this TPtr is needed only because of
       
  2343             // incorrect argument type in FW API, can be removed when API fixed
       
  2344             iNewMessageTextPart->SetContent( bodyPtr );
       
  2345             CleanupStack::PopAndDestroy( body );
       
  2346             iMessageTextPartModified = ETrue;
       
  2347             }
       
  2348 	    }
  2267 	    }
  2349 	else // iNewMessageTextPart is still NULL
  2268 
  2350 	    {
  2269     if ( commitBodyField )
  2351         User::Leave( KErrNotFound );
  2270         {
  2352 	    }
  2271         HBufC* body = iContainer->GetBodyContentLC();
  2353         
  2272         TPtr bodyPtr = body->Des(); // this TPtr is needed only because of
       
  2273         // incorrect argument type in FW API, can be removed when API fixed
       
  2274         iNewMessageTextPart->SetContent( bodyPtr );
       
  2275         CleanupStack::PopAndDestroy( body );
       
  2276         iMessageTextPartModified = ETrue;
       
  2277         }
       
  2278 
  2354     iMessageModified = ETrue;
  2279     iMessageModified = ETrue;
  2355     RefreshToolbar();
  2280     RefreshToolbar();
  2356 
  2281 
  2357     if ( aSaveNow )
  2282     if ( aSaveNow )
  2358         {
  2283         {
  2529         if ( item && !item->IsRemote() ) // cannot open remote attachments
  2454         if ( item && !item->IsRemote() ) // cannot open remote attachments
  2530             {
  2455             {
  2531             CFSMailMessagePart* msgPart = 
  2456             CFSMailMessagePart* msgPart = 
  2532                 iNewMessage->ChildPartL( item->MailMsgPartId() );
  2457                 iNewMessage->ChildPartL( item->MailMsgPartId() );
  2533             CleanupStack::PushL( msgPart );
  2458             CleanupStack::PushL( msgPart );
  2534             
       
  2535             //We are forbidding to change MSK label during OpenAttachmentL
       
  2536             //because dialog/popup can be open
       
  2537             iContainer->SwitchChangeMskOff( ETrue );
       
  2538             TFsEmailUiUtility::OpenAttachmentL( *msgPart );
  2459             TFsEmailUiUtility::OpenAttachmentL( *msgPart );
  2539             iContainer->SwitchChangeMskOff( EFalse );
       
  2540             
       
  2541             CleanupStack::PopAndDestroy( msgPart );
  2460             CleanupStack::PopAndDestroy( msgPart );
  2542             }
  2461             }
  2543         }
  2462         }
  2544 	}
  2463 	}
  2545 
  2464 
  2933         iNewMessage->SaveMessageL();
  2852         iNewMessage->SaveMessageL();
  2934         iMessageModified = EFalse;
  2853         iMessageModified = EFalse;
  2935         }
  2854         }
  2936 
  2855 
  2937     TFsEmailUiUtility::CreatePlainTextPartL( *iNewMessage, iNewMessageTextPart );
  2856     TFsEmailUiUtility::CreatePlainTextPartL( *iNewMessage, iNewMessageTextPart );
  2938     if (NULL == iNewMessageTextPart) // problems with creating 
       
  2939         {
       
  2940         User::Leave( KErrUnknown );
       
  2941         }
       
  2942     }
  2857     }
  2943 
  2858 
  2944 // -----------------------------------------------------------------------------
  2859 // -----------------------------------------------------------------------------
  2945 // CNcsComposeView::GenerateForwardMessageL
  2860 // CNcsComposeView::GenerateForwardMessageL
  2946 // -----------------------------------------------------------------------------
  2861 // -----------------------------------------------------------------------------
  2988         iNewMessage->SaveMessageL();
  2903         iNewMessage->SaveMessageL();
  2989 	    }
  2904 	    }
  2990     
  2905     
  2991 	TFsEmailUiUtility::CreatePlainTextPartL( 
  2906 	TFsEmailUiUtility::CreatePlainTextPartL( 
  2992 	        *iNewMessage, iNewMessageTextPart );
  2907 	        *iNewMessage, iNewMessageTextPart );
  2993     if (NULL == iNewMessageTextPart) // problems with creating 
  2908 
  2994         {
       
  2995         User::Leave( KErrUnknown );
       
  2996         }
       
  2997     }
  2909     }
  2998 
  2910 
  2999 // -----------------------------------------------------------------------------
  2911 // -----------------------------------------------------------------------------
  3000 // CNcsComposeView::InitReplyUiL
  2912 // CNcsComposeView::InitReplyUiL
  3001 // -----------------------------------------------------------------------------
  2913 // -----------------------------------------------------------------------------
  3217     TBool result = EFalse;
  3129     TBool result = EFalse;
  3218     if ( iFirstStartCompleted ) // Safety
  3130     if ( iFirstStartCompleted ) // Safety
  3219         {
  3131         {
  3220         if ( !aError )
  3132         if ( !aError )
  3221             {
  3133             {
  3222             // may leave if unable to create new message part
       
  3223             TRAP( aError, InitReplyOrForwardUiL() );
  3134             TRAP( aError, InitReplyOrForwardUiL() );
  3224             }
       
  3225         if ( !aError )
       
  3226             {
       
  3227             iAutoSaver->Enable( ETrue );
  3135             iAutoSaver->Enable( ETrue );
  3228             }
  3136             }
  3229         else
  3137         else
  3230             {
  3138             {
  3231             // something went wrong
  3139             // something went wrong
  3271 //
  3179 //
  3272 void CNcsComposeView::ExitComposer()
  3180 void CNcsComposeView::ExitComposer()
  3273     {
  3181     {
  3274     FUNC_LOG;
  3182     FUNC_LOG;
  3275 
  3183 
  3276     // dont exit while in child activation 
       
  3277     if ( EChildActivationStarted == iChildActivationState )
       
  3278         {
       
  3279         iChildActivationState = EChildActivationError;
       
  3280         }
       
  3281     if ( EChildActivationError == iChildActivationState )
       
  3282         {
       
  3283         return; 
       
  3284         }
       
  3285     
       
  3286     if ( iStatusPaneIndicators )
  3184     if ( iStatusPaneIndicators )
  3287         {
  3185         {
  3288         iStatusPaneIndicators->HideStatusPaneIndicators();
  3186         iStatusPaneIndicators->HideStatusPaneIndicators();
  3289         }
  3187         }
  3290     
  3188     
  3350         {
  3248         {
  3351         AppUi()->RemoveFromStack( iContainer );
  3249         AppUi()->RemoveFromStack( iContainer );
  3352         delete iContainer;
  3250         delete iContainer;
  3353         iContainer = NULL;
  3251         iContainer = NULL;
  3354         }
  3252         }
  3355     iIncludeMessageTextAsync = EFalse;
  3253 
  3356     }
  3254     }
  3357 
  3255 
  3358 // -----------------------------------------------------------------------------
  3256 // -----------------------------------------------------------------------------
  3359 // CNcsComposeView::SaveAndCleanPreviousMessage
  3257 // CNcsComposeView::SaveAndCleanPreviousMessage
  3360 // -----------------------------------------------------------------------------
  3258 // -----------------------------------------------------------------------------
  3408 // -----------------------------------------------------------------------------
  3306 // -----------------------------------------------------------------------------
  3409 //
  3307 //
  3410 void CNcsComposeView::AsyncExitL()
  3308 void CNcsComposeView::AsyncExitL()
  3411     {
  3309     {
  3412     FUNC_LOG;
  3310     FUNC_LOG;
  3413     if ( EChildActivationExitRequired == iChildActivationState )
  3311     if ( iFakeSyncGoingOn || iExecutingDoExitL )
  3414         {
       
  3415         ExitComposer();
       
  3416         }
       
  3417     else if ( iFakeSyncGoingOn || iExecutingDoExitL )
       
  3418         {
  3312         {
  3419         // if some sync method is still going on, we continue waiting
  3313         // if some sync method is still going on, we continue waiting
  3420         iActiveHelper->Cancel();
  3314         iActiveHelper->Cancel();
  3421         iActiveHelper->Start();
  3315         iActiveHelper->Start();
  3422         }
  3316         }
  3506 
  3400 
  3507     return button;
  3401     return button;
  3508     }
  3402     }
  3509 
  3403 
  3510 // ---------------------------------------------------------------------------
  3404 // ---------------------------------------------------------------------------
  3511 // Returns ETrue if WLAN connection is active.
       
  3512 // ---------------------------------------------------------------------------
       
  3513 //
       
  3514 TBool CNcsComposeView::WLANConnectionActive()    
       
  3515     {
       
  3516     TBool ret = EFalse;
       
  3517     
       
  3518     TInt wlanState;
       
  3519     TInt err = RProperty::Get( KPSUidWlan, KPSWlanIndicator, wlanState );
       
  3520 
       
  3521     if ( err == KErrNone )
       
  3522         {
       
  3523         if ( wlanState == EPSWlanIndicatorActive ||
       
  3524              wlanState == EPSWlanIndicatorActiveSecure )
       
  3525             {
       
  3526             ret = ETrue;
       
  3527             }
       
  3528         }
       
  3529     
       
  3530     return ret;    
       
  3531     }
       
  3532 
       
  3533 
       
  3534 // ---------------------------------------------------------------------------
       
  3535 // CActiveHelper::NewL()
  3405 // CActiveHelper::NewL()
  3536 // ---------------------------------------------------------------------------
  3406 // ---------------------------------------------------------------------------
  3537 //
  3407 //
  3538 CActiveHelper* CActiveHelper::NewL( CNcsComposeView* aSession )
  3408 CActiveHelper* CActiveHelper::NewL( CNcsComposeView* aSession )
  3539     {
  3409     {
  3579 // ---------------------------------------------------------------------------
  3449 // ---------------------------------------------------------------------------
  3580 //
  3450 //
  3581 void CActiveHelper::RunL()
  3451 void CActiveHelper::RunL()
  3582     {
  3452     {
  3583     if( iComposeView )
  3453     if( iComposeView )
  3584         {
       
  3585         iComposeView->AsyncExitL();
  3454         iComposeView->AsyncExitL();
  3586         }
       
  3587     }
  3455     }
  3588 
  3456 
  3589 // ---------------------------------------------------------------------------
  3457 // ---------------------------------------------------------------------------
  3590 // CActiveHelper::DoCancel()
  3458 // CActiveHelper::DoCancel()
  3591 // ---------------------------------------------------------------------------
  3459 // ---------------------------------------------------------------------------