brandingserver/BSServer/cbsserver.cpp
changeset 31 9dbc70490d9a
equal deleted inserted replaced
30:1fa9b890f29c 31:9dbc70490d9a
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  cbsserver.cpp
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 //  INCLUDE FILES
       
    21 
       
    22 #define __INCLUDE_CAPABILITY_NAMES__
       
    23 #define __INCLUDE_ALL_SUPPORTED_CAPABILITIES__
       
    24 
       
    25 #include "cbsserver.h"
       
    26 #include "cbssession.h"
       
    27 #include "bsserverdefs.h"
       
    28 #include "DebugTrace.h"
       
    29 #include "cbsstoragemanager.h"
       
    30 #include "cbsinstallhandler.h"
       
    31 #include "cbsbackupobserver.h"
       
    32 
       
    33 // CBSFileMapping
       
    34 
       
    35 CBSServer::CBSFileMapping* CBSServer::CBSFileMapping::NewL( CBSSession* aSession,
       
    36 				    									    const TDesC& aFile,
       
    37 				    									    TBool aVersioned )
       
    38 	{
       
    39 	CBSFileMapping* self = new( ELeave ) CBSFileMapping( aVersioned );
       
    40 	CleanupStack::PushL( self );
       
    41 	self->ConstructL( aSession, aFile );
       
    42 	CleanupStack::Pop( self );
       
    43 	return self;
       
    44 	}
       
    45 void CBSServer::CBSFileMapping::ConstructL(  CBSSession* aSession,
       
    46     									     const TDesC& aFile )
       
    47 	{
       
    48 	iSession = aSession;
       
    49 	iFile = aFile.AllocL();
       
    50 	}
       
    51 CBSServer::CBSFileMapping::CBSFileMapping( TBool aVersioned )
       
    52 : iVersioned( aVersioned )
       
    53 	{
       
    54 	}
       
    55 CBSServer::CBSFileMapping::~CBSFileMapping()
       
    56 	{
       
    57 	delete iFile;
       
    58 	}
       
    59 
       
    60 CBSSession* CBSServer::CBSFileMapping::Session()
       
    61 	{
       
    62 	return iSession;
       
    63 	}
       
    64 const TDesC& CBSServer::CBSFileMapping::File()
       
    65 	{
       
    66 	return *iFile;
       
    67 	}
       
    68 TBool CBSServer::CBSFileMapping::Versioned()
       
    69 	{
       
    70 	return iVersioned;
       
    71 	}
       
    72 
       
    73 
       
    74 // ==============================================================
       
    75 // =============== PLATSEC POLICY CONFIGURATION =================
       
    76 // ==============================================================
       
    77 
       
    78 static const TInt KBSPlatSecRangeCount = 2;
       
    79 
       
    80 //Ranges for the Request values
       
    81 static const TInt KBSPlatSecRanges[ KBSPlatSecRangeCount ] =
       
    82     {
       
    83     0,
       
    84     EBSOperationLast
       
    85     };
       
    86 
       
    87 
       
    88 // Element indexes for the defined ranges
       
    89 static const TUint8 KBSPlatSecElementsIndex[ KBSPlatSecRangeCount ] =
       
    90     {
       
    91     0,
       
    92     CPolicyServer::ENotSupported
       
    93     };
       
    94 
       
    95 
       
    96 // Policy elements
       
    97 static const CPolicyServer::TPolicyElement KBSPlatSecElements[] =
       
    98     {
       
    99         {
       
   100         _INIT_SECURITY_POLICY_C2( ECapabilityReadUserData,
       
   101                                   ECapabilityWriteUserData ),
       
   102         -5 //CPolicyServer::EFailClient
       
   103         }
       
   104     };
       
   105 
       
   106 
       
   107 // The platsec policy
       
   108 static const CPolicyServer::TPolicy KBSPlatSecPolicy =
       
   109     {
       
   110     // Shortcut to the index into Elements,that is used to check a connection attempt
       
   111     0,
       
   112 
       
   113     // Number of ranges in the iRanges array
       
   114     KBSPlatSecRangeCount,
       
   115 
       
   116     // A pointer to an array of ordered ranges of request numbers
       
   117     KBSPlatSecRanges,
       
   118 
       
   119     // A pointer to an array of TUint8 values specifying
       
   120     // the appropriate action to take for each range in iRanges
       
   121     KBSPlatSecElementsIndex,
       
   122 
       
   123     // A pointer to an array of distinct policy elements
       
   124     KBSPlatSecElements
       
   125     };
       
   126 
       
   127 
       
   128 
       
   129 // ==============================================================
       
   130 // ======================= SERVER  ==============================
       
   131 // ==============================================================
       
   132 void CBSServer::ExecuteL()
       
   133     {
       
   134     TRACE( T_LIT( "CBrandingServer::ExecuteL() begin") );
       
   135     // start scheduler
       
   136     CActiveScheduler* pA = new( ELeave )CActiveScheduler;
       
   137     CleanupStack::PushL( pA );
       
   138     CActiveScheduler::Install( pA );
       
   139 
       
   140 
       
   141     // create server
       
   142     CBSServer* server = new( ELeave ) CBSServer();
       
   143     CleanupStack::PushL( server );
       
   144     server->InitializeL();
       
   145     server->StartL( KBSServerName );
       
   146 
       
   147 
       
   148     //Signal client that we are started
       
   149     RProcess().Rendezvous( KErrNone );
       
   150 
       
   151     //Execute the server
       
   152     // Codescanner warning: using CActiveScheduler::Start (id:3)
       
   153     // this has to be called for server starting.
       
   154     CActiveScheduler::Start(); // CSI: 3 # See above
       
   155 
       
   156 
       
   157     //Cleanup
       
   158     CleanupStack::PopAndDestroy( server );//server
       
   159     CleanupStack::PopAndDestroy( pA );
       
   160     CActiveScheduler::Install( NULL );
       
   161     TRACE( T_LIT( "CBrandingServer::ExecuteL() end") );
       
   162     }
       
   163 
       
   164 
       
   165 
       
   166 CBSServer::~CBSServer()
       
   167     {
       
   168     TRACE( T_LIT( "CBrandingServer::~CBSServer() begin") );
       
   169     delete iBackupObserver;
       
   170     delete iInstallHandler;
       
   171     iSessions.Close();
       
   172     iFileMapping.Close();
       
   173     delete iStorageManager;
       
   174 
       
   175 #if _BullseyeCoverage
       
   176     cov_write();
       
   177 #endif
       
   178     TRACE( T_LIT( "CBrandingServer::~CBSServer() end") );
       
   179     }
       
   180 
       
   181 
       
   182 
       
   183 CBSServer::CBSServer()
       
   184     : CPolicyServer( CActive::EPriorityStandard,
       
   185                      KBSPlatSecPolicy )
       
   186     {
       
   187     }
       
   188 
       
   189 
       
   190 
       
   191 CSession2* CBSServer::NewSessionL( const TVersion &aVersion,
       
   192                                           const RMessage2& /*aMessage*/ ) const
       
   193     {
       
   194     TRACE( T_LIT( "CBrandingServer::NewSessionL() begin") );
       
   195     TVersion srvVersion( KBSVersionMajor,
       
   196                          KBSVersionMinor,
       
   197                          KBSVersionBuild );
       
   198 
       
   199 
       
   200     if( !User::QueryVersionSupported( aVersion, srvVersion ) )
       
   201         {
       
   202         User::Leave( KErrNotSupported );
       
   203         }
       
   204 
       
   205     CBSSession* session = CBSSession::NewL();
       
   206     //enable backup observer
       
   207     iBackupObserver->RegisterObserver( session );
       
   208     
       
   209     TRACE( T_LIT( "CBrandingServer::NewSessionL() end session[%d] created"), session );
       
   210     return session;
       
   211     }
       
   212 
       
   213 
       
   214 CPolicyServer::TCustomResult
       
   215     CBSServer::CustomFailureActionL( const RMessage2& aMsg,
       
   216                                             TInt /*aAction*/,
       
   217                                             const TSecurityInfo& aMissing )
       
   218     {
       
   219     TRACE( T_LIT( "CBrandingServer::CustomFailureActionL() Request %d to session [%d] failed."),
       
   220                    aMsg.Function(), aMsg.Session() );
       
   221 
       
   222     TBuf<512> diagnosticMsg;
       
   223     _LIT( KDetails, "Failure details: ");
       
   224     diagnosticMsg.Append( KDetails );
       
   225     _LIT( KFormat, "SecureId[%d] VendorId[%d] Missing caps[" );
       
   226     diagnosticMsg.AppendFormat( KFormat,
       
   227                                 aMissing.iSecureId.iId, aMissing.iVendorId.iId );
       
   228 
       
   229     const SCapabilitySet& missingCaps = (const SCapabilitySet&) aMissing.iCaps;
       
   230     TBuf<1> separator;
       
   231     _LIT( KSeparator, "]" );
       
   232 	for( TInt ix = 0; ix < ECapability_Limit; ix++ )
       
   233 		{
       
   234 		if( missingCaps[ix>>5] &(1<<(ix&31)))
       
   235 			{
       
   236             diagnosticMsg.Append( separator );
       
   237 
       
   238             const char* capName = CapabilityNames[ ix ];
       
   239 		    while( *capName )
       
   240 		        {
       
   241                 TUint16 c = *capName;
       
   242                 diagnosticMsg.Append( &c, 1 );
       
   243                 ++capName;
       
   244                 }
       
   245 			
       
   246             separator = KSeparator;
       
   247     		}
       
   248 		}
       
   249 
       
   250     diagnosticMsg.Append( KSeparator );
       
   251     TRACE( T_LIT( "%S"), &diagnosticMsg );
       
   252 
       
   253     return CPolicyServer::EFail;
       
   254     }
       
   255 
       
   256 void CBSServer::HandleBackupStateL( TBackupState aState )
       
   257     {
       
   258     switch( aState )
       
   259         {
       
   260         case EBackupNotActive: // backup has completed
       
   261             {
       
   262             // restart install handler and check for brand changes
       
   263             iInstallHandler->InstallNewFilesL();
       
   264             iInstallHandler->StartObservingL();
       
   265             
       
   266             //notify clients that we're back in business
       
   267             break;
       
   268             }
       
   269         case EBackupActive: // backup activated
       
   270             {
       
   271             // stop install handler 
       
   272             iInstallHandler->StopObserving();
       
   273             
       
   274             // Notify clients that branding data is not currently 
       
   275             //       available
       
   276             break;
       
   277             }
       
   278         default:
       
   279             {
       
   280             // unknown state
       
   281             }
       
   282         }
       
   283     }
       
   284 
       
   285 void CBSServer::SessionCreatedL( CBSSession* aSession )
       
   286     {
       
   287     TRACE( T_LIT( "CBSServer::SessionCreatedL begin aSession[%d]"),aSession );
       
   288     iSessionCount++;
       
   289     iSessions.AppendL( aSession );
       
   290     }
       
   291 
       
   292 
       
   293 void CBSServer::SessionDied( CBSSession* aSession )
       
   294     {
       
   295     TInt count = iSessions.Count();
       
   296 	for( TInt i = 0; i < count; i++ )
       
   297 		{
       
   298 		if( iSessions[i] == aSession )
       
   299 			{
       
   300 			iSessions.Remove( i );
       
   301 			break;
       
   302 			}
       
   303 		}
       
   304 	TInt ignore = 0;
       
   305 	TRAP( ignore, UnRegisterSessionL( aSession ) );
       
   306 	
       
   307     //enable backup observer
       
   308 	iBackupObserver->UnregisterObserver( aSession );
       
   309     
       
   310     iSessionCount--;
       
   311     if( iSessionCount == 0 )
       
   312         {
       
   313         // Codescanner warning: using CActiveScheduler::Stop ( Id: 4)
       
   314         // it is required to stop the server
       
   315         CActiveScheduler::Stop(); // CSI: 4 # See above
       
   316         }
       
   317     }
       
   318 
       
   319 
       
   320 
       
   321 TBool CBSServer::MatchSessionL( const TDesC& aApplicationId,
       
   322 							    const TDesC& aBrandId,
       
   323 							    TLanguage aLanguageId,
       
   324 							 	CBSSession* aSession,
       
   325 							 	TInt aReserved  )
       
   326 	{
       
   327 	TInt sessionCount = iSessions.Count();
       
   328 	TBool returnValue = EFalse;
       
   329 	for( TInt i = 0; i < sessionCount; i++ )
       
   330 		{
       
   331 		if( iSessions[i] == aSession )
       
   332 			{
       
   333 			// we don't want to report the querying session itself
       
   334 			continue;
       
   335 			}
       
   336 		if( iSessions[i]->MatchSessionL( aApplicationId,
       
   337 										 aBrandId,
       
   338 										 aLanguageId,
       
   339 										 aReserved ) )
       
   340 			{
       
   341 			// even one match is enough for us
       
   342 			returnValue = ETrue;
       
   343 			break;
       
   344 			}
       
   345 		}
       
   346 	return returnValue;
       
   347 	}
       
   348 
       
   349 TBool CBSServer::MatchSessionUninstallL( const TDesC& aApplicationId,
       
   350 								 const TDesC& aBrandId, CBSSession* aSession)
       
   351 {
       
   352 	TInt sessionCount = iSessions.Count();
       
   353 	TBool returnValue = EFalse;
       
   354 	for( TInt i = 0; i < sessionCount; i++ )
       
   355 		{
       
   356 		if( iSessions[i] == aSession )
       
   357 			{
       
   358 			// we don't want to report the querying session itself
       
   359 			continue;
       
   360 			}
       
   361 		if( iSessions[i]->MatchSessionUninstallL( aApplicationId,
       
   362 										 aBrandId ))
       
   363 			{
       
   364 			// even one match is enough for us
       
   365 			returnValue = ETrue;
       
   366 			break;
       
   367 			}
       
   368 		}
       
   369 	return returnValue;
       
   370 	
       
   371 }
       
   372 
       
   373 void CBSServer::RegisterFileForSessionL( CBSSession* aSession, 
       
   374 										 const TDesC& aFile,
       
   375 										 TBool aVersioned )
       
   376 	{
       
   377 	TRACE( T_LIT( "CBSServer::RegisterFileForSessionL begin aSession[%d],aFile[%S]"),aSession,&aFile );
       
   378 	TBool found  = EFalse;
       
   379 	TInt count = iFileMapping.Count();		
       
   380 	for( TInt i = 0; i < count; i ++ )
       
   381 		{		
       
   382 		if( iFileMapping[i]->Session() == aSession && iFileMapping[i]->File() == aFile &&
       
   383 				iFileMapping[i]->Versioned() == aVersioned)
       
   384 			{
       
   385 				found = ETrue; 			
       
   386 			}			
       
   387 		}
       
   388 	
       
   389 	if(!found)
       
   390 		{			
       
   391 		
       
   392 		CBSFileMapping* fileMapping = CBSFileMapping::NewL( aSession, aFile, aVersioned );
       
   393 		CleanupStack::PushL( fileMapping );
       
   394 		iFileMapping.AppendL( fileMapping );
       
   395 		CleanupStack::Pop( fileMapping );
       
   396 		}
       
   397 	TRACE( T_LIT( "CBSServer::RegisterFileForSessionL end") );
       
   398 	}
       
   399 
       
   400 void CBSServer::UnRegisterSessionL( CBSSession* aSession )
       
   401 	{
       
   402 	TRACE( T_LIT( "CBSServer::RegisterFileForSessionL begin aSession[%d]"),aSession );
       
   403 	TInt count = iFileMapping.Count();
       
   404 	for( TInt i = 0; i < count; i ++ )
       
   405 		{
       
   406 		if( iFileMapping[i]->Session() == aSession )
       
   407 			{
       
   408 
       
   409 			if( !iStorageManager )
       
   410 				{
       
   411 				iStorageManager = CBSStorageManager::NewL( aSession, KNullDesC );	
       
   412 				}
       
   413 			if( !FileStillInUse( aSession, iFileMapping[i]->File() ) )
       
   414 				{
       
   415 				TPtrC baseFile = KNullDesC();
       
   416 				if( iFileMapping[i]->Versioned() )
       
   417 					{
       
   418 					baseFile.Set( iStorageManager->FilenameWithoutVersion( iFileMapping[i]->File() ) );
       
   419 					}
       
   420 				else
       
   421 					{
       
   422 					baseFile.Set( iFileMapping[i]->File() );
       
   423 					}
       
   424 				// we found the session, now check if any other
       
   425 				// session is using the same file
       
   426 				if( !FileStillInUse( aSession, baseFile ) )
       
   427 					{
       
   428 					// no other sessions using the file
       
   429 					// cleanup versioned file
       
   430 					CleanupFileL( iFileMapping[i]->File() );
       
   431 					}					
       
   432 
       
   433 				}
       
   434 			CBSFileMapping* fileMapping = iFileMapping[i];
       
   435 			iFileMapping.Remove( i );
       
   436 			delete fileMapping;
       
   437 			break;
       
   438 			}
       
   439 		}
       
   440 	TRACE( T_LIT( "CBSServer::RegisterFileForSessionL end") );
       
   441 	}
       
   442 
       
   443 TBool CBSServer::FileStillInUse( CBSSession* aSession,
       
   444 								 const TDesC& aFile )
       
   445 	{
       
   446 	TBool returnValue = EFalse;
       
   447 	TInt count = iFileMapping.Count();
       
   448 	for( TInt i = 0; i < count; i ++ )
       
   449 		{
       
   450 		if( 0 == iFileMapping[i]->File().Compare( aFile ) )
       
   451 			{
       
   452 			// file found, check that it's not the same sesion
       
   453 			if( iFileMapping[i]->Session() != aSession )
       
   454 				{
       
   455 
       
   456 				// it's not the same session
       
   457 				// so the file is still in use, we can
       
   458 				// return ETrue
       
   459 				returnValue = ETrue;
       
   460 				break;
       
   461 				}
       
   462 			}
       
   463 		}
       
   464 	return returnValue;
       
   465 	}
       
   466 		
       
   467 void CBSServer::CleanupFileL( const TDesC& aFile )
       
   468 	{
       
   469 	if( !iStorageManager )
       
   470 		{
       
   471 		iStorageManager = CBSStorageManager::NewL( NULL, KNullDesC);	
       
   472 		}
       
   473 	iStorageManager->CleanupFileL( aFile ); 
       
   474 	}
       
   475 
       
   476 TArray<CBSServer::CBSFileMapping*> CBSServer::RegisteredFiles()
       
   477 	{
       
   478 	return iFileMapping.Array();
       
   479 	}
       
   480 
       
   481 void CBSServer::InitializeL()
       
   482     {
       
   483     TRACE( T_LIT( "CBSServer::InitializeL begin") );
       
   484     // Initialize brand install handler
       
   485     iInstallHandler = CBSInstallHandler::NewL();
       
   486     iInstallHandler->InstallNewFilesL();
       
   487     iInstallHandler->StartObservingL();
       
   488     
       
   489     //to enable backup observer
       
   490     // Initialize backup and restore observer
       
   491     CBSBackupObserver* tmp = CBSBackupObserver::NewL();
       
   492     delete iBackupObserver;
       
   493     iBackupObserver = tmp;
       
   494     User::LeaveIfError( iBackupObserver->RegisterObserver( this ) );
       
   495     TRACE( T_LIT( "CBSServer::InitializeL end") );
       
   496     }
       
   497 
       
   498 void CBSServer::BrandUpdatedL( const TDesC& aApplicationId,
       
   499 							   const TDesC& aBrandId,
       
   500 							   TLanguage aLanguageId,
       
   501 							   CBSSession* aSession,
       
   502 							   TInt aReserved )
       
   503 	{
       
   504 	TRACE( T_LIT( "CBSServer::BrandUpdatedL begin aAppid[%S],aBrandId[%S]"),&aApplicationId, &aBrandId );
       
   505 	TInt sessionCount = iSessions.Count();
       
   506 	for( TInt i = 0; i < sessionCount; i++ )
       
   507 		{
       
   508 		if( iSessions[i] == aSession )
       
   509 			{
       
   510 			// we don't want to report the querying session itself
       
   511 			continue;
       
   512 			}
       
   513 		iSessions[i]->BrandUpdatedL( aApplicationId,
       
   514 									 aBrandId,
       
   515 									 aLanguageId,
       
   516 									 aReserved );
       
   517 		}
       
   518 	TRACE( T_LIT( "CBSServer::BrandUpdatedL end") );
       
   519 	}
       
   520 
       
   521 
       
   522 
       
   523 // ---------------------------------------------------------------------------
       
   524 // CBSServer::DisplaySessionInfoL display the info for each open session,
       
   525 // except for the one that called this method
       
   526 // ---------------------------------------------------------------------------
       
   527 //
       
   528 void CBSServer::DisplaySessionInfoL( CBSSession* aSession, TInt aErrorCode )
       
   529 	{
       
   530     TRACE( T_LIT( "CBSServer::DisplaySessionInfoL() begin aSession[%d], aErrorCode[%d]"),aSession,aErrorCode );
       
   531 
       
   532     User::LeaveIfNull( aSession );
       
   533     // some constants
       
   534     const TInt KStringLength = 512;
       
   535     const TInt KNumberLength = 16;
       
   536     _LIT( KMessage0,"Operation failed.Errorcode:");    
       
   537     _LIT( KMessage1," Info on open sessions [ProcessFileName|ThreadId|ProcessId|Caption]:");
       
   538     _LIT( KBracketOpen, " [");
       
   539     _LIT( KBracketClose, "]");
       
   540     _LIT( KSeparator, "|");
       
   541     
       
   542 
       
   543     HBufC* outputString = HBufC::NewLC( KStringLength );
       
   544     TPtr outputStringPtr( outputString->Des() );
       
   545 
       
   546     TBuf<KNumberLength> number;
       
   547     number.Num( aErrorCode );
       
   548     
       
   549     //make sure the string is long enough
       
   550     TInt newLength = outputString->Length() +
       
   551                      KMessage0().Length() +
       
   552                      number.Length() + 
       
   553                      KMessage1().Length();
       
   554     
       
   555     //reallocate if necessary
       
   556     if ( outputStringPtr.MaxLength() < newLength )
       
   557         {
       
   558         CleanupStack::Pop( outputString );
       
   559         outputString = outputString->ReAllocL( newLength );
       
   560         outputStringPtr.Set( outputString->Des() );
       
   561         CleanupStack::PushL( outputString );
       
   562         }    
       
   563         
       
   564     outputStringPtr.Append( KMessage0 );
       
   565     outputStringPtr.Append( number );
       
   566     outputStringPtr.Append( KMessage1 );
       
   567     
       
   568         
       
   569     TInt count = iSessions.Count();
       
   570 	TRACE( T_LIT( "CBSServer::DisplaySessionInfoL() numberSessions=%d"),count );
       
   571 	CBSSession* currentSession;
       
   572 	for( TInt i = 0; i < count; i++ )
       
   573 		{		
       
   574 		currentSession = iSessions[i];
       
   575         TRACE( T_LIT( "CBSServer::DisplaySessionInfoL() iteration=%d session=%d"),i,currentSession );
       
   576     	if ( currentSession 
       
   577     	     && currentSession->InfoAvailable()
       
   578     	     && currentSession != aSession )
       
   579     	    {
       
   580     		TBuf<KNumberLength> threadIdStr;
       
   581     		TThreadId threadId;
       
   582     		if ( KErrNone == currentSession->ThreadId( threadId ) )
       
   583     		    {
       
   584     		    threadIdStr.NumUC( threadId.Id(), EDecimal );
       
   585     		    }    		
       
   586     		TBuf<KNumberLength> processIdStr;
       
   587     		TProcessId processId;
       
   588     		if ( KErrNone == currentSession->ProcessId( processId ) )
       
   589     		    {
       
   590     		    processIdStr.NumUC( processId.Id(), EDecimal );
       
   591     		    }
       
   592             
       
   593             //make sure the string is long enough
       
   594             newLength = outputString->Length() +
       
   595                         KBracketOpen().Length() +
       
   596                         currentSession->FileName().Length() + 
       
   597                         threadIdStr.Length() + 
       
   598                         processIdStr.Length() +
       
   599                         currentSession->Caption().Length() +                        
       
   600                         ( 3 * KSeparator().Length() ) +                        
       
   601                         KBracketClose().Length();
       
   602 
       
   603             //reallocate if necessary
       
   604             if ( outputStringPtr.MaxLength() < newLength )
       
   605                 {
       
   606                 CleanupStack::Pop( outputString );
       
   607                 outputString = outputString->ReAllocL( newLength );
       
   608                 outputStringPtr.Set( outputString->Des() );
       
   609                 CleanupStack::PushL( outputString );
       
   610                 }
       
   611 
       
   612   		    outputStringPtr.Append( KBracketOpen );
       
   613     		
       
   614     		//processfilename
       
   615     		outputStringPtr.Append( currentSession->FileName() );
       
   616     		outputStringPtr.Append( KSeparator );
       
   617     		    		
       
   618     		//threadid    		
       
   619     		outputStringPtr.Append( threadIdStr );
       
   620     		outputStringPtr.Append( KSeparator );
       
   621     		
       
   622     		//processid    		
       
   623     		outputStringPtr.Append( processIdStr );
       
   624     		outputStringPtr.Append( KSeparator );	
       
   625     		
       
   626     		//caption
       
   627     		outputStringPtr.Append( currentSession->Caption() );    		
       
   628 
       
   629     		outputStringPtr.Append( KBracketClose );
       
   630     	    }
       
   631 		}     
       
   632 	
       
   633 	TRACE( T_LIT( "CBSServer::DisplaySessionInfoL() string creation OK") );
       
   634 	TRACE( T_LIT( "%S"), outputString );
       
   635 	CleanupStack::PopAndDestroy( outputString );
       
   636 	TRACE( T_LIT( "CBSServer::DisplaySessionInfoL() end") );
       
   637 	}
       
   638 	
       
   639 // ==============================================================
       
   640 // ====================== ENTRY POINT ===========================
       
   641 // ==============================================================
       
   642 GLDEF_C TInt E32Main()
       
   643     {
       
   644     TRACE( T_LIT("E32Main - enter") );
       
   645 
       
   646     User::RenameThread( KBSServerName );
       
   647 
       
   648     CTrapCleanup* tc = CTrapCleanup::New();
       
   649     if( !tc )
       
   650         {
       
   651         return KErrNoMemory;
       
   652         }
       
   653 
       
   654     TRAPD( err, CBSServer::ExecuteL() );
       
   655     delete tc;
       
   656 
       
   657     TRACE( T_LIT("E32Main - exit: %d"), err );
       
   658     return err;
       
   659     }
       
   660 
       
   661 
       
   662 
       
   663 //  END OF FILE
       
   664 
       
   665