videoplayerapp/videoplayerengine/src/videoservices.cpp
changeset 52 e3cecb93e76a
parent 24 7d93ee07fb27
--- a/videoplayerapp/videoplayerengine/src/videoservices.cpp	Tue Jul 06 14:17:50 2010 +0300
+++ b/videoplayerapp/videoplayerengine/src/videoservices.cpp	Wed Aug 18 09:50:14 2010 +0300
@@ -15,7 +15,7 @@
 *
 */
 
-// Version : %version: da1mmcf#8 %
+// Version : %version: da1mmcf#10 %
 
 #include "videoplayerengine.h"
 #include "videoservices.h"
@@ -23,17 +23,18 @@
 #include "videoserviceplay.h"
 #include "videoserviceview.h"
 #include "videoservicebrowse.h"
+#include "videoserviceuri.h"
 #include "mpxvideo_debug.h"
 #include <xqaiwdecl.h>
 #include <xqserviceutil.h>
 
 VideoServices *VideoServices::mInstance = 0;
 
-// -----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 // VideoServices::instance()
-// -----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 //
-VideoServices* VideoServices::instance(QVideoPlayerEngine* engine)
+VideoServices* VideoServices::instance( VideoPlayerEngine* engine )
 {
     MPX_ENTER_EXIT(_L("VideoServices::instance()"));
     
@@ -50,9 +51,9 @@
     return mInstance;
 }
 
-// -----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 // VideoServices::decreaseReferenceCount()
-// -----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 //
 void VideoServices::decreaseReferenceCount()
 {
@@ -60,7 +61,7 @@
     
     if ( mInstance )
     {
-        if( --mInstance->mReferenceCount == 0 )
+        if ( --mInstance->mReferenceCount == 0 )
         {
             delete mInstance;
             mInstance = NULL;
@@ -68,11 +69,11 @@
     }
 }
 
-// ----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 // setEngine()
-// ----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 //
-void VideoServices::setEngine(QVideoPlayerEngine* engine)
+void VideoServices::setEngine( VideoPlayerEngine* engine )
 {
     MPX_ENTER_EXIT(_L("VideoServices::setEngine()"));
     
@@ -87,25 +88,31 @@
     	mEngine = engine;
     	mServiceView->setEngine(engine);    	
     }
+    
+    if ( mServiceUriView )
+    {
+        mEngine = engine;
+        mServiceUriView->setEngine(engine);  
+    }
     		
 }
 
-// ----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 // engine()
-// ----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 //
-QVideoPlayerEngine* VideoServices::engine()
+VideoPlayerEngine* VideoServices::engine()
 {
     MPX_DEBUG(_L("VideoServices::engine"));
 	
     return mEngine;
 }
 
-// ----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 // VideoServices()
-// ----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 //
-VideoServices::VideoServices( QVideoPlayerEngine* engine ) 
+VideoServices::VideoServices( VideoPlayerEngine* engine ) 
     : mReferenceCount( 0 )
     , mEngine( engine )
     , mCurrentService( VideoServices::ENoService )
