diff -r 84c6623982f6 -r ed07dcc72692 apengine/apeng/src/ApEngineCommons.cpp --- a/apengine/apeng/src/ApEngineCommons.cpp Fri Sep 17 08:32:43 2010 +0300 +++ b/apengine/apeng/src/ApEngineCommons.cpp Mon Oct 04 00:43:42 2010 +0300 @@ -38,8 +38,6 @@ void ApCommons::Panic( TApEnginePanicCodes aPanic ) { - _LIT( kApSet, "APEngine" ) ; - User::Panic( kApSet, aPanic ) ; } @@ -49,34 +47,7 @@ // TBool ApCommons::StartPushedTransactionLC( CCommsDatabase& aDb, TBool aRetry ) { - CLOG( ( ETransaction, 0, - _L( "-> ApCommons::StartPushedTransactionLC" ) ) ); - - TBool retval( EFalse ); - if ( !aDb.InTransaction() ) - { - TInt retriesLeft( aRetry ? KRetryCount : 1 ); - TInt err = aDb.BeginTransaction(); - while ( ( ( err == KErrLocked ) || ( err == KErrAccessDenied ) ) - && --retriesLeft ) - { - User::After( KRetryWait ); - err = aDb.BeginTransaction(); - } - User::LeaveIfError( err ); - CleanupStack::PushL - ( - TCleanupItem( ApCommons::RollbackTransactionOnLeave, &aDb ) - ); - retval = ETrue; - } - else - { - retval = EFalse; - } - CLOG( ( ETransaction, 1, - _L( "<- ApCommons::StartPushedTransactionLC" ) ) ); - return retval; + return EFalse; } @@ -87,14 +58,6 @@ // void ApCommons::RollbackTransactionOnLeave( TAny* aDb ) { - CLOG( ( ETransaction, 0, - _L( "-> ApCommons::RollbackTransactionOnLeave" ) ) ); - - CCommsDatabase* db = STATIC_CAST( CCommsDatabase*, aDb ); - db->RollbackTransaction(); - - CLOG( ( ETransaction, 1, - _L( "<- ApCommons::RollbackTransactionOnLeave" ) ) ); } @@ -113,99 +76,7 @@ TBool aIsNew ) { - CLOG( ( ECommons, 0, _L( "-> ApCommons::DoMakeValidNameL" ) ) ); - - aChanged = EFalse; - HBufC* temp = HBufC::NewLC( KApMaxConnNameLength ); - HBufC* temp2 = HBufC::NewLC( KApMaxConnNameLength ); - - HBufC* corrname = ApCommons::EnsureMaxLengthLC( aName, aChanged ); - *temp = *corrname; - TInt postfix( 0 ); - TInt pf( 0 ); - TInt i( 0 ); - TBool valid ( EFalse ); - - TPtrC prefix = ApCommons::GetPrefix( *corrname ); - - CApUtils* utils = CApUtils::NewLC( aDb ); - - if ( aIsNew ) - { - aUid = 0; - } - - postfix = GetPostfix( *temp, prefix ); - postfix = -1; - do - { - valid = utils->IsValidNameL( *temp, aUid ); - if ( !valid ) - { - aChanged = ETrue; - postfix++; - // check the length of postfix, check text length accordingly - pf = postfix; - for (i=1; i<10; i++) - { - pf /= 10; - if ( !pf ) - break; - } - TPtr sgdptr( temp->Des() ); - TPtr sgdptr2( temp2->Des() ); - if ( postfix ) - { - if ( postfix < 10 ) - { - sgdptr2 = prefix.Left( KApMaxConnNameLength - i - 3 ); - } - else - { - sgdptr2 = prefix.Left( KApMaxConnNameLength - i - 2 ); - } - } - else - { - sgdptr2 = prefix.Left( KApMaxConnNameLength ); - } - if ( postfix ) - { - if ( postfix > 9 ) - { - sgdptr.Format( KFormatLargePostfix, &sgdptr2, - postfix ); - } - else - { - sgdptr.Format( KFormatPostfix, &sgdptr2, - postfix ); - } - } - else - { - sgdptr.Format( KFormatNoPostfix, &sgdptr2 ); - } - } - } while ( !valid ); - - CleanupStack::PopAndDestroy( utils ); - CleanupStack::PopAndDestroy( corrname ); - CleanupStack::PopAndDestroy( temp2 ); - - if ( aChanged ) - { - CleanupStack::Pop( temp ); - } - else - { - CleanupStack::PopAndDestroy( temp ); - temp = NULL; - } - - CLOG( ( ECommons, 1, _L( "<- ApCommons::DoMakeValidNameL" ) ) ); - - return temp; + return NULL; } @@ -218,41 +89,7 @@ // HBufC* ApCommons::EnsureMaxLengthLC( const TDesC* aName, TBool& aChanged ) { - CLOG( ( ECommons, 0, _L( "-> ApCommons::EnsureMaxLengthLC" ) ) ); - - TInt length = aName->Length(); - - aChanged = EFalse; - - if ( !length ) - { - // Name is required. - User::Leave(KErrInvalidName); - } - - HBufC* corrname; - if ( KApMaxConnNameLength < length ) - { // name too long, truncate. - corrname = aName->Left( KApMaxConnNameLength ).AllocLC(); - aChanged = ETrue; - } - else - { - corrname = aName->AllocLC(); - corrname->Des().Trim(); - if ( corrname->Length() == 0 ) - { - User::Leave(KErrInvalidName); - } - // comes here only if name is valid - if ( corrname->Length() != aName->Length() ) - { - aChanged = ETrue; - } - } - CLOG( ( ECommons, 1, _L( "<- ApCommons::EnsureMaxLengthLC" ) ) ); - - return corrname; + return NULL; } @@ -274,22 +111,7 @@ */ TPtrC ApCommons::GetPrefix( const TDesC& aName ) { - TPtrC prefix = aName; - TInt lastBrace = aName.LocateReverse('('); - if ( lastBrace != KErrNotFound ) - { - // aName looks like "". - // See if is an integer number. - TPtrC num = aName.Right( aName.Length() - lastBrace - 1 ); - TInt val; - TLex lex( num ); - if ( lex.Val( val ) == KErrNone ) - { - // Yes, the trailer is an integer. - prefix.Set( aName.Left( lastBrace ) ); - } - } - return prefix; + User::Leave( KErrNotSupported ); } @@ -306,45 +128,7 @@ */ TInt ApCommons::GetPostfix( const TDesC& aName, const TDesC& aPrefix ) { - TInt postfix( KErrNotFound ); - TInt nameLength = aName.Length(); - TInt prefixLength = aPrefix.Length(); - if ( nameLength >= prefixLength && aName.FindF( aPrefix ) == 0 ) - { - // aName is longer or equal length, and - // aPrefix can be found in the beginning of aName. - if ( nameLength == prefixLength ) - { - // They have the same length; they equal. - postfix = 0; - } - else - { - if ( aName[ prefixLength ] == '(' ) - { - // (Now we know that aName is longer than aPrefix.) - // aName looks like "aPrefix". - // See if is an integer number. - TPtrC num = aName.Right( nameLength - prefixLength - 1 ); - TInt val; - TLex lex( num ); - if ( lex.Val( val ) == KErrNone ) - { - // Yes, the trailer is an integer. - if ( val > 0 ) - { - postfix = val; - } - else - { - // signal that it is invalid... - postfix = -1; - } - } - } - } - } - return postfix; + return 0; } @@ -361,14 +145,7 @@ TUint32& aValue ) { - __ASSERT_DEBUG( (atable), Panic( ENullPointer ) ) ; - TRAPD( err, atable->ReadUintL( aColumn, aValue ) ); - if ( err != KErrNone ) - { // do not leave if readed value is not present in table... - if ( ( err != KErrUnknown ) && ( err != KErrNotFound ) ) - User::Leave( err ); - } - return err; + return KErrUnknown; } @@ -383,14 +160,7 @@ TBool& aValue ) { - __ASSERT_DEBUG( (atable), Panic( ENullPointer ) ) ; - TRAPD( err, atable->ReadBoolL( aColumn, aValue ) ); - if ( err != KErrNone ) - { // do not leave if readed value is not present in table... - if ( err != KErrUnknown ) - User::Leave( err ); - } - return err; + return KErrUnknown; } @@ -406,18 +176,7 @@ TInt& aErrCode ) { - __ASSERT_DEBUG( (atable), Panic( ENullPointer ) ) ; - HBufC* value = NULL; - // because of Trap, we need to call a func - // which pops it from the stack & push it back afterwards... - TRAP( aErrCode, value = ReadLongTextL( atable, aColumn ) ); - CleanupStack::PushL( value ); - if ( aErrCode != KErrNone ) - { // do not leave if readed value is not present in table... - if ( aErrCode != KErrUnknown ) - User::Leave( aErrCode ); - } - return value; + return NULL; } @@ -429,10 +188,7 @@ HBufC* ApCommons::ReadLongTextL( CCommsDbTableView* atable, const TDesC& aColumn ) { - __ASSERT_DEBUG( (atable), Panic( ENullPointer ) ) ; - HBufC* value = atable->ReadLongTextLC( aColumn ); - CleanupStack::Pop( value ); - return value; + return NULL; } @@ -443,23 +199,7 @@ // HBufC* ApCommons::EscapeTextLC( const TDesC& aLiteral ) { - TInt l( aLiteral.Length() ); - //> 2*, to ensure correct esc. even if ALL chars are quotes... - HBufC* retbuf = HBufC::NewLC( 2*l ); - TPtr ret = retbuf->Des(); - TUint quote( '\'' ); // TChar gives warnings in THUMB & ARMI - TInt i( 0 ); - - for( i=0; iReadColumnLengthL(aCol, aLength); - - HBufC* buf = HBufC::NewLC(aLength); - TPtr ptr( buf->Des() ); - atable->ReadTextL(aCol, ptr); - return buf; + return NULL; } @@ -495,14 +222,7 @@ HBufC8* ApCommons::ReadText8ValueLC( CCommsDbTableView* atable, const TDesC& aCol ) { - __ASSERT_DEBUG( (atable), Panic( ENullPointer ) ) ; - TInt aLength(0); - atable->ReadColumnLengthL(aCol, aLength); - - HBufC8* buf = HBufC8::NewLC(aLength); - TPtr8 ptr( buf->Des() ); - atable->ReadTextL(aCol, ptr); - return buf; + return NULL; } @@ -512,7 +232,7 @@ // TBool ApCommons::DoGetReadOnlyL( CCommsDbTableView& aTable ) { - return CApProtHandler::GetProtectionStateL( aTable ); + return EFalse; } @@ -523,10 +243,7 @@ // TInt ApCommons::CommitTransaction( CCommsDatabase& aDb ) { - CLOG( ( ETransaction, 0, _L( "-> ApCommons::CommitTransaction" ) ) ); - TInt err = aDb.CommitTransaction(); - CLOG( ( ETransaction, 1, _L( "<- ApCommons::CommitTransaction" ) ) ); - return err; + return KErrNotSupported; } @@ -538,16 +255,7 @@ // TInt ApCommons::GetVariantL() { - CLOG( ( ETransaction, 0, _L( "-> ApCommons::GetVariantL" ) ) ); - TInt variant( 0 ); - // Connecting and initialization: - CRepository* repository = CRepository::NewL( KCRUidApEngineLV ); - repository->Get( KApEngineLVFlags, variant ); - delete repository; - - CLOG( ( ETransaction, 1, _L( "<- ApCommons::GetVariantL" ) ) ); - - return variant; + return 0; } @@ -559,12 +267,7 @@ TInt ApCommons::IsGivenSharedDataSupportL( const TUid aUid, const TUint32 aKey ) { - TInt value( 0 ); - // Connecting and initialization: - CRepository* repository = CRepository::NewL( aUid ); - repository->Get( aKey, value ); - delete repository; - return value; + return 0; }