videoplayerapp/videoplayerengine/src/videoservices.cpp
branchRCL_3
changeset 22 839377eedc2b
equal deleted inserted replaced
21:315810614048 22:839377eedc2b
       
     1 /*
       
     2 * Copyright (c) 2009 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:  Implementation of VideoServices
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version: da1mmcf#10 %
       
    19 
       
    20 #include "videoplayerengine.h"
       
    21 #include "videoservices.h"
       
    22 #include "videoserviceurifetch.h"
       
    23 #include "videoserviceplay.h"
       
    24 #include "videoserviceview.h"
       
    25 #include "videoservicebrowse.h"
       
    26 #include "videoserviceuri.h"
       
    27 #include "mpxvideo_debug.h"
       
    28 #include <xqaiwdecl.h>
       
    29 #include <xqserviceutil.h>
       
    30 
       
    31 VideoServices *VideoServices::mInstance = 0;
       
    32 
       
    33 // -------------------------------------------------------------------------------------------------
       
    34 // VideoServices::instance()
       
    35 // -------------------------------------------------------------------------------------------------
       
    36 //
       
    37 VideoServices* VideoServices::instance( VideoPlayerEngine* engine )
       
    38 {
       
    39     MPX_ENTER_EXIT(_L("VideoServices::instance()"));
       
    40     
       
    41     if ( ! mInstance )
       
    42     {
       
    43         mInstance = new VideoServices(engine);
       
    44     }
       
    45     else if ( engine && ! mInstance->engine() )
       
    46     {
       
    47     	mInstance->setEngine(engine);
       
    48     }
       
    49 
       
    50     mInstance->mReferenceCount++;
       
    51     return mInstance;
       
    52 }
       
    53 
       
    54 // -------------------------------------------------------------------------------------------------
       
    55 // VideoServices::decreaseReferenceCount()
       
    56 // -------------------------------------------------------------------------------------------------
       
    57 //
       
    58 void VideoServices::decreaseReferenceCount()
       
    59 {
       
    60     MPX_ENTER_EXIT(_L("VideoServices::decreaseReferenceCount()"));
       
    61     
       
    62     if ( mInstance )
       
    63     {
       
    64         if ( --mInstance->mReferenceCount == 0 )
       
    65         {
       
    66             delete mInstance;
       
    67             mInstance = NULL;
       
    68         }
       
    69     }
       
    70 }
       
    71 
       
    72 // -------------------------------------------------------------------------------------------------
       
    73 // setEngine()
       
    74 // -------------------------------------------------------------------------------------------------
       
    75 //
       
    76 void VideoServices::setEngine( VideoPlayerEngine* engine )
       
    77 {
       
    78     MPX_ENTER_EXIT(_L("VideoServices::setEngine()"));
       
    79     
       
    80     if ( mServicePlay )
       
    81     {
       
    82     	mEngine = engine;
       
    83     	mServicePlay->setEngine(engine);
       
    84     }
       
    85     
       
    86     if ( mServiceView )
       
    87     {
       
    88     	mEngine = engine;
       
    89     	mServiceView->setEngine(engine);    	
       
    90     }
       
    91     
       
    92     if ( mServiceUriView )
       
    93     {
       
    94         mEngine = engine;
       
    95         mServiceUriView->setEngine(engine);  
       
    96     }
       
    97     		
       
    98 }
       
    99 
       
   100 // -------------------------------------------------------------------------------------------------
       
   101 // engine()
       
   102 // -------------------------------------------------------------------------------------------------
       
   103 //
       
   104 VideoPlayerEngine* VideoServices::engine()
       
   105 {
       
   106     MPX_DEBUG(_L("VideoServices::engine"));
       
   107 	
       
   108     return mEngine;
       
   109 }
       
   110 
       
   111 // -------------------------------------------------------------------------------------------------
       
   112 // VideoServices()
       
   113 // -------------------------------------------------------------------------------------------------
       
   114 //
       
   115 VideoServices::VideoServices( VideoPlayerEngine* engine ) 
       
   116     : mReferenceCount( 0 )
       
   117     , mEngine( engine )
       
   118     , mCurrentService( VideoServices::ENoService )
       
   119     , mFetchSelected( false )
       
   120 {
       
   121     MPX_ENTER_EXIT(_L("VideoServices::VideoServices()"));
       
   122    
       
   123     // New service, new interface
       
   124     mServicePlay = new VideoServicePlay( this, engine, 
       
   125                                  QLatin1String("videoplayer.com.nokia.symbian.IVideoView") );  
       
   126 
       
   127     // New service, new interface
       
   128     mServiceView = new VideoServiceView( this, engine, 
       
   129                                  QLatin1String("videoplayer.com.nokia.symbian.IFileView") ); 
       
   130           
       
   131     // New service, new interface
       
   132     mServiceUriFetch = new VideoServiceUriFetch( this, 
       
   133                                  QLatin1String("videoplayer.com.nokia.symbian.IVideoFetch") ); 
       
   134 
       
   135     // New service, new interface
       
   136     mServiceBrowse = new VideoServiceBrowse( this, 
       
   137                                  QLatin1String("videoplayer.com.nokia.symbian.IVideoBrowse") ); 
       
   138 
       
   139     // New service, old interface
       
   140     mServicePlayDeprecatedNewService = new VideoServicePlay( this, engine, 
       
   141                                                       QLatin1String("videoplayer.IVideoView") ); 
       
   142 
       
   143     // Old service, old interface
       
   144     mServicePlayDeprecatedOldService = new VideoServicePlay( this, engine, 
       
   145                                                       QLatin1String("com.nokia.Videos.IVideoView") );    
       
   146     
       
   147     // New service, old interface
       
   148     mServiceViewDeprecatedNewService = new VideoServiceView( this, engine, 
       
   149                                                       QLatin1String("videoplayer.IFileView") ); 
       
   150 
       
   151     // Old service, old interface 
       
   152     mServiceViewDeprecatedOldService = new VideoServiceView( this, engine, 
       
   153                                                       QLatin1String("com.nokia.Videos.IFileView") );     
       
   154     
       
   155     // New service, old interface
       
   156     mServiceUriFetchDeprecatedNewService = new VideoServiceUriFetch( this, 
       
   157                                                       QLatin1String("videoplayer.IVideoFetch") ); 
       
   158 
       
   159     // Old service, old interface
       
   160     mServiceUriFetchDeprecatedOldService = new VideoServiceUriFetch( this, 
       
   161                                                       QLatin1String("com.nokia.Videos.IVideoFetch") );     
       
   162 
       
   163     // New service, old interface
       
   164     mServiceBrowseDeprecatedNewService = new VideoServiceBrowse( this, 
       
   165                                                       QLatin1String("videoplayer.IVideoBrowse")) ; 
       
   166 
       
   167     // Old service, old interface
       
   168     mServiceBrowseDeprecatedOldService = new VideoServiceBrowse( this, 
       
   169                                                       QLatin1String("com.nokia.Videos.IVideoBrowse") ); 
       
   170 	
       
   171     // new service, new interface
       
   172     mServiceUriView = new VideoServiceUri(  this, engine, QLatin1String("videoplayer.com.nokia.symbian.IUriView"));	
       
   173     
       
   174 	
       
   175 }
       
   176 
       
   177 // -------------------------------------------------------------------------------------------------
       
   178 // ~VideoServices()
       
   179 // -------------------------------------------------------------------------------------------------
       
   180 //
       
   181 VideoServices::~VideoServices()
       
   182 {
       
   183     MPX_ENTER_EXIT(_L("VideoServices::~VideoServices()"));
       
   184     
       
   185     delete mServiceUriFetch;
       
   186     delete mServicePlay;
       
   187     delete mServiceView;
       
   188     delete mServiceBrowse;
       
   189     delete mServicePlayDeprecatedNewService;
       
   190     delete mServicePlayDeprecatedOldService;
       
   191     delete mServiceViewDeprecatedNewService;
       
   192     delete mServiceViewDeprecatedOldService;
       
   193     delete mServiceBrowseDeprecatedNewService;
       
   194     delete mServiceUriFetchDeprecatedNewService;
       
   195     delete mServiceBrowseDeprecatedOldService;
       
   196     delete mServiceUriFetchDeprecatedOldService;
       
   197     delete mServiceUriView;
       
   198 }
       
   199 
       
   200 // -------------------------------------------------------------------------------------------------
       
   201 // currentService()
       
   202 // -------------------------------------------------------------------------------------------------
       
   203 //
       
   204 VideoServices::TVideoService VideoServices::currentService()
       
   205 {
       
   206     MPX_DEBUG(_L("VideoServices::currentService() ret %d"), mCurrentService );
       
   207 	
       
   208     return mCurrentService;
       
   209 }
       
   210 
       
   211 // -------------------------------------------------------------------------------------------------
       
   212 // getBrowseCategory()
       
   213 // -------------------------------------------------------------------------------------------------
       
   214 //
       
   215 int VideoServices::getBrowseCategory() const
       
   216 {
       
   217     MPX_DEBUG(_L("VideoServices::getBrowseCategory()"));
       
   218 	
       
   219     int category = 0;
       
   220 
       
   221     if ( mServiceBrowse && ( XQServiceUtil::interfaceName().contains("symbian") ) )
       
   222     {
       
   223         category = mServiceBrowse->getBrowseCategory();
       
   224     }
       
   225     else if ( mServiceBrowseDeprecatedNewService && 
       
   226               mServiceBrowseDeprecatedOldService && 
       
   227               ! ( XQServiceUtil::interfaceName().contains("symbian") ) )
       
   228     {
       
   229     	if ( mServiceBrowseDeprecatedNewService->isActive() )
       
   230     	{
       
   231             category = mServiceBrowseDeprecatedNewService->getBrowseCategory();
       
   232     	}
       
   233     	else
       
   234     	{
       
   235             category = mServiceBrowseDeprecatedOldService->getBrowseCategory();
       
   236     	}
       
   237     }
       
   238 
       
   239     return category;
       
   240 }
       
   241 
       
   242 // -------------------------------------------------------------------------------------------------
       
   243 // setCurrentService()
       
   244 // -------------------------------------------------------------------------------------------------
       
   245 //
       
   246 void VideoServices::setCurrentService(VideoServices::TVideoService service)
       
   247 {
       
   248     MPX_DEBUG(_L("VideoServices::setCurrentService(%d)"), service );
       
   249 	
       
   250     mCurrentService = service;	
       
   251 }
       
   252 
       
   253 // -------------------------------------------------------------------------------------------------
       
   254 // contextTitle()
       
   255 // -------------------------------------------------------------------------------------------------
       
   256 //
       
   257 QString VideoServices::contextTitle() const
       
   258 {
       
   259     MPX_DEBUG(_L("VideoServices::contextTitle()") );
       
   260 	
       
   261     QString title;
       
   262 
       
   263     if ( mCurrentService == VideoServices::EUriFetcher )
       
   264     {
       
   265     	if ( mServiceUriFetch && ( XQServiceUtil::interfaceName().contains("symbian") ) )
       
   266     	{
       
   267             title = mServiceUriFetch->contextTitle();
       
   268     	}
       
   269     	else if ( mServiceUriFetchDeprecatedNewService && 
       
   270                   mServiceUriFetchDeprecatedOldService && 
       
   271                   ! ( XQServiceUtil::interfaceName().contains("symbian") ) )
       
   272     	{
       
   273 
       
   274             if ( mServiceUriFetchDeprecatedNewService->isActive() )
       
   275     	    {
       
   276     	        title = mServiceUriFetchDeprecatedNewService->contextTitle();
       
   277             }
       
   278     	    else
       
   279     	    {
       
   280     	        title = mServiceUriFetchDeprecatedOldService->contextTitle();
       
   281     	    }
       
   282     	}
       
   283     }
       
   284     else if ( mCurrentService == VideoServices::EBrowse )
       
   285     {
       
   286     	if ( mServiceBrowse && ( XQServiceUtil::interfaceName().contains("symbian") ) )
       
   287         {
       
   288             title = mServiceBrowse->contextTitle();
       
   289         }
       
   290     	else if ( mServiceBrowseDeprecatedNewService && 
       
   291                   mServiceBrowseDeprecatedOldService && 
       
   292                   ! ( XQServiceUtil::interfaceName().contains("symbian") ) )
       
   293         {
       
   294             if ( mServiceBrowseDeprecatedNewService->isActive() )
       
   295             {
       
   296                 title = mServiceBrowseDeprecatedNewService->contextTitle();
       
   297             }
       
   298             else
       
   299             {
       
   300                 title = mServiceBrowseDeprecatedOldService->contextTitle();
       
   301             }
       
   302         }
       
   303     }
       
   304     
       
   305     return title;
       
   306 }
       
   307 
       
   308 // -------------------------------------------------------------------------------------------------
       
   309 // sortRole()
       
   310 // -------------------------------------------------------------------------------------------------
       
   311 //
       
   312 int VideoServices::sortRole() const
       
   313 {
       
   314     MPX_ENTER_EXIT(_L("VideoServices::sortType()"));
       
   315     
       
   316     int sortRole = 0;
       
   317 
       
   318     if ( mCurrentService == EBrowse )
       
   319     {
       
   320     	if ( mServiceBrowse && ( XQServiceUtil::interfaceName().contains("symbian") ) )
       
   321         {
       
   322             sortRole = mServiceBrowse->sortRole();
       
   323         }
       
   324     	else if ( mServiceBrowseDeprecatedNewService && 
       
   325                   mServiceBrowseDeprecatedOldService && 
       
   326                   ! ( XQServiceUtil::interfaceName().contains("symbian") ) )
       
   327         {
       
   328             if ( mServiceBrowseDeprecatedNewService->isActive() )
       
   329             {
       
   330                 sortRole = mServiceBrowseDeprecatedNewService->sortRole();
       
   331             }
       
   332             else
       
   333             {
       
   334                 sortRole = mServiceBrowseDeprecatedOldService->sortRole();
       
   335             }
       
   336         }
       
   337     }
       
   338     
       
   339     return sortRole;
       
   340 }
       
   341 
       
   342 // -------------------------------------------------------------------------------------------------
       
   343 // itemSelected()
       
   344 // -------------------------------------------------------------------------------------------------
       
   345 //
       
   346 void VideoServices::itemSelected(const QString& item)
       
   347 {
       
   348     MPX_ENTER_EXIT(_L("VideoServices::itemSelected()"),
       
   349                    _L("item = %s"), item.data() );
       
   350     
       
   351     QStringList list;
       
   352     list.append( item );
       
   353 
       
   354     if( mServiceUriFetch && ( XQServiceUtil::interfaceName().contains("symbian") ) )
       
   355     {
       
   356     	mServiceUriFetch->complete( list );
       
   357     }
       
   358     else if ( mServiceUriFetchDeprecatedNewService && mServiceUriFetchDeprecatedOldService )
       
   359     {
       
   360     	if ( mServiceUriFetchDeprecatedNewService->isActive() )
       
   361     	{
       
   362             mServiceUriFetchDeprecatedNewService->complete( list );
       
   363     	}
       
   364     	else
       
   365     	{
       
   366             mServiceUriFetchDeprecatedOldService->complete( list );
       
   367     	}
       
   368     }
       
   369 
       
   370     mFetchSelected = true;
       
   371 }
       
   372 
       
   373 // -------------------------------------------------------------------------------------------------
       
   374 // browsingEnded()
       
   375 // -------------------------------------------------------------------------------------------------
       
   376 //
       
   377 void VideoServices::browsingEnded()
       
   378 {
       
   379     MPX_ENTER_EXIT(_L("VideoServices::browsingEnded()"));
       
   380 
       
   381     if ( mServiceBrowse && ( XQServiceUtil::interfaceName().contains("symbian") ) )
       
   382     {
       
   383         mServiceBrowse->complete();
       
   384     }
       
   385     else if ( mServiceBrowseDeprecatedNewService && 
       
   386               mServiceBrowseDeprecatedOldService && 
       
   387               ! ( XQServiceUtil::interfaceName().contains("symbian") ) )
       
   388     {
       
   389         if ( mServiceBrowseDeprecatedNewService->isActive() )
       
   390     	{
       
   391             mServiceBrowseDeprecatedNewService->complete();
       
   392     	}
       
   393     	else
       
   394     	{
       
   395             mServiceBrowseDeprecatedOldService->complete();
       
   396     	}
       
   397     }
       
   398 }
       
   399 
       
   400 // End of file