os/mm/devsoundextensions/restrictedaudiooutput/RestrictedAudioOutputProxy/src/RestrictedAudioOutputProxy.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/devsoundextensions/restrictedaudiooutput/RestrictedAudioOutputProxy/src/RestrictedAudioOutputProxy.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,155 @@
     1.4 +/*
     1.5 +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:   This is the implementation of the CRestrictedAudioOutputProxy class.
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +
    1.23 +// INCLUDE FILES
    1.24 +#include <e32svr.h>
    1.25 +#include <RestrictedAudioOutput.h>
    1.26 +#include <RestrictedAudioOutputProxy.h>
    1.27 +#include <RestrictedAudioOutputMessageTypes.h>
    1.28 +#include <CustomInterfaceUtility.h>
    1.29 +
    1.30 +    
    1.31 +// ================= MEMBER FUNCTIONS =======================
    1.32 +
    1.33 +// C++ default constructor can NOT contain any code, that
    1.34 +// might leave.
    1.35 +//
    1.36 +CRestrictedAudioOutputProxy::CRestrictedAudioOutputProxy(
    1.37 +	TMMFMessageDestinationPckg aMessageHandler,
    1.38 +	MCustomCommand& aCustomCommand,
    1.39 +	CCustomInterfaceUtility* aCustomInterfaceUtility )
    1.40 +	: 	iCustomCommand(&aCustomCommand),
    1.41 +		iMessageHandler(aMessageHandler),
    1.42 +		iCustomInterfaceUtility(aCustomInterfaceUtility),
    1.43 +		iArray(4)
    1.44 +
    1.45 +    {  
    1.46 +
    1.47 +    }
    1.48 +
    1.49 +// Two-phased constructor.
    1.50 +EXPORT_C CRestrictedAudioOutputProxy* CRestrictedAudioOutputProxy::NewL(
    1.51 +	TMMFMessageDestinationPckg aMessageHandler,
    1.52 +    MCustomCommand& aCustomCommand,
    1.53 +    CCustomInterfaceUtility* aCustomInterfaceUtility)
    1.54 +    {
    1.55 +    
    1.56 +#ifdef _DEBUG    
    1.57 +	RDebug::Print(_L("CRestrictedAudioOutputProxy::NewL:\n"));
    1.58 +#endif
    1.59 +
    1.60 +
    1.61 +	    
    1.62 +  	CRestrictedAudioOutputProxy* self = new(ELeave) CRestrictedAudioOutputProxy(aMessageHandler, aCustomCommand, aCustomInterfaceUtility);
    1.63 + 	CleanupStack::PushL(self);
    1.64 + 	self->ConstructL();  // Call base class ConstructL
    1.65 +    CleanupStack::Pop(self);    
    1.66 +    return self;
    1.67 +    
    1.68 +    }	
    1.69 +      
    1.70 + EXPORT_C CRestrictedAudioOutputProxy* CRestrictedAudioOutputProxy::NewL(CMMFDevSound& aDevSound)
    1.71 +    {
    1.72 +    
    1.73 +#ifdef _DEBUG    
    1.74 +	RDebug::Print(_L("CRestrictedAudioOutputProxy::NewL (DevSound):\n"));
    1.75 +#endif
    1.76 +
    1.77 +  	CRestrictedAudioOutputProxy* audioOutputProxy = (CRestrictedAudioOutputProxy*)aDevSound.CustomInterface(KUidRestrictedAudioOutput);	  	
    1.78 +   	
    1.79 +	if (audioOutputProxy == NULL)
    1.80 +	{
    1.81 +#ifdef _DEBUG	
    1.82 +        RDebug::Print(_L("No Adaptation Support - leaving")); 
    1.83 +#endif          
    1.84 +    	User::Leave(KErrNotSupported);
    1.85 +	} 
    1.86 +		  	 
    1.87 +    return audioOutputProxy;
    1.88 +    
    1.89 +    }	       
    1.90 +
    1.91 +// Destructor
    1.92 +CRestrictedAudioOutputProxy::~CRestrictedAudioOutputProxy()
    1.93 +    {
    1.94 +#ifdef _DEBUG 
    1.95 +	RDebug::Print(_L("CRestrictedAudioOutputProxy::~CRestrictedAudioOutputProxy\n"));
    1.96 +#endif 
    1.97 +	  
    1.98 +	iArray.Reset();	   
    1.99 +    // Remove the custom interface message handler before we destroy the proxy.
   1.100 +    if (iCustomInterfaceUtility)
   1.101 +    {
   1.102 +    iCustomInterfaceUtility->RemoveCustomInterface(iMessageHandler);
   1.103 +    }
   1.104 +	delete iCustomInterfaceUtility;
   1.105 + 
   1.106 +    }
   1.107 +    
   1.108 +// ---------------------------------------------------------
   1.109 +// CRestrictedAudioOutput::Uid
   1.110 +// ?implementation_description
   1.111 +// (other items were commented in a header).
   1.112 +// ---------------------------------------------------------
   1.113 +//
   1.114 +EXPORT_C const TUid CRestrictedAudioOutputProxy::Uid()
   1.115 +	{
   1.116 +	return KUidRestrictedAudioOutput;
   1.117 +	}
   1.118 +
   1.119 +// ---------------------------------------------------------
   1.120 +// CRestrictedAudioOutputProxy::Commit
   1.121 +// ?implementation_description
   1.122 +// (other items were commented in a header).
   1.123 +// ---------------------------------------------------------
   1.124 +//
   1.125 +EXPORT_C TInt CRestrictedAudioOutputProxy::Commit()
   1.126 +	{
   1.127 +#ifdef _DEBUG 	
   1.128 +	RDebug::Print(_L("CRestrictedAudioOutputProxy::Commit"));
   1.129 +#endif
   1.130 +	
   1.131 +	TInt count;
   1.132 +	TAllowedOutputPreference pref;
   1.133 +	iArray.Reset();
   1.134 +	
   1.135 +	TInt err = GetAllowedOutputCount(count);
   1.136 +		
   1.137 +#ifdef _DEBUG 		
   1.138 +	RDebug::Print(_L("CRestrictedAudioOutputProxy::Commit: Current array count = %d"), count);
   1.139 +#endif		
   1.140 +	
   1.141 +	for (TInt i=0; i < count;i++)
   1.142 +	{
   1.143 +		err = GetAllowedOutput(i, pref);		
   1.144 +		TRAP(err,iArray.AppendL(pref));		
   1.145 +	}
   1.146 +
   1.147 +	TInt length = iArray.Length() * count;
   1.148 +	TPtrC8 arrayPtr((const TUint8*)&iArray[0], length);
   1.149 +	TPckgC<TInt> countPckg(count);
   1.150 +	
   1.151 +	iCustomCommand->CustomCommandSync(iMessageHandler, ERaofCommit, countPckg, arrayPtr );
   1.152 + 	
   1.153 +	
   1.154 +	return KErrNone;	
   1.155 +	}
   1.156 +	
   1.157 +
   1.158 +// End of File