emailuis/emailui/src/FreestyleEmailUiUtilities.cpp
branchRCL_3
changeset 10 f5907b1a1053
parent 8 e1b6206813b4
child 11 0396474f30f5
equal deleted inserted replaced
8:e1b6206813b4 10:f5907b1a1053
    25 #include <MuiuMsvUiServiceUtilities.h>
    25 #include <MuiuMsvUiServiceUtilities.h>
    26 #include <StringLoader.h>
    26 #include <StringLoader.h>
    27 #include <AknIconUtils.h>
    27 #include <AknIconUtils.h>
    28 #include <aknlists.h>
    28 #include <aknlists.h>
    29 #include <aknPopup.h>
    29 #include <aknPopup.h>
       
    30 #include <akndiscreetpopup.h>
    30 #include <AknGlobalConfirmationQuery.h>
    31 #include <AknGlobalConfirmationQuery.h>
    31 #include <aknnotewrappers.h>
    32 #include <aknnotewrappers.h>
    32 #include <AknWaitDialog.h>
    33 #include <AknWaitDialog.h>
    33 #include <AknGlobalNote.h>
    34 #include <AknGlobalNote.h>
    34 #include <commonphoneparser.h>
    35 #include <commonphoneparser.h>
    68 #include <SendUiConsts.h>	// Constants for sendui
    69 #include <SendUiConsts.h>	// Constants for sendui
    69 #include <CMessageData.h>	// CMessageData
    70 #include <CMessageData.h>	// CMessageData
    70 #include <CSendingServiceInfo.h>
    71 #include <CSendingServiceInfo.h>
    71 #include <CoreApplicationUIsSDKCRKeys.h> // offline mode keys
    72 #include <CoreApplicationUIsSDKCRKeys.h> // offline mode keys
    72 #include <data_caging_path_literals.hrh>
    73 #include <data_caging_path_literals.hrh>
    73 #include <cmailwidgetcenrepkeys.h>
    74 #include "cmailwidgetcenrepkeys.h"
    74 
    75 
    75 // <cmail> Removed DISABLE_DEFAULT_EMAIL
    76 // <cmail> Removed DISABLE_DEFAULT_EMAIL
    76 //#ifndef DISABLE_DEFAULT_EMAIL
    77 //#ifndef DISABLE_DEFAULT_EMAIL
    77 //#include <MessagingDomainCRKeys.h>
    78 //#include <MessagingDomainCRKeys.h>
    78 //#include <centralrepository.h>
    79 //#include <centralrepository.h>
   231         // Close open file handle.
   232         // Close open file handle.
   232         iFileHandle.Close();
   233         iFileHandle.Close();
   233         iHandleOpen = EFalse;
   234         iHandleOpen = EFalse;
   234         }
   235         }
   235     MAknServerAppExitObserver::HandleServerAppExit( aReason );
   236     MAknServerAppExitObserver::HandleServerAppExit( aReason );
       
   237     
       
   238     // Get current AppUi.
       
   239     CFreestyleEmailUiAppUi* appUi = (CFreestyleEmailUiAppUi*)CCoeEnv::Static()->AppUi();
       
   240     if( appUi->EmbeddedApp() )
       
   241         {
       
   242         // Set embedded application flag to false when embedded application exit.
       
   243         appUi->SetEmbeddedApp( EFalse );
       
   244         }
       
   245     
       
   246     // if email editor is not started from embedded app.
       
   247     if( !appUi->EditorStartedFromEmbeddedApp() )
       
   248         {
       
   249         // Do not set embedded app to previous app.
       
   250         appUi->SetEmbeddedAppToPreviousApp( EFalse );
       
   251         }
       
   252     else
       
   253         {
       
   254         // Set flag for judging if email editor started from embedded app to false.
       
   255         appUi->SetEditorStartedFromEmbeddedApp( EFalse );
       
   256         }
   236 
   257 
   237     // Clear the temp directory since the closed file might have been copied there
   258     // Clear the temp directory since the closed file might have been copied there
   238     TFsEmailUiUtility::EraseTempDir();
   259     TFsEmailUiUtility::EraseTempDir();
   239     }
   260     }
   240 
   261 
   492     CleanupStack::PopAndDestroy( globalNote );
   513     CleanupStack::PopAndDestroy( globalNote );
   493     CleanupStack::PopAndDestroy( noteText );
   514     CleanupStack::PopAndDestroy( noteText );
   494     }
   515     }
   495 
   516 
   496 // -----------------------------------------------------------------------------
   517 // -----------------------------------------------------------------------------
       
   518 // TFsEmailUiUtility::ShowDiscreetInfoNoteL
       
   519 // -----------------------------------------------------------------------------
       
   520 void TFsEmailUiUtility::ShowDiscreetInfoNoteL( TInt aResourceStringId )
       
   521     {
       
   522     FUNC_LOG;   
       
   523     //create a host of dummy parameters in order to change the popup duration flag...
       
   524     const TDesC& dummyText = KNullDesC;
       
   525     CGulIcon* dummyIcon = NULL;
       
   526     const TAknsItemID& dummySkinId = KAknsIIDNone;
       
   527     const TDesC& dummyBitmapFile = KNullDesC;
       
   528     const TInt dummyBitmapId = 0;
       
   529     const TInt dummyMaskId = 0;
       
   530     
       
   531     //Set timeout flag
       
   532     TInt flags = 0;
       
   533     flags |= KAknDiscreetPopupDurationLong;
       
   534     
       
   535     HBufC* noteText = StringLoader::LoadLC( aResourceStringId );
       
   536     CAknDiscreetPopup::ShowLocalPopupL(*noteText, 
       
   537                                         dummyText, 
       
   538                                         dummyIcon, 
       
   539                                         dummySkinId,
       
   540                                         dummyBitmapFile, 
       
   541                                         dummyBitmapId, 
       
   542                                         dummyMaskId, 
       
   543                                         flags);
       
   544     CleanupStack::PopAndDestroy( noteText );
       
   545     }
       
   546 
       
   547 // -----------------------------------------------------------------------------
   497 // TFsEmailUiUtility::ShowWaitNoteL
   548 // TFsEmailUiUtility::ShowWaitNoteL
   498 // -----------------------------------------------------------------------------
   549 // -----------------------------------------------------------------------------
   499 void TFsEmailUiUtility::ShowWaitNoteL( CAknWaitDialog*& aDialog, TInt aTextResourceId,
   550 void TFsEmailUiUtility::ShowWaitNoteL( CAknWaitDialog*& aDialog, TInt aTextResourceId,
   500         TBool aAllowCancel, TBool aVisibilityDelayOff /*= EFalse*/ )
   551         TBool aAllowCancel, TBool aVisibilityDelayOff /*= EFalse*/ )
   501     {
   552     {
   668     }
   719     }
   669 
   720 
   670 // -----------------------------------------------------------------------------
   721 // -----------------------------------------------------------------------------
   671 // TFsEmailUiUtility::OpenFileL
   722 // TFsEmailUiUtility::OpenFileL
   672 // -----------------------------------------------------------------------------
   723 // -----------------------------------------------------------------------------
   673 void TFsEmailUiUtility::OpenFileL( RFile& aFileToOpen, TDataType& aDataType, TBool aAllowSave )
   724 void TFsEmailUiUtility::OpenFileL( RFile& aFileToOpen, TDataType& aDataType, TBool /* aAllowSave */)
   674     {
   725     {
   675     FUNC_LOG;
   726     FUNC_LOG;
   676     CFreestyleEmailUiAppUi* appUi = (CFreestyleEmailUiAppUi*)CCoeEnv::Static()->AppUi();
   727     CFreestyleEmailUiAppUi* appUi = (CFreestyleEmailUiAppUi*)CCoeEnv::Static()->AppUi();
   677 
   728 
   678     // Set file handle shutter to close the file handle after the embedded
   729     // Set file handle shutter to close the file handle after the embedded
   679     // viewer application exits.
   730     // viewer application exits.
   680     appUi->FileHandleShutter().SetFile( aFileToOpen );
   731     appUi->FileHandleShutter().SetFile( aFileToOpen );
   681 
   732 
   682     CDocumentHandler& docHandler = appUi->DocumentHandler();
   733     CDocumentHandler& docHandler = appUi->DocumentHandler();
   683    	CAiwGenericParamList& paramList = docHandler.InParamListL();
       
   684 
       
   685    	// Set allow save to parameter.
       
   686    	if ( aAllowSave )
       
   687    	    {
       
   688         TAiwVariant allowSaveVariant( ETrue );
       
   689         TAiwGenericParam genericParamAllowSave( EGenericParamAllowSave,
       
   690                 allowSaveVariant );
       
   691         paramList.AppendL( genericParamAllowSave );
       
   692    	    }
       
   693 
   734 
   694     TInt res = KErrNone;
   735     TInt res = KErrNone;
   695     TRAPD( err, res = docHandler.OpenFileEmbeddedL( aFileToOpen, aDataType, paramList ) );
   736     TRAPD( err, res = docHandler.OpenFileEmbeddedL( aFileToOpen, aDataType ) );
   696 
   737 
   697     // Try again with an empty data type if opening using the given data type fails
   738     // Try again with an empty data type if opening using the given data type fails
   698     if ( err != KErrNone || res != KErrNone )
   739     if ( err != KErrNone || res != KErrNone )
   699         {
   740         {
   700         TDataType emptyType;
   741         TDataType emptyType;
   701 
   742 
   702         // Open file embedded
   743         // Open file embedded
   703  	    TRAP( err, res = docHandler.OpenFileEmbeddedL( aFileToOpen, emptyType, paramList ) );
   744         TRAP( err, res = docHandler.OpenFileEmbeddedL( aFileToOpen, emptyType ) );
   704 
   745 
   705         // Show an error note if opening the file still didn't succeed
   746         // Show an error note if opening the file still didn't succeed
   706         // Ensure also that the file handle got closed.
   747         // Ensure also that the file handle got closed.
   707         if ( err != KErrNone || res != KErrNone )
   748         if ( err != KErrNone || res != KErrNone )
   708             {
   749             {
   709             ShowErrorNoteL( R_FREESTYLE_EMAIL_INFO_NOTE_UNABLE_TO_OPEN, EFalse );
   750             ShowErrorNoteL( R_FREESTYLE_EMAIL_INFO_NOTE_UNABLE_TO_OPEN, EFalse );
   710             appUi->FileHandleShutter().HandleServerAppExit( KErrCancel );
   751             appUi->FileHandleShutter().HandleServerAppExit( KErrCancel );
   711             }
   752             }
   712         }
   753         else
   713 	}
   754             {
       
   755             // Set embedded app flag to true when embedded app start up.
       
   756             appUi->SetEmbeddedApp( ETrue );
       
   757             // Set flag for judging if previous app is embedded app.
       
   758             appUi->SetEmbeddedAppToPreviousApp( ETrue );
       
   759             }
       
   760         }
       
   761     else
       
   762         {
       
   763         // Set embedded app flag to true when embedded app start up.
       
   764         appUi->SetEmbeddedApp( ETrue );
       
   765         // Set flag for judging if previous app is embedded app.
       
   766         appUi->SetEmbeddedAppToPreviousApp( ETrue );
       
   767         }
       
   768     }
   714 
   769 
   715 // -----------------------------------------------------------------------------
   770 // -----------------------------------------------------------------------------
   716 // TFsEmailUiUtility::OpenAttachmentL
   771 // TFsEmailUiUtility::OpenAttachmentL
   717 // -----------------------------------------------------------------------------
   772 // -----------------------------------------------------------------------------
   718 void TFsEmailUiUtility::OpenAttachmentL( const TPartData& aAttachmentPart )
   773 void TFsEmailUiUtility::OpenAttachmentL( const TPartData& aAttachmentPart )
  2705 // -----------------------------------------------------------------------------
  2760 // -----------------------------------------------------------------------------
  2706 void TFsEmailUiUtility::ToggleEmailIconL( TBool aIconOn, const TFSMailMsgId& aMailBox )
  2761 void TFsEmailUiUtility::ToggleEmailIconL( TBool aIconOn, const TFSMailMsgId& aMailBox )
  2707 	{
  2762 	{
  2708     FUNC_LOG;
  2763     FUNC_LOG;
  2709     //Toggle email status indicator
  2764     //Toggle email status indicator
  2710 	if(aIconOn)
  2765 	//This is only used for mailwidget status updating
       
  2766 	/*if(aIconOn)
  2711 		{
  2767 		{
  2712 		RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsNewEmailStatus, ECoreAppUIsNewEmail );
  2768 		RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsNewEmailStatus, ECoreAppUIsNewEmail );
  2713 		}
  2769 		}
  2714 	else
  2770 	else
  2715 		{
  2771 		{
  2716 		RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsNewEmailStatus, ECoreAppUIsNoNewEmail );
  2772 		RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsNewEmailStatus, ECoreAppUIsNoNewEmail );
  2717 		}
  2773 		}*/
  2718 
  2774 
  2719     //Toggle new mail icon in widget
  2775     //Toggle new mail icon in widget
  2720     if (aMailBox.Id())
  2776     if (aMailBox.Id())
  2721         {
  2777         {
  2722         CRepository* repository(NULL);
  2778         CRepository* repository(NULL);