videoplayback/hbvideoplaybackview/controlsrc/mpxvideoplaybackcontrolscontroller.cpp
changeset 36 8aed59de29f9
parent 35 3738fe97f027
child 37 4eb2df7f7cbe
--- a/videoplayback/hbvideoplaybackview/controlsrc/mpxvideoplaybackcontrolscontroller.cpp	Thu Apr 01 23:32:44 2010 +0300
+++ b/videoplayback/hbvideoplaybackview/controlsrc/mpxvideoplaybackcontrolscontroller.cpp	Fri Apr 16 18:13:14 2010 +0300
@@ -15,7 +15,7 @@
 *
 */
 
-// Version : %version: da1mmcf#29 %
+// Version : %version: da1mmcf#34 %
 
 
 
@@ -28,12 +28,13 @@
 #include <QTimer>
 #include <QFileInfo>
 #include <thumbnailmanager_qt.h>
+#include <xqserviceutil.h>
 
 #include <hblabel.h>
-#include <hbaction.h>
 #include <hbiconitem.h>
 #include <hbratingslider.h>
 #include <hbiconanimator.h>
+#include <hbvolumesliderpopup.h>
 #include <hbtransparentwindow.h>
 #include <hbiconanimationmanager.h>
 
@@ -45,11 +46,11 @@
 #include "mpxvideoplaybackviewfiledetails.h"
 #include "mpxvideoplaybackstatuspanecontrol.h"
 #include "mpxvideoplaybackfiledetailswidget.h"
-#include "mpxvideoplaybacknontouchvolumebar.h"
 #include "mpxvideoplaybackfullscreencontrol.h"
 #include "mpxvideoplaybackcontrolscontroller.h"
 #include "mpxvideoplaybackcontrolconfiguration.h"
 #include "mpxvideoplaybackdetailsplaybackwindow.h"
+#include "videoservices.h"
 
 
 // ================= MEMBER FUNCTIONS ==============================================================
@@ -71,7 +72,9 @@
     , mLoader( NULL )
     , mVolumeControl( NULL )
     , mThumbnailManager( NULL )
+    , mVideoServices( 0 )
     , mViewTransitionIsGoingOn( false )
+    , mIsAttachOperation( false )
     , mThumbNailState( EThumbNailEmpty )
     , mState( EPbStateNotInitialised )
     , mViewMode( EFullScreenView )
@@ -102,13 +105,11 @@
     {
         QGraphicsWidget *widget = mLoader->findWidget( QString( "content" ) );
         mView->setWidget( widget );
-
-        widget = mLoader->findWidget( QString( "volumeSlider" ) );
-        mVolumeControl = qobject_cast<QMPXVideoPlaybackNonTouchVolumeBar*>( widget );
     }
     else
     {
-        MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::initializeController()- can't find xml"));
+        MPX_DEBUG(
+                _L("QMPXVideoPlaybackControlsController::initializeController()- can't find xml"));
 
         //
         // Can't find xml for layout. Delete mLoader
@@ -117,17 +118,56 @@
         mLoader = NULL;
     }
 
-    mControlsPolicy = new QMPXVideoPlaybackControlPolicy();
-    mControlsConfig = new QMPXVideoPlaybackControlConfiguration( this );
-
-    connect( mControlsConfig, SIGNAL( controlListUpdated() ), this, SLOT( controlsListUpdated() ) );
-    
     mControlsTimer = new QTimer( this );
     mControlsTimer->setInterval( KMPXControlsTimeOut );
     mControlsTimer->setSingleShot( false );
     connect( mControlsTimer, SIGNAL( timeout() ), this, SLOT( hideAllControls() ) );
 
     connect( mView, SIGNAL( tappedOnScreen() ), this, SLOT( handleTappedOnScreen() ) );
+	
+    mControlsPolicy = new QMPXVideoPlaybackControlPolicy();
+    
+    mControlsConfig = new QMPXVideoPlaybackControlConfiguration( this );
+    connect( mControlsConfig, SIGNAL( controlListUpdated() ), this, SLOT( controlsListUpdated() ) );
+    mControlsConfig->createControlList();
+
+    mVolumeControl = new HbVolumeSliderPopup();
+    mVolumeControl->setVisible( false );
+    mVolumeControl->setTimeout( KMPXControlsTimeOut );
+    mVolumeControl->setTickPosition( Hb::NoSliderTicks );
+    mVolumeControl->setRange( KPbPlaybackVolumeLevelMin, KPbPlaybackVolumeLevelMax );
+
+    //
+    // if videoplayback is in service mode, create a videoservices instance
+    //
+    if ( XQServiceUtil::isService() && ! mVideoServices )
+    {
+        //
+        // obtain VideoServices instance 
+        //
+        mVideoServices = VideoServices::instance(); 
+
+        //
+        // allow 'attach' operation only for non-streaming media clips
+        //
+        if ( mVideoServices && mFileDetails->mPlaybackMode == EMPXVideoLocal )
+        {
+            //
+            // determine if this is 'attach' operation
+            //
+            mIsAttachOperation = ( mVideoServices->currentService() == VideoServices::EUriFetcher );
+            
+            if ( mIsAttachOperation )
+            {
+                //
+                // connect signal filePath() to videoservices slot itemSelected()
+                //
+                connect( this, SIGNAL( attachVideoPath( const QString& ) ), 
+                         mVideoServices, SLOT( itemSelected( const QString& ) ) );                        
+            }
+        }
+    }
+
 }
 
 // -------------------------------------------------------------------------------------------------
