1 /* |
|
2 * Copyright (c) 2007 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: Location Centre Server object. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // SYSTEM INCLUDES |
|
20 |
|
21 // USER INCLUDES |
|
22 #include "lcserver.h" |
|
23 #include "lcserverinterface.h" |
|
24 #include "lcserversession.h" |
|
25 #include "lcservershutdowntimer.h" |
|
26 #include "lcserverengine.h" |
|
27 |
|
28 // CONSTANT DEFINTIONS |
|
29 |
|
30 // ----- Member funtions for CLcServer --------------------------------- |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // CLcServer::CLcServer |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 CLcServer::CLcServer() |
|
37 :CServer2( CActive::EPriorityStandard ) |
|
38 { |
|
39 // C++ Default constructor. No allocations or functions which can Leave |
|
40 // should be called from here. |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // CLcServer::~CLcServer |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 CLcServer::~CLcServer() |
|
48 { |
|
49 // C++ Destructor. Free all resources associated with this class. |
|
50 |
|
51 // Delete the Server Engine. |
|
52 delete iEngine; |
|
53 |
|
54 // Delete the shutdown timer. |
|
55 delete iShutDownTimer; |
|
56 |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // CLcServer* CLcServer::NewL |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 CLcServer* CLcServer::NewL() |
|
64 { |
|
65 CLcServer* self = NewLC(); |
|
66 CleanupStack::Pop( self ); |
|
67 return self; |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // CLcServer* CLcServer::NewLC |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 CLcServer* CLcServer::NewLC() |
|
75 { |
|
76 // Symbian Two phased constructor. Leaves the object on the Clean-up |
|
77 // stack. |
|
78 CLcServer* self = new ( ELeave )CLcServer(); |
|
79 CleanupStack::PushL( self ); |
|
80 self->ConstructL(); |
|
81 return self; |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // void CLcService::ConstructL |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 void CLcServer::ConstructL() |
|
89 { |
|
90 // Start the Location Centre Server |
|
91 StartL( KLocationCentreServerName ); |
|
92 |
|
93 // Create the shutdown timer |
|
94 iShutDownTimer = CLcServerShutDownTimer::NewL(); |
|
95 |
|
96 // Create the Location Centre Server Engine. |
|
97 iEngine = CLcServerEngine::NewL( *this ); |
|
98 } |
|
99 |
|
100 // --------------------------------------------------------------------------- |
|
101 // CSession2* CLcServer::NewSessionL |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 CSession2* CLcServer::NewSessionL( const TVersion& aVersion, |
|
105 const RMessage2& /* aMessage */ ) const |
|
106 { |
|
107 // Check the version number. We dont support any other version numbers |
|
108 // greater than ( 1, 0, 0 ). Hence, if the version number passed to this |
|
109 // function is greater than the supported number leave with KErrNotSupported. |
|
110 TVersion version( KLcServerMajorVersionNumber, |
|
111 KLcServerMinorVersionNumber, |
|
112 KLcServerBuildVersionNumber ); |
|
113 if ( !User::QueryVersionSupported( version, aVersion )) |
|
114 { |
|
115 User::Leave( KErrNotSupported ); |
|
116 } |
|
117 |
|
118 // Make new session |
|
119 CSession2* newSession = |
|
120 CLcServerSession::NewL( *( const_cast< CLcServer* >( this )), |
|
121 *iEngine ); |
|
122 |
|
123 return newSession; |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // void CLcServer::IncrementSessions |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 void CLcServer::IncrementSessions() |
|
131 { |
|
132 // Increment the number of sessions |
|
133 iNumberofSessions++; |
|
134 |
|
135 // Stop the Shutdown timer. This function does nothing if the timer |
|
136 // is not already running. |
|
137 iShutDownTimer->StopTimer(); |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------------------------- |
|
141 // void CLcServer::DecrementSessions |
|
142 // --------------------------------------------------------------------------- |
|
143 // |
|
144 void CLcServer::DecrementSessions() |
|
145 { |
|
146 |
|
147 // If the number of sessions is equal to zero then start the shutdown |
|
148 // timer. |
|
149 if ( --iNumberofSessions == 0 ) |
|
150 { |
|
151 iShutDownTimer->StartTimer(); |
|
152 } |
|
153 } |
|
154 |
|
155 // --------------------------------------------------------------------------- |
|
156 // void CLcServer::LcRegistryUpdated |
|
157 // --------------------------------------------------------------------------- |
|
158 // |
|
159 void CLcServer::LcRegistryUpdated() |
|
160 { |
|
161 // Inform all the Sessions contained here that there is an update to the |
|
162 // registry so that they can inform any clients which have registered |
|
163 // for notification |
|
164 iSessionIter.SetToFirst(); |
|
165 |
|
166 while ( iSessionIter ) |
|
167 { |
|
168 // Obtain the element at the current position and notify the corresponding |
|
169 // session object. |
|
170 CLcServerSession& session = static_cast <CLcServerSession&>( *iSessionIter ); |
|
171 session.RegistryUpdated(); |
|
172 |
|
173 // Increment the Session object to point to the next session instance |
|
174 iSessionIter++; |
|
175 } |
|
176 } |
|
177 // End of File |
|