emailuis/emailui/src/FreestyleEmailUiAppui.cpp
branchRCL_3
changeset 8 e1b6206813b4
parent 4 e7aa27f58ae1
child 10 f5907b1a1053
equal deleted inserted replaced
4:e7aa27f58ae1 8:e1b6206813b4
    30 #include <apgcli.h>
    30 #include <apgcli.h>
    31 #include <FreestyleEmailUi.rsg>
    31 #include <FreestyleEmailUi.rsg>
    32 #include <fsmailserver.rsg>
    32 #include <fsmailserver.rsg>
    33 #include <StringLoader.h>
    33 #include <StringLoader.h>
    34 //<cmail>
    34 //<cmail>
    35 #include "CFSMailClient.h"
    35 #include "cfsmailclient.h"
    36 #include "CFSMailBox.h"
    36 #include "cfsmailbox.h"
    37 #include "CFSMailFolder.h"
    37 #include "cfsmailfolder.h"
    38 #include "CFSMailMessage.h"
    38 #include "cfsmailmessage.h"
    39 #include "CFSMailAddress.h"
    39 #include "cfsmailaddress.h"
    40 #include "CFSMailCommon.h"
    40 #include "cfsmailcommon.h"
    41 //</cmail>
    41 //</cmail>
    42 #include <freestyleemailui.mbg>
    42 #include <freestyleemailui.mbg>
    43 #include <AknQueryDialog.h>
    43 #include <AknQueryDialog.h>
    44 #include <AknBidiTextUtils.h>
    44 #include <AknBidiTextUtils.h>
    45 #include <gdi.h>
    45 #include <gdi.h>
   167     iMsgReaderIsSupported( KErrGeneral ),
   167     iMsgReaderIsSupported( KErrGeneral ),
   168     iSwitchingToBackground( EFalse )
   168     iSwitchingToBackground( EFalse )
   169     {
   169     {
   170     FUNC_LOG;
   170     FUNC_LOG;
   171     iEnv = &aEnv;
   171     iEnv = &aEnv;
       
   172     TIMESTAMP( "Application starting" );
   172     }
   173     }
   173 
   174 
   174 // ---------------------------------------------------------------------------
   175 // ---------------------------------------------------------------------------
   175 // Load specified resource file, file name may (and should) contain wild cards
   176 // Load specified resource file, file name may (and should) contain wild cards
   176 // ---------------------------------------------------------------------------
   177 // ---------------------------------------------------------------------------
   379 
   380 
   380     // this includes a wait note where code running will be pending
   381     // this includes a wait note where code running will be pending
   381     // until a certain callback event is received
   382     // until a certain callback event is received
   382     // -> thus keep this last in this method!
   383     // -> thus keep this last in this method!
   383     iWizardObserver->DoWizardStartupActionsL();
   384     iWizardObserver->DoWizardStartupActionsL();
       
   385     TIMESTAMP( "Application started" );
   384     }
   386     }
   385 
   387 
   386 // Functions loads some views as delayed to reduce startup time
   388 // Functions loads some views as delayed to reduce startup time
   387 TInt CFreestyleEmailUiAppUi::ViewLoadIdleCallbackFunctionL()
   389 TInt CFreestyleEmailUiAppUi::ViewLoadIdleCallbackFunctionL()
   388 	{
   390 	{
   529     CFSEmailDownloadInfoMediator::Destroy();
   531     CFSEmailDownloadInfoMediator::Destroy();
   530 
   532 
   531     delete iNaviDecorator2MailViewer;
   533     delete iNaviDecorator2MailViewer;
   532 
   534 
   533     delete iConnectionStatusIconAnimTimer;
   535     delete iConnectionStatusIconAnimTimer;
       
   536     TIMESTAMP( "Application exit" );
   534     }
   537     }
   535 
   538 
   536 
   539 
   537 void CFreestyleEmailUiAppUi::EnterFsEmailViewL( TUid aViewId )
   540 void CFreestyleEmailUiAppUi::EnterFsEmailViewL( TUid aViewId )
   538     {
   541     {
   632         else
   635         else
   633             {
   636             {
   634             iCurrentActiveView = iNavigationHistory->Pop();
   637             iCurrentActiveView = iNavigationHistory->Pop();
   635             }
   638             }
   636         }
   639         }
       
   640     // may be tricky; added here to handle activation of composer view from external app when email is plugin settings view
       
   641     // in this case also duplictaed view needs to be poped up, but iSettingsViewActive is already set to EFalse
       
   642     // other solution would need to expand api of this class to handle directly this case 
       
   643     else
       
   644     	if ( iPreviousActiveView->Id() == SettingsViewId  || iPreviousActiveView->Id() == MailListId )
       
   645     		{
       
   646     		iCurrentActiveView = iNavigationHistory->Pop();
       
   647     		}
   637     }
   648     }
   638 
   649 
   639 void CFreestyleEmailUiAppUi::ViewActivatedExternallyL( TUid aViewId )
   650 void CFreestyleEmailUiAppUi::ViewActivatedExternallyL( TUid aViewId )
   640     {
   651     {
   641     FUNC_LOG;
   652     FUNC_LOG;
   666             {
   677             {
   667             iNavigationHistory->PushL( iCurrentActiveView );
   678             iNavigationHistory->PushL( iCurrentActiveView );
   668             iCurrentActiveView = static_cast<CFsEmailUiViewBase*>( View(aViewId) );
   679             iCurrentActiveView = static_cast<CFsEmailUiViewBase*>( View(aViewId) );
   669             }
   680             }
   670         }
   681         }
   671 
   682     TIMESTAMP( "View activated" );
   672     }
   683     }
   673 
   684 
   674 void CFreestyleEmailUiAppUi::SetSwitchingToBackground( TBool aValue )
   685 void CFreestyleEmailUiAppUi::SetSwitchingToBackground( TBool aValue )
   675     {
   686     {
   676     FUNC_LOG;
   687     FUNC_LOG;
   698 	    }
   709 	    }
   699 	else
   710 	else
   700 	    {
   711 	    {
   701        	ReturnToPreviousViewL();
   712        	ReturnToPreviousViewL();
   702 	    }
   713 	    }
       
   714 	TIMESTAMP( "Returned from html viewer view to previous view" );
   703 	}
   715 	}
   704 
   716 
   705 TUid CFreestyleEmailUiAppUi::ReturnToPreviousViewL( const TDesC8& aCustomMessage /*= KNullDesC8*/ )
   717 TUid CFreestyleEmailUiAppUi::ReturnToPreviousViewL( const TDesC8& aCustomMessage /*= KNullDesC8*/ )
   706     {
   718     {
   707     FUNC_LOG;
   719     FUNC_LOG;
   723 
   735 
   724     // Activate the proper view
   736     // Activate the proper view
   725 	if ( viewId == AppGridId )
   737 	if ( viewId == AppGridId )
   726 		{
   738 		{
   727 		ActivateLocalViewL( AppGridId );
   739 		ActivateLocalViewL( AppGridId );
       
   740 		TIMESTAMP( "Return to application grid view" );
   728 		}
   741 		}
   729 	else if ( viewId == MailListId )
   742 	else if ( viewId == MailListId )
   730 		{
   743 		{
   731 		if ( aCustomMessage.Length() )
   744 		if ( aCustomMessage.Length() )
   732 		    {
   745 		    {
   735 		else
   748 		else
   736 		    {
   749 		    {
   737     		const TPckgBuf<TMailListActivationData> pkgOut;
   750     		const TPckgBuf<TMailListActivationData> pkgOut;
   738     		ActivateLocalViewL( MailListId, KStartListReturnToPreviousFolder, pkgOut );
   751     		ActivateLocalViewL( MailListId, KStartListReturnToPreviousFolder, pkgOut );
   739 		    }
   752 		    }
       
   753 		TIMESTAMP( "Return to message list view" );
   740 		}
   754 		}
   741 	else if ( viewId == SearchListViewId )
   755 	else if ( viewId == SearchListViewId )
   742 		{
   756 		{
   743 		TSearchListActivationData tmp;
   757 		TSearchListActivationData tmp;
   744 		tmp.iMailBoxId = GetActiveMailbox()->GetId();
   758 		tmp.iMailBoxId = GetActiveMailbox()->GetId();
   753 	else if ( viewId == HtmlViewerId )
   767 	else if ( viewId == HtmlViewerId )
   754 	    {
   768 	    {
   755 	    // launch html viewer
   769 	    // launch html viewer
   756 		const TPckgBuf<THtmlViewerActivationData> pkgOut;
   770 		const TPckgBuf<THtmlViewerActivationData> pkgOut;
   757 		ActivateLocalViewL( HtmlViewerId, KHtmlViewerReturnToPrevious, pkgOut );
   771 		ActivateLocalViewL( HtmlViewerId, KHtmlViewerReturnToPrevious, pkgOut );
       
   772 		TIMESTAMP( "Return to html viewer view" );
   758 	    }
   773 	    }
   759 	else if ( viewId == MailEditorId )
   774 	else if ( viewId == MailEditorId )
   760 		{
   775 		{
   761 		ActivateLocalViewL( MailEditorId, TUid::Uid(KEditorCmdReturnToPrevious), aCustomMessage );
   776 		ActivateLocalViewL( MailEditorId, TUid::Uid(KEditorCmdReturnToPrevious), aCustomMessage );
       
   777 		TIMESTAMP( "Return to email editor view" );
   762 		}
   778 		}
   763 	else if ( viewId == MsgDetailsViewId )
   779 	else if ( viewId == MsgDetailsViewId )
   764 		{
   780 		{
   765 		ActivateLocalViewL( MsgDetailsViewId, KStartMsgDetailsReturnToPrevious, aCustomMessage );
   781 		ActivateLocalViewL( MsgDetailsViewId, KStartMsgDetailsReturnToPrevious, aCustomMessage );
   766 		}
   782 		}
   770 	    }
   786 	    }
   771 	else
   787 	else
   772 		{
   788 		{
   773 		// Generic case where the view does not need any startup parameters
   789 		// Generic case where the view does not need any startup parameters
   774 		ActivateLocalViewL( viewId );
   790 		ActivateLocalViewL( viewId );
       
   791 		TIMESTAMP( "Return to previous view" );
   775 		}
   792 		}
   776 
   793 
   777 	return viewId;
   794 	return viewId;
   778     }
   795     }
   779 
   796 
   822         }
   839         }
   823     else
   840     else
   824         {
   841         {
   825         ActivateLocalViewL( iCurrentActiveView->Id() );
   842         ActivateLocalViewL( iCurrentActiveView->Id() );
   826         }
   843         }
       
   844     TIMESTAMP( "Return to earlier view" );
   827     }
   845     }
   828 
   846 
   829 void CFreestyleEmailUiAppUi::ShowFolderListInPopupL(
   847 void CFreestyleEmailUiAppUi::ShowFolderListInPopupL(
   830         const TFSMailMsgId aFolderId,
   848         const TFSMailMsgId aFolderId,
   831         MFSEmailUiFolderListCallback* aCallback,
   849         MFSEmailUiFolderListCallback* aCallback,
   895     }
   913     }
   896 
   914 
   897 void CFreestyleEmailUiAppUi::Exit()
   915 void CFreestyleEmailUiAppUi::Exit()
   898     {
   916     {
   899     FUNC_LOG;
   917     FUNC_LOG;
       
   918     TIMESTAMP ("Exiting from email application");
   900     g_ApplicationExitOnGoing = ETrue;
   919     g_ApplicationExitOnGoing = ETrue;
   901     if ( iExitGuardian->ExitApplication() == KRequestPending )
   920     if ( iExitGuardian->ExitApplication() == KRequestPending )
   902         {
   921         {
   903         SendToBackground();
   922         SendToBackground();
   904         }
   923         }
  1739 
  1758 
  1740 	}
  1759 	}
  1741 
  1760 
  1742 // Force Sync on active mailbox.
  1761 // Force Sync on active mailbox.
  1743 void CFreestyleEmailUiAppUi::SyncActiveMailBoxL()
  1762 void CFreestyleEmailUiAppUi::SyncActiveMailBoxL()
  1744 	{
  1763      {
  1745     FUNC_LOG;
  1764      FUNC_LOG;
  1746 	if ( iActiveMailbox )
  1765      if( iActiveMailbox )
  1747 		{
  1766          {
  1748     	iSyncStatusReqId = iActiveMailbox->RefreshNowL( *this );
  1767          // Start sync automatically if not syncing already
  1749 		}
  1768          TSSMailSyncState latestSyncstate = iActiveMailbox->CurrentSyncState();
  1750 	}
  1769          if( latestSyncstate != InboxSyncing && latestSyncstate != StartingSync && latestSyncstate != EmailSyncing )
  1751 
  1770 	     {
       
  1771     	     iSyncStatusReqId = iActiveMailbox->RefreshNowL( *this );
       
  1772 	     }
       
  1773          }
       
  1774       }
  1752 void CFreestyleEmailUiAppUi::StopActiveMailBoxSyncL()
  1775 void CFreestyleEmailUiAppUi::StopActiveMailBoxSyncL()
  1753 	{
  1776      {
  1754     FUNC_LOG;
  1777      FUNC_LOG;
  1755     if ( iActiveMailbox )
  1778      if ( iActiveMailbox && iActiveMailbox->GetMailBoxStatus()==EFSMailBoxOnline)
  1756         {
  1779          {
  1757         iActiveMailbox->CancelSyncL();
  1780          TSSMailSyncState latestSyncstate = iActiveMailbox->CurrentSyncState();
  1758         }
  1781          if(latestSyncstate == InboxSyncing ||
  1759 	}
  1782                 latestSyncstate == EmailSyncing ||
  1760 
  1783                 latestSyncstate == OutboxSyncing ||
       
  1784                 latestSyncstate == SentItemsSyncing ||
       
  1785                 latestSyncstate == DraftsSyncing ||
       
  1786                 latestSyncstate == CalendarSyncing ||
       
  1787                 latestSyncstate == ContactsSyncing ||
       
  1788                 latestSyncstate == TasksSyncing ||
       
  1789                 latestSyncstate == NotesSyncing ||
       
  1790                 latestSyncstate == FilesSyncing ||
       
  1791                 latestSyncstate == DataSyncStarting )
       
  1792              {
       
  1793              iActiveMailbox->CancelSyncL();
       
  1794              }
       
  1795          }
       
  1796      }
  1761 
  1797 
  1762 MCoeMessageObserver::TMessageResponse CFreestyleEmailUiAppUi::HandleMessageL(
  1798 MCoeMessageObserver::TMessageResponse CFreestyleEmailUiAppUi::HandleMessageL(
  1763     TUint32 aClientHandleOfTargetWindowGroup,
  1799     TUint32 aClientHandleOfTargetWindowGroup,
  1764     TUid aMessageUid,
  1800     TUid aMessageUid,
  1765     const TDesC8& aMessageParameters )
  1801     const TDesC8& aMessageParameters )
  1881     			{
  1917     			{
  1882         		switch ( *newSyncState )
  1918         		switch ( *newSyncState )
  1883         			{
  1919         			{
  1884                     case StartingSync:
  1920                     case StartingSync:
  1885                         {
  1921                         {
       
  1922                         TIMESTAMP( "Starting sync" );
  1886                         //If syncs were started by user, show the synchoronisation indicator
  1923                         //If syncs were started by user, show the synchoronisation indicator
       
  1924                         TIMESTAMP( "Sync error" );
  1887                         if(iManualMailBoxSyncAll)
  1925                         if(iManualMailBoxSyncAll)
  1888                             {
  1926                             {
  1889                             ManualMailBoxSyncAll(EFalse);
  1927                             ManualMailBoxSyncAll(EFalse);
  1890                             }
  1928                             }
  1891                         }
  1929                         }
  1908                         break;
  1946                         break;
  1909                     case FinishedSuccessfully:
  1947                     case FinishedSuccessfully:
  1910                     case SyncCancelled:
  1948                     case SyncCancelled:
  1911                     case Idle:
  1949                     case Idle:
  1912                         {
  1950                         {
       
  1951                         TIMESTAMP( "Sync finished" );
  1913                         ManualMailBoxSync( EFalse );
  1952                         ManualMailBoxSync( EFalse );
  1914                         }
  1953                         }
  1915                         break;
  1954                         break;
  1916 
  1955 
  1917        				case PushChannelOffBecauseBatteryIsLow:
  1956        				case PushChannelOffBecauseBatteryIsLow: