|
1 /* |
|
2 * Copyright (c) 2010 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: server class implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 |
|
20 #include "locprivacyserver.h" |
|
21 #include "locprivacycommon.h" |
|
22 #include "locprivacyserversession.h" |
|
23 #include "locprivacyserverdebugpanic.h" |
|
24 #include "locutilsdebug.h" |
|
25 |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 // ================= MEMBER FUNCTIONS ======================= |
|
30 |
|
31 // C++ default constructor can NOT contain any code, that |
|
32 // might leave. |
|
33 // |
|
34 CLocPrivacyServer::CLocPrivacyServer(TInt aPriority) |
|
35 : CServer2(aPriority), |
|
36 iNumSessions(0) |
|
37 { |
|
38 // This does not do anything. |
|
39 __DECLARE_NAME(_S("CLocPrivacyServer")); |
|
40 } |
|
41 |
|
42 // EPOC default constructor can leave. |
|
43 void CLocPrivacyServer::ConstructL() |
|
44 { |
|
45 LOCUTILSDEBUG( "+CLocPrivacyServer::ConstructL" ) |
|
46 User::LeaveIfError(Start(KLocPrivacyServerName)); |
|
47 LOCUTILSDEBUG( "-CLocPrivacyServer::ConstructL" ) |
|
48 } |
|
49 |
|
50 // Two-phased constructor |
|
51 CLocPrivacyServer* CLocPrivacyServer::NewL() |
|
52 { |
|
53 CLocPrivacyServer* self = new (ELeave) CLocPrivacyServer(EPriority); |
|
54 CleanupStack::PushL(self); |
|
55 self->ConstructL(); |
|
56 CleanupStack::Pop(self); |
|
57 return self; |
|
58 } |
|
59 |
|
60 // Destructor |
|
61 CLocPrivacyServer::~CLocPrivacyServer() |
|
62 { |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------- |
|
66 // CLocPrivacyServer::IncrementSessions |
|
67 // |
|
68 // (other items were commented in a header). |
|
69 // --------------------------------------------------------- |
|
70 // |
|
71 void CLocPrivacyServer::IncrementSessions() |
|
72 { |
|
73 LOCUTILSDEBUG( "+CLocPrivacyServer::IncrementSessions" ) |
|
74 iNumSessions++; |
|
75 LOCUTILSDEBUG( "-CLocPrivacyServer::IncrementSessions" ) |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------- |
|
79 // CLocPrivacyServer::DecrementSessions |
|
80 // |
|
81 // (other items were commented in a header). |
|
82 // --------------------------------------------------------- |
|
83 // |
|
84 void CLocPrivacyServer::DecrementSessions( |
|
85 CLocPrivacyServerSession* /*aSession*/) |
|
86 { |
|
87 LOCUTILSDEBUG( "+CLocPrivacyServer::DecrementSessions" ) |
|
88 iNumSessions--; |
|
89 if (iNumSessions == 0) |
|
90 { |
|
91 // Shutdown the server by shutting down the active scheduler. |
|
92 CActiveScheduler::Stop(); |
|
93 } |
|
94 LOCUTILSDEBUG( "-CLocPrivacyServer::DecrementSessions" ) |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------- |
|
98 // CLocPrivacyServer::NewSessionL |
|
99 // |
|
100 // (other items were commented in a header). |
|
101 // --------------------------------------------------------- |
|
102 // |
|
103 CSession2* CLocPrivacyServer::NewSessionL( |
|
104 const TVersion& /*aVersion*/, |
|
105 const RMessage2& /*aMessage*/) const |
|
106 { |
|
107 LOCUTILSDEBUG( "+CLocPrivacyServer::NewSessionL" ) |
|
108 // Make new session |
|
109 CLocPrivacyServerSession* newSession = CLocPrivacyServerSession::NewL( |
|
110 const_cast<CLocPrivacyServer&>(*this)); |
|
111 |
|
112 LOCUTILSDEBUG( "-CLocPrivacyServer::NewSessionL" ) |
|
113 return newSession; |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------- |
|
117 // CLocPrivacyServer::RunError |
|
118 // This method is called by the active scheduler whenever an |
|
119 // untrapped leave occurs in the server active object. |
|
120 // (other items were commented in a header). |
|
121 // --------------------------------------------------------- |
|
122 // |
|
123 TInt CLocPrivacyServer::RunError(TInt aError) |
|
124 { |
|
125 LOCUTILSDEBUG( "-CLocPrivacyServer::RunError" ) |
|
126 Message().Complete(aError); |
|
127 ReStart(); |
|
128 LOCUTILSDEBUG( "-CLocPrivacyServer::RunError" ) |
|
129 return KErrNone; |
|
130 } |
|
131 |
|
132 |
|
133 // End of File |