@@ -113,27 +120,63 @@
 {
     MPX_ENTER_EXIT(_L("VideoServices::VideoServices()"));
    
-    mServicePlay     = new VideoServicePlay(this, engine, QLatin1String("videoplayer.com.nokia.symbian.IVideoView"));  //New service, new interface
-    mServiceView     = new VideoServiceView(this, engine, QLatin1String("videoplayer.com.nokia.symbian.IFileView"));   //New service, new interface        
-    mServiceUriFetch = new VideoServiceUriFetch(this, QLatin1String("videoplayer.com.nokia.symbian.IVideoFetch")); //New service, new interface
-    mServiceBrowse   = new VideoServiceBrowse(  this, QLatin1String("videoplayer.com.nokia.symbian.IVideoBrowse")); //New service, new interface
+    // New service, new interface
+    mServicePlay = new VideoServicePlay( this, engine, 
+                                 QLatin1String("videoplayer.com.nokia.symbian.IVideoView") );  
+
+    // New service, new interface
+    mServiceView = new VideoServiceView( this, engine, 
+                                 QLatin1String("videoplayer.com.nokia.symbian.IFileView") ); 
+          
+    // New service, new interface
+    mServiceUriFetch = new VideoServiceUriFetch( this, 
+                                 QLatin1String("videoplayer.com.nokia.symbian.IVideoFetch") ); 
 
-    mServicePlayDeprecatedNewService = new VideoServicePlay(this, engine, QLatin1String("videoplayer.IVideoView")); //New service, old interface
-    mServicePlayDeprecatedOldService = new VideoServicePlay(this, engine, QLatin1String("com.nokia.Videos.IVideoView")); //Old service, old interface   
+    // New service, new interface
+    mServiceBrowse = new VideoServiceBrowse( this, 
+                                 QLatin1String("videoplayer.com.nokia.symbian.IVideoBrowse") ); 
+
+    // New service, old interface
+    mServicePlayDeprecatedNewService = new VideoServicePlay( this, engine, 
+                                                      QLatin1String("videoplayer.IVideoView") ); 
+
+    // Old service, old interface
+    mServicePlayDeprecatedOldService = new VideoServicePlay( this, engine, 
+                                                      QLatin1String("com.nokia.Videos.IVideoView") );    
     
-    mServiceViewDeprecatedNewService = new VideoServiceView(this, engine, QLatin1String("videoplayer.IFileView")); //New service, old interface
-    mServiceViewDeprecatedOldService = new VideoServiceView(this, engine, QLatin1String("com.nokia.Videos.IFileView")); //Old service, old interface     
+    // New service, old interface
+    mServiceViewDeprecatedNewService = new VideoServiceView( this, engine, 
+                                                      QLatin1String("videoplayer.IFileView") ); 
+
+    // Old service, old interface 
+    mServiceViewDeprecatedOldService = new VideoServiceView( this, engine, 
+                                                      QLatin1String("com.nokia.Videos.IFileView") );     
     
-    mServiceUriFetchDeprecatedNewService = new VideoServiceUriFetch(this, QLatin1String("videoplayer.IVideoFetch")); //New service, old interface
-    mServiceUriFetchDeprecatedOldService = new VideoServiceUriFetch(this, QLatin1String("com.nokia.Videos.IVideoFetch")); //Old service, old interface    
+    // New service, old interface
+    mServiceUriFetchDeprecatedNewService = new VideoServiceUriFetch( this, 
+                                                      QLatin1String("videoplayer.IVideoFetch") ); 
+
+    // Old service, old interface
+    mServiceUriFetchDeprecatedOldService = new VideoServiceUriFetch( this, 
+                                                      QLatin1String("com.nokia.Videos.IVideoFetch") );     
 
-    mServiceBrowseDeprecatedNewService   = new VideoServiceBrowse(this, QLatin1String("videoplayer.IVideoBrowse")); //New service, old interface
-    mServiceBrowseDeprecatedOldService   = new VideoServiceBrowse(this, QLatin1String("com.nokia.Videos.IVideoBrowse")); //Old service, old interface
+    // New service, old interface
+    mServiceBrowseDeprecatedNewService = new VideoServiceBrowse( this, 
+                                                      QLatin1String("videoplayer.IVideoBrowse")) ; 
+
+    // Old service, old interface
+    mServiceBrowseDeprecatedOldService = new VideoServiceBrowse( this, 
+                                                      QLatin1String("com.nokia.Videos.IVideoBrowse") ); 
+	
+    // new service, new interface
+    mServiceUriView = new VideoServiceUri(  this, engine, QLatin1String("videoplayer.com.nokia.symbian.IUriView"));	
+    
+	
 }
 
-// ----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 // ~VideoServices()
-// ----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 //
 VideoServices::~VideoServices()
 {
@@ -151,11 +194,12 @@
     delete mServiceUriFetchDeprecatedNewService;
     delete mServiceBrowseDeprecatedOldService;
     delete mServiceUriFetchDeprecatedOldService;
+    delete mServiceUriView;
 }
 
-// ----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 // currentService()
-// ----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 //
 VideoServices::TVideoService VideoServices::currentService()
 {
@@ -164,9 +208,9 @@
     return mCurrentService;
 }
 
