|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __CSEARCHSERVER_H__ |
|
19 #define __CSEARCHSERVER_H__ |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <e32base.h> |
|
23 #include "SearchServer.pan" |
|
24 |
|
25 class CHouseKeepingHandler; |
|
26 |
|
27 // CLASS DECLARATION |
|
28 /** |
|
29 * CSearchServer |
|
30 */ |
|
31 class CSearchServer : public CPolicyServer |
|
32 { |
|
33 public : // Constructors and destructors |
|
34 |
|
35 /** |
|
36 * NewL. |
|
37 * Two-phased constructor. |
|
38 * @return Pointer to created CSearchServer object. |
|
39 */ |
|
40 static CSearchServer* NewL(); |
|
41 |
|
42 /** |
|
43 * NewLC. |
|
44 * Two-phased constructor. |
|
45 * @return Pointer to created CSearchServer object. |
|
46 */ |
|
47 static CSearchServer* NewLC(); |
|
48 |
|
49 /** |
|
50 * ~CSearchServer. |
|
51 * Destructor. |
|
52 */ |
|
53 virtual ~CSearchServer(); |
|
54 |
|
55 public: // New functions |
|
56 |
|
57 /** |
|
58 * ThreadFunction. |
|
59 * Main function for the server thread. |
|
60 * @return Error code. |
|
61 */ |
|
62 static void ThreadFunction(); |
|
63 |
|
64 /** |
|
65 * NewContainerL. |
|
66 * Returns an object container, and guaranteed |
|
67 * to produce object containers with unique |
|
68 * ids within the server. |
|
69 * Called by a new session to create a container |
|
70 * Containers created by this method MUST be release |
|
71 * with RemoveContainer method. |
|
72 */ |
|
73 CObjectCon* NewContainerL(); |
|
74 |
|
75 /** |
|
76 * RemoveContainer. |
|
77 * Removes a container created by NewContainerL |
|
78 */ |
|
79 void RemoveContainer(CObjectCon* aContainer); |
|
80 |
|
81 /** |
|
82 * HandleHeartBeatL. |
|
83 * From MHeartBeatObserver |
|
84 * Called by the CHeartBeatTimer |
|
85 */ |
|
86 void HandleHeartBeatL(); |
|
87 |
|
88 /** |
|
89 * Stop housekeeping |
|
90 */ |
|
91 void StopHouseKeeping(); |
|
92 |
|
93 /** |
|
94 * Continue housekeeping |
|
95 */ |
|
96 void ContinueHouseKeeping(); |
|
97 |
|
98 /** |
|
99 * Force housekeeping |
|
100 */ |
|
101 void ForceHouseKeeping(); |
|
102 |
|
103 public: // For CSearchServerSession |
|
104 |
|
105 /** |
|
106 * Increments session count by one |
|
107 */ |
|
108 void AddSession(); |
|
109 |
|
110 /** |
|
111 * Reduces session count by one. May cause the server |
|
112 * shutdown, if server is preparing for one. |
|
113 */ |
|
114 void RemoveSession(); |
|
115 |
|
116 /** |
|
117 * Starts shutting down |
|
118 */ |
|
119 void ShutDown(); |
|
120 |
|
121 private: // Constructors and destructors |
|
122 |
|
123 /** |
|
124 * CSearchServer. |
|
125 * C++ default constructor. |
|
126 * @param aPriority priority for this thread. |
|
127 */ |
|
128 CSearchServer( TInt aPriority ); |
|
129 |
|
130 /** |
|
131 * ConstructL. |
|
132 * 2nd phase constructor. |
|
133 */ |
|
134 void ConstructL(); |
|
135 |
|
136 private: // New methods |
|
137 |
|
138 /** |
|
139 * PanicClient. |
|
140 * Panics the client. |
|
141 * @param aMessage The message channel to the client. |
|
142 * @param aReason The reason code for the panic. |
|
143 */ |
|
144 static void PanicClient( const RMessage2& aMessage, |
|
145 TSearchServerPanic aReason ); |
|
146 |
|
147 /** |
|
148 * PanicServer. |
|
149 * Panics the server. |
|
150 * @param aPanic The panic code. |
|
151 */ |
|
152 static void PanicServer( TSearchServerPanic aPanic ); |
|
153 |
|
154 /** |
|
155 * ThreadFunctionL. |
|
156 * Second stage startup for the server thread. |
|
157 */ |
|
158 static void ThreadFunctionL(); |
|
159 |
|
160 private: // Functions from base classes |
|
161 |
|
162 /** |
|
163 * From CServer, NewSessionL. |
|
164 * Creates a time server session. |
|
165 * @param aVersion The client version. |
|
166 * @param aMessage Message from client. |
|
167 * @return Pointer to new session. |
|
168 */ |
|
169 CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const; |
|
170 |
|
171 private: // Internal state declaration |
|
172 |
|
173 enum TState |
|
174 { |
|
175 EUp, |
|
176 EShuttingDown |
|
177 }; |
|
178 |
|
179 private: // Data |
|
180 |
|
181 // The server has an object container index that |
|
182 // creates an object container for each session. |
|
183 CObjectConIx* iContainerIndex; |
|
184 |
|
185 TState iState; |
|
186 |
|
187 TInt iSessionCount; |
|
188 |
|
189 // House keeping handler |
|
190 CHouseKeepingHandler* iHouseKeepingHandler; |
|
191 }; |
|
192 |
|
193 #endif // __CSEARCHSERVER_H__ |
|
194 |
|
195 // End of File |