videoplayerapp/videoplayerengine/src/videoplayerengine.cpp
changeset 62 0e1e938beb1a
parent 59 a76e86df7ccd
equal deleted inserted replaced
59:a76e86df7ccd 62:0e1e938beb1a
    13 *
    13 *
    14 * Description:  Implementation of VideoPlayerEngine
    14 * Description:  Implementation of VideoPlayerEngine
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // Version : %version: da1mmcf#43 %
    18 // Version : %version: 47 %
    19 
    19 
    20 
    20 
    21 #include <QApplication>
    21 #include <QApplication>
    22 
    22 
    23 #include <hbinstance.h>
    23 #include <hbinstance.h>
    24 #include <xqpluginloader.h>
    24 #include <xqpluginloader.h>
    25 #include <xqplugininfo.h>
    25 #include <xqplugininfo.h>
    26 #include <xqserviceutil.h>
    26 #include <xqserviceutil.h>
    27 #include <hbview.h>
    27 #include <hbview.h>
    28 #include <hbapplication.h>
    28 #include <hbapplication.h>
    29 #include <hbactivitymanager.h>
       
    30 #include <hbnotificationdialog.h>
    29 #include <hbnotificationdialog.h>
       
    30 #include <afactivitystorage.h>
    31 
    31 
    32 #include "videoplayerengine.h"
    32 #include "videoplayerengine.h"
    33 #include "videoactivitystate.h"
    33 #include "videoactivitystate.h"
    34 #include "videoplaybackwrapper.h"
    34 #include "videoplaybackwrapper.h"
    35 #include "videoservices.h"
    35 #include "videoservices.h"
    48     , mPlaybackViewPlugin( 0 )
    48     , mPlaybackViewPlugin( 0 )
    49     , mCollectionViewPlugin( 0 )
    49     , mCollectionViewPlugin( 0 )
    50     , mFileDetailsViewPlugin( 0 )
    50     , mFileDetailsViewPlugin( 0 )
    51     , mPlaybackWrapper( 0 )
    51     , mPlaybackWrapper( 0 )
    52     , mVideoServices( 0 )
    52     , mVideoServices( 0 )
       
    53     , mActivityStorage( 0 )
    53 {
    54 {
    54     MPX_DEBUG(_L("VideoPlayerEngine::VideoPlayerEngine()"));
    55     MPX_DEBUG(_L("VideoPlayerEngine::VideoPlayerEngine()"));
    55 }
    56 }
    56 
    57 
    57 // -------------------------------------------------------------------------------------------------
    58 // -------------------------------------------------------------------------------------------------
    89         mFileDetailsViewPlugin = 0;
    90         mFileDetailsViewPlugin = 0;
    90     }
    91     }
    91 
    92 
    92     delete mPlaybackWrapper;
    93     delete mPlaybackWrapper;
    93 
    94 
       
    95     delete mActivityStorage;
       
    96     
    94     // disconnect all signals 
    97     // disconnect all signals 
    95     disconnect();
    98     disconnect();
    96 }
    99 }
    97 
   100 
    98 // -------------------------------------------------------------------------------------------------
   101 // -------------------------------------------------------------------------------------------------
   149             }
   152             }
   150         }
   153         }
   151     }
   154     }
   152     else
   155     else
   153     {
   156     {
       
   157         if(!mActivityStorage)
       
   158         {
       
   159             mActivityStorage = new AfActivityStorage();
       
   160         }
       
   161         
       
   162         VideoActivityState::instance().setActivityData(mActivityStorage->activityData(ACTIVITY_VIDEOPLAYER_MAINVIEW));    
       
   163 
       
   164         // after reading, remove activity to prevent multiple instances in taskswitcher
       
   165         mActivityStorage->removeActivity(ACTIVITY_VIDEOPLAYER_MAINVIEW);
       
   166         
   154         //
   167         //
   155         // check latest plugin type from activity manager data and create + activate it 
   168         // check latest plugin type from activity manager data and create + activate it 
   156         // CollectionView (default) and playbackview are the ones that are accepted
   169         // CollectionView (default) and playbackview are the ones that are accepted
   157         //
   170         //
   158         MpxHbVideoCommon::MpxHbVideoViewType viewType = MpxHbVideoCommon::CollectionView;
   171         MpxHbVideoCommon::MpxHbVideoViewType viewType = MpxHbVideoCommon::CollectionView;
   228         default:
   241         default:
   229         {
   242         {
   230             break;
   243             break;
   231         }
   244         }
   232     }    
   245     }    
   233 }
       
   234 
       
   235 // -------------------------------------------------------------------------------------------------
       
   236 // viewReadySlot()
       
   237 // -------------------------------------------------------------------------------------------------
       
   238 //
       
   239 void VideoPlayerEngine::viewReadySlot()
       
   240 {
       
   241     MPX_ENTER_EXIT(_L("VideoPlayerEngine::viewReady()"));
       
   242     emit applicationReady();
       
   243     // since we need to emit applicationReady only once at startup,
       
   244     // disconnect the viewReady -signal from this object
       
   245     disconnect(hbInstance->allMainWindows().value(0), SIGNAL(viewReady()), 
       
   246                this, SLOT(viewReadySlot()));
       
   247 }
   246 }
   248 
   247 
   249 // -------------------------------------------------------------------------------------------------
   248 // -------------------------------------------------------------------------------------------------
   250 // doDelayedLoad()
   249 // doDelayedLoad()
   251 // -------------------------------------------------------------------------------------------------
   250 // -------------------------------------------------------------------------------------------------
   486 //
   485 //
   487 void VideoPlayerEngine::handleQuit()
   486 void VideoPlayerEngine::handleQuit()
   488 {
   487 {
   489     MPX_ENTER_EXIT(_L("VideoPlayerEngine::handleQuit()"));
   488     MPX_ENTER_EXIT(_L("VideoPlayerEngine::handleQuit()"));
   490 	
   489 	
   491     if ( ! mIsService )
   490     if ( ! mIsService && mActivityStorage)
   492     {
   491     {
   493         VideoActivityState &localActivity(VideoActivityState::instance());
   492         VideoActivityState &localActivity(VideoActivityState::instance());
   494             
   493         
   495         QVariant data = QVariant();
   494         // screenshot required for activity to save correctly
   496         HbActivityManager *actManager = qobject_cast<HbApplication*>(qApp)->activityManager();
   495         // need to take it before deactivation to actually show something
       
   496         QVariantHash metadata;
       
   497         HbMainWindow *window = hbInstance->allMainWindows().first();
       
   498         metadata.insert("screenshot", QPixmap::grabWidget(window, window->rect()));
       
   499             
       
   500         QVariant data = QVariant();      
   497         
   501         
   498         //
   502         //
   499         // deactivate is the final point for current plugin to save it's activity data into 
   503         // deactivate is the final point for current plugin to save it's activity data into 
   500         // VideoActivityState before they are saved to to activity manager
   504         // VideoActivityState before they are saved to to activity manager
   501         //
   505         //
   502         mCurrentViewPlugin->deactivateView();        
   506         if ( mCurrentViewPlugin )
       
   507         {
       
   508             mCurrentViewPlugin->deactivateView();
       
   509         }
   503         
   510         
   504         //
   511         //
   505         // get and save recent view type: either playback or collection view plugins are currently used.
   512         // get and save recent view type: either playback or collection view plugins are currently used.
   506         // activity will not be saved from the details plugin
   513         // activity will not be saved from the details plugin
   507         //
   514         //
   521             }            
   528             }            
   522         }
   529         }
   523         
   530         
   524         data = viewType;
   531         data = viewType;
   525         localActivity.setActivityData( data, KEY_VIEWPLUGIN_TYPE );
   532         localActivity.setActivityData( data, KEY_VIEWPLUGIN_TYPE );
   526         
   533 
   527         // save data to activity manager
   534         // save data to activity manager, if it fails there's nothing to do
   528         actManager->addActivity( ACTIVITY_VIDEOPLAYER_MAINVIEW, 
   535         mActivityStorage->saveActivity( ACTIVITY_VIDEOPLAYER_MAINVIEW, 
   529                                  localActivity.getActivityData(),
   536                                         localActivity.getActivityData(),
   530                                  QVariantHash() );                
   537                                         metadata );
       
   538                                                 
   531     }
   539     }
   532     
   540     
   533     delete this;
   541     delete this;
   534 }
   542 }
   535 
   543 
   631 {
   639 {
   632     MPX_ENTER_EXIT(_L("VideoPlayerEngine::isPlayServiceInvoked()"));       
   640     MPX_ENTER_EXIT(_L("VideoPlayerEngine::isPlayServiceInvoked()"));       
   633     
   641     
   634     bool result = false;   
   642     bool result = false;   
   635     
   643     
   636     if ( mIsService )
   644     if ( mIsPlayService )
       
   645     {
       
   646         result = true;        
       
   647     }    
       
   648     else if ( mIsService )
   637     {
   649     {
   638         QString intface = XQServiceUtil::interfaceName();
   650         QString intface = XQServiceUtil::interfaceName();
   639         MPX_DEBUG(_L("VideoPlayerEngine::isPlayServiceInvoked() : interfaceName(%s)"), intface.data() );     
   651         MPX_DEBUG(_L("VideoPlayerEngine::isPlayServiceInvoked() : interfaceName(%s)"), intface.data() );     
   640                         
   652                         
   641         if ( intface.contains("IVideoView") ||
   653         if ( intface.contains("IVideoView") ||