Update contrib.
1 // Copyright (c) 2007-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 the License "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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\earlyextension\d_testearlyextension.cpp
18 #include <kernel/kernel.h>
19 #include "d_wsdextension.h"
21 _LIT(KWsdExtName, "D_WSDEXTENSION.LDD");
24 class DWsdExtLddFactory : public DLogicalDevice
28 virtual TInt Install();
29 virtual void GetCaps(TDes8 &aDes) const;
30 virtual TInt Create(DLogicalChannelBase*& aChannel);
34 /** Logical channel */
35 class DWsdExtension : public DLogicalChannelBase
41 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
42 virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
43 virtual TInt RequestUserHandle(DThread* aThread, TOwnerType aType);
48 TInt DWsdExtLddFactory::iData = 0xEFEFEFEF;
51 DWsdExtLddFactory::DWsdExtLddFactory()
57 /** Entry point for this driver */
58 //DECLARE_EXTENSION_WITH_PRIORITY(LATE_EXTENSION_PRIORITY)
59 DECLARE_STANDARD_EXTENSION()
61 Kern::Printf("D_WSDEXTENSION.LDD Start");
62 DWsdExtLddFactory* device = new DWsdExtLddFactory;
65 TInt r = Kern::InstallLogicalDevice(device);
69 DECLARE_EXTENSION_LDD()
71 Kern::Printf("D_WSDEXTENSION.LDD Start 2");
72 return new DWsdExtLddFactory;
74 /** Second stage constuctor */
75 TInt DWsdExtLddFactory::Install()
77 Kern::Printf("D_WSDEXTENSION.LDD Install");
78 return(SetName(&KWsdExtName));
81 /** Device capabilities */
82 void DWsdExtLddFactory::GetCaps(TDes8& aDes)const
87 /** Create logical channel, only open of one channel is allowed at a time */
88 TInt DWsdExtLddFactory::Create(DLogicalChannelBase*& aChannel)
90 if (iOpenChannels != 0) //A Channel is already open
92 aChannel = new DWsdExtension;
99 TInt DWsdExtension::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
104 /** Constructor of Logical channel */
105 DWsdExtension::DWsdExtension()
107 iClient = &Kern::CurrentThread();
108 ((DObject*)iClient)->Open();
112 DWsdExtension::~DWsdExtension()
114 // Close our reference on the client thread
115 Kern::SafeClose((DObject*&)iClient,NULL);
118 /** Handle user side requests */
119 TInt DWsdExtension::Request(TInt aReqNo, TAny* a1, TAny*)
123 case (RLddWsdExtension::EGET_STATIC_DATA):
126 i=DWsdExtLddFactory::iData;
127 kumemput(a1, &DWsdExtLddFactory::iData, sizeof(TInt));
131 return KErrNotSupported;
134 /** Restricting handle duplication */
135 TInt DWsdExtension::RequestUserHandle(DThread* aThread, TOwnerType aType)
137 if (aType!=EOwnerThread || aThread!=iClient)
138 return KErrAccessDenied;