emailuis/emailui/src/FreestyleEmailUiAppui.cpp
branchRCL_3
changeset 12 4ce476e64c59
parent 11 0396474f30f5
child 13 8592a65ad3fb
equal deleted inserted replaced
11:0396474f30f5 12:4ce476e64c59
    93 #include "FreestyleEmailUiContactHandler.h"
    93 #include "FreestyleEmailUiContactHandler.h"
    94 #include "FreestyleEmailUiAppui.h"
    94 #include "FreestyleEmailUiAppui.h"
    95 #include "FreestyleEmailUi.hrh"
    95 #include "FreestyleEmailUi.hrh"
    96 #include "FreestyleEmailUiLauncherGrid.h"
    96 #include "FreestyleEmailUiLauncherGrid.h"
    97 #include "FreestyleEmailUiLayoutHandler.h"
    97 #include "FreestyleEmailUiLayoutHandler.h"
    98 #include "FreestyleEmailUiMailViewerVisualiser.h"
       
    99 #include "FreestyleEmailUiMailListControl.h"
    98 #include "FreestyleEmailUiMailListControl.h"
   100 #include "FreestyleEmailUiMailListModel.h"
    99 #include "FreestyleEmailUiMailListModel.h"
   101 #include "FreestyleEmailUiMailListVisualiser.h"
   100 #include "FreestyleEmailUiMailListVisualiser.h"
   102 #include "FreestyleEmailUiTextureManager.h"
   101 #include "FreestyleEmailUiTextureManager.h"
   103 #include "FreestyleEmailUiMsgDetailsVisualiser.h"
   102 #include "FreestyleEmailUiMsgDetailsVisualiser.h"
   481     //iLayoutManager->LoadLayoutL();
   480     //iLayoutManager->LoadLayoutL();
   482     //<cmail>
   481     //<cmail>
   483 
   482 
   484     // Set up layouthandler
   483     // Set up layouthandler
   485     iLayoutHandler = CFSEmailUiLayoutHandler::NewL( *iEnv );
   484     iLayoutHandler = CFSEmailUiLayoutHandler::NewL( *iEnv );
   486 	iLayoutHandler->ScreenResolutionChanged();
       
   487 
   485 
   488     // Create mail client, list mailboxes
   486     // Create mail client, list mailboxes
   489     iMailClient = CFSMailClient::NewL();
   487     iMailClient = CFSMailClient::NewL();
   490 
   488 
   491 	// Connect to messaging server
   489 	// Connect to messaging server
   532 	CleanupStack::Pop( settingsListView );
   530 	CleanupStack::Pop( settingsListView );
   533 	CFsEmailUiGlobalSettingsListView* globalSettingsView = CFsEmailUiGlobalSettingsListView::NewLC( this, *iSettingsListControlGroup );
   531 	CFsEmailUiGlobalSettingsListView* globalSettingsView = CFsEmailUiGlobalSettingsListView::NewLC( this, *iSettingsListControlGroup );
   534 	AddViewL( globalSettingsView );
   532 	AddViewL( globalSettingsView );
   535 	CleanupStack::Pop( globalSettingsView );
   533 	CleanupStack::Pop( globalSettingsView );
   536 
   534 
   537 	// Create and start view load in idle. Loads rest of the views when in idle.
   535     // Create and start view load in idle. Loads rest of the views when in idle.
   538   	iViewLoadIdle = CIdle::NewL( CActive::EPriorityIdle );
   536     iViewLoadIdle = CIdle::NewL( CActive::EPriorityIdle );
   539 	iViewLoadIdleCallback = new (ELeave) TCallBack( DelayedViewLoaderCallBackL, this );
   537     iViewLoadIdleCallback = new (ELeave) TCallBack( DelayedViewLoaderCallBackL, this );
   540   	iViewLoadIdle->Start( *iViewLoadIdleCallback );
   538     iViewLoadIdle->Start( *iViewLoadIdleCallback );
   541 
   539 
   542 	// Create mail viewer
   540     // Create html viewer
   543 	iViewerVisualiser = CFSEmailUiMailViewerVisualiser::NewL( *iEnv, *this, *iEmailViewerControlGroup );
   541     iHtmlViewerControlGroup = &iEnv->NewControlGroupL( KHtmlViewerDisplayGroup );
   544 	AddViewL( iViewerVisualiser );
       
   545 	// Create html viewer
       
   546 	iHtmlViewerControlGroup = &iEnv->NewControlGroupL( KHtmlViewerDisplayGroup );
       
   547     iHtmlViewerView = CFsEmailUiHtmlViewerView::NewL( *iEnv, *this, *iHtmlViewerControlGroup );
   542     iHtmlViewerView = CFsEmailUiHtmlViewerView::NewL( *iEnv, *this, *iHtmlViewerControlGroup );
   548     AddViewL( iHtmlViewerView );
   543     AddViewL( iHtmlViewerView );
   549 
   544 
   550 	// Create mail list
   545 	// Create mail list
   551     iMailListVisualiser = CFSEmailUiMailListVisualiser::NewL(*iEnv, this, *iMailListControlGroup );
   546     iMailListVisualiser = CFSEmailUiMailListVisualiser::NewL(*iEnv, this, *iMailListControlGroup );
   605 	//<cmail> hard coded paths removal
   600 	//<cmail> hard coded paths removal
   606 	TFileName phCltResPath(KDC_RESOURCE_FILES_DIR);
   601 	TFileName phCltResPath(KDC_RESOURCE_FILES_DIR);
   607     phCltResPath.Append(KETelCallEngPhCltResourceFile);
   602     phCltResPath.Append(KETelCallEngPhCltResourceFile);
   608     //</cmail>
   603     //</cmail>
   609     BaflUtils::NearestLanguageFile( iEikonEnv->FsSession(), phCltResPath );
   604     BaflUtils::NearestLanguageFile( iEikonEnv->FsSession(), phCltResPath );
   610     iPhCltResHandle = CCoeEnv::Static()->AddResourceFileL( phCltResPath );
   605     iPhCltResHandle = iEikonEnv->AddResourceFileL( phCltResPath );
   611 
   606 
   612 	// Create attachment list visualiser and control
   607 	// Create attachment list visualiser and control
   613 	iAttachmentControlGroup = &iEnv->NewControlGroupL( KAttachmentManagerDisplayGroup );
   608 	iAttachmentControlGroup = &iEnv->NewControlGroupL( KAttachmentManagerDisplayGroup );
   614 	iAttachmentListVisualiser = CFSEmailUiAttachmentsListVisualiser::NewL( *iEnv, this, *iAttachmentControlGroup );
   609 	iAttachmentListVisualiser = CFSEmailUiAttachmentsListVisualiser::NewL( *iEnv, this, *iAttachmentControlGroup );
   615 	AddViewL( iAttachmentListVisualiser );
   610 	AddViewL( iAttachmentListVisualiser );
   981 		{
   976 		{
   982 		TSearchListActivationData tmp;
   977 		TSearchListActivationData tmp;
   983 		tmp.iMailBoxId = GetActiveMailbox()->GetId();
   978 		tmp.iMailBoxId = GetActiveMailbox()->GetId();
   984 		const TPckgBuf<TSearchListActivationData> pkgOut( tmp );
   979 		const TPckgBuf<TSearchListActivationData> pkgOut( tmp );
   985 		ActivateLocalViewL( SearchListViewId, KStartWithPreviousResults, pkgOut );
   980 		ActivateLocalViewL( SearchListViewId, KStartWithPreviousResults, pkgOut );
   986 		}
       
   987 	else if ( viewId == MailViewerId )
       
   988 		{
       
   989 		const TPckgBuf<TMsgViewerActivationData> pkgOut;
       
   990 		ActivateLocalViewL( MailViewerId, KStartViewerReturnToPreviousMsg,  pkgOut);
       
   991 		}
   981 		}
   992 	else if ( viewId == HtmlViewerId )
   982 	else if ( viewId == HtmlViewerId )
   993 	    {
   983 	    {
   994 	    // launch html viewer
   984 	    // launch html viewer
   995 		const TPckgBuf<THtmlViewerActivationData> pkgOut;
   985 		const TPckgBuf<THtmlViewerActivationData> pkgOut;
  1177         }
  1167         }
  1178     if ( iMailListVisualiser )
  1168     if ( iMailListVisualiser )
  1179         {
  1169         {
  1180         iMailListVisualiser->PrepareForExit();
  1170         iMailListVisualiser->PrepareForExit();
  1181         }
  1171         }
  1182     if ( iViewerVisualiser )
       
  1183         {
       
  1184         iViewerVisualiser->PrepareForExit();
       
  1185         }
       
  1186     if ( iHtmlViewerView )
  1172     if ( iHtmlViewerView )
  1187         {
  1173         {
  1188         iHtmlViewerView->PrepareForExit();
  1174         iHtmlViewerView->PrepareForExit();
  1189         }
  1175         }
  1190     if ( iSearchListVisualiser )
  1176     if ( iSearchListVisualiser )
  1452 
  1438 
  1453     // Refresh mode is changed to manual to avoid any flickering during
  1439     // Refresh mode is changed to manual to avoid any flickering during
  1454     // resource change handling in list views. Trap any leaves so that we set
  1440     // resource change handling in list views. Trap any leaves so that we set
  1455     // the automatic refresh mode back on even in case of error.
  1441     // the automatic refresh mode back on even in case of error.
  1456     iEnv->SetRefreshMode( EAlfRefreshModeManual );
  1442     iEnv->SetRefreshMode( EAlfRefreshModeManual );
       
  1443     switch ( aType )
       
  1444         {
       
  1445         case KEikDynamicLayoutVariantSwitch:
       
  1446             iEnv->NotifyLayoutChangedL();
       
  1447             break;
       
  1448         case KAknsMessageSkinChange:            
       
  1449             iEnv->NotifySkinChangedL();
       
  1450             break;
       
  1451         }
  1457     TRAPD( error, DoHandleResourceChangeL( aType ) );
  1452     TRAPD( error, DoHandleResourceChangeL( aType ) );
  1458     iEnv->SetRefreshMode( EAlfRefreshModeAutomatic );
  1453     iEnv->SetRefreshMode( EAlfRefreshModeAutomatic );
  1459     User::LeaveIfError( error );
  1454     User::LeaveIfError( error );
  1460     }
  1455     }
  1461 
  1456 
  1467     // compose screen loadbackgroundcontext sends 2 skin change events
  1462     // compose screen loadbackgroundcontext sends 2 skin change events
  1468     //if( aType == KAknsMessageSkinChange && iConstructComplete )
  1463     //if( aType == KAknsMessageSkinChange && iConstructComplete )
  1469     //    {
  1464     //    {
  1470     //    CAlfEnv::Static()->NotifySkinChangedL();
  1465     //    CAlfEnv::Static()->NotifySkinChangedL();
  1471     //    }
  1466     //    }
  1472 
  1467     
  1473     if( aType == KEikDynamicLayoutVariantSwitch || aType == KAknsMessageSkinChange )
  1468     if ( aType == KEikDynamicLayoutVariantSwitch )
  1474         {
  1469     	{
  1475         // Changing layout for status pane (just in case it is not switched
  1470         // Changing layout for status pane (just in case it is not switched
  1476         // correctly), fix for HMNN-82BAGR error
  1471         // correctly), fix for HMNN-82BAGR error
       
  1472         // it's not related with skin change so "moved up" TJOS-83DELP fix 
  1477         TBool landscape(Layout_Meta_Data::IsLandscapeOrientation());
  1473         TBool landscape(Layout_Meta_Data::IsLandscapeOrientation());
  1478         CEikStatusPane* statusPane = StatusPane();
  1474         CEikStatusPane* statusPane = StatusPane();
  1479         if(landscape)
  1475         if(landscape)
  1480         	{
  1476         	{
  1481 			if( statusPane->CurrentLayoutResId() != R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT)
  1477 			if( statusPane->CurrentLayoutResId() != R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT)
  1487         	{
  1483         	{
  1488 			if( statusPane->CurrentLayoutResId() != R_AVKON_STATUS_PANE_LAYOUT_USUAL_EXT)
  1484 			if( statusPane->CurrentLayoutResId() != R_AVKON_STATUS_PANE_LAYOUT_USUAL_EXT)
  1489 				{
  1485 				{
  1490 				statusPane->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_USUAL_EXT);
  1486 				statusPane->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_USUAL_EXT);
  1491 				}
  1487 				}
  1492         	}
  1488         	}       
       
  1489     	}
       
  1490 
       
  1491     if( aType == KEikDynamicLayoutVariantSwitch || aType == KAknsMessageSkinChange )
       
  1492         {
  1493 
  1493 
  1494 	  	TRect screenRect;
  1494 	  	TRect screenRect;
  1495 	 	AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, screenRect );
  1495 	 	AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, screenRect );
  1496         //<cmail> layout manager call removed </cmail>
       
  1497         // Notify layouthandler of changed screen resolution.
       
  1498         iLayoutHandler->ScreenResolutionChanged();
       
  1499   		StatusPane()->DrawNow();
  1496   		StatusPane()->DrawNow();
  1500         if(iEnv)
  1497         if(iEnv)
  1501             {
  1498             {
  1502 			Display().SetVisibleArea( screenRect );
  1499 			Display().SetVisibleArea( screenRect );
  1503             }
  1500             }
  1965                 }
  1962                 }
  1966 			}
  1963 			}
  1967 		CleanupStack::PopAndDestroy( &markedMsgIdArray );
  1964 		CleanupStack::PopAndDestroy( &markedMsgIdArray );
  1968 		}
  1965 		}
  1969 	// Check if view is in mail viewer
  1966 	// Check if view is in mail viewer
  1970 	else if ( mb && ( View(MailViewerId)->IsForeground() || View(SearchListViewId)->IsForeground() ) )
  1967 	else if ( mb && ( View(HtmlViewerId)->IsForeground() || View(SearchListViewId)->IsForeground() ) )
  1971 		{
  1968 		{
  1972         delete iCustomMessageToMessageReader;
  1969         delete iCustomMessageToMessageReader;
  1973         iCustomMessageToMessageReader = NULL;
  1970         iCustomMessageToMessageReader = NULL;
  1974 		iCustomMessageToMessageReader = HBufC8::NewL(16);
  1971 		iCustomMessageToMessageReader = HBufC8::NewL(16);
  1975 		TPtr8 msgPtr = iCustomMessageToMessageReader->Des();
  1972 		TPtr8 msgPtr = iCustomMessageToMessageReader->Des();
  1977 		CleanupClosePushL( outStream );
  1974 		CleanupClosePushL( outStream );
  1978 	    outStream.WriteInt32L( mb->GetId().PluginId().iUid );
  1975 	    outStream.WriteInt32L( mb->GetId().PluginId().iUid );
  1979 	    outStream.WriteUint32L( mb->GetId().Id() );
  1976 	    outStream.WriteUint32L( mb->GetId().Id() );
  1980 		TFSMailMsgId folderId;
  1977 		TFSMailMsgId folderId;
  1981 	   	TFSMailMsgId msgId;
  1978 	   	TFSMailMsgId msgId;
  1982 	   	if ( View(MailViewerId)->IsForeground() && iHtmlViewerView )
  1979 	   	if ( View(HtmlViewerId)->IsForeground() && iHtmlViewerView )
  1983 	   		{
  1980 	   		{
  1984 	   		folderId = iHtmlViewerView->ViewedMessageFolderId();
  1981 	   		folderId = iHtmlViewerView->ViewedMessageFolderId();
  1985 	   		msgId = iHtmlViewerView->ViewedMessageId();
  1982 	   		msgId = iHtmlViewerView->ViewedMessageId();
  1986 	   		}
  1983 	   		}
  1987 	   	else if ( View(SearchListViewId)->IsForeground() && iSearchListVisualiser )
  1984 	   	else if ( View(SearchListViewId)->IsForeground() && iSearchListVisualiser )
  2101 
  2098 
  2102 void CFreestyleEmailUiAppUi::EventL( TFSMailEvent aEvent, TFSMailMsgId aMailbox,
  2099 void CFreestyleEmailUiAppUi::EventL( TFSMailEvent aEvent, TFSMailMsgId aMailbox,
  2103                                      TAny* aParam1, TAny* aParam2, TAny* aParam3 )
  2100                                      TAny* aParam1, TAny* aParam2, TAny* aParam3 )
  2104     {
  2101     {
  2105     FUNC_LOG;
  2102     FUNC_LOG;
       
  2103     INFO_1( "CMAIL Received event: %d", aEvent );
  2106 
  2104 
  2107     if (iExitGuardian)
  2105     if (iExitGuardian)
  2108         {
  2106         {
  2109         iExitGuardian->EnterLC();
  2107         iExitGuardian->EnterLC();
  2110         }
  2108         }
  2190                         // error occured during "Connect" or "Send and receive" operation
  2188                         // error occured during "Connect" or "Send and receive" operation
  2191                         // check if user needs to be notified
  2189                         // check if user needs to be notified
  2192                         TIMESTAMP( "Sync error" );
  2190                         TIMESTAMP( "Sync error" );
  2193                         if ( iManualMailBoxSync )
  2191                         if ( iManualMailBoxSync )
  2194                             {
  2192                             {
  2195                             // since error id is not provided by plugin, lets popup general note
  2193 							/* 
  2196                             HBufC* text = StringLoader::LoadL( R_FS_MSERVER_TEXT_UNABLE_TO_COMPLETE );
  2194 							 * As a fix to TJOS-82ZFCW, this general popup is no longer needed
  2197                             CleanupStack::PushL( text );
  2195                              * // since error id is not provided by plugin, lets popup general note
  2198                             CAknInformationNote* infoNote = new ( ELeave ) CAknInformationNote;
  2196                              * HBufC* text = StringLoader::LoadL( R_FS_MSERVER_TEXT_UNABLE_TO_COMPLETE );
  2199                             infoNote->ExecuteLD( *text );
  2197                              * CleanupStack::PushL( text );
  2200                             CleanupStack::PopAndDestroy( text );
  2198                              * CAknInformationNote* infoNote = new ( ELeave ) CAknInformationNote;
       
  2199                              * infoNote->ExecuteLD( *text );
       
  2200                              * CleanupStack::PopAndDestroy( text );
       
  2201                              */
  2201                             ManualMailBoxSync( EFalse );
  2202                             ManualMailBoxSync( EFalse );
  2202                             }
  2203                             }
  2203                         }
  2204                         }
  2204                         break;
  2205                         break;
  2205                     case FinishedSuccessfully:
  2206                     case FinishedSuccessfully:
  2288     	iFolderListVisualiser->HandleMailBoxEventL( aEvent, aMailbox, aParam1, aParam2, aParam3 );
  2289     	iFolderListVisualiser->HandleMailBoxEventL( aEvent, aMailbox, aParam1, aParam2, aParam3 );
  2289     	}
  2290     	}
  2290     // </cmail>
  2291     // </cmail>
  2291 
  2292 
  2292 	// MAIL DELETED EVENT HANDLING BASED ON VIEW ACTIVE STATE.
  2293 	// MAIL DELETED EVENT HANDLING BASED ON VIEW ACTIVE STATE.
  2293     // Handle mail deleted event in mail viewer, as viewed mail could be open
       
  2294     if ( iViewerVisualiser && aEvent == TFSEventMailDeleted &&
       
  2295     	 iCurrentActiveView->Id() == MailViewerId )
       
  2296     	{
       
  2297     	iViewerVisualiser->HandleMailBoxEventL( aEvent, aMailbox, aParam1, aParam2, aParam3 );
       
  2298     	}
       
  2299     // Handle mail deleted event in attachment list, as the viewed mail could be open
  2294     // Handle mail deleted event in attachment list, as the viewed mail could be open
  2300     else if ( iAttachmentListVisualiser && aEvent == TFSEventMailDeleted  &&
  2295     if ( iAttachmentListVisualiser && aEvent == TFSEventMailDeleted  &&
  2301     	 iCurrentActiveView->Id() == AttachmentMngrViewId)
  2296     	 iCurrentActiveView->Id() == AttachmentMngrViewId)
  2302     	{
  2297     	{
  2303     	iAttachmentListVisualiser->HandleMailBoxEventL( aEvent, aMailbox, aParam1, aParam2, aParam3 );
  2298     	iAttachmentListVisualiser->HandleMailBoxEventL( aEvent, aMailbox, aParam1, aParam2, aParam3 );
  2304     	}
  2299     	}
  2305     // Handle mail deleted event in Html view list, as the mails might become obsolete
  2300     // Handle mail deleted event in Html view list, as the mails might become obsolete
       
  2301 	// Pass sync finished event there too in order to dismiss status dialogs
  2306     else if ( iHtmlViewerView && (aEvent == TFSEventMailDeleted || 
  2302     else if ( iHtmlViewerView && (aEvent == TFSEventMailDeleted || 
  2307                                   aEvent == TFSEventMailDeletedFromViewer || 
  2303                                   aEvent == TFSEventMailDeletedFromViewer ||
       
  2304 								  aEvent == TFSEventMailboxSyncStateChanged || 
  2308                                   aEvent == TFSEventNewMail) && iCurrentActiveView->Id() == HtmlViewerId)
  2305                                   aEvent == TFSEventNewMail) && iCurrentActiveView->Id() == HtmlViewerId)
  2309     	{
  2306     	{
  2310     	iHtmlViewerView->HandleMailBoxEventL( aEvent, aMailbox, aParam1, aParam2, aParam3 );
  2307     	iHtmlViewerView->HandleMailBoxEventL( aEvent, aMailbox, aParam1, aParam2, aParam3 );
  2311     	}
  2308     	}
  2312     // Download manager removed
  2309     // Download manager removed
  3189                 case RMobilePhone::ENotRegisteredNoService:
  3186                 case RMobilePhone::ENotRegisteredNoService:
  3190                 case RMobilePhone::ENotRegisteredEmergencyOnly:
  3187                 case RMobilePhone::ENotRegisteredEmergencyOnly:
  3191                 case RMobilePhone::ENotRegisteredSearching:
  3188                 case RMobilePhone::ENotRegisteredSearching:
  3192                 case RMobilePhone::ERegisteredBusy:
  3189                 case RMobilePhone::ERegisteredBusy:
  3193                 case RMobilePhone::ERegistrationDenied:
  3190                 case RMobilePhone::ERegistrationDenied:
  3194                 case RMobilePhone::ERegisteredRoaming:
  3191                 //case RMobilePhone::ERegisteredRoaming:
  3195                 	// No autoconnect in these cases
  3192                 	// No autoconnect in these cases
  3196                     break;
  3193                     break;
  3197                 // This is ok
  3194                 // This is ok
  3198                 case RMobilePhone::ERegisteredOnHomeNetwork:
  3195                 case RMobilePhone::ERegisteredOnHomeNetwork:
  3199 					// TRAP autoconnect, because list UI must open regardless success
  3196                 case RMobilePhone::ERegisteredRoaming:
       
  3197      				// TRAP autoconnect, because list UI must open regardless success
  3200 					// or failure of the auto-connect
  3198 					// or failure of the auto-connect
  3201                 	TRAP_IGNORE( iAppUi.DoAutoConnectL() );
  3199                 	TRAP_IGNORE( iAppUi.DoAutoConnectL() );
  3202                     break;
  3200                     break;
  3203                 default:
  3201                 default:
  3204                     break;
  3202                     break;