photosgallery/viewframework/commandhandlers/commandhandlerupnp/src/glxcommandhandlershowviaupnp.cpp
changeset 0 4e91876724a2
child 20 d1bdfdf534bd
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2008-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:    Upnp Command Handlers.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "glxcommandhandlershowviaupnp.h"
       
    22 
       
    23 //Includes
       
    24 #include <eikmenup.h>
       
    25 #include <glxcommandhandlers.hrh>
       
    26 #include <glxtracer.h>
       
    27 #include <glxlog.h>
       
    28 
       
    29 #include "glxupnprenderer.h"     
       
    30 #include "glxupnprendererdefs.h"
       
    31 
       
    32 //-----------------------------------------------------------------------------------------
       
    33 // Two phased Constructor
       
    34 //-----------------------------------------------------------------------------------------
       
    35 EXPORT_C CGlxCommandHandlerShowViaUpnp* CGlxCommandHandlerShowViaUpnp::
       
    36     NewL(MGlxMediaListProvider* aMediaListProvider, TBool aUseHomeNetworkCascadeMenu)
       
    37     {  
       
    38     TRACER( "CGlxCommandHandlerShowViaUpnp::NewL");
       
    39     CGlxCommandHandlerShowViaUpnp* self =new(ELeave) 
       
    40               CGlxCommandHandlerShowViaUpnp(aMediaListProvider, aUseHomeNetworkCascadeMenu);
       
    41     CleanupStack::PushL( self );
       
    42     self->ConstructL();
       
    43     CleanupStack::Pop( self );
       
    44     return self;
       
    45     }
       
    46   
       
    47 //-----------------------------------------------------------------------------------------
       
    48 //  First Phase Constructor
       
    49 //-----------------------------------------------------------------------------------------  
       
    50 CGlxCommandHandlerShowViaUpnp::CGlxCommandHandlerShowViaUpnp
       
    51     (MGlxMediaListProvider* aMediaListProvider, TBool aUseHomeNetworkCascadeMenu)
       
    52 : CGlxMediaListCommandHandler(aMediaListProvider), iUseHomeNetworkCascadeMenu(aUseHomeNetworkCascadeMenu)
       
    53     {
       
    54     TRACER(" CGlxCommandHandlerShowViaUpnp::CGlxCommandHandlerShowViaUpnp");
       
    55     }
       
    56   
       
    57 //-----------------------------------------------------------------------------------------
       
    58 // Destructor
       
    59 //-----------------------------------------------------------------------------------------
       
    60 CGlxCommandHandlerShowViaUpnp::~CGlxCommandHandlerShowViaUpnp()
       
    61     {
       
    62     //Do Nothing  
       
    63     }  
       
    64   
       
    65 //-----------------------------------------------------------------------------------------
       
    66 // ConstructL
       
    67 //-----------------------------------------------------------------------------------------  
       
    68   
       
    69 void CGlxCommandHandlerShowViaUpnp::ConstructL()  
       
    70     {
       
    71     TRACER(" CGlxCommandHandlerShowViaUpnp::ConstructL");
       
    72     AddUpnpCommandL();   
       
    73     }
       
    74 
       
    75 //-----------------------------------------------------------------------------------------
       
    76 // Add the UPnP commands to the CommandInfo
       
    77 //-----------------------------------------------------------------------------------------  
       
    78 void CGlxCommandHandlerShowViaUpnp::AddUpnpCommandL()
       
    79     {
       
    80     // Add the Show on Home Network Command        
       
    81     TCommandInfo infoStartShowing(EGlxShowViaUpnp);                          
       
    82     infoStartShowing.iMinSelectionLength = 1;    
       
    83     infoStartShowing.iMaxSelectionLength = 1;
       
    84     // Fix for ABAI-7C3J5K, the menu item should be enabled for DRM items
       
    85     infoStartShowing.iDisallowDRM = EFalse;    
       
    86     AddCommandL(infoStartShowing) ;
       
    87 
       
    88     // We need two versions of the start and stop showing command if iUseHomeNetworkCascadeMenu is true
       
    89     if (iUseHomeNetworkCascadeMenu)
       
    90         {
       
    91         //Add the home network cascaded menu (sub-menu)
       
    92         TCommandInfo infoHomeNetworkSubmenu(EGlxHomeNetworkSubmenu);
       
    93         infoHomeNetworkSubmenu.iMinSelectionLength = 1;
       
    94         infoHomeNetworkSubmenu.iMaxSelectionLength = KMaxTInt;
       
    95         // Show in Grid View
       
    96         infoHomeNetworkSubmenu.iViewingState = TCommandInfo::EViewingStateBrowse;
       
    97         AddCommandL(infoHomeNetworkSubmenu);
       
    98        
       
    99         // Add the Show on Home Network Command (submenu version)
       
   100         TCommandInfo infoStartShowingSubmenuVersion(EGlxShowViaUpnpSubmenuVersion);                          
       
   101         infoStartShowingSubmenuVersion.iMinSelectionLength = 1;    
       
   102         infoStartShowingSubmenuVersion.iMaxSelectionLength = 1;
       
   103         infoStartShowingSubmenuVersion.iDisallowDRM = ETrue;
       
   104         AddCommandL(infoStartShowingSubmenuVersion);
       
   105            
       
   106         //Add the Stop Showing Command (submenu version)
       
   107         TCommandInfo infoStopShowingSubmenuVersion(EGlxStopShowingSubmenuVersion); 
       
   108         AddCommandL(infoStopShowingSubmenuVersion);   
       
   109         }
       
   110     
       
   111     //Add the Stop Showing Command
       
   112     TCommandInfo infoStopShowing(EGlxStopShowing);
       
   113     //By default the MinSelectionLength and MaxSelectionLength will be
       
   114     //set to zero and KMaxTInt respectively    
       
   115     AddCommandL(infoStopShowing);
       
   116  
       
   117     // Get notified when we switch to 'browsing'
       
   118     TCommandInfo browseInfo(EGlxCmdStateBrowse);
       
   119     browseInfo.iMinSelectionLength = 0;
       
   120     browseInfo.iMaxSelectionLength = KMaxTInt;
       
   121     // Filter out static items
       
   122     AddCommandL(browseInfo);
       
   123     
       
   124     // Get notified when we switch to 'viewing' (fullscreen)
       
   125     TCommandInfo viewInfo(EGlxCmdStateView);
       
   126     viewInfo.iMinSelectionLength = 0;
       
   127     viewInfo.iMaxSelectionLength = KMaxTInt;
       
   128     // Filter out static items
       
   129     AddCommandL(viewInfo);
       
   130     
       
   131     //Add the Play command here as we need to add some filters    
       
   132     TCommandInfo infoplay(EGlxCmdPlay);              
       
   133     // filter out everything except videos
       
   134     infoplay.iCategoryFilter = EMPXVideo;
       
   135     infoplay.iCategoryRule = TCommandInfo::ERequireAll;                    
       
   136     infoplay.iMinSelectionLength = 1;
       
   137     infoplay.iMaxSelectionLength = 1;    
       
   138     AddCommandL(infoplay);       
       
   139     }
       
   140 
       
   141 //-----------------------------------------------------------------------------------------
       
   142 // Executing the command handler
       
   143 //-----------------------------------------------------------------------------------------
       
   144   
       
   145 TBool CGlxCommandHandlerShowViaUpnp::DoExecuteL(TInt aCommandId, MGlxMediaList& /*aList*/)
       
   146     {
       
   147     TRACER( "CGlxCommandHandlerShowViaUpnp::DoExecuteL");
       
   148 
       
   149     TBool consumed = ETrue;    
       
   150       
       
   151     switch(aCommandId)
       
   152         {
       
   153         case EGlxShowViaUpnpSubmenuVersion: // fallthrough
       
   154         case EGlxShowViaUpnp:
       
   155             {    
       
   156             GLX_LOG_INFO("DoExecuteL -ShowViaUPNP");  
       
   157             
       
   158             GlxUpnpRenderer:: StartShowingL();              
       
   159             } 
       
   160             break;
       
   161         case EGlxStopShowingSubmenuVersion: // fallthrough
       
   162         case EGlxStopShowing:
       
   163             {
       
   164             GLX_LOG_INFO("DoExecuteL -StopShowing");                      
       
   165             GlxUpnpRenderer::ShowStopL();
       
   166             GlxUpnpRenderer::StopShowingL();                  
       
   167             }
       
   168             break;
       
   169             
       
   170         case EGlxCmdPlay:
       
   171             {            
       
   172             GLX_LOG_INFO("DoExecuteL -UPnpPlay");  
       
   173 			//@ Fix for EVTY-7M87LF
       
   174             if ( NGlxUpnpRenderer::EActive == GlxUpnpRenderer::Status() )
       
   175 	            {
       
   176                 GlxUpnpRenderer::ShowVideoL();
       
   177 	            }
       
   178             else
       
   179 	            {
       
   180         		consumed = EFalse;
       
   181 	            }
       
   182             }
       
   183             break;           
       
   184         case EGlxCmdStateBrowse:
       
   185         case EGlxCmdStateView:
       
   186             {
       
   187             GLX_LOG_INFO("DoExecuteL -CmdStateBrowse / CmdStateView");  
       
   188             iFullScreen = (aCommandId == EGlxCmdStateView);
       
   189             consumed = EFalse;
       
   190             }
       
   191             break;
       
   192         default:
       
   193             {
       
   194             consumed = EFalse;  //Command is not Executed                        
       
   195             }
       
   196             break;
       
   197          }
       
   198      return consumed;     
       
   199      }
       
   200 
       
   201 //-----------------------------------------------------------------------------------------
       
   202 // Disable the command handler
       
   203 //-----------------------------------------------------------------------------------------
       
   204 TBool CGlxCommandHandlerShowViaUpnp::DoIsDisabled(TInt aCommandId, MGlxMediaList& /*aList*/) const
       
   205     {
       
   206     TRACER("CGlxCommandHandlerShowViaUpnp::DoIsDisabled");    
       
   207 
       
   208     TBool disabled = ETrue;
       
   209     NGlxUpnpRenderer::TStatus rendererStatus = GlxUpnpRenderer::Status();
       
   210     
       
   211     switch(aCommandId)
       
   212         {
       
   213         case EGlxShowViaUpnpSubmenuVersion:
       
   214             {
       
   215             GLX_LOG_INFO("DoIsDisabled -ShowViaUpnpSubmenuVersion");
       
   216           
       
   217             disabled = !(rendererStatus == NGlxUpnpRenderer::EAvailableNotActive && iUseHomeNetworkCascadeMenu);
       
   218             }
       
   219         break;
       
   220         case EGlxShowViaUpnp:
       
   221             {    
       
   222             GLX_LOG_INFO("DoIsDisabled -ShowViaUpnp");
       
   223                                        
       
   224             //If the access point is set and renderer is not active and we are in full screen or we are not using the cascaded menu
       
   225             disabled = !(rendererStatus == NGlxUpnpRenderer::EAvailableNotActive && (iFullScreen || !iUseHomeNetworkCascadeMenu));                             
       
   226             }                     
       
   227         break;
       
   228         case EGlxStopShowingSubmenuVersion:
       
   229             {
       
   230             GLX_LOG_INFO("DoIsDisabled - StopShowingSubmenuVersion");
       
   231             //If the renderer device is showing the image/video 
       
   232             disabled = !(rendererStatus == NGlxUpnpRenderer::EActive);   
       
   233             }
       
   234         break;
       
   235         case EGlxStopShowing:
       
   236             {
       
   237             GLX_LOG_INFO("DoIsDisabled -StopShowing");
       
   238             
       
   239             disabled = !(rendererStatus == NGlxUpnpRenderer::EActive && 
       
   240                     (!iUseHomeNetworkCascadeMenu || iFullScreen || (!iFullScreen && SelectionLength() == 0)));
       
   241             }
       
   242         break;  
       
   243         case EGlxCmdPlay:
       
   244             {
       
   245             GLX_LOG_INFO("DoIsDisabled -UPNPPlay");
       
   246 			//@ Fix for EVTY-7M87LF
       
   247             // If the focussed item is video file,
       
   248 			// Play command should be visible to play either in device or renderer if active.
       
   249             disabled = EFalse;
       
   250             }
       
   251         break;
       
   252         case EGlxHomeNetworkSubmenu:
       
   253             {
       
   254             GLX_LOG_INFO("DoIsDisabled - HomeNetworkSubmenu");
       
   255             
       
   256             disabled = (rendererStatus == NGlxUpnpRenderer::ENotAvailable && !iFullScreen);
       
   257             }
       
   258         break;
       
   259         case EGlxCmdStateBrowse:
       
   260         case EGlxCmdStateView:
       
   261             {
       
   262             GLX_LOG_INFO("DoIsDisabled - CmdStateBrowse / CmdStateView");
       
   263             disabled = EFalse;
       
   264             }
       
   265         default: 
       
   266             {            
       
   267             GLX_LOG_WARNING("DoIsDisabled -UnknownCommandHandler");
       
   268             }
       
   269         break;
       
   270         }
       
   271     return disabled;
       
   272     }