--- a/cmmanager/cmmgr/cmmserver/src/cmmsession.cpp Thu Jun 17 22:32:02 2010 +0100
+++ b/cmmanager/cmmgr/cmmserver/src/cmmsession.cpp Thu Jul 22 16:37:38 2010 +0100
@@ -16,7 +16,7 @@
*
*/
-
+#include <sysutil.h>
#include <cmconnectionmethoddef.h>
#include <cmpluginembdestinationdef.h>
#include <cmdefconnvalues.h>
@@ -63,7 +63,8 @@
CCmmSession::CCmmSession( CCmmServer& aServer, CCmmCache& aCache )
:
iServer( aServer ),
- iCache( aCache )
+ iCache( aCache ),
+ iFsConnected( EFalse )
{
OstTraceFunctionEntry0( CCMMSESSION_CCMMSESSION_ENTRY );
@@ -128,6 +129,13 @@
iServer.RemoveContainer( iConnMethodContainer );
iConnMethodContainer = NULL;
}
+
+ if ( iFsConnected )
+ {
+ iFs.Close();
+ iFsConnected = EFalse;
+ }
+
OstTraceFunctionExit0( DUP1_CCMMSESSION_CCMMSESSION_EXIT );
}
@@ -207,6 +215,11 @@
GetSupportedBearersL( aMessage );
}
break;
+ case ECmmGetUncategorizedIcon:
+ {
+ GetUncategorizedIconL( aMessage );
+ }
+ break;
case ECmmReadDefaultConnection:
{
ReadDefaultConnectionL( aMessage );
@@ -269,6 +282,7 @@
case EDestIsConnected:
case EDestIsHidden:
case EDestIsEqual:
+ case EDestGetIcon:
case EDestAddConnMethod:
case EDestAddEmbeddedDestination:
case EDestDeleteConnMethod:
@@ -280,6 +294,7 @@
case EDestSetHidden:
case EDestUpdate:
case EDestDelete:
+ case EDestSetIcon:
{
ServiceDestinationL( aMessage );
}
@@ -329,7 +344,7 @@
// -----------------------------------------------------------------------------
//
CCmmConnMethodInstance* CCmmSession::FindConnMethodInstanceById(
- const TUint32& aConnMethodId )
+ const TUint32 aConnMethodId )
{
OstTraceFunctionEntry0( CCMMSESSION_FINDCONNMETHODINSTANCEBYID_ENTRY );
@@ -356,7 +371,7 @@
// -----------------------------------------------------------------------------
//
CCmmDestinationInstance* CCmmSession::FindDestinationInstanceByHandleL(
- const TInt& aDestinationHandle )
+ const TInt aDestinationHandle )
{
OstTraceFunctionEntry0( CCMMSESSION_FINDDESTINATIONINSTANCEBYHANDLEL_ENTRY );
@@ -369,7 +384,7 @@
// -----------------------------------------------------------------------------
//
CCmmDestinationInstance* CCmmSession::FindDestinationInstanceById(
- const TUint32& aDestinationId )
+ const TUint32 aDestinationId )
{
OstTraceFunctionEntry0( CCMMSESSION_FINDDESTINATIONINSTANCEBYID_ENTRY );
@@ -396,8 +411,8 @@
// -----------------------------------------------------------------------------
//
TBool CCmmSession::ConnMethodInOtherDestination(
- const TUint32& aConnMethodId,
- const TUint32& aDestinationId )
+ const TUint32 aConnMethodId,
+ const TUint32 aDestinationId )
{
OstTraceFunctionEntry0( CCMMSESSION_CONNMETHODINOTHERDESTINATION_ENTRY );
@@ -432,12 +447,14 @@
// -----------------------------------------------------------------------------
//
TBool CCmmSession::EmbeddedDestinationConflictsFromAllSessions(
- const TUint32& aDestinationId,
- const TUint32& aEmbeddedDestinationId )
+ const TUint32 aDestinationId,
+ const TUint32 aEmbeddedDestinationId )
{
OstTraceFunctionEntry0( CCMMSESSION_EMBEDDEDDESTINATIONCONFLICTSFROMALLSESSIONS_ENTRY );
- return iServer.EmbeddedDestinationConflictsFromAllSessions( aDestinationId, aEmbeddedDestinationId );
+ return iServer.EmbeddedDestinationConflictsFromAllSessions(
+ aDestinationId,
+ aEmbeddedDestinationId );
}
// -----------------------------------------------------------------------------
@@ -455,8 +472,8 @@
// -----------------------------------------------------------------------------
//
TBool CCmmSession::EmbeddedDestinationConflicts(
- const TUint32& aDestinationId,
- const TUint32& aEmbeddedDestinationId )
+ const TUint32 aDestinationId,
+ const TUint32 aEmbeddedDestinationId )
{
OstTraceFunctionEntry0( CCMMSESSION_EMBEDDEDDESTINATIONCONFLICTS_ENTRY );
@@ -562,7 +579,7 @@
// ---------------------------------------------------------------------------
//
void CCmmSession::RemoveConnMethodFromDestinationHandles(
- const TUint32& aConnMethodId )
+ const TUint32 aConnMethodId )
{
OstTraceFunctionEntry0( CCMMSESSION_REMOVECONNMETHODFROMDESTINATIONHANDLES_ENTRY );
@@ -591,7 +608,7 @@
// updated/deleted destination/connection method.
// ---------------------------------------------------------------------------
//
-void CCmmSession::RefreshHandles( const TUint32& aId ) const
+void CCmmSession::RefreshHandles( const TUint32 aId ) const
{
OstTraceFunctionEntry0( CCMMSESSION_REFRESHHANDLES_ENTRY );
@@ -682,7 +699,7 @@
CleanupStack::PushL( result );
TInt bufferLen = aMessage.GetDesMaxLength( 2 );
- if ( result && result->Length() > bufferLen )
+ if ( result->Length() > bufferLen )
{
User::Leave( KErrArgument );
}
@@ -714,7 +731,7 @@
CleanupStack::PushL( result );
TInt bufferLen = aMessage.GetDesMaxLength( 2 );
- if ( result && result->Length() > bufferLen )
+ if ( result->Length() > bufferLen )
{
User::Leave( KErrArgument );
}
@@ -782,7 +799,7 @@
CleanupStack::PushL( result );
TInt bufferLen = aMessage.GetDesMaxLength( 2 );
- if ( result && result->Length() > bufferLen )
+ if ( result->Length() > bufferLen )
{
User::Leave( KErrArgument );
}
@@ -814,7 +831,7 @@
CleanupStack::PushL( result );
TInt bufferLen = aMessage.GetDesMaxLength( 2 );
- if ( result && result->Length() > bufferLen )
+ if ( result->Length() > bufferLen )
{
User::Leave( KErrArgument );
}
@@ -1017,6 +1034,29 @@
}
// -----------------------------------------------------------------------------
+// CCmmSession::GetUncategorizedIconL
+// -----------------------------------------------------------------------------
+//
+void CCmmSession::GetUncategorizedIconL( const RMessage2& aMessage )
+ {
+ OstTraceFunctionEntry0( CCMMSESSION_GETUNCATEGORIZEDICONL_ENTRY );
+
+ HBufC* result = KCmmUncategorizedIconName().AllocLC();
+
+ TInt bufferLen = aMessage.GetDesMaxLength( 0 );
+ if ( result->Length() > bufferLen )
+ {
+ User::Leave( KErrArgument );
+ }
+
+ TPtrC resultPtr = result->Des();
+ aMessage.WriteL( 0, resultPtr );
+ CleanupStack::PopAndDestroy( result );
+
+ OstTraceFunctionExit0( CCMMSESSION_GETUNCATEGORIZEDICONL_EXIT );
+ }
+
+// -----------------------------------------------------------------------------
// CCmmSession::ReadDefaultConnectionL
// -----------------------------------------------------------------------------
//
@@ -1103,7 +1143,8 @@
for ( TInt i = 0; i < bearerCountInArray; i++ )
{
// Skip if service type is not valid.
- if ( bearerPriorityArray[i]->ServiceType() && bearerPriorityArray[i]->ServiceType()->Length() > 0 )
+ if ( bearerPriorityArray[i]->ServiceType() &&
+ bearerPriorityArray[i]->ServiceType()->Length() > 0 )
{
maxBufLen += KCmmBearerPriorityHeaderLength; // Priorities and servicetype length.
maxBufLen += bearerPriorityArray[i]->ServiceType()->Length();
@@ -1141,7 +1182,8 @@
for ( TInt i = 0; i < bearerCountInArray; i++ )
{
// Skip if service type is not valid.
- if ( bearerPriorityArray[i]->ServiceType() && bearerPriorityArray[i]->ServiceType()->Length() > 0 )
+ if ( bearerPriorityArray[i]->ServiceType() &&
+ bearerPriorityArray[i]->ServiceType()->Length() > 0 )
{
TUint32 priority = bearerPriorityArray[i]->Priority();
TUint32 uiPriority = bearerPriorityArray[i]->UiPriority();
@@ -1173,6 +1215,12 @@
{
OstTraceFunctionEntry0( CCMMSESSION_UPDATEBEARERPRIORITYARRAYL_ENTRY );
+ // Check the disk space.
+ if ( CheckSpaceBelowCriticalLevelL() )
+ {
+ User::Leave( KErrDiskFull );
+ }
+
HBufC* bearerPriorityBuf = HBufC::NewLC( aMessage.GetDesMaxLengthL( 0 ) );
TPtr bearerPriorityBufPtr( bearerPriorityBuf->Des() );
@@ -1213,7 +1261,10 @@
position += stringLength;
TPtrC tempServiceType( serviceName->Des() );
- CCmmBearerPriority* item = CCmmBearerPriority::NewLC( tempServiceType, priority, uiPriority );
+ CCmmBearerPriority* item = CCmmBearerPriority::NewLC(
+ tempServiceType,
+ priority,
+ uiPriority );
bearerPriorityArray.AppendL( item );
CleanupStack::Pop( item );
@@ -1240,8 +1291,16 @@
{
OstTraceFunctionEntry0( CCMMSESSION_COPYCONNMETHODL_ENTRY );
- CCmmDestinationInstance* destination = ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int0() );
- CCmmConnMethodInstance* connMethod = ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int1() );
+ // Check the disk space.
+ if ( CheckSpaceBelowCriticalLevelL() )
+ {
+ User::Leave( KErrDiskFull );
+ }
+
+ CCmmDestinationInstance* destination =
+ ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int0() );
+ CCmmConnMethodInstance* connMethod =
+ ( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int1() );
// Can't add an embedded destination this way.
if ( connMethod->IsEmbeddedDestination() )
@@ -1249,7 +1308,20 @@
User::Leave( KErrArgument );
}
- //TODO, capability check, what to do if anything is protected.
+ // Check the protection level of the destination.
+ // And based on that check the needed capabilities from the client.
+ CMManager::TProtectionLevel protLevel( CMManager::EProtLevel0 );
+ destination->GetProtectionL( protLevel );
+ CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+ if ( protLevel == CMManager::EProtLevel1 )
+ {
+ capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+ }
+
+ if ( capabilities == CPolicyServer::EFail )
+ {
+ User::Leave( KErrPermissionDenied );
+ }
// Add connection method into destination.
TInt index = destination->AddConnMethodL( *connMethod );
@@ -1274,6 +1346,12 @@
{
OstTraceFunctionEntry0( CCMMSESSION_MOVECONNMETHODL_ENTRY );
+ // Check the disk space.
+ if ( CheckSpaceBelowCriticalLevelL() )
+ {
+ User::Leave( KErrDiskFull );
+ }
+
// Read data from client request.
TPckgBuf<TCmmIpcStructMoveConnMethod> attributesPckg;
aMessage.ReadL( 0, attributesPckg );
@@ -1313,7 +1391,38 @@
User::Leave( KErrInUse );
}
- //TODO, capability checks, what to do if anything is protected.
+ // Check the protection level of the source and target destination.
+ // And based on those check the needed capabilities from the client.
+ TBool protectionExists( EFalse );
+ CMManager::TProtectionLevel protLevelSource( CMManager::EProtLevel0 );
+ sourceDestination->GetProtectionL( protLevelSource );
+ if ( protLevelSource == CMManager::EProtLevel1
+ || protLevelSource == CMManager::EProtLevel3 )
+ {
+ protectionExists = ETrue;
+ }
+
+ // If source destination is not protected check the target destination.
+ if ( !protectionExists )
+ {
+ CMManager::TProtectionLevel protLevelTarget( CMManager::EProtLevel0 );
+ targetDestination->GetProtectionL( protLevelTarget );
+ if ( protLevelTarget == CMManager::EProtLevel1 )
+ {
+ protectionExists = ETrue;
+ }
+ }
+
+ CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+ if ( protectionExists )
+ {
+ capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+ }
+
+ if ( capabilities == CPolicyServer::EFail )
+ {
+ User::Leave( KErrPermissionDenied );
+ }
// Add connection method into target destination and update it.
attributesPckg().iIndex = targetDestination->AddConnMethodL( *connMethod );
@@ -1343,7 +1452,20 @@
CCmmConnMethodInstance* connMethodInstance =
( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int1() );
- //TODO, capability checks
+ // Check the protection level of the destination.
+ // And based on that check the needed capabilities from the client.
+ CMManager::TProtectionLevel protLevel( CMManager::EProtLevel0 );
+ destinationInstance->GetProtectionL( protLevel );
+ CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+ if ( protLevel == CMManager::EProtLevel1 || protLevel == CMManager::EProtLevel3 )
+ {
+ capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+ }
+
+ if ( capabilities == CPolicyServer::EFail )
+ {
+ User::Leave( KErrPermissionDenied );
+ }
destinationInstance->RemoveConnMethodFromDestinationL( *connMethodInstance );
destinationInstance->UpdateL();
@@ -1363,6 +1485,20 @@
CCmmConnMethodInstance* connMethodInstance =
( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int0() );
+ TBool capabilityCheckNeeded( EFalse );
+ iCache.CheckIfConnMethodBelongsToProtectedDestinationL(
+ *connMethodInstance,
+ capabilityCheckNeeded );
+ if ( capabilityCheckNeeded )
+ {
+ CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+ capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+ if ( capabilities == CPolicyServer::EFail )
+ {
+ User::Leave( KErrPermissionDenied );
+ }
+ }
+
iCache.CheckIfConnMethodReferencesCanBeRemovedL( *connMethodInstance );
iCache.RemoveAllReferencesToConnMethodL( *connMethodInstance );
@@ -1454,6 +1590,11 @@
DestinationIsEqualL( aMessage );
}
break;
+ case EDestGetIcon:
+ {
+ GetDestinationIconL( aMessage );
+ }
+ break;
case EDestAddConnMethod:
{
DestAddConnMethodL( aMessage );
@@ -1509,6 +1650,11 @@
DeleteDestinationL( aMessage );
}
break;
+ case EDestSetIcon:
+ {
+ SetDestinationIconL( aMessage );
+ }
+ break;
default:
{
User::Leave( KErrNotSupported );
@@ -1685,10 +1831,12 @@
}
// Check if a destination with given ID exists (or is already created but not saved).
- if ( iCache.DestinationExistsWithId( destinationId ) ||
- iCache.DestinationOpenWithId( destinationId ) )
+ //TODO, Implement one single method for this check in CCmmCache-class, and call that. CCmmCache::DestinationOpenWithId() can be removed after that.
+ if ( iCache.DestinationExistsWithId( destinationId ) || iCache.DestinationOpenWithId( destinationId ) )
{
User::Leave( KErrAlreadyExists );
+ //TODO: Destination ID is decided based on network record ID. Connection methods also use network records.
+ //TODO: Add a check here too see that the necessary network record ID is also available.
}
// Load and check name.
@@ -1804,12 +1952,19 @@
User::LeaveIfError( index );
// Check if the connection method is an embedded destination.
- if ( connMethodInstance->GetBearerType() == KUidEmbeddedDestination )
+ if ( connMethodInstance->IsEmbeddedDestination() )
{
index = CMManager::KDataMobilitySelectionPolicyPriorityWildCard;
}
- //TODO, what if CM is virtual?
+ // If this is a virtual IAP that doesn't link to an IAP, the priority is wildcard.
+ else if ( connMethodInstance->GetBoolAttributeL( CMManager::ECmVirtual ) )
+ {
+ if ( connMethodInstance->GetIntAttributeL( CMManager::ECmNextLayerIapId ) == 0 )
+ {
+ index = CMManager::KDataMobilitySelectionPolicyPriorityWildCard;
+ }
+ }
TUint priority = ( TUint )index;
TPckg<TUint> priorityPckg( priority );
@@ -1847,6 +2002,33 @@
}
// -----------------------------------------------------------------------------
+// CCmmSession::GetDestinationIconL
+// -----------------------------------------------------------------------------
+//
+void CCmmSession::GetDestinationIconL( const RMessage2& aMessage )
+ {
+ OstTraceFunctionEntry0( CCMMSESSION_GETDESTINATIONICONL_ENTRY );
+
+ CCmmDestinationInstance* destinationInstance =
+ ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() );
+
+ HBufC* icon = destinationInstance->GetDestinationIconL();
+ CleanupStack::PushL( icon );
+ TPtrC iconPtr( icon->Des() );
+
+ TInt bufferLen = aMessage.GetDesMaxLength( 0 );
+ if ( iconPtr.Length() > bufferLen )
+ {
+ User::Leave( KErrArgument );
+ }
+
+ aMessage.WriteL( 0, iconPtr );
+ CleanupStack::PopAndDestroy( icon );
+
+ OstTraceFunctionExit0( CCMMSESSION_GETDESTINATIONICONL_EXIT );
+ }
+
+// -----------------------------------------------------------------------------
// CCmmSession::GetDestinationIdL
// -----------------------------------------------------------------------------
//
@@ -2012,6 +2194,20 @@
CCmmDestinationInstance* destination =
( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() );
+
+ // Check the protection and if protected check the needed capabilities.
+ CMManager::TProtectionLevel protLevel =
+ destination->CurrentProtectionLevelL();
+ if ( protLevel == CMManager::EProtLevel1 )
+ {
+ CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+ capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+ if ( capabilities == CPolicyServer::EFail )
+ {
+ User::Leave( KErrPermissionDenied );
+ }
+ }
+
CCmmConnMethodInstance* connMethod =
( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int0() );
@@ -2035,12 +2231,26 @@
{
OstTraceFunctionEntry0( CCMMSESSION_DESTADDEMBEDDEDDESTINATIONL_ENTRY );
- CCmmDestinationInstance* destination =
+ CCmmDestinationInstance* destinationInstance =
( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() );
+
+ // Check the protection and if protected check the needed capabilities.
+ CMManager::TProtectionLevel protLevel =
+ destinationInstance->CurrentProtectionLevelL();
+ if ( protLevel == CMManager::EProtLevel1 )
+ {
+ CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+ capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+ if ( capabilities == CPolicyServer::EFail )
+ {
+ User::Leave( KErrPermissionDenied );
+ }
+ }
+
CCmmDestinationInstance* embeddedDestination =
( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int0() );
- TInt index = destination->AddEmbeddedDestinationL( *embeddedDestination );
+ TInt index = destinationInstance->AddEmbeddedDestinationL( *embeddedDestination );
TPckg<TInt> indexPckg( index );
aMessage.WriteL( 1, indexPckg );
@@ -2059,8 +2269,25 @@
( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() );
CCmmConnMethodInstance* connMethodInstance =
( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int0() );
-
- //TODO, capability checks
+
+ // Check the protection of destination and if protected check the needed
+ // capabilities.
+ CMManager::TProtectionLevel protLevel =
+ destinationInstance->CurrentProtectionLevelL();
+ if ( protLevel == CMManager::EProtLevel1 ||
+ protLevel == CMManager::EProtLevel3 )
+ {
+ CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+ capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+ if ( capabilities == CPolicyServer::EFail )
+ {
+ User::Leave( KErrPermissionDenied );
+ }
+ }
+
+ // Check the protection of CM and if protected check the needed
+ // capabilities.
+ CheckCapabilitiesForProtectedCML( aMessage, connMethodInstance );
destinationInstance->DeleteConnMethodFromDestinationL( *connMethodInstance );
@@ -2080,7 +2307,20 @@
CCmmConnMethodInstance* connMethodInstance =
( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int0() );
- //TODO, capability checks
+ // Check the protection of destination and if protected check the needed
+ // capabilities.
+ CMManager::TProtectionLevel protLevel =
+ destinationInstance->CurrentProtectionLevelL();
+ if ( protLevel == CMManager::EProtLevel1 ||
+ protLevel == CMManager::EProtLevel3 )
+ {
+ CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+ capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+ if ( capabilities == CPolicyServer::EFail )
+ {
+ User::Leave( KErrPermissionDenied );
+ }
+ }
destinationInstance->RemoveConnMethodFromDestinationL( *connMethodInstance );
@@ -2097,11 +2337,25 @@
CCmmDestinationInstance* destinationInstance =
( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() );
+
+ // Check the protection of destination and if protected check the needed
+ // capabilities.
+ CMManager::TProtectionLevel protLevel =
+ destinationInstance->CurrentProtectionLevelL();
+ if ( protLevel == CMManager::EProtLevel1 ||
+ protLevel == CMManager::EProtLevel3 )
+ {
+ CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+ capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+ if ( capabilities == CPolicyServer::EFail )
+ {
+ User::Leave( KErrPermissionDenied );
+ }
+ }
+
CCmmConnMethodInstance* connMethodInstance =
( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int0() );
- //TODO, capability checks
-
// Index values start from 0 (0 meaning highest priority).
TUint index( ( TUint )aMessage.Int1() );
@@ -2121,6 +2375,28 @@
CCmmDestinationInstance* destinationInstance =
( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() );
+ // Check that client does not try to change the name of the Internet Destination.
+ TUint32 metadata( 0 );
+ destinationInstance->GetMetadataL( CMManager::ESnapMetadataPurpose, metadata );
+ if ( metadata == CMManager::ESnapPurposeInternet )
+ {
+ User::Leave( KErrPermissionDenied );
+ }
+
+ // Check the protection and if protected check the needed capabilities.
+ CMManager::TProtectionLevel protLevel =
+ destinationInstance->CurrentProtectionLevelL();
+ if ( protLevel == CMManager::EProtLevel1 ||
+ protLevel == CMManager::EProtLevel2 )
+ {
+ CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+ capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+ if ( capabilities == CPolicyServer::EFail )
+ {
+ User::Leave( KErrPermissionDenied );
+ }
+ }
+
// Load and check name.
TInt destNameLength = aMessage.GetDesLength( 0 );
if ( destNameLength <= 0 )
@@ -2147,6 +2423,48 @@
}
// -----------------------------------------------------------------------------
+// CCmmSession::SetDestinationIconL
+// -----------------------------------------------------------------------------
+//
+void CCmmSession::SetDestinationIconL( const RMessage2& aMessage )
+ {
+ OstTraceFunctionEntry0( CCMMSESSION_SETDESTINATIONICONL_ENTRY );
+
+ CCmmDestinationInstance* destinationInstance =
+ ( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() );
+
+ // Check the protection and if protected check the needed capabilities.
+ CMManager::TProtectionLevel protLevel =
+ destinationInstance->CurrentProtectionLevelL();
+ if ( protLevel == CMManager::EProtLevel1 ||
+ protLevel == CMManager::EProtLevel2 )
+ {
+ CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+ capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+ if ( capabilities == CPolicyServer::EFail )
+ {
+ User::Leave( KErrPermissionDenied );
+ }
+ }
+
+ // Load and check name.
+ TInt destIconNameLength = aMessage.GetDesLength( 0 );
+ if ( destIconNameLength < 0 || destIconNameLength > KCmmStringLengthMax )
+ {
+ User::Leave( KErrArgument );
+ }
+
+ HBufC* newIconName = HBufC::NewLC( destIconNameLength );
+ TPtr ptrNewIconName = newIconName->Des();
+ aMessage.ReadL( 0, ptrNewIconName );
+
+ destinationInstance->SetDestinationIconL( *newIconName );
+ CleanupStack::PopAndDestroy( newIconName );
+
+ OstTraceFunctionExit0( CCMMSESSION_SETDESTINATIONICONL_EXIT );
+ }
+
+// -----------------------------------------------------------------------------
// CCmmSession::SetDestinationMetadataL
// -----------------------------------------------------------------------------
//
@@ -2154,11 +2472,23 @@
{
OstTraceFunctionEntry0( CCMMSESSION_SETDESTINATIONMETADATAL_ENTRY );
- //TODO, Capability check. Protection level or Internet destination.
-
CCmmDestinationInstance* destinationInstance =
( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() );
+ // Check the protection and if protected check the needed capabilities.
+ CMManager::TProtectionLevel protLevel =
+ destinationInstance->CurrentProtectionLevelL();
+ if ( protLevel == CMManager::EProtLevel1 ||
+ protLevel == CMManager::EProtLevel2 )
+ {
+ CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+ capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+ if ( capabilities == CPolicyServer::EFail )
+ {
+ User::Leave( KErrPermissionDenied );
+ }
+ }
+
CMManager::TSnapMetadataField metadataField =
( CMManager::TSnapMetadataField )aMessage.Int0();
TUint32 metadata = aMessage.Int1();
@@ -2176,7 +2506,13 @@
{
OstTraceFunctionEntry0( CCMMSESSION_SETDESTINATIONPROTECTIONL_ENTRY );
- //TODO, Capability check: ECapabilityNetworkControl
+ // Check the needed capabilities.
+ CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+ capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+ if ( capabilities == CPolicyServer::EFail )
+ {
+ User::Leave( KErrPermissionDenied );
+ }
CCmmDestinationInstance* destinationInstance =
( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() );
@@ -2198,6 +2534,20 @@
CCmmDestinationInstance* destinationInstance =
( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() );
+ // Check the protection and if protected check the needed capabilities.
+ CMManager::TProtectionLevel protLevel =
+ destinationInstance->CurrentProtectionLevelL();
+ if ( protLevel == CMManager::EProtLevel1 ||
+ protLevel == CMManager::EProtLevel2 )
+ {
+ CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+ capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+ if ( capabilities == CPolicyServer::EFail )
+ {
+ User::Leave( KErrPermissionDenied );
+ }
+ }
+
TBool hidden = aMessage.Int0();
destinationInstance->SetMetadataL( CMManager::ESnapMetadataHiddenAgent, hidden );
@@ -2212,8 +2562,30 @@
{
OstTraceFunctionEntry0( CCMMSESSION_UPDATEDESTINATIONL_ENTRY );
+ // Check the disk space.
+ if ( CheckSpaceBelowCriticalLevelL() )
+ {
+ User::Leave( KErrDiskFull );
+ }
+
CCmmDestinationInstance* destinationInstance =
( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() );
+
+ // Check the protection and if protected check the needed capabilities
+ CMManager::TProtectionLevel protLevel =
+ destinationInstance->CurrentProtectionLevelL();
+ if ( protLevel == CMManager::EProtLevel1 ||
+ protLevel == CMManager::EProtLevel2 ||
+ protLevel == CMManager::EProtLevel3 )
+ {
+ CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+ capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+ if ( capabilities == CPolicyServer::EFail )
+ {
+ User::Leave( KErrPermissionDenied );
+ }
+ }
+
destinationInstance->UpdateL();
OstTraceFunctionExit0( CCMMSESSION_UPDATEDESTINATIONL_EXIT );
@@ -2230,6 +2602,22 @@
CCmmDestinationInstance* destinationInstance =
( CCmmDestinationInstance* )iDestinationObjects->AtL( aMessage.Int3() );
+ // Check the protection of destination and if protected check the needed
+ // capabilities.
+ CMManager::TProtectionLevel protLevel =
+ destinationInstance->CurrentProtectionLevelL();
+ if ( protLevel == CMManager::EProtLevel1 ||
+ protLevel == CMManager::EProtLevel2 ||
+ protLevel == CMManager::EProtLevel3 )
+ {
+ CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+ capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+ if ( capabilities == CPolicyServer::EFail )
+ {
+ User::Leave( KErrPermissionDenied );
+ }
+ }
+
iCache.CheckIfDestinationCanBeDeletedL( *destinationInstance );
iCache.DeleteDestinationL( *destinationInstance );
@@ -2380,13 +2768,14 @@
TUint32 bearerType( aMessage.Int0() );
- CCmmConnMethodInstance* connMethod = CCmmConnMethodInstance::NewLC( this, &iCache );
- iCache.CreateConnMethodL( *connMethod, NULL, bearerType, 0 );
-
- iConnMethodContainer->AddL( ( CObject* ) connMethod );
- TInt handle = iConnMethodObjects->AddL( ( CObject* ) connMethod );
- connMethod->SetHandle( handle );
- CleanupStack::Pop( connMethod );
+ CCmmConnMethodInstance* connMethodInstance =
+ CCmmConnMethodInstance::NewLC( this, &iCache );
+ iCache.CreateConnMethodL( *connMethodInstance, NULL, bearerType, 0 );
+
+ iConnMethodContainer->AddL( ( CObject* ) connMethodInstance );
+ TInt handle = iConnMethodObjects->AddL( ( CObject* ) connMethodInstance );
+ connMethodInstance->SetHandle( handle );
+ CleanupStack::Pop( connMethodInstance );
TPckg<TInt> handlePckg( handle );
TInt error = aMessage.Write( 3, handlePckg );
@@ -2408,9 +2797,19 @@
{
OstTraceFunctionEntry0( CCMMSESSION_UPDATECONNMETHODL_ENTRY );
- CCmmConnMethodInstance* connMethod =
+ // Check the disk space.
+ if ( CheckSpaceBelowCriticalLevelL() )
+ {
+ User::Leave( KErrDiskFull );
+ }
+
+ CCmmConnMethodInstance* connMethodInstance =
( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() );
- connMethod->UpdateL();
+
+ // Check if the Client has capabilities to modify this CM.
+ CheckCapabilitiesForProtectedCML( aMessage, connMethodInstance );
+
+ connMethodInstance->UpdateL();
OstTraceFunctionExit0( CCMMSESSION_UPDATECONNMETHODL_EXIT );
}
@@ -2435,7 +2834,7 @@
}
// -----------------------------------------------------------------------------
-// CCmmSession::ConnMethodUpdateL
+// CCmmSession::DeleteConnMethodL
// -----------------------------------------------------------------------------
//
void CCmmSession::DeleteConnMethodL( const RMessage2& aMessage )
@@ -2445,6 +2844,15 @@
CCmmConnMethodInstance* connMethodInstance =
( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() );
+ // Embedded destinations cannot be deleted through connection method handle.
+ if ( connMethodInstance->IsEmbeddedDestination() )
+ {
+ User::Leave( KErrNotSupported );
+ }
+
+ // Check if the Client has capabilities to delete this CM.
+ CheckCapabilitiesForProtectedCML( aMessage, connMethodInstance );
+
iCache.CheckIfConnMethodCanBeDeletedL( *connMethodInstance );
iCache.DeleteConnMethodL( *connMethodInstance );
// Ignore the boolean return value. It is always true, or the
@@ -2583,7 +2991,7 @@
CleanupStack::PushL( value );
TPtrC valuePtr = value->Des();
- // check the buffer length of the given buffer
+ // Check the buffer length of the given buffer.
TInt bufferLen = aMessage.GetDesMaxLength( 1 );
if ( valuePtr.Length() > bufferLen )
{
@@ -2617,7 +3025,7 @@
CleanupStack::PushL( value );
TPtrC8 valuePtr = value->Des();
- // check the buffer length of the given buffer
+ // Check the buffer length of the given buffer.
TInt bufferLen = aMessage.GetDesMaxLength( 1 );
if ( valuePtr.Length() > bufferLen )
{
@@ -2641,6 +3049,10 @@
CCmmConnMethodInstance* cm =
( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() );
+ // Check the capability needed if protected CM
+ // ECapabilityWriteDeviceData is checked earlier already.
+ CheckCapabilitiesForProtectedCML( aMessage, cm );
+
TUint32 attribute( aMessage.Int0() );
TUint32 value( aMessage.Int1() );
@@ -2660,6 +3072,10 @@
CCmmConnMethodInstance* cm =
( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() );
+ // Check the capability needed if protected CM
+ // ECapabilityWriteDeviceData is checked earlier already.
+ CheckCapabilitiesForProtectedCML( aMessage, cm );
+
TUint32 attribute( aMessage.Int0() );
TBool value( aMessage.Int1() );
@@ -2679,6 +3095,10 @@
CCmmConnMethodInstance* cm =
( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() );
+ // Check the capability needed if protected CM
+ // ECapabilityWriteDeviceData is checked earlier already.
+ CheckCapabilitiesForProtectedCML( aMessage, cm );
+
TUint32 attribute( aMessage.Int0() );
HBufC* value = HBufC::NewLC( aMessage.GetDesLengthL( 1 ) );
@@ -2703,6 +3123,10 @@
CCmmConnMethodInstance* cm =
( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() );
+ // Check the capability needed if protected CM
+ // ECapabilityWriteDeviceData is checked earlier already.
+ CheckCapabilitiesForProtectedCML( aMessage, cm );
+
TUint32 attribute( aMessage.Int0() );
HBufC8* value = HBufC8::NewLC( aMessage.GetDesLengthL( 1 ) );
@@ -2881,6 +3305,19 @@
CCmmDestinationInstance* destination =
( CCmmDestinationInstance* )iDestinationObjects->AtL( destinationHandle );
+ // Check the protection and if protected check the needed capabilities.
+ CMManager::TProtectionLevel protLevel =
+ destination->CurrentProtectionLevelL();
+ if ( protLevel == CMManager::EProtLevel1 )
+ {
+ CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+ capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+ if ( capabilities == CPolicyServer::EFail )
+ {
+ User::Leave( KErrPermissionDenied );
+ }
+ }
+
CCmmConnMethodInstance* connMethod = CCmmConnMethodInstance::NewLC( this, &iCache );
iCache.CreateConnMethodL( *connMethod, destination, bearerType, 0 );
@@ -2917,6 +3354,19 @@
CCmmDestinationInstance* destination =
( CCmmDestinationInstance* )iDestinationObjects->AtL( destinationHandle );
+ // Check the protection and if protected check the needed capabilities.
+ CMManager::TProtectionLevel protLevel =
+ destination->CurrentProtectionLevelL();
+ if ( protLevel == CMManager::EProtLevel1 )
+ {
+ CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+ capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+ if ( capabilities == CPolicyServer::EFail )
+ {
+ User::Leave( KErrPermissionDenied );
+ }
+ }
+
CCmmConnMethodInstance* connMethod =
CCmmConnMethodInstance::NewLC( this, &iCache );
// Will check if ID is available.
@@ -2999,7 +3449,8 @@
}
// -----------------------------------------------------------------------------
-// Creates a copy of an existing connection method and opens a handle to it.
+// Opens a destination handle to the embedded destination that the provided
+// connection method handle represents.
// -----------------------------------------------------------------------------
//
void CCmmSession::GetEmbeddedDestinationL( const RMessage2& aMessage )
@@ -3009,7 +3460,8 @@
CCmmConnMethodInstance* connMethodInstance =
( CCmmConnMethodInstance* )iConnMethodObjects->AtL( aMessage.Int3() );
- if ( connMethodInstance->GetBearerType() != KUidEmbeddedDestination )
+ // Check this connection method realy represents an embedded destination.
+ if ( !connMethodInstance->IsEmbeddedDestination() )
{
User::Leave( KErrNotSupported );
}
@@ -3058,7 +3510,55 @@
iDestinationObjects->Remove( handle );
User::Leave( error );
}
+
OstTraceFunctionExit0( CCMMSESSION_GETEMBEDDEDDESTINATIONL_EXIT );
}
+// -----------------------------------------------------------------------------
+// Check if CM is protected and if so then check the needed capabilities.
+// -----------------------------------------------------------------------------
+//
+void CCmmSession::CheckCapabilitiesForProtectedCML(
+ const RMessage2& aMessage,
+ CCmmConnMethodInstance* aConnectionMethodInstance )
+ {
+ OstTraceFunctionEntry0( CCMMSESSION_CHECKCAPABILITIESFORPROTECTEDCML_ENTRY );
+
+ TBool prot = aConnectionMethodInstance->GetBoolAttributeL( CMManager::ECmProtected );
+ if ( prot )
+ {
+ CPolicyServer::TCustomResult capabilities( CPolicyServer::EPass );
+ capabilities = iServer.CapabilityCheckWithProtection( aMessage );
+ if ( capabilities == CPolicyServer::EFail )
+ {
+ User::Leave( KErrPermissionDenied );
+ }
+ }
+
+ OstTraceFunctionExit0( CCMMSESSION_CHECKCAPABILITIESFORPROTECTEDCML_EXIT );
+ }
+
+// ---------------------------------------------------------------------------
+// Check if there is space enough in the disk.
+// ---------------------------------------------------------------------------
+//
+TBool CCmmSession::CheckSpaceBelowCriticalLevelL()
+ {
+ if ( !iFsConnected )
+ {
+ TInt err = iFs.Connect();
+ if ( err )
+ {
+ // Error happened in connect --> disk space cannot be checked,
+ // --> return information that everything is ok.
+ return EFalse;
+ }
+ iFsConnected = ETrue;
+ }
+
+ TBool belowCL = SysUtil::FFSSpaceBelowCriticalLevelL( &iFs, KMinimumDiskSpace );
+
+ return belowCL;
+ }
+
// End of file