1 /* |
|
2 * Copyright (c) 2005-2007 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: Header file for the CUPnPAiwEngine class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef UPNP_AIW_ENGINE_H |
|
20 #define UPNP_AIW_ENGINE_H |
|
21 |
|
22 // INCLUDES |
|
23 // System |
|
24 #include <e32base.h> |
|
25 #include <AknProgressDialog.h> |
|
26 |
|
27 // avcontroller api |
|
28 #include "upnpavrenderingsessionobserver.h" |
|
29 #include "upnpavdeviceobserver.h" |
|
30 #include "upnpitemresolverobserver.h" |
|
31 |
|
32 // upnpframework / internal api's |
|
33 #include "upnpcommonui.h" |
|
34 |
|
35 // aiwengine internal |
|
36 #include "upnpaiwengineobserver.h" |
|
37 #include "upnpaiwtimerobserver.h" |
|
38 |
|
39 |
|
40 // ENUMERATIONS |
|
41 enum TUPnPEngineState |
|
42 { |
|
43 EUPnPEngineNotConnected = 1, |
|
44 EUPnPEngineConnectionLost, |
|
45 EUPnPEngineConnected, |
|
46 EUPnPEngineActive, |
|
47 EUPnPEngineBrowsingHomeNetwork |
|
48 }; |
|
49 |
|
50 enum TUPnPAiwEngineDeviceType |
|
51 { |
|
52 EUPnPAiwEngineTargetDeviceWithAudioSupport = 1, |
|
53 EUPnPAiwEngineTargetDeviceWithImageAndVideoSupport, |
|
54 EUPnPAiwEngineTargetDeviceWithImageSupport |
|
55 }; |
|
56 |
|
57 enum TUPnPAiwEngineTransferMode |
|
58 { |
|
59 EAiwEngineCopy = 0, |
|
60 EAiwEngineCopyPlaylist, |
|
61 EAiwEngineMove |
|
62 }; |
|
63 |
|
64 // FORWARD DECLARATIONS |
|
65 class CAknWaitDialog; |
|
66 class CUPnPAiwTimer; |
|
67 class MUPnPAVController; |
|
68 class MUPnPAVRenderingSession; |
|
69 class MUPnPAVSessionBase; |
|
70 |
|
71 // CLASS DECLARATION |
|
72 |
|
73 /** |
|
74 * CUPnPAiwEngine |
|
75 * The class works as an engine component between the UPnP AIW, UPnP Common |
|
76 * UI components and UPnPAVController components. |
|
77 * @since S60 3.0 |
|
78 */ |
|
79 class CUPnPAiwEngine : public CBase, |
|
80 public MUPnPAVRenderingSessionObserver, |
|
81 public MUPnPAiwTimerObserver, |
|
82 public MProgressDialogCallback, |
|
83 public MUPnPAVDeviceObserver, |
|
84 public MUPnPItemResolverObserver |
|
85 { |
|
86 |
|
87 public: // Constructors and destructor |
|
88 |
|
89 /** |
|
90 * Two-phased constructor. |
|
91 */ |
|
92 IMPORT_C static CUPnPAiwEngine* NewL(); |
|
93 |
|
94 /** |
|
95 * Releases the instance. |
|
96 * |
|
97 * @since S60 3.0 |
|
98 */ |
|
99 IMPORT_C static void ReleaseInstance(); |
|
100 |
|
101 /** |
|
102 * Destructor. |
|
103 */ |
|
104 virtual ~CUPnPAiwEngine(); |
|
105 |
|
106 public: // Methods from MUPnPAVDeviceObserver |
|
107 |
|
108 // Unnecessary callback methods |
|
109 void UPnPDeviceDiscovered( const CUpnpAVDevice& /*aDevice*/ ) {} |
|
110 void UPnPDeviceDisappeared (const CUpnpAVDevice& /*aDevice*/ ) {} |
|
111 |
|
112 /** |
|
113 * Notifies that the WLAN connection has been lost. All sessions |
|
114 * are now usable and must be closed. |
|
115 * |
|
116 * @since Series 60 3.1 |
|
117 * @return None |
|
118 */ |
|
119 void WLANConnectionLost(); |
|
120 |
|
121 public: // UPnP Aiw Engine call back |
|
122 |
|
123 /** |
|
124 * Sets the observer instance. |
|
125 * |
|
126 * @since S60 3.0 |
|
127 * @param aObserver (MUPnPAiwEngineObserver*) observer instance |
|
128 */ |
|
129 IMPORT_C void SetEngineObserver( MUPnPAiwEngineObserver* aObserver ); |
|
130 |
|
131 /** |
|
132 * Removes the observer instance. |
|
133 * |
|
134 * @since S60 3.0 |
|
135 */ |
|
136 IMPORT_C void RemoveEngineObserver(); |
|
137 |
|
138 public: |
|
139 |
|
140 /** |
|
141 * Returns the state of the UPnP AIW Engine. |
|
142 * |
|
143 * @since S60 3.0 |
|
144 * @return TUPnPEngineState State of the engine |
|
145 */ |
|
146 IMPORT_C TUPnPEngineState EngineState(); |
|
147 |
|
148 /** |
|
149 * Opens the External media UI. |
|
150 * |
|
151 * Leaves if the UpnpAiwEngine is already in use, if the |
|
152 * UpnpAvController instantiation fails, or if the device selection/ |
|
153 * browse dialog leaves. |
|
154 * |
|
155 * @since S60 3.0 |
|
156 */ |
|
157 IMPORT_C void OpenExternalMediaL(); |
|
158 |
|
159 /** |
|
160 * Enables the showing of local media files on a remote renderer |
|
161 * device. |
|
162 * |
|
163 * Leaves if the UpnpAiwEngine is already in use, if the |
|
164 * UpnpAvController instantiation fails, or if the device selection |
|
165 * dialog leaves. |
|
166 * |
|
167 * @since S60 3.0 |
|
168 */ |
|
169 IMPORT_C void EnableExternalL(); |
|
170 |
|
171 /** |
|
172 * Disables the showing of local media files on remote renderer |
|
173 * device. |
|
174 * |
|
175 * @since S60 3.0 |
|
176 */ |
|
177 IMPORT_C void DisableExternal(); |
|
178 |
|
179 /** |
|
180 * Copies local files to a remote media server. |
|
181 * |
|
182 * @since S60 3.0 |
|
183 * @param aFileNames (RPointerArray<TDesC>&) Reference to an array |
|
184 * of TDesC objects containing the list of file names. All |
|
185 * files that are successfully copied are removed from the |
|
186 * list. |
|
187 */ |
|
188 IMPORT_C void CopyToExternalL( RPointerArray<TDesC>& aFileNames ); |
|
189 |
|
190 /** |
|
191 * Copies a local playlist to a remote media server. |
|
192 * |
|
193 * @since S60 3.0 |
|
194 * @param aFileNames (RPointerArray<TDesC>&) Reference to an array |
|
195 * of TDesC objects containing the list of file names. All |
|
196 * files that are successfully copied are removed from the |
|
197 * list. |
|
198 * @param aPlaylistName (const TDesC&) name of the playlist |
|
199 */ |
|
200 IMPORT_C void CopyPlaylistToExternalL( |
|
201 const TDesC& aPlaylistName, |
|
202 RPointerArray<TDesC>& aFileNames ); |
|
203 |
|
204 /** |
|
205 * Moves local files to a remote media server. |
|
206 * |
|
207 * @since S60 3.0 |
|
208 * @param aFileNames (RPointerArray<TDesC>&) Reference to an array |
|
209 * of TDesC objects containing the list of file names. All |
|
210 * files that are successfully moved removed from the list. |
|
211 */ |
|
212 IMPORT_C void MoveToExternalL( RPointerArray<TDesC>& aFileNames ); |
|
213 |
|
214 /** |
|
215 * Plays (sends for rendering) local media file using the selected |
|
216 * UPnP Media renderer. Only image and video files are supported |
|
217 * after Upnp Fw 2.0. |
|
218 * |
|
219 * Leaves if the given filename is not valid, file is not a media |
|
220 * file, if the UpnpAiwEngine is not ready (enable external to done), |
|
221 * or if the bearer or remote upnp device is lost. |
|
222 * |
|
223 * @since S60 3.0 |
|
224 * @param aFileName (const TDesC&) reference to the file name of |
|
225 * the media file. |
|
226 */ |
|
227 IMPORT_C void PlayL( const TDesC& aFileName ); |
|
228 |
|
229 /** |
|
230 * Displays connection error if creating of control point fails. |
|
231 * |
|
232 * @since S60 3.1 |
|
233 */ |
|
234 IMPORT_C void ShowConnectionErrorL(); |
|
235 |
|
236 public: // Methods to update the singleton reference counter |
|
237 |
|
238 /** |
|
239 * Sets the initial value of the user counter to zero. |
|
240 * |
|
241 * @since S60 3.0 |
|
242 */ |
|
243 void InitialiseUserCounter(); |
|
244 |
|
245 /** |
|
246 * Increases the value of the user counter. |
|
247 * |
|
248 * @since S60 3.0 |
|
249 */ |
|
250 void IncreaseUserCounter(); |
|
251 |
|
252 /** |
|
253 * Decreases the value of the user counter. |
|
254 * |
|
255 * @since S60 3.0 |
|
256 */ |
|
257 void DecreaseUserCounter(); |
|
258 |
|
259 /** |
|
260 * Gets the value of the user counter. |
|
261 * |
|
262 * @since S60 3.0 |
|
263 * @return TInt |
|
264 */ |
|
265 TInt UserCounter() const; |
|
266 |
|
267 /** |
|
268 * Displays connection lost error if copying files fails. |
|
269 * |
|
270 * @since S60 3.2.3 |
|
271 */ |
|
272 void ShowConnectionLostCopyErrorL(); |
|
273 |
|
274 private: |
|
275 |
|
276 /** |
|
277 * Transfers (copies/moves) local files/playlist to a remote media |
|
278 * server. |
|
279 * |
|
280 * Leaves if the given parameters are not valid, if the UpnpAiwEngine |
|
281 * is already in use, if user cancels the operation, or if the bearer |
|
282 * or remote upnp device is lost. |
|
283 * |
|
284 * @since S60 3.0 |
|
285 * @param aMode (TUPnPAiwEngineTransferMode) transfer mode |
|
286 * @param aFileNames (RPointerArray<TDesC>&) Reference to an array |
|
287 * of TDesC objects containing the list of file names. All |
|
288 * files that are successfully copied are removed from the |
|
289 * list. |
|
290 * @param aPlaylistName (const TDesC&) name of the playlist |
|
291 */ |
|
292 void TransferToExternalL( TUPnPAiwEngineTransferMode aMode, |
|
293 RPointerArray<TDesC>& aFilePaths, |
|
294 const TDesC& aPlaylistName ); |
|
295 |
|
296 /** |
|
297 * Starts a rendering session with UpnpAvController. Queries the |
|
298 * target rendering device. |
|
299 * |
|
300 * Leaves if any instantiation fails or used cancels the device |
|
301 * selection. |
|
302 * |
|
303 * @since S60 3.0 |
|
304 * @param aDeviceType (TUPnPAiwEngineDeviceType) type of the device |
|
305 */ |
|
306 void StartRenderingSessionL( TUPnPAiwEngineDeviceType aDeviceType ); |
|
307 |
|
308 /** |
|
309 * Handles the UPnP device disappeared call back method. |
|
310 * |
|
311 * @since S60 3.0 |
|
312 * @param aDevice (const CUpnpAVDevice&) pointer to the device info |
|
313 */ |
|
314 void HandleUPnPDeviceDisappearedL( const CUpnpAVDevice& aDevice ); |
|
315 |
|
316 /** |
|
317 * Waits for local media server file sharing activation (or user |
|
318 * cancel). |
|
319 * |
|
320 * @since S60 3.1 |
|
321 * @param aSession (MUPnPAVSessionBase*) pointer to the AVController |
|
322 * session. |
|
323 */ |
|
324 void StartLocalFileSharingL( MUPnPAVSessionBase *aSession ); |
|
325 |
|
326 public: // Call back methods of MUPnPAVRenderingSessionObserver |
|
327 |
|
328 // Unused callback methods |
|
329 void VolumeResult( TInt /*aError*/, |
|
330 TInt /*aVolumeLevel*/, |
|
331 TBool /*aActionResponse*/ ) {} |
|
332 void MuteResult( TInt /*aError*/, |
|
333 TBool /*aMute*/, |
|
334 TBool /*aActionResponse*/ ) {} |
|
335 void PositionInfoResult( TInt /*aError*/, |
|
336 const TDesC8& /*aTrackPosition*/, |
|
337 const TDesC8& /*aTrackLength*/ ) {} |
|
338 void SetNextURIResult( TInt /*aError*/ ) {} |
|
339 |
|
340 /** |
|
341 * UPnP AV Controller calls this method to indicate that the requested |
|
342 * interaction operation (play, stop, etc.) is complete. In other |
|
343 * words, the target rendering device has changed it's state |
|
344 * accordingly. |
|
345 * |
|
346 * @since Series 60 3.1 |
|
347 * @param aError (TInt) error code |
|
348 * @param aOperation (TAVInteractOperation) operation Id |
|
349 */ |
|
350 void InteractOperationComplete( TInt aError, |
|
351 TUPnPAVInteractOperation aOperation ); |
|
352 |
|
353 /** |
|
354 * UPnP AV Controller calls this method as a response to SetUri |
|
355 * action. |
|
356 * |
|
357 * @since Series 60 3.1 |
|
358 * @param aError (TInt) error code |
|
359 */ |
|
360 void SetURIResult( TInt aError ); |
|
361 |
|
362 /** |
|
363 * Notifies that the Media Renderer we have a session with has |
|
364 * disappeared. Session is now unusable and must be closed. |
|
365 * |
|
366 * @since Series 60 3.1 |
|
367 * @param aReason (TUPnPDeviceDisconnectedReason) reason code |
|
368 */ |
|
369 void MediaRendererDisappeared( |
|
370 TUPnPDeviceDisconnectedReason aReason ); |
|
371 |
|
372 public: // Call back methods of MUPnPAVSessionObserverBase |
|
373 |
|
374 /** |
|
375 * Notifies that the Media Server startup has completed. |
|
376 * |
|
377 * @since Series 60 3.1 |
|
378 * @return aError (TInt) error code |
|
379 */ |
|
380 void ReserveLocalMSServicesCompleted( TInt aError ); |
|
381 |
|
382 public: // Call back methods of MAknProgressDialogCallback |
|
383 |
|
384 /** |
|
385 * ProgressDialog call back method. |
|
386 * Get's called when a dialog is dismissed. |
|
387 * |
|
388 * @since S60 3.0 |
|
389 * @param aButtonId (TInt) ID of the button pressed |
|
390 */ |
|
391 void DialogDismissedL( TInt aButtonId ); |
|
392 |
|
393 public: // Timer related methods |
|
394 |
|
395 /** |
|
396 * Starts the UPnPAiWTimer. |
|
397 * |
|
398 * @since S60 3.0 |
|
399 */ |
|
400 void StartTimer(); |
|
401 |
|
402 /** |
|
403 * Stops the UPnPAiWTimer. |
|
404 * |
|
405 * @since S60 3.0 |
|
406 */ |
|
407 void StopTimer(); |
|
408 |
|
409 /** |
|
410 * Callback method for the UPnPAiwTimer. |
|
411 * |
|
412 * @since S60 3.0 |
|
413 */ |
|
414 void TimerCallback(); |
|
415 |
|
416 private: // Helper methods |
|
417 |
|
418 /** |
|
419 * Method for selecting a device. |
|
420 * |
|
421 * Leaves if the engine is not ready (UpnpAvController not |
|
422 * instantiated), if the user cancels the operation, or if the bearer |
|
423 * is lost during the device selection. |
|
424 * |
|
425 * @since S60 3.1 |
|
426 * @param aDeviceType (TUPnPDeviceTypesToSearch) type of device |
|
427 * @param aDlgTitle title used in device selection dialog |
|
428 * @return CUpnpAVDevice* selected upnp av device. |
|
429 */ |
|
430 CUpnpAVDevice* SelectDeviceL( |
|
431 TUPnPDeviceTypesToSearch aDeviceType, |
|
432 TUPnPDialogTitle aDlgTitle ); |
|
433 |
|
434 /** |
|
435 * Method for releasing upnp resource. |
|
436 * |
|
437 * @since S60 3.1 |
|
438 * @param none |
|
439 * @return none |
|
440 */ |
|
441 void ReleaseUpnpResourceL(); |
|
442 |
|
443 /** |
|
444 * Method for playing a local file |
|
445 * |
|
446 * @since S60 3.1 |
|
447 * @param none |
|
448 * @return none |
|
449 */ |
|
450 void InitPlayL(); |
|
451 |
|
452 /** |
|
453 * Method for playing a local video |
|
454 * |
|
455 * @since S60 3.1 |
|
456 * @param aFilePath file path |
|
457 * @return none |
|
458 */ |
|
459 void StartVideoPlayL( const TDesC& aFileName ); |
|
460 |
|
461 /** |
|
462 * Shows info note after the file transfer has been completed. |
|
463 * |
|
464 * @since S60 5.1 |
|
465 * @param aMode Type of file transfer (copy or move) |
|
466 * @param aCount Number of files copied to server |
|
467 * @param aDevice Device files were copied to |
|
468 * @return none |
|
469 */ |
|
470 void ShowTransferInfoNoteL( |
|
471 TUPnPAiwEngineTransferMode aMode, |
|
472 TInt aCount, |
|
473 const CUpnpAVDevice& aServerName ) const; |
|
474 |
|
475 /** |
|
476 * creates upnpitem using helper resolve local item |
|
477 * |
|
478 * @since S60 5.1 |
|
479 * @param aFileName |
|
480 */ |
|
481 void CreateUpnpItemAndSetUriL( const TDesC& aFileName ); |
|
482 |
|
483 /** |
|
484 * Helper method to create MUPnPItemResolver. |
|
485 * |
|
486 * @since S60 5.1 |
|
487 * @param aFilePath file path |
|
488 * @return Pointer to resolver instance that is put to cleanupstack. |
|
489 */ |
|
490 MUPnPItemResolver* CreateResolverLC( const TDesC& aFilePath ); |
|
491 |
|
492 /** |
|
493 * Static cleanup function for MUPnPItemResolver. |
|
494 * Method makes sure that MUPnPItemResolver is properly cleaned up. |
|
495 * |
|
496 * @since S60 5.1 |
|
497 * @param aResolver TAny pointer to CUPnPAiwEngine object. |
|
498 */ |
|
499 static void CleanupResolver( TAny* aAiwEngine ); |
|
500 |
|
501 /** |
|
502 * starts asynchronous CActiveSchedulerWait |
|
503 */ |
|
504 void Wait(); |
|
505 |
|
506 /** |
|
507 * stops asynchronous CActiveSchedulerWait |
|
508 */ |
|
509 void StopWait(); |
|
510 |
|
511 private: // Construction methods |
|
512 |
|
513 // Constructor |
|
514 CUPnPAiwEngine(); |
|
515 |
|
516 /** |
|
517 * ConstructL. |
|
518 */ |
|
519 void ConstructL(); |
|
520 |
|
521 private: // from MUPnPItemResolverObserver |
|
522 |
|
523 /** |
|
524 * see MUPnPItemResolverObserver |
|
525 */ |
|
526 void ResolveComplete( |
|
527 const MUPnPItemResolver& aResolver, |
|
528 TInt aError ); |
|
529 |
|
530 private: // Data members |
|
531 |
|
532 // State of the engine |
|
533 TUPnPEngineState iEngineState; |
|
534 |
|
535 // Reference to the AV Controller ECom plug-in |
|
536 MUPnPAVController* iAVController; // owned |
|
537 |
|
538 // Reference to the AIW Provider instance |
|
539 MUPnPAiwEngineObserver* iObserver; // not owned |
|
540 |
|
541 // File sharing activation wait note and related member vars |
|
542 CAknWaitDialog* iFileSharingActivationWaitNote; // owned; |
|
543 TBool iLocalFileSharingActivated; |
|
544 TInt iFileSharingError; |
|
545 |
|
546 // CoeEnv and the resource offset (needed when loading and |
|
547 // unloading resources) |
|
548 CEikonEnv* iCoeEnv; // not owned |
|
549 TInt iResFileOffset; |
|
550 |
|
551 // Wait note dialog |
|
552 CAknWaitDialog* iWaitNoteDialog; // owned |
|
553 |
|
554 // Timer |
|
555 CUPnPAiwTimer* iUPnPAiwTimer; // owned |
|
556 |
|
557 MUPnPAVRenderingSession* iRenderingSession; // owned |
|
558 |
|
559 CUPnPCommonUI* iCommonUI; //owned |
|
560 HBufC16* iFileName; |
|
561 |
|
562 TBool iRenderingSessionInUse; |
|
563 TBool iVideoPlay; |
|
564 TBool iVideoPlayCancel; |
|
565 TBool iVideoPlayWait; |
|
566 private: // Singleton data members |
|
567 |
|
568 // Counter, which maintains the number of users of this singleton |
|
569 TInt iNumberOfUsers; |
|
570 |
|
571 /** |
|
572 * For async operations |
|
573 */ |
|
574 CActiveSchedulerWait iWait; |
|
575 |
|
576 MUPnPItemResolver* iResolver; |
|
577 |
|
578 TInt iResolveResult; |
|
579 }; |
|
580 |
|
581 #endif // UPNP_AIW_ENGINE_H |
|
582 |
|
583 // End of file |
|