|
1 /* |
|
2 * Copyright (c) 2002-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: Implements Target Selector Plugin (TSP) used by Symbian's |
|
15 * Remote Control Framework. TSP controls sending of operations |
|
16 * between Series 60 components and remote targets. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef CREMCONTSPCONTROLLER_H |
|
22 #define CREMCONTSPCONTROLLER_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 #include <remcon/remcontargetselectorplugin.h> |
|
27 #include <remcon/remcontargetselectorplugininterface.h> |
|
28 #include <e32property.h> |
|
29 #include <cfclient.h> |
|
30 #include <cflistener.h> |
|
31 #include <AudioClientsListPSData.h> |
|
32 #include "remconidlelistener.h" |
|
33 #include "remconeventtable.h" |
|
34 |
|
35 // CONSTANTS |
|
36 |
|
37 // MACROS |
|
38 |
|
39 // DATA TYPES |
|
40 |
|
41 // FUNCTION PROTOTYPES |
|
42 |
|
43 // FORWARD DECLARATIONS |
|
44 class CRemConLogger; |
|
45 class TClientInfo; |
|
46 |
|
47 |
|
48 // CLASS DECLARATION |
|
49 |
|
50 /** |
|
51 * Controls delivering of commands between Series 60 components and remote |
|
52 * targets. |
|
53 * |
|
54 * @lib RemConTspController.dll |
|
55 * @since Series 60 3.0 |
|
56 */ |
|
57 class CRemConTspController : public CRemConTargetSelectorPlugin, |
|
58 public MRemConTargetSelectorPluginInterfaceV2, |
|
59 public MRemConTargetSelectorPluginInterfaceV3, |
|
60 public MCFListener |
|
61 { |
|
62 public: // Constructors and destructor |
|
63 |
|
64 /** |
|
65 * Two-phased constructor. |
|
66 */ |
|
67 static CRemConTspController* NewL( |
|
68 MRemConTargetSelectorPluginObserver& aObserver ); |
|
69 |
|
70 /** |
|
71 * Destructor. |
|
72 */ |
|
73 virtual ~CRemConTspController(); |
|
74 |
|
75 public: // Functions from base classes |
|
76 |
|
77 void CreateAfterIdleL(); |
|
78 |
|
79 protected: // New functions |
|
80 |
|
81 protected: // Functions from base classes |
|
82 |
|
83 private: |
|
84 |
|
85 /** |
|
86 * C++ default constructor. |
|
87 */ |
|
88 CRemConTspController( MRemConTargetSelectorPluginObserver& aObserver ); |
|
89 |
|
90 private: // from CRemConTargetSelectorPlugin |
|
91 |
|
92 /** |
|
93 * Called by RemCon server to get a pointer to an object which |
|
94 * implements the TSP interface with UID aUid. This is a mechanism |
|
95 * for allowing future change to the TSP API without breaking BC |
|
96 * in existing (non-updated) TSPs. |
|
97 * |
|
98 * @param aUid Queried TSP interface version. |
|
99 * @return TAny A pointer to implementation of this TSP version, if |
|
100 * quaried TSP interface version is the one implemented |
|
101 * by this TSP. Otherwise a NULL will be returned. |
|
102 */ |
|
103 TAny* GetInterface( TUid aUid ); |
|
104 |
|
105 private: // from MRemConTargetSelectorPluginInterface |
|
106 |
|
107 /** |
|
108 * Called by RemCon server to get the TSP to address an outgoing |
|
109 * command (from a connectionless controller client) to zero or |
|
110 * more remote targets. |
|
111 * @param aInterfaceUid The UID of the client interface. |
|
112 * @param aOperationId The operation ID of the command. |
|
113 * @param aSender The TClientInfo of the sending session. |
|
114 * @param aConnections An empty collection of connections. |
|
115 * TRemConAddresses must be made on the heap. |
|
116 * RemCon takes ownership of any items in the |
|
117 * collection. |
|
118 * @params aBearerSecurity Contains all the bearer security policies. |
|
119 * @return TAny void |
|
120 */ |
|
121 void AddressOutgoingCommand( |
|
122 TUid aInterfaceUid, |
|
123 TUint aOperationId, |
|
124 const TClientInfo& aSender, |
|
125 TSglQue<TRemConAddress>& aConnections, |
|
126 TSglQue<TBearerSecurity>& aBearerSecurity ); |
|
127 |
|
128 /** |
|
129 * Called by RemCon server to find out from the TSP whether the given |
|
130 * connection-oriented controller client is permitted to send the given |
|
131 * command to remote target. |
|
132 * @param aInterfaceUid The UID of the client interface. |
|
133 * @param aOperationId The operation ID of the command. |
|
134 * @param aSender The TClientInfo of the sending session. |
|
135 * @param aConnection The remote the command will be sent over if |
|
136 * permission is granted. |
|
137 * @return void |
|
138 */ |
|
139 void PermitOutgoingCommand( |
|
140 TUid aInterfaceUid, |
|
141 TUint aOperationId, |
|
142 const TClientInfo& aSender, |
|
143 const TRemConAddress& aConnection ); |
|
144 |
|
145 /** |
|
146 * Called by RemCon server to cancel the current AddressOutgoingCommand |
|
147 * or PermitOutgoingCommand command. |
|
148 * @return void |
|
149 */ |
|
150 void CancelOutgoingCommand(); |
|
151 |
|
152 /** |
|
153 * Called by RemCon server to get the TSP to address an incoming command |
|
154 * (from a remote target to zero or more Series 60 components). There's |
|
155 * no 'cancel' method for AddressIncomingCommand. |
|
156 * @since Series 60 3.0 |
|
157 * @param aInterfaceUid The UID of the client interface. |
|
158 * @param aOperationId The operation ID of the command. |
|
159 * @param aClients A collection of existing target clients. TSP's |
|
160 * responsibility is to modify this parameter, if |
|
161 * it wants that command will not be sent to all |
|
162 * proposed clients. Thus, when this method has |
|
163 * been finished, aClients will include those |
|
164 * target clients to whom command should be sent. |
|
165 * @return void |
|
166 */ |
|
167 void AddressIncomingCommand( |
|
168 TUid aInterfaceUid, |
|
169 TUint aOperationId, |
|
170 TSglQue<TClientInfo>& aClients ); |
|
171 |
|
172 /** |
|
173 * Called by RemCon to get the TSP to decide which client should be |
|
174 * allowed to respond to a command. |
|
175 * @param aInterfaceUid The UID of the client interface. |
|
176 * @param aOperationId The operation ID of the command. |
|
177 * @param aClient The client which is trying to send a response |
|
178 * @param aClients A list of clients which are still expected to respond, |
|
179 * including the one specified in aClient |
|
180 */ |
|
181 void PermitOutgoingResponse( |
|
182 TUid aInterfaceUid, |
|
183 TUint aOperationId, |
|
184 const TClientInfo& aClient, |
|
185 TClientInfoConstIter& aClients); |
|
186 |
|
187 /** |
|
188 * Called by RemCon to cancel the current PermitOutgoingResponse request. |
|
189 */ |
|
190 void CancelOutgoingResponse(); |
|
191 |
|
192 /** |
|
193 * Called by RemCon to get the TSP to address an incoming notify (from a |
|
194 * remote to zero or more target clients). |
|
195 * @param aInterfaceUid The UID of the client interface. |
|
196 * @param aOperationId The operation ID of the command. |
|
197 * @param aClients A collection of existing target clients. The implementor |
|
198 * may wish to start a target client and call IncomingNotifyAddressed |
|
199 * with a new TClientInfo. The new TClientInfo item must be made on the stack. |
|
200 * Note when creating the new TClientInfo, only the process ID needs to |
|
201 * be correctly populated. |
|
202 */ |
|
203 void AddressIncomingNotify( |
|
204 TUid aInterfaceUid, |
|
205 TUint aOperationId, |
|
206 TSglQue<TClientInfo>& aClients); |
|
207 |
|
208 // From MRemConTargetSelectorPluginInterfaceV3 |
|
209 |
|
210 /** |
|
211 Called by RemCon to get the TSP to address an outgoing notify command (from a |
|
212 connectionless controller client) to zero or one remote. |
|
213 @param aInterfaceUid The UID of the client interface. |
|
214 @param aOperationId The operation ID of the command. |
|
215 @param aSender The TClientInfo of the sending session. |
|
216 @param aBearerSecurity Contains all the bearer security policies. |
|
217 */ |
|
218 void AddressOutgoingNotify( |
|
219 TUid aInterfaceUid, |
|
220 TUint aOperationId, |
|
221 const TClientInfo& aSender, |
|
222 TSglQue<TBearerSecurity>& aBearerSecurity); |
|
223 |
|
224 /** |
|
225 Called by RemCon to cancel the current AddressOutgoingNotify or |
|
226 PermitOutgoingNotifyCommand command. |
|
227 */ |
|
228 void CancelOutgoingNotifyCommand(); |
|
229 |
|
230 /** |
|
231 Called by RemCon to find out from the TSP whether the given |
|
232 connection-oriented controller client is permitted to send the given notify |
|
233 command to the given remote at this time. |
|
234 @param aInterfaceUid The UID of the client interface. |
|
235 @param aOperationId The operation ID of the command. |
|
236 @param aSender The TClientInfo of the sending session. |
|
237 @param aConnection The remote the command will be sent over if permission |
|
238 is granted. |
|
239 */ |
|
240 void PermitOutgoingNotifyCommand( |
|
241 TUid aInterfaceUid, |
|
242 TUint aOperationId, |
|
243 const TClientInfo& aSender, |
|
244 const TRemConAddress& aConnection); |
|
245 |
|
246 // From MCFListener |
|
247 |
|
248 /** |
|
249 * Indicates a change in context for subscribed clients. |
|
250 * If client has subscribed to partial context class path, |
|
251 * only the changed context will be indicated. |
|
252 * |
|
253 * @param aIndication: Context indication. |
|
254 * @return None |
|
255 */ |
|
256 void ContextIndicationL( |
|
257 const CCFContextIndication& aChangedContext ); |
|
258 |
|
259 /** |
|
260 * Indicates that specified action is needed to be executed. |
|
261 * When action indication is received certain rule has been triggered |
|
262 * and action is needed to be performed. |
|
263 * |
|
264 * @param aActionToExecute Action indication. |
|
265 * @return None |
|
266 */ |
|
267 void ActionIndicationL( |
|
268 const CCFActionIndication& aActionToExecute ); |
|
269 |
|
270 /** |
|
271 * Returns an extension interface. |
|
272 * The extension interface is mapped with the extension UID. |
|
273 * |
|
274 * If the client does not support the requested interface, |
|
275 * client must return NULL. Otherwise client needs to return |
|
276 * the correct interface combined with the UID. |
|
277 * |
|
278 * @since S60 5.0 |
|
279 * @param aExtensionUid: The identifier of the extension. |
|
280 * @return Pointer to the extension. |
|
281 */ |
|
282 TAny* Extension( const TUid& aExtensionUid ) const; |
|
283 |
|
284 /** |
|
285 * Indicates that error has occured. |
|
286 * |
|
287 * @param aError Error code. |
|
288 * @return None |
|
289 */ |
|
290 void HandleContextFrameworkError( TCFError aError, |
|
291 const TDesC& aSource, |
|
292 const TDesC& aType ); |
|
293 |
|
294 /** |
|
295 * Gets the foreground application. |
|
296 * |
|
297 * @param aError Error code. |
|
298 * @return None |
|
299 */ |
|
300 void GetActiveWindowClientL(); |
|
301 |
|
302 /** |
|
303 * Checks if process is connected to Remcon |
|
304 */ |
|
305 TClientInfo* FindRemconConnection( TProcessId aProcessId, TSglQue<TClientInfo>& aClients ) const; |
|
306 |
|
307 /** |
|
308 * Checks if client with given secure id is connected to Remcon |
|
309 */ |
|
310 TClientInfo* FindRemconConnection( TSecureId aSecureId, TSglQue<TClientInfo>& aClients ) const; |
|
311 |
|
312 /** |
|
313 * Sorts the audio clients to a correct order. The last played is first. |
|
314 */ |
|
315 void GetActivePidsL( RArray<TProcessId>& aArray ); |
|
316 |
|
317 #if ( defined COMPONENT_TRACE_FLAG && _DEBUG ) |
|
318 void TraceAudioPolicyClients( const TUint32 aState, TAudioPolicyProcessIdList aIdList ); |
|
319 #endif |
|
320 |
|
321 public: // Data |
|
322 |
|
323 protected: // Data |
|
324 |
|
325 void ConstructL(); |
|
326 |
|
327 private: |
|
328 |
|
329 void GetCorrectClientL( |
|
330 TUid aInterfaceUid, |
|
331 TUint aKeyEvent, |
|
332 TSglQue<TClientInfo>& aClients ); |
|
333 |
|
334 void SetKeyEventTableL( const CCFActionIndication& aActionToExecute ); |
|
335 |
|
336 void ActivateApplicationL( const TUid aUid ) const; |
|
337 |
|
338 TBool IsStateNormal() const; |
|
339 |
|
340 TInt FindRoutingTablePos( |
|
341 const RPointerArray<CRemConEventTable>& aTableArray, TInt aTableNum ) const; |
|
342 |
|
343 CRemConEventTable* FindRoutingTable( |
|
344 const RPointerArray<CRemConEventTable>& aTableArray, TInt aTableNum ) const; |
|
345 |
|
346 TBool FindActiveAudioFromAudioPolicy( TSglQue<TClientInfo>& aClients ); |
|
347 |
|
348 TBool FindActiveAudioFromCustomIfL( TSglQue<TClientInfo>& aClients ); |
|
349 |
|
350 /** |
|
351 * Returns whether system lock is active. |
|
352 */ |
|
353 TBool DeviceLocked() const; |
|
354 |
|
355 private: // Data |
|
356 |
|
357 // owned |
|
358 CRemConIdleListener* iIdle; |
|
359 |
|
360 // Interface to P&S key that returns call state |
|
361 RProperty iProperty; |
|
362 |
|
363 CCFClient* iCFClient; |
|
364 |
|
365 RPointerArray<CRemConEventTable> iArrayOfTables; |
|
366 |
|
367 TUid iUidForeground; |
|
368 |
|
369 TProcessId iProcessIdForeground; |
|
370 |
|
371 TProcessId iProcessIdActive; |
|
372 |
|
373 RPointerArray<CRemConEventTable> iArrayOfStoredTables; |
|
374 |
|
375 public: // Friend classes |
|
376 |
|
377 protected: // Friend classes |
|
378 |
|
379 private: // Friend classes |
|
380 |
|
381 }; |
|
382 |
|
383 #endif // CREMCONTSPCONTROLLER_H |