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 "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: // sl@0: sl@0: #include sl@0: #include "eventdd.h" sl@0: sl@0: /** sl@0: Logical Device (factory class) for 'EventDD' sl@0: */ sl@0: class DEventFactory : public DLogicalDevice sl@0: { sl@0: public: sl@0: DEventFactory(); sl@0: //Pure virtual funcitons from DLogicalDevice sl@0: TInt Install(); sl@0: void GetCaps(TDes8& aDes) const; sl@0: TInt Create(DLogicalChannelBase*& aChannel); sl@0: }; sl@0: sl@0: class DEventDD : public DLogicalChannelBase sl@0: { sl@0: public: sl@0: //Pure virtual function from DLogicalChannelBase sl@0: TInt Request(TInt aReqNo,TAny* a1,TAny* a2); sl@0: private: sl@0: TInt DoControl(TInt aFunction, TAny* a1, TAny* a2); sl@0: TInt SendEvent(TRawEvent* aEvent); sl@0: }; sl@0: sl@0: sl@0: /* DLL Factory Function */ sl@0: sl@0: DECLARE_STANDARD_LDD() sl@0: { sl@0: return new DEventFactory; sl@0: } sl@0: sl@0: sl@0: /* DEventFactory */ sl@0: sl@0: DEventFactory::DEventFactory() :DLogicalDevice() sl@0: { sl@0: iVersion=REventDD::VersionRequired(); //Set version number for this device sl@0: } sl@0: sl@0: TInt DEventFactory::Install() sl@0: { sl@0: return SetName(&REventDD::DriverName()); sl@0: } sl@0: sl@0: void DEventFactory::GetCaps(TDes8& aDes) const sl@0: { sl@0: Kern::InfoCopy(aDes,KNullDesC8); sl@0: } sl@0: sl@0: TInt DEventFactory::Create(DLogicalChannelBase*& aChannel) sl@0: { sl@0: aChannel=new DEventDD; sl@0: return aChannel?KErrNone:KErrNoMemory; sl@0: } sl@0: sl@0: sl@0: /* DEventDD */ // Logical Channel sl@0: sl@0: TInt DEventDD::Request(TInt aReqNo,TAny* a1,TAny* a2) sl@0: { sl@0: // Decode the message type and dispatch it to the relevent handler function... sl@0: // only using synchronous control messages sl@0: if (static_cast(aReqNo)(KMaxTInt)) sl@0: return DoControl(aReqNo,a1,a2); sl@0: return KErrNotSupported; sl@0: } sl@0: sl@0: /** sl@0: Process synchronous 'control' requests sl@0: */ sl@0: TInt DEventDD::DoControl(TInt aFunction,TAny* a1,TAny* /*a2*/) sl@0: { sl@0: TInt ret=KErrNotSupported; sl@0: sl@0: switch (aFunction) sl@0: { sl@0: case REventDD::ESendEvent: sl@0: ret=SendEvent(static_cast(a1)); sl@0: break; sl@0: default:; sl@0: } sl@0: return ret; sl@0: } sl@0: sl@0: TInt DEventDD::SendEvent(TRawEvent* aEvent) sl@0: { sl@0: TRawEvent event; sl@0: kumemget(&event,aEvent,sizeof(TRawEvent)); //fetch event from user memory sl@0: NKern::ThreadEnterCS(); sl@0: TInt err=Kern::AddEvent(event); sl@0: NKern::ThreadLeaveCS(); sl@0: return err; sl@0: }