messagingfw/msgtestproduct/testutils/src/MessagingTestUtilityServer2Main.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18 */
       
    19 
       
    20 #include "MessagingTestUtilityServer2.h"
       
    21 #include <messagingtestutility2.h>
       
    22 
       
    23 
       
    24 /**
       
    25 RunServerL()
       
    26 Perform all server initialisation, in particular creation of the
       
    27 scheduler and server and then run the scheduler
       
    28 */
       
    29 static void RunServerL()
       
    30 	{
       
    31 	// create and install the active scheduler we need
       
    32 	CActiveScheduler* s=new(ELeave) CActiveScheduler;
       
    33 	CleanupStack::PushL(s);
       
    34 	CActiveScheduler::Install(s);
       
    35 
       
    36 	//
       
    37 	// create the server (leave it on the cleanup stack)
       
    38 	CMessagingTestUtilityServer2::NewLC();
       
    39 	//
       
    40 	// naming the server thread after the server helps to debug panics
       
    41 	User::LeaveIfError(RThread::RenameMe(KTestServerName));
       
    42 	//
       
    43 	// Initialisation complete, now signal the client
       
    44 	RProcess::Rendezvous(KErrNone);
       
    45 	//
       
    46 	// Ready to run
       
    47 	CActiveScheduler::Start();
       
    48 
       
    49 	// Ready to exit.
       
    50 	// Cleanup the server and scheduler
       
    51 	CleanupStack::PopAndDestroy(2);
       
    52 	}
       
    53 
       
    54 /**
       
    55 RunMessagingTestUtilityServer()
       
    56 Main entry-point for the server thread
       
    57 
       
    58 @return
       
    59 KErrNone on successful execution, else some systemwide error.
       
    60 */
       
    61 static TInt RunMessagingTestUtilityServer()
       
    62 	{
       
    63 	__UHEAP_MARK;
       
    64 	//
       
    65 	CTrapCleanup* cleanup=CTrapCleanup::New();
       
    66 	TInt r=KErrNoMemory;
       
    67 	if (cleanup)
       
    68 		{
       
    69 		TRAP(r,RunServerL());
       
    70 		delete cleanup;
       
    71 		}
       
    72 	//
       
    73 	__UHEAP_MARKEND;
       
    74 	return r;
       
    75 	}
       
    76 
       
    77 
       
    78 /**
       
    79 E32Main()
       
    80 EXE entry point function.
       
    81 
       
    82 @return
       
    83 KErrNone on successful execution, else some systemwide error.
       
    84 */
       
    85 TInt E32Main()
       
    86 	{
       
    87 	return RunMessagingTestUtilityServer();
       
    88 	}
       
    89