460 err = iClient->GetTransitionData( aHandle, transdata ); |
462 err = iClient->GetTransitionData( aHandle, transdata ); |
461 |
463 |
462 switch(aState) |
464 switch(aState) |
463 { |
465 { |
464 case EFallback: |
466 case EFallback: |
|
467 case EAbort: |
|
468 for(TInt i = 0 ; i < iControlEffects.Count(); i++ ) |
|
469 { |
|
470 // clear ongoing effect for this handle |
|
471 if( iControlEffects[i].iHandle == aHandle) |
|
472 { |
|
473 iControlEffects.Remove(i); |
|
474 i--; |
|
475 } |
|
476 } |
465 break; |
477 break; |
466 case EPreBeginCapture: |
478 case EPreBeginCapture: |
467 break; |
479 break; |
468 case EPostBeginCapture: |
480 case EPostBeginCapture: |
469 // Send control effect request to ALf. This is done immediately after call of |
481 // Send control effect request to ALf. This is done immediately after call of |
470 // GfxTransEffect::Begin(). This makes it possible (NOT QUARANTEENED) |
482 // GfxTransEffect::Begin(). This makes it possible (NOT QUARANTEENED) |
471 // that effect request arrives to Alf before possible visiblity changes are made to |
483 // that effect request arrives to Alf before possible visiblity changes are made to |
472 // the control. |
484 // the control. |
473 if ( iHasPlugin && aKey && aKey->DrawableWindow()) |
485 if (aKey && aKey->DrawableWindow() && err == KErrNone) |
474 { |
486 { |
475 // We must generate our own transition as we won't be sending |
487 TControlEffect newEffect; |
476 // iClient->TransitionFinished back. |
488 newEffect.iHandle = aHandle; |
477 // (Client did not ask for transition to be started, and won't be |
489 newEffect.iWindowGroup = aKey->DrawableWindow()->WindowGroupId(); |
478 // interested in the end.) |
490 newEffect.iWindowHandle =aKey->DrawableWindow()->ClientHandle(); |
479 TRAP( err, GenerateTransitionL( aKey, transdata ) ); |
491 iControlEffects.Append(newEffect); |
480 } |
492 } |
481 break; |
493 break; |
482 case EPreEndCapture: |
494 case EPreEndCapture: |
483 break; |
495 break; |
484 case EPostEndCapture: |
496 case EPostEndCapture: |
485 break; |
497 if (aKey && err == KErrNone) |
486 case EAbort: |
498 { |
487 // Abort component transition, handle given. |
499 TRAP( err, GenerateComponentTransitionEventL( transdata, MAlfGfxEffectPlugin::EBeginComponentTransition, aHandle ) ); |
|
500 } |
488 break; |
501 break; |
489 case EGlobalAbort: |
502 case EGlobalAbort: |
490 // abort component transition, no handle. |
503 // abort component transition, no handle. |
|
504 for(TInt i = 0 ; i < iControlEffects.Count(); i++ ) |
|
505 { |
|
506 // clear all on going effects |
|
507 iControlEffects.Remove(i); |
|
508 i--; |
|
509 } |
|
510 // TODO: send abort to server |
|
511 // TRAP( err, GenerateComponentTransitionEventL( transdata, MAlfGfxEffectPlugin::EAbortComponentTransition) ); |
|
512 |
491 break; |
513 break; |
492 case EBeginGroup: |
514 case EBeginGroup: |
493 { |
515 { |
494 __ALFFXLOGSTRING1("-- BeginGroup: New transition group for groupid: %d)",aHandle); |
516 __ALFFXLOGSTRING1("-- BeginGroup: New transition group for groupid: %d)",aHandle); |
495 SendGroupCommand(aHandle, EFalse); |
517 SendGroupCommand(aHandle, EFalse); |
496 break; |
518 break; |
497 } |
519 } |
498 case EEndGroup: |
520 case EEndGroup: |
499 { |
521 { |
500 __ALFFXLOGSTRING1("-- EndGroup: closing transition group: %d)",aHandle); |
522 __ALFFXLOGSTRING1("-- EndGroup: closing transition group: %d)",aHandle); |
501 SendGroupCommand(aHandle, ETrue); |
523 SendGroupCommand(aHandle, ETrue); |
502 break; |
524 break; |
503 } |
525 } |
504 default: |
526 default: |
505 break; |
527 break; |
506 } |
528 } |
775 TSecureId CGfxTransAdapterTfx::SecureIdFromAppUid( TUid aAppUid ) |
797 TSecureId CGfxTransAdapterTfx::SecureIdFromAppUid( TUid aAppUid ) |
776 { |
798 { |
777 TSecureId result(aAppUid); |
799 TSecureId result(aAppUid); |
778 if ( aAppUid == TUid::Null() ) |
800 if ( aAppUid == TUid::Null() ) |
779 { |
801 { |
|
802 iCachedUidMapping.iWindowGroupId = -1; |
780 return result; |
803 return result; |
781 } |
804 } |
782 |
805 |
783 TBool found = EFalse; |
806 __ALFFXLOGSTRING1("CGfxTransAdapterTfx::SecureIdFromAppUid Searching SID&WGID for aAppUid: 0x%x", aAppUid.iUid ); |
784 |
807 |
785 // first check the cache |
808 // first check the cache |
786 if ( iCachedUidMapping.iAppUid == aAppUid.iUid && iCachedUidMapping.iSecureId != 0 ) |
809 if ( iCachedUidMapping.iAppUid == aAppUid.iUid && iCachedUidMapping.iSecureId != 0 ) |
787 { |
810 { |
788 result = iCachedUidMapping.iSecureId; |
811 __ALFFXLOGSTRING2( "CGfxTransAdapterTfx::SecureIdFromAppUid using cached SID 0x%x and WGID: %d", |
789 found = ETrue; |
812 iCachedUidMapping.iSecureId, |
790 } |
813 iCachedUidMapping.iWindowGroupId ); |
|
814 return TSecureId(iCachedUidMapping.iSecureId); |
|
815 } |
|
816 |
|
817 TInt windowGroupId = -1; |
|
818 RProcess thisProcess; |
|
819 TUidType uidType = thisProcess.Type(); |
791 |
820 |
792 if ( !found ) |
821 if ( uidType.IsValid() ) |
793 { |
822 { |
794 // do the hard work |
823 bool thisApplication = false; |
795 // first check this process - this is quick |
824 if ( uidType[2] == aAppUid ) // 0 = UID1, 1 = UID2, 2 = UID3 |
796 // also, if this is the start-up effect on an application, the TApaTask is not yet updated with the |
825 { |
797 // window group created by this application (yet). |
826 // this application |
798 TInt windowGroupId = -1; |
827 result = thisProcess.SecureId(); |
799 RProcess thisProcess; |
828 thisApplication = ETrue; |
800 TUidType uidType = thisProcess.Type(); |
829 __ALFFXLOGSTRING2("CGfxTransAdapterTfx::SecureIdFromAppUid Own SID 0x%x in thread %S", |
801 if ( uidType.IsValid() ) |
830 result.iId, |
|
831 &RThread().Name() ); |
|
832 } |
|
833 |
|
834 CCoeEnv* env = CCoeEnv::Static(); |
|
835 RWsSession localSession; |
|
836 RWsSession* usedWsSession = NULL; |
|
837 if ( env ) |
802 { |
838 { |
803 if ( uidType[2] == aAppUid ) // 0 = UID1, 1 = UID2, 2 = UID3 |
839 usedWsSession = &env->WsSession(); |
804 { |
840 } |
805 result = thisProcess.SecureId(); |
841 else |
806 // take the window gruop ID as well if available |
842 { |
807 CCoeEnv* env = CCoeEnv::Static(); |
843 if ( localSession.Connect() == KErrNone ) |
808 if ( env ) |
844 { |
809 { |
845 usedWsSession = &localSession; |
810 windowGroupId = env->RootWin().Identifier(); |
|
811 } |
|
812 found = ETrue; |
|
813 } |
846 } |
814 } |
847 } |
815 thisProcess.Close(); |
848 |
816 |
849 // check if the AppArcServer has already information about this Application |
817 // If not this application, find UID using the TApaTask |
850 if ( usedWsSession ) |
818 if ( !found ) |
|
819 { |
851 { |
820 TApaTaskList taskList( CCoeEnv::Static()->WsSession() ); |
852 TApaTaskList taskList( *usedWsSession ); |
821 const TApaTask task = taskList.FindApp( aAppUid ); |
853 const TApaTask task = taskList.FindApp( aAppUid ); |
822 const TThreadId threadId = task.ThreadId(); |
854 const TThreadId otherThreadId = task.ThreadId(); |
823 RThread otherThread; |
855 |
824 if ( otherThread.Open( threadId ) == KErrNone ) // ignore error |
856 if ( thisApplication ) |
825 { |
857 { |
826 result = otherThread.SecureId(); |
858 // if security ID of the other thread matched, we take the WG ID from AppArcServer |
827 windowGroupId = task.WgId(); // take it for free at this point. |
859 RThread otherThread; |
828 found = ETrue; |
860 if ( otherThread.Open( otherThreadId ) == KErrNone ) |
829 } |
|
830 otherThread.Close(); |
|
831 } |
|
832 |
|
833 if ( found ) |
|
834 { |
|
835 // update cache |
|
836 if ( iCachedUidMapping.iAppUid == aAppUid.iUid ) |
|
837 { |
|
838 // found the missing secure ID |
|
839 iCachedUidMapping.iSecureId = result.iId; |
|
840 |
|
841 if ( windowGroupId > 0 ) |
|
842 { |
861 { |
843 // if we got the window group ID, update that as well to the cache |
862 __ALFFXLOGSTRING1("CGfxTransAdapterTfx::SecureIdFromAppUid Exising TApaTask found using thread %S", &otherThread.Name() ); |
844 iCachedUidMapping.iWindowGroupId = windowGroupId; |
863 if ( otherThread.SecureId() == result ) |
|
864 { |
|
865 windowGroupId = task.WgId(); |
|
866 __ALFFXLOGSTRING1("CGfxTransAdapterTfx::SecureIdFromAppUid SID match -> WGID : &d found from TApaTask", windowGroupId ); |
|
867 } |
|
868 else |
|
869 { |
|
870 __ALFFXLOGSTRING2("CGfxTransAdapterTfx::SecureIdFromAppUid otherSID 0x%x otherWGID : &d not matching in TApaTask", otherThread.SecureId().iId , task.WgId() ); |
|
871 } |
|
872 } |
|
873 otherThread.Close(); |
|
874 |
|
875 if ( windowGroupId == -1 && env ) |
|
876 { |
|
877 // take the root WG ID |
|
878 windowGroupId = env->RootWin().Identifier(); |
|
879 __ALFFXLOGSTRING1("CGfxTransAdapterTfx::SecureIdFromAppUid root WGID %d used", windowGroupId ); |
845 } |
880 } |
846 } |
881 } |
847 else |
882 else |
848 { |
883 { |
849 iCachedUidMapping.iAppUid = aAppUid.iUid; |
884 RThread otherThread; |
850 iCachedUidMapping.iSecureId = result.iId; |
885 if ( otherThread.Open( otherThreadId ) == KErrNone ) |
851 // wgid might not be updated at this point. |
886 { |
852 iCachedUidMapping.iWindowGroupId = Max(windowGroupId,0); // might be -1 -> treat 0 and -1 is just 0 |
887 result = otherThread.SecureId(); |
|
888 windowGroupId = task.WgId(); |
|
889 __ALFFXLOGSTRING3("CGfxTransAdapterTfx::SecureIdFromAppUid Taking SID 0x%x WGID %d from thread %S via TApaTask", result.iId, windowGroupId, &otherThread.Name() ); |
|
890 } |
|
891 otherThread.Close(); |
853 } |
892 } |
854 } |
893 } |
855 } |
894 |
|
895 localSession.Close(); |
|
896 } |
|
897 thisProcess.Close(); |
856 |
898 |
857 if ( !found ) |
899 if ( windowGroupId != -1 ) |
858 { |
900 { |
859 __ALFFXLOGSTRING1( "CGfxTransAdapterTfx::SecureIdFromAppUid AppUid 0x%x not found (yet)", aAppUid.iUid ); |
901 // update cache |
860 } |
902 iCachedUidMapping.iAppUid = aAppUid.iUid; |
861 else if ( aAppUid.iUid != result.iId ) |
903 iCachedUidMapping.iSecureId = result; |
862 { |
904 iCachedUidMapping.iWindowGroupId = windowGroupId; |
863 __ALFFXLOGSTRING2( "CGfxTransAdapterTfx::SecureIdFromAppUid SecureID 0x%x differs form AppUid 0x%x", result.iId, aAppUid.iUid ); |
|
864 } |
905 } |
865 |
906 |
866 return result; |
907 return result; |
867 } |
908 } |
868 |
909 |
870 // GfxTransEffect::WindowGroupIdFromAppUid |
911 // GfxTransEffect::WindowGroupIdFromAppUid |
871 // --------------------------------------------------------------------------- |
912 // --------------------------------------------------------------------------- |
872 // |
913 // |
873 TInt32 CGfxTransAdapterTfx::WindowGroupIdFromAppUid( TUid aAppUid ) |
914 TInt32 CGfxTransAdapterTfx::WindowGroupIdFromAppUid( TUid aAppUid ) |
874 { |
915 { |
875 if ( aAppUid == TUid::Null() ) |
916 TInt32 result = 0; |
876 { |
917 if ( iCachedUidMapping.iAppUid == aAppUid.iUid ) |
877 return 0; |
918 { |
878 } |
919 result = iCachedUidMapping.iWindowGroupId; |
879 |
920 } |
880 TInt result = 0; |
921 iCachedUidMapping.iSecureId = 0; |
881 TBool found = EFalse; |
922 return result; |
882 |
|
883 // check the cache. most likely this is already up-to-date due the previous execution of SecureIdFromAppUid |
|
884 if ( iCachedUidMapping.iAppUid == aAppUid.iUid ) |
|
885 { |
|
886 if ( iCachedUidMapping.iWindowGroupId > 0 ) |
|
887 { |
|
888 result = iCachedUidMapping.iWindowGroupId; |
|
889 iCachedUidMapping.iSecureId = 0; |
|
890 found = true; |
|
891 } |
|
892 } |
|
893 |
|
894 if ( !found ) |
|
895 { |
|
896 // do the hard work |
|
897 TApaTaskList taskList( CCoeEnv::Static()->WsSession() ); |
|
898 const TApaTask task = taskList.FindApp( aAppUid ); |
|
899 result = TInt32(task.WgId()); |
|
900 |
|
901 if ( result > 0 ) |
|
902 { |
|
903 // update cache |
|
904 found = ETrue; |
|
905 if ( iCachedUidMapping.iAppUid != aAppUid.iUid ) |
|
906 { |
|
907 iCachedUidMapping.iAppUid = aAppUid.iUid; |
|
908 iCachedUidMapping.iSecureId = 0; |
|
909 } |
|
910 iCachedUidMapping.iWindowGroupId = result; |
|
911 } |
|
912 else |
|
913 { |
|
914 result = 0; // might be -1 -> treat 0 and -1 is just 0 |
|
915 } |
|
916 } |
|
917 |
|
918 if ( !found ) |
|
919 { |
|
920 __ALFFXLOGSTRING1( "CGfxTransAdapterTfx::WindowGroupIdFromAppUid AppUid 0x%x not found (yet)", aAppUid.iUid ); |
|
921 } |
|
922 |
|
923 return TInt32(result); |
|
924 } |
923 } |
925 |
924 |
926 |
925 |
927 // --------------------------------------------------------------------------- |
926 // --------------------------------------------------------------------------- |
928 // GfxTransEffect::BeginFullscreen gets passed here. |
927 // GfxTransEffect::BeginFullscreen gets passed here. |
1262 iCurrHandle = 0; |
1261 iCurrHandle = 0; |
1263 */ |
1262 */ |
1264 __ALFFXLOGSTRING("CGfxTransAdapterTfx::DoStartTransitionL <<"); |
1263 __ALFFXLOGSTRING("CGfxTransAdapterTfx::DoStartTransitionL <<"); |
1265 } |
1264 } |
1266 |
1265 |
1267 void CGfxTransAdapterTfx::GenerateTransitionL( const CCoeControl* aKey, const CTransitionData* aTransData) |
1266 void CGfxTransAdapterTfx::GenerateComponentTransitionEventL(const CTransitionData* aTransData, TInt aOp, TInt aHandle) |
1268 { |
1267 { |
1269 |
1268 |
1270 // We generate a transition call from begin capture for control exit transitions |
1269 // We generate a transition call from begin capture for control exit transitions |
1271 TPtr8 inPtr = iTransferBuffer->Des(); |
1270 TPtr8 inPtr = iTransferBuffer->Des(); |
1272 inPtr.Zero(); |
1271 inPtr.Zero(); |
1273 TPtr8 outPtr = iReturnBuffer->Des(); |
1272 TPtr8 outPtr = iReturnBuffer->Des(); |
1274 outPtr.Zero(); |
1273 outPtr.Zero(); |
1275 RDesWriteStream inBuf( inPtr ); |
1274 RDesWriteStream inBuf( inPtr ); |
1276 TInt op = MAlfGfxEffectPlugin::EBeginComponentTransition; |
1275 TInt op = aOp; |
1277 TInt windowGroup = aKey->DrawableWindow()->WindowGroupId(); |
|
1278 TInt windowHandle = aKey->DrawableWindow()->ClientHandle(); |
|
1279 |
1276 |
1280 __ALFFXLOGSTRING4("CGfxTransAdapterTfx::GenerateTransitionL - Operation: MAlfGfxEffectPlugin::EBeginComponentTransition Action: %d, Uid: 0x%x, WindowGroup: %d, WindowHandle: %d >>", |
1277 TInt windowGroup = KErrNotFound; |
|
1278 TInt windowHandle = KErrNotFound; |
|
1279 if( aHandle != KErrNotFound ) |
|
1280 { |
|
1281 for(TInt i = 0 ; i < iControlEffects.Count(); i++ ) |
|
1282 { |
|
1283 // we take the last one. to make hopefully clean up any earlier effect that was not finished for some reason. |
|
1284 if( iControlEffects[i].iHandle == aHandle) |
|
1285 { |
|
1286 windowGroup = iControlEffects[i].iWindowGroup; |
|
1287 windowHandle = iControlEffects[i].iWindowHandle; |
|
1288 iControlEffects.Remove(i); |
|
1289 i--; |
|
1290 } |
|
1291 } |
|
1292 } |
|
1293 if(aHandle != KErrNotFound && (windowGroup == KErrNotFound || windowHandle == KErrNotFound)) |
|
1294 { |
|
1295 return; |
|
1296 } |
|
1297 |
|
1298 __ALFFXLOGSTRING1("CGfxTransAdapterTfx::GenerateComponentTransitionEventL - Operation: %d", op ); |
|
1299 |
|
1300 __ALFFXLOGSTRING4("CGfxTransAdapterTfx::GenerateComponentTransitionEventL - Action: %d, Uid: 0x%x, WindowGroup: %d, WindowHandle: %d >>", |
1281 aTransData->iAction, |
1301 aTransData->iAction, |
1282 aTransData->iUid.iUid, |
1302 aTransData->iUid.iUid, |
1283 windowGroup, |
1303 windowGroup, |
1284 windowHandle |
1304 windowHandle |
1285 ); |
1305 ); |