@@ -136,7 +176,7 @@
 //
 QMPXVideoPlaybackControlsController::~QMPXVideoPlaybackControlsController()
 {
-    MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::~QMPXVideoPlaybackControlsController"));
+    MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::~QMPXVideoPlaybackControlsController()"));
 
     disconnect( mControlsConfig, SIGNAL( controlListUpdated() ), this, SLOT( controlsListUpdated() ) );
 
@@ -174,8 +214,33 @@
     if ( mThumbnailManager )
     {
         delete mThumbnailManager;
-        mThumbnailManager = 0;                    
+        mThumbnailManager = NULL;                    
+    }
+
+    if ( mVolumeControl )
+    {
+        delete mVolumeControl;
+        mVolumeControl = NULL;
     }
+    
+    if ( mIsAttachOperation )
+    {
+        //
+        // disable connection for 'attach' operation
+        //
+        disconnect( this, SIGNAL( attachVideoPath( const QString& ) ), 
+                    mVideoServices, SLOT( itemSelected( const QString& ) ) );    
+    }
+    
+    if ( mVideoServices )
+    {    
+        //
+        // decrease videoservices instance count
+        //
+    	mVideoServices->decreaseReferenceCount();
+    	mVideoServices = 0;
+    }
+    
 }
 
 // -------------------------------------------------------------------------------------------------
@@ -187,17 +252,6 @@
 {
     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::addFileDetails"));
 
-    //
-    // If it is not local, hide the star rating
-    //
-    if ( details->mPlaybackMode != EMPXVideoLocal )
-    {
-        QString sectionName = "nonLocalPlayback";
-
-        bool ok = false;
-        mLoader->load( KMPXPLAYBACKVIEW_XML, sectionName, &ok );
-    }
-
     mFileDetails = details;
 
     mFileDetails->mRNFormat = realFormat( mFileDetails->mClipName );
@@ -363,34 +417,25 @@
 
         switch ( newState )
         {
-            case EPbStateInitialised:
-            {
-                //
-                //  remove branding control when the state is transitioned to Initialized
-                //
-                if ( mFileDetails->mPlaybackMode == EMPXVideoStreaming ||
-                     mFileDetails->mPlaybackMode == EMPXVideoLiveStreaming )
-                {
-                    mControlsConfig->updateControlList( EMPXControlCmdPluginInitialized ); 
-                }
-                
-                break;                
-            }
             case EPbStatePlaying:
             case EPbStateInitialising:
             case EPbStateBuffering:
             case EPbStatePaused:
             case EPbStateNotInitialised:
             {
-                updateState();
-
                 //
                 //  Show all the controls
                 //
                 showControls();
 
+                updateState();
+
                 break;
             }
+            default:
+            {
+                break;    
+            }
         }
     }
 }
@@ -1069,7 +1114,8 @@
 void QMPXVideoPlaybackControlsController::changeViewMode( 
         TPlaybackViewMode viewMode, bool transitionEffect )
 {
-    MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::changeViewMode()"));
+    MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::changeViewMode( %d, %d )"),
+            viewMode, transitionEffect );
 
     if ( viewMode != mViewMode )
     {
@@ -1159,7 +1205,8 @@
 //
 void QMPXVideoPlaybackControlsController::updateVideoRect( bool transitionEffect )
 {
-    MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::updateVideoRect()"));
+    MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::updateVideoRect( %d )"),
+            transitionEffect );
 
     if ( mFileDetails->mVideoEnabled && ! mFileDetails->mTvOutConnected )
     {
@@ -1167,6 +1214,9 @@
 
         QRectF rect;
 
+        MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::updateVideoRect() : mViewMode = %d )"),
+                mViewMode );
+			
         if ( mViewMode == EDetailsView )
         {
             QGraphicsWidget *parent = mLoader->findWidget( QString( "detailsPlaybackWindow" ) );
@@ -1285,16 +1335,6 @@
         hbIcon->setSize( tvOutBitmap->size() );
         tvOutLabel->setIcon( *hbIcon );
 
-        if ( qicon )
-        {
-            delete qicon;
-        }
-
-        if ( hbIcon )
-        {
-            delete hbIcon;
-        }
-
         mThumbNailState = EThumbNailSet;
     }
     else
@@ -1308,4 +1348,36 @@
                 this, SLOT( handleThumbnailReady( QPixmap , void * , int , int ) ) );
 }
 
+// -------------------------------------------------------------------------------------------------
+// QMPXVideoPlaybackControlsController::isAttachOperation
+// -------------------------------------------------------------------------------------------------
+//
+bool QMPXVideoPlaybackControlsController::isAttachOperation()
+{        
+    MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::isAttachOperation() ret %d"), 
+	    mIsAttachOperation );
+    
+    return mIsAttachOperation;
+}
+
+// -------------------------------------------------------------------------------------------------
+// QMPXVideoPlaybackControlsController::attachVideo()
+// -------------------------------------------------------------------------------------------------
+//
+void QMPXVideoPlaybackControlsController::attachVideo()
+{
+    MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlsController::attachVideo()"));
+    
+	//
+	// close and release resources
+	//
+    handleCommand( EMPXPbvCmdClose );
+	
+	//
+	// emit signal to launch videoservices itemSelected() slot
+	//
+    emit( attachVideoPath( mFileDetails->mClipName ) );
+    
+}
+
 // End of File