|
1 /* |
|
2 * Copyright (c) 2006 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: Class CCatalogsClientServerServer declaration |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CATALOGS_CLIENT_SERVER_SERVER_H |
|
20 #define C_CATALOGS_CLIENT_SERVER_SERVER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 |
|
24 #include "catalogsshutdownoperation.h" |
|
25 |
|
26 class CCatalogsServerEngine; |
|
27 class MCatalogsSession; |
|
28 class MCatalogsContext; |
|
29 |
|
30 class CCatalogsClientServerServer : |
|
31 public CServer2, |
|
32 public MCatalogsShutdownOperationObserver |
|
33 { |
|
34 public: |
|
35 |
|
36 |
|
37 /** |
|
38 * Static constructor, leaves pointer on cleanup stack |
|
39 */ |
|
40 static CCatalogsClientServerServer* NewLC(); |
|
41 |
|
42 /** |
|
43 * Destructor |
|
44 */ |
|
45 virtual ~CCatalogsClientServerServer(); |
|
46 |
|
47 /** |
|
48 * Main function for the server thread. |
|
49 * |
|
50 * @since S60 ?S60_version |
|
51 * @param aNone Not used. |
|
52 * @return System wide error code. |
|
53 */ |
|
54 static TInt ThreadFunction( TAny* aNone ); |
|
55 |
|
56 /** |
|
57 * Increments the count of the active sessions for this server. |
|
58 * |
|
59 * @since S60 ?S60_version |
|
60 */ |
|
61 void IncrementSessions(); |
|
62 |
|
63 /** |
|
64 * Decrements the count of the active sessions for this server. |
|
65 * |
|
66 * @since S60 ?S60_version |
|
67 */ |
|
68 void DecrementSessions(); |
|
69 |
|
70 /** |
|
71 * Informs objects of session removal. They should not use |
|
72 * given session in anyway anymore |
|
73 * |
|
74 * @since S60 ?S60_version |
|
75 * @param aSession Session that is not in use anymore. |
|
76 */ |
|
77 void HandleSessionRemoval( MCatalogsSession& aSession ); |
|
78 |
|
79 /** |
|
80 * Create a new object container. Called by sessions. |
|
81 * |
|
82 * @since S60 ?S60_version |
|
83 * @return Created object container. |
|
84 */ |
|
85 CObjectCon* NewContainerL(); |
|
86 |
|
87 /** |
|
88 * Removes an object container. Called by sessions. |
|
89 * |
|
90 * @since S60 ?S60_version |
|
91 * @param aCon Container that should be removed. |
|
92 */ |
|
93 void RemoveContainer( CObjectCon* aCon ); |
|
94 |
|
95 |
|
96 /** |
|
97 * Adds an object to container. These objects are objects |
|
98 * that communicate to client-side. Called by sessions. Leaves |
|
99 * on error, but not if the object is tried to add for a second |
|
100 * time into the container. Then simply does not do anything. |
|
101 * |
|
102 * @since S60 ?S60_version |
|
103 * @param aObject Object that is communicable. |
|
104 */ |
|
105 void AddObjectToContainerL( CObject* aObject ); |
|
106 |
|
107 /** |
|
108 * Function that conveys provider creation request to the |
|
109 * engine. |
|
110 * |
|
111 * @since S60 ?S60_version |
|
112 * @param aSession Interface to register objects. |
|
113 * @param aProviderIdentifier Int (uid) to identify desired provider |
|
114 * @param aHandle Reference to an integer which is used to |
|
115 * pass the handle to the created provider back. |
|
116 * @param aProviderOptions Provider options |
|
117 */ |
|
118 void CreateProviderL( MCatalogsSession& aSession, |
|
119 TInt aProviderIdentifier, |
|
120 TInt& aHandle, |
|
121 TUint32 aProviderOptions ); |
|
122 |
|
123 TInt NewInstanceId(); |
|
124 |
|
125 /** |
|
126 * Adds a shutdown operation to the server's operation queue |
|
127 * The operation is deleted if appending fails |
|
128 * |
|
129 * @return Symbian error code |
|
130 */ |
|
131 static TInt AddShutdownOperation( CCatalogsShutdownOperation* aOperation ); |
|
132 |
|
133 /** |
|
134 * Executes/cancels shutdown operations for the given client |
|
135 * |
|
136 * @param aContext |
|
137 * @param aExecute If ETrue, shutdown operations are executed, |
|
138 * if false they are canceled |
|
139 */ |
|
140 void OperateShutdownOperations( |
|
141 const MCatalogsContext& aContext, |
|
142 TBool aExecute ); |
|
143 |
|
144 |
|
145 protected: // MCatalogsShutdownOperationObserver |
|
146 |
|
147 |
|
148 void ShutdownOperationComplete( |
|
149 CCatalogsShutdownOperation* aOperation, |
|
150 TInt aError ); |
|
151 |
|
152 |
|
153 protected: // Methods from CActive |
|
154 |
|
155 // from base class CActive |
|
156 |
|
157 /** |
|
158 * From CActive |
|
159 * @see CActive::RunError |
|
160 * |
|
161 * @since S60 ?S60_version |
|
162 */ |
|
163 TInt RunError( TInt aError ); |
|
164 |
|
165 private: |
|
166 |
|
167 /** |
|
168 * Constructor |
|
169 * |
|
170 * @param aPriority Priority for this thread. |
|
171 */ |
|
172 CCatalogsClientServerServer( TInt aPriority ); |
|
173 |
|
174 /** |
|
175 * Second phase construct. |
|
176 */ |
|
177 void ConstructL(); |
|
178 |
|
179 /** |
|
180 * Second stage startup for the server thread. |
|
181 * |
|
182 * @since S60 ?S60_version |
|
183 */ |
|
184 static void ThreadFunctionL(); |
|
185 |
|
186 |
|
187 // from base class CServer |
|
188 |
|
189 /** |
|
190 * From CServer |
|
191 * @see CServer::NewSessionL |
|
192 * |
|
193 * @since S60 ?S60_version |
|
194 */ |
|
195 CSession2* NewSessionL( const TVersion& aVersion, |
|
196 const RMessage2& aMsg ) const; |
|
197 |
|
198 private: |
|
199 |
|
200 static CCatalogsClientServerServer* iCatalogsServer; |
|
201 |
|
202 /** |
|
203 * Amount of sessions. |
|
204 */ |
|
205 TInt iSessionCount; |
|
206 |
|
207 /** |
|
208 * Server-side engine |
|
209 * Own. |
|
210 */ |
|
211 CCatalogsServerEngine* iEngine; |
|
212 |
|
213 |
|
214 /** |
|
215 * Object container index |
|
216 * Own. |
|
217 */ |
|
218 CObjectConIx* iContainerIndex; |
|
219 |
|
220 /** |
|
221 * Container of objects that are registered as objects which |
|
222 * communicate to client-side. |
|
223 * Own. |
|
224 */ |
|
225 CObjectCon* iContainer; |
|
226 |
|
227 #ifdef CATALOGS_UNDERTAKER |
|
228 |
|
229 RProcess iUndertakerProcess; |
|
230 |
|
231 #endif |
|
232 |
|
233 /** |
|
234 * Counter, used for identifying session instances. |
|
235 */ |
|
236 TInt iSessionInstanceIdCounter; |
|
237 |
|
238 RPointerArray<CCatalogsShutdownOperation> iShutdownOperations; |
|
239 }; |
|
240 |
|
241 #endif // C_CATALOGS_CLIENT_SERVER_SERVER_H |
|
242 |