os/mm/mmlibs/mmfw/tsrc/mmfunittest/GEF/Plugin/TestGlobalEffectPlugin.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include "TestGlobalEffectPlugin.h"
    17 
    18 #include <ecom/ecom.h>
    19 #include <ecom/implementationproxy.h>
    20 #include "../src/TestGlobalEffect.hrh"
    21 
    22 const TUid KUidTestGlbCustomCall = {KUidTestGlbCustomCallDefine};
    23 const TInt KPresetsCount = 3;
    24 
    25 //
    26 // CTestEffect
    27 //
    28 
    29 CTestEffect::CTestEffect()
    30 	{
    31 	}
    32 	
    33 CTestEffect::~CTestEffect()
    34 	{
    35 	delete iSettingsDes;
    36 	delete iPresetList;
    37 	REComSession::DestroyedImplementation(iDestructorKey);
    38 	}
    39 	
    40 MMmfGlobalAudioImpl* CTestEffect::NewL()
    41 	{
    42 	return new (ELeave) CTestEffect;
    43 	}
    44 
    45 void CTestEffect::Release()
    46 	{
    47 	// this is effectively delete
    48 	delete this;
    49 	}
    50 	
    51 TUint CTestEffect::Capability(TBool aCurrentOnly)
    52 	{
    53 	// not totally clear what to do for testing purposes, so just return 0 or -1 depending on param
    54 	return aCurrentOnly ? 0xffff : 0;
    55 	}
    56 	
    57 void CTestEffect::RequestNotificationL(TUid aEventUid)
    58 	{
    59 	// for test, just remember the pass event uid and use in test GenCallbackL() call
    60 	iNotifyUid = aEventUid;
    61 	}
    62 	
    63 void CTestEffect::GenCallbackL()
    64 	{
    65 	iObserver->GAEEventNotificationL(iParent, iNotifyUid, KNullDesC8);
    66 	}
    67 	
    68 TBool CTestEffect::IsEnabled() const
    69 	{
    70 	return iEnabled;
    71 	}
    72 	
    73 void CTestEffect::SetEnabledL(TBool aBool)
    74 	{
    75 	iEnabled = aBool;
    76 	}
    77 	
    78 TBool CTestEffect::IsActive() const
    79 	{
    80 	return iIsActive;
    81 	}
    82 	
    83 void CTestEffect::SetActive(TBool aValue)
    84 	{
    85 	iIsActive = aValue;
    86 	}
    87 	
    88 TUid CTestEffect::SettingsByUidL() const
    89 	{
    90 	if (iValueState!=ESetByUid)
    91 		{
    92 		User::Leave(KErrNotSupported);
    93 		}
    94 	return iSettingsUid;
    95 	}
    96 	
    97 void CTestEffect::SetSettingsByUidL(TUid aPresetUid)
    98 	{
    99 	iSettingsUid = aPresetUid;
   100 	iValueState = ESetByUid;
   101 	}
   102 	
   103 HBufC8* CTestEffect::SettingsByDesL() const
   104 	{
   105 	// for test, if we've not set via Des then return default value - except for SetByValue
   106 	_LIT8(KDefaultDes, "1234");
   107 	if (iValueState==ESetByDes)
   108 		{
   109 		return iSettingsDes->AllocL();
   110 		}
   111 	else if (iValueState!=ESetByValue)
   112 		{
   113 		return KDefaultDes().AllocL();
   114 		}
   115 	else
   116 		{
   117 		User::Leave(KErrNotSupported);
   118 		return NULL;
   119 		}
   120 	}
   121 	
   122 void CTestEffect::SetSettingsByDesL(const TDesC8& aParam)
   123 	{
   124 	delete iSettingsDes;
   125 	iSettingsDes = NULL;
   126 	iSettingsDes = aParam.Alloc();
   127 	iValueState = ESetByDes;
   128 	}
   129 	
   130 MMmfGlobalAudioPresetList* CTestEffect::KnownPresetsL()
   131 	{
   132 	delete iPresetList;
   133 	iPresetList = NULL;
   134 	iPresetList = CPresetList::NewL();
   135 	
   136 	// produce list of num in numeric and readable form, upto count
   137 	for (TInt index=0; index<KPresetsCount; index++)
   138 		{
   139 		TBuf<10> name;
   140 		name.Num(index);
   141 		TUid tempUid={index};
   142 		iPresetList->AppendL(tempUid, name);
   143 		}
   144 	return iPresetList;
   145 	}
   146 	
   147 void CTestEffect::ExtractValuesL(TDes8& aPackageBuf)
   148 	{
   149 	if (iValueState!=ESetByValue)
   150 		{
   151 		User::LeaveIfError(KErrNotSupported);
   152 		}
   153 	TPckgC<TInt> packageBuf(iSettingsValue);
   154 	aPackageBuf = packageBuf;
   155 	}
   156 	
   157 void CTestEffect::SetByValuesL(const TDesC8& aPackageBuf)
   158 	{
   159 	TPckg<TInt> packageBuf(iSettingsValue);
   160 	packageBuf.Copy(aPackageBuf);
   161 	iValueState = ESetByValue;
   162 	}
   163 	
   164 TInt CTestEffect::CreateCustomInterface(TUid aInterfaceUid)
   165 	{
   166 	if (aInterfaceUid==KUidTestGlbCustomCall)
   167 		{
   168 		// we derive from this anyway, so just return KErrNone to say supported
   169 		return KErrNone;
   170 		}
   171 	return KErrNotSupported;
   172 	}
   173 
   174 
   175 TAny* CTestEffect::CustomInterface(TUid aInterfaceUid)
   176 	{
   177 	if (aInterfaceUid==KUidTestGlbCustomCall)
   178 		{
   179 		MTestEffectCustomIf* castedThis = this;
   180 		return castedThis;
   181 		}
   182 	return NULL;
   183 	}
   184 		
   185 void CTestEffect::PassDestructorKey(TUid aDestructorKey)
   186 	{
   187 	iDestructorKey = aDestructorKey;
   188 	}
   189 	
   190 void CTestEffect::CompleteConstructL(CMmfGlobalAudioEffect* aParent, MMmfGlobalAudioEffectObserver* aObserver)
   191 	{
   192 	iParent = aParent;
   193 	iObserver = aObserver;
   194 	}
   195 
   196 
   197 
   198 
   199 // __________________________________________________________________________
   200 // Exported proxy for instantiation method resolution
   201 // Define the interface UIDs
   202 const TImplementationProxy ImplementationTable[] = 
   203 	{
   204 		IMPLEMENTATION_PROXY_ENTRY(KUidTestGlblPluginImpDefine,	CTestEffect::NewL),
   205 	};
   206 
   207 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
   208 	{
   209 	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
   210 
   211 	return ImplementationTable;
   212 	}
   213