-// ----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 // getBrowseCategory()
-// ----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 //
 int VideoServices::getBrowseCategory() const
 {
@@ -174,28 +218,30 @@
 	
     int category = 0;
 
-    if ( mServiceBrowse && (XQServiceUtil::interfaceName().contains("symbian")))
+    if ( mServiceBrowse && ( XQServiceUtil::interfaceName().contains("symbian") ) )
     {
         category = mServiceBrowse->getBrowseCategory();
     }
-    else if ( mServiceBrowseDeprecatedNewService && mServiceBrowseDeprecatedOldService && !(XQServiceUtil::interfaceName().contains("symbian")))
+    else if ( mServiceBrowseDeprecatedNewService && 
+              mServiceBrowseDeprecatedOldService && 
+              ! ( XQServiceUtil::interfaceName().contains("symbian") ) )
     {
-    	if (mServiceBrowseDeprecatedNewService->isActive())
+    	if ( mServiceBrowseDeprecatedNewService->isActive() )
     	{
-    		category = mServiceBrowseDeprecatedNewService->getBrowseCategory();
+            category = mServiceBrowseDeprecatedNewService->getBrowseCategory();
     	}
     	else
     	{
-    		category = mServiceBrowseDeprecatedOldService->getBrowseCategory();
+            category = mServiceBrowseDeprecatedOldService->getBrowseCategory();
     	}
     }
 
     return category;
 }
 
-// ----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 // setCurrentService()
-// ----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 //
 void VideoServices::setCurrentService(VideoServices::TVideoService service)
 {
@@ -204,9 +250,9 @@
     mCurrentService = service;	
 }
 
-// ----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 // contextTitle()
-// ----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 //
 QString VideoServices::contextTitle() const
 {
@@ -214,49 +260,54 @@
 	
     QString title;
 
-    if (mCurrentService == VideoServices::EUriFetcher)
+    if ( mCurrentService == VideoServices::EUriFetcher )
     {
-    	if(mServiceUriFetch && (XQServiceUtil::interfaceName().contains("symbian")))
+    	if ( mServiceUriFetch && ( XQServiceUtil::interfaceName().contains("symbian") ) )
     	{
-    		title = mServiceUriFetch->contextTitle();
+            title = mServiceUriFetch->contextTitle();
     	}
-    	else if (mServiceUriFetchDeprecatedNewService && mServiceUriFetchDeprecatedOldService && !(XQServiceUtil::interfaceName().contains("symbian")))
+    	else if ( mServiceUriFetchDeprecatedNewService && 
+                  mServiceUriFetchDeprecatedOldService && 
+                  ! ( XQServiceUtil::interfaceName().contains("symbian") ) )
     	{
-    		if(mServiceUriFetchDeprecatedNewService->isActive())
-    		{
-    			title = mServiceUriFetchDeprecatedNewService->contextTitle();
-    		}
-    		else
-    		{
-    			title = mServiceUriFetchDeprecatedOldService->contextTitle();
-    		}
+
+            if ( mServiceUriFetchDeprecatedNewService->isActive() )
+    	    {
+    	        title = mServiceUriFetchDeprecatedNewService->contextTitle();
+            }
+    	    else
+    	    {
+    	        title = mServiceUriFetchDeprecatedOldService->contextTitle();
+    	    }
     	}
     }
-    else if (mCurrentService == VideoServices::EBrowse)
+    else if ( mCurrentService == VideoServices::EBrowse )
     {
-    	if ( mServiceBrowse && (XQServiceUtil::interfaceName().contains("symbian")))
-		{
-			title = mServiceBrowse->contextTitle();
-		}
-    	else if ( mServiceBrowseDeprecatedNewService && mServiceBrowseDeprecatedOldService && !(XQServiceUtil::interfaceName().contains("symbian")))
-		{
-        	if (mServiceBrowseDeprecatedNewService->isActive())
-        	{
-    			title = mServiceBrowseDeprecatedNewService->contextTitle();
-        	}
-        	else
-        	{
-    			title = mServiceBrowseDeprecatedOldService->contextTitle();
-        	}
-		}
+    	if ( mServiceBrowse && ( XQServiceUtil::interfaceName().contains("symbian") ) )
+        {
+            title = mServiceBrowse->contextTitle();
+        }
+    	else if ( mServiceBrowseDeprecatedNewService && 
+                  mServiceBrowseDeprecatedOldService && 
+                  ! ( XQServiceUtil::interfaceName().contains("symbian") ) )
+        {
+            if ( mServiceBrowseDeprecatedNewService->isActive() )
+            {
+                title = mServiceBrowseDeprecatedNewService->contextTitle();
+            }
+            else
+            {
+                title = mServiceBrowseDeprecatedOldService->contextTitle();
+            }
+        }
     }
     
     return title;
 }
 
-// ----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 // sortRole()
-// ----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 //
 int VideoServices::sortRole() const
 {
@@ -264,31 +315,33 @@
     
     int sortRole = 0;
 
-    if (mCurrentService == EBrowse)
+    if ( mCurrentService == EBrowse )
     {
-    	if ( mServiceBrowse && (XQServiceUtil::interfaceName().contains("symbian")))
-		{
-			sortRole = mServiceBrowse->sortRole();
-		}
-    	else if ( mServiceBrowseDeprecatedNewService && mServiceBrowseDeprecatedOldService && !(XQServiceUtil::interfaceName().contains("symbian")))
-		{
-        	if (mServiceBrowseDeprecatedNewService->isActive())
-        	{
-        		sortRole = mServiceBrowseDeprecatedNewService->sortRole();
-        	}
-        	else
-        	{
-        		sortRole = mServiceBrowseDeprecatedOldService->sortRole();
-        	}
-		}
+    	if ( mServiceBrowse && ( XQServiceUtil::interfaceName().contains("symbian") ) )
+        {
+            sortRole = mServiceBrowse->sortRole();
+        }
+    	else if ( mServiceBrowseDeprecatedNewService && 
+                  mServiceBrowseDeprecatedOldService && 
+                  ! ( XQServiceUtil::interfaceName().contains("symbian") ) )
+        {
+            if ( mServiceBrowseDeprecatedNewService->isActive() )
+            {
+                sortRole = mServiceBrowseDeprecatedNewService->sortRole();
+            }
+            else
+            {
+                sortRole = mServiceBrowseDeprecatedOldService->sortRole();
+            }
+        }
     }
     
     return sortRole;
 }
 
-// ----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 // itemSelected()
-// ----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 //
 void VideoServices::itemSelected(const QString& item)
 {
@@ -298,47 +351,50 @@
     QStringList list;
     list.append( item );
 
-    if(mServiceUriFetch && (XQServiceUtil::interfaceName().contains("symbian")))
+    if( mServiceUriFetch && ( XQServiceUtil::interfaceName().contains("symbian") ) )
     {
     	mServiceUriFetch->complete( list );
     }
-    else if (mServiceUriFetchDeprecatedNewService && mServiceUriFetchDeprecatedOldService)
+    else if ( mServiceUriFetchDeprecatedNewService && mServiceUriFetchDeprecatedOldService )
     {
-    	if (mServiceUriFetchDeprecatedNewService->isActive())
+    	if ( mServiceUriFetchDeprecatedNewService->isActive() )
     	{
-        	mServiceUriFetchDeprecatedNewService->complete( list );
+            mServiceUriFetchDeprecatedNewService->complete( list );
     	}
     	else
     	{
-        	mServiceUriFetchDeprecatedOldService->complete( list );
+            mServiceUriFetchDeprecatedOldService->complete( list );
     	}
     }
+
     mFetchSelected = true;
 }
 
-// ----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 // browsingEnded()
-// ----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
 //
 void VideoServices::browsingEnded()
 {
     MPX_ENTER_EXIT(_L("VideoServices::browsingEnded()"));
 
-	if ( mServiceBrowse && (XQServiceUtil::interfaceName().contains("symbian")))
-	{
-		mServiceBrowse->complete();
-	}
-	else if ( mServiceBrowseDeprecatedNewService && mServiceBrowseDeprecatedOldService && !(XQServiceUtil::interfaceName().contains("symbian")))
-	{
-    	if (mServiceBrowseDeprecatedNewService->isActive())
+    if ( mServiceBrowse && ( XQServiceUtil::interfaceName().contains("symbian") ) )
+    {
+        mServiceBrowse->complete();
+    }
+    else if ( mServiceBrowseDeprecatedNewService && 
+              mServiceBrowseDeprecatedOldService && 
+              ! ( XQServiceUtil::interfaceName().contains("symbian") ) )
+    {
+        if ( mServiceBrowseDeprecatedNewService->isActive() )
     	{
-    		mServiceBrowseDeprecatedNewService->complete();
+            mServiceBrowseDeprecatedNewService->complete();
     	}
     	else
     	{
-    		mServiceBrowseDeprecatedOldService->complete();
+            mServiceBrowseDeprecatedOldService->complete();
     	}
-	}
+    }
 }
 
 // End of file