1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
21 #include "surfaceupdate.h" |
21 #include "surfaceupdate.h" |
22 #include "suerror.h" |
22 #include "suerror.h" |
23 #ifdef TEST_SURFACE_UPDATE |
23 #ifdef TEST_SURFACE_UPDATE |
24 #include "surfaceupdatetest.h" |
24 #include "surfaceupdatetest.h" |
25 #endif |
25 #endif |
26 #include <e32atomics.h> |
|
27 |
26 |
28 |
27 |
29 const TUint KDefaultHeapSize=0x10000; |
28 const TUint KDefaultHeapSize=0x10000; |
30 |
29 |
31 void *gProvider = NULL; |
30 void *gProvider = NULL; |
884 (static_cast<CSurfaceUpdateServer*> (server))-> iNumberPendingNotification++; |
883 (static_cast<CSurfaceUpdateServer*> (server))-> iNumberPendingNotification++; |
885 } |
884 } |
886 } |
885 } |
887 #endif |
886 #endif |
888 |
887 |
|
888 |
|
889 /** |
|
890 Set number of UpdateReceivers - called when update receivers are added/removed. |
|
891 |
|
892 @param aNumUpdateReceivers - new number of update receivers for the batch. |
|
893 */ |
889 void CUpdateReceiverNotificationBatch::SetNumUpdateReceivers(TInt aNumUpdateReceivers) |
894 void CUpdateReceiverNotificationBatch::SetNumUpdateReceivers(TInt aNumUpdateReceivers) |
890 { |
895 { |
891 __ASSERT_DEBUG(iType == EUpdateSrvReusable, CSurfaceUpdateServer::PanicServer(EUpdateServPanicDataIntegrity)); |
896 __ASSERT_DEBUG(aNumUpdateReceivers >= 0 && aNumUpdateReceivers < 1000 /* arbitrary "large" limit */, |
|
897 CSurfaceUpdateServer::PanicServer(EUpdateServPanicDataIntegrity)); |
|
898 __ASSERT_DEBUG(iType == EUpdateSrvReusable, |
|
899 CSurfaceUpdateServer::PanicServer(EUpdateServPanicDataIntegrity)); |
892 iNumUpdateReceivers = aNumUpdateReceivers; |
900 iNumUpdateReceivers = aNumUpdateReceivers; |
893 } |
901 } |
894 /** |
902 /** |
895 |
903 |
896 The class will be used by composition receiver |
904 The class will be used by composition receiver |
962 RThread thread; |
970 RThread thread; |
963 |
971 |
964 if(thread.Open(iThreadId) == KErrNone) |
972 if(thread.Open(iThreadId) == KErrNone) |
965 { |
973 { |
966 TInt err = gProviderFastLock.CreateLocal(); |
974 TInt err = gProviderFastLock.CreateLocal(); |
967 //ignore error on double create. |
975 __ASSERT_ALWAYS(err == KErrNone || err == KErrAlreadyExists, CSurfaceUpdateServer::PanicServer(EUpdateServPanicGlobalFastLock)); |
|
976 |
968 gProviderFastLock.Wait(); |
977 gProviderFastLock.Wait(); |
969 gProvider = NULL; |
978 gProvider = NULL; |
970 if (iServer) |
979 if (iServer) |
971 { |
980 { |
972 while((static_cast<CSurfaceUpdateServer*> (iServer))-> iNumberPendingNotification) |
981 while((static_cast<CSurfaceUpdateServer*> (iServer))-> iNumberPendingNotification) |
1024 which will be set when the server is started. The variable will be used to registry |
1033 which will be set when the server is started. The variable will be used to registry |
1025 composition receiver instances. The caller doesn't acquire the ownership of this instance, |
1034 composition receiver instances. The caller doesn't acquire the ownership of this instance, |
1026 thus mustn't delete it. The pointer will be valid until server is operating, |
1035 thus mustn't delete it. The pointer will be valid until server is operating, |
1027 i.e. system is up. |
1036 i.e. system is up. |
1028 |
1037 |
1029 @panic KErrAccessDenied If is called from process other than WSERV. |
|
1030 @return KErrNone if an operation is successful, any other system error codes otherwise |
1038 @return KErrNone if an operation is successful, any other system error codes otherwise |
1031 */ |
1039 */ |
1032 EXPORT_C TInt StartSurfaceUpdateServer(MSurfaceUpdateServerProvider*& aSurfaceUpdateServerProvider) |
1040 EXPORT_C TInt StartSurfaceUpdateServer(MSurfaceUpdateServerProvider*& aSurfaceUpdateServerProvider) |
1033 { |
1041 { |
1034 #ifndef TEST_SURFACE_UPDATE |
1042 #ifndef TEST_SURFACE_UPDATE |
1035 RProcess process; |
|
1036 TUidType uidType = process.Type(); |
|
1037 const TInt32 KWservUid = 268450592; |
|
1038 const TUid& uid1 = uidType[2]; |
|
1039 |
|
1040 if(uid1.iUid != KWservUid) //only wserv process can start the server |
|
1041 {// some malicious client tries to launch the server |
|
1042 process.Panic(_L("Access denied"), KErrAccessDenied); |
|
1043 return KErrAccessDenied; |
|
1044 } |
|
1045 TPtrC serverName(KSurfaceUpdateServerName); |
1043 TPtrC serverName(KSurfaceUpdateServerName); |
1046 #else |
1044 #else |
1047 TPtrC serverName(KTestSurfaceUpdateServerName); |
1045 TPtrC serverName(KTestSurfaceUpdateServerName); |
1048 #endif |
1046 #endif |
1049 //locking |
1047 //locking |