|
1 /* |
|
2 * Copyright (c) 2004-2005 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: MPM Server Entry Point |
|
15 * |
|
16 */ |
|
17 |
|
18 /** |
|
19 @file mpmstarter.cpp |
|
20 Mobility Policy Manager server entry point. |
|
21 */ |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include <e32svr.h> |
|
25 |
|
26 #include "mpmstarter.h" |
|
27 #include "mpmserver.h" |
|
28 #include "mpmlogger.h" |
|
29 #include "mpmdefaultconnserver.h" |
|
30 |
|
31 // ============================= LOCAL FUNCTIONS =============================== |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // Perform all server initialisation, in particular creation of the |
|
35 // scheduler and server and then run the scheduler |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 static void RunServerL() |
|
39 { |
|
40 MPMLOGSTRING( "MPMStarter::RunServerL" ) |
|
41 // create and install the active scheduler we need |
|
42 CActiveScheduler* s=new( ELeave ) CActiveScheduler; |
|
43 CleanupStack::PushL( s ); |
|
44 CActiveScheduler::Install( s ); |
|
45 // |
|
46 // create the server |
|
47 CServer2* server = MPMStarter::CreateAndStartServerL(); |
|
48 CleanupStack::PushL( server ); |
|
49 |
|
50 // create default connection server |
|
51 CServer2* server2 = MPMStarter::CreateDefaultConnServerL( |
|
52 static_cast<CMPMServer*> ( server ) ); |
|
53 CleanupStack::PushL( server2 ); |
|
54 |
|
55 User::LeaveIfError( RThread::RenameMe( MPMStarter::ServerName() ) ); |
|
56 |
|
57 // Initialisation complete, now signal the client |
|
58 RProcess::Rendezvous( KErrNone ); |
|
59 |
|
60 // Ready to run |
|
61 CActiveScheduler::Start(); |
|
62 // |
|
63 // Cleanup the server and scheduler |
|
64 CleanupStack::PopAndDestroy( server2 ); |
|
65 CleanupStack::PopAndDestroy( server ); |
|
66 CleanupStack::PopAndDestroy( s ); |
|
67 } |
|
68 |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // Server process entry-point |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 GLDEF_C TInt E32Main() |
|
75 { |
|
76 __UHEAP_MARK; |
|
77 |
|
78 CTrapCleanup* cleanup=CTrapCleanup::New(); |
|
79 TInt r=KErrNoMemory; |
|
80 if ( cleanup ) |
|
81 { |
|
82 TRAP( r, RunServerL() ); |
|
83 delete cleanup; |
|
84 } |
|
85 #ifdef _DEBUG |
|
86 else |
|
87 { |
|
88 MPMLOGSTRING( "E32Main - null cleanup pointer!" ) |
|
89 } |
|
90 #endif // _DEBUG |
|
91 __UHEAP_MARKEND; |
|
92 #ifdef _DEBUG |
|
93 if ( ( r != KErrNone ) && ( r != KErrAlreadyExists ) ) |
|
94 { |
|
95 MPMLOGSTRING2( "E32Main - RunServerL made a leave: %i", r ) |
|
96 } |
|
97 #endif // _DEBUG |
|
98 return r; |
|
99 } |
|
100 |
|
101 |
|
102 // ============================ MEMBER FUNCTIONS =============================== |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // MPMStarter::CreateAndStartServerL |
|
106 // create server object |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 CServer2* MPMStarter::CreateAndStartServerL() |
|
110 { |
|
111 MPMLOGSTRING( "MPMStarter::CreateAndStartServerL" ) |
|
112 return CMPMServer::NewL(); |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // MPMStarter::CreateDefaultConnServerL |
|
117 // create default connection server object |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 CServer2* MPMStarter::CreateDefaultConnServerL( CMPMServer* aMPMServer ) |
|
121 { |
|
122 MPMLOGSTRING( "MPMStarter::CreateDefaultConnServerL" ) |
|
123 return CMPMDefaultConnServer::NewL( aMPMServer ); |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // MPMStarter::ServerName |
|
128 // return server name |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 TPtrC MPMStarter::ServerName() |
|
132 { |
|
133 return KMPMServerName().Mid( 0 ); |
|
134 } |
|
135 |
|
136 // End of File |