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