videoplayback/hbvideoplaybackview/viewsrc/hbvideobaseplaybackview.cpp
changeset 52 e3cecb93e76a
parent 47 45e72b57a2fd
child 59 a76e86df7ccd
--- a/videoplayback/hbvideoplaybackview/viewsrc/hbvideobaseplaybackview.cpp	Tue Jul 06 14:17:50 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,484 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:   Implementation of Video base playback view
-*
-*/
-
-// Version : %version: da1mmcf#43 %
-
-
-
-//  Include Files
-
-
-
-#include <QTimer>
-#include <QGraphicsSceneEvent>
-
-#include <hbmenu.h>
-#include <hbaction.h>
-#include <hbinstance.h>
-#include <hbnotificationdialog.h>
-#include <hblabel.h>
-#include <hbtapgesture.h>
-#include <hbpangesture.h>
-
-#include <textresolver.h>
-#include <mmf/common/mmferrors.h>
-#include <DRMHelper.h>
-
-#include <mpxvideoplaybackdefs.h>
-#include <mpxplaybackcommanddefs.h>
-#include <mpxhbvideocommondefs.h>
-
-#include "mpxvideo_debug.h"
-#include "mpxvideoviewwrapper.h"
-#include "mpxvideoplaybackuids.hrh"
-#include "hbvideobaseplaybackview.h"
-#include "videoactivitystate.h"   
-#include "mpxvideoplaybackviewfiledetails.h"  
-#include "mpxcommonvideoplaybackview.hrh"
-
-
-//  Member Functions
-
-// -------------------------------------------------------------------------------------------------
-// HbVideoBasePlaybackView::HbVideoBasePlaybackView()
-// -------------------------------------------------------------------------------------------------
-//
-HbVideoBasePlaybackView::HbVideoBasePlaybackView()
-    : mVideoMpxWrapper( NULL )
-    , mTimerForClosingView( NULL )
-    , mActivated( false )
-    , mStayPaused ( false )
-{
-    MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::HbVideoBasePlaybackView()"));
-}
-
-// -------------------------------------------------------------------------------------------------
-//   HbVideoBasePlaybackView::initializeVideoPlaybackView()
-// -------------------------------------------------------------------------------------------------
-//
-void HbVideoBasePlaybackView::initializeVideoPlaybackView()
-{
-    MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::initializeVideoPlaybackView()"));
-
-    //
-    // Need to set to control full screen including status pane area
-    //
-    setContentFullScreen();
-
-    mTimerForClosingView = new QTimer();
-    mTimerForClosingView->setSingleShot( true );
-    mTimerForClosingView->setInterval( 10 );
-    connect( mTimerForClosingView, SIGNAL( timeout() ), this, SIGNAL( activatePreviousView() ) );
-    
-    //
-    // Read activity data ...
-    // If last playback was forced to terminate due to low memory (GOOM, etc.)
-    // then the clip needs to be restored to the last played position 
-    // and the state needs to be paused, since forced termination can only occur for
-    // background apps - so if this happened Video Player must have been in background
-    // which implies paused state
-    //    
-    int lastViewType = VideoActivityState::instance().getActivityData(KEY_VIEWPLUGIN_TYPE).toInt();    
-    if ( lastViewType == MpxHbVideoCommon::PlaybackView ) 
-    {
-        QVariant data = VideoActivityState::instance().getActivityData(KEY_LAST_PLAY_POSITION_ID);
-        mLastPlayPosition = data.toInt();   
-        
-        mStayPaused = true;
-    }     
-}
-
-// -------------------------------------------------------------------------------------------------
-// HbVideoBasePlaybackView::~HbVideoBasePlaybackView()
-// -------------------------------------------------------------------------------------------------
-//
-HbVideoBasePlaybackView::~HbVideoBasePlaybackView()
-{
-    MPX_DEBUG(_L("HbVideoBasePlaybackView::~HbVideoBasePlaybackView()"));
-
-    if ( mTimerForClosingView )
-    {
-        disconnect( mTimerForClosingView, SIGNAL( timeout() ), this, SIGNAL( activatePreviousView() ) );
-
-        if ( mTimerForClosingView->isActive() )
-        {
-            mTimerForClosingView->stop();
-        }
-
-        delete mTimerForClosingView;
-        mTimerForClosingView = NULL;
-    }
-
-    if ( mVideoMpxWrapper )
-    {
-        delete mVideoMpxWrapper;
-        mVideoMpxWrapper = NULL;
-    }
-
-    setParentItem( 0 );
-}
-
-// -------------------------------------------------------------------------------------------------
-//   HbVideoBasePlaybackView::handleActivateView()
-// -------------------------------------------------------------------------------------------------
-//
-void HbVideoBasePlaybackView::handleActivateView()
-{
-    MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::handleActivateView()"));
-
-    MPX_TRAPD( err, mVideoMpxWrapper = CMPXVideoViewWrapper::NewL( this ) );
-
-    QCoreApplication::instance()->installEventFilter( this );
-
-    //
-    //  Request the needed Media from the Playback Plugin
-    //
-    MPX_TRAP( err, mVideoMpxWrapper->RequestMediaL() );
-
-    menu()->close();
-
-    //
-    // Landscape orientation
-    // Workaround: Disable orientation transition effect
-	// since orbit couldn't emit the orientationChanged signal with transition effect
-	//
-    hbInstance->allMainWindows()[0]->setOrientation( Qt::Horizontal, false );
-
-    mActivated = true;
-}
-
-// -------------------------------------------------------------------------------------------------
-//   HbVideoBasePlaybackView::handleDeactivateView()
-// -------------------------------------------------------------------------------------------------
-//
-void HbVideoBasePlaybackView::handleDeactivateView()
-{
-    MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::handleDeactivateView()"));
-
-    saveActivityData();
-    
-    mActivated = false;
-
-    QCoreApplication::instance()->removeEventFilter( this );
-
-    //
-    //  Close the playback plugin to release all references to previous clip
-    //
-    MPX_TRAPD( err, mVideoMpxWrapper->HandleCommandL( EMPXPbvCmdClose ) );
-
-    if ( mVideoMpxWrapper )
-    {
-        delete mVideoMpxWrapper;
-        mVideoMpxWrapper = NULL;
-    }
-
-    //
-    // go back to device orientation
-    //
-    //hbInstance->allMainWindows()[0]->unsetOrientation();
-}
-
-// -------------------------------------------------------------------------------------------------
-//   HbVideoBasePlaybackView::saveActivityData()
-// -------------------------------------------------------------------------------------------------
-//
-void HbVideoBasePlaybackView::saveActivityData()
-{
-    MPX_DEBUG( _L("HbVideoBasePlaybackView::saveActivityData()") );  
-    
-    // save the activity data
-    QVariant data = QString( mVideoMpxWrapper->iFileDetails->mClipName );
-    VideoActivityState::instance().setActivityData(data, KEY_LAST_PLAYED_CLIP); 
-    
-    data = int( mVideoMpxWrapper->iPlayPosition );
-    VideoActivityState::instance().setActivityData(data, KEY_LAST_PLAY_POSITION_ID);
-    
-    data = bool( mVideoMpxWrapper->iFileDetails->mPlaybackMode == EMPXVideoLocal );
-    VideoActivityState::instance().setActivityData(data, KEY_LAST_LOCAL_PLAYBACK);     
-}
-
-// -------------------------------------------------------------------------------------------------
-//   HbVideoBasePlaybackView::handleClosePlaybackView()
-// -------------------------------------------------------------------------------------------------
-//
-void HbVideoBasePlaybackView::handleClosePlaybackView()
-{
-    MPX_DEBUG(
-      _L("HbVideoBasePlaybackView::handleClosePlaybackView()") );
-
-    if ( mVideoMpxWrapper && mVideoMpxWrapper->IsMultiItemPlaylist() )
-    {
-        TRAP_IGNORE( mVideoMpxWrapper->HandleCommandL( EMPXPbvCmdNextListItem ) );
-    }
-    else
-    {
-        closePlaybackView();
-    }
-}
-
-// -------------------------------------------------------------------------------------------------
-//   HbVideoBasePlaybackView::handlePluginError()
-// -------------------------------------------------------------------------------------------------
-//
-void HbVideoBasePlaybackView::handlePluginError( int aError )
-{
-    MPX_DEBUG(
-      _L("HbVideoBasePlaybackView::handlePluginError() aError = %d"), aError );
-
-    switch ( aError )
-    {
-        case KErrCancel:
-		{
-            handleClosePlaybackView();
-            break;
-        }
-        case KErrMMDRMNotAuthorized:
-        case KErrCANoRights:
-        case KErrCANoPermission:
-        {
-            showDialog( hbTrId( "txt_videos_info_license_has_expired_or_it_is_missi" ) );
-            break;
-        }
-        case KMPXVideoCallOngoingError:
-        {
-            showDialog( hbTrId( "txt_videos_info_video_playback_is_not_allowed_duri" ), false );
-            break;
-        }
-        default:
-        {
-            TRAP_IGNORE(
-
-                //
-                //  TextResolver instance for error resolving.
-                //
-                CTextResolver* textresolver = CTextResolver::NewLC();
-
-                //
-                //  Resolve the error text
-                //
-                TPtrC text;
-                text.Set( textresolver->ResolveErrorString( aError ) );
-
-                //
-                // convert to QString
-                //
-                const QString qString( (QChar*)text.Ptr(), text.Length() );
-
-                //
-                // clean up textresolver
-                //
-                CleanupStack::PopAndDestroy( textresolver );
-
-                //
-                // display error and close playback view
-                //
-                showDialog( qString );
-            );
-        }
-    }
-}
-
-// -------------------------------------------------------------------------------------------------
-//   HbVideoBasePlaybackView::showDialog
-// -------------------------------------------------------------------------------------------------
-//
-void HbVideoBasePlaybackView::showDialog( const QString& qString, bool closeView )
-{
-    MPX_DEBUG(_L("HbVideoBasePlaybackView::showDialog( %s, %d )"), qString.data(), closeView );
-
-    //
-    // create pop-up dialog for error notes,
-    //     set its position to the middle of the screen
-    //     and make sure pop-up dialog gets deleted on close.
-    //
-    QRectF screenRect = hbInstance->allMainWindows()[0]->rect();
-    HbNotificationDialog* dlg = new HbNotificationDialog();
-    dlg->setAttribute( Qt::WA_DeleteOnClose );
-    dlg->setMinimumSize( QSizeF(200, 100) );
-    dlg->setPreferredPos( QPointF( screenRect.height()/2, screenRect.width()/2 ),
-                          HbPopup::Center );
-
-	if ( closeView )
-	{
-        //
-        // connect aboutToClose() signal to handleClosePopupDialog() slot so that
-        // when pop-up dialog is closed, playback view is closed also
-        //
-        connect( dlg, SIGNAL( aboutToClose() ), this, SLOT( handleClosePopupDialog() ) );
-    }
-
-    //
-    // convert string to label so text alignment can be set
-    //
-    HbLabel *label = new HbLabel( qString );
-    label->setAlignment( Qt::AlignCenter );
-
-    //
-    // set label as content widget and show pop-up dialog
-    //
-    dlg->setContentWidget( label );
-    dlg->show();
-}
-
-// -------------------------------------------------------------------------------------------------
-//   HbVideoBasePlaybackView::doClosePlayer
-// -------------------------------------------------------------------------------------------------
-//
-void HbVideoBasePlaybackView::doClosePlayer()
-{
-    MPX_DEBUG(_L("HbVideoBasePlaybackView::doClosePlayer()"));
-
-    handleDeactivateView();
-
-    qApp->quit();
-}
-
-// -------------------------------------------------------------------------------------------------
-//   HbVideoBasePlaybackView::issuePlayCommand
-// -------------------------------------------------------------------------------------------------
-//
-void HbVideoBasePlaybackView::issuePlayCommand()
-{
-    MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::issuePlayCommand()"));
-
-    int err = KErrNone;
-
-    TRAP( err, mVideoMpxWrapper->CreateGeneralPlaybackCommandL( EPbCmdPlay ));
-
-    MPX_DEBUG(_L("HbVideoBasePlaybackView::issuePlayCommand() error = %d"), err);
-}
-
-// -------------------------------------------------------------------------------------------------
-//   HbVideoBasePlaybackView::retrievePdlInformation
-// -------------------------------------------------------------------------------------------------
-//
-void HbVideoBasePlaybackView::retrievePdlInformation()
-{
-    MPX_DEBUG(_L("HbVideoBasePlaybackView::retrievePdlInformation()"));
-}
-
-// -------------------------------------------------------------------------------------------------
-//   HbVideoBasePlaybackView::handleBufferingState
-// -------------------------------------------------------------------------------------------------
-//
-void HbVideoBasePlaybackView::handleBufferingState()
-{
-    MPX_DEBUG(_L("HbVideoBasePlaybackView::handleBufferingState()"));
-}
-
-// -------------------------------------------------------------------------------------------------
-//   HbVideoBasePlaybackView::closePlaybackView()
-// -------------------------------------------------------------------------------------------------
-//
-void HbVideoBasePlaybackView::closePlaybackView()
-{
-    MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::closePlaybackView()"));
-
-    mTimerForClosingView->start( 0 );
-}
-
-// ---------------------------------------------------------------------------
-// HbVideoBasePlaybackView::eventFilter
-// ---------------------------------------------------------------------------
-//
-bool HbVideoBasePlaybackView::eventFilter( QObject *object, QEvent *event )
-{
-    Q_UNUSED( object );
-
-    switch ( event->type() )
-    {
-        case QEvent::ApplicationActivate:
-        {
-            if ( mActivated )
-            {
-                MPX_DEBUG(_L("HbVideoBasePlaybackView::eventFilter foreground()") );
-                TRAP_IGNORE( mVideoMpxWrapper->IssueVideoAppForegroundCmdL( true ) );
-            }
-            break;
-        }
-        case QEvent::ApplicationDeactivate:
-        {
-            if ( mActivated )
-            {
-                MPX_DEBUG(_L("HbVideoBasePlaybackView::eventFilter background()") );
-                TRAP_IGNORE( mVideoMpxWrapper->IssueVideoAppForegroundCmdL( false ) );
-            }
-            break;
-        }
-    }
-
-    return QObject::eventFilter( object, event );
-}
-
-// -------------------------------------------------------------------------------------------------
-//   HbVideoBasePlaybackView::getWindow()
-// -------------------------------------------------------------------------------------------------
-//
-RWindow *HbVideoBasePlaybackView::getWindow()
-{
-    return static_cast<RWindow*>( hbInstance->allMainWindows()[0]->effectiveWinId()->DrawableWindow() );
-}
-
-// -------------------------------------------------------------------------------------------------
-//   HbVideoBasePlaybackView::handleClosePopupDialog()
-// -------------------------------------------------------------------------------------------------
-//
-void HbVideoBasePlaybackView::handleClosePopupDialog()
-{
-    MPX_DEBUG(_L("HbVideoBasePlaybackView::handleClosePopupDialog()") );
-
-    handleClosePlaybackView();
-}
-
-// -------------------------------------------------------------------------------------------------
-//   HbVideoBasePlaybackView::gestureEvent()
-// -------------------------------------------------------------------------------------------------
-//
-void HbVideoBasePlaybackView::gestureEvent( QGestureEvent* event )
-{
-    if ( HbTapGesture * gesture = static_cast<HbTapGesture *>( event->gesture( Qt::TapGesture ) ) )
-    {
-        if ( gesture->state() == Qt::GestureFinished && mActivated )
-        {
-            MPX_DEBUG(_L("HbVideoBasePlaybackView::gestureEvent() tapGesture finished") );
-
-            emit tappedOnScreen();
-        }
-    }
-    else if ( HbPanGesture* gesture = static_cast<HbPanGesture*>( event->gesture( Qt::PanGesture ) ) )
-    {
-        if ( gesture->state() == Qt::GestureFinished && mActivated )
-        {
-            QPointF delta( gesture->sceneDelta() );
-
-            if ( delta.x() > 0 )
-            {
-                MPX_DEBUG(_L("HbVideoBasePlaybackView::gestureEvent() right") );
-
-                emit pannedToRight();
-            }
-            else
-            {
-                MPX_DEBUG(_L("HbVideoBasePlaybackView::gestureEvent() left") );
-
-                emit pannedToLeft();
-            }
-        }
-    }
-}
-
-// EOF