|
1 // Copyright (c) 1997-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 // Server startup code and session object implementation. |
|
15 // |
|
16 // |
|
17 |
|
18 #include "EComDebug.h" |
|
19 #include "EComServerStart.h" |
|
20 #include "EComServer.h" |
|
21 |
|
22 // __________________________________________________________________________ |
|
23 // Server startup code |
|
24 static void RunServerL() |
|
25 // |
|
26 // Perform all server initialisation, in particular creation of the |
|
27 // scheduler and server and then run the scheduler |
|
28 // |
|
29 { |
|
30 // naming the server thread after the server helps to debug panics |
|
31 User::LeaveIfError(User::RenameThread(KEComServerName)); |
|
32 // |
|
33 // create and install the active scheduler we need |
|
34 CActiveScheduler* scheduler=new(ELeave) CActiveScheduler; |
|
35 CleanupStack::PushL(scheduler); |
|
36 CActiveScheduler::Install(scheduler); |
|
37 // |
|
38 // create the server (leave it on the cleanup stack) |
|
39 CEComServer::NewLC(); |
|
40 // |
|
41 // Initialisation complete, now signal the client |
|
42 RProcess::Rendezvous(KErrNone); |
|
43 // |
|
44 // Ready to run |
|
45 __ECOM_TRACE("ECOM: Server ready, starting active scheduler"); |
|
46 CActiveScheduler::Start(); |
|
47 // |
|
48 // Cleanup the server and scheduler |
|
49 CleanupStack::PopAndDestroy(2, scheduler); |
|
50 } |
|
51 |
|
52 |
|
53 |
|
54 TInt ServerStart() |
|
55 { |
|
56 CTrapCleanup* cleanup=CTrapCleanup::New(); |
|
57 TInt err=KErrNoMemory; |
|
58 if (cleanup) |
|
59 { |
|
60 TRAP(err,RunServerL()); |
|
61 if (err != KErrNone) |
|
62 { |
|
63 __ECOM_LOG1("ECOM: Server unexpectedly exited, error = %d", err); |
|
64 } |
|
65 delete cleanup; |
|
66 } |
|
67 return err; |
|
68 } |
|
69 |
|
70 // |
|
71 // Main entry-point for the server thread |
|
72 // |
|
73 #ifndef __ECOMSERVER_TESTING__ |
|
74 TInt E32Main() |
|
75 // |
|
76 // Server process entry-point |
|
77 // Recover the startup parameters and run the server |
|
78 // |
|
79 { |
|
80 __UHEAP_MARK; |
|
81 __ECOM_TRACE("ECOM: Server started, initialisation begun"); |
|
82 |
|
83 TInt err = ServerStart(); |
|
84 |
|
85 __UHEAP_MARKEND; |
|
86 return err; |
|
87 } |
|
88 #endif // __ECOMSERVER_TESTING__ |