|
1 /* |
|
2 * Copyright (c) 2003-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: This module defines event mediator server side session. |
|
15 * |
|
16 */ |
|
17 #ifndef EVENTMEDIATORSESSION_H_ |
|
18 #define EVENTMEDIATORSESSION_H_ |
|
19 |
|
20 #include <e32base.h> |
|
21 #include <f32file.h> |
|
22 #include "eventmediatorapi.h" |
|
23 |
|
24 /** |
|
25 * Defines the session to the VPN manager server. |
|
26 */ |
|
27 class CEventMediatorServer; |
|
28 class CListenerContainer; |
|
29 |
|
30 class CEventMediatorSession : public CSession2 |
|
31 { |
|
32 public: // Methods |
|
33 |
|
34 // Constructors and destructor |
|
35 |
|
36 /** |
|
37 * Static constructor |
|
38 */ |
|
39 static CEventMediatorSession* NewL(CEventMediatorServer& aServer, |
|
40 TBool aIsSitSession); |
|
41 |
|
42 /** |
|
43 * Default destructor |
|
44 */ |
|
45 ~CEventMediatorSession(void); |
|
46 |
|
47 /** |
|
48 * Wrapper function which Dispatches and executes the client's service calls |
|
49 * (See Message type definition). |
|
50 */ |
|
51 void ServiceL(const RMessage2& aMessage); |
|
52 |
|
53 /** |
|
54 * Checks if client is listening events of the given type and completes message |
|
55 * sent by clients ListenToEvent function. The length of the event data and |
|
56 * the pointer to that data are written to the message. |
|
57 * @param aType: type of the event. |
|
58 * @param aSpec: additional info on event. |
|
59 * @param aData: event data. |
|
60 * @return number of listeners for the event was listened. |
|
61 */ |
|
62 TInt CheckEventL(const TEventType aType, const TDesC8* aSpec, const TDesC8* aData, TInt aStatus); |
|
63 |
|
64 /** |
|
65 * Tries to find a task request that is not being fulfilled |
|
66 * already |
|
67 */ |
|
68 CListenerContainer* FindWaitingTaskRequest(); |
|
69 |
|
70 /** |
|
71 * Retrieves the event listener object, if any, that is using |
|
72 * the SIT that is fulfilling the specified event. |
|
73 */ |
|
74 CListenerContainer* FindListener(TEventType aEventType, TInt aEventSpecId); |
|
75 |
|
76 /** |
|
77 * Retrieves the event listener object, if any, that is using |
|
78 * the SIT that is fulfilling the specified event. |
|
79 */ |
|
80 CListenerContainer* FindListener(TEventType aEventType, const TDesC8* aEventSpec); |
|
81 |
|
82 /** |
|
83 * Completes the specified listener if it is owned by the |
|
84 * session. Returns ETrue is the listener was found and |
|
85 * completed, EFalse otherwise. |
|
86 */ |
|
87 void CompleteListener(TEventType aEventType, const TDesC8* aEventSpec, TInt aStatus); |
|
88 |
|
89 void CompleteTaskRequests(TInt aStatus); |
|
90 |
|
91 TBool IsASitSession(); |
|
92 |
|
93 private: //Methods |
|
94 // Constructors and destructor |
|
95 |
|
96 /** |
|
97 * Constructor |
|
98 */ |
|
99 CEventMediatorSession(CEventMediatorServer& aServer, TBool aIsSitSession); |
|
100 void ConstructL(); |
|
101 |
|
102 /** |
|
103 * Starts listening events of requesteed type by coping the message to iListenedEvents. |
|
104 * @param aMessage: aMessage sent by clients ListenToEvent function. |
|
105 * @return: error code, KErrNone if successfull. |
|
106 */ |
|
107 TInt ListenToEventWithSpecL(const RMessage2& aMessage); |
|
108 |
|
109 /** |
|
110 * Starts listening events of requesteed type by coping the message to iListenedEvents. |
|
111 * @param aMessage: aMessage sent by clients ListenToEvent function. |
|
112 * @return: error code, KErrNone if successfull. |
|
113 */ |
|
114 TInt ListenToEventL(const RMessage2& aMessage); |
|
115 |
|
116 /** |
|
117 * Reports the event contained in the message to the event mediator server. |
|
118 * @param aMessage: aMessage sent by clients ReportEvent function. |
|
119 * @return: error code, KErrNone if successfull. |
|
120 */ |
|
121 void ReportEventL(const RMessage2& aMessage); |
|
122 |
|
123 /** |
|
124 * Reports a log event contained in the message to the event mediator server. |
|
125 * @param aMessage: aMessage sent by clients ReportLogEvent function. |
|
126 * @return: error code, KErrNone if successfull. |
|
127 */ |
|
128 void ReportLogEventL(const RMessage2& aMessage); |
|
129 |
|
130 /** |
|
131 * Reports the event contained in the message to the event mediator server. |
|
132 * @param aMessage: aMessage sent by clients ReportEvent function. |
|
133 * @return: error code, KErrNone if successfull. |
|
134 */ |
|
135 void ReportEventWithSpecL(const RMessage2& aMessage); |
|
136 |
|
137 /** |
|
138 * Cancels listning of one event type. |
|
139 * @param aMessage: aMessage sent by clients CancelListenToEvent function. |
|
140 */ |
|
141 void CancelListening(const RMessage2& aMessage); |
|
142 |
|
143 /** |
|
144 * Cancels listning of one event type. |
|
145 * @param aMessage: aMessage sent by clients CancelListenToEvent function. |
|
146 */ |
|
147 void CancelListeningWithSpecL(const RMessage2& aMessage); |
|
148 |
|
149 /** |
|
150 * Cancels all listening. |
|
151 * @param aMessage: aMessage sent by clients CancelAllListening function. |
|
152 */ |
|
153 void CancelAll(); |
|
154 |
|
155 /** |
|
156 * Copies event data from the server to the client. |
|
157 * @param aMessage: aMessage sent by clients FetchData function. |
|
158 * @return: error code, KErrNone if successfull. |
|
159 */ |
|
160 TInt FetchDataL(const RMessage2& aMessage); |
|
161 |
|
162 /** |
|
163 * Looks up a message from iListenedEvents. |
|
164 * @param aType: type of the event the message is listening to. |
|
165 * @param aIndex: the position of the message in iListenedEvents. |
|
166 * @return ETrue if message exists, EFalse if not. |
|
167 */ |
|
168 TBool FindListenerMsg(const TEventType aType,TInt& index); |
|
169 |
|
170 /** |
|
171 * Looks up a message from iListenedEvents. |
|
172 * @param aType: type of the event the message is listening to. |
|
173 * @param aIndex: the position of the message in iListenedEvents. |
|
174 * @return ETrue if message exists, EFalse if not. |
|
175 */ |
|
176 TBool FindListenerMsg(const TEventType aType,const TDesC8* aSpec,TInt& index); |
|
177 |
|
178 /** |
|
179 * Searches for a task request type event listening request |
|
180 */ |
|
181 TBool FindTaskRequestListenerMsg(TInt& index); |
|
182 |
|
183 /** |
|
184 * Reads data that was reported with the event from client. Allocates a buffer |
|
185 * for data and gives ownership of that buffer to caller. |
|
186 * @param aMessage: aMessage sent by clients ReportEvent function. |
|
187 * @return pointer to the newly created buffer containig data. |
|
188 */ |
|
189 HBufC8* ReadEventDataFromClientL(const RMessage2& aMessage); |
|
190 |
|
191 /** |
|
192 * Reads specification describing the event from client. Allocates a buffer |
|
193 * for secification and gives ownership of that buffer to caller. |
|
194 * @param aMessage: aMessage sent with event specification. |
|
195 * @return pointer to the newly created buffer containig data. |
|
196 */ |
|
197 HBufC8* ReadSpecificationFromClientL(const RMessage2& aMessage); |
|
198 |
|
199 /** |
|
200 * Completes the specified listener and deletes it from the |
|
201 * listener list |
|
202 */ |
|
203 void CompleteListener(TInt aIndex, TInt aStatus); |
|
204 |
|
205 /** |
|
206 * Returns to the client a new event specification ID |
|
207 */ |
|
208 void NewEventSpecIdL(const RMessage2& aMessage); |
|
209 |
|
210 TInt DeletePrivateFiles(); |
|
211 void DeletePrivateFilesL(); |
|
212 |
|
213 TInt GetEventLogSize(const RMessage2& aMessage); |
|
214 TInt GetEventLogHeader(const RMessage2& aMessage); |
|
215 TInt GetEventLogData(const RMessage2& aMessage); |
|
216 TInt ClearEventLog(); |
|
217 |
|
218 private: //Data |
|
219 // List of messages listening to events |
|
220 CArrayFixFlat<CListenerContainer*> iListenedEvents; |
|
221 // Event mediator server |
|
222 CEventMediatorServer& iServer; |
|
223 |
|
224 RFs iFs; |
|
225 RFile iEventLogFile; |
|
226 TBool iEventLogFileOpen; |
|
227 // Is this session from a SIT or not |
|
228 |
|
229 public: |
|
230 TBool iIsSitSession; |
|
231 }; |
|
232 |
|
233 #endif /* EVENTMEDIATORSESSION_H_ */ |