|
1 /* |
|
2 * Copyright (c) 2009-2010 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: |
|
15 * Creates and starts the server. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "cmmstarter.h" |
|
21 |
|
22 |
|
23 // |
|
24 // Perform all server initialisation, in particular creation of the scheduler |
|
25 // and server and then run the scheduler. |
|
26 // |
|
27 static void RunServerL() |
|
28 { |
|
29 // Create and install the active scheduler we need. |
|
30 CActiveScheduler* s = new( ELeave ) CActiveScheduler; |
|
31 CleanupStack::PushL( s ); |
|
32 CActiveScheduler::Install( s ); |
|
33 |
|
34 // Create the server. |
|
35 CServer2* server = CCmmStarter::CreateAndStartServerL(); |
|
36 CleanupStack::PushL( server ); |
|
37 |
|
38 // Naming the server thread after server startup helps to debug panics. |
|
39 User::LeaveIfError( RThread::RenameMe( CCmmStarter::ServerName() ) ); |
|
40 |
|
41 // Initialisation complete, now signal the client. |
|
42 RProcess::Rendezvous( KErrNone ); |
|
43 |
|
44 // Ready to run. |
|
45 CActiveScheduler::Start(); |
|
46 |
|
47 // Cleanup the server and scheduler. |
|
48 CleanupStack::PopAndDestroy( server ); |
|
49 CleanupStack::PopAndDestroy( s ); |
|
50 } |
|
51 |
|
52 // |
|
53 // Server process entry-point. |
|
54 // |
|
55 TInt E32Main() |
|
56 { |
|
57 // __UHEAP_MARK; |
|
58 |
|
59 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
60 TInt r = KErrNoMemory; |
|
61 if ( cleanup ) |
|
62 { |
|
63 TRAP( r, RunServerL() ); |
|
64 delete cleanup; |
|
65 } |
|
66 |
|
67 // __UHEAP_MARKEND; |
|
68 return r; |
|
69 } |
|
70 |
|
71 // End of file |