mpx/tsrc/public/basic/common/testplugins/testplaybackplugin/src/testplaybackplugin.cpp
changeset 64 92dbd2a406d9
equal deleted inserted replaced
61:3b098142db83 64:92dbd2a406d9
       
     1 /*
       
     2 * Copyright (c) 2002 - 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:  CTestPlaybackPlugin implementation
       
    15 *
       
    16 */
       
    17 
       
    18 //
       
    19 //  INCLUDE FILES
       
    20 //
       
    21 #include <apgcli.h>
       
    22 #include <e32cmn.h>
       
    23 #include <mpxmediageneraldefs.h>
       
    24 #include <mpxcommandgeneraldefs.h>
       
    25 #include <mpxmessagegeneraldefs.h>
       
    26 #include <mpxplaybackcommanddefs.h>
       
    27 #include <mpxplaybackpluginobserver.h>
       
    28 #include "testplaybackplugin.h"
       
    29 
       
    30 //
       
    31 //  CONSTANTS
       
    32 //
       
    33 const TUid KLocalPlaybackUid = { 0x10282556 };
       
    34 
       
    35 
       
    36 // ============================ MEMBER FUNCTIONS ===============================
       
    37 
       
    38 //  ----------------------------------------------------------------------------
       
    39 //    Two-phased constructor.
       
    40 //  ----------------------------------------------------------------------------
       
    41 //
       
    42 CTestPlaybackPlugin* CTestPlaybackPlugin::NewL( TAny* /*aInitParams*/ )
       
    43 {
       
    44     CTestPlaybackPlugin* p = new (ELeave) CTestPlaybackPlugin();
       
    45     CleanupStack::PushL(p);
       
    46     p->ConstructL();
       
    47     CleanupStack::Pop(p);
       
    48     return p;
       
    49 }
       
    50 
       
    51 //  ----------------------------------------------------------------------------
       
    52 //    Symbian 2nd phase constructor can leave.
       
    53 //  ----------------------------------------------------------------------------
       
    54 //
       
    55 void CTestPlaybackPlugin::ConstructL()
       
    56 {
       
    57     User::LeaveIfError( iFs.Connect() );
       
    58     iFs.ShareProtected();
       
    59 }
       
    60 
       
    61 //  ----------------------------------------------------------------------------
       
    62 //    C++ constructor
       
    63 //  ----------------------------------------------------------------------------
       
    64 //
       
    65 CTestPlaybackPlugin::CTestPlaybackPlugin()
       
    66 {
       
    67 }
       
    68 
       
    69 //  ----------------------------------------------------------------------------
       
    70 //    Destructor
       
    71 //  ----------------------------------------------------------------------------
       
    72 //
       
    73 CTestPlaybackPlugin::~CTestPlaybackPlugin()
       
    74 {
       
    75     iFile.Close();
       
    76     iFs.Close();
       
    77 }
       
    78 
       
    79 //  ----------------------------------------------------------------------------
       
    80 //    Set observer
       
    81 //  ----------------------------------------------------------------------------
       
    82 //
       
    83 void CTestPlaybackPlugin::SetObserver( MMPXPlaybackPluginObserver& aObs )
       
    84 {
       
    85 	iObs = &aObs;
       
    86 }
       
    87 
       
    88 //  ----------------------------------------------------------------------------
       
    89 //    Initializes a clip for playback from a file name
       
    90 //  ----------------------------------------------------------------------------
       
    91 //
       
    92 void CTestPlaybackPlugin::InitialiseL( const TDesC& aSong )
       
    93 {
       
    94 	delete iClipName;
       
    95     iClipName = NULL;
       
    96     iClipName = aSong.AllocL();
       
    97 
       
    98     iFile.Close();
       
    99 
       
   100     TInt err = iFile.Open( iFs, aSong, EFileRead | EFileShareReadersOrWriters );
       
   101 
       
   102     //
       
   103     //  Remap KErrNotReady to KErrNotFound, because it is referencing a drive
       
   104     //  that is not existent
       
   105     //
       
   106     if ( KErrNotReady == err )
       
   107     {
       
   108         err = KErrNotFound;
       
   109     }
       
   110 
       
   111     // if aSong is an streaming link and contains one of the streaming schemas
       
   112     // eg. rtsp:// , http:// etc. then a file handle can not be opened
       
   113     // ignore KErrBadName
       
   114     if (err != KErrBadName)
       
   115     {
       
   116         User::LeaveIfError( err );    
       
   117     }    
       
   118 }
       
   119 
       
   120 //  ----------------------------------------------------------------------------
       
   121 //    Initializes a clip for playback from a file handle
       
   122 //  ----------------------------------------------------------------------------
       
   123 //
       
   124 void CTestPlaybackPlugin::InitialiseL( RFile& aSong )
       
   125 {
       
   126 	delete iClipName;
       
   127     iClipName = NULL;
       
   128     iClipName = HBufC::NewL( KMaxFileName );
       
   129     TPtr ptr = iClipName->Des();
       
   130     aSong.FullName( ptr );
       
   131 
       
   132     iFile.Close();
       
   133     User::LeaveIfError( iFile.Duplicate( aSong ));
       
   134 }
       
   135 
       
   136 /**
       
   137 * Initializes a file for playback.
       
   138 *
       
   139 * @since S60 9.2
       
   140 * @param aUri URI of the item
       
   141 * @param aType the mime type of the item
       
   142 * @param aAccessPoint the access point
       
   143 */
       
   144 void CTestPlaybackPlugin::InitStreamingL(const TDesC& /*aUri*/, 
       
   145         const TDesC8& /*aType*/, TInt /*aAccessPoint*/)
       
   146     {
       
   147     }
       
   148 
       
   149 /**
       
   150 * Initializes a file handle for playback.
       
   151 *
       
   152 * @since S60 9.2
       
   153 * @param aFile file handle of a file
       
   154 * @param aAccessPoint the access point
       
   155 */
       
   156 void CTestPlaybackPlugin::InitStreamingL(RFile& /*aFile*/, TInt /*aAccessPoint*/)
       
   157     {
       
   158     }
       
   159 
       
   160 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
   161 /**
       
   162 * Initializes a file handle for playback.
       
   163 *
       
   164 * @since S60 9.2
       
   165 * @param aFile 64 bit file handle of a file
       
   166 * @param aAccessPoint the access point
       
   167 */
       
   168 void CTestPlaybackPlugin::InitStreaming64L(RFile64& /*aFile*/, TInt /*aAccessPoint*/)
       
   169     {
       
   170     }
       
   171 
       
   172 /**
       
   173 * Initializes a song for playback.
       
   174 *
       
   175 * @since S60 9.2
       
   176 * @param aFile 64 bit file handle of a song
       
   177 */
       
   178 void CTestPlaybackPlugin::Initialise64L(RFile64& /*aSong*/)
       
   179     {
       
   180     }
       
   181 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
   182 
       
   183 //  ----------------------------------------------------------------------------
       
   184 //    Executes a command on the selected song
       
   185 //  ----------------------------------------------------------------------------
       
   186 //
       
   187 void CTestPlaybackPlugin::CommandL( CMPXCommand& /*aCmd*/ )
       
   188 {
       
   189 }
       
   190 
       
   191 
       
   192 //  ----------------------------------------------------------------------------
       
   193 //    Executes a command on the selected song
       
   194 //  ----------------------------------------------------------------------------
       
   195 //
       
   196 void CTestPlaybackPlugin::CommandL(TMPXPlaybackCommand /*aCmd*/, TInt /*aData*/)
       
   197 {
       
   198 }
       
   199 
       
   200 
       
   201 //  ----------------------------------------------------------------------------
       
   202 //    Sets a property of the plugin
       
   203 //  ----------------------------------------------------------------------------
       
   204 //
       
   205 void CTestPlaybackPlugin::SetL( TMPXPlaybackProperty /*aProperty*/, TInt /*aValue*/ )
       
   206 {
       
   207 }
       
   208 
       
   209 //  ----------------------------------------------------------------------------
       
   210 //    Gets a property of the plugin (async)
       
   211 //  ----------------------------------------------------------------------------
       
   212 //
       
   213 void CTestPlaybackPlugin::PropertyL( TMPXPlaybackProperty /*aProperty*/ ) const
       
   214 {
       
   215 }
       
   216 
       
   217 //  ----------------------------------------------------------------------------
       
   218 //    Gets a list of sub players, UPnP only
       
   219 //  ----------------------------------------------------------------------------
       
   220 //
       
   221 void CTestPlaybackPlugin::SubPlayerNamesL()
       
   222 {
       
   223     iObs->HandleSubPlayerNames( KLocalPlaybackUid, NULL, ETrue, KErrNone );
       
   224 }
       
   225 
       
   226 //  ----------------------------------------------------------------------------
       
   227 //    Select a sub player
       
   228 //  ----------------------------------------------------------------------------
       
   229 //
       
   230 void CTestPlaybackPlugin::SelectSubPlayerL( TInt /*aIndex*/ )
       
   231 {
       
   232     User::Leave( KErrNotSupported );
       
   233 }
       
   234 
       
   235 //  ----------------------------------------------------------------------------
       
   236 //    Returns current sub player name
       
   237 //  ----------------------------------------------------------------------------
       
   238 //
       
   239 const TDesC& CTestPlaybackPlugin::SubPlayerName()
       
   240 {
       
   241     return KNullDesC;
       
   242 }
       
   243 
       
   244 //  ----------------------------------------------------------------------------
       
   245 //    Current sub player index
       
   246 //  ----------------------------------------------------------------------------
       
   247 //
       
   248 TInt CTestPlaybackPlugin::SubPlayerIndex() const
       
   249 {
       
   250    return KErrNotFound;
       
   251 }
       
   252 
       
   253 //  ----------------------------------------------------------------------------
       
   254 //    Gets media properties
       
   255 //  ----------------------------------------------------------------------------
       
   256 //
       
   257 void CTestPlaybackPlugin::MediaL( const TArray<TMPXAttribute>& /*aAttrs*/ )
       
   258 {
       
   259 }
       
   260 
       
   261 //  ----------------------------------------------------------------------------
       
   262 //    Cancel request
       
   263 //  ----------------------------------------------------------------------------
       
   264 //
       
   265 void CTestPlaybackPlugin::CancelRequest()
       
   266 {
       
   267 }
       
   268 
       
   269 //  ----------------------------------------------------------------------------
       
   270 //  CTestPlaybackPlugin::GetFileHandle()
       
   271 //  ----------------------------------------------------------------------------
       
   272 //
       
   273 RFile CTestPlaybackPlugin::GetFileHandle()
       
   274 {
       
   275     return iFile;
       
   276 }
       
   277 
       
   278 // End of file