|
1 /** |
|
2 * Copyright (c) 2010 Sasken Communication Technologies Ltd. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Pritam Roy Biswas, Sasken Communication Technologies Ltd - Initial contribution |
|
11 * |
|
12 * Description: |
|
13 * Routines for Credential Manager Server. |
|
14 */ |
|
15 |
|
16 // Include Files |
|
17 #include <e32base.h> |
|
18 #include <e32std.h> |
|
19 #include <smfcredmgrcommon.h> |
|
20 |
|
21 #include "smfcredmgrserver.h" |
|
22 #include "smfcredmgrserversession.h" |
|
23 #include "smfcredmgrdb.h" |
|
24 |
|
25 // Perform all server initialisation, in particular creation of the |
|
26 // scheduler and server and then run the scheduler |
|
27 static void RunServerL() |
|
28 { |
|
29 // naming the server thread after the server helps to debug panics |
|
30 User::LeaveIfError(User::RenameThread(KCredMgrServerName)); |
|
31 |
|
32 // create and install the active scheduler we need |
|
33 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
34 CleanupStack::PushL(scheduler); |
|
35 CActiveScheduler::Install(scheduler); |
|
36 |
|
37 // create the server (leave it on the cleanup stack) |
|
38 CSmfCredMgrServer* server = CSmfCredMgrServer::NewL(); |
|
39 CleanupStack::PushL(server); |
|
40 |
|
41 // Initialisation complete, now signal the client |
|
42 RProcess::Rendezvous(KErrNone); |
|
43 |
|
44 // Run (will block until server exits) |
|
45 CActiveScheduler::Start(); |
|
46 |
|
47 // Cleanup the server and scheduler |
|
48 CleanupStack::PopAndDestroy(server); |
|
49 CleanupStack::PopAndDestroy(scheduler); |
|
50 } |
|
51 |
|
52 // Server process entry-point |
|
53 TInt E32Main() |
|
54 { |
|
55 |
|
56 __UHEAP_MARK; |
|
57 |
|
58 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
59 TInt r = KErrNoMemory; |
|
60 if (cleanup) |
|
61 { |
|
62 TRAP( r, RunServerL() ); |
|
63 delete cleanup; |
|
64 } |
|
65 |
|
66 __UHEAP_MARKEND; |
|
67 return r; |
|
68 } |
|
69 |
|
70 CSmfCredMgrServer::CSmfCredMgrServer() : |
|
71 CPolicyServer(CActive::EPriorityStandard, policy, EUnsharableSessions) |
|
72 { |
|
73 |
|
74 } |
|
75 |
|
76 /** |
|
77 * CSmfCredMgrServer::NewL() |
|
78 * Two-phased constructor. |
|
79 */ |
|
80 CSmfCredMgrServer* CSmfCredMgrServer::NewL() |
|
81 { |
|
82 CSmfCredMgrServer* Server = CSmfCredMgrServer::NewLC(); |
|
83 CleanupStack::Pop(Server); |
|
84 return Server; |
|
85 } |
|
86 |
|
87 /** |
|
88 * CSmfCredMgrServer::NewLC() |
|
89 * Two-phased constructor. |
|
90 */ |
|
91 CSmfCredMgrServer* CSmfCredMgrServer::NewLC() |
|
92 { |
|
93 CSmfCredMgrServer* Server = new (ELeave) CSmfCredMgrServer(); |
|
94 CleanupStack::PushL(Server); |
|
95 Server->ConstructL(); |
|
96 return Server; |
|
97 } |
|
98 |
|
99 /** |
|
100 * CSmfCredMgrServer::ConstructL() |
|
101 * Symbian 2nd phase constructor can leave. |
|
102 */ |
|
103 void CSmfCredMgrServer::ConstructL() |
|
104 { |
|
105 |
|
106 iDbCreator = CSmfCredMgrDb::NewL(); |
|
107 StartL(KCredMgrServerName); |
|
108 RDebug::Printf("in constructor CSmfCredMgrServer"); |
|
109 } |
|
110 |
|
111 /** |
|
112 * CSmfCredMgrServer::~CSmfCredMgrServer() |
|
113 * Destructor. |
|
114 */ |
|
115 CSmfCredMgrServer::~CSmfCredMgrServer() |
|
116 { |
|
117 delete iDbCreator; |
|
118 RDebug::Printf("in destructor CSmfCredMgrServer"); |
|
119 } |
|
120 |
|
121 /** |
|
122 * CSmfCredMgrServer::NewSessionL |
|
123 * Creates a new session with the server. |
|
124 */ |
|
125 CSession2* CSmfCredMgrServer::NewSessionL(const TVersion& aVersion, |
|
126 const RMessage2& /*aMessage*/) const |
|
127 { |
|
128 // Check that the version is OK |
|
129 TVersion v(KSecureServMajorVersionNumber, KSecureServMinorVersionNumber, |
|
130 KSecureServBuildVersionNumber); |
|
131 if (!User::QueryVersionSupported(v, aVersion)) |
|
132 User::Leave(KErrNotSupported); |
|
133 |
|
134 return CSmfCredMgrServerSession::NewL( |
|
135 *const_cast<CSmfCredMgrServer*> (this)); |
|
136 } |
|
137 |