os/mm/devsoundextensions/mmfcustominterfaces/Ra8DecoderIntfc/Ra8DecoderIntfcProxy/src/ra8custominterfaceproxy.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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:   Custom Interface proxy for RA8 decoder.
    15 *
    16 */
    17 
    18 
    19 
    20 // INCLUDE FILES
    21 #include <CustomCommandUtility.h>
    22 #include <CustomInterfaceUtility.h>
    23 #include <sounddevice.h>
    24 #include "Ra8CustomInterfaceProxy.h"
    25 #include "Ra8CustomInterfaceMsgs.h"
    26 
    27 // EXTERNAL DATA STRUCTURES
    28 
    29 // EXTERNAL FUNCTION PROTOTYPES  
    30 
    31 // CONSTANTS
    32 
    33 // MACROS
    34 
    35 // LOCAL CONSTANTS AND MACROS
    36 
    37 // MODULE DATA STRUCTURES
    38 
    39 // LOCAL FUNCTION PROTOTYPES
    40 
    41 // FORWARD DECLARATIONS
    42 
    43 // ============================= LOCAL FUNCTIONS ===============================
    44 
    45 // ================= MEMBER FUNCTIONS =======================
    46 
    47 // -----------------------------------------------------------------------------
    48 // CRa8CustomInterfaceProxy::CRa8CustomInterfaceProxy
    49 // C++ default constructor can NOT contain any code, that
    50 // might leave.
    51 // -----------------------------------------------------------------------------
    52 //
    53 CRa8CustomInterfaceProxy::CRa8CustomInterfaceProxy(
    54                           TMMFMessageDestinationPckg aMessageHandler, 
    55                           MCustomCommand& aCustomCommand,
    56                           CCustomInterfaceUtility* aCustomInterfaceUtility) :
    57 	iCustomCommand(aCustomCommand),
    58 	iMessageHandler(aMessageHandler),
    59 	iCustomInterfaceUtility(aCustomInterfaceUtility)
    60     {
    61     }
    62 
    63 
    64 // -----------------------------------------------------------------------------
    65 // CRa8CustomInterfaceProxy::ConstructL
    66 // Symbian 2nd phase constructor can leave.
    67 // -----------------------------------------------------------------------------
    68 //
    69 void CRa8CustomInterfaceProxy::ConstructL()
    70     {
    71     }
    72 
    73 // -----------------------------------------------------------------------------
    74 // CRa8CustomInterfaceProxy::NewL
    75 // Two-phased constructor.
    76 // -----------------------------------------------------------------------------
    77 //
    78 EXPORT_C CRa8CustomInterfaceProxy* CRa8CustomInterfaceProxy::NewL(
    79                             TMMFMessageDestinationPckg aMessageHandler, 
    80                             MCustomCommand& aCustomCommand,
    81                             CCustomInterfaceUtility* aCustomInterfaceUtility)
    82     {
    83     CRa8CustomInterfaceProxy* self = new(ELeave) CRa8CustomInterfaceProxy(
    84                                                     aMessageHandler,
    85                                                     aCustomCommand,
    86                                                     aCustomInterfaceUtility);
    87     CleanupStack::PushL( self );
    88     self->ConstructL();
    89     CleanupStack::Pop(self);
    90     return self;
    91     }
    92 
    93 // -----------------------------------------------------------------------------
    94 // CRa8CustomInterfaceProxy::NewL
    95 // Two-phased constructor (overloaded version).
    96 // -----------------------------------------------------------------------------
    97 //
    98 EXPORT_C CRa8CustomInterfaceProxy* CRa8CustomInterfaceProxy::NewL(
    99                                    CMMFDevSound& aDevSound)
   100     {
   101     CRa8CustomInterfaceProxy* ra8CustomInterfaceProxy;
   102     ra8CustomInterfaceProxy = 
   103     (CRa8CustomInterfaceProxy*)aDevSound.CustomInterface(KUidRa8DecHwDeviceCI);
   104      
   105     if (!ra8CustomInterfaceProxy)
   106         {
   107         User::Leave(KErrNotFound);
   108         }
   109         
   110     return ra8CustomInterfaceProxy;
   111     }
   112     
   113 // -----------------------------------------------------------------------------
   114 // Destructor
   115 // -----------------------------------------------------------------------------
   116 //
   117 EXPORT_C CRa8CustomInterfaceProxy::~CRa8CustomInterfaceProxy()
   118     {
   119     iCustomInterfaceUtility->RemoveCustomInterface(iMessageHandler);
   120     delete iCustomInterfaceUtility;
   121     }
   122 
   123 // -----------------------------------------------------------------------------
   124 // CRa8CustomInterfaceProxy::FrameNumber
   125 // Sends the custom command for this function to its message handler.
   126 // (other items were commented in a header).
   127 // -----------------------------------------------------------------------------
   128 //
   129 EXPORT_C TInt CRa8CustomInterfaceProxy::FrameNumber()
   130     {
   131     TInt frame = 0;
   132 	TPckgBuf<TInt> frameBuf(frame);
   133 	TInt status = iCustomCommand.CustomCommandSync(iMessageHandler,
   134 	                                               ERa8CiFrameNumber,
   135 	                                               KNullDesC8,
   136 	                                               KNullDesC8,
   137 	                                               frameBuf);
   138     if (status == KErrNone)
   139         {        
   140         frame = frameBuf();
   141         }
   142     else
   143         {        
   144         frame = status;
   145         }
   146     
   147 	return frame;
   148     }
   149     
   150 // -----------------------------------------------------------------------------
   151 // CRa8CustomInterfaceProxy::SetInitString
   152 // Sends the custom command for this function to its message handler.
   153 // (other items were commented in a header).
   154 // -----------------------------------------------------------------------------
   155 //
   156 EXPORT_C TInt CRa8CustomInterfaceProxy::SetInitString(TDesC8& aInitString)
   157     {
   158 	TInt status = iCustomCommand.CustomCommandSync(iMessageHandler,
   159 	                                               ERa8CiSetInitString,
   160 	                                               aInitString,
   161 	                                               KNullDesC8);
   162 	return status;
   163     }
   164 
   165 // ========================== OTHER EXPORTED FUNCTIONS =========================
   166 
   167 // End of File