videoplayerapp/videoplayerengine/src/videoplayerengine.cpp
changeset 47 45e72b57a2fd
parent 46 adbe7d5ba2f5
child 52 e3cecb93e76a
equal deleted inserted replaced
46:adbe7d5ba2f5 47:45e72b57a2fd
    13 *
    13 *
    14 * Description:  Implementation of VideoPlayerEngine
    14 * Description:  Implementation of VideoPlayerEngine
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // Version : %version: 33 %
    18 // Version : %version: da1mmcf#37 %
    19 
    19 
    20 
    20 
    21 #include <QApplication>
    21 #include <QApplication>
    22 
    22 
    23 #include <hbinstance.h>
    23 #include <hbinstance.h>
    58 // -------------------------------------------------------------------------------------------------
    58 // -------------------------------------------------------------------------------------------------
    59 //
    59 //
    60 QVideoPlayerEngine::~QVideoPlayerEngine()
    60 QVideoPlayerEngine::~QVideoPlayerEngine()
    61 {
    61 {
    62     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::~QVideoPlayerEngine()"));
    62     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::~QVideoPlayerEngine()"));
    63     	
    63 
    64     if ( mVideoServices )
    64     if ( mVideoServices )
    65     {
    65     {
    66     	mVideoServices->decreaseReferenceCount();
    66     	mVideoServices->decreaseReferenceCount();
    67     	mVideoServices = 0;
    67     	mVideoServices = 0;
    68     }
    68     }
    69 
    69 
    70     if ( mCollectionViewPlugin ) 
    70     if ( mCollectionViewPlugin )
    71     {
    71     {
    72         mCollectionViewPlugin->destroyView();
    72         mCollectionViewPlugin->destroyView();
    73 		delete mCollectionViewPlugin;
    73 		delete mCollectionViewPlugin;
    74 		mCollectionViewPlugin = 0;
    74 		mCollectionViewPlugin = 0;
    75     }
    75     }
    76 
    76 
    77     if ( mPlaybackViewPlugin ) 
    77     if ( mPlaybackViewPlugin )
    78     {
    78     {
    79         mPlaybackViewPlugin->destroyView();
    79         mPlaybackViewPlugin->destroyView();
    80 		delete mPlaybackViewPlugin;
    80 		delete mPlaybackViewPlugin;
    81 		mPlaybackViewPlugin = 0;
    81 		mPlaybackViewPlugin = 0;
    82     }
    82     }
    83 
    83 
    84     if ( mFileDetailsViewPlugin ) 
    84     if ( mFileDetailsViewPlugin )
    85     {
    85     {
    86         mFileDetailsViewPlugin->destroyView();
    86         mFileDetailsViewPlugin->destroyView();
    87 		delete mFileDetailsViewPlugin;
    87 		delete mFileDetailsViewPlugin;
    88 		mFileDetailsViewPlugin = 0;
    88 		mFileDetailsViewPlugin = 0;
    89     }
    89     }
    90 
    90 
    91     delete mPlaybackWrapper;
    91     delete mPlaybackWrapper;
    92 
    92 
    93     // disconnect all signals 
    93     // disconnect all signals
    94     disconnect();
    94     disconnect();
    95 }
    95 }
    96 
    96 
    97 // -------------------------------------------------------------------------------------------------
    97 // -------------------------------------------------------------------------------------------------
    98 // initialize()
    98 // initialize()
    99 // -------------------------------------------------------------------------------------------------
    99 // -------------------------------------------------------------------------------------------------
   100 //
   100 //
   101 void QVideoPlayerEngine::initialize()
   101 void QVideoPlayerEngine::initialize()
   102 {
   102 {
   103     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::initialize()"));	
   103     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::initialize()"));
   104 	
   104 
   105     //
   105     //
   106     // Clean up QVideoPlayerEngine when qApp try to quit
   106     // Clean up QVideoPlayerEngine when qApp try to quit
   107     //
   107     //
   108     connect( qApp, SIGNAL( aboutToQuit() ), this, SLOT( handleQuit() ) );
   108     connect( qApp, SIGNAL( aboutToQuit() ), this, SLOT( handleQuit() ) );
   109 
   109 
   119                  SLOT( handleCommand( int ) ) );
   119                  SLOT( handleCommand( int ) ) );
   120     }
   120     }
   121 
   121 
   122     QList<XQPluginInfo> impls;
   122     QList<XQPluginInfo> impls;
   123     XQPluginLoader::listImplementations("org.nokia.mmdt.MpxViewPlugin/1.0", impls);
   123     XQPluginLoader::listImplementations("org.nokia.mmdt.MpxViewPlugin/1.0", impls);
   124     
   124 
   125     if ( mIsService )
   125     if ( mIsService )
   126     {
   126     {
   127         if(!mVideoServices)
   127         if(!mVideoServices)
   128         {
   128         {
   129             mVideoServices = VideoServices::instance(this);
   129             mVideoServices = VideoServices::instance(this);
   130             connect( mVideoServices, SIGNAL(activated(int)), this, SLOT(handleCommand(int)));
   130             connect( mVideoServices, SIGNAL(activated(int)), this, SLOT(handleCommand(int)));
   131         }
   131         }
   132         if ( isPlayServiceInvoked() )
   132         if ( isPlayServiceInvoked() )
   133         {
   133         {
   134             createPlaybackView(); 
   134             createPlaybackView();
   135         }
   135         }
   136         else
   136         else
   137         {
   137         {
   138             loadPluginAndCreateView( MpxHbVideoCommon::CollectionView );  
   138             loadPluginAndCreateView( MpxHbVideoCommon::CollectionView );
   139             
   139 
   140             // Browse service will activate view once the category to be opened is informed from highway
   140             // Browse service will activate view once the category to be opened is informed from highway
   141             // since the category is not known at this point, we do not activate view for it here
   141             // since the category is not known at this point, we do not activate view for it here
   142             if(!(XQServiceUtil::interfaceName().contains("IVideoBrowse")))
   142             if(!(XQServiceUtil::interfaceName().contains("IVideoBrowse")))
   143             {
   143             {
   144                 activateView( MpxHbVideoCommon::CollectionView );   
   144                 activateView( MpxHbVideoCommon::CollectionView );
   145             }
   145             }
   146         }
   146         }
   147     }
   147     }
   148     else
   148     else
   149     {
   149     {
   150         // check latest plugin type from activity manager data and create + activate it 
   150         // check latest plugin type from activity manager data and create + activate it
   151         // CollectionView (default) and playbackview are the ones that are accepted
   151         // CollectionView (default) and playbackview are the ones that are accepted
   152         MpxHbVideoCommon::MpxHbVideoViewType viewType = MpxHbVideoCommon::CollectionView;
   152         MpxHbVideoCommon::MpxHbVideoViewType viewType = MpxHbVideoCommon::CollectionView;
   153         int typeGotten = VideoActivityState::instance().getActivityData(VideoActivityData::KEY_VIEWPLUGIN_TYPE).toInt();
   153         int typeGotten = VideoActivityState::instance().getActivityData(KEY_VIEWPLUGIN_TYPE).toInt();
   154         if(typeGotten == MpxHbVideoCommon::CollectionView || typeGotten == MpxHbVideoCommon::PlaybackView)
   154 
   155         {
   155         if ( typeGotten == MpxHbVideoCommon::PlaybackView )
       
   156         {
       
   157             createPlaybackView();
   156             viewType = MpxHbVideoCommon::MpxHbVideoViewType(typeGotten);
   158             viewType = MpxHbVideoCommon::MpxHbVideoViewType(typeGotten);
   157         }
   159             QVariant data = VideoActivityState::instance().getActivityData(KEY_LAST_PLAYED_CLIP);
   158         loadPluginAndCreateView( viewType );  
   160             playMedia( data.toString() );
   159         activateView( viewType );
   161         }
   160     }
   162         else
   161             
   163         {
       
   164             loadPluginAndCreateView( viewType );
       
   165             activateView( viewType );
       
   166         }
       
   167     }
   162 }
   168 }
   163 
   169 
   164 // -------------------------------------------------------------------------------------------------
   170 // -------------------------------------------------------------------------------------------------
   165 // handleCommand()
   171 // handleCommand()
   166 // -------------------------------------------------------------------------------------------------
   172 // -------------------------------------------------------------------------------------------------
   167 //
   173 //
   168 void QVideoPlayerEngine::handleCommand( int commandCode )
   174 void QVideoPlayerEngine::handleCommand( int commandCode )
   169 {
   175 {
   170     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::handleCommand()"),
   176     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::handleCommand()"),
   171                    _L("commandCode = %d"), commandCode );
   177                    _L("commandCode = %d"), commandCode );
   172     
   178 
   173     switch ( commandCode )
   179     switch ( commandCode )
   174     {
   180     {
   175         case MpxHbVideoCommon::ActivateCollectionView:
   181         case MpxHbVideoCommon::ActivateCollectionView:
   176         {
   182         {
   177             if ( mCurrentViewPlugin != mCollectionViewPlugin )
   183             if ( mCurrentViewPlugin != mCollectionViewPlugin )
   178             { 
   184             {
   179                 activateView( MpxHbVideoCommon::CollectionView );
   185                 activateView( MpxHbVideoCommon::CollectionView );
   180             }
   186             }
   181             break;
   187             break;
   182         }
   188         }
   183         case MpxHbVideoCommon::ActivatePlaybackView:
   189         case MpxHbVideoCommon::ActivatePlaybackView:
   184         {
   190         {
   185             if ( mCurrentViewPlugin != mPlaybackViewPlugin )
   191             if ( mCurrentViewPlugin != mPlaybackViewPlugin )
   186             {                
   192             {
   187                 activateView( MpxHbVideoCommon::PlaybackView );                
   193                 activateView( MpxHbVideoCommon::PlaybackView );
   188             }
   194             }
   189             break;
   195             break;
   190         }
   196         }
   191         case MpxHbVideoCommon::ActivateVideoDetailsView:
   197         case MpxHbVideoCommon::ActivateVideoDetailsView:
   192         {
   198         {
   193             if ( mCurrentViewPlugin != mFileDetailsViewPlugin )
   199             if ( mCurrentViewPlugin != mFileDetailsViewPlugin )
   194             {
   200             {
   195                 activateView( MpxHbVideoCommon::VideoDetailsView );                
   201                 activateView( MpxHbVideoCommon::VideoDetailsView );
   196             }
   202             }
   197             break;
   203             break;
   198         }
   204         }
   199         case MpxHbVideoCommon::DoDelayedLoad:
   205         case MpxHbVideoCommon::DoDelayedLoad:
   200         {
   206         {
   202             {
   208             {
   203                 doDelayedLoad();
   209                 doDelayedLoad();
   204             }
   210             }
   205             break;
   211             break;
   206         }
   212         }
   207         
   213 
   208         default:
   214         default:
   209         {
   215         {
   210             break;
   216             break;
   211         }
   217         }
   212     }    
   218     }
   213 }
   219 }
   214 
   220 
   215 // -------------------------------------------------------------------------------------------------
   221 // -------------------------------------------------------------------------------------------------
   216 // doDelayedLoad()
   222 // doDelayedLoad()
   217 // -------------------------------------------------------------------------------------------------
   223 // -------------------------------------------------------------------------------------------------
   218 //
   224 //
   219 void QVideoPlayerEngine::doDelayedLoad()
   225 void QVideoPlayerEngine::doDelayedLoad()
   220 {
   226 {
   221     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::doDelayedLoad()"));
   227     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::doDelayedLoad()"));
   222 	
   228 
   223     createMissingViews();
   229     createMissingViews();
   224 	
   230 
   225     mDelayedLoadDone = true;
   231     mDelayedLoadDone = true;
   226 }
   232 }
   227 
   233 
   228 // -------------------------------------------------------------------------------------------------
   234 // -------------------------------------------------------------------------------------------------
   229 // createPlaybackView()
   235 // createPlaybackView()
   230 // -------------------------------------------------------------------------------------------------
   236 // -------------------------------------------------------------------------------------------------
   231 //
   237 //
   232 void QVideoPlayerEngine::createPlaybackView()
   238 void QVideoPlayerEngine::createPlaybackView()
   233 {
   239 {
       
   240     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::createPlaybackView()"));
       
   241 
   234     mPlaybackWrapper->lateInit();
   242     mPlaybackWrapper->lateInit();
   235        
   243 
   236     if ( ! mPlaybackViewPlugin )
   244     if ( ! mPlaybackViewPlugin )
   237     {
   245     {
   238        loadPluginAndCreateView( MpxHbVideoCommon::PlaybackView );
   246        loadPluginAndCreateView( MpxHbVideoCommon::PlaybackView );
   239     }
   247     }
   240 }
   248 }
   244 // -------------------------------------------------------------------------------------------------
   252 // -------------------------------------------------------------------------------------------------
   245 //
   253 //
   246 void QVideoPlayerEngine::createMissingViews()
   254 void QVideoPlayerEngine::createMissingViews()
   247 {
   255 {
   248     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::createMissingViews()"));
   256     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::createMissingViews()"));
   249     
   257 
   250     //
   258     //
   251     // delayed initialization of some uiengine member variables
   259     // delayed initialization of some uiengine member variables
   252     // to help application startup time & improve playback start time
   260     // to help application startup time & improve playback start time
   253     //
   261     //
   254     createPlaybackView();
   262     createPlaybackView();
   271 //
   279 //
   272 void QVideoPlayerEngine::activateView( MpxHbVideoCommon::MpxHbVideoViewType viewType )
   280 void QVideoPlayerEngine::activateView( MpxHbVideoCommon::MpxHbVideoViewType viewType )
   273 {
   281 {
   274     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::activateView() "),
   282     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::activateView() "),
   275                    _L("viewType = %d"), viewType );
   283                    _L("viewType = %d"), viewType );
   276     	  
   284 
   277     disconnectView();
   285     disconnectView();
   278     
   286 
   279     if ( mCurrentViewPlugin )
   287     if ( mCurrentViewPlugin )
   280     {
   288     {
   281         mCurrentViewPlugin->deactivateView();
   289         mCurrentViewPlugin->deactivateView();
   282         mCurrentViewPlugin = NULL;
   290         mCurrentViewPlugin = NULL;
   283     }
   291     }
   287         case MpxHbVideoCommon::CollectionView:
   295         case MpxHbVideoCommon::CollectionView:
   288         {
   296         {
   289             if ( shouldExit() )
   297             if ( shouldExit() )
   290             {
   298             {
   291                 qApp->quit();
   299                 qApp->quit();
   292                 XQServiceUtil::toBackground( false );             
   300                 XQServiceUtil::toBackground( false );
   293             }
   301             }
   294             else if ( shouldActivateCollectionView()  )
   302             else if ( shouldActivateCollectionView()  )
   295             {
   303             {
   296                 if ( ! mCollectionViewPlugin )
   304                 if ( ! mCollectionViewPlugin )
   297                 {
   305                 {
   298                     loadPluginAndCreateView( MpxHbVideoCommon::CollectionView );
   306                     loadPluginAndCreateView( MpxHbVideoCommon::CollectionView );
   299                 }            
   307                 }
   300                 mCurrentViewPlugin = mCollectionViewPlugin;
   308                 mCurrentViewPlugin = mCollectionViewPlugin;
   301                 setCurrentView();                    
   309                 setCurrentView();
   302             }
   310             }
   303             
   311 
   304             break;    
   312             break;
   305         }
   313         }
   306         case MpxHbVideoCommon::PlaybackView:
   314         case MpxHbVideoCommon::PlaybackView:
   307         {
   315         {
   308             if ( ! mPlaybackViewPlugin )
   316             if ( ! mPlaybackViewPlugin )
   309             {
   317             {
   310                 loadPluginAndCreateView( MpxHbVideoCommon::PlaybackView );
   318                 loadPluginAndCreateView( MpxHbVideoCommon::PlaybackView );
   311             }
   319             }
   312             
   320 
   313             mCurrentViewPlugin = mPlaybackViewPlugin;
   321             mCurrentViewPlugin = mPlaybackViewPlugin;
   314             setCurrentView();     
   322             setCurrentView();
   315             
   323 
   316             break;    
   324             break;
   317         }
   325         }
   318         case MpxHbVideoCommon::VideoDetailsView:
   326         case MpxHbVideoCommon::VideoDetailsView:
   319         {
   327         {
   320             if ( ! mFileDetailsViewPlugin )
   328             if ( ! mFileDetailsViewPlugin )
   321             {
   329             {
   322                 loadPluginAndCreateView( MpxHbVideoCommon::VideoDetailsView );  
   330                 loadPluginAndCreateView( MpxHbVideoCommon::VideoDetailsView );
   323             }
   331             }
   324             
   332 
   325             mCurrentViewPlugin = mFileDetailsViewPlugin;
   333             mCurrentViewPlugin = mFileDetailsViewPlugin;
   326             setCurrentView();       
   334             setCurrentView();
   327             
   335 
   328             break;    
   336             break;
   329         }        
   337         }
   330     }    
   338     }
   331 }
   339 }
   332 
   340 
   333 // -------------------------------------------------------------------------------------------------
   341 // -------------------------------------------------------------------------------------------------
   334 // loadPluginAndCreateView()
   342 // loadPluginAndCreateView()
   335 // -------------------------------------------------------------------------------------------------
   343 // -------------------------------------------------------------------------------------------------
   336 //
   344 //
   337 void QVideoPlayerEngine::loadPluginAndCreateView( MpxHbVideoCommon::MpxHbVideoViewType viewType )
   345 void QVideoPlayerEngine::loadPluginAndCreateView( MpxHbVideoCommon::MpxHbVideoViewType viewType )
   338 {
   346 {
   339     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::loadPluginAndCreateView() "), 
   347     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::loadPluginAndCreateView() "),
   340                    _L("viewType = %d"), viewType );
   348                    _L("viewType = %d"), viewType );
   341 	  
   349 
   342     int viewTypeUid( 0 );
   350     int viewTypeUid( 0 );
   343 
   351 
   344     if ( viewType == MpxHbVideoCommon::CollectionView ) 
   352     if ( viewType == MpxHbVideoCommon::CollectionView )
   345     {
   353     {
   346         viewTypeUid = MpxHbVideoCommon::KMpxVideoPluginDllCollectionUid;
   354         viewTypeUid = MpxHbVideoCommon::KMpxVideoPluginDllCollectionUid;
   347     }
   355     }
   348     else if ( viewType == MpxHbVideoCommon::PlaybackView ) 
   356     else if ( viewType == MpxHbVideoCommon::PlaybackView )
   349     {
   357     {
   350         viewTypeUid = MpxHbVideoCommon::KMpxVideoPluginDllPlaybackUid;
   358         viewTypeUid = MpxHbVideoCommon::KMpxVideoPluginDllPlaybackUid;
   351     }
   359     }
   352     else if ( viewType == MpxHbVideoCommon::VideoDetailsView )
   360     else if ( viewType == MpxHbVideoCommon::VideoDetailsView )
   353     {
   361     {
   354         viewTypeUid = MpxHbVideoCommon::KMpxVideoPluginDllFileDetailsUid;
   362         viewTypeUid = MpxHbVideoCommon::KMpxVideoPluginDllFileDetailsUid;
   355     }
   363     }
   356 
   364 
   357     if ( viewTypeUid )
   365     if ( viewTypeUid )
   358     {
   366     {
   359         // 
   367         //
   360         // load corresponding plug-in
   368         // load corresponding plug-in
   361         //
   369         //
   362         XQPluginLoader pluginLoader( viewTypeUid );
   370         XQPluginLoader pluginLoader( viewTypeUid );
   363         QObject* instance = pluginLoader.instance();
   371         QObject* instance = pluginLoader.instance();
   364 
   372 
   365         if ( instance )
   373         if ( instance )
   366         {
   374         {
   367             MpxViewPlugin *currentViewPlugin = NULL;
   375             MpxViewPlugin *currentViewPlugin = NULL;
   368 
   376 
   369             if ( viewType == MpxHbVideoCommon::CollectionView ) 
   377             if ( viewType == MpxHbVideoCommon::CollectionView )
   370             {
   378             {
   371                 mCollectionViewPlugin = qobject_cast<MpxViewPlugin*>( instance )->viewPlugin();
   379                 mCollectionViewPlugin = qobject_cast<MpxViewPlugin*>( instance )->viewPlugin();
   372                 currentViewPlugin = mCollectionViewPlugin;
   380                 currentViewPlugin = mCollectionViewPlugin;
   373             }
   381             }
   374             else if ( viewType == MpxHbVideoCommon::PlaybackView )
   382             else if ( viewType == MpxHbVideoCommon::PlaybackView )
   381                 mFileDetailsViewPlugin = qobject_cast<MpxViewPlugin*>( instance )->viewPlugin();
   389                 mFileDetailsViewPlugin = qobject_cast<MpxViewPlugin*>( instance )->viewPlugin();
   382                 currentViewPlugin = mFileDetailsViewPlugin;
   390                 currentViewPlugin = mFileDetailsViewPlugin;
   383             }
   391             }
   384             else
   392             else
   385             {
   393             {
   386                 MPX_DEBUG(_L("QVideoPlayerEngine::loadPluginAndCreateView() : plugin not FOUND ! "));                
   394                 MPX_DEBUG(_L("QVideoPlayerEngine::loadPluginAndCreateView() : plugin not FOUND ! "));
   387             }
   395             }
   388             
   396 
   389             //
   397             //
   390             // create corresponding view
   398             // create corresponding view
   391             //
   399             //
   392             if ( currentViewPlugin ) 
   400             if ( currentViewPlugin )
   393             {
   401             {
   394                 QGraphicsWidget *view = currentViewPlugin->getView();
   402                 QGraphicsWidget *view = currentViewPlugin->getView();
   395           
   403 
   396                 if ( ! view )
   404                 if ( ! view )
   397                 {
   405                 {
   398                     MPX_DEBUG(_L("QVideoPlayerEngine::loadPluginAndCreateView() : create view "));
   406                     MPX_DEBUG(_L("QVideoPlayerEngine::loadPluginAndCreateView() : create view "));
   399                     
   407 
   400                     currentViewPlugin->createView();
   408                     currentViewPlugin->createView();
   401                     hbInstance->allMainWindows().value(0)->addView( currentViewPlugin->getView() );
   409                     hbInstance->allMainWindows().value(0)->addView( currentViewPlugin->getView() );
   402                 }
   410                 }
   403                 else
   411                 else
   404                 {
   412                 {
   405                     MPX_DEBUG(_L("QVideoPlayerEngine::loadPluginAndCreateView() : view has already been created! "));                    
   413                     MPX_DEBUG(_L("QVideoPlayerEngine::loadPluginAndCreateView() : view has already been created! "));
   406                 }
   414                 }
   407             }
   415             }
   408             else
   416             else
   409             {
   417             {
   410                 MPX_DEBUG(_L("QVideoPlayerEngine::loadPluginAndCreateView() : currentViewPlugin is NULL ! "));                    
   418                 MPX_DEBUG(_L("QVideoPlayerEngine::loadPluginAndCreateView() : currentViewPlugin is NULL ! "));
   411             }            
   419             }
   412         }
   420         }
   413     }
   421     }
   414 }
   422 }
   415 
   423 
   416 // -------------------------------------------------------------------------------------------------
   424 // -------------------------------------------------------------------------------------------------
   419 // -------------------------------------------------------------------------------------------------
   427 // -------------------------------------------------------------------------------------------------
   420 //
   428 //
   421 void QVideoPlayerEngine::connectView()
   429 void QVideoPlayerEngine::connectView()
   422 {
   430 {
   423     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::connectView()"));
   431     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::connectView()"));
   424 	  
   432 
   425     connect( mCurrentViewPlugin,
   433     connect( mCurrentViewPlugin,
   426              SIGNAL( command( int ) ),
   434              SIGNAL( command( int ) ),
   427              this,
   435              this,
   428              SLOT( handleCommand( int ) ) );
   436              SLOT( handleCommand( int ) ) );
   429 }
   437 }
   434 // -------------------------------------------------------------------------------------------------
   442 // -------------------------------------------------------------------------------------------------
   435 //
   443 //
   436 void QVideoPlayerEngine::disconnectView()
   444 void QVideoPlayerEngine::disconnectView()
   437 {
   445 {
   438     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::disconnectView()"));
   446     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::disconnectView()"));
   439 	  
   447 
   440     if ( mCurrentViewPlugin )
   448     if ( mCurrentViewPlugin )
   441     {
   449     {
   442         disconnect( mCurrentViewPlugin,
   450         disconnect( mCurrentViewPlugin,
   443                     SIGNAL( command( int ) ),
   451                     SIGNAL( command( int ) ),
   444                     this,
   452                     this,
   445                     SLOT( handleCommand( int ) ) );   
   453                     SLOT( handleCommand( int ) ) );
   446     }
   454     }
   447 }
   455 }
   448 
   456 
   449 // -------------------------------------------------------------------------------------------------
   457 // -------------------------------------------------------------------------------------------------
   450 // handleQuit()
   458 // handleQuit()
   451 // -------------------------------------------------------------------------------------------------
   459 // -------------------------------------------------------------------------------------------------
   452 //
   460 //
   453 void QVideoPlayerEngine::handleQuit()
   461 void QVideoPlayerEngine::handleQuit()
   454 {
   462 {
   455     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::handleQuit()"));
   463     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::handleQuit()"));
   456 	
   464 
   457     if(!mIsService)
   465     if(!mIsService)
   458     {
   466     {
   459         VideoActivityState &localActivity(VideoActivityState::instance());
   467         VideoActivityState &localActivity(VideoActivityState::instance());
   460             
   468 
   461         QVariant data = QVariant();
   469         QVariant data = QVariant();
   462         HbActivityManager *actManager = qobject_cast<HbApplication*>(qApp)->activityManager();
   470         HbActivityManager *actManager = qobject_cast<HbApplication*>(qApp)->activityManager();
   463         
   471 
       
   472         //
       
   473         // deactivate is the final point for current plugin to save it's activity data into
       
   474         // VideoActivityState before they are saved to to activity manager
       
   475         //
       
   476         mCurrentViewPlugin->deactivateView();
       
   477 
   464         //
   478         //
   465         // get and save recent view type: either playback or collection view plugins are currently used.
   479         // get and save recent view type: either playback or collection view plugins are currently used.
   466         // activity will not be saved from the details plugin
   480         // activity will not be saved from the details plugin
   467         //
   481         //
   468         int viewType = MpxHbVideoCommon::CollectionView;
   482         int viewType = MpxHbVideoCommon::CollectionView;
   469         if(mCurrentViewPlugin == mPlaybackViewPlugin)
   483         if(mCurrentViewPlugin == mPlaybackViewPlugin)
   470         {
   484         {
   471             viewType = MpxHbVideoCommon::PlaybackView;
   485             // for playback view, the state preservation and restoration should only be done
   472         }
   486             // for loacl clips (non-streaming) - so set KEY_VIEWPLUGIN_TYPE to PlaybackView only
       
   487             // for local clips. Otherwise the default value CollectionView should be set.
       
   488             //
       
   489             QVariant playdata = VideoActivityState::instance().getActivityData(KEY_LAST_LOCAL_PLAYBACK);
       
   490             if  ( playdata.toBool() )
       
   491             {
       
   492                 viewType = MpxHbVideoCommon::PlaybackView;
       
   493             }
       
   494         }
       
   495 
   473         data = viewType;
   496         data = viewType;
   474         localActivity.setActivityData(data, VideoActivityData::KEY_VIEWPLUGIN_TYPE);
   497         localActivity.setActivityData(data, KEY_VIEWPLUGIN_TYPE);
   475         
   498 
   476         //
       
   477         // deactivate is the final point for current plugin to save it's activity data into 
       
   478         // VideoActivityState before they are saved to to activity manager
       
   479         //
       
   480         mCurrentViewPlugin->deactivateView();
       
   481         
       
   482         // save data to activity manager
   499         // save data to activity manager
   483         actManager->addActivity(ACTIVITY_VIDEOPLAYER_MAINVIEW, 
   500         actManager->addActivity(ACTIVITY_VIDEOPLAYER_MAINVIEW,
   484                                 localActivity.getActivityData(),
   501                                 localActivity.getActivityData(),
   485                                 QVariantHash());                
   502                                 QVariantHash());
   486     }
   503     }
   487     
   504 
   488     delete this;
   505     delete this;
   489 }
   506 }
   490 
   507 
   491 
   508 
   492 // -------------------------------------------------------------------------------------------------
   509 // -------------------------------------------------------------------------------------------------
   494 // -------------------------------------------------------------------------------------------------
   511 // -------------------------------------------------------------------------------------------------
   495 //
   512 //
   496 void QVideoPlayerEngine::playMedia( QString filePath )
   513 void QVideoPlayerEngine::playMedia( QString filePath )
   497 {
   514 {
   498     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::playMedia()"),
   515     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::playMedia()"),
   499                    _L("filePath = %s"), filePath.data() );  
   516                    _L("filePath = %s"), filePath.data() );
   500 	  	
   517 
   501     mPlaybackWrapper->playMedia( filePath );
   518     mPlaybackWrapper->playMedia( filePath );
   502 }
   519 }
   503 
   520 
   504 // -------------------------------------------------------------------------------------------------
   521 // -------------------------------------------------------------------------------------------------
   505 // playMedia()
   522 // playMedia()
   506 // -------------------------------------------------------------------------------------------------
   523 // -------------------------------------------------------------------------------------------------
   507 //
   524 //
   508 void QVideoPlayerEngine::playMedia( RFile file )
   525 void QVideoPlayerEngine::playMedia( RFile file )
   509 {
   526 {
   510     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::playMedia( RFile )")); 
   527     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::playMedia( RFile )"));
   511         
   528 
   512     mPlaybackWrapper->playMedia( file );    
   529     mPlaybackWrapper->playMedia( file );
   513 }
   530 }
   514 
   531 
   515 // -------------------------------------------------------------------------------------------------
   532 // -------------------------------------------------------------------------------------------------
   516 // setEmbedded()
   533 // setEmbedded()
   517 // -------------------------------------------------------------------------------------------------
   534 // -------------------------------------------------------------------------------------------------
   518 //
   535 //
   519 void QVideoPlayerEngine::setEmbedded()
   536 void QVideoPlayerEngine::setEmbedded()
   520 {
   537 {
   521     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::setEmbedded()")); 
   538     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::setEmbedded()"));
   522 	  
   539 
   523     mEmbedded = true;
   540     mEmbedded = true;
   524 }
   541 }
   525 
   542 
   526 // -------------------------------------------------------------------------------------------------
   543 // -------------------------------------------------------------------------------------------------
   527 // setCurrentView()
   544 // setCurrentView()
   528 // -------------------------------------------------------------------------------------------------
   545 // -------------------------------------------------------------------------------------------------
   529 //
   546 //
   530 void QVideoPlayerEngine::setCurrentView()
   547 void QVideoPlayerEngine::setCurrentView()
   531 {
   548 {
   532     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::setCurrentView()")); 
   549     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::setCurrentView()"));
   533 	
   550 
   534     if ( mCurrentViewPlugin )
   551     if ( mCurrentViewPlugin )
   535     {
   552     {
   536         //
   553         //
   537         // set current view
   554         // set current view
   538         //
   555         //
   539         hbInstance->allMainWindows().value(0)->setCurrentView( 
   556         hbInstance->allMainWindows().value(0)->setCurrentView(
   540 		                            qobject_cast<HbView*>( mCurrentViewPlugin->getView() ), false );
   557 		                            qobject_cast<HbView*>( mCurrentViewPlugin->getView() ), false );
   541 
   558 
   542         //
   559         //
   543         // connect view
   560         // connect view
   544         //
   561         //
   545         connectView();
   562         connectView();
   546 
   563 
   547         // 
   564         //
   548         // activate view
   565         // activate view
   549         //
   566         //
   550         mCurrentViewPlugin->activateView();
   567         mCurrentViewPlugin->activateView();
   551     }
   568     }
   552 }
   569 }
   555 // isPlayServiceInvoked()
   572 // isPlayServiceInvoked()
   556 // -------------------------------------------------------------------------------------------------
   573 // -------------------------------------------------------------------------------------------------
   557 //
   574 //
   558 bool QVideoPlayerEngine::isPlayServiceInvoked()
   575 bool QVideoPlayerEngine::isPlayServiceInvoked()
   559 {
   576 {
   560     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::isPlayServiceInvoked()"));       
   577     MPX_ENTER_EXIT(_L("QVideoPlayerEngine::isPlayServiceInvoked()"));
   561     
   578 
   562     bool result = false;   
   579     bool result = false;
   563     
   580 
   564     if ( mIsService )
   581     if ( mIsService )
   565     {
   582     {
   566         QString intface = XQServiceUtil::interfaceName();
   583         QString intface = XQServiceUtil::interfaceName();
   567                         
   584 
   568         if ( intface.contains("IVideoView") ||
   585         if ( intface.contains("IVideoView") ||
   569              intface.contains("IFileView") )
   586              intface.contains("IFileView") )
   570         {
   587         {
   571             result = true;
   588             result = true;
   572             mIsPlayService = true;
   589             mIsPlayService = true;
   573         }
   590         }
   574     }
   591     }
   575     
   592 
   576     return result;
   593     return result;
   577 }
   594 }
   578 
   595 
   579 // -------------------------------------------------------------------------------------------------
   596 // -------------------------------------------------------------------------------------------------
   580 // shouldExit()
   597 // shouldExit()
   581 // -------------------------------------------------------------------------------------------------
   598 // -------------------------------------------------------------------------------------------------
   582 //
   599 //
   583 bool QVideoPlayerEngine::shouldExit()
   600 bool QVideoPlayerEngine::shouldExit()
   584 {            
   601 {
   585     bool result = false;
   602     bool result = false;
   586     
   603 
   587     if ( mIsPlayService )  // play or view service
   604     if ( mIsPlayService )  // play or view service
   588     {
   605     {
   589         result = true;               
   606         result = true;
   590     }
   607     }
   591     
   608 
   592     MPX_DEBUG(_L("QVideoPlayerEngine::shouldExit() return %d"), result);     
   609     MPX_DEBUG(_L("QVideoPlayerEngine::shouldExit() return %d"), result);
   593     
   610 
   594     return result;
   611     return result;
   595 }
   612 }
   596 
   613 
   597 
   614 
   598 // -------------------------------------------------------------------------------------------------
   615 // -------------------------------------------------------------------------------------------------
   599 // shouldActivateCollectionView()
   616 // shouldActivateCollectionView()
   600 // -------------------------------------------------------------------------------------------------
   617 // -------------------------------------------------------------------------------------------------
   601 //
   618 //
   602 bool QVideoPlayerEngine::shouldActivateCollectionView()
   619 bool QVideoPlayerEngine::shouldActivateCollectionView()
   603 {            
   620 {
   604     bool result = true;  
   621     bool result = true;
   605     
   622 
   606     // the only case where collection view should NOT be activated is ...
   623     // the only case where collection view should NOT be activated is ...
   607     // if we are in service and that service is fetch and if fetch is selected 
   624     // if we are in service and that service is fetch and if fetch is selected
   608     // in all other cases collection view should be activated
   625     // in all other cases collection view should be activated
   609     
   626 
   610     if ( mIsService &&
   627     if ( mIsService &&
   611          mVideoServices->currentService() == VideoServices::EUriFetcher &&
   628          mVideoServices->currentService() == VideoServices::EUriFetcher &&
   612          mVideoServices->mFetchSelected  )
   629          mVideoServices->mFetchSelected  )
   613     {
   630     {
   614         result = false;                    
   631         result = false;
   615     }  
   632     }
   616         
   633 
   617     MPX_DEBUG(_L("QVideoPlayerEngine::shouldActivateCollectionView() return %d"), result);     
   634     MPX_DEBUG(_L("QVideoPlayerEngine::shouldActivateCollectionView() return %d"), result);
   618     
   635 
   619     return result;
   636     return result;
   620 }
   637 }
   621 
   638 
   622 // End of file
   639 // End of file