sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\earlyextension\d_testearlyextension.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include "d_wsdextension.h" sl@0: sl@0: _LIT(KWsdExtName, "D_WSDEXTENSION.LDD"); sl@0: sl@0: /** Factory class */ sl@0: class DWsdExtLddFactory : public DLogicalDevice sl@0: { sl@0: public: sl@0: DWsdExtLddFactory(); sl@0: virtual TInt Install(); sl@0: virtual void GetCaps(TDes8 &aDes) const; sl@0: virtual TInt Create(DLogicalChannelBase*& aChannel); sl@0: static TInt iData; sl@0: }; sl@0: sl@0: /** Logical channel */ sl@0: class DWsdExtension : public DLogicalChannelBase sl@0: { sl@0: public: sl@0: DWsdExtension(); sl@0: ~DWsdExtension(); sl@0: protected: sl@0: virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); sl@0: virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2); sl@0: virtual TInt RequestUserHandle(DThread* aThread, TOwnerType aType); sl@0: private: sl@0: DThread* iClient; sl@0: }; sl@0: sl@0: TInt DWsdExtLddFactory::iData = 0xEFEFEFEF; sl@0: sl@0: /** Factory class */ sl@0: DWsdExtLddFactory::DWsdExtLddFactory() sl@0: { sl@0: iParseMask=0; sl@0: iUnitsMask=0; sl@0: } sl@0: sl@0: /** Entry point for this driver */ sl@0: //DECLARE_EXTENSION_WITH_PRIORITY(LATE_EXTENSION_PRIORITY) sl@0: DECLARE_STANDARD_EXTENSION() sl@0: { sl@0: Kern::Printf("D_WSDEXTENSION.LDD Start"); sl@0: DWsdExtLddFactory* device = new DWsdExtLddFactory; sl@0: if(!device) sl@0: return KErrNoMemory; sl@0: TInt r = Kern::InstallLogicalDevice(device); sl@0: return r; sl@0: } sl@0: sl@0: DECLARE_EXTENSION_LDD() sl@0: { sl@0: Kern::Printf("D_WSDEXTENSION.LDD Start 2"); sl@0: return new DWsdExtLddFactory; sl@0: } sl@0: /** Second stage constuctor */ sl@0: TInt DWsdExtLddFactory::Install() sl@0: { sl@0: Kern::Printf("D_WSDEXTENSION.LDD Install"); sl@0: return(SetName(&KWsdExtName)); sl@0: } sl@0: sl@0: /** Device capabilities */ sl@0: void DWsdExtLddFactory::GetCaps(TDes8& aDes)const sl@0: { sl@0: aDes.FillZ(); sl@0: } sl@0: sl@0: /** Create logical channel, only open of one channel is allowed at a time */ sl@0: TInt DWsdExtLddFactory::Create(DLogicalChannelBase*& aChannel) sl@0: { sl@0: if (iOpenChannels != 0) //A Channel is already open sl@0: return KErrInUse; sl@0: aChannel = new DWsdExtension; sl@0: if(!aChannel) sl@0: return KErrNoMemory; sl@0: return KErrNone; sl@0: } sl@0: sl@0: /** Create channel */ sl@0: TInt DWsdExtension::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/) sl@0: { sl@0: return KErrNone; sl@0: } sl@0: sl@0: /** Constructor of Logical channel */ sl@0: DWsdExtension::DWsdExtension() sl@0: { sl@0: iClient = &Kern::CurrentThread(); sl@0: ((DObject*)iClient)->Open(); sl@0: } sl@0: sl@0: /** Destructor */ sl@0: DWsdExtension::~DWsdExtension() sl@0: { sl@0: // Close our reference on the client thread sl@0: Kern::SafeClose((DObject*&)iClient,NULL); sl@0: } sl@0: sl@0: /** Handle user side requests */ sl@0: TInt DWsdExtension::Request(TInt aReqNo, TAny* a1, TAny*) sl@0: { sl@0: switch(aReqNo) sl@0: { sl@0: case (RLddWsdExtension::EGET_STATIC_DATA): sl@0: { sl@0: TInt i=0; sl@0: i=DWsdExtLddFactory::iData; sl@0: kumemput(a1, &DWsdExtLddFactory::iData, sizeof(TInt)); sl@0: return KErrNone; sl@0: } sl@0: } sl@0: return KErrNotSupported; sl@0: } sl@0: sl@0: /** Restricting handle duplication */ sl@0: TInt DWsdExtension::RequestUserHandle(DThread* aThread, TOwnerType aType) sl@0: { sl@0: if (aType!=EOwnerThread || aThread!=iClient) sl@0: return KErrAccessDenied; sl@0: return KErrNone; sl@0: } sl@0: sl@0: