os/ossrv/lowlevellibsandfws/pluginfw/Framework/Example/exampletwelve.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/Framework/Example/exampletwelve.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,547 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// The implementation of some classes to be provided by ECom.
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +/**
    1.22 + @file
    1.23 + @internalComponent
    1.24 +*/
    1.25 +
    1.26 +#include "exampletwelve.h"
    1.27 +
    1.28 +// __________________________________________________________________________
    1.29 +//
    1.30 +// Implementation of CImplementationClassTwelve
    1.31 +
    1.32 +/**
    1.33 +Safe construction which leaves nothing upon the cleanup stack
    1.34 +@param			aInitParams Initialization parameters
    1.35 +@return			CImplementationClassTwelve* a pointer to the fully instantiated CImplementationClassTwelve object
    1.36 +*/
    1.37 +CImplementationClassTwelve* CImplementationClassTwelve::NewL(TAny* aInitParams)
    1.38 +	{
    1.39 +	CImplementationClassTwelve* self=new(ELeave) CImplementationClassTwelve(); 
    1.40 +	CleanupStack::PushL(self);	
    1.41 +	self->ConstructL(aInitParams);
    1.42 +	CleanupStack::Pop(self);
    1.43 +	return self;
    1.44 +	}
    1.45 +
    1.46 +/**
    1.47 +Destructor of CImplementationClassTwelve
    1.48 + */
    1.49 +CImplementationClassTwelve::~CImplementationClassTwelve()
    1.50 +	{
    1.51 +	delete iInternalDescriptor;
    1.52 +	Dll::SetTls(NULL);
    1.53 +	}
    1.54 +
    1.55 +/**
    1.56 +Default Constructor : usable only by derived classes
    1.57 +*/
    1.58 +CImplementationClassTwelve::CImplementationClassTwelve()
    1.59 +: CExampleInterface()
    1.60 +	{
    1.61 +	//set the extended interface Uid
    1.62 +	iExtendedInterfaceUid.iUid = 0x10009E44;
    1.63 +	}
    1.64 +
    1.65 +/**
    1.66 +Safely complete the initialization of the constructed object.
    1.67 +@param			aInitParams Initialization parameters
    1.68 +*/
    1.69 +void CImplementationClassTwelve::ConstructL(TAny* aInitParams)
    1.70 +	{
    1.71 +	TExampleInterfaceInitParams* params = REINTERPRET_CAST(TExampleInterfaceInitParams*,aInitParams);
    1.72 +	if(params)
    1.73 +		{
    1.74 +		if(params->descriptor)
    1.75 +			{
    1.76 +			iInternalDescriptor = params->descriptor->AllocL();
    1.77 +			}
    1.78 +		}
    1.79 +	User::LeaveIfError(Dll::SetTls(&iTLSInt));
    1.80 +	}
    1.81 +
    1.82 +/**
    1.83 +Overload of the pure interface method.Representative of a method provided on
    1.84 +the interface by the interface definer.
    1.85 + */
    1.86 +void CImplementationClassTwelve::DoMethodL()
    1.87 +	{
    1.88 +	// Access TLS to ensure it has been set properly
    1.89 +	ASSERT(Dll::Tls()!=NULL);
    1.90 +	}
    1.91 +
    1.92 +/**
    1.93 +Overload of the pure interface method asynchronous function which
    1.94 +an interface definer could specify.
    1.95 +@return			TInt KErrNone for success.
    1.96 + */
    1.97 +TInt CImplementationClassTwelve::FireAndForget()
    1.98 +	{
    1.99 +	return KErrNone;			
   1.100 +	}
   1.101 +
   1.102 +// Provide the CActive overloads
   1.103 +void CImplementationClassTwelve::RunL()
   1.104 +	{
   1.105 +	// Do nothing : should never be called
   1.106 +	__ASSERT_DEBUG(EFalse,User::Invariant());
   1.107 +	}
   1.108 +
   1.109 +void CImplementationClassTwelve::DoCancel()
   1.110 +	{
   1.111 +	// Do nothing
   1.112 +	}
   1.113 +
   1.114 +TInt CImplementationClassTwelve::RunError(TInt /*aError*/)
   1.115 +	{
   1.116 +	return KErrNone;
   1.117 +	}
   1.118 +
   1.119 +/**
   1.120 +To verify the object returned by ECOM.
   1.121 +@return			TUid (ECOM's Implementation Uid for this class.)
   1.122 + */
   1.123 +TUid CImplementationClassTwelve::ImplId()
   1.124 +	{
   1.125 +	return KImplUid1;
   1.126 +	}
   1.127 +
   1.128 +/**
   1.129 +Extended interface method. Called to verify the Extended interface.
   1.130 + */
   1.131 +void CImplementationClassTwelve::DoMethodExtended()
   1.132 +	{
   1.133 +	//check the extended interface uid has been set properly
   1.134 +	ASSERT(iExtendedInterfaceUid.iUid == 0x10009E44);
   1.135 +	}
   1.136 +
   1.137 +/**
   1.138 +Get the extended interface. This method will be called by ECOM, so the method must
   1.139 +follow the signature defined by TProxyExtendedInterfaceGetPtrL. This must be a static
   1.140 +method since it is used in the proxy table.
   1.141 +@param			aObject A pointer to the instantiation interface (CImplementationClassTwelve
   1.142 +				in this case) instance. This will be provided by ECOM. It must be provided
   1.143 +				as a parameter,	as this method is a static method (and must be a static
   1.144 +				method because it is called by the proxy table).
   1.145 +@param			aExtendedInterface The extended interface to fetch. Must be a unique UID.
   1.146 +@param			aBitFlags Flags used for communication between plugin's and ECOM. Currently
   1.147 +				used to signal if an extended interface requires release.
   1.148 +@param			aReleaseObject return parameter, provides ECOM with the object to destroy
   1.149 +				if the interface requires to be released.
   1.150 +@return			TAny* a pointer to the fully constructed extended interface object
   1.151 +*/
   1.152 +TAny* CImplementationClassTwelve::GetExtendedInterfaceL(TAny* aObject,const TUid& aExtendedInterface,TUint32& aBitFlags,TAny*& aReleaseObject)
   1.153 +
   1.154 +	{
   1.155 +	//Initialise the release bit
   1.156 +	aBitFlags = aBitFlags & 0xFFFFFFFE;
   1.157 +	TAny* ret = NULL;
   1.158 +	switch (aExtendedInterface.iUid)
   1.159 +		{
   1.160 +		case 0x10009E44:
   1.161 +		    {
   1.162 +	        // No release is required, so do not modify aBitFlags.
   1.163 +		    ret = static_cast<MExampleInterfaceExtended*>(static_cast<CImplementationClassTwelve*>(aObject));
   1.164 +		    break;
   1.165 +		    }
   1.166 +		case 0x10009E45:
   1.167 +		    {
   1.168 +		    // Indicate to caller that release is required
   1.169 +		    aBitFlags = aBitFlags | KReleaseRequiredMask;
   1.170 +
   1.171 +		    CImplementationClassTwelveExtended *classExt = CImplementationClassTwelveExtended::NewL();
   1.172 +		    // Must set the release object for ECOM to release later, this will not be the same as the interface object that is returned.
   1.173 +		    aReleaseObject = classExt;
   1.174 +
   1.175 +		    ret = static_cast<MExampleInterfaceExtended2*>(classExt);
   1.176 +		    break;
   1.177 +		    }
   1.178 +		case 0x10009E46:
   1.179 +		    {
   1.180 +		    // Indicate to caller that release is required
   1.181 +		    aBitFlags = aBitFlags | KReleaseRequiredMask;
   1.182 +
   1.183 +		    CImplementationClassTwelveExtended2 *classExt = CImplementationClassTwelveExtended2::NewL();
   1.184 +		    // Must set the release object for ECOM to release later, this will not be the same as the interface object that is returned.
   1.185 +		    aReleaseObject = classExt;
   1.186 +
   1.187 +		    ret = static_cast<MExampleInterfaceExtended2*>(classExt);
   1.188 +		    break;
   1.189 +		    }
   1.190 +		default:
   1.191 +			{
   1.192 +		    break;
   1.193 +		    }
   1.194 +		}
   1.195 +	return ret;
   1.196 +	}
   1.197 +
   1.198 +/**
   1.199 +Release the specified extended interface. This method will be called by ECOM, so the method must
   1.200 +follow the signature defined by TProxyExtendedInterfaceReleasePtr. This must be a static
   1.201 +method since it is used in the proxy table.
   1.202 +method.
   1.203 +@param			aReleaseObject provides ECOM with the object to destroy
   1.204 +				if the interface requires to be released.
   1.205 +@param			aExtendedInterface extended interface that is to be released
   1.206 +@return			TAny* a pointer to the fully constructed extended interface object
   1.207 +*/
   1.208 +void CImplementationClassTwelve::ReleaseExtendedInterface(TAny* aReleaseObject,const TUid& aExtendedInterface)
   1.209 +	{
   1.210 +	switch (aExtendedInterface.iUid)
   1.211 +	    {
   1.212 +	    case 0x10009E45:
   1.213 +			{
   1.214 +	        // this object is an interface that was a separate object from the main instantiated object, and must be cleaned up.
   1.215 +			CImplementationClassTwelveExtended* classExt = static_cast<CImplementationClassTwelveExtended*>(aReleaseObject);
   1.216 +			delete classExt;
   1.217 +			break;
   1.218 +	        }
   1.219 + 		case 0x10009E46:
   1.220 +			{
   1.221 +	        // this object is an interface that was a separate object from the main instantiated object, and must be cleaned up.
   1.222 +			CImplementationClassTwelveExtended2* classExt = static_cast<CImplementationClassTwelveExtended2*>(aReleaseObject);
   1.223 +			delete classExt;
   1.224 +			break;
   1.225 +	        }
   1.226 +	    default:
   1.227 +			{
   1.228 +			break;    
   1.229 +			}    
   1.230 +	    }
   1.231 +	}
   1.232 +
   1.233 +
   1.234 +// __________________________________________________________________________
   1.235 +//
   1.236 +// Implementation of CImplementationClassTwelveExtended
   1.237 +
   1.238 +/**
   1.239 +Safe construction which leaves nothing upon the cleanup stack
   1.240 +@return			CImplementationClassTwelve* a pointer to the fully instantiated CImplementationClassTwelve object
   1.241 +*/
   1.242 +CImplementationClassTwelveExtended* CImplementationClassTwelveExtended::NewL()
   1.243 +
   1.244 +	{
   1.245 +	CImplementationClassTwelveExtended* self=new(ELeave) CImplementationClassTwelveExtended();  // calls c'tor
   1.246 +	return self;
   1.247 +	}
   1.248 +
   1.249 +/**
   1.250 +Destructor of CImplementationClassTwelveExtended
   1.251 + */
   1.252 +CImplementationClassTwelveExtended::~CImplementationClassTwelveExtended()
   1.253 +	{
   1.254 +	// do nothing
   1.255 +	}
   1.256 +
   1.257 +/**
   1.258 +Default Constructor : usable only by derived classes
   1.259 +*/
   1.260 +CImplementationClassTwelveExtended::CImplementationClassTwelveExtended()
   1.261 +	{
   1.262 +	//set the extended interface uid
   1.263 +	iExtendedInterfaceUid.iUid = 0x10009E45;
   1.264 +	}
   1.265 +
   1.266 +/**
   1.267 +Extended interface.
   1.268 +*/
   1.269 +void CImplementationClassTwelveExtended::DoMethodExtended2()
   1.270 +	{
   1.271 +	//check the extended interface uid has been set properly
   1.272 +	ASSERT(iExtendedInterfaceUid.iUid == 0x10009E45);
   1.273 +	}
   1.274 +
   1.275 +// __________________________________________________________________________
   1.276 +//
   1.277 +// Implementation of CImplementationClassTwelveExtended2
   1.278 +
   1.279 +/**
   1.280 +Safe construction which leaves nothing upon the cleanup stack
   1.281 +@return			CImplementationClassTwelveExtended2* a pointer to the fully instantiated CImplementationClassTwelve object
   1.282 +*/
   1.283 +CImplementationClassTwelveExtended2* CImplementationClassTwelveExtended2::NewL()
   1.284 +	{
   1.285 +	CImplementationClassTwelveExtended2* self=new(ELeave) CImplementationClassTwelveExtended2();  // calls c'tor
   1.286 +	return self;
   1.287 +	}
   1.288 +
   1.289 +/**
   1.290 +Destructor of CImplementationClassTwelveExtended2
   1.291 + */
   1.292 +CImplementationClassTwelveExtended2::~CImplementationClassTwelveExtended2()
   1.293 +	{
   1.294 +	// do nothing
   1.295 +	}
   1.296 +
   1.297 +/**
   1.298 +Default Constructor : usable only by derived classes
   1.299 +*/
   1.300 +CImplementationClassTwelveExtended2::CImplementationClassTwelveExtended2()
   1.301 +	{
   1.302 +	//set the extended interface uid
   1.303 +	iExtendedInterfaceUid.iUid = 0x10009E46;
   1.304 +	}
   1.305 +
   1.306 +/**
   1.307 +Extended interface.
   1.308 +*/
   1.309 +void CImplementationClassTwelveExtended2::DoMethodExtended2()
   1.310 +	{
   1.311 +	//check the extended interface uid has been set properly
   1.312 +	ASSERT(iExtendedInterfaceUid.iUid == 0x10009E46);
   1.313 +	}
   1.314 +
   1.315 +
   1.316 +// __________________________________________________________________________
   1.317 +// Implementation of CImplementationClassTwelveBasic
   1.318 +
   1.319 +/**
   1.320 +Safe construction which leaves nothing upon the cleanup stack
   1.321 +@param			aInitParams The parameter struct used for initialising this object
   1.322 +@return			CImplementationClassTwelveBasic* a pointer to the fully instantiated CImplementationClassTwelveBasic object
   1.323 +*/
   1.324 +CImplementationClassTwelveBasic* CImplementationClassTwelveBasic::NewL(TAny* aInitParams)
   1.325 +	{
   1.326 +	CImplementationClassTwelveBasic* self=new(ELeave) CImplementationClassTwelveBasic();  
   1.327 +	CleanupStack::PushL(self);	
   1.328 +	self->ConstructL(aInitParams); 
   1.329 +	CleanupStack::Pop(self);
   1.330 +	return self;
   1.331 +	}
   1.332 +
   1.333 +/**
   1.334 +Destructor of CImplementationClassTwelveBasic
   1.335 + */
   1.336 +CImplementationClassTwelveBasic::~CImplementationClassTwelveBasic()
   1.337 +	{
   1.338 +	delete iInternalDescriptor;
   1.339 +	Dll::FreeTls();
   1.340 +	}
   1.341 +
   1.342 +/**
   1.343 +Default Constructor : usable only by derived classes
   1.344 +*/
   1.345 +CImplementationClassTwelveBasic::CImplementationClassTwelveBasic()
   1.346 +: CExampleInterface()
   1.347 +	{
   1.348 +	}
   1.349 +
   1.350 +/**
   1.351 +Completes the safe construction of the CImplementationClassTwelveBasic object
   1.352 +@param			aInitParams The parameter struct used for initialising this object
   1.353 + */
   1.354 +void CImplementationClassTwelveBasic::ConstructL(TAny* aInitParams)
   1.355 +	{
   1.356 +	TExampleInterfaceInitParams* params = REINTERPRET_CAST(TExampleInterfaceInitParams*, aInitParams);
   1.357 +	if(params)
   1.358 +		{
   1.359 +		if(params->descriptor)
   1.360 +			{
   1.361 +			iInternalDescriptor = params->descriptor->AllocL();
   1.362 +			}
   1.363 +		}
   1.364 +	User::LeaveIfError(Dll::SetTls(&iTLSInt));
   1.365 +	}
   1.366 +
   1.367 +/**
   1.368 +Overload of the pure interface method.Representative of a method provided on
   1.369 +the interface by the interface definer.
   1.370 + */
   1.371 +void CImplementationClassTwelveBasic::DoMethodL()
   1.372 +	{
   1.373 +	// Access TLS to ensure it has been set properly
   1.374 +	ASSERT(Dll::Tls() != NULL);
   1.375 +	}
   1.376 +
   1.377 +/**
   1.378 +Overload of the pure interface method asynchronous function which
   1.379 +an interface definer could specify. 
   1.380 +@return			TInt KErrNone for success.
   1.381 + */
   1.382 +TInt CImplementationClassTwelveBasic::FireAndForget()
   1.383 +	{
   1.384 +	return KErrNone;			
   1.385 +	}
   1.386 +
   1.387 +// Provide the CActive overloads
   1.388 +void CImplementationClassTwelveBasic::RunL()
   1.389 +	{
   1.390 +	// Do nothing : should never be called
   1.391 +	__ASSERT_DEBUG(EFalse,User::Invariant());
   1.392 +	}
   1.393 +
   1.394 +void CImplementationClassTwelveBasic::DoCancel()
   1.395 +	{
   1.396 +	// Do nothing
   1.397 +	}
   1.398 +
   1.399 +TInt CImplementationClassTwelveBasic::RunError(TInt /*aError*/)
   1.400 +	{
   1.401 +	return KErrNone;
   1.402 +	}
   1.403 +
   1.404 +/**
   1.405 +To verify the object returned by ECOM.
   1.406 +@return			TUid (ECOM's Implementation Uid for this class.)
   1.407 + */
   1.408 +TUid CImplementationClassTwelveBasic::ImplId()
   1.409 +	{
   1.410 +	return KImplUid2;
   1.411 +	}
   1.412 +
   1.413 +// __________________________________________________________________________
   1.414 +// Implementation of CImplementationClassTwelve2
   1.415 +
   1.416 +/**
   1.417 +Standardised safe construction which leaves nothing the cleanup stack.
   1.418 +@param			aInitParams The parameter struct used for initialising this object
   1.419 +@return			CImplementationClassTwelve2* The class instance.
   1.420 + */
   1.421 +CImplementationClassTwelve2* CImplementationClassTwelve2::NewL(TAny* aInitParams)
   1.422 +	{
   1.423 +	CImplementationClassTwelve2* self=new(ELeave) CImplementationClassTwelve2();  // calls c'tor
   1.424 +	CleanupStack::PushL(self);	// Make the construction safe by using the cleanup stack
   1.425 +	self->ConstructL(aInitParams); // Complete the 'construction'.
   1.426 +	CleanupStack::Pop(self);
   1.427 +	return self;
   1.428 +	}
   1.429 +/**
   1.430 +Destructor of CImplementationClassTwelve2
   1.431 + */
   1.432 +CImplementationClassTwelve2::~CImplementationClassTwelve2()
   1.433 +	{
   1.434 +	delete iInternalDescriptor;
   1.435 +	Dll::FreeTls();
   1.436 +	}
   1.437 +
   1.438 +/**
   1.439 +Default Constructor
   1.440 +*/
   1.441 +CImplementationClassTwelve2::CImplementationClassTwelve2()
   1.442 +: CExampleInterface()
   1.443 +	{
   1.444 +	//set the extended interface uid
   1.445 +	iExtendedInterfaceUid.iUid = 0x10009E44;
   1.446 +	}
   1.447 +
   1.448 +/**
   1.449 +Completes the safe construction of the CImplementationClassTwelveBasic object
   1.450 +@param			aInitParams The parameter struct used for initialising this object
   1.451 + */
   1.452 +void CImplementationClassTwelve2::ConstructL(TAny* aInitParams)
   1.453 +	{
   1.454 +	TExampleInterfaceInitParams* params = REINTERPRET_CAST(TExampleInterfaceInitParams*, aInitParams);
   1.455 +	if(params)
   1.456 +		{
   1.457 +		if(params->descriptor)
   1.458 +			iInternalDescriptor = params->descriptor->AllocL();
   1.459 +		}
   1.460 +	User::LeaveIfError(Dll::SetTls(&iTLSInt));
   1.461 +	}
   1.462 +
   1.463 +/**
   1.464 +Overload of the pure interface method.Representative of a method provided on
   1.465 +the interface by the interface definer.
   1.466 + */
   1.467 +void CImplementationClassTwelve2::DoMethodL()
   1.468 +	{
   1.469 +	// Access TLS to ensure it has been set properly
   1.470 +	ASSERT(Dll::Tls()!=NULL);
   1.471 +	}
   1.472 +
   1.473 +/**
   1.474 +Overload of the pure interface method asynchronous function which
   1.475 +an interface definer could specify. 
   1.476 +@return			TInt KErrNone for success.
   1.477 + */
   1.478 +TInt CImplementationClassTwelve2::FireAndForget()
   1.479 +	{
   1.480 +	return KErrNone;			
   1.481 +	}
   1.482 +
   1.483 +// Provide the CActive overloads
   1.484 +void CImplementationClassTwelve2::RunL()
   1.485 +	{
   1.486 +	// Do nothing : should never be called
   1.487 +	__ASSERT_DEBUG(EFalse,User::Invariant());
   1.488 +	}
   1.489 +
   1.490 +void CImplementationClassTwelve2::DoCancel()
   1.491 +	{
   1.492 +	// Do nothing
   1.493 +	}
   1.494 +
   1.495 +TInt CImplementationClassTwelve2::RunError(TInt /*aError*/)
   1.496 +	{
   1.497 +	return KErrNone;
   1.498 +	}
   1.499 +
   1.500 +/**
   1.501 +To verify the object returned by ECOM.
   1.502 +@return			TUid (ECOM's Implementation Uid for this class.)
   1.503 + */
   1.504 +TUid CImplementationClassTwelve2::ImplId()
   1.505 +	{
   1.506 +	return KImplUid3;
   1.507 +	}
   1.508 +
   1.509 +/**
   1.510 +Extended interface method. Called to verify the Extended interface.
   1.511 + */
   1.512 +void CImplementationClassTwelve2::DoMethodExtended()
   1.513 +	{
   1.514 +	//check the extended interface uid has been set properly
   1.515 +	ASSERT(iExtendedInterfaceUid.iUid == 0x10009E44);
   1.516 +	}
   1.517 +
   1.518 +/**
   1.519 +Get the extended interface. This method will be called by ECOM, so the method must
   1.520 +follow the signature defined by TProxyExtendedInterfaceGetPtrL.This must be a static
   1.521 +method since it is used in the proxy table.
   1.522 +@param			aObject A pointer to the instantiation interface (CImplementationClassTwelve
   1.523 +				in this case) instance. This will be provided by ECOM. It must be provided
   1.524 +				as a parameter,	as this method is a static method (and must be a static
   1.525 +				method because it is called by the proxy table).
   1.526 +@param			aExtendedInterface The extended interface to fetch. Must be a unique UID.
   1.527 +@param			aBitFlags Flags used for communication between plugin's and ECOM. Currently
   1.528 +				used to signal if an extended interface requires release.
   1.529 +@param			aReleaseObject return parameter, provides ECOM with the object to destroy
   1.530 +				if the interface requires to be released.
   1.531 +@return			TAny* a pointer to the fully constructed extended interface object
   1.532 +*/
   1.533 +TAny* CImplementationClassTwelve2::GetExtendedInterfaceL(TAny* aObject,const TUid& aExtendedInterface,TUint32& /*aBitFlags*/,TAny*& /*releaseObject*/)
   1.534 +	{
   1.535 +	TAny* ret = NULL;
   1.536 +	switch (aExtendedInterface.iUid)
   1.537 +		{
   1.538 +		case 0x10009E44:
   1.539 +		    {
   1.540 +	        // No release is required, so do not modify aBitFlags.
   1.541 +		    ret = static_cast<MExampleInterfaceExtended*>(static_cast<CImplementationClassTwelve2*>(aObject));
   1.542 +		    break;
   1.543 +		    }
   1.544 +		default:
   1.545 +			{
   1.546 +			break;    
   1.547 +			}    
   1.548 +		}
   1.549 +	return ret;
   1.550 +	}