videocollection/hgmyvideos/src/vcxhgmyvideosaiwmenuhandler.cpp
changeset 0 96612d01cf9f
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     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 the License "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:  A class to manage AIW provided menu items*
       
    15 */
       
    16 
       
    17 
       
    18 #include <AiwServiceHandler.h>
       
    19 #include <eikmenup.h>
       
    20 #include <mediarecognizer.h>
       
    21 #include <vcxhgmyvideos.rsg>
       
    22 
       
    23 #include "vcxhgmyvideosaiwmenuhandler.h"
       
    24 #include "vcxhgmyvideos.hrh"
       
    25 #include "IptvDebug.h"
       
    26 
       
    27 
       
    28 // ======== MEMBER FUNCTIONS ========
       
    29 
       
    30 // ---------------------------------------------------------------------------
       
    31 // CHgMyVideosAiwMenuHandler::CHgMyVideosAiwMenuHandler()
       
    32 // ---------------------------------------------------------------------------
       
    33 //
       
    34 CHgMyVideosAiwMenuHandler::CHgMyVideosAiwMenuHandler()
       
    35     {
       
    36     IPTVLOGSTRING_LOW_LEVEL(
       
    37             "CHgMyVideosAiwMenuHandler::CHgMyVideosAiwMenuHandler()");
       
    38     }
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // CHgMyVideosAiwMenuHandler::~CHgMyVideosAiwMenuHandler()
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 CHgMyVideosAiwMenuHandler::~CHgMyVideosAiwMenuHandler()
       
    45     {
       
    46     IPTVLOGSTRING_LOW_LEVEL(
       
    47             "CHgMyVideosAiwMenuHandler::~CHgMyVideosAiwMenuHandler()");
       
    48 
       
    49     delete iMediaRecognizer;
       
    50     delete iAiwServiceHandler;
       
    51     delete iPath;
       
    52     delete iMimeType;
       
    53     }
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // CHgMyVideosAiwMenuHandler::AttachMenuL()
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 void CHgMyVideosAiwMenuHandler::AttachMenuL( TInt aMenuPaneId )
       
    60     {
       
    61     IPTVLOGSTRING2_LOW_LEVEL(
       
    62             "CHgMyVideosAiwMenuHandler::AttachMenuL(%d)", aMenuPaneId );
       
    63 
       
    64     if ( ! iAiwServiceHandler )
       
    65         {
       
    66         iAiwServiceHandler = CAiwServiceHandler::NewL();
       
    67         }
       
    68 
       
    69     iAiwServiceHandler->AttachMenuL(
       
    70             aMenuPaneId, R_VCXHGMYVIDEOS_AIW_ASSIGN_INTEREST );
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // CHgMyVideosAiwMenuHandler::DetachMenu()
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 void CHgMyVideosAiwMenuHandler::DetachMenu( TInt aMenuPaneId )
       
    78     {
       
    79     IPTVLOGSTRING2_LOW_LEVEL(
       
    80             "CHgMyVideosAiwMenuHandler::DetachMenu(%d)", aMenuPaneId );
       
    81 
       
    82     iAiwServiceHandler->DetachMenu(
       
    83             aMenuPaneId, R_VCXHGMYVIDEOS_AIW_ASSIGN_INTEREST );
       
    84     }
       
    85 
       
    86 // ---------------------------------------------------------------------------
       
    87 // CHgMyVideosAiwMenuHandler::TryHandleSubmenuL()
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 TBool CHgMyVideosAiwMenuHandler::TryHandleSubmenuL( CEikMenuPane* aMenuPane )
       
    91     {
       
    92     IPTVLOGSTRING_LOW_LEVEL("CHgMyVideosAiwMenuHandler::HandleSubmenuL()");
       
    93     return iAiwServiceHandler->HandleSubmenuL( *aMenuPane );
       
    94     }
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // CHgMyVideosAiwMenuHandler::InitializeMenuPaneL()
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 void CHgMyVideosAiwMenuHandler::InitializeMenuPaneL(
       
   101         TInt aResourceId,
       
   102         CEikMenuPane* aMenuPane,
       
   103         const TDesC& aPath,
       
   104         const TDesC& aMimeType )
       
   105     {
       
   106     IPTVLOGSTRING_LOW_LEVEL("CHgMyVideosAiwMenuHandler::InitializeMenuPaneL()");
       
   107 
       
   108     // Let provider add its menu items to the view menu.
       
   109     // If placeholder has been deleted, no AIW option is displayed.
       
   110     // Note! Filehandles are not used, only file paths.
       
   111     CAiwGenericParamList& paramList = iAiwServiceHandler->InParamListL();
       
   112 
       
   113     FillAiwParamsL( paramList, aPath, aMimeType );
       
   114 
       
   115     iAiwServiceHandler->InitializeMenuPaneL(
       
   116             *aMenuPane,
       
   117             aResourceId,
       
   118             EVcxHgMyVideosCmdAiwBase,
       
   119             paramList );
       
   120     }
       
   121 
       
   122 // ---------------------------------------------------------------------------
       
   123 // CHgMyVideosAiwMenuHandler::IsAiwCommand()
       
   124 // ---------------------------------------------------------------------------
       
   125 //
       
   126 TBool CHgMyVideosAiwMenuHandler::IsAiwCommand( TInt aCommand )
       
   127     {
       
   128     TBool res = EFalse;
       
   129 
       
   130     if ( iAiwServiceHandler )
       
   131         {
       
   132         res = iAiwServiceHandler->ServiceCmdByMenuCmd( aCommand ) != KAiwCmdNone;
       
   133         }
       
   134 
       
   135     IPTVLOGSTRING2_LOW_LEVEL("CHgMyVideosAiwMenuHandler::IsAiwCommand(%d)", res);
       
   136 
       
   137     return res;
       
   138     }
       
   139 
       
   140 // ---------------------------------------------------------------------------
       
   141 // CHgMyVideosAiwMenuHandler::HandleAiwCommandL()
       
   142 // ---------------------------------------------------------------------------
       
   143 //
       
   144 void CHgMyVideosAiwMenuHandler::HandleAiwCommandL(
       
   145         TInt aCommand,
       
   146         const TDesC& aPath,
       
   147         const TDesC& aMimeType )
       
   148     {
       
   149     IPTVLOGSTRING_LOW_LEVEL("CHgMyVideosAiwMenuHandler::HandleAiwCommandL()");
       
   150 
       
   151     //
       
   152     //  Save the command parameters so they can be used to cancel
       
   153     //  menu if needed
       
   154     //
       
   155     iCommand = aCommand;
       
   156 
       
   157     HBufC* newPath = aPath.AllocL();
       
   158     if ( iPath )
       
   159         {
       
   160         delete iPath;
       
   161         iPath = NULL;
       
   162         }
       
   163     iPath = newPath;
       
   164 
       
   165     HBufC* newMimeType = aMimeType.AllocL();
       
   166     if ( iMimeType )
       
   167         {
       
   168         delete iMimeType;
       
   169         iMimeType = NULL;
       
   170         }
       
   171     iMimeType = newMimeType;
       
   172 
       
   173     CAiwGenericParamList& paramList = iAiwServiceHandler->InParamListL();
       
   174     FillAiwParamsL( paramList, aPath, aMimeType );
       
   175 
       
   176     iMenuActive = ETrue;
       
   177     // Call AIW service handler
       
   178     iAiwServiceHandler->ExecuteMenuCmdL(
       
   179             aCommand,
       
   180             paramList,
       
   181             iAiwServiceHandler->OutParamListL() );
       
   182     iMenuActive = EFalse;
       
   183     }
       
   184 
       
   185 // ---------------------------------------------------------------------------
       
   186 // CHgMyVideosAiwMenuHandler::IsMenuActive()
       
   187 // ---------------------------------------------------------------------------
       
   188 //
       
   189 TBool CHgMyVideosAiwMenuHandler::IsMenuActive()
       
   190     {
       
   191     return iMenuActive;
       
   192     }
       
   193 
       
   194 // ---------------------------------------------------------------------------
       
   195 // CHgMyVideosAiwMenuHandler::FillAiwParamsL()
       
   196 // ---------------------------------------------------------------------------
       
   197 //
       
   198 void CHgMyVideosAiwMenuHandler::FillAiwParamsL(
       
   199         CAiwGenericParamList& aAiwParamsList,
       
   200         const TDesC& aPath,
       
   201         const TDesC& aMimeType )
       
   202     {
       
   203     IPTVLOGSTRING_LOW_LEVEL("CHgMyVideosAiwMenuHandler::FillAiwParamsL()");
       
   204 
       
   205     HBufC* path = aPath.AllocLC();
       
   206     TAiwVariant varMime( aMimeType );
       
   207     if ( ! aMimeType.Length() )
       
   208         {
       
   209         if ( ! iMediaRecognizer )
       
   210             {
       
   211             iMediaRecognizer = CMediaRecognizer::NewL();
       
   212             }
       
   213         varMime.Set( iMediaRecognizer->MimeTypeL( *path ) );
       
   214         }
       
   215 
       
   216     TAiwGenericParam paramMime( EGenericParamMIMEType, varMime );
       
   217     aAiwParamsList.AppendL( paramMime );
       
   218 
       
   219     TAiwVariant varFile( *path );
       
   220     TAiwGenericParam paramFile( EGenericParamFile, varFile );
       
   221     aAiwParamsList.AppendL( paramFile );
       
   222 
       
   223     CleanupStack::PopAndDestroy( path );
       
   224     }
       
   225 
       
   226 //------------------------------------------------------------------------------
       
   227 // CHgMyVideosAiwMenuHandler::CloseOpenAiwMenuL()
       
   228 //------------------------------------------------------------------------------
       
   229 //
       
   230 void CHgMyVideosAiwMenuHandler::CloseOpenAiwMenuL()
       
   231     {
       
   232     IPTVLOGSTRING_LOW_LEVEL("CHgMyVideosAiwMenuHandler::CloseOpenAiwMenuL()");
       
   233 
       
   234     if ( iMenuActive )
       
   235         {
       
   236         CAiwGenericParamList& paramList = iAiwServiceHandler->InParamListL();
       
   237 
       
   238         FillAiwParamsL( paramList, iPath->Des(), iMimeType->Des() );
       
   239 
       
   240         //  Call AIW service handler to cancel the menu
       
   241         iAiwServiceHandler->ExecuteMenuCmdL(
       
   242                 iCommand,
       
   243                 paramList,
       
   244                 iAiwServiceHandler->OutParamListL(),
       
   245                 KAiwOptCancel );
       
   246 
       
   247         // Reset the member variables so command will not be reset
       
   248         iMenuActive = EFalse;
       
   249         iCommand    = 0;
       
   250         delete iPath;
       
   251         iPath = NULL;
       
   252         delete iMimeType;
       
   253         iMimeType = NULL;
       
   254         }
       
   255     }
       
   256 
       
   257 //  End of File