// --------------------------------------------------------------------------- // CBSServer::DisplaySessionInfoL display the info for each open session, // except for the one that called this method // --------------------------------------------------------------------------- // void CBSServer::DisplaySessionInfoL( CBSSession* aSession, TInt aErrorCode ) { TRACE( T_LIT( "CBSServer::DisplaySessionInfoL() begin aSession[%d], aErrorCode[%d]"),aSession,aErrorCode ); User::LeaveIfNull( aSession ); // some constants const TInt KStringLength = 512; const TInt KNumberLength = 16; _LIT( KMessage0,"Operation failed.Errorcode:"); _LIT( KMessage1," Info on open sessions [ProcessFileName|ThreadId|ProcessId|Caption]:"); _LIT( KBracketOpen, " ["); _LIT( KBracketClose, "]"); _LIT( KSeparator, "|"); HBufC* outputString = HBufC::NewLC( KStringLength ); TPtr outputStringPtr( outputString->Des() ); TBuf<KNumberLength> number; number.Num( aErrorCode ); //make sure the string is long enough TInt newLength = outputString->Length() + KMessage0().Length() + number.Length() + KMessage1().Length(); //reallocate if necessary if ( outputStringPtr.MaxLength() < newLength ) { CleanupStack::Pop( outputString ); outputString = outputString->ReAllocL( newLength ); outputStringPtr.Set( outputString->Des() ); CleanupStack::PushL( outputString ); } outputStringPtr.Append( KMessage0 ); outputStringPtr.Append( number ); outputStringPtr.Append( KMessage1 ); TInt count = iSessions.Count(); TRACE( T_LIT( "CBSServer::DisplaySessionInfoL() numberSessions=%d"),count ); CBSSession* currentSession; for( TInt i = 0; i < count; i++ ) { currentSession = iSessions[i]; TRACE( T_LIT( "CBSServer::DisplaySessionInfoL() iteration=%d session=%d"),i,currentSession ); if ( currentSession && currentSession->InfoAvailable() && currentSession != aSession ) { TBuf<KNumberLength> threadIdStr; TThreadId threadId; if ( KErrNone == currentSession->ThreadId( threadId ) ) { threadIdStr.NumUC( threadId.Id(), EDecimal ); } TBuf<KNumberLength> processIdStr; TProcessId processId; if ( KErrNone == currentSession->ProcessId( processId ) ) { processIdStr.NumUC( processId.Id(), EDecimal ); } //make sure the string is long enough newLength = outputString->Length() + KBracketOpen().Length() + currentSession->FileName().Length() + threadIdStr.Length() + processIdStr.Length() + currentSession->Caption().Length() + ( 3 * KSeparator().Length() ) + KBracketClose().Length(); //reallocate if necessary if ( outputStringPtr.MaxLength() < newLength ) { CleanupStack::Pop( outputString ); outputString = outputString->ReAllocL( newLength ); outputStringPtr.Set( outputString->Des() ); CleanupStack::PushL( outputString ); } outputStringPtr.Append( KBracketOpen ); //processfilename outputStringPtr.Append( currentSession->FileName() ); outputStringPtr.Append( KSeparator ); //threadid outputStringPtr.Append( threadIdStr ); outputStringPtr.Append( KSeparator ); //processid outputStringPtr.Append( processIdStr ); outputStringPtr.Append( KSeparator ); //caption outputStringPtr.Append( currentSession->Caption() ); outputStringPtr.Append( KBracketClose ); } } TRACE( T_LIT( "CBSServer::DisplaySessionInfoL() string creation OK") ); TRACE( T_LIT( "%S"), outputString ); CleanupStack::PopAndDestroy( outputString ); TRACE( T_LIT( "CBSServer::DisplaySessionInfoL() end") ); }
TBool CDataWrapperBase::GetCommandStringParameterL(const TDesC& aSectName, const TDesC& aKeyName, TPtrC& aResult) { TBool ret=EFalse; if ( aSectName.Length()!=0 ) { ret=CDataWrapper::GetStringFromConfig(aSectName, aKeyName, aResult); for ( TInt index=iInclude.Count(); (index>0) && (!ret); ) { ret=iInclude[--index]->FindVar(aSectName, aKeyName, aResult); } } if ( ret ) { if ( aResult.Match(KMatch)!=KErrNotFound ) { // We have an entry of the format // entry =*{section,entry}* // where * is one or more characters // We need to construct this from other data in the ini file replacing {*,*} // with the data from // [section] // entry =some_value HBufC* buffer=HBufC::NewLC(aResult.Length()); buffer->Des().Copy(aResult); TInt startLength=KStart().Length(); TInt sparatorLength=KSeparator().Length(); TInt endLength=KEnd().Length(); TInt bufferLength; TInt start; TInt sparator; TInt end; TPtrC remaining; TLex lex; do { bufferLength=buffer->Length(); start=buffer->Find(KStart); remaining.Set(buffer->Des().Right(bufferLength-start-startLength)); sparator=remaining.Find(KSeparator); remaining.Set(remaining.Right(remaining.Length()-sparator-sparatorLength)); sparator += (start + startLength); end=remaining.Find(KEnd) + sparator + sparatorLength; TPtrC sectionName(buffer->Ptr()+start+startLength, sparator-start-startLength); TPtrC keyName(buffer->Ptr()+sparator+sparatorLength, end-sparator-sparatorLength); sectionName.Set(TLex(sectionName).NextToken()); keyName.Set(TLex(keyName).NextToken()); TInt entrySize=0; TPtrC entryData; TBool found=CDataWrapper::GetStringFromConfig(sectionName, keyName, entryData); for ( TInt index=iInclude.Count(); (index>0) && (!found); ) { found=iInclude[--index]->FindVar(sectionName, keyName, entryData); } if ( found ) { entrySize=entryData.Length(); } TInt newLength=start + bufferLength - end - endLength + entrySize; HBufC* bufferNew=HBufC::NewLC(newLength); bufferNew->Des().Copy(buffer->Ptr(), start); if ( entrySize>0 ) { bufferNew->Des().Append(entryData); } bufferNew->Des().Append(buffer->Ptr() + end + endLength, bufferLength - end - endLength); CleanupStack::Pop(bufferNew); CleanupStack::PopAndDestroy(buffer); buffer=bufferNew; CleanupStack::PushL(buffer); } while ( buffer->Match(KMatch)!=KErrNotFound ); iBuffer.Append(buffer); CleanupStack::Pop(buffer); aResult.Set(*buffer); INFO_PRINTF4(KDataRead, &aSectName, &aKeyName , &aResult); } } return ret; }