|
1 /* |
|
2 * Copyright (c) 2004-2009 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: Harvester server* |
|
15 */ |
|
16 |
|
17 #ifndef __CHARVESTERSERVER__ |
|
18 #define __CHARVESTERSERVER__ |
|
19 |
|
20 #include <e32cmn.h> |
|
21 #include <apmrec.h> |
|
22 |
|
23 #include "mdeharvestersession.h" |
|
24 #include "contextengine.h" |
|
25 |
|
26 #include "harvesterplugin.h" |
|
27 #include "composerplugin.h" |
|
28 #include "harvesterplugininfo.h" |
|
29 #include "harvesterqueue.h" |
|
30 #include "harvesterao.h" |
|
31 #include "pauseobserverao.h" |
|
32 #include "harvestershutdownobserver.h" |
|
33 |
|
34 _LIT( KDefaultPanicName, "Harvester Server Panic" ); |
|
35 _LIT( KHarvesterServerName, "HarvesterServer" ); |
|
36 |
|
37 class CHarvesterServer : public CPolicyServer, |
|
38 public MHarvesterStatusObserver, |
|
39 public MHarvesterShutdownObserver |
|
40 { |
|
41 |
|
42 public: |
|
43 |
|
44 /** |
|
45 * Constructs a new harvester server implementation. |
|
46 * |
|
47 * @return Harvester server implementation |
|
48 */ |
|
49 static CHarvesterServer* NewL(); |
|
50 |
|
51 /** |
|
52 * Constructs a new harvester server implementation and leaves the server implementation |
|
53 * in the cleanup stack. |
|
54 * |
|
55 * @return Harvester server implementation. |
|
56 */ |
|
57 static CHarvesterServer* NewLC(); |
|
58 |
|
59 /** |
|
60 * C++ Constructor. |
|
61 * @param aPriority Server process priority. |
|
62 * @param aPolicy Server policies. |
|
63 * @param aType Indicates what session type server supports . |
|
64 */ |
|
65 CHarvesterServer( TInt aPriority, const TPolicy& aPolicy, TServerType aType ); |
|
66 |
|
67 /** |
|
68 * 2nd-phase construction, called by NewLC() |
|
69 */ |
|
70 void ConstructL(); |
|
71 |
|
72 /** |
|
73 * Destructor. |
|
74 */ |
|
75 virtual ~CHarvesterServer(); |
|
76 |
|
77 /** |
|
78 * Public method to start the server. |
|
79 * @param aNone Not used. |
|
80 * @return Error code. |
|
81 */ |
|
82 static TInt ThreadFunction( TAny* aNone ); |
|
83 |
|
84 /** |
|
85 * Method used to panic the client. |
|
86 * @param aMessage Message that is received from client. |
|
87 * @param aPanic Panic code which to raise on client side. |
|
88 * @param aPanicDescription Description of the panic. |
|
89 */ |
|
90 static void PanicClient( const RMessage2& aMessage, TInt aPanic, |
|
91 const TDesC& aPanicDescription = KDefaultPanicName ); |
|
92 |
|
93 /** |
|
94 * Method used to panic the server. |
|
95 * @param aPanic Panic code which to raise. |
|
96 * @param aPanicDescription Description of the panic. |
|
97 */ |
|
98 static void PanicServer( TInt aPanic, const TDesC& aPanicDescription = KDefaultPanicName ); |
|
99 |
|
100 /** |
|
101 * Method used to pause the server. |
|
102 * @param aMessage Message which was received from the client side. |
|
103 */ |
|
104 void Pause( const RMessage2& aMessage ); |
|
105 |
|
106 /** |
|
107 * Method used to resume the operation of the server. |
|
108 * @param aMessage Message which was received from the client side. |
|
109 */ |
|
110 void Resume( const RMessage2& aMessage ); |
|
111 |
|
112 /** |
|
113 * Method used to pause the server. |
|
114 */ |
|
115 void Pause(); |
|
116 |
|
117 /** |
|
118 * Method used to resume the operation of the server. |
|
119 */ |
|
120 void Resume(); |
|
121 |
|
122 /** |
|
123 * Method used to initiate harvesting of a file. |
|
124 * @param aMessage Message which was received from the client side. |
|
125 */ |
|
126 void HarvestFile( const RMessage2& aMessage ); |
|
127 |
|
128 /** |
|
129 * Method used to initiate harvesting of a file. |
|
130 * @param aMessage Message which was received from the client side. |
|
131 */ |
|
132 void HarvestFileWithUID( const RMessage2& aMessage ); |
|
133 |
|
134 /** |
|
135 * Register a processes's origin value. |
|
136 * @param aMessage Message which was received from the client side. |
|
137 */ |
|
138 void RegisterProcessOrigin( const RMessage2& aMessage ); |
|
139 |
|
140 /** |
|
141 * Unregister a process origin mapping. |
|
142 * @param aMessage Message which was received from the client side. |
|
143 */ |
|
144 void UnregisterProcessOrigin( const RMessage2& aMessage ); |
|
145 |
|
146 /** |
|
147 * Register a harvesting complete from server |
|
148 * @param aMessage Message which was received from the client side. |
|
149 */ |
|
150 TInt RegisterHarvestComplete( const CHarvesterServerSession& aSession, const RMessage2& aMessage ); |
|
151 |
|
152 /** |
|
153 * Unregister a harvesting complete from server |
|
154 * @param aSession harvester server session. |
|
155 */ |
|
156 TInt UnregisterHarvestComplete( const CHarvesterServerSession& aSession); |
|
157 |
|
158 /** |
|
159 * Register a harvester event from server |
|
160 * @param aMessage Message which was received from the client side. |
|
161 */ |
|
162 void RegisterHarvesterEvent( const RMessage2& aMessage ); |
|
163 |
|
164 /** |
|
165 * Unregister a harvester event from server |
|
166 * @param aMessage Message which was received from the client side. |
|
167 */ |
|
168 void UnregisterHarvesterEvent( const RMessage2& aMessage ); |
|
169 |
|
170 public: // MHarvesterStatusObserver |
|
171 virtual void PauseReady( TInt aError ); |
|
172 virtual void ResumeReady( TInt aError ); |
|
173 |
|
174 /** |
|
175 * Returns the ID of the latest registered event observer. |
|
176 * @param aMessage Message which was received from the client side. |
|
177 */ |
|
178 void GetLastObserverId( const RMessage2& aMessage ); |
|
179 |
|
180 public: // MHarvesterShutdownObserver |
|
181 |
|
182 void ShutdownNotification(); |
|
183 |
|
184 void RestartNotification(); |
|
185 |
|
186 protected: // Functions from base classes |
|
187 |
|
188 /** |
|
189 * From CPolicyServer. |
|
190 * Handles capability checking for certain server requests. |
|
191 * @param aMsg Message which was received from the client side |
|
192 * @param aAction |
|
193 * @param aMissing |
|
194 * @result return one of TCustomResult set {EPass, EFail, EAsync}. |
|
195 */ |
|
196 CPolicyServer::TCustomResult CustomSecurityCheckL( |
|
197 const RMessage2 &aMsg, TInt &aAction, TSecurityInfo &aMissing ); |
|
198 |
|
199 /** |
|
200 * From CPolicyServer. |
|
201 * Handles failure |
|
202 * @param aMsg Message which was received from the client side |
|
203 * @param aAction |
|
204 * @param aMissing |
|
205 * @result return one of TCustomResult set {EPass, EFail, EAsync}. |
|
206 */ |
|
207 CPolicyServer::TCustomResult CustomFailureActionL( |
|
208 const RMessage2 &aMsg, TInt aAction, const TSecurityInfo &aMissing ); |
|
209 |
|
210 private: |
|
211 |
|
212 /** |
|
213 * Method that initializes the server. |
|
214 */ |
|
215 static void ThreadFunctionL(); |
|
216 |
|
217 /** |
|
218 * RunError. |
|
219 * @param aError Error which has occurred |
|
220 * @return Error code - how operation should continue |
|
221 */ |
|
222 TInt RunError( TInt aError ); |
|
223 |
|
224 /** |
|
225 * Method used to create new server session. |
|
226 * @param Mandatory Client/Server framework parameter - not used |
|
227 * @param Mandatory Client/Server framework parameter - not used |
|
228 */ |
|
229 CSession2* NewSessionL( const TVersion&, const RMessage2& ) const; |
|
230 |
|
231 private: |
|
232 |
|
233 /** |
|
234 * Active Object which runs the harvesting operation |
|
235 */ |
|
236 CHarvesterAO* iHarvesterAO; |
|
237 |
|
238 const RMessage2* iMessage; |
|
239 |
|
240 /** |
|
241 * Pause P&S observer |
|
242 */ |
|
243 CPauseObserverAO* iPauseObserverAO; |
|
244 |
|
245 CHarvesterShutdownObserver* iShutdownObserver; |
|
246 |
|
247 }; |
|
248 |
|
249 #endif |