sysstatemgmt/systemstatereferenceplugins/custcmd/src/ssmuiproviderdlldefault.cpp
branchRCL_3
changeset 10 1fc153c72b60
parent 0 4e1aa6a622a0
child 41 c87e5f80c17d
equal deleted inserted replaced
8:6bb05bdcbe09 10:1fc153c72b60
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-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".
    19 */
    19 */
    20 
    20 
    21 #include "ssmuiproviderdll.h"
    21 #include "ssmuiproviderdll.h"
    22 #include "ssmpanic.h"
    22 #include "ssmpanic.h"
    23 #include <e32property.h>
    23 #include <e32property.h>
    24 #include <f32file.h>
    24 #include "ssmdebug.h"
    25 
    25 
    26 const TUid KPSStartupUid = {0x2000E65E};
    26 const TUid KPSStartupUid = {0x2000E65E};
    27 const TUid KSecurityPinNotifierUid = {0x2000E667};
    27 const TUid KSecurityPinNotifierUid = {0x2000E667};
    28 const TUid KScreenOutputChannel = {0x10009D48};
    28 const TUid KScreenOutputChannel = {0x10009D48};
    29 const TUid KEmergencyCallPropertyCategory = {0x2001032C};
    29 const TUid KEmergencyCallPropertyCategory = {0x2001032C};
    35 
    35 
    36 const TUid KRFStatusPropertyCategory = {0x2000D75B};
    36 const TUid KRFStatusPropertyCategory = {0x2000D75B};
    37 const TUint KRFStatusPropertyKey = 0x2001D2A9;
    37 const TUint KRFStatusPropertyKey = 0x2001D2A9;
    38 const TUid KValidateRTCPropertyCategory = {0x2000D75B};
    38 const TUid KValidateRTCPropertyCategory = {0x2000D75B};
    39 const TUint KValidateRTCPropertyKey = 0x2001D2AB;
    39 const TUint KValidateRTCPropertyKey = 0x2001D2AB;
       
    40 //Number of clusterSize to be reserve for phone memory space 
       
    41 const TInt KNumberOfCluster = 2;
    40 
    42 
    41 _LIT(KTsyModuleName, "mm.tsy");
    43 _LIT(KTsyModuleName, "mm.tsy");
    42 _LIT(KTsyPhoneName, "GsmPhone1");
    44 _LIT(KTsyPhoneName, "GsmPhone1");
    43 
    45 
    44 CSsmUiSpecific::CSsmUiSpecific()
    46 CSsmUiSpecific::CSsmUiSpecific()
    45 : iReferenceCount(1)
    47 : iReferenceCount(1), iReservedPhoneMemory(0)
    46 	{
    48 	{
    47 	}
    49 	}
    48 
    50 
    49 EXPORT_C CSsmUiSpecific::~CSsmUiSpecific()
    51 EXPORT_C CSsmUiSpecific::~CSsmUiSpecific()
    50 	{
    52 	{
       
    53 	iReservedPhoneMemoryFs.Close();
    51 	}
    54 	}
    52 
    55 
    53 EXPORT_C TUid CSsmUiSpecific::StartupPSUid()
    56 EXPORT_C TUid CSsmUiSpecific::StartupPSUid()
    54 	{
    57 	{
    55 	return KPSStartupUid;
    58 	return KPSStartupUid;
    93 	if (NULL == Dll::Tls())
    96 	if (NULL == Dll::Tls())
    94 		{
    97 		{
    95 		//Instantiate CSsmUiSpecific if TLS is null
    98 		//Instantiate CSsmUiSpecific if TLS is null
    96 		self = new (ELeave) CSsmUiSpecific();
    99 		self = new (ELeave) CSsmUiSpecific();
    97 		CleanupStack::PushL(self);
   100 		CleanupStack::PushL(self);
    98 		
   101 		self->ConstructL();
    99 		//Copy CSsmUiSpecific pointer in TLS
   102 		//Copy CSsmUiSpecific pointer in TLS
   100 		User::LeaveIfError(Dll::SetTls(self));
   103 		User::LeaveIfError(Dll::SetTls(self));
   101 		CleanupStack::Pop(self);
   104 		CleanupStack::Pop(self);
   102 		}
   105 		}
   103 	else
   106 	else
   201 EXPORT_C TInt CSsmUiSpecific::PhoneMemoryRootDriveId()
   204 EXPORT_C TInt CSsmUiSpecific::PhoneMemoryRootDriveId()
   202 	{
   205 	{
   203 	return EDriveC;
   206 	return EDriveC;
   204 	}
   207 	}
   205 
   208 
       
   209 /**
       
   210 Leaving construction inside ConstructL
       
   211 */
       
   212 void CSsmUiSpecific::ConstructL()
       
   213 	{
       
   214 	User::LeaveIfError( iReservedPhoneMemoryFs.Connect() );
       
   215 	}
       
   216 
       
   217 /**
       
   218 Reserve two ClusterSize in Phone Memory Space on H/W
       
   219 and 512 bytes for __WINS__
       
   220 @return KErrNone if successful or systemwide error
       
   221 */
       
   222 EXPORT_C TInt CSsmUiSpecific::ReservePhoneMemorySpace()
       
   223     {
       
   224 	TVolumeIOParamInfo volumeParamInfo; 
       
   225 	const TInt phoneMemoryDriveID = PhoneMemoryRootDriveId();
       
   226 	TInt errorCode = iReservedPhoneMemoryFs.VolumeIOParam(phoneMemoryDriveID, volumeParamInfo); 
       
   227 	if( KErrNone == errorCode )
       
   228 		{
       
   229 #ifdef __WINS__
       
   230 		//512 bytes for __WINS__
       
   231 		const TInt reservedMemory = 512;
       
   232 #else
       
   233 		//Reserving two clusterSize Phone memory 
       
   234 		const TInt reservedMemory = KNumberOfCluster * (volumeParamInfo.iClusterSize);
       
   235 #endif //__WINS__
       
   236 		errorCode = iReservedPhoneMemoryFs.ReserveDriveSpace(phoneMemoryDriveID, reservedMemory);
       
   237 
       
   238 		if ( KErrNone == errorCode )
       
   239 			{
       
   240 			iReservedPhoneMemory = reservedMemory;
       
   241 			}
       
   242 		}
       
   243     return errorCode;
       
   244     }
       
   245 
       
   246 /**
       
   247 Free reserved bytes from Phone Memory Space. If aSpaceToFree is 0 bytes 
       
   248 then free complete reserved memory
       
   249 @param aSpaceToFree request to free memory
       
   250 @return KErrNone if successful or systemwide error
       
   251 */
       
   252 EXPORT_C TInt CSsmUiSpecific::FreeReservedPhoneMemorySpace(const TInt aSpaceToFree)
       
   253     {
       
   254     TInt errorCode(KErrGeneral);
       
   255 	DEBUGPRINT3A("Reserved memory is = %d bytes, Request to free memory is = %d bytes", iReservedPhoneMemory, aSpaceToFree);
       
   256     if(0 < iReservedPhoneMemory)
       
   257         {
       
   258 		if(0 == aSpaceToFree)
       
   259 		    {
       
   260 		   	//Free complete reserved phone memory
       
   261 			errorCode = iReservedPhoneMemoryFs.ReserveDriveSpace( PhoneMemoryRootDriveId(), 0 );
       
   262 			DEBUGPRINT2A("Freeing memory completed with = %d", errorCode);
       
   263 			iReservedPhoneMemory = 0; 
       
   264 		    }
       
   265 		else
       
   266 		    {
       
   267 		    TInt newReserveSize = iReservedPhoneMemory - aSpaceToFree;
       
   268 		    newReserveSize = newReserveSize >= 0 ? newReserveSize : 0;
       
   269 		    errorCode = iReservedPhoneMemoryFs.ReserveDriveSpace( PhoneMemoryRootDriveId(), newReserveSize );
       
   270 			DEBUGPRINT2A("Freeing partial phone memory completed with = %d", errorCode);
       
   271 		    if(KErrNone == errorCode)
       
   272 			    {
       
   273 			    iReservedPhoneMemory = newReserveSize;
       
   274 			    }
       
   275 		    }
       
   276     	}
       
   277     return errorCode;
       
   278     }