58 #include "xneffectmanager.h" |
58 #include "xneffectmanager.h" |
59 #include "xnkeyeventdispatcher.h" |
59 #include "xnkeyeventdispatcher.h" |
60 |
60 |
61 // Constants |
61 // Constants |
62 _LIT8( KEmptyWidgetUid, "0x2001f47f" ); |
62 _LIT8( KEmptyWidgetUid, "0x2001f47f" ); |
|
63 _LIT8( KTemplateViewUID, "0x20026f50" ); |
63 |
64 |
64 const TInt KPSCategoryUid( 0x200286E3 ); |
65 const TInt KPSCategoryUid( 0x200286E3 ); |
65 const TInt KPSCrashCountKey( 1 ); |
66 const TInt KPSCrashCountKey( 1 ); |
66 const TInt KStabilityInterval( 60000000 ); // 1 minute |
67 const TInt KStabilityInterval( 60000000 ); // 1 minute |
67 const TInt KActivationCompleteInterval( 2000000 ); // 2s |
68 const TInt KActivationCompleteInterval( 2000000 ); // 2s |
889 // ----------------------------------------------------------------------------- |
890 // ----------------------------------------------------------------------------- |
890 // CXnViewManager::ActivateNextViewL() |
891 // CXnViewManager::ActivateNextViewL() |
891 // Activates the next view |
892 // Activates the next view |
892 // ----------------------------------------------------------------------------- |
893 // ----------------------------------------------------------------------------- |
893 // |
894 // |
894 void CXnViewManager::ActivateNextViewL() |
895 void CXnViewManager::ActivateNextViewL( TInt /*aEffectId*/ ) |
895 { |
896 { |
896 CXnViewData& next( NextViewData() ); |
897 CXnViewData& next( NextViewData() ); |
897 ActivateViewL( next, KGfxContextActivateNextView ); |
898 |
|
899 if ( !next.Occupied() ) |
|
900 { |
|
901 TInt err( next.Load() ); |
|
902 |
|
903 if ( err ) |
|
904 { |
|
905 HandleErrorNotes( err ); |
|
906 return; |
|
907 } |
|
908 } |
|
909 |
|
910 // Activate view |
|
911 if ( next.Occupied() && !next.Active() ) |
|
912 { |
|
913 iAppUiAdapter.ViewAdapter().ActivateContainerL( |
|
914 next, EFalse, KGfxContextActivateNextView ); |
|
915 } |
898 } |
916 } |
899 |
917 |
900 // ----------------------------------------------------------------------------- |
918 // ----------------------------------------------------------------------------- |
901 // CXnViewManager::ActivatePreviousViewL() |
919 // CXnViewManager::ActivatePreviousViewL() |
902 // Activates the previous view |
920 // Activates the previous view |
903 // ----------------------------------------------------------------------------- |
921 // ----------------------------------------------------------------------------- |
904 // |
922 // |
905 void CXnViewManager::ActivatePreviousViewL() |
923 void CXnViewManager::ActivatePreviousViewL( TInt /*aEffectId*/ ) |
906 { |
924 { |
907 CXnViewData& prev( PreviousViewData() ); |
925 CXnViewData& prev( PreviousViewData() ); |
908 ActivateViewL( prev, KGfxContextActivatePrevView ); |
926 |
909 } |
927 if ( !prev.Occupied() ) |
910 |
928 { |
911 // ----------------------------------------------------------------------------- |
929 TInt err( prev.Load() ); |
912 // CXnViewManager::ActivatePreviousViewL() |
|
913 // Activates the previous view |
|
914 // ----------------------------------------------------------------------------- |
|
915 // |
|
916 void CXnViewManager::ActivateViewL( CXnViewData& aViewData, TUid aEffect, |
|
917 TBool aUpdateBg ) |
|
918 { |
|
919 if ( !aViewData.Occupied() ) |
|
920 { |
|
921 TInt err( aViewData.Load() ); |
|
922 |
930 |
923 if ( err ) |
931 if ( err ) |
924 { |
932 { |
925 HandleErrorNotes( err ); |
933 HandleErrorNotes( err ); |
926 return; |
934 return; |
927 } |
935 } |
928 } |
936 } |
929 |
937 |
930 // Activate view |
938 // Activate view |
931 if ( aViewData.Occupied() && !aViewData.Active() ) |
939 if ( prev.Occupied() && !prev.Active() ) |
932 { |
940 { |
933 iAppUiAdapter.ViewAdapter().ActivateContainerL( |
941 iAppUiAdapter.ViewAdapter().ActivateContainerL( |
934 aViewData, EFalse, aEffect, aUpdateBg ); |
942 prev, EFalse, KGfxContextActivatePrevView ); |
935 } |
943 } |
936 } |
944 } |
937 |
945 |
938 // ----------------------------------------------------------------------------- |
946 // ----------------------------------------------------------------------------- |
939 // CXnViewManager::AddViewL() |
947 // CXnViewManager::AddViewL() |
944 { |
952 { |
945 if ( iRootData->PluginData().Count() >= iRootData->MaxPages() ) |
953 if ( iRootData->PluginData().Count() >= iRootData->MaxPages() ) |
946 { |
954 { |
947 return KErrGeneral; |
955 return KErrGeneral; |
948 } |
956 } |
949 |
957 |
950 // If phone layout is mirrored new view needs to be added to left. Other right. |
|
951 TInt mirror = AknLayoutUtils::LayoutMirrored() ? 0 : 1; |
|
952 |
|
953 // Add new view (template view) to hsps |
958 // Add new view (template view) to hsps |
954 CAddPluginResult* result = iHspsWrapper->AddPluginL( |
959 CAddPluginResult* result = iHspsWrapper->AddPluginL( |
955 iRootData->ConfigurationId(), aInfo.Uid(), |
960 iRootData->ConfigurationId(), aInfo.Uid(), |
956 ViewIndex() + mirror ); |
961 ViewIndex() + 1 ); |
957 CleanupStack::PushL( result ); |
962 CleanupStack::PushL( result ); |
958 |
963 |
959 TInt retval( result->Status() ); |
964 TInt retval( result->Status() ); |
960 |
965 |
961 if( retval == KErrDiskFull ) |
966 if( retval == KErrDiskFull ) |
980 // Load succeed, add the new view behind the current view |
985 // Load succeed, add the new view behind the current view |
981 RPointerArray< CXnPluginData >& views( iRootData->PluginData() ); |
986 RPointerArray< CXnPluginData >& views( iRootData->PluginData() ); |
982 |
987 |
983 TInt index( views.Find( &ActiveViewData() ) ); |
988 TInt index( views.Find( &ActiveViewData() ) ); |
984 |
989 |
985 views.InsertL( newView, index + mirror ); |
990 views.InsertL( newView, index + 1 ); |
986 |
991 |
987 // Root data owns the new view now |
992 // Root data owns the new view now |
988 CleanupStack::Pop( newView ); |
993 CleanupStack::Pop( newView ); |
989 |
994 |
990 // Inform observers about added view |
995 // Inform observers about added view |
1023 { |
1028 { |
1024 TRAP_IGNORE( ShowErrorL( R_QTN_HS_MAX_AMOUNT_OF_PAGES_NOTE ) ); |
1029 TRAP_IGNORE( ShowErrorL( R_QTN_HS_MAX_AMOUNT_OF_PAGES_NOTE ) ); |
1025 |
1030 |
1026 return; |
1031 return; |
1027 } |
1032 } |
1028 |
1033 |
1029 // If phone layout is mirrored new view needs to be added to left. Other right. |
|
1030 TInt mirror = AknLayoutUtils::LayoutMirrored() ? 0 : 1; |
|
1031 |
|
1032 // Add new view (template view) to hsps |
1034 // Add new view (template view) to hsps |
1033 CAddPluginResult* result = iHspsWrapper->AddPluginL( |
1035 CAddPluginResult* result = iHspsWrapper->AddPluginL( |
1034 iRootData->ConfigurationId(), iRootData->TemplateViewUid(), |
1036 iRootData->ConfigurationId(), KTemplateViewUID, |
1035 ViewIndex() + mirror ); |
1037 ViewIndex() + 1 ); |
1036 CleanupStack::PushL( result ); |
1038 CleanupStack::PushL( result ); |
1037 |
1039 |
1038 TInt status( result->Status() ); |
1040 TInt status( result->Status() ); |
1039 |
1041 |
1040 if( status == KErrDiskFull ) |
1042 if( status == KErrDiskFull ) |
1066 // Load succeed, add the new view behind the current view |
1068 // Load succeed, add the new view behind the current view |
1067 RPointerArray< CXnPluginData >& views( iRootData->PluginData() ); |
1069 RPointerArray< CXnPluginData >& views( iRootData->PluginData() ); |
1068 |
1070 |
1069 TInt index( views.Find( &ActiveViewData() ) ); |
1071 TInt index( views.Find( &ActiveViewData() ) ); |
1070 |
1072 |
1071 views.InsertL( newView, index + mirror ); |
1073 views.InsertL( newView, index + 1 ); |
1072 |
1074 |
1073 // Root data owns the new view now |
1075 // Root data owns the new view now |
1074 CleanupStack::Pop( newView ); |
1076 CleanupStack::Pop( newView ); |
1075 |
1077 |
|
1078 // Activate view |
|
1079 iAppUiAdapter.ViewAdapter().ActivateContainerL( *newView, ETrue ); |
|
1080 |
1076 // Inform observers about added view |
1081 // Inform observers about added view |
1077 NotifyViewAdditionL( *newView ); |
1082 NotifyViewAdditionL( *newView ); |
1078 |
|
1079 // Activate view |
|
1080 iAppUiAdapter.ViewAdapter().ActivateContainerL( *newView, ETrue ); |
|
1081 } |
1083 } |
1082 else |
1084 else |
1083 { |
1085 { |
1084 // creation failed, remove it from hsps |
1086 // creation failed, remove it from hsps |
1085 iHspsWrapper->RemovePluginL( result->PluginId() ); |
1087 iHspsWrapper->RemovePluginL( result->PluginId() ); |
1499 ReportWidgetAmountL( aViewData ); |
1501 ReportWidgetAmountL( aViewData ); |
1500 |
1502 |
1501 for ( TInt i = 0; i < iObservers.Count(); i++ ) |
1503 for ( TInt i = 0; i < iObservers.Count(); i++ ) |
1502 { |
1504 { |
1503 iObservers[i]->NotifyViewActivatedL( aViewData ); |
1505 iObservers[i]->NotifyViewActivatedL( aViewData ); |
1504 } |
|
1505 } |
|
1506 |
|
1507 // ----------------------------------------------------------------------------- |
|
1508 // CXnViewManager::NotifyViewLoadedL() |
|
1509 // Notifies view is activated |
|
1510 // ----------------------------------------------------------------------------- |
|
1511 // |
|
1512 void CXnViewManager::NotifyViewLoadedL( const CXnViewData& aViewData ) |
|
1513 { |
|
1514 for ( TInt i = 0; i < iObservers.Count(); i++ ) |
|
1515 { |
|
1516 iObservers[i]->NotifyViewLoadedL( aViewData ); |
|
1517 } |
1506 } |
1518 } |
1507 } |
1519 |
1508 |
1520 // ----------------------------------------------------------------------------- |
1509 // ----------------------------------------------------------------------------- |
1521 // CXnViewManager::NotifyViewDeactivatedL() |
1510 // CXnViewManager::NotifyViewDeactivatedL() |