diff -r 05bc53fe583b -r 83ca720e2b9a dbcreator/commsdatcreator/Src/cdcprocessorglobal.cpp --- a/dbcreator/commsdatcreator/Src/cdcprocessorglobal.cpp Tue Aug 31 15:35:44 2010 +0300 +++ b/dbcreator/commsdatcreator/Src/cdcprocessorglobal.cpp Wed Sep 01 12:23:51 2010 +0100 @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -105,14 +106,16 @@ RPointerArray< RCmConnectionMethodExt >& aPluginArray, RPointerArray< HBufC >& aPluginNames, RPointerArray< RCmDestinationExt >& aDestArray, - RPointerArray< HBufC >& aDestNames ) + RPointerArray< HBufC >& aDestNames, + RPointerArray< HBufC >& aDefCon ) { CProcessorGlobal* self = new ( ELeave ) CProcessorGlobal( aFileReader, aCmManager, aPluginArray, aPluginNames, aDestArray, - aDestNames ); + aDestNames, + aDefCon ); CleanupStack::PushL( self ); // From base class @@ -131,10 +134,12 @@ RPointerArray< RCmConnectionMethodExt >& aPluginArray, RPointerArray< HBufC >& aPluginNames, RPointerArray< RCmDestinationExt >& aDestArray, - RPointerArray< HBufC >& aDestNames ) : + RPointerArray< HBufC >& aDestNames, + RPointerArray< HBufC >& aDefCon ) : CProcessorBase( aFileReader, aCmManager, aPluginArray, aPluginNames, aDestArray, aDestNames ), iAttachWhenNeeded ( EFalse ) { + iDefCon = &aDefCon; } @@ -151,7 +156,7 @@ // Create General connection settings struct and set the default values iGenConnSettings = new (ELeave) TCmGenConnSettings; iGenConnSettings->iUsageOfWlan = ECmUsageOfWlanKnown; - iGenConnSettings->iCellularDataUsageHome = ECmCellularDataUsageAutomatic; + iGenConnSettings->iCellularDataUsageHome = ECmCellularDataUsageConfirm; iGenConnSettings->iCellularDataUsageVisitor = ECmCellularDataUsageConfirm; CLOG_WRITE( "Initialising FeatureManager\n" ) @@ -262,10 +267,19 @@ CCDSNAPMetadataRecord* defaultRecord = new( ELeave ) CCDSNAPMetadataRecord( snapTable->TableId() ); CleanupStack::PushL( defaultRecord ); - defaultRecord->SetRecordId( KCDNewRecordRequest ); defaultRecord->iMetadata.SetL( 0 ); - defaultRecord->iIcon.SetL( icon ); - defaultRecord->StoreL( *iSession ); + + if ( !defaultRecord->FindL( *iSession ) ) + { + defaultRecord->SetRecordId( KCDNewRecordRequest ); + defaultRecord->iIcon.SetL( icon ); + defaultRecord->StoreL( *iSession ); + } + else + { + defaultRecord->iIcon.SetL( icon ); + defaultRecord->ModifyL( *iSession ); + } CleanupStack::PopAndDestroy( defaultRecord ); // defaultRecord CleanupStack::PopAndDestroy( snapTable ); // snapTable @@ -303,6 +317,20 @@ break; } + case EDefaultConnectionType: + { + iDefCon->Append( ptrTag->AllocL() ); + //SetDefaultConnectionTypeL( ptrTag ) + break; + } + + case EDefaultConnectionName: + { + iDefCon->Append( ptrTag->AllocL() ); + //SetDefaultConnectionNameL( ptrTag ) + break; + } + case EGprsLastSocketActivityTimeout: case EGprsLastSessionClosedTimeout: case EGprsLastSocketClosedTimeout: @@ -592,6 +620,87 @@ } // --------------------------------------------------------- +// CProcessorGlobal::SetDefaultConnectionL +// --------------------------------------------------------- +// +void CProcessorGlobal::SetDefaultConnectionL() + { + if( iDefCon->Count() > 0 ) + { + SetDefaultConnectionTypeL( (*iDefCon)[0] ); + } + if( iDefCon->Count() > 1 ) + { + SetDefaultConnectionNameL( (*iDefCon)[1] ); + } + } + +// --------------------------------------------------------- +// CProcessorGlobal::SetDefaultConnectionTypeL +// --------------------------------------------------------- +// +void CProcessorGlobal::SetDefaultConnectionTypeL( HBufC16* aPtrTag ) + { + iDefaultConnectionSet = EFalse; + + if ( aPtrTag->CompareF( KStrAlwaysAsk ) == 0 ) + { + iDefaultConnectionType = ECmDefConnAlwaysAsk; + SetDefConnRecordL( 0 ); + } + else if ( aPtrTag->CompareF( KStrAskOnce ) == 0 ) + { + iDefaultConnectionType = ECmDefConnAskOnce; + SetDefConnRecordL( 0 ); + } + else if ( aPtrTag->CompareF( KStrDestination ) == 0 ) + { + iDefaultConnectionType = ECmDefConnDestination; + } + else if ( aPtrTag->CompareF( KStrConnectionMethod ) == 0 ) + { + iDefaultConnectionType = ECmDefConnConnectionMethod; + } + else + { + CLOG_WRITE( + "Warning: Default connection type is not valid. Always ask is set.") + iDefaultConnectionType = ECmDefConnAlwaysAsk; + SetDefConnRecordL( 0 ); + } + } + +// --------------------------------------------------------- +// CProcessorGlobal::SetDefaultConnectionNameL +// --------------------------------------------------------- +// +void CProcessorGlobal::SetDefaultConnectionNameL( HBufC16* aPtrTag ) + { + + // Name is ignored if the defconn has been set. It can happen e.g. + // if iDefaultConnectionType is ECmDefConnAlwaysAsk or ECmDefConnAskOnce + if ( iDefaultConnectionSet ) + { + return; + } + + TInt uId = KErrNotFound; + if ( iDefaultConnectionType == ECmDefConnDestination ) + { + uId = GetDestinationIdL( aPtrTag ); + } + else if ( iDefaultConnectionType == ECmDefConnConnectionMethod ) + { + uId = GetPluginIdL( aPtrTag ); + } + + if( uId != KErrNotFound ) + { + SetDefConnRecordL( uId ); + } + } + +// --------------------------------------------------------- // CProcessorGlobal::SetGenConnSettingWlanUsage // --------------------------------------------------------- // @@ -656,6 +765,25 @@ } //----------------------------------------------------------------------------- +// CProcessorGlobal::SetDefConnRecordL() +//----------------------------------------------------------------------------- +// +void CProcessorGlobal::SetDefConnRecordL( const TInt aId ) + { + + TCmDefConnValue value; + value.iType = iDefaultConnectionType; + value.iId = aId; + + iCmManager->WriteDefConnL( value ); + + // It gets true if the defconn was set correctly + iDefaultConnectionSet = ETrue; + + } + + +//----------------------------------------------------------------------------- // CProcessorGlobal::SaveGlobalWlanParameterL() //----------------------------------------------------------------------------- //