|
1 // Copyright (c) 2005-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 |
|
18 // INCLUDE FILES |
|
19 #include <e32base.h> |
|
20 #include <lbsipc.h> |
|
21 //#include <StartPosServer.h> |
|
22 //#include "EPos_PosServerStartup.h" |
|
23 #include "EPos_CPosServer.h" |
|
24 #include "EPos_Global.h" |
|
25 |
|
26 #ifdef _DEBUG |
|
27 _LIT(KTraceFileName, "EPos_PosServerStartup.cpp"); |
|
28 #endif |
|
29 |
|
30 // ================= GLOBAL FUNCTIONS ======================= |
|
31 |
|
32 #ifdef _DEBUG |
|
33 void GlobalTraceCleanUp(TAny* /*aAny*/) |
|
34 { |
|
35 Global::TearDownTrace(); |
|
36 } |
|
37 #endif |
|
38 |
|
39 // ================= MEMBER FUNCTIONS ======================= |
|
40 |
|
41 // --------------------------------------------------------- |
|
42 // StartEposServerL |
|
43 // Server startup routine |
|
44 // --------------------------------------------------------- |
|
45 // |
|
46 void StartEposServerL() |
|
47 { |
|
48 |
|
49 // Rename thread to aid debugging |
|
50 User::LeaveIfError(RThread().RenameMe(KPositionServerName)); |
|
51 |
|
52 // Start scheduler and server |
|
53 |
|
54 CActiveScheduler* scheduler = new(ELeave) CActiveScheduler; |
|
55 CleanupStack::PushL(scheduler); |
|
56 CActiveScheduler::Install(scheduler); |
|
57 |
|
58 #ifdef _DEBUG |
|
59 Global::SetupTraceL(); |
|
60 TCleanupItem cItem(GlobalTraceCleanUp); |
|
61 CleanupStack::PushL(cItem); |
|
62 #endif |
|
63 |
|
64 DEBUG_TRACE("Creating server object...", __LINE__) |
|
65 CPosServer* server = CPosServer::NewL(); |
|
66 CleanupStack::PushL(server); |
|
67 |
|
68 DEBUG_TRACE("Rendezvous with LbsApi...", __LINE__) |
|
69 // Signal that we've started |
|
70 RProcess::Rendezvous(KErrNone); |
|
71 |
|
72 CleanupStack::Pop(server); |
|
73 |
|
74 #ifdef _DEBUG |
|
75 CleanupStack::Pop(); // GlobalTrace CleanupItem |
|
76 #endif |
|
77 CleanupStack::Pop(scheduler); |
|
78 |
|
79 DEBUG_TRACE("Starting scheduler...", __LINE__) |
|
80 CActiveScheduler::Start(); |
|
81 DEBUG_TRACE("Scheduler stopped, destroying server.", __LINE__) |
|
82 |
|
83 #ifdef _DEBUG |
|
84 Global::TearDownTrace(); |
|
85 #endif |
|
86 |
|
87 delete server; |
|
88 delete scheduler; |
|
89 } |
|
90 |
|
91 // |
|
92 // --------------------------------------------------------- |
|
93 // E32Dll |
|
94 // Server process entry-point |
|
95 // Recover the startup parameters and run the server |
|
96 // --------------------------------------------------------- |
|
97 TInt E32Main() |
|
98 { |
|
99 __UHEAP_MARK; |
|
100 |
|
101 CTrapCleanup* cleanupStack = CTrapCleanup::New(); |
|
102 |
|
103 TInt ret = KErrNoMemory; |
|
104 if (cleanupStack) |
|
105 { |
|
106 TRAP(ret, StartEposServerL()); |
|
107 delete cleanupStack; |
|
108 } |
|
109 |
|
110 __UHEAP_MARKEND; |
|
111 |
|
112 return ret; |
|
113 } |
|
114 |
|
115 // End of File |