|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "cmodematsrv.h" |
|
21 #include "modematclientsrv.h" |
|
22 #include "modemattrace.h" |
|
23 |
|
24 static void RunServerL(); |
|
25 |
|
26 /** |
|
27 * Main entry-point for the server process. |
|
28 **/ |
|
29 GLDEF_C TInt E32Main() |
|
30 { |
|
31 |
|
32 |
|
33 __UHEAP_MARK; |
|
34 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
35 TInt retTrap = KErrNoMemory; |
|
36 if ( cleanup ) |
|
37 { |
|
38 TRAP( retTrap, RunServerL() ); |
|
39 delete cleanup; |
|
40 } |
|
41 __UHEAP_MARKEND; |
|
42 |
|
43 return retTrap; |
|
44 } |
|
45 |
|
46 /** |
|
47 Create the active scheduler and server instances, and start the |
|
48 server. |
|
49 */ |
|
50 static void RunServerL() |
|
51 { |
|
52 |
|
53 TFindServer find( KATExtSrvName ); |
|
54 TFullName name; |
|
55 |
|
56 if ( find.Next(name) == KErrNone ) |
|
57 { |
|
58 // Server is already up |
|
59 C_TRACE((_L("ext srv already running."))); |
|
60 return; |
|
61 } |
|
62 |
|
63 User::LeaveIfError( User::RenameThread(KATExtSrvName) ); |
|
64 // Create and install the active scheduler. |
|
65 CActiveScheduler* scheduler = new(ELeave) CActiveScheduler; |
|
66 CleanupStack::PushL( scheduler ); |
|
67 CActiveScheduler::Install( scheduler ); |
|
68 |
|
69 // Create the server. |
|
70 CModemAtSrv::NewLC(); |
|
71 |
|
72 // Initialisation complete, now signal the client |
|
73 RProcess::Rendezvous( KErrNone ); |
|
74 |
|
75 // Ready to run. This only returns when the server is closing down. |
|
76 CActiveScheduler::Start(); |
|
77 |
|
78 // Clean up the server and scheduler. |
|
79 CleanupStack::PopAndDestroy( 2 ); |
|
80 } |
|
81 |