upnpframework/upnpaiwprovider/src/upnpaiwplayonexternalmenuservice.cpp
changeset 0 7f85d04be362
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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 the UpnpAiwPlayOnExternalMenuService
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <AiwMenu.h>
       
    20 #include <AiwCommon.hrh>
       
    21 #include <aknnotewrappers.h>
       
    22 #include "upnpaiwengine.h"
       
    23 #include "upnpaiwplayonexternalmenuservice.h"
       
    24 
       
    25 _LIT( KComponentLogfile, "upnpaiwprovider.log" );
       
    26 #include "upnplog.h"
       
    27 
       
    28 // --------------------------------------------------------------------------
       
    29 // CUPnPAiwPlayOnExternalMenuService::NewL
       
    30 // NewL.
       
    31 // --------------------------------------------------------------------------
       
    32 CUPnPAiwPlayOnExternalMenuService* CUPnPAiwPlayOnExternalMenuService::NewL()
       
    33     {
       
    34     __LOG( "[UpnpAiwProvider]\t CUPnPAiwPlayOnExternalMenuService::NewL" );
       
    35 
       
    36     CUPnPAiwPlayOnExternalMenuService* self = 
       
    37         new (ELeave) CUPnPAiwPlayOnExternalMenuService;
       
    38     CleanupStack::PushL( self );
       
    39 
       
    40     self->ConstructL();
       
    41 
       
    42     CleanupStack::Pop( self );
       
    43     return self;
       
    44     }
       
    45 
       
    46 // --------------------------------------------------------------------------
       
    47 // CUPnPAiwPlayOnExternalMenuService::CUPnPAiwPlayOnExternalMenuService
       
    48 // Constructor.
       
    49 // --------------------------------------------------------------------------
       
    50 CUPnPAiwPlayOnExternalMenuService::CUPnPAiwPlayOnExternalMenuService()
       
    51     {
       
    52     __LOG( "[UpnpAiwProvider]\t CUPnPAiwPlayOnExternalMenuService::\
       
    53 CUPnPAiwPlayOnExternalMenuService" );
       
    54     }
       
    55 
       
    56 // --------------------------------------------------------------------------
       
    57 // CUPnPAiwPlayOnExternalMenuService::~CUPnPAiwPlayOnExternalMenuService
       
    58 // Destructor.
       
    59 // --------------------------------------------------------------------------
       
    60 CUPnPAiwPlayOnExternalMenuService::~CUPnPAiwPlayOnExternalMenuService()
       
    61     {
       
    62     __LOG( "[UpnpAiwProvider]\t CUPnPAiwPlayOnExternalMenuService::\
       
    63 ~CUPnPAiwPlayOnExternalMenuService" );
       
    64 
       
    65     // Empty the file name array and close it
       
    66     EmptyFileNameArray();
       
    67     iFileNames.Close();
       
    68 
       
    69     // Delete the filename of the file that is played
       
    70     delete iFileName;
       
    71     iFileName = NULL;
       
    72 
       
    73     // Set the client call back reference to NULL
       
    74     iClient = NULL;
       
    75 
       
    76     // Release the engine instance
       
    77     if( iEngine )
       
    78         {
       
    79         CUPnPAiwEngine::ReleaseInstance();
       
    80         iEngine = NULL;
       
    81         }
       
    82     }
       
    83 
       
    84 // --------------------------------------------------------------------------
       
    85 // CUPnPAiwPlayOnExternalMenuService::ConstructL
       
    86 // Second phase constructor.
       
    87 // --------------------------------------------------------------------------
       
    88 void CUPnPAiwPlayOnExternalMenuService::ConstructL()
       
    89     {
       
    90     __LOG( "[UpnpAiwProvider]\t CUPnPAiwPlayOnExternalMenuService::\
       
    91 ConstructL" );
       
    92 
       
    93     // Create the engine and register as an observer for call backs
       
    94     iEngine = CUPnPAiwEngine::NewL();
       
    95     }
       
    96 
       
    97 // --------------------------------------------------------------------------
       
    98 // CUPnPAiwPlayOnExternalMenuService::InitializeMenuPaneL
       
    99 // AIW Framework's method for initialising the menu
       
   100 // --------------------------------------------------------------------------
       
   101 void CUPnPAiwPlayOnExternalMenuService::InitializeMenuPaneL(
       
   102                               CAiwMenuPane& /*aMenuPane*/,
       
   103                               TInt /*aIndex*/,
       
   104                               TInt /*aCascadeId*/,
       
   105                               const CAiwGenericParamList& /*aInParamList*/ )
       
   106     {
       
   107     __LOG( "[UpnpAiwProvider]\t CUPnPAiwPlayOnExternalMenuService::\
       
   108 InitializeMenuPaneL" );
       
   109 
       
   110     __LOG( "[UpnpAiwProvider]\t CUPnPAiwPlayOnExternalMenuService, \
       
   111 supported anymore (after Upnp Fw 2.0)!" );
       
   112     }
       
   113 
       
   114 // --------------------------------------------------------------------------
       
   115 // CUPnPAiwPlayOnExternalMenuService::HandleMenuCmdL
       
   116 // AIW Framework's method for handling menu commands
       
   117 // --------------------------------------------------------------------------
       
   118 void CUPnPAiwPlayOnExternalMenuService::HandleMenuCmdL( 
       
   119                             TInt /*aMenuCmdId*/,
       
   120                             const CAiwGenericParamList& /*aInParamList*/,
       
   121                             CAiwGenericParamList& /*aOutParamList*/,
       
   122                             TUint /*aCmdOptions*/,
       
   123                             const MAiwNotifyCallback* /*aCallback*/ )
       
   124     {
       
   125     __LOG( "[UpnpAiwProvider]\t CUPnPAiwPlayOnExternalMenuService::\
       
   126 HandleMenuCmdL" );
       
   127 
       
   128     __LOG( "[UpnpAiwProvider]\t CUPnPAiwPlayOnExternalMenuService, \
       
   129 supported anymore (after Upnp Fw 2.0)!" );
       
   130     }
       
   131 
       
   132 // --------------------------------------------------------------------------
       
   133 // CUPnPAiwPlayOnExternalMenuService::EmptyFileNameArray
       
   134 // Empties the file name array (data member variable).
       
   135 // --------------------------------------------------------------------------
       
   136 void CUPnPAiwPlayOnExternalMenuService::EmptyFileNameArray()
       
   137     {
       
   138     __LOG( "[UpnpAiwProvider]\t CUPnPAiwPlayOnExternalMenuService::\
       
   139 EmptyFileNameArray" );
       
   140 
       
   141     // delete the list of file names and close the file name array
       
   142     for( TInt index=0; index<iFileNames.Count(); index++ )
       
   143         {
       
   144         delete iFileNames[index];
       
   145         iFileNames[index] = NULL;
       
   146         }
       
   147     iFileNames.Reset();
       
   148     }
       
   149 
       
   150 // --------------------------------------------------------------------------
       
   151 // CUPnPAiwPlayOnExternalMenuService::PlayCompleteL
       
   152 // Indicates that the play operation is complete.
       
   153 // --------------------------------------------------------------------------
       
   154 void CUPnPAiwPlayOnExternalMenuService::PlayCompleteL( TInt aStatus )
       
   155     {
       
   156     __LOG( "[UpnpAiwProvider]\t CUPnPAiwPlayOnExternalMenuService::\
       
   157 PlayCompleteL" );
       
   158 
       
   159     // If there is a client that has registered as an observer
       
   160     if( iClient )
       
   161         {
       
   162         if( iFileName )
       
   163             {
       
   164 
       
   165             // Create parameter lists
       
   166             CAiwGenericParamList* eventParamList =
       
   167                                     CAiwGenericParamList::NewLC();
       
   168             CAiwGenericParamList* inParamList = 
       
   169                                     CAiwGenericParamList::NewLC();
       
   170 
       
   171 
       
   172             // Create TAIWGenericParam for the filename
       
   173             TFileName fileName( *iFileName );
       
   174             TAiwGenericParam fileParameter( EGenericParamFile, fileName );
       
   175 
       
   176             // Append the file filename param on the out list
       
   177             eventParamList->AppendL( fileParameter );
       
   178 
       
   179             // Convert the error code into AIW event code
       
   180             TInt eventCode;
       
   181             if( aStatus == KErrNone )
       
   182                 {
       
   183                 eventCode = KAiwEventCompleted;
       
   184                 }
       
   185             else
       
   186                 {
       
   187                 eventCode = KAiwEventError;
       
   188                 }
       
   189 
       
   190             // Make the call back
       
   191             iClient->HandleNotifyL( KAiwCmdUPnPPlay,
       
   192                                     eventCode,
       
   193                                     *eventParamList,
       
   194                                     *inParamList );
       
   195 
       
   196             // Clean up
       
   197             CleanupStack::PopAndDestroy( inParamList );
       
   198             inParamList = NULL;
       
   199             CleanupStack::PopAndDestroy( eventParamList );
       
   200             eventParamList = NULL;
       
   201             delete iFileName;
       
   202             iFileName = NULL;
       
   203 
       
   204             // Stop observing the AIW Engine
       
   205             if( iEngine )
       
   206                 {
       
   207                 iEngine->RemoveEngineObserver();
       
   208                 }
       
   209             }
       
   210         }
       
   211     }
       
   212 
       
   213 // --------------------------------------------------------------------------
       
   214 // CUPnPAiwPlayOnExternalMenuService::ConnectionLostL
       
   215 // Indicates that the connection with the target UPnP device has 
       
   216 // been lost.
       
   217 // --------------------------------------------------------------------------
       
   218 void CUPnPAiwPlayOnExternalMenuService::ConnectionLostL()
       
   219     {
       
   220     __LOG( "[UpnpAiwProvider]\t CUPnPAiwPlayOnExternalMenuService::\
       
   221 ConnectionLostL" );
       
   222 
       
   223     // If there is a client that has registered as an observer
       
   224     if( iClient )
       
   225         {
       
   226         // Create parameter lists
       
   227         CAiwGenericParamList* emptyParamlist = CAiwGenericParamList::NewLC();
       
   228 
       
   229         TInt eventCode = KAiwEventStopped;
       
   230 
       
   231         // Make the call back
       
   232         iClient->HandleNotifyL( KAiwCmdUPnPPlay,
       
   233                                 eventCode,
       
   234                                 *emptyParamlist,
       
   235                                 *emptyParamlist );
       
   236 
       
   237         // Clean up
       
   238         CleanupStack::PopAndDestroy( emptyParamlist );
       
   239         emptyParamlist = NULL;
       
   240         }
       
   241     }
       
   242 
       
   243 // End of file