229 CEventMediatorServer(void); |
239 CEventMediatorServer(void); |
230 |
240 |
231 /** |
241 /** |
232 * Perform the second phase construction of a CVpnManagerServer |
242 * Perform the second phase construction of a CVpnManagerServer |
233 * object. |
243 * object. |
234 * @param aServer Pointer to the server itself. |
244 */ |
235 */ |
245 void ConstructL(); |
236 void ConstructL(CEventMediatorServer* aServer); |
|
237 |
246 |
238 // Other methods |
247 // Other methods |
239 |
248 |
240 /** |
|
241 * Stops the server if the session count is zero. |
|
242 */ |
|
243 void StopEventMediator(void); |
|
244 |
|
245 /** |
|
246 * Copies data describing an event to the client. |
|
247 * @param aMessge: a message from client side sent by RConnection::FetchData |
|
248 * @return error code, KErrNone if successfull |
|
249 */ |
|
250 TInt CopyEventDataL(const RMessage2& aMessage); |
|
251 |
249 |
252 /** |
250 /** |
253 * Reduces listener count of a stored event by one and destroys it if count becomes zero. |
251 * Reduces listener count of a stored event by one and destroys it if count becomes zero. |
254 * @param aIndex: the index of the stored event in the list. |
252 * @param aIndex: the index of the stored event in the list. |
255 */ |
253 */ |
256 void MarkStoredEventListened(TInt aIndex); |
254 void MarkStoredEventListened(TInt aIndex); |
257 |
|
258 /** |
|
259 * Sets the iShuttingDown flag. |
|
260 */ |
|
261 void SetShuttingDown(TBool aShuttingDown); |
|
262 |
255 |
263 private: //Data |
256 private: //Data |
264 // List of Events that have been reported but not handled by all listeners. |
257 // List of Events that have been reported but not handled by all listeners. |
265 CArrayFixFlat<TEventContainer*> iStoredEvents; |
258 CArrayFixFlat<TEventContainer*> iStoredEvents; |
266 // Number of currently existing sessions. |
259 // Number of currently existing sessions. |
267 TInt iSessionCount; |
260 mutable TInt iSessionCount; |
268 // Log writer |
261 // Log writer |
269 CEventLogger* iLogger; |
262 CEventLogger* iLogger; |
270 // The next event specification ID |
263 // The next event specification ID |
271 // (used with SIT event listening requests) |
264 // (used with SIT event listening requests) |
272 TInt iNextEventSpecId; |
265 TInt iNextEventSpecId; |
288 static const CPolicyServer::TPolicyElement iElements[]; |
281 static const CPolicyServer::TPolicyElement iElements[]; |
289 static const CPolicyServer::TPolicy iPolicy; |
282 static const CPolicyServer::TPolicy iPolicy; |
290 |
283 |
291 }; |
284 }; |
292 |
285 |
293 // CLASS DECLARATION |
|
294 |
|
295 /** |
|
296 * Defines the session to the VPN manager server. |
|
297 */ |
|
298 class CEventMediatorSession : public CSession2 |
|
299 { |
|
300 public: //Message types |
|
301 enum |
|
302 { |
|
303 KEventMediatorListen, |
|
304 KEventMediatorListenWithSpec, |
|
305 KEventMediatorCancel, |
|
306 KEventMediatorCancelWithSpec, |
|
307 KEventMediatorCancelAll, |
|
308 KEventMediatorReportEvent, |
|
309 KEventMediatorReportEventWithSpec, |
|
310 KEventMediatorFetchData, |
|
311 KEventMediatorReportLogEvent, |
|
312 KEventMediatorNewEventSpecId, |
|
313 KEventMediatorDeletePrivateFiles, |
|
314 KEventMediatorGetEventLogSize, |
|
315 KEventMediatorGetEventLogHeader, |
|
316 KEventMediatorGetEventLogData, |
|
317 KEventMediatorClearEventLog |
|
318 }; |
|
319 |
|
320 public: // Methods |
|
321 |
|
322 // Constructors and destructor |
|
323 |
|
324 /** |
|
325 * Static constructor |
|
326 */ |
|
327 static CEventMediatorSession* NewL(CEventMediatorServer* aServer, const RMessage2& aMessage); |
|
328 |
|
329 /** |
|
330 * Default destructor |
|
331 */ |
|
332 ~CEventMediatorSession(void); |
|
333 |
|
334 /** |
|
335 * Wrapper function which Dispatches and executes the client's service calls |
|
336 * (See Message type definition). |
|
337 */ |
|
338 void ServiceL(const RMessage2& aMessage); |
|
339 |
|
340 /** |
|
341 * Checks if client is listening events of the given type and completes message |
|
342 * sent by clients ListenToEvent function. The length of the event data and |
|
343 * the pointer to that data are written to the message. |
|
344 * @param aType: type of the event. |
|
345 * @param aSpec: additional info on event. |
|
346 * @param aData: event data. |
|
347 * @return number of listeners for the event was listened. |
|
348 */ |
|
349 TInt CheckEventL(const TEventType aType, const TDesC8* aSpec, const TDesC8* aData, TInt aStatus); |
|
350 |
|
351 /** |
|
352 * Tries to find a task request that is not being fulfilled |
|
353 * already |
|
354 */ |
|
355 CListenerContainer* FindWaitingTaskRequest(); |
|
356 |
|
357 /** |
|
358 * Retrieves the event listener object, if any, that is using |
|
359 * the SIT that is fulfilling the specified event. |
|
360 */ |
|
361 CListenerContainer* FindListener(TEventType aEventType, TInt aEventSpecId); |
|
362 |
|
363 /** |
|
364 * Retrieves the event listener object, if any, that is using |
|
365 * the SIT that is fulfilling the specified event. |
|
366 */ |
|
367 CListenerContainer* FindListener(TEventType aEventType, const TDesC8* aEventSpec); |
|
368 |
|
369 /** |
|
370 * Completes the specified listener if it is owned by the |
|
371 * session. Returns ETrue is the listener was found and |
|
372 * completed, EFalse otherwise. |
|
373 */ |
|
374 void CompleteListener(TEventType aEventType, const TDesC8* aEventSpec, TInt aStatus); |
|
375 |
|
376 void CompleteTaskRequests(TInt aStatus); |
|
377 |
|
378 TBool IsASitSession(); |
|
379 |
|
380 private: //Methods |
|
381 // Constructors and destructor |
|
382 |
|
383 /** |
|
384 * Constructor |
|
385 */ |
|
386 CEventMediatorSession(CEventMediatorServer* aServer); |
|
387 |
|
388 /** |
|
389 * Starts listening events of requesteed type by coping the message to iListenedEvents. |
|
390 * @param aMessage: aMessage sent by clients ListenToEvent function. |
|
391 * @return: error code, KErrNone if successfull. |
|
392 */ |
|
393 TInt ListenToEventWithSpecL(const RMessage2& aMessage); |
|
394 |
|
395 /** |
|
396 * Starts listening events of requesteed type by coping the message to iListenedEvents. |
|
397 * @param aMessage: aMessage sent by clients ListenToEvent function. |
|
398 * @return: error code, KErrNone if successfull. |
|
399 */ |
|
400 TInt ListenToEventL(const RMessage2& aMessage); |
|
401 |
|
402 /** |
|
403 * Reports the event contained in the message to the event mediator server. |
|
404 * @param aMessage: aMessage sent by clients ReportEvent function. |
|
405 * @return: error code, KErrNone if successfull. |
|
406 */ |
|
407 void ReportEventL(const RMessage2& aMessage); |
|
408 |
|
409 /** |
|
410 * Reports a log event contained in the message to the event mediator server. |
|
411 * @param aMessage: aMessage sent by clients ReportLogEvent function. |
|
412 * @return: error code, KErrNone if successfull. |
|
413 */ |
|
414 void ReportLogEventL(const RMessage2& aMessage); |
|
415 |
|
416 /** |
|
417 * Reports the event contained in the message to the event mediator server. |
|
418 * @param aMessage: aMessage sent by clients ReportEvent function. |
|
419 * @return: error code, KErrNone if successfull. |
|
420 */ |
|
421 void ReportEventWithSpecL(const RMessage2& aMessage); |
|
422 |
|
423 /** |
|
424 * Cancels listning of one event type. |
|
425 * @param aMessage: aMessage sent by clients CancelListenToEvent function. |
|
426 */ |
|
427 void CancelListening(const RMessage2& aMessage); |
|
428 |
|
429 /** |
|
430 * Cancels listning of one event type. |
|
431 * @param aMessage: aMessage sent by clients CancelListenToEvent function. |
|
432 */ |
|
433 void CancelListeningWithSpecL(const RMessage2& aMessage); |
|
434 |
|
435 /** |
|
436 * Cancels all listening. |
|
437 * @param aMessage: aMessage sent by clients CancelAllListening function. |
|
438 */ |
|
439 void CancelAll(); |
|
440 |
|
441 /** |
|
442 * Copies event data from the server to the client. |
|
443 * @param aMessage: aMessage sent by clients FetchData function. |
|
444 * @return: error code, KErrNone if successfull. |
|
445 */ |
|
446 TInt FetchDataL(const RMessage2& aMessage); |
|
447 |
|
448 /** |
|
449 * Looks up a message from iListenedEvents. |
|
450 * @param aType: type of the event the message is listening to. |
|
451 * @param aIndex: the position of the message in iListenedEvents. |
|
452 * @return ETrue if message exists, EFalse if not. |
|
453 */ |
|
454 TBool FindListenerMsg(const TEventType aType,TInt& index); |
|
455 |
|
456 /** |
|
457 * Looks up a message from iListenedEvents. |
|
458 * @param aType: type of the event the message is listening to. |
|
459 * @param aIndex: the position of the message in iListenedEvents. |
|
460 * @return ETrue if message exists, EFalse if not. |
|
461 */ |
|
462 TBool FindListenerMsg(const TEventType aType,const TDesC8* aSpec,TInt& index); |
|
463 |
|
464 /** |
|
465 * Searches for a task request type event listening request |
|
466 */ |
|
467 TBool FindTaskRequestListenerMsg(TInt& index); |
|
468 |
|
469 /** |
|
470 * Reads data that was reported with the event from client. Allocates a buffer |
|
471 * for data and gives ownership of that buffer to caller. |
|
472 * @param aMessage: aMessage sent by clients ReportEvent function. |
|
473 * @return pointer to the newly created buffer containig data. |
|
474 */ |
|
475 HBufC8* ReadEventDataFromClientL(const RMessage2& aMessage); |
|
476 |
|
477 /** |
|
478 * Reads specification describing the event from client. Allocates a buffer |
|
479 * for secification and gives ownership of that buffer to caller. |
|
480 * @param aMessage: aMessage sent with event specification. |
|
481 * @return pointer to the newly created buffer containig data. |
|
482 */ |
|
483 HBufC8* ReadSpecificationFromClientL(const RMessage2& aMessage); |
|
484 |
|
485 /** |
|
486 * Completes the specified listener and deletes it from the |
|
487 * listener list |
|
488 */ |
|
489 void CompleteListener(TInt aIndex, TInt aStatus); |
|
490 |
|
491 /** |
|
492 * Returns to the client a new event specification ID |
|
493 */ |
|
494 void NewEventSpecIdL(const RMessage2& aMessage); |
|
495 |
|
496 TInt DeletePrivateFiles(); |
|
497 void DeletePrivateFilesL(); |
|
498 |
|
499 TInt GetEventLogSize(const RMessage2& aMessage); |
|
500 TInt GetEventLogHeader(const RMessage2& aMessage); |
|
501 TInt GetEventLogData(const RMessage2& aMessage); |
|
502 TInt ClearEventLog(); |
|
503 |
|
504 private: //Data |
|
505 // List of messages listening to events |
|
506 CArrayFixFlat<CListenerContainer*> iListenedEvents; |
|
507 // Event mediator server |
|
508 CEventMediatorServer* iServer; |
|
509 |
|
510 RFs iFs; |
|
511 RFile iEventLogFile; |
|
512 TBool iEventLogFileOpen; |
|
513 // Is this session from a SIT or not |
|
514 |
|
515 public: |
|
516 TBool iIsSitSession; |
|
517 }; |
|
518 |
286 |
519 // CLASS DECLARATION |
287 // CLASS DECLARATION |
520 |
288 |
521 /** |
289 /** |
522 * Container for one reported event from witch it can be read by all listening sessions. |
290 * Container for one reported event from witch it can be read by all listening sessions. |