Revision: 201021
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 11 Jun 2010 14:27:06 +0300
changeset 28 85e0c0339cc3
parent 25 48a2e0d8a4ce
child 33 883e91c086aa
Revision: 201021 Kit: 2010123
backupandrestore/backuptest/burtestserver/Group/bld.inf
group/bld.inf
group/dummy.txt
layers.sysdef.xml
localconnectivityservice/dun/atext/bwins/dunatextu.def
localconnectivityservice/dun/atext/eabi/dunatextu.def
localconnectivityservice/dun/atext/group/bld.inf
localconnectivityservice/dun/atext/group/dunatext.mmp
localconnectivityservice/dun/atext/inc/DunAtCmdEchoer.h
localconnectivityservice/dun/atext/inc/DunAtCmdHandler.h
localconnectivityservice/dun/atext/inc/DunAtCmdPusher.h
localconnectivityservice/dun/atext/inc/DunAtEcomListen.h
localconnectivityservice/dun/atext/inc/DunAtModeListen.h
localconnectivityservice/dun/atext/inc/DunAtNvramListen.h
localconnectivityservice/dun/atext/inc/DunAtSpecialCmdHandler.h
localconnectivityservice/dun/atext/inc/DunAtUrcHandler.h
localconnectivityservice/dun/atext/src/DunAtCmdEchoer.cpp
localconnectivityservice/dun/atext/src/DunAtCmdHandler.cpp
localconnectivityservice/dun/atext/src/DunAtCmdPusher.cpp
localconnectivityservice/dun/atext/src/DunAtEcomListen.cpp
localconnectivityservice/dun/atext/src/DunAtModeListen.cpp
localconnectivityservice/dun/atext/src/DunAtNvramListen.cpp
localconnectivityservice/dun/atext/src/DunAtSpecialCmdHandler.cpp
localconnectivityservice/dun/atext/src/DunAtUrcHandler.cpp
localconnectivityservice/dun/client/group/bld.inf
localconnectivityservice/dun/client/group/dunclient.mmp
localconnectivityservice/dun/client/inc/dunactive.h
localconnectivityservice/dun/client/inc/dunclient.h
localconnectivityservice/dun/client/inc/dunplugin.h
localconnectivityservice/dun/client/inc/dunserverdef.h
localconnectivityservice/dun/client/src/0x20002775.rss
localconnectivityservice/dun/client/src/dunactive.cpp
localconnectivityservice/dun/client/src/dunclient.cpp
localconnectivityservice/dun/client/src/dunplugin.cpp
localconnectivityservice/dun/client/src/proxy.cpp
localconnectivityservice/dun/group/bld.inf
localconnectivityservice/dun/group/dun.mrp
localconnectivityservice/dun/plugins/bwins/dunbtu.def
localconnectivityservice/dun/plugins/bwins/duniru.def
localconnectivityservice/dun/plugins/bwins/dunusbu.def
localconnectivityservice/dun/plugins/eabi/dunbtu.def
localconnectivityservice/dun/plugins/eabi/duniru.def
localconnectivityservice/dun/plugins/eabi/dunusbu.def
localconnectivityservice/dun/plugins/group/bld.inf
localconnectivityservice/dun/plugins/group/dunbt.mmp
localconnectivityservice/dun/plugins/group/dunir.mmp
localconnectivityservice/dun/plugins/group/dunusb.mmp
localconnectivityservice/dun/plugins/inc/bt/DunBtListen.h
localconnectivityservice/dun/plugins/inc/bt/DunBtPlugin.h
localconnectivityservice/dun/plugins/inc/ir/DunIrPlugin.h
localconnectivityservice/dun/plugins/inc/usb/DunUsbConfig.h
localconnectivityservice/dun/plugins/inc/usb/DunUsbListen.h
localconnectivityservice/dun/plugins/inc/usb/DunUsbPlugin.h
localconnectivityservice/dun/plugins/src/bt/DunBtListen.cpp
localconnectivityservice/dun/plugins/src/bt/DunBtPlugin.cpp
localconnectivityservice/dun/plugins/src/ir/DunIrPlugin.cpp
localconnectivityservice/dun/plugins/src/usb/DunUsbConfig.cpp
localconnectivityservice/dun/plugins/src/usb/DunUsbListen.cpp
localconnectivityservice/dun/plugins/src/usb/DunUsbPlugin.cpp
localconnectivityservice/dun/rom/dunatext.iby
localconnectivityservice/dun/rom/dunbt.iby
localconnectivityservice/dun/rom/dunclient.iby
localconnectivityservice/dun/rom/dunir.iby
localconnectivityservice/dun/rom/dunresources.iby
localconnectivityservice/dun/rom/dunserver.iby
localconnectivityservice/dun/rom/dunusb.iby
localconnectivityservice/dun/rom/dunutils.iby
localconnectivityservice/dun/server/group/bld.inf
localconnectivityservice/dun/server/group/dunserver.mmp
localconnectivityservice/dun/server/inc/DunCloseWait.h
localconnectivityservice/dun/server/inc/DunServer.h
localconnectivityservice/dun/server/inc/DunServerSecurityPolicy.h
localconnectivityservice/dun/server/inc/DunServerUtils.h
localconnectivityservice/dun/server/inc/DunSession.h
localconnectivityservice/dun/server/inc/dunserverdef.h
localconnectivityservice/dun/server/src/DunCloseWait.cpp
localconnectivityservice/dun/server/src/DunServer.cpp
localconnectivityservice/dun/server/src/DunServerUtils.cpp
localconnectivityservice/dun/server/src/DunSession.cpp
localconnectivityservice/dun/utils/bwins/dunutilsu.def
localconnectivityservice/dun/utils/data/dunutils.rss
localconnectivityservice/dun/utils/eabi/dunutilsu.def
localconnectivityservice/dun/utils/group/bld.inf
localconnectivityservice/dun/utils/group/dunutils.mmp
localconnectivityservice/dun/utils/inc/DunChanMan.h
localconnectivityservice/dun/utils/inc/DunDataPusher.h
localconnectivityservice/dun/utils/inc/DunDataWaiter.h
localconnectivityservice/dun/utils/inc/DunDebug.h
localconnectivityservice/dun/utils/inc/DunDownstream.h
localconnectivityservice/dun/utils/inc/DunNetDataport.h
localconnectivityservice/dun/utils/inc/DunNoteHandler.h
localconnectivityservice/dun/utils/inc/DunPlugin.h
localconnectivityservice/dun/utils/inc/DunSignalCopy.h
localconnectivityservice/dun/utils/inc/DunSignalNotify.h
localconnectivityservice/dun/utils/inc/DunSignalWaiter.h
localconnectivityservice/dun/utils/inc/DunStream.h
localconnectivityservice/dun/utils/inc/DunTransUtils.h
localconnectivityservice/dun/utils/inc/DunTransporter.h
localconnectivityservice/dun/utils/inc/DunUpstream.h
localconnectivityservice/dun/utils/inc/DunUtils.h
localconnectivityservice/dun/utils/loc/dunutils.loc
localconnectivityservice/dun/utils/src/DunChanMan.cpp
localconnectivityservice/dun/utils/src/DunDataPusher.cpp
localconnectivityservice/dun/utils/src/DunDataWaiter.cpp
localconnectivityservice/dun/utils/src/DunDownstream.cpp
localconnectivityservice/dun/utils/src/DunNetDataport.cpp
localconnectivityservice/dun/utils/src/DunNoteHandler.cpp
localconnectivityservice/dun/utils/src/DunSignalCopy.cpp
localconnectivityservice/dun/utils/src/DunSignalNotify.cpp
localconnectivityservice/dun/utils/src/DunSignalWaiter.cpp
localconnectivityservice/dun/utils/src/DunStream.cpp
localconnectivityservice/dun/utils/src/DunTransUtils.cpp
localconnectivityservice/dun/utils/src/DunTransporter.cpp
localconnectivityservice/dun/utils/src/DunUpstream.cpp
localconnectivityservice/dun/utils/src/DunUtils.cpp
localconnectivityservice/generichid/bwins/generichidu.def
localconnectivityservice/generichid/eabi/generichidu.def
localconnectivityservice/generichid/group/bld.inf
localconnectivityservice/generichid/group/generichid.mmp
localconnectivityservice/generichid/group/generichid.mrp
localconnectivityservice/generichid/inc/debug.h
localconnectivityservice/generichid/inc/debugconfig.h
localconnectivityservice/generichid/inc/hidconnectioninfo.h
localconnectivityservice/generichid/inc/hiddriveritem.h
localconnectivityservice/generichid/inc/hiditem.h
localconnectivityservice/generichid/inc/hidparser.h
localconnectivityservice/generichid/inc/hidreportgenerator.h
localconnectivityservice/generichid/inc/hiduids.h
localconnectivityservice/generichid/inc/prjconfig.h
localconnectivityservice/generichid/rom/generichid.iby
localconnectivityservice/generichid/src/hidcollection.cpp
localconnectivityservice/generichid/src/hidconnectioninfo.cpp
localconnectivityservice/generichid/src/hiddriveritem.cpp
localconnectivityservice/generichid/src/hidfield.cpp
localconnectivityservice/generichid/src/hidgeneric.cpp
localconnectivityservice/generichid/src/hidinterfaces.cpp
localconnectivityservice/generichid/src/hiditem.cpp
localconnectivityservice/generichid/src/hidparser.cpp
localconnectivityservice/generichid/src/hidreportbase.cpp
localconnectivityservice/generichid/src/hidreportgenerator.cpp
localconnectivityservice/generichid/src/hidreportroot.cpp
localconnectivityservice/generichid/src/hidreporttranslator.cpp
localconnectivityservice/generichid/src/hidsearch.cpp
localconnectivityservice/generichid/tsrc/GenericHidTest/Bmarm/GenericHidTestU.DEF
localconnectivityservice/generichid/tsrc/GenericHidTest/Bwins/GenericHidTestU.DEF
localconnectivityservice/generichid/tsrc/GenericHidTest/conf/GenericHidTest.cfg
localconnectivityservice/generichid/tsrc/GenericHidTest/data/E000B181.rss
localconnectivityservice/generichid/tsrc/GenericHidTest/data/UsagePoC.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkdesignatorminandmax.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkdesignatorminandmax2.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkdesignatorminandmax3.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkfieldbitneeded.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkforcollectionerrors.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkforfielderrors.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkforfielderrors2.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkformainerrors.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkformainerrors2.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkformainerrors3.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/checklogicalminandmax.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkmandatoryfieldexistence.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkmandatoryfieldexistence2.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkmandatoryfieldexistence3.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkparseerrors.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkparseerrors2.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkparseerrors3.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkstringminandmax.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkstringminandmax2.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkstringminandmax3.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkusageminandmax.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkusageminandmax2.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkusageminandmax3.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/connectad83.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/delimiter.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/designator.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/designatorindex.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/dummyconnect.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/empty.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/feature.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/feature1.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/globaitem_unknown.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/globalphysicalmax.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/globalphysicalmin.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/globalpop.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/globalpop_withoutpush.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/globalpush.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/globalunit.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/globalunit_smallvalue.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/globalunitexponent.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/globalunitexponent2.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/handleitem_withindelimiter.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/headsetcon2.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/headsetconnect.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/headsetvolumeup.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/headsetvolumeupm.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/hook.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/hookconnect.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/inputdata.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/localdelimiter.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/localdelimiter_lonelydelimiter.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/localdelimiter_nesteddelimiter.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/localdesignatorindex.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/localdesignatormaximum.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/localdesignatorminimum.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/localitem_unknown.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/localstringindex.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/localstringmaximum.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/localstringminimum.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/localusage.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/localusagemaximum.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/localusageminimum.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/longitem.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/mainfeature.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/mainitem_unknown.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/mainoutputtag.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/multipagec.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/multipagein.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/multiple_usage_page_connect.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/mute.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/next.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/output.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/output1.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/physicalmax.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/play.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/pop.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/prev.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/push.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/stop.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/string.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/stringindex.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/unit.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/unitexponent.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/voldown.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/data/volup.hid
localconnectivityservice/generichid/tsrc/GenericHidTest/eabi/GenericHidTestU.def
localconnectivityservice/generichid/tsrc/GenericHidTest/group/CHidDriverPlugin.mmp
localconnectivityservice/generichid/tsrc/GenericHidTest/group/GenericHidTest.mmp
localconnectivityservice/generichid/tsrc/GenericHidTest/group/GenericHidTest_ats.pkg
localconnectivityservice/generichid/tsrc/GenericHidTest/group/GenericHidTest_exe.mmp
localconnectivityservice/generichid/tsrc/GenericHidTest/group/GenericHidTest_phone.pkg
localconnectivityservice/generichid/tsrc/GenericHidTest/group/bld.inf
localconnectivityservice/generichid/tsrc/GenericHidTest/group/build_sis_ats.bat
localconnectivityservice/generichid/tsrc/GenericHidTest/group/build_sis_phone.bat
localconnectivityservice/generichid/tsrc/GenericHidTest/inc/CHidDriverPlugin.h
localconnectivityservice/generichid/tsrc/GenericHidTest/inc/GenericHidTest.h
localconnectivityservice/generichid/tsrc/GenericHidTest/inc/alarmcontrol.h
localconnectivityservice/generichid/tsrc/GenericHidTest/inc/hidreports.h
localconnectivityservice/generichid/tsrc/GenericHidTest/inc/tdialclient.h
localconnectivityservice/generichid/tsrc/GenericHidTest/inc/tgenerichidapi.h
localconnectivityservice/generichid/tsrc/GenericHidTest/inc/timer.h
localconnectivityservice/generichid/tsrc/GenericHidTest/init/GenericHidTest_ats.ini
localconnectivityservice/generichid/tsrc/GenericHidTest/init/GenericHidTest_phone.ini
localconnectivityservice/generichid/tsrc/GenericHidTest/src/CHidDriverPlugin.cpp
localconnectivityservice/generichid/tsrc/GenericHidTest/src/CHidDriverPluginProxy.cpp
localconnectivityservice/generichid/tsrc/GenericHidTest/src/GenericHidTest.cpp
localconnectivityservice/generichid/tsrc/GenericHidTest/src/GenericHidTestBlocks.cpp
localconnectivityservice/generichid/tsrc/GenericHidTest/src/GenericHidTest_exe.cpp
localconnectivityservice/generichid/tsrc/GenericHidTest/src/alarmcontrol.cpp
localconnectivityservice/generichid/tsrc/GenericHidTest/src/tdialclient.cpp
localconnectivityservice/generichid/tsrc/GenericHidTest/src/tgenerichidapi.cpp
localconnectivityservice/generichid/tsrc/GenericHidTest/src/timer.cpp
localconnectivityservice/group/bld.inf
localconnectivityservice/headset/data/hidheadset.rss
localconnectivityservice/headset/group/bld.inf
localconnectivityservice/headset/group/headset.mrp
localconnectivityservice/headset/group/hidheadset.mmp
localconnectivityservice/headset/hidremconbearer/data/hidremconbearer.rss
localconnectivityservice/headset/hidremconbearer/group/bld.inf
localconnectivityservice/headset/hidremconbearer/group/hidremconbearer.mmp
localconnectivityservice/headset/hidremconbearer/inc/debug.h
localconnectivityservice/headset/hidremconbearer/inc/debugconfig.h
localconnectivityservice/headset/hidremconbearer/inc/hidremconbearerimplementation.h
localconnectivityservice/headset/hidremconbearer/inc/hidremconbearerinternalpskeys.h
localconnectivityservice/headset/hidremconbearer/inc/hidremconbearerobserver.h
localconnectivityservice/headset/hidremconbearer/inc/hidremconbearerscancodes.h
localconnectivityservice/headset/hidremconbearer/inc/prjconfig.h
localconnectivityservice/headset/hidremconbearer/src/hidremconbearerimplementation.cpp
localconnectivityservice/headset/hidremconbearer/src/hidremconbearermain.cpp
localconnectivityservice/headset/hidremconbearer/src/hidremconbearerobserver.cpp
localconnectivityservice/headset/inc/debug.h
localconnectivityservice/headset/inc/debugconfig.h
localconnectivityservice/headset/inc/finder.h
localconnectivityservice/headset/inc/headset.h
localconnectivityservice/headset/inc/headsetuids.h
localconnectivityservice/headset/inc/keypresstimer.h
localconnectivityservice/headset/inc/prjconfig.h
localconnectivityservice/headset/rom/hidheadset.iby
localconnectivityservice/headset/src/finder.cpp
localconnectivityservice/headset/src/headset.cpp
localconnectivityservice/headset/src/hidheadsetdriverproxy.cpp
localconnectivityservice/headset/src/keypresstimer.cpp
localconnectivityservice/locod/commoninc/locodbearer.h
localconnectivityservice/locod/commoninc/locodbearerplugin.h
localconnectivityservice/locod/commoninc/locodbearerplugin.inl
localconnectivityservice/locod/commoninc/locodbearerpluginobserver.h
localconnectivityservice/locod/commoninc/locodbearerpluginparams.h
localconnectivityservice/locod/commoninc/locodbearerpluginparams.inl
localconnectivityservice/locod/commoninc/locodplugin.hrh
localconnectivityservice/locod/commoninc/locodserviceplugin.h
localconnectivityservice/locod/commoninc/locodserviceplugin.inl
localconnectivityservice/locod/commoninc/locodservicepluginobserver.h
localconnectivityservice/locod/commoninc/locodservicepluginparams.h
localconnectivityservice/locod/commoninc/locodservicepluginparams.inl
localconnectivityservice/locod/group/bld.inf
localconnectivityservice/locod/group/locod.mmp
localconnectivityservice/locod/group/locod.mrp
localconnectivityservice/locod/inc/debug.h
localconnectivityservice/locod/inc/debugconfig.h
localconnectivityservice/locod/inc/locodaemon.h
localconnectivityservice/locod/inc/locodservice.h
localconnectivityservice/locod/inc/locodserviceman.h
localconnectivityservice/locod/inc/prjconfig.h
localconnectivityservice/locod/inc/utils.h
localconnectivityservice/locod/rom/locod.iby
localconnectivityservice/locod/src/locodaemon.cpp
localconnectivityservice/locod/src/locodmain.cpp
localconnectivityservice/locod/src/locodservice.cpp
localconnectivityservice/locod/src/locodserviceman.cpp
localconnectivityservice/locod/src/utils.cpp
mtpdataproviders/mtpimagedp/group/bld.inf
mtpdataproviders/mtpimagedp/src/cmtpimagedp.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpsendobjectinfo.cpp
mtpdataproviders/mtppictbridgedp/pictbridgeengine/BWINS/pictbridgeU.DEF
mtpdataproviders/mtppictbridgedp/pictbridgeengine/eabi/pictbridgeU.DEF
mtpdataproviders/mtppictbridgedp/pictbridgeengine/group/bld.inf
mtpdataproviders/mtppictbridgedp/pictbridgeengine/group/pictbridge.mmp
mtpdataproviders/mtppictbridgedp/pictbridgeengine/group/pictbridgeengine.mrp
mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dps.rh
mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsconnectnotifier.h
mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsconst.h
mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsdefs.h
mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsfile.h
mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsfile.inl
mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsoperation.h
mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsoperation.inl
mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsparam.h
mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsparam.inl
mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsptpnotifier.h
mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsscriptreceiver.h
mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsscriptsender.h
mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsstate.h
mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsstatemachine.h
mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsstatemachine.inl
mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpstransaction.h
mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpstransaction.inl
mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsusbnotifier.h
mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsxmlgenerator.h
mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsxmlparser.h
mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsxmlparser.inl
mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsxmlstring.h
mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/pictbridge.h
mtpdataproviders/mtppictbridgedp/pictbridgeengine/rom/pictbridge.iby
mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dps.rss
mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsconnectnotifier.cpp
mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsfile.cpp
mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsoperation.cpp
mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsparam.cpp
mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsptpnotifier.cpp
mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsscriptreceiver.cpp
mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsscriptsender.cpp
mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsstate.cpp
mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsstatemachine.cpp
mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpstransaction.cpp
mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsusbnotifier.cpp
mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsxmlgenerator.cpp
mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsxmlparser.cpp
mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsxmlstring.cpp
mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/pictbridge.cpp
mtpfws/mtpfw/common/inc/mtpdatacapture.h
mtpfws/mtpfw/common/inc/uiklafinternalcrkeys.h
mtpfws/mtpfw/daemon/client/src/rmtpclient.cpp
mtpfws/mtpfw/daemon/server/group/mtpserver.mmp
mtpfws/mtpfw/dataproviders/devdp/group/bld.inf
mtpfws/mtpfw/dataproviders/devdp/inc/cmtpdevicedatastore.h
mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevicedatastore.cpp
mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetdeviceinfo.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpfsenumerator.cpp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpsendobjectinfo.cpp
mtpfws/mtpfw/datatypes/group/mtpdatatypes.mmp
mtpfws/mtpfw/datatypes/interface/cmtptypefile.h
mtpfws/mtpfw/datatypes/src/cmtptypefile.cpp
mtpfws/mtpfw/group/bld.inf
mtpfws/mtpfw/inc/cmtpconnectionmgr.h
mtpfws/mtpfw/inc/mtpframeworkconst.h
mtpfws/mtpfw/src/cmtpconnectionmgr.cpp
mtpfws/mtpfw/src/cmtpdataprovider.cpp
mtpfws/mtpfw/src/cmtpobjectstore.cpp
mtpfws/mtpfw/src/cmtpstoragemgr.cpp
mtptransports/mtpcontroller/group/bld.inf
mtptransports/mtpptpiptransport/ptpipdatatypes/group/bld.inf
mtptransports/mtpptpiptransport/ptpipplugin/group/bld.inf
mtptransports/mtpusbtransport/usbsic_cc/group/bld.inf
mtptransports/mtpusbtransport/usbsic_imp/group/bld.inf
mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbconnection.cpp
mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepbase.cpp
remoteconn_plat/dialup_connection_status_api/dialup_connection_status_api.metaxml
remoteconn_plat/dialup_connection_status_api/group/bld.inf
remoteconn_plat/dialup_connection_status_api/group/dialup_connection_status_api.mrp
remoteconn_plat/dialup_connection_status_api/inc/dundomainpskeys.h
remoteconn_plat/dun_secondary_display_notification_api/dun_secondary_display_notification_api.metaxml
remoteconn_plat/dun_secondary_display_notification_api/group/bld.inf
remoteconn_plat/dun_secondary_display_notification_api/group/dun_secondary_display_notification_api.mrp
remoteconn_plat/dun_secondary_display_notification_api/inc/secondarydisplay/dunsecondarydisplayapi.h
remoteconn_plat/generic_hid_api/group/bld.inf
remoteconn_plat/generic_hid_api/group/generic_hid_api.mrp
remoteconn_plat/generic_hid_api/inc/hidcollection.h
remoteconn_plat/generic_hid_api/inc/hidfield.h
remoteconn_plat/generic_hid_api/inc/hidgeneric.h
remoteconn_plat/generic_hid_api/inc/hidinterfaces.h
remoteconn_plat/generic_hid_api/inc/hidreportroot.h
remoteconn_plat/generic_hid_api/inc/hidtranslate.h
remoteconn_plat/generic_hid_api/inc/hidvalues.h
remoteconn_plat/group/bld.inf
remoteconn_plat/locod_bearer_plugin_api/group/bld.inf
remoteconn_plat/locod_bearer_plugin_api/group/locod_bearer_plugin_api.mrp
remoteconn_plat/locod_bearer_plugin_api/inc/locodbearer.h
remoteconn_plat/locod_bearer_plugin_api/inc/locodbearerplugin.h
remoteconn_plat/locod_bearer_plugin_api/inc/locodbearerplugin.inl
remoteconn_plat/locod_bearer_plugin_api/inc/locodbearerpluginobserver.h
remoteconn_plat/locod_bearer_plugin_api/inc/locodbearerpluginparams.h
remoteconn_plat/locod_bearer_plugin_api/inc/locodbearerpluginparams.inl
remoteconn_plat/locod_bearer_plugin_api/inc/locodplugin.hrh
remoteconn_plat/locod_service_plugin_api/group/bld.inf
remoteconn_plat/locod_service_plugin_api/group/locod_service_plugin_api.mrp
remoteconn_plat/locod_service_plugin_api/inc/locodserviceplugin.h
remoteconn_plat/locod_service_plugin_api/inc/locodserviceplugin.inl
remoteconn_plat/locod_service_plugin_api/inc/locodservicepluginobserver.h
remoteconn_plat/locod_service_plugin_api/inc/locodservicepluginparams.h
remoteconn_plat/locod_service_plugin_api/inc/locodservicepluginparams.inl
sysdef_1_5_1.dtd
--- a/backupandrestore/backuptest/burtestserver/Group/bld.inf	Thu May 27 13:42:43 2010 +0300
+++ b/backupandrestore/backuptest/burtestserver/Group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -40,9 +40,6 @@
 ../testscripts/test_restorepackage.script       z:/testdata/scripts/sbetestdata/test_restorepackage.script
 ../testscripts/test_increament.script           z:/testdata/scripts/sbetestdata/test_increament.script
 
-../testscripts/sbeconfig.xml                /epoc32/release/winscw/udeb/z/private/10202d56/sbeconfig.xml
-../testscripts/sbeconfig.xml                /epoc32/release/winscw/urel/z/private/10202d56/sbeconfig.xml
-
 PRJ_TESTMMPFILES
     burtestserver.mmp
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+// Local Connectivity Service Component
+#include "../remoteconn_plat/group/bld.inf"
+#include "../localconnectivityservice/group/bld.inf"
+
+// MTP Component
+#include "../mtpdataproviders/mtppictbridgedp/pictbridgeengine/group/bld.inf"
+#include "../mtpfws/mtpfw/group/bld.inf"
+#include "../mtpdataproviders/mtpfileandfolderdp/group/bld.inf"
+#include "../mtpdataproviders/mtpwmpextndp/group/bld.inf"
+#include "../mtptransports/mtpusbtransport/group/bld.inf"
+#include "../mtpfws/mtpfw/dataproviders/devdp/devdpextn/group/bld.inf"
+#include "../mtptransports/mtpptpiptransport/group/bld.inf"
+#include "../mtptransports/mtpbttransport/group/bld.inf"
+#include "../mtpdataproviders/mtpmetadatadp/group/bld.inf"
+#include "../mtpdataproviders/mtpstatusdp/group/bld.inf"
+#include "../mtpdataproviders/mtppictbridgedp/group/bld.inf"
+#include "../mtpdataproviders/mtpimagedp/group/bld.inf"
+
+#ifdef FF_MTP_CONTROLLER
+#include        "../mtptransports/mtpcontroller/group/bld.inf"
+#endif//FF_MTP_CONTROLLER
+
+// SBE Component
+#include "../backupandrestore/backupengine/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/group/dummy.txt	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,3 @@
+test1.
+
+test2.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/layers.sysdef.xml	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,82 @@
+<?xml version="1.0"?>
+<!DOCTYPE SystemDefinition SYSTEM "sysdef_1_5_1.dtd" [
+  <!ENTITY layer_real_source_path "sf/mw/remoteconn" >
+]>
+
+<SystemDefinition name="Remoteconn" schema="1.5.1">
+  <systemModel>
+    <layer name="mw_layer">
+      	<module name="localconnectivityservice">
+         <unit unitID="lcdo.localconnectivityservice" mrp="" bldFile="&layer_real_source_path;/localconnectivityservice/group" name="localconnectivityservice" />
+      	</module>
+      	<module name="dialup_connection_service_api">
+         <unit unitID="lcdo.localconnectivityservice.dialup_connection_status_api" mrp="" bldFile="&layer_real_source_path;/remoteconn_plat/dialup_connection_status_api/group" name="dialup_connection_status_api"/>
+      	</module>
+	<module name="dun_secondary_display_notification_api">
+         <unit unitID="lcdo.localconnectivityservice.dun_secondary_display_notification_api" mrp="" bldFile="&layer_real_source_path;/remoteconn_plat/dun_secondary_display_notification_api/group" name="dun_secondary_display_notification_api"/>
+      	</module>
+	<module name="generic_hid_api">
+         <unit unitID="lcdo.localconnectivityservice.generic_hid_api" mrp="" bldFile="&layer_real_source_path;/remoteconn_plat/generic_hid_api/group" name="generic_hid_api"/>
+      	</module>
+	<module name="locod_bearer_plugin_api">
+         <unit unitID="lcdo.localconnectivityservice.locod_bearer_plugin_api" mrp="" bldFile="&layer_real_source_path;/remoteconn_plat/locod_bearer_plugin_api/group" name="locod_bearer_plugin_api"/>
+      	</module>
+	<module name="locod_service_plugin_api">
+         <unit unitID="lcdo.localconnectivityservice.locod_service_plugin_api" mrp="" bldFile="&layer_real_source_path;/remoteconn_plat/locod_service_plugin_api/group" name="locod_service_plugin_api"/>
+      	</module>
+	<module name="mtppictbridgedp">
+      	<unit unitID="lcdo.localconnectivityservice.mtppictbridgeengine" mrp="" bldFile="&layer_real_source_path;/mtpdataproviders/mtppictbridgedp/pictbridgeengine/group" name="mtppictbridgeengine"/>
+      	</module>
+		
+	        <module name="MTP Framework">
+				<unit name="MTP_Framework" unitID="smw.mtpfws.mtpfw" bldFile="sf\mw\remoteconn\mtpfws\mtpfw\group" mrp="sf\mw\remoteconn\mtpfws\mtpfw\group\mtp_framework.mrp"/>
+			</module>
+
+			<module name="MTP File and Folder Provider">
+				<unit name="MTP_File_Folder" unitID="smw.mtpdps.mtpfilefolder" bldFile="sf\mw\remoteconn\mtpdataproviders\mtpfileandfolderdp\group" mrp="sf\mw\remoteconn\mtpdataproviders\mtpfileandfolderdp\group\mtp_filedp.mrp"/>
+			</module>
+
+			<module name="WMP Extension Data Provider">
+				<unit name="MTP_ExtDP" unitID="smw.mtpdps.mtpextdp" bldFile="sf\mw\remoteconn\mtpdataproviders\mtpwmpextndp\group" mrp="sf\mw\remoteconn\mtpdataproviders\mtpwmpextndp\group\mtp_wmpextndp.mrp"/>
+			</module>
+		  
+			<module name="MTP USB Transport">
+				<unit name="MTP_Usb" unitID="smw.mtptsp.mtpusbtsp" bldFile="sf\mw\remoteconn\mtptransports\mtpusbtransport\group" mrp="sf\mw\remoteconn\mtptransports\mtpusbtransport\group\mtp_usbsic.mrp"/>
+			</module>
+
+			<module name="MTP Device Provider Extension">
+				<unit name="MTP_DPExt" unitID="smw.mtpfws.devdp" bldFile="sf\mw\remoteconn\mtpfws\mtpfw\dataproviders\devdp\devdpextn\group" mrp=""/>
+			</module>
+
+			<module name="MTP PTP-IP Transport">
+				<unit name="MTP_PTP_IP" unitID="smw.mtptsp.mtpptpip" bldFile="sf\mw\remoteconn\mtptransports\mtpptpiptransport\group" mrp="sf\mw\remoteconn\mtptransports\mtpptpiptransport\group\mtp_ptpip.mrp"/>
+			</module>
+
+			<module name="MTP Bluetooth Transport">
+				<unit name="MTP_Bt_Tsp" unitID="smw.mtptsp.mtpbt" bldFile="sf\mw\remoteconn\mtptransports\mtpbttransport\group" mrp="sf\mw\remoteconn\mtptransports\mtpbttransport\group\mtp_bt.mrp"/>
+			</module>
+
+			<module name="MTP Device Metadata Data Provider">
+				<unit name="MTP_MetaDP" unitID="smw.mtpdps.mtpmetadp" bldFile="sf\mw\remoteconn\mtpdataproviders\mtpmetadatadp\group" mrp="sf\mw\remoteconn\mtpdataproviders\mtpmetadatadp\group\mtp_metadatadp.mrp"/>
+			</module>
+
+			<module name="MTP Status Data Provider">
+				<unit name="MTP_StatDP" unitID="smw.mtpdps.mtpstatdp" bldFile="sf\mw\remoteconn\mtpdataproviders\mtpstatusdp\group" mrp="sf\mw\remoteconn\mtpdataproviders\mtpstatusdp\group\mtp_statusdp.mrp"/>
+			</module>
+
+			<module name="MTP PictBridge Data Provider">
+				<unit name="MTP_Pic_Bri" unitID="smw.mtpdps.mtppicbri" bldFile="sf\mw\remoteconn\mtpdataproviders\mtppictbridgedp\group" mrp="sf\mw\remoteconn\mtpdataproviders\mtppictbridgedp\group\mtp_pictbridgedp.mrp"/>
+			</module>
+
+			<module name="MTP Image Data Provider">
+				<unit name="MTP_ImageDP" unitID="smw.mtptsp.mtpimagedp" bldFile="sf\mw\remoteconn\mtpdataproviders\mtpimagedp\group" mrp="sf\mw\remoteconn\mtpdataproviders\mtpimagedp\group\mtp_imagedp.mrp"/>
+			</module>
+			
+			<module name="Backup Engine">
+				<unit name="backupengine" unitID="smw.br.backupengine" bldFile="sf\mw\remoteconn\backupandrestore\backupengine\group" mrp="sf\mw\remoteconn\backupandrestore\backupengine\group\connectivity_backupengine.mrp"/>
+			</module>
+
+			
+    </layer>
+  </systemModel>
+</SystemDefinition>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/atext/bwins/dunatextu.def	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,12 @@
+EXPORTS
+	?StopUrc@CDunAtCmdHandler@@QAEHXZ @ 1 NONAME ; int CDunAtCmdHandler::StopUrc(void)
+	?Stop@CDunAtCmdHandler@@QAEHXZ @ 2 NONAME ; int CDunAtCmdHandler::Stop(void)
+	?SetEndOfCmdLine@CDunAtCmdHandler@@QAEXH@Z @ 3 NONAME ; void CDunAtCmdHandler::SetEndOfCmdLine(int)
+	?ResetData@CDunAtCmdHandler@@QAEXXZ @ 4 NONAME ; void CDunAtCmdHandler::ResetData(void)
+	?AddCmdModeCallback@CDunAtCmdHandler@@QAEHPAVMDunCmdModeMonitor@@@Z @ 5 NONAME ; int CDunAtCmdHandler::AddCmdModeCallback(class MDunCmdModeMonitor *)
+	?NewL@CDunAtCmdHandler@@SAPAV1@PAVMDunAtCmdStatusReporter@@PAVMDunStreamManipulator@@PBVTDesC8@@@Z @ 6 NONAME ; class CDunAtCmdHandler * CDunAtCmdHandler::NewL(class MDunAtCmdStatusReporter *, class MDunStreamManipulator *, class TDesC8 const *)
+	?ParseCommand@CDunAtCmdHandler@@QAEHAAVTDesC8@@AAH@Z @ 7 NONAME ; int CDunAtCmdHandler::ParseCommand(class TDesC8 &, int &)
+	?StartUrc@CDunAtCmdHandler@@QAEHXZ @ 8 NONAME ; int CDunAtCmdHandler::StartUrc(void)
+	?ManageAbortRequest@CDunAtCmdHandler@@QAEHXZ @ 9 NONAME ; int CDunAtCmdHandler::ManageAbortRequest(void)
+	?SendEchoCharacter@CDunAtCmdHandler@@QAEHPBVTDesC8@@PAVMDunAtCmdEchoer@@@Z @ 10 NONAME ; int CDunAtCmdHandler::SendEchoCharacter(class TDesC8 const *, class MDunAtCmdEchoer *)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/atext/eabi/dunatextu.def	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,12 @@
+EXPORTS
+	_ZN16CDunAtCmdHandler12ParseCommandER6TDesC8Ri @ 1 NONAME
+	_ZN16CDunAtCmdHandler15SetEndOfCmdLineEi @ 2 NONAME
+	_ZN16CDunAtCmdHandler18AddCmdModeCallbackEP18MDunCmdModeMonitor @ 3 NONAME
+	_ZN16CDunAtCmdHandler4NewLEP23MDunAtCmdStatusReporterP21MDunStreamManipulatorPK6TDesC8 @ 4 NONAME
+	_ZN16CDunAtCmdHandler4StopEv @ 5 NONAME
+	_ZN16CDunAtCmdHandler7StopUrcEv @ 6 NONAME
+	_ZN16CDunAtCmdHandler8StartUrcEv @ 7 NONAME
+	_ZN16CDunAtCmdHandler9ResetDataEv @ 8 NONAME
+	_ZN16CDunAtCmdHandler18ManageAbortRequestEv @ 9 NONAME
+	_ZN16CDunAtCmdHandler17SendEchoCharacterEPK6TDesC8P15MDunAtCmdEchoer @ 10 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/atext/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*	 This file provides the information required for building the
+*    whole of DUN ATEXT
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+../../rom/dunatext.iby         CORE_MW_LAYER_IBY_EXPORT_PATH(dunatext.iby)
+
+PRJ_MMPFILES
+dunatext.mmp
+
+PRJ_TESTMMPFILES
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/atext/group/dunatext.mmp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,54 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project DUN ATEXT
+*
+*/
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET                  dunatext.dll
+TARGETTYPE              DLL
+UID                     0x1000008d 0x2001CBE6
+
+CAPABILITY              CAP_GENERAL_DLL
+VENDORID                VID_DEFAULT
+
+SOURCEPATH              ../src
+SOURCE                  DunAtCmdEchoer.cpp
+SOURCE                  DunAtCmdHandler.cpp
+SOURCE                  DunAtCmdPusher.cpp
+SOURCE                  DunAtUrcHandler.cpp
+SOURCE                  DunAtModeListen.cpp
+SOURCE                  DunAtEcomListen.cpp
+SOURCE                  DunAtNvramListen.cpp
+SOURCE                  DunAtSpecialCmdHandler.cpp
+
+USERINCLUDE             ../inc ../../utils/inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+// Note:
+// The only other SYSTEMINCLUDE should you shall add are Symbian specific ones.
+// If there is a S60 header in the subdirectory then that should be
+// added into the include statements (like #include <phonebook/header.h>)
+//SYSTEMINCLUDE           /epoc32/include/ecom
+SYSTEMINCLUDE           ../../../inc
+
+LIBRARY                 atextclient.lib
+LIBRARY                 atextcommon.lib
+LIBRARY                 euser.lib
+LIBRARY                 bafl.lib
+DEBUGLIBRARY            flogger.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/atext/inc/DunAtCmdEchoer.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,135 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Echoer for AT commands
+*
+*/
+
+#ifndef C_CDUNATCMDECHOER_H
+#define C_CDUNATCMDECHOER_H
+
+#include "DunDataPusher.h"
+
+class MDunStreamManipulator;
+
+/**
+ *  Notification interface class for text mode
+ *
+ *  @lib dunatext.lib
+ *  @since TB9.2
+ */
+NONSHARABLE_CLASS( MDunAtCmdEchoer )
+    {
+
+public:
+
+    /**
+     * Notifies about completed echo in text mode
+     *
+     * @since TB9.2
+     * @return None
+     */
+    virtual void NotifyEchoComplete() = 0;
+
+    };
+
+/**
+ *  Class for AT command echoer
+ *
+ *  @lib dunatext.lib
+ *  @since TB9.2
+ */
+NONSHARABLE_CLASS( CDunAtCmdEchoer ) : public CBase,
+                                       public MDunCompletionReporter
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aStreamCallback Callback to stream
+     * @return Instance of self
+     */
+    static CDunAtCmdEchoer* NewL( MDunStreamManipulator* aStreamCallback );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunAtCmdEchoer();
+
+    /**
+     * Resets data to initial values
+     *
+     * @since TB9.2
+     * @return None
+     */
+    void ResetData();
+
+    /**
+     * Sends a character to be echoed
+     *
+     * @since TB9.2
+     * @param aInput Input to echo
+     * @param aCallback Callback to echo request completions
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt SendEchoCharacter( const TDesC8* aInput, MDunAtCmdEchoer* aCallback );
+
+private:
+
+    CDunAtCmdEchoer( MDunStreamManipulator* aStreamCallback );
+
+    void ConstructL();
+
+    /**
+     * Initializes this class
+     *
+     * @since TB9.2
+     * @return None
+     */
+    void Initialize();
+
+// from base class MDunCompletionReporter
+
+    /**
+     * From MDunCompletionReporter.
+     * Gets called when data push is complete
+     *
+     * @since S60 5.0
+     * @param aAllPushed ETrue if all in the queue were pushed, EFalse otherwise
+     * @return None
+     */
+    void NotifyDataPushComplete( TBool aAllPushed );
+
+private:  // data
+
+    /**
+     * Notification interface class for echo request completions
+     * Not own.
+     */
+    MDunAtCmdEchoer* iCallback;
+
+    /**
+     * Callback to call when data to push
+     * Not own.
+     */
+    MDunStreamManipulator* iStreamCallback;
+
+    /**
+     * Current state of echoing: active or inactive
+     */
+    TDunState iAtEchoState;
+
+    };
+
+#endif  // C_CDUNATCMDECHOER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/atext/inc/DunAtCmdHandler.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,996 @@
+/*
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  AT command handler and notifier
+*
+*/
+
+#ifndef C_CDUNATCMDHANDLER_H
+#define C_CDUNATCMDHANDLER_H
+
+#include <atext.h>
+#include <e32base.h>
+#include <atextcommon.h>
+#include "DunDataPusher.h"
+#include "DunAtCmdPusher.h"
+#include "DunAtCmdEchoer.h"
+#include "DunAtEcomListen.h"
+#include "DunAtModeListen.h"
+#include "DunAtNvramListen.h"
+#include "DunAtSpecialCmdHandler.h"
+
+const TInt KDunChSetMaxCharLen = 1;          // Only ASCII supported for now
+const TInt KDunOkBufLength     = 1+1+2+1+1;  // <CR>+<LF>+"OK"+<CR>+<LF>
+const TInt KDunErrorBufLength  = 1+1+5+1+1;  // <CR>+<LF>+"ERROR"+<CR>+<LF>
+const TInt KDunInputBufLength  = (512 + 1);  // 512 chars for command + <CR>
+const TInt KDunEscBufLength    = 1;          // Escape (0x1B) character
+
+class CDunAtUrcHandler;
+class MDunConnMon;
+class MDunStreamManipulator;
+
+/**
+ *  Class used for storing information related to string conversion and parsing
+ *
+ *  @lib dunatext.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( TDunParseInfo )
+    {
+
+public:
+
+    /**
+     * Buffer for sending
+     */
+    TBuf8<KDunInputBufLength> iSendBuffer;
+
+    /**
+     * Conversion limit for upper case conversion.
+     * This is needed to convert the base part of special commands to upper case
+     * where the part after the base part should not be converted to upper case.
+     */
+    TInt iLimit;
+
+    };
+
+/**
+ *  Class used for AT command decoding related functionality
+ *
+ *  @lib dunatext.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS( TDunDecodeInfo )
+    {
+
+public:
+
+    /**
+     * Flag to indicate if first decode
+     */
+    TBool iFirstDecode;
+
+    /**
+     * Index in iInputBuffer for decoding to iDecodeBuffer
+     */
+    TInt iDecodeIndex;
+
+    /**
+     * Index in iInputBuffer for extended character position 
+     */
+    TInt iExtendedIndex;
+
+    /**
+     * Previous character in parsing
+     */
+    TChar iPrevChar;
+
+    /**
+     * Flag to indicate if previous character exists
+     */
+    TBool iPrevExists;
+
+    /**
+     * Flag to indicate if assignment mark found
+     */
+    TBool iAssignFound;
+
+    /**
+     * Flag to indicate if processing inside quotes 
+     */
+    TBool iInQuotes;
+
+    /**
+     * Flag to indicate if special subcommand found
+     */
+    TBool iSpecialFound;
+    
+    /**
+     * Buffer for parsing
+     */
+    TBuf8<KDunInputBufLength> iDecodeBuffer;
+
+    };
+
+/**
+ *  Class used for AT command editor mode related functionality
+ *
+ *  @lib dunatext.lib
+ *  @since TB9.2
+ */
+NONSHARABLE_CLASS( TDunEditorModeInfo )
+    {
+
+public:
+
+    /**
+     * Flag to indicate if content found (not used if iContentFindStarted is EFalse)
+     */
+    TBool iContentFound;
+
+    /**
+     * AT command decoding related information for peeked data
+     * (not to be used if HandleNextDecodedCommand() returns EFalse)
+     */
+    TDunDecodeInfo iPeekInfo;
+
+    };
+
+/**
+ *  Notification interface class for command mode start/end
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS( MDunCmdModeMonitor )
+    {
+
+public:
+
+    /**
+     * Notifies about command mode start
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    virtual void NotifyCommandModeStart() = 0;
+
+    /**
+     * Notifies about command mode end
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    virtual void NotifyCommandModeEnd() = 0;
+
+    };
+
+/**
+ *  Notification interface class for status changes in AT command handling
+ *
+ *  @lib dunatext.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS( MDunAtCmdStatusReporter )
+    {
+
+public:
+
+    /**
+     * Notifies about AT command handling start
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    virtual void NotifyAtCmdHandlingStart() = 0;
+
+    /**
+     * Notifies about AT command handling end
+     *
+     * @since S60 5.0
+     * @param aEndIndex Index to the start of next command
+     * @return None
+     */
+    virtual void NotifyAtCmdHandlingEnd( TInt aStartIndex ) = 0;
+
+    /**
+     * Notifies about editor mode reply
+     *
+     * @since TB9.2
+     * @param aStart ETrue if start of editor mode, EFalse otherwise
+     * @return None
+     */
+    virtual void NotifyEditorModeReply( TBool aStart ) = 0;
+
+    };
+
+/**
+ *  Class for AT command handler and notifier
+ *
+ *  @lib dunatext.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS( CDunAtCmdHandler ) : public CBase,
+                                        public MDunAtCmdPusher,
+                                        public MDunAtEcomListen,
+                                        public MDunAtModeListen
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aUpstream Callback to upstream
+     * @param aDownstream Callback to downstream
+     * @param aConnectionName Connection identifier name
+     * @return Instance of self
+     */
+	IMPORT_C static CDunAtCmdHandler* NewL(
+	    MDunAtCmdStatusReporter* aUpstream,
+	    MDunStreamManipulator* aDownstream,
+	    const TDesC8* aConnectionName );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunAtCmdHandler();
+
+    /**
+     * Resets data to initial values
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    IMPORT_C void ResetData();
+
+    /**
+     * Adds callback for command mode notification
+     * The callback will be called when command mode starts or ends
+     *
+     * @since S60 5.0
+     * @param aCallback Callback to call when command mode starts or ends
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    IMPORT_C TInt AddCmdModeCallback( MDunCmdModeMonitor* aCallback );
+
+    /**
+     * Parses an AT command
+     *
+     * @since S60 5.0
+     * @param aCommand Command to parse
+     * @param aPartialInput ETrue if partial input, EFalse otherwise
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    IMPORT_C TInt ParseCommand( TDesC8& aCommand, TBool& aPartialInput );
+
+    /**
+     * Manages request to abort command handling
+     *
+     * @since S60 5.0
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    IMPORT_C TInt ManageAbortRequest();
+
+    /**
+     * Sets end of command line marker on for the possible series of AT
+     * commands.
+     *
+     * @since S60 5.0
+     * @param aClearInput ETrue to clear input buffer, EFalse otherwise
+     * @return None
+     */
+    IMPORT_C void SetEndOfCmdLine( TBool aClearInput );
+
+    /**
+     * Sends a character to be echoed
+     *
+     * @since TB9.2
+     * @param aInput Input to echo
+     * @param aCallback Callback to echo request completions
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    IMPORT_C TInt SendEchoCharacter( const TDesC8* aInput,
+                                     MDunAtCmdEchoer* aCallback );
+
+    /**
+     * Stops sending of AT command from decode buffer
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    IMPORT_C TInt Stop();
+
+    /**
+     * Starts URC message handling
+     *
+     * @since S60 5.0
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    IMPORT_C TInt StartUrc();
+
+    /**
+     * Stops URC message handling
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    IMPORT_C TInt StopUrc();
+
+private:
+
+    CDunAtCmdHandler( MDunAtCmdStatusReporter* aUpstream,
+                      MDunStreamManipulator* aDownstream,
+                      const TDesC8* aConnectionName );
+
+    void ConstructL();
+
+    /**
+     * Initializes this class
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void Initialize();
+
+    /**
+     * Creates plugin handlers for this class
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void CreatePluginHandlersL();
+
+    /**
+     * Creates the array of special commands
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void CreateSpecialCommandsL();
+
+    /**
+     * Recreates special command data.
+     * This is done when a plugin is installed or uninstalled.
+     *
+     * @since S60 5.0
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt RecreateSpecialCommands();
+
+    /**
+     * Gets default settings from RATExtCommon and sets them to RATExt
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void GetAndSetDefaultSettingsL();
+
+    /**
+     * Regenerates the reply strings based on settings
+     *
+     * @since S60 5.0
+     * @return ETrue if quiet mode, EFalse otherwise
+     */
+    TBool RegenerateReplyStrings();
+
+    /**
+     * Regenerates the ok reply based on settings
+     *
+     * @since S60 5.0
+     * @return ETrue if quiet mode, EFalse otherwise
+     */
+    TBool RegenerateOkReply();
+
+    /**
+     * Regenerates the error reply based on settings
+     *
+     * @since S60 5.0
+     * @return ETrue if quiet mode, EFalse otherwise
+     */
+    TBool RegenerateErrorReply();
+
+    /**
+     * Gets current mode
+     *
+     * @since S60 5.0
+     * @param aMask Mask for current mode (only one supported)
+     * @return New current mode
+     */
+    TUint GetCurrentModeL( TUint aMask );
+
+    /**
+     * Instantiates one URC message handling class instance and adds it to
+     * the URC message handler array
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    CDunAtUrcHandler* AddOneUrcHandlerL();
+
+    /**
+     * Deletes all instantiated URC message handlers
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void DeletePluginHandlers();
+
+    /**
+     * Manages partial AT command
+     *
+     * @since S60 5.0
+     * @param aCommand Command to process
+     * @param aNeedsCarriage ETrue if full and non-consumed AT command needs
+     *                       carriage return (AT command "A/")
+     * @return ETrue if no other processing needed, EFalse otherwise
+     */
+    TBool ManagePartialCommand( TDesC8& aCommand,
+                                TBool& aNeedsCarriage );
+
+    /**
+     * Echoes a command if echo is on
+     *
+     * @since S60 5.0
+     * @param aDes String descriptor
+     * @return ETrue if echo push started, EFalse otherwise
+     */
+    TBool EchoCommand( TDesC8& aDes );
+
+    /**
+     * Handles backspace and cancel characters
+     *
+     * @since S60 5.0
+     * @param aCommand Command to process
+     * @return ETrue if special character found, EFalse otherwise
+     */
+    TBool HandleSpecialCharacters( TDesC8& aCommand );
+
+    /**
+     * Appends command to input buffer
+     *
+     * @since S60 5.0
+     * @param aCommand Command to append to input buffer
+     * @param aEndFound ETrue if end (carriage return) was found
+     * @return ETrue if overflow was found, EFalse otherwise
+     */
+    TBool AppendCommandToInputBuffer( TDesC8& aCommand, TBool& aEndFound );
+
+    /**
+     * Handles next decoded command from input buffer
+     *
+     * @since S60 5.0
+     * @return ETrue if last command decoded, EFalse otherwise
+     */
+    TBool HandleNextDecodedCommand();
+
+    /**
+     * Finds the start of the next command
+     *
+     * @since TB9.2
+     * @return Index to the next command or Symbian error code on error
+     */
+    TInt FindStartOfNextCommand();
+
+    /**
+     * Manages end of AT command handling
+     *
+     * @since S60 5.0
+     * @param aNotifyExternal Notify external parties
+     * @param aNotifyLocal Notify local parties
+     * @param aClearInput ETrue to clear input buffer, EFalse otherwise
+     * @return None
+     */
+    void ManageEndOfCmdHandling( TBool aNotifyExternal,
+                                 TBool aNotifyLocal,
+                                 TBool aClearInput );
+
+    /**
+     * Extracts next decoded command from input buffer to decode buffer
+     *
+     * @since S60 5.0
+     * @param aPeek Peek for the next command if ETrue, EFalse otherwise
+     * @return ETrue if command extracted, EFalse otherwise
+     */
+    TBool ExtractNextDecodedCommand( TBool aPeek=EFalse );
+
+    /**
+     * Restores old decode info. For ExtractNextDecodedCommand() when aPeeks is
+     * ETrue.
+     *
+     * @since S60 5.0
+     * @param aPeek Peek for the next command if ETrue, EFalse otherwise
+     * @param aOldInfo Old information to restore when aPeek is ETrue
+     * @return None
+     */
+    void RestoreOldDecodeInfo( TBool aPeek, TDunDecodeInfo& aOldInfo );
+
+    /**
+     * Finds end of an AT command
+     *
+     * @since S60 5.0
+     * @param aDes String descriptor
+     * @param aStartIndex Start index for search
+     * @return Index if found, KErrNotFound otherwise
+     */
+    TInt FindEndOfCommand( TDesC8& aDes, TInt aStartIndex=0 );
+
+    /**
+     * Tests for end of AT command character
+     *
+     * @since S60 5.0
+     * @param aCharacter Character to test
+     * @return ETrue if end of command, EFalse otherwise
+     */
+    TBool IsEndOfCommand( TChar& aCharacter );
+
+    /**
+     * Finds start of a decoded AT command
+     *
+     * @since S60 5.0
+     * @param aDes String descriptor
+     * @param aStartIndex Start index for search
+     * @return Index if found, KErrNotFound otherwise
+     */
+    TInt FindStartOfDecodedCommand( TDesC8& aDes,
+                                    TInt aStartIndex );
+
+    /**
+     * Checks if character is delimiter character
+     *
+     * @since S60 5.0
+     * @param aCharacter Character to test
+     * @return ETrue if delimiter character, EFalse otherwise
+     */
+    TBool IsDelimiterCharacter( TChar aCharacter );
+
+    /**
+     * Checks if character is of extended group
+     *
+     * @since S60 5.0
+     * @param aCharacter Character to test
+     * @return ETrue if extended character, EFalse otherwise
+     */
+    TBool IsExtendedCharacter( TChar aCharacter );
+
+    /**
+     * Checks special command
+     *
+     * @since S60 5.0
+     * @param aStartIndex Start index (doesn't change)
+     * @param aEndIndex End index (changes)
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TBool CheckSpecialCommand( TInt aStartIndex,
+                               TInt& aEndIndex );
+
+    /**
+     * Saves character decode state for a found character
+     *
+     * @since TB9.2
+     * @param aCharacter Character to save a state for
+     * @param aAddSpecial ETrue to add character for special command,
+     *                    EFalse otherwise
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    void SaveFoundCharDecodeState( TChar aCharacter,
+                                   TBool aAddSpecial=ETrue );
+    
+    /**
+     * Saves character decode state for a not found character
+     *
+     * @since TB9.2
+     * @param aStartIndex Start index (doesn't change)
+     * @param aEndIndex End index (changes)
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    void SaveNotFoundCharDecodeState();
+
+    /**
+     * Find quotes within subcommands
+     *
+     * @since TB9.2
+     * @param aCharacter Character to check
+     * @param aStartIndex Start index (doesn't change)
+     * @param aEndIndex End index (changes)
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TBool FindSubCommandQuotes( TChar aCharacter, TInt aStartIndex, TInt& aEndIndex );
+
+    /**
+     * Check if in next subcommand's extended border
+     *
+     * @since TB9.2
+     * @param aCharacter Extended character to check
+     * @param aStartIndex Start index (doesn't change)
+     * @param aEndIndex End index (changes)
+     * @return ETrue if in next command's extended border, EFalse otherwise
+     */
+    TBool IsExtendedBorder( TChar aCharacter, TInt aStartIndex, TInt& aEndIndex );
+    
+    /**
+     * Finds subcommand with alphanumeric borders
+     *
+     * @since TB9.2
+     * @param aCharacter Character to check
+     * @param aEndIndex End index (changes)
+     * @return ETrue if alpha border found, EFalse otherwise
+     */
+    TBool FindSubCommandAlphaBorder( TChar aCharacter, TInt& aEndIndex );
+
+    /**
+     * Finds subcommand
+     *
+     * @since TB9.2
+     * @param aStartIndex Start index (doesn't change)
+     * @param aEndIndex End index (changes)
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt FindSubCommand( TInt aStartIndex, TInt& aEndIndex );
+
+    /**
+     * Check if "A/" command
+     *
+     * @since S60 5.0
+     * @return ETrue if "A/" command, EFalse otherwise
+     */
+    TBool IsASlashCommand();
+
+    /**
+     * Handles "A/" command
+     *
+     * @since S60 5.0
+     * @return ETrue if error reply push started, EFalse otherwise
+     */
+    TBool HandleASlashCommand();
+
+    /**
+     * Resets parse buffers
+     *
+     * @since S60 5.0
+     * @param aClearInput ETrue to clear input buffer, EFalse otherwise
+     * @return None
+     */
+    void ResetParseBuffers( TBool aClearInput=ETrue );
+
+    /**
+     * Manages command mode change
+     *
+     * @since S60 5.0
+     * @param aMode Mode to manage
+     * @return ETrue if command mode change detected, EFalse otherwise
+     */
+    TBool ManageCommandModeChange( TUint aMode );
+
+    /**
+     * Reports command mode start/end change
+     *
+     * @since S60 3.2
+     * @param aStart Command mode start if ETrue, end otherwise
+     * @return None
+     */
+    void ReportCommandModeChange( TBool aStart );
+
+    /**
+     * Manages echo mode change
+     *
+     * @since S60 5.0
+     * @param aMode Mode to manage
+     * @return ETrue if echo mode change detected, EFalse otherwise
+     */
+    TBool ManageEchoModeChange( TUint aMode );
+
+    /**
+     * Manages quiet mode change
+     *
+     * @since S60 5.0
+     * @param aMode Mode to manage
+     * @return ETrue if quiet mode change detected, EFalse otherwise
+     */
+    TBool ManageQuietModeChange( TUint aMode );
+
+    /**
+     * Manages verbose mode change
+     *
+     * @since S60 5.0
+     * @param aMode Mode to manage
+     * @return ETrue if verbose mode change detected, EFalse otherwise
+     */
+    TBool ManageVerboseModeChange( TUint aMode );
+
+    /**
+     * Manages character change
+     *
+     * @since S60 5.0
+     * @param aMode Mode to manage
+     * @return None
+     */
+    void ManageCharacterChange( TUint aMode );
+
+    /**
+     * Manages editor mode reply
+     *
+     * @since TB9.2
+     * @param aStart ETrue if start of editor mode, EFalse otherwise
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt ManageEditorModeReply( TBool aStart );
+
+    /**
+     * Finds the next content from the input buffer
+     *
+     * @since TB9.2
+     * @param aStart ETrue if start of editor mode, EFalse otherwise
+     * @return ETrue if next content found, EFalse otherwise
+     */
+    TBool FindNextContent( TBool aStart );
+
+// from base class MDunAtCmdPusher
+
+    /**
+     * From MDunAtCmdPusher.
+     * Notifies about end of AT command processing.
+     * This is after all reply data for an AT command is multiplexed to the
+     * downstream.
+     *
+     * @since S60 5.0
+     * @param aError Error code of command processing completion
+     * @return None
+     */
+    TInt NotifyEndOfProcessing( TInt aError );
+
+    /**
+     * Notifies about request to stop AT command handling for the rest of the
+     * command line data
+     *
+     * @since S60 5.0
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt NotifyEndOfCmdLineProcessing();
+
+    /**
+     * Notifies about request to peek for the next command
+     *
+     * @since S60 5.0
+     * @return ETrue if next command exists, EFalse otherwise
+     */
+    TBool NotifyNextCommandPeekRequest();
+
+    /**
+     * Notifies about editor mode reply
+     *
+     * @since TB9.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt NotifyEditorModeReply();
+
+// from base class MDunAtCmdEchoer
+
+    /**
+     * Notifies about completed echo in text mode
+     *
+     * @since TB9.2
+     * @return None
+     */
+    void NotifyEchoComplete();
+
+// from base class MDunAtEcomListen
+
+    /**
+     * From MDunAtEcomListen.
+     * Notifies about new plugin installation
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    TInt NotifyPluginInstallation( TUid& aPluginUid );
+
+    /**
+     * From MDunAtEcomListen.
+     * Notifies about existing plugin uninstallation
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    TInt NotifyPluginUninstallation( TUid& aPluginUid );
+
+// from base class MDunAtModeListen
+
+    /**
+     * From MDunAtModeListen.
+     * Gets called on mode status change
+     *
+     * @since S60 5.0
+     * @param aMode Mode to manage
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt NotifyModeStatusChange( TUint aMode );
+
+private:  // data
+
+    /**
+     * Callback to call when AT command handling status changes
+     * Not own.
+     */
+    MDunAtCmdStatusReporter* iUpstream;
+
+    /**
+     * Callback to call when data to push
+     * Not own.
+     */
+    MDunStreamManipulator* iDownstream;
+
+    /**
+     * Callback(s) to call when command mode starts or ends
+     * Usually two needed: one for upstream and second for downstream
+     */
+    RPointerArray<MDunCmdModeMonitor> iCmdCallbacks;
+
+    /**
+     * Connection identifier name
+     */
+    const TDesC8* iConnectionName;
+
+    /**
+     * Current state of AT command handling: active or inactive
+     */
+    TDunState iHandleState;
+
+    /**
+     * Character for carriage return
+     */
+    TInt8 iCarriageReturn;
+
+    /**
+     * Character for line feed
+     */
+    TInt8 iLineFeed;
+
+    /**
+     * Character for backspace
+     */
+    TInt8 iBackspace;
+
+    /**
+     * Current command to ParseCommand()
+     * Not own.
+     */
+    TDesC8* iCommand;
+
+    /**
+     * Special commands for parsing
+     */
+    RPointerArray<HBufC8> iSpecials;
+
+    /**
+     * Buffer for character echoing
+     */
+    TBuf8<KDunChSetMaxCharLen> iEchoBuffer;
+
+    /**
+     * Buffer for ok reply
+     */
+    TBuf8<KDunOkBufLength> iOkBuffer;
+
+    /**
+     * Buffer for error reply
+     */
+    TBuf8<KDunErrorBufLength> iErrorBuffer;
+
+    /**
+     * Buffer for AT command input
+     */
+    TBuf8<KDunInputBufLength> iInputBuffer;
+
+    /**
+     * Buffer for last AT command input (for "A/")
+     */
+    TBuf8<KDunInputBufLength> iLastBuffer;
+
+    /**
+     * Buffer for <ESC> command
+     */
+    TBuf8<KDunEscBufLength> iEscapeBuffer;
+
+    /**
+     * AT command decoding related information
+     */
+    TDunDecodeInfo iDecodeInfo;
+
+    /**
+     * Information for parsing
+     */
+    TDunParseInfo iParseInfo;
+
+    /**
+     * Information for editor mode
+     */
+    TDunEditorModeInfo iEditorModeInfo;
+
+    /**
+     * AT command reply pusher
+     * Own.
+     */
+    CDunAtCmdPusher* iCmdPusher;
+
+    /**
+     * AT command reply echoer
+     * Own.
+     */
+    CDunAtCmdEchoer* iCmdEchoer;
+
+    /**
+     * URC message handlers
+     * Own.
+     */
+    RPointerArray<CDunAtUrcHandler> iUrcHandlers;
+
+    /**
+     * ECOM plugin interface status change listener
+     * Own.
+     */
+    CDunAtEcomListen* iEcomListen;
+
+    /**
+     * Modem mode status change listener
+     * Own.
+     */
+    CDunAtModeListen* iModeListen;
+
+    /**
+     * NVRAM status change listener
+     * Own.
+     */
+    CDunAtNvramListen* iNvramListen;
+
+    /**
+     * Flag to mark command mode start/end
+     */
+    TBool iDataMode;
+
+    /**
+     * Flag to be set on if echo on
+     */
+    TBool iEchoOn;
+
+    /**
+     * Flag to be set on if quiet mode on
+     */
+    TBool iQuietOn;
+
+    /**
+     * Flag to be set on if verbose mode on
+     */
+    TBool iVerboseOn;
+
+    /**
+     * End index for command delimiter
+     */
+    TInt iEndIndex;
+
+    /**
+     * AT command extension
+     */
+    RATExt iAtCmdExt;
+
+    /**
+     * AT command extension to common functionality
+     */
+    RATExtCommon iAtCmdExtCommon;
+
+    /**
+     * Special AT command handler for handling commands like AT&FE0Q0V1&C1&D2+IFC=3,1.
+     */
+    CDunAtSpecialCmdHandler* iAtSpecialCmdHandler;
+    };
+
+#endif  // C_CDUNATCMDHANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/atext/inc/DunAtCmdPusher.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,372 @@
+/*
+* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  AT command pusher for downstream
+*
+*/
+
+#ifndef C_CDUNATCMDPUSHER_H
+#define C_CDUNATCMDPUSHER_H
+
+#include <atext.h>
+#include <e32base.h>
+#include "DunDataPusher.h"
+
+class MDunStreamManipulator;
+
+/**
+ *  Notification interface class for data pushing status changes
+ *
+ *  @lib dunatext.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS( MDunAtCmdPusher )
+    {
+
+public:
+
+    /**
+     * Notifies about end of AT command processing.
+     * This is after all reply data for an AT command is multiplexed to the
+     * downstream.
+     *
+     * @since S60 5.0
+     * @param aError Error code of command processing completion
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt NotifyEndOfProcessing( TInt aError ) = 0;
+
+    /**
+     * Notifies about request to stop AT command handling for the rest of the
+     * command line data
+     *
+     * @since S60 5.0
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt NotifyEndOfCmdLineProcessing() = 0;
+
+    /**
+     * Notifies about request to peek for the next command
+     *
+     * @since S60 5.0
+     * @return ETrue if next command exists, EFalse otherwise
+     */
+    virtual TBool NotifyNextCommandPeekRequest() = 0;
+
+    /**
+     * Notifies about editor mode reply
+     *
+     * @since TB9.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt NotifyEditorModeReply() = 0;
+
+    };
+
+/**
+ *  Class for AT command URC handler
+ *
+ *  @lib dunatext.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS( CDunAtCmdPusher ) : public CActive,
+                                       public MDunCompletionReporter
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aAtCmdExt Pointer to AT command extension
+     * @param aCallback Callback to AT command handler
+     * @param aDownstream Callback to downstream,
+     * @param aOkBuffer Buffer for ok reply
+     * @return Instance of self
+     */
+	static CDunAtCmdPusher* NewL( RATExt* aAtCmdExt,
+	                              MDunAtCmdPusher* aCallback,
+	                              MDunStreamManipulator* aDownstream,
+	                              TDesC8* aOkBuffer );
+
+    /**
+     * Two-phased constructor.
+     * @param aAtCmdExt Pointer to AT command extension
+     * @param aCallback Callback to AT command handler
+     * @param aDownstream Callback to downstream
+     * @param aOkBuffer Buffer for ok reply
+     * @return Instance of self
+     */
+    static CDunAtCmdPusher* NewLC( RATExt* aAtCmdExt,
+                                   MDunAtCmdPusher* aCallback,
+                                   MDunStreamManipulator* aDownstream,
+                                   TDesC8* aOkBuffer );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunAtCmdPusher();
+
+    /**
+     * Resets data to initial values
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void ResetData();
+
+    /**
+     * Starts AT command handling
+     *
+     * @since S60 5.0
+     * @param aCommand AT command or editor mode input to handle
+     * @param aNormalMode ETrue if request issue for normal mode
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt IssueRequest( TDesC8& aCommand, TBool aNormalMode=ETrue );
+
+    /**
+     * Stops AT command handling
+     *
+     * @since S60 5.0
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt Stop();
+
+    /**
+     * Manages request to abort command handling
+     *
+     * @since S60 5.0
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt ManageAbortRequest();
+
+    /**
+     * Sets end of command line marker on for the possible series of AT
+     * commands.
+     *
+     * @since S60 5.0
+     * @param aPushLast ETrue to push last reply, EFalse otherwise
+     * @return None
+     */
+    void SetEndOfCmdLine();
+
+    /**
+     * Gets the editor mode status
+     *
+     * @since TB9.2
+     * @return ETrue if in editor mode, EFalse otherwise
+     */
+    TBool EditorMode();
+
+private:
+
+    CDunAtCmdPusher( RATExt* aAtCmdExt,
+                     MDunAtCmdPusher* aCallback,
+                     MDunStreamManipulator* aDownstream,
+                     TDesC8* aOkBuffer );
+
+    void ConstructL();
+
+    /**
+     * Initializes this class
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void Initialize();
+
+    /**
+     * Sets state to idle and notifies about subcommand handling completion
+     *
+     * @since S60 5.0
+     * @param aError Error code for completion
+     * @return None
+     */
+    void SetToIdleAndNotifyEnd( TInt aError );
+
+    /**
+     * Checks if "OK" (verbose) or "0" (numeric) string or exists at the end of
+     * buffer and removes it
+     *
+     * @since S60 5.0
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt CheckAndRemoveOkString();
+
+    /**
+     * Sends reply data to downstream
+     *
+     * @since S60 5.0
+     * @param aRecvBuffer ETrue if using receive buffer
+     *                    EFalse if using "OK" buffer
+     * @return None
+     */
+    void SendReplyData( TBool aRecvBuffer=ETrue );
+
+    /**
+     * Manages change in reply type to EReplyTypeOther
+     *
+     * @since TB9.2
+     * @return None
+     */
+    void ManageReplyTypeChangeToOther();
+
+    /**
+     * Manages change in reply type to EReplyTypeOk
+     *
+     * @since TB9.2
+     * @return None
+     */
+    void ManageReplyTypeChangeToOk();
+
+    /**
+     * Manages change in reply type to EReplyTypeError
+     *
+     * @since TB9.2
+     * @return None
+     */
+    void ManageReplyTypeChangeToError();
+
+    /**
+     * Manages change in reply type to EReplyTypeEditor
+     *
+     * @since TB9.2
+     * @return None
+     */
+    void ManageReplyTypeChangeToEditor();
+
+    /**
+     * Manages change in reply type
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void ManageReplyTypeChange();
+
+// from base class CActive
+
+    /**
+     * From CActive.
+     * Gets called when AT command handled
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void RunL();
+
+    /**
+     * From CActive.
+     * Gets called on cancel
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void DoCancel();
+
+// from base class MDunCompletionReporter
+
+    /**
+     * From MDunCompletionReporter.
+     * Gets called when data push is complete
+     *
+     * @since S60 5.0
+     * @param aAllPushed ETrue if all in the queue were pushed, EFalse otherwise
+     * @return None
+     */
+    void NotifyDataPushComplete( TBool aAllPushed );
+
+private:  // data
+
+    /**
+     * AT command extension
+     * Not own.
+     */
+    RATExt* iAtCmdExt;
+
+    /**
+     * Notification interface class for data pushing status changes
+     * Not own.
+     */
+    MDunAtCmdPusher* iCallback;
+
+    /**
+     * Callback to call when data to push
+     * Not own.
+     */
+    MDunStreamManipulator* iDownstream;
+
+    /**
+     * Buffer for ok reply
+     * Not own.
+     */
+    TDesC8* iOkBuffer;
+
+    /**
+     * Current state of AT command handling: active or inactive
+     */
+    TDunState iAtPushState;
+
+    /**
+     * Buffer for receiving
+     */
+    TBuf8<KDefaultCmdBufLength> iRecvBuffer;
+
+    /**
+     * Indicates how many bytes of reply left
+     */
+    TInt iReplyBytesLeft;
+
+    /**
+     * Package for reply bytes left
+     */
+    TPckg<TInt> iReplyLeftPckg;
+
+    /**
+     * Reply type for the handled AT command
+     */
+    TATExtensionReplyType iReplyType;
+
+    /**
+     * Package for reply type for the handled AT command
+     */
+    TPckg<TATExtensionReplyType> iReplyTypePckg;
+
+    /**
+     * Flag indicating if other than "ERROR" reply already received in the
+     * command line
+     */
+    TBool iNoErrorReceived;
+
+    /**
+     * Flag indicating if the last "OK" reply push is started
+     */
+    TBool iLastOkPush;
+
+    /**
+     * Flag indicating if abort already tried for one command
+     */
+    TBool iCmdAbort;
+
+    /**
+     * Flag indicating if stop needed after the next reply
+     */
+    TBool iStop;
+
+    /**
+     * Flag indicating if in editor mode
+     */
+    TBool iEditorMode;
+
+    };
+
+#endif  // C_CDUNATCMDPUSHER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/atext/inc/DunAtEcomListen.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,185 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ECom plugin install/uninstall/version listener
+*
+*/
+
+
+#ifndef C_CDUNATECOMLISTEN_H
+#define C_CDUNATECOMLISTEN_H
+
+#include <atext.h>
+#include "DunTransporter.h"
+
+/**
+ *  Notification interface class for ECOM plugin interface status changes
+ *
+ *  @lib dunatext.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS( MDunAtEcomListen )
+    {
+
+public:
+
+    /**
+     * Notifies about new plugin installation
+     *
+     * @since S60 5.0
+     * @param aPluginUid UID of installed plugin
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt NotifyPluginInstallation( TUid& aPluginUid ) = 0;
+
+    /**
+     * Notifies about existing plugin uninstallation
+     *
+     * @since S60 5.0
+     * @param aPluginUid UID of uninstalled plugin
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt NotifyPluginUninstallation( TUid& aPluginUid ) = 0;
+
+    };
+
+/**
+ *  Class for ECom plugin install/uninstall/version listener
+ *
+ *  @lib dunatext.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS( CDunAtEcomListen ) : public CActive
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aAtCmdExt Pointer to AT command extension
+     * @param aCallback Callback to mode status change
+     * @return Instance of self
+     */
+	static CDunAtEcomListen* NewL( RATExt* aAtCmdExt,
+                                   MDunAtEcomListen* aCallback );
+
+    /**
+     * Two-phased constructor.
+     * @param aAtCmdExt Pointer to AT command extension
+     * @param aCallback Callback to mode status change
+     * @return Instance of self
+     */
+    static CDunAtEcomListen* NewLC( RATExt* aAtCmdExt,
+                                    MDunAtEcomListen* aCallback );
+	
+    /**
+    * Destructor.
+    */
+    virtual ~CDunAtEcomListen();
+
+    /**
+     * Resets data to initial values
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void ResetData();
+
+    /**
+     * Starts waiting for ECom plugin install/uninstall/version status changes
+     *
+     * @since S60 5.0
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt IssueRequest();
+
+    /**
+     * Stops waiting for Ecom plugin install/uninstall/version status changes
+     *
+     * @since S60 5.0
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt Stop();
+
+private:
+
+    CDunAtEcomListen( RATExt* aAtCmdExt,
+                      MDunAtEcomListen* aCallback );
+
+    void ConstructL();
+
+    /**
+     * Initializes this class
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void Initialize();
+
+// from base class CActive
+
+    /**
+     * From CActive.
+     * Gets called when plugin installed, uninstalled or changed
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void RunL();
+
+    /**
+     * From CActive.
+     * Gets called on cancel
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void DoCancel();
+
+private:  // data
+
+    /**
+     * AT command extension
+     * Not own.
+     */
+    RATExt* iAtCmdExt;
+
+    /**
+     * Callback to call when plugin installed, uninstalled or changed
+     * Not own.
+     */
+    MDunAtEcomListen* iCallback;
+
+    /**
+     * Current state of ECom interface listening: active or inactive
+     */
+    TDunState iEcomListenState;
+
+    /**
+     * UID of the installed, uninstalled or changed plugin
+     */
+    TUid iPluginUid;
+
+    /**
+     * Package for plugin UID
+     */
+    TPckg<TUid> iPluginUidPckg;
+
+    /**
+     * Package for ECOM type
+     */
+    TPckg<TATExtensionEcomType> iEcomTypePckg;
+
+    };
+
+#endif  // C_CDUNATECOMLISTEN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/atext/inc/DunAtModeListen.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,172 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Modem's mode listener and notifier
+*
+*/
+
+
+#ifndef C_CDUNATMODELISTEN_H
+#define C_CDUNATMODELISTEN_H
+
+#include <e32base.h>
+#include <atextcommon.h>
+#include "DunTransporter.h"
+
+/**
+ *  Notification interface class for modem's mode listener
+ *
+ *  @lib dunatext.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS( MDunAtModeListen )
+    {
+
+public:
+
+    /**
+     * Notifies about mode status change
+     *
+     * @since S60 5.0
+     * @param aMode Current modem modes
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt NotifyModeStatusChange( TUint aMode ) = 0;
+
+    };
+
+/**
+ *  Class for modem's mode listener and notifier
+ *
+ *  @lib dunatext.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS( CDunAtModeListen ) : public CActive
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * aAtCmdExtCommand AT command extension to common functionality
+     * aCallback Callback to mode status change
+     * @return Instance of self
+     */
+	static CDunAtModeListen* NewL( RATExtCommon* aAtCmdExtCommon,
+	                               MDunAtModeListen* aCallback );
+
+    /**
+     * Two-phased constructor.
+     * aAtCmdExtCommand AT command extension to common functionality
+     * aCallback Callback to mode status change
+     * @return Instance of self
+     */
+    static CDunAtModeListen* NewLC( RATExtCommon* aAtCmdExtCommon,
+                                    MDunAtModeListen* aCallback );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunAtModeListen();
+
+    /**
+     * Resets data to initial values
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void ResetData();
+
+    /**
+     * Issues request to start monitoring for mode status changes
+     *
+     * @since S60 5.0
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt IssueRequest();
+
+    /**
+     * Stops monitoring for mode status changes
+     *
+     * @since S60 5.0
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt Stop();
+
+private:
+
+    CDunAtModeListen( RATExtCommon* iAtCmdExtCommon,
+                      MDunAtModeListen* aCallback );
+
+    void ConstructL();
+
+    /**
+     * Initializes this class
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void Initialize();
+
+// from base class CActive
+
+    /**
+     * From CActive.
+     * Gets called when mode changes
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void RunL();
+
+    /**
+     * From CActive.
+     * Gets called on cancel
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void DoCancel();
+
+private:  // data
+
+    /**
+     * AT command extension to common functionality
+     * Not own.
+     */
+    RATExtCommon* iAtCmdExtCommon;
+
+    /**
+     * Callback to call when mode status changes
+     * Not own.
+     */
+    MDunAtModeListen* iCallback;
+
+    /**
+     * Current state of mode listening: active or inactive
+     */
+    TDunState iModeListenState;
+
+    /**
+     * Stored mode status change
+     */
+    TUint iMode;
+
+    /**
+     * Package for mode status changes
+     */
+    TPckg<TUint> iModePckg;
+
+    };
+
+#endif  // C_CDUNATMODELISTEN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/atext/inc/DunAtNvramListen.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,151 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  AT NVRAM status change listener and notifier
+*
+*/
+
+#ifndef C_CDUNATNVRAMLISTEN_H
+#define C_CDUNATNVRAMLISTEN_H
+
+#include <atext.h>
+#include <atextcommon.h>
+#include "DunTransporter.h"
+
+/**
+ *  Class for AT NVRAM status change listener
+ *
+ *  @lib dunatext.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS( CDunAtNvramListen ) : public CActive
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aAtCmdExt Pointer to AT command extension
+     * @param aAtCmdExtCommon Pointer to AT command extension to common
+     *                        functionality
+     * @return Instance of self
+     */
+	static CDunAtNvramListen* NewL( RATExt* aAtCmdExt,
+	                                RATExtCommon* aAtCmdExtCommon );
+
+    /**
+     * Two-phased constructor.
+     * @param aAtCmdExt Pointer to AT command extension
+     * @param aAtCmdExtCommon Pointer to AT command extension to common
+     *                        functionality
+     * @return Instance of self
+     */
+    static CDunAtNvramListen* NewLC( RATExt* aAtCmdExt,
+                                     RATExtCommon* aAtCmdExtCommon );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunAtNvramListen();
+
+    /**
+     * Resets data to initial values
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void ResetData();
+
+    /**
+     * Starts waiting for NVRAM status changes
+     *
+     * @since S60 5.0
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt IssueRequest();
+
+    /**
+     * Stops waiting for NVRAM status changes
+     *
+     * @since S60 5.0
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt Stop();
+
+private:
+
+    CDunAtNvramListen( RATExt* aAtCmdExt,
+                       RATExtCommon* aAtCmdExtCommon );
+
+    void ConstructL();
+
+    /**
+     * Initializes this class
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void Initialize();
+
+// from base class CActive
+
+    /**
+     * From CActive.
+     * Gets called when NVRAM has changed
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void RunL();
+
+    /**
+     * From CActive.
+     * Gets called on cancel
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void DoCancel();
+
+private:  // data
+
+    /**
+     * AT command extension
+     * Not own.
+     */
+    RATExt* iAtCmdExt;
+
+    /**
+     * AT command extension to common functionality
+     * Not own.
+     */
+    RATExtCommon* iAtCmdExtCommon;
+
+    /**
+     * Current state of NVRAM status change listening; active or inactive
+     */
+    TDunState iNvramHandleState;
+
+    /**
+     * Buffer for NVRAM
+     */
+    TBuf8<KDefaultNvramBufLength> iNvramBuffer;
+
+    /**
+     * Flag to indicate start of receiving
+     */
+    TBool iStarted;
+
+    };
+
+#endif  // C_CDUNATNVRAMLISTEN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/atext/inc/DunAtSpecialCmdHandler.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,110 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Special AT command handler
+*
+*/
+
+#ifndef C_CDUNATSPECIALCMDHANDLER_H
+#define C_CDUNATSPECIALCMDHANDLER_H
+
+#include <e32base.h>
+#include <badesca.h>
+
+const TInt KInputBufLength = (512 + 1);  // Set this the same as in KDunInputBufLength
+
+/**
+ *  Class for special AT command handler
+ *
+ *  @lib dunatext.lib
+ *  @since TB9.2
+ */
+NONSHARABLE_CLASS( CDunAtSpecialCmdHandler ) : public CBase
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param None
+     * @return Instance of self
+     */
+	static CDunAtSpecialCmdHandler* NewL();
+
+    /**
+    * Destructor.
+    */
+    ~CDunAtSpecialCmdHandler();
+
+public:
+
+    /**
+     * Checks if the command has to be treated special way.
+     * For example in case of MAC, it sends command AT&FE0Q0V1&C1&D2+IFC=3,1.
+     * meaning there is no delimiters in the command.
+     * In case of MAC we try to search AT&F (sub command) string from the
+     * beginning of the command.
+     * Search is done string basis.
+     *
+     * @since TB9.2
+     * @param aCharacter Character to add
+     * @return ETrue if data is ready for comparison, EFalse otherwise
+     */
+    TBool IsCompleteSubCommand( TChar aCharacter );
+
+    /**
+     * Resets the buffer used for comparisons
+     *
+     * @since TB9.2
+     * @return None
+     */
+    void ResetComparisonBuffer();
+
+private:
+
+    CDunAtSpecialCmdHandler();
+
+    void ConstructL();
+
+    /**
+     * Defines when comparison is excecuted, checks if the data lengths are
+     * equal.
+     *
+     * @since TB9.2
+     * @return ETrue if data is ready for comparison, EFalse otherwise
+     */
+    TBool IsDataReadyForComparison( TInt aLength );
+
+    /**
+     * Defines minimum length of the special commands.
+     *
+     * @since TB9.2
+     * @return Minimum length of the special commands
+     */
+    TInt MinimumLength();
+
+private:  // data
+
+    /**
+     * Buffer for temporary AT command input
+     */
+    TBuf8<KInputBufLength> iBuffer;
+
+    /**
+     * Special commands for parsing
+     */
+    CDesC8Array *iSpecialCmds;
+
+    };
+
+#endif  // C_CDUNATSPECIALCMDHANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/atext/inc/DunAtUrcHandler.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,182 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  AT command URC handler
+*
+*/
+
+
+#ifndef C_CDUNATURCHANDLER_H
+#define C_CDUNATURCHANDLER_H
+
+#include <atext.h>
+#include "DunDataPusher.h"
+
+class MDunStreamManipulator;
+
+/**
+ *  Class for AT command URC handler
+ *
+ *  @lib dunatext.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS( CDunAtUrcHandler ) : public CActive,
+                                        public MDunCompletionReporter
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aAtCmdExt Pointer to AT command extension
+     * @param aStreamCallback Callback to stream
+     * @return Instance of self
+     */
+	static CDunAtUrcHandler* NewL( RATExt* aAtCmdExt,
+	                               MDunStreamManipulator* aStreamCallback );
+
+    /**
+     * Two-phased constructor.
+     * @param aAtCmdExt Pointer to AT command extension
+     * @param aStreamCallback Callback to stream
+     * @return Instance of self
+     */
+	static CDunAtUrcHandler* NewLC( RATExt* aAtCmdExt,
+	                                MDunStreamManipulator* aStreamCallback );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunAtUrcHandler();
+
+    /**
+     * Resets data to initial values
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void ResetData();
+
+    /**
+     * Starts waiting for an incoming URC message
+     *
+     * @since S60 5.0
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt IssueRequest();
+
+    /**
+     * Stops waiting for an incoming URC message
+     *
+     * @since S60 5.0
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt Stop();
+
+    /**
+     * UID of the owning plugin
+     *
+     * @since S60 5.0
+     * @return UID of the owning plugin
+     */
+    TUid OwnerUid();
+
+private:
+
+    CDunAtUrcHandler( RATExt* aAtCmdExt,
+                      MDunStreamManipulator* aStreamCallback );
+
+    void ConstructL();
+
+    /**
+     * Initializes this class
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void Initialize();
+
+// from base class CActive
+
+    /**
+     * From CActive.
+     * Gets called when URC command received
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void RunL();
+
+    /**
+     * From CActive.
+     * Gets called on cancel
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void DoCancel();
+
+// from base class MDunCompletionReporter
+
+    /**
+     * From MDunCompletionReporter.
+     * Gets called when data push is complete
+     *
+     * @since S60 5.0
+     * @param aAllPushed ETrue if all in the queue were pushed, EFalse otherwise
+     * @return None
+     */
+    void NotifyDataPushComplete( TBool aAllPushed );
+
+private:  // data
+
+    /**
+     * AT command extension
+     * Not own.
+     */
+    RATExt* iAtCmdExt;
+
+    /**
+     * Callback to call when data to push
+     * Not own.
+     */
+    MDunStreamManipulator* iStreamCallback;
+
+    /**
+     * Current state of URC message handling: active or inactive
+     */
+    TDunState iUrcHandleState;
+
+    /**
+     * Buffer for receiving
+     */
+    TBuf8<KDefaultUrcBufLength> iRecvBuffer;
+
+    /**
+     * UID of the responsible ATEXT plugin
+     */
+    TUid iOwnerUid;
+
+    /**
+     * Package for owner UID
+     */
+    TPckg<TUid> iOwnerUidPckg;
+
+    /**
+     * Flag to indicate start of receiving (for ownership marking)
+     */
+    TBool iStarted;
+
+    };
+
+#endif  // C_CDUNATURCHANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/atext/src/DunAtCmdEchoer.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,129 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Echoer for AT commands
+*
+*/
+
+#include "DunAtCmdEchoer.h"
+#include "DunDownstream.h"
+#include "DunDebug.h"
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunAtCmdEchoer* CDunAtCmdEchoer::NewL(
+    MDunStreamManipulator* aStreamCallback )
+    {
+    CDunAtCmdEchoer* self = new (ELeave) CDunAtCmdEchoer( aStreamCallback );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunAtCmdEchoer::~CDunAtCmdEchoer()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdEchoer::~CDunAtCmdEchoer()") ));
+    ResetData();
+    FTRACE(FPrint( _L("CDunAtCmdEchoer::~CDunAtCmdEchoer() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Resets data to initial values
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdEchoer::ResetData()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdEchoer::ResetData()") ));
+    // Internal
+    Initialize();
+    FTRACE(FPrint( _L("CDunAtCmdEchoer::ResetData() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Sends a character to be echoed
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtCmdEchoer::SendEchoCharacter(
+    const TDesC8* aInput,
+    MDunAtCmdEchoer* aCallback )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdEchoer::SendEchoCharacter()") ));
+    if ( iAtEchoState!=EDunStateIdle || iCallback )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdEchoer::SendEchoCharacter() (not ready) complete") ));
+        return KErrNotReady;
+        }
+    iStreamCallback->NotifyDataPushRequest( aInput, this );
+    iCallback = aCallback;
+    iAtEchoState = EDunStateAtCmdEchoing;
+    FTRACE(FPrint( _L("CDunDownstream::SendEchoCharacter() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunAtCmdEchoer::CDunAtCmdEchoer
+// ---------------------------------------------------------------------------
+//
+CDunAtCmdEchoer::CDunAtCmdEchoer( MDunStreamManipulator* aStreamCallback ) :
+    iStreamCallback( aStreamCallback )
+    {
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// CDunAtCmdEchoer::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdEchoer::ConstructL()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdEchoer::ConstructL()") ));
+    if ( !iStreamCallback )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdEchoer::ConstructL() complete") ));
+        User::Leave( KErrGeneral );
+        }
+    FTRACE(FPrint( _L("CDunAtCmdEchoer::ConstructL() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes this class
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdEchoer::Initialize()
+    {
+    // Don't initialize iStreamCallback here (it is set through NewL)
+    iCallback = NULL;
+    iAtEchoState = EDunStateIdle;
+    }
+
+// ---------------------------------------------------------------------------
+// From MDunCompletionReporter.
+// Gets called when data push is complete
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdEchoer::NotifyDataPushComplete( TBool /*aAllPushed*/ )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdEchoer::NotifyDataPushComplete()") ));
+    MDunAtCmdEchoer* callback = iCallback;
+    iCallback = NULL;
+    iAtEchoState = EDunStateIdle;
+    callback->NotifyEchoComplete();
+    FTRACE(FPrint( _L("CDunAtCmdEchoer::NotifyDataPushComplete() complete") ));
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/atext/src/DunAtCmdHandler.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1777 @@
+/*
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  AT command handler and notifier
+*
+*/
+
+/*
+ * Points to consider:
+ * - Each of the AT commands sent to ATEXT are converted to upper case form.
+ *   Thus the ATEXT plugins don't need to check for case. The conversion to
+ *   upper case form stops when carriage return or '=' character is found.
+ */
+
+/*
+ * The AT command handling is splitted to two parts on high level:
+ * 1) Splitter: splitting the sub-commands in a command line to multiple ones
+ *    for ATEXT to process.
+ * 2) Combiner: combining the replies coming from ATEXT using a filter
+ *    (the filter categories are explained in DunAtCmdPusher.cpp)
+ */
+
+#include "DunAtCmdHandler.h"
+#include "DunAtUrcHandler.h"
+#include "DunDownstream.h"
+#include "DunDebug.h"
+
+const TInt8 KDunCancel = 24;  // Used for line editing, cancel character
+const TInt8 KDunEscape = 27;  // Used for editor ending, escape character
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CDunAtCmdHandler* CDunAtCmdHandler::NewL(
+    MDunAtCmdStatusReporter* aUpstream,
+    MDunStreamManipulator* aDownstream,
+    const TDesC8* aConnectionName )
+    {
+    CDunAtCmdHandler* self = new (ELeave) CDunAtCmdHandler(
+        aUpstream,
+        aDownstream,
+        aConnectionName );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunAtCmdHandler::~CDunAtCmdHandler()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::~CDunAtCmdHandler()") ));
+    ResetData();
+    FTRACE(FPrint( _L("CDunAtCmdHandler::~CDunAtCmdHandler() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Resets data to initial values
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CDunAtCmdHandler::ResetData()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ResetData()") ));
+    // APIs affecting this:
+    // IssueRequest()
+    Stop();
+    // NewL()
+    DeletePluginHandlers();
+    delete iCmdEchoer;
+    iCmdEchoer = NULL;
+    delete iNvramListen;
+    iNvramListen = NULL;
+    delete iModeListen;
+    iModeListen = NULL;
+    delete iEcomListen;
+    iEcomListen = NULL;
+    delete iAtSpecialCmdHandler;
+    iAtSpecialCmdHandler = NULL;
+    if ( iAtCmdExtCommon.Handle() )
+        {
+        iAtCmdExtCommon.SynchronousClose();
+        iAtCmdExtCommon.Close();
+        }
+    if ( iAtCmdExt.Handle() )
+        {
+        iAtCmdExt.SynchronousClose();
+        iAtCmdExt.Close();
+        }
+    iSpecials.ResetAndDestroy();
+    iSpecials.Close();
+    // AddCmdModeCallback()
+    iCmdCallbacks.Close();
+    // Internal
+    Initialize();
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ResetData() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Adds callback for command mode notification
+// The callback will be called when command mode starts or ends
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CDunAtCmdHandler::AddCmdModeCallback( MDunCmdModeMonitor* aCallback )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::AddCmdModeCallback()" ) ));
+    if ( !aCallback )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::AddCmdModeCallback() (aCallback) not initialized!" ) ));
+        return KErrGeneral;
+        }
+    TInt retTemp = iCmdCallbacks.Find( aCallback );
+    if ( retTemp != KErrNotFound )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::AddCmdModeCallback() (already exists) complete" ) ));
+        return KErrAlreadyExists;
+        }
+    retTemp = iCmdCallbacks.Append( aCallback );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::AddCmdModeCallback() (append failed!) complete" ) ));
+        return retTemp;
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::AddCmdModeCallback() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Parses an AT command
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CDunAtCmdHandler::ParseCommand( TDesC8& aCommand,
+                                              TBool& aPartialInput )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ParseCommand()") ));
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ParseCommand() received:") ));
+    FTRACE(FPrintRaw(aCommand) );
+    TBool editorMode = iCmdPusher->EditorMode();
+    if ( editorMode )
+        {
+        // Note: return here with "no partial input" and some error to fool
+        // CDunUpstream into not reissuing the read request.
+        iCmdPusher->IssueRequest( aCommand, EFalse );
+        aPartialInput = EFalse;
+        return KErrGeneral;
+        }
+    iCommand = &aCommand;  // iCommand only for normal mode
+    // Manage partial AT command
+    TBool needsCarriage = ETrue;
+    TBool okToExit = ManagePartialCommand( aCommand, needsCarriage );
+    if ( okToExit )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::ParseCommand() (ok to exit) complete") ));
+        aPartialInput = ETrue;
+        return KErrNone;
+        }
+    if ( iHandleState != EDunStateIdle )
+        {
+        aPartialInput = EFalse;
+        ResetParseBuffers();
+        FTRACE(FPrint( _L("CDunAtCmdHandler::ParseCommand() (not ready) complete") ));
+        return KErrNotReady;
+        }
+    TBool pushStarted = HandleASlashCommand();
+    if ( pushStarted )
+        {
+        // Note: return here with "partial input" status to fool CDunUpstream
+        // into reissuing the read request. The AT command has not really
+        // started yet so this is necessary.
+        aPartialInput = ETrue;
+        ResetParseBuffers();
+        FTRACE(FPrint( _L("CDunAtCmdHandler::ParseCommand() (A/) complete") ));
+        return KErrNone;
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ParseCommand() received total:") ));
+    FTRACE(FPrintRaw(iInputBuffer) );
+    iHandleState = EDunStateAtCmdHandling;
+    iUpstream->NotifyAtCmdHandlingStart();
+    iDecodeInfo.iFirstDecode = ETrue;
+    iDecodeInfo.iDecodeIndex = 0;
+    HandleNextDecodedCommand();
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ParseCommand() complete") ));
+    aPartialInput = EFalse;
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Manages request to abort command handling
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CDunAtCmdHandler::ManageAbortRequest()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ManageAbortRequest()") ));
+    // Just forward the request, do no other own processing
+    TInt retVal = iCmdPusher->ManageAbortRequest();
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ManageAbortRequest() complete") ));
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// Sets end of command line marker on for the possible series of AT commands.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CDunAtCmdHandler::SetEndOfCmdLine( TBool aClearInput )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::SetEndOfCmdLine()") ));
+    ManageEndOfCmdHandling( EFalse, ETrue, aClearInput );
+    FTRACE(FPrint( _L("CDunAtCmdHandler::SetEndOfCmdLine() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Sends a character to be echoed
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CDunAtCmdHandler::SendEchoCharacter( const TDesC8* aInput,
+                                                   MDunAtCmdEchoer* aCallback )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::SendEchoCharacter()") ));
+    TInt retVal = iCmdEchoer->SendEchoCharacter( aInput, aCallback );
+    FTRACE(FPrint( _L("CDunAtCmdHandler::SendEchoCharacter() complete") ));
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// Stops sending of AT command from parse buffer
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CDunAtCmdHandler::Stop()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::Stop()") ));
+    // Only stop iCmdPusher here, not iUrcHandlers!
+    if ( iHandleState != EDunStateAtCmdHandling )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::Stop() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    iCmdPusher->Stop();
+    // The line below is used in the case when this function is called by
+    // CDunUpstream as a result of "data mode ON" change notification.
+    // In this case it is possible that HandleNextDecodedCommand() returns
+    // without resetting the iInputBuffer because of the way it checks the
+    // iHandleState.
+    ManageEndOfCmdHandling( EFalse, ETrue, ETrue );
+    FTRACE(FPrint( _L("CDunAtCmdHandler::Stop() complete") ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Starts URC message handling
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CDunAtCmdHandler::StartUrc()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::StartUrc()") ));
+    TInt i;
+    TInt count = iUrcHandlers.Count();
+    for ( i=0; i<count; i++ )
+        {
+        TInt retTemp = iUrcHandlers[i]->IssueRequest();
+        if ( retTemp!=KErrNone && retTemp!=KErrNotReady )
+            {
+            FTRACE(FPrint( _L("CDunAtCmdHandler::StartUrc() (ERROR) complete") ));
+            return retTemp;
+            }
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::StartUrc() complete") ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Stops URC message handling
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CDunAtCmdHandler::StopUrc()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::StopUrc()") ));
+    TInt i;
+    TInt retVal = KErrNone;
+    TInt count = iUrcHandlers.Count();
+    for ( i=0; i<count; i++ )
+        {
+        retVal = iUrcHandlers[i]->Stop();
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::StopUrc() complete") ));
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunAtCmdHandler::CDunAtCmdHandler
+// ---------------------------------------------------------------------------
+//
+CDunAtCmdHandler::CDunAtCmdHandler( MDunAtCmdStatusReporter* aUpstream,
+                                    MDunStreamManipulator* aDownstream,
+                                    const TDesC8* aConnectionName ) :
+    iUpstream( aUpstream ),
+    iDownstream( aDownstream ),
+    iConnectionName( aConnectionName )
+    {
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// CDunAtCmdHandler::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdHandler::ConstructL()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ConstructL()") ));
+    if ( !iUpstream || !iDownstream || !iConnectionName )
+        {
+        User::Leave( KErrGeneral );
+        }
+    // Connect to AT command extension (must succeed)
+    TInt retTemp = KErrNone;
+    CleanupClosePushL( iAtCmdExt );
+    retTemp = iAtCmdExt.Connect( EDunATExtension, *iConnectionName );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::ConstructL() connect (%d)"), retTemp));
+        User::Leave( retTemp );
+        }
+    CleanupClosePushL( iAtCmdExtCommon );
+    retTemp = iAtCmdExtCommon.Connect( *iConnectionName );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::ConstructL() common connect (%d)"), retTemp));
+        User::Leave( retTemp );
+        }
+    // Create the array of special commands
+    CreateSpecialCommandsL();
+    // Create the plugin handlers
+    CreatePluginHandlersL();
+    // Create the echo handler
+    iCmdEchoer = CDunAtCmdEchoer::NewL( iDownstream );
+    // Create the listeners
+    iEcomListen = CDunAtEcomListen::NewL( &iAtCmdExt, this );
+    iModeListen = CDunAtModeListen::NewL( &iAtCmdExtCommon, this );
+    iNvramListen = CDunAtNvramListen::NewL( &iAtCmdExt, &iAtCmdExtCommon );
+    iAtSpecialCmdHandler = CDunAtSpecialCmdHandler::NewL();
+    // Set the default modes (+report) and characters
+    GetAndSetDefaultSettingsL();
+    // Start listening
+    iEcomListen->IssueRequest();
+    iModeListen->IssueRequest();
+    iNvramListen->IssueRequest();
+    CleanupStack::Pop( &iAtCmdExtCommon );
+    CleanupStack::Pop( &iAtCmdExt );
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ConstructL() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes this class
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdHandler::Initialize()
+    {
+    // Don't initialize iUpstream here (it is set through NewL)
+    // Don't initialize iDownstream here (it is set through NewL)
+    // Don't initialize iConnectionName here (it is set through NewL)
+    iHandleState = EDunStateIdle;
+    iCarriageReturn = 0;
+    iLineFeed = 0;
+    iBackspace = 0;
+    iCommand = NULL;
+    iDecodeInfo.iFirstDecode = ETrue;
+    iDecodeInfo.iDecodeIndex = KErrNotFound;
+    iDecodeInfo.iExtendedIndex = KErrNotFound;
+    iDecodeInfo.iPrevChar = 0;
+    iDecodeInfo.iPrevExists = EFalse;
+    iDecodeInfo.iAssignFound = EFalse;
+    iDecodeInfo.iInQuotes = EFalse;
+    iDecodeInfo.iSpecialFound = EFalse;
+    iEditorModeInfo.iContentFound = EFalse;
+    iCmdPusher = NULL;
+    iEcomListen = NULL;
+    iModeListen = NULL;
+    iNvramListen = NULL;
+    iDataMode = EFalse;
+    iEchoOn = EFalse;
+    iQuietOn = EFalse;
+    iVerboseOn = EFalse;
+    iEndIndex = KErrNotFound;
+    }
+
+// ---------------------------------------------------------------------------
+// Creates plugin handlers for this class
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdHandler::CreatePluginHandlersL()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::CreatePluginHandlersL()") ));
+    if ( !iAtCmdExt.Handle() )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::CreatePluginHandlersL() complete") ));
+        User::Leave( KErrGeneral );
+        }
+    // First create the command reply pusher
+    CDunAtCmdPusher* cmdPusher = CDunAtCmdPusher::NewLC( &iAtCmdExt,
+                                                         this,
+                                                         iDownstream,
+                                                         &iOkBuffer );
+    // Next create the URC handlers
+    TInt i;
+    TInt numOfPlugins = iAtCmdExt.NumberOfPlugins();
+    for ( i=0; i<numOfPlugins; i++ )
+        {
+        AddOneUrcHandlerL();
+        }
+    CleanupStack::Pop( cmdPusher );
+    iCmdPusher = cmdPusher;
+    FTRACE(FPrint( _L("CDunAtCmdHandler::CreatePluginHandlersL() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Creates an array of special commands
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdHandler::CreateSpecialCommandsL()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::CreateSpecialCommandsL()") ));
+    TInt retTemp = KErrNone;
+    TBool firstSearch = ETrue;
+    for ( ;; )
+        {
+        retTemp = iAtCmdExt.GetNextSpecialCommand( iInputBuffer, firstSearch );
+        if ( retTemp != KErrNone )
+            {
+            break;
+            }
+        HBufC8* specialCmd = HBufC8::NewMaxLC( iInputBuffer.Length() );
+        TPtr8 specialCmdPtr = specialCmd->Des();
+        specialCmdPtr.Copy( iInputBuffer );
+        specialCmdPtr.UpperCase();
+        iSpecials.AppendL( specialCmd );
+        CleanupStack::Pop( specialCmd );
+        }
+    iInputBuffer.Zero();
+    FTRACE(FPrint( _L("CDunAtCmdHandler::CreateSpecialCommandsL() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Recreates special command data.
+// This is done when a plugin is installed or uninstalled.
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtCmdHandler::RecreateSpecialCommands()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::RecreateSpecialCommands()") ));
+    iSpecials.ResetAndDestroy();
+    TRAPD( retTrap, CreateSpecialCommandsL() );
+    FTRACE(FPrint( _L("CDunAtCmdHandler::RecreateSpecialCommands() complete") ));
+    return retTrap;
+    }
+
+// ---------------------------------------------------------------------------
+// Gets default settings from RATExtCommon and sets them to RATExt
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdHandler::GetAndSetDefaultSettingsL()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::GetAndSetDefaultSettingsL()") ));
+    // Note: Let's assume command mode is off by default
+    TUint modeSet = GetCurrentModeL( KModeEcho | KModeQuiet | KModeVerbose );
+    iEchoOn    = ( modeSet & KEchoModeBase    ) ? ETrue : EFalse;
+    iQuietOn   = ( modeSet & KQuietModeBase   ) ? ETrue : EFalse;
+    iVerboseOn = ( modeSet & KVerboseModeBase ) ? ETrue : EFalse;
+    iCarriageReturn = GetCurrentModeL( KModeCarriage );
+    iLineFeed = GetCurrentModeL( KModeLineFeed );
+    iBackspace = GetCurrentModeL( KModeBackspace );
+    iAtCmdExt.ReportQuietModeChange( iQuietOn );
+    iAtCmdExt.ReportVerboseModeChange( iVerboseOn );
+    iAtCmdExt.ReportCharacterChange( ECharTypeCarriage, iCarriageReturn );
+    iAtCmdExt.ReportCharacterChange( ECharTypeLineFeed, iLineFeed );
+    iAtCmdExt.ReportCharacterChange( ECharTypeBackspace, iBackspace );
+    RegenerateReplyStrings();
+    FTRACE(FPrint( _L("CDunAtCmdHandler::GetAndSetDefaultSettingsL() settings: E=%d, Q=%d, V=%d"), iEchoOn, iQuietOn, iVerboseOn ));
+    FTRACE(FPrint( _L("CDunAtCmdHandler::GetAndSetDefaultSettingsL() settings: CR=%u, LF=%u, BS=%u"), iCarriageReturn, iLineFeed, iBackspace ));
+    FTRACE(FPrint( _L("CDunAtCmdHandler::GetAndSetDefaultSettingsL() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Regenerates the reply strings based on settings
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdHandler::RegenerateReplyStrings()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::RegenerateReplyStrings()") ));
+    TBool retVal = EFalse;
+    retVal |= RegenerateOkReply();
+    retVal |= RegenerateErrorReply();
+    FTRACE(FPrint( _L("CDunAtCmdHandler::RegenerateReplyStrings() complete") ));
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// Regenerates the ok reply based on settings
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdHandler::RegenerateOkReply()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::RegenerateOkReply()") ));
+    iOkBuffer.Zero();
+    if ( iQuietOn )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::RegenerateOkReply() (quiet) complete") ));
+        return ETrue;
+        }
+    if ( iVerboseOn )
+        {
+        _LIT8( KVerboseOk, "OK" );
+        iOkBuffer.Append( iCarriageReturn );
+        iOkBuffer.Append( iLineFeed );
+        iOkBuffer.Append( KVerboseOk );
+        iOkBuffer.Append( iCarriageReturn );
+        iOkBuffer.Append( iLineFeed );
+        }
+    else
+        {
+        _LIT8( KNumericOk, "0" );
+        iOkBuffer.Append( KNumericOk );
+        iOkBuffer.Append( iCarriageReturn );
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::RegenerateOkReply() complete") ));
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// Regenerates the error reply based on settings
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdHandler::RegenerateErrorReply()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::RegenerateErrorReply()") ));
+    iErrorBuffer.Zero();
+    if ( iQuietOn )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::RegenerateErrorReply() (quiet) complete") ));
+        return ETrue;
+        }
+    if ( iVerboseOn )
+        {
+        _LIT8( KVerboseError, "ERROR" );
+        iErrorBuffer.Append( iCarriageReturn );
+        iErrorBuffer.Append( iLineFeed );
+        iErrorBuffer.Append( KVerboseError );
+        iErrorBuffer.Append( iCarriageReturn );
+        iErrorBuffer.Append( iLineFeed );
+        }
+    else
+        {
+        _LIT8( KNumericError, "4" );
+        iErrorBuffer.Append( KNumericError );
+        iErrorBuffer.Append( iCarriageReturn );
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::RegenerateErrorReply() complete") ));
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// Gets current mode
+// ---------------------------------------------------------------------------
+//
+TUint CDunAtCmdHandler::GetCurrentModeL( TUint aMask )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::GetCurrentModeL()") ));
+    TUint maskCheck = aMask & ( ~KSupportedModes );
+    if ( maskCheck != 0 )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::GetCurrentModeL() (not supported) complete") ));
+        User::Leave( KErrNotSupported );
+        }
+    TUint newMode = 0;
+    TInt retTemp = iAtCmdExtCommon.GetMode( aMask, newMode );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::GetCurrentModeL() (ERROR) complete") ));
+        User::Leave( retTemp );
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::GetCurrentModeL() complete") ));
+    return newMode & (KModeChanged-1);
+    }
+
+// ---------------------------------------------------------------------------
+// Instantiates one URC message handling class instance and adds it to the URC
+// message handler array
+// ---------------------------------------------------------------------------
+//
+CDunAtUrcHandler* CDunAtCmdHandler::AddOneUrcHandlerL()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::AddOneUrcHandlerL()") ));
+    CDunAtUrcHandler* urcHandler = CDunAtUrcHandler::NewLC( &iAtCmdExt,
+                                                            iDownstream );
+    iUrcHandlers.AppendL( urcHandler );
+    CleanupStack::Pop( urcHandler );
+    FTRACE(FPrint( _L("CDunAtCmdHandler::AddOneUrcHandlerL() complete") ));
+    return urcHandler;
+    }
+
+// ---------------------------------------------------------------------------
+// Deletes all instantiated URC message handlers
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdHandler::DeletePluginHandlers()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::DeletePluginHandlers()") ));
+    delete iCmdPusher;
+    iCmdPusher = NULL;
+    TInt i;
+    TInt count = iUrcHandlers.Count();
+    for ( i=0; i<count; i++ )
+        {
+        delete iUrcHandlers[i];
+        iUrcHandlers[i] = NULL;
+        }
+    iUrcHandlers.Reset();
+    iUrcHandlers.Close();
+    FTRACE(FPrint( _L("CDunAtCmdHandler::DeletePluginHandlers() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Manages partial AT command
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdHandler::ManagePartialCommand( TDesC8& aCommand,
+                                              TBool& aNeedsCarriage )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ManagePartialCommand()") ));
+    aNeedsCarriage = ETrue;
+    // Check length of command
+    if ( aCommand.Length() == 0 )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::ManagePartialCommand() (length zero) complete") ));
+        return ETrue;
+        }
+    // Check one character (or unit) based input data
+    if ( aCommand.Length() == KDunChSetMaxCharLen )
+        {
+        EchoCommand( aCommand );
+        // Handle backspace and cancel characters
+        TBool found = HandleSpecialCharacters( aCommand );
+        if ( found )
+            {
+            FTRACE(FPrint( _L("CDunAtCmdHandler::ManagePartialCommand() (special) complete") ));
+            return ETrue;
+            }
+        }
+    TBool endFound = EFalse;
+    TBool overflow = AppendCommandToInputBuffer( aCommand, endFound );
+    if ( overflow )
+        {
+        // Overflow occurred so return ETrue (consumed) to skip all the rest
+        // characters until carriage return is found
+        FTRACE(FPrint( _L("CDunAtCmdHandler::ManagePartialCommand() (overflow) complete") ));
+        return ETrue;
+        }
+    // If something went wrong, do nothing (return consumed)
+    if ( iInputBuffer.Length() <= 0 )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::ManagePartialCommand() (length) complete") ));
+        return ETrue;
+        }
+    // If "A/", no carriage return is needed, check that now
+    if ( IsASlashCommand() )
+        {
+        aNeedsCarriage = EFalse;
+        FTRACE(FPrint( _L("CDunAtCmdHandler::ManagePartialCommand() (A/) complete") ));
+        return EFalse;
+        }
+    // For other commands and if no end, just return with consumed
+    if ( !endFound )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::ManagePartialCommand() (void) complete") ));
+        return ETrue;
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ManagePartialCommand() complete") ));
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// Echoes a command if echo is on
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdHandler::EchoCommand( TDesC8& aDes )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::EchoCommand()") ));
+    if ( aDes.Length() > KDunChSetMaxCharLen )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::EchoCommand() (wrong length) complete") ));
+        return EFalse;
+        }
+    if ( iEchoOn )
+        {
+        iEchoBuffer.Copy( aDes );
+        iDownstream->NotifyDataPushRequest( &iEchoBuffer, NULL );
+        FTRACE(FPrint( _L("CDunAtCmdHandler::EchoCommand() complete") ));
+        return ETrue;
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::EchoCommand() (not started) complete") ));
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// Handles backspace and cancel characters
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdHandler::HandleSpecialCharacters( TDesC8& aCommand )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::HandleSpecialCharacters()") ));
+    if ( aCommand.Length() != KDunChSetMaxCharLen )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::HandleSpecialCharacters() (wrong length) complete") ));
+        return EFalse;
+        }
+    if ( aCommand[0] == iBackspace )
+        {
+        TInt bufferLength = iInputBuffer.Length();
+        if ( bufferLength > 0 )
+            {
+            iInputBuffer.SetLength( bufferLength-1 );
+            }
+        FTRACE(FPrint( _L("CDunAtCmdHandler::HandleSpecialCharacters() (backspace) complete") ));
+        return ETrue;
+        }
+    if ( aCommand[0] == KDunCancel )
+        {
+        ResetParseBuffers();  // More processing here?
+        FTRACE(FPrint( _L("CDunAtCmdHandler::HandleSpecialCharacters() (cancel) complete") ));
+        return ETrue;
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::HandleSpecialCharacters() complete") ));
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// Appends command to parse buffer
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdHandler::AppendCommandToInputBuffer( TDesC8& aCommand,
+                                                    TBool& aEndFound )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::AppendCommandToInputBuffer()") ));
+    aEndFound = EFalse;
+    TInt cmdBufIndex = 0;
+    TInt cmdBufLim = aCommand.Length();
+    while ( cmdBufIndex < cmdBufLim )
+        {
+        if ( iInputBuffer.Length() == iInputBuffer.MaxLength() )
+            {
+            // 1) If output is full and end found from input
+            //    -> reset buffers and overflow found
+            // 2) If output is full and end not found from input
+            //    -> don't reset buffers and overflow found
+            TInt foundIndex = FindEndOfCommand( aCommand );
+            if ( foundIndex >= 0 )
+                {
+                aEndFound = ETrue;
+                ResetParseBuffers();
+                FTRACE(FPrint( _L("CDunAtCmdHandler::AppendCommandToInputBuffer() (reset) complete") ));
+                }
+            FTRACE(FPrint( _L("CDunAtCmdHandler::AppendCommandToInputBuffer() (overflow) complete") ));
+            return ETrue;
+            }
+        TChar character = aCommand[cmdBufIndex];
+        if ( IsEndOfCommand(character) )
+            {
+            aEndFound = ETrue;
+            iEndIndex = cmdBufIndex;
+            break;
+            }
+        iInputBuffer.Append( aCommand[cmdBufIndex] );
+        cmdBufIndex++;
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::AppendCommandToInputBuffer() complete") ));
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// Handles next decoded command from input buffer
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdHandler::HandleNextDecodedCommand()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::HandleNextDecodedCommand()") ));
+    if ( iHandleState != EDunStateAtCmdHandling )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::HandleNextDecodedCommand() (not ready) complete") ));
+        return ETrue;
+        }
+    TBool extracted = ExtractNextDecodedCommand();
+    if ( !extracted )
+        {
+        ManageEndOfCmdHandling( ETrue, ETrue, ETrue );
+        FTRACE(FPrint( _L("CDunAtCmdHandler::HandleNextDecodedCommand() (last) complete") ));
+        return ETrue;
+        }
+    // Next convert the decoded AT command to uppercase
+    // Don't check for case status -> let mixed cases pass
+    iParseInfo.iSendBuffer.Copy( iDecodeInfo.iDecodeBuffer );
+    TInt maxLength = iParseInfo.iSendBuffer.MaxLength();
+    TPtr8 upperDes( &iParseInfo.iSendBuffer[0], iParseInfo.iLimit, maxLength );
+    upperDes.UpperCase();
+    // Next always send the command to ATEXT
+    iCmdPusher->IssueRequest( iParseInfo.iSendBuffer );
+    FTRACE(FPrint( _L("CDunAtCmdHandler::HandleNextDecodedCommand() complete") ));
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// Finds the start of the next command
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtCmdHandler::FindStartOfNextCommand()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::FindStartOfNextCommand()") ));
+    // Note: here we need to avoid internal recursion when parsing the
+    // multiple IsEndOfCommand() and IsDelimiterCharacter() markers inside the
+    // same upstream block.
+    // Skip all the extra markers except the one we already know to exist.
+    TInt i;
+    TInt startVal = iEndIndex + 1;
+    TInt foundIndex = KErrNotFound;
+    TInt count = iCommand->Length();
+    for ( i=startVal; i<count; i++ )
+        {
+        TChar character = (*iCommand)[i];
+        if ( !(IsEndOfCommand(character)||IsDelimiterCharacter(character)) )
+            {
+            foundIndex = i;
+            break;
+            }
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::FindStartOfNextCommand() complete") ));
+    return foundIndex;
+    }
+
+// ---------------------------------------------------------------------------
+// Manages end of AT command handling
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdHandler::ManageEndOfCmdHandling( TBool aNotifyExternal,
+                                               TBool aNotifyLocal,
+                                               TBool aClearInput )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ManageEndOfCmdHandling()") ));
+    if ( iInputBuffer.Length() > 0 )
+        {
+        iLastBuffer.Copy( iInputBuffer );
+        }
+    ResetParseBuffers( aClearInput );
+    iHandleState = EDunStateIdle;
+    if ( aNotifyLocal )
+        {
+        iCmdPusher->SetEndOfCmdLine();
+        }
+    if ( !aNotifyExternal )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::ManageEndOfCmdHandling() (no external) complete") ));
+        return;
+        }
+    TInt foundIndex = FindStartOfNextCommand();
+    iUpstream->NotifyAtCmdHandlingEnd( foundIndex );
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ManageEndOfCmdHandling() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Extracts next decoded command from input buffer to decode buffer
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdHandler::ExtractNextDecodedCommand( TBool aPeek )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ExtractNextDecodedCommand()") ));
+    iParseInfo.iLimit = KErrNotFound;
+    TDunDecodeInfo oldInfo = iDecodeInfo;
+    iDecodeInfo.iDecodeBuffer.Zero();
+    // Find start of decode command from input buffer
+    TInt startIndex = iDecodeInfo.iDecodeIndex;
+    startIndex = FindStartOfDecodedCommand( iInputBuffer, startIndex );
+    if ( startIndex < 0 )
+        {
+        RestoreOldDecodeInfo( aPeek, oldInfo );
+        FTRACE(FPrint( _L("CDunAtCmdHandler::ExtractNextDecodedCommand() (no start) complete") ));
+        return EFalse;
+        }
+    // Find end of decode command from input buffer
+    TBool specialCmd = EFalse;
+    TInt endIndex = KErrNotFound;
+    specialCmd = CheckSpecialCommand( startIndex, endIndex );
+    if ( !specialCmd )
+        {
+        FindSubCommand( startIndex, endIndex );
+        }
+    if ( endIndex < startIndex )
+        {
+        RestoreOldDecodeInfo( aPeek, oldInfo );
+        FTRACE(FPrint( _L("CDunAtCmdHandler::ExtractNextDecodedCommand() (no end) complete") ));
+        return EFalse;
+        }
+    TInt cmdLength = endIndex - startIndex + 1;
+    // If the limit was not already set then do it now
+    if ( iParseInfo.iLimit < 0 )
+        {
+        iParseInfo.iLimit = cmdLength;
+        }
+    // Next create a new command
+    if ( !iDecodeInfo.iFirstDecode && !specialCmd )
+        {
+        _LIT( KAtMsg, "AT" );
+        iDecodeInfo.iDecodeBuffer.Append( KAtMsg );
+        iParseInfo.iLimit += 2;  // Length of "AT"
+        // Note: The length of iDecodeBuffer is not exceeded here because "AT"
+        // is added only for the second commands after that.
+        }
+    TPtrC8 decodedCmd = iInputBuffer.Mid( startIndex, cmdLength );
+    iDecodeInfo.iDecodeBuffer.Append( decodedCmd );
+    // Set index for next round
+    iDecodeInfo.iFirstDecode = EFalse;
+    iDecodeInfo.iDecodeIndex = endIndex + 1;
+    RestoreOldDecodeInfo( aPeek, oldInfo );
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ExtractNextDecodedCommand() complete") ));
+    return ETrue;
+    }
+
+// ---------------------------------------------------------------------------
+// Restores old decode info. For ExtractNextDecodedCommand() when aPeeks is
+// ETrue.
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdHandler::RestoreOldDecodeInfo( TBool aPeek,
+                                             TDunDecodeInfo& aOldInfo )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::RestoreOldDecodeInfo()") ));
+    if ( aPeek )
+        {
+        iEditorModeInfo.iPeekInfo = iDecodeInfo;
+        iDecodeInfo = aOldInfo;
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::RestoreOldDecodeInfo() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Finds end of an AT command
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtCmdHandler::FindEndOfCommand( TDesC8& aDes, TInt aStartIndex )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::FindEndOfCommand()") ));
+    TInt i;
+    TInt length = aDes.Length();
+    for ( i=aStartIndex; i<length; i++ )
+        {
+        TChar character = aDes[i];
+        if ( IsEndOfCommand(character) )
+            {
+            FTRACE(FPrint( _L("CDunAtCmdHandler::FindEndOfCommand() complete (%d)"), i ));
+            return i;
+            }
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::FindEndOfCommand() (not found) complete") ));
+    return KErrNotFound;
+    }
+
+// ---------------------------------------------------------------------------
+// Tests for end of AT command character
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdHandler::IsEndOfCommand( TChar& aCharacter )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::IsEndOfCommand()") ));
+    if ( aCharacter==iCarriageReturn || aCharacter==iLineFeed )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::IsEndOfCommand() (found) complete") ));
+        return ETrue;
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::IsEndOfCommand() (not found) complete") ));
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// Finds start of a decoded AT command
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtCmdHandler::FindStartOfDecodedCommand( TDesC8& aDes,
+                                                  TInt aStartIndex )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::FindStartOfDecodedCommand()") ));
+    TInt i;
+    TInt count = aDes.Length();
+    for ( i=aStartIndex; i<count; i++ )
+        {
+        TChar character = aDes[i];
+        if ( !IsDelimiterCharacter(character) )
+            {
+            FTRACE(FPrint( _L("CDunAtCmdHandler::FindStartOfDecodedCommand() complete (%d)"), i ));
+            return i;
+            }
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::FindStartOfDecodedCommand() (not found) complete") ));
+    return KErrNotFound;
+    }
+
+// ---------------------------------------------------------------------------
+// Checks if character is delimiter character
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdHandler::IsDelimiterCharacter( TChar aCharacter )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::IsDelimiterCharacter()") ));
+    if ( aCharacter.IsSpace() || aCharacter==';' || aCharacter==0x00 )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::IsDelimiterCharacter() complete") ));
+        return ETrue;
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::IsDelimiterCharacter() (not delimiter) complete") ));
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// Checks if character is of extended group
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdHandler::IsExtendedCharacter( TChar aCharacter )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::IsExtendedCharacter()") ));
+    if ( aCharacter=='+'  || aCharacter=='&' || aCharacter=='%' ||
+         aCharacter=='\\' || aCharacter=='*' || aCharacter=='#' ||
+         aCharacter=='$'  || aCharacter=='^' )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::IsExtendedCharacter() complete") ));
+        return ETrue;
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::IsExtendedCharacter() (not extended) complete") ));
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// Checks special command
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdHandler::CheckSpecialCommand( TInt aStartIndex,
+                                             TInt& aEndIndex )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::CheckSpecialCommand()") ));
+    TBuf8<KDunInputBufLength> upperBuf;
+    TInt newLength = iInputBuffer.Length() - aStartIndex;
+    upperBuf.Copy( &iInputBuffer[aStartIndex], newLength );
+    upperBuf.UpperCase();
+    TInt i;
+    TInt count = iSpecials.Count();
+    for ( i=0; i<count; i++ )
+        {
+        HBufC8* specialCmd = iSpecials[i];
+        TInt specialLength = specialCmd->Length();
+        if ( newLength < specialLength )
+            {
+            continue;
+            }
+        TInt origLength = newLength;
+        if ( newLength > specialLength )
+            {
+            upperBuf.SetLength( specialLength );
+            }
+        TInt cmpResult = upperBuf.Compare( *specialCmd );
+        upperBuf.SetLength( origLength );
+        if ( cmpResult == 0 )
+            {
+            iParseInfo.iLimit = specialLength;
+            aEndIndex = (origLength-1) + aStartIndex;
+            FTRACE(FPrint( _L("CDunAtCmdHandler::CheckSpecialCommand() complete") ));
+            return ETrue;
+            }
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::CheckSpecialCommand() (not found) complete") ));
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// Saves character decode state for a found character
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdHandler::SaveFoundCharDecodeState( TChar aCharacter,
+                                                 TBool aAddSpecial )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::SaveFoundCharDecodeState()") ));
+    iDecodeInfo.iPrevExists = ETrue;
+    iDecodeInfo.iPrevChar = aCharacter;
+    if ( aAddSpecial )
+        {
+        iDecodeInfo.iSpecialFound =
+                iAtSpecialCmdHandler->IsCompleteSubCommand( aCharacter );
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::SaveFoundCharDecodeState() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Saves character decode state for a not found character
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdHandler::SaveNotFoundCharDecodeState()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::SaveNotFoundCharDecodeState()") ));
+    iDecodeInfo.iPrevExists = EFalse;
+    // Note: don't set iAssignFound or iInQuotes here
+    iDecodeInfo.iSpecialFound = EFalse;
+    FTRACE(FPrint( _L("CDunAtCmdHandler::SaveNotFoundCharDecodeState() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Find quotes within subcommands
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdHandler::FindSubCommandQuotes( TChar aCharacter,
+                                              TInt aStartIndex,
+                                              TInt& aEndIndex )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommandQuotes()") ));
+    if ( aCharacter == '"' )
+        {
+        if ( iParseInfo.iLimit < 0 )  // Only first the first '"'
+            {
+            iParseInfo.iLimit = aEndIndex - aStartIndex;
+            }
+        iDecodeInfo.iInQuotes ^= ETrue;  // EFalse to ETrue or ETrue to EFalse
+        SaveFoundCharDecodeState( aCharacter, EFalse );
+        FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommandQuotes() (quote) complete") ));
+        return ETrue;
+        }
+    // The next ones are those that are not in quotes.
+    // We still need to save the iParseInfo.iLimit and skip non-delimiter characters.
+    if ( aCharacter == '=' )
+        {
+        if ( iParseInfo.iLimit < 0 )  // Only first the first '"'
+            {
+            iParseInfo.iLimit = aEndIndex - aStartIndex;
+            }
+        iDecodeInfo.iAssignFound = ETrue;
+        SaveFoundCharDecodeState( aCharacter, EFalse );
+        FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommandQuotes() (equals) complete") ));
+        return ETrue;
+        }
+    if ( iDecodeInfo.iInQuotes )
+        {
+        SaveNotFoundCharDecodeState();
+        FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommandQuotes() (in quotes) complete") ));
+        return ETrue;
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommandQuotes() (not found) complete") ));
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// Check if in next subcommand's extended border
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdHandler::IsExtendedBorder( TChar aCharacter,
+                                          TInt aStartIndex,
+                                          TInt& aEndIndex )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::IsExtendedBorder()") ));
+    TInt expectedIndex = 0;  // "+CMD" when iDecodeInfo.iFirstDecode is EFalse
+    TInt extendedIndex = aEndIndex - aStartIndex;  // absolute index to the extended character
+    if ( iDecodeInfo.iFirstDecode )
+        {
+        expectedIndex = 2;  // "AT+CMD"
+        }
+    if ( extendedIndex == expectedIndex )
+        {
+        iDecodeInfo.iExtendedIndex = aEndIndex;
+        SaveFoundCharDecodeState( aCharacter );
+        FTRACE(FPrint( _L("CDunAtCmdHandler::IsExtendedBorder() (no border) complete") ));
+        return EFalse;
+        }
+    aEndIndex--;
+    FTRACE(FPrint( _L("CDunAtCmdHandler::IsExtendedBorder() (border) complete") ));
+    return ETrue;
+    }
+
+// ---------------------------------------------------------------------------
+// Finds subcommand with alphanumeric borders
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdHandler::FindSubCommandAlphaBorder( TChar aCharacter,
+                                                   TInt& aEndIndex )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommandAlphaBorder()") ));
+    if ( iDecodeInfo.iAssignFound && !iDecodeInfo.iInQuotes )
+        {
+        // Check the special case when assigning a number with "basic" command
+        // and there is no delimiter after it. In this case <Numeric>|<Alpha>
+        // border must be detected but only for a "basic" command, not for
+        // extended.
+        if ( iDecodeInfo.iExtendedIndex<0    && iDecodeInfo.iPrevExists &&
+             iDecodeInfo.iPrevChar.IsDigit() && aCharacter.IsAlpha() )
+            {
+            aEndIndex--;
+            FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommandAlphaBorder() (N|A) complete") ));
+            return ETrue;
+            }
+        // The code below is for the following type of cases:
+        // (do not check alphanumeric borders if "=" set without quotes):
+        // AT+CMD=a
+        FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommandAlphaBorder() (skip) complete") ));
+        return EFalse;
+        }
+    if ( !iDecodeInfo.iPrevExists || !aCharacter.IsAlpha() )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommandAlphaBorder() (not found) complete") ));
+        return EFalse;
+        }
+    if ( iDecodeInfo.iPrevChar.IsAlpha() )
+        {
+        // The check below detects the following type of cases
+        // (note that special handling is needed to separate the Alpha|Alpha boundary):
+        // AT&FE0
+        if ( iDecodeInfo.iSpecialFound )
+            {
+            // Special command was found before and this is Alpha|Alpha boundary -> end
+            aEndIndex--;
+            FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommandAlphaBorder() (special) complete") ));
+            return ETrue;
+            }
+        // The code below is for the following type of cases
+        // (note there is no border between C|M, for example -> continue):
+        // ATCMD
+        FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommandAlphaBorder() (continue) complete") ));
+        return EFalse;
+        }
+    // The code below is for skipping the following type of cases:
+    // AT+CMD [the '+' must be skipped]
+    if ( aEndIndex-1 == iDecodeInfo.iExtendedIndex )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommandAlphaBorder() (extended) complete") ));
+        return EFalse;
+        }
+    // The code below is for the following type of cases:
+    // ATCMD?ATCMD
+    FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommandAlphaBorder() (boundary) complete") ));
+    aEndIndex--;
+    return ETrue;
+    }
+
+// ---------------------------------------------------------------------------
+// Finds subcommand
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtCmdHandler::FindSubCommand( TInt aStartIndex, TInt& aEndIndex )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommand()") ));
+    aEndIndex = aStartIndex;
+    TBool found = EFalse;
+    TInt length = iInputBuffer.Length();
+    iDecodeInfo.iAssignFound = EFalse;
+    iDecodeInfo.iInQuotes = EFalse;
+    iDecodeInfo.iExtendedIndex = KErrNotFound;
+    SaveNotFoundCharDecodeState();
+    iAtSpecialCmdHandler->ResetComparisonBuffer();  // just to be sure
+    for ( ; aEndIndex<length; aEndIndex++ )
+        {
+        TChar character = iInputBuffer[aEndIndex];
+        found = FindSubCommandQuotes( character, aStartIndex, aEndIndex );
+        if ( found )
+            {
+            continue;
+            }
+        if ( character == '?' )
+            {
+            FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommand() (?) complete") ));
+            return KErrNone;
+            }
+        // The check below detects the following type of cases:
+        // ATCMD<delimiter>
+        if ( IsDelimiterCharacter(character) )
+            {
+            aEndIndex--;
+            FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommand() (delimiter) complete") ));
+            return KErrNone;
+            }
+        // The check below detects the following type of cases:
+        // ATCMD+CMD [first + as delimiter]
+        // AT+CMD+CMD [second + as delimiter]
+        if ( IsExtendedCharacter(character) )
+            {
+            found = IsExtendedBorder( character, aStartIndex, aEndIndex );
+            if ( !found )
+                {
+                continue;
+                }
+            FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommand() (extended) complete") ));
+            return KErrNone;
+            }
+        found = FindSubCommandAlphaBorder( character, aEndIndex );
+        if ( found )
+            {
+            FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommand() (alpha sub) complete") ));
+            return KErrNone;
+            }
+        SaveFoundCharDecodeState( character );
+        }
+    aEndIndex--;
+    FTRACE(FPrint( _L("CDunAtCmdHandler::FindSubCommand() (not found) complete") ));
+    return KErrNotFound;
+    }
+
+// ---------------------------------------------------------------------------
+// Check if "A/" command
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdHandler::IsASlashCommand()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::IsASlashCommand()") ));
+    if ( iInputBuffer.Length() == 2 )
+        {
+        if ( iInputBuffer[1] == '/' &&
+            (iInputBuffer[0] == 'A' || iInputBuffer[0] == 'a') )
+            {
+            FTRACE(FPrint( _L("CDunAtCmdHandler::IsASlashCommand() (found) complete") ));
+            return ETrue;
+            }
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::IsASlashCommand() (not found) complete") ));
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// Handles "A/" command
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdHandler::HandleASlashCommand()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::HandleASlashCommand()") ));
+    // If not "A/" command, return
+    if ( !IsASlashCommand() )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::HandleASlashCommand() (no push) complete") ));
+        return EFalse;
+        }
+    // If "A/" command and last buffer exist, set the last buffer as the current buffer
+    if ( iLastBuffer.Length() > 0 )
+        {
+        iInputBuffer.Copy( iLastBuffer );
+        FTRACE(FPrint( _L("CDunAtCmdHandler::HandleASlashCommand() (copy) complete") ));
+        return EFalse;
+        }
+    // Last buffer not set so return "ERROR" if quiet mode not on
+    if ( iQuietOn )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::HandleASlashCommand() (quiet) complete") ));
+        return EFalse;
+        }
+    iDownstream->NotifyDataPushRequest( &iErrorBuffer, NULL );
+    FTRACE(FPrint( _L("CDunAtCmdHandler::HandleASlashCommand() complete") ));
+    return ETrue;
+    }
+
+// ---------------------------------------------------------------------------
+// Resets parse buffers
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdHandler::ResetParseBuffers( TBool aClearInput )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ResetParseBuffers()") ));
+    if ( aClearInput )
+        {
+        iInputBuffer.Zero();
+        }
+    iDecodeInfo.iFirstDecode = ETrue;
+    iDecodeInfo.iDecodeIndex = 0;
+    iDecodeInfo.iPrevExists = EFalse;
+    iDecodeInfo.iDecodeBuffer.Zero();
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ResetParseBuffers() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Manages command mode change
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdHandler::ManageCommandModeChange( TUint aMode )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ManageCommandModeChange()" ) ));
+    if ( aMode & KCommandModeChanged )
+        {
+        if ( aMode & KModeCommand )  // command mode ON
+            {
+            ReportCommandModeChange( ETrue );
+            FTRACE(FPrint( _L("CDunAtCmdHandler::ManageCommandModeChange() command mode changed ON" ) ));
+            }
+        else  // command mode OFF
+            {
+            ReportCommandModeChange( EFalse );
+            FTRACE(FPrint( _L("CDunAtCmdHandler::ManageCommandModeChange() command mode changed OFF" ) ));
+            }
+        FTRACE(FPrint( _L("CDunAtCmdHandler::ManageCommandModeChange() (change) complete" ) ));
+        return ETrue;
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ManageCommandModeChange()" ) ));
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// Reports command mode start/end change
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdHandler::ReportCommandModeChange( TBool aStart )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ReportCommandModeChange()" ) ));
+    TInt i;
+    TInt count = iCmdCallbacks.Count();
+    if ( aStart )
+        {
+        if ( iDataMode )
+            {
+            for ( i=0; i<count; i++ )
+                {
+                iCmdCallbacks[i]->NotifyCommandModeStart();
+                }
+            iDataMode = EFalse;
+            }
+        }
+    else  // end
+        {
+        if ( !iDataMode )
+            {
+            for ( i=0; i<count; i++ )
+                {
+                iCmdCallbacks[i]->NotifyCommandModeEnd();
+                }
+            iDataMode = ETrue;
+            }
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ReportCommandModeChange() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// Manages echo mode change
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdHandler::ManageEchoModeChange( TUint aMode )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ManageEchoModeChange()" ) ));
+    if ( aMode & KEchoModeChanged )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::ManageEchoModeChange() checking echo mode..." ) ));
+        if ( aMode & KModeEcho )  // echo mode ON
+            {
+            iEchoOn = ETrue;
+            FTRACE(FPrint( _L("CDunAtCmdHandler::ManageEchoModeChange() echo mode changed ON" ) ));
+            }
+        else  // echo mode OFF
+            {
+            iEchoOn = EFalse;
+            FTRACE(FPrint( _L("CDunAtCmdHandler::ManageEchoModeChange() echo mode changed OFF" ) ));
+            }
+        FTRACE(FPrint( _L("CDunAtCmdHandler::ManageEchoModeChange() (change) complete" ) ));
+        return ETrue;
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ManageEchoModeChange() complete" ) ));
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// Manages quiet mode change
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdHandler::ManageQuietModeChange( TUint aMode )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ManageQuietModeChange()" ) ));
+    if ( aMode & KQuietModeChanged )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::ManageEchoModeChange() checking quiet mode..." ) ));
+        if ( aMode & KModeQuiet )  // quiet mode ON
+            {
+            iAtCmdExt.ReportQuietModeChange( ETrue );
+            iQuietOn = ETrue;
+            FTRACE(FPrint( _L("CDunAtCmdHandler::ManageQuietModeChange() quiet mode changed ON" ) ));
+            }
+        else  // quiet mode OFF
+            {
+            iAtCmdExt.ReportQuietModeChange( EFalse );
+            iQuietOn = EFalse;
+            FTRACE(FPrint( _L("CDunAtCmdHandler::ManageQuietModeChange() quiet mode changed OFF" ) ));
+            }
+        FTRACE(FPrint( _L("CDunAtCmdHandler::ManageQuietModeChange() (change) complete" ) ));
+        return ETrue;
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ManageQuietModeChange() complete" ) ));
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// Manages quiet mode change
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdHandler::ManageVerboseModeChange( TUint aMode )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ManageVerboseModeChange()" ) ));
+    if ( aMode & KVerboseModeChanged )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::ManageVerboseModeChange() checking verbose mode..." ) ));
+        if ( aMode & KModeVerbose )  // verbose mode ON
+            {
+            iAtCmdExt.ReportVerboseModeChange( ETrue );
+            iVerboseOn = ETrue;
+            FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyVerboseStatusChange() verbose mode changed ON" ) ));
+            }
+        else  // verbose mode OFF
+            {
+            iAtCmdExt.ReportVerboseModeChange( EFalse );
+            iVerboseOn = EFalse;
+            FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyVerboseStatusChange() verbose mode changed OFF" ) ));
+            }
+        FTRACE(FPrint( _L("CDunAtCmdHandler::ManageVerboseModeChange() (change) complete" ) ));
+        return ETrue;
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ManageVerboseModeChange() complete" ) ));
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// Manages character change
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdHandler::ManageCharacterChange( TUint aMode )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ManageCharacterChange()" ) ));
+    if ( aMode & KCarriageChanged )
+        {
+        iCarriageReturn = aMode & (KModeChanged-1);
+        iAtCmdExt.ReportCharacterChange( ECharTypeCarriage, iCarriageReturn );
+        FTRACE(FPrint( _L("CDunAtCmdHandler::ManageCharacterChange() carriage return changed" ) ));
+        }
+    else if ( aMode & KLineFeedChanged )
+        {
+        iLineFeed = aMode & (KModeChanged-1);
+        iAtCmdExt.ReportCharacterChange( ECharTypeLineFeed, iLineFeed );
+        FTRACE(FPrint( _L("CDunAtCmdHandler::ManageCharacterChange() line feed changed" ) ));
+        }
+    else if ( aMode & KBackspaceChanged )
+        {
+        iBackspace = aMode & (KModeChanged-1);
+        iAtCmdExt.ReportCharacterChange( ECharTypeBackspace, iBackspace );
+        FTRACE(FPrint( _L("CDunAtCmdHandler::ManageCharacterChange() backspace changed" ) ));
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ManageCharacterChange() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// Manages editor mode reply
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtCmdHandler::ManageEditorModeReply( TBool aStart )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ManageEditorModeReply()" ) ));
+    // Two modes possible here:
+    // 1) Sending data directly from DTE to DCE, i.e. no subsequent data in
+    //    the input buffer -> Reissue read request from DTE.
+    // 2) Sending data from input buffer to DCE -> Do not reissue read request
+    //    from DTE: send the data in a loop
+    // In summary: send data byte-by-byte in editor mode until end of input.
+    // When end of input notify CDunUpstream to reissue the read request.
+    TBool nextContentFound = FindNextContent( aStart );
+    if ( !nextContentFound )
+        {
+        iUpstream->NotifyEditorModeReply( aStart );
+        FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyEditorModeReply() complete") ));
+        return KErrNone;
+        }
+    // In block mode end the block mode by sending <ESC> and hope it works.
+    iEscapeBuffer.Zero();
+    iEscapeBuffer.Append( KDunEscape );
+    iCmdPusher->IssueRequest( iEscapeBuffer, EFalse );
+    FTRACE(FPrint( _L("CDunAtCmdHandler::ManageEditorModeReply() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Finds the next content from the input data
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdHandler::FindNextContent( TBool aStart )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::FindNextContent()" ) ));
+    if ( !aStart )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::FindNextContent() (skip) complete" ) ));
+        return iEditorModeInfo.iContentFound;
+        }
+    iEditorModeInfo.iContentFound = EFalse;
+    TInt foundCmdIndex = KErrNotFound;
+    TBool nextContentFound = ExtractNextDecodedCommand( ETrue );  // peek
+    if ( !nextContentFound )
+        {
+        // Check the next subblock
+        foundCmdIndex = FindStartOfNextCommand();
+        }
+    if ( !nextContentFound && foundCmdIndex<0 )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::FindNextContent() (not found) complete") ));
+        return EFalse;
+        }
+    iEditorModeInfo.iContentFound = ETrue;
+    FTRACE(FPrint( _L("CDunAtCmdHandler::FindNextContent() complete" ) ));
+    return ETrue;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunAtCmdPusher.
+// Notifies about end of AT command processing. This is after all reply data
+// for an AT command is multiplexed to the downstream.
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtCmdHandler::NotifyEndOfProcessing( TInt /*aError*/ )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyEndOfProcessing()" ) ));
+    TBool editorMode = iCmdPusher->EditorMode();
+    if ( editorMode )
+        {
+        ManageEditorModeReply( ETrue );
+        FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyEndOfProcessing() (editor) complete" ) ));
+        return KErrNone;
+        }
+    HandleNextDecodedCommand();
+    FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyEndOfProcessing() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunAtCmdPusher.
+// Notifies about request to stop AT command handling for the rest of the
+// command line data
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtCmdHandler::NotifyEndOfCmdLineProcessing()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyEndOfCmdLineProcessing()" ) ));
+    TInt retVal = Stop();
+    ManageEndOfCmdHandling( ETrue, EFalse, ETrue );
+    FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyEndOfCmdLineProcessing() complete" ) ));
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunAtCmdPusher.
+// Notifies about request to peek for the next command
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdHandler::NotifyNextCommandPeekRequest()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyNextCommandPeekRequest()") ));
+    TBool extracted = ExtractNextDecodedCommand( ETrue );
+    FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyNextCommandPeekRequest() complete") ));
+    return extracted;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunAtCmdPusher.
+// Notifies about editor mode reply
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtCmdHandler::NotifyEditorModeReply()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyEditorModeReply()") ));
+    TInt retVal = ManageEditorModeReply( EFalse );
+    FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyEditorModeReply() complete") ));
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunAtEcomListen.
+// Notifies about new plugin installation
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtCmdHandler::NotifyPluginInstallation( TUid& /*aPluginUid*/ )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyPluginInstallation()" ) ));
+    CDunAtUrcHandler* urcHandler = NULL;
+    TRAPD( retTrap, urcHandler=AddOneUrcHandlerL() );
+    if ( retTrap != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyPluginInstallation() (trapped!) complete" ) ));
+        return retTrap;
+        }
+    TInt retTemp = urcHandler->IssueRequest();
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyPluginInstallation() (issuerequest) complete" ) ));
+        return retTemp;
+        }
+    TUid ownerUid = urcHandler->OwnerUid();
+    iAtCmdExt.ReportListenerUpdateReady( ownerUid, EEcomTypeInstall );
+    // As a last step recreate the special command data
+    retTemp = RecreateSpecialCommands();
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyPluginInstallation() (recreate) complete" ) ));
+        return retTemp;
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyPluginInstallation() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunAtEcomListen.
+// Notifies about existing plugin uninstallation
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtCmdHandler::NotifyPluginUninstallation( TUid& aPluginUid )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyPluginUninstallation()" ) ));
+    TInt i;
+    TInt count = iUrcHandlers.Count();
+    for ( i=count-1; i>=0; i-- )
+        {
+        TUid ownerUid = iUrcHandlers[i]->OwnerUid();
+        if ( ownerUid == aPluginUid )
+            {
+            delete iUrcHandlers[i];
+            iUrcHandlers.Remove( i );
+            iAtCmdExt.ReportListenerUpdateReady( ownerUid,
+                                                 EEcomTypeUninstall );
+            }
+        }
+    // As a last step recreate the special command data
+    TInt retTemp = RecreateSpecialCommands();
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyPluginUninstallation() (recreate) complete" ) ));
+        return retTemp;
+        }
+    FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyPluginUninstallation() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunAtModeListen.
+// Gets called on mode status change
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtCmdHandler::NotifyModeStatusChange( TUint aMode )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyModeStatusChange()") ));
+    TBool commandModeSet = ManageCommandModeChange( aMode );
+    TBool echoModeSet = ManageEchoModeChange( aMode );
+    TBool quietModeSet = ManageQuietModeChange( aMode );
+    TBool verboseModeSet = ManageVerboseModeChange( aMode );
+    if ( quietModeSet || verboseModeSet )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyModeStatusChange() new settings: E=%d, Q=%d, V=%d"), iEchoOn, iQuietOn, iVerboseOn ));
+        FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyModeStatusChange() (regenerate) mode set" ) ));
+        RegenerateReplyStrings();
+        return KErrNone;
+        }
+    // Keep the following after "quietModeSet || verboseModeSet" in order to
+    // regenerate the reply also if two modes change at the same time
+    if ( commandModeSet || echoModeSet )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyModeStatusChange() new settings: E=%d, Q=%d, V=%d"), iEchoOn, iQuietOn, iVerboseOn ));
+        FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyModeStatusChange() mode set" ) ));
+        return KErrNone;
+        }
+    ManageCharacterChange( aMode );
+    FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyModeStatusChange() new settings: CR=%u, LF=%u, BS=%u"), iCarriageReturn, iLineFeed, iBackspace ));
+    RegenerateReplyStrings();
+    FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyModeStatusChange() complete") ));
+    return KErrNone;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/atext/src/DunAtCmdPusher.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,515 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  AT command pusher for downstream
+*
+*/
+
+/*
+ * Filtering categories for multiple commands on one line (DunAtCmdPusher.cpp)
+ * (here "OTHER" reply means a reply which is something else than "OK" and "ERROR")
+ * One reply:     OK           -> OK
+ * One reply:     OTHER        -> OTHER
+ * One reply:     ERROR        -> ERROR
+ * Two replies:   OK, OK       -> OK
+ * Two replies:   OTHER, OTHER -> OTHER, OTHER
+ * Two replies:   OK, OTHER    -> OTHER
+ * Two replies:   OTHER, OK    -> OTHER
+ * Two replies:   OK, ERROR    -> ERROR
+ * Two replies:   OTHER, ERROR -> OTHER, ERROR
+ * Note: "OK" replies are skipped. The "OK" string is stripped from the "OTHER"
+ * replies and manually added the the downstream as the last operation if either
+ * "OK" or "OTHER" was received before.
+ */
+
+#include "DunAtCmdPusher.h"
+#include "DunDownstream.h"
+#include "DunDebug.h"
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunAtCmdPusher* CDunAtCmdPusher::NewL(
+    RATExt* aAtCmdExt,
+    MDunAtCmdPusher* aCallback,
+    MDunStreamManipulator* aDownstream,
+    TDesC8* aOkBuffer )
+    {
+    CDunAtCmdPusher* self = NewLC( aAtCmdExt,
+                                   aCallback,
+                                   aDownstream,
+                                   aOkBuffer );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunAtCmdPusher* CDunAtCmdPusher::NewLC(
+    RATExt* aAtCmdExt,
+    MDunAtCmdPusher* aCallback,
+    MDunStreamManipulator* aDownstream,
+    TDesC8* aOkBuffer )
+    {
+    CDunAtCmdPusher* self = new (ELeave) CDunAtCmdPusher( aAtCmdExt,
+                                                          aCallback,
+                                                          aDownstream,
+                                                          aOkBuffer );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunAtCmdPusher::~CDunAtCmdPusher()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdPusher::~CDunAtCmdPusher()") ));
+    ResetData();
+    FTRACE(FPrint( _L("CDunAtCmdPusher::~CDunAtCmdPusher() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Resets data to initial values
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdPusher::ResetData()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdPusher::ResetData()") ));
+    // APIs affecting this:
+    // IssueRequest()
+    Stop();
+    // Internal
+    Initialize();
+    FTRACE(FPrint( _L("CDunAtCmdPusher::ResetData() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Starts AT command handling
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtCmdPusher::IssueRequest( TDesC8& aCommand, TBool aNormalMode )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdPusher::IssueRequest()") ));
+    FTRACE(FPrint( _L("CDunAtCmdPusher::IssueRequest() send ATEXT:") ));
+    FTRACE(FPrintRaw(aCommand) );
+    if ( iAtPushState!=EDunStateIdle && aNormalMode )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdPusher::IssueRequest() (not ready) complete") ));
+        return KErrNotReady;
+        }
+    iStatus = KRequestPending;
+    iAtCmdExt->HandleCommand( iStatus,
+                              aCommand,
+                              iRecvBuffer,
+                              iReplyLeftPckg,
+                              iReplyTypePckg );
+    SetActive();
+    iAtPushState = EDunStateAtCmdPushing;
+    FTRACE(FPrint( _L("CDunAtCmdPusher::IssueRequest() complete") ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Stops AT command handling
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtCmdPusher::Stop()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdPusher::Stop()") ));
+    if ( iAtPushState != EDunStateAtCmdPushing )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::Stop() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    // As the EDunStateAtCmdHandling can be set even when the actual request
+    // has completed (when replying with NotifyDataPushComplete() and setting
+    // idle eventually), cancel the actual operation in DoCancel()
+    Cancel();
+    iAtPushState = EDunStateIdle;
+    SetEndOfCmdLine();
+    FTRACE(FPrint( _L("CDunAtCmdPusher::Stop() complete") ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Manages request to abort command handling
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtCmdPusher::ManageAbortRequest()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdPusher::ManageAbortRequest()") ));
+    if ( iAtPushState != EDunStateAtCmdPushing )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdHandler::ManageAbortRequest() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    if ( iCmdAbort )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdPusher::ManageAbortRequest() (already exists) complete") ));
+        return KErrAlreadyExists;
+        }
+    TInt retTemp = iAtCmdExt->ReportHandleCommandAbort( iStop );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdPusher::ManageAbortRequest() (ERROR) complete") ));
+        return retTemp;
+        }
+    iCmdAbort = ETrue;
+    FTRACE(FPrint( _L("CDunAtCmdPusher::ManageAbortRequest() complete") ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Sets end of command line marker on for the possible series of AT commands.
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdPusher::SetEndOfCmdLine()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdPusher::SetEndOfCmdLine()") ));
+    iNoErrorReceived = EFalse;
+    iLastOkPush = EFalse;
+    iCmdAbort = EFalse;
+    iStop = EFalse;
+    iEditorMode = EFalse;
+    FTRACE(FPrint( _L("CDunAtCmdPusher::SetEndOfCmdLine() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Gets the editor mode status
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtCmdPusher::EditorMode()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdPusher::EditorMode()") ));
+    FTRACE(FPrint( _L("CDunAtCmdPusher::EditorMode() complete") ));
+    return iEditorMode;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunAtCmdPusher::CDunAtCmdPusher
+// ---------------------------------------------------------------------------
+//
+CDunAtCmdPusher::CDunAtCmdPusher( RATExt* aAtCmdExt,
+                                  MDunAtCmdPusher* aCallback,
+                                  MDunStreamManipulator* aDownstream,
+                                  TDesC8* aOkBuffer ) :
+    CActive( EPriorityHigh ),
+    iAtCmdExt( aAtCmdExt ),
+    iCallback( aCallback ),
+    iDownstream( aDownstream ),
+    iOkBuffer( aOkBuffer ),
+    iReplyLeftPckg( iReplyBytesLeft ),
+    iReplyTypePckg( iReplyType )
+    {
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// CDunAtCmdPusher::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdPusher::ConstructL()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdPusher::ConstructL()") ));
+    if ( !iAtCmdExt || !iCallback || !iDownstream || !iOkBuffer )
+        {
+        User::Leave( KErrGeneral );
+        }
+    CActiveScheduler::Add( this );
+    FTRACE(FPrint( _L("CDunAtCmdPusher::ConstructL() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes this class
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdPusher::Initialize()
+    {
+    // Don't initialize iAtCmdExt here (it is set through NewL)
+    // Don't initialize iCallback here (it is set through NewL)
+    // Don't initialize iDownstream here (it is set through NewL)
+    // Don't initialize iOkBuffer here (it is set through NewL)
+    iAtPushState = EDunStateIdle;
+    iReplyBytesLeft = 0;
+    iReplyType = EReplyTypeUndefined;
+    SetEndOfCmdLine();
+    }
+
+// ---------------------------------------------------------------------------
+// Sets state to idle and notifies about subcommand handling completion
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdPusher::SetToIdleAndNotifyEnd( TInt aError )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdPusher::SetToIdleAndNotifyEnd()") ));
+    iCmdAbort = EFalse;
+    iAtPushState = EDunStateIdle;
+    iCallback->NotifyEndOfProcessing( aError );
+    FTRACE(FPrint( _L("CDunAtCmdPusher::SetToIdleAndNotifyEnd() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Checks if "OK" (verbose) or "0" (numeric) string or exists at the end of
+// buffer and removes it
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtCmdPusher::CheckAndRemoveOkString()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdPusher::CheckAndRemoveOkString()") ));
+    TInt recvBufferLength = iRecvBuffer.Length();
+    TInt okBufferLength = iOkBuffer->Length();
+    // Skip the removal if removing not possible, if removal results in zero
+    // length (plugin should have used KErrReplyTypeOk) or if string to be
+    // removed is zero.
+    // Note also that if plugin sends a final reply when quiet mode is on, DUN
+    // can't remove the possibly existing result code as it is different from
+    // iOkReply (zero length).
+    if ( recvBufferLength<=okBufferLength || okBufferLength<=0 )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdPusher::CheckAndRemoveOkString() (skip) complete") ));
+        return KErrGeneral;
+        }
+    TInt lengthWithNoOk = recvBufferLength - okBufferLength;
+    TPtr8 recvBufferDes( &iRecvBuffer[lengthWithNoOk], okBufferLength, okBufferLength );
+    if ( recvBufferDes.Compare(*iOkBuffer) != 0 )
+        {
+        FTRACE(FPrint( _L("CDunAtCmdPusher::CheckAndRemoveOkString() (not found) complete") ));
+        return KErrNotFound;
+        }
+    iRecvBuffer.SetLength( lengthWithNoOk );
+    FTRACE(FPrint( _L("CDunAtCmdPusher::CheckAndRemoveOkString() complete") ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Sends reply data to downstream
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdPusher::SendReplyData( TBool aRecvBuffer )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdPusher::SendReplyData()") ));
+    TDesC8* sendBuffer = iOkBuffer;
+    if ( aRecvBuffer )
+        {
+        sendBuffer = &iRecvBuffer;
+        // Check if last block of long push and remove "OK" if exists
+        if ( iReplyType==EReplyTypeOther && iReplyBytesLeft==0 )
+            {
+            CheckAndRemoveOkString();
+            }
+        }
+    FTRACE(FPrint( _L("CDunAtCmdPusher::SendReplyData() send reply:") ));
+    FTRACE(FPrintRaw(*sendBuffer) );
+    iDownstream->NotifyDataPushRequest( sendBuffer, this );
+    FTRACE(FPrint( _L("CDunAtCmdPusher::SendReplyData() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Manages change in reply type to EReplyTypeOther
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdPusher::ManageReplyTypeChangeToOther()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToOther()") ));
+    iNoErrorReceived = ETrue;
+    SendReplyData();
+    FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToOther() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Manages change in reply type to EReplyTypeOk
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdPusher::ManageReplyTypeChangeToOk()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToOk()") ));
+    // Skip the "OK" replies if not last. Only push the "OK" reply at the end.
+    // iStop changes it so that the we have to send the "OK" immediately and
+    // only stop with NotifyDataPushComplete()
+    TBool found = iCallback->NotifyNextCommandPeekRequest();
+    if ( !found || iStop )
+        {
+        SendReplyData();
+        }
+    else
+        {
+        iNoErrorReceived = ETrue;
+        SetToIdleAndNotifyEnd( KErrNone );
+        }
+    FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToOk() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Manages change in reply type to EReplyTypeError
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdPusher::ManageReplyTypeChangeToError()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToError()") ));
+    if ( iNoErrorReceived )
+       {
+       iAtCmdExt->ReportExternalHandleCommandError();
+       }
+    SendReplyData();
+    FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToError() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Manages change in reply type to EReplyTypeEditor
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdPusher::ManageReplyTypeChangeToEditor()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToEditor()") ));
+    if ( !iEditorMode )
+        {
+        // First change to editor mode: manage it as EReplyTypeOther (prompt)
+        iEditorMode = ETrue;
+        ManageReplyTypeChangeToOther();
+        FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToEditor() (editor) complete") ));
+        return;
+        }
+    // The same reply to editor mode as before: no reply, only notification for
+    // echo/forwarding purposes
+    iCallback->NotifyEditorModeReply();
+    // Do nothing after notifying. The next ForwardEditorModeInput() triggers
+    // the next call of this function.
+    FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToEditor() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Manages change in reply type
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdPusher::ManageReplyTypeChange()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChange()") ));
+    switch ( iReplyType )
+        {
+        case EReplyTypeOther:
+            {
+            FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChange() EReplyTypeOther") ));
+            iEditorMode = EFalse;
+            ManageReplyTypeChangeToOther();
+            }
+            break;
+        case EReplyTypeOk:
+            {
+            FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChange() EReplyTypeOk") ));
+            iEditorMode = EFalse;
+            ManageReplyTypeChangeToOk();
+            }
+            break;
+        case EReplyTypeError:
+            {
+            FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChange() EReplyTypeError") ));
+            iEditorMode = EFalse;
+            ManageReplyTypeChangeToError();
+            }
+            break;
+        case EReplyTypeEditor:
+            FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChange() EReplyTypeEditor") ));
+            ManageReplyTypeChangeToEditor();
+            break;
+        default:
+            {
+            FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChange() EReplyTypeUndefined") ));
+            iEditorMode = EFalse;
+            SetToIdleAndNotifyEnd( KErrNone );
+            }
+            break;
+        }
+    FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChange() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called when AT command handled
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdPusher::RunL()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdPusher::RunL()") ));
+    TInt retTemp = iStatus.Int();
+    if ( retTemp != KErrNone )
+        {
+        SetToIdleAndNotifyEnd( retTemp );
+        FTRACE(FPrint( _L("CDunAtCmdPusher::RunL() (ERROR) complete (%d)"), retTemp));
+        return;
+        }
+    ManageReplyTypeChange();
+    FTRACE(FPrint( _L("CDunAtCmdPusher::RunL() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called on cancel
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdPusher::DoCancel()
+    {
+    FTRACE(FPrint( _L("CDunAtCmdPusher::DoCancel()") ));
+    iAtCmdExt->CancelHandleCommand();
+    FTRACE(FPrint( _L("CDunAtCmdPusher::DoCancel() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunCompletionReporter.
+// Gets called when data push is complete
+// ---------------------------------------------------------------------------
+//
+void CDunAtCmdPusher::NotifyDataPushComplete( TBool /*aAllPushed*/ )
+    {
+    FTRACE(FPrint( _L("CDunAtCmdPusher::NotifyDataPushComplete()") ));
+    // First check if error or stop condition detected
+    if ( iReplyType==EReplyTypeError || iStop )
+        {
+        iCallback->NotifyEndOfCmdLineProcessing();
+        iAtPushState = EDunStateIdle;
+        FTRACE(FPrint( _L("CDunAtCmdPusher::NotifyDataPushComplete() (error reply) complete") ));
+        return;
+        }
+    // Secondly check only the case where push restart is required
+    if ( iReplyType==EReplyTypeOther && iReplyBytesLeft>0 )
+        {
+        iAtCmdExt->GetNextPartOfReply( iRecvBuffer, iReplyBytesLeft );
+        SendReplyData();
+        FTRACE(FPrint( _L("CDunAtCmdPusher::NotifyDataPushComplete() (push restart) complete") ));
+        return;
+        }
+    // Next check the case where other than "OK" and "ERROR" reply is received
+    // and that is the last one in the command line. Then just send "OK".
+    if ( !iLastOkPush && iReplyType==EReplyTypeOther )
+        {
+        TBool found = iCallback->NotifyNextCommandPeekRequest();
+        if ( !found )
+            {
+            // Force iReplyType here to match the correct one in NotifyDataPushComplete()
+            iReplyType = EReplyTypeOk;
+            iLastOkPush = ETrue;
+            SendReplyData( EFalse );
+            FTRACE(FPrint( _L("CDunAtCmdPusher::NotifyDataPushComplete() (last OK) complete") ));
+            return;
+            }
+        // Now the next command was found so just fall through
+        }
+    // As a last step just set to idle
+    SetToIdleAndNotifyEnd( KErrNone );
+    FTRACE(FPrint( _L("CDunAtCmdPusher::NotifyDataPushComplete() complete") ));
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/atext/src/DunAtEcomListen.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,199 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ECom plugin install/uninstall/version listener
+*
+*/
+
+
+#include "DunAtEcomListen.h"
+#include "DunDebug.h"
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunAtEcomListen* CDunAtEcomListen::NewL(
+    RATExt* aAtCmdExt,
+    MDunAtEcomListen* aCallback )
+    {
+    CDunAtEcomListen* self = NewLC( aAtCmdExt, aCallback );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunAtEcomListen* CDunAtEcomListen::NewLC(
+    RATExt* aAtCmdExt,
+    MDunAtEcomListen* aCallback )
+    {
+    CDunAtEcomListen* self = new (ELeave) CDunAtEcomListen( aAtCmdExt,
+                                                            aCallback );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunAtEcomListen::~CDunAtEcomListen()
+    {
+    FTRACE(FPrint( _L("CDunAtEcomListen::~CDunAtEcomListen()") ));
+    ResetData();
+    FTRACE(FPrint( _L("CDunAtEcomListen::~CDunAtEcomListen() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Resets data to initial values
+// ---------------------------------------------------------------------------
+//
+void CDunAtEcomListen::ResetData()
+    {
+    FTRACE(FPrint( _L("CDunAtEcomListen::ResetData()") ));
+    // APIs affecting this:
+    // IssueRequest()
+    Stop();
+    // Internal
+    Initialize();
+    FTRACE(FPrint( _L("CDunAtEcomListen::ResetData() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Starts waiting for ECom plugin install/uninstall/version status changes
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtEcomListen::IssueRequest()
+    {
+    FTRACE(FPrint( _L("CDunAtEcomListen::IssueRequest()") ));
+    if ( iEcomListenState != EDunStateIdle )
+        {
+        FTRACE(FPrint( _L("CDunAtEcomListen::IssueRequest() (not ready) complete") ));
+        return KErrNotReady;
+        }
+    iStatus = KRequestPending;
+    iAtCmdExt->ReceiveEcomPluginChange( iStatus, iPluginUidPckg, iEcomTypePckg );
+    SetActive();
+    iEcomListenState = EDunStateEcomListening;
+    FTRACE(FPrint( _L("CDunAtEcomListen::IssueRequest() complete") ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Stops waiting for Ecom plugin install/uninstall/version status changes
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtEcomListen::Stop()
+    {
+    FTRACE(FPrint( _L("CDunAtEcomListen::Stop()") ));
+    if ( iEcomListenState != EDunStateEcomListening )
+        {
+        FTRACE(FPrint( _L("CDunAtEcomListen::Stop() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    iAtCmdExt->CancelReceiveEcomPluginChange();
+    Cancel();
+    iEcomListenState = EDunStateIdle;
+    FTRACE(FPrint( _L("CDunAtEcomListen::Stop() complete") ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunAtEcomListen::CDunAtEcomListen
+// ---------------------------------------------------------------------------
+//
+CDunAtEcomListen::CDunAtEcomListen( RATExt* aAtCmdExt,
+                                    MDunAtEcomListen* aCallback ) :
+    CActive( EPriorityHigh ),
+    iAtCmdExt( aAtCmdExt ),
+    iCallback( aCallback ),
+    iPluginUidPckg( iPluginUid ),
+    iEcomTypePckg( EEcomTypeUninstall )
+    {
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// CDunAtEcomListen::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunAtEcomListen::ConstructL()
+    {
+    FTRACE(FPrint( _L("CDunAtEcomListen::ConstructL()") ));
+    if ( !iAtCmdExt || !iCallback )
+        {
+        User::Leave( KErrGeneral );
+        }
+    CActiveScheduler::Add( this );
+    FTRACE(FPrint( _L("CDunAtEcomListen::ConstructL() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes this class
+// ---------------------------------------------------------------------------
+//
+void CDunAtEcomListen::Initialize()
+    {
+    // Don't initialize iAtCmdExt here (it is set through NewL)
+    // Don't initialize iCallback here (it is set through NewL)
+    iEcomListenState = EDunStateIdle;
+    iPluginUid = TUid::Null();
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called when plugin installed, uninstalled or changed
+// ---------------------------------------------------------------------------
+//
+void CDunAtEcomListen::RunL()
+    {
+    FTRACE(FPrint( _L("CDunAtEcomListen::RunL()") ));
+    iEcomListenState = EDunStateIdle;
+    TInt retTemp = iStatus.Int();
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunAtEcomListen::RunL() (ERROR) complete (%d)"), retTemp ));
+        return;
+        }
+    IssueRequest();
+    // Now the operation is either unintall or install of plugin
+    // Notify parent and ATEXT
+    if ( iEcomTypePckg() == EEcomTypeUninstall )
+        {
+        iCallback->NotifyPluginUninstallation( iPluginUid );
+        }
+    else if ( iEcomTypePckg() == EEcomTypeInstall )
+        {
+        iCallback->NotifyPluginInstallation( iPluginUid );
+        }
+    else
+        {
+        FTRACE(FPrint( _L("CDunAtEcomListen::RunL() (not supported) complete") ));
+        }
+    FTRACE(FPrint( _L("CDunAtEcomListen::RunL() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called on cancel
+// ---------------------------------------------------------------------------
+//
+void CDunAtEcomListen::DoCancel()
+    {
+    FTRACE(FPrint( _L("CDunAtEcomListen::DoCancel()") ));
+    FTRACE(FPrint( _L("CDunAtEcomListen::DoCancel() complete") ));
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/atext/src/DunAtModeListen.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,182 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Modem's mode listener and notifier
+*
+*/
+
+
+#include "DunAtModeListen.h"
+#include "DunDebug.h"
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunAtModeListen* CDunAtModeListen::NewL( RATExtCommon* aAtCmdExtCommon,
+                                          MDunAtModeListen* aCallback )
+    {
+    CDunAtModeListen* self = NewLC( aAtCmdExtCommon, aCallback );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunAtModeListen* CDunAtModeListen::NewLC( RATExtCommon* aAtCmdExtCommon,
+                                           MDunAtModeListen* aCallback )
+    {
+    CDunAtModeListen* self = new (ELeave) CDunAtModeListen( aAtCmdExtCommon,
+                                                            aCallback );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunAtModeListen::~CDunAtModeListen()
+    {
+    FTRACE(FPrint( _L("CDunAtModeListen::~CDunAtModeListen()") ));
+    ResetData();
+    FTRACE(FPrint( _L("CDunAtModeListen::~CDunAtModeListen() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Resets data to initial values
+// ---------------------------------------------------------------------------
+//
+void CDunAtModeListen::ResetData()
+    {
+    FTRACE(FPrint( _L("CDunAtModeListen::ResetData()") ));
+    // APIs affecting this:
+    // IssueRequest()
+    Stop();
+    // Internal
+    Initialize();
+    FTRACE(FPrint( _L("CDunAtModeListen::ResetData() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Issues request to start monitoring for mode status changes
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtModeListen::IssueRequest()
+    {
+    FTRACE(FPrint( _L("CDunAtModeListen::IssueRequest()" )));
+    if ( iModeListenState != EDunStateIdle )
+        {
+        FTRACE(FPrint( _L("CDunAtModeListen::IssueRequest() (not ready) complete" ) ));
+        return KErrNotReady;
+        }
+    iStatus = KRequestPending;
+    iAtCmdExtCommon->ReceiveModeStatusChange( iStatus, iModePckg );
+    SetActive();
+    iModeListenState = EDunStateModeListening;
+    FTRACE(FPrint( _L("CDunAtModeListen::IssueRequest() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Stops monitoring for mode status changes
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtModeListen::Stop()
+    {
+    FTRACE(FPrint( _L("CDunAtModeListen::Stop()" )));
+    if ( iModeListenState != EDunStateModeListening )
+        {
+        FTRACE(FPrint( _L("CDunAtModeListen::Stop() (not ready) complete" ) ));
+        return KErrNotReady;
+        }
+    iAtCmdExtCommon->CancelReceiveModeStatusChange();
+    Cancel();
+    iModeListenState = EDunStateIdle;
+    FTRACE(FPrint( _L("CDunAtModeListen::Stop() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunAtModeListen::CDunAtModeListen
+// ---------------------------------------------------------------------------
+//
+CDunAtModeListen::CDunAtModeListen( RATExtCommon* aAtCmdExtCommon,
+                                    MDunAtModeListen* aCallback ) :
+    CActive( EPriorityHigh ),
+    iAtCmdExtCommon( aAtCmdExtCommon ),
+    iCallback( aCallback ),
+    iModePckg( iMode )
+    {
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// CDunAtModeListen::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunAtModeListen::ConstructL()
+    {
+    FTRACE(FPrint( _L("CDunAtModeListen::ConstructL()") ));
+    if ( !iAtCmdExtCommon || !iCallback )
+        {
+        User::Leave( KErrGeneral );
+        }
+    CActiveScheduler::Add( this );
+    FTRACE(FPrint( _L("CDunAtModeListen::ConstructL() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes this class
+// ---------------------------------------------------------------------------
+//
+void CDunAtModeListen::Initialize()
+    {
+    // Don't initialize iAtCmdExtCommon here (it is set through NewL)
+    // Don't initialize iCallback here (it is set through NewL)
+    iModeListenState = EDunStateIdle;
+    iMode = 0;
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called when mode changes
+// ---------------------------------------------------------------------------
+//
+void CDunAtModeListen::RunL()
+    {
+    FTRACE(FPrint( _L("CDunAtModeListen::RunL()") ));
+    iModeListenState = EDunStateIdle;
+    TInt retTemp = iStatus.Int();
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunAtModeListen::RunL() (ERROR) complete (%d)"), retTemp ));
+        return;
+        }
+    FTRACE(FPrint( _L("CDunAtModeListen::RunL() managing 0x%08X" ), iMode ));
+    iCallback->NotifyModeStatusChange( iMode );
+    IssueRequest();
+    FTRACE(FPrint( _L("CDunAtModeListen::RunL() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called on cancel
+// ---------------------------------------------------------------------------
+//
+void CDunAtModeListen::DoCancel()
+    {
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/atext/src/DunAtNvramListen.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,190 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  AT NVRAM status change listener and notifier
+*
+*/
+
+
+#include "DunAtNvramListen.h"
+#include "DunDebug.h"
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunAtNvramListen* CDunAtNvramListen::NewL( RATExt* aAtCmdExt,
+                                            RATExtCommon* aAtCmdExtCommon )
+    {
+    CDunAtNvramListen* self = NewLC( aAtCmdExt, aAtCmdExtCommon );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunAtNvramListen* CDunAtNvramListen::NewLC( RATExt* aAtCmdExt,
+                                             RATExtCommon* aAtCmdExtCommon )
+    {
+    CDunAtNvramListen* self = new (ELeave) CDunAtNvramListen(
+        aAtCmdExt,
+        aAtCmdExtCommon );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunAtNvramListen::~CDunAtNvramListen()
+    {
+    FTRACE(FPrint( _L("CDunAtNvramListen::~CDunAtNvramListen()") ));
+    ResetData();
+    FTRACE(FPrint( _L("CDunAtNvramListen::~CDunAtNvramListen() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Resets data to initial values
+// ---------------------------------------------------------------------------
+//
+void CDunAtNvramListen::ResetData()
+    {
+    FTRACE(FPrint( _L("CDunAtNvramListen::ResetData()") ));
+    // APIs affecting this:
+    // IssueRequest()
+    Stop();
+    // Internal
+    Initialize();
+    FTRACE(FPrint( _L("CDunAtNvramListen::ResetData() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Starts waiting for NVRAM status changes
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtNvramListen::IssueRequest()
+    {
+    FTRACE(FPrint( _L("CDunAtNvramListen::IssueRequest()") ));
+    if ( iNvramHandleState != EDunStateIdle )
+        {
+        FTRACE(FPrint( _L("CDunAtNvramListen::IssueRequest() (not ready) complete") ));
+        return KErrNotReady;
+        }
+    if ( !iStarted )
+        {
+        iAtCmdExtCommon->GetNvramStatus( iNvramBuffer );
+        iAtCmdExt->BroadcastNvramStatusChange( iNvramBuffer );
+        iStarted = ETrue;
+        }
+    iStatus = KRequestPending;
+    iAtCmdExtCommon->ReceiveNvramStatusChange( iStatus, iNvramBuffer );
+    SetActive();
+    iNvramHandleState = EDunStateNvramListening;
+    FTRACE(FPrint( _L("CDunAtNvramListen::IssueRequest() complete") ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Stops waiting for NVRAM status changes
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtNvramListen::Stop()
+    {
+    FTRACE(FPrint( _L("CDunAtNvramListen::Stop()") ));
+    if ( iNvramHandleState != EDunStateNvramListening )
+        {
+        FTRACE(FPrint( _L("CDunAtNvramListen::Stop() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    iAtCmdExtCommon->CancelReceiveNvramStatusChange();
+    Cancel();
+    iNvramHandleState = EDunStateIdle;
+    FTRACE(FPrint( _L("CDunAtNvramListen::Stop() complete") ));
+    // Note: Don't mark iStarted to EFalse here!
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunAtNvramListen::CDunAtNvramListen
+// ---------------------------------------------------------------------------
+//
+CDunAtNvramListen::CDunAtNvramListen( RATExt* aAtCmdExt,
+                                      RATExtCommon* aAtCmdExtCommon ) :
+    CActive( EPriorityHigh ),
+    iAtCmdExt( aAtCmdExt ),
+    iAtCmdExtCommon( aAtCmdExtCommon )
+    {
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// CDunAtNvramListen::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunAtNvramListen::ConstructL()
+    {
+    FTRACE(FPrint( _L("CDunAtNvramListen::ConstructL()") ));
+    if ( !iAtCmdExt || !iAtCmdExtCommon )
+        {
+        User::Leave( KErrGeneral );
+        }
+    CActiveScheduler::Add( this );
+    FTRACE(FPrint( _L("CDunAtNvramListen::ConstructL() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes this class
+// ---------------------------------------------------------------------------
+//
+void CDunAtNvramListen::Initialize()
+    {
+    // Don't initialize iAtCmdExt here (it is set through NewL)
+    // Don't initialize iAtCmdExtCommon here (it is set through NewL)
+    iNvramHandleState = EDunStateIdle;
+    iStarted = EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called when NVRAM has changed
+// ---------------------------------------------------------------------------
+//
+void CDunAtNvramListen::RunL()
+    {
+    FTRACE(FPrint( _L("CDunAtNvramListen::RunL()") ));
+    iNvramHandleState = EDunStateIdle;
+    TInt retTemp = iStatus.Int();
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunAtNvramListen::RunL() (ERROR) complete (%d)"), retTemp ));
+        return;
+        }
+    iAtCmdExt->BroadcastNvramStatusChange( iNvramBuffer );
+    IssueRequest();
+    FTRACE(FPrint( _L("CDunAtNvramListen::RunL() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called on cancel
+// ---------------------------------------------------------------------------
+//
+void CDunAtNvramListen::DoCancel()
+    {
+    FTRACE(FPrint( _L("CDunAtNvramListen::DoCancel()") ));
+    FTRACE(FPrint( _L("CDunAtNvramListen::DoCancel() complete") ));
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/atext/src/DunAtSpecialCmdHandler.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,161 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Special AT command handler
+*
+*/
+
+#include "DunAtSpecialCmdHandler.h"
+#include "DunDebug.h"
+
+const TInt KDefaultGranularity = 1;
+
+// AT command(s) below is part of the AT&FE0Q0V1&C1&D2+IFC=3,1. command which
+// is sent by MAC. There is no delimiter between "AT&F" and "E0".
+// Only list those commands where alphabetical boundary detection is needed
+// (i.e. "AT&F0" is not needed as "AT&F0E0" has non-alphabetical boundary)
+_LIT8( KSpecialATCmd1, "AT&F" );
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunAtSpecialCmdHandler* CDunAtSpecialCmdHandler::NewL()
+    {
+    CDunAtSpecialCmdHandler* self = new (ELeave) CDunAtSpecialCmdHandler();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunAtSpecialCmdHandler::CDunAtSpecialCmdHandler
+// ---------------------------------------------------------------------------
+//
+CDunAtSpecialCmdHandler::CDunAtSpecialCmdHandler()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CDunAtSpecialCmdHandler::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunAtSpecialCmdHandler::ConstructL()
+    {
+    iSpecialCmds = new (ELeave) CDesC8ArrayFlat( KDefaultGranularity );
+    // Add here all special commands which need to be handled
+    iSpecialCmds->AppendL( KSpecialATCmd1 );
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunAtSpecialCmdHandler::~CDunAtSpecialCmdHandler()
+    {
+    FTRACE(FPrint( _L("CDunAtSpecialCmdHandler::~CDunAtSpecialCmdHandler()") ));
+    delete iSpecialCmds;
+    FTRACE(FPrint( _L("CDunAtSpecialCmdHandler::~CDunAtSpecialCmdHandler() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Checks if the command has to be treated special way.
+// For example in case of MAC, it sends command AT&FE0Q0V1&C1&D2+IFC=3,1.
+// meaning there is no delimiters in the command.
+// In case of MAC we try to search AT&F (sub command) string from the beginning
+// of the command.
+// Search is done character by character basis.
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtSpecialCmdHandler::IsCompleteSubCommand( TChar aCharacter )
+    {
+    FTRACE(FPrint( _L("CDunAtSpecialCmdHandler::IsCompleteSubCommand()") ));
+    iBuffer.Append( aCharacter );
+    TBool completeSubCmd = EFalse;
+
+    if( !IsDataReadyForComparison(iBuffer.Length()) )
+        {
+        // No need to do comparison because we don't have correct amount of data
+        FTRACE(FPrint( _L("CDunAtSpecialCmdHandler::IsCompleteSubCommand(), no need to compare") ));
+        return completeSubCmd;
+        }
+
+    TInt count = iSpecialCmds->Count();
+    for ( TInt i=0; i<count; i++ )
+        {
+        if( iSpecialCmds->MdcaPoint(i).Compare(iBuffer) == 0 )
+            {
+            FTRACE(FPrint( _L("CDunAtSpecialCmdHandler::IsCompleteSubCommand(), match found, cmd index %d"), i ));
+            // Reset internal buffer for next comparison.
+            ResetComparisonBuffer();
+            completeSubCmd = ETrue;
+            break;
+            }
+        }
+    FTRACE(FPrint( _L("CDunAtSpecialCmdHandler::IsCompleteSubCommand() complete") ));
+    return completeSubCmd;
+    }
+
+// ---------------------------------------------------------------------------
+// Resets the buffer used for comparisons
+// ---------------------------------------------------------------------------
+//
+void CDunAtSpecialCmdHandler::ResetComparisonBuffer()
+    {
+    FTRACE(FPrint( _L("CDunAtSpecialCmdHandler::ResetComparisonBuffer()") ));
+    iBuffer.FillZ();
+    iBuffer.Zero();
+    FTRACE(FPrint( _L("CDunAtSpecialCmdHandler::ResetComparisonBuffer() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Defines when comparison is excecuted, checks if the data lengths are equal.
+// ---------------------------------------------------------------------------
+//
+TBool CDunAtSpecialCmdHandler::IsDataReadyForComparison( TInt aLength )
+    {
+    FTRACE(FPrint( _L("CDunAtSpecialCmdHandler::IsDataReadyForComparison()") ));
+    TInt count = iSpecialCmds->Count();
+    for ( TInt i=0; i<count; i++ )
+        {
+        if( iSpecialCmds->MdcaPoint(i).Length() == aLength )
+            {
+            FTRACE(FPrint( _L("CDunAtSpecialCmdHandler::IsDataReadyForComparison() (ready) complete") ));
+            return ETrue;
+            }
+        }
+    FTRACE(FPrint( _L("CDunAtSpecialCmdHandler::IsDataReadyForComparison() (not ready) complete") ));
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// Defines minimum length of the special commands.
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtSpecialCmdHandler::MinimumLength()
+    {
+    FTRACE(FPrint( _L("CDunAtSpecialCmdHandler::MinimumLength()") ));
+    TInt length = iSpecialCmds->MdcaPoint(0).Length();
+    TInt count = iSpecialCmds->Count();
+    for ( TInt i=1; i<count; i++ )
+        {
+        if( iSpecialCmds->MdcaPoint(i).Length() < length )
+            {
+            length = iSpecialCmds->MdcaPoint(i).Length();
+            break;
+            }
+        }
+    FTRACE(FPrint( _L("CDunAtSpecialCmdHandler::MinimumLength() complete") ));
+    return length;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/atext/src/DunAtUrcHandler.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,228 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  AT command URC handler
+*
+*/
+
+
+#include <atext.h>
+#include "DunAtCmdHandler.h"
+#include "DunAtUrcHandler.h"
+#include "DunDownstream.h"
+#include "DunDebug.h"
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunAtUrcHandler* CDunAtUrcHandler::NewL(
+    RATExt* aAtCmdExt,
+    MDunStreamManipulator* aStreamCallback )
+    {
+    CDunAtUrcHandler* self = NewLC( aAtCmdExt, aStreamCallback );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunAtUrcHandler* CDunAtUrcHandler::NewLC(
+    RATExt* aAtCmdExt,
+    MDunStreamManipulator* aStreamCallback )
+    {
+    CDunAtUrcHandler* self = new (ELeave) CDunAtUrcHandler( aAtCmdExt,
+                                                            aStreamCallback );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunAtUrcHandler::~CDunAtUrcHandler()
+    {
+    FTRACE(FPrint( _L("CDunAtUrcHandler::~CDunAtUrcHandler()") ));
+    ResetData();
+    FTRACE(FPrint( _L("CDunAtUrcHandler::~CDunAtUrcHandler() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Resets data to initial values
+// ---------------------------------------------------------------------------
+//
+void CDunAtUrcHandler::ResetData()
+    {
+    FTRACE(FPrint( _L("CDunAtUrcHandler::ResetData()") ));
+    // APIs affecting this:
+    // IssueRequest()
+    Stop();
+    // Don't close iAtCmdExt here (it is done in CDunAtCmdHandler)!
+    // Internal
+    Initialize();
+    FTRACE(FPrint( _L("CDunAtUrcHandler::ResetData() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Starts waiting for an incoming URC message
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtUrcHandler::IssueRequest()
+    {
+    FTRACE(FPrint( _L("CDunAtUrcHandler::IssueRequest()") ));
+    if ( iUrcHandleState != EDunStateIdle )
+        {
+        FTRACE(FPrint( _L("CDunAtUrcHandler::IssueRequest() (not ready) complete") ));
+        return KErrNotReady;
+        }
+    iStatus = KRequestPending;
+    iAtCmdExt->ReceiveUnsolicitedResult( iStatus, iRecvBuffer, iOwnerUidPckg );
+    SetActive();
+    iUrcHandleState = EDunStateAtUrcHandling;
+    // Next mark ownership
+    if ( !iStarted )
+        {
+        TInt retTemp = iAtCmdExt->MarkUrcHandlingOwnership( iOwnerUid );
+        if ( retTemp != KErrNone )
+            {
+            FTRACE(FPrint( _L("CDunAtUrcHandler::IssueRequest() (not owned) complete") ));
+            return KErrGeneral;
+            }
+        }
+    iStarted = ETrue;
+    FTRACE(FPrint( _L("CDunAtUrcHandler::IssueRequest() complete") ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Stops waiting for an incoming URC message
+// ---------------------------------------------------------------------------
+//
+TInt CDunAtUrcHandler::Stop()
+    {
+    FTRACE(FPrint( _L("CDunAtUrcHandler::Stop()") ));
+    if ( iUrcHandleState != EDunStateAtUrcHandling )
+        {
+        FTRACE(FPrint( _L("CDunAtUrcHandler::Stop() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    iAtCmdExt->CancelReceiveUnsolicitedResult( iOwnerUid );
+    Cancel();
+    iUrcHandleState = EDunStateIdle;
+    FTRACE(FPrint( _L("CDunAtUrcHandler::Stop() complete") ));
+    // Note: Don't mark iStarted to EFalse here as it is used to get the UID
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// UID of the owning plugin
+// ---------------------------------------------------------------------------
+//
+TUid CDunAtUrcHandler::OwnerUid()
+    {
+    return iOwnerUid;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunAtUrcHandler::CDunAtUrcHandler
+// ---------------------------------------------------------------------------
+//
+CDunAtUrcHandler::CDunAtUrcHandler( RATExt* aAtCmdExt,
+                                    MDunStreamManipulator* aStreamCallback ) :
+    CActive( EPriorityHigh ),
+    iAtCmdExt( aAtCmdExt ),
+    iStreamCallback( aStreamCallback ),
+    iOwnerUidPckg( iOwnerUid )
+    {
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// CDunAtUrcHandler::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunAtUrcHandler::ConstructL()
+    {
+    FTRACE(FPrint( _L("CDunAtUrcHandler::ConstructL()") ));
+    if ( !iAtCmdExt || !iStreamCallback  )
+        {
+        User::Leave( KErrGeneral );
+        }
+    CActiveScheduler::Add( this );
+    FTRACE(FPrint( _L("CDunAtUrcHandler::ConstructL() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes this class
+// ---------------------------------------------------------------------------
+//
+void CDunAtUrcHandler::Initialize()
+    {
+    // Don't initialize iStreamCallback here (it is set through NewL)
+    iUrcHandleState = EDunStateIdle;
+    iOwnerUid = TUid::Null();
+    iStarted = EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called when URC command received
+// ---------------------------------------------------------------------------
+//
+void CDunAtUrcHandler::RunL()
+    {
+    FTRACE(FPrint( _L("CDunAtUrcHandler::RunL()") ));
+    iUrcHandleState = EDunStateIdle;
+    TInt retTemp = iStatus.Int();
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunAtUrcHandler::RunL() (ERROR) complete (%d)"), retTemp));
+        return;
+        }
+    if ( iRecvBuffer.Length() == 0 )
+        {
+        FTRACE(FPrint( _L("CDunAtUrcHandler::RunL() (empty buffer) complete") ));
+        return;
+        }
+
+    // Send received URC message
+
+    iStreamCallback->NotifyDataPushRequest( &iRecvBuffer, this );
+
+    FTRACE(FPrint( _L("CDunAtUrcHandler::RunL() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called on cancel
+// ---------------------------------------------------------------------------
+//
+void CDunAtUrcHandler::DoCancel()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunCompletionReporter.
+// Gets called when data push is complete
+// ---------------------------------------------------------------------------
+//
+void CDunAtUrcHandler::NotifyDataPushComplete( TBool /*aAllPushed*/ )
+    {
+    FTRACE(FPrint( _L("CDunAtUrcHandler::NotifyDataPushComplete()") ));
+    IssueRequest();
+    FTRACE(FPrint( _L("CDunAtUrcHandler::NotifyDataPushComplete() complete") ));
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/client/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*	 This file provides the information required for building the
+*    whole of DUN client
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+../../rom/dunclient.iby       CORE_MW_LAYER_IBY_EXPORT_PATH(dunclient.iby)
+
+PRJ_MMPFILES
+dunclient.mmp
+
+PRJ_TESTMMPFILES
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/client/group/dunclient.mmp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project DUN client
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET                  dunclient.dll
+TARGETTYPE              PLUGIN
+UID                     0x10009D8D 0x20002775
+
+CAPABILITY              CAP_ECOM_PLUGIN
+VENDORID                VID_DEFAULT
+
+SOURCEPATH              ../src
+SOURCE                  dunplugin.cpp
+SOURCE                  dunactive.cpp
+SOURCE                  dunclient.cpp
+SOURCE                  proxy.cpp
+
+START RESOURCE          0x20002775.rss
+TARGET                  dunclient.rsc
+END // RESOURCE
+
+USERINCLUDE             ../inc ../../utils/inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+// Note:
+// The only other SYSTEMINCLUDE should you shall add are Symbian specific ones.
+// If there is a S60 header in the subdirectory then that should be
+// added into the include statements (like #include <phonebook/header.h>)
+//SYSTEMINCLUDE           /epoc32/include/ecom
+SYSTEMINCLUDE           ../../../inc ../../../../inc /epoc32/include/ecom
+
+LIBRARY                 euser.lib
+LIBRARY                 ecom.lib
+DEBUGLIBRARY            flogger.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/client/inc/dunactive.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,169 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Controls asynchronous requests between LOCOD and DUN server
+*
+*/
+
+
+#ifndef C_CDUNACTIVE_H
+#define C_CDUNACTIVE_H
+
+#include <locodservicepluginobserver.h>
+
+class CDunPlugin;
+
+/**
+ *  Class for accessing bearer statuses of CDunActive class
+ *
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( MDunActive )
+    {
+
+public:
+
+    /**
+     * Bearer
+     *
+     * @since S60 3.2
+     * @return Bearer
+     */
+    virtual TLocodBearer Bearer() = 0;
+
+    /**
+     * Bearer status
+     *
+     * @since S60 3.2
+     * @return Bearer status
+     */
+    virtual TBool BearerStatus() = 0;
+
+    };
+
+/**
+ *  Class that controls asynchronous requests between LOCOD and DUN server
+ *
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CDunActive ) : public CActive, public MDunActive
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aPlugin Plugin
+     * @param aBearer Brearer
+     * @param aBearerStatus Bearer status
+     * @return Instance of self
+     */
+    static CDunActive* NewL( CDunPlugin* aPlugin,
+                             TLocodBearer aBearer,
+                             TBool aBearerStatus );
+
+    /**
+     * Two-phased constructor.
+     * @param aPlugin Plugin
+     * @param aBearer Brearer
+     * @param aBearerStatus Bearer status
+     * @return Instance of self
+     */
+    static CDunActive* NewLC( CDunPlugin* aPlugin,
+                              TLocodBearer aBearer,
+                              TBool aBearerStatus );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunActive();
+
+    /**
+     * Request function
+     *
+     * @since S60 3.2
+     * @return Symbian Error code
+     */
+    TInt ServiceRequest();
+
+private:
+
+    CDunActive( CDunPlugin* aPlugin,
+                TLocodBearer aBearer,
+                TBool aBearerStatus );
+
+    void ConstructL();
+
+// from base class CActive
+
+    /**
+     * From CActive.
+     * Called when read or write operation is ready.
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void RunL();
+
+    /**
+     * From CActive.
+     * Cancel current activity.
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void DoCancel();
+
+// from base class MDunActive
+
+    /**
+     * From MDunActive.
+     * Bearer
+     *
+     * @since S60 3.2
+     * @return Bearer
+     */
+    TLocodBearer Bearer();
+
+    /**
+     * From MDunActive.
+     * Bearer status
+     *
+     * @since S60 3.2
+     * @return Bearer status
+     */
+    TBool BearerStatus();
+
+private:  // data
+
+    /**
+     * CDunPlugin
+     * Not own. Passed by DunPlugin
+     */
+    CDunPlugin* iPlugin;
+
+    /**
+     * Bearer
+     * Not own. Passed by DunPlugin
+     */
+    TLocodBearer iBearer;
+
+    /**
+     * Service state
+     * Not own. Passed by DunPlugin
+     */
+    TBool iBearerStatus;
+
+    };
+
+#endif  // C_CDUNACTIVE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/client/inc/dunclient.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Main client side interface of DUN
+*
+*/
+
+
+#ifndef R_RDUNCLIENT_H
+#define R_RDUNCLIENT_H
+
+#include <e32def.h>
+#include <e32std.h>
+#include <locodserviceplugin.h>
+
+class MDunActive;
+
+/**
+ *  Main client side interface of DUN
+ *  Manages service from/to LOCOD
+ *
+ *  @since S60 v3.2
+ */
+class RDun : public RSessionBase
+    {
+
+public:
+
+    RDun();
+
+    /**
+     * This function starts DUN open/close for different medias
+     *
+     * @since S60 3.2
+     * @param aRequest Request to manage
+     * @param aReqStatus Active object's request status
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt ManageService( MDunActive* aRequest, TRequestStatus& aReqStatus );
+
+    /**
+     * This function gets the active connection
+     * (For testing purposes only).
+     *
+     * @since S60 5.0
+     * @return Active connection if found, NULL otherwise
+     */
+    TAny* ActiveConnection();
+
+    /**
+     * Version number
+     *
+     * @since S60 3.2
+     * @return Version number of DUN
+     */
+    TVersion Version() const;
+
+    /**
+     * This function connects to DUN server and creates a new session.
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt Connect();
+
+    };
+
+#endif  // R_RDUNCLIENT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/client/inc/dunplugin.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,117 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  EComm interface implementation and the client side of DUN
+*
+*/
+
+
+#ifndef C_CDUNPLUGIN_H
+#define C_CDUNPLUGIN_H
+
+#include <locodbearer.h>
+#include <locodserviceplugin.h>
+#include "dunclient.h"
+
+class CDunActive;
+
+/**
+ *  Class of EComm interface implementation and the client side of DUN
+ *
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CDunPlugin ) : public CLocodServicePlugin
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aParams LOCOD service plugin parameters
+     * @return Instance of self
+     */
+    static CDunPlugin* NewL( TLocodServicePluginParams& aParams );
+
+    /**
+    * Destructor.
+    */
+    ~CDunPlugin();
+
+    /**
+     * Return owned RServer
+     *
+     * @since S60 3.2
+     * @return RDun
+     */
+    RDun& Server();
+
+    /**
+     * Called by instance of CDunActive to inform Observer of service completed.
+     * Destruct the active object.
+     *
+     * @since S60 3.2
+     * @param aRequest Request to service
+     * @param aError Error value
+     * @return None
+     */
+    void ServiceCompleted( MDunActive* aRequest, TInt aError );
+
+// from base class CLocodServicePlugin
+
+    /**
+     * From CLocodServicePlugin.
+     * Implements interface virtual function
+     *
+     * @since S60 3.2
+     * @param aBearer, BT/IR/USB bearer defined in locodbearer.h
+     * @param aBearerStatus, the status of this bearer,
+              ETrue if it is available;
+              EFalse otherwise.
+     * @return None
+     */
+    void ManageService( TLocodBearer aBearer, TBool aBearerStatus );
+
+private:
+
+    CDunPlugin( TLocodServicePluginParams& aParams );
+
+    void ConstructL();
+
+    /**
+     * Reports completion status to LOCOD
+     *
+     * @since S60 3.2
+     * @param aBearer Bearer to report
+     * @param aBearerStatus Bearer status to report
+     * @param aErr Error condition to report
+     * @return None
+     */
+    void ReportCompletion( TLocodBearer aBearer,
+                           TBool aBearerStatus,
+                           TInt aErr);
+
+private:  // data
+
+    /**
+     * Client side of DUN Server
+     */
+    RDun iServer;
+
+    /**
+     * Array of Active Object
+     */
+    RPointerArray<CDunActive> iActiveContainer;
+
+    };
+
+#endif  // C_CDUNPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/client/inc/dunserverdef.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definitions for server
+*
+*/
+
+
+#ifndef DUN_SERVERDEF_H
+#define DUN_SERVERDEF_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <e32svr.h>
+
+// DATA TYPES
+enum TDunIpc
+    {
+    EDunFuncManageService,
+    EDunFuncActiveConnection,  // For testing purposes only
+    EInvalidIpc
+    };
+
+// GLOBAL CONSTANTS
+
+_LIT( KDialupServerName, "dunserver" );
+
+const TUint KDunServerMajorVersionNumber = 2;
+const TUint KDunServerMinorVersionNumber = 0;
+const TUint KDunServerBuildVersionNumber = 0;
+
+#endif  // DUN_SERVERDEF_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/client/src/0x20002775.rss	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource definitions for project DUN
+*
+*/
+
+
+#include "registryinfov2.rh"
+#include "locodplugin.hrh"
+
+RESOURCE REGISTRY_INFO theInfo
+	{
+    // resource_format_version must always be set as follows
+    resource_format_version = RESOURCE_FORMAT_VERSION_2;
+	
+	// UID for the DLL
+	dll_uid = 0x20002775;
+	// Declare array of interface info
+	interfaces = 
+		{
+		INTERFACE_INFO
+			{
+			// UID of interface that is implemented
+			interface_uid = KLOCODSERVICEINTERFACEUID;
+			implementations = 
+				{
+				// Info for CDunPlugin
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = KFeatureIdDialupNetworking;
+					version_no = 1;
+					display_name = "DialupNetwork Plugin";
+					default_data = "";
+					opaque_data = "";
+					// This implementation CANNOT be overridden by a RAM-based plug-in
+					rom_only = 1;
+					}
+				};
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/client/src/dunactive.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,150 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Controls asynchronous requests between LOCOD and DUN server
+*
+*/
+
+
+#include "dunactive.h"
+#include "dunplugin.h"
+#include "DunDebug.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunActive* CDunActive::NewL( CDunPlugin* aPlugin,
+                              TLocodBearer aBearer,
+                              TBool aBearerStatus)
+    {
+    CDunActive* self = CDunActive::NewLC( aPlugin, aBearer, aBearerStatus );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunActive* CDunActive::NewLC( CDunPlugin* aPlugin,
+                               TLocodBearer aBearer,
+                               TBool aBearerStatus )
+    {
+    CDunActive* self = new (ELeave) CDunActive( aPlugin,
+                                                aBearer,
+                                                aBearerStatus );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunActive::~CDunActive()
+    {
+    FTRACE(FPrint( _L("CDunActive::~CDunActive()") ));
+    Cancel();
+    FTRACE(FPrint( _L("CDunActive::~CDunActive() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Request function
+// ---------------------------------------------------------------------------
+//
+TInt CDunActive::ServiceRequest()
+    {
+    FTRACE(FPrint( _L("CDunActive::ServiceRequest()") ));
+    TInt err = KErrNone;
+
+    iStatus = KRequestPending;
+    err = (iPlugin->Server()).ManageService( this, iStatus );
+    SetActive();
+    FTRACE(FPrint( _L("CDunActive::ServiceRequest() complete") ));
+    return err;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunActive::CDunActive
+// ---------------------------------------------------------------------------
+//
+CDunActive::CDunActive( CDunPlugin* aPlugin,
+                        TLocodBearer aBearer,
+                        TBool aBearerStatus )
+    : CActive( EPriorityStandard ),
+    iPlugin( aPlugin ),
+    iBearer( aBearer ),
+    iBearerStatus( aBearerStatus )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CDunActive::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunActive::ConstructL()
+    {
+    FTRACE(FPrint( _L("CDunActive::ConstructL()") ));
+    CActiveScheduler::Add( this );
+    FTRACE(FPrint( _L("CDunActive::ConstructL() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Cancel current activity.
+// ---------------------------------------------------------------------------
+//
+void CDunActive::DoCancel()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive
+// Called when read or write operation is ready.
+// ---------------------------------------------------------------------------
+//
+void CDunActive::RunL()
+    {
+    FTRACE(FPrint( _L("CDunActive::RunL()") ));
+    TInt retVal = iStatus.Int();
+    iPlugin->ServiceCompleted( this, retVal );
+    FTRACE(FPrint( _L("CDunActive::RunL() complete (%d)"), retVal ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunActive.
+// Bearer
+// ---------------------------------------------------------------------------
+//
+TLocodBearer CDunActive::Bearer()
+    {
+    FTRACE(FPrint( _L("CDunActive::Bearer()") ));
+    FTRACE(FPrint( _L("CDunActive::Bearer() complete") ));
+    return iBearer;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunActive.
+// Bearer status
+// ---------------------------------------------------------------------------
+//
+TBool CDunActive::BearerStatus()
+    {
+    FTRACE(FPrint( _L("CDunActive::BearerStatus()") ));
+    FTRACE(FPrint( _L("CDunActive::BearerStatus() complete") ));
+    return iBearerStatus;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/client/src/dunclient.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,164 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Main client side interface of DUN
+*
+*/
+
+
+#include "dunclient.h"
+#include "dunserverdef.h"
+#include "DunDebug.h"
+#include "dunactive.h"
+
+const TInt KDunRetryCount        = 3;
+const TInt KDunNumOfMessageSlots = 4;
+
+// ======== LOCAL FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Create server thread/process
+// ---------------------------------------------------------------------------
+//
+static TInt StartServer()
+    {
+    FTRACE(FPrint( _L("StartServer()") ));
+    TInt retVal = KErrNone;
+    TRequestStatus statusStarted;
+
+    RProcess server;
+    retVal = server.Create( KDialupServerName, KNullDesC, EOwnerThread );
+
+    if ( retVal != KErrNone )
+        {
+        FTRACE(FPrint( _L("StartServer() complete (%d)"), retVal ));
+        return retVal;
+        }
+
+    TRequestStatus stat;
+    server.Rendezvous( stat );
+
+    if ( stat != KRequestPending )
+        {
+        server.Kill( 0 );  //abort startup
+        }
+    else
+        {
+        server.Resume(); //logon OK - start the server
+        }
+
+    User::WaitForRequest( stat ); //wait the start or death of the server
+
+    /*
+    we can't use the 'exit reason' if the server panicked as this
+    is the panic 'reason' and may be '0' which cannot be distinguished
+    from KErrNone
+    */
+    retVal = stat.Int();
+    if ( server.ExitType() == EExitPanic )
+        {
+        retVal = KErrServerTerminated;
+        }
+
+    server.Close();
+    FTRACE(FPrint( _L("StartServer() complete (%d)"), retVal ));
+    return retVal;
+    }
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// RDun::RDun()
+// ---------------------------------------------------------------------------
+//
+RDun::RDun()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// This function starts DUN open/close for different medias
+// ---------------------------------------------------------------------------
+//
+TInt RDun::ManageService( MDunActive* aRequest, TRequestStatus& aReqStatus )
+    {
+    FTRACE(FPrint( _L("RDun::ManageService()") ));
+    SendReceive( EDunFuncManageService,
+                 TIpcArgs(aRequest->Bearer(),
+                          aRequest->BearerStatus()),
+                 aReqStatus );
+    FTRACE(FPrint( _L("RDun::ManageService() complete") ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// This function gets the active connection
+// ---------------------------------------------------------------------------
+//
+TAny* RDun::ActiveConnection()
+    {
+    FTRACE(FPrint( _L("RDun::ActiveConnection()") ));
+    TAny* connId = NULL;
+    TPckg<TAny*> connIdPckg( connId );
+    SendReceive( EDunFuncActiveConnection,
+                 TIpcArgs(&connIdPckg) );
+    FTRACE(FPrint( _L("RDun::ActiveConnection() complete") ));
+    return connId;
+    }
+
+// ---------------------------------------------------------------------------
+// Version number
+// ---------------------------------------------------------------------------
+//
+TVersion RDun::Version() const
+    {
+    FTRACE(FPrint( _L("RDun::Version()") ));
+    FTRACE(FPrint( _L("RDun::Version() complete") ));
+    return ( TVersion(KDunServerMajorVersionNumber,
+                      KDunServerMinorVersionNumber,
+                      KDunServerBuildVersionNumber) );
+    }
+
+// ---------------------------------------------------------------------------
+// This function connects to DUN server and creates a new session.
+// ---------------------------------------------------------------------------
+//
+TInt RDun::Connect()
+    {
+    FTRACE(FPrint( _L("RDun::Connect()") ));
+    TInt retry;
+    TInt retVal = KErrNone;
+    for ( retry=KDunRetryCount; retry>=0; retry-- )
+        {
+        retVal=CreateSession( KDialupServerName,
+                              TVersion(KDunServerMajorVersionNumber,
+                                       KDunServerMinorVersionNumber,
+                                       KDunServerBuildVersionNumber),
+                              KDunNumOfMessageSlots );
+        if ( retVal == KErrNotFound || retVal == KErrServerTerminated )
+            {
+            retVal = StartServer();
+            if ( retVal!=KErrNone && retVal!=KErrAlreadyExists )
+                {
+                FTRACE(FPrint( _L("RDun::Connect() complete (%d)"), retVal ));
+                return retVal;
+                }
+            }
+        else // KErrNone, or other error code.
+            {
+            FTRACE(FPrint( _L("RDun::Connect() complete (%d)"), retVal ));
+            return retVal;
+            }
+        }
+    FTRACE(FPrint( _L("RDun::Connect() complete (%d)"), retVal ));
+    return retVal;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/client/src/dunplugin.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,166 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  EComm interface implementation and the client side of DUN
+*
+*/
+
+
+#include "dunplugin.h"
+#include "dunactive.h"
+#include "DunDebug.h"
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunPlugin* CDunPlugin::NewL( TLocodServicePluginParams& aParams )
+    {
+    CDunPlugin* self = new (ELeave) CDunPlugin( aParams );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunPlugin::~CDunPlugin()
+    {
+    FTRACE(FPrint( _L("CDunPlugin::~CDunPlugin()") ));
+    iActiveContainer.ResetAndDestroy();
+    iActiveContainer.Close();
+    if ( iServer.Handle() != KNullHandle )
+        {
+        iServer.Close();
+        }
+    FTRACE(FPrint( _L("CDunPlugin::~CDunPlugin() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Return owned RServer
+// ---------------------------------------------------------------------------
+//
+RDun& CDunPlugin::Server()
+    {
+    FTRACE(FPrint( _L("CDunPlugin::Server()") ));
+    FTRACE(FPrint( _L("CDunPlugin::Server() complete") ));
+    return iServer;
+    }
+
+// ---------------------------------------------------------------------------
+// Called by instance of CDunActive to inform Observer of service completed.
+// Destruct the active object.
+// ---------------------------------------------------------------------------
+//
+void CDunPlugin::ServiceCompleted( MDunActive* aRequest, TInt aError )
+    {
+    FTRACE(FPrint( _L("CDunPlugin::ServiceCompleted()") ));
+    TInt i;
+    TLocodBearer bearer = aRequest->Bearer();
+    TBool status = aRequest->BearerStatus();
+    for ( i=iActiveContainer.Count()-1; i>=0; i-- )
+        {
+        if ( iActiveContainer[i] == aRequest )
+            {
+            delete iActiveContainer[i];
+            iActiveContainer.Remove( i );
+            break;
+            }
+        }
+    ReportCompletion( bearer, status, aError );
+    FTRACE(FPrint( _L("CDunPlugin::ServiceCompleted() completed (%d)"), aError ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CLocodServicePlugin.
+// Implements interface virtual function
+// ---------------------------------------------------------------------------
+//
+void CDunPlugin::ManageService( TLocodBearer aBearer, TBool aBearerStatus )
+    {
+    FTRACE(FPrint( _L("CDunPlugin::ManageService()") ));
+    TInt retTemp;
+    if ( iServer.Handle() == KNullHandle )
+        {
+        retTemp = iServer.Connect();
+        if ( retTemp != KErrNone )
+            {
+            ReportCompletion( aBearer, aBearerStatus, retTemp );
+            FTRACE(FPrint( _L("CDunPlugin::ManageService() (failed!) complete (%d)"), retTemp ));
+            return;
+            }
+        }
+    CDunActive* stateRequest = NULL;
+    TRAPD( retTrap, stateRequest=CDunActive::NewL( this,
+                                                   aBearer,
+                                                   aBearerStatus ));
+    if ( retTrap != KErrNone )
+        {
+        ReportCompletion( aBearer, aBearerStatus, retTrap );
+        FTRACE(FPrint( _L("CDunPlugin::ManageService() (failed!) complete (%d)"), retTrap ));
+        return;
+        }
+    if ( !stateRequest )
+        {
+        ReportCompletion( aBearer, aBearerStatus, KErrGeneral );
+        FTRACE(FPrint( _L("CDunPlugin::ManageService() (failed!) complete (%d)"), KErrGeneral ));
+        return;
+        }
+    retTemp = iActiveContainer.Append( stateRequest );
+    if ( retTemp != KErrNone )
+        {
+        ReportCompletion( aBearer, aBearerStatus, retTemp );
+        FTRACE(FPrint( _L("CDunPlugin::ManageService() (failed!) complete (%d)"), retTemp ));
+        return;
+        }
+    stateRequest->ServiceRequest();
+    FTRACE(FPrint( _L("CDunPlugin::ManageService() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// CDunPlugin::CDunPlugin
+// ---------------------------------------------------------------------------
+//
+CDunPlugin::CDunPlugin( TLocodServicePluginParams& aParams )
+    : CLocodServicePlugin( aParams )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CDunPlugin::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunPlugin::ConstructL()
+    {
+    FTRACE(FPrint( _L("CDunPlugin::ConstructL()") ));
+    FTRACE(FPrint( _L("CDunPlugin::ConstructL() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Reports completion status to LOCOD
+// ---------------------------------------------------------------------------
+//
+void CDunPlugin::ReportCompletion( TLocodBearer aBearer,
+                                   TBool aBearerStatus,
+                                   TInt aErr)
+    {
+    FTRACE(FPrint( _L("CDunPlugin::ReportCompletion()") ));
+    Observer().ManageServiceCompleted( aBearer,
+                                       aBearerStatus,
+                                       ImplementationUid(),
+                                       aErr);
+    FTRACE(FPrint( _L("CDunPlugin::ReportCompletion() completed (%d)"), aErr ));
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/client/src/proxy.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Export ECom interface implementations
+*
+*/
+
+
+#include <implementationproxy.h> //ECom header file
+#include "dunplugin.h"
+
+// ---------------------------------------------------------------------------
+// An array of TImplementationProxy objects which onnect each 
+// implemeation with its instantiation function
+// ---------------------------------------------------------------------------
+//
+const TImplementationProxy ImplementationTable[] = 
+    {
+    IMPLEMENTATION_PROXY_ENTRY( KFeatureIdDialupNetworking, CDunPlugin::NewL )
+    };
+    
+// ---------------------------------------------------------------------------
+// Exported proxy function to resolve instantiation methods for an Ecom
+// plug-in DLL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(
+    TInt & aTableCount )
+    {
+    aTableCount = sizeof( ImplementationTable ) /
+                  sizeof( TImplementationProxy );
+    return ImplementationTable; 
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+
+// bld.inf list of the modules to be build using this file
+// NOTE: order of this list must be same as the correct building order
+
+#include "../atext/group/bld.inf"
+#include "../utils/group/bld.inf"
+#include "../server/group/bld.inf"
+#include "../client/group/bld.inf"
+#include "../plugins/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/group/dun.mrp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+component	dun
+
+source \sf\mw\remoteconn\localconnectivityservice\dun
+
+notes_source	\component_defs\release.src
+
+ipr E 
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/plugins/bwins/dunbtu.def	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,3 @@
+EXPORTS
+	?NewLocalPluginL@@YAPAVMDunLocalMediaPlugin@@XZ @ 1 NONAME ; class MDunLocalMediaPlugin * NewLocalPluginL(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/plugins/bwins/duniru.def	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,3 @@
+EXPORTS
+	?NewLocalPluginL@@YAPAVMDunLocalMediaPlugin@@XZ @ 1 NONAME ; class MDunLocalMediaPlugin * NewLocalPluginL(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/plugins/bwins/dunusbu.def	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,3 @@
+EXPORTS
+	?NewLocalPluginL@@YAPAVMDunLocalMediaPlugin@@XZ @ 1 NONAME ; class MDunLocalMediaPlugin * NewLocalPluginL(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/plugins/eabi/dunbtu.def	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,3 @@
+EXPORTS
+	_Z15NewLocalPluginLv @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/plugins/eabi/duniru.def	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,3 @@
+EXPORTS
+	_Z15NewLocalPluginLv @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/plugins/eabi/dunusbu.def	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,3 @@
+EXPORTS
+	_Z15NewLocalPluginLv @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/plugins/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*	 This file provides the information required for building the whole of
+*    plugins.
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+#ifdef __BT
+../../rom/dunbt.iby     CORE_MW_LAYER_IBY_EXPORT_PATH(dunbt.iby)
+#endif
+#ifdef __IRDA
+../../rom/dunir.iby     CORE_MW_LAYER_IBY_EXPORT_PATH(dunir.iby)
+#endif
+#ifdef __USB
+../../rom/dunusb.iby    CORE_MW_LAYER_IBY_EXPORT_PATH(dunusb.iby)
+#endif
+
+PRJ_MMPFILES
+
+#ifdef __BT
+dunbt.mmp
+#endif
+#ifdef __IRDA
+dunir.mmp
+#endif
+#ifdef __USB
+dunusb.mmp
+#endif
+
+PRJ_TESTMMPFILES
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/plugins/group/dunbt.mmp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project DUN BT plugin.
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET                  dunbt.dll
+TARGETTYPE              DLL
+UID                     0x101F6E2D 0x101F6E2B
+
+CAPABILITY              CAP_GENERAL_DLL
+VENDORID                VID_DEFAULT
+
+SOURCEPATH              ../src/bt
+SOURCE                  DunBtPlugin.cpp
+SOURCE                  DunBtListen.cpp
+
+USERINCLUDE             ../inc/bt ../../utils/inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+// Note:
+// The only other SYSTEMINCLUDE should you shall add are Symbian specific ones.
+// If there is a S60 header in the subdirectory then that should be
+// added into the include statements (like #include <phonebook/header.h>)
+//SYSTEMINCLUDE           /epoc32/include/ecom
+SYSTEMINCLUDE           ../../../inc
+
+LIBRARY                 euser.lib
+LIBRARY                 esock.lib
+LIBRARY                 btengdiscovery.lib
+LIBRARY                 bluetooth.lib
+LIBRARY                 dunutils.lib
+DEBUGLIBRARY            flogger.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/plugins/group/dunir.mmp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project DUN IR plugin
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET                  dunir.dll
+TARGETTYPE              DLL
+UID                     0x101F6E2D 0x101FBAEB
+
+CAPABILITY              CAP_GENERAL_DLL
+VENDORID                VID_DEFAULT
+
+SOURCEPATH              ../src/ir
+SOURCE                  DunIrPlugin.cpp
+
+USERINCLUDE             ../inc/ir ../../utils/inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+// Note:
+// The only other SYSTEMINCLUDE should you shall add are Symbian specific ones.
+// If there is a S60 header in the subdirectory then that should be
+// added into the include statements (like #include <phonebook/header.h>)
+//SYSTEMINCLUDE           /epoc32/include/ecom
+SYSTEMINCLUDE          ../../../inc
+
+LIBRARY                 euser.lib
+LIBRARY                 c32.lib
+LIBRARY                 dunutils.lib
+DEBUGLIBRARY            flogger.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/plugins/group/dunusb.mmp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project DUN USB plugin
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET                  dunusb.dll
+TARGETTYPE              DLL
+UID                     0x101F6E2D 0x101F6E2F
+
+CAPABILITY              CAP_GENERAL_DLL
+VENDORID                VID_DEFAULT
+
+SOURCEPATH              ../src/usb
+SOURCE                  DunUsbPlugin.cpp
+SOURCE                  DunUsbListen.cpp
+SOURCE                  DunUsbConfig.cpp
+
+USERINCLUDE            ../inc/usb ../../utils/inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+// Note:
+// The only other SYSTEMINCLUDE should you shall add are Symbian specific ones.
+// If there is a S60 header in the subdirectory then that should be
+// added into the include statements (like #include <phonebook/header.h>)
+//SYSTEMINCLUDE           /epoc32/include/ecom
+SYSTEMINCLUDE           ../../../inc
+
+LIBRARY                 euser.lib
+LIBRARY                 c32.lib
+LIBRARY                 usbman.lib
+LIBRARY                 dunutils.lib
+DEBUGLIBRARY            flogger.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/plugins/inc/bt/DunBtListen.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,261 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DUN Bluetooth plugin's listener
+*
+*/
+
+
+#ifndef C_CDUNBTLISTEN_H
+#define C_CDUNBTLISTEN_H
+
+#include <btengdiscovery.h>
+#include "DunPlugin.h"
+#include "DunTransporter.h"
+
+class TBtPortEntity;
+
+enum TBtListenState
+    {
+    EBtListenStateIdle,
+    EBtListenStateListening
+    };
+
+/**
+ *  DUN Bluetooth plugin's listener class
+ *  This class starts listening on a created BT RFComm channel and notifies
+ *  parent (CDunBtPlugin) when new connection is detected. Also registers and
+ *  unregisters DUN SDP record.
+ *
+ *  @lib dunbt.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CDunBtListen ) : public CActive,
+                                    public MDunServAdvMon
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aServer Server
+     * @param aParent Callback interface to parent
+     * @param aTransporter Transporter
+     * @param aEntity Data socket entity
+     * @return Instance of self
+     */
+    static CDunBtListen* NewL( MDunServerCallback* aServer,
+                               MDunListenCallback* aParent,
+                               CDunTransporter* aTransporter,
+                               TBtPortEntity& aEntity );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunBtListen();
+
+    /**
+     * Resets data to initial values
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void ResetData();
+
+    /**
+     * Registers DUN and starts to listen.
+     * Registers itself to SDP and BT manager, opens a socket
+     * and starts to listen it.
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void IssueRequestL();
+
+    /**
+     * Stops listening
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt Stop();
+
+private:
+
+    CDunBtListen( MDunServerCallback* aServer,
+                  MDunListenCallback* aParent,
+                  CDunTransporter* aTransporter,
+                  TBtPortEntity& aEntity );
+
+    void ConstructL();
+
+    /**
+     * Initializes this class
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void Initialize();
+
+    /**
+     * Starts dialup service advertisement
+     *
+     * @since S60 3.2
+     * @param aInUse ETrue is returned if all RFCOMM channels in use.
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt StartServiceAdvertisement( TBool& aInUse );
+
+    /**
+     * Stops dialup service advertisement
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt StopServiceAdvertisement();
+
+    /**
+     * Method which reserves local RFCOMM channel (from possible channels 1-30)
+     * and returns it to client.
+     *
+     * @since S60 3.2
+     * @param aSocketServer Handle to connected socket server.
+     * @param aListenSocket Socket which is initiated for listening.
+     * @param aChannelNum RFCOMM channel which is reserved for listening.
+     * @param aInUse ETrue is returned if all RFCOMM channels in use.
+     * @return KErrNone if OK, else value indicating error situation.
+     */
+    TInt ReserveLocalChannel( RSocketServ& aSocketServ,
+                              RSocket& aListenSocket,
+                              TUint& aChannelNum,
+                              TBool& aInUse );
+
+    /**
+     * Tries to bind to a fixed port and if that fails with
+     * KRfcommPassiveAutoBind. This is for spec breaking solutions like the
+     * OSX Leopard.
+     *
+     * @since S60 5.0
+     * @param aListenSocket Listen socket for Bind()
+     * @param aSockAddr Address for the socket
+     *                 (must be set for KRfcommPassiveAutoBind)
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt DoExtendedBind( RSocket& aListenSocket, TRfcommSockAddr& aSockAddr );
+
+// from base class CActive
+
+    /**
+     * From CActive.
+     * Called when a service is requested via BT.
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void RunL();
+
+    /**
+     * From CActive.
+     * Cancel current activity.
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void DoCancel();
+
+// from base class MDunServAdvMon
+
+    /**
+     * From MDunServAdvMon.
+     * Gets called when advertisement status changes to start
+     *
+     * @since S60 5.0
+     * @param aCreation ETrue if channel creation
+     *                  EFalse if channel free
+     * @return None
+     */
+    void NotifyAdvertisementStart( TBool aCreation );
+
+    /**
+     * From MDunServAdvMon.
+     * Gets called when advertisement status changes to end
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void NotifyAdvertisementEnd();
+
+private:  // data
+
+    /**
+     * Callback to call when notification via MDunServerCallback to be made
+     * Not own.
+     */
+    MDunServerCallback* iServer;
+
+    /**
+     * Callback to call when notification via MDunListenCallback to be made
+     * Not own.
+     */
+    MDunListenCallback* iParent;
+
+    /**
+     * Transporter to use for network side communication
+     * Not own.
+     */
+    CDunTransporter* iTransporter;
+
+    /**
+     * Data socket entity for actual data transfer
+     * This will be valid after CDunBtListen reacts to new data in
+     * listener socket
+     */
+    TBtPortEntity& iEntity;
+
+    /**
+     * Current state of listening: active or inactive
+     */
+    TBtListenState iListenState;
+
+    /**
+     * Listener socket that will listen for activity in RFComm channel
+     */
+    RSocket iListenSocket;
+
+    /**
+     * Socket server used to reserve RFComm channel and creating data socket
+     */
+    RSocketServ iSockServer;
+
+    /**
+     * BT engine's Bluetooth discovery functionality
+     * Used for registering/unregistering SDP record
+     * Own.
+     */
+    CBTEngDiscovery* iDiscovery;
+
+    /**
+     * Local BT channel number
+     * Set to reserved RFComm channel and used to register SDP record
+     */
+    TUint iChannelNum;
+
+    /**
+     * Handle to the reserver SDP channel
+     * Set when SDP record registered
+     */
+    TSdpServRecordHandle iSDPHandleDun;
+
+    };
+
+#endif  // C_CDUNBTLISTEN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/plugins/inc/bt/DunBtPlugin.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,310 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DUN Bluetooth plugin
+*
+*/
+
+
+#ifndef C_CDUNBTPLUGIN_H
+#define C_CDUNBTPLUGIN_H
+
+#include <e32base.h>
+#include <es_sock.h>
+#include "DunTransporter.h"
+#include "DunPlugin.h"
+
+/**
+ *  Cleanup information for AllocateChannelL().
+ *  This data is needed to clean up partially constructed data in
+ *  NotifyChannelAllocate() when a leave occurs in channel creation.
+ *
+ *  @lib dunbt.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS( TBtCleanupInfo )
+    {
+
+public:
+
+    /**
+     * Flag to indicate whether or not a new entity was created
+     */
+    TBool iNewEntity;
+
+    /**
+     * Index to the position of the found entity
+     */
+    TInt iEntityIndex;
+
+    };
+
+/**
+ *  DUN BT plugin's port entity
+ *  This class is used to keep track of N number of BT ports and RFCOMM
+ *  channel numbers associated to them.
+ *
+ *  @lib dunbt.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( TBtPortEntity )
+    {
+
+public:
+
+    /**
+     * RFCOMM channel number for BT local media side
+     */
+    TInt iChannelNum;
+
+    /**
+     * Port for BT local media side
+     */
+    RSocket iBTPort;
+
+    };
+
+/**
+ *  DUN Bluetooth plugin's main class
+ *  This class creates new transporter channel when new data is detected by
+ *  CDunBtListen class and acts on transporter's state changes. Also acts on
+ *  DUN server's requests.
+ *
+ *  @lib dunbt.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CDunBtPlugin ) : public CBase,
+                                    public MDunLocalMediaPlugin,
+                                    public MDunListenCallback,
+                                    public MDunConnMon
+    {
+
+public:
+
+    CDunBtPlugin();
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunBtPlugin();
+
+private:
+
+    /**
+     * State of this plugin
+     *
+     * @since S60 3.2
+     * @return State of plugin
+     */
+    TDunPluginState PluginState();
+
+    /**
+     * Constructs a listener object for this plugin
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void ConstructListenerL();
+
+    /**
+     * Sets new state
+     * New state must be one more than the old state
+     *
+     * @since S60 3.2
+     * @param aPluginState New state to set for a plugin
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt ReportStateChangeUp( TDunPluginState aPluginState );
+
+    /**
+     * Sets new state
+     * New state must be one less than the old state
+     *
+     * @since S60 3.2
+     * @param aPluginState New state to set for a plugin
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt ReportStateChangeDown( TDunPluginState aPluginState );
+
+    /**
+     * Allocates a free channel
+     *
+     * @since S60 3.2
+     * @param aNoFreeChans ETrue if no free channels, EFalse otherwise
+     * @param aCleanupInfo Cleanup information
+     * @return None
+     */
+    void AllocateChannelL( TBool& aNoFreeChans, TBtCleanupInfo& aCleanupInfo );
+
+    /**
+     * Frees existing channels
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt FreeChannels();
+
+    /**
+     * Uninitializes this plugin
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt Uninitialize();
+
+    /**
+     * Gets port's index and entity by connection ID
+     *
+     * @since S60 3.2
+     * @param aConnId Connection ID of the connection to find
+     * @param aEntity Returned port entity
+     * @return KErrNotFound if entity not found, found index otherwise
+     */
+    TInt GetPortByConnId( TConnId aConnId, TBtPortEntity*& aEntity );
+
+    /**
+     * Gets first free port's index and entity
+     *
+     * @since S60 3.2
+     * @param aEntity Returned port entity
+     * @return KErrNotFound if entity not found, found index otherwise
+     */
+    TInt GetFirstFreePort( TBtPortEntity*& aEntity );
+
+    /**
+     * Sets modem's MSC (Modem Status Command)
+     *
+     * @since S60 3.2
+     * @param aEntity Port entity for which to change signal
+     * @param aSignal Signal to set to high or low
+     * @param aSignalOn ETrue if signal wanted high, otherwise low
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt SetRFCOMMStatusCommand( TBtPortEntity& aEntity,
+                                 TUint8 aSignal,
+                                 TBool aSignalOn );
+
+    /**
+     * Manages advertiser for channel free operation
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void ManageAdvertiserFreeOperationL();
+
+    /**
+     * Cleans partial created channel data based on TATExtCleanupInfo
+     *
+     * @since S60 5.0
+     * @param aCleanupInfo Cleanup information
+     * @return None
+     */
+    void CleanPartialChanneldata( TBtCleanupInfo& aCleanupInfo );
+    
+// from base class MDunLocalMediaPlugin
+
+    void ConstructL( MDunServerCallback* aServer,
+                     CDunTransporter* aTransporter );
+
+    /**
+     * From MDunLocalMediaPlugin.
+     * Gets called when server changes a plugin's state
+     *
+     * @since S60 3.2
+     * @param aPluginState New changed state
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt NotifyServerStateChange( TDunPluginState aPluginState );
+
+    /**
+     * From MDunLocalMediaPlugin.
+     * Gets called when server needs to know the active connection
+     * (For testing purposes only)
+     *
+     * @since S60 5.0
+     * @return Active connection, NULL otherwise
+     */
+    TConnId ActiveConnection();
+
+// from base class MDunListenCallback
+
+    /**
+     * From MDunListenCallback.
+     * Gets called when new channel must be created
+     *
+     * @since S60 3.2
+     * @param aNoFreeChans ETrue if no free channels, EFalse otherwise
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt NotifyChannelAllocate( TBool& aNoFreeChans );
+
+    /**
+     * From MDunListenCallback.
+     * Gets called when an existing channel must be freed
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt NotifyChannelFree();
+
+// from base class MDunConnMon
+
+    /**
+     * From MDunConnMon.
+     * Gets called when line status changes or when any type of error is
+     * detected
+     *
+     * @since S60 3.2
+     * @param aConnId Connection ID for callback
+     * @param aConnReason Reason for progress change
+     * @return None
+     */
+    void NotifyProgressChangeL( TConnId aConnId,
+                                TDunConnectionReason aConnReason );
+
+private:  // data
+
+    /**
+     * Callback to call when notification via MDunServerCallback to be made
+     * Not own.
+     */
+    MDunServerCallback* iServer;
+
+    /**
+     * Listener for detecting new data in RFComm channel
+     * Notifies this class about new data
+     * Own.
+     */
+    CDunBtListen* iBTListen;
+
+    /**
+     * Data socket entity for actual data transfer
+     * This will be valid after CDunBtListen reacts to new data in
+     * listener socket
+     */
+    TBtPortEntity iEntity;
+
+    /**
+     * Array of RSocket port(s) entities for BT local media side
+     */
+    RArray<TBtPortEntity> iBTPorts;
+
+    /**
+     * Transporter to use for network side communication
+     * Not own.
+     */
+    CDunTransporter* iTransporter;
+
+    };
+
+#endif  // C_CDUNBTPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/plugins/inc/ir/DunIrPlugin.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,177 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DUN Infrared plugin
+*
+*/
+
+
+#ifndef C_CDUNIRPLUGIN_H
+#define C_CDUNIRPLUGIN_H
+
+#include <e32base.h>
+#include <c32comm.h>
+#include "DunTransporter.h"
+#include "DunPlugin.h"
+
+/**
+ *  DUN Infrared plugin's main class
+ *  This class creates new transporter channel as soon as listening is
+ *  required by DUN server
+ *
+ *  @lib dunir.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CDunIrPlugin ) : public CBase,
+                                    public MDunLocalMediaPlugin,
+                                    public MDunConnMon
+    {
+
+public:
+
+    CDunIrPlugin();
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunIrPlugin();
+
+private:
+
+    /**
+     * State of this plugin
+     *
+     * @since S60 3.2
+     * @return State of plugin
+     */
+    TDunPluginState PluginState();
+
+    /**
+     * Constructs a listener object for this plugin
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    TInt ConstructListener();
+
+    /**
+     * Sets new state
+     * New state must be one more than the old state
+     *
+     * @since S60 3.2
+     * @param aPluginState New state to set for a plugin
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt ReportStateChangeUp( TDunPluginState aPluginState );
+
+    /**
+     * Sets new state
+     * New state must be one less than the old state
+     *
+     * @since S60 3.2
+     * @param aPluginState New state to set for a plugin
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt ReportStateChangeDown( TDunPluginState aPluginState );
+
+    /**
+     * Initializes one infrared port with role DCE
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt InitPort();
+
+    /**
+     * Allocates a channel
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void AllocateChannelL();
+
+    /**
+     * Uninitializes this plugin
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt Uninitialize();
+
+// from base class MDunLocalMediaPlugin
+
+    void ConstructL( MDunServerCallback* aServer,
+                     CDunTransporter* aTransporter );
+
+    /**
+     * From MDunLocalMediaPlugin.
+     * Gets called when server changes a plugin's state
+     *
+     * @since S60 3.2
+     * @param aPluginState New changed state
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt NotifyServerStateChange( TDunPluginState aPluginState );
+
+    /**
+     * From MDunLocalMediaPlugin.
+     * Gets called when server needs to know the active connection
+     * (For testing purposes only)
+     *
+     * @since S60 5.0
+     * @return Active connection, NULL otherwise
+     */
+    TConnId ActiveConnection();
+
+// from base class MDunConnMon
+
+    /**
+     * From MDunConnMon.
+     * Gets called when line status changes or when any type of error is
+     * detected
+     *
+     * @since S60 3.2
+     * @param aConnId Connection ID for callback
+     * @param aConnReason Reason for progress change
+     * @return None
+     */
+    void NotifyProgressChangeL( TConnId aConnId,
+                                TDunConnectionReason aConnReason );
+
+private:  // Data
+
+    /**
+     * Callback to call when notification MDunServerCallback via to be made
+     * Not own.
+     */
+    MDunServerCallback* iServer;
+
+    /**
+     * Communications server used to load IRCOMM and open IR port
+     */
+    RCommServ iCommServer;
+
+    /**
+     * RComm port for infrared local media side
+     */
+    RComm iIrPort;
+
+    /**
+     * Transporter to use for network side communication
+     * Not own.
+     */
+    CDunTransporter* iTransporter;
+
+    };
+
+#endif  // C_CDUNIRPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/plugins/inc/usb/DunUsbConfig.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,207 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DUN USB configuration accessor and listener
+*
+*/
+
+
+#ifndef C_CDUNUSBCONFIG_H
+#define C_CDUNUSBCONFIG_H
+
+#include <e32property.h>
+#include <usb/acmconfig.h>
+#include "DunPlugin.h"
+
+enum TUsbConfigState
+    {
+    EUsbConfigStateIdle,
+    EUsbConfigStateWaiting
+    };
+
+/**
+ *  Notification interface class to report USB ACM configuration change
+ *
+ *  @lib dunusb.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( MDunUsbConfig )
+	{
+
+public:
+
+    /**
+     * Gets called when one or more ACM configurations are added
+     *
+     * @since S60 3.2
+     * @param aIndex Index (also port number) of added ACM configuration
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt NotifyConfigAddition( TInt aIndex ) = 0;
+
+    /**
+     * Gets called when one or more ACM configurations are removed
+     *
+     * @since S60 3.2
+     * @param aIndex Index (also port number) of removed ACM configuration
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt NotifyConfigRemoval( TInt aIndex ) = 0;
+
+	};
+
+/**
+ *  Class for detecting USB ACM configuration change
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CDunUsbConfig ) : public CActive
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aServer Server
+     * @param aCallback Pointer to listener callback
+     * @param aProtocol Protocol number to listen
+     * @return Instance of self
+     */
+	static CDunUsbConfig* NewL( MDunServerCallback* aServer,
+                                MDunUsbConfig* aCallback,
+                                TUint8 aProtocol );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunUsbConfig();
+
+    /**
+     * Resets data to initial values
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void ResetData();
+
+    /**
+     * Compares initialized protocol number to configuration by index
+     *
+     * @since S60 3.2
+     * @param aIndex Index for which to compare protocol number
+     * @param aValidity If initialized protocol matched at aIndex then ETrue
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt GetConfigValidityByIndex( TInt aIndex, TBool& aValidity );
+
+    /**
+     * Starts listening for ACM configuration changes
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt IssueRequest();
+
+    /**
+     * Stops listening for ACM configuration changes
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt Stop();
+
+private:
+
+    CDunUsbConfig( MDunServerCallback* aServer,
+                   MDunUsbConfig* aCallback,
+                   TUint8 aProtocol );
+
+    void ConstructL();
+
+    /**
+     * Initializes this class
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void Initialize();
+
+    /*
+     * Gets current ACM configuration
+     */
+    TInt GetConfiguration( TPublishedAcmConfigs& aConfig );
+
+// from base class CActive
+
+    /**
+     * From CActive.
+     * Gets called when ACM configuration changes
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void RunL();
+
+    /**
+     * From CActive.
+     * Gets called on cancel
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void DoCancel();
+
+private:  // data
+
+    /**
+     * Callback to call when notification via MDunServerCallback to be made
+     * Not own.
+     */
+    MDunServerCallback* iServer;
+
+    /**
+     * Callback to call when notification(s) via MDunUsbConfig to be made
+     */
+    MDunUsbConfig* iCallback;
+
+    /**
+     * Current state of configuration waiting: active or inactive
+     */
+    TUsbConfigState iConfigState;
+
+    /*
+     * Protocol number of USB ACM to which listening is done
+     */
+    TUint8 iProtocol;
+
+    /**
+     * ACM config from the previous Get()
+     * Used to check whether configs are added or removed and also array data
+     * needed for check in the removal case
+     */
+    TPublishedAcmConfigs iConfig;
+
+    /*
+     * ACM configuration property
+     */
+    RProperty iAcmProperty;
+
+    /*
+     * Flag to indicate if configuration already received
+     */
+    TBool iConfigExist;
+
+    };
+
+#endif  // C_CDUNUSBCONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/plugins/inc/usb/DunUsbListen.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,168 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DUN USB plugin's listener
+*
+*/
+
+
+#ifndef C_CDUNUSBLISTEN_H
+#define C_CDUNUSBLISTEN_H
+
+#include <e32std.h>
+#include <c32comm.h>
+#include <usbman.h>
+#include "DunPlugin.h"
+
+enum TUsbListenState
+    {
+    EUsbListenStateIdle,
+    EUsbListenStateListening
+    };
+
+/**
+ *  DUN USB plugin's listener class
+ *  This class starts listening for USB device state to change to configured.
+ *  When change to configured is detected, parent (CDunUsbPlugin) is notified
+ *  to create a channel. Also when device state is no longer configured,
+ *  parent (CDunUsbPlugin) is notified to remove a channel.
+ *
+ *  @lib dunusb.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CDunUsbListen ) : public CActive
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aServer Server
+     * @param aParent Creator of this instance
+     * @param aUsbServer USB server
+     * @return Instance of self
+     */
+    static CDunUsbListen* NewL( MDunServerCallback* aServer,
+                                MDunListenCallback* aParent,
+                                RUsb& aUsbServer );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunUsbListen();
+
+    /**
+     * Resets data to initial values
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void ResetData();
+
+    /**
+     * IssueRequest to USB server for device state change notifications
+     *
+     * @return KErrAlreadyExists if device state configured,
+     *         KErrNone otherwise
+     */
+    TInt IssueRequestL();
+
+    /**
+     * Stops listening
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt Stop();
+
+private:
+
+    CDunUsbListen( MDunServerCallback* aServer,
+                   MDunListenCallback* aParent,
+                   RUsb& aUsbServer );
+
+    void ConstructL();
+
+    /**
+     * Initializes this class
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void Initialize();
+
+    /**
+     * Activates listening request
+     *
+     * @since S60 3.2
+     * @return KErrNotReady if already active, KErrNone otherwise
+     */
+    TInt Activate();
+
+// from base class CActive
+
+    /**
+     * From CActive.
+     * Called when read or write operation is ready.
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void RunL();
+
+    /**
+     * From CActive.
+     * Cancel current activity.
+     *
+     * @return None
+     */
+    void DoCancel();
+
+private:  // data
+
+    /**
+     * Callback to call when notification via MDunServerCallback to be made
+     * Not own.
+     */
+    MDunServerCallback* iServer;
+
+    /**
+     * Callback to call when notification via MDunListenCallback to be made
+     * Not own.
+     */
+    MDunListenCallback* iParent;
+
+    /**
+     * Current state of listening: active or inactive
+     */
+    TUsbListenState iListenState;
+
+    /**
+     * USB server (USB manager) needed for device state notifications
+     * Device states needed to create transporter channel
+     */
+    RUsb& iUsbServer;
+
+    /**
+     * Device state of USB set when RUsb::DeviceStateNotification completes
+     */
+    TUsbDeviceState iDeviceState;
+
+    /**
+     * Previous state of USB set when RUsb::DeviceStateNotification completes
+     */
+    TUsbDeviceState iDeviceStatePrev;
+
+    };
+
+#endif  // C_CDUNUSBLISTEN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/plugins/inc/usb/DunUsbPlugin.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,362 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DUN USB plugin
+*
+*/
+
+
+#ifndef C_CDUNUSBPLUGIN_H
+#define C_CDUNUSBPLUGIN_H
+
+#include <e32base.h>
+#include <usbman.h>
+#include "DunTransporter.h"
+#include "DunUsbListen.h"
+#include "DunUsbConfig.h"
+#include "DunPlugin.h"
+
+/**
+ *  DUN USB plugin's port entity
+ *  This class is used to keep track of N number of USB ports and port
+ *  numbers associated to them (for CDunUsbConfig's purposes).
+ *
+ *  @lib dunusb.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( TUsbPortEntity )
+    {
+
+public:
+
+    /**
+     * Port number for USB local media side
+     */
+    TInt iPortNum;
+
+    /**
+     * Port for USB local media side
+     */
+    RComm iUsbPort;
+
+    };
+
+/**
+ *  DUN USB plugin's main class
+ *  This class creates new transporter channel(s) when configured USB is
+ *  detected by CDunUsbListen class and acts on transporter's state changes.
+ *  Also acts on DUN server's requests.
+ *
+ *  @lib dunusb.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CDunUsbPlugin ) : public CBase,
+                                     public MDunLocalMediaPlugin,
+                                     public MDunListenCallback,
+                                     public MDunBufferCorrection,
+                                     public MDunConnMon,
+                                     public MDunUsbConfig
+    {
+
+public:
+
+    CDunUsbPlugin();
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunUsbPlugin();
+
+private:
+
+    /**
+     * State of this plugin
+     *
+     * @since S60 3.2
+     * @return State of plugin
+     */
+    TDunPluginState PluginState();
+
+    /**
+     * Constructs a listener object for this plugin
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void ConstructListenerL();
+
+    /**
+     * Initializes USB by loading LDD
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void InitUsbL();
+
+    /**
+     * Initializes all usable USB ports for DUN
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt InitPorts();
+
+    /**
+     * Creates empty usable USB ports that can be used by DUN
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt CreateAllPorts();
+
+    /**
+     * Initializes one USB port for DUN
+     *
+     * @since S60 3.2
+     * @param aEntity Pointer to port entity
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt InitOnePort( TUsbPortEntity* aEntity );
+
+    /**
+     * Sets channel for one USB port
+     *
+     * @since S60 3.2
+     * @param aEntity Pointer to port entity
+     * @return None
+     */
+    void SetChannelL( TUsbPortEntity* aEntity );
+
+    /**
+     * Adds skipped error code to Transporter
+     * The skipped error is added to local media's read and write operations
+     *
+     * @since S60 3.2
+     * @param aError Skipped error code to add
+     * @param aComm RComm object for which to add the error code
+     * @return None
+     */
+    void AddSkippedErrorL( TInt aError, RComm* aComm );
+
+    /**
+     * Sets new state
+     * New state must be one more than the old state
+     *
+     * @since S60 3.2
+     * @param aPluginState New state to set for a plugin
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt ReportStateChangeUp( TDunPluginState aPluginState );
+
+    /**
+     * Sets new state
+     * New state must be one less than the old state
+     *
+     * @since S60 3.2
+     * @param aPluginState New state to set for a plugin
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt ReportStateChangeDown( TDunPluginState aPluginState );
+
+    /**
+     * Frees existing channels
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt FreeChannels();
+
+    /**
+     * Uninitializes this plugin
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt Uninitialize();
+
+    /**
+     * Gets port's index and entity by connection ID
+     *
+     * @since S60 3.2
+     * @param aConnId Connection ID of the connection to find
+     * @param aEntity Returned port entity
+     * @return KErrNotFound if entity not found, found index otherwise
+     */
+    TInt GetEntityByConnId( TConnId aConnId, TUsbPortEntity*& aEntity );
+
+    /**
+     * Gets port's entity by port number
+     *
+     * @since S60 3.2
+     * @param aPortNum Port number of the connection to find
+     * @param aEntity Returned port entity
+     * @return KErrNotFound if entity not found, found index otherwise
+     */
+    TInt GetEntityByPortNumber( TInt aPortNum, TUsbPortEntity*& aEntity );
+
+    /**
+     * Gets first free port's index and entity
+     *
+     * @since S60 3.2
+     * @param aEntity Returned port entity
+     * @return KErrNotFound if entity not found, found index otherwise
+     */
+    TInt GetFirstFreeEntity( TUsbPortEntity*& aEntity );
+
+// from base class MDunLocalMediaPlugin
+
+    void ConstructL( MDunServerCallback* aServer,
+                     CDunTransporter* aTransporter );
+
+    /**
+     * From MDunLocalMediaPlugin.
+     * Gets called when server changes a plugin's state
+     *
+     * @since S60 3.2
+     * @param aPluginState New changed state
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt NotifyServerStateChange( TDunPluginState aPluginState );
+
+    /**
+     * From MDunLocalMediaPlugin.
+     * Gets called when server needs to know the active connection
+     * (For testing purposes only)
+     *
+     * @since S60 5.0
+     * @return Active connection, NULL otherwise
+     */
+    TConnId ActiveConnection();
+
+// from base class MDunListenCallback
+
+    /**
+     * From MDunListenCallback.
+     * Gets called when new channel must be created
+     *
+     * @since S60 3.2
+     * @param aNoFreeChans ETrue if no free channels, EFalse otherwise
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt NotifyChannelAllocate( TBool& aNoFreeChans );
+
+    /**
+     * From MDunListenCallback.
+     * Gets called when an existing channel must be freed
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt NotifyChannelFree();
+
+// from base class MDunConnMon
+
+    /**
+     * From MDunConnMon.
+     * Gets called when line status changes or when any type of error is
+     * detected
+     *
+     * @since S60 3.2
+     * @param aConnId Connection ID for callback
+     * @param aConnReason Reason for progress change
+     * @return None
+     */
+    void NotifyProgressChangeL( TConnId aConnId,
+                                TDunConnectionReason aConnReason );
+
+// from base class MDunBufferCorrection
+
+    /**
+     * Gets called when request to change local media's buffer size
+     *
+     * @since S60 3.2
+     * @param aLength Suggested buffer length that will be used if no
+     *                correction done
+     * @return New (corrected) buffer length
+     */
+    TInt NotifyBufferCorrection( TInt aLength );
+
+// from base class MDunUsbConfig
+
+    /**
+     * Gets called when one or more ACM configurations are added
+     *
+     * @since S60 3.2
+     * @param aIndex Index (also port number) of added ACM configuration
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt NotifyConfigAddition( TInt aIndex );
+
+    /**
+     * Gets called when one or more ACM configurations are removed
+     *
+     * @since S60 3.2
+     * @param aIndex Index (also port number) of removed ACM configuration
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt NotifyConfigRemoval( TInt aIndex );
+
+private:  // data
+
+    /**
+     * Callback to call when notification via MDunServerCallback to be made
+     * Not own.
+     */
+    MDunServerCallback* iServer;
+
+    /**
+     * Listener for detecting attached USB cable and configured ACM
+     * Notifies this class to create new channel
+     * Own.
+     */
+    CDunUsbListen* iUsbListen;
+
+    /**
+     * Listener and accessor for detecting USB ACM configuration change
+     * Own.
+     */
+    CDunUsbConfig* iUsbConfig;
+
+    /**
+     * Communications server used to load ECACM and open USB port(s)
+     * Also used to get port information to calculate number of supported ACMs
+     */
+    RCommServ iCommServer;
+
+    /**
+     * USB server (USB manager) needed for device state notifications
+     * Device states needed to create transporter channel
+     */
+    RUsb iUsbServer;
+
+    /**
+     * Array of port(s) for USB local media side
+     */
+    RArray<TUsbPortEntity> iUsbPorts;
+
+    /**
+     * Transporter to use for network side communication
+     * Not own.
+     */
+    CDunTransporter* iTransporter;
+
+    /**
+     * Flag to be set on if CDunUsbPlugin is waiting for shutdown.
+     * This flag is used to skip subsequent higher-level error codes after
+     * driver based error occurred.
+     */
+    TBool iShutdown;
+
+    };
+
+#endif  // C_CDUNUSBPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/plugins/src/bt/DunBtListen.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,464 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DUN Bluetooth plugin's listener
+*
+*/
+
+
+#include <btsdp.h>
+#include <e32std.h>
+#include <bt_sock.h>
+#include <btengdiscovery.h>
+#include "DunPlugin.h"
+#include "DunBtListen.h"
+#include "DunBtPlugin.h"
+#include "DunDebug.h"
+
+const TInt KListenQueSize   = 1;
+const TInt KDunFixedChannel = 22;  // Hack/kludge for Apple Bug ID 6527598
+
+//Service Class Bits supported by DUN
+static const TUint16 KCoDDunServiceClass = EMajorServiceTelephony | EMajorServiceNetworking;
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunBtListen* CDunBtListen::NewL( MDunServerCallback* aServer,
+                                  MDunListenCallback* aParent,
+                                  CDunTransporter* aTransporter,
+                                  TBtPortEntity& aEntity )
+    {
+    CDunBtListen* self = new (ELeave) CDunBtListen( aServer,
+                                                    aParent,
+                                                    aTransporter,
+                                                    aEntity );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunBtListen::~CDunBtListen()
+    {
+    FTRACE(FPrint( _L("CDunBtListen::~CDunBtListen()") ));
+    ResetData();
+    FTRACE(FPrint( _L("CDunBtListen::~CDunBtListen() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Resets data to initial values
+// ---------------------------------------------------------------------------
+//
+void CDunBtListen::ResetData()
+    {
+    // APIs affecting this:
+    // IssueRequestL()
+    Stop();
+    StopServiceAdvertisement();
+    // NewL()
+    iTransporter->FreeAdvertisementMonitor( KDunBtPluginUid, this );
+    delete iDiscovery;
+    iDiscovery = NULL;
+    if ( iSockServer.Handle() != KNullHandle )
+        {
+        iSockServer.Close();
+        }
+    // Internal
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// Registers itself to SDP and BT manager, opens a socket
+// and starts to listen it.
+// ---------------------------------------------------------------------------
+//
+void CDunBtListen::IssueRequestL()
+    {
+    FTRACE(FPrint( _L( "CDunBtListen::IssueRequestL()" ) ));
+
+    if ( iListenState == EBtListenStateListening )
+        {
+        FTRACE(FPrint( _L( "CDunBtListen::IssueRequestL() (already active) complete" ) ));
+        User::Leave( KErrNotReady );
+        }
+
+    TBool advertise = iTransporter->AdvertisementStatus();
+    if ( !advertise )
+        {
+        // Return silently here as CDunTransporter will notify later
+        return;
+        }
+
+    TBool inUse = EFalse;
+    TInt numOfChans = 0;
+    TInt retTemp = StartServiceAdvertisement( inUse );
+    if ( retTemp != KErrNone )
+        {
+        if ( inUse )
+            {
+            numOfChans = iTransporter->GetNumberOfAllocatedChannelsByUid(
+                KDunBtPluginUid );
+            if ( numOfChans == 0)
+                {
+                // No channels so parent can't reissue requests of this object
+                // This is fatal case -> leave.
+                // NOTE: To add full support for this case a poller (timer) is
+                // needed that polls for free RFCOMM channel by given interval.
+                User::Leave( retTemp );
+                }
+            // If in use and parent has channels then just fail silently.
+            // Let this object to wait until parent finds new resources.
+            FTRACE(FPrint( _L( "CDunBtListen::IssueRequestL() complete" ) ));
+            return;
+            }
+        FTRACE(FPrint( _L( "CDunBtListen::IssueRequestL() (failed!) complete" ) ));
+        User::Leave( retTemp );
+        }
+
+    // Not already active here so start listening
+    // First open blank data socket
+    retTemp = iEntity.iBTPort.Open( iSockServer );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L( "CDunBtListen::IssueRequestL() (ERROR) complete (%d)" ), retTemp));
+        User::Leave( retTemp );
+        }
+    iStatus = KRequestPending;
+    iListenSocket.Accept( iEntity.iBTPort, iStatus );
+    SetActive();
+    iListenState = EBtListenStateListening;
+
+    FTRACE(FPrint( _L( "CDunBtListen::IssueRequestL() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Stops listening
+// ---------------------------------------------------------------------------
+//
+TInt CDunBtListen::Stop()
+    {
+    FTRACE(FPrint( _L( "CDunBtListen::Stop()") ));
+    if ( iListenState != EBtListenStateListening )
+        {
+        FTRACE(FPrint( _L("CDunBtListen::Stop() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    iListenSocket.CancelAccept();
+    Cancel();
+    iListenState = EBtListenStateIdle;
+    FTRACE(FPrint( _L( "CDunBtListen::Stop() complete") ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunBtListen::CDunBtListen
+// ---------------------------------------------------------------------------
+//
+CDunBtListen::CDunBtListen( MDunServerCallback* aServer,
+                            MDunListenCallback* aParent,
+                            CDunTransporter* aTransporter,
+                            TBtPortEntity& aEntity ) :
+    CActive( EPriorityStandard ),
+    iServer( aServer ),
+    iParent( aParent ),
+    iTransporter( aTransporter ),
+    iEntity( aEntity )
+    {
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// CDunBtListen::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunBtListen::ConstructL()
+    {
+    FTRACE(FPrint(_L("CDunBtListen::ConstructL()")));
+    if ( !iServer || !iParent || !iTransporter )
+        {
+        User::Leave( KErrGeneral );
+        }
+
+    CBTEngDiscovery* discovery = CBTEngDiscovery::NewLC();
+    FTRACE(FPrint(_L("CDunBtListen::ConstructL: iSockServer.Connect")));
+    User::LeaveIfError( iSockServer.Connect() );
+
+    // Set advertisement monitor
+    iTransporter->SetAdvertisementMonitorL( KDunBtPluginUid, this );
+
+    // Then we are ready to start listening and accepting incoming connection
+    // requests.
+    CleanupStack::Pop( discovery );
+    iDiscovery = discovery;
+    CActiveScheduler::Add( this );
+    FTRACE(FPrint(_L("CDunBtListen::ConstructL() complete")));
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes this class
+// ---------------------------------------------------------------------------
+//
+void CDunBtListen::Initialize()
+    {
+    // Don't initialize iServer here (it is set through NewL)
+    // Don't initialize iParent here (it is set through NewL)
+    // Don't initialize iTransporter here (it is set through NewL)
+    // Don't initialize iEntity here (it is set through NewL)
+    iListenState = EBtListenStateIdle;
+    iDiscovery = NULL;
+    iChannelNum = 0;
+    iSDPHandleDun = 0;
+    }
+
+// ---------------------------------------------------------------------------
+// Starts dialup service advertisement
+// ---------------------------------------------------------------------------
+//
+TInt CDunBtListen::StartServiceAdvertisement( TBool& aInUse )
+    {
+    FTRACE(FPrint( _L( "CDunBtListen::StartServiceAdvertisement()" ) ));
+
+    TInt retTemp = ReserveLocalChannel( iSockServer,
+                                        iListenSocket,
+                                        iChannelNum,
+                                        aInUse );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L( "CDunBtListen::StartServiceAdvertisement() (ERROR) complete" ) ));
+        return retTemp;
+        }
+
+    // Now RFCOMM channel number of the next data socket must be the same as
+    // the current listener's RFCOMM channel number. Set that now.
+    iEntity.iChannelNum = iChannelNum;
+
+    // Register SDP record
+    iSDPHandleDun = 0;
+    retTemp = iDiscovery->RegisterSdpRecord( KDialUpNetworkingUUID,
+                                             iChannelNum,
+                                             iSDPHandleDun );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L( "CDunBtListen::StartServiceAdvertisement() (failed!) complete (%d)" ), retTemp));
+        return retTemp;
+        }
+    FTRACE(FPrint( _L( "CDunBtListen::StartServiceAdvertisement() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Stops dialup service advertisement
+// ---------------------------------------------------------------------------
+//
+TInt CDunBtListen::StopServiceAdvertisement()
+    {
+    FTRACE(FPrint( _L( "CDunBtListen::StopServiceAdvertisement()" ) ));
+    if ( !iDiscovery )
+        {
+        FTRACE(FPrint( _L( "CDunBtListen::StopServiceAdvertisement() (iDiscovery) not initialized!" ) ));
+        return KErrGeneral;
+        }
+    if ( iSDPHandleDun != 0 )
+        {
+        TInt retTemp = iDiscovery->DeleteSdpRecord( iSDPHandleDun );
+        FTRACE(FPrint( _L( "CDunBtListen::StopServiceAdvertisement() record closed (%d)" ), retTemp ));
+        iSDPHandleDun = 0;
+        }
+    if ( iListenSocket.SubSessionHandle() )
+        {
+        iListenSocket.Close();
+        }
+    FTRACE(FPrint( _L( "CDunBtListen::StopServiceAdvertisement() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Method which reserves local RFCOMM channel (from possible channels 1-30)
+// and returns it to client.
+// ---------------------------------------------------------------------------
+//
+TInt CDunBtListen::ReserveLocalChannel( RSocketServ& aSocketServ,
+                                        RSocket& aListenSocket,
+                                        TUint& aChannelNum,
+                                        TBool& aInUse )
+    {
+    FTRACE(FPrint(_L("CDunBtListen::ReserveLocalChannel()")));
+    aInUse = EFalse;
+    if ( aListenSocket.SubSessionHandle() )
+        {
+        FTRACE(FPrint(_L("CDunBtListen::ReserveLocalChannel() (open socket!) complete")));
+        return KErrArgument;
+        }
+    TInt retTemp;
+    TProtocolDesc pInfo;
+    retTemp = aSocketServ.FindProtocol( TProtocolName(KRFCOMMDesC), pInfo );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunBtListen::ReserveLocalChannel() (FindProtocol failed) complete (%d)"), retTemp));
+        return retTemp;
+        }
+    retTemp = aListenSocket.Open( aSocketServ,
+                                  pInfo.iAddrFamily,
+                                  pInfo.iSockType,
+                                  pInfo.iProtocol );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunBtListen::ReserveLocalChannel() (Open failed) complete (%d)"), retTemp));
+        return retTemp;
+        }
+    TRfcommSockAddr addr;
+    TBTServiceSecurity sec;
+    sec.SetAuthentication( ETrue );
+    sec.SetAuthorisation( ETrue );
+    sec.SetEncryption( ETrue );
+    sec.SetPasskeyMinLength( 0 );
+    addr.SetSecurity( sec );
+    addr.SetPort( KRfcommPassiveAutoBind );
+    // When fix from Apple, replace the following with
+    // "retTemp = aListenSocket.Bind( addr );"
+    retTemp = DoExtendedBind( aListenSocket, addr );
+    if ( retTemp != KErrNone )
+        {
+        aListenSocket.Close();
+        aInUse = ETrue;
+        FTRACE(FPrint(_L("CDunBtListen::ReserveLocalChannel() Bind() complete (%d)"), retTemp));
+        return KErrInUse;
+        }
+    aChannelNum = aListenSocket.LocalPort();
+    
+    // We try to set the Telephony and Networking bits in our service class.  If this fails we
+    // ignore it, as it's better to carry on without it than to fail to start listening.
+    (void)aListenSocket.SetOpt(KBTRegisterCodService, KSolBtRFCOMM, KCoDDunServiceClass);
+    
+    retTemp = aListenSocket.Listen( KListenQueSize );
+    if ( retTemp != KErrNone )
+        {
+        aListenSocket.Close();
+        FTRACE(FPrint(_L("CDunBtListen::ReserveLocalChannel() Listen() complete (%d)"), retTemp));
+        return retTemp;
+        }
+    FTRACE(FPrint(_L("CDunBtListen::ReserveLocalChannel() complete (%d)"), aChannelNum));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Tries to bind to a fixed port and if that fails with KRfcommPassiveAutoBind.
+// This is for spec breaking solutions like the OSX Leopard.
+// ---------------------------------------------------------------------------
+//
+TInt CDunBtListen::DoExtendedBind( RSocket& aListenSocket,
+                                   TRfcommSockAddr& aSockAddr )
+    {
+    FTRACE(FPrint(_L("CDunBtListen::DoExtendedBind()")));
+    if ( !aListenSocket.SubSessionHandle() )
+        {
+        FTRACE(FPrint(_L("CDunBtListen::DoExtendedBind() (closed socket!) complete")));
+        return KErrGeneral;
+        }
+    TRfcommSockAddr fixedAddr = aSockAddr;
+    fixedAddr.SetPort( KDunFixedChannel );
+    TInt retTemp = aListenSocket.Bind( fixedAddr );
+    if ( retTemp == KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunBtListen::DoExtendedBind() complete")));
+        return KErrNone;
+        }
+    TInt retVal = aListenSocket.Bind( aSockAddr );
+    FTRACE(FPrint(_L("CDunBtListen::DoExtendedBind() complete")));
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Called when a service is requested via BT.
+// ---------------------------------------------------------------------------
+//
+void CDunBtListen::RunL()
+    {
+    FTRACE(FPrint( _L( "CDunBtListen::RunL()" ) ));
+    iListenState = EBtListenStateIdle;
+
+    StopServiceAdvertisement();
+
+    TInt retTemp = iStatus.Int();
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L( "CDunBtListen::RunL() (ERROR) complete (%d)" ), retTemp));
+        iServer->NotifyPluginCloseRequest( KDunBtPluginUid, ETrue );
+        return;
+        }
+    // Notify new connection
+    TBool noFreeChans = EFalse;
+    retTemp = iParent->NotifyChannelAllocate( noFreeChans );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L( "CDunBtListen::RunL() channel allocation failed! (%d)" ), retTemp));
+        // Other error than no free channels, close plugin now
+        if ( !noFreeChans )
+            {
+            iServer->NotifyPluginCloseRequest( KDunBtPluginUid, ETrue );
+            }
+        return;
+        }
+
+    // Don't restart listening here. Request is issued via
+    // NotifyAdvertisementStart()
+
+    FTRACE(FPrint( _L( "CDunBtListen::RunL() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Cancel current activity.
+// ---------------------------------------------------------------------------
+//
+void CDunBtListen::DoCancel()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunServAdvMon.
+// Gets called when advertisement status changes to start.
+// ---------------------------------------------------------------------------
+//
+void CDunBtListen::NotifyAdvertisementStart( TBool aCreation )
+    {
+    FTRACE(FPrint( _L( "CDunBtListen::NotifyAdvertisementStart()" ) ));
+    // Remove the "if" below when fix comes from Apple
+    if ( !aCreation )
+        {
+        TRAP_IGNORE( IssueRequestL() );
+        }
+    FTRACE(FPrint( _L( "CDunBtListen::NotifyAdvertisementStart() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunServAdvMon.
+// Gets called when advertisement status changes to end.
+// ---------------------------------------------------------------------------
+//
+void CDunBtListen::NotifyAdvertisementEnd()
+    {
+    FTRACE(FPrint( _L( "CDunBtListen::NotifyAdvertisementEnd()" ) ));
+    Stop();
+    StopServiceAdvertisement();
+    FTRACE(FPrint( _L( "CDunBtListen::NotifyAdvertisementEnd() complete" ) ));
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/plugins/src/bt/DunBtPlugin.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,582 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DUN Bluetooth plugin
+*
+*/
+
+
+#include <bt_sock.h>
+#include <c32comm.h>
+#include "DunPlugin.h"
+#include "DunBtListen.h"
+#include "DunBtPlugin.h"
+#include "DunDebug.h"
+#include "DunTransporter.h"
+
+_LIT( KBtChannelName, "DUNBT::"  );
+
+const TInt KCharactersInTInt = 10;  // For "2147483648"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CDunBtPlugin::CDunBtPlugin()
+// ---------------------------------------------------------------------------
+//
+CDunBtPlugin::CDunBtPlugin() :
+    iServer( NULL ),
+    iBTListen( NULL ),
+    iTransporter( NULL )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunBtPlugin::~CDunBtPlugin()
+    {
+    FTRACE(FPrint( _L( "CDunBtPlugin::~CDunBtPlugin()" ) ));
+    Uninitialize();
+    FTRACE(FPrint( _L( "CDunBtPlugin::~CDunBtPlugin() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// State of this plugin
+// ---------------------------------------------------------------------------
+//
+TDunPluginState CDunBtPlugin::PluginState()
+    {
+    return iServer->GetPluginStateByUid( KDunBtPluginUid );
+    }
+
+// ---------------------------------------------------------------------------
+// Constructs a listener object for this plugin
+// ---------------------------------------------------------------------------
+//
+void CDunBtPlugin::ConstructListenerL()
+    {
+    FTRACE(FPrint(_L("CDunBtPlugin::ConstructListenerL()")));
+    if ( PluginState() != EDunStateLoaded )
+        {
+        FTRACE(FPrint(_L("CDunBtPlugin::ConstructListenerL() (not ready) complete")));
+        User::Leave( KErrNotReady );
+        }
+    ReportStateChangeUp( EDunStateTryListen );
+    if ( iBTListen )
+        {
+        FTRACE(FPrint(_L("CDunBtPlugin::ConstructListenerL() (already exists) complete")));
+        User::Leave( KErrAlreadyExists );
+        }
+    CDunBtListen* listen = CDunBtListen::NewL( iServer,
+                                               this,
+                                               iTransporter,
+                                               iEntity );
+    CleanupStack::PushL( listen );
+    listen->IssueRequestL();
+    CleanupStack::Pop( listen );
+    iBTListen = listen;
+    ReportStateChangeUp( EDunStateListening );
+    FTRACE(FPrint(_L("CDunBtPlugin::ConstructListenerL() complete")));
+    }
+
+// ---------------------------------------------------------------------------
+// Sets new state
+// New state must be one more than the old state
+// ---------------------------------------------------------------------------
+//
+TInt CDunBtPlugin::ReportStateChangeUp( TDunPluginState aPluginState )
+    {
+    FTRACE(FPrint(_L("CDunBtPlugin::ReportStateChangeUp()")));
+    TInt retTemp = iServer->NotifyPluginStateChangeUp( aPluginState,
+                                                       KDunBtPluginUid );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunBtPlugin::ReportStateChangeUp() (ERROR) complete")));
+        return retTemp;
+        }
+    FTRACE(FPrint(_L("CDunBtPlugin::ReportStateChangeUp() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Sets new state
+// New state must be one less than the old state
+// ---------------------------------------------------------------------------
+//
+TInt CDunBtPlugin::ReportStateChangeDown( TDunPluginState aPluginState )
+    {
+    FTRACE(FPrint(_L("CDunBtPlugin::ReportStateChangeDown()")));
+    TInt retTemp = iServer->NotifyPluginStateChangeDown( aPluginState,
+                                                         KDunBtPluginUid );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunBtPlugin::ReportStateChangeDown() (ERROR) complete")));
+        return retTemp;
+        }
+    FTRACE(FPrint(_L("CDunBtPlugin::ReportStateChangeDown() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Allocates a free channel
+// ---------------------------------------------------------------------------
+//
+void CDunBtPlugin::AllocateChannelL( TBool& aNoFreeChans,
+                                     TBtCleanupInfo& aCleanupInfo )
+    {
+    FTRACE(FPrint(_L("CDunBtPlugin::AllocateChannelL()")));
+    // iDataSocket has new data socket information so copy it to iBTPorts
+    TBtPortEntity* foundEntity = NULL;
+    TInt foundIndex = GetFirstFreePort( foundEntity );
+    if ( !foundEntity )  // free not found so add new
+        {
+        TBtPortEntity newEntity;
+        iBTPorts.AppendL( newEntity );
+        aCleanupInfo.iNewEntity = ETrue;
+        aCleanupInfo.iEntityIndex = iBTPorts.Count() - 1;
+        foundEntity = &iBTPorts[ aCleanupInfo.iEntityIndex ];
+        }
+    else  // free found so change array
+        {
+        aCleanupInfo.iNewEntity = EFalse;
+        aCleanupInfo.iEntityIndex = foundIndex;
+        foundEntity = &iBTPorts[ foundIndex ];
+        }
+    foundEntity->iChannelNum = iEntity.iChannelNum;
+    foundEntity->iBTPort = iEntity.iBTPort;
+    RSocket* socket = &foundEntity->iBTPort;
+    HBufC8* channelName = HBufC8::NewMaxLC( KBtChannelName().Length() +
+                          KCharactersInTInt );
+    TPtr8 channelNamePtr = channelName->Des();
+    channelNamePtr.Copy( KBtChannelName );
+    channelNamePtr.AppendNum( iEntity.iChannelNum );
+    iTransporter->AllocateChannelL( socket,
+                                    KDunBtPluginUid,
+                                    channelNamePtr,
+                                    EFalse,
+                                    aNoFreeChans );
+    iTransporter->AddConnMonCallbackL( socket,
+                                       this,
+                                       EDunReaderUpstream,
+                                       EFalse );
+    iTransporter->AddConnMonCallbackL( socket,
+                                       this,
+                                       EDunWriterUpstream,
+                                       EFalse );
+    iTransporter->AddConnMonCallbackL( socket,
+                                       this,
+                                       EDunReaderDownstream,
+                                       ETrue );
+    iTransporter->AddConnMonCallbackL( socket,
+                                       this,
+                                       EDunWriterDownstream,
+                                       EFalse );
+    iTransporter->IssueTransferRequestsL( socket );
+    CleanupStack::PopAndDestroy( channelName );
+    FTRACE(FPrint(_L("CDunBtPlugin::AllocateChannelL() complete")));
+    }
+
+// ---------------------------------------------------------------------------
+// Frees an existing channel
+// ---------------------------------------------------------------------------
+//
+TInt CDunBtPlugin::FreeChannels()
+    {
+    FTRACE(FPrint(_L("CDunBtPlugin::FreeChannels()")));
+    if ( PluginState() != EDunStateTryUninitialize )
+        {
+        FTRACE(FPrint(_L("CDunBtPlugin::FreeChannels() (not ready) complete")));
+        return KErrNotReady;
+        }
+    TInt i;
+    TInt count = iBTPorts.Count();
+    for ( i=0; i<count; i++ )
+        {
+        if ( iBTPorts[i].iBTPort.SubSessionHandle() )
+            {
+            iTransporter->FreeChannel( &iBTPorts[i].iBTPort );
+            iBTPorts[i].iBTPort.Close();
+            // All channels freed and this is for Uninitialize() so don't touch
+            // advertisement monitor here!
+            }
+        iBTPorts[i].iChannelNum = KErrNotFound;
+        }
+    iBTPorts.Close();
+    FTRACE(FPrint(_L("CDunBtPlugin::FreeChannels() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Uninitializes this plugin
+// ---------------------------------------------------------------------------
+//
+TInt CDunBtPlugin::Uninitialize()
+    {
+    FTRACE(FPrint( _L( "CDunBtPlugin::Uninitialize()" ) ));
+    ReportStateChangeDown( EDunStateTryUninitialize );
+    // Free channels (ignore errors)
+    FreeChannels();
+    // Delete listening object (also advertisement monitor)
+    delete iBTListen;
+    iBTListen = NULL;
+    // Set state back to loaded
+    ReportStateChangeUp( EDunStateUninitialized );
+    ReportStateChangeUp( EDunStateTryLoad );
+    ReportStateChangeUp( EDunStateLoaded );
+    FTRACE(FPrint( _L( "CDunBtPlugin::Uninitialize() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Gets port's index and entity by connection ID
+// ---------------------------------------------------------------------------
+//
+TInt CDunBtPlugin::GetPortByConnId( TConnId aConnId, TBtPortEntity*& aEntity )
+    {
+    FTRACE(FPrint( _L( "CDunBtPlugin::GetPortByConnId()")) );
+    TInt i;
+    TInt count = iBTPorts.Count();
+    for ( i=0; i<count; i++ )
+        {
+        if ( &iBTPorts[i].iBTPort == aConnId )
+            {
+            aEntity = &iBTPorts[i];
+            FTRACE(FPrint( _L( "CDunBtPlugin::GetPortByConnId() complete")) );
+            return i;
+            }
+        }
+    aEntity = NULL;
+    FTRACE(FPrint( _L( "CDunBtPlugin::GetPortByConnId() (not found) complete")) );
+    return KErrNotFound;
+    }
+
+// ---------------------------------------------------------------------------
+// Gets first free port's index and entity
+// ---------------------------------------------------------------------------
+//
+TInt CDunBtPlugin::GetFirstFreePort( TBtPortEntity*& aEntity )
+    {
+    FTRACE(FPrint( _L( "CDunBtPlugin::GetFirstFreePort()")) );
+    TInt i;
+    TInt count = iBTPorts.Count();
+    for ( i=0; i<count; i++ )
+        {
+        if ( !iBTPorts[i].iBTPort.SubSessionHandle() )
+            {
+            aEntity = &iBTPorts[i];
+            FTRACE(FPrint( _L( "CDunBtPlugin::GetFirstFreePort() complete")) );
+            return i;
+            }
+        }
+    aEntity = NULL;
+    FTRACE(FPrint( _L( "CDunBtPlugin::GetFirstFreePort() (not found) complete")) );
+    return KErrNotFound;
+    }
+
+// ---------------------------------------------------------------------------
+// Sets modem's MSC (Modem Status Command)
+// ---------------------------------------------------------------------------
+//
+TInt CDunBtPlugin::SetRFCOMMStatusCommand( TBtPortEntity& aEntity,
+                                           TUint8 aSignal,
+                                           TBool aSignalOn )
+    {
+    FTRACE(FPrint( _L( "CDunBtPlugin::SetRFCOMMStatusCommand()" ) ));
+    // Get existing Modem Status Command (MSC)
+    // Ref.: 3GPP TS 07.10 V7.2.0 (2002-03)
+    // Table 6,7, (5.4.6.3.7)
+    TUint8 modemStatus = 0;
+    TPckgBuf<TUint8> pkg( modemStatus );
+    TInt retTemp = aEntity.iBTPort.GetOpt( KRFCOMMLocalModemStatus,
+                                           KSolBtRFCOMM,
+                                           pkg );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L( "CDunBtPlugin::SetRFCOMMStatusCommand() (GetOpt failed!) complete" ) ));
+        return retTemp;
+        }
+    modemStatus = pkg();
+    FTRACE(FPrint( _L( "CDunBtPlugin::SetRFCOMMStatusCommand() signals are: 0x%02X" ), modemStatus));
+    TBool changed = EFalse;
+    TUint8 signal = modemStatus & aSignal;
+    if ( aSignalOn )
+        {
+        if ( !signal )
+            {
+            modemStatus |= aSignal;
+            changed = ETrue;
+            }
+        }
+    else
+        {
+        if ( signal )
+            {
+            modemStatus &= ( ~aSignal );
+            changed = ETrue;
+            }
+        }
+    if ( changed )
+        {
+        pkg = modemStatus;
+        retTemp = aEntity.iBTPort.SetOpt( KRFCOMMLocalModemStatus,
+                                          KSolBtRFCOMM,
+                                          pkg );
+        if ( retTemp != KErrNone )
+            {
+            FTRACE(FPrint( _L( "CDunBtPlugin::SetRFCOMMStatusCommand() (SetOpt failed!) complete" ) ));
+            return retTemp;
+            }
+        }
+    FTRACE(FPrint( _L( "CDunBtPlugin::SetRFCOMMStatusCommand() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Manages advertiser for channel free operation
+// ---------------------------------------------------------------------------
+//
+void CDunBtPlugin::ManageAdvertiserFreeOperationL()
+    {
+    FTRACE(FPrint(_L("CDunBtPlugin::ManageAdvertiserFreeOperationL()")));
+    TInt numOfChans = iTransporter->NumberOfAllocatedChannels();
+    // Remove of last CDunTransporter channel removes also the
+    // advertisement monitor so set it now if necessary
+    if ( numOfChans == 0 )
+        {
+        iTransporter->SetAdvertisementMonitorL( KDunBtPluginUid, iBTListen );
+        }
+    FTRACE(FPrint(_L("CDunBtPlugin::ManageAdvertiserFreeOperationL() complete")));
+    }
+
+// ---------------------------------------------------------------------------
+// Cleans partial created channel data based on TATExtCleanupInfo
+// ---------------------------------------------------------------------------
+//
+void CDunBtPlugin::CleanPartialChanneldata( TBtCleanupInfo& aCleanupInfo )
+    {
+    FTRACE(FPrint(_L("CDunBtPlugin::CleanPartialChanneldata()")));
+    RSocket* socket = &iBTPorts[aCleanupInfo.iEntityIndex].iBTPort;
+    iTransporter->FreeChannel( socket );
+    iBTPorts[aCleanupInfo.iEntityIndex].iChannelNum = KErrNotFound;
+    socket->Close();
+    if ( aCleanupInfo.iNewEntity )
+        {
+        iBTPorts.Remove( aCleanupInfo.iEntityIndex );
+        }
+    FTRACE(FPrint(_L("CDunBtPlugin::CleanPartialChanneldata() complete")));
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunLocalMediaPlugin.
+// CDunBtPlugin::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunBtPlugin::ConstructL( MDunServerCallback* aServer,
+                               CDunTransporter* aTransporter )
+    {
+    FTRACE(FPrint( _L( "CDunBtPlugin::ConstructL()" ) ));
+    if ( !aServer || !aTransporter )
+        {
+        FTRACE(FPrint(_L("CDunBtPlugin::ConstructL() not initialized!")));
+        User::Leave( KErrBadHandle );
+        }
+    iServer = aServer;
+    iTransporter = aTransporter;
+    FTRACE(FPrint( _L( "CDunBtPlugin::ConstructL() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunLocalMediaPlugin.
+// Gets called when server changes a plugin's state
+// ---------------------------------------------------------------------------
+//
+TInt CDunBtPlugin::NotifyServerStateChange( TDunPluginState aPluginState )
+    {
+    FTRACE(FPrint(_L("CDunBtPlugin::NotifyServerStateChange()")));
+    TInt retTemp;
+    switch ( aPluginState )
+        {
+        case EDunStateTryListen:
+            if ( PluginState() != EDunStateLoaded )
+                {
+                FTRACE(FPrint(_L("CDunBtPlugin::NotifyServerStateChange() (not ready) complete")));
+                return KErrNotReady;
+                }
+            // Change to listening mode
+            TRAPD( retTrap, ConstructListenerL() );
+            if ( retTrap != KErrNone )
+                {
+                FTRACE(FPrint(_L("CDunBtPlugin::NotifyServerStateChange() (ERROR) complete (%d)"), retTrap));
+                return retTrap;
+                }
+            break;
+        case EDunStateTryUninitialize:
+            if ( PluginState() == EDunStateUninitialized )
+                {
+                FTRACE(FPrint(_L("CDunBtPlugin::NotifyServerStateChange() (not ready) complete")));
+                return KErrNotReady;
+                }
+            // Uninitialize
+            retTemp = Uninitialize();
+            if ( retTemp != KErrNone )
+                {
+                FTRACE(FPrint(_L("CDunBtPlugin::NotifyServerStateChange() (not ready) complete (%d)"), retTemp));
+                return KErrNotReady;
+                }
+            break;
+        default:
+            FTRACE(FPrint(_L("CDunBtPlugin::NotifyServerStateChange() (unknown state) complete")));
+            return KErrNotSupported;
+        }
+    FTRACE(FPrint(_L("CDunBtPlugin::NotifyServerStateChange() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunLocalMediaPlugin.
+// Gets called when server needs to know the active connection
+// ---------------------------------------------------------------------------
+//
+TConnId CDunBtPlugin::ActiveConnection()
+    {
+    FTRACE(FPrint(_L("CDunBtPlugin::ActiveConnection()")));
+    if ( iBTPorts.Count() >= 1 )
+        {
+        FTRACE(FPrint(_L("CDunBtPlugin::ActiveConnection() complete")));
+        return &iBTPorts[0];
+        }
+    FTRACE(FPrint(_L("CDunBtPlugin::ActiveConnection() (not found) complete")));
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunListenCallback.
+// Gets called when new channel must be created
+// ---------------------------------------------------------------------------
+//
+TInt CDunBtPlugin::NotifyChannelAllocate( TBool& aNoFreeChans )
+    {
+    // Now state can be either EDunStateListening (no channels) or
+    // EDunStateChanneled (one or more channels). Support both states
+    TDunPluginState startState = PluginState();
+    if ( startState!=EDunStateListening && startState!=EDunStateChanneled )
+        {
+        FTRACE(FPrint(_L("CDunBtPlugin::NotifyChannelAllocate() (not ready) complete")));
+        return KErrNotReady;
+        }
+    if ( startState == EDunStateListening )
+        {
+        ReportStateChangeUp( EDunStateTryChannel );
+        }
+    TBtCleanupInfo cleanupInfo;
+    TRAPD( retTrap, AllocateChannelL(aNoFreeChans,cleanupInfo) );
+    if ( retTrap != KErrNone )
+        {
+        CleanPartialChanneldata( cleanupInfo );
+        FTRACE(FPrint(_L("CDunBtPlugin::NotifyChannelAllocate() (trapped!) complete")));
+        return retTrap;
+        }
+    if ( startState == EDunStateListening )
+        {
+        ReportStateChangeUp( EDunStateChanneled );
+        }
+    FTRACE(FPrint(_L("CDunBtPlugin::NotifyChannelAllocate() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunListenCallback.
+// Gets called when an existing channel must be freed
+// ---------------------------------------------------------------------------
+//
+TInt CDunBtPlugin::NotifyChannelFree()
+    {
+    // No implementation needed here
+    return KErrNotSupported;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunConnMon.
+// Gets called when line status changes or when any type of error is detected
+// ---------------------------------------------------------------------------
+//
+void CDunBtPlugin::NotifyProgressChangeL( TConnId aConnId,
+                                          TDunConnectionReason aConnReason )
+    {
+    FTRACE(FPrint( _L( "CDunBtPlugin::NotifyProgressChangeL()" ) ));
+    // Find matching failed ID
+    TBtPortEntity* foundEntity = NULL;
+    TInt foundIndex = GetPortByConnId( aConnId, foundEntity );
+    if ( !foundEntity )
+        {
+        FTRACE(FPrint( _L( "CDunBtPlugin::NotifyProgressChangeL() (not found) complete")) );
+        User::Leave( KErrNotFound );
+        }
+    if ( aConnReason.iReasonType == EDunReasonTypeSignal )
+        {
+        if ( aConnReason.iContext != EDunMediaContextNetwork )
+            {
+            // Should never come here as other signals are for RComm
+            FTRACE(FPrint( _L( "CDunBtPlugin::NotifyProgressChangeL() (ERROR) complete")) );
+            User::Leave( KErrGeneral );
+            }
+        // Signal change detected on network side -> process change
+        if ( aConnReason.iSignalType == KSignalDCD )
+            {
+            SetRFCOMMStatusCommand( *foundEntity,
+                                    KModemSignalDV,
+                                    aConnReason.iSignalHigh );
+            FTRACE(FPrint( _L( "CDunBtPlugin::NotifyProgressChangeL() DV changed")) );
+            }
+        else if ( aConnReason.iSignalType == KSignalRNG )
+            {
+            SetRFCOMMStatusCommand( *foundEntity,
+                                    KModemSignalIC,
+                                    aConnReason.iSignalHigh );
+            FTRACE(FPrint( _L( "CDunBtPlugin::NotifyProgressChangeL() IC changed")) );
+            }
+        // Omit other signals
+        }
+    else
+        {
+        // All other cases are down indications from local media side
+        if ( foundEntity->iBTPort.SubSessionHandle() )
+            {
+            iTransporter->FreeChannel( &foundEntity->iBTPort );
+            // CDunTransporter will notify the listener about advertisement
+            // status change after FreeChannel() so no need to do
+            // IssueRequestL() for CDunBtListen here after this.
+            foundEntity->iBTPort.Close();
+            }
+        ManageAdvertiserFreeOperationL();
+        // Now resources are freed so command server to reopen possibly
+        // existing queued plugins
+        iServer->NotifyPluginReopenRequest();
+        }
+    FTRACE(FPrint( _L( "CDunBtPlugin::NotifyProgressChangeL() complete")) );
+    }
+
+// ======== GLOBAL FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// NewLocalPluginL implements factory construction for
+// the class CDunBtPlugin.
+// The function is exported at ordinal 1.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C MDunLocalMediaPlugin* NewLocalPluginL()
+    {
+    return new (ELeave) CDunBtPlugin;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/plugins/src/ir/DunIrPlugin.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,340 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DUN Infrared plugin
+*
+*/
+
+
+#include "DunIrPlugin.h"
+#include "DunUtils.h"
+#include "DunDebug.h"
+
+_LIT( KIrdaCsy,       "IRCOMM"    );
+_LIT( KIrdaCsy0,      "IRCOMM::0" );
+_LIT( KIrChannelName, "DUNIR::0"  );
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CDunIrPlugin::CDunIrPlugin
+// ---------------------------------------------------------------------------
+//
+CDunIrPlugin::CDunIrPlugin() :
+    iServer( NULL ),
+    iTransporter( NULL )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunIrPlugin::~CDunIrPlugin()
+    {
+    FTRACE(FPrint( _L( "CDunIrPlugin::~CDunIrPlugin()" ) ));
+    Uninitialize();
+    FTRACE(FPrint( _L( "CDunIrPlugin::~CDunIrPlugin() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// Gets state of this plugin
+// ---------------------------------------------------------------------------
+//
+TDunPluginState CDunIrPlugin::PluginState()
+    {
+    return iServer->GetPluginStateByUid( KDunIrPluginUid );
+    }
+
+// ---------------------------------------------------------------------------
+// Constructs a listener object for this plugin
+// ---------------------------------------------------------------------------
+//
+TInt CDunIrPlugin::ConstructListener()
+    {
+    FTRACE(FPrint(_L("CDunIrPlugin::ConstructListenerL()")));
+    if ( PluginState() != EDunStateLoaded )
+        {
+        FTRACE(FPrint(_L("CDunIrPlugin::ConstructListenerL() (not ready) complete")));
+        return KErrNotReady;
+        }
+    ReportStateChangeUp( EDunStateTryListen );
+    TInt retTemp = InitPort();
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunIrPlugin::ConstructListenerL() (ERROR) complete")));
+        return retTemp;
+        }
+    ReportStateChangeUp( EDunStateListening );
+    ReportStateChangeUp( EDunStateTryChannel );
+    TRAPD( retTrap, AllocateChannelL() );
+    if ( retTrap != KErrNone )
+        {
+        iTransporter->FreeChannel( &iIrPort );
+        FTRACE(FPrint(_L("CDunIrPlugin::ConstructListenerL() (trapped!) complete")));
+        return retTrap;
+        }
+    ReportStateChangeUp( EDunStateChanneled );
+    FTRACE(FPrint(_L("CDunIrPlugin::ConstructListenerL() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Sets new state
+// New state must be one more than the old state
+// ---------------------------------------------------------------------------
+//
+TInt CDunIrPlugin::ReportStateChangeUp( TDunPluginState aPluginState )
+    {
+    FTRACE(FPrint(_L("CDunIrPlugin::ReportStateChangeUp()")));
+    TInt retTemp = iServer->NotifyPluginStateChangeUp( aPluginState,
+                                                       KDunIrPluginUid );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunIrPlugin::ReportStateChangeUp() (ERROR) complete")));
+        return retTemp;
+        }
+    FTRACE(FPrint(_L("CDunIrPlugin::ReportStateChangeUp() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Sets new state
+// New state must be one less than the old state
+// ---------------------------------------------------------------------------
+//
+TInt CDunIrPlugin::ReportStateChangeDown( TDunPluginState aPluginState )
+    {
+    FTRACE(FPrint(_L("CDunIrPlugin::ReportStateChangeDown()")));
+    TInt retTemp = iServer->NotifyPluginStateChangeDown( aPluginState,
+                                                         KDunIrPluginUid );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunIrPlugin::ReportStateChangeDown() (ERROR) complete")));
+        return retTemp;
+        }
+    FTRACE(FPrint(_L("CDunIrPlugin::ReportStateChangeDown() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes one infrared port with role DCE
+// ---------------------------------------------------------------------------
+//
+TInt CDunIrPlugin::InitPort()
+    {
+    FTRACE(FPrint( _L( "CDunIrPlugin::InitPort()" ) ));
+    TInt retTemp;
+    retTemp = CDunUtils::ConnectCommsServer( iCommServer );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L( "CDunIrPlugin::InitPort() (ERROR) complete" ) ));
+        return retTemp;
+        }
+    retTemp = iCommServer.LoadCommModule( KIrdaCsy );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunIrPlugin::InitPort() (load module) failed!") ));
+        return retTemp;
+        }
+    if ( iIrPort.SubSessionHandle() )
+        {
+        FTRACE(FPrint(_L("CDunIrPlugin::InitPort (already exists!) complete") ));
+        return KErrAlreadyExists;
+        }
+    retTemp = iIrPort.Open( iCommServer,
+                            KIrdaCsy0,
+                            ECommExclusive,
+                            ECommRoleDCE );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunIrPlugin::InitPort() (open) failed!") ));
+        return retTemp;
+        }
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Allocates a channel
+// ---------------------------------------------------------------------------
+//
+void CDunIrPlugin::AllocateChannelL()
+    {
+    FTRACE(FPrint(_L("CDunIrPlugin::AllocateChannelL()")));
+    HBufC8* channelName = HBufC8::NewMaxLC( KIrChannelName().Length() );
+    TPtr8 channelNamePtr = channelName->Des();
+    channelNamePtr.Copy( KIrChannelName );
+    iTransporter->AllocateChannelL( &iIrPort,
+                                    KDunIrPluginUid,
+                                    channelNamePtr,
+                                    ETrue );
+    iTransporter->AddConnMonCallbackL( &iIrPort,
+                                       this,
+                                       EDunReaderUpstream,
+                                       EFalse );
+    iTransporter->AddConnMonCallbackL( &iIrPort,
+                                       this,
+                                       EDunWriterUpstream,
+                                       EFalse );
+    iTransporter->AddConnMonCallbackL( &iIrPort,
+                                       this,
+                                       EDunReaderDownstream,
+                                       EFalse );
+    iTransporter->AddConnMonCallbackL( &iIrPort,
+                                       this,
+                                       EDunWriterDownstream,
+                                       EFalse );
+    iTransporter->IssueTransferRequestsL( &iIrPort );
+    CleanupStack::PopAndDestroy( channelName );
+    FTRACE(FPrint(_L("CDunIrPlugin::AllocateChannelL() complete")));
+    }
+
+// ---------------------------------------------------------------------------
+// Uninitializes this plugin
+// ---------------------------------------------------------------------------
+//
+TInt CDunIrPlugin::Uninitialize()
+    {
+    FTRACE(FPrint(_L("CDunIrPlugin::Uninitialize()" )));
+    ReportStateChangeDown( EDunStateTryUninitialize );
+    if ( iIrPort.SubSessionHandle() )
+        {
+        iTransporter->FreeChannel( &iIrPort );
+        iIrPort.SetSignals( 0, KSignalDCEOutputs );
+        iIrPort.Close();
+        }
+    if ( iCommServer.Handle() )
+        {
+        iCommServer.UnloadCommModule( KIrdaCsy );
+        iCommServer.Close();
+        }
+    ReportStateChangeUp( EDunStateUninitialized );
+    ReportStateChangeUp( EDunStateTryLoad );
+    ReportStateChangeUp( EDunStateLoaded );
+    FTRACE(FPrint(_L("CDunIrPlugin::Uninitialize() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunLocalMediaPlugin.
+// CDunIrPlugin::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunIrPlugin::ConstructL( MDunServerCallback* aServer,
+                               CDunTransporter* aTransporter )
+    {
+    FTRACE(FPrint(_L("CDunIrPlugin::ConstructL()")));
+    if ( !aServer || !aTransporter )
+        {
+        FTRACE(FPrint(_L("CDunIrPlugin::ConstructL() not initialized!")));
+        User::Leave( KErrGeneral );
+        }
+    iServer = aServer;
+    iTransporter = aTransporter;
+    FTRACE(FPrint(_L("CDunIrPlugin::ConstructL() complete")));
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunLocalMediaPlugin.
+// Gets called when server changes a plugin's state
+// ---------------------------------------------------------------------------
+//
+TInt CDunIrPlugin::NotifyServerStateChange( TDunPluginState aPluginState )
+    {
+    FTRACE(FPrint(_L("CDunIrPlugin::NotifyServerStateChange()")));
+    TInt retTemp;
+    switch ( aPluginState )
+        {
+        case EDunStateTryListen:
+            if ( PluginState() != EDunStateLoaded )
+                {
+                FTRACE(FPrint(_L("CDunIrPlugin::NotifyServerStateChange() (not ready) complete")));
+                return KErrNotReady;
+                }
+            // Change to listening mode
+            retTemp = ConstructListener();
+            if ( retTemp != KErrNone )
+                {
+                FTRACE(FPrint(_L("CDunIrPlugin::NotifyServerStateChange() (ERROR) complete (%d)"), retTemp));
+                return retTemp;
+                }
+            break;
+        case EDunStateTryUninitialize:
+            if ( PluginState() == EDunStateUninitialized )
+                {
+                FTRACE(FPrint(_L("CDunIrPlugin::NotifyServerStateChange() (not ready) complete")));
+                return KErrNotReady;
+                }
+            // Uninitialize
+            retTemp = Uninitialize();
+            if ( retTemp != KErrNone )
+                {
+                FTRACE(FPrint(_L("CDunIrPlugin::NotifyServerStateChange() (ERROR) complete (%d)"), retTemp));
+                return retTemp;
+                }
+            break;
+        default:
+            FTRACE(FPrint(_L("CDunIrPlugin::NotifyServerStateChange() (unknown state) complete")));
+            return KErrNotSupported;
+        }
+    FTRACE(FPrint(_L("CDunIrPlugin::NotifyServerStateChange() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunLocalMediaPlugin.
+// Gets called when server needs to know the active connection
+// ---------------------------------------------------------------------------
+//
+TConnId CDunIrPlugin::ActiveConnection()
+    {
+    FTRACE(FPrint(_L("CDunIrPlugin::ActiveConnection()")));
+    FTRACE(FPrint(_L("CDunIrPlugin::ActiveConnection() (not found) complete")));
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunConnMon.
+// Gets called when line status changes or when any type of error is detected
+// ---------------------------------------------------------------------------
+//
+void CDunIrPlugin::NotifyProgressChangeL(
+    TConnId aConnId,
+    TDunConnectionReason /*aConnReason*/ )
+    {
+    FTRACE(FPrint( _L( "CDunIrPlugin::NotifyProgressChangeL()" ) ));
+    RComm* irConn = static_cast<RComm*>( aConnId );
+    if ( &iIrPort != irConn )
+        {
+        FTRACE(FPrint( _L( "CDunIrPlugin::NotifyProgressChangeL() (not found) complete")) );
+        User::Leave( KErrNotFound );
+        }
+    // Now indications are down indications from local media side
+    FTRACE(FPrint( _L( "CDunIrPlugin::NotifyProgressChangeL() restart plugin" ) ));
+    iServer->NotifyPluginRestart( KDunIrPluginUid );
+    FTRACE(FPrint( _L( "CDunIrPlugin::NotifyProgressChangeL() complete")) );
+    }
+
+// ======== GLOBAL FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// NewLocalPluginL implements factory construction for
+// the class CDunIrPlugin.
+// The function is exported at ordinal 1.
+// Returns: Pointer: The new instance of CDunIrPlugin
+// ---------------------------------------------------------------------------
+//
+EXPORT_C MDunLocalMediaPlugin* NewLocalPluginL()
+    {
+    return new (ELeave) CDunIrPlugin;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/plugins/src/usb/DunUsbConfig.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,292 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DUN USB configuration accessor and listener
+*
+*/
+
+
+#include "DunUsbConfig.h"
+#include "DunDebug.h"
+
+const TUint KDunUsbSupportedConfigVersion = 1;
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunUsbConfig* CDunUsbConfig::NewL( MDunServerCallback* aServer,
+                                    MDunUsbConfig* aCallback,
+                                    TUint8 aProtocol )
+    {
+    CDunUsbConfig* self = new (ELeave) CDunUsbConfig( aServer,
+                                                      aCallback,
+                                                      aProtocol );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunUsbConfig::~CDunUsbConfig()
+    {
+    FTRACE(FPrint( _L("CDunUsbConfig::~CDunUsbConfig()" )));
+    ResetData();
+    FTRACE(FPrint( _L("CDunUsbConfig::~CDunUsbConfig() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Resets data to initial values
+// ---------------------------------------------------------------------------
+//
+void CDunUsbConfig::ResetData()
+    {
+    // APIs affecting this:
+    // IssueRequest()
+    Stop();
+    // NewL()
+    iAcmProperty.Close();
+    // Internal
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// Compares initialized protocol number to configuration by index
+// ---------------------------------------------------------------------------
+//
+TInt CDunUsbConfig::GetConfigValidityByIndex( TInt aIndex, TBool& aValidity )
+    {
+    FTRACE(FPrint( _L("CDunUsbConfig::GetConfigValidityByIndex()" )));
+    if ( iConfigState != EUsbConfigStateIdle )
+        {
+        FTRACE(FPrint( _L("CDunUsbConfig::GetConfigValidityByIndex() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    if ( !iConfigExist )
+        {
+        TInt retTemp = GetConfiguration( iConfig );
+        if ( retTemp != KErrNone )
+            {
+            FTRACE(FPrint( _L("CDunUsbConfig::GetConfigValidityByIndex() (get failed) complete" )));
+            return retTemp;
+            }
+        }
+    if ( aIndex < 0 ||
+         aIndex >= iConfig.iAcmCount ||
+         aIndex >= TPublishedAcmConfigs::KAcmMaxFunctions )
+        {
+        FTRACE(FPrint( _L("CDunUsbConfig::GetConfigValidityByIndex() (not found) complete" )));
+        return KErrNotFound;
+        }
+    if ( iConfig.iAcmConfig[aIndex].iProtocol == iProtocol )
+        {
+        aValidity = ETrue;
+        }
+    else
+        {
+        aValidity = EFalse;
+        }
+    FTRACE(FPrint( _L("CDunUsbConfig::GetConfigValidityByIndex() complete (%d/%d)" ), aIndex, aValidity));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Starts listening for ACM configuration changes
+// ---------------------------------------------------------------------------
+//
+TInt CDunUsbConfig::IssueRequest()
+    {
+    FTRACE(FPrint( _L("CDunUsbConfig::IssueRequest()" )));
+    if ( iConfigState != EUsbConfigStateIdle )
+        {
+        FTRACE(FPrint( _L("CDunUsbConfig::IssueRequest() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    iStatus = KRequestPending;
+    iAcmProperty.Subscribe( iStatus );
+    SetActive();
+    iConfigState = EUsbConfigStateWaiting;
+    FTRACE(FPrint( _L("CDunUsbConfig::IssueRequest() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Stops listening for ACM configuration changes
+// ---------------------------------------------------------------------------
+//
+TInt CDunUsbConfig::Stop()
+    {
+    FTRACE(FPrint( _L("CDunUsbConfig::Stop()" )));
+    if ( iConfigState != EUsbConfigStateWaiting )
+        {
+        FTRACE(FPrint( _L("CDunUsbConfig::Stop() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    iAcmProperty.Cancel();
+    Cancel();
+    iConfigState = EUsbConfigStateIdle;
+    FTRACE(FPrint( _L("CDunUsbConfig::Stop() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunUsbConfig::CDunUsbConfig
+// ---------------------------------------------------------------------------
+//
+CDunUsbConfig::CDunUsbConfig( MDunServerCallback* aServer,
+                              MDunUsbConfig* aCallback,
+                              TUint8 aProtocol ) :
+    CActive( EPriorityStandard ),
+    iServer( aServer ),
+    iCallback( aCallback ),
+    iProtocol( aProtocol )
+    {
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// CDunUsbConfig::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunUsbConfig::ConstructL()
+    {
+    FTRACE(FPrint( _L("CDunUsbConfig::ConstructL()" )));
+    if ( !iServer || !iCallback )
+        {
+        User::Leave( KErrGeneral );
+        }
+    User::LeaveIfError( iAcmProperty.Attach(KUidSystemCategory,KAcmKey) );
+    CActiveScheduler::Add( this );
+    FTRACE(FPrint( _L("CDunUsbConfig::ConstructL() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes this class
+// ---------------------------------------------------------------------------
+//
+void CDunUsbConfig::Initialize()
+    {
+    // Don't initialize iCallback here (it is set through NewL)
+    // Don't initialize iProtocol here (it is set through NewL)
+    iConfigState = EUsbConfigStateIdle;
+    iConfig.iAcmConfigVersion = 0;
+    iConfig.iAcmCount = 0;
+    iConfigExist = EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// Gets current ACM configuration
+// ---------------------------------------------------------------------------
+//
+TInt CDunUsbConfig::GetConfiguration( TPublishedAcmConfigs& aConfig )
+    {
+    FTRACE(FPrint( _L("CDunUsbConfig::GetConfiguration()" )));
+    TPckgBuf<TPublishedAcmConfigs> configBuf;
+    TInt retTemp = iAcmProperty.Get( configBuf );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunUsbConfig::GetConfiguration() (ERROR) complete" )));
+        return retTemp;
+        }
+    aConfig = configBuf();
+    // Check that version is that which we currently support
+    if ( aConfig.iAcmConfigVersion != KDunUsbSupportedConfigVersion )
+        {
+        FTRACE(FPrint( _L("CDunUsbConfig::GetConfiguration() (not supported) complete" )));
+        return KErrNotSupported;
+        }
+    // Check that count is within bounds
+    if ( aConfig.iAcmCount > TPublishedAcmConfigs::KAcmMaxFunctions )
+        {
+        FTRACE(FPrint( _L("CDunUsbConfig::GetConfiguration() (overflow) complete" )));
+        return KErrOverflow;
+        }
+    iConfigExist = ETrue;
+    FTRACE(FPrint( _L("CDunUsbConfig::GetConfiguration() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called when ACM configuration changes
+// ---------------------------------------------------------------------------
+//
+void CDunUsbConfig::RunL()
+    {
+    FTRACE(FPrint( _L("CDunUsbConfig::RunL()" )));
+    iConfigState = EUsbConfigStateIdle;
+
+    TPublishedAcmConfigs newConfig;
+    TInt retTemp = GetConfiguration( newConfig );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunUsbConfig::RunL() (ERROR) complete (%d)" ), retTemp));
+        iServer->NotifyPluginCloseRequest( KDunUsbPluginUid, ETrue );
+        return;
+        }
+    // Change that is same is not possible so check that first
+    if ( newConfig.iAcmCount == iConfig.iAcmCount )
+        {
+        FTRACE(FPrint( _L("CDunUsbConfig::RunL() (no change) complete" )));
+        iServer->NotifyPluginCloseRequest( KDunUsbPluginUid, ETrue );
+        return;
+        }
+
+    // Now we have the changed configuration so find out are there added or
+    // removed USB ACMs
+
+    TInt i;
+    if ( newConfig.iAcmCount > iConfig.iAcmCount )  // addition
+        {
+        // Addition is always done to end of ACM queue by N entry addition
+        // Scan through new array and report change if necessary
+        for ( i=iConfig.iAcmCount; i<newConfig.iAcmCount; i++ )
+            {
+            if ( newConfig.iAcmConfig[i].iProtocol == iProtocol )
+                {
+                iCallback->NotifyConfigAddition( i );
+                }
+            }
+        }
+    else  // removal ( newConfig.iAcmCount < iConfig.iAcmCount )
+        {
+        // Removal is always done to end of ACM queue by N entry removal
+        // Scan through old array and report change if necessary
+        for ( i=newConfig.iAcmCount; i<iConfig.iAcmCount; i++ )
+            {
+            if ( iConfig.iAcmConfig[i].iProtocol == iProtocol )
+                {
+                iCallback->NotifyConfigRemoval( i );
+                }
+            }
+        }
+
+    // Update config and restart listening
+    iConfig = newConfig;
+    IssueRequest();
+
+    FTRACE(FPrint( _L("CDunUsbConfig::RunL() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called on cancel
+// ---------------------------------------------------------------------------
+//
+void CDunUsbConfig::DoCancel()
+    {
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/plugins/src/usb/DunUsbListen.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,259 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DUN USB plugin's listener
+*
+*/
+
+
+#include <e32std.h>
+#include "DunUtils.h"
+#include "DunUsbListen.h"
+#include "DunDebug.h"
+
+const TUint KDunUsbDeviceStateMask = 0x00ff;
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunUsbListen* CDunUsbListen::NewL( MDunServerCallback* aServer,
+                                    MDunListenCallback* aParent,
+                                    RUsb& aUsbServer )
+    {
+    CDunUsbListen* self = new (ELeave) CDunUsbListen( aServer,
+                                                      aParent,
+                                                      aUsbServer );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunUsbListen::~CDunUsbListen()
+    {
+    FTRACE(FPrint( _L( "CDunUsbListen::~CDunUsbListen()" ) ));
+    ResetData();
+    FTRACE(FPrint( _L( "CDunUsbListen::~CDunUsbListen() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// Resets data to initial values
+// ---------------------------------------------------------------------------
+//
+void CDunUsbListen::ResetData()
+    {
+    // APIs affecting this:
+    // IssueRequestL()
+    Stop();
+    // Internal
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// IssueRequest to USB server for device state change notifications
+// ---------------------------------------------------------------------------
+//
+TInt CDunUsbListen::IssueRequestL()
+    {
+    FTRACE(FPrint( _L( "CDunUsbListen::IssueRequestL()" )));
+
+    if ( iUsbServer.Handle() == KNullHandle )
+        {
+        FTRACE(FPrint( _L( "CDunUsbListen::IssueRequestL() (iUsbServer) complete" ) ));
+        User::Leave( KErrGeneral );
+        }
+
+    TUsbDeviceState usbDeviceState;
+    User::LeaveIfError( iUsbServer.GetDeviceState(usbDeviceState) );
+    FTRACE(FPrint( _L( "CDunUsbListen::IssueRequestL() Usb device state = %X" ), usbDeviceState));
+    if ( iDeviceState == EUsbDeviceStateUndefined )
+        {
+        iDeviceState = usbDeviceState;
+        }
+
+    // USB device state now set; if configured already, notify parent
+    // If not yet configured, start listening
+
+    if ( usbDeviceState == EUsbDeviceStateConfigured )
+        {
+        FTRACE(FPrint( _L( "CDunUsbListen::IssueRequestL() (already exists) complete" ) ));
+        return KErrAlreadyExists;
+        }
+
+    Activate();
+
+    FTRACE(FPrint( _L( "CDunUsbListen::IssueRequestL() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Stops listening
+// ---------------------------------------------------------------------------
+//
+TInt CDunUsbListen::Stop()
+    {
+    FTRACE(FPrint( _L( "CDunUsbListen::Stop()" ) ));
+    if ( iListenState != EUsbListenStateListening )
+        {
+        FTRACE(FPrint( _L( "CDunUsbListen::Stop() (not ready) complete" ) ));
+        return KErrNotReady;
+        }
+    iUsbServer.DeviceStateNotificationCancel();
+    Cancel();
+    iListenState = EUsbListenStateIdle;
+    iDeviceState = EUsbDeviceStateUndefined;
+    iDeviceStatePrev = EUsbDeviceStateUndefined;
+    FTRACE(FPrint( _L( "CDunUsbListen::Stop() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunUsbListen::CDunUsbListen
+// ---------------------------------------------------------------------------
+//
+CDunUsbListen::CDunUsbListen( MDunServerCallback* aServer,
+                              MDunListenCallback* aParent,
+                              RUsb& aUsbServer ) :
+    CActive( EPriorityStandard ),
+    iServer( aServer ),
+    iParent( aParent ),
+    iUsbServer( aUsbServer )
+    {
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// CDunUsbListen::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunUsbListen::ConstructL()
+    {
+    FTRACE(FPrint( _L( "CDunUsbListen::ConstructL()" ) ));
+    if ( !iServer || !iParent )
+        {
+        User::Leave( KErrGeneral );
+        }
+    CActiveScheduler::Add( this );
+    FTRACE(FPrint( _L( "CDunUsbListen::ConstructL() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes this class
+// ---------------------------------------------------------------------------
+//
+void CDunUsbListen::Initialize()
+    {
+    // Don't initialize iServer here (it is set through NewL)
+    // Don't initialize iParent here (it is set through NewL)
+    // Don't initialize iUsbServer here (it is set through NewL)
+    iDeviceState = EUsbDeviceStateUndefined;
+    iDeviceStatePrev = EUsbDeviceStateUndefined;
+    }
+
+// ---------------------------------------------------------------------------
+// Activates listening request
+// ---------------------------------------------------------------------------
+//
+TInt CDunUsbListen::Activate()
+    {
+    FTRACE(FPrint( _L( "CDunUsbListen::Activate()" ) ));
+
+    if ( iListenState != EUsbListenStateIdle )
+        {
+        FTRACE(FPrint( _L( "CDunUsbListen::Activate() (not ready) complete" ) ));
+        return KErrNotReady;
+        }
+    iDeviceStatePrev = iDeviceState;
+    iStatus = KRequestPending;
+    iUsbServer.DeviceStateNotification( KDunUsbDeviceStateMask,
+                                        iDeviceState,
+                                        iStatus );
+    SetActive();
+    iListenState = EUsbListenStateListening;
+    FTRACE(FPrint( _L( "CDunUsbListen::Activate() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Called when read or write operation is ready.
+// ---------------------------------------------------------------------------
+//
+void CDunUsbListen::RunL()
+    {
+    FTRACE(FPrint( _L( "CDunUsbListen::RunL() iStatus=%d"), iStatus.Int() ));
+    iListenState = EUsbListenStateIdle;
+
+    if ( iStatus.Int() != KErrNone )
+        {
+        FTRACE(FPrint( _L( "CDunUsbListen::RunL() (ERROR) complete" )));
+        iServer->NotifyPluginCloseRequest( KDunUsbPluginUid, ETrue );
+        return;
+        }
+
+    FTRACE(FPrint( _L( "CDunUsbListen::RunL() Usb device state =%X, Issue request" ), iDeviceState));
+
+    TDunPluginState parentState = iServer->GetPluginStateByUid( KDunUsbPluginUid );
+
+    TInt retTemp = KErrNone;
+    if ( iDeviceState == EUsbDeviceStateConfigured &&
+         iDeviceStatePrev != EUsbDeviceStateConfigured &&
+         parentState != EDunStateChanneled )
+        {
+        // USB has been connected&configured and we are in PC Suite mode
+        FTRACE(FPrint( _L( "CDunUsbListen::RunL() DeviceState is configured -> open connection" ) ));
+        TBool noFreeChans = EFalse;
+        // noFreeChans will be omitted (not needed to set to RComm)
+        retTemp = iParent->NotifyChannelAllocate( noFreeChans );
+        if ( retTemp != KErrNone )
+            {
+            FTRACE(FPrint( _L( "CDunUsbListen::RunL() channel allocation failed!" ) ));
+            iServer->NotifyPluginCloseRequest( KDunUsbPluginUid, ETrue );
+            return;
+            }
+        }
+    else if ( iDeviceState < EUsbDeviceStateConfigured &&
+              iDeviceStatePrev >= EUsbDeviceStateConfigured &&
+              parentState == EDunStateChanneled )
+        {
+        FTRACE(FPrint( _L( "CDunUsbListen::RunL() DeviceState is not configured -> close connection" ) ));
+        retTemp = iParent->NotifyChannelFree();
+        if ( retTemp != KErrNone )
+            {
+            FTRACE(FPrint( _L( "CDunUsbListen::RunL() channel free failed!" ) ));
+            iServer->NotifyPluginCloseRequest( KDunUsbPluginUid, ETrue );
+            return;
+            }
+        }
+
+    // Start listening again
+    Activate();
+
+    FTRACE(FPrint( _L( "CDunUsbListen::RunL() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Cancel current activity.
+// ---------------------------------------------------------------------------
+//
+void CDunUsbListen::DoCancel()
+    {
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/plugins/src/usb/DunUsbPlugin.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,781 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DUN USB plugin
+*
+*/
+
+
+#include <c32comm.h>
+#include <d32usbc.h>
+#include "DunPlugin.h"
+#include "DunUtils.h"
+#include "DunUsbPlugin.h"
+#include "DunDebug.h"
+
+_LIT( KUsbCsyName,     "ECACM"    );
+_LIT( KUsbPortName,    "ACM"      );
+_LIT( KUsbPortPort,    "::"       );
+_LIT( KUsbLddName,     "EUSBC"    );
+_LIT( KUsbChannelName, "DUNUSB::" );
+
+const TInt   KCharactersInTInt      = 10;    // For "2147483648"
+const TUint8 KDefaultAcmProtocolNum = 0x01;  // Hayes compatible modem
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CDunUsbPlugin::CDunUsbPlugin
+// ---------------------------------------------------------------------------
+//
+CDunUsbPlugin::CDunUsbPlugin() :
+    iServer( NULL ),
+    iUsbListen( NULL ),
+    iUsbConfig( NULL ),
+    iTransporter( NULL )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunUsbPlugin::~CDunUsbPlugin()
+    {
+    FTRACE(FPrint( _L( "CDunUsbPlugin::~CDunUsbPlugin()" ) ));
+    Uninitialize();
+    FTRACE(FPrint( _L( "CDunUsbPlugin::~CDunUsbPlugin() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// State of this plugin
+// ---------------------------------------------------------------------------
+//
+TDunPluginState CDunUsbPlugin::PluginState()
+    {
+    return iServer->GetPluginStateByUid( KDunUsbPluginUid );
+    }
+
+// ---------------------------------------------------------------------------
+// Constructs a listener object for this plugin
+// ---------------------------------------------------------------------------
+//
+void CDunUsbPlugin::ConstructListenerL()
+    {
+    FTRACE(FPrint(_L("CDunUsbPlugin::ConstructListenerL()")));
+    if ( PluginState() != EDunStateLoaded )
+        {
+        FTRACE(FPrint(_L("CDunUsbPlugin::ConstructListenerL() (not ready) complete")));
+        User::Leave( KErrNotReady );
+        }
+    ReportStateChangeUp( EDunStateTryListen );
+    if ( iUsbListen )
+        {
+        FTRACE(FPrint(_L("CDunUsbPlugin::ConstructListenerL() (already exists) complete")));
+        User::Leave( KErrAlreadyExists );
+        }
+    InitUsbL();
+    CDunUsbListen* listen = CDunUsbListen::NewL( iServer, this, iUsbServer );
+    CleanupStack::PushL( listen );
+    TInt retTemp = listen->IssueRequestL();
+    CleanupStack::Pop( listen );
+    iUsbListen = listen;
+    // Here return value of KErrAlreadyExists means the device is already
+    // configured
+    // In this case we have to switch directly to channeled mode
+    ReportStateChangeUp( EDunStateListening );
+    if ( retTemp == KErrAlreadyExists )
+        {
+        TBool noFreeChans = EFalse;
+        // noFreeChans will be omitted (not needed to set to RComm)
+        NotifyChannelAllocate( noFreeChans );  // Create channel and change state
+        }
+    FTRACE(FPrint(_L("CDunUsbPlugin::ConstructListenerL() complete")));
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes USB by loading LDD
+// ---------------------------------------------------------------------------
+//
+void CDunUsbPlugin::InitUsbL()
+    {
+    FTRACE(FPrint( _L( "CDunUsbPlugin::InitUsbL()") ));
+    // Load Logical device driver for USB
+    FTRACE(FPrint( _L( "CDunUsbPlugin::InitUsbL() LoadLogicalDevice") ));
+    TInt retTemp = User::LoadLogicalDevice( KUsbLddName );
+    if ( retTemp!=KErrAlreadyExists && retTemp!=KErrNone )
+        {
+        User::Leave( retTemp );
+        }
+    // Connect to the USB Manager server
+    FTRACE(FPrint( _L( "CDunUsbPlugin::InitUsbL() Connect()") ));
+    User::LeaveIfError( iUsbServer.Connect() );
+    // Create USB configuration accessor and listener
+    iUsbConfig = CDunUsbConfig::NewL( iServer, this, KDefaultAcmProtocolNum );
+    FTRACE(FPrint( _L( "CDunUsbPlugin::InitUsbL() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes all usable USB ports for DUN
+// ---------------------------------------------------------------------------
+//
+TInt CDunUsbPlugin::InitPorts()
+    {
+    FTRACE(FPrint( _L( "CDunUsbPlugin::InitPorts() (num=%d)" ), iUsbPorts.Count()));
+    TInt i;
+    TInt retTemp = CreateAllPorts();
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L( "CDunUsbPlugin::InitPorts() (ERROR) complete" )));
+        return retTemp;
+        }
+    TInt count = iUsbPorts.Count();
+    for ( i=0; i<count; i++ )
+        {
+        retTemp = InitOnePort( &iUsbPorts[i] );
+        if ( retTemp != KErrNone )
+            {
+            FTRACE(FPrint( _L( "CDunUsbPlugin::InitPorts() (not ready) complete" )));
+            return KErrGeneral;
+            }
+        }
+    FTRACE(FPrint( _L( "CDunUsbPlugin::InitPorts() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Creates empty usable USB ports that can be used by DUN
+// ---------------------------------------------------------------------------
+//
+TInt CDunUsbPlugin::CreateAllPorts()
+    {
+    FTRACE(FPrint( _L( "CDunUsbPlugin::CreateAllPorts()" ) ));
+    // Connect to comms server
+    TInt retTemp = CDunUtils::ConnectCommsServer( iCommServer );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L( "CDunUsbPlugin::CreateAllPorts() (ERROR) complete" )));
+        return retTemp;
+        }
+    // Load communications module
+    retTemp = iCommServer.LoadCommModule( KUsbCsyName );
+    if ( retTemp!=KErrNone && retTemp!=KErrAlreadyExists )
+        {
+        FTRACE(FPrint( _L( "CDunUsbPlugin::CreateAllPorts() (LoadCommModule failed) complete" ) ));
+        return retTemp;
+        }
+    // Stop waiter now (just to be sure) before explicitly fetching port data
+    iUsbConfig->Stop();
+    // Find out what ports can be supported and append them to array
+    TBool validConfig;
+    TUsbPortEntity entity;
+    for ( TInt i=0;; i++ )
+        {
+        retTemp = iUsbConfig->GetConfigValidityByIndex( i, validConfig );
+        if ( retTemp != KErrNone )
+            {
+            break;
+            }
+        if ( !validConfig )
+            {
+            continue;
+            }
+        // Valid config found, append it to array
+        entity.iPortNum = i;
+        retTemp = iUsbPorts.Append( entity );
+        if ( retTemp != KErrNone )
+            {
+            FTRACE(FPrint( _L( "CDunUsbPlugin::CreateAllPorts() (append failed!) complete" ) ));
+            return retTemp;
+            }
+        }
+    FTRACE(FPrint( _L( "CDunUsbPlugin::CreateAllPorts() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes one USB port for DUN
+// ---------------------------------------------------------------------------
+//
+TInt CDunUsbPlugin::InitOnePort( TUsbPortEntity* aEntity )
+    {
+    FTRACE(FPrint( _L( "CDunUsbPlugin::InitOnePort()" )));
+    if ( !aEntity )
+        {
+        FTRACE(FPrint( _L( "CDunUsbPlugin::InitOnePort() (not initialized!) complete" )));
+        return KErrGeneral;
+        }
+    TInt retTemp;
+    TName portName;
+    portName.Copy( KUsbPortName );
+    portName.Append( KUsbPortPort );
+    portName.AppendNum( aEntity->iPortNum );
+    retTemp = aEntity->iUsbPort.Open( iCommServer,
+                                      portName,
+                                      ECommExclusive,
+                                      ECommRoleDCE );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L( "CDunUsbPlugin::InitOnePort() Open failed (%d)" ), retTemp));
+        return retTemp;
+        }
+    TRAPD( retTrap, SetChannelL(aEntity) );
+    if ( retTrap != KErrNone )
+        {
+        iTransporter->FreeChannel( &aEntity->iUsbPort );
+        FTRACE(FPrint( _L( "CDunUsbPlugin::InitOnePort() (trapped!) complete" )));
+        return retTrap;
+        }
+    FTRACE(FPrint( _L( "CDunUsbPlugin::InitOnePort() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Sets channel for one USB port
+// ---------------------------------------------------------------------------
+//
+void CDunUsbPlugin::SetChannelL( TUsbPortEntity* aEntity )
+    {
+    FTRACE(FPrint( _L( "CDunUsbPlugin::SetChannelL()" )));
+    if ( !aEntity )
+        {
+        FTRACE(FPrint( _L( "CDunUsbPlugin::SetChannelL() (not initialized!) complete" )));
+        User::Leave( KErrGeneral );
+        }
+    HBufC8* channelName = HBufC8::NewMaxLC( KUsbChannelName().Length() +
+                          KCharactersInTInt );
+    TPtr8 channelNamePtr = channelName->Des();
+    channelNamePtr.Copy( KUsbChannelName );
+    channelNamePtr.AppendNum( aEntity->iPortNum );
+    iTransporter->AllocateChannelL( &aEntity->iUsbPort,
+                                    KDunUsbPluginUid,
+                                    channelNamePtr,
+                                    ETrue,
+                                    this );
+    AddSkippedErrorL( KErrUsbInterfaceChange, &aEntity->iUsbPort );
+    iTransporter->AddConnMonCallbackL( &aEntity->iUsbPort,
+                                       this,
+                                       EDunReaderUpstream,
+                                       EFalse );
+    iTransporter->AddConnMonCallbackL( &aEntity->iUsbPort,
+                                       this,
+                                       EDunWriterUpstream,
+                                       EFalse );
+    iTransporter->AddConnMonCallbackL( &aEntity->iUsbPort,
+                                       this,
+                                       EDunReaderDownstream,
+                                       EFalse );
+    iTransporter->AddConnMonCallbackL( &aEntity->iUsbPort,
+                                       this,
+                                       EDunWriterDownstream,
+                                       EFalse );
+    iTransporter->IssueTransferRequestsL( &aEntity->iUsbPort );
+    CleanupStack::PopAndDestroy( channelName );
+    FTRACE(FPrint( _L( "CDunUsbPlugin::SetChannelL() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Adds skipped error code to Transporter
+// The skipped error is added to local media's read and write operations
+// ---------------------------------------------------------------------------
+//
+void CDunUsbPlugin::AddSkippedErrorL( TInt aError, RComm* aComm )
+    {
+    iTransporter->AddSkippedErrorL( aError, aComm, EDunReaderUpstream );
+    iTransporter->AddSkippedErrorL( aError, aComm, EDunWriterDownstream );
+    }
+
+// ---------------------------------------------------------------------------
+// Sets new state
+// New state must be one more than the old state
+// ---------------------------------------------------------------------------
+//
+TInt CDunUsbPlugin::ReportStateChangeUp( TDunPluginState aPluginState )
+    {
+    FTRACE(FPrint(_L("CDunUsbPlugin::ReportStateChangeUp()")));
+    TInt retTemp = iServer->NotifyPluginStateChangeUp( aPluginState,
+                                                       KDunUsbPluginUid );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunUsbPlugin::ReportStateChangeUp() (ERROR) complete")));
+        return retTemp;
+        }
+    FTRACE(FPrint(_L("CDunUsbPlugin::ReportStateChangeUp() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Sets new state
+// New state must be one less than the old state
+// ---------------------------------------------------------------------------
+//
+TInt CDunUsbPlugin::ReportStateChangeDown( TDunPluginState aPluginState )
+    {
+    FTRACE(FPrint(_L("CDunUsbPlugin::ReportStateChangeDown()")));
+    TInt retTemp = iServer->NotifyPluginStateChangeDown( aPluginState,
+                                                         KDunUsbPluginUid );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunUsbPlugin::ReportStateChangeDown() (ERROR) complete")));
+        return retTemp;
+        }
+    FTRACE(FPrint(_L("CDunUsbPlugin::ReportStateChangeDown() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Frees existing channels
+// ---------------------------------------------------------------------------
+//
+TInt CDunUsbPlugin::FreeChannels()
+    {
+    FTRACE(FPrint(_L("CDunUsbPlugin::FreeChannels()")));
+    if ( PluginState() != EDunStateTryUninitialize )
+        {
+        FTRACE(FPrint( _L( "CDunUsbPlugin::FreeChannels() (not ready) complete" ) ));
+        return KErrNotReady;
+        }
+    TInt i;
+    TInt count = iUsbPorts.Count();
+    for ( i=0; i<count; i++ )
+        {
+        FTRACE(FPrint( _L( "CDunUsbPlugin::FreeChannels() i=%d" ), i));
+        if ( iUsbPorts[i].iUsbPort.SubSessionHandle() )
+            {
+            iTransporter->FreeChannel( &iUsbPorts[i].iUsbPort );
+            iUsbPorts[i].iUsbPort.SetSignals( 0, KSignalDCEOutputs );
+            iUsbPorts[i].iUsbPort.Close();
+            }
+        }
+    iUsbPorts.Close();
+    if ( iCommServer.Handle() != KNullHandle )
+        {
+        iCommServer.UnloadCommModule( KUsbCsyName );
+        iCommServer.Close();
+        }
+    FTRACE(FPrint(_L("CDunUsbPlugin::FreeChannels() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Uninitializes this plugin
+// ---------------------------------------------------------------------------
+//
+TInt CDunUsbPlugin::Uninitialize()
+    {
+    FTRACE(FPrint( _L( "CDunUsbPlugin::Uninitialize()" ) ));
+    ReportStateChangeDown( EDunStateTryUninitialize );
+    // Free channel(s), ignore errors
+    FreeChannels();
+    delete iUsbListen;  // delete before iUsbServer close
+    iUsbListen = NULL;
+    delete iUsbConfig;
+    iUsbConfig = NULL;
+    if ( iUsbServer.Handle() != KNullHandle )
+        {
+        iUsbServer.Close();
+        }
+    User::FreeLogicalDevice( KUsbLddName );
+    ReportStateChangeUp( EDunStateUninitialized );
+    ReportStateChangeUp( EDunStateTryLoad );
+    ReportStateChangeUp( EDunStateLoaded );
+    FTRACE(FPrint( _L( "CDunUsbPlugin::Uninitialize() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Gets port's index and entity by connection ID
+// ---------------------------------------------------------------------------
+//
+TInt CDunUsbPlugin::GetEntityByConnId( TConnId aConnId,
+                                       TUsbPortEntity*& aEntity )
+    {
+    FTRACE(FPrint( _L( "CDunUsbPlugin::GetEntityByConnId()")) );
+    TInt i;
+    TInt count = iUsbPorts.Count();
+    for ( i=0; i<count; i++ )
+        {
+        if ( &iUsbPorts[i].iUsbPort == aConnId )
+            {
+            aEntity = &iUsbPorts[i];
+            FTRACE(FPrint( _L( "CDunUsbPlugin::GetEntityByConnId() complete")) );
+            return i;
+            }
+        }
+    aEntity = NULL;
+    FTRACE(FPrint( _L( "CDunUsbPlugin::GetEntityByConnId() (not found) complete")) );
+    return KErrNotFound;
+    }
+
+// ---------------------------------------------------------------------------
+// Gets port's entity by port number
+// ---------------------------------------------------------------------------
+//
+TInt CDunUsbPlugin::GetEntityByPortNumber( TInt aPortNum,
+                                           TUsbPortEntity*& aEntity )
+    {
+    FTRACE(FPrint( _L( "CDunUsbPlugin::GetEntityByPortNumber()")) );
+    TInt i;
+    TInt count = iUsbPorts.Count();
+    for ( i=0; i<count; i++ )
+        {
+        if ( iUsbPorts[i].iPortNum == aPortNum )
+            {
+            aEntity = &iUsbPorts[i];
+            FTRACE(FPrint( _L( "CDunUsbPlugin::GetEntityByPortNumber() complete")) );
+            return i;
+            }
+        }
+    aEntity = NULL;
+    FTRACE(FPrint( _L( "CDunUsbPlugin::GetEntityByPortNumber() (not found) complete")) );
+    return KErrNotFound;
+    }
+
+// ---------------------------------------------------------------------------
+// Gets first free port's index and entity
+// ---------------------------------------------------------------------------
+//
+TInt CDunUsbPlugin::GetFirstFreeEntity( TUsbPortEntity*& aEntity )
+    {
+    FTRACE(FPrint( _L( "CDunUsbPlugin::GetFirstFreeEntity()")) );
+    TInt i;
+    TInt count = iUsbPorts.Count();
+    for ( i=0; i<count; i++ )
+        {
+        if ( iUsbPorts[i].iPortNum == KErrNotFound &&
+             !iUsbPorts[i].iUsbPort.SubSessionHandle() )
+            {
+            aEntity = &iUsbPorts[i];
+            FTRACE(FPrint( _L( "CDunUsbPlugin::GetFirstFreeEntity() complete")) );
+            return i;
+            }
+        }
+    aEntity = NULL;
+    FTRACE(FPrint( _L( "CDunUsbPlugin::GetFirstFreeEntity() (not found) complete")) );
+    return KErrNotFound;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunLocalMediaPlugin.
+// CDunUsbPlugin::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunUsbPlugin::ConstructL( MDunServerCallback* aServer,
+                                CDunTransporter* aTransporter )
+    {
+    FTRACE(FPrint( _L( "CDunUsbPlugin::ConstructL()" ) ));
+    if ( !aServer || !aTransporter )
+        {
+        FTRACE(FPrint( _L( "CDunUsbPlugin::ConstructL() not initialized!" ) ));
+        User::Leave( KErrGeneral );
+        }
+    iServer = aServer;
+    iTransporter = aTransporter;
+    FTRACE(FPrint( _L( "CDunUsbPlugin::ConstructL() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunLocalMediaPlugin.
+// Gets called when server changes a plugin's state
+// ---------------------------------------------------------------------------
+//
+TInt CDunUsbPlugin::NotifyServerStateChange( TDunPluginState aPluginState )
+    {
+    FTRACE(FPrint(_L("CDunUsbPlugin::NotifyServerStateChange()")));
+    TInt retTemp;
+    switch ( aPluginState )
+        {
+        case EDunStateTryListen:
+            if ( PluginState() != EDunStateLoaded )
+                {
+                FTRACE(FPrint(_L("CDunUsbPlugin::NotifyServerStateChange() (not ready) complete")));
+                return KErrNotReady;
+                }
+            // Change to listening mode
+            TRAPD( retTrap, ConstructListenerL() );
+            if ( retTrap != KErrNone )
+                {
+                FTRACE(FPrint(_L("CDunUsbPlugin::NotifyServerStateChange() (ERROR) complete (%d)"), retTrap));
+                return retTrap;
+                }
+            break;
+        case EDunStateTryUninitialize:
+            if ( PluginState() == EDunStateUninitialized )
+                {
+                FTRACE(FPrint(_L("CDunUsbPlugin::NotifyServerStateChange() (not ready) complete")));
+                return KErrNotReady;
+                }
+            // Uninitialize
+            retTemp = Uninitialize();
+            if ( retTemp != KErrNone )
+                {
+                FTRACE(FPrint(_L("CDunUsbPlugin::NotifyServerStateChange() (not ready) complete (%d)"), retTemp));
+                return retTemp;
+                }
+            break;
+        default:
+            FTRACE(FPrint(_L("CDunUsbPlugin::NotifyServerStateChange() (unknown state) complete")));
+            return KErrNotSupported;
+        }
+    FTRACE(FPrint(_L("CDunUsbPlugin::NotifyServerStateChange() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunLocalMediaPlugin.
+// Gets called when server needs to know the active connection
+// ---------------------------------------------------------------------------
+//
+TConnId CDunUsbPlugin::ActiveConnection()
+    {
+    FTRACE(FPrint(_L("CDunUsbPlugin::ActiveConnection()")));
+    FTRACE(FPrint(_L("CDunUsbPlugin::ActiveConnection() (not found) complete")));
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunListenCallback.
+// Gets called when new channel must be created
+// ---------------------------------------------------------------------------
+//
+TInt CDunUsbPlugin::NotifyChannelAllocate( TBool& /*aNoFreeChans*/ )
+    {
+    FTRACE(FPrint(_L("CDunUsbPlugin::NotifyChannelAllocate()")));
+    if ( PluginState() != EDunStateListening )
+        {
+        FTRACE(FPrint(_L("CDunUsbPlugin::NotifyChannelAllocate() (not ready) complete")));
+        return KErrNotReady;
+        }
+    ReportStateChangeUp( EDunStateTryChannel );
+    TInt retTemp = InitPorts();
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunUsbPlugin::NotifyChannelAllocate() (ERROR) complete")));
+        return retTemp;
+        }
+    // Channels allocated so start to wait for possible port config change
+    retTemp = iUsbConfig->IssueRequest();
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunUsbPlugin::NotifyChannelAllocate() (ERROR) complete")));
+        return retTemp;
+        }
+    iShutdown = EFalse;
+    ReportStateChangeUp( EDunStateChanneled );
+    FTRACE(FPrint(_L("CDunUsbPlugin::NotifyChannelAllocate() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunListenCallback.
+// Gets called when an existing channel must be freed
+// ---------------------------------------------------------------------------
+//
+TInt CDunUsbPlugin::NotifyChannelFree()
+    {
+    FTRACE(FPrint(_L("CDunUsbPlugin::NotifyChannelFree()")));
+    if ( PluginState() != EDunStateChanneled )
+        {
+        FTRACE(FPrint(_L("CDunUsbPlugin::NotifyChannelFree() (not ready) complete")));
+        return KErrNotReady;
+        }
+    // Cable removed or PC sleep, hibernate or reset.
+    // Just remove channels.
+    ReportStateChangeDown( EDunStateTryUninitialize );
+    TInt retTemp = FreeChannels();
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunUsbPlugin::NotifyChannelFree() (ERROR) complete")));
+        return retTemp;
+        }
+    ReportStateChangeUp( EDunStateUninitialized );
+    ReportStateChangeUp( EDunStateTryLoad );
+    ReportStateChangeUp( EDunStateLoaded );
+    ReportStateChangeUp( EDunStateTryListen );
+    ReportStateChangeUp( EDunStateListening );
+    FTRACE(FPrint(_L("CDunUsbPlugin::NotifyChannelFree() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunConnMon.
+// Gets called when line status changes or when any type of error is detected
+// ---------------------------------------------------------------------------
+//
+void CDunUsbPlugin::NotifyProgressChangeL(
+    TConnId aConnId,
+    TDunConnectionReason aConnReason )
+    {
+    FTRACE(FPrint( _L( "CDunUsbPlugin::NotifyProgressChangeL()")) );
+    // Find matching failed ID
+    TUsbPortEntity* foundEntity = NULL;
+    TInt foundIndex = GetEntityByConnId( aConnId, foundEntity );
+    if ( !foundEntity )
+        {
+        FTRACE(FPrint( _L( "CDunUsbPlugin::NotifyProgressChangeL() (not found) complete")) );
+        User::Leave( KErrNotFound );
+        }
+    if ( aConnReason.iReasonType == EDunReasonTypeRW ||
+         aConnReason.iReasonType == EDunReasonTypeRunL )
+        {
+        // The following check will make it possible for CDunUsbListen to react
+        // to cable removal (<KErrUsbDriverBase) or to the case when personality
+        // is changed from USBUI and LOCOD/USBWatcher is too slow to notify the
+        // change (KErrAccessDenied).
+        if ( aConnReason.iErrorCode < KErrUsbDriverBase ||
+             aConnReason.iErrorCode == KErrAccessDenied )
+            {
+            FTRACE(FPrint( _L( "CDunUsbPlugin::NotifyProgressChangeL() (shutdown now) complete")) );
+            iShutdown = ETrue;
+            return;
+            }
+        }
+    if ( iShutdown )
+        {
+        FTRACE(FPrint( _L( "CDunUsbPlugin::NotifyProgressChangeL() (shutdown) complete")) );
+        return;
+        }
+    // Now indications are down indications from local media side
+    if ( foundEntity->iUsbPort.SubSessionHandle() )
+        {
+        iTransporter->FreeChannel( &foundEntity->iUsbPort );
+        foundEntity->iUsbPort.SetSignals( 0, KSignalDCEOutputs );
+        foundEntity->iUsbPort.Close();
+        }
+    TInt retTemp = InitOnePort( foundEntity );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L( "CDunUsbPlugin::NotifyProgressChangeL() (ERROR) complete")) );
+        User::Leave( KErrGeneral );
+        }
+    // Now this plugin was basically "restarted", but only for one
+    // channel. Because transporter has channels with waiters, notify
+    // server to reopen queued plugin(s)
+    iServer->NotifyPluginReopenRequest();
+    FTRACE(FPrint( _L( "CDunUsbPlugin::NotifyProgressChangeL() complete")) );
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunBufferCorrection.
+// Gets called when request to change local media's buffer size
+// ---------------------------------------------------------------------------
+//
+TInt CDunUsbPlugin::NotifyBufferCorrection( TInt aLength )
+    {
+    FTRACE(FPrint( _L( "CDunUsbPlugin::NotifyBufferCorrection()")) );
+    /*
+     * This method modifies the default buffer length to match the maximum value
+     * used by "CanHandleZLP=0" configuration option. This length is nearest length
+     * divisible by 64 - 1. With slow USB compared to high speed HSDPA some products
+     * can start to collect data to Dataport which results in full packet writes to
+     * USB. However, the default full packet must not be divisible by 64, which results
+     * in the ACM to send the full packet to LDD plus one extra packet with one byte
+     * (disabling interrupts for a long time with current non-DMA USB driver).
+     */
+    TInt newLength = aLength;
+    if ( newLength % 64 == 0 )
+        {
+        newLength = ((aLength >> 6) << 6) - 1;
+        }
+    FTRACE(FPrint( _L( "CDunUsbPlugin::NotifyBufferCorrection() complete")) );
+    return newLength;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunUsbConfig.
+// Gets called when one or more ACM configurations are added
+// ---------------------------------------------------------------------------
+//
+TInt CDunUsbPlugin::NotifyConfigAddition( TInt aIndex )
+    {
+    FTRACE(FPrint( _L( "CDunUsbPlugin::NotifyConfigAddition()")) );
+    // Configuration added so aIndex is the port number to be added to array.
+    // This port number must not already exist in the array.
+    TUsbPortEntity* foundEntity = NULL;
+    TInt foundIndex = GetEntityByPortNumber( aIndex, foundEntity );
+    if ( foundEntity )
+        {
+        FTRACE(FPrint( _L( "CDunUsbPlugin::NotifyConfigAddition() (already exists) complete")) );
+        return KErrAlreadyExists;
+        }
+    // Now either find port with KErrNotFound set as port number or if that is
+    // not found then try to append to array
+    foundIndex = GetFirstFreeEntity( foundEntity );
+    if ( !foundEntity )  // free not found so add new
+        {
+        // Now append the new port to array
+        TUsbPortEntity newEntity;
+        newEntity.iPortNum = aIndex;
+        TInt retTemp = iUsbPorts.Append( newEntity );
+        if ( retTemp != KErrNone )
+            {
+            FTRACE(FPrint( _L( "CDunUsbPlugin::NotifyConfigAddition() (append failed!) complete")) );
+            return KErrGeneral;
+            }
+        // entity not valid here so set now
+        foundEntity = &iUsbPorts[iUsbPorts.Count()-1];
+        }
+    else  // free found so change array
+        {
+        foundEntity->iPortNum = aIndex;
+        }
+    // Open port and create channel for it
+    TInt retTemp = InitOnePort( foundEntity );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L( "CDunUsbPlugin::NotifyConfigAddition() (ERROR) complete" )));
+        return KErrGeneral;
+        }
+    FTRACE(FPrint( _L( "CDunUsbPlugin::NotifyConfigAddition() complete")) );
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunUsbConfig.
+// Gets called when one or more ACM configurations are removed
+// ---------------------------------------------------------------------------
+//
+TInt CDunUsbPlugin::NotifyConfigRemoval( TInt aIndex )
+    {
+    FTRACE(FPrint( _L( "CDunUsbPlugin::NotifyConfigRemoval()")) );
+    // Configuration removed so aIndex is the port number to be added to array.
+    // This port number must already exist in the array.
+    TUsbPortEntity* foundEntity = NULL;
+    TInt foundIndex = GetEntityByPortNumber( aIndex, foundEntity );
+    if ( !foundEntity )
+        {
+        FTRACE(FPrint( _L( "CDunUsbPlugin::NotifyConfigRemoval() (not found) complete")) );
+        return KErrNotFound;
+        }
+    // Now free channel and mark as unused
+    iTransporter->FreeChannel( &foundEntity->iUsbPort );
+    foundEntity->iUsbPort.SetSignals( 0, KSignalDCEOutputs );
+    foundEntity->iUsbPort.Close();
+    iUsbPorts[foundIndex].iPortNum = KErrNotFound;
+    FTRACE(FPrint( _L( "CDunUsbPlugin::NotifyConfigRemoval() complete")) );
+    return KErrNone;
+    }
+
+// ======== GLOBAL FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// NewLocalPluginL implements factory construction for
+// the class CDunUsbPlugin.
+// The function is exported at ordinal 1.
+// Returns: Pointer: The new instance of CDunUsbPlugin
+// ---------------------------------------------------------------------------
+//
+EXPORT_C MDunLocalMediaPlugin* NewLocalPluginL()
+    {
+    return new (ELeave) CDunUsbPlugin;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/rom/dunatext.iby	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Image description file for project DUN ATEXT
+*
+*/
+
+
+#ifndef __DUNATEXT_IBY__
+#define __DUNATEXT_IBY__
+
+#ifdef __DIALUP_NETWORKING
+file=ABI_DIR\BUILD_DIR\dunatext.dll              SHARED_LIB_DIR\dunatext.dll
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/rom/dunbt.iby	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Image description file for project DUN BT plugin
+*
+*/
+
+
+#ifndef __DUNBT_IBY__
+#define __DUNBT_IBY__
+
+#ifdef __DIALUP_NETWORKING
+#ifdef __BT
+file=ABI_DIR\BUILD_DIR\dunbt.dll        SHARED_LIB_DIR\dunbt.dll
+#endif
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/rom/dunclient.iby	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Image description file for project DUN
+*
+*/
+
+
+#ifndef __DUNCLIENT_IBY__
+#define __DUNCLIENT_IBY__
+
+#ifdef __DIALUP_NETWORKING
+ECOM_PLUGIN(dunclient.dll,dunclient.rsc)
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/rom/dunir.iby	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Image description file for project DUN IR plugin
+*
+*/
+
+
+#ifndef __DUNIR_IBY__
+#define __DUNIR_IBY__
+
+#ifdef __DIALUP_NETWORKING
+#ifdef __IRDA
+file=ABI_DIR\BUILD_DIR\dunir.dll        SHARED_LIB_DIR\dunir.dll
+#endif
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/rom/dunresources.iby	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Image description file for project DUN utilities
+*
+*/
+
+
+#ifndef __DUNRESOURCES_IBY__
+#define __DUNRESOURCES_IBY__
+
+#ifdef __DIALUP_NETWORKING
+data=DATAZ_\RESOURCE_FILES_DIR\dunutils.rsc      RESOURCE_FILES_DIR\dunutils.rsc
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/rom/dunserver.iby	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Image description file for project DUN
+*
+*/
+
+
+#ifndef __DUNSERVER_IBY__
+#define __DUNSERVER_IBY__
+
+#ifdef __DIALUP_NETWORKING
+file=ABI_DIR\BUILD_DIR\dunserver.exe      PROGRAMS_DIR\dunserver.exe
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/rom/dunusb.iby	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Image description file for project DUN USB plugin
+*
+*/
+
+
+#ifndef __DUNUSB_IBY__
+#define __DUNUSB_IBY__
+
+#ifdef __DIALUP_NETWORKING
+#ifdef __USB
+file=ABI_DIR\BUILD_DIR\dunusb.dll       SHARED_LIB_DIR\dunusb.dll
+#endif
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/rom/dunutils.iby	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Image description file for project DUN utilities
+*
+*/
+
+
+#ifndef __DUNUTILS_IBY__
+#define __DUNUTILS_IBY__
+
+#ifdef __DIALUP_NETWORKING
+file=ABI_DIR\BUILD_DIR\dunutils.dll              SHARED_LIB_DIR\dunutils.dll
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/server/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*	 This file provides the information required for building the
+*    whole of a DUN server
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+../../rom/dunserver.iby       CORE_MW_LAYER_IBY_EXPORT_PATH(dunserver.iby)
+
+PRJ_MMPFILES
+dunserver.mmp
+
+PRJ_TESTMMPFILES
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/server/group/dunserver.mmp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project DUN server
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET                  dunserver.exe
+TARGETTYPE              EXE
+UID                     0x1000008d 0x0100387D
+
+CAPABILITY              CAP_SERVER NetworkControl CommDD LocalServices WriteDeviceData
+VENDORID                VID_DEFAULT
+
+SOURCEPATH              ../src
+SOURCE                  DunSession.cpp
+SOURCE	                DunServer.cpp
+SOURCE                  DunServerUtils.cpp
+SOURCE                  DunCloseWait.cpp
+
+USERINCLUDE            ../inc ../../utils/inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+// Note:
+// The only other SYSTEMINCLUDE should you shall add are Symbian specific ones.
+// If there is a S60 header in the subdirectory then that should be
+// added into the include statements (like #include <phonebook/header.h>)
+//SYSTEMINCLUDE           /epoc32/include/ecom
+SYSTEMINCLUDE           ../../../inc ../../../../inc
+
+LIBRARY                 euser.lib
+LIBRARY                 dunutils.lib
+LIBRARY                 btfeatures.lib
+DEBUGLIBRARY            flogger.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/server/inc/DunCloseWait.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,152 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Common waiter for closing self-destruct plugins
+*
+*/
+
+#ifndef C_CDUNCLOSEWAIT_H
+#define C_CDUNCLOSEWAIT_H
+
+#include <e32base.h>
+
+class MDunLocalMediaPlugin;
+
+/**
+ *  Notification interface class to report requst for closing a plugin
+ *
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS( MDunCloseWait )
+    {
+
+public:
+
+    /**
+     * Gets called when closing of plugins should be done
+     *
+     * @since S60 5.0
+     * @param aPluginsToClose Plugins to be closed
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual void NotifyPluginCloseAfterWait(
+        RPointerArray<MDunLocalMediaPlugin>& aPluginsToClose ) = 0;
+
+    };
+
+/**
+ *  Common waiter for closing self-destruct plugins
+ *
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS( CDunCloseWait ) : public CActive
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aCallback Callback to call when notification via MDunCloseWait
+     *                  to be made
+     * @return Instance of self
+     */
+	static CDunCloseWait* NewL( MDunCloseWait* aCallback );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunCloseWait();
+
+    /**
+     * Resets data to initial values
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void ResetData();
+
+    /**
+     * Adds a new plugin to be closed to the list
+     *
+     * @since S60 5.0
+     * @param aPluginToClose The plugin to be closed
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt AddPluginToClose( MDunLocalMediaPlugin* aPluginToClose );
+
+    /**
+     * Issues request to start closing the objects in the close list
+     *
+     * @since S60 5.0
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt IssueRequest();
+
+    /**
+     * Stops closing the objects in the close list
+     *
+     * @since S60 5.0
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt Stop();
+
+private:
+
+    CDunCloseWait( MDunCloseWait* aCallback );
+
+    void ConstructL();
+
+    /**
+     * Initializes this class
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void Initialize();
+
+// from base class CActive
+
+    /**
+     * From CActive.
+     * Gets called when closing of the plugins should be done
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void RunL();
+
+    /**
+     * From CActive.
+     * Gets called on cancel
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void DoCancel();
+
+private:  // data
+
+    /**
+     * Callback to call when notification via MDunCloseWait to be made
+     */
+    MDunCloseWait* iCallback;
+
+    /**
+     * List of plugins to be closed
+     * Not own.
+     */
+    RPointerArray<MDunLocalMediaPlugin> iCloseList;
+
+};
+
+#endif  // C_CDUNCLOSEWAIT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/server/inc/DunServer.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,361 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DUN server
+*
+*/
+
+
+#ifndef C_CDUNSERVER_H
+#define C_CDUNSERVER_H
+
+#include <e32base.h>
+#include "DunPlugin.h"
+#include "DunCloseWait.h"
+#include "dunserverdef.h"
+#include "dundomainpskeys.h"
+
+_LIT( KDunPluginBt,   "dunbt.dll"  );
+_LIT( KDunPluginIrda, "dunir.dll"  );
+_LIT( KDunPluginUsb,  "dunusb.dll" );
+
+class MDunSession;
+class MDunServerUtility;
+
+/**
+ *  Class used to store data needed for each separate plugin
+ *  One TDunConnectionData data contains objects needed for one plugin
+ *
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( TDunConnectionData )
+    {
+
+public:
+
+    /**
+     * Pointer to plugin DLL
+     * Not own.
+     */
+    MDunLocalMediaPlugin* iLocalModulePtr;
+
+    /**
+     * Current state of plugin
+     */
+    TDunPluginState iPluginState;
+
+    /**
+     * DLL library server needed to open/close existing plugin
+     */
+    RLibrary iModuleLibrary;
+
+    /**
+     * Loaded plugin's UID
+     */
+    TUid iLocalModuleUid;
+
+    };
+
+/**
+ *  Main DUN server's class
+ *
+ *  @since S60 v3.2
+ */
+class CDunServer : public CPolicyServer,
+                   public MDunServerCallback,
+                   public MDunCloseWait
+    {
+
+    friend class CDunServerUtils;
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @return Instance of self
+     */
+    static CDunServer* NewL();
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunServer();
+
+    /**
+     * Notification to manage local media On request
+     * This comes from client
+     *
+     * @since S60 3.2
+     * @param aPluginUid UID of the local media plugin to open
+     * @return None
+     */
+    TInt NotifyMediaOpenRequest( TUid aPluginUid );
+
+    /**
+     * Notification to manage local media Off request
+     * This comes from client
+     *
+     * @since S60 3.2
+     * @param aPluginUid UID of the local media plugin to close
+     * @return None
+     */
+    TInt NotifyMediaCloseRequest( TUid aPluginUid );
+
+    /**
+     * Current active connection
+     * (For testing purposes only)
+     *
+     * @since S60 5.0
+     * @return Active connection, NULL otherwise
+     */
+    TConnId ActiveConnection();
+
+    /**
+     * Increases reference count made by sessions
+     * This comes from client
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void IncRefCount();
+
+    /**
+     * Decreases reference count made by sessions
+     * This comes from client
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void DecRefCount();
+
+// from base class CServer2 (CPolicyServer -> CServer2)
+
+    /**
+     * From CServer2 (CPolicyServer derived from CServer2).
+     * Creates a server-side client session object.
+     *
+     * @since S60 3.2
+     * @param aVersion Version information supplied by the client
+     * @return A pointer to the newly created server-side client session
+     */
+    CSession2* NewSessionL( const TVersion& aVersion, const RMessage2& ) const;
+
+private:
+
+    CDunServer( TInt aPriority );
+
+    void ConstructL();
+
+    /**
+     * Opens local media plugin by UID
+     *
+     * @since S60 3.2
+     * @param aPluginUid UID of local media plugin to open
+     * @param aDequeue ETrue if restarting of queued plugins and plugin
+     *                 dequeue wanted after successful plugin close
+     *                 (normal case, see also TryClosePlugin()),
+     *                 EFalse if no restarting of queued plugins and plugin
+     *                 dequeue wanted after successful plugin close
+     *                 (in this case caller is reopener itself, see also
+     *                 ReopenQeueuedPlugins())
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt OpenMediaByUid( TUid aPluginUid, TBool aDequeue );
+
+    /**
+     * Closes local media plugin by UID
+     *
+     * @since S60 3.2
+     * @param aPluginUid UID of local media plugin to close
+     * @param aClearQueued ETrue if clear from plugin queue wanted,
+     *                     EFalse otherwise
+     * @param aClientClose ETrue if close originator is client
+     * @param aSelfDelete ETrue if plugin closes itself, EFalse otherwise
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt CloseMediaByUid( TUid aPluginUid,
+                          TBool aClearQueued,
+                          TBool aClientClose,
+                          TBool aSelfDelete );
+
+    /**
+     * Reopens plugins from plugin queue
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt ReopenQueuedPlugins();
+
+// from base class MDunServerCallback
+
+    /**
+     * From MDunServerCallback.
+     * Searches for plugin in connection data and returns its state
+     *
+     * @since S60 3.2
+     * @param aPluginUid UID of local media plugin to search for
+     * @return State of plugin
+     */
+    TDunPluginState GetPluginStateByUid( TUid aPluginUid );
+
+    /**
+     * From MDunServerCallback.
+     * Notification about request to change plugin state up by one level
+     *
+     * @since S60 3.2
+     * @param aPluginState New state to set for a local media plugin
+     * @param aPluginUid UID of the local media plugin whose state to change
+     * @return KErrNotFound if plugin not found by UID,
+               KErrNotSupported if unknown state,
+               KErrNone otherwise
+     */
+    TInt NotifyPluginStateChangeUp( TDunPluginState aPluginState,
+                                    TUid aPluginUid );
+
+    /**
+     * From MDunServerCallback.
+     * Notification about request to change plugin state down by one level
+     *
+     * @since S60 3.2
+     * @param aPluginState New state to set for a local media plugin
+     * @param aPluginUid UID of the local media plugin whose state to change
+     * @return KErrNotFound if plugin not found by UID,
+               KErrNotSupported if unknown state,
+               KErrNone otherwise
+     */
+    TInt NotifyPluginStateChangeDown( TDunPluginState aPluginState,
+                                      TUid aPluginUid );
+
+    /**
+     * From MDunServerCallback.
+     * Notification about plugin restart request
+     *
+     * @since S60 3.2
+     * @param aPluginUid UID of the local media plugin to restart
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt NotifyPluginRestart( TUid aPluginUid );
+
+    /**
+     * From MDunServerCallback.
+     * Notification about plugin reopen request
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt NotifyPluginReopenRequest();
+
+// from base class MDunPluginManager (MDunServerCallback->MDunPluginManager).
+
+    /**
+     * From MDunPluginManager (MDunServerCallback->MDunPluginManager).
+     * Notification about request to enqueue a plugin to plugin queue
+     *
+     * @since S60 3.2
+     * @param aPluginUid UID of the local media plugin to enqueue
+     * @return KErrNotFound = plugin not found by UID,
+               KErrAlreadyExists = plugin already in queue,
+               KErrNone otherwise
+     */
+    TInt NotifyPluginEnqueueRequest( TUid aPluginUid );
+
+    /**
+     * From MDunPluginManager (MDunServerCallback->MDunPluginManager).
+     * Notification about request to dequeue a plugin from plugin queue
+     * Just removes a found UID from the queue
+     *
+     * @since S60 3.2
+     * @param aPluginUid UID of the local media plugin to dequeue
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt NotifyPluginDequeueRequest( TUid aPluginUid );
+
+    /**
+     * From MDunPluginManager (MDunServerCallback->MDunPluginManager).
+     * Notification about request to close a plugin
+     *
+     * @since S60 3.2
+     * @param aPluginUid UID of the local media plugin to close
+     * @param aSelfClose ETrue if plugin closes itself, EFalse otherwise
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt NotifyPluginCloseRequest( TUid aPluginUid,
+                                   TBool aSelfClose );
+
+// from base class MDunCloseWait
+
+    /**
+     * From MDunCloseWait.
+     * Notification about request to close a plugin after wait
+     *
+     * @since S60 5.0
+     * @param aPluginsToClose Plugins to be closed
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    void NotifyPluginCloseAfterWait(
+        RPointerArray<MDunLocalMediaPlugin>& aPluginsToClose );
+
+private:  // data
+
+    /**
+     * Pointer to common utility class
+     * Own.
+     */
+    MDunServerUtility* iUtility;
+
+    /**
+     * Transporter to use for network side communication
+     * Own.
+     */
+    CDunTransporter* iTransporter;
+
+    /**
+     * Waiter for closing self-destruct plugins
+     * Own.
+     */
+    CDunCloseWait* iCloseWait;
+
+    /**
+     * Array of TDunConnectionData needed for each loaded plugin
+     */
+    RArray<TDunConnectionData> iConnData;
+
+    /**
+     * Array of plugin UIDs
+     * Used for queuing plugins that have no resources to use
+     * Used for dequeuing plugins when free resources detected
+     */
+    RArray<TUid> iPluginQueue;
+
+    /**
+     * Array of plugin UIDs
+     * Used for queuing plugins that were successfully closed outside
+     * this server. This is to avoid returning KErrNotFound to LOCOD
+     * when NotifyMediaCloseRequest() is caught
+     */
+    RArray<TUid> iClosedQueue;
+
+    /**
+     * Connection status of dialup: active or inactive
+     * Used for updating KPSUidDialupConnStatus Pub&Sub key
+     */
+    TDialupConnStatus iConnStatus;
+
+    /**
+     * Reference count of client sides
+     */
+    TInt iRefCount;
+
+    };
+
+#endif  // C_CDUNSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/server/inc/DunServerSecurityPolicy.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DUN server security policy definition
+*
+*/
+
+
+#ifndef DUNSERVER_SECURITYPOLICY_H
+#define DUNSERVER_SECURITYPOLICY_H
+
+#include "dunserverdef.h"
+
+// First range for KServerRanges[] definition, do not change
+const TInt KFirstServerRange  = 0;
+
+// First range for KServerElementsIndex[] definition, do not change
+const TInt KFirstElementRange = 0;
+
+// ---------------------------------------------------------------------------
+// DunServer's policy
+// ---------------------------------------------------------------------------
+//
+
+// Definition of the ranges of IPC numbers
+const TInt KServerRanges[] =
+    {
+    KFirstServerRange,  // Range 1: all client APIs
+    EInvalidIpc         // Range 2: Invalid IPC opcode
+    };
+
+const TUint KServerRangeCount = sizeof( KServerRanges ) / sizeof( TInt );
+
+// Policy to implement for each of the above ranges
+const TUint8 KServerElementsIndex[KServerRangeCount] =
+    {
+    KFirstElementRange,           // applies to 0th range
+    CPolicyServer::ENotSupported  // out of range DUN's IPC
+    };
+
+//Specific capability checks
+const CPolicyServer::TPolicyElement KServerElements[] =
+    {
+        {_INIT_SECURITY_POLICY_C2(ECapabilityLocalServices, ECapabilityNetworkServices),
+         CPolicyServer::EFailClient
+        } // Policy 0
+    };
+
+// Policy structure for DunServer. This is passed to DunServer's constructor
+const CPolicyServer::TPolicy KDunServerPolicy =
+        {
+        CPolicyServer::EAlwaysPass,  // Indicates that Connect attempts should be processed without any further checks.
+        KServerRangeCount,           // Range count
+        KServerRanges,               // ranges array
+        KServerElementsIndex,        // elements' index
+        KServerElements              // array of elements
+        };
+
+#endif // DUNSERVER_SECURITYPOLICY_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/server/inc/DunServerUtils.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,389 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Utility class for CDunServer
+*
+*/
+
+
+#ifndef C_CDUNSERVERUTILS_H
+#define C_CDUNSERVERUTILS_H
+
+#include <e32base.h>
+#include "DunPlugin.h"
+
+class CDunServer;
+
+/**
+ *  Utility accessor class for CDunServer class
+ *  Basically a collection of miscellaneous helper methods
+ *
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( MDunServerUtility )
+    {
+
+public:
+
+    /**
+     * From MDunServerUtility.
+     * Closes plugins with state marked as zombie
+     *
+     * @since S60 3.2
+     * @return KErrGeneral = close on any of the plugins failed,
+               KErrNone otherwise
+     */
+    virtual TInt RemoveZombiePlugins() = 0;
+
+    /**
+     * From MDunServerUtility.
+     * Loads local media module
+     *
+     * @since S60 3.2
+     * @param aPluginUid UID of the local media module to load
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt CreateNewPlugin( TUid aPluginUid ) = 0;
+
+    /**
+     * From MDunServerUtility.
+     * Constructs local media module
+     *
+     * @since S60 3.2
+     * @param aPluginUid UID of the local media module to construct
+     * @param aDllName Name of the DLL to the constructed local media module
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt ConstructLocalMediaModule( const TUid& aPluginUid,
+                                            const TPtrC& aDllName ) = 0;
+
+    /**
+     * From MDunServerUtility.
+     * Clears queued UIDs
+     *
+     * @since S60 3.2
+     * @param aPluginUid UID of local media plugin to remove
+     * @param aClearClosed ETrue if clear from closed queued wanted
+     * @param aClearQueued ETrue if clear from plugin queue wanted
+     * @return ETrue if plugin UID was removed, EFalse otherwise
+     */
+    virtual TBool ClearQueuedUIDs( TUid aPluginUid,
+                                   TBool aClearClosed,
+                                   TBool aClearQueued ) = 0;
+
+    /**
+     * From MDunServerUtility.
+     * Tries to close loaded local media plugin
+     *
+     * @since S60 3.2
+     * @param aIndex Index of plugin in connectiondata
+     * @param aDequeue ETrue if restarting of queued plugins and plugin
+     *                 dequeue wanted after successful plugin close
+     *                 (normal case, see also OpenMediaByUid()),
+     *                 EFalse if no restarting of queued plugins and plugin
+     *                 dequeue wanted after successful plugin close
+     *                 (in this case caller is reopener itself, see also
+     *                 ReopenQeueuedPlugins())
+     * @param aClientClose ETrue if close originator is client
+     * @param aSelfClose ETrue if plugin closes itself, EFalse otherwise
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt TryClosePlugin( TInt aIndex,
+                                 TBool aDequeue,
+                                 TBool aClientClose,
+                                 TBool aSelfClose ) = 0;
+
+    /**
+     * From MDunServerUtility.
+     * Closes a plugin directly without uninitializing it
+     *
+     * @since S60 5.0
+     * @param aIndex Index of plugin in connectiondata
+     * @param aDequeue ETrue if restarting of queued plugins and plugin
+     *                 dequeue wanted after successful plugin close
+     *                 (normal case, see also OpenMediaByUid()),
+     *                 EFalse if no restarting of queued plugins and plugin
+     *                 dequeue wanted after successful plugin close
+     *                 (in this case caller is reopener itself, see also
+     *                 ReopenQeueuedPlugins())
+     * @param aClientClose ETrue if close originator is client
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt DoClosePlugin( TInt aIndex,
+                                TBool aDequeue,
+                                TBool aClientClose ) = 0;
+
+    /**
+     * From MDunServerUtility.
+     * Does immediate close of plugin
+     *
+     * @since S60 3.2
+     * @param aIndex Index of plugin in connectiondata
+     * @param aDequeue ETrue if restarting of queued plugins and plugin
+     *                 dequeue wanted after successful plugin close
+     *                 (normal case, see also OpenMediaByUid()),
+     *                 EFalse if no restarting of queued plugins and plugin
+     *                 dequeue wanted after successful plugin close
+     *                 (in this case caller is reopener itself, see also
+     *                 ReopenQeueuedPlugins())
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt DoImmediatePluginClose( TInt aIndex,
+                                         TBool aDequeue ) = 0;
+
+    /**
+     * From MDunServerUtility.
+     * Tries uninitialization and after that listening state switch on a plugin
+     *
+     * @since S60 3.2
+     * @param aPluginUid UID of the plugin to initialize to listening state
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt TryInitializeToListening( TUid aPluginUid ) = 0;
+
+    /**
+     * From MDunServerUtility.
+     * Tries listening state switch on a plugin
+     *
+     * @since S60 3.2
+     * @param aIndex Index of plugin in connectiondata
+     * @return KErrNotFound = plugin not found,
+               KErrNotReady = wrong state,
+               KErrNone otherwise
+     */
+    virtual TInt TryListening( TInt aIndex ) = 0;
+
+    /**
+     * From MDunServerUtility.
+     * Tries uninitialization of a plugin
+     *
+     * @since S60 3.2
+     * @param aIndex Index of plugin in connectiondata
+     * @return KErrNotFound = plugin not found, KErrNone otherwise
+     */
+    virtual TInt TryUninitialize( TInt aIndex ) = 0;
+
+    };
+
+/**
+ *  DUN server's utility class
+ *
+ *  @since S60 v3.2
+ */
+class CDunServerUtils : public CBase,
+                        public MDunServerUtility
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aParent Parent class owning this friend class (CDunServer)
+     * @return Instance of self
+     */
+    static CDunServerUtils* NewL( CDunServer& aParent );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunServerUtils();
+
+private:
+
+    CDunServerUtils( CDunServer& aParent );
+
+    void ConstructL();
+
+// from base class MDunServerUtility
+
+    /**
+     * From MDunServerUtility.
+     * Closes plugins with state marked as zombie
+     *
+     * @since S60 3.2
+     * @return KErrGeneral = close on any of the plugins failed,
+               KErrNone otherwise
+     */
+    TInt RemoveZombiePlugins();
+
+    /**
+     * From MDunServerUtility.
+     * Loads local media module
+     *
+     * @since S60 3.2
+     * @param aPluginUid UID of the local media module to load
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt CreateNewPlugin( TUid aPluginUid );
+
+    /**
+     * From MDunServerUtility.
+     * Constructs local media module
+     *
+     * @since S60 3.2
+     * @param aPluginUid UID of the local media module to construct
+     * @param aDllName Name of the DLL to the constructed local media module
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt ConstructLocalMediaModule( const TUid& aPluginUid,
+                                    const TPtrC& aDllName );
+
+    /**
+     * From MDunServerUtility.
+     * Clears queued UIDs
+     *
+     * @since S60 3.2
+     * @param aPluginUid UID of local media plugin to remove
+     * @param aClearClosed ETrue if clear from closed queued wanted
+     * @param aClearQueued ETrue if clear from plugin queue wanted
+     * @return ETrue if plugin UID was removed, EFalse otherwise
+     */
+    TBool ClearQueuedUIDs( TUid aPluginUid,
+                           TBool aClearClosed,
+                           TBool aClearQueued );
+
+    /**
+     * From MDunServerUtility.
+     * Tries to close loaded local media plugin
+     *
+     * @since S60 3.2
+     * @param aIndex Index of plugin in connectiondata
+     * @param aDequeue ETrue if restarting of queued plugins and plugin
+     *                 dequeue wanted after successful plugin close
+     *                 (normal case, see also OpenMediaByUid()),
+     *                 EFalse if no restarting of queued plugins and plugin
+     *                 dequeue wanted after successful plugin close
+     *                 (in this case caller is reopener itself, see also
+     *                 ReopenQeueuedPlugins())
+     * @param aClientClose ETrue if close originator is client
+     * @param aSelfClose ETrue if plugin closes itself, EFalse otherwise
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt TryClosePlugin( TInt aIndex,
+                         TBool aDequeue,
+                         TBool aClientClose,
+                         TBool aSelfClose );
+
+    /**
+     * From MDunServerUtility.
+     * Closes a plugin directly without uninitializing it
+     *
+     * @since S60 5.0
+     * @param aIndex Index of plugin in connectiondata
+     * @param aDequeue ETrue if restarting of queued plugins and plugin
+     *                 dequeue wanted after successful plugin close
+     *                 (normal case, see also OpenMediaByUid()),
+     *                 EFalse if no restarting of queued plugins and plugin
+     *                 dequeue wanted after successful plugin close
+     *                 (in this case caller is reopener itself, see also
+     *                 ReopenQeueuedPlugins())
+     * @param aClientClose ETrue if close originator is client
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt DoClosePlugin( TInt aIndex,
+                        TBool aDequeue,
+                        TBool aClientClose );
+
+    /**
+     * From MDunServerUtility.
+     * Does immediate close of plugin
+     *
+     * @since S60 3.2
+     * @param aIndex Index of plugin in connectiondata
+     * @param aDequeue ETrue if restarting of queued plugins and plugin
+     *                 dequeue wanted after successful plugin close
+     *                 (normal case, see also OpenMediaByUid()),
+     *                 EFalse if no restarting of queued plugins and plugin
+     *                 dequeue wanted after successful plugin close
+     *                 (in this case caller is reopener itself, see also
+     *                 ReopenQeueuedPlugins())
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt DoImmediatePluginClose( TInt aIndex,
+                                 TBool aDequeue );
+
+    /**
+     * From MDunServerUtility.
+     * Tries uninitialization and after that listening state switch on a plugin
+     *
+     * @since S60 3.2
+     * @param aPluginUid UID of the plugin to initialize to listening state
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt TryInitializeToListening( TUid aPluginUid );
+
+    /**
+     * From MDunServerUtility.
+     * Tries listening state switch on a plugin
+     *
+     * @since S60 3.2
+     * @param aIndex Index of plugin in connectiondata
+     * @return KErrNotFound = plugin not found,
+               KErrNotReady = wrong state,
+               KErrNone otherwise
+     */
+    TInt TryListening( TInt aIndex );
+
+    /**
+     * From MDunServerUtility.
+     * Tries uninitialization of a plugin
+     *
+     * @since S60 3.2
+     * @param aIndex Index of plugin in connectiondata
+     * @return KErrNotFound = plugin not found, KErrNone otherwise
+     */
+    TInt TryUninitialize( TInt aIndex );
+
+private:  // data
+
+    /**
+     * Parent class owning this friend class (CDunServer)
+     */
+    CDunServer& iParent;
+
+    /**
+     * Transporter to use for network side communication
+     * (from parent iParent)
+     */
+    CDunTransporter*& iTransporter;
+
+    /**
+     * Waiter for closing self-destruct plugins
+     * (from parent iParent)
+     */
+    CDunCloseWait*& iCloseWait;
+
+    /**
+     * Array of TDunConnectionData needed for each loaded plugin
+     * (from parent iParent)
+     */
+    RArray<TDunConnectionData>& iConnData;
+
+    /**
+     * Array of plugin UIDs (from parent iParent)
+     * Used for queuing plugins that have no resources to use
+     * Used for dequeuing plugins when free resources detected
+     */
+    RArray<TUid>& iPluginQueue;
+
+    /**
+     * Array of plugin UIDs (from parent iParent)
+     * Used for queuing plugins that were successfully closed outside
+     * this server. This is to avoid returning KErrNotFound to LOCOD
+     * when NotifyMediaCloseRequest() is caught
+     */
+    RArray<TUid>& iClosedQueue;
+
+    };
+
+#endif  // C_CDUNSERVERUTILS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/server/inc/DunSession.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,105 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The session object for DUN server
+*
+*/
+
+
+#include "DunServer.h"
+
+#ifndef C_CDUNSESSION_H
+#define C_CDUNSESSION_H
+
+/**
+ *  Manages separate DUN server sessions for client(s)
+ *
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CDunSession ) : public CSession2
+    {
+
+public:
+
+    CDunSession( CDunServer* aDunServer );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunSession();
+
+    /**
+     * Return the version number
+     *
+     * @since S60 3.2
+     * @return Version number
+     */
+    TVersion Version() const;
+
+// from base class CSession2
+
+    /**
+     * From CSession2.
+     * Handles the servicing of client requests passed to the server
+     *
+     * @since S60 3.2
+     * @param aMessage Message containing the client request
+     * @return None
+     */
+    void ServiceL( const RMessage2 &aMessage );
+
+    /**
+     * From CSession2.
+     * Return a reference to DUN server
+     *
+     * @since S60 3.2
+     * @return Server reference
+     */
+    CDunServer& Server() const;
+
+private:
+
+    /**
+     * Handles incoming service messages
+     *
+     * @since S60 3.2
+     * @param aMessage Message containing the client request
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt DoService( const RMessage2& aMessage );
+
+    /**
+     * Handles incoming test service messages
+     *
+     * @since S60 5.0
+     * @param aMessage Message containing the client request
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt DoTestService( const RMessage2& aMessage );
+
+private:  // data
+
+    /**
+     * Message containing the client request
+     */
+    RMessage2   iMessage;
+
+    /**
+     * Pointer to DUN server
+     * Not own.
+     */
+    CDunServer* iDunServer;
+
+};
+
+#endif  // C_CDUNSESSION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/server/inc/dunserverdef.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definitions for server
+*
+*/
+
+
+#ifndef DUN_SERVERDEF_H
+#define DUN_SERVERDEF_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <e32svr.h>
+
+// DATA TYPES
+enum TDunIpc
+    {
+    EDunFuncManageService,
+    EDunFuncActiveConnection,  // For testing purposes only
+    EInvalidIpc
+    };
+
+// GLOBAL CONSTANTS
+
+_LIT( KDialupServerName, "dunserver" );
+
+const TUint KDunServerMajorVersionNumber = 2;
+const TUint KDunServerMinorVersionNumber = 0;
+const TUint KDunServerBuildVersionNumber = 0;
+
+#endif  // DUN_SERVERDEF_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/server/src/DunCloseWait.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,178 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Common waiter for closing self-destruct plugins
+*
+*/
+
+#include "DunCloseWait.h"
+#include "DunDebug.h"
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunCloseWait* CDunCloseWait::NewL( MDunCloseWait* aCallback )
+    {
+    CDunCloseWait* self = new (ELeave) CDunCloseWait( aCallback );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunCloseWait::~CDunCloseWait()
+    {
+    FTRACE(FPrint( _L("CDunCloseWait::~CDunCloseWait()" )));
+    ResetData();
+    FTRACE(FPrint( _L("CDunCloseWait::~CDunCloseWait() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Resets data to initial values
+// ---------------------------------------------------------------------------
+//
+void CDunCloseWait::ResetData()
+    {
+    // IssueRequest()
+    Stop();
+    // AddPluginToClose()
+    iCloseList.Close();
+    // Internal
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// Adds a new object to be destructed to the list
+// ---------------------------------------------------------------------------
+//
+TInt CDunCloseWait::AddPluginToClose( MDunLocalMediaPlugin* aPluginToClose )
+    {
+    FTRACE(FPrint( _L("CDunCloseWait::AddPluginToClose()" ) ));
+    if ( !aPluginToClose )
+        {
+        FTRACE(FPrint( _L("CDunCloseWait::AddPluginToClose() (ERROR) complete" ) ));
+        return KErrGeneral;
+        }
+    TInt retTemp = iCloseList.Find( aPluginToClose );
+    if ( retTemp != KErrNotFound )
+        {
+        FTRACE(FPrint( _L("CDunCloseWait::AddPluginToClose() (already exists) complete" ) ));
+        return KErrAlreadyExists;
+        }
+    retTemp = iCloseList.Append( aPluginToClose );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunCloseWait::AddPluginToClose() (append failed!) complete" ) ));
+        return retTemp;
+        }
+    FTRACE(FPrint( _L("CDunCloseWait::AddPluginToClose() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Issues request to start closing the objects in the close list
+// ---------------------------------------------------------------------------
+//
+TInt CDunCloseWait::IssueRequest()
+    {
+    FTRACE(FPrint( _L("CDunCloseWait::IssueRequest()" )));
+    if ( IsActive() )
+        {
+        FTRACE(FPrint( _L("CDunCloseWait::IssueRequest() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    iStatus = KRequestPending;
+    SetActive();
+    TRequestStatus* requestStatus = &iStatus;
+    User::RequestComplete( requestStatus, KErrNone );
+    FTRACE(FPrint( _L("CDunCloseWait::IssueRequest() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Stops closing the objects in the close list
+// ---------------------------------------------------------------------------
+//
+TInt CDunCloseWait::Stop()
+    {
+    FTRACE(FPrint( _L("CDunCloseWait::Stop()" )));
+    if ( !IsActive() )
+        {
+        FTRACE(FPrint( _L("CDunCloseWait::Stop() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    Cancel();
+    FTRACE(FPrint( _L("CDunCloseWait::Stop() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunCloseWait::CDunCloseWait
+// ---------------------------------------------------------------------------
+//
+CDunCloseWait::CDunCloseWait( MDunCloseWait* aCallback ) :
+    CActive( EPriorityHigh ),
+    iCallback( aCallback )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CDunCloseWait::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunCloseWait::ConstructL()
+    {
+    FTRACE(FPrint( _L("CDunCloseWait::ConstructL()" ) ));
+    if ( !iCallback )
+        {
+        User::Leave( KErrGeneral );
+        }
+    CActiveScheduler::Add( this );
+    FTRACE(FPrint( _L("CDunCloseWait::ConstructL() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes this class
+// ---------------------------------------------------------------------------
+//
+void CDunCloseWait::Initialize()
+    {
+    // Don't initialize iCallback here (it is set through NewL)
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called when closing of the plugins should be done
+// ---------------------------------------------------------------------------
+//
+void CDunCloseWait::RunL()
+    {
+    FTRACE(FPrint( _L("CDunCloseWait::RunL()" )));
+    iCallback->NotifyPluginCloseAfterWait( iCloseList );
+    iCloseList.Reset();
+    FTRACE(FPrint( _L("CDunCloseWait::RunL() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called on cancel
+// ---------------------------------------------------------------------------
+//
+void CDunCloseWait::DoCancel()
+    {
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/server/src/DunServer.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,674 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DUN server
+*
+*/
+
+
+#include <e32property.h>
+#include "DunServer.h"
+#include "DunServerUtils.h"
+#include "DunSession.h"
+#include "DunDebug.h"
+#include "DunServerSecurityPolicy.h"
+#include "dundomainpskeys.h"
+#include "DunTransporter.h"
+
+// PubSub security settings constants
+_LIT_SECURITY_POLICY_PASS( KConnStatusReadPolicy );
+_LIT_SECURITY_POLICY_C2( KConnStatusWritePolicy,
+                         ECapabilityLocalServices,
+                         ECapabilityWriteDeviceData );
+
+// ======== LOCAL FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// StartServerL Create Active Scheduler and CDunServer.
+// ---------------------------------------------------------------------------
+//
+static void StartServerL()
+    {
+    FTRACE(FPrint( _L("CDunServer::StartServerL()") ));
+    CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
+    CleanupStack::PushL( scheduler );
+    CActiveScheduler::Install( scheduler );
+
+    CDunServer* server = CDunServer::NewL();
+    CleanupStack::PushL( server );
+
+    User::RenameThread( KDialupServerName );
+    RProcess::Rendezvous( KErrNone );
+    FTRACE(FPrint( _L("CDunServer::StartServerL() Initialization done. Server is running.") ));
+
+    CActiveScheduler::Start();  // run the server
+
+    CleanupStack::PopAndDestroy( server );
+    CleanupStack::PopAndDestroy( scheduler );
+    FTRACE(FPrint( _L("CDunServer::StartServerL() complete") ));
+    }
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunServer* CDunServer::NewL()
+    {
+    CDunServer* self = new (ELeave) CDunServer( EPriorityStandard );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunServer::~CDunServer()
+    {
+    FTRACE(FPrint(_L("CDunServer::~CDunServer()")));
+    // Destroy iConnData
+    TInt i;
+    for ( i=iConnData.Count()-1; i>=0; i-- )
+        {
+        if ( iUtility )
+            {
+            iUtility->TryClosePlugin( i, EFalse, EFalse, EFalse );
+            }
+        }
+    if ( iConnData.Count() == 0 )
+        {
+        iConnData.Close();
+        }
+    else
+        {
+        FTRACE(FPrint(_L("CDunServer::~CDunServer() (ERROR) complete")));
+        }
+    // Destroy iPluginQueue
+    iPluginQueue.Close();
+    // Destroy iClosedQueue
+    iClosedQueue.Close();
+    // Destroy transporter
+    delete iTransporter;
+    iTransporter = NULL;
+    // Destroy utility
+    CDunServerUtils* utility = static_cast<CDunServerUtils*>( iUtility );
+    delete utility;
+    iUtility = NULL;
+    // Destroy close waiter
+    delete iCloseWait;
+    iCloseWait = NULL;
+    // Remove key
+    RProperty::Delete( KPSUidDialupConnStatus, KDialupConnStatus );
+    FTRACE(FPrint(_L("CDunServer::~CDunServer() complete")));
+    }
+
+// ---------------------------------------------------------------------------
+// Notification to manage local media On request
+// This comes from client
+// ---------------------------------------------------------------------------
+//
+TInt CDunServer::NotifyMediaOpenRequest( TUid aPluginUid )
+    {
+    FTRACE(FPrint(_L("CDunServer::NotifyMediaOpenRequest()")));
+    iUtility->ClearQueuedUIDs( aPluginUid, ETrue, ETrue );
+    iUtility->RemoveZombiePlugins();
+    TInt retVal = OpenMediaByUid( aPluginUid, ETrue );
+    FTRACE(FPrint(_L("CDunServer::NotifyMediaOpenRequest() complete (%d)"), retVal));
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// Notification to manage local media Off request
+// This comes from client
+// ---------------------------------------------------------------------------
+//
+TInt CDunServer::NotifyMediaCloseRequest( TUid aPluginUid )
+    {
+    FTRACE(FPrint(_L("CDunServer::NotifyMediaCloseRequest()")));
+    // If plugin can be found with iEnqueue or iClosed marked ETrue,
+    // Close also them in the same way (no special processing needed)
+    TInt retVal = CloseMediaByUid( aPluginUid, ETrue, ETrue, ETrue );
+    FTRACE(FPrint(_L("CDunServer::NotifyMediaCloseRequest() complete (%d)"), retVal));
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// Current active connection
+// This comes from client
+// ---------------------------------------------------------------------------
+//
+TConnId CDunServer::ActiveConnection()
+    {
+    FTRACE(FPrint(_L("CDunServer::ActiveConnection()")));
+    if ( iConnData.Count()<1 || iConnData.Count()>1 )
+        {
+        FTRACE(FPrint(_L("CDunServer::ActiveConnection() (unknown plugin amount) complete")));
+        return NULL;
+        }
+    TDunConnectionData& plugin = iConnData[0];
+    if ( !plugin.iLocalModulePtr )
+        {
+        FTRACE(FPrint(_L("CDunServer::ActiveConnection() (no instance) complete")));
+        return NULL;
+        }
+    TConnId connId = plugin.iLocalModulePtr->ActiveConnection();
+    FTRACE(FPrint(_L("CDunServer::ActiveConnection() complete")));
+    return connId;
+    }
+
+// ---------------------------------------------------------------------------
+// Increases reference count made by sessions
+// This comes from client
+// ---------------------------------------------------------------------------
+//
+void CDunServer::IncRefCount()
+    {
+    FTRACE(FPrint(_L("CDunServer::IncRefCount()")));
+    iRefCount++;
+    FTRACE(FPrint(_L("CDunServer::IncRefCount() complete")));
+    }
+
+// ---------------------------------------------------------------------------
+// Decreases reference count made by sessions
+// This comes from client
+// ---------------------------------------------------------------------------
+//
+void CDunServer::DecRefCount()
+    {
+    FTRACE(FPrint(_L("CDunServer::DecRefCount()")));
+    if ( iRefCount > 0 )
+        {
+        iRefCount--;
+        FTRACE(FPrint(_L("CDunServer::DecRefCount() reference count decreased")));
+        if ( iRefCount == 0 )
+            {
+            FTRACE(FPrint(_L("CDunServer::DecRefCount() stopping activescheduler...")));
+            CActiveScheduler::Stop();
+            }
+        }
+    FTRACE(FPrint(_L("CDunServer::DecRefCount() complete")));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CServer2 (CPolicyServer -> CServer2).
+// Creates a server-side client session object.
+// ---------------------------------------------------------------------------
+//
+CSession2* CDunServer::NewSessionL( const TVersion& aVersion,
+                                    const RMessage2& /*aMessage*/ ) const
+    {
+    FTRACE(FPrint(_L("CDunServer::NewSessionL()")));
+    TVersion version(KDunServerMajorVersionNumber,
+                     KDunServerMinorVersionNumber,
+                     KDunServerBuildVersionNumber );
+    TBool supported = User::QueryVersionSupported( version, aVersion );
+    if ( !supported )
+        {
+        FTRACE(FPrint(_L("CDunServer::NewSessionL() (not supported) complete")));
+        User::Leave( KErrNotSupported );
+        }
+    CDunSession* session = new (ELeave) CDunSession(const_cast<CDunServer*>( this ));
+    FTRACE(FPrint(_L("CDunServer::NewSessionL() complete")));
+    return session;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunServer::CDunServer
+// ---------------------------------------------------------------------------
+//
+CDunServer::CDunServer( TInt aPriority ) :
+    // aPriority: priority of AO
+    // KDunServerPolicy: TPolicy structure of DUN
+    CPolicyServer( aPriority, KDunServerPolicy ),
+    iTransporter( NULL ),
+    iConnStatus( EDialupUndefined ),
+    iRefCount( 0 )
+    {
+    FTRACE( FPrint( _L( "CDunServer::CDunServer()" )));
+    }
+
+// ---------------------------------------------------------------------------
+// CDunServer::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunServer::ConstructL()
+    {
+    FTRACE( FPrint( _L( "CDunServer::ConstructL()" )));
+    StartL( KDialupServerName );
+    // Initialize pubsub key properties
+    User::LeaveIfError(
+        RProperty::Define( KPSUidDialupConnStatus,
+                           KDialupConnStatus,
+                           RProperty::EInt,
+                           KConnStatusReadPolicy,
+                           KConnStatusWritePolicy) );
+    // Set key to initial value
+    RProperty::Set( KPSUidDialupConnStatus,
+                    KDialupConnStatus,
+                    EDialupInactive );
+    // Create waiter for closing self-destruct plugins
+    CDunCloseWait* closeWait = CDunCloseWait::NewL( this );
+    CleanupStack::PushL( closeWait );
+    // Create transporter
+    CDunTransporter* transporter = CDunTransporter::NewL( this );
+    CleanupStack::PushL( transporter );
+    // Create utility
+    CDunServerUtils* utility = CDunServerUtils::NewL( *this );
+    iUtility = static_cast<MDunServerUtility*>( utility );
+    iTransporter = transporter;
+    iCloseWait = closeWait;
+    CleanupStack::Pop( transporter );
+    CleanupStack::Pop( closeWait );
+    FTRACE( FPrint( _L( "CDunServer::ConstructL() complete")));
+    }
+
+// ---------------------------------------------------------------------------
+// Opens local media plugin by UID
+// ---------------------------------------------------------------------------
+//
+TInt CDunServer::OpenMediaByUid( TUid aPluginUid, TBool aDequeue )
+    {
+    FTRACE(FPrint(_L("CDunServer::OpenMediaByUid()")));
+    TInt i;
+    TInt count = iConnData.Count();
+    for ( i=0; i<count; i++ )
+        {
+        if ( iConnData[i].iLocalModuleUid == aPluginUid )
+            {
+            FTRACE(FPrint(_L("CDunServer::OpenMediaByUid() (already exists) complete")));
+            return KErrAlreadyExists;
+            }
+        }
+    FTRACE(FPrint(_L("CDunServer::OpenMediaByUid() creating new plugin 0x%08X"), aPluginUid.iUid));
+    TInt retTemp = iUtility->CreateNewPlugin( aPluginUid );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunServer::OpenMediaByUid() (ERROR) complete")));
+        return retTemp;
+        }
+    TInt pluginIndex = iConnData.Count() - 1;
+    FTRACE(FPrint(_L("CDunServer::OpenMediaByUid() trying listen at index %d"), pluginIndex));
+    retTemp = iUtility->TryListening( pluginIndex );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunServer::OpenMediaByUid() trying close at index %d"), pluginIndex));
+        iUtility->TryClosePlugin( pluginIndex, aDequeue, EFalse, EFalse );
+        // Ignore error(s), TryClosePlugin()'s TryUninitialize already sets to Zombie if error(s)
+        FTRACE(FPrint(_L("CDunServer::OpenMediaByUid() (ERROR) complete")));
+        return retTemp;
+        }
+    // Clear queued also from queued plugin UIDs, just to be safe
+    iUtility->ClearQueuedUIDs( aPluginUid, ETrue, ETrue );
+    FTRACE(FPrint(_L("CDunServer::OpenMediaByUid() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Closes local media plugin by UID
+// ---------------------------------------------------------------------------
+//
+TInt CDunServer::CloseMediaByUid( TUid aPluginUid,
+                                  TBool aClearQueued,
+                                  TBool aClientClose,
+                                  TBool aSelfDelete )
+    {
+    FTRACE(FPrint(_L("CDunServer::CloseMediaByUid()")));
+    TInt i;
+    TBool cleared = EFalse;
+    if ( aClearQueued )
+        {
+        cleared = iUtility->ClearQueuedUIDs( aPluginUid, ETrue, ETrue );
+        }
+    TInt count = iConnData.Count();
+    for ( i=0; i<count; i++ )
+        {
+        if ( iConnData[i].iLocalModuleUid == aPluginUid )
+            {
+            break;
+            }
+        }
+    if ( i >= count )
+        {
+        FTRACE(FPrint(_L("CDunServer::CloseMediaByUid() (not found) complete")));
+        return KErrNotFound;
+        }
+    FTRACE(FPrint(_L("CDunServer::CloseMediaByUid() trying close at index %d"), i));
+    // Plugin found from main list, now close
+    TInt retTemp = iUtility->TryClosePlugin( i,
+                                             ETrue,
+                                             aClientClose,
+                                             aSelfDelete );
+    if ( retTemp!=KErrNone && !cleared )
+        {
+        FTRACE(FPrint(_L("CDunServer::CloseMediaByUid() (ERROR) complete")));
+        return retTemp;
+        }
+    FTRACE(FPrint(_L("CDunServer::CloseMediaByUid() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Reopens plugins from plugin queue
+// ---------------------------------------------------------------------------
+//
+TInt CDunServer::ReopenQueuedPlugins()
+    {
+    FTRACE(FPrint(_L("CDunServer::ReopenQueuedPlugins() (%d)"), iPluginQueue.Count()));
+    TInt i = iPluginQueue.Count() - 1;
+    while ( i >= 0 )
+        {
+        TInt retTemp = OpenMediaByUid( iPluginQueue[i], EFalse );
+        if ( retTemp == KErrNone )
+            {
+            // Open succeeded so plugin UID was removed by ClearQueuedUIDs().
+            // Recalculate i because this method can remove more than one
+            // match.
+            i = iPluginQueue.Count() - 1;
+            }
+        else
+            {
+            // Open failed so the plugin UID was not removed from queue.
+            // Just decrease index (avoid forever loop).
+            i--;
+            }
+        }
+    FTRACE(FPrint(_L("CDunServer::ReopenQueuedPlugin()")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunServerCallback.
+// Searches for plugin in connection data and returns its state
+// ---------------------------------------------------------------------------
+//
+TDunPluginState CDunServer::GetPluginStateByUid( TUid aPluginUid )
+    {
+    FTRACE(FPrint(_L("CDunServer::GetPluginStateByUid()")));
+    TInt i;
+    TInt count = iConnData.Count();
+    for ( i=0; i<count; i++ )
+        {
+        if ( iConnData[i].iLocalModuleUid == aPluginUid )
+            {
+            break;
+            }
+        }
+    if ( i >= count )
+        {
+        FTRACE(FPrint(_L("CDunServer::GetPluginStateByUid() (not found) complete")));
+        return EDunStateNone;
+        }
+    FTRACE(FPrint(_L("CDunServer::GetPluginStateByUid() state at index %d is %d"), i, iConnData[i].iPluginState));
+    FTRACE(FPrint(_L("CDunServer::GetPluginStateByUid() complete")));
+    return iConnData[i].iPluginState;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunServerCallback.
+// Notification about request to change plugin state up by one level
+// ---------------------------------------------------------------------------
+//
+TInt CDunServer::NotifyPluginStateChangeUp( TDunPluginState aPluginState,
+                                            TUid aPluginUid )
+    {
+    FTRACE(FPrint(_L("CDunServer::NotifyPluginStateChangeUp()")));
+    TInt i;
+    TInt count = iConnData.Count();
+    for ( i=0; i<count; i++ )
+        {
+        if ( iConnData[i].iLocalModuleUid == aPluginUid )
+            {
+            break;
+            }
+        }
+    if ( i >= count )
+        {
+        FTRACE(FPrint(_L("CDunServer::NotifyPluginStateChangeUp() (not found) complete")));
+        return KErrNotFound;
+        }
+    FTRACE(FPrint(_L("CDunServer::NotifyPluginStateChangeUp() found at index %d"), i));
+    TDunPluginState pluginState = iConnData[i].iPluginState;
+    if ( pluginState<EDunStateTryUninitialize || aPluginState-pluginState!=1 )
+        {
+        FTRACE(FPrint(_L("CDunServer::NotifyPluginStateChangeUp() (unknown state) complete (%d/%d)"), pluginState, aPluginState));
+        return KErrNotSupported;
+        }
+    iConnData[i].iPluginState = aPluginState;
+    FTRACE(FPrint(_L("CDunServer::NotifyPluginStateChangeUp() state changed to %d(%d)"), aPluginState, pluginState));
+    FTRACE(FPrint(_L("CDunServer::NotifyPluginStateChangeUp() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunServerCallback.
+// Notification about request to change plugin state down by one level
+// ---------------------------------------------------------------------------
+//
+TInt CDunServer::NotifyPluginStateChangeDown( TDunPluginState aPluginState,
+                                              TUid aPluginUid)
+    {
+    FTRACE(FPrint(_L("CDunServer::NotifyPluginStateChangeDown()")));
+    TInt i;
+    TInt count = iConnData.Count();
+    for ( i=0; i<count; i++ )
+        {
+        if ( iConnData[i].iLocalModuleUid == aPluginUid )
+            {
+            break;
+            }
+        }
+    if ( i >= count )
+        {
+        FTRACE(FPrint(_L("CDunServer::NotifyPluginStateChangeDown() (not found) complete")));
+        return KErrNotFound;
+        }
+    FTRACE(FPrint(_L("CDunServer::NotifyPluginStateChangeDown() found at index %d"), i));
+    TDunPluginState pluginState = iConnData[i].iPluginState;
+    if ( aPluginState >= pluginState )
+        {
+        FTRACE(FPrint(_L("CDunServer::NotifyPluginStateChangeDown() (unknown state) complete (%d/%d)"), pluginState, aPluginState));
+        return KErrNotSupported;
+        }
+    // Next catch the cases where state is not "try"
+    if ( aPluginState != EDunStateTryUninitialize &&
+         aPluginState != EDunStateTryLoad         &&
+         aPluginState != EDunStateTryListen       &&
+         aPluginState != EDunStateTryChannel )
+        {
+        FTRACE(FPrint(_L("CDunServer::NotifyPluginStateChangeDown() (unknown state) complete (%d/%d)"), pluginState, aPluginState));
+        return KErrNotSupported;
+        }
+    iConnData[i].iPluginState = aPluginState;
+    FTRACE(FPrint(_L("CDunServer::NotifyPluginStateChangeDown() state changed to %d(%d)"), aPluginState, pluginState));
+    FTRACE(FPrint(_L("CDunServer::NotifyPluginStateChangeDown() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunServerCallback.
+// Notification about plugin restart request
+// ---------------------------------------------------------------------------
+//
+TInt CDunServer::NotifyPluginRestart( TUid aPluginUid )
+    {
+    FTRACE(FPrint(_L("CDunServer::NotifyPluginRestart()")));
+    TInt retTemp = iUtility->TryInitializeToListening( aPluginUid );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunServer::NotifyPluginRestart() (ERROR) initialize failed")));
+        return retTemp;
+        }
+    // Restarting may have freed channel(s),
+    // try to reopen queued plugins (ignore error(s))
+    ReopenQueuedPlugins();
+    FTRACE(FPrint(_L("CDunServer::NotifyPluginRestart() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunServerCallback.
+// Notification about plugin restart request
+// ---------------------------------------------------------------------------
+//
+TInt CDunServer::NotifyPluginReopenRequest()
+    {
+    FTRACE(FPrint(_L("CDunServer::NotifyPluginReopenRequest()")));
+    TInt retVal = ReopenQueuedPlugins();
+    FTRACE(FPrint(_L("CDunServer::NotifyPluginReopenRequest() complete")));
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunPluginManager (MDunServerCallback->MDunPluginManager).
+// Notification about request to enqueue a plugin to plugin queue
+// ---------------------------------------------------------------------------
+//
+TInt CDunServer::NotifyPluginEnqueueRequest( TUid aPluginUid )
+    {
+    FTRACE(FPrint(_L("CDunServer::NotifyPluginEnqueueRequest()")));
+    TInt i;
+    TInt count = iConnData.Count();
+    for ( i=0; i<count; i++ )
+        {
+        if ( iConnData[i].iLocalModuleUid == aPluginUid )
+            {
+            break;
+            }
+        }
+    if ( i >= count )
+        {
+        FTRACE(FPrint(_L("CDunServer::NotifyPluginEnqueueRequest() (not found) complete")));
+        return KErrNotFound;
+        }
+    FTRACE(FPrint(_L("CDunServer::NotifyPluginEnqueueRequest() found at index %d"), i));
+    // Plugin exists, now try to find it from plugin queue
+    count = iPluginQueue.Count();
+    for ( i=0; i<count; i++ )
+        {
+        if ( iPluginQueue[i] == aPluginUid )
+            {
+            FTRACE(FPrint(_L("CDunServer::NotifyPluginEnqueueRequest() (already exists) complete")));
+            return KErrAlreadyExists;
+            }
+        }
+    // New plugin found, queue
+    TInt retTemp = CloseMediaByUid( aPluginUid, EFalse, EFalse, ETrue );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunServer::NotifyPluginEnqueueRequest() (close failed) complete")));
+        return KErrGeneral;
+        }
+    retTemp = iPluginQueue.Append( aPluginUid );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunServer::NotifyPluginEnqueueRequest() (append failed!) complete")));
+        return retTemp;
+        }
+    FTRACE(FPrint(_L("CDunServer::NotifyPluginEnqueueRequest() appended to index %d"), iPluginQueue.Count()-1));
+    FTRACE(FPrint(_L("CDunServer::NotifyPluginEnqueueRequest() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunPluginManager (MDunServerCallback->MDunPluginManager).
+// Notification about request to dequeue a plugin from plugin queue
+// ---------------------------------------------------------------------------
+//
+TInt CDunServer::NotifyPluginDequeueRequest( TUid aPluginUid )
+    {
+    FTRACE(FPrint(_L("CDunServer::NotifyPluginDequeueRequest()")));
+    TBool cleared = iUtility->ClearQueuedUIDs( aPluginUid, ETrue, ETrue );
+    if ( !cleared )
+        {
+        FTRACE(FPrint(_L("CDunServer::NotifyPluginDequeueRequest() (not found) complete")));
+        return KErrNotFound;
+        }
+    FTRACE(FPrint(_L("CDunServer::NotifyPluginDequeueRequest() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunPluginManager (MDunServerCallback->MDunPluginManager).
+// Notification about request to close a plugin
+// ---------------------------------------------------------------------------
+//
+TInt CDunServer::NotifyPluginCloseRequest( TUid aPluginUid, TBool aSelfClose )
+    {
+    FTRACE(FPrint(_L("CDunServer::NotifyPluginCloseRequest()")));
+    TInt retTemp = CloseMediaByUid( aPluginUid, ETrue, EFalse, aSelfClose );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunServer::NotifyPluginCloseRequest() (ERROR) complete")));
+        return retTemp;
+        }
+    FTRACE(FPrint(_L("CDunServer::NotifyPluginCloseRequest() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From MDunCloseWait.
+// Notification about request to close a plugin after wait
+// ---------------------------------------------------------------------------
+//
+void CDunServer::NotifyPluginCloseAfterWait(
+    RPointerArray<MDunLocalMediaPlugin>& aPluginsToClose )
+    {
+    FTRACE(FPrint(_L("CDunServer::NotifyPluginCloseAfterWait()")));
+    TInt i;
+    TInt j;
+    TInt closeCount = aPluginsToClose.Count();
+    for ( i=0; i<closeCount; i++ )
+        {
+        // keep iConnData.Count() on the line below as it changes!
+        for ( j=0; j<iConnData.Count(); j++ )
+            {
+            if ( iConnData[j].iLocalModulePtr == aPluginsToClose[i] )
+                {
+                iUtility->DoClosePlugin( j, ETrue, EFalse );
+                }
+            }
+        }
+    FTRACE(FPrint(_L("CDunServer::NotifyPluginCloseAfterWait() complete")));
+    }
+
+// ======== GLOBAL FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// WinsMain/E32Main implements main function for DUN
+// exe.
+// Create Cleanup Stack, initialise server and start Active
+// Scheduler.
+// Returns: Error value: General error value
+// ---------------------------------------------------------------------------
+//
+TInt E32Main()
+    {
+    FTRACE(FPrint( _L("CDunServer::Main() Process started.") ));
+__UHEAP_MARK;
+    CTrapCleanup* cleanup = CTrapCleanup::New();
+    TInt retVal = KErrNoMemory;
+
+    if ( cleanup )
+        {
+        TRAP( retVal, StartServerL() ); // perform all other initialisation
+        delete cleanup;
+        }
+__UHEAP_MARKEND;
+
+    FTRACE(FPrint( _L("CDunServer::Main() Process exit code = %d"), retVal));
+    return retVal;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/server/src/DunServerUtils.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,497 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Utility class for CDunServer
+*
+*/
+
+
+#include <e32uid.h>
+#include "DunServer.h"
+#include "DunServerUtils.h"
+#include "DunDebug.h"
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunServerUtils* CDunServerUtils::NewL( CDunServer& aParent )
+    {
+    CDunServerUtils* self = new (ELeave) CDunServerUtils( aParent );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunServerUtils::~CDunServerUtils()
+    {
+    FTRACE(FPrint(_L("CDunServerUtils::~CDunServerUtils()")));
+    FTRACE(FPrint(_L("CDunServerUtils::~CDunServerUtils() complete")));
+    }
+
+// ---------------------------------------------------------------------------
+// CDunServerUtils::CDunServerUtils
+// ---------------------------------------------------------------------------
+//
+CDunServerUtils::CDunServerUtils( CDunServer& aParent ) :
+    iParent( aParent ),
+    iTransporter( aParent.iTransporter ),
+    iCloseWait( aParent.iCloseWait ),
+    iConnData( aParent.iConnData ),
+    iPluginQueue( aParent.iPluginQueue ),
+    iClosedQueue( aParent.iClosedQueue )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CDunServerUtils::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunServerUtils::ConstructL()
+    {
+    FTRACE(FPrint( _L("CDunServerUtils::ConstructL()" ) ));
+    FTRACE(FPrint( _L("CDunServerUtils::ConstructL() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunServerUtility.
+// Closes plugins with state marked as zombie
+// ---------------------------------------------------------------------------
+//
+TInt CDunServerUtils::RemoveZombiePlugins()
+    {
+    FTRACE(FPrint(_L("CDunServerUtils::RemoveZombiePlugins()")));
+    TInt i;
+    TInt retVal = KErrNone;
+    for ( i=iConnData.Count()-1; i>=0; i-- )
+        {
+        if ( iConnData[i].iPluginState == EDunStateZombie )
+            {
+            // Following closes and removes if remove ok
+            FTRACE(FPrint(_L("CDunServerUtils::RemoveZombiePlugins() trying close at index %d"), i));
+            TInt retTemp = TryClosePlugin( i, ETrue, EFalse, EFalse );
+            if ( retTemp != KErrNone )
+                {
+                retVal = KErrGeneral;
+                }
+            }
+        }
+    FTRACE(FPrint(_L("CDunServerUtils::RemoveZombiePlugins() complete")));
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunServerUtility.
+// Loads local media module
+// ---------------------------------------------------------------------------
+//
+TInt CDunServerUtils::CreateNewPlugin( TUid aPluginUid )
+    {
+    FTRACE(FPrint(_L("CDunServerUtils::CreateNewPlugin()")));
+    // plugin not constructed, construct now
+    TFileName pluginFile;
+    switch ( aPluginUid.iUid )
+        {
+        case KDunBtPluginUidValue:
+            pluginFile.Copy( KDunPluginBt );
+            break;
+        case KDunIrPluginUidValue:
+            pluginFile.Copy( KDunPluginIrda );
+            break;
+        case KDunUsbPluginUidValue:
+            pluginFile.Copy( KDunPluginUsb );
+            break;
+        default:
+            FTRACE(FPrint(_L("CDunServerUtils::CreateNewPlugin() (not supported) complete")));
+            return KErrNotSupported;
+        }
+    TDunConnectionData emptyConn;
+    emptyConn.iLocalModulePtr = NULL;
+    emptyConn.iLocalModuleUid = TUid::Null();
+    emptyConn.iPluginState = EDunStateNone;
+    TInt retTemp = iConnData.Append( emptyConn );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunServerUtils::CreateNewPlugin() (append failed!) complete")));
+        return retTemp;
+        }
+    retTemp = ConstructLocalMediaModule( aPluginUid, pluginFile );
+    if ( retTemp != KErrNone )
+        {
+        iConnData.Remove( iConnData.Count()-1 );
+        FTRACE(FPrint(_L("CDunServerUtils::CreateNewPlugin() (ERROR) complete")));
+        return retTemp;
+        }
+    FTRACE(FPrint(_L("CDunServerUtils::CreateNewPlugin() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunServerUtility.
+// Constructs local media module
+// ---------------------------------------------------------------------------
+//
+TInt CDunServerUtils::ConstructLocalMediaModule( const TUid& aPluginUid,
+                                                 const TPtrC& aDllName )
+    {
+    FTRACE(FPrint(_L("CDunServerUtils::ConstructLocalMediaModule()")));
+    // Create a new library object
+    if ( iConnData.Count() == 0 )
+        {
+        FTRACE(FPrint(_L("CDunServerUtils::ConstructLocalMediaModule() (not ready) complete")));
+        return KErrNotReady;
+        }
+    TInt index = iConnData.Count() - 1;
+    iConnData[index].iLocalModuleUid = aPluginUid;
+    iConnData[index].iPluginState = EDunStateTryLoad;
+    // Load the DLL containing the plug-in
+    TUidType uidType( KDynamicLibraryUid,
+                      KDunLocalMediaPluginInterfaceUid,
+                      aPluginUid );
+    FTRACE(FPrint(_L("CDunServerUtils::ConstructLocalMediaModule() loading")));
+    TInt retTemp = iConnData[index].iModuleLibrary.Load( aDllName, uidType );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunServerUtils::ConstructLocalMediaModule() (ERROR) complete")));
+        return retTemp;
+        }
+    FTRACE(FPrint(_L("CDunServerUtils::ConstructLocalMediaModule() plugin 0x%08X loaded"), aPluginUid.iUid));
+    // Create the plugin object.
+    FTRACE(FPrint(_L("CDunServerUtils::ConstructLocalMediaModule() looking up")));
+    TLibraryFunction factoryFunction = iConnData[index].iModuleLibrary.Lookup( 1 );
+    if ( !factoryFunction )
+        {
+        iConnData[index].iModuleLibrary.Close();
+        FTRACE(FPrint(_L("CDunServerUtils::ConstructLocalMediaModule() (ERROR) complete")));
+        return KErrNotFound;
+        }
+    MDunLocalMediaPlugin* localPlugin =
+        reinterpret_cast<MDunLocalMediaPlugin*>( factoryFunction() );
+    if ( !localPlugin )
+        {
+        iConnData[index].iModuleLibrary.Close();
+        FTRACE(FPrint(_L("CDunServerUtils::ConstructLocalMediaModule() (ERROR) complete")));
+        return KErrGeneral;
+        }
+    iConnData[index].iLocalModulePtr = localPlugin;
+    FTRACE(FPrint(_L("CDunServerUtils::ConstructLocalMediaModule() constructing")));
+    TRAPD( retTrap, localPlugin->ConstructL(&iParent, iTransporter) );
+    if ( retTrap != KErrNone )
+        {
+        delete iConnData[index].iLocalModulePtr;
+        iConnData[index].iLocalModulePtr = NULL;
+        iConnData[index].iModuleLibrary.Close();
+        FTRACE(FPrint(_L("CDunServerUtils::ConstructLocalMediaModule() (ERROR) complete")));
+        return retTrap;
+        }
+    iConnData[index].iPluginState = EDunStateLoaded;
+    FTRACE(FPrint(_L("CDunServerUtils::ConstructLocalMediaModule() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunServerUtility.
+// Clears queued UIDs
+// ---------------------------------------------------------------------------
+//
+TBool CDunServerUtils::ClearQueuedUIDs( TUid aPluginUid,
+                                        TBool aClearClosed,
+                                        TBool aClearQueued )
+    {
+    FTRACE(FPrint(_L("CDunServerUtils::ClearQueuedUIDs()")));
+    TInt i;
+    TBool cleared = EFalse;
+    if ( aClearClosed )
+        {
+        for ( i=iClosedQueue.Count()-1; i>=0; i-- )
+            {
+            if ( iClosedQueue[i] == aPluginUid )
+                {
+                iClosedQueue.Remove( i );
+                cleared = ETrue;
+                FTRACE(FPrint(_L("CDunServerUtils::ClearQueuedUIDs() removed from closed queue at %d"), i));
+                }
+            }
+        }
+    if ( aClearQueued )
+        {
+        for ( i=iPluginQueue.Count()-1; i>=0; i-- )
+            {
+            if ( iPluginQueue[i] == aPluginUid )
+                {
+                iPluginQueue.Remove( i );
+                cleared = ETrue;
+                FTRACE(FPrint(_L("CDunServerUtils::ClearQueuedUIDs() removed from plugin queue at %d"), i));
+                }
+            }
+        }
+    FTRACE(FPrint(_L("CDunServerUtils::ClearQueuedUIDs() complete")));
+    return cleared;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunServerUtility.
+// Tries to close loaded local media plugin
+// ---------------------------------------------------------------------------
+//
+TInt CDunServerUtils::TryClosePlugin( TInt aIndex,
+                                      TBool aDequeue,
+                                      TBool aClientClose,
+                                      TBool aSelfClose )
+    {
+    FTRACE(FPrint(_L("CDunServerUtils::TryClosePlugin()")));
+    if ( aIndex < 0 ||
+         aIndex >= iConnData.Count() )
+        {
+        FTRACE(FPrint(_L("CDunServerUtils::TryClosePlugin() (not found) complete")));
+        return KErrNotFound;
+        }
+    TInt retTemp = TryUninitialize( aIndex );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunServerUtils::TryClosePlugin() (ERROR) complete")));
+        return retTemp;
+        }
+    if ( !aSelfClose )
+        {
+        retTemp = DoClosePlugin( aIndex, aDequeue, aClientClose );
+        FTRACE(FPrint(_L("CDunServerUtils::TryClosePlugin() complete")));
+        return retTemp;
+        }
+    retTemp = iCloseWait->AddPluginToClose( iConnData[aIndex].iLocalModulePtr );
+    if ( retTemp != KErrNone )
+        {
+        iConnData[aIndex].iPluginState = EDunStateZombie;
+        FTRACE(FPrint(_L("CDunServerUtils::TryClosePlugin() state changed to %d"), EDunStateZombie));
+        return retTemp;
+        }
+    retTemp = iCloseWait->IssueRequest();
+    if ( retTemp != KErrNone )
+        {
+        iConnData[aIndex].iPluginState = EDunStateZombie;
+        FTRACE(FPrint(_L("CDunServerUtils::TryClosePlugin() state changed to %d"), EDunStateZombie));
+        return retTemp;
+        }
+    FTRACE(FPrint(_L("CDunServerUtils::TryClosePlugin() (waiting) complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunServerUtility.
+// Closes a plugin directly without uninitializing it
+// ---------------------------------------------------------------------------
+//
+TInt CDunServerUtils::DoClosePlugin(
+    TInt aIndex,
+    TBool aDequeue,
+    TBool aClientClose )
+    {
+    FTRACE(FPrint(_L("CDunServerUtils::DoClosePlugin()")));
+    if ( aIndex < 0 ||
+         aIndex >= iConnData.Count() )
+        {
+        FTRACE(FPrint(_L("CDunServerUtils::DoClosePlugin() (not found) complete")));
+        return KErrNotFound;
+        }
+    TUid pluginUid = iConnData[aIndex].iLocalModuleUid;
+    DoImmediatePluginClose( aIndex, aDequeue );
+    if ( !aClientClose )
+        {
+        // Plugin was closed by something else than client
+        // Enqueue it to closed queue
+        TInt i;
+        TInt count = iClosedQueue.Count();
+        for ( i=0; i<count; i++ )
+            {
+            if ( iClosedQueue[i] == pluginUid )
+                {
+                FTRACE(FPrint(_L("CDunServerUtils::DoClosePlugin() (already exists) complete")));
+                return KErrAlreadyExists;
+                }
+            }
+        TInt retTemp = iClosedQueue.Append( pluginUid );
+        if ( retTemp != KErrNone )
+            {
+            FTRACE(FPrint(_L("CDunServerUtils::DoClosePlugin() (append failed!) complete")));
+            return retTemp;
+            }
+        FTRACE(FPrint(_L("CDunServerUtils::DoClosePlugin() appended to index %d"), iClosedQueue.Count()-1));
+        }
+    FTRACE(FPrint(_L("CDunServerUtils::DoClosePlugin() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunServerUtility.
+// Does immediate close of plugin
+// ---------------------------------------------------------------------------
+//
+TInt CDunServerUtils::DoImmediatePluginClose( TInt aIndex, TBool aDequeue )
+    {
+    FTRACE(FPrint(_L("CDunServerUtils::DoImmediatePluginClose()")));
+    if ( aIndex < 0 ||
+         aIndex >= iConnData.Count() )
+        {
+        FTRACE(FPrint(_L("CDunServerUtils::DoImmediatePluginClose() (not found) complete")));
+        return KErrNotFound;
+        }
+    delete iConnData[aIndex].iLocalModulePtr;
+    iConnData[aIndex].iLocalModulePtr = NULL;
+    if ( iConnData[aIndex].iModuleLibrary.Handle() != KNullHandle )
+        {
+        iConnData[aIndex].iModuleLibrary.Close();
+        }
+    iConnData.Remove( aIndex );
+    // Now, the following check is needed to avoid recursion by:
+    // ReopenQueuedPlugins()->OpenMediaByUid()->TryClosePlugin()->
+    // DoImmediatePluginClose()->ReopenQueuedPlugins()
+    if ( aDequeue )
+        {
+        iParent.ReopenQueuedPlugins();
+        }
+    // Ignore error(s); this function must only report it's own operation status
+    FTRACE(FPrint(_L("CDunServerUtils::DoImmediatePluginClose() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunServerUtility.
+// Tries uninitialization and after that listening state switch on a plugin
+// ---------------------------------------------------------------------------
+//
+TInt CDunServerUtils::TryInitializeToListening( TUid aPluginUid )
+    {
+    FTRACE(FPrint(_L("CDunServerUtils::TryInitializeToListening()")));
+    TInt i;
+    TInt count = iConnData.Count();
+    for ( i=0; i<count; i++ )
+        {
+        if ( iConnData[i].iLocalModuleUid == aPluginUid )
+            {
+            break;
+            }
+        }
+    if ( i >= count )
+        {
+        FTRACE(FPrint(_L("CDunServerUtils::TryInitializeToListening() (not found) complete")));
+        return KErrNotFound;
+        }
+    TInt retTemp = TryUninitialize( i );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunServerUtils::TryInitializeToListening() (uninitialize error) complete")));
+        return retTemp;
+        }
+    // Change from Uninitialized to Loaded because listening mode needs it
+    // (plugin is already loaded anyway)
+    iConnData[i].iPluginState = EDunStateLoaded;
+    retTemp = TryListening( i );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L("CDunServerUtils::TryInitializeToListening() (listening error) complete")));
+        return retTemp;
+        }
+    FTRACE(FPrint(_L("CDunServerUtils::TryInitializeToListening() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunServerUtility.
+// Tries listening state switch on a plugin
+// ---------------------------------------------------------------------------
+//
+TInt CDunServerUtils::TryListening( TInt aIndex )
+    {
+    FTRACE(FPrint(_L("CDunServerUtils::TryListening()")));
+    if ( aIndex < 0 ||
+         aIndex >= iConnData.Count() )
+        {
+        FTRACE(FPrint(_L("CDunServerUtils::TryListening() (not found) complete")));
+        return KErrNotFound;
+        }
+    if ( iConnData[aIndex].iPluginState != EDunStateLoaded )
+        {
+        FTRACE(FPrint(_L("CDunServerUtils::TryListening() (not ready) complete")));
+        return KErrNotReady;
+        }
+    FTRACE(FPrint(_L("CDunServerUtils::TryListening() notifying server state change (%d)"), EDunStateTryListen));
+    TInt retTemp =
+        iConnData[aIndex].iLocalModulePtr->NotifyServerStateChange( EDunStateTryListen );
+    if ( retTemp != KErrNone )
+        {
+        iConnData[aIndex].iPluginState = EDunStateZombie;
+        FTRACE(FPrint(_L("CDunServerUtils::TryListening() state changed to %d"), EDunStateZombie));
+        FTRACE(FPrint(_L("CDunServerUtils::TryListening() (ERROR) complete")));
+        return retTemp;
+        }
+    // Plugin could have changed state, only change state if possible
+    // This can happen if plugin has no real listening and switches directly
+    // from listening mode to channeled mode
+    if ( iConnData[aIndex].iPluginState == EDunStateTryListen )
+        {
+        iConnData[aIndex].iPluginState = EDunStateListening;
+        }
+    FTRACE(FPrint(_L("CDunServerUtils::TryListening() state changed to %d"), EDunStateListening));
+    FTRACE(FPrint(_L("CDunServerUtils::TryListening() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunServerUtility.
+// Tries uninitialization of a plugin
+// ---------------------------------------------------------------------------
+//
+TInt CDunServerUtils::TryUninitialize( TInt aIndex )
+    {
+    FTRACE(FPrint(_L("CDunServerUtils::TryUninitialize()")));
+    if ( aIndex < 0 ||
+         aIndex >= iConnData.Count() )
+        {
+        FTRACE(FPrint(_L("CDunServerUtils::TryUninitialize() (not found) complete")));
+        return KErrNotFound;
+        }
+    if ( iConnData[aIndex].iPluginState == EDunStateUninitialized )
+        {
+        FTRACE(FPrint(_L("CDunServerUtils::TryUninitialize() (already uninitialized) complete")));
+        return KErrNotReady;
+        }
+    FTRACE(FPrint(_L("CDunServerUtils::TryUninitialize() notifying server state change (%d)"), EDunStateTryUninitialize));
+    TInt retTemp =
+        iConnData[aIndex].iLocalModulePtr->NotifyServerStateChange( EDunStateTryUninitialize );
+    if ( retTemp != KErrNone )
+        {
+        iConnData[aIndex].iPluginState = EDunStateZombie;
+        FTRACE(FPrint(_L("CDunServerUtils::TryUninitialize() state changed to %d"), EDunStateZombie));
+        FTRACE(FPrint(_L("CDunServerUtils::TryUninitialize() (ERROR) complete")));
+        return retTemp;
+        }
+    // Plugin state must be EDunStateLoaded after uninitialization
+    if ( iConnData[aIndex].iPluginState == EDunStateLoaded )
+        {
+        iConnData[aIndex].iPluginState = EDunStateUninitialized;
+        FTRACE(FPrint(_L("CDunServerUtils::TryUninitialize() state changed to %d"), EDunStateUninitialized));
+        }
+    else
+        {
+        // Should never come here
+        iConnData[aIndex].iPluginState = EDunStateZombie;
+        FTRACE(FPrint(_L("CDunServerUtils::TryUninitialize() state changed to %d"), EDunStateZombie));
+        }
+    FTRACE(FPrint(_L("CDunServerUtils::TryUninitialize() complete")));
+    return KErrNone;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/server/src/DunSession.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,195 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The session object for DUN server
+*
+*/
+
+
+#include <e32std.h>
+#include <c32comm.h>
+#include <f32file.h>
+#include <e32math.h>
+#include <locodbearer.h>
+#include <btfeaturescfg.h>
+#include "dunserverdef.h"
+#include "DunSession.h"
+#include "DunServer.h"
+#include "DunPlugin.h"
+#include "DunDebug.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CDunSession::CDunSession
+// ---------------------------------------------------------------------------
+//
+CDunSession::CDunSession( CDunServer* aDunServer ) :
+    CSession2(),
+    iDunServer( aDunServer )
+    {
+    FTRACE(FPrint( _L( "CDunSession::CDunSession()") ));
+    iDunServer->IncRefCount();
+    FTRACE(FPrint( _L( "CDunSession::CDunSession() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunSession::~CDunSession()
+    {
+    FTRACE(FPrint(_L("CDunSession::~CDunSession()")));
+    if ( iDunServer )
+        {
+        iDunServer->DecRefCount();
+        iDunServer = NULL;
+        }
+    FTRACE(FPrint(_L("CDunSession::~CDunSession() complete")));
+    }
+
+// ---------------------------------------------------------------------------
+// Return the version number
+// ---------------------------------------------------------------------------
+//
+TVersion CDunSession::Version(void) const
+    {
+    return (TVersion( KDunServerMajorVersionNumber,
+                      KDunServerMinorVersionNumber,
+                      KDunServerBuildVersionNumber ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CSession2.
+// Handles the servicing of client requests passed to the server
+// ---------------------------------------------------------------------------
+//
+void CDunSession::ServiceL( const RMessage2& aMessage )
+    {
+    FTRACE(FPrint(_L("CDunSession::ServiceL()")));
+    TBool hasCapability = aMessage.HasCapability( ECapabilityLocalServices );
+    if ( !hasCapability )
+        {
+        aMessage.Complete( KErrPermissionDenied );
+        FTRACE(FPrint(_L("CDunSession::ServiceL() (no capability) complete")));
+        return;
+        }
+    TInt retVal = KErrNotSupported;
+    switch ( aMessage.Function() )
+        {
+        case EDunFuncManageService:
+            retVal = DoService( aMessage );
+            break;
+        case EDunFuncActiveConnection:
+            retVal = DoTestService( aMessage );
+            break;
+        default:
+            FTRACE(FPrint(_L("CDunSession::ServiceL() (not supported) complete")));
+            break;
+        }
+    aMessage.Complete( retVal );
+    FTRACE(FPrint(_L("CDunSession::ServiceL() complete")));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CSession2.
+// Return a reference to DUN server
+// ---------------------------------------------------------------------------
+//
+CDunServer& CDunSession::Server() const
+    {
+    return *iDunServer;
+    }
+
+// ---------------------------------------------------------------------------
+// Handles incoming service messages
+// ---------------------------------------------------------------------------
+//
+TInt CDunSession::DoService( const RMessage2& aMessage )
+    {
+    FTRACE(FPrint(_L("CDunSession::DoService()")));
+    if ( !iDunServer )
+        {
+        FTRACE(FPrint(_L("CDunSession::DoService() (iDunServer) not initialized!")));
+        return KErrGeneral;
+        }
+
+    TLocodBearer bearer = static_cast<TLocodBearer>( aMessage.Int0() );
+    TBool bearerStatus = static_cast<TBool>( aMessage.Int1() );
+
+    TUid pluginUid;
+    switch ( bearer )
+        {
+        case ELocodBearerBT:
+			{
+            pluginUid = KDunBtPluginUid;
+            FTRACE(FPrint(_L("CDunSession::DoService() Managing service for BT, bearer status %d"), bearerStatus));
+			
+			BluetoothFeatures::TEnterpriseEnablementMode mode = BluetoothFeatures::EDisabled;
+			TRAPD(err, mode = BluetoothFeatures::EnterpriseEnablementL());
+			if ( err )
+				{
+				FTRACE(FPrint(_L("CDunSession::DoService() complete: failed to get BluetoothFeatures::EnterpriseEnablementL")));
+				return err;
+				}
+			if ( mode != BluetoothFeatures::EEnabled )
+				{
+				FTRACE(FPrint(_L("CDunSession::DoService() complete: !BluetoothFeatures::EEnabled")));
+				return KErrNotSupported;
+				}
+			}
+            break;
+        case ELocodBearerIR:
+            pluginUid = KDunIrPluginUid;
+            FTRACE(FPrint(_L("CDunSession::DoService() Managing service for IR, bearer status %d"), bearerStatus));
+            break;
+        case ELocodBearerUSB:
+            pluginUid = KDunUsbPluginUid;
+            FTRACE(FPrint(_L("CDunSession::DoService() Managing service for USB, bearer status %d"), bearerStatus));
+            break;
+        default:
+            FTRACE(FPrint(_L("CDunSession::DoService() Unknown service %d, bearer status %d!"), bearer, bearerStatus));
+            return KErrNotSupported;
+        }
+    TInt retVal = KErrNone;
+    if ( bearerStatus )  // ON
+        {
+        retVal = iDunServer->NotifyMediaOpenRequest( pluginUid );
+        }
+    else  // OFF
+        {
+        retVal = iDunServer->NotifyMediaCloseRequest( pluginUid );
+        }
+    FTRACE(FPrint(_L("CDunSession::DoService() complete")));
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// Handles incoming test service messages
+// ---------------------------------------------------------------------------
+//
+TInt CDunSession::DoTestService( const RMessage2& aMessage )
+    {
+    FTRACE(FPrint(_L("CDunSession::DoTestService()")));
+    if ( !iDunServer )
+        {
+        FTRACE(FPrint(_L("CDunSession::DoTestService() (iDunServer) not initialized!")));
+        return KErrGeneral;
+        }
+    TConnId connId = iDunServer->ActiveConnection();
+    TPckgBuf<TConnId> connIdPckg( connId );
+    aMessage.Write( 0, connIdPckg );  // First argument in EDunFuncActiveConnection
+    FTRACE(FPrint(_L("CDunSession::DoTestService() complete")));
+    return KErrNone;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/bwins/dunutilsu.def	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,26 @@
+EXPORTS
+	?NewL@CDunTransporter@@SAPAV1@PAVMDunPluginManager@@H@Z @ 1 NONAME ; class CDunTransporter * CDunTransporter::NewL(class MDunPluginManager *, int)
+	?NumberOfAllocatedChannels@CDunTransporter@@QAEHXZ @ 2 NONAME ; int CDunTransporter::NumberOfAllocatedChannels(void)
+	?AllocateChannelL@CDunTransporter@@QAEXPAVRComm@@VTUid@@ABVTDesC8@@HPAVMDunBufferCorrection@@@Z @ 3 NONAME ; void CDunTransporter::AllocateChannelL(class RComm *, class TUid, class TDesC8 const &, int, class MDunBufferCorrection *)
+	?SetAdvertisementMonitorL@CDunTransporter@@QAEXVTUid@@PAVMDunServAdvMon@@@Z @ 4 NONAME ; void CDunTransporter::SetAdvertisementMonitorL(class TUid, class MDunServAdvMon *)
+	?InitializeL@CDunTransporter@@AAEHXZ @ 5 NONAME ; int CDunTransporter::InitializeL(void)
+	?AllocateChannelL@CDunTransporter@@QAEXPAVRSocket@@VTUid@@ABVTDesC8@@HAAH@Z @ 6 NONAME ; void CDunTransporter::AllocateChannelL(class RSocket *, class TUid, class TDesC8 const &, int, int &)
+	?GetNumberOfAllocatedChannelsByUid@CDunTransporter@@QAEHVTUid@@@Z @ 7 NONAME ; int CDunTransporter::GetNumberOfAllocatedChannelsByUid(class TUid)
+	?FreeChannel@CDunTransporter@@QAEHPAVRComm@@@Z @ 8 NONAME ; int CDunTransporter::FreeChannel(class RComm *)
+	?FreeChannel@CDunTransporter@@QAEHPAVRSocket@@@Z @ 9 NONAME ; int CDunTransporter::FreeChannel(class RSocket *)
+	?FreeAdvertisementMonitor@CDunTransporter@@QAEHVTUid@@PAVMDunServAdvMon@@@Z @ 10 NONAME ; int CDunTransporter::FreeAdvertisementMonitor(class TUid, class MDunServAdvMon *)
+	?GetNumberOfWaitingChannelsByUid@CDunTransporter@@QAEHVTUid@@@Z @ 11 NONAME ; int CDunTransporter::GetNumberOfWaitingChannelsByUid(class TUid)
+	?StopTransfers@CDunTransporter@@QAEHPAVRComm@@@Z @ 12 NONAME ; int CDunTransporter::StopTransfers(class RComm *)
+	?NumberOfWaitingChannels@CDunTransporter@@QAEHXZ @ 13 NONAME ; int CDunTransporter::NumberOfWaitingChannels(void)
+	?AddSkippedErrorL@CDunTransporter@@QAEXHPAVRComm@@W4TDunDirection@@@Z @ 14 NONAME ; void CDunTransporter::AddSkippedErrorL(int, class RComm *, enum TDunDirection)
+	?ConnectCommsServer@CDunUtils@@SAHAAVRCommServ@@@Z @ 15 NONAME ; int CDunUtils::ConnectCommsServer(class RCommServ &)
+	?IssueTransferRequestsL@CDunTransporter@@QAEXPAVRSocket@@@Z @ 16 NONAME ; void CDunTransporter::IssueTransferRequestsL(class RSocket *)
+	?AddConnMonCallbackL@CDunTransporter@@QAEXPAVRSocket@@PAVMDunConnMon@@W4TDunDirection@@H@Z @ 17 NONAME ; void CDunTransporter::AddConnMonCallbackL(class RSocket *, class MDunConnMon *, enum TDunDirection, int)
+	?UnInitialize@CDunTransporter@@AAEXXZ @ 18 NONAME ; void CDunTransporter::UnInitialize(void)
+	?StopTransfers@CDunTransporter@@QAEHPAVRSocket@@@Z @ 19 NONAME ; int CDunTransporter::StopTransfers(class RSocket *)
+	?AddSkippedErrorL@CDunTransporter@@QAEXHPAVRSocket@@W4TDunDirection@@@Z @ 20 NONAME ; void CDunTransporter::AddSkippedErrorL(int, class RSocket *, enum TDunDirection)
+	?AddConnMonCallbackL@CDunTransporter@@QAEXPAVRComm@@PAVMDunConnMon@@W4TDunDirection@@H@Z @ 21 NONAME ; void CDunTransporter::AddConnMonCallbackL(class RComm *, class MDunConnMon *, enum TDunDirection, int)
+	?IssueTransferRequestsL@CDunTransporter@@QAEXPAVRComm@@@Z @ 22 NONAME ; void CDunTransporter::IssueTransferRequestsL(class RComm *)
+	?SetRCommBufferLength@CDunUtils@@SAHAAVRComm@@H@Z @ 23 NONAME ; int CDunUtils::SetRCommBufferLength(class RComm &, int)
+	?AdvertisementStatus@CDunTransporter@@QAEHXZ @ 24 NONAME ; int CDunTransporter::AdvertisementStatus(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/data/dunutils.rss	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource definitions for project DUN
+*
+*/
+
+
+NAME DUNX
+
+#include <eikon.rh>
+#include <dunutils.loc>
+
+RESOURCE RSS_SIGNATURE { }
+RESOURCE TBUF r_dun_maximum_dialups { buf=qtn_dun_max_number; }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/eabi/dunutilsu.def	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,26 @@
+EXPORTS
+	_ZN15CDunTransporter11FreeChannelEP5RComm @ 1 NONAME
+	_ZN15CDunTransporter11FreeChannelEP7RSocket @ 2 NONAME
+	_ZN15CDunTransporter11InitializeLEv @ 3 NONAME
+	_ZN15CDunTransporter12UnInitializeEv @ 4 NONAME
+	_ZN15CDunTransporter13StopTransfersEP5RComm @ 5 NONAME
+	_ZN15CDunTransporter13StopTransfersEP7RSocket @ 6 NONAME
+	_ZN15CDunTransporter16AddSkippedErrorLEiP5RComm13TDunDirection @ 7 NONAME
+	_ZN15CDunTransporter16AddSkippedErrorLEiP7RSocket13TDunDirection @ 8 NONAME
+	_ZN15CDunTransporter16AllocateChannelLEP5RComm4TUidRK6TDesC8iP20MDunBufferCorrection @ 9 NONAME
+	_ZN15CDunTransporter16AllocateChannelLEP7RSocket4TUidRK6TDesC8iRi @ 10 NONAME
+	_ZN15CDunTransporter19AddConnMonCallbackLEP5RCommP11MDunConnMon13TDunDirectioni @ 11 NONAME
+	_ZN15CDunTransporter19AddConnMonCallbackLEP7RSocketP11MDunConnMon13TDunDirectioni @ 12 NONAME
+	_ZN15CDunTransporter19AdvertisementStatusEv @ 13 NONAME
+	_ZN15CDunTransporter22IssueTransferRequestsLEP5RComm @ 14 NONAME
+	_ZN15CDunTransporter22IssueTransferRequestsLEP7RSocket @ 15 NONAME
+	_ZN15CDunTransporter23NumberOfWaitingChannelsEv @ 16 NONAME
+	_ZN15CDunTransporter24FreeAdvertisementMonitorE4TUidP14MDunServAdvMon @ 17 NONAME
+	_ZN15CDunTransporter24SetAdvertisementMonitorLE4TUidP14MDunServAdvMon @ 18 NONAME
+	_ZN15CDunTransporter25NumberOfAllocatedChannelsEv @ 19 NONAME
+	_ZN15CDunTransporter31GetNumberOfWaitingChannelsByUidE4TUid @ 20 NONAME
+	_ZN15CDunTransporter33GetNumberOfAllocatedChannelsByUidE4TUid @ 21 NONAME
+	_ZN15CDunTransporter4NewLEP17MDunPluginManageri @ 22 NONAME
+	_ZN9CDunUtils18ConnectCommsServerER9RCommServ @ 23 NONAME
+	_ZN9CDunUtils20SetRCommBufferLengthER5RCommi @ 24 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*	 This file provides the information required for building the
+*    whole of DUN utilities
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+../../rom/dunutils.iby         CORE_MW_LAYER_IBY_EXPORT_PATH(dunutils.iby)
+../../rom/dunresources.iby     LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(dunresources.iby)
+../loc/dunutils.loc            MW_LAYER_LOC_EXPORT_PATH(dunutils.loc)
+
+PRJ_MMPFILES
+dunutils.mmp
+
+PRJ_TESTMMPFILES
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/group/dunutils.mmp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,88 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project DUN utilities
+*
+*/
+
+
+// Define the following flag to enable network side logging.
+// This makes it possible to test AT commands with idle Telephony/RComm.
+// Note that because RComm is a stub the only way to test the connection
+// is via RSocket (Bluetooth).
+
+#undef ENABLE_NETWORK_STUBS
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+#ifdef ENABLE_NETWORK_STUBS
+MACRO PRJ_USE_NETWORK_STUBS
+#define PRJ_USE_NETWORK_STUBS
+#endif  // ENABLE_NETWORK_STUBS
+
+TARGET                  dunutils.dll
+TARGETTYPE              DLL
+UID                     0x1000008d 0x101F6E2A
+
+CAPABILITY              CAP_GENERAL_DLL
+VENDORID                VID_DEFAULT
+
+SOURCEPATH              ../src
+SOURCE                  DunStream.cpp
+SOURCE                  DunUpstream.cpp
+SOURCE                  DunDownstream.cpp
+SOURCE                  DunSignalCopy.cpp
+SOURCE                  DunSignalNotify.cpp
+SOURCE                  DunSignalWaiter.cpp
+SOURCE                  DunDataWaiter.cpp
+SOURCE                  DunNetDataport.cpp
+SOURCE                  DunTransUtils.cpp
+SOURCE                  DunTransporter.cpp
+SOURCE                  DunChanMan.cpp
+SOURCE                  DunDataPusher.cpp
+SOURCE                  DunNoteHandler.cpp
+SOURCE                  DunUtils.cpp
+
+START RESOURCE          ../data/dunutils.rss
+TARGETPATH              RESOURCE_FILES_DIR
+HEADER
+LANGUAGE_IDS
+END // RESOURCE
+
+USERINCLUDE             ../inc ../../atext/inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+// Note:
+// The only other SYSTEMINCLUDE should you shall add are Symbian specific ones.
+// If there is a S60 header in the subdirectory then that should be
+// added into the include statements (like #include <phonebook/header.h>)
+//SYSTEMINCLUDE           /epoc32/include/ecom
+SYSTEMINCLUDE           ../../../inc
+
+LIBRARY                 aknnotify.lib
+LIBRARY                 bafl.lib
+#ifdef PRJ_USE_NETWORK_STUBS
+LIBRARY                 c32comm_stub.lib
+LIBRARY                 etelmm_stub.lib
+#else
+LIBRARY                 c32.lib
+LIBRARY                 etel.lib
+LIBRARY                 etelmm.lib
+#endif
+LIBRARY                 esock.lib
+LIBRARY                 dunatext.lib
+LIBRARY                 efsrv.lib
+LIBRARY                 euser.lib
+DEBUGLIBRARY            flogger.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/inc/DunChanMan.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,407 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  RComm channel management related functionality (waiter)
+*
+*/
+
+
+#ifndef C_CDUNCHANMAN_H
+#define C_CDUNCHANMAN_H
+
+#include "DunTransUtils.h"
+#include "DunTransporter.h"
+
+class CDunSignalWaiter;
+class CDunDataWaiter;
+
+/**
+ *  Class for CDunDataWaiter's and CDunSignalWaiter's connection monitoring
+ *  support
+ *  When CDunDataWaiter or CDunSignalWaiter detects activity, data in this
+ *  class is used as helper data to create subsequent calls to
+ *  CDunTransporter::AddConnMonCallbackL
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( TDunConnMonCallback )
+    {
+
+public:
+
+    /**
+     * Callback to call when notification via MDunConnMon to be made
+     * (CDunTransporter::AddConnMonCallbackL, aCallback parameter)
+     * Not own.
+     */
+    MDunConnMon* iCallback;
+
+    /**
+     * Direction where to add connection monitor
+     * (CDunTransporter::AddConnMonCallbackL, aDirection parameter)
+     */
+    TDunDirection iDirection;
+
+    };
+
+/**
+ *  Class for CDunDataWaiter's and CDunSignalWaiter's connection monitoring
+ *  support
+ *  When CDunConnWaiter or CDunSignalWaiter detects activity, data in this
+ *  class is used as helper data to create subsequent calls to
+ *  CDunTransporter::AddSkippedErrorL
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( TDunSkippedError )
+    {
+
+public:
+
+    /**
+     * Error code of read/write condition that should be skipped
+     * (CDunTransporter::AddSkippedErrorL, aError parameter)
+     */
+    TInt iError;
+
+    /**
+     * Direction of read/write error condition
+     * (CDunTransporter::AddSkippedErrorL, aDirection parameter)
+     */
+    TDunDirection iDirection;
+
+    };
+
+/**
+ *  Class for CDunDataWaiter's or CDunSignalWaiter's connection monitoring
+ *  support
+ *  When CDunDataWaiter or CDunSignalWaiter detects activity, data in this
+ *  class is used as helper
+ *  data to create subsequent calls to the following APIs
+ *  CDunTransporter::AddConnMonCallbackL
+ *  CDunTransporter::AddSkippedErrorL
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( TDunWaiterData )
+    {
+
+public:
+
+    /**
+     * RComm object of local media side
+     * Not own.
+     */
+    RComm* iComm;
+
+    /**
+     * Name for the channel
+     */
+    HBufC8* iChannelName;
+
+    /**
+     * Signal waiter object for a channel
+     * Not own.
+     */
+    CDunSignalWaiter* iSignalWaiter;
+
+    /**
+     * Data waiter object for a channel
+     * Not own.
+     */
+    CDunDataWaiter* iDataWaiter;
+
+    /**
+     * Pointer to object implementing buffer correction
+     * Not own.
+     */
+    MDunBufferCorrection* iCorrection;
+
+    /**
+     * Connection monitor raw data that will be added to TDunChannelData array
+     * after activity detected by iDataWaiter or iSignalWaiter
+     */
+    RArray<TDunConnMonCallback> iConnMons;
+
+    /**
+     * Skipped error raw data that will be added to TDunChannelData array
+     * after activity detected by iDataWaiter or iSignalWaiter
+     */
+    RArray<TDunSkippedError> iOkErrors;
+
+    /**
+     * Flag to indicate whether enqueued channel allocation required.
+     * Second option is to use service advertisement API.
+     */
+    TBool iEnqueuedFail;
+
+    /**
+     * UID of plugin that allocated this channel
+     * Used for making notification via MDunPluginManager callback
+     * Added to TDunChannelData array after activity detected by iDataWaiter
+     */
+    TUid iOwnerUid;
+
+    };
+
+/**
+ *  Notification interface class for creating new channel
+ *  Used by CDunDataWaiter ro CDunSignalWaiter to create new channel when
+ *  activity is detected
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( MDunChannelAllocator )
+    {
+
+public:
+
+    /**
+     * CDunTransporter callback: gets called when waiter wants new channel
+     *
+     * @since S60 3.2
+     * @param aComm Connection where new data exists
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt NotifyNewChannelRequest( RComm* aComm ) = 0;
+
+    };
+
+/**
+ *  Class for RComm channel management related functionality (waiter)
+ *  activity is detected by CDunDataWaiter or CDunSignalWaiter objects
+ *  Also takes care of waiter object creation.
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CDunChanMan ) : public CBase,
+                                   public MDunChannelAllocator
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aParent Parent class owning this friend class (CDunTransporter)
+     * @param aUtility Pointer to common utility class
+     * @param aUtilityAux Pointer to other than CDunTransporter utility class
+     * @param aPluginManager Callback to call when notification via
+     *                       MDunPluginManager to be made
+     * @return Instance of self
+     */
+	static CDunChanMan* NewL( CDunTransporter& aParent,
+	                          MDunTransporterUtility* aUtility,
+	                          MDunTransporterUtilityAux* aUtilityAux,
+	                          MDunPluginManager* aPluginManager );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunChanMan();
+
+    /**
+     * Resets data to initial values
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void ResetData();
+
+    /**
+     * Number of waiters
+     *
+     * @since S60 3.2
+     * @return Number of waiters
+     */
+    TInt NumberOfWaiters();
+
+    /**
+     * Gets number of waiters by owner UID
+     *
+     * @since S60 5.0
+     * @param aOwnerUid UID of the channel owner
+     * @return Number of waiters
+     */
+    TInt GetNumberOfWaitersByUid( TUid aOwnerUid );
+
+    /**
+     * Adds new connection waiter to connection waiter array
+     *
+     * @since S60 3.2
+     * @param aComm Pointer to opened local media RComm ID object
+     * @param aOwnerUid UID of the channel owner
+     * @param aName Name for the channel
+     * @param aEnqueuedFail ETrue if enqueued failure, EFalse otherwise
+     * @param aCorrection Pointer to object implementing buffer correction
+     * @return None
+     */
+    void AddConnWaiterL( RComm* aComm,
+                         TUid aOwnerUid,
+                         const TDesC8& aName,
+                         TBool aEnqueuedFail,
+                         MDunBufferCorrection* aCorrection );
+
+    /**
+     * Removes existing waiter from connection waiter array
+     *
+     * @since S60 3.2
+     * @param aComm Pointer to opened local media RComm ID object
+     * @return KErrNotFound if waiter not found, KErrNone if removed
+     */
+    TInt RemoveConnWaiter( RComm* aComm );
+
+    /**
+     * Makes CDunDataWaiter and CDunSignalWaiter ready to detect activity
+     *
+     * @since S60 3.2
+     * @param aComm Pointer to opened local media RComm ID object
+     * @return KErrNotFound if waiter not found, KErrNone if request issued
+     */
+    TInt IssueConnWaiterRequest( RComm* aComm );
+
+    /**
+     * Stops CDunDataWaiter and CDunSignalWaiter to detect new data
+     *
+     * @since S60 3.2
+     * @param aComm Pointer to opened local media RComm ID object
+     * @return KErrNotFound if waiter not found, KErrNone if stopped
+     */
+    TInt StopConnWaiter( RComm* aComm );
+
+    /**
+     * Saves waiter's connection monitor callback data
+     *
+     * @since S60 3.2
+     * @param aComm Pointer to opened local media RComm ID object
+     * @param aCallback Pointer to object whose callbacks will be called
+     * @param aDirection Direction of operation to monitor for read/write
+     *                   error
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt SaveWaiterConnMonCallbackL( RComm* aComm,
+                                     MDunConnMon* aCallback,
+                                     TDunDirection aDirection );
+
+    /**
+     * Saves waiter's skipped error data
+     *
+     * @since S60 3.2
+     * @param aError Error code to consider as "no error"
+     * @param aComm Pointer to opened local media RComm ID object
+     * @param aDirection One of four data transfer endpoints where to add a
+     *                   skipped error code
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt SaveWaiterSkippedErrorL( TInt aError,
+                                  RComm* aComm,
+                                  TDunDirection aDirection );
+
+private:
+
+    CDunChanMan( CDunTransporter& aParent,
+                 MDunTransporterUtility* aUtility,
+                 MDunTransporterUtilityAux* aUtilityAux,
+                 MDunPluginManager* aPluginManager );
+
+    void ConstructL();
+
+    /**
+     * Initializes this class
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void Initialize();
+
+     /**
+      * Fills data for channel created by waiter
+      *
+      * @since S60 3.2
+      * @param aComm Pointer to opened local media RComm ID object
+      * @param aFirstFree Index to first free channel
+      * @return Symbian error code on error, KErrNone otherwise
+      */
+    TInt FillNewWaiterChannelData(RComm* aComm, TInt aFirstFree);
+
+    /**
+     * Restores saved waiter data to connection data
+     *
+     * @since S60 3.2
+     * @param aWaiterIndex Index to waiter data
+     * @param aChannelIndex Index to connection data
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt RestoreWaiterData( TInt aWaiterIndex, TInt aChannelIndex );
+
+    /**
+     * Deletes waiter objects of aIndex:th waiters
+     *
+     * @since S60 3.2
+     * @param aIndex Index of waiters to delete
+     * @param aNewOwnership ETrue if ownership transferred, EFalse otherwise
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt DeleteWaiters( TInt aIndex, TBool aNewOwnership=EFalse );
+
+// from base class MDunChannelAllocator
+
+    /**
+     * From MDunChannelAllocator.
+     * Notifies when new channel is wanted
+     *
+     * @since S60 3.2
+     * @param aComm Connection where new data exists
+     * @return KErrNone
+     */
+    TInt NotifyNewChannelRequest( RComm* aComm );
+
+private:  // data
+
+    /**
+     * Parent class owning this friend class (CDunTransporter)
+     */
+    CDunTransporter& iParent;
+
+    /**
+     * Pointer to common utility class
+     * Not own.
+     */
+    MDunTransporterUtility* iUtility;
+
+    /**
+     * Pointer to other than CDunTransporter utility class
+     * Not own.
+     */
+    MDunTransporterUtilityAux* iUtilityAux;
+
+    /**
+     * Callback to call when notification via MDunPluginManager to be made
+     * Not own.
+     */
+    MDunPluginManager* iPluginManager;
+
+    /**
+     * Waiter's data that will be added to iChannelData when waiter detects
+     * read activity. After copying to iChannelData the data will be removed
+     * from this array.
+     */
+    RArray<TDunWaiterData> iWaiterData;
+
+    };
+
+#endif  // C_CDUNCHANMAN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/inc/DunDataPusher.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,284 @@
+/*
+* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Pushes data to existing stream from outside
+*
+*/
+
+
+#ifndef C_CDUNDATAPUSHER_H
+#define C_CDUNDATAPUSHER_H
+
+#include "DunTransporter.h"
+
+class MDunCompletionReporter;
+
+/**
+ *  Class used for storing data related to data push
+ *  (data coming from MDunStreamManipulator::NotifyDataPushRequest())
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( TDunDataPush )
+    {
+
+public:
+
+    /**
+     * Data to push to the stream (not copied)
+     */
+    const TDesC8 *iPushedData;
+
+    /**
+     * Callback to call when data is processed by the stream
+     * If this is NULL then no callback will be made
+     */
+    MDunCompletionReporter* iCallback;
+
+    };
+
+/**
+ *  Class for notifications of stream manipulator's completion events
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( MDunCompletionReporter )
+    {
+
+public:
+
+    /**
+     * Gets called when data from
+     * MDunStreamManipulator::NotifyDataPushRequest() has been processed and
+     * CDunDownstream is ready to process more data.
+     *
+     * @since S60 5.0
+     * @param aAllPushed ETrue if all in the queue were pushed, EFalse otherwise
+     * @return None
+     */
+    virtual void NotifyDataPushComplete( TBool aAllPushed ) = 0;
+
+    };
+
+/**
+ *  Class for pushing data to existing CDunDownstream stream from outside
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CDunDataPusher ) : public CActive
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aParent Parent class owning this friend class (CDunDownstream)
+     * @param aStreamCallback Callback to call when events processed
+     * @return Instance of self
+     */
+	static CDunDataPusher* NewL( CDunDownstream& aParent,
+	                             MDunCompletionReporter* aStreamCallback );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunDataPusher();
+
+    /**
+     * Resets data to initial values
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void ResetData();
+
+    /**
+     * Sets media to be used for this endpoint
+     *
+     * @since S60 3.2
+     * @param aComm RComm pointer to use as the endpoint
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt SetMedia( RComm* aComm );
+
+    /**
+     * Sets media to be used for this endpoint
+     *
+     * @since S60 3.2
+     * @param aSocket RSocket pointer to use as the endpoint
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt SetMedia( RSocket* aSocket );
+
+    /**
+     * Adds event notification to queue
+     *
+     * @since S60 3.2
+     * @param aPushedData Data to push to the stream (not copied)
+     * @param aCallback Callback to call when data is processed by the stream
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt AddToEventQueue( const TDesC8 *aPushedData,
+                          MDunCompletionReporter* aCallback );
+
+    /**
+     * Finds an event from queue
+     *
+     * @since S60 5.0
+     * @param aPushedData Data to push to the stream (not copied)
+     * @return Index of found event, Symbian error code otherwise
+     */
+    TInt FindEventFromQueue( const TDesC8 *aPushedData );
+
+    /**
+     * Stops one event in the event queue
+     *
+     * @since S60 5.0
+     * @param aPushedData Data to push to the stream (not copied)
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt StopOneEvent( const TDesC8 *aPushedData );
+
+    /**
+     * Sends queued data in round robin
+     *
+     * @since S60 3.2
+     * @return ETrue if sending started, EFalse if nothing to do
+     */
+    TBool SendQueuedData();
+
+    /**
+     * Stops sending for write endpoint
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt Stop();
+
+    /**
+     * Stops sending for write endpoint and clears event queue
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt StopAndClearQueue();
+
+    /**
+     * Signals completion status in round robin and clears event queue
+     *
+     * @return Symbian error code on error, KErrNone otherwise
+     * @return None
+     */
+    TInt SignalCompletionAndClearQueue();
+
+private:
+
+    CDunDataPusher( CDunDownstream& aParent,
+                    MDunCompletionReporter* aStreamCallback );
+
+    void ConstructL();
+
+    /**
+     * Initializes this class
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void Initialize();
+
+    /**
+     * Manages one event's data push
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    TInt ManageOneEvent();
+
+    /**
+     * Check whether an error code is severe error or not
+     *
+     * @since S60 3.2
+     * @param aError Error code to check for severity
+     * @param aIsError ETrue if error code is error, EFalse if not error
+     * @return ETrue if severe error detected, EFalse if not severe error
+     */
+    TBool ProcessErrorCondition( TInt aError, TBool& aIsError );
+
+// from base class CActive
+
+    /**
+     * From CActive.
+     * Gets called when endpoint data write complete
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void RunL();
+
+    /**
+     * From CActive.
+     * Gets called on cancel
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void DoCancel();
+
+private:  // data
+
+    /**
+     * Parent class owning this friend class (CDunDownstream)
+     */
+    CDunDownstream& iParent;
+
+    /**
+     * Callback to call when notification via MDunCompletionReporter to be made
+     * Not own.
+     */
+    MDunCompletionReporter* iStreamCallback;
+
+    /**
+     * Event queue for pushed data requests
+     */
+    RArray<TDunDataPush> iEventQueue;
+
+    /**
+     * Current state of data push: active or inactive
+     */
+    TDunState iPushState;
+
+    /**
+     * Index of current event to serve
+     */
+    TInt iEventIndex;
+
+    /**
+     * RSocket object of local media side
+     * If this is set then iComm is not used
+     * Not own.
+     */
+    RSocket* iSocket;
+
+    /**
+     * RComm object of local media or network side
+     * If this is set then iSocket is not used
+     * Not own.
+     */
+    RComm* iComm;
+
+    };
+
+#endif  // C_DUNDATAPUSHER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/inc/DunDataWaiter.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,156 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Monitors for new data in RComm local media side
+*
+*/
+
+
+#ifndef C_CDUNDATAWAITER_H
+#define C_CDUNDATAWAITER_H
+
+#include "DunChanMan.h"
+
+/**
+ *  Class to monitor for new data in RComm local media side
+ *  This class is needed to avoid unnecessary resource allocation of Dataport
+ *  side when number of supported Dataport ports for DUN is less than the
+ *  number of local media side plugins that use RComm
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CDunDataWaiter ) : public CActive
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aChannelCallback Callback to call when notification via
+     *                         MDunChannelAllocator to be made
+     * @return Instance of self
+     */
+	static CDunDataWaiter* NewL( MDunChannelAllocator* aChannelCallback );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunDataWaiter();
+
+    /**
+     * Resets data to initial values
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void ResetData();
+
+    /**
+     * Adds callback for RunL error controlling
+     * The callback will be called when error is detected in asynchronous
+     * operation
+     *
+     * @since S60 3.2
+     * @param aCallback Callback to call when line status changes
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt AddCallback( MDunConnMon* aCallback );
+
+    /**
+     * Sets media to use for this endpoint
+     *
+     * @since S60 3.2
+     * @param aComm RComm pointer to use as the endpoint
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt SetMedia( RComm* aComm );
+
+    /**
+     * Issues request to start waiting for new data in RComm
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt IssueRequest();
+
+    /**
+     * Stops monitoring for new data
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt Stop();
+
+private:
+
+    CDunDataWaiter( MDunChannelAllocator* aChannelCallback );
+
+    void ConstructL();
+
+    /**
+     * Initializes this class
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void Initialize();
+
+// from base class CActive
+
+    /**
+     * From CActive.
+     * Gets called when new data in RComm object
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void RunL();
+
+    /**
+     * From CActive.
+     * Gets called on cancel
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void DoCancel();
+
+private:  // data
+
+    /**
+     * Callback(s) to call when notification(s) via MDunConnMon to be made
+     * Normally contains only one callback
+     */
+    RPointerArray<MDunConnMon> iCallbacks;
+
+    /**
+     * Callback to call when notification via MDunChannelAllocator to be made
+     * Not own.
+     */
+    MDunChannelAllocator* iChannelCallback;
+
+    /**
+     * Current state of data monitoring: active or inactive
+     */
+    TDunState iDataWaiterState;
+
+    /**
+     * RComm object of local media side
+     * Not own.
+     */
+    RComm* iComm;
+
+    };
+
+#endif  // C_CDUNDATAWAITER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/inc/DunDebug.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,107 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Common debug functionality for this component
+*
+*/
+
+
+#ifndef DUN_DEBUG_H
+#define DUN_DEBUG_H
+
+_LIT( KComponentName, "[DUN] " );
+
+//#define FILE_LOGGING
+
+#ifdef _DEBUG
+
+#ifdef FILE_LOGGING
+
+#include <e32std.h>
+#include <f32file.h>
+#include <flogger.h>
+
+#define FTRACE(a)    {a;}
+
+_LIT( KLogFile,"dun.txt" );
+_LIT( KLogDir, "dun" );
+_LIT( KLogDirFullName,"c:\\logs\\dun\\" );
+
+// Declare the FPrint function
+//
+inline void FPrint( const TRefByValue<const TDesC> aFmt, ... )
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list );
+    }
+
+inline void FPrintRaw( const TDesC8& /*aDes*/ )
+    {
+    }
+
+#else
+
+#include <e32svr.h>
+
+#define FTRACE(a)    {a;}
+
+/**
+Overflow handler for VA_LIST parsing into a fixed size buffer to
+be printed out using RDebug.
+*/
+NONSHARABLE_CLASS( TRDebugOverflowHander ) : public TDesOverflow
+{
+    /**
+    The function that will get called when the buffer is over-flowed.
+    In this case we just ignore the overflow, so the buffer will
+    effectively be truncated.
+    */
+    virtual void Overflow( TDes16& /*aDes*/ ) { return; }
+};
+
+/** The maximum length of a log line (in characters) output using RDebug. */
+const TUint KRDebugMaxLineLen = 0x100;
+
+// Declare the FPrint function
+//
+
+inline void FPrint( const TRefByValue<const TDesC> aFmt, ... )
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    TRDebugOverflowHander overflow;
+    TBuf<KRDebugMaxLineLen> buf;
+    TRefByValue<const TDesC> fmt = aFmt;
+    buf.Copy( KComponentName );
+    buf.AppendFormatList( fmt, list, &overflow );
+    RDebug::Print( buf );
+    }
+
+inline void FPrintRaw( const TDesC8& aDes )
+    {
+    RDebug::RawPrint( aDes );
+    }
+
+#endif // FILE_LOGGING
+
+// ===========================================================================
+#else // // No loggings --> Reduced binary size
+// ===========================================================================
+#define FTRACE( a )
+
+#endif // _DEBUG
+
+#endif  // DUN_DEBUG_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/inc/DunDownstream.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,258 @@
+/*
+* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definitions needed for one "stream" of CDunTransporter
+*
+*/
+
+
+#ifndef C_CDUNDOWNSTREAM_H
+#define C_CDUNDOWNSTREAM_H
+
+#include "DunTransUtils.h"
+#include "DunStream.h"
+#include "DunAtCmdHandler.h"
+#include "DunDataPusher.h"
+
+class MDunCompletionReporter;
+class MDunAtCmdHandler;
+
+/**
+ *  Class used for storing data related to data pushing
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( TDunPushData )
+    {
+
+public:
+
+    /**
+     * Flag for command mode notifier's MDunCmdModeMonitor callback
+     * This flag is needed to mark command mode start/end
+     */
+    TBool iDataMode;
+
+    /**
+     * Data pusher for stream manipulation
+     */
+    CDunDataPusher* iDataPusher;
+
+    /**
+     * AT command handling related functionality for CDunDownstream
+     * Not own.
+     */
+    MDunAtCmdHandler* iAtCmdHandler;
+
+    };
+
+/**
+ *  Class for manipulating existing stream's contents from outside
+ *  (outside of class CDunDownstream)
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( MDunStreamManipulator )
+    {
+
+public:
+
+    /**
+     * Gets called when outside party wants to push data to the existing stream
+     *
+     * @since S60 5.0
+     * @param aPushedData Data to push to the stream (not copied)
+     * @param aCallback Callback to call when data is processed by the stream
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt NotifyDataPushRequest(
+        const TDesC8 *aPushedData,
+        MDunCompletionReporter* aCallback ) = 0;
+
+    };
+
+/**
+ *  Class for data transmission of one "stream" from network to local media
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CDunDownstream ) : public CDunStream,
+                                      public MDunStreamManipulator,
+                                      public MDunCompletionReporter,
+                                      public MDunCmdModeMonitor
+    {
+
+    friend class CDunDataPusher;
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aUtility Pointer to common utility class
+     * @return Instance of self
+     */
+	static CDunDownstream* NewL( MDunTransporterUtilityAux* aUtility );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunDownstream();
+
+    /**
+     * Resets data to initial values
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void ResetData();
+
+    /**
+     * Starts downstream by issuing read request
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt StartStream();
+
+    /**
+     * Stops transfer for read or write endpoints
+     *
+     * @since S60 3.2
+     * @param aStopMplex ETrue if multiplexer stop, EFalse otherwise
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt Stop( TBool aStopMplex=ETrue );
+
+    /**
+     * Initializes this stream for data pushing
+     *
+     * @since S60 3.2
+     * @param aAtCmdHandler AT command handling related functionality
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt InitializeForDataPushing( MDunAtCmdHandler* aAtCmdHandler );
+
+    /**
+     * Adds data to event queue and starts sending if needed
+     *
+     * @since S60 5.0
+     * @param aPushedData Data to push to the stream (not copied)
+     * @param aCallback Callback to call when data is processed by the stream
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt AddToQueueAndSend( const TDesC8 *aPushedData,
+                            MDunCompletionReporter* aCallback );
+
+private:
+
+    CDunDownstream( MDunTransporterUtilityAux* aUtility );
+
+    void ConstructL();
+
+    /**
+     * Initializes this class
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void Initialize();
+
+    /**
+     * Issues transfer request for this stream
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt IssueRequest();
+
+// from base class CActive
+
+    /**
+     * From CActive.
+     * Gets called when endpoint data read complete
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void RunL();
+
+    /**
+     * From CActive.
+     * Gets called on cancel
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void DoCancel();
+
+// from base class MDunStreamManipulator
+
+    /**
+     * Gets called when outside party wants to push data to the existing stream
+     *
+     * @since S60 3.2
+     * @param aPushedData Data to push to the stream (not copied)
+     * @param aCallback Callback to call when data is processed by the stream
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt NotifyDataPushRequest( const TDesC8 *aPushedData,
+                                MDunCompletionReporter* aCallback );
+
+// from base class MDunCompletionReporter
+
+    /**
+     * Gets called when data push is complete
+     *
+     * @since S60 5.0
+     * @param aAllPushed ETrue if all in the queue were pushed, EFalse otherwise
+     * @return None
+     */
+    void NotifyDataPushComplete( TBool aAllPushed );
+
+// from base class MDunCmdModeMonitor
+
+    /**
+     * Notifies about command mode start
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void NotifyCommandModeStart();
+
+    /**
+     * Notifies about command mode end
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void NotifyCommandModeEnd();
+
+private:  // data
+
+    /**
+     * Pointer to common utility class
+     * Not own.
+     */
+    MDunTransporterUtilityAux* iUtility;
+
+    /**
+     * Data related to data pushing
+     */
+    TDunPushData iPushData;
+
+    };
+
+#endif  // C_CDUNDOWNSTREAM_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/inc/DunNetDataport.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,286 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Dataport specific network resource accessor implementation
+*
+*/
+
+
+#ifndef C_CDUNNETDATAPORT_H
+#define C_CDUNNETDATAPORT_H
+
+#include <e32base.h>
+#ifdef PRJ_USE_NETWORK_STUBS
+#include <c32comm_stub.h>
+#include <etelmm_stub.h>
+#else
+#include <etelmm.h>
+#endif
+
+/**
+ *  Class to store data needed for each separate "call"
+ *  One TDunDataportEntity entity contains objects needed for one network data
+ *  connection
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( TDunDataportEntity )
+    {
+
+public:
+
+    /**
+     * Dataport for one call
+     */
+    RComm iDataport;
+
+    /**
+     * Call for this entity
+     */
+    RMobileCall iMobileCall;
+
+    /**
+     * Specifies whether this entity is in use or not
+     */
+    TBool iEntityInUse;
+
+    };
+
+/**
+ *  Class for common network resource usage
+ *  This class provides network side independent functionality
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( MDunNetwork )
+    {
+
+public:
+
+    /**
+     * Abstract; Initializes network
+     * Must be called before any other operation
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    virtual void InitializeL() = 0;
+
+    };
+
+/**
+ *  Class for Dataport specific network resource usage
+ *  This class is provides Dataport (RComm) dependent functionality
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( MDunNetDataport ) : public MDunNetwork
+    {
+
+public:
+
+    /**
+     * Abstract; Called when channel was created by transporter
+     * Initializes network for channel creation
+     *
+     * @since S60 3.2
+     * @param aComm Network ID returned when allocation successful
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt AllocateChannel( RComm*& aComm ) = 0;
+
+    /**
+     * Abstract; Called when channel was deleted/closed by transporter
+     * Uninitializes network for channel deletion/close
+     *
+     * @since S60 3.2
+     * @param aComm Network ID of owning entity that will be freed
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt FreeChannel( RComm* aComm ) = 0;
+
+    /**
+     * Gets index by network ID for Dataport
+     *
+     * @since S60 3.2
+     * @param aComm Index to get by this network ID
+     * @return Symbian error code on error, index otherwise
+     */
+    virtual TInt GetIndexById( RComm* aComm ) = 0;
+
+    };
+
+/**
+ *  Class for accessing network functionality through Dataport
+ *  This class is needed by CDunTransporter to create abstract "channels"
+ *  for data communication.
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CDunNetDataport ) : public CBase, public MDunNetDataport
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aNumOfMaxChannels Maximum number of supported Dataport ports
+     *                          for DUN
+     * @return Instance of self
+     */
+	static CDunNetDataport* NewL( TInt aNumOfMaxChannels );
+
+    /**
+    * Destructor.
+    */
+    ~CDunNetDataport();
+
+// from base class MDunNetwork (MDunNetDataport -> MDunNetwork)
+
+    /**
+     * From MDunNetwork (MDunNetDataport -> MDunNetwork).
+     * Initializes network for Dataport
+     * Must be called before any other operation
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void InitializeL();
+
+// from base class MDunNetDataport
+
+    /**
+     * From MDunNetDataport.
+     * Called when channel was created by transporter for Dataport
+     * Initializes network for channel creation
+     *
+     * @since S60 3.2
+     * @param aComm Network ID returned when allocation successful
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt AllocateChannel( RComm*& aComm );
+
+    /**
+     * From MDunNetDataport.
+     * Called when channel was deleted/closed by transporter for Dataport
+     * Uninitializes network for channel deletion/close
+     *
+     * @since S60 3.2
+     * @param aComm Network ID of owning entity that will be freed
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt FreeChannel( RComm* aComm );
+
+    /**
+     * From MDunNetDataport.
+     * Gets index by network ID for Dataport
+     *
+     * @since S60 3.2
+     * @param aComm Index to get by this network ID
+     * @return Symbian error code on error, index otherwise
+     */
+    TInt GetIndexById( RComm* aComm );
+
+private:
+
+    CDunNetDataport( TInt aNumOfMaxChannels );
+
+    void ConstructL();
+
+    /**
+     * Allocates phone objects for use
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void AllocatePhoneObjectsL();
+
+    /**
+     * Initializes first free entity
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, found index otherwise
+     */
+    TInt InitializeFirstFreeEntity();
+
+    /**
+     * Remove network entity by index
+     *
+     * @since S60 3.2
+     * @param aIndex Index which entity to remove
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt RemoveEntity( TInt aIndex );
+
+    /**
+     * Deletes own internal data
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void DeleteNetwork();
+
+    /**
+     * Deletes one network entity at index aIndex for Dataport
+     *
+     * @since S60 3.2
+     * @param aIndex Index where to delete an entity
+     * @param aCheckFree Check free status before deletion
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt DeleteNetworkEntity( TInt aIndex, TBool aCheckFree );
+
+private:  // data
+
+    /**
+     * Maximum number of supported Dataport ports for DUN
+     */
+    TInt iNumOfMaxChannels;
+
+    /**
+     * Array of abstractions of each "call".
+     * One TDunDataportEntity entity contains objects needed for one network
+     * data connection
+     */
+    RArray<TDunDataportEntity> iEntities;
+
+    /**
+     * Communication server needed for Dataport port opening, port information
+     * fetching, and Dataport communication module loading and unloading
+     */
+    RCommServ iCommServer;
+
+    /**
+     * Telephony server needed for opening iMobilePhone mobile phone session
+     * and for telephony module loading and unloading
+     */
+    RTelServer iTelServer;
+
+    /**
+     * Mobile phone server needed for opening iMobileLine mobile line session
+     */
+    RMobilePhone iMobilePhone;
+
+    /**
+     * Mobile line server needed for opening new calls to Dataport.
+     * Each new call is also new network data connection
+     */
+    RMobileLine iMobileLine;
+
+    };
+
+#endif  // C_CDUNNETDATAPORT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/inc/DunNoteHandler.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,140 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Manages note showing in UI
+*
+*/
+
+
+#ifndef C_CDUNNOTEHANDLER_H
+#define C_CDUNNOTEHANDLER_H
+
+#include <e32base.h>
+#include <dunutils.rsg>
+#include <AknGlobalConfirmationQuery.h>
+#include <data_caging_path_literals.hrh>
+#include "DunTransporter.h"
+
+/**
+ *  Class for managing note showing in UI
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CDunNoteHandler ) : public CActive
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @return Instance of self
+     */
+	static CDunNoteHandler* NewL();
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunNoteHandler();
+
+    /**
+     * Resets data to initial values
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void ResetData();
+
+    /**
+     * Issues request to start showing UI note
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt IssueRequest();
+
+    /**
+     * Stops showing UI note
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt Stop();
+
+private:
+
+    CDunNoteHandler();
+
+    void ConstructL();
+
+    /**
+     * Initializes this class
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void Initialize();
+
+    /**
+     * Issues request to start showing UI note
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void DoIssueRequestL();
+
+    /**
+     * Reads resource text
+     *
+     * @since S60 3.2
+     * @param aResourceId Resource ID to read
+     * @param aUnicode Buffer containing the note string to show
+     * @return None
+     */
+    void ReadResourceTextL( TInt aResourceId, HBufC16*& aUnicode );
+
+// from base class CActive
+
+    /*
+     * From CActive.
+     * Gets called when UI note dismissed
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void RunL();
+
+    /**
+     * From CActive.
+     * Gets called on cancel
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void DoCancel();
+
+private:  // data
+
+    /**
+     * Note to show
+     */
+    CAknGlobalConfirmationQuery* iNote;
+
+    /**
+     * Current state of note showing: active or inactive
+     */
+    TDunState iNoteState;
+
+    };
+
+#endif  // C_CDUNNOTEHANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/inc/DunPlugin.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,243 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Common definitions and classes needed by DUN plugins
+*
+*/
+
+
+#ifndef DUN_PLUGIN_H
+#define DUN_PLUGIN_H
+
+#include <e32base.h>
+
+typedef TAny* TConnId;  // supported now: RSocket*, RComm*
+
+enum TDunPluginState
+    {
+    EDunStateNone = KErrNotFound,  // -1
+    EDunStateZombie = 0,           //  0
+    EDunStateTryUninitialize,      //  1
+    EDunStateUninitialized,        //  2
+    EDunStateTryLoad,              //  3
+    EDunStateLoaded,               //  4
+    EDunStateTryListen,            //  5
+    EDunStateListening,            //  6
+    EDunStateTryChannel,           //  7
+    EDunStateChanneled             //  8
+    };
+
+const TInt KDunLocalMediaPluginInterfaceUidValue = 0x101F6E2D;
+const TUid KDunLocalMediaPluginInterfaceUid      = { KDunLocalMediaPluginInterfaceUidValue };
+
+const TInt KDunBtPluginUidValue   = 0x101F6E2B;
+const TUid KDunBtPluginUid        = { KDunBtPluginUidValue };
+const TInt KDunIrPluginUidValue   = 0x101FBAEB;
+const TUid KDunIrPluginUid        = { KDunIrPluginUidValue };
+const TInt KDunUsbPluginUidValue  = 0x101F6E2F;
+const TUid KDunUsbPluginUid       = { KDunUsbPluginUidValue };
+
+class CDunTransporter;
+
+/**
+ *  Notification interface class to report request for plugin enqueue
+ *  This reqeust is made when there are not enough network resources for a
+ *  certain plugin's needs
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( MDunPluginManager )
+    {
+
+public:
+
+    /**
+     * Gets called when old plugin should be enqueued
+     *
+     * @since S60 3.2
+     * @param aPluginUid UID of the plugin that should be enqueued
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt NotifyPluginEnqueueRequest( TUid aPluginUid ) = 0;
+
+     /**
+     * Gets called when new plugin should be dequeued
+     *
+     * @since S60 3.2
+     * @param aPluginUid UID of the local media plugin to dequeue
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt NotifyPluginDequeueRequest( TUid aPluginUid ) = 0;
+
+    /**
+     * Get callen when plugin should be closed
+     *
+     * @since S60 3.2
+     * @param aPluginUid UID of the local media plugin to close
+     * @param aSelfClose ETrue if plugin closes itself, EFalse otherwise
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt NotifyPluginCloseRequest( TUid aPluginUid,
+                                           TBool aSelfClose ) = 0;
+
+    };
+
+/**
+ *  Interface class for accessing CDunServer's functionality
+ *  Shares basic interface for all plugins to use when plugin needs to access
+ *  server's functionality
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( MDunServerCallback ) : public MDunPluginManager
+    {
+
+public:
+
+    /**
+     * Callback from plugins to server to get a plugin's state
+     *
+     * @since S60 3.2
+     * @param aPluginUid Plugin's UID which state to get
+     * @return Plugin's state
+     */
+    virtual TDunPluginState GetPluginStateByUid( TUid aPluginUid ) = 0;
+
+    /**
+     * Callback from plugins to server to set a new state
+     * New state must be one more than the old state
+     *
+     * @since S60 3.2
+     * @param aPluginState New state to set for a plugin
+     * @param aPluginUid Plugin's UID for which to change state
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt NotifyPluginStateChangeUp( TDunPluginState aPluginState,
+                                            TUid aPluginUid ) = 0;
+
+    /**
+     * Callback from plugins to server to set a new state
+     * New state must be one less than the old state
+     *
+     * @since S60 3.2
+     * @param aPluginState New state to set for a plugin
+     * @param aPluginUid Plugin's UID for which to change state
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt NotifyPluginStateChangeDown( TDunPluginState aPluginState,
+                                              TUid aPluginUid ) = 0;
+
+    /**
+     * Callback from plugins to server to restart a plugin
+     * Restarting must be done by uninitialization->listening switch since
+     * context is in plugin
+     *
+     * @since S60 3.2
+     * @param aPluginUid Plugin's UID to restart
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt NotifyPluginRestart( TUid aPluginUid ) = 0;
+
+    /**
+     * Callback from plugins to server to reopen a plugin from queue
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt NotifyPluginReopenRequest() = 0;
+
+    };
+
+/**
+ *  Interface class for accessing plugins' functionality
+ *  Shares basic interface for server to use when server needs to access
+ *  plugin's functionality
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( MDunLocalMediaPlugin )
+    {
+
+public:
+
+    /**
+     * Destructor. Derived class must have virtual destructor also as a plugin
+     * module is always destructed via M-class.
+     */
+    inline virtual ~MDunLocalMediaPlugin() {};
+
+    /**
+     * Symbian 2nd phase constructor.
+     */
+    virtual void ConstructL( MDunServerCallback* aServer,
+                             CDunTransporter* aTransporter ) = 0;
+
+    /**
+     * Callback from server to plugins to notify when server changes a
+     * plugin's state
+     *
+     * @since S60 3.2
+     * @param aPluginState New changed state
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt NotifyServerStateChange( TDunPluginState aPluginState ) = 0;
+
+    /**
+     * Callback from server to plugins to ask for current active connection
+     * (For testing purposes only)
+     *
+     * @since S60 5.0
+     * @return Active connection, NULL otherwise
+     */
+    virtual TConnId ActiveConnection() = 0;
+
+    };
+
+/**
+ *  Interface class for accessing plugin's main class when its listener
+ *  reports that channel can be created. Can be used also to notify plugin's
+ *  main class when channel can be deleted.
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( MDunListenCallback )
+    {
+
+public:
+
+    /**
+     * Callback from plugin's listener to plugin to notify about need to
+     * allocate new channel
+     *
+     * @since S60 3.2
+     * @param aNoFreeChan ETrue if no free channels, EFalse otherwise
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt NotifyChannelAllocate( TBool& aNoFreeChans ) = 0;
+
+    /**
+     * Callback from plugin's listener to plugin to notify about need to free
+     * an existing channel
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt NotifyChannelFree() = 0;
+
+    };
+
+#endif // DUN_PLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/inc/DunSignalCopy.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,226 @@
+/*
+* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Copies signals changes between network and local media
+*
+*/
+
+
+#ifndef C_CDUNSIGNALCOPY_H
+#define C_CDUNSIGNALCOPY_H
+
+#include "DunTransporter.h"
+#include "DunTransUtils.h"
+#include "DunAtCmdHandler.h"
+
+/**
+ *  Class for copying signal changes between to endpoints
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CDunSignalCopy ) : public CActive
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @return Instance of self
+     */
+	static CDunSignalCopy* NewL();
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunSignalCopy();
+
+    /**
+     * Resets data to initial values
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void ResetData();
+
+    /**
+     * Adds callback for line status change controlling
+     * The callback will be called when RunL error is detected
+     *
+     * @since S60 3.2
+     * @param aCallback Callback to call when line status changes
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt AddCallback( MDunConnMon* aCallback );
+
+    /**
+     * Sets media to use for this endpoint monitor
+     *
+     * @since S60 3.2
+     * @param aComm RComm pointer to local media side
+     * @param aNetwork RComm pointer to network side
+     * @param aStreamType Stream type for this endpoint
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt SetMedia( RComm* aComm,
+                   RComm* aNetwork,
+                   TDunStreamType aStreamType );
+
+    /**
+     * Issues request to start monitoring the endpoint for line status change
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt IssueRequest();
+
+    /**
+     * Stops monitoring the endpoint for line status change
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt Stop();
+
+private:
+
+    CDunSignalCopy();
+
+    void ConstructL();
+
+    /**
+     * Initializes this class
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void Initialize();
+
+    /**
+     * Manages upstream signal changes
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void ManageSignalChange();
+
+    /**
+     * Manages signal changes
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void ManageSignalChangeUpstream();
+
+    /**
+     * Manages downstream signal changes
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void ManageSignalChangeDownstream();
+
+    /**
+     * Changes upstream signal
+     *
+     * @since S60 5.0
+     * @param aSetMask Set the handshaking lines in the mask
+     * @param aClearMask Clear the handshaking lines in the mask
+     * @return None
+     */
+    void ChangeUpstreamSignal( TUint aSetMask, TUint aClearMask );
+
+    /**
+     * Changes downstream signal
+     *
+     * @since S60 3.2
+     * @param aSetMask Set the handshaking lines in the mask
+     * @param aClearMask Clear the handshaking lines in the mask
+     * @return None
+     */
+    void ChangeDownstreamSignal( TUint aSetMask, TUint aClearMask );
+
+// from base class CActive
+
+    /*
+     * From CActive.
+     * Gets called when line status changes
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void RunL();
+
+    /**
+     * From CActive.
+     * Gets called on cancel
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void DoCancel();
+
+private:  // data
+
+    /**
+     * Callback(s) to call when notification(s) via MDunConnMon to be made
+     * Normally contains only one callback
+     */
+    RPointerArray<MDunConnMon> iCallbacks;
+
+    /**
+     * Callback(s) to call when command mode starts or ends
+     * Usually two needed: one for upstream and second for downstream
+     */
+    RPointerArray<MDunCmdModeMonitor> iCmdCallbacks;
+
+    /**
+     * Used media context: network or local
+     */
+    TDunMediaContext iContextInUse;
+
+    /**
+     * Used stream type: upstream or downstream
+     */
+    TDunStreamType iStreamType;
+
+    /**
+     * Current state of connection monitoring: active or inactive
+     */
+    TDunState iSignalCopyState;
+
+    /**
+     * Signal to listen with RComm::NotifySignalChange()
+     */
+    TUint iListenSignals;
+
+    /**
+     * Signals set when RComm::NotifySignalChange() request completes
+     */
+    TUint iSignals;
+
+    /**
+     * RComm object of network side
+     * Not own.
+     */
+    RComm* iNetwork;
+
+    /**
+     * RComm object of local media side
+     * Not own.
+     */
+    RComm* iComm;
+
+    };
+
+#endif  // C_CDUNSIGNALCOPY_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/inc/DunSignalNotify.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,181 @@
+/*
+* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Monitors signal changes on network side and reports changes
+*
+*/
+
+
+#ifndef C_CDUNSIGNALNOTIFY_H
+#define C_CDUNSIGNALNOTIFY_H
+
+#include "DunTransUtils.h"
+#include "DunAtCmdHandler.h"
+
+/**
+ *  Class for monitoring line status and reporting changes
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CDunSignalNotify ) : public CActive
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aUtility Pointer to common utility class
+     * @return Instance of self
+     */
+	static CDunSignalNotify* NewL( MDunTransporterUtilityAux* aUtility );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunSignalNotify();
+
+    /**
+     * Resets data to initial values
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void ResetData();
+
+    /**
+     * Adds callback for line status change controlling
+     * The callback will be called when line status change is detected in
+     * endpoint
+     *
+     * @since S60 3.2
+     * @param aCallback Callback to call when line status changes
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt AddCallback( MDunConnMon* aCallback );
+
+    /**
+     * Sets media to use for this endpoint monitor (network side)
+     *
+     * @since S60 3.2
+     * @param aComm RComm pointer to use as the endpoint
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt SetMedia( RComm* aComm );
+
+    /**
+     * Issues request to start monitoring the endpoint for line status change
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt IssueRequest();
+
+    /**
+     * Stops monitoring the endpoint for line status change
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt Stop();
+
+private:
+
+    CDunSignalNotify( MDunTransporterUtilityAux* aUtility );
+
+    void ConstructL();
+
+    /**
+     * Initializes this class
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void Initialize();
+
+    /**
+     * Manages signal changes
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void ManageSignalChange();
+
+    /**
+     * Reports signal change
+     *
+     * @since S60 3.2
+     * @param aSetMask Set the handshaking lines in the mask
+     * @param aClearMask Clear the handshaking lines in the mask.
+     * @return None
+     */
+    void ReportSignalChange( TUint aSetMask, TUint aClearMask );
+
+// from base class CActive
+
+    /*
+     * From CActive.
+     * Gets called when line status changes
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void RunL();
+
+    /**
+     * From CActive.
+     * Gets called on cancel
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void DoCancel();
+
+private:  // data
+
+    /**
+     * Callback(s) to call when notification(s) via MDunConnMon to be made
+     * Normally contains only one callback
+     */
+    RPointerArray<MDunConnMon> iCallbacks;
+
+    /**
+     * Pointer to common utility class
+     * Not own.
+     */
+    MDunTransporterUtilityAux* iUtility;
+
+    /**
+     * Current state of signal monitoring: active or inactive
+     */
+    TDunState iSignalNotifyState;
+
+    /**
+     * Signals to listen with RComm::NotifySignalChange()
+     */
+    TUint iListenSignals;
+
+    /**
+     * Signals set when RComm::NotifySignalChange() request completes
+     */
+    TUint iSignals;
+
+    /**
+     * RComm object of network side
+     * Not own.
+     */
+    RComm* iNetwork;
+
+    };
+
+#endif  // C_CDUNSIGNALNOTIFY_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/inc/DunSignalWaiter.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,161 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Monitors for signal change in RComm local media side
+*
+*/
+
+
+#ifndef C_CDUNSIGNALWAITER_H
+#define C_CDUNSIGNALWAITER_H
+
+#include "DunChanMan.h"
+
+/**
+ *  Class to monitor for signal change in RComm local media side
+ *  This class is needed to avoid unnecessary resource allocation of Dataport
+ *  side when number of supported Dataport ports for DUN is less than the
+ *  number of local media side plugins that use RComm
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CDunSignalWaiter ) : public CActive
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aChannelCallback Callback to call when notification via
+     *                         MDunChannelAllocator to be made
+     * @return Instance of self
+     */
+	static CDunSignalWaiter* NewL( MDunChannelAllocator* aChannelCallback );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunSignalWaiter();
+
+    /**
+     * Resets data to initial values
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void ResetData();
+
+    /**
+     * Adds callback for RunL error controlling
+     * The callback will be called when error is detected in asynchronous
+     * operation
+     *
+     * @since S60 3.2
+     * @param aCallback Callback to call when line status changes
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt AddCallback( MDunConnMon* aCallback );
+
+    /**
+     * Sets media to use for this endpoint
+     *
+     * @since S60 3.2
+     * @param aComm RComm pointer to use as the endpoint
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt SetMedia( RComm* aComm );
+
+    /**
+    * Issues request to start waiting for new data in RComm
+    *
+    * @since S60 3.2
+    * @return Symbian error code on error, KErrNone otherwise
+    */
+    TInt IssueRequest();
+
+    /**
+     * Stops monitoring for new data
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt Stop();
+
+private:
+
+    CDunSignalWaiter( MDunChannelAllocator* aChannelCallback );
+
+    void ConstructL();
+
+    /**
+     * Initializes this class
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void Initialize();
+
+// from base class CActive
+
+    /**
+     * From CActive.
+     * Gets called when new data in RComm object
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void RunL();
+
+    /**
+     * From CActive.
+     * Gets called on cancel
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void DoCancel();
+
+private:  // data
+
+    /**
+     * Callback(s) to call when notification(s) via MDunConnMon to be made
+     * Normally contains only one callback
+     */
+    RPointerArray<MDunConnMon> iCallbacks;
+
+    /**
+     * Callback to call when notification via MDunChannelAllocator to be made
+     * Not own.
+     */
+    MDunChannelAllocator* iChannelCallback;
+
+    /**
+     * Current state of data monitoring: active or inactive
+     */
+    TDunState iSignalWaiterState;
+
+    /**
+     * Signals set when RComm::NotifySignalChange() request completes
+     */
+    TUint iSignals;
+
+    /**
+     * RComm object of local media side
+     * Not own.
+     */
+    RComm* iComm;
+
+    };
+
+#endif  // C_CDUNSIGNALWAITER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/inc/DunStream.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,229 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definitions needed for common stream functionality
+*
+*/
+
+
+#ifndef C_CDUNSTREAM_H
+#define C_CDUNSTREAM_H
+
+#include "DunTransporter.h"
+
+/**
+ *  Class for common stream functionality
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CDunStream ) : public CActive
+    {
+
+public:
+
+    /**
+     * Resets data to initial values
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void ResetData();
+
+    /**
+     * Adds error code to consider as "no error" to either endpoint
+     *
+     * @since S60 3.2
+     * @param aError Error code to add
+     * @param aOperationType Type of operation for which to add error
+     *                       (read or write)
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt AddSkippedError( TInt aError, TDunOperationType aOperationType );
+
+    /**
+     * Adds callback for line status change controlling
+     * The callback will be called when serious read error is detected
+     *
+     * @since S60 3.2
+     * @param aCallback Callback to call when read error occurs
+     * @param aOperationType Type of operation for which to add error
+     *                       (read or write)
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt AddConnMonCallback( MDunConnMon* aCallback,
+                             TDunOperationType aOperationType );
+
+    /**
+     * Sets buffering for this stream
+     *
+     * @since S60 3.2
+     * @param aBufferPtr Pointer to the buffer
+     * @return KErrGeneral if buffer pointer null, KErrNone otherwise
+     */
+    TInt SetBuffering( TPtr8* aBufferPtr );
+
+    /**
+     * Sets media to be used for this endpoint
+     *
+     * @since S60 3.2
+     * @param aComm RComm pointer to use as the endpoint
+     * @param aMediaContext Media context to use for this endpoint, either
+     *                      local or network
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt SetMedia( RComm* aComm, TDunMediaContext aMediaContext );
+
+    /**
+     * Sets media to be used for this endpoint
+     *
+     * @since S60 3.2
+     * @param aSocket RSocket pointer to use as the endpoint
+     * @param aMediaContext Media context to use for this endpoint, either
+     *                      local or network
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt SetMedia( RSocket* aSocket, TDunMediaContext aMediaContext );
+
+    /**
+     * Gets media context
+     *
+     * @since S60 3.2
+     * @param aStreamType Stream type
+     * @return Media context in use
+     */
+    TDunMediaContext GetMediaContext( TDunStreamType aStreamType );
+
+protected:
+
+    CDunStream();
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunStream();
+
+    /**
+     * Check whether an error code is severe error or not
+     *
+     * @since S60 3.2
+     * @param aError Error code to check for severity
+     * @param aIsError ETrue if error code is error, EFalse if not error
+     * @return ETrue if severe error detected, EFalse if not severe error
+     */
+    TBool ProcessErrorCondition( TInt aError, TBool& aIsError );
+
+// from base class CActive
+
+    /**
+     * From CActive.
+     * Gets called when endpoint data read/write complete
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    virtual void RunL() {};
+
+    /**
+     * From CActive.
+     * Gets called on cancel
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    virtual void DoCancel() {};
+
+private:
+
+    /**
+     * Initializes this class
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void Initialize();
+
+protected:  // data
+
+    /**
+     * Pointer to stream's data buffer: upstream or downstream
+     * Not own.
+     */
+    TPtr8* iBufferPtr;
+
+    /**
+     * Callback(s) to call when notification(s) via MDunConnMon to be made
+     * These callbacks are called on read failures
+     */
+    RPointerArray<MDunConnMon> iCallbacksR;
+
+    /**
+     * Callback(s) to call when notification(s) via MDunConnMon to be made
+     * These callbacks are called on write failures
+     */
+    RPointerArray<MDunConnMon> iCallbacksW;
+
+    /**
+     * Read length set when RSocket::RecvOneOrMore() request completes
+     */
+    TSockXfrLength iReadLengthSocket;
+
+    /**
+     * Type of current operation: read or write
+     */
+    TDunOperationType iOperationType;
+
+    /**
+     * Current state of transfer: active or inactive
+     */
+    TDunState iTransferState;
+
+    /**
+     * Direction of data transfer
+     * This is set after iStreamType and iOperationType are known
+     */
+    TDunDirection iDirection;
+
+    /**
+     * Array of error codes that will be skipped for read operations
+     */
+    RArray<TInt> iOkErrorsR;
+
+    /**
+     * Array of error codes that will be skipped for write operations
+     */
+    RArray<TInt> iOkErrorsW;
+
+    /**
+     * RComm object of network side
+     * Not own.
+     */
+    RComm* iNetwork;
+
+    /**
+     * RSocket object of local media side
+     * If this is set then iComm is not used
+     * Not own.
+     */
+    RSocket* iSocket;
+
+    /**
+     * RComm object of local media side
+     * If this is set then iSocket is not used
+     * Not own.
+     */
+    RComm* iComm;
+
+    };
+
+#endif  // C_CDUNSTREAM_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/inc/DunTransUtils.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,531 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Utility class for other CDunTransporter classes
+*
+*/
+
+
+#ifndef C_CDUNTRANSUTILS_H
+#define C_CDUNTRANSUTILS_H
+
+#include "DunTransporter.h"
+
+/**
+ *  Notification interface class for managing channel's activity
+ *  This class is needed to update KPSUidDialupConnStatus pub&sub key
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( MDunActivityManager )
+    {
+
+public:
+
+    /**
+     * CDunTransporter callback: gets called when activity is detected on a
+     * channel
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt NotifyChannelActivity() = 0;
+
+    /**
+     * CDunTransporter callback: gets called when inactivity is detected on a
+     * channel
+     *
+     * @since S60 3.2
+     * @return KErrGeneral if mismatch in channel activity, KErrNone otherwise
+     */
+    virtual TInt NotifyChannelInactivity() = 0;
+
+    };
+
+/**
+ *  Utility accessor class for CDunTransporter class itself
+ *  Shares basic functionality of CDunTransporter by simplifying it
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( MDunTransporterUtility )
+    {
+
+public:
+
+    /**
+     * Initializes first free channel
+     *
+     * @since S60 3.2
+     * @param aLocalIdNew Identifier of the new local endpoint
+     * @return Symbian error code on error, found index otherwise
+     */
+    virtual TInt InitializeFirstFreeChannel( TConnId aLocalIdNew ) = 0;
+
+    /**
+     * Allocates a channel by creating and setting local media independent
+     * objects
+     * This is a common method used by exported local media dependent methods
+     *
+     * @since S60 3.2
+     * @param aBufferLength Buffer length selected for this channel
+     * @param aFirstFree Index to first free channel data
+     * @param aCorrection Pointer to object implementing buffer correction
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual void DoAllocateChannelL(
+        RComm* aComm,
+        TInt& aBufferLength,
+        TInt aFirstFree,
+        MDunBufferCorrection* aCorrection ) = 0;
+
+    /**
+     * Adds connection monitor callback for either local media or network side
+     * by connection ID
+     * Error will be added to aIndex:th endpoint
+     *
+     * @since S60 3.2
+     * @param aIndex Index where to add new connection monitor callback
+     * @param aCallback Pointer to object whose callbacks will be called
+     * @param aDirection Direction of operation to monitor for read/write error
+     * @param aSignal Receive also signal change if ETrue
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt DoAddConnMonCallback( TInt aIndex,
+                                       MDunConnMon* aCallback,
+                                       TDunDirection aDirection,
+                                       TBool aSignal ) = 0;
+
+    /**
+     * Adds error to consider as no error condition when doing any of the four
+     * endpoint's read/writer operation
+     * Error will be added to aIndex:th endpoint
+     *
+     * @since S60 3.2
+     * @param aIndex Index where to add new "no error" code
+     * @param aError Error code to consider as "no error"
+     * @param aDirection One of four data transfer endpoints where to add a
+     *                   skipped error code
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt DoAddSkippedError( TInt aIndex,
+                                    TInt aError,
+                                    TDunDirection aDirection ) = 0;
+
+    /**
+     * Issues transfers requests for aIndex:th transfer objects
+     *
+     * @since S60 3.2
+     * @param aIndex Index to transfer objects that will be activated
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt DoIssueTransferRequests( TInt aIndex ) = 0;
+
+    /**
+     * Stops transfers for aIndex:th transfer objects
+     *
+     * @since S60 3.2
+     * @param aIndex Index to transfer objects that will be stopped
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt DoStopTransfers( TInt aIndex ) = 0;
+
+    /**
+     * Free aIndex:th channel's objects
+     *
+     * @since S60 3.2
+     * @param aIndex Index of channel to free
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt DoFreeChannel( TInt aIndex ) = 0;
+
+    };
+
+/**
+ *  Utility accessor class for other than CDunTransporter classes
+ *  Basically a collection of miscellaneous helper methods
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( MDunTransporterUtilityAux )
+    {
+
+public:
+
+    /**
+     * Gets local ID counterpart of a network ID
+     *
+     * @since S60 3.2
+     * @param aComm Network ID to search for
+     * @return Null if ID not found, otherwise found ID
+     */
+    virtual TConnId GetLocalId( RComm* aComm ) = 0;
+
+    /**
+     * Notifies when serious read/write error is detected on a connection
+     *
+     * @since S60 3.2
+     * @param aComm Non-null if error on RComm
+     * @param aSocket Non-null if error on RSocket
+     * @param aConnReason Reason of connection error
+     * @param aCallbacks Callbacks to notify on connections error
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt DoNotifyConnectionNotOk(
+        RComm* aComm,
+        RSocket* aSocket,
+        TDunConnectionReason& aConnReason,
+        RPointerArray<MDunConnMon>& aCallbacks) = 0;
+
+    };
+
+/**
+ *  Utility class for other CDunTransporter classes
+ *  This class implements basic functionality that is shared by different
+ *  CDunTransporter classes, also for simplifying CDunTransporter itself
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CDunTransUtils ) : public CBase,
+                                      public MDunActivityManager,
+                                      public MDunTransporterUtility,
+                                      public MDunTransporterUtilityAux
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aParent Parent class owning this friend class (CDunTransporter)
+     * @param aPluginManager Callback to call when notification via
+     *                       MDunPluginManager to be made
+     * @return Instance of self
+     */
+	static CDunTransUtils* NewL( CDunTransporter& aParent,
+	                             MDunPluginManager* aPluginManager );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunTransUtils();
+
+private:
+
+    CDunTransUtils( CDunTransporter& aParent,
+                    MDunPluginManager* aPluginManager );
+
+    void ConstructL();
+
+    /**
+     * Manages service advertisement status changes
+     *
+     * @since S60 5.0
+     * @param aAdvertise New advertisement status
+     * @param aCreation ETrue if channel creation
+     *                  EFalse if channel free
+     * @return None
+     */
+    void ManageAdvertisementStatusChange( TBool aAdvertise,
+                                          TBool aCreation=EFalse );
+
+    /**
+     * Creates empty channel data
+     *
+     * @since S60 3.2
+     * @param aChannel Channel data to set empty
+     * @return None
+     */
+    void CreateEmptyChannelData( TDunChannelData& aChannel );
+
+    /**
+     * Creates new buffer if source buffer defined, otherwise already existing
+     * buffer will be used
+     *
+     * @since S60 3.2
+     * @param aSrcBuffer Source buffer
+     * @param aSrcPtr Pointer to source buffer
+     * @param aDstBuffer Destination buffer
+     * @param aDstPtr Pointer to destination buffer
+     * @param aItemsInCs Items in cleanup stack, will be incremented if
+     *                   necessary
+     * @return None
+     */
+    void DoCreateBufferLC( TUint8* aSrcBuffer,
+                           TPtr8* aSrcPtr,
+                           TUint8*& aDstBuffer,
+                           TPtr8*& aDstPtr,
+                           TInt aBufferLength,
+                           TInt& aItemsInCs );
+
+    /**
+     * Creates new signal copy object if source defined, otherwise
+     * already existing will be used
+     *
+     * @since S60 3.2
+     * @param aSrcSignalCopy Source signal copy object
+     * @param aDstSignalCopy Destination signal copy object
+     * @param aItemsInCs Items in cleanup stack, will be incremented if
+     *                   necessary
+     * @return None
+     */
+    void DoCreateSignalCopyLC( CDunSignalCopy* aSrcSignalCopy,
+                               CDunSignalCopy*& aDstSignalCopy,
+                               TInt& aItemsInCs );
+
+    /**
+     * Creates new signal notify object if source defined, otherwise
+     * already existing will be used
+     *
+     * @since S60 3.2
+     * @param aSrcSignalNotify Source signal notify object
+     * @param aDstSignalNotify Destination signal notify object
+     * @param aItemsInCs Items in cleanup stack, will be incremented if
+     *                   necessary
+     * @return None
+     */
+    void DoCreateSignalNotifyLC( CDunSignalNotify* aSrcSignalNotify,
+                                 CDunSignalNotify*& aDstSignalNotify,
+                                 TInt& aItemsInCs );
+
+    /**
+     * Creates transfer objects for reader and writer if sources defined,
+     * otherwise already existing ones will be used
+     *
+     * @since S60 3.2
+     * @param aSrcReader Source reader object
+     * @param aDstReader Destination reader object
+     * @param aItemsInCs Items in cleanup stack, will be incremented if
+     *                   necessary
+     * @return None
+     */
+    void DoCreateUpTransferObjectL( CDunUpstream* aSrcReader,
+                                    CDunUpstream*& aDstReader,
+                                    TInt& aItemsInCs );
+
+    /**
+     * Creates transfer objects for reader and writer if sources defined,
+     * otherwise already existing ones will be used
+     *
+     * @since S60 3.2
+     * @param aSrcReader Source reader object
+     * @param aDstReader Destination reader object
+     * @param aItemsInCs Items in cleanup stack, will be incremented if
+     *                   necessary
+     * @return None
+     */
+    void DoCreateDownTransferObjectL( CDunDownstream* aSrcReader,
+                                      CDunDownstream*& aDstReader,
+                                      TInt& aItemsInCs );
+
+    /**
+     * Resets/frees network data of aIndex:th channel
+     *
+     * @since S60 3.2
+     * @param aIndex Index of channel to reset/free
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt DeleteOneNetworkData( TInt aIndex );
+
+    /**
+     * Deletes local data of aIndex:th channel
+     *
+     * @since S60 3.2
+     * @param aIndex Index of channel to delete
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt DeleteOneLocalData( TInt aIndex );
+
+    /**
+     * Deletes buffering objects of aIndex:th channel
+     *
+     * @since S60 3.2
+     * @param aIndex Index of channel to delete
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt DeleteBuffering( TInt aIndex );
+
+// from base class MDunTransporterUtility
+
+    /**
+     * From MDunTransporterUtility.
+     * Initializes first free channel
+     *
+     * @since S60 3.2
+     * @param aLocalIdNew Identifier of the new local endpoint
+     * @return Symbian error code on error, found index otherwise
+     */
+    TInt InitializeFirstFreeChannel( TConnId aLocalIdNew );
+
+    /**
+     * From MDunTransporterUtility.
+     * Allocates a channel by creating and setting local media independent
+     * objects
+     * This is a common method used by exported local media dependent methods
+     *
+     * @since S60 3.2
+     * @param aBufferLength Buffer length selected for this channel
+     * @param aFirstFree Index to first free channel data
+     * @param aCorrection Pointer to object implementing buffer correction
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    void DoAllocateChannelL( RComm* aComm,
+                             TInt& aBufferLength,
+                             TInt aFirstFree,
+                             MDunBufferCorrection* aCorrection );
+
+    /**
+     * From MDunTransporterUtility.
+     * Adds connection monitor callback for either local media or network side
+     * by connection ID
+     * Connection monitor will be added to aIndex:th endpoint
+     *
+     * @since S60 3.2
+     * @param aIndex Index where to add new connection monitor callback
+     * @param aCallback Pointer to object whose callbacks will be called
+     * @param aDirection Direction of operation to monitor for read/write error
+     * @param aSignal Receive also signal change if ETrue
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt DoAddConnMonCallback( TInt aIndex,
+                               MDunConnMon* aCallback,
+                               TDunDirection aDirection,
+                               TBool aSignal );
+
+    /**
+     * From MDunTransporterUtility.
+     * Adds error to consider as no error condition when doing any of the four
+     * endpoint's read/writer operation
+     * Error will be added to aIndex:th endpoint
+     *
+     * @since S60 3.2
+     * @param aIndex Index where to add new "no error" code
+     * @param aError Error code to consider as "no error"
+     * @param aDirection One of four data transfer endpoints where to add a
+     *                   skipped error code
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt DoAddSkippedError( TInt aIndex,
+                            TInt aError,
+                            TDunDirection aDirection );
+
+    /**
+     * From MDunTransporterUtility.
+     * Issues transfers requests for aIndex:th transfer objects
+     *
+     * @since S60 3.2
+     * @param aIndex Index to transfer objects that will be activated
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt DoIssueTransferRequests( TInt aIndex );
+
+    /**
+     * From MDunTransporterUtility.
+     * Stops transfers for aIndex:th transfer objects
+     *
+     * @since S60 3.2
+     * @param aIndex Index to transfer objects that will be stopped
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt DoStopTransfers( TInt aIndex );
+
+    /**
+     * From MDunTransporterUtility.
+     * Free aIndex:th channel's objects
+     *
+     * @since S60 3.2
+     * @param aIndex Index of channel to free
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt DoFreeChannel( TInt aIndex );
+
+// from base class MDunTransporterUtilityAux
+
+    /**
+     * From MDunTransporterUtilityAux.
+     * Gets local ID counterpart of a network ID
+     *
+     * @since S60 3.2
+     * @param aComm Network ID to search for
+     * @return Null if ID not found, otherwise found ID
+     */
+    TConnId GetLocalId( RComm* aComm );
+
+    /**
+     * From MDunTransporterUtilityAux.
+     * Notifies when serious read/write error is detected on a connection
+     *
+     * @since S60 3.2
+     * @param aComm Non-null if error on RComm
+     * @param aSocket Non-null if error on RSocket
+     * @param aConnReason Reason of connection error
+     * @param aCallbacks Callbacks to notify on connections error
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt DoNotifyConnectionNotOk(
+        RComm* aComm,
+        RSocket* aSocket,
+        TDunConnectionReason& aConnReason,
+        RPointerArray<MDunConnMon>& aCallbacks);
+
+// from base class MDunActivityManager
+
+    /**
+     * From MDunActivityManager.
+     * Notifies about activity on a channel
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt NotifyChannelActivity();
+
+    /**
+     * From MDunActivityManager.
+     * Notifies about inactivity on a channel
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt NotifyChannelInactivity();
+
+private:  // data
+
+    /**
+     * Parent class owning this friend class (CDunTransporter)
+     */
+    CDunTransporter& iParent;
+
+    /**
+     * Array of abstractions of each "channel" (from parent iParent)
+     * One TDunChannelData entry contains objects needed for one channel
+     */
+    RArray<TDunChannelData>& iChannelData;
+
+    /**
+     * Array of service advertisement data for each plugin (from parent iParent)
+     * One TDunServAdvData entry contains objects needed for one plugin
+     */
+    RArray<TDunServAdvData>& iServAdvData;
+
+    /**
+     * Callback to call when notification via MDunPluginManager to be made
+     * Not own.
+     */
+    MDunPluginManager* iPluginManager;
+
+    };
+
+#endif  // C_CDUNTRANSUTILS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/inc/DunTransporter.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,800 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Managing abstracted "channels" of network side communication
+*
+*/
+
+
+#ifndef C_CDUNTRANSPORTER_H
+#define C_CDUNTRANSPORTER_H
+
+#include <e32base.h>
+#ifdef PRJ_USE_NETWORK_STUBS
+#include <c32comm_stub.h>
+#else
+#include <c32comm.h>
+#endif
+#include <es_sock.h>
+#include "DunNetDataport.h"
+
+typedef TAny* TConnId;  // supported now: RSocket*, RComm*
+
+const TInt KDunStreamTypeMask    = 0x02;  // 10
+const TInt KDunOperationTypeMask = 0x01;  // 01
+
+enum TDunOperationType
+    {
+    EDunOperationTypeUndefined = KErrNotFound,
+    EDunOperationTypeRead      = 0x00,  // 00
+    EDunOperationTypeWrite     = 0x01   // 01
+    };
+
+enum TDunMediaContext
+    {
+    EDunMediaContextUndefined = KErrNotFound,
+    EDunMediaContextNetwork   = 0,
+    EDunMediaContextLocal
+    };
+
+enum TDunMedia
+    {
+    EDunMediaUndefined = KErrNotFound,
+    EDunMediaNetwork   = 0,
+    EDunMediaRComm,
+    EDunMediaRSocket
+    };
+
+enum TDunDirection
+    {
+    EDunDirectionUndefined = KErrNotFound,
+    EDunReaderUpstream     = 0x00,  // 00
+    EDunWriterUpstream     = 0x01,  // 01
+    EDunReaderDownstream   = 0x02,  // 10
+    EDunWriterDownstream   = 0x03   // 11
+    };
+
+enum TDunStreamType
+    {
+    EDunStreamTypeUndefined  = KErrNotFound,
+    EDunStreamTypeUpstream   = 0x00,  // 00
+    EDunStreamTypeDownstream = 0x02   // 10
+    };
+
+enum TDunState
+    {
+    EDunStateIdle,
+    EDunStateTransferring,     // Transporter state for data tranfer (up/downstream)
+    EDunStateSignalCopy,       // Transporter state for signal copying (RComm)
+    EDunStateSignalNotify,     // Transporter state for signal notifying (RSocket)
+    EDunStateDataWaiting,      // Transporter state for data waiting
+    EDunStateSignalWaiting,    // Transporter state for signal waiting
+    EDunStateDataPushing,      // Transporter state for data pushing (multiplexer)
+    EDunStateCallListen,       // Transporter state for call state listening
+    EDunStateAtCmdHandling,    // ATEXT state for AT command handling
+    EDunStateAtCmdPushing,     // ATEXT state for AT command reply pushing
+    EDunStateAtCmdEchoing,     // ATEXT state for AT command character echoing (text mode)
+    EDunStateAtUrcHandling,    // ATEXT state for URC handling
+    EDunStateModeListening,    // ATEXT state for mode change listening
+    EDunStateEcomListening,    // ATEXT state for ECOM change listening
+    EDunStateNvramListening,   // ATEXT state for NVRAM change listening
+    EDunStateUiNoting          // Transporter state for UI note showing
+    };
+
+enum TDunReasonType
+    {
+    EDunReasonTypeSignal,
+    EDunReasonTypeRW,
+    EDunReasonTypeRunL
+    };
+
+class CDunChanMan;
+class MDunPluginManager;
+class MDunTransporterUtility;
+class CDunTransUtils;
+class CDunConnWaiter;
+class TDunWaiterData;
+class CDunUpstream;
+class CDunDownstream;
+class CDunSignalCopy;
+class CDunSignalNotify;
+class CDunNoteHandler;
+
+/**
+ *  Class used for reporting connection error's reason and signal changes
+ *  of network side
+ *  Connection error can happen in read/write and RunL error cases
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( TDunConnectionReason )
+    {
+
+public:
+
+    /**
+     * Reason type of error; either R/W or RunL
+     * or signal (network side)
+     * Set in all cases (signal, R/W, RunL)
+     */
+    TDunReasonType iReasonType;
+
+    /**
+     * Context of media where error occurred: network or local
+     * Set in all error cases (signal, R/W, RunL)
+     */
+    TDunMediaContext iContext;
+
+    /**
+     * Signal type of network side
+     * Set if signal case, 0 otherwise
+     */
+    TUint iSignalType;
+
+    /**
+     * Is signal high or low of network side
+     * Set if signal case, 0 otherwise
+     */
+    TBool iSignalHigh;
+
+    /**
+     * Direction of data transfer
+     * Set if R/W case, EDunDirectionUndefined otherwise
+     */
+    TDunDirection iDirection;
+
+    /**
+     * Error code of failure
+     * Set if R/W or RunL case, KErrNone otherwise
+     */
+    TInt iErrorCode;
+
+    };
+
+/**
+ *  Notification interface class to report line status
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( MDunConnMon )
+	{
+
+public:
+
+    /**
+     * Gets called when line status changes or when any type of error is
+     * detected
+     *
+     * @since S60 3.2
+     * @param aConnId Connection ID for callback
+     * @param aConnReason Reason for progress change
+     * @return None
+     */
+    virtual void NotifyProgressChangeL(
+        TConnId aConnId,
+        TDunConnectionReason aConnReason ) = 0;
+
+	};
+
+/**
+ *  Notification interface class to report service advertisement status changes
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( MDunServAdvMon )
+    {
+
+public:
+
+    /**
+     * Gets called when advertisement status changes to start
+     *
+     * @since S60 5.0
+     * @param aCreation ETrue if channel creation
+     *                  EFalse if channel free
+     * @return None
+     */
+    virtual void NotifyAdvertisementStart( TBool aCreation ) = 0;
+
+    /**
+     * Gets called when advertisement status changes to end
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    virtual void NotifyAdvertisementEnd() = 0;
+
+    };
+
+/**
+ *  Notification interface class for buffer correction
+ *  This interface makes possible to change suggested local media buffer size
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( MDunBufferCorrection )
+    {
+
+public:
+
+    /**
+     * Notifies about request to change local media's buffer size
+     *
+     * @since S60 3.2
+     * @param aLength Suggested buffer length that will be used if no
+     *                correction done
+     * @return New (corrected) buffer length
+     */
+    virtual TInt NotifyBufferCorrection( TInt aLength ) = 0;
+
+    };
+
+/**
+ *  Class to store data needed for each separate "channel"
+ *  One TDunChannelData data contains objects needed for one channel
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( TDunChannelData )
+    {
+
+public:
+
+    /**
+     * RComm object of network side
+     * Not own.
+     */
+    RComm* iNetwork;
+
+    /**
+     * RComm object of local media side
+     * If this is set then iSocket is not used
+     * Not own.
+     */
+    RComm* iComm;
+
+    /**
+     * RSocket object of local media side
+     * If this is set then iComm is not used
+     * Not own.
+     */
+    RSocket* iSocket;
+
+    /**
+     * Name for the channel
+     */
+    HBufC8* iChannelName;
+
+    /**
+     * Upstream read/write object
+     * Reads data from local media and writes to network
+     * Not own.
+     */
+    CDunUpstream* iUpstreamRW;
+
+    /**
+     * Downstream read/write object
+     * Reads data from network and writes to local media
+     * Not own.
+     */
+    CDunDownstream* iDownstreamRW;
+
+    /**
+     * Upstream buffer (Local -> Network)
+     * Not own.
+     */
+    TUint8* iBufferUpstream;
+
+    /**
+     * Downstream buffer (Local <- Network)
+     * Not own.
+     */
+    TUint8* iBufferDownstream;
+
+    /**
+     * Pointer to upstream's buffer (Local -> Network)
+     * Not own.
+     */
+    TPtr8* iBufferUpPtr;
+
+    /**
+     * Pointer to downstream's buffer (Local <- Network)
+     * Not own.
+     */
+    TPtr8* iBufferDownPtr;
+
+    /**
+     * Upstream signal copy
+     * If this is set then iSignalNotify is not used
+     * Not own.
+     */
+    CDunSignalCopy* iUpstreamSignalCopy;
+
+    /**
+     * Downstream signal copy
+     * If this is set then iSignalNotify is not used
+     * Not own.
+     */
+    CDunSignalCopy* iDownstreamSignalCopy;
+
+    /**
+     * Signal notifier
+     * If this is set then the following are not used:
+     * iUpstreamSignalCopy, iDownstreamSignalCopy
+     * Not own.
+     */
+    CDunSignalNotify* iSignalNotify;
+
+    /**
+     * Owner's UID
+     */
+    TUid iOwnerUid;
+
+    /**
+     * Flag that indicates whether this channel is allocated or not
+     */
+    TBool iChannelInUse;
+
+    };
+
+/**
+ *  Class to store data needed for each plugin service advertisement
+ *  One TDunChannelData data contains objects needed for one plugin
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( TDunServAdvData )
+    {
+
+public:
+
+    /**
+     * Owner's UID for which to have the monitor
+     */
+    TUid iOwnerUid;
+
+    /**
+     * Service advertisement monitor
+     * Not own.
+     */
+    MDunServAdvMon* iServAdvMon;
+
+    };
+
+/**
+ *  Class for managing abstracted "channels" of network side communication
+ *  This is main class to be used by other components
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CDunTransporter ) : public CBase
+    {
+
+    friend class CDunTransUtils;
+    friend class CDunChanMan;
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aPluginManager Callback to call when notification via
+     *                       MDunPluginManager to be made
+     * @param aNumOfMaxChannels Number of wanted maximum channels
+     *                          (can be omitted with 0)
+     * @return Instance of self
+     */
+	IMPORT_C static CDunTransporter* NewL( MDunPluginManager* aPluginManager,
+	                                       TInt aNumOfMaxChannels=0 );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunTransporter();
+
+    /**
+     * Number of allocated channels, is the same number as allocated and active
+     * (non-waiting) channels
+     *
+     * @since S60 3.2
+     * @return Number of allocated channels
+     */
+    IMPORT_C TInt NumberOfAllocatedChannels();
+
+    /**
+     * Number of waiting channels, is the same number as allocated and inactive
+     * (waiting) channels
+     *
+     * @since S60 3.2
+     * @return Number of waiting channels
+     */
+    IMPORT_C TInt NumberOfWaitingChannels();
+
+    /**
+     * Gets the number of allocated channels by owner UID, is the same number
+     * as allocated and active (non-waiting) channels
+     *
+     * @since S60 5.0
+     * @param aOwnerUid UID of the channel owner
+     * @return Number of allocated channels by UID
+     */
+    IMPORT_C TInt GetNumberOfAllocatedChannelsByUid( TUid aOwnerUid );
+
+    /**
+     * Gets the number of waiting channels by owner UID, is the same number
+     * as allocated and inactive (waiting) channels
+     *
+     * @since S60 5.0
+     * @param aOwnerUid UID of the channel owner
+     * @return Number of waiting channels by UID
+     */
+    IMPORT_C TInt GetNumberOfWaitingChannelsByUid( TUid aOwnerUid );
+
+    /**
+     * Service advertisement status
+     *
+     * @since S60 5.0
+     * @return ETrue if OK to advertise, EFalse otherwise
+     */
+    IMPORT_C TBool AdvertisementStatus();
+
+    /**
+     * Creates a channel of communication between local media (aComm) and
+     * network
+     * Local media object pointer also works as a connection ID for the
+     * allocated channel
+     *
+     * @since S60 3.2
+     * @param aComm Pointer to opened local media RComm ID object
+     * @param aOwnerUid UID of the channel owner
+     * @param aName Name for the channel
+     * @param aEnqueuedFail ETrue if enqueued failure, EFalse otherwise
+     * @param aCorrection Pointer to object implementing buffer correction
+     * @return None
+     */
+    IMPORT_C void AllocateChannelL(
+        RComm* aComm,
+        TUid aOwnerUid,
+        const TDesC8& aName,
+        TBool aEnqueuedFail,
+        MDunBufferCorrection* aCorrection=NULL );
+
+    /**
+     * Creates a channel of communication between local media (aSocket) and
+     * network
+     * Local media object pointer also works as a connection ID for the
+     * allocated channel
+     *
+     * @since S60 3.2
+     * @param aSocket Pointer to opened local media RSocket ID object
+     * @param aOwnerUid UID of the channel owner
+     * @param aName Name for the channel
+     * @param aEnqueuedFail ETrue if enqueued failure, EFalse otherwise
+     * @param aNoFreeChans ETrue if no free channels, EFalse otherwise
+     * @return None
+     */
+    IMPORT_C void AllocateChannelL(
+        RSocket* aSocket,
+        TUid aOwnerUid,
+        const TDesC8& aName,
+        TBool aEnqueuedFail,
+        TBool& aNoFreeChans );
+
+    /**
+     * Frees an allocated channel by local media (aComm) connection ID
+     *
+     * @since S60 3.2
+     * @param aComm Pointer to opened local media RComm ID object
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    IMPORT_C TInt FreeChannel( RComm* aComm );
+
+    /**
+     * Frees an allocated channel by local media (aSocket) connection ID
+     *
+     * @since S60 3.2
+     * @param aSocket Pointer to opened local media RSocket ID object
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    IMPORT_C TInt FreeChannel( RSocket* aSocket );
+
+    /**
+     * Issues transfer requests for all transfer objects by local media
+     * (aComm) connection ID
+     * This will cause the Transporter by be ready for transferring data
+     *
+     * @since S60 3.2
+     * @param aComm Pointer to opened local media RComm ID object
+     * @return None
+     */
+    IMPORT_C void IssueTransferRequestsL( RComm* aComm );
+
+    /**
+     * Issues transfer requests for all transfer objects by local media
+     * (aSocket) connection ID
+     * This will cause the Transporter by be ready for transferring data
+     *
+     * @since S60 3.2
+     * @param aSocket Pointer to opened local media RSocket ID object
+     * @return None
+     */
+    IMPORT_C void IssueTransferRequestsL( RSocket* aSocket );
+
+    /**
+     * Stops transfers for all transfer objects by local media (aComm)
+     * connection ID
+     *
+     * @since S60 3.2
+     * @param aComm Pointer to opened local media RComm ID object
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    IMPORT_C TInt StopTransfers( RComm* aComm );
+
+    /**
+     * Stops transfers for all transfer objects by local media (aSocket)
+     * connection ID
+     *
+     * @since S60 3.2
+     * @param aSocket Pointer to opened local media RSocket ID object
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    IMPORT_C TInt StopTransfers( RSocket* aSocket );
+
+    /**
+     * Adds connection monitor callback for either local media or network side
+     * by connection ID
+     * Callbacks will be called read/write error is detected during endpoint
+     * operation
+     *
+     * @since S60 3.2
+     * @param aComm Pointer to opened local media RComm ID object
+     * @param aCallback Pointer to object whose callbacks will be called
+     * @param aDirection Direction of operation to monitor for read/write error
+     * @param aSignal ETrue if also signal notification wanted from network side
+     * @return None
+     */
+    IMPORT_C void AddConnMonCallbackL( RComm* aComm,
+                                       MDunConnMon* aCallback,
+                                       TDunDirection aDirection,
+                                       TBool aSignal );
+
+    /**
+     * Adds connection monitor callback for either local media or network side
+     * by connection ID
+     * Callbacks will be called when line status switches to high or low
+     *
+     * @since S60 3.2
+     * @param aSocket Pointer to opened local media RSocket ID object
+     * @param aCallback Pointer to object whose callbacks will be called
+     * @param aDirection Direction of operation to monitor for read/write error
+     * @param aSignal ETrue if also signal notification wanted from network side
+     * @return None
+     */
+    IMPORT_C void AddConnMonCallbackL( RSocket* aSocket,
+                                       MDunConnMon* aCallback,
+                                       TDunDirection aDirection,
+                                       TBool aSignal );
+
+    /**
+     * Adds error to consider as no error condition when doing any of the four
+     * endpoint's read/writer operation
+     *
+     * @since S60 3.2
+     * @param aError Error code to consider as "no error"
+     * @param aComm Pointer to opened local media RComm ID object
+     * @param aDirection One of four data transfer endpoints where to add a
+     *                   skipped error code
+     * @return None
+     */
+    IMPORT_C void AddSkippedErrorL( TInt aError,
+                                    RComm* aComm,
+                                    TDunDirection aDirection );
+
+    /**
+     * Adds error to consider as no error condition when doing any of the four
+     * endpoint's read/writer operation
+     *
+     * @since S60 3.2
+     * @param aError Error code to consider as "no error"
+     * @param aSocket Pointer to opened local media RSocket ID object
+     * @param aDirection One of four data transfer endpoints where to add a
+     *                   skipped error code
+     * @return None
+     */
+    IMPORT_C void AddSkippedErrorL( TInt aError,
+                                    RSocket* aSocket,
+                                    TDunDirection aDirection );
+
+    /**
+     * Sets service advertisement monitor callback by owner UID
+     * Callbacks will be called when advertisement status changes.
+     * The callbacks are updated with every successfully completed
+     * channel allocation/free (and allocation failure) so it is recommended
+     * to call this method after AllocateChannelL().
+     *
+     * @since S60 5.0
+     * @param aOwnerUid Owner's UID for which to have the monitor
+     * @param aCallback Pointer to object whose callbacks will be called
+     * @return None
+     */
+    IMPORT_C void SetAdvertisementMonitorL( TUid aOwnerUid,
+                                            MDunServAdvMon* aCallback );
+
+    /**
+     * Frees service advertisement monitor callback by owner UID
+     *
+     * @since S60 5.0
+     * @param aOwnerUid Owner's UID for which to have the monitor
+     * @param aCallback Pointer to object whose callbacks will be called
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    IMPORT_C TInt FreeAdvertisementMonitor( TUid aOwnerUid,
+                                            MDunServAdvMon* aCallback );
+
+private:
+
+    CDunTransporter( MDunPluginManager* aPluginManager,
+                     TInt aNumOfMaxChannels );
+
+    void ConstructL();
+
+    /**
+     * Initializes the transporter, must be called as the first operation
+     *
+     * @since S60 3.2
+     * @return KErrAlreadyExists = already initialized,
+     *         KErrGeneral = network initialization failed,
+     *         KErrNone otherwise
+     */
+    TInt InitializeL();
+
+    /**
+     * UnInitializes the transporter, can be called as the last operation
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void UnInitialize();
+
+    /**
+     * Initialize the transporter
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt InitializeOnDemand();
+
+    /**
+     * UnInitialize the transporter
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt UnInitializeOnDemand();
+
+    /**
+     * Returns index of media for connection ID
+     *
+     * @since S60 3.2
+     * @param aConnId Connection ID for media
+     * @param aMediaContext Context of media to search for; either local or
+     *                      network
+     * @return Symbian error code on error, found index otherwise
+     */
+    TInt GetMediaIndex( TConnId aConnId,
+                        TDunMediaContext aMediaContext=EDunMediaContextLocal );
+
+    /**
+     * Returns index of media for connection ID
+     *
+     * @since S60 3.2
+     * @param aConnId Connection ID for media
+     * @param aMediaContext Context of media to search for; either local or
+     *                      network
+     * @return Found index
+     */
+    TInt GetMediaIndexL( TConnId aConnId,
+                         TDunMediaContext aMediaContext=EDunMediaContextLocal );
+
+    /**
+     * Checks initialization and RSubSessionBase() handle
+     *
+     * @since S60 3.2
+     * @param aConnId Connection ID for media
+     * @return KErrNotReady if not initialized, KErrBadHandle if no handle
+     */
+    TInt CheckInitAndHandle( TConnId aConnId );
+
+    /**
+     * Deletes own internal data
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void DeleteTransporter();
+
+private:  // data
+
+    /**
+     * Pointer to common utility class
+     * Own.
+     */
+    MDunTransporterUtility* iUtility;
+
+    /**
+     * Pointer to RComm channel manager class
+     * Own.
+     */
+    CDunChanMan* iChanMan;
+
+    /**
+     * Pointer to note handler class
+     * Own.
+     */
+    CDunNoteHandler* iNoteHandler;
+
+    /**
+     * Array of abstractions of each "channel"
+     * One TDunChannelData entry contains objects needed for one channel
+     */
+    RArray<TDunChannelData> iChannelData;
+
+    /**
+     * Array of service advertisement data for each plugin
+     * One TDunServAdvData entry contains objects needed for one plugin
+     */
+    RArray<TDunServAdvData> iServAdvData;
+
+    /**
+     * Callback to call when notification via MDunPluginManager to be made
+     * Not own.
+     */
+    MDunPluginManager* iPluginManager;
+
+    /**
+     * Number of channels that are active
+     * Used for updating KPSUidDialupConnStatus Pub&Sub key
+     */
+    TInt iActiveChannels;
+
+    /**
+     * Number of wanted maximum channels (can be omitted with 0)
+     * Used for initialization of this class
+     */
+    TInt iNumOfMaxChannels;
+
+    /**
+     * Indicates whether this class is initialized or not
+     */
+    TBool iInitialized;
+
+    /**
+     * Indicates whether or not it is OK to advertise services
+     */
+    TBool iAdvertise;
+
+    /**
+     * Instance of network side abstraction
+     * Own.
+     */
+    CDunNetDataport* iNetwork;
+
+    };
+
+#endif  // C_CDUNTRANSPORTER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/inc/DunUpstream.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,366 @@
+/*
+* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definitions needed for one "stream" of CDunTransporter
+*
+*/
+
+
+#ifndef C_CDUNUPSTREAM_H
+#define C_CDUNUPSTREAM_H
+
+#include "DunTransUtils.h"
+#include "DunStream.h"
+#include "DunAtCmdHandler.h"
+#include "DunAtCmdEchoer.h"
+#include "DunDataPusher.h"
+
+class MDunCmdModeMonitor;
+
+/**
+ *  Class used for storing data related to activity monitoring
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( TDunActivityData )
+    {
+
+public:
+
+    /**
+     * Callback to call when notification via MDunActivityManager to be made
+     * Not own.
+     */
+    MDunActivityManager* iActivityCallback;
+
+    /**
+     * Flag for data read activity's MDunActivityManager callback
+     * This flag is needed to prevent multiple notifications of same activity
+     */
+    TBool iDataRead;
+
+    /**
+     * Used as a flag for the first notification of read activity
+     * This flag is needed to keep MDunActivityManager notifications in sync
+     * (inactivity notification done only if activity notification done first)
+     */
+    TBool iNotified;
+
+    };
+
+/**
+ *  Class used for storing data related to AT command parsing
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( TDunParseData )
+    {
+
+public:
+
+    /**
+     * Flag for command mode notifier's MDunCmdModeMonitor callback
+     * This flag is needed to mark command mode start/end for parse start/end
+     */
+    TBool iDataMode;
+
+    /**
+     * Flag to indicate whether AT parsing is needed or not
+     */
+    TBool iParseNeeded;
+
+    /**
+     * Flag to be set when AT command handling starts
+     */
+    TBool iHandling;
+
+    /**
+     * AT Command handler. Used if iAtParseNeeded is ETrue
+     */
+    CDunAtCmdHandler* iAtCmdHandler;
+
+    };
+
+/**
+ *  Accessor class for AT command handling related functionality
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( MDunAtCmdHandler )
+    {
+
+public:
+
+    /**
+     * Starts URC message handling
+     * This is an accessor for CDunDownstream's StartStream()
+     *
+     * @since S60 5.0
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    virtual TInt StartUrc() = 0;
+
+    /**
+     * Stops AT command handling downstream related activity (also URC)
+     * This is an accessor for CDunDownstream's Stop()
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    virtual TInt StopAtCmdHandling() = 0;
+
+    };
+
+/**
+ *  Class for data transmission of one "stream" from local media to network
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CDunUpstream ) : public CDunStream,
+                                    public MDunAtCmdHandler,
+                                    public MDunCmdModeMonitor,
+                                    public MDunAtCmdStatusReporter,
+                                    public MDunAtCmdEchoer
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aUtility Pointer to common utility class
+     * @return Instance of self
+     */
+	static CDunUpstream* NewL( MDunTransporterUtilityAux* aUtility );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDunUpstream();
+
+    /**
+     * Resets data to initial values
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void ResetData();
+
+    /**
+     * Sets activity callback for this stream
+     *
+     * @since S60 3.2
+     * @param aActivityCallback Pointer to activity callback
+     * @return KErrGeneral if callback null, KErrNone otherwise
+     */
+    TInt SetActivityCallback( MDunActivityManager* aActivityCallback );
+
+    /**
+     * Initializes this stream for AT command notifications
+     *
+     * @since S60 5.0
+     * @param aStreamCallback Pointer to stream callback
+     * @param aConnectionName Connection identifier name
+     * @param aCallbackUp Upstream callback to call when command mode starts or
+     *                    ends
+     * @param aCallbackDown Downstream callback to call when command mode starts
+     *                    or ends
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt InitializeForAtParsing( MDunStreamManipulator* aStreamCallback,
+                                 const TDesC8* aConnectionName,
+                                 MDunCmdModeMonitor* aCallbackUp,
+                                 MDunCmdModeMonitor* aCallbackDown );
+
+    /**
+     * Starts upstream by issuing read request
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt StartStream();
+
+    /**
+     * Stops transfer for read & write endpoints
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt Stop();
+
+    /**
+     * Data transmission state (if read completed)
+     *
+     * @since S60 3.2
+     * @return ETrue if data successfully read, EFalse otherwise
+     */
+    TBool DataReadStatus();
+
+private:
+
+    CDunUpstream( MDunTransporterUtilityAux* aUtility );
+
+    void ConstructL();
+
+    /**
+     * Initializes this class
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void Initialize();
+
+    /**
+     * Issues transfer request for this stream
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt IssueRequest();
+
+    /**
+     * Processes data that was read
+     *
+     * @since S60 5.0
+     * @return ETrue if request to be reissued, EFalse otherwise
+     */
+    TBool ProcessReadData();
+
+    /**
+     * Manages activity in a channel
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt ManageChannelActivity();
+
+// from base class CActive
+
+    /**
+     * From CActive.
+     * Gets called when endpoint data read/write complete
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void RunL();
+
+    /**
+     * From CActive.
+     * Gets called on cancel
+     *
+     * @since S60 3.2
+     * @return None
+     */
+    void DoCancel();
+
+// from base class MDunAtCmdStatusReporter
+
+    /**
+     * Notifies about AT command handling start
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void NotifyAtCmdHandlingStart();
+
+    /**
+     * Notifies about AT command handling end
+     *
+     * @since S60 5.0
+     * @param aEndIndex Index to the start of next command
+     * @return None
+     */
+    void NotifyAtCmdHandlingEnd( TInt aStartIndex );
+
+    /**
+     * Notifies about editor mode reply
+     *
+     * @since TB9.2
+     * @param aStart ETrue if start of editor mode, EFalse otherwise
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    void NotifyEditorModeReply( TBool aStart );
+
+// from base class MDunAtCmdHandler
+
+    /**
+     * Starts URC message handling
+     * This is an accessor for CDunDownstream's StartStream()
+     *
+     * @since S60 5.0
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt StartUrc();
+
+    /**
+     * Stops AT command handling downstream related activity (also URC)
+     * This is an accessor for CDunDownstream's Stop()
+     *
+     * @since S60 3.2
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    TInt StopAtCmdHandling();
+
+// from base class MDunCmdModeMonitor
+
+    /**
+     * Notifies about command mode start
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void NotifyCommandModeStart();
+
+    /**
+     * Notifies about command mode end
+     *
+     * @since S60 5.0
+     * @return None
+     */
+    void NotifyCommandModeEnd();
+
+// from base class MDunAtCmdEchoer
+
+    /**
+     * Notifies about completed echo in text mode
+     *
+     * @since TB9.2
+     * @return None
+     */
+    void NotifyEchoComplete();
+
+private:  // data
+
+    /**
+     * Pointer to common utility class
+     * Not own.
+     */
+    MDunTransporterUtilityAux* iUtility;
+
+    /**
+     * Data related to activity monitoring
+     */
+    TDunActivityData iActivityData;
+
+    /**
+     * Data related to AT command parsing
+     */
+    TDunParseData iParseData;
+
+    };
+
+#endif  // C_CDUNUPSTREAM_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/inc/DunUtils.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Common utility methods for DUN
+*
+*/
+
+
+#ifndef C_CDUNUTILS_H
+#define C_CDUNUTILS_H
+
+#ifdef PRJ_USE_NETWORK_STUBS
+#include <c32comm_stub.h>
+#else
+#include <c32comm.h>
+#endif
+#include <e32std.h>
+
+/**
+ *  This class contains common utility methods for DUN
+ *
+ *  @lib dunutils.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CDunUtils ) : public CBase
+    {
+
+public:
+
+    /**
+     * Connects to comms server
+     *
+     * @since S60 3.2
+     * @param aCommServer Comms server where to connect
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    IMPORT_C static TInt ConnectCommsServer( RCommServ& aCommServer );
+
+    /**
+     * Sets RComm buffer length
+     *
+     * @since S60 3.2
+     * @param aComm RComm object whose length to set
+     * @param aLength Length to set to aComm
+     * @return Symbian error code on error, KErrNone otherwise
+     */
+    IMPORT_C static TInt SetRCommBufferLength( RComm& aComm, TInt aLength );
+
+    };
+
+#endif  // C_CDUNUTILS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/loc/dunutils.loc	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Localization strings for project DUN
+*
+*/
+
+
+// d: When a maximum number of dial-up connections with any bearer are already established
+// d: and the user tries to set up another one, a global query with this text is shown.
+// d: Query has only left softkey OK $text.softkey.ok$. This softkey confirms that user
+// d: see the note. User has to press softkey or Selection key and after that the note
+// d: disappears.
+// l: popup_note_window
+// w:
+// r: 5.0
+#define qtn_dun_max_number "Maximum number of dialup-connections. Dial-up failed."
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/src/DunChanMan.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,577 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  RComm channel management related functionality (waiter)
+*
+*/
+
+
+#include "DunSignalWaiter.h"
+#include "DunDataWaiter.h"
+#include "DunUpstream.h"
+#include "DunDownstream.h"
+#include "DunSignalCopy.h"
+#include "DunChanMan.h"
+#include "DunUtils.h"
+#include "DunDebug.h"
+#include "DunPlugin.h"
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunChanMan* CDunChanMan::NewL( CDunTransporter& aParent,
+                                MDunTransporterUtility* aUtility,
+                                MDunTransporterUtilityAux* aUtilityAux,
+                                MDunPluginManager* aPluginManager )
+    {
+    CDunChanMan* self = new (ELeave) CDunChanMan( aParent,
+                                                  aUtility,
+                                                  aUtilityAux,
+                                                  aPluginManager );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunChanMan::~CDunChanMan()
+    {
+    FTRACE(FPrint( _L("CDunChanMan::~CDunChanMan()") ));
+    ResetData();
+    FTRACE(FPrint( _L("CDunChanMan::~CDunChanMan() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Resets data to initial values
+// ---------------------------------------------------------------------------
+//
+void CDunChanMan::ResetData()
+    {
+    FTRACE(FPrint( _L("CDunChanMan::ResetData()") ));
+    // APIs affecting this:
+    // AddConnWaiterL()
+    // IssueConnWaiterRequest()
+    TInt i;
+    TInt count = iWaiterData.Count();
+    for ( i=0; i<count; i++ )
+        {
+        DeleteWaiters( i );
+        }
+    iWaiterData.Close();
+    FTRACE(FPrint( _L("CDunChanMan::ResetData() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Number of waiters
+// ---------------------------------------------------------------------------
+//
+TInt CDunChanMan::NumberOfWaiters()
+    {
+    FTRACE(FPrint( _L("CDunChanMan::NumberOfWaiters()" )));
+    TInt waiters = iWaiterData.Count();
+    FTRACE(FPrint( _L("CDunChanMan::NumberOfWaiters() complete" )));
+    return waiters;
+    }
+
+// ---------------------------------------------------------------------------
+// Gets number of waiters by owner UID
+// ---------------------------------------------------------------------------
+//
+TInt CDunChanMan::GetNumberOfWaitersByUid( TUid aOwnerUid )
+    {
+    FTRACE(FPrint( _L("CDunChanMan::GetNumberOfWaitersByUid()" )));
+    TInt i;
+    TInt waiters = 0;
+    TInt count = iWaiterData.Count();
+    for ( i=0; i<count; i++ )
+        {
+        TDunWaiterData& waiterData = iWaiterData[i];
+        if ( waiterData.iOwnerUid == aOwnerUid )
+            {
+            waiters++;
+            }
+        }
+    FTRACE(FPrint( _L("CDunChanMan::GetNumberOfWaitersByUid() complete" )));
+    return waiters;
+    }
+
+// ---------------------------------------------------------------------------
+// Adds new connection waiter to connection waiter array
+// ---------------------------------------------------------------------------
+//
+void CDunChanMan::AddConnWaiterL( RComm* aComm,
+                                  TUid aOwnerUid,
+                                  const TDesC8& aName,
+                                  TBool aEnqueuedFail,
+                                  MDunBufferCorrection* aCorrection )
+    {
+    FTRACE(FPrint( _L("CDunChanMan::AddConnWaiterL()" )));
+    if ( !aComm )
+        {
+        FTRACE(FPrint( _L("CDunChanMan::AddConnWaiterL() (aComm not initialized!) complete" )));
+        User::Leave( KErrGeneral );
+        }
+    CDunSignalWaiter* signalWaiter = CDunSignalWaiter::NewL( this );
+    CleanupStack::PushL( signalWaiter );
+    TInt retTemp = signalWaiter->SetMedia( aComm );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunChanMan::AddConnWaiterL() (ERROR) complete" )));
+        User::Leave( retTemp );
+        }
+    CDunDataWaiter* dataWaiter = CDunDataWaiter::NewL( this );
+    CleanupStack::PushL( dataWaiter );
+    retTemp = dataWaiter->SetMedia( aComm );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunChanMan::AddConnWaiterL() (ERROR) complete" )));
+        User::Leave( retTemp );
+        }
+    TDunWaiterData waiterData;
+    waiterData.iComm = aComm;
+    waiterData.iChannelName = HBufC8::NewMaxL( aName.Length() );
+    TPtr8 chanNamePtr = waiterData.iChannelName->Des();
+    chanNamePtr.Copy( aName );
+    waiterData.iSignalWaiter = signalWaiter;
+    waiterData.iDataWaiter = dataWaiter;
+    waiterData.iCorrection = aCorrection;
+    waiterData.iEnqueuedFail = aEnqueuedFail;
+    waiterData.iOwnerUid = aOwnerUid;
+    iWaiterData.AppendL( waiterData );
+    CleanupStack::Pop( dataWaiter );
+    CleanupStack::Pop( signalWaiter );
+    FTRACE(FPrint( _L("CDunChanMan::AddConnWaiterL() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Removes existing waiter from connection waiter array
+// ---------------------------------------------------------------------------
+//
+TInt CDunChanMan::RemoveConnWaiter( RComm* aComm )
+    {
+    FTRACE(FPrint( _L("CDunChanMan::RemoveConnWaiter()" )));
+    TInt i;
+    for ( i=iWaiterData.Count()-1; i>=0; i-- )
+        {
+        TDunWaiterData& waiterData = iWaiterData[i];
+        if ( waiterData.iComm == aComm )
+            {
+            DeleteWaiters( i );
+            iWaiterData.Remove( i );
+            FTRACE(FPrint( _L("CDunChanMan::RemoveConnWaiter() complete" )));
+            return KErrNone;
+            }
+        }
+    FTRACE(FPrint( _L("CDunChanMan::RemoveConnWaiter() (not found) complete" )));
+    return KErrNotFound;
+    }
+
+// ---------------------------------------------------------------------------
+// Makes CDunConnWaiter ready to detect new data
+// ---------------------------------------------------------------------------
+//
+TInt CDunChanMan::IssueConnWaiterRequest( RComm* aComm )
+    {
+    FTRACE(FPrint( _L("CDunChanMan::IssueConnWaiterRequest()" )));
+    TInt i;
+    TInt count = iWaiterData.Count();
+    for ( i=0; i<count; i++ )
+        {
+        TDunWaiterData& waiterData = iWaiterData[i];
+        if ( waiterData.iComm == aComm )
+            {
+            waiterData.iSignalWaiter->IssueRequest();
+            waiterData.iDataWaiter->IssueRequest();
+            FTRACE(FPrint( _L("CDunChanMan::IssueConnWaiterRequest() complete" )));
+            return KErrNone;
+            }
+        }
+    FTRACE(FPrint( _L("CDunChanMan::IssueConnWaiterRequest() (not found) complete" )));
+    return KErrNotFound;
+    }
+
+// ---------------------------------------------------------------------------
+// Stops CDunConnWaiter to detect new data
+// ---------------------------------------------------------------------------
+//
+TInt CDunChanMan::StopConnWaiter( RComm* aComm )
+    {
+    FTRACE(FPrint( _L("CDunChanMan::StopConnWaiter()" )));
+    TInt i;
+    TInt count = iWaiterData.Count();
+    for ( i=0; i<count; i++ )
+        {
+        TDunWaiterData& waiterData = iWaiterData[i];
+        if ( waiterData.iComm == aComm )
+            {
+            waiterData.iSignalWaiter->Stop();
+            waiterData.iDataWaiter->Stop();
+            FTRACE(FPrint( _L("CDunChanMan::StopConnWaiter() complete" )));
+            return KErrNone;
+            }
+        }
+    FTRACE(FPrint( _L("CDunChanMan::StopConnWaiter() (not found) complete" )));
+    return KErrNotFound;
+    }
+
+// ---------------------------------------------------------------------------
+// Saves waiter's connection monitor callback data
+// ---------------------------------------------------------------------------
+//
+TInt CDunChanMan::SaveWaiterConnMonCallbackL( RComm* aComm,
+                                              MDunConnMon* aCallback,
+                                              TDunDirection aDirection )
+    {
+    FTRACE(FPrint( _L("CDunChanMan::SaveWaiterConnMonCallbackL()" )));
+    TInt i;
+    TInt count = iWaiterData.Count();
+    for ( i=0; i<count; i++ )
+        {
+        TDunWaiterData& waiterData = iWaiterData[i];
+        if ( waiterData.iComm != aComm )
+            {
+            continue;
+            }
+        TDunConnMonCallback connMon;
+        connMon.iCallback = aCallback;
+        connMon.iDirection = aDirection;
+        if ( aDirection==EDunReaderUpstream ||
+             aDirection==EDunWriterDownstream )
+            {
+            // Local media -> add to object
+            // Add signal waiter's callback (for RunL error monitoring)
+            if ( !waiterData.iSignalWaiter )
+                {
+                FTRACE(FPrint( _L("CDunTransUtils::SaveWaiterConnMonCallbackL() (ERROR) complete" )));
+                return KErrGeneral;
+                }
+            waiterData.iSignalWaiter->AddCallback( aCallback );
+            // Add data waiter's callback (for RunL error monitoring)
+            if ( !waiterData.iDataWaiter )
+                {
+                FTRACE(FPrint( _L("CDunTransUtils::SaveWaiterConnMonCallbackL() (ERROR) complete" )));
+                return KErrGeneral;
+                }
+            waiterData.iDataWaiter->AddCallback( aCallback );
+            // Now just store information for R/W case
+            waiterData.iConnMons.AppendL( connMon );
+            FTRACE(FPrint( _L("CDunChanMan::SaveWaiterConnMonCallbackL() complete" )));
+            return KErrNone;
+            }
+        else if ( aDirection==EDunWriterUpstream ||
+                  aDirection==EDunReaderDownstream )
+            {
+            // Network -> just store information for R/W case
+            waiterData.iConnMons.AppendL( connMon );
+            FTRACE(FPrint( _L("CDunChanMan::SaveWaiterConnMonCallbackL() complete" )));
+            return KErrNone;
+            }
+        else
+            {
+            FTRACE(FPrint( _L("CDunTransUtils::SaveWaiterConnMonCallbackL() (ERROR) complete" )));
+            return KErrGeneral;
+            }
+        }
+    FTRACE(FPrint( _L("CDunChanMan::SaveWaiterConnMonCallbackL() (not found) complete" )));
+    return KErrNotFound;
+    }
+
+// ---------------------------------------------------------------------------
+// Saves waiter's skipped error data
+// ---------------------------------------------------------------------------
+//
+TInt CDunChanMan::SaveWaiterSkippedErrorL( TInt aError,
+                                           RComm* aComm,
+                                           TDunDirection aDirection )
+    {
+    FTRACE(FPrint( _L("CDunChanMan::SaveWaiterSkippedErrorL()" )));
+    TInt i;
+    TInt count = iWaiterData.Count();
+    for ( i=0; i<count; i++ )
+        {
+        TDunWaiterData& waiterData = iWaiterData[i];
+        if ( waiterData.iComm == aComm )
+            {
+            TDunSkippedError skippedError;
+            skippedError.iError = aError;
+            skippedError.iDirection = aDirection;
+            waiterData.iOkErrors.AppendL( skippedError );
+            FTRACE(FPrint( _L("CDunChanMan::SaveWaiterSkippedErrorL() complete" )));
+            return KErrNone;
+            }
+        }
+    FTRACE(FPrint( _L("CDunChanMan::SaveWaiterSkippedErrorL() (not found) complete" )));
+    return KErrNotFound;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunChanMan::CDunChanMan
+// ---------------------------------------------------------------------------
+//
+CDunChanMan::CDunChanMan( CDunTransporter& aParent,
+                          MDunTransporterUtility* aUtility,
+                          MDunTransporterUtilityAux* aUtilityAux,
+                          MDunPluginManager* aPluginManager ) :
+    iParent( aParent ),
+    iUtility( aUtility ),
+    iUtilityAux( aUtilityAux ),
+    iPluginManager( aPluginManager )
+    {
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// CDunChanMan::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunChanMan::ConstructL()
+    {
+    FTRACE(FPrint( _L("CDunChanMan::ConstructL()" ) ));
+    if ( !iUtility || !iUtilityAux || !iPluginManager )
+        {
+        User::Leave( KErrGeneral );
+        }
+    FTRACE(FPrint( _L("CDunChanMan::ConstructL() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes this class
+// ---------------------------------------------------------------------------
+//
+void CDunChanMan::Initialize()
+    {
+    FTRACE(FPrint( _L("CDunChanMan::Initialize()" ) ));
+    // Don't initialize iParent here (it is set through NewL)
+    // Don't initialize iUtility here (it is set through NewL)
+    // Don't initialize iUtilityAux here (it is set through NewL)
+    // Don't initialize iPluginManager here (it is set through NewL)
+    FTRACE(FPrint( _L("CDunChanMan::Initialize() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunChannelAllocator.
+// Notifies when new channel is wanted
+// ---------------------------------------------------------------------------
+//
+TInt CDunChanMan::NotifyNewChannelRequest( RComm* aComm )
+    {
+    FTRACE(FPrint( _L("CDunChanMan::NotifyNewChannelRequest()" )));
+    if ( !aComm->SubSessionHandle() )
+        {
+        FTRACE(FPrint( _L("CDunChanMan::NotifyNewChannelRequest() (RComm) (bad handle) complete" ) ));
+        return KErrBadHandle;
+        }
+    // Get plugin UID for connection ID
+    TInt i;
+    TUid foundUid = TUid::Null();
+    TInt count = iWaiterData.Count();
+    for ( i=0; i<count; i++ )
+        {
+        if ( iWaiterData[i].iComm == aComm )
+            {
+            foundUid = iWaiterData[i].iOwnerUid;
+            break;
+            }
+        }
+    if ( i >= count )
+        {
+        FTRACE(FPrint( _L("CDunChanMan::NotifyNewChannelRequest() (RComm) (not found) complete" )));
+        return KErrNotFound;
+        }
+    TDunWaiterData& waiterData = iWaiterData[i];
+    // Try to stop if either one of the waiters are still runnig
+    waiterData.iSignalWaiter->Stop();
+    waiterData.iDataWaiter->Stop();
+    // enqueued will be omitted (not needed to set to RComm)
+    TInt firstFree = iUtility->InitializeFirstFreeChannel( aComm );
+    if ( firstFree < 0 )
+        {
+        FTRACE(FPrint( _L("CDunChanMan::NotifyNewChannelRequest() (RComm) (firstfree failed!) complete" ) ));
+        return firstFree;
+        }
+    if ( firstFree >= iParent.iChannelData.Count() )
+        {
+        FTRACE(FPrint( _L("CDunChanMan::NotifyNewChannelRequest() (RComm) (firstfree failed!) complete" )));
+        return KErrGeneral;
+        }
+    TInt bufferLength = KErrNotFound;
+    MDunBufferCorrection* correction = waiterData.iCorrection;
+    TRAPD( retTrap,
+        iUtility->DoAllocateChannelL(aComm, bufferLength, firstFree, correction) );
+    if ( retTrap != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunChanMan::NotifyNewChannelRequest() trapped!" ) ));
+        iParent.UnInitializeOnDemand();  // remove unused initialized channel
+        if ( retTrap == KErrTooBig )
+            {
+            if ( waiterData.iEnqueuedFail )
+                {
+                // Inform plugin enqueue request
+                iPluginManager->NotifyPluginEnqueueRequest( foundUid );
+                }
+            FTRACE(FPrint( _L("CDunTransporter::AllocateChannel() (RSocket) complete" )));
+            return KErrTooBig;
+            }
+        iPluginManager->NotifyPluginCloseRequest( foundUid, EFalse );
+        FTRACE(FPrint( _L("CDunChanMan::NotifyNewChannelRequest() (ERROR) complete" )));
+        return retTrap;
+        }
+    TInt retTemp = CDunUtils::SetRCommBufferLength( *aComm, bufferLength );
+    if ( retTemp != KErrNone )
+        {
+        iParent.UnInitializeOnDemand();  // remove unused initialized channel
+        iPluginManager->NotifyPluginCloseRequest( foundUid, EFalse );
+        FTRACE(FPrint( _L("CDunChanMan::NotifyNewChannelRequest() (ERROR) complete" )));
+        }
+    // Next find aComm from iWaiterData and copy its contents to channel data
+    retTemp = FillNewWaiterChannelData( aComm, firstFree );
+    if ( retTemp != KErrNone )
+        {
+        iParent.UnInitializeOnDemand();  // remove unused initialized channel
+        iPluginManager->NotifyPluginCloseRequest( foundUid, EFalse );
+        FTRACE(FPrint( _L("CDunChanMan::NotifyNewChannelRequest() (RComm) (not found) complete" )));
+        }
+    FTRACE(FPrint( _L("CDunChanMan::NotifyNewChannelRequest() (RComm) complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Fills data for channel created by waiter
+// ---------------------------------------------------------------------------
+//
+TInt CDunChanMan::FillNewWaiterChannelData( RComm* aComm,
+                                            TInt aFirstFree )
+    {
+    FTRACE(FPrint( _L("CDunChanMan::FillNewWaiterChannelData()" )));
+    TInt i;
+    TInt count = iWaiterData.Count();
+    for ( i=0; i<count; i++ )
+        {
+        if ( iWaiterData[i].iComm == aComm )
+            {
+            break;
+            }
+        }
+    if ( i >= count ||
+         aFirstFree < 0 ||
+         aFirstFree >= iParent.iChannelData.Count() )
+        {
+        FTRACE(FPrint( _L("CDunChanMan::FillNewWaiterChannelData() (not found) complete" )));
+        return KErrNotFound;
+        }
+    TUid thisUid = iWaiterData[i].iOwnerUid; // pick up before remove
+    TDunChannelData& channelData = iParent.iChannelData[aFirstFree];
+    TDunWaiterData& waiterData = iWaiterData[i];
+    channelData.iComm = waiterData.iComm;
+    channelData.iChannelName = waiterData.iChannelName;
+    channelData.iUpstreamRW->SetMedia( aComm, EDunMediaContextLocal );
+    channelData.iDownstreamRW->SetMedia( aComm, EDunMediaContextLocal );
+    channelData.iOwnerUid = thisUid;
+    // Channel now occupied
+    channelData.iChannelInUse = ETrue;
+    // Restore data from waiter to transfer objects
+    RestoreWaiterData( i, aFirstFree );
+    // Now delete waiters before request issuing
+    DeleteWaiters( i, ETrue );
+    iWaiterData.Remove( i );
+    // Issue transfer requests
+    iUtility->DoIssueTransferRequests( aFirstFree );
+    // Clear the queue, just to be sure
+    iPluginManager->NotifyPluginDequeueRequest( thisUid );
+    FTRACE(FPrint( _L("CDunChanMan::FillNewWaiterChannelData() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Restores saved waiter data to connection data
+// ---------------------------------------------------------------------------
+//
+TInt CDunChanMan::RestoreWaiterData( TInt aWaiterIndex,
+                                     TInt aChannelIndex )
+    {
+    FTRACE(FPrint( _L("CDunChanMan::RestoreWaiterData()" )));
+    if ( aWaiterIndex < 0 ||
+         aWaiterIndex >= iWaiterData.Count() ||
+         aChannelIndex < 0 ||
+         aChannelIndex >= iParent.iChannelData.Count() )
+        {
+        FTRACE(FPrint( _L("CDunChanMan::RestoreWaiterData() (not found) complete" )));
+        return KErrNotFound;
+        }
+    TInt i;
+    TInt count = iWaiterData[aWaiterIndex].iConnMons.Count();
+    for ( i=0; i<count; i++ )
+        {
+        TDunConnMonCallback& connMon = iWaiterData[aWaiterIndex].iConnMons[i];
+        // Add connection monitor callbacks (ignore errors)
+        // Errors are ignored because in this phase they cannot be reported to
+        // plugins. Instead add error checking to
+        // CDunTransporter::AddConnMonCallbackL() if needed
+        iUtility->DoAddConnMonCallback( aChannelIndex,
+                                        connMon.iCallback,
+                                        connMon.iDirection,
+                                        NULL );
+        }
+    count = iWaiterData[aWaiterIndex].iOkErrors.Count();
+    for (i=0; i<count; i++)
+        {
+        TDunSkippedError& skippedError = iWaiterData[aWaiterIndex].iOkErrors[i];
+        // Add skipped errors (ignore errors)
+        // Errors are ignored because in this phase they cannot be reported to
+        // plugins. Instead add error checking to
+        // CDunTransporter::AddSkippedErrorL() if needed
+        iUtility->DoAddSkippedError( aChannelIndex,
+                                     skippedError.iError,
+                                     skippedError.iDirection );
+        }
+    FTRACE(FPrint( _L("CDunChanMan::RestoreWaiterData() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Deletes waiter objects of aIndex:th waiters
+// ---------------------------------------------------------------------------
+//
+TInt CDunChanMan::DeleteWaiters( TInt aIndex, TBool aNewOwnership )
+    {
+    FTRACE(FPrint( _L("CDunChanMan::DeleteWaiters()" )));
+
+    if ( aIndex < 0 ||
+         aIndex >= iWaiterData.Count() )
+        {
+        FTRACE(FPrint( _L("CDunChanMan::DeleteWaiters() (not found) complete" )));
+        return KErrNotFound;
+        }
+
+    TDunWaiterData& waiterData = iWaiterData[aIndex];
+    if ( !aNewOwnership )
+        {
+        delete waiterData.iChannelName;
+        }
+    waiterData.iChannelName = NULL;
+    delete waiterData.iSignalWaiter;
+    waiterData.iSignalWaiter = NULL;
+    delete waiterData.iDataWaiter;
+    waiterData.iDataWaiter = NULL;
+
+    waiterData.iConnMons.Close();
+    waiterData.iOkErrors.Close();
+
+    FTRACE(FPrint( _L("CDunChanMan::DeleteWaiters() complete" )));
+    return KErrNone;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/src/DunDataPusher.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,449 @@
+/*
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Pushes data to existing stream from outside
+*
+*/
+
+
+#include "DunDataPusher.h"
+#include "DunDownstream.h"
+#include "DunDebug.h"
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunDataPusher* CDunDataPusher::NewL( CDunDownstream& aParent,
+                                      MDunCompletionReporter* aStreamCallback )
+    {
+    CDunDataPusher* self = new (ELeave) CDunDataPusher( aParent,
+                                                        aStreamCallback );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunDataPusher::~CDunDataPusher()
+    {
+    FTRACE(FPrint( _L("CDunDataPusher::~CDunDataPusher()" )));
+    ResetData();
+    FTRACE(FPrint( _L("CDunDataPusher::~CDunDataPusher() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Resets data to initial values
+// ---------------------------------------------------------------------------
+//
+void CDunDataPusher::ResetData()
+    {
+    // APIs affecting this:
+    // SendQueuedData()
+    Stop();
+    // AddToEventQueue()
+    iEventQueue.Close();
+    // Internal
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// Sets media to be used for this endpoint
+// ---------------------------------------------------------------------------
+//
+TInt CDunDataPusher::SetMedia( RComm* aComm )
+    {
+    FTRACE(FPrint( _L("CDunDataPusher::SetMedia() (RComm)" )));
+    if ( !aComm )
+        {
+        FTRACE(FPrint( _L("CDunDataPusher::SetMedia() (RComm) (not initialized!) complete" )));
+        return KErrGeneral;
+        }
+    iComm = aComm;
+    FTRACE(FPrint( _L("CDunDataPusher::SetMedia() (RComm) complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Sets media to be used for this endpoint
+// ---------------------------------------------------------------------------
+//
+TInt CDunDataPusher::SetMedia( RSocket* aSocket )
+    {
+    FTRACE(FPrint( _L("CDunDataPusher::SetMedia() (RSocket)" )));
+    if ( !aSocket )
+        {
+        FTRACE(FPrint( _L("CDunDataPusher::SetMedia() (RSocket) (not initialized!) complete" )));
+        return KErrGeneral;
+        }
+    iSocket = aSocket;
+    FTRACE(FPrint( _L("CDunDataPusher::SetMedia() (RSocket) complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Adds event notification to queue
+// ---------------------------------------------------------------------------
+//
+TInt CDunDataPusher::AddToEventQueue( const TDesC8 *aPushedData,
+                                      MDunCompletionReporter* aCallback )
+    {
+    FTRACE(FPrint( _L("CDunDataPusher::AddToQueue()" )));
+    if ( !aPushedData || aPushedData->Length()<0 )
+        {
+        FTRACE(FPrint( _L("CDunDataPusher::AddToQueue() (unknown data) complete" )));
+        return KErrGeneral;
+        }
+    // Check if identical pointer to data already exists
+    TInt foundIndex = FindEventFromQueue( aPushedData );
+    if ( foundIndex >= 0 )
+        {
+        FTRACE(FPrint( _L("CDunDataPusher::AddToQueue() (already exists) complete" )));
+        return KErrAlreadyExists;
+        }
+    // Unique pointer -> add to event queue
+    TDunDataPush dataPush;
+    dataPush.iPushedData = aPushedData;
+    dataPush.iCallback = aCallback;
+    TInt retTemp = iEventQueue.Append( dataPush );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunDataPusher::AddToQueue() (append failed!) complete" )));
+        return retTemp;
+        }
+    FTRACE(FPrint( _L("CDunDataPusher::AddToQueue() complete (%d)" ), iEventQueue.Count() ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Finds an event from queue
+// ---------------------------------------------------------------------------
+//
+TInt CDunDataPusher::FindEventFromQueue( const TDesC8 *aPushedData )
+    {
+    FTRACE(FPrint( _L("CDunDataPusher::FindEventFromQueue()" )));
+    TInt i;
+    TInt count = iEventQueue.Count();
+    for ( i=0; i<count; i++ )
+        {
+        if ( iEventQueue[i].iPushedData == aPushedData )
+            {
+            FTRACE(FPrint( _L("CDunDataPusher::FindEventFromQueue() complete" )));
+            return i;
+            }
+        }
+    FTRACE(FPrint( _L("CDunDataPusher::FindEventFromQueue() (not found) complete" )));
+    return KErrNotFound;
+    }
+
+// ---------------------------------------------------------------------------
+// Stops one event in the event queue
+// ---------------------------------------------------------------------------
+//
+TInt CDunDataPusher::StopOneEvent( const TDesC8 *aPushedData )
+    {
+    FTRACE(FPrint( _L("CDunDataPusher::StopOneEvent()" )));
+    if ( !aPushedData )
+        {
+        FTRACE(FPrint( _L("CDunDataPusher::StopOneEvent() (unknown data) complete" )));
+        return KErrGeneral;
+        }
+    TInt foundIndex = FindEventFromQueue( aPushedData );
+    if ( foundIndex >= 0 )
+        {
+        if ( iEventIndex == foundIndex )
+            {
+            Stop();
+            }
+        FTRACE(FPrint( _L("CDunDataPusher::StopOneEvent() complete" )));
+        return KErrNone;
+        }
+    FTRACE(FPrint( _L("CDunDataPusher::StopOneEvent() (not found) complete" )));
+    return KErrNotFound;
+    }
+
+// ---------------------------------------------------------------------------
+// Sends queued data in round robin
+// ---------------------------------------------------------------------------
+//
+TBool CDunDataPusher::SendQueuedData()
+    {
+    FTRACE(FPrint( _L("CDunDataPusher::SendQueuedData()" )));
+    if ( iPushState!=EDunStateIdle || iEventQueue.Count()==0 )
+        {
+        FTRACE(FPrint( _L("CDunDataPusher::SendQueuedData() (not ready) complete" )));
+        return EFalse;
+        }
+    TInt retTemp = ManageOneEvent();
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunDataPusher::SendQueuedData() (ERROR) complete" )));
+        return EFalse;
+        }
+    iPushState = EDunStateDataPushing;
+    FTRACE(FPrint( _L("CDunDataPusher::SendQueuedData() complete (%d)" ), iEventQueue.Count() ));
+    return ETrue;
+    }
+
+// ---------------------------------------------------------------------------
+// Stops sending for write endpoint
+// ---------------------------------------------------------------------------
+//
+TInt CDunDataPusher::Stop()
+    {
+    FTRACE(FPrint( _L("CDunDataPusher::Stop()" )));
+    if ( iPushState != EDunStateDataPushing )
+        {
+        FTRACE(FPrint( _L("CDunDataPusher::Stop() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    // As the EDunStateDataPushing can be on even with multiple requests,
+    // cancel the actual operation in DoCancel()
+    Cancel();
+    iPushState = EDunStateIdle;
+    FTRACE(FPrint( _L("CDunDataPusher::Stop() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Stops sending for write endpoint and clears event queue
+// ---------------------------------------------------------------------------
+//
+TInt CDunDataPusher::StopAndClearQueue()
+    {
+    FTRACE(FPrint( _L("CDunDataPusher::StopAndClearQueue()" )));
+    TInt retVal = Stop();
+    iEventQueue.Reset();
+    iEventIndex = 0;
+    FTRACE(FPrint( _L("CDunDataPusher::StopAndClearQueue() complete" )));
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// Signals completion status in round robin and clears event queue
+// ---------------------------------------------------------------------------
+//
+TInt CDunDataPusher::SignalCompletionAndClearQueue()
+    {
+    FTRACE(FPrint( _L("CDunDataPusher::SignalCompletionAndClearQueue()" )));
+    // First copy the event queue to temporary notitication queue and
+    // reset the real event queue before notifications. This is done because
+    // implementor of NotifyDataPushComplete() can call AddToEventQueue()
+    // (and KErrAlreadyExists will happen there)
+    TInt i;
+    TInt retTemp;
+    RPointerArray<MDunCompletionReporter> notify;
+    TInt count = iEventQueue.Count();
+    for ( i=0; i<count; i++ )
+        {
+        if ( !iEventQueue[i].iCallback )
+            {
+            continue;
+            }
+        retTemp = notify.Append( iEventQueue[i].iCallback );
+        if ( retTemp != KErrNone )
+            {
+            FTRACE(FPrint( _L("CDunDataPusher::SignalCompletionAndClearQueue() (append failed!) complete" )));
+            return retTemp;
+            }
+        }
+    iEventQueue.Reset();
+    iEventIndex = 0;
+    // Now notify
+    count = notify.Count();
+    for ( i=0; i<count; i++ )
+        {
+        notify[i]->NotifyDataPushComplete( EFalse );
+        }
+    notify.Close();
+    FTRACE(FPrint( _L("CDunDataPusher::SignalCompletionAndClearQueue() complete (%d)" ), count ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunDataPusher::CDunDataPusher
+// ---------------------------------------------------------------------------
+//
+CDunDataPusher::CDunDataPusher( CDunDownstream& aParent,
+                                MDunCompletionReporter* aStreamCallback ) :
+    CActive( EPriorityHigh ),
+    iParent( aParent ),
+    iStreamCallback( aStreamCallback )
+    {
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// CDunDataPusher::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunDataPusher::ConstructL()
+    {
+    FTRACE(FPrint( _L("CDunDataPusher::ConstructL()" )));
+    if ( !iStreamCallback )
+        {
+        User::Leave( KErrGeneral );
+        }
+    CActiveScheduler::Add( this );
+    FTRACE(FPrint( _L("CDunDataPusher::ConstructL() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes this class
+// ---------------------------------------------------------------------------
+//
+void CDunDataPusher::Initialize()
+    {
+    // Don't initialize iUtility here (it is set through NewL)
+    // Don't initialize iStreamCallback here (it is set through NewL)
+    iPushState = EDunStateIdle;
+    iEventIndex = 0;
+    iSocket = NULL;
+    iComm = NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// Manages one event's data push
+// ---------------------------------------------------------------------------
+//
+TInt CDunDataPusher::ManageOneEvent()
+    {
+    FTRACE(FPrint( _L("CDunDataPusher::ManageOneEvent()" )));
+    if ( IsActive() )
+        {
+        FTRACE(FPrint( _L("CDunDataPusher::ManageOneEvent() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    if ( iEventIndex < 0 ||
+         iEventIndex >= iEventQueue.Count() )
+        {
+        FTRACE(FPrint( _L("CDunDataPusher::ManageOneEvent() (buffer mismatch) complete" )));
+        return KErrGeneral;
+        }
+    iStatus = KRequestPending;
+    const TDesC8 *pushedData = iEventQueue[iEventIndex].iPushedData;
+    if ( iComm )
+        {
+        iComm->Write( iStatus, *pushedData );
+        FTRACE(FPrint( _L("CDunDataPusher::ManageOneEvent() RComm Write() requested" ) ));
+        }
+    else if ( iSocket )
+        {
+        iSocket->Send( *pushedData, 0, iStatus );
+        FTRACE(FPrint( _L("CDunDataPusher::ManageOneEvent() RSocket Send() requested" ) ));
+        }
+    else
+        {
+        FTRACE(FPrint( _L("CDunDataPusher::ManageOneEvent() (ERROR) complete" )));
+        return KErrGeneral;
+        }
+    SetActive();
+    FTRACE(FPrint( _L("CDunDataPusher::ManageOneEvent() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Check whether an error code is severe error or not
+// ---------------------------------------------------------------------------
+//
+TInt CDunDataPusher::ProcessErrorCondition( TInt aError, TBool& aIsError )
+    {
+    FTRACE(FPrint( _L("CDunDataPusher::ProcessErrorCondition() (Dir=%d)" ), EDunWriterDownstream));
+    aIsError = EFalse;
+    if ( aError != KErrNone )
+        {
+        aIsError = ETrue;
+        TInt retTemp = iParent.iOkErrorsW.Find( aError );
+        if ( retTemp == KErrNotFound )
+            {
+            FTRACE(FPrint( _L("CDunDataPusher::ProcessErrorCondition() (Dir=%d) (%d=ETrue) complete" ), EDunWriterDownstream, aError));
+            return ETrue;
+            }
+        }
+    FTRACE(FPrint( _L("CDunDataPusher::ProcessErrorCondition() (Dir=%d) (%d=EFalse) complete" ), EDunWriterDownstream, aError));
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called when endpoint data write complete
+// ---------------------------------------------------------------------------
+//
+void CDunDataPusher::RunL()
+    {
+    FTRACE(FPrint( _L("CDunDataPusher::RunL()" )));
+
+    TBool isError;
+    TInt retTemp = iStatus.Int();
+    TInt stop = ProcessErrorCondition( retTemp, isError );
+
+    if ( !stop )  // no real error detected -> continue
+        {
+        if ( !isError )
+            {
+            iEventIndex++;
+            }
+        if ( iEventIndex < iEventQueue.Count() )
+            {
+            // More to serve so start again
+            ManageOneEvent();
+            }
+        else
+            {
+            // Last was served so stop processing and notify
+            iPushState = EDunStateIdle;
+            iStreamCallback->NotifyDataPushComplete( ETrue );
+            }
+        }  // if ( !stop )
+    else  // stop -> tear down connection
+        {
+        TDunConnectionReason connReason;
+        connReason.iReasonType = EDunReasonTypeRW;
+        connReason.iContext = EDunMediaContextLocal;
+        connReason.iSignalType = 0;
+        connReason.iSignalHigh = EFalse;
+        connReason.iDirection = EDunWriterDownstream;
+        connReason.iErrorCode = retTemp;
+        iParent.iUtility->DoNotifyConnectionNotOk( iComm,
+                                                   iSocket,
+                                                   connReason,
+                                                   iParent.iCallbacksW );
+        }  // else
+
+    FTRACE(FPrint( _L("CDunDataPusher::RunL() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called on cancel
+// ---------------------------------------------------------------------------
+//
+void CDunDataPusher::DoCancel()
+    {
+    FTRACE(FPrint( _L("CDunDataPusher::DoCancel()" )));
+    if ( iComm )
+        {
+        iComm->WriteCancel();
+        FTRACE(FPrint( _L("CDunDataPusher::DoCancel() (RComm) cancelled" )));
+        }
+    else if ( iSocket )
+        {
+        iSocket->CancelWrite();
+        FTRACE(FPrint( _L("CDunDataPusher::DoCancel() (RSocket) cancelled" )));
+        }
+    FTRACE(FPrint( _L("CDunDataPusher::DoCancel() complete" )));
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/src/DunDataWaiter.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,253 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Monitors for new data in RComm local media side
+*
+*/
+
+
+#include "DunTransporter.h"
+#include "DunDataWaiter.h"
+#include "DunSignalCopy.h"
+#include "DunDebug.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunDataWaiter* CDunDataWaiter::NewL( MDunChannelAllocator* aChannelCallback )
+    {
+    CDunDataWaiter* self = new (ELeave) CDunDataWaiter( aChannelCallback );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunDataWaiter::~CDunDataWaiter()
+    {
+    FTRACE(FPrint( _L("CDunDataWaiter::~CDunDataWaiter()") ));
+    ResetData();
+    FTRACE(FPrint( _L("CDunDataWaiter::~CDunDataWaiter() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Resets data to initial values
+// ---------------------------------------------------------------------------
+//
+void CDunDataWaiter::ResetData()
+    {
+    FTRACE(FPrint( _L("CDunDataWaiter::ResetData()") ));
+    Stop();
+    // APIs affecting this:
+    // AddConnMonCallbackL()
+    iCallbacks.Close();
+    // Internal
+    Initialize();
+    FTRACE(FPrint( _L("CDunDataWaiter::ResetData() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Adds callback for RunL error controlling
+// The callback will be called when error is detected in asynchronous
+// operation
+// ---------------------------------------------------------------------------
+//
+TInt CDunDataWaiter::AddCallback( MDunConnMon* aCallback )
+    {
+    FTRACE(FPrint( _L("CDunDataWaiter::AddCallback()" ) ));
+    if ( !aCallback )
+        {
+        FTRACE(FPrint( _L("CDunDataWaiter::AddCallback() (ERROR) complete" ) ));
+        return KErrGeneral;
+        }
+    TInt retTemp = iCallbacks.Find( aCallback );
+    if ( retTemp != KErrNotFound )
+        {
+        FTRACE(FPrint( _L("CDunDataWaiter::AddCallback() (already exists) complete" ) ));
+        return KErrAlreadyExists;
+        }
+    retTemp = iCallbacks.Append( aCallback );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunDataWaiter::AddCallback() (append failed!) complete" ) ));
+        return retTemp;
+        }
+    FTRACE(FPrint( _L("CDunDataWaiter::AddCallback() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Sets media to use for this endpoint
+// ---------------------------------------------------------------------------
+//
+TInt CDunDataWaiter::SetMedia( RComm* aComm )
+    {
+    FTRACE(FPrint( _L("CDunDataWaiter::SetMedia(RComm) (addr=0x%08X)" ), aComm));
+    if ( !aComm )
+        {
+        FTRACE(FPrint( _L("CDunDataWaiter::SetMedia() (aComm) not initialized!" )));
+        return KErrGeneral;
+        }
+    TCommCaps2 caps;
+    aComm->Caps( caps );
+    if ( !(caps().iNotificationCaps & KNotifyDataAvailableSupported) )
+        {
+        FTRACE(FPrint( _L("CDunDataWaiter::SetMedia() (RComm) (not supported) complete" )));
+        return KErrNotSupported;
+        }
+    iComm = aComm;
+    FTRACE(FPrint( _L("CDunDataWaiter::SetMedia() (RComm) complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Issues request to start waiting for new data in RComm
+// ---------------------------------------------------------------------------
+//
+TInt CDunDataWaiter::IssueRequest()
+    {
+    FTRACE(FPrint( _L("CDunDataWaiter::IssueRequest()" )));
+    if ( iDataWaiterState != EDunStateIdle )
+        {
+        FTRACE(FPrint( _L("CDunDataWaiter::IssueRequest() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    if ( !iComm )
+        {
+        FTRACE(FPrint( _L("CDunDataWaiter::IssueRequest() (iComm) not initialized!" ) ));
+        return KErrGeneral;
+        }
+    iStatus = KRequestPending;
+    iComm->ResetBuffers();
+    iComm->NotifyDataAvailable( iStatus );
+    SetActive();
+    iDataWaiterState = EDunStateDataWaiting;
+    FTRACE(FPrint( _L("CDunDataWaiter::IssueRequest() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Stops monitoring for new data
+// ---------------------------------------------------------------------------
+//
+TInt CDunDataWaiter::Stop()
+    {
+    FTRACE(FPrint( _L("CDunDataWaiter::Stop()" )));
+    if ( iDataWaiterState != EDunStateDataWaiting )
+        {
+        FTRACE(FPrint( _L("CDunDataWaiter::Stop() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    if ( !iComm )
+        {
+        FTRACE(FPrint( _L("CDunDataWaiter::Stop() (iComm) not initialized!" )));
+        return KErrGeneral;
+        }
+    iComm->NotifyDataAvailableCancel();
+    Cancel();
+    iDataWaiterState = EDunStateIdle;
+    FTRACE(FPrint( _L("CDunDataWaiter::Stop() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunDataWaiter::CDunDataWaiter
+// ---------------------------------------------------------------------------
+//
+CDunDataWaiter::CDunDataWaiter( MDunChannelAllocator* aChannelCallback ) :
+    CActive( EPriorityHigh ),
+    iChannelCallback( aChannelCallback )
+    {
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// CDunDataWaiter::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunDataWaiter::ConstructL()
+    {
+    FTRACE(FPrint( _L("CDunDataWaiter::ConstructL()" ) ));
+    if ( !iChannelCallback )
+        {
+        User::Leave( KErrGeneral );
+        }
+    CActiveScheduler::Add( this );
+    FTRACE(FPrint( _L("CDunDataWaiter::ConstructL() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes this class
+// ---------------------------------------------------------------------------
+//
+void CDunDataWaiter::Initialize()
+    {
+    FTRACE(FPrint( _L("CDunDataWaiter::Initialize()" ) ));
+    // Don't initialize iChannelCallback here (it is set through NewL)
+    iDataWaiterState = EDunStateIdle;
+    iComm = NULL;
+    FTRACE(FPrint( _L("CDunDataWaiter::Initialize() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called when new data in RComm object
+// ---------------------------------------------------------------------------
+//
+void CDunDataWaiter::RunL()
+    {
+    FTRACE(FPrint( _L("CDunDataWaiter::RunL()" ) ));
+    iDataWaiterState = EDunStateIdle;
+    TInt retTemp = iStatus.Int();
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunDataWaiter::RunL() (failed) complete (%d)"), retTemp));
+        TInt count = iCallbacks.Count();
+        TDunConnectionReason connReason;
+        connReason.iReasonType = EDunReasonTypeRunL;
+        connReason.iContext = EDunMediaContextLocal;
+        connReason.iSignalType = 0;
+        connReason.iSignalHigh = EFalse;
+        connReason.iDirection = EDunDirectionUndefined;
+        connReason.iErrorCode = retTemp;
+        for ( TInt i=0; i<count; i++ )
+            {
+            TRAP_IGNORE(
+                iCallbacks[i]->NotifyProgressChangeL( iComm, connReason ) );
+            }
+        return;
+        }
+    if ( iChannelCallback )
+        {
+        iChannelCallback->NotifyNewChannelRequest( iComm );
+        }
+    // Don't check other iMediaInUse values here
+    // They can't be other than EDunMediaRComm (checked in IssueRequest())
+    FTRACE(FPrint( _L("CDunDataWaiter::RunL() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called on cancel
+// ---------------------------------------------------------------------------
+//
+void CDunDataWaiter::DoCancel()
+    {
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/src/DunDownstream.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,450 @@
+/*
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definitions needed for one "stream" of CDunTransporter
+*
+*/
+
+
+/*
+ * TODO: When local media is of type RComm, listening on it is started with
+ * RComm::NotifyDataAvailable() call. Check that USB ACM port and Irda RCOMM
+ * (and any other new media in the future) behaves correctly so that when
+ * RComm::ReadOneOrMore() is issued, the read is issued immediately without
+ * checking for new data. If waiting for new data happens in this
+ * NotifyDataAvailable/ReadOneOrMore combination, raise a defect to Symbian.
+ */
+
+#include "DunTransporter.h"
+#include "DunDownstream.h"
+#include "DunUpstream.h"
+#include "DunDebug.h"
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunDownstream* CDunDownstream::NewL( MDunTransporterUtilityAux* aUtility )
+    {
+    CDunDownstream* self = new (ELeave) CDunDownstream( aUtility );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunDownstream::~CDunDownstream()
+    {
+    FTRACE(FPrint( _L("CDunDownstream::~CDunDownstream()" )));
+    ResetData();
+    FTRACE(FPrint( _L("CDunDownstream::~CDunDownstream() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Resets data to initial values
+// ---------------------------------------------------------------------------
+//
+void CDunDownstream::ResetData()
+    {
+    // APIs affecting this:
+    // IssueRequest()
+    Stop();
+    // InitializeForDataPushing()
+    delete iPushData.iDataPusher;
+    iPushData.iDataPusher = NULL;
+    // AddConnMonCallbackL()
+    iCallbacksR.Close();
+    iCallbacksW.Close();
+    // AddSkippedErrorL()
+    iOkErrorsR.Close();
+    iOkErrorsW.Close();
+    // Internal
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes this stream for AT command notifications
+// ---------------------------------------------------------------------------
+//
+TInt CDunDownstream::InitializeForDataPushing(
+    MDunAtCmdHandler* aAtCmdHandler )
+    {
+    FTRACE(FPrint( _L("CDunDownstream::InitializeForDataPushing()" ) ));
+    if ( iPushData.iDataPusher || iPushData.iAtCmdHandler )  // optional
+        {
+        FTRACE(FPrint( _L("CDunDownstream::InitializeForDataPushing() (already exists) complete" ) ));
+        return KErrAlreadyExists;
+        }
+    if ( !aAtCmdHandler )
+        {
+        FTRACE(FPrint( _L("CDunDownstream::InitializeForDataPushing() (aAtCmdHandler) not initialized!" ) ));
+        return KErrGeneral;
+        }
+    CDunDataPusher* dataPusher = NULL;
+    TRAPD( retTrap, dataPusher = CDunDataPusher::NewL(*this,this) );
+    if ( retTrap != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunDownstream::InitializeForDataPushing() (trapped!) complete" ) ));
+        return retTrap;
+        }
+    if ( iComm )
+        {
+        dataPusher->SetMedia( iComm );
+        }
+    else if ( iSocket )
+        {
+        dataPusher->SetMedia( iSocket );
+        }
+    iPushData.iDataPusher = dataPusher;
+    iPushData.iAtCmdHandler = aAtCmdHandler;
+    FTRACE(FPrint( _L("CDunDownstream::InitializeForDataPushing() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Adds data to event queue and starts sending if needed
+// ---------------------------------------------------------------------------
+//
+TInt CDunDownstream::AddToQueueAndSend( const TDesC8 *aPushedData,
+                                        MDunCompletionReporter* aCallback )
+    {
+    FTRACE(FPrint( _L("CDunDownstream::AddToQueueAndSend()" ) ));
+    if ( !iPushData.iDataPusher )
+        {
+        FTRACE(FPrint( _L("CDunDownstream::AddToQueueAndSend() (iPushData.iDataPusher not initialized!) complete" )));
+        return KErrGeneral;
+        }
+    // Add to event queue. If something went wrong, just return
+    TInt retTemp = iPushData.iDataPusher->AddToEventQueue( aPushedData, aCallback );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunDownstream::AddToQueueAndSend() (ERROR) complete" )));
+        return retTemp;
+        }
+    // Now push the data. If already active, push will start later, if not
+    // active it will start immediately.
+    iPushData.iDataPusher->SendQueuedData();
+    FTRACE(FPrint( _L("CDunDownstream::AddToQueueAndSend() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Starts downstream by issuing read request
+// ---------------------------------------------------------------------------
+//
+TInt CDunDownstream::StartStream()
+    {
+    FTRACE(FPrint( _L("CDunDownstream::StartStream()" ) ));
+    // Note: only start URC here.
+    // The downstream read request is started when command mode ends.
+    // This is done to make the data arrive in the correct order (reply vs.
+    // data) with "ATD" command.
+    TInt retVal = KErrNone;
+    if ( iPushData.iAtCmdHandler )
+        {
+        retVal = iPushData.iAtCmdHandler->StartUrc();
+        }
+    FTRACE(FPrint( _L("CDunDownstream::StartStream() complete" ) ));
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// Stops transfer for read or write endpoints
+// ---------------------------------------------------------------------------
+//
+TInt CDunDownstream::Stop( TBool aStopMplex )
+    {
+    FTRACE(FPrint( _L("CDunDownstream::Stop() (Dir=%d)" ), iDirection));
+    if ( !iPushData.iDataPusher )
+        {
+        FTRACE(FPrint( _L("CDunDownstream::Stop() (iPushData.iDatapusher not initialized!) complete" )));
+        return KErrGeneral;
+        }
+    // Stop the downstream related AT command handling functionality
+    if ( aStopMplex )  // optional
+        {
+        if ( iPushData.iAtCmdHandler )
+            {
+            iPushData.iAtCmdHandler->StopAtCmdHandling();
+            }
+        // Stop the multiplexer separately
+        iPushData.iDataPusher->Stop();
+        }
+    if ( iTransferState != EDunStateTransferring )
+        {
+        FTRACE(FPrint( _L("CDunDownstream::Stop() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    // Stop only current operation
+    if ( iOperationType == EDunOperationTypeRead )
+        {
+        if ( iNetwork )
+            {
+            iNetwork->ReadCancel();
+            Cancel();
+            FTRACE(FPrint( _L("CDunDownstream::Stop() (Network) cancelled" )));
+            }
+        }
+    else if ( iOperationType == EDunOperationTypeWrite )
+        {
+        iPushData.iDataPusher->StopOneEvent( iBufferPtr );
+        }
+    iTransferState = EDunStateIdle;
+    FTRACE(FPrint( _L("CDunDownstream::Stop() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunDownstream::CDunDownstream
+// ---------------------------------------------------------------------------
+//
+CDunDownstream::CDunDownstream( MDunTransporterUtilityAux* aUtility ) :
+    iUtility( aUtility )
+    {
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// CDunDownstream::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunDownstream::ConstructL()
+    {
+    FTRACE(FPrint( _L("CDunDownstream::ConstructL()" ) ));
+    if ( !iUtility )
+        {
+        User::Leave( KErrGeneral );
+        }
+    FTRACE(FPrint( _L("CDunDownstream::ConstructL() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes this class
+// ---------------------------------------------------------------------------
+//
+void CDunDownstream::Initialize()
+    {
+    // Don't initialize iUtility here (it is set through NewL)
+    iPushData.iDataMode = EFalse;
+    iPushData.iDataPusher = NULL;
+    iPushData.iAtCmdHandler = NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// Issues transfer request for this stream
+// ---------------------------------------------------------------------------
+//
+TInt CDunDownstream::IssueRequest()
+    {
+    // Set direction
+    iDirection = static_cast<TDunDirection>( EDunStreamTypeDownstream | iOperationType );
+
+    FTRACE(FPrint( _L("CDunDownstream::IssueRequest() (Dir=%d)" ), iDirection));
+    if ( !iPushData.iDataPusher )
+        {
+        FTRACE(FPrint( _L("CDunDownstream::IssueRequest() (iPushData.iDataPusher not initialized!) complete" ) ));
+        return KErrGeneral;
+        }
+
+    if ( iTransferState != EDunStateIdle )
+        {
+        FTRACE(FPrint( _L("CDunDownstream::IssueRequest() (not ready) complete" ) ));
+        return KErrNotReady;
+        }
+
+    if ( iOperationType == EDunOperationTypeRead )
+        {
+        iBufferPtr->SetLength( iBufferPtr->MaxLength() );
+        FTRACE(FPrint( _L("CDunDownstream::IssueRequest() trying to read %d bytes... (Dir=%d)" ), iBufferPtr->Length(), iDirection));
+        }
+    else // iOperationType == EDunOperationTypeWrite
+        {
+        FTRACE(FPrint( _L("CDunDownstream::IssueRequest() writing %d bytes... (Dir=%d)" ), iBufferPtr->Length(), iDirection));
+        }
+
+    switch ( iDirection )
+        {
+        case EDunReaderDownstream:
+            iStatus = KRequestPending;
+            iNetwork->ReadOneOrMore( iStatus, *iBufferPtr );
+            SetActive();
+            FTRACE(FPrint( _L("CDunDownstream::IssueRequest() RComm ReadOneOrMore() requested" ) ));
+            break;
+        case EDunWriterDownstream:
+            AddToQueueAndSend( iBufferPtr, this );
+            break;
+        default:
+            FTRACE(FPrint( _L("CDunDownstream::IssueRequest() (ERROR) complete" ) ));
+            return KErrGeneral;
+        }
+
+    iTransferState = EDunStateTransferring;
+
+    FTRACE(FPrint( _L("CDunDownstream::IssueRequest() (Dir=%d) complete" ), iDirection));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called when endpoint data read complete
+// ---------------------------------------------------------------------------
+//
+void CDunDownstream::RunL()
+    {
+    FTRACE(FPrint( _L("CDunDownstream::RunL() (Dir=%d)" ), iDirection));
+    iTransferState = EDunStateIdle;
+    if ( iOperationType != EDunOperationTypeRead )
+        {
+        FTRACE(FPrint( _L("CDunDownstream::RunL() (wrong operation type!) complete" )));
+        return;
+        }
+
+    TBool isError;
+    TInt retTemp = iStatus.Int();
+    TInt stop = ProcessErrorCondition( retTemp, isError );
+
+    if ( !stop )  // no real error detected -> continue
+        {
+        if ( !isError )
+            {
+            // Operation type was read so now set to write
+            iOperationType = EDunOperationTypeWrite;
+            }  // if ( !isError )
+
+        IssueRequest();
+
+        }  // if ( !stop )
+    else  // stop -> tear down connection
+        {
+        // Now CDunDataPusher notifies to write case so here we just notify the
+        // read case.
+        TDunConnectionReason connReason;
+        connReason.iReasonType = EDunReasonTypeRW;
+        connReason.iContext = GetMediaContext( EDunStreamTypeDownstream );
+        connReason.iSignalType = 0;
+        connReason.iSignalHigh = EFalse;
+        connReason.iDirection = iDirection;
+        connReason.iErrorCode = retTemp;
+        iUtility->DoNotifyConnectionNotOk( iComm,
+                                           iSocket,
+                                           connReason,
+                                           iCallbacksR );
+        FTRACE(FPrint( _L("CDunDownstream::RunL() stop" )));
+        }  // else
+
+    FTRACE(FPrint( _L("CDunDownstream::RunL() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called on cancel
+// ---------------------------------------------------------------------------
+//
+void CDunDownstream::DoCancel()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunStreamManipulator.
+// Gets called when outside party wants to push data to the existing stream
+// ---------------------------------------------------------------------------
+//
+TInt CDunDownstream::NotifyDataPushRequest( const TDesC8 *aPushedData,
+                                            MDunCompletionReporter* aCallback )
+    {
+    FTRACE(FPrint( _L("CDunDownstream::NotifyDataPushRequest()" )));
+    // If in data mode push the reply anyway as "CONNECT" or "NO CARRIER"
+    // reply could arrive before/after the command mode information itself.
+    TInt retVal = AddToQueueAndSend( aPushedData, aCallback );
+    FTRACE(FPrint( _L("CDunDownstream::NotifyDataPushRequest() complete" )));
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunCompletionReporter.
+// Gets called when data push is complete
+// ---------------------------------------------------------------------------
+//
+void CDunDownstream::NotifyDataPushComplete( TBool aAllPushed )
+    {
+    FTRACE(FPrint( _L("CDunDownstream::NotifyDataPushComplete()" )));
+    // Next just skip the notifications of atomic operations because also this
+    // class initiates the pushing of atomic data.
+    if ( !aAllPushed )
+        {
+        FTRACE(FPrint( _L("CDunDownstream::NotifyDataPushComplete() (continue) complete" )));
+        return;
+        }
+    iTransferState = EDunStateIdle;
+    iOperationType = EDunOperationTypeUndefined;
+    if ( !iPushData.iDataPusher )
+        {
+        FTRACE(FPrint( _L("CDunDownstream::NotifyDataPushComplete() (iPushData.iDataPusher not initialized!) complete" )));
+        return;
+        }
+    // Now the multiplexer might have pushed the contained data in this class
+    // or it might have pushed only the external data. If the pushed data
+    // contains this classes data then reissue request, otherwise just clear
+    // the queue.
+    TInt foundIndex = iPushData.iDataPusher->FindEventFromQueue( iBufferPtr );
+    iPushData.iDataPusher->SignalCompletionAndClearQueue();
+    FTRACE(FPrint( _L("CDunDownstream::NotifyDataPushComplete() (find event)" )));
+    if ( foundIndex >= 0 )
+        {
+        // Restart the reading from Dataport only if in data mode
+        FTRACE(FPrint( _L("CDunDownstream::NotifyDataPushComplete() (issue request)" )));
+        if ( iPushData.iDataMode )
+            {
+            iOperationType = EDunOperationTypeRead;
+            IssueRequest();
+            }
+        }
+    FTRACE(FPrint( _L("CDunDownstream::NotifyDataPushComplete() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunCmdModeMonitor.
+// Notifies about command mode start
+// ---------------------------------------------------------------------------
+//
+void CDunDownstream::NotifyCommandModeStart()
+    {
+    FTRACE(FPrint( _L("CDunDownstream::NotifyCommandModeStart()" )));
+    iPushData.iDataMode = EFalse;
+    // Now the data mode has ended.
+    // If read operation then cancel it.
+    if ( iOperationType == EDunOperationTypeRead )
+        {
+        Stop( EFalse );
+        }
+    FTRACE(FPrint( _L("CDunDownstream::NotifyCommandModeStart() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunCmdModeMonitor.
+// Notifies about command mode end
+// ---------------------------------------------------------------------------
+//
+void CDunDownstream::NotifyCommandModeEnd()
+    {
+    FTRACE(FPrint( _L("CDunDownstream::NotifyCommandModeEnd()" )));
+    iPushData.iDataMode = ETrue;
+    // Command mode ends here so start reading from Dataport
+    iOperationType = EDunOperationTypeRead;
+    IssueRequest();
+    FTRACE(FPrint( _L("CDunDownstream::NotifyCommandModeEnd() complete" )));
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/src/DunNetDataport.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,395 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Dataport specific network resource accessor implementation
+*
+*/
+
+
+#include <mmtsy_names.h>
+#include "DunNetDataport.h"
+#include "DunUtils.h"
+#include "DunDebug.h"
+
+_LIT(DUN_GGP_DATAPORT_CSY_PORT, "::DUN");
+_LIT(DUN_GGP_DATAPORT_CSY, "DATAPORT");
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunNetDataport* CDunNetDataport::NewL( TInt aNumOfMaxChannels )
+    {
+    CDunNetDataport* self = new (ELeave) CDunNetDataport( aNumOfMaxChannels );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunNetDataport::~CDunNetDataport()
+    {
+    FTRACE(FPrint(_L( "CDunNetDataport::~CDunNetDataport()")));
+    TInt i;
+    TInt count = iEntities.Count();
+    for ( i=0; i<count; i++ )
+        {
+        DeleteNetworkEntity( i, ETrue );
+        }
+    DeleteNetwork();
+    FTRACE(FPrint(_L( "CDunNetDataport::~CDunNetDataport() complete")));
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunNetwork (MDunNetDataport -> MDunNetwork).
+// Initializes network for Dataport
+// Must be called before any other operation
+// ---------------------------------------------------------------------------
+//
+void CDunNetDataport::InitializeL()
+    {
+    FTRACE(FPrint(_L( "CDunNetDataport::InitializeL()")));
+    AllocatePhoneObjectsL();
+    FTRACE(FPrint(_L( "CDunNetDataport::InitializeL() complete")));
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunNetDataport.
+// Called when channel was created by transporter for Dataport
+// Initializes network for channel creation
+// ---------------------------------------------------------------------------
+//
+TInt CDunNetDataport::AllocateChannel( RComm*& aComm )
+    {
+    FTRACE(FPrint(_L( "CDunNetDataport::AllocateChannel()")));
+    TInt firstFree = InitializeFirstFreeEntity();
+    if ( firstFree < 0 )
+        {
+        FTRACE(FPrint(_L( "CDunNetDataport::AllocateChannel() (not found) complete")));
+        return firstFree;
+        }
+    if ( firstFree >= iEntities.Count() )
+        {
+        FTRACE(FPrint(_L( "CDunNetDataport::AllocateChannel() (firstfree failed!) complete")));
+        return KErrGeneral;
+        }
+    TInt retTemp = iEntities[firstFree].iMobileCall.OpenNewCall( iMobileLine );
+    if ( retTemp != KErrNone )
+        {
+        RemoveEntity( firstFree );  // remove unused initialized channel
+        FTRACE(FPrint(_L( "CDunNetDataport::AllocateChannel() OpenNewCall FAILED %d" ), retTemp));
+        return KErrGeneral;
+        }
+    retTemp = iEntities[firstFree].iMobileCall.Connect();
+    if ( retTemp != KErrNone )
+        {
+        RemoveEntity( firstFree );  // remove unused initialized channel
+        FTRACE(FPrint(_L( "CDunNetDataport::AllocateChannel() iEntities[%d]->iMobileCall.Connect FAILED %d" ), firstFree, retTemp));
+        return KErrGeneral;
+        }
+    RCall::TCommPort portName;
+    portName.iPort.Copy( DUN_GGP_DATAPORT_CSY );
+    portName.iPort.Append( DUN_GGP_DATAPORT_CSY_PORT );
+    retTemp = iEntities[firstFree].iMobileCall.LoanDataPort( portName );
+    if ( retTemp != KErrNone )
+        {
+        RemoveEntity( firstFree );  // remove unused initialized channel
+        if ( retTemp == KErrEtelPortNotLoanedToClient )
+            {
+            FTRACE(FPrint(_L( "CDunNetDataport::AllocateChannel() (too big) complete")));
+            return KErrTooBig;
+            }
+        FTRACE(FPrint(_L( "CDunNetDataport::AllocateChannel() iEntities[%d]->iMobileCall.LoanDataPort FAILED %d" ), firstFree, retTemp));
+        return KErrGeneral;
+        }
+    FTRACE(FPrint(_L( "CDunNetDataport::AllocateChannel() Created call object at index %d" ), firstFree));
+    retTemp = iEntities[firstFree].iDataport.Open( iCommServer,
+                                                   portName.iPort,
+                                                   ECommExclusive,
+                                                   ECommRoleDTE );
+    if ( retTemp != KErrNone )
+        {
+        RemoveEntity( firstFree );  // remove unused initialized channel
+        FTRACE(FPrint(_L( "CDunNetDataport::AllocateChannel() FAILED to open dataport %d"), retTemp));
+        return KErrGeneral;
+        }
+    iEntities[firstFree].iDataport.ResetBuffers();
+    iEntities[firstFree].iEntityInUse = ETrue;
+    aComm = &iEntities[firstFree].iDataport;
+    FTRACE(FPrint(_L( "CDunNetDataport::AllocateChannel() (iEntities[%d]->iDataport) opened"), firstFree));
+    FTRACE(FPrint(_L( "CDunNetDataport::AllocateChannel() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunNetDataport.
+// Called when channel was deleted/closed by transporter for Dataport
+// Uninitializes network for channel deletion/close
+// ---------------------------------------------------------------------------
+//
+TInt CDunNetDataport::FreeChannel( RComm* aComm )
+    {
+    FTRACE(FPrint(_L( "CDunNetDataport::FreeChannel()")));
+    TInt i;
+    TInt count = iEntities.Count();
+    for ( i=0; i<count; i++ )
+        {
+        if ( &iEntities[i].iDataport == aComm )
+            {
+            if ( iEntities[i].iEntityInUse )
+                {
+                break;
+                }
+            }
+        }
+    if ( i >= count )
+        {
+        FTRACE(FPrint(_L( "CDunNetDataport::FreeChannel() (not found) complete")));
+        return KErrNotFound;
+        }
+    DeleteNetworkEntity( i, ETrue );
+    FTRACE(FPrint(_L( "CDunNetDataport::FreeChannel() (iEntities[%d]->iDataport) freed"), i));
+    FTRACE(FPrint(_L( "CDunNetDataport::FreeChannel() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunNetDataport.
+// Gets index by network ID for Dataport
+// ---------------------------------------------------------------------------
+//
+TInt CDunNetDataport::GetIndexById( RComm* aComm )
+    {
+    FTRACE(FPrint(_L( "CDunNetDataport::GetIndexById()")));
+    TInt i;
+    TInt count = iEntities.Count();
+    for ( i=0; i<count; i++ )
+        {
+        TDunDataportEntity& entity = iEntities[i];
+        if ( entity.iEntityInUse )
+            {
+            if ( &entity.iDataport == aComm )
+                {
+                return i;
+                }
+            }
+        }
+    FTRACE(FPrint(_L( "CDunNetDataport::GetIndexById() (not found) complete")));
+    return KErrNotFound;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunNetDataport::CDunNetDataport
+// ---------------------------------------------------------------------------
+//
+CDunNetDataport::CDunNetDataport( TInt aNumOfMaxChannels ) :
+    iNumOfMaxChannels( aNumOfMaxChannels )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CDunNetDataport::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunNetDataport::ConstructL()
+    {
+    FTRACE(FPrint(_L( "CDunNetDataport::ConstructL()")));
+    if ( iNumOfMaxChannels < 0 )
+        {
+        User::Leave( KErrGeneral );
+        }
+    TInt retTemp = CDunUtils::ConnectCommsServer( iCommServer );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L( "CDunNetDataport::ConstructL() FAILED to connect comms server")));
+        User::Leave( retTemp );
+        }
+    retTemp = iCommServer.LoadCommModule( DUN_GGP_DATAPORT_CSY );
+    if ( retTemp != KErrNone )
+        {
+        iCommServer.Close();
+        FTRACE(FPrint(_L( "CDunNetDataport::ConstructL() FAILED to load comm module")));
+        User::Leave( retTemp );
+        }
+    FTRACE(FPrint(_L( "CDunNetDataport::ConstructL() complete")));
+    }
+
+// ---------------------------------------------------------------------------
+// Allocates phone objects for use
+// ---------------------------------------------------------------------------
+//
+void CDunNetDataport::AllocatePhoneObjectsL()
+    {
+    FTRACE(FPrint(_L( "CDunNetDataport::AllocatePhoneObjectsL()" ) ));
+    TInt retTemp;
+    retTemp = iTelServer.Connect();
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L( "CDunNetDataport::AllocatePhoneObjectsL() iTelServer Connect FAILED %d" ), retTemp ));
+        User::Leave( retTemp );
+        }
+    retTemp = iTelServer.LoadPhoneModule( KMmTsyModuleName );
+    if ( retTemp!=KErrNone && retTemp!=KErrAlreadyExists )
+        {
+        FTRACE(FPrint(_L( "CDunNetDataport::AllocatePhoneObjectsL() LoadPhoneModule FAILED %d" ), retTemp ));
+        User::Leave( retTemp );
+        }
+    retTemp = iMobilePhone.Open( iTelServer, KMmTsyPhoneName );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L( "CDunNetDataport::AllocatePhoneObjectsL() MobilePhone Open FAILED %d" ), retTemp ));
+        User::Leave( retTemp );
+        }
+    retTemp = iMobileLine.Open( iMobilePhone, KMmTsyDataLineName );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L( "CDunNetDataport::AllocatePhoneObjectsL() MobileLine Open FAILED %d" ), retTemp ));
+        User::Leave( retTemp );
+        }
+    FTRACE(FPrint(_L( "CDunNetDataport::AllocatePhoneObjectsL() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes first free entity
+// ---------------------------------------------------------------------------
+//
+TInt CDunNetDataport::InitializeFirstFreeEntity()
+    {
+    FTRACE(FPrint(_L( "CDunNetDataport::InitializeFirstFreeEntity()")));
+    TInt i;
+    TInt retTemp;
+    TInt count = iEntities.Count();
+    for ( i=0; i<count; i++ )
+        {
+        if ( !iEntities[i].iEntityInUse )
+            {
+            FTRACE(FPrint( _L("CDunNetDataport::InitializeFirstFreeEntity() complete" )));
+            return i;
+            }
+        }
+    // Free channel not found, now create new if possible
+    if ( iNumOfMaxChannels!=0 && iEntities.Count()>=iNumOfMaxChannels )
+        {
+        FTRACE(FPrint( _L("CDunNetDataport::InitializeFirstFreeEntity() (too big) complete" )));
+        return KErrTooBig;
+        }
+    TDunDataportEntity emptyEntity;
+    emptyEntity.iEntityInUse = EFalse;
+    retTemp = iEntities.Append( emptyEntity );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunNetDataport::InitializeFirstFreeEntity() (append failed!) complete" )));
+        return retTemp;
+        }
+    FTRACE(FPrint(_L( "CDunNetDataport::InitializeFirstFreeEntity() complete")));
+    return i;
+    }
+
+// ---------------------------------------------------------------------------
+// Remove network entity by index
+// ---------------------------------------------------------------------------
+//
+TInt CDunNetDataport::RemoveEntity( TInt aIndex )
+    {
+    FTRACE(FPrint(_L( "CDunNetDataport::RemoveEntity()")));
+    if ( aIndex < 0 ||
+         aIndex >= iEntities.Count() )
+        {
+        FTRACE(FPrint(_L( "CDunNetDataport::RemoveEntity() (not found) complete")));
+        return KErrNotFound;
+        }
+    DeleteNetworkEntity( aIndex, EFalse );
+    FTRACE(FPrint(_L( "CDunNetDataport::RemoveEntity() complete")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Deletes own internal data
+// ---------------------------------------------------------------------------
+//
+void CDunNetDataport::DeleteNetwork()
+    {
+    FTRACE(FPrint(_L( "CDunNetDataport::DeleteNetwork()")));
+    if ( iMobileLine.SubSessionHandle() )
+        {
+        iMobileLine.Close();
+        FTRACE(FPrint(_L( "CDunNetDataport::DeleteNetwork() mobile line closed")));
+        }
+    if ( iMobilePhone.SubSessionHandle() )
+        {
+        iMobilePhone.Close();
+        FTRACE(FPrint(_L( "CDunNetDataport::DeleteNetwork() mobile phone closed")));
+        }
+    if ( iTelServer.Handle() )
+        {
+        iTelServer.UnloadPhoneModule( KMmTsyModuleName );
+        FTRACE(FPrint(_L( "CDunNetDataport::DeleteNetwork() phone module unloaded")));
+        iTelServer.Close();
+        FTRACE(FPrint(_L( "CDunNetDataport::DeleteNetwork() phone module closed")));
+        }
+    if ( iCommServer.Handle() )
+        {
+        iCommServer.UnloadCommModule( DUN_GGP_DATAPORT_CSY );
+        FTRACE(FPrint(_L( "CDunNetDataport::DeleteNetwork() comm module unloaded")));
+        iCommServer.Close();
+        FTRACE(FPrint(_L( "CDunNetDataport::DeleteNetwork() comm module closed")));
+        }
+    iEntities.Close();
+    FTRACE(FPrint(_L( "CDunNetDataport::DeleteNetwork() complete")));
+    }
+
+// ---------------------------------------------------------------------------
+// Deletes one network entity at index aIndex for Dataport
+// ---------------------------------------------------------------------------
+//
+TInt CDunNetDataport::DeleteNetworkEntity( TInt aIndex, TBool aCheckFree )
+    {
+    FTRACE(FPrint(_L( "CDunNetDataport::DeleteNetworkEntity()")));
+    if ( aIndex < 0 ||
+         aIndex >= iEntities.Count() )
+        {
+        FTRACE(FPrint(_L( "CDunNetDataport::DeleteNetworkEntity() (not found) complete"), aIndex));
+        return KErrGeneral;
+        }
+    TDunDataportEntity& entity = iEntities[aIndex];
+    if ( (aCheckFree&&entity.iEntityInUse) || !aCheckFree )
+        {
+        if ( entity.iDataport.SubSessionHandle() )
+            {
+            // The next will set KSignalDTEOutputs down twice for RComm
+            // local media case because CDunSignalCopy clears them also which
+            // in turn causes plugin to free channel. But this probably won't
+            // cause any harm.
+            entity.iDataport.SetSignals( 0, KSignalDTEOutputs );
+            FTRACE(FPrint(_L( "CDunNetDataport::DeleteNetworkEntity() RComm signals set")));
+            entity.iDataport.Close();
+            FTRACE(FPrint(_L( "CDunNetDataport::DeleteNetworkEntity() RComm closed")));
+            }
+        if ( entity.iMobileCall.SubSessionHandle() )
+            {
+            entity.iMobileCall.RecoverDataPort();
+            FTRACE(FPrint(_L( "CDunNetDataport::DeleteNetworkEntity() Dataport recovered")));
+            entity.iMobileCall.Close();
+            FTRACE(FPrint(_L( "CDunNetDataport::DeleteNetworkEntity() Dataport closed")));
+            }
+        entity.iEntityInUse = EFalse;
+        }
+    FTRACE(FPrint(_L( "CDunNetDataport::DeleteNetworkEntity() complete")));
+    return KErrNone;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/src/DunNoteHandler.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,248 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Manages note showing in UI
+*
+*/
+
+
+#include <bautils.h>
+#include <featmgr.h>
+#include <aknSDData.h>
+#include <secondarydisplay/dunsecondarydisplayapi.h>
+#include "DunNoteHandler.h"
+#include "DunDebug.h"
+
+_LIT( KDunUtilsDriveSpec, "z:" );
+_LIT( KDunUtilsResourceFileName, "dunutils.rsc" );
+
+const TInt KDunCoverEnumStart     = (ECmdNone + 1);  // start after ECmdNone
+const TInt KDunPtr8toPtr16Divider = 2;               // Divider for converting
+const TInt KDunThreeItemsToPop    = 3;
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunNoteHandler* CDunNoteHandler::NewL()
+    {
+    CDunNoteHandler* self = new (ELeave) CDunNoteHandler();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CDunNoteHandler::~CDunNoteHandler()
+    {
+    FTRACE(FPrint( _L("CDunNoteHandler::~CDunNoteHandler()") ));
+    ResetData();
+    FTRACE(FPrint( _L("CDunNoteHandler::~CDunNoteHandler() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Resets data to initial values
+// ---------------------------------------------------------------------------
+//
+void CDunNoteHandler::ResetData()
+    {
+    FTRACE(FPrint( _L("CDunNoteHandler::ResetData()") ));
+    // APIs affecting this:
+    // IssueRequest()
+    Stop();
+    delete iNote;
+    iNote = NULL;
+    // Internal
+    Initialize();
+    FTRACE(FPrint( _L("CDunNoteHandler::ResetData() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Issues request to start showing UI note
+// ---------------------------------------------------------------------------
+//
+TInt CDunNoteHandler::IssueRequest()
+    {
+    FTRACE(FPrint( _L("CDunNoteHandler::IssueRequest()") ));
+    if ( iNoteState != EDunStateIdle )
+        {
+        FTRACE(FPrint( _L("CDunNoteHandler::IssueRequest() (not ready) complete") ));
+        return KErrNotReady;
+        }
+    TRAPD( retTrap, DoIssueRequestL() );
+    if ( retTrap != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunNoteHandler::IssueRequest() (trapped!) complete (%d)"), retTrap));
+        return retTrap;
+        }
+    SetActive();
+    iNoteState = EDunStateUiNoting;
+    FTRACE(FPrint( _L("CDunNoteHandler::IssueRequest() complete") ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Stops showing UI note
+// ---------------------------------------------------------------------------
+//
+TInt CDunNoteHandler::Stop()
+    {
+    FTRACE(FPrint( _L("CDunNoteHandler::Stop()") ));
+    if ( iNoteState != EDunStateUiNoting )
+        {
+        FTRACE(FPrint( _L("CDunNoteHandler::Stop() (not ready) complete") ));
+        return KErrNotReady;
+        }
+    if ( !iNote )
+        {
+        FTRACE(FPrint( _L("CDunNoteHandler::Stop() (iNote not initialized!) complete") ));
+        return KErrGeneral;
+        }
+    iNote->CancelConfirmationQuery();
+    Cancel();
+    iNoteState = EDunStateIdle;
+    FTRACE(FPrint( _L("CDunNoteHandler::Stop() complete") ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunNoteHandler::CDunNoteHandler
+// ---------------------------------------------------------------------------
+//
+CDunNoteHandler::CDunNoteHandler() :
+    CActive( EPriorityStandard )
+    {
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// CDunNoteHandler::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunNoteHandler::ConstructL()
+    {
+    FTRACE(FPrint( _L("CDunNoteHandler::ConstructL()") ));
+    CActiveScheduler::Add( this );
+    FTRACE(FPrint( _L("CDunNoteHandler::ConstructL() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes this class
+// ---------------------------------------------------------------------------
+//
+void CDunNoteHandler::Initialize()
+    {
+    FTRACE(FPrint( _L("CDunNoteHandler::Initialize()" ) ));
+    iNote = NULL;
+    iNoteState = EDunStateIdle;
+    FTRACE(FPrint( _L("CDunNoteHandler::Initialize() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// Issues request to start showing UI note
+// ---------------------------------------------------------------------------
+//
+void CDunNoteHandler::DoIssueRequestL()
+    {
+    FTRACE(FPrint( _L("CDunNoteHandler::DoIssueRequestL()") ));
+    if ( iNote )
+        {
+        FTRACE(FPrint( _L("CDunNoteHandler::DoIssueRequestL() (ERROR) complete") ));
+        User::Leave( KErrGeneral );
+        }
+    HBufC16* unicodeString = NULL;
+    ReadResourceTextL( R_DUN_MAXIMUM_DIALUPS, unicodeString );
+    CAknGlobalConfirmationQuery* note = CAknGlobalConfirmationQuery::NewLC();
+    // Publish cover UI note data
+    CAknSDData* sdData = CAknSDData::NewL( KDunNoteCategory,
+                                           ECmdMaxNumber - KDunCoverEnumStart,
+                                           KNullDesC8 );
+    note->SetSecondaryDisplayData( sdData );  // ownership transferred
+    // Start to show note
+    iStatus = KRequestPending;
+    note->ShowConfirmationQueryL( iStatus,
+                                  *unicodeString,
+                                  R_AVKON_SOFTKEYS_OK_EMPTY,
+                                  R_QGN_NOTE_ERROR_ANIM,
+                                  KNullDesC,
+                                  0,
+                                  0,
+                                  CAknQueryDialog::EErrorTone );
+    CleanupStack::Pop( note );
+    delete unicodeString;
+    iNote = note;
+    FTRACE(FPrint( _L("CDunNoteHandler::DoIssueRequestL() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Reads resource string
+// ---------------------------------------------------------------------------
+//
+void CDunNoteHandler::ReadResourceTextL( TInt aResourceId, HBufC16*& aUnicode )
+    {
+    FTRACE(FPrint( _L("CDunNoteHandler::ReadNoteResourceL()") ));
+    // Connect to file server (for resource file reading)
+    RFs fileSession;
+    CleanupClosePushL<RFs>( fileSession );
+    User::LeaveIfError( fileSession.Connect() );
+    // Create dunutils.rsc path and file name
+    TFileName fileName;
+    fileName = KDunUtilsDriveSpec;
+    fileName += KDC_RESOURCE_FILES_DIR;
+    fileName += KDunUtilsResourceFileName;
+    // Find nearest language file for resource
+    BaflUtils::NearestLanguageFile( fileSession, fileName );
+    // Read note resource
+    RResourceFile resourceFile;
+    CleanupClosePushL<RResourceFile>( resourceFile );
+    resourceFile.OpenL( fileSession, fileName );
+    resourceFile.ConfirmSignatureL();
+    HBufC8* readBuffer = resourceFile.AllocReadLC( aResourceId );
+    // Convert read HBufC8 to HBufC16
+    const TPtrC16 ptr16(reinterpret_cast<const TUint16*>
+                       (readBuffer->Ptr()),
+                       (readBuffer->Size() / KDunPtr8toPtr16Divider) );
+    aUnicode = HBufC16::NewL( ptr16.Length() );
+    *aUnicode = ptr16;
+    CleanupStack::PopAndDestroy( KDunThreeItemsToPop );  // readBuffer, resourceFile, fileSession
+    FTRACE(FPrint( _L("CDunNoteHandler::ReadNoteResourceL() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called when UI note dismissed
+// ---------------------------------------------------------------------------
+//
+void CDunNoteHandler::RunL()
+    {
+    FTRACE(FPrint( _L("CDunNoteHandler::RunL()" ) ));
+    iNoteState = EDunStateIdle;
+    delete iNote;
+    iNote = NULL;
+    FTRACE(FPrint( _L("CDunNoteHandler::RunL() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called on cancel
+// ---------------------------------------------------------------------------
+//
+void CDunNoteHandler::DoCancel()
+    {
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/src/DunSignalCopy.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,475 @@
+/*
+* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Copies signals changes between network and local media
+*
+*/
+
+
+#ifdef PRJ_USE_NETWORK_STUBS
+#include <c32comm_stub.h>
+#else
+#include <d32comm.h>
+#endif
+#include "DunTransporter.h"
+#include "DunSignalCopy.h"
+#include "DunDebug.h"
+
+const TUint KDunSixLowestBitsMask = 0x3F;  // Symbian magic
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunSignalCopy* CDunSignalCopy::NewL()
+    {
+    CDunSignalCopy* self = new (ELeave) CDunSignalCopy();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CDunSignalCopy::~CDunSignalCopy()
+    {
+    FTRACE(FPrint( _L("CDunSignalCopy::~CDunSignalCopy()") ));
+    ResetData();
+    FTRACE(FPrint( _L("CDunSignalCopy::~CDunSignalCopy() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Resets data to initial values
+// ---------------------------------------------------------------------------
+//
+void CDunSignalCopy::ResetData()
+    {
+    FTRACE(FPrint( _L("CDunSignalCopy::ResetData()") ));
+    // APIs affecting this:
+    // IssueRequest()
+    Stop();
+    // AddCallback()
+    iCallbacks.Close();
+    // Internal
+    Initialize();
+    FTRACE(FPrint( _L("CDunSignalCopy::ResetData() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Adds callback for line status change controlling
+// The callback will be called when RunL error is detected
+// ---------------------------------------------------------------------------
+//
+TInt CDunSignalCopy::AddCallback( MDunConnMon* aCallback )
+    {
+    FTRACE(FPrint( _L("CDunSignalCopy::AddCallback()" ) ));
+    if ( !aCallback )
+        {
+        FTRACE(FPrint( _L("CDunSignalCopy::AddCallback() (aCallback) not initialized!" ) ));
+        return KErrGeneral;
+        }
+    TInt retTemp = iCallbacks.Find( aCallback );
+    if ( retTemp != KErrNotFound )
+        {
+        FTRACE(FPrint( _L("CDunSignalCopy::AddCallback() (already exists) complete" ) ));
+        return KErrAlreadyExists;
+        }
+    retTemp = iCallbacks.Append( aCallback );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunSignalCopy::AddCallback() (append failed!) complete" ) ));
+        return retTemp;
+        }
+    FTRACE(FPrint( _L("CDunSignalCopy::AddCallback() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Sets media to use for this endpoint monitor
+// ---------------------------------------------------------------------------
+//
+TInt CDunSignalCopy::SetMedia( RComm* aComm,
+                               RComm* aNetwork,
+                               TDunStreamType aStreamType )
+    {
+    FTRACE(FPrint( _L("CDunSignalCopy::SetMedia()" )));
+    if ( !aNetwork )
+        {
+        FTRACE(FPrint( _L("CDunSignalCopy::SetMedia() (aComm) not initialized!" )));
+        return KErrGeneral;
+        }
+    RComm* comm = NULL;
+    if ( aStreamType == EDunStreamTypeUpstream )
+        {
+        iContextInUse = EDunMediaContextLocal;
+        comm = aComm;
+        }
+    else if ( aStreamType == EDunStreamTypeDownstream )
+        {
+        iContextInUse = EDunMediaContextNetwork;
+        comm = aNetwork;
+        }
+    else
+        {
+        FTRACE(FPrint( _L("CDunSignalCopy::SetMedia() (aStreamtype) not initialized!" )));
+        return KErrGeneral;
+        }
+    // No possibility to do iUtility->GetLocalId() here as aComm is not yet
+    // in channel data; use aComm directly
+    TCommCaps2 caps;
+    comm->Caps( caps );
+    if ( !(caps().iNotificationCaps & KNotifySignalsChangeSupported) )
+        {
+        FTRACE(FPrint( _L("CDunSignalCopy::SetMedia() (RComm) (not supported) complete" )));
+        return KErrNotSupported;
+        }
+    iComm = aComm;
+    iNetwork = aNetwork;
+    iStreamType = aStreamType;
+    FTRACE(FPrint( _L("CDunSignalCopy::SetMedia() (RComm) complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Issues request to start monitoring the endpoint for line status change
+// ---------------------------------------------------------------------------
+//
+TInt CDunSignalCopy::IssueRequest()
+    {
+    FTRACE(FPrint( _L("CDunSignalCopy::IssueRequest()" )));
+    if ( iSignalCopyState != EDunStateIdle )
+        {
+        FTRACE(FPrint( _L("CDunSignalCopy::IssueRequest() (not ready) complete" ) ));
+        return KErrNotReady;
+        }
+    RComm* comm = NULL;
+    if ( iStreamType == EDunStreamTypeUpstream )
+        {
+        iListenSignals = KSignalDCEInputs;
+        comm = iComm;
+        }
+    else if ( iStreamType == EDunStreamTypeDownstream )
+        {
+        iListenSignals = KSignalDTEInputs;
+        comm = iNetwork;
+        }
+    else
+        {
+        FTRACE(FPrint( _L("CDunSignalCopy::IssueRequest() (ERROR) complete" ) ));
+        return KErrGeneral;
+        }
+    TUint currentSignals = comm->Signals( iListenSignals );
+    TUint oldSignalsLow = iSignals & KDunSixLowestBitsMask;
+    TUint newSignalsLow = currentSignals & KDunSixLowestBitsMask;
+    TUint oldSignalsHigh = oldSignalsLow * KSignalChanged;
+    TUint newSignalsHigh = newSignalsLow * KSignalChanged;
+    FTRACE(FPrint( _L("CDunSignalCopy::IssueRequest() oldSignalsLow=0x%08X" ), oldSignalsLow ));
+    FTRACE(FPrint( _L("CDunSignalCopy::IssueRequest() newSignalsLow=0x%08X" ), newSignalsLow ));
+    FTRACE(FPrint( _L("CDunSignalCopy::IssueRequest() oldSignalsHigh=0x%08X" ), oldSignalsHigh ));
+    FTRACE(FPrint( _L("CDunSignalCopy::IssueRequest() newSignalsHigh=0x%08X" ), newSignalsHigh ));
+    if ( newSignalsLow != oldSignalsLow )
+        {
+        FTRACE(FPrint( _L("CDunSignalCopy::IssueRequest() signals already set..." ) ));
+        iSignals = newSignalsLow | (oldSignalsHigh ^ newSignalsHigh);
+        ManageSignalChange();
+        }
+    else
+        {
+        FTRACE(FPrint( _L("CDunSignalCopy::IssueRequest() start waiting for change..." ) ));
+        iStatus = KRequestPending;
+        comm->NotifySignalChange( iStatus, iSignals, iListenSignals );
+        SetActive();
+        iSignalCopyState = EDunStateSignalCopy;
+        }
+    FTRACE(FPrint( _L("CDunSignalCopy::IssueRequest() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Stops monitoring the endpoint for line status change
+// ---------------------------------------------------------------------------
+//
+TInt CDunSignalCopy::Stop()
+    {
+    FTRACE(FPrint( _L("CDunSignalCopy::Stop()" )));
+    if ( iSignalCopyState != EDunStateSignalCopy )
+        {
+        FTRACE(FPrint( _L("CDunSignalCopy::Stop() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    if ( iStreamType == EDunStreamTypeUpstream )
+        {
+        iComm->NotifySignalChangeCancel();
+        }
+    else if ( iStreamType == EDunStreamTypeDownstream )
+        {
+        iNetwork->NotifySignalChangeCancel();
+        }
+    else
+        {
+        FTRACE(FPrint( _L("CDunSignalCopy::Stop() (ERROR) complete" )));
+        return KErrGeneral;
+        }
+    Cancel();
+    iSignalCopyState = EDunStateIdle;
+    FTRACE(FPrint( _L("CDunSignalCopy::Stop() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunSignalCopy::CDunSignalCopy
+// ---------------------------------------------------------------------------
+//
+CDunSignalCopy::CDunSignalCopy() :
+    CActive( EPriorityHigh )
+    {
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// CDunSignalCopy::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunSignalCopy::ConstructL()
+    {
+    FTRACE(FPrint( _L("CDunSignalCopy::ConstructL()" ) ));
+    CActiveScheduler::Add( this );
+    FTRACE(FPrint( _L("CDunSignalCopy::ConstructL() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes this class
+// ---------------------------------------------------------------------------
+//
+void CDunSignalCopy::Initialize()
+    {
+    FTRACE(FPrint( _L("CDunSignalCopy::Initialize()" ) ));
+    iContextInUse = EDunMediaContextUndefined;
+    iStreamType = EDunStreamTypeUndefined;
+    iSignalCopyState = EDunStateIdle;
+    iListenSignals = 0;
+    iSignals = 0;
+    iNetwork = NULL;
+    iComm = NULL;
+    FTRACE(FPrint( _L("CDunSignalCopy::Initialize() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// Manages signal changes
+// ---------------------------------------------------------------------------
+//
+void CDunSignalCopy::ManageSignalChange()
+    {
+    FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChange()" ) ));
+
+    if ( iStreamType == EDunStreamTypeUpstream )
+        {
+        // Manage upstream case
+        ManageSignalChangeUpstream();
+        }
+    else  // iStreamType == EDunStreamTypeDownstream
+        {
+        // Manage downstream case
+        ManageSignalChangeDownstream();
+        }
+
+    FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChange() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// Manages upstream signal changes
+// ---------------------------------------------------------------------------
+//
+void CDunSignalCopy::ManageSignalChangeUpstream()
+    {
+    FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeUpstream()" ) ));
+    // For upstream the following signals are set for local media:
+    // KSignalDCEInputs = KSignalRTS | KSignalDTR
+    if ( iSignals & KRTSChanged )
+        {
+        FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeUpstream() checking RTS..." ) ));
+        if ( iSignals & KSignalRTS )  // RTS changed to high
+            {
+            ChangeUpstreamSignal( KSignalRTS, 0 );
+            FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeUpstream() RTS changed high" ) ));
+            }
+        else  // RTS changed to low
+            {
+            ChangeUpstreamSignal( 0, KSignalRTS );
+            FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeUpstream() RTS changed low" ) ));
+            }
+        }
+    if ( iSignals & KDTRChanged )
+        {
+        FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeUpstream() checking DTR..." ) ));
+        if ( iSignals & KSignalDTR )  // DTR changed to high
+            {
+            ChangeUpstreamSignal( KSignalDTR, 0 );
+            FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeUpstream() DTR changed high" ) ));
+            }
+        else  // DTR changed to low
+            {
+            ChangeUpstreamSignal( 0, KSignalDTR );
+            FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeUpstream() DTR changed low" ) ));
+            }
+        }
+    IssueRequest();
+    FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeUpstream() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// Manages downstream signal changes
+// ---------------------------------------------------------------------------
+//
+void CDunSignalCopy::ManageSignalChangeDownstream()
+    {
+    FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeDownstream()" ) ));
+    // For downstream the following signals are set for network:
+    // KSignalDTEInputs = KSignalCTS | KSignalDSR | KSignalDCD | KSignalRNG
+    if ( iSignals & KCTSChanged )
+        {
+        FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeDownstream() checking CTS..." ) ));
+        if ( iSignals & KSignalCTS )  // CTS changed to high or initially high
+            {
+            ChangeDownstreamSignal( KSignalCTS, 0 );
+            FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeDownstream() CTS changed high" ) ));
+            }
+        else  // CTS changed to low
+            {
+            ChangeDownstreamSignal( 0, KSignalCTS );
+            FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeDownstream() CTS changed low" ) ));
+            }
+        }
+    if ( iSignals & KDSRChanged )
+        {
+        FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeDownstream() checking DSR..." ) ));
+        if ( iSignals & KSignalDSR )  // DSR changed to high
+            {
+            ChangeDownstreamSignal( KSignalDSR, 0 );
+            FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeDownstream() DSR changed high" ) ));
+            }
+        else  // DSR changed to low
+            {
+            ChangeDownstreamSignal( 0, KSignalDSR );
+            FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeDownstream() DSR changed low" ) ));
+            }
+        }
+    if ( iSignals & KDCDChanged )
+        {
+        FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeDownstream() checking DCD..." ) ));
+        if ( iSignals & KSignalDCD )  // DCD changed to high
+            {
+            ChangeDownstreamSignal( KSignalDCD, 0 );
+            FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeDownstream() DCD changed high" ) ));
+            }
+        else  // DCD changed to low
+            {
+            ChangeDownstreamSignal( 0, KSignalDCD );
+            FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeDownstream() DCD changed low" ) ));
+            }
+        }
+    if ( iSignals & KRNGChanged )
+        {
+        FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeDownstream() checking RNG..." ) ));
+        if ( iSignals & KSignalRNG )  // RNG changed to high
+            {
+            ChangeDownstreamSignal( KSignalRNG, 0 );
+            FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeDownstream() RNG changed high" ) ));
+            }
+        else  // RNG changed to low
+            {
+            ChangeDownstreamSignal( 0, KSignalRNG );
+            FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeDownstream() RNG changed low" ) ));
+            }
+        }
+    IssueRequest();
+    FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeDownstream() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// Changes upstream signal
+// ---------------------------------------------------------------------------
+//
+void CDunSignalCopy::ChangeUpstreamSignal( TUint aSetMask, TUint aClearMask )
+    {
+    FTRACE(FPrint( _L("CDunSignalCopy::ChangeUpstreamSignal()" ) ));
+    if ( iNetwork )
+        {
+        iNetwork->SetSignals( aSetMask, aClearMask );
+        }
+    // Add other cases here if necessary
+    FTRACE(FPrint( _L("CDunSignalCopy::ChangeUpstreamSignal() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// Changes downstream signal
+// ---------------------------------------------------------------------------
+//
+void CDunSignalCopy::ChangeDownstreamSignal( TUint aSetMask, TUint aClearMask )
+    {
+    FTRACE(FPrint( _L("CDunSignalCopy::ChangeDownstreamSignal()" ) ));
+    if ( iComm )
+        {
+        iComm->SetSignals( aSetMask, aClearMask );
+        }
+    // Add other cases here if necessary
+    FTRACE(FPrint( _L("CDunSignalCopy::ChangeDownstreamSignal() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called when line status changes
+// ---------------------------------------------------------------------------
+//
+void CDunSignalCopy::RunL()
+    {
+    FTRACE(FPrint( _L("CDunSignalCopy::RunL()" ) ));
+    iSignalCopyState = EDunStateIdle;
+    TInt retTemp = iStatus.Int();
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunSignalCopy::RunL() (failed) complete (%d)"), retTemp));
+        TInt i;
+        TInt count = iCallbacks.Count();
+        TDunConnectionReason connReason;
+        connReason.iReasonType = EDunReasonTypeRunL;
+        connReason.iContext = iContextInUse;
+        connReason.iSignalType = 0;
+        connReason.iSignalHigh = EFalse;
+        connReason.iDirection = EDunDirectionUndefined;
+        connReason.iErrorCode = retTemp;
+        for ( i=0; i<count; i++ )
+            {
+            TRAP_IGNORE(
+                iCallbacks[i]->NotifyProgressChangeL( iComm, connReason ) );
+            }
+        return;
+        }
+    FTRACE(FPrint( _L("CDunSignalCopy::RunL() managing signal 0x%08X" ), iSignals ));
+    ManageSignalChange();
+    FTRACE(FPrint( _L("CDunSignalCopy::RunL() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called on cancel
+// ---------------------------------------------------------------------------
+//
+void CDunSignalCopy::DoCancel()
+    {
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/src/DunSignalNotify.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,385 @@
+/*
+* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Monitors signal changes on network side and reports changes
+*
+*/
+
+
+#ifdef PRJ_USE_NETWORK_STUBS
+#include <c32comm_stub.h>
+#else
+#include <d32comm.h>
+#endif
+#include "DunTransporter.h"
+#include "DunSignalNotify.h"
+#include "DunDebug.h"
+
+const TUint KDunSixLowestBitsMask = 0x3F;  // Symbian magic
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunSignalNotify* CDunSignalNotify::NewL( MDunTransporterUtilityAux* aUtility )
+    {
+    CDunSignalNotify* self = new (ELeave) CDunSignalNotify( aUtility );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CDunSignalNotify::~CDunSignalNotify()
+    {
+    FTRACE(FPrint( _L("CDunSignalNotify::~CDunSignalNotify()") ));
+    ResetData();
+    FTRACE(FPrint( _L("CDunSignalNotify::~CDunSignalNotify() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Resets data to initial values
+// ---------------------------------------------------------------------------
+//
+void CDunSignalNotify::ResetData()
+    {
+    FTRACE(FPrint( _L("CDunSignalNotify::ResetData()") ));
+    // APIs affecting this:
+    // IssueRequest()
+    Stop();
+    // AddCallback()
+    iCallbacks.Close();
+    // Internal
+    Initialize();
+    FTRACE(FPrint( _L("CDunSignalNotify::ResetData() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Adds callback for line status change controlling
+// The callback will be called when line status change is detected in
+// endpoint
+// ---------------------------------------------------------------------------
+//
+TInt CDunSignalNotify::AddCallback( MDunConnMon* aCallback )
+    {
+    FTRACE(FPrint( _L("CDunSignalNotify::AddCallback()" ) ));
+    if ( !aCallback )
+        {
+        FTRACE(FPrint( _L("CDunSignalNotify::AddCallback() (ERROR) complete" ) ));
+        return KErrGeneral;
+        }
+    TInt retTemp = iCallbacks.Find( aCallback );
+    if ( retTemp != KErrNotFound )
+        {
+        FTRACE(FPrint( _L("CDunSignalNotify::AddCallback() (already exists) complete" ) ));
+        return KErrAlreadyExists;
+        }
+    retTemp = iCallbacks.Append( aCallback );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunSignalNotify::AddCallback() (append failed!) complete" ) ));
+        return retTemp;
+        }
+    FTRACE(FPrint( _L("CDunSignalNotify::AddCallback() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Sets media to use for this endpoint monitor
+// ---------------------------------------------------------------------------
+//
+TInt CDunSignalNotify::SetMedia( RComm* aComm )
+    {
+    FTRACE(FPrint( _L("CDunSignalNotify::SetMedia()" )));
+    if ( !aComm )
+        {
+        FTRACE(FPrint( _L("CDunSignalNotify::SetMedia() (aComm) not initialized!" )));
+        return KErrGeneral;
+        }
+    // As it's not possible to listen for RFCOMM signal changes the RTS and DTR
+    // signals should be anyway set high to Dataport
+    aComm->SetSignals( KSignalRTS|KSignalDTR, 0 );
+    // Next check if signal change notification from Dataport supported
+    TCommCaps2 caps;
+    aComm->Caps( caps );
+    if ( !(caps().iNotificationCaps & KNotifySignalsChangeSupported) )
+        {
+        FTRACE(FPrint( _L("CDunSignalNotify::SetMedia() (RComm) (not supported) complete" )));
+        return KErrNotSupported;
+        }
+    iListenSignals = KSignalDTEInputs;
+    iNetwork = aComm;
+    FTRACE(FPrint( _L("CDunSignalNotify::SetMedia() (RComm) complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Issues request to start monitoring the endpoint for line status change
+// ---------------------------------------------------------------------------
+//
+TInt CDunSignalNotify::IssueRequest()
+    {
+    FTRACE(FPrint( _L("CDunSignalNotify::IssueRequest()" )));
+    if ( iSignalNotifyState != EDunStateIdle )
+        {
+        FTRACE(FPrint( _L("CDunSignalNotify::IssueRequest() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    if ( !iNetwork )
+        {
+        FTRACE(FPrint( _L("CDunSignalNotify::IssueRequest() (iNetwork) not initialized!" ) ));
+        return KErrGeneral;
+        }
+    TUint currentSignals = iNetwork->Signals( iListenSignals );
+    TUint oldSignalsLow = iSignals & KDunSixLowestBitsMask;
+    TUint newSignalsLow = currentSignals & KDunSixLowestBitsMask;
+    TUint oldSignalsHigh = oldSignalsLow * KSignalChanged;
+    TUint newSignalsHigh = newSignalsLow * KSignalChanged;
+    FTRACE(FPrint( _L("CDunSignalNotify::IssueRequest() oldSignalsLow=0x%08X" ), oldSignalsLow ));
+    FTRACE(FPrint( _L("CDunSignalNotify::IssueRequest() newSignalsLow=0x%08X" ), newSignalsLow ));
+    FTRACE(FPrint( _L("CDunSignalNotify::IssueRequest() oldSignalsHigh=0x%08X" ), oldSignalsHigh ));
+    FTRACE(FPrint( _L("CDunSignalNotify::IssueRequest() newSignalsHigh=0x%08X" ), newSignalsHigh ));
+    if ( newSignalsLow != oldSignalsLow )
+        {
+        FTRACE(FPrint( _L("CDunSignalNotify::IssueRequest() signals already set..." ) ));
+        iSignals = newSignalsLow | (oldSignalsHigh ^ newSignalsHigh);
+        ManageSignalChange();
+        }
+    else
+        {
+        FTRACE(FPrint( _L("CDunSignalNotify::IssueRequest() start waiting for change..." ) ));
+        iStatus = KRequestPending;
+        iNetwork->NotifySignalChange( iStatus, iSignals, iListenSignals );
+        SetActive();
+        iSignalNotifyState = EDunStateSignalNotify;
+        }
+    FTRACE(FPrint( _L("CDunSignalNotify::IssueRequest() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Stops monitoring the endpoint for line status change
+// ---------------------------------------------------------------------------
+//
+TInt CDunSignalNotify::Stop()
+    {
+    FTRACE(FPrint( _L("CDunSignalNotify::Stop()" )));
+    if ( iSignalNotifyState != EDunStateSignalNotify )
+        {
+        FTRACE(FPrint( _L("CDunSignalNotify::Stop() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    if ( !iNetwork )
+        {
+        FTRACE(FPrint( _L("CDunSignalNotify::Stop() (iNetwork) not initialized!" )));
+        return KErrGeneral;
+        }
+    iNetwork->NotifySignalChangeCancel();
+    Cancel();
+    iSignalNotifyState = EDunStateIdle;
+    FTRACE(FPrint( _L("CDunSignalNotify::Stop() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunSignalNotify::CDunSignalNotify
+// ---------------------------------------------------------------------------
+//
+CDunSignalNotify::CDunSignalNotify( MDunTransporterUtilityAux* aUtility ) :
+    CActive( EPriorityHigh ),
+    iUtility( aUtility )
+    {
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// CDunSignalNotify::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunSignalNotify::ConstructL()
+    {
+    FTRACE(FPrint( _L("CDunSignalNotify::ConstructL()" ) ));
+    if ( !iUtility )
+        {
+        User::Leave( KErrGeneral );
+        }
+    CActiveScheduler::Add( this );
+    FTRACE(FPrint( _L("CDunSignalNotify::ConstructL() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes this class
+// ---------------------------------------------------------------------------
+//
+void CDunSignalNotify::Initialize()
+    {
+    FTRACE(FPrint( _L("CDunSignalNotify::Initialize()" ) ));
+    // Don't initialize iUtility here (it is set through NewL)
+    iSignalNotifyState = EDunStateIdle;
+    iListenSignals = 0;
+    iSignals = 0;
+    iNetwork = NULL;
+    FTRACE(FPrint( _L("CDunSignalNotify::Initialize() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// Manages signal changes
+// ---------------------------------------------------------------------------
+//
+void CDunSignalNotify::ManageSignalChange()
+    {
+    FTRACE(FPrint( _L("CDunSignalNotify::ManageSignalChange()" ) ));
+    // The following signals are input signals from network side:
+    // KSignalDTEInputs = KSignalCTS | KSignalDSR | KSignalDCD | KSignalRNG
+    if ( iSignals & KCTSChanged )
+        {
+        FTRACE(FPrint( _L("CDunSignalNotify::ManageSignalChange() checking CTS..." ) ));
+        if ( iSignals & KSignalCTS )  // CTS changed to high
+            {
+            ReportSignalChange( KSignalCTS, 0 );
+            FTRACE(FPrint( _L("CDunSignalNotify::ManageSignalChange() CTS changed high" ) ));
+            }
+        else  // CTS changed to low
+            {
+            ReportSignalChange( 0, KSignalCTS );
+            FTRACE(FPrint( _L("CDunSignalNotify::ManageSignalChange() CTS changed low" ) ));
+            }
+        }
+    if ( iSignals & KDSRChanged )
+        {
+        FTRACE(FPrint( _L("CDunSignalNotify::ManageSignalChange() checking DSR..." ) ));
+        if ( iSignals & KSignalDSR )  // DSR changed to high
+            {
+            ReportSignalChange( KSignalDSR, 0 );
+            FTRACE(FPrint( _L("CDunSignalNotify::ManageSignalChange() DSR changed high" ) ));
+            }
+        else  // DSR changed to low
+            {
+            ReportSignalChange( 0, KSignalDSR );
+            FTRACE(FPrint( _L("CDunSignalNotify::ManageSignalChange() DSR changed low" ) ));
+            }
+        }
+    if ( iSignals & KDCDChanged )
+        {
+        FTRACE(FPrint( _L("CDunSignalNotify::ManageSignalChange() checking DCD..." ) ));
+        if ( iSignals & KSignalDCD )  // DCD changed to high
+            {
+            ReportSignalChange( KSignalDCD, 0 );
+            FTRACE(FPrint( _L("CDunSignalNotify::ManageSignalChange() DCD changed high" ) ));
+            }
+        else  // DCD changed to low
+            {
+            ReportSignalChange( 0, KSignalDCD );
+            FTRACE(FPrint( _L("CDunSignalNotify::ManageSignalChange() DCD changed low" ) ));
+            }
+        }
+    if ( iSignals & KRNGChanged )
+        {
+        FTRACE(FPrint( _L("CDunSignalNotify::ManageSignalChange() checking RNG..." ) ));
+        if ( iSignals & KSignalRNG )  // RNG changed to high
+            {
+            ReportSignalChange( KSignalRNG, 0 );
+            FTRACE(FPrint( _L("CDunSignalNotify::ManageSignalChange() RNG changed high" ) ));
+            }
+        else  // RNG changed to low
+            {
+            ReportSignalChange( 0, KSignalRNG );
+            FTRACE(FPrint( _L("CDunSignalNotify::ManageSignalChange() RNG changed low" ) ));
+            }
+        }
+    IssueRequest();
+    FTRACE(FPrint( _L("CDunSignalNotify::ManageSignalChange() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// Reports signal change
+// ---------------------------------------------------------------------------
+//
+void CDunSignalNotify::ReportSignalChange( TUint aSetMask, TUint aClearMask )
+    {
+    FTRACE(FPrint( _L("CDunSignalNotify::ReportSignalChange()" ) ));
+
+    TUint signalType = aClearMask;
+    TUint signalHigh = EFalse;
+    if ( aSetMask != 0 )
+        {
+        signalType = aSetMask;
+        signalHigh = ETrue;
+        }
+    TInt i;
+    TInt count = iCallbacks.Count();
+    TDunConnectionReason connReason;
+    TConnId localId = iUtility->GetLocalId( iNetwork );
+    connReason.iReasonType = EDunReasonTypeSignal;
+    connReason.iContext = EDunMediaContextNetwork;
+    connReason.iSignalType = signalType;
+    connReason.iSignalHigh = signalHigh;
+    connReason.iDirection = EDunDirectionUndefined;
+    connReason.iErrorCode = KErrNone;
+    for ( i=0; i<count; i++ )
+        {
+        TRAP_IGNORE(
+            iCallbacks[i]->NotifyProgressChangeL( localId, connReason ) );
+        }
+
+    FTRACE(FPrint( _L("CDunSignalNotify::ReportSignalChange() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called when line status changes
+// ---------------------------------------------------------------------------
+//
+void CDunSignalNotify::RunL()
+    {
+    FTRACE(FPrint( _L("CDunSignalNotify::RunL()" ) ));
+    iSignalNotifyState = EDunStateIdle;
+    TInt retTemp = iStatus.Int();
+    if ( retTemp != KErrNone )
+        {
+        TInt i;
+        TInt count = iCallbacks.Count();
+        TDunConnectionReason connReason;
+        TConnId localId = iUtility->GetLocalId( iNetwork );
+        connReason.iReasonType = EDunReasonTypeRunL;
+        connReason.iContext = EDunMediaContextNetwork;
+        connReason.iSignalType = 0;
+        connReason.iSignalHigh = EFalse;
+        connReason.iDirection = EDunDirectionUndefined;
+        connReason.iErrorCode = retTemp;
+        for ( i=0; i<count; i++ )
+            {
+            TRAP_IGNORE(
+                iCallbacks[i]->NotifyProgressChangeL( localId, connReason ) );
+            }
+        return;
+        }
+    FTRACE(FPrint( _L("CDunSignalNotify::RunL() managing signal 0x%08X" ), iSignals ));
+    ManageSignalChange();
+    FTRACE(FPrint( _L("CDunSignalNotify::RunL() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called on cancel
+// ---------------------------------------------------------------------------
+//
+void CDunSignalNotify::DoCancel()
+    {
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/src/DunSignalWaiter.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,257 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Monitors for new data in RComm local media side
+*
+*/
+
+
+#ifdef PRJ_USE_NETWORK_STUBS
+#include <c32comm_stub.h>
+#else
+#include <d32comm.h>
+#endif
+#include "DunTransporter.h"
+#include "DunSignalWaiter.h"
+#include "DunSignalCopy.h"
+#include "DunDebug.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunSignalWaiter* CDunSignalWaiter::NewL( MDunChannelAllocator* aChannelCallback )
+    {
+    CDunSignalWaiter* self = new (ELeave) CDunSignalWaiter( aChannelCallback );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunSignalWaiter::~CDunSignalWaiter()
+    {
+    FTRACE(FPrint( _L("CDunSignalWaiter::~CDunSignalWaiter()") ));
+    ResetData();
+    FTRACE(FPrint( _L("CDunSignalWaiter::~CDunSignalWaiter() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Resets data to initial values
+// ---------------------------------------------------------------------------
+//
+void CDunSignalWaiter::ResetData()
+    {
+    FTRACE(FPrint( _L("CDunSignalWaiter::ResetData()") ));
+    // APIs affecting this:
+    // IssueRequest()
+    Stop();
+    // AddConnMonCallbackL()
+    iCallbacks.Close();
+    // Internal
+    Initialize();
+    FTRACE(FPrint( _L("CDunSignalWaiter::ResetData() complete") ));
+    }
+
+// ---------------------------------------------------------------------------
+// Adds callback for RunL error controlling
+// The callback will be called when error is detected in asynchronous
+// operation
+// ---------------------------------------------------------------------------
+//
+TInt CDunSignalWaiter::AddCallback( MDunConnMon* aCallback )
+    {
+    FTRACE(FPrint( _L("CDunSignalWaiter::AddCallback()" ) ));
+    if ( !aCallback )
+        {
+        FTRACE(FPrint( _L("CDunSignalWaiter::AddCallback() (ERROR) complete" ) ));
+        return KErrGeneral;
+        }
+    TInt retTemp = iCallbacks.Find( aCallback );
+    if ( retTemp != KErrNotFound )
+        {
+        FTRACE(FPrint( _L("CDunSignalWaiter::AddCallback() (already exists) complete" ) ));
+        return KErrAlreadyExists;
+        }
+    retTemp = iCallbacks.Append( aCallback );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunSignalWaiter::AddCallback() (append failed!) complete" ) ));
+        return retTemp;
+        }
+    FTRACE(FPrint( _L("CDunSignalWaiter::AddCallback() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Sets media to use for this endpoint
+// ---------------------------------------------------------------------------
+//
+TInt CDunSignalWaiter::SetMedia( RComm* aComm )
+    {
+    FTRACE(FPrint( _L("CDunSignalWaiter::SetMedia(RComm) (addr=0x%08X)" ), aComm));
+    if ( !aComm )
+        {
+        FTRACE(FPrint( _L("CDunSignalWaiter::SetMedia() (aComm) not initialized!" )));
+        return KErrGeneral;
+        }
+    TCommCaps2 caps;
+    aComm->Caps( caps );
+    if ( !(caps().iNotificationCaps & KNotifySignalsChangeSupported) )
+        {
+        FTRACE(FPrint( _L("CDunSignalWaiter::SetMedia() (RComm) (not supported) complete" )));
+        return KErrNotSupported;
+        }
+    iComm = aComm;
+    FTRACE(FPrint( _L("CDunSignalWaiter::SetMedia() (RComm) complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Issues request to start waiting for new data in RComm
+// ---------------------------------------------------------------------------
+//
+TInt CDunSignalWaiter::IssueRequest()
+    {
+    FTRACE(FPrint( _L("CDunSignalWaiter::IssueRequest()" )));
+    if ( iSignalWaiterState != EDunStateIdle )
+        {
+        FTRACE(FPrint( _L("CDunSignalWaiter::IssueRequest() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    if ( !iComm )
+        {
+        FTRACE(FPrint( _L("CDunSignalWaiter::IssueRequest() (iComm) not initialized!" ) ));
+        return KErrGeneral;
+        }
+    iStatus = KRequestPending;
+    iComm->NotifySignalChange( iStatus, iSignals, KSignalDCEInputs );
+    SetActive();
+    iSignalWaiterState = EDunStateSignalWaiting;
+    FTRACE(FPrint( _L("CDunSignalWaiter::IssueRequest() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Stops monitoring for new data
+// ---------------------------------------------------------------------------
+//
+TInt CDunSignalWaiter::Stop()
+    {
+    FTRACE(FPrint( _L("CDunSignalWaiter::Stop()" )));
+    if ( iSignalWaiterState != EDunStateSignalWaiting )
+        {
+        FTRACE(FPrint( _L("CDunSignalWaiter::Stop() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    if ( !iComm )
+        {
+        FTRACE(FPrint( _L("CDunSignalWaiter::Stop() (iComm) not initialized!" )));
+        return KErrGeneral;
+        }
+    iComm->NotifySignalChangeCancel();
+    Cancel();
+    iSignalWaiterState = EDunStateIdle;
+    FTRACE(FPrint( _L("CDunSignalWaiter::Stop() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunSignalWaiter::CDunSignalWaiter
+// ---------------------------------------------------------------------------
+//
+CDunSignalWaiter::CDunSignalWaiter( MDunChannelAllocator* aChannelCallback ) :
+    CActive( EPriorityHigh ),
+    iChannelCallback( aChannelCallback )
+    {
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// CDunSignalWaiter::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunSignalWaiter::ConstructL()
+    {
+    FTRACE(FPrint( _L("CDunSignalWaiter::ConstructL()" ) ));
+    if ( !iChannelCallback )
+        {
+        User::Leave( KErrGeneral );
+        }
+    CActiveScheduler::Add( this );
+    FTRACE(FPrint( _L("CDunSignalWaiter::ConstructL() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes this class
+// ---------------------------------------------------------------------------
+//
+void CDunSignalWaiter::Initialize()
+    {
+    FTRACE(FPrint( _L("CDunSignalWaiter::Initialize()" ) ));
+    // Don't initialize iChannelCallback here (it is set through NewL)
+    iSignalWaiterState = EDunStateIdle;
+    iSignals = 0;
+    iComm = NULL;
+    FTRACE(FPrint( _L("CDunSignalWaiter::Initialize() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called when signals changed in RComm object
+// ---------------------------------------------------------------------------
+//
+void CDunSignalWaiter::RunL()
+    {
+    FTRACE(FPrint( _L("CDunSignalWaiter::RunL()" ) ));
+    iSignalWaiterState = EDunStateIdle;
+    TInt retTemp = iStatus.Int();
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunSignalWaiter::RunL() (failed) complete (%d)"), retTemp));
+        TInt count = iCallbacks.Count();
+        TDunConnectionReason connReason;
+        connReason.iReasonType = EDunReasonTypeRunL;
+        connReason.iContext = EDunMediaContextLocal;
+        connReason.iSignalType = 0;
+        connReason.iSignalHigh = EFalse;
+        connReason.iDirection = EDunDirectionUndefined;
+        connReason.iErrorCode = retTemp;
+        for ( TInt i=0; i<count; i++ )
+            {
+            TRAP_IGNORE(
+                iCallbacks[i]->NotifyProgressChangeL( iComm, connReason ) );
+            }
+        return;
+        }
+    if ( iChannelCallback )
+        {
+        iChannelCallback->NotifyNewChannelRequest( iComm );
+        }
+    FTRACE(FPrint( _L("CDunSignalWaiter::RunL() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called on cancel
+// ---------------------------------------------------------------------------
+//
+void CDunSignalWaiter::DoCancel()
+    {
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/src/DunStream.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,320 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definitions needed for common stream functionality
+*
+*/
+
+
+/*
+ * TODO: When local media is of type RComm, listening on it is started with
+ * RComm::NotifyDataAvailable() call. Check that USB ACM port and Irda RCOMM
+ * (and any other new media in the future) behaves correctly so that when
+ * RComm::ReadOneOrMore() is issued, the read is issued immediately without
+ * checking for new data. If waiting for new data happens in this
+ * NotifyDataAvailable/ReadOneOrMore combination, raise a defect to Symbian.
+ */
+
+#include "DunStream.h"
+#include "DunDebug.h"
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunStream::~CDunStream()
+    {
+    FTRACE(FPrint( _L("CDunStream::~CDunStream()" )));
+    ResetData();
+    FTRACE(FPrint( _L("CDunStream::~CDunStream() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Resets data to initial values
+// ---------------------------------------------------------------------------
+//
+void CDunStream::ResetData()
+    {
+    // APIs affecting this:
+    // AddConnMonCallback()
+    iCallbacksR.Close();
+    iCallbacksW.Close();
+    // AddSkippedError()
+    iOkErrorsR.Close();
+    iOkErrorsW.Close();
+    // Internal
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// Adds error code to consider as "no error" to either endpoint
+// ---------------------------------------------------------------------------
+//
+TInt CDunStream::AddSkippedError( TInt aError,
+                                  TDunOperationType aOperationType )
+    {
+    FTRACE(FPrint( _L("CDunStream::AddSkippedError()" ) ));
+    RArray<TInt>* okErrors = NULL;
+    if ( aOperationType == EDunOperationTypeRead )
+        {
+        okErrors = &iOkErrorsR;
+        }
+    else if ( aOperationType == EDunOperationTypeWrite )
+        {
+        okErrors = &iOkErrorsW;
+        }
+    else
+        {
+        FTRACE(FPrint( _L("CDunStream::AddSkippedError() (ERROR) complete" ) ));
+        return KErrGeneral;
+        }
+    if ( aError >= 0 )  // errors can't be >= 0
+        {
+        FTRACE(FPrint( _L("CDunStream::AddSkippedError() (ERROR) complete" ) ));
+        return KErrGeneral;
+        }
+    TInt retTemp = okErrors->Find( aError );
+    if ( retTemp != KErrNotFound )
+        {
+        FTRACE(FPrint( _L("CDunStream::AddSkippedError() (already exists) complete" ) ));
+        return KErrAlreadyExists;
+        }
+    retTemp = okErrors->Append( aError );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunStream::AddSkippedError() (append failed!) complete" ) ));
+        return retTemp;
+        }
+    FTRACE(FPrint( _L("CDunStream::AddSkippedError() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Adds callback for line status change controlling
+// The callback will be called when serious read error is detected
+// ---------------------------------------------------------------------------
+//
+TInt CDunStream::AddConnMonCallback( MDunConnMon* aCallback,
+                                     TDunOperationType aOperationType )
+    {
+    FTRACE(FPrint( _L("CDunStream::AddConnMonCallback()" ) ));
+    RPointerArray<MDunConnMon>* callbacks = NULL;
+    if ( aOperationType == EDunOperationTypeRead )
+        {
+        callbacks = &iCallbacksR;
+        }
+    else if ( aOperationType == EDunOperationTypeWrite )
+        {
+        callbacks = &iCallbacksW;
+        }
+    else
+        {
+        FTRACE(FPrint( _L("CDunStream::AddConnMonCallback() (ERROR) complete" ) ));
+        return KErrGeneral;
+        }
+    if ( !aCallback )
+        {
+        FTRACE(FPrint( _L("CDunStream::AddConnMonCallback() (aCallback) not initialized!" ) ));
+        return KErrGeneral;
+        }
+    TInt retTemp = callbacks->Find( aCallback );
+    if ( retTemp != KErrNotFound )
+        {
+        FTRACE(FPrint( _L("CDunStream::AddCallback() (already exists) complete" ) ));
+        return KErrAlreadyExists;
+        }
+    retTemp = callbacks->Append( aCallback );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunStream::AddCallback() (append failed!) complete" ) ));
+        return retTemp;
+        }
+    FTRACE(FPrint( _L("CDunStream::AddCallback() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Sets buffering for this stream
+// ---------------------------------------------------------------------------
+//
+TInt CDunStream::SetBuffering( TPtr8* aBufferPtr )
+    {
+    FTRACE(FPrint( _L("CDunStream::SetBuffering()" ) ));
+    if ( !aBufferPtr )
+        {
+        FTRACE(FPrint( _L("CDunStream::SetBuffering() (aBufferPtr) not initialized!" ) ));
+        return KErrGeneral;
+        }
+    if ( iBufferPtr )
+        {
+        FTRACE(FPrint( _L("CDunStream::SetBuffering() (already exists) complete" ) ));
+        return KErrAlreadyExists;
+        }
+    iBufferPtr = aBufferPtr;
+    FTRACE(FPrint( _L("CDunStream::SetBuffering() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Sets media to use for this endpoint
+// ---------------------------------------------------------------------------
+//
+TInt CDunStream::SetMedia( RComm* aComm, TDunMediaContext aMediaContext )
+    {
+    FTRACE(FPrint( _L("CDunStream::SetMedia() (RComm)" ) ));
+    if ( !aComm )
+        {
+        FTRACE(FPrint( _L("CDunStream::SetMedia() (RComm) (aComm not initialized!) complete" ) ));
+        return KErrGeneral;
+        }
+    if ( aMediaContext == EDunMediaContextNetwork )
+        {
+        iNetwork = aComm;
+        }
+    else if ( aMediaContext == EDunMediaContextLocal )
+        {
+        iComm = aComm;
+        }
+    else
+        {
+        FTRACE(FPrint( _L("CDunStream::SetMedia() (RComm) (ERROR) complete" )));
+        return KErrGeneral;
+        }
+    FTRACE(FPrint( _L("CDunStream::SetMedia() (RComm) complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Sets media to use for this endpoint
+// ---------------------------------------------------------------------------
+//
+TInt CDunStream::SetMedia( RSocket* aSocket,
+                           TDunMediaContext aMediaContext )
+    {
+    FTRACE(FPrint( _L("CDunStream::SetMedia() (RSocket)" ) ));
+    if ( !aSocket )
+        {
+        FTRACE(FPrint( _L("CDunStream::SetMedia() (RSocket) (aSocket not initialized!) complete" ) ));
+        return KErrGeneral;
+        }
+    if ( aMediaContext == EDunMediaContextLocal )
+        {
+        iSocket = aSocket;
+        }
+    else
+        {
+        FTRACE(FPrint( _L("CDunStream::SetMedia() (RSocket) (not supported) complete" ) ));
+        return KErrNotSupported;
+        }
+    FTRACE(FPrint( _L("CDunStream::SetMedia() (RSocket) complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Gets media context
+// ---------------------------------------------------------------------------
+//
+TDunMediaContext CDunStream::GetMediaContext( TDunStreamType aStreamType )
+    {
+    FTRACE(FPrint( _L("CDunStream::GetMediaContext()" ) ));
+    if ( aStreamType == EDunStreamTypeUpstream )
+        {
+        if ( iOperationType == EDunOperationTypeRead )
+            {
+            return EDunMediaContextLocal;
+            }
+        else if ( iOperationType == EDunOperationTypeWrite )
+            {
+            return EDunMediaContextNetwork;
+            }
+        else
+            {
+            return EDunMediaContextUndefined;
+            }
+        }
+    else if ( aStreamType == EDunStreamTypeDownstream )
+        {
+        if ( iOperationType == EDunOperationTypeRead )
+            {
+            return EDunMediaContextNetwork;
+            }
+        else if ( iOperationType == EDunOperationTypeWrite )
+            {
+            return EDunMediaContextLocal;
+            }
+        else
+            {
+            return EDunMediaContextUndefined;
+            }
+        }
+    FTRACE(FPrint( _L("CDunStream::GetMediaContext() complete" ) ));
+    return EDunMediaContextUndefined;
+    }
+
+// ---------------------------------------------------------------------------
+// Check whether an error code is severe error or not
+// ---------------------------------------------------------------------------
+//
+TInt CDunStream::ProcessErrorCondition( TInt aError, TBool& aIsError )
+    {
+    FTRACE(FPrint( _L("CDunStream::ProcessErrorCondition() (Dir=%d)" ), iDirection));
+    aIsError = EFalse;
+    if ( aError != KErrNone )
+        {
+        aIsError = ETrue;
+        RArray<TInt>* okErrors = NULL;
+        if ( iOperationType == EDunOperationTypeRead )
+            {
+            okErrors = &iOkErrorsR;
+            }
+        else // iOperationType == EDunOperationTypeWrite
+            {
+            okErrors = &iOkErrorsW;
+            }
+        TInt retTemp = okErrors->Find( aError );
+        if ( retTemp == KErrNotFound )
+            {
+            FTRACE(FPrint( _L("CDunStream::ProcessErrorCondition() (Dir=%d) (%d=ETrue) complete" ), iDirection, aError));
+            return ETrue;
+            }
+        }
+    FTRACE(FPrint( _L("CDunStream::ProcessErrorCondition() (Dir=%d) (%d=EFalse) complete" ), iDirection, aError));
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunStream::CDunStream
+// ---------------------------------------------------------------------------
+//
+CDunStream::CDunStream() : CActive( EPriorityHigh )
+    {
+    Initialize();
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes this class
+// ---------------------------------------------------------------------------
+//
+void CDunStream::Initialize()
+    {
+    // Don't initialize iUtility here (it is set through NewL)
+    iBufferPtr = NULL;
+    iReadLengthSocket = 0;
+    iOperationType = EDunOperationTypeUndefined;
+    iTransferState = EDunStateIdle;
+    iDirection = EDunDirectionUndefined;
+    iNetwork = NULL;
+    iSocket = NULL;
+    iComm = NULL;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/src/DunTransUtils.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1077 @@
+/*
+* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Utility class for other CDunTransporter classes
+*
+*/
+
+
+#include <e32base.h>
+#include <e32property.h>
+#include "dundomainpskeys.h"
+#include "DunTransUtils.h"
+#include "DunDataWaiter.h"
+#include "DunUpstream.h"
+#include "DunDownstream.h"
+#include "DunSignalCopy.h"
+#include "DunSignalNotify.h"
+#include "DunNoteHandler.h"
+#include "DunUtils.h"
+#include "DunDebug.h"
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunTransUtils* CDunTransUtils::NewL( CDunTransporter& aParent,
+                                      MDunPluginManager* aPluginManager )
+    {
+    CDunTransUtils* self = new (ELeave) CDunTransUtils( aParent,
+                                                        aPluginManager );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunTransUtils::~CDunTransUtils()
+    {
+    FTRACE(FPrint( _L("CDunTransUtils::~CDunTransUtils()" )));
+    FTRACE(FPrint( _L("CDunTransUtils::~CDunTransUtils() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// CDunTransUtils::CDunTransUtils
+// ---------------------------------------------------------------------------
+//
+CDunTransUtils::CDunTransUtils( CDunTransporter& aParent,
+                                MDunPluginManager* aPluginManager ) :
+    iParent( aParent ),
+    iChannelData( aParent.iChannelData ),
+    iServAdvData( aParent.iServAdvData ),
+    iPluginManager( aPluginManager )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CDunTransUtils::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunTransUtils::ConstructL()
+    {
+    FTRACE(FPrint( _L("CDunTransUtils::ConstructL()" )));
+    if ( !iPluginManager )
+        {
+        User::Leave( KErrGeneral );
+        }
+    FTRACE(FPrint( _L("CDunTransUtils::ConstructL() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Manages service advertisement status changes
+// ---------------------------------------------------------------------------
+//
+void CDunTransUtils::ManageAdvertisementStatusChange( TBool aAdvertise,
+                                                      TBool aCreation )
+    {
+    FTRACE(FPrint( _L("CDunTransUtils::ManageAdvertisementStatusChange()" )));
+    TInt i;
+    TInt count;
+    iParent.iAdvertise = aAdvertise;
+    count = iServAdvData.Count();
+    for ( i=0; i<count; i++ )
+        {
+        TDunServAdvData& servAdvData = iServAdvData[i];
+        if ( servAdvData.iServAdvMon )
+            {
+            if ( aAdvertise )
+                {
+                servAdvData.iServAdvMon->NotifyAdvertisementStart( aCreation );
+                }
+            else
+                {
+                servAdvData.iServAdvMon->NotifyAdvertisementEnd();
+                }
+            }
+        }
+    FTRACE(FPrint( _L("CDunTransUtils::ManageAdvertisementStatusChange() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Creates empty channel data
+// ---------------------------------------------------------------------------
+//
+void CDunTransUtils::CreateEmptyChannelData( TDunChannelData& aChannel )
+    {
+    FTRACE(FPrint( _L("CDunTransUtils::CreateEmptyChannelData()" )));
+    aChannel.iNetwork = NULL;
+    aChannel.iComm = NULL;
+    aChannel.iSocket = NULL;
+    aChannel.iChannelName = NULL;
+    aChannel.iUpstreamRW = NULL;
+    aChannel.iDownstreamRW = NULL;
+    aChannel.iBufferUpstream = NULL;
+    aChannel.iBufferDownstream = NULL;
+    aChannel.iBufferUpPtr = NULL;
+    aChannel.iBufferDownPtr = NULL;
+    aChannel.iUpstreamSignalCopy = NULL;
+    aChannel.iDownstreamSignalCopy = NULL;
+    aChannel.iSignalNotify = NULL;
+    aChannel.iOwnerUid = TUid::Null();
+    aChannel.iChannelInUse = EFalse;
+    FTRACE(FPrint( _L("CDunTransUtils::CreateEmptyChannelData() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Creates new buffer if source buffer defined, otherwise already existing
+// buffer will be used
+// ---------------------------------------------------------------------------
+//
+void CDunTransUtils::DoCreateBufferLC( TUint8* aSrcBuffer,
+                                       TPtr8* aSrcPtr,
+                                       TUint8*& aDstBuffer,
+                                       TPtr8*& aDstPtr,
+                                       TInt aBufferLength,
+                                       TInt& aItemsInCs )
+    {
+    FTRACE(FPrint( _L("CDunTransUtils::DoCreateBufferLC()" )));
+    TUint8* buffer;
+    if ( !aSrcBuffer )
+        {
+        buffer = new (ELeave) TUint8[aBufferLength];
+        CleanupStack::PushL( buffer );
+        aItemsInCs++;
+        FTRACE(FPrint( _L("CDunTransUtils::DoCreateBufferLC() new created" )));
+        }
+    else
+        {
+        buffer = aSrcBuffer;
+        FTRACE(FPrint( _L("CDunTransUtils::DoCreateBufferLC() existing set" )));
+        }
+    TPtr8* bufferPtr;
+    if ( !aSrcPtr )
+        {
+        bufferPtr = new (ELeave) TPtr8( buffer, aBufferLength, aBufferLength );
+        CleanupStack::PushL( bufferPtr );
+        aItemsInCs++;
+        FTRACE(FPrint( _L("CDunTransUtils::DoCreateBufferLC() new created" )));
+        }
+    else
+        {
+        bufferPtr = aSrcPtr;
+        FTRACE(FPrint( _L("CDunTransUtils::DoCreateBufferLC() existing set" )));
+        }
+    aDstBuffer = buffer;
+    aDstPtr = bufferPtr;
+    FTRACE(FPrint( _L("CDunTransUtils::DoCreateBufferLC() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Creates new signal copy object if source defined, otherwise already
+// existing will be used
+// ---------------------------------------------------------------------------
+//
+void CDunTransUtils::DoCreateSignalCopyLC( CDunSignalCopy* aSrcSignalCopy,
+                                           CDunSignalCopy*& aDstSignalCopy,
+                                           TInt& aItemsInCs )
+    {
+    FTRACE(FPrint( _L("CDunTransUtils::DoCreateSignalCopyLC()" )));
+    CDunSignalCopy* signalCopy;
+    if ( !aSrcSignalCopy )
+        {
+        signalCopy = CDunSignalCopy::NewL();
+        CleanupStack::PushL( signalCopy );
+        aItemsInCs++;
+        FTRACE(FPrint( _L("CDunTransUtils::DoCreateSignalCopyLC() new created" )));
+        }
+    else
+        {
+        signalCopy = aSrcSignalCopy;
+        FTRACE(FPrint( _L("CDunTransUtils::DoCreateSignalCopyLC() existing set" )));
+        }
+    aDstSignalCopy = signalCopy;
+    FTRACE(FPrint( _L("CDunTransUtils::DoCreateSignalCopyLC() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Creates new signal notify object if source defined, otherwise already
+// existing will be used
+// ---------------------------------------------------------------------------
+//
+void CDunTransUtils::DoCreateSignalNotifyLC(
+    CDunSignalNotify* aSrcSignalNotify,
+    CDunSignalNotify*& aDstSignalNotify,
+    TInt& aItemsInCs )
+    {
+    FTRACE(FPrint( _L("CDunTransUtils::DoCreateSignalNotifyLC()" )));
+    CDunSignalNotify* signalNotify;
+    if ( !aSrcSignalNotify )
+        {
+        signalNotify = CDunSignalNotify::NewL( this );
+        CleanupStack::PushL( signalNotify );
+        aItemsInCs++;
+        FTRACE(FPrint( _L("CDunTransUtils::DoCreateSignalNotifyLC() new created" )));
+        }
+    else
+        {
+        signalNotify = aSrcSignalNotify;
+        FTRACE(FPrint( _L("CDunTransUtils::DoCreateSignalNotifyLC() existing set" )));
+        }
+    aDstSignalNotify = signalNotify;
+    FTRACE(FPrint( _L("CDunTransUtils::DoCreateSignalNotifyLC() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Creates transfer objects for reader and writer if sources defined,
+// otherwise already existing ones will be used
+// ---------------------------------------------------------------------------
+//
+void CDunTransUtils::DoCreateUpTransferObjectL( CDunUpstream* aSrcReader,
+                                                CDunUpstream*& aDstReader,
+                                                TInt& aItemsInCs )
+    {
+    FTRACE(FPrint( _L("CDunTransUtils::DoCreateUpTransferObjectL()" )));
+    CDunUpstream* dunReader;
+    if ( !aSrcReader )
+        {
+        dunReader = CDunUpstream::NewL( this );
+        CleanupStack::PushL( dunReader );
+        aItemsInCs++;
+        FTRACE(FPrint( _L("CDunTransUtils::DoCreateUpTransferObjectL() new created" )));
+        }
+    else
+        {
+        dunReader = aSrcReader;
+        FTRACE(FPrint( _L("CDunTransUtils::DoCreateUpTransferObjectL() existing set" )));
+        }
+    aDstReader = dunReader;
+    FTRACE(FPrint( _L("CDunTransUtils::DoCreateUpTransferObjectL() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Creates transfer objects for reader and writer if sources defined,
+// otherwise already existing ones will be used
+// ---------------------------------------------------------------------------
+//
+void CDunTransUtils::DoCreateDownTransferObjectL( CDunDownstream* aSrcReader,
+                                                  CDunDownstream*& aDstReader,
+                                                  TInt& aItemsInCs )
+    {
+    FTRACE(FPrint( _L("CDunTransUtils::DoCreateDownTransferObjectL()" )));
+    CDunDownstream* dunReader;
+    if ( !aSrcReader )
+        {
+        dunReader = CDunDownstream::NewL( this );
+        CleanupStack::PushL( dunReader );
+        aItemsInCs++;
+        FTRACE(FPrint( _L("CDunTransUtils::DoCreateDownTransferObjectL() new created" )));
+        }
+    else
+        {
+        dunReader = aSrcReader;
+        FTRACE(FPrint( _L("CDunTransUtils::DoCreateDownTransferObjectL() existing set" )));
+        }
+    aDstReader = dunReader;
+    FTRACE(FPrint( _L("CDunTransUtils::DoCreateDownTransferObjectL() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Resets/frees network data of aIndex:th channel
+// ---------------------------------------------------------------------------
+//
+TInt CDunTransUtils::DeleteOneNetworkData( TInt aIndex )
+    {
+    FTRACE(FPrint( _L("CDunTransUtils::DeleteOneNetworkData()" )));
+
+    if ( aIndex < 0 ||
+         aIndex >= iChannelData.Count() )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DeleteOneNetworkData (not found) complete" )));
+        return KErrNotFound;
+        }
+
+    TDunChannelData& channelData = iChannelData[aIndex];
+    if ( !channelData.iChannelInUse )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DeleteOneNetworkData() (channel not found) complete" ), aIndex));
+        return KErrGeneral;
+        }
+
+    // channelData.iDownstreamSignalCopy may or may not exist (optional)
+    // channelData.iSignalNotify may or may not exist (optional)
+    delete channelData.iDownstreamSignalCopy;
+    channelData.iDownstreamSignalCopy = NULL;
+    delete channelData.iSignalNotify;
+    channelData.iSignalNotify = NULL;
+    delete channelData.iDownstreamRW;
+    channelData.iDownstreamRW = NULL;
+
+    FTRACE(FPrint( _L("CDunTransUtils::DeleteOneNetworkData complete()" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Resets/frees network data of aIndex:th channel
+// ---------------------------------------------------------------------------
+//
+TInt CDunTransUtils::DeleteOneLocalData( TInt aIndex )
+    {
+    FTRACE(FPrint( _L("CDunTransUtils::DeleteOneLocalData()" )));
+
+    if ( aIndex < 0 ||
+         aIndex >= iChannelData.Count() )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DeleteOneLocalData() (not found) complete" )));
+        return KErrNotFound;
+        }
+
+    TDunChannelData& channelData = iChannelData[aIndex];
+    if ( !channelData.iChannelInUse )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DeleteOneLocalData() (channel not found) complete" ), aIndex));
+        return KErrGeneral;
+        }
+
+    // channelData.iUpstreamSignalCopy may or may not exist (optional)
+    delete channelData.iUpstreamSignalCopy;
+    channelData.iUpstreamSignalCopy = NULL;
+    delete channelData.iUpstreamRW;
+    channelData.iUpstreamRW = NULL;
+
+    FTRACE(FPrint( _L("CDunTransUtils::DeleteOneLocalData() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Deletes buffering objects of aIndex:th channel
+// ---------------------------------------------------------------------------
+//
+TInt CDunTransUtils::DeleteBuffering( TInt aIndex )
+    {
+    FTRACE(FPrint( _L("CDunTransUtils::DeleteBuffering()" )));
+
+    if ( aIndex < 0 ||
+         aIndex >= iChannelData.Count() )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DeleteBuffering() (not found) complete" )));
+        return KErrNotFound;
+        }
+    TDunChannelData& channelData = iChannelData[aIndex];
+    if ( !channelData.iChannelInUse )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DeleteBuffering() (channel not found) complete" ), aIndex));
+        return KErrGeneral;
+        }
+
+    delete channelData.iChannelName;
+    channelData.iChannelName = NULL;
+    delete channelData.iBufferUpstream;
+    channelData.iBufferUpstream = NULL;
+    delete channelData.iBufferDownstream;
+    channelData.iBufferDownstream = NULL;
+    delete channelData.iBufferUpPtr;
+    channelData.iBufferUpPtr = NULL;
+    delete channelData.iBufferDownPtr;
+    channelData.iBufferDownPtr = NULL;
+
+    FTRACE(FPrint( _L("CDunTransUtils::DeleteBuffering() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes first free channel
+// ---------------------------------------------------------------------------
+//
+TInt CDunTransUtils::InitializeFirstFreeChannel( TConnId aLocalIdNew )
+    {
+    FTRACE(FPrint( _L("CDunTransUtils::InitializeFirstFreeChannel()" )));
+    TInt i;
+    TInt count;
+    TInt retTemp;
+    TInt firstFree = KErrNotFound;
+    count = iChannelData.Count();
+    for ( i=0; i<count; i++ )
+        {
+        TDunChannelData& channelData = iChannelData[i];
+        if ( channelData.iComm==aLocalIdNew ||
+             channelData.iSocket==aLocalIdNew )
+            {
+            FTRACE(FPrint( _L("CDunTransUtils::InitializeFirstFreeChannel() (already exists) complete" )));
+            return KErrAlreadyExists;
+            }
+        if ( !channelData.iChannelInUse && firstFree==KErrNotFound )
+            {
+            firstFree = i;
+            // no "break" here since KErrAlreadyExists needs to be checked
+            }
+        }
+    if ( firstFree >= 0 )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::InitializeFirstFreeChannel() complete" )));
+        return i;
+        }
+    // Free channel not found, now create new if possible
+    TDunChannelData emptyChannel;
+    CreateEmptyChannelData( emptyChannel );
+    retTemp = iChannelData.Append( emptyChannel );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::InitializeFirstFreeChannel() (append failed!) complete" )));
+        return retTemp;
+        }
+    FTRACE(FPrint( _L("CDunTransUtils::InitializeFirstFreeChannel() complete" )));
+    return i;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunTransporterUtility.
+// Allocates a channel by creating and setting local media independent
+// objects
+// This is a common method used by exported local media dependent methods
+// ---------------------------------------------------------------------------
+//
+void CDunTransUtils::DoAllocateChannelL( RComm* aComm,
+                                         TInt& aBufferLength,
+                                         TInt aFirstFree,
+                                         MDunBufferCorrection* aCorrection )
+    {
+    FTRACE(FPrint( _L("CDunTransUtils::DoAllocateChannelL()" )));
+    TInt retTemp;
+    TInt itemsInCs = 0;
+
+    if ( !iParent.iNetwork )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DoAllocateChannelL() (iNetwork) not initialized!" )));
+        User::Leave( KErrGeneral );
+        }
+
+    FTRACE(FPrint( _L("CDunTransUtils::DoAllocateChannelL() aFirstFree = %d" ), aFirstFree));
+
+    // Allocate network channel
+    RComm* networkEntity;
+    retTemp = iParent.iNetwork->AllocateChannel( networkEntity );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DoAllocateChannelL() network allocation failed" )));
+        if ( retTemp == KErrTooBig )
+            {
+            // Start to show note
+            if ( iParent.iNoteHandler )
+                {
+                iParent.iNoteHandler->IssueRequest();
+                }
+            // Set flag to indicate that advertisement is not possible anymore
+            ManageAdvertisementStatusChange( EFalse );
+            FTRACE(FPrint( _L("CDunTransUtils::DoAllocateChannelL() (too big) complete" )));
+            User::Leave( KErrTooBig );
+            }
+        FTRACE(FPrint( _L("CDunTransUtils::DoAllocateChannelL() (ERROR) complete" )));
+        User::Leave( KErrGeneral );
+        }
+
+    TInt currentLength = networkEntity->ReceiveBufferLength();
+    TInt newLength = currentLength;
+    FTRACE(FPrint( _L("CDunTransUtils::DoAllocateChannelL() buffer length before = %d" ), currentLength));
+    if ( aCorrection )
+        {
+        // Get network side buffer length and request change if required.
+        // Check "newlength>currentLength" here as it is not possible to
+        // increase Dataport's buffer length
+        newLength = aCorrection->NotifyBufferCorrection( currentLength );
+        if ( newLength<=0 || newLength>currentLength )
+            {
+            FTRACE(FPrint( _L("CDunTransUtils::DoAllocateChannelL() unknown buffer length" )));
+            User::Leave( KErrGeneral );
+            }
+        // It is not possible to set Dataport side receive buffer length to any
+        // arbitrary value (currently only 8kB..20kB are supported but that
+        // can't be queried via an API). So here only default buffer size will
+        // be used from Dataport while this component's local buffering uses
+        // Dataport's default buffer size if not adjusted via plugin side.
+        // NOTE: If Dataport side starts to support arbitrary receive buffer
+        // size, it should be changed here if newLength != currentLength.
+        }
+    aBufferLength = newLength;
+    FTRACE(FPrint( _L("CDunTransUtils::DoAllocateChannelL() buffer length after = %d" ), newLength));
+
+    // Get channel data
+
+    TDunChannelData& channelData = iChannelData[aFirstFree];
+
+    // Create buffers and set length
+
+    TUint8* bufferUpstream;
+    TPtr8* bufferUpPtr;
+    DoCreateBufferLC( channelData.iBufferUpstream,
+                      channelData.iBufferUpPtr,
+                      bufferUpstream,
+                      bufferUpPtr,
+                      newLength,
+                      itemsInCs );
+
+    TUint8* bufferDownstream;
+    TPtr8* bufferDownPtr;
+    DoCreateBufferLC( channelData.iBufferDownstream,
+                      channelData.iBufferDownPtr,
+                      bufferDownstream,
+                      bufferDownPtr,
+                      newLength,
+                      itemsInCs );
+
+    // Create signal copy objects
+
+    CDunSignalCopy* upstreamCopy = channelData.iUpstreamSignalCopy;
+    CDunSignalCopy* downstreamCopy = channelData.iDownstreamSignalCopy;
+    if ( aComm )
+        {
+        DoCreateSignalCopyLC( channelData.iUpstreamSignalCopy,
+                              upstreamCopy,
+                              itemsInCs );
+        DoCreateSignalCopyLC( channelData.iDownstreamSignalCopy,
+                              downstreamCopy,
+                              itemsInCs );
+        retTemp = upstreamCopy->SetMedia( aComm,
+                                          networkEntity,
+                                          EDunStreamTypeUpstream );
+        if ( retTemp != KErrNone )
+            {
+            delete upstreamCopy;
+            upstreamCopy = NULL;
+            }
+        retTemp = downstreamCopy->SetMedia( aComm,
+                                            networkEntity,
+                                            EDunStreamTypeDownstream );
+        if ( retTemp != KErrNone )
+            {
+            delete downstreamCopy;
+            downstreamCopy = NULL;
+            }
+        }
+
+    // Create signal notify objects
+
+    CDunSignalNotify* signalNotify = channelData.iSignalNotify;
+    if ( !aComm )  // RSocket
+        {
+        DoCreateSignalNotifyLC( channelData.iSignalNotify,
+                                signalNotify,
+                                itemsInCs );
+        retTemp = signalNotify->SetMedia( networkEntity );
+        if ( retTemp != KErrNone )
+            {
+            delete signalNotify;
+            signalNotify = NULL;
+            }
+        }
+
+    // Create upstream objects
+
+    CDunUpstream* upstreamRW;
+    DoCreateUpTransferObjectL( channelData.iUpstreamRW,
+                               upstreamRW,
+                               itemsInCs );
+    upstreamRW->SetBuffering( bufferUpPtr );
+    upstreamRW->SetMedia( networkEntity, EDunMediaContextNetwork );
+    upstreamRW->SetActivityCallback( this );
+
+    // Create downstream objects
+
+    CDunDownstream* downstreamRW;
+    DoCreateDownTransferObjectL( channelData.iDownstreamRW,
+                                 downstreamRW,
+                                 itemsInCs );
+    downstreamRW->SetBuffering( bufferDownPtr );
+    downstreamRW->SetMedia( networkEntity, EDunMediaContextNetwork );
+
+    // Save values
+
+    channelData.iNetwork = networkEntity;
+    channelData.iUpstreamRW = upstreamRW;
+    channelData.iDownstreamRW = downstreamRW;
+    channelData.iBufferUpstream = bufferUpstream;
+    channelData.iBufferDownstream = bufferDownstream;
+    channelData.iBufferUpPtr = bufferUpPtr;
+    channelData.iBufferDownPtr = bufferDownPtr;
+    channelData.iUpstreamSignalCopy = upstreamCopy;
+    channelData.iDownstreamSignalCopy = downstreamCopy;
+    channelData.iSignalNotify = signalNotify;
+
+    CleanupStack::Pop( itemsInCs );
+
+    // Set flag to indicate that advertisement is now possible
+    ManageAdvertisementStatusChange( ETrue, ETrue );
+
+    FTRACE(FPrint( _L("CDunTransUtils::DoAllocateChannelL() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunTransporterUtility.
+// Adds connection monitor callback for either local media or network side
+// by connection ID
+// Connection monitor will be added to aIndex:th endpoint
+// ---------------------------------------------------------------------------
+//
+TInt CDunTransUtils::DoAddConnMonCallback( TInt aIndex,
+                                           MDunConnMon* aCallback,
+                                           TDunDirection aDirection,
+                                           TBool aSignal )
+    {
+    FTRACE(FPrint( _L("CDunTransUtils::DoAddConnMonCallback()" )));
+
+    if ( !iParent.iNetwork )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DoAddConnMonCallback() (iNetwork) not initialized!" )));
+        return KErrGeneral;
+        }
+
+    if ( aIndex < 0 ||
+         aIndex >= iChannelData.Count() )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DoAddConnMonCallback() (not found) complete" )));
+        return KErrNotFound;
+        }
+
+    TDunChannelData& channelData = iChannelData[aIndex];
+
+    // Get upstream and downstream
+    CDunUpstream* upstream = channelData.iUpstreamRW;
+    CDunDownstream* downstream = channelData.iDownstreamRW;
+
+    if ( aDirection == EDunReaderUpstream )
+        {
+        // Initialize stream for AT parsing (ignore errors)
+        upstream->InitializeForAtParsing( downstream,
+                                          channelData.iChannelName,
+                                          upstream,
+                                          downstream );
+        downstream->InitializeForDataPushing( upstream );
+        }
+
+    // Get stream type and operation type
+
+    TDunStreamType streamType =
+        static_cast<TDunStreamType>( aDirection & KDunStreamTypeMask );
+    TDunOperationType operationType =
+        static_cast<TDunOperationType>( aDirection & KDunOperationTypeMask );
+
+    if ( streamType == EDunStreamTypeUpstream )
+        {
+        // If signal copy object(s) exist then add RunL error monitoring for them
+        if ( channelData.iUpstreamSignalCopy )  // optional
+            {
+            // Add callback (ignore errors)
+            channelData.iUpstreamSignalCopy->AddCallback( aCallback );
+            }
+        }
+    else if ( streamType == EDunStreamTypeDownstream )
+        {
+        // If signal copy object(s) exist then add RunL error monitoring for them
+        if ( channelData.iDownstreamSignalCopy )  // optional
+            {
+            // Add callback (ignore errors)
+            channelData.iDownstreamSignalCopy->AddCallback( aCallback );
+            }
+        }
+    else
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DoAddConnMonCallback() (stream) not initialized!" ) ));
+        return KErrGeneral;
+        }
+
+    // Set signal notify callback
+
+    if ( aSignal && aDirection==EDunReaderDownstream )
+        {
+        if ( !channelData.iSignalNotify )
+            {
+            FTRACE(FPrint( _L("CDunTransUtils::DoAddConnMonCallback() (iSignalNotify) not initialized" )));
+            return KErrGeneral;
+            }
+        // Add callback (ignore errors)
+        channelData.iSignalNotify->AddCallback( aCallback );
+        }
+
+    // Add callback (ignore errors)
+    if ( streamType == EDunStreamTypeUpstream )
+        {
+        upstream->AddConnMonCallback( aCallback, operationType );
+        }
+    else  // streamType == EDunStreamTypeDownstream
+        {
+        downstream->AddConnMonCallback( aCallback, operationType );
+        }
+
+    FTRACE(FPrint( _L("CDunTransUtils::DoAddConnMonCallback() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunTransporterUtility.
+// Adds error to consider as no error condition when doing any of the four
+// endpoint's read/writer operation
+// Error will be added to aIndex:th endpoint
+// ---------------------------------------------------------------------------
+//
+TInt CDunTransUtils::DoAddSkippedError( TInt aIndex,
+                                        TInt aError,
+                                        TDunDirection aDirection )
+    {
+    FTRACE(FPrint( _L("CDunTransUtils::AddOneSkippedError" ) ));
+    if ( aIndex < 0 ||
+         aIndex >= iChannelData.Count() )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DoAddSkippedError() (not found) complete" )));
+        return KErrNotFound;
+        }
+    TDunChannelData& channelData = iChannelData[aIndex];
+    if ( !channelData.iChannelInUse )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DoAddSkippedError() (channel not found) complete" ), aIndex));
+        return KErrGeneral;
+        }
+
+    if ( aDirection != EDunReaderUpstream  &&
+         aDirection != EDunWriterUpstream &&
+         aDirection != EDunReaderDownstream &&
+         aDirection != EDunWriterDownstream )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DoAddSkippedError() (ERROR) added" ) ));
+        return KErrNotSupported;
+        }
+
+    TDunStreamType streamType =
+        static_cast<TDunStreamType>( aDirection & KDunStreamTypeMask );
+    TDunOperationType operationType =
+        static_cast<TDunOperationType>( aDirection & KDunOperationTypeMask );
+
+    if ( streamType != EDunStreamTypeUpstream &&
+         streamType != EDunStreamTypeDownstream )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DoAddSkippedError() (stream) not initialized!" ) ));
+        return KErrGeneral;
+        }
+
+    // Add skipped error (ignore errors)
+
+    if ( streamType == EDunStreamTypeUpstream )
+        {
+        channelData.iUpstreamRW->AddSkippedError( aError, operationType );
+        }
+    else if ( streamType == EDunStreamTypeDownstream )
+        {
+        channelData.iDownstreamRW->AddSkippedError( aError, operationType );
+        }
+    else
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DoAddSkippedError() (stream) not initialized!" ) ));
+        return KErrGeneral;
+        }
+
+    FTRACE(FPrint( _L("CDunTransUtils::DoAddSkippedError() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunTransporterUtility.
+// Issues transfers requests for aIndex:th transfer objects
+// ---------------------------------------------------------------------------
+//
+TInt CDunTransUtils::DoIssueTransferRequests( TInt aIndex )
+    {
+    FTRACE(FPrint( _L("CDunTransUtils::DoIssueTransferRequests()" )));
+    if ( aIndex < 0 ||
+         aIndex >= iChannelData.Count() )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DoIssueTransferRequests() (not found) complete" )));
+        return KErrNotFound;
+        }
+    TDunChannelData& channelData = iChannelData[aIndex];
+    if ( !channelData.iChannelInUse )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DoIssueTransferRequests() (channel not found) complete" ), aIndex));
+        return KErrGeneral;
+        }
+
+    if ( !channelData.iUpstreamRW )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DoIssueTransferRequests() (iUpstreamRW) not initialized!" )));
+        return KErrGeneral;
+        }
+    if ( !channelData.iDownstreamRW )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DoIssueTransferRequests() (iDownstreamRW) not initialized!" )));
+        return KErrGeneral;
+        }
+
+    // Below issuing requests on signal objects (CDunSignalCopy,
+    // CDunSignalNotify) before issuing request on read/write objects
+    // (CDunUpstream/CDunDownstream). This is to guarantee that if signals are
+    // already set in local media side then they will be copied to network side
+    // before data.
+
+    if ( channelData.iUpstreamSignalCopy )  // optional (RComm)
+        {
+        channelData.iUpstreamSignalCopy->IssueRequest();
+        }
+    if ( channelData.iDownstreamSignalCopy )  // optional (RComm)
+        {
+        channelData.iDownstreamSignalCopy->IssueRequest();
+        }
+    if ( channelData.iSignalNotify )  // optional (RSocket)
+        {
+        channelData.iSignalNotify->IssueRequest();
+        }
+    channelData.iUpstreamRW->StartStream();
+    channelData.iDownstreamRW->StartStream();
+
+    FTRACE(FPrint( _L("CDunTransUtils::DoIssueTransferRequests() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunTransporterUtility.
+// Stops transfers for aIndex:th transfer objects
+// ---------------------------------------------------------------------------
+//
+TInt CDunTransUtils::DoStopTransfers( TInt aIndex )
+    {
+    FTRACE(FPrint( _L("CDunTransUtils::DoStopTransfers()" )));
+    if ( aIndex < 0 ||
+         aIndex >= iChannelData.Count() )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DoStopTransfers() (not found) complete" )));
+        return KErrNotFound;
+        }
+
+    TDunChannelData& channelData = iChannelData[aIndex];
+    if ( !channelData.iChannelInUse )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DoStopTransfers() (channel not found) complete" ), aIndex));
+        return KErrGeneral;
+        }
+
+    if ( !channelData.iUpstreamRW )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DoStopTransfers() (iUpstreamRW) not initialized!" )));
+        return KErrGeneral;
+        }
+    if ( !channelData.iDownstreamRW )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DoStopTransfers() (iDownstreamRW) not initialized!" )));
+        return KErrGeneral;
+        }
+
+    // Now stop operation of signal objects (CDunSignalCopy, CDunSignalNotify)
+    // before stopping operation on read/write objects (CDunUpstream/
+    // CDunDownstream). This is to ensure that signals don't change after
+    // stopping read/write which in turn could cause problems.
+
+    if ( channelData.iUpstreamSignalCopy )  // optional (RComm)
+        {
+        channelData.iUpstreamSignalCopy->Stop();
+        }
+    if ( channelData.iDownstreamSignalCopy )  // optional (RComm)
+        {
+        channelData.iDownstreamSignalCopy->Stop();
+        }
+    if ( channelData.iSignalNotify )  // optional (RSocket)
+        {
+        channelData.iSignalNotify->Stop();
+        }
+    channelData.iUpstreamRW->Stop();
+    channelData.iDownstreamRW->Stop();
+
+    FTRACE(FPrint( _L("CDunTransUtils::DoStopTransfers() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunTransporterUtility.
+// Free aIndex:th channel's objects
+// ---------------------------------------------------------------------------
+//
+TInt CDunTransUtils::DoFreeChannel( TInt aIndex )
+    {
+    FTRACE(FPrint( _L("CDunTransUtils::DoFreeChannel()" )));
+
+    TDunChannelData& channelData = iChannelData[aIndex];
+    if ( aIndex < 0 ||
+         aIndex >= iChannelData.Count() )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DoFreeChannel (not found) complete" )));
+        return KErrNotFound;
+        }
+    if ( !channelData.iChannelInUse )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DoFreeChannel (already free) complete" )));
+        return KErrNone;
+        }
+    if ( !iParent.iNetwork )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::DoFreeChannel (iNetwork) not initialized!" )));
+        return KErrGeneral;
+        }
+
+    DoStopTransfers( aIndex );
+    DeleteOneNetworkData( aIndex );
+    DeleteOneLocalData( aIndex );
+    DeleteBuffering( aIndex );
+
+    iParent.iNetwork->FreeChannel( channelData.iNetwork );
+
+    channelData.iNetwork = NULL;
+    channelData.iComm = NULL;
+    channelData.iSocket = NULL;
+    channelData.iChannelInUse = EFalse;
+
+    // If note exist then stop it now as no reason to show it anymore
+    if ( iParent.iNoteHandler )
+        {
+        iParent.iNoteHandler->Stop();
+        }
+    // Set flag to indicate that advertisement is now possible
+    ManageAdvertisementStatusChange( ETrue, EFalse );
+
+    FTRACE(FPrint( _L("CDunTransUtils::DoFreeChannel() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunTransporterUtilityAux.
+// Gets local ID counterpart of a network ID
+// ---------------------------------------------------------------------------
+//
+TConnId CDunTransUtils::GetLocalId( RComm* aComm )
+    {
+    FTRACE(FPrint( _L("CDunTransUtils::GetLocalId()" )));
+    TInt mediaIndex = iParent.GetMediaIndex( aComm, EDunMediaContextNetwork );
+    if ( mediaIndex < 0 )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::GetLocalId() (ERROR) complete (%d)" ), mediaIndex));
+        return NULL;
+        }
+    if ( mediaIndex >= iChannelData.Count() )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::GetLocalId() (not found) complete" ) ));
+        return NULL;
+        }
+    TDunChannelData& channelData = iChannelData[mediaIndex];
+    if ( channelData.iComm )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::GetLocalId() (iComm) complete" )));
+        return channelData.iComm;
+        }
+    if ( channelData.iSocket )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::GetLocalId() (iSocket) complete" )));
+        return channelData.iSocket;
+        }
+    FTRACE(FPrint( _L("CDunTransUtils::GetLocalId() (ERROR) complete" )));
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// From MDunTransporterUtilityAux.
+// Notifies when serious read/write error is detected on a connection
+// ---------------------------------------------------------------------------
+//
+TInt CDunTransUtils::DoNotifyConnectionNotOk(
+    RComm* aComm,
+    RSocket* aSocket,
+    TDunConnectionReason& aConnReason,
+    RPointerArray<MDunConnMon>& aCallbacks )
+    {
+    FTRACE(FPrint( _L("CDunTransUtils::DoNotifyConnectionNotOk()" )));
+    TConnId localId = NULL;
+    if ( aComm )
+        {
+        localId = aComm;
+        }
+    else if ( aSocket )
+        {
+        localId = aSocket;
+        }
+    TInt i;
+    TInt count = aCallbacks.Count();
+    for ( i=0; i<count; i++ )
+        {
+        if ( !aCallbacks[i] )
+            {
+            FTRACE(FPrint( _L("CDunTransUtils::DoNotifyConnectionNotOk() (iCallbacks[%d]) not initialized!" ), i));
+            return KErrGeneral;
+            }
+        TRAP_IGNORE(
+            aCallbacks[i]->NotifyProgressChangeL( localId, aConnReason ) );
+        }
+    FTRACE(FPrint( _L("CDunTransUtils::DoNotifyConnectionNotOk() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunActivityManager.
+// Notifies about activity on a channel
+// ---------------------------------------------------------------------------
+//
+TInt CDunTransUtils::NotifyChannelActivity()
+    {
+    FTRACE(FPrint( _L("CDunTransUtils::NotifyChannelActivity()" )));
+    iParent.iActiveChannels++;
+    if ( iParent.iActiveChannels == 1 )
+        {
+        // Now set key and notify (only once) that DUN is active
+        TInt retTemp = RProperty::Set( KPSUidDialupConnStatus,
+                                       KDialupConnStatus,
+                                       EDialupActive );
+        if ( retTemp != KErrNone )
+            {
+            FTRACE(FPrint( _L("CDunTransUtils::NotifyChannelActivity() (ERROR) complete" )));
+            return retTemp;
+            }
+        }
+    FTRACE(FPrint( _L("CDunTransUtils::NotifyChannelActivity() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunActivityManager.
+// Notifies about inactivity on a channel
+// ---------------------------------------------------------------------------
+//
+TInt CDunTransUtils::NotifyChannelInactivity()
+    {
+    FTRACE(FPrint( _L("CDunTransUtils::NotifyChannelInactivity()" )));
+    if ( iParent.iActiveChannels <= 0 )
+        {
+        FTRACE(FPrint( _L("CDunTransUtils::NotifyChannelInactivity() (wrong iActiveChannels!) complete" )));
+        return KErrGeneral;
+        }
+    iParent.iActiveChannels--;
+    if ( iParent.iActiveChannels == 0 )
+        {
+        // Now set key and notify (only once) that DUN is inactive
+        TInt retTemp = RProperty::Set( KPSUidDialupConnStatus,
+                                       KDialupConnStatus,
+                                       EDialupInactive );
+        if ( retTemp != KErrNone )
+            {
+            FTRACE(FPrint( _L("CDunTransUtils::NotifyChannelInactivity() (ERROR) complete" )));
+            return retTemp;
+            }
+        }
+    FTRACE(FPrint( _L("CDunTransUtils::NotifyChannelInactivity() complete" )));
+    return KErrNone;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/src/DunTransporter.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,891 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Managing abstracted "channels" of network side communication
+*
+*/
+
+
+#include "DunTransUtils.h"
+#include "DunTransporter.h"
+#include "DunDataWaiter.h"
+#include "DunUpstream.h"
+#include "DunDownstream.h"
+#include "DunSignalCopy.h"
+#include "DunNoteHandler.h"
+#include "DunUtils.h"
+#include "DunDebug.h"
+#include "DunPlugin.h"
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CDunTransporter* CDunTransporter::NewL(
+    MDunPluginManager* aPluginManager,
+    TInt aNumOfMaxChannels )
+    {
+    CDunTransporter* self = new (ELeave) CDunTransporter( aPluginManager,
+                                                          aNumOfMaxChannels );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunTransporter::~CDunTransporter()
+    {
+    FTRACE(FPrint( _L("CDunTransporter::~CDunTransporter()" )));
+    UnInitialize();
+    FTRACE(FPrint( _L("CDunTransporter::~CDunTransporter() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Number of allocated channels, is the same number as allocated and active
+// (non-waiting) channels
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CDunTransporter::NumberOfAllocatedChannels()
+    {
+    FTRACE(FPrint( _L("CDunTransporter::NumberOfAllocatedChannels()" )));
+    TInt i;
+    TInt allocChannels = 0;
+    TInt count = iChannelData.Count();
+    for ( i=0; i<count; i++ )
+        {
+        TDunChannelData& channelData = iChannelData[i];
+        if ( channelData.iChannelInUse )
+            {
+            allocChannels++;
+            }
+        }
+    FTRACE(FPrint( _L("CDunTransporter::NumberOfAllocatedChannels() complete" )));
+    return allocChannels;
+    }
+
+// ---------------------------------------------------------------------------
+// Number of waiting channels, is the same number as allocated and inactive
+// (waiting) channels
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CDunTransporter::NumberOfWaitingChannels()
+    {
+    FTRACE(FPrint( _L("CDunTransporter::NumberWaitingChannels()" )));
+    if ( !iInitialized )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::NumberWaitingChannels() complete" )));
+        return 0;
+        }
+    TInt waiters = iChanMan->NumberOfWaiters();
+    FTRACE(FPrint( _L("CDunTransporter::NumberWaitingChannels() complete" )));
+    return waiters;
+    }
+
+// ---------------------------------------------------------------------------
+// Gets the number of allocated channels by owner UID, is the same number as
+// allocated and active (non-waiting) channels
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CDunTransporter::GetNumberOfAllocatedChannelsByUid(
+    TUid aOwnerUid )
+    {
+    FTRACE(FPrint( _L("CDunTransporter::GetNumberOfAllocatedChannelsByUid()" )));
+    TInt i;
+    TInt allocChannels = 0;
+    TInt count = iChannelData.Count();
+    for ( i=0; i<count; i++ )
+        {
+        TDunChannelData& channelData = iChannelData[i];
+        if ( channelData.iOwnerUid==aOwnerUid && channelData.iChannelInUse )
+            {
+            allocChannels++;
+            }
+        }
+    FTRACE(FPrint( _L("CDunTransporter::GetNumberOfAllocatedChannelsByUid() complete" )));
+    return allocChannels;
+    }
+
+// ---------------------------------------------------------------------------
+// Gets the number of waiting channels by owner UID, is the same number as
+// allocated and inactive (waiting) channels
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CDunTransporter::GetNumberOfWaitingChannelsByUid(
+    TUid aOwnerUid )
+    {
+    FTRACE(FPrint( _L("CDunTransporter::GetNumberWaitingChannelsByUid()" )));
+    if ( !iInitialized )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::GetNumberWaitingChannelsByUid() complete" )));
+        return 0;
+        }
+    TInt waiters = iChanMan->GetNumberOfWaitersByUid( aOwnerUid );
+    FTRACE(FPrint( _L("CDunTransporter::GetNumberWaitingChannelsByUid() complete" )));
+    return waiters;
+    }
+
+// ---------------------------------------------------------------------------
+// Transporter's service advertisement status
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TBool CDunTransporter::AdvertisementStatus()
+    {
+    FTRACE(FPrint( _L("CDunTransporter::AdvertisementStatus()" )));
+    FTRACE(FPrint( _L("CDunTransporter::AdvertisementStatus() complete" )));
+    return iAdvertise;
+    }
+
+// ---------------------------------------------------------------------------
+// Creates a channel of communication between local media (aComm) and network
+// Local media object pointer also works as a connection ID for the
+// allocated channel
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CDunTransporter::AllocateChannelL(
+    RComm* aComm,
+    TUid aOwnerUid,
+    const TDesC8& aName,
+    TBool aEnqueuedFail,
+    MDunBufferCorrection* aCorrection )
+    {
+    FTRACE(FPrint( _L("CDunTransporter::AllocateChannel() (RComm)" )));
+
+    if ( !aComm )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::AllocateChannel() (aComm not initialized!) complete" )));
+        User::Leave( KErrGeneral );
+        }
+
+    if ( !aComm->SubSessionHandle() )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::AllocateChannel() (RComm) (bad handle) complete" ) ));
+        User::Leave( KErrBadHandle );
+        }
+
+    TInt retTemp = InitializeOnDemand();
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::AllocateChannel() (RComm) (ERROR) complete" ) ));
+        User::Leave( retTemp );
+        }
+
+    iChanMan->AddConnWaiterL( aComm,
+                              aOwnerUid,
+                              aName,
+                              aEnqueuedFail,
+                              aCorrection );
+
+    FTRACE(FPrint( _L("CDunTransporter::AllocateChannel() (RComm) complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Creates a channel of communication between local media (aSocket) and
+// network
+// Local media object pointer also works as a connection ID for the
+// allocated channel
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CDunTransporter::AllocateChannelL(
+    RSocket* aSocket,
+    TUid aOwnerUid,
+    const TDesC8& aName,
+    TBool aEnqueuedFail,
+    TBool& aNoFreeChans )
+    {
+    FTRACE(FPrint( _L("CDunTransporter::AllocateChannel() (RSocket)" )));
+
+    aNoFreeChans = EFalse;  // Initialize now if plugin didn't do it already
+
+    if ( !aSocket )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::AllocateChannel() (aSocket not initialized!) complete" )));
+        User::Leave( KErrGeneral );
+        }
+    if ( !aSocket->SubSessionHandle() )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::AllocateChannel() (RSocket) (bad handle) complete" ) ));
+        User::Leave( KErrBadHandle );
+        }
+    TInt retTemp = InitializeOnDemand();
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::AllocateChannel() (RSocket) (ERROR) complete" )));
+        User::Leave( retTemp );
+        }
+    TInt firstFree = iUtility->InitializeFirstFreeChannel( aSocket );
+    if ( firstFree < 0 )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::AllocateChannel() (RSocket) (firstfree failed!) complete" ) ));
+        User::Leave( firstFree );
+        }
+    if ( firstFree >= iChannelData.Count() )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::AllocateChannel() (RSocket) (firstfree failed!) complete" ) ));
+        User::Leave( KErrGeneral );
+        }
+    TInt bufferLength = KErrNotFound;
+    // bufferLength will be omitted (not needed to set to RSocket)
+    TRAPD( retTrap,
+        iUtility->DoAllocateChannelL(NULL, bufferLength, firstFree, NULL) );
+    if ( retTrap != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::AllocateChannel() (RSocket) trapped!" ) ));
+        UnInitializeOnDemand();  // remove unused initialized channel
+        if ( retTrap == KErrTooBig )
+            {
+            if ( aEnqueuedFail )
+                {
+                // Inform plugin enqueue request
+                iPluginManager->NotifyPluginEnqueueRequest( aOwnerUid );
+                }
+            aNoFreeChans = ETrue;  // Inform plugin about no free channels
+            FTRACE(FPrint( _L("CDunTransporter::AllocateChannel() (RSocket) complete" )));
+            User::Leave( KErrTooBig );
+            }
+        FTRACE(FPrint( _L("CDunTransporter::AllocateChannel() (RSocket) complete" )));
+        User::Leave( retTrap );
+        }
+    TDunChannelData& channelData = iChannelData[firstFree];
+    channelData.iSocket = aSocket;
+    channelData.iChannelName = HBufC8::NewMaxL( aName.Length() );
+    TPtr8 chanNamePtr = channelData.iChannelName->Des();
+    chanNamePtr.Copy( aName );
+    channelData.iUpstreamRW->SetMedia( aSocket, EDunMediaContextLocal );
+    channelData.iDownstreamRW->SetMedia( aSocket, EDunMediaContextLocal );
+    channelData.iOwnerUid = aOwnerUid;
+    // Channel now occupied
+    channelData.iChannelInUse = ETrue;
+
+    // Clear the queue, just to be sure
+    iPluginManager->NotifyPluginDequeueRequest( aOwnerUid );
+
+    FTRACE(FPrint( _L("CDunTransporter::AllocateChannel() (RSocket) complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Frees an allocated channel by local media (aComm) connection ID
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CDunTransporter::FreeChannel( RComm* aComm )
+    {
+    FTRACE(FPrint( _L("CDunTransporter::FreeChannel() (RComm)" )));
+
+    TInt retTemp = CheckInitAndHandle( aComm );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::FreeChannel() (RComm) (ERROR) complete" ) ));
+        return retTemp;
+        }
+
+    retTemp = iChanMan->RemoveConnWaiter( aComm );
+    if ( retTemp == KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::FreeChannel() (RComm) complete" )));
+        return KErrNone;
+        }
+
+    // No waiter found, so try to find from channels
+    TInt mediaIndex = GetMediaIndex( aComm );
+    if ( mediaIndex < 0 )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::FreeChannel() (RComm) (ERROR) complete" ) ));
+        return mediaIndex;
+        }
+
+    retTemp = iUtility->DoFreeChannel( mediaIndex );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::FreeChannel() (RComm) (ERROR) complete" )));
+        return retTemp;
+        }
+    UnInitializeOnDemand();
+
+    FTRACE(FPrint( _L("CDunTransporter::FreeChannel() (RComm) complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Frees an allocated channel by local media (aSocket) connection ID
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CDunTransporter::FreeChannel( RSocket* aSocket )
+    {
+    FTRACE(FPrint( _L("CDunTransporter::FreeChannel() (RSocket)" )));
+
+    TInt retTemp = CheckInitAndHandle( aSocket );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::FreeChannel() (RSocket) (ERROR) complete" ) ));
+        return retTemp;
+        }
+
+    TInt mediaIndex = GetMediaIndex( aSocket );
+    if ( mediaIndex < 0 )
+        {
+        return mediaIndex;
+        }
+
+    retTemp = iUtility->DoFreeChannel( mediaIndex );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::FreeChannel() (RSocket) (ERROR) complete" ) ));
+        return retTemp;
+        }
+    UnInitializeOnDemand();
+
+    FTRACE(FPrint( _L("CDunTransporter::FreeChannel() (RSocket) complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Issues transfer requests for all transfer objects by local media
+// (aComm) connection ID
+// This will cause the Transporter by be ready for transferring data
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CDunTransporter::IssueTransferRequestsL( RComm* aComm )
+    {
+    FTRACE(FPrint( _L("CDunTransporter::IssueTransferRequests() (RComm)" )));
+
+    User::LeaveIfError( CheckInitAndHandle( aComm ) );
+    TInt retTemp = iChanMan->IssueConnWaiterRequest( aComm );
+    if ( retTemp == KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::IssueTransferRequests() (RComm) complete" )));
+        return;
+        }
+
+    // No waiter found, so try to find from channels
+    TInt mediaIndex = GetMediaIndexL( aComm );
+    User::LeaveIfError( iUtility->DoIssueTransferRequests( mediaIndex ) );
+
+    FTRACE(FPrint( _L("CDunTransporter::IssueTransferRequests() (RComm) complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Issues transfer requests for all transfer objects by local media
+// (aSocket) connection ID
+// This will cause the Transporter by be ready for transferring data
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CDunTransporter::IssueTransferRequestsL( RSocket* aSocket )
+    {
+    FTRACE(FPrint( _L("CDunTransporter::IssueTransferRequests() (RSocket)" )));
+
+    User::LeaveIfError( CheckInitAndHandle( aSocket ) );
+    TInt mediaIndex = GetMediaIndexL( aSocket );
+    User::LeaveIfError( iUtility->DoIssueTransferRequests(mediaIndex) );
+
+    FTRACE(FPrint( _L("CDunTransporter::IssueTransferRequests() (RSocket) complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Stops transfers for all transfer objects by local media (aComm)
+// connection ID
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CDunTransporter::StopTransfers( RComm* aComm )
+    {
+    FTRACE(FPrint( _L("CDunTransporter::StopTransfers() (RComm)" )));
+
+    TInt retTemp = CheckInitAndHandle( aComm );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::StopTransfers() (RComm) (ERROR) complete" ) ));
+        return retTemp;
+        }
+
+    retTemp = iChanMan->StopConnWaiter( aComm );
+    if ( retTemp == KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::StopTransfers() (RComm) complete" )));
+        return KErrNone;
+        }
+
+    // No waiter found, so try to find from channels
+    TInt mediaIndex = GetMediaIndex( aComm );
+    if ( mediaIndex < 0 )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::StopTransfers() (RComm) (ERROR) complete" ) ));
+        return mediaIndex;
+        }
+
+    retTemp = iUtility->DoStopTransfers( mediaIndex );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::StopTransfers() (RComm) (ERROR) complete" )));
+        return retTemp;
+        }
+
+    FTRACE(FPrint( _L("CDunTransporter::StopTransfers() (RComm) complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Stops transfers for all transfer objects by local media (aSocket)
+// connection ID
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CDunTransporter::StopTransfers( RSocket* aSocket )
+    {
+    FTRACE(FPrint( _L("CDunTransporter::StopTransfers() (RSocket)" )));
+
+    TInt retTemp = CheckInitAndHandle( aSocket );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::StopTransfers() (RSocket) (ERROR) complete" ) ));
+        return retTemp;
+        }
+
+    TInt mediaIndex = GetMediaIndex( aSocket );
+    if ( mediaIndex < 0 )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::StopTransfers() (RSocket) (ERROR) complete" ) ));
+        return mediaIndex;
+        }
+
+    retTemp = iUtility->DoStopTransfers( mediaIndex );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::StopTransfers() (RSocket) (ERROR) complete" )));
+        return retTemp;
+        }
+
+    FTRACE(FPrint( _L("CDunTransporter::StopTransfers() (RSocket) complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Adds connection monitor callback for either local media or network side
+// by connection ID
+// Callbacks will be called read/write error is detected during endpoint
+// operation
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CDunTransporter::AddConnMonCallbackL( RComm* aComm,
+                                                    MDunConnMon* aCallback,
+                                                    TDunDirection aDirection,
+                                                    TBool /*aSignal*/ )
+    {
+    FTRACE(FPrint( _L("CDunTransporter::AddConnMonCallbackL() (RComm)" )));
+
+    User::LeaveIfError( CheckInitAndHandle( aComm ) );
+    TInt retTemp = iChanMan->SaveWaiterConnMonCallbackL( aComm,
+                                                         aCallback,
+                                                         aDirection );
+    if ( retTemp == KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::AddConnMonCallbackL() (RComm) complete" )));
+        return;
+        }
+
+    TInt mediaIndex = GetMediaIndexL( aComm );
+    User::LeaveIfError( iUtility->DoAddConnMonCallback( mediaIndex,
+                                                        aCallback,
+                                                        aDirection,
+                                                        NULL ));
+
+    FTRACE(FPrint( _L("CDunTransporter::AddConnMonCallbackL() (RComm) complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Adds connection monitor callback for either local media or network side
+// by connection ID
+// Callbacks will be called when line status switches to high or low
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CDunTransporter::AddConnMonCallbackL( RSocket* aSocket,
+                                                    MDunConnMon* aCallback,
+                                                    TDunDirection aDirection,
+                                                    TBool aSignal )
+    {
+    FTRACE(FPrint( _L("CDunTransporter::AddConnMonCallbackL() (RSocket)" )));
+
+    User::LeaveIfError( CheckInitAndHandle( aSocket ) );
+    TInt mediaIndex = GetMediaIndexL( aSocket );
+    User::LeaveIfError( iUtility->DoAddConnMonCallback( mediaIndex,
+                                                        aCallback,
+                                                        aDirection,
+                                                        aSignal ));
+
+    FTRACE(FPrint( _L("CDunTransporter::AddConnMonCallbackL() (RSocket) complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Adds error to consider as no error condition when doing any of the four
+// endpoint's read/writer operation
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CDunTransporter::AddSkippedErrorL( TInt aError,
+                                                 RComm* aComm,
+                                                 TDunDirection aDirection )
+    {
+    FTRACE(FPrint( _L("CDunTransporter::AddSkippedErrorL() (RComm)" )));
+
+    User::LeaveIfError( CheckInitAndHandle( aComm ) );
+    TInt retTemp = iChanMan->SaveWaiterSkippedErrorL( aError,
+                                                      aComm,
+                                                      aDirection );
+    if ( retTemp == KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::AddSkippedErrorL() (RComm) complete" )));
+        return;
+        }
+
+    TInt mediaIndex = GetMediaIndexL( aComm );
+    User::LeaveIfError( iUtility->DoAddSkippedError( mediaIndex,
+                                                     aError,
+                                                     aDirection ));
+
+    FTRACE(FPrint( _L("CDunTransporter::AddSkippedErrorL() (RComm) complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Adds error to consider as no error condition when doing any of the four
+// endpoint's read/writer operation
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CDunTransporter::AddSkippedErrorL( TInt aError,
+                                                 RSocket* aSocket,
+                                                 TDunDirection aDirection )
+    {
+    FTRACE(FPrint( _L("CDunTransporter::AddSkippedErrorL() (RSocket)" )));
+
+    User::LeaveIfError( CheckInitAndHandle( aSocket ) );
+    TInt mediaIndex = GetMediaIndexL( aSocket );
+    User::LeaveIfError( iUtility->DoAddSkippedError( mediaIndex,
+                                                     aError,
+                                                     aDirection ));
+
+    FTRACE(FPrint( _L("CDunTransporter::AddSkippedErrorL() (RSocket) complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Sets service advertisement monitor callback by owner UID
+// Callbacks will be called when advertisement status changes.
+// The callbacks are updated with every successfully completed
+// channel allocation/free (and allocation failure) so it is recommended
+// to call this method after AllocateChannelL().
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CDunTransporter::SetAdvertisementMonitorL(
+    TUid aOwnerUid,
+    MDunServAdvMon* aCallback )
+    {
+    FTRACE(FPrint( _L("CDunTransporter::SetAdvertisementMonitorL()" )));
+    TInt i;
+    TInt count;
+    if ( !aCallback )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::SetAdvertisementMonitorL() (aCallback) not initialized!" )));
+        User::Leave( KErrGeneral );
+        }
+    count = iServAdvData.Count();
+    for ( i=0; i<count; i++ )
+        {
+        TDunServAdvData& servAdvData = iServAdvData[i];
+        if ( servAdvData.iOwnerUid==aOwnerUid &&
+             servAdvData.iServAdvMon==aCallback )
+            {
+            FTRACE(FPrint( _L("CDunTransporter::SetAdvertisementMonitorL() (already exist) complete" )));
+            User::Leave( KErrAlreadyExists );
+            }
+        }
+    TDunServAdvData servAdvData;
+    servAdvData.iOwnerUid = aOwnerUid;
+    servAdvData.iServAdvMon = aCallback;
+    iServAdvData.AppendL( servAdvData );
+    FTRACE(FPrint( _L("CDunTransporter::SetAdvertisementMonitorL() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Frees service advertisement monitor callback by plugin UID
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CDunTransporter::FreeAdvertisementMonitor(
+    TUid aOwnerUid,
+    MDunServAdvMon* aCallback )
+    {
+    FTRACE(FPrint( _L("CDunTransporter::FreeAdvertisementMonitor()" )));
+    TInt i;
+    TInt count = iServAdvData.Count();
+    for ( i=0; i<count; i++ )
+        {
+        TDunServAdvData& servAdvData = iServAdvData[i];
+        if ( servAdvData.iOwnerUid==aOwnerUid &&
+             servAdvData.iServAdvMon==aCallback )
+            {
+            iServAdvData.Remove( i );
+            FTRACE(FPrint( _L("CDunTransporter::FreeAdvertisementMonitor() complete" )));
+            return KErrNone;
+            }
+        }
+    FTRACE(FPrint( _L("CDunTransporter::FreeAdvertisementMonitor() (not found) complete" )));
+    return KErrNotFound;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunTransporter::CDunTransporter
+// ---------------------------------------------------------------------------
+//
+CDunTransporter::CDunTransporter( MDunPluginManager* aPluginManager,
+                                  TInt aNumOfMaxChannels ) :
+    iUtility( NULL ),
+    iPluginManager( aPluginManager ),
+    iActiveChannels( 0 ),
+    iNumOfMaxChannels( aNumOfMaxChannels ),
+    iInitialized( EFalse ),
+    iAdvertise( ETrue ),
+    iNetwork( NULL )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CDunTransporter::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunTransporter::ConstructL()
+    {
+    FTRACE(FPrint( _L("CDunTransporter::ConstructL()" )));
+    if ( !iPluginManager || iNumOfMaxChannels<0 )
+        {
+        User::Leave( KErrGeneral );
+        }
+    FTRACE(FPrint( _L("CDunTransporter::ConstructL() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes the transporter, must be called as the first operation
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CDunTransporter::InitializeL()
+    {
+    FTRACE(FPrint( _L("CDunTransporter::InitializeL()" )));
+
+    if ( iInitialized )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::InitializeL() (already exists) complete" )));
+        return KErrAlreadyExists;
+        }
+    CDunTransUtils* utility = CDunTransUtils::NewL( *this, iPluginManager );
+    iUtility = static_cast<MDunTransporterUtility*>( utility );
+    MDunTransporterUtilityAux* utilityAux = static_cast<MDunTransporterUtilityAux*>( utility );
+    iChanMan = CDunChanMan::NewL( *this, iUtility, utilityAux, iPluginManager );
+    iNetwork = CDunNetDataport::NewL( iNumOfMaxChannels );
+    iNetwork->InitializeL();
+    iNoteHandler = CDunNoteHandler::NewL();
+    iInitialized = ETrue;
+
+    FTRACE(FPrint( _L("CDunTransporter::InitializeL() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// UnInitializes the transporter, can be called as the last operation
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CDunTransporter::UnInitialize()
+    {
+    FTRACE(FPrint( _L("CDunTransporter::UnInitialize()" )));
+    // first stop channel waiters before deletion
+    if ( iChanMan )
+        {
+        iChanMan->ResetData();
+        }
+    // now ready to remove channel data as no existing waiters
+    TInt i;
+    TInt count = iChannelData.Count();
+    for ( i=0; i<count; i++ )
+        {
+        if ( iChannelData[i].iChannelInUse )
+            {
+            iUtility->DoFreeChannel( i );
+            }
+        }
+    iChannelData.Close();
+    iServAdvData.Close();
+    DeleteTransporter();
+    iInitialized = EFalse;
+    FTRACE(FPrint( _L("CDunTransporter::UnInitialize() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Initialize the transporter
+// ---------------------------------------------------------------------------
+//
+TInt CDunTransporter::InitializeOnDemand()
+    {
+    FTRACE(FPrint( _L("CDunTransporter::InitializeOnDemand()" ) ));
+    if ( !iInitialized )
+        {
+        TRAPD( retTrap, InitializeL() );
+        if ( retTrap != KErrNone )
+            {
+            FTRACE(FPrint( _L("CDunTransporter::InitializeOnDemand() initialize failed!" ) ));
+            return retTrap;
+            }
+        }
+    FTRACE(FPrint( _L("CDunTransporter::InitializeOnDemand() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// UnInitialize the transporter
+// ---------------------------------------------------------------------------
+//
+TInt CDunTransporter::UnInitializeOnDemand()
+    {
+    FTRACE(FPrint( _L("CDunTransporter::UnInitializeOnDemand()" ) ));
+    if ( !iInitialized )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::UnInitializeOnDemand() (not ready) complete" ) ));
+        return KErrNotReady;
+        }
+    // Check if non-free channel exists, also remove empty channel(s)
+    TInt i;
+    TBool allFree = ETrue;
+    for ( i=iChannelData.Count()-1; i>=0; i-- )
+        {
+        TDunChannelData& channelData = iChannelData[i];
+        if ( !channelData.iChannelInUse )
+            {
+            if ( !channelData.iNetwork )
+                {
+                // iChannelData must not contain data here
+                iChannelData.Remove( i );
+                }
+            }
+        else  // channel not free
+            {
+            allFree = EFalse;
+            FTRACE(FPrint( _L("CDunTransporter::UnInitializeOnDemand() channel found" ) ));
+            }
+        }
+    if ( iChanMan->NumberOfWaiters() > 0 )
+        {
+        allFree = EFalse;
+        FTRACE(FPrint( _L("CDunTransporter::UnInitializeOnDemand() waiter found" ) ));
+        }
+    if ( allFree )
+        {
+        // All channels were free -> uninitialize
+        UnInitialize();
+        FTRACE(FPrint( _L("CDunTransporter::UnInitializeOnDemand() complete" ) ));
+        return KErrNone;
+        }
+    FTRACE(FPrint( _L("CDunTransporter::UnInitializeOnDemand() (not ready) complete" ) ));
+    return KErrNotReady;
+    }
+
+// ---------------------------------------------------------------------------
+// Returns index of media for connection ID
+// ---------------------------------------------------------------------------
+//
+TInt CDunTransporter::GetMediaIndex( TConnId aConnId,
+                                     TDunMediaContext aMediaContext )
+    {
+    FTRACE(FPrint( _L("CDunTransporter::GetMediaIndex()" )));
+    if ( aMediaContext != EDunMediaContextNetwork &&
+         aMediaContext != EDunMediaContextLocal )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::GetMediaIndex() (not supported) complete" )));
+        return KErrNotSupported;
+        }
+    TInt i;
+    TInt count = iChannelData.Count();
+    for ( i=0; i<count; i++ )
+        {
+        TDunChannelData& channelData = iChannelData[i];
+        if ( (aMediaContext==EDunMediaContextNetwork && channelData.iNetwork==aConnId) ||
+             (aMediaContext==EDunMediaContextLocal   && channelData.iComm==aConnId)    ||
+             (aMediaContext==EDunMediaContextLocal   && channelData.iSocket==aConnId) )
+            {
+            if ( !channelData.iChannelInUse )
+                {
+                FTRACE(FPrint( _L("CDunTransporter::GetMediaIndex() (channel free!) complete" ) ));
+                return KErrGeneral;
+                }
+            FTRACE(FPrint( _L("CDunTransporter::GetMediaIndex() complete (i=%d)" ), i));
+            return i;
+            }
+        }
+    FTRACE(FPrint( _L("CDunTransporter::GetMediaIndex() (not found) complete" )));
+    return KErrNotFound;
+    }
+
+// ---------------------------------------------------------------------------
+// Returns index of media for connection ID
+// ---------------------------------------------------------------------------
+//
+TInt CDunTransporter::GetMediaIndexL( TConnId aConnId,
+                                      TDunMediaContext aMediaContext )
+    {
+    FTRACE(FPrint( _L("CDunTransporter::GetMediaIndexL()" )));
+    TInt index = GetMediaIndex( aConnId, aMediaContext );
+    if ( index < 0 )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::GetMediaIndexL() (ERROR) complete" )));
+        User::Leave( index );
+        }
+    FTRACE(FPrint( _L("CDunTransporter::GetMediaIndexL() complete" )));
+    return index;
+    }
+
+// ---------------------------------------------------------------------------
+// Checks initialization and RSubSessionBase() handle
+// ---------------------------------------------------------------------------
+//
+TInt CDunTransporter::CheckInitAndHandle( TConnId aConnId )
+    {
+    FTRACE(FPrint( _L("CDunTransporter::CheckInitAndHandle()" )));
+    if ( !iInitialized )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::CheckInitAndHandle() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    RSubSessionBase* subBase = static_cast<RSubSessionBase*>( aConnId );
+    if ( !subBase->SubSessionHandle() )
+        {
+        FTRACE(FPrint( _L("CDunTransporter::CheckInitAndHandle() (bad handle) complete" )));
+        return KErrBadHandle;
+        }
+    FTRACE(FPrint( _L("CDunTransporter::CheckInitAndHandle() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Deletes own internal data
+// ---------------------------------------------------------------------------
+//
+void CDunTransporter::DeleteTransporter()
+    {
+    FTRACE(FPrint( _L("CDunTransporter::DeleteTransporter()" )));
+    // first, delete channel manager with waiters
+    delete iChanMan;
+    iChanMan = NULL;
+    // second, delete the network object
+    delete iNetwork;
+    iNetwork = NULL;
+    // as last step delete utility class
+    CDunTransUtils* utility = static_cast<CDunTransUtils*>( iUtility );
+    delete utility;
+    iUtility = NULL;
+    // delete note class
+    delete iNoteHandler;
+    iNoteHandler = NULL;
+    FTRACE(FPrint( _L("CDunTransporter::DeleteTransporter() complete" )));
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/src/DunUpstream.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,620 @@
+/*
+* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definitions needed for one "stream" of CDunTransporter
+*
+*/
+
+/*
+ * TODO: When local media is of type RComm, listening on it is started with
+ * RComm::NotifyDataAvailable() call. Check that USB ACM port and Irda RCOMM
+ * (and any other new media in the future) behaves correctly so that when
+ * RComm::ReadOneOrMore() is issued, the read is issued immediately without
+ * checking for new data. If waiting for new data happens in this
+ * NotifyDataAvailable/ReadOneOrMore combination, raise a defect to Symbian.
+ */
+
+#include "DunTransporter.h"
+#include "DunUpstream.h"
+#include "DunDebug.h"
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CDunUpstream* CDunUpstream::NewL( MDunTransporterUtilityAux* aUtility )
+    {
+    CDunUpstream* self = new (ELeave) CDunUpstream( aUtility );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CDunUpstream::~CDunUpstream()
+    {
+    FTRACE(FPrint( _L("CDunUpstream::~CDunUpstream()" )));
+    ResetData();
+    FTRACE(FPrint( _L("CDunUpstream::~CDunUpstream() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// Resets data to initial values
+// ---------------------------------------------------------------------------
+//
+void CDunUpstream::ResetData()
+    {
+    // APIs affecting this:
+    // IssueRequest()
+    Stop();
+    // InitializeForAtParsing()
+    delete iParseData.iAtCmdHandler;
+    iParseData.iAtCmdHandler = NULL;
+    // AddConnMonCallbackL()
+    iCallbacksR.Close();
+    iCallbacksW.Close();
+    // AddSkippedErrorL()
+    iOkErrorsR.Close();
+    iOkErrorsW.Close();
+    // Internal
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// Sets activity callback for this stream
+// ---------------------------------------------------------------------------
+//
+TInt CDunUpstream::SetActivityCallback(
+    MDunActivityManager* aActivityCallback )
+    {
+    if ( !aActivityCallback )
+        {
+        FTRACE(FPrint( _L("CDunUpstream::SetActivityCallback() (aActivityCallback) not initialized!" ) ));
+        return KErrGeneral;
+        }
+    if ( iActivityData.iActivityCallback )
+        {
+        FTRACE(FPrint( _L("CDunUpstream::SetActivityCallback() (already exists) complete" ) ));
+        return KErrAlreadyExists;
+        }
+    iActivityData.iActivityCallback = aActivityCallback;
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes this stream for AT command notifications
+// ---------------------------------------------------------------------------
+//
+TInt CDunUpstream::InitializeForAtParsing(
+    MDunStreamManipulator* aStreamCallback,
+    const TDesC8* aConnectionName,
+    MDunCmdModeMonitor* aCallbackUp,
+    MDunCmdModeMonitor* aCallbackDown )
+    {
+    FTRACE(FPrint( _L("CDunUpstream::InitializeForAtParsing()" ) ));
+    if ( iParseData.iAtCmdHandler )
+        {
+        FTRACE(FPrint( _L("CDunUpstream::InitializeForAtParsing() (already exists) complete" ) ));
+        return KErrAlreadyExists;
+        }
+    TInt retTrap = KErrNone;
+    CDunAtCmdHandler* atCmdHandler = NULL;
+    TRAP( retTrap, atCmdHandler = CDunAtCmdHandler::NewL(this,
+                                                         aStreamCallback,
+                                                         aConnectionName) );
+    if ( retTrap != KErrNone )
+        {
+        FTRACE(FPrint( _L("CDunUpstream::InitializeForAtParsing() (trapped!) complete" ) ));
+        return retTrap;
+        }
+    atCmdHandler->AddCmdModeCallback( aCallbackUp );
+    atCmdHandler->AddCmdModeCallback( aCallbackDown );
+    iParseData.iDataMode = EFalse;
+    iParseData.iParseNeeded = ETrue;
+    iParseData.iHandling = EFalse;
+    iParseData.iAtCmdHandler = atCmdHandler;
+    FTRACE(FPrint( _L("CDunUpstream::InitializeForAtParsing() complete" ) ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Starts upstream by issuing read request
+// ---------------------------------------------------------------------------
+//
+TInt CDunUpstream::StartStream()
+    {
+    FTRACE(FPrint( _L("CDunUpstream::StartStream()" ) ));
+    if ( !iNetwork )
+        {
+        FTRACE(FPrint( _L("CDunUpstream::StartStream() (iNetwork) not initialized!" ) ));
+        return KErrGeneral;
+        }
+    if ( !iComm && !iSocket )
+        {
+        FTRACE(FPrint( _L("CDunUpstream::StartStream() (iComm&iSocket) not initialized!" ) ));
+        return KErrGeneral;
+        }
+    iOperationType = EDunOperationTypeRead;
+    TInt retVal = IssueRequest();
+    FTRACE(FPrint( _L("CDunUpstream::StartStream() complete" ) ));
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// Stops transfer for read or write endpoints
+// ---------------------------------------------------------------------------
+//
+TInt CDunUpstream::Stop()
+    {
+    FTRACE(FPrint( _L("CDunUpstream::Stop() (Dir=%d)" ), iDirection));
+    // Don't stop CDunAtCmdHandler here as it is downstream related!
+    if ( iTransferState != EDunStateTransferring )
+        {
+        FTRACE(FPrint( _L("CDunUpstream::Stop() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    // Stop only current operation
+    if ( iOperationType == EDunOperationTypeRead )
+        {
+        if ( iComm )
+            {
+            iComm->ReadCancel();
+            FTRACE(FPrint( _L("CDunUpstream::Stop() (RComm) cancelled" )));
+            }
+        else if ( iSocket )
+            {
+            iSocket->CancelRecv();
+            FTRACE(FPrint( _L("CDunUpstream::Stop() (RSocket) cancelled" )));
+            }
+        }
+    else if ( iOperationType == EDunOperationTypeWrite )
+        {
+        if ( iNetwork )
+            {
+            iNetwork->WriteCancel();
+            FTRACE(FPrint( _L("CDunUpstream::Stop() (Network) cancelled" )));
+            }
+        }
+    Cancel();
+    iTransferState = EDunStateIdle;
+    // Notify parent about inactivity
+    if ( iActivityData.iActivityCallback && iActivityData.iNotified )
+        {
+        iActivityData.iActivityCallback->NotifyChannelInactivity();
+        iActivityData.iNotified = EFalse;
+        }
+    FTRACE(FPrint( _L("CDunUpstream::Stop() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Data transmission state (if read completed)
+// ---------------------------------------------------------------------------
+//
+TBool CDunUpstream::DataReadStatus()
+    {
+    return iActivityData.iDataRead;
+    }
+
+// ---------------------------------------------------------------------------
+// CDunUpstream::CDunUpstream
+// ---------------------------------------------------------------------------
+//
+CDunUpstream::CDunUpstream( MDunTransporterUtilityAux* aUtility ) :
+    iUtility( aUtility )
+    {
+    Initialize();
+    }
+
+// ---------------------------------------------------------------------------
+// CDunUpstream::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDunUpstream::ConstructL()
+    {
+    FTRACE(FPrint( _L("CDunUpstream::ConstructL()" ) ));
+    if ( !iUtility )
+        {
+        User::Leave( KErrGeneral );
+        }
+    FTRACE(FPrint( _L("CDunUpstream::ConstructL() complete" ) ));
+    }
+
+// ---------------------------------------------------------------------------
+// Initializes this class
+// ---------------------------------------------------------------------------
+//
+void CDunUpstream::Initialize()
+    {
+    // Don't initialize iUtility here (it is set through NewL)
+    iActivityData.iActivityCallback = NULL;
+    iActivityData.iDataRead = EFalse;
+    iActivityData.iNotified = EFalse;
+    iParseData.iDataMode = EFalse;
+    iParseData.iParseNeeded = EFalse;
+    iParseData.iHandling = EFalse;
+    iParseData.iAtCmdHandler = NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// Issues transfer request for this stream
+// ---------------------------------------------------------------------------
+//
+TInt CDunUpstream::IssueRequest()
+    {
+    // Set direction
+    iDirection = static_cast<TDunDirection>( EDunStreamTypeUpstream | iOperationType );
+
+    FTRACE(FPrint( _L("CDunUpstream::IssueRequest() (Dir=%d)" ), iDirection));
+
+    if ( iTransferState != EDunStateIdle )
+        {
+        FTRACE(FPrint( _L("CDunUpstream::IssueRequest() (not ready) complete" ) ));
+        return KErrNotReady;
+        }
+
+    if ( iOperationType == EDunOperationTypeRead )
+        {
+        iBufferPtr->SetLength( iBufferPtr->MaxLength() );
+        FTRACE(FPrint( _L("CDunUpstream::IssueRequest() trying to read %d bytes... (Dir=%d)" ), iBufferPtr->Length(), iDirection));
+        }
+    else // iOperationType == EDunOperationTypeWrite
+        {
+        FTRACE(FPrint( _L("CDunUpstream::IssueRequest() writing %d bytes... (Dir=%d)" ), iBufferPtr->Length(), iDirection));
+        }
+
+    switch ( iDirection )
+        {
+        case EDunReaderUpstream:
+            if ( iComm )
+                {
+                iStatus = KRequestPending;
+                iComm->ReadOneOrMore( iStatus, *iBufferPtr );
+                FTRACE(FPrint( _L("CDunUpstream::IssueRequest() RComm ReadOneOrMore() requested" ) ));
+                }
+            else if ( iSocket )
+                {
+                iStatus = KRequestPending;
+                iSocket->RecvOneOrMore( *iBufferPtr, 0, iStatus, iReadLengthSocket );
+                FTRACE(FPrint( _L("CDunUpstream::IssueRequest() RSocket RecvOneOrMore() requested" ) ));
+                }
+            else
+                {
+                FTRACE(FPrint( _L("CDunUpstream::IssueRequest() (ERROR) complete" ) ));
+                return KErrGeneral;
+                }
+            break;
+        case EDunWriterUpstream:
+            iStatus = KRequestPending;
+            iNetwork->Write( iStatus, *iBufferPtr );
+            FTRACE(FPrint( _L("CDunUpstream::IssueRequest() RComm Write() requested" ) ));
+            break;
+        default:
+            FTRACE(FPrint( _L("CDunUpstream::IssueRequest() (ERROR) complete" ) ));
+            return KErrGeneral;
+        }
+
+    SetActive();
+    iTransferState = EDunStateTransferring;
+
+    FTRACE(FPrint( _L("CDunUpstream::IssueRequest() (Dir=%d) complete" ), iDirection));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Processes data that was read
+// ---------------------------------------------------------------------------
+//
+TBool CDunUpstream::ProcessReadData()
+    {
+    FTRACE(FPrint( _L("CDunUpstream::ProcessReadData()" )));
+    // The following will be transferred to Dataport
+    if ( iParseData.iDataMode || !iParseData.iParseNeeded )
+        {
+        iOperationType = EDunOperationTypeWrite;
+        FTRACE(FPrint( _L("CDunUpstream::ProcessReadData() (next write) complete" )));
+        return ETrue;
+        }
+    if ( !iParseData.iAtCmdHandler )  // optional
+        {
+        FTRACE(FPrint( _L("CDunUpstream::ProcessReadData() (no handler) complete" )));
+        return ETrue;
+        }
+    // The following will be transferred to parser
+    TInt retTemp = KErrNone;
+    TBool partialInput = EFalse;
+    retTemp = iParseData.iAtCmdHandler->ParseCommand( *iBufferPtr,
+                                                      partialInput );
+    if ( retTemp!=KErrNone || !partialInput )
+        {
+        FTRACE(FPrint( _L("CDunUpstream::ProcessReadData() (no reissue) complete" )));
+        return EFalse;
+        }
+    FTRACE(FPrint( _L("CDunUpstream::ProcessReadData() (reissue) complete" )));
+    return ETrue;
+    }
+
+// ---------------------------------------------------------------------------
+// Manages activity in a channel
+// ---------------------------------------------------------------------------
+//
+TInt CDunUpstream::ManageChannelActivity()
+    {
+    FTRACE(FPrint( _L("CDunUpstream::ManageChannelActivity()" )));
+    if ( iActivityData.iDataRead )
+        {
+        FTRACE(FPrint( _L("CDunUpstream::ManageChannelActivity() (not ready) complete" )));
+        return KErrNotReady;
+        }
+    iActivityData.iDataRead = ETrue;
+    if ( iActivityData.iActivityCallback && !iActivityData.iNotified )
+        {
+        iActivityData.iActivityCallback->NotifyChannelActivity();
+        iActivityData.iNotified = ETrue;
+        }
+    FTRACE(FPrint( _L("CDunUpstream::ManageChannelActivity() complete" )));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called when endpoint data read/write complete
+// ---------------------------------------------------------------------------
+//
+void CDunUpstream::RunL()
+    {
+    FTRACE(FPrint( _L("CDunUpstream::RunL() (Dir=%d)" ), iDirection));
+    iTransferState = EDunStateIdle;
+
+    TBool isError;
+    TInt retTemp = iStatus.Int();
+    TInt stop = ProcessErrorCondition( retTemp, isError );
+
+    if ( !stop )  // no real error detected -> continue
+        {
+        TBool reIssue = ETrue;
+        if ( !isError )
+            {
+            if ( iOperationType == EDunOperationTypeRead )
+                {
+                ManageChannelActivity();
+                reIssue = ProcessReadData();
+                }  // if ( iOperationType == EDunOperationTypeRead )
+            else // iOperationType == EDunOperationTypeWrite
+                {
+                iOperationType = EDunOperationTypeRead;
+                }
+            }  // if ( !isError )
+
+        if ( reIssue )
+            {
+            IssueRequest();
+            }
+
+        }  // if ( !stop )
+    else  // stop -> tear down connection
+        {
+        FTRACE(FPrint( _L("CDunUpstream::RunL() stop" )));
+        TDunConnectionReason connReason;
+        connReason.iReasonType = EDunReasonTypeRW;
+        connReason.iContext = GetMediaContext( EDunStreamTypeUpstream );
+        connReason.iSignalType = 0;
+        connReason.iSignalHigh = EFalse;
+        connReason.iDirection = iDirection;
+        connReason.iErrorCode = retTemp;
+        if ( iOperationType == EDunOperationTypeRead )
+            {
+            iUtility->DoNotifyConnectionNotOk( iComm,
+                                               iSocket,
+                                               connReason,
+                                               iCallbacksR );
+            }
+        else  // iOperationType == EDunOperationTypeWrite
+            {
+            iUtility->DoNotifyConnectionNotOk( iComm,
+                                               iSocket,
+                                               connReason,
+                                               iCallbacksW );
+            }
+        }  // else
+
+    FTRACE(FPrint( _L("CDunUpstream::RunL() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// Gets called on cancel
+// ---------------------------------------------------------------------------
+//
+void CDunUpstream::DoCancel()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunAtCmdStatusReporter
+// Notifies about AT command handling start
+// ---------------------------------------------------------------------------
+//
+void CDunUpstream::NotifyAtCmdHandlingStart()
+    {
+    FTRACE(FPrint( _L("CDunUpstream::NotifyAtCmdHandlingStart()" )));
+    if ( iParseData.iHandling )
+        {
+        FTRACE(FPrint( _L("CDunUpstream::NotifyAtCmdHandlingStart() (already set!)" )));
+        }
+    iParseData.iHandling = ETrue;
+    FTRACE(FPrint( _L("CDunUpstream::NotifyAtCmdHandlingStart() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunAtCmdStatusReporter
+// Notifies about AT command handling end
+// ---------------------------------------------------------------------------
+//
+void CDunUpstream::NotifyAtCmdHandlingEnd( TInt aStartIndex )
+    {
+    FTRACE(FPrint( _L("CDunUpstream::NotifyAtCmdHandlingEnd()" )));
+    if ( !iParseData.iHandling )
+        {
+        FTRACE(FPrint( _L("CDunUpstream::NotifyAtCmdHandlingEnd() (already set!)" )));
+        }
+    iParseData.iHandling = EFalse;
+    // Next check the offset to the next command inside this block
+    TInt length = iBufferPtr->Length();
+    if ( aStartIndex < 0 )
+        {
+        // Start of the next command not found so here we need to just reissue
+        // the read request and not clear the input buffer.
+        iParseData.iAtCmdHandler->SetEndOfCmdLine( EFalse );
+        IssueRequest();  // iOperationType must be read here (don't set)
+        FTRACE(FPrint( _L("CDunUpstream::NotifyAtCmdHandlingEnd() (not found) complete" )));
+        return;
+        }
+    // Here the start of next command was found so try to directly handle that
+    // command using ProcessReadData() for the next subblock.
+    iParseData.iAtCmdHandler->SetEndOfCmdLine( ETrue );
+    TInt maxLength = iBufferPtr->MaxLength();
+    iBufferPtr->Set( &(*iBufferPtr)[aStartIndex], length-aStartIndex, maxLength );
+    TBool reIssue = ProcessReadData();
+    if ( reIssue )
+        {
+        // Note: should come here only if something went wrong
+        IssueRequest();
+        }
+    FTRACE(FPrint( _L("CDunUpstream::NotifyAtCmdHandlingEnd() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunAtCmdStatusReporter
+// Notifies about editor mode reply
+// ---------------------------------------------------------------------------
+//
+void CDunUpstream::NotifyEditorModeReply( TBool aStart )
+    {
+    FTRACE(FPrint( _L("CDunUpstream::NotifyEditorModeReply()" )));
+    if ( iParseData.iDataMode )
+        {
+        FTRACE(FPrint( _L("CDunUpstream::NotifyEditorModeReply() (not ready) complete" )));
+        return;
+        }
+    // If start of editor mode then just reissue the read request
+    // If continuation then echo and reissue the read request
+    if ( aStart )
+        {
+        IssueRequest();
+        FTRACE(FPrint( _L("CDunUpstream::NotifyEditorModeReply() (start) complete" )));
+        return;
+        }
+    iParseData.iAtCmdHandler->SendEchoCharacter( iBufferPtr, this );
+    FTRACE(FPrint( _L("CDunUpstream::NotifyEditorModeReply() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunAtCmdHandler
+// Starts URC message handling
+// ---------------------------------------------------------------------------
+//
+TInt CDunUpstream::StartUrc()
+    {
+    FTRACE(FPrint( _L("CDunUpstream::StartUrc()" )));
+    TInt retVal = KErrNone;
+    if ( iParseData.iAtCmdHandler )  // optional
+        {
+        retVal = iParseData.iAtCmdHandler->StartUrc();
+        }
+    FTRACE(FPrint( _L("CDunUpstream::StartUrc() complete" )));
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunAtCmdHandler
+// Stops AT command handling downstream related activity (also URC)
+// ---------------------------------------------------------------------------
+//
+TInt CDunUpstream::StopAtCmdHandling()
+    {
+    FTRACE(FPrint( _L("CDunUpstream::StopAtCmdHandling()" )));
+    TInt retVal = KErrNone;
+    if ( iParseData.iAtCmdHandler )  // optional
+        {
+        retVal = iParseData.iAtCmdHandler->StopUrc();
+        if ( retVal != KErrNone )
+            {
+            iParseData.iAtCmdHandler->Stop();
+            FTRACE(FPrint( _L("CDunUpstream::StopAtCmdHandling() (iAtCmdHandler) complete" )));
+            return retVal;
+            }
+        retVal = iParseData.iAtCmdHandler->Stop();
+        }
+    FTRACE(FPrint( _L("CDunUpstream::StopAtCmdHandling() complete" )));
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunCmdModeMonitor.
+// Notifies about command mode start
+// ---------------------------------------------------------------------------
+//
+void CDunUpstream::NotifyCommandModeStart()
+    {
+    FTRACE(FPrint( _L("CDunUpstream::NotifyCommandModeStart()" )));
+    iParseData.iDataMode = EFalse;
+    // Stop processing (just to be sure).
+    // This will stop any possibly pending operations of
+    // CDunAtCmdHandler and CDunAtUrcHandler. CDunDownstream will take care of
+    // clearing (and stopping) non-callback write queues.
+    StopAtCmdHandling();
+    // Also restart the URC handling after the data mode
+    StartUrc();
+    FTRACE(FPrint( _L("CDunUpstream::NotifyCommandModeStart() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunCmdModeMonitor.
+// Notifies about command mode end
+// ---------------------------------------------------------------------------
+//
+void CDunUpstream::NotifyCommandModeEnd()
+    {
+    FTRACE(FPrint( _L("CDunUpstream::NotifyCommandModeEnd()" )));
+    iParseData.iDataMode = ETrue;
+    // Stop processing (mandatory).
+    // This will stop any possibly pending operations of
+    // CDunAtCmdHandler and CDunAtUrcHandler. CDunDownstream will take care of
+    // clearing (and stopping) non-callback write queues.
+    StopAtCmdHandling();
+    // The follow is needed because stopping the AT command handling here
+    // prevents the subsequent AT command handling notification to reach the
+    // NotifyAtCmdHandlingEnd() in this class (the notification starts from
+    // CDunAtCmdPusher's SetToIdleAndNotifyEnd()).
+    // So here we have to do the block "if ( aStartIndex < 0 )" in function
+    // NotifyAtCmdHandlingEnd().
+    IssueRequest();
+    FTRACE(FPrint( _L("CDunUpstream::NotifyCommandModeEnd() complete" )));
+    }
+
+// ---------------------------------------------------------------------------
+// From class MDunAtCmdEchoer.
+// Notifies about command mode end
+// ---------------------------------------------------------------------------
+//
+void CDunUpstream::NotifyEchoComplete()
+    {
+    FTRACE(FPrint( _L("CDunUpstream::NotifyEchoComplete()" )));
+    IssueRequest();
+    FTRACE(FPrint( _L("CDunUpstream::NotifyEchoComplete() complete" )));
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/dun/utils/src/DunUtils.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,72 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Common utility methods for DUN
+*
+*/
+
+
+#include <e32base.h>
+#include "DunUtils.h"
+#include "DunDebug.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Connects to comms server
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CDunUtils::ConnectCommsServer( RCommServ& aCommServer )
+    {
+    FTRACE(FPrint(_L( "CDunUtils::ConnectCommsServer()") ));
+    TInt retTemp;
+#ifndef PRJ_USE_NETWORK_STUBS
+    retTemp = StartC32();
+    if ( retTemp!=KErrNone && retTemp!=KErrAlreadyExists )
+        {
+        FTRACE(FPrint(_L( "CDunUtils::ConnectCommsServer() StartC32 %d" ), retTemp));
+        return retTemp;
+        }
+#endif
+    retTemp = aCommServer.Connect();
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L( "CDunUtils::ConnectCommsServer() aCommServer.Connect %d" ), retTemp));
+        return retTemp;
+        }
+    FTRACE(FPrint(_L( "CDunUtils::ConnectCommsServer() complete") ));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Sets RComm buffer length
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CDunUtils::SetRCommBufferLength( RComm& aComm, TInt aLength )
+    {
+    FTRACE(FPrint(_L( "CDunUtils::SetRCommBufferLength()") ));
+    TInt retTemp = aComm.SetReceiveBufferLength( aLength );
+    if ( retTemp != KErrNone )
+        {
+        FTRACE(FPrint(_L( "CDunUtils::SetRCommBufferLength() (set failed) complete (%d)"), retTemp));
+        return retTemp;
+        }
+    TInt setLength = aComm.ReceiveBufferLength();
+    if ( setLength != aLength )
+        {
+        FTRACE(FPrint(_L( "CDunUtils::SetRCommBufferLength() (get failed) complete") ));
+        return KErrGeneral;
+        }
+    FTRACE(FPrint(_L( "CDunUtils::SetRCommBufferLength() complete") ));
+    return KErrNone;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/bwins/generichidu.def	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,101 @@
+EXPORTS
+	?Unit@CField@@QBEHXZ @ 1 NONAME ; int CField::Unit(void) const
+	?IsInReport@CField@@QBEHH@Z @ 2 NONAME ; int CField::IsInReport(int) const
+	?NewLC@CGenericHid@@SAPAV1@PAVMTransportLayer@@@Z @ 3 NONAME ; class CGenericHid * CGenericHid::NewLC(class MTransportLayer *)
+	?UsageMax@CField@@QBEHXZ @ 4 NONAME ; int CField::UsageMax(void) const
+	?UnitExponent@CField@@QBEHXZ @ 5 NONAME ; int CField::UnitExponent(void) const
+	?StringMin@CField@@QBEHXZ @ 6 NONAME ; int CField::StringMin(void) const
+	?NewL@CHidDriver@@SAPAV1@VTUid@@PAVMDriverAccess@@@Z @ 7 NONAME ; class CHidDriver * CHidDriver::NewL(class TUid, class MDriverAccess *)
+	?SetOffset@CField@@QAEXH@Z @ 8 NONAME ; void CField::SetOffset(int)
+	?NewLC@CParser@@SAPAV1@XZ @ 9 NONAME ; class CParser * CParser::NewLC(void)
+	?SetStringRange@CField@@QAEXHH@Z @ 10 NONAME ; void CField::SetStringRange(int, int)
+	?ReportSizeBytes@CReportRoot@@QBEHHW4TType@CField@@@Z @ 11 NONAME ; int CReportRoot::ReportSizeBytes(int, enum CField::TType) const
+	?ClearUsageList@CField@@QAEXXZ @ 12 NONAME ; void CField::ClearUsageList(void)
+	?IsNamedArray@CCollection@@QBEHXZ @ 13 NONAME ; int CCollection::IsNamedArray(void) const
+	?SetUnitExponent@CField@@QAEXH@Z @ 14 NONAME ; void CField::SetUnitExponent(int)
+	?SetAttributes@CField@@QAEXK@Z @ 15 NONAME ; void CField::SetAttributes(unsigned long)
+	?SetPhysicalMin@CField@@QAEXH@Z @ 16 NONAME ; void CField::SetPhysicalMin(int)
+	?SetUsagePage@CField@@QAEXH@Z @ 17 NONAME ; void CField::SetUsagePage(int)
+	?SetStringMin@CField@@QAEXH@Z @ 18 NONAME ; void CField::SetStringMin(int)
+	?CollectionByIndex@CCollection@@QBEPBV1@H@Z @ 19 NONAME ; class CCollection const * CCollection::CollectionByIndex(int) const
+	?FieldByIndex@CCollection@@QBEPBVCField@@H@Z @ 20 NONAME ; class CField const * CCollection::FieldByIndex(int) const
+	?SetPhysicalRange@CField@@QAEXHH@Z @ 21 NONAME ; void CField::SetPhysicalRange(int, int)
+	?SetDesignatorRange@CField@@QAEXHH@Z @ 22 NONAME ; void CField::SetDesignatorRange(int, int)
+	?CollectionCount@CCollection@@QBEHXZ @ 23 NONAME ; int CCollection::CollectionCount(void) const
+	?NewLC@CReportGenerator@@SAPAV1@PBVCReportRoot@@HW4TType@CField@@@Z @ 24 NONAME ; class CReportGenerator * CReportGenerator::NewLC(class CReportRoot const *, int, enum CField::TType)
+	?IsInput@CField@@QBEHXZ @ 25 NONAME ; int CField::IsInput(void) const
+	?StringMax@CField@@QBEHXZ @ 26 NONAME ; int CField::StringMax(void) const
+	?SetLogicalMin@CField@@QAEXH@Z @ 27 NONAME ; void CField::SetLogicalMin(int)
+	?GetUsageId@TReportTranslator@@QBEHAAHH@Z @ 28 NONAME ; int TReportTranslator::GetUsageId(int &, int) const
+	?SearchL@THidFieldSearch@@QAEXPBVCReportRoot@@PAVMHidFieldFinder@@@Z @ 29 NONAME ; void THidFieldSearch::SearchL(class CReportRoot const *, class MHidFieldFinder *)
+	?IsConstant@CField@@QBEHXZ @ 30 NONAME ; int CField::IsConstant(void) const
+	?PhysicalMin@CField@@QBEHXZ @ 31 NONAME ; int CField::PhysicalMin(void) const
+	?ParseL@CParser@@QAEPAVCReportRoot@@ABVTDesC8@@@Z @ 32 NONAME ; class CReportRoot * CParser::ParseL(class TDesC8 const &)
+	?AddUsageL@CField@@QAEXH@Z @ 33 NONAME ; void CField::AddUsageL(int)
+	?Count@CField@@QBEHXZ @ 34 NONAME ; int CField::Count(void) const
+	?SetSize@CField@@QAEXH@Z @ 35 NONAME ; void CField::SetSize(int)
+	??0TReportTranslator@@QAE@ABVTDesC8@@PBVCField@@@Z @ 36 NONAME ; TReportTranslator::TReportTranslator(class TDesC8 const &, class CField const *)
+	?ReportId@CField@@QBEHXZ @ 37 NONAME ; int CField::ReportId(void) const
+	?IsArray@CField@@QBEHXZ @ 38 NONAME ; int CField::IsArray(void) const
+	?SetPhysicalMax@CField@@QAEXH@Z @ 39 NONAME ; void CField::SetPhysicalMax(int)
+	?NewL@CGenericHid@@SAPAV1@PAVMTransportLayer@@@Z @ 40 NONAME ; class CGenericHid * CGenericHid::NewL(class MTransportLayer *)
+	?HasUsage@CField@@QBEHH@Z @ 41 NONAME ; int CField::HasUsage(int) const
+	?SetStringMax@CField@@QAEXH@Z @ 42 NONAME ; void CField::SetStringMax(int)
+	?IsFeature@CField@@QBEHXZ @ 43 NONAME ; int CField::IsFeature(void) const
+	?StringIndex@CField@@QBEHXZ @ 44 NONAME ; int CField::StringIndex(void) const
+	?Report@CReportGenerator@@QAE?AVTPtr8@@XZ @ 45 NONAME ; class TPtr8 CReportGenerator::Report(void)
+	??0CHidDriver@@IAE@XZ @ 46 NONAME ; CHidDriver::CHidDriver(void)
+	?AllowedToHandleEvent@CHidInputDataHandlingReg@@QAEHHH@Z @ 47 NONAME ; int CHidInputDataHandlingReg::AllowedToHandleEvent(int, int)
+	?UsageIdL@TReportTranslator@@QBEHH@Z @ 48 NONAME ; int TReportTranslator::UsageIdL(int) const
+	?SetLogicalMax@CField@@QAEXH@Z @ 49 NONAME ; void CField::SetLogicalMax(int)
+	?IsOutput@CField@@QBEHXZ @ 50 NONAME ; int CField::IsOutput(void) const
+	?Usage@CCollection@@QBEHXZ @ 51 NONAME ; int CCollection::Usage(void) const
+	?SetUnit@CField@@QAEXH@Z @ 52 NONAME ; void CField::SetUnit(int)
+	?PhysicalMax@CField@@QBEHXZ @ 53 NONAME ; int CField::PhysicalMax(void) const
+	?IsData@CField@@QBEHXZ @ 54 NONAME ; int CField::IsData(void) const
+	?SetUsageRange@CField@@QAEXHH@Z @ 55 NONAME ; void CField::SetUsageRange(int, int)
+	?DesignatorIndex@CField@@QBEHXZ @ 56 NONAME ; int CField::DesignatorIndex(void) const
+	?IsApplication@CCollection@@QBEHXZ @ 57 NONAME ; int CCollection::IsApplication(void) const
+	?LogicalMin@CField@@QBEHXZ @ 58 NONAME ; int CField::LogicalMin(void) const
+	?DesignatorMin@CField@@QBEHXZ @ 59 NONAME ; int CField::DesignatorMin(void) const
+	?RawValueL@TReportTranslator@@QBEHH@Z @ 60 NONAME ; int TReportTranslator::RawValueL(int) const
+	?SetDesignatorIndex@CField@@QAEXH@Z @ 61 NONAME ; void CField::SetDesignatorIndex(int)
+	?AddHandledEvent@CHidInputDataHandlingReg@@QAEXHH@Z @ 62 NONAME ; void CHidInputDataHandlingReg::AddHandledEvent(int, int)
+	?Type@CField@@QBE?AW4TType@1@XZ @ 63 NONAME ; enum CField::TType CField::Type(void) const
+	?Attributes@CField@@QBEKXZ @ 64 NONAME ; unsigned long CField::Attributes(void) const
+	?IsReport@CCollection@@QBEHXZ @ 65 NONAME ; int CCollection::IsReport(void) const
+	?IsUsageModifier@CCollection@@QBEHXZ @ 66 NONAME ; int CCollection::IsUsageModifier(void) const
+	?LastUsage@CField@@QBEHXZ @ 67 NONAME ; int CField::LastUsage(void) const
+	?SetUsageMin@CField@@QAEXH@Z @ 68 NONAME ; void CField::SetUsageMin(int)
+	?IsUsageSwitch@CCollection@@QBEHXZ @ 69 NONAME ; int CCollection::IsUsageSwitch(void) const
+	?Size@CField@@QBEHXZ @ 70 NONAME ; int CField::Size(void) const
+	?IsLogical@CCollection@@QBEHXZ @ 71 NONAME ; int CCollection::IsLogical(void) const
+	?FieldCount@CCollection@@QBEHXZ @ 72 NONAME ; int CCollection::FieldCount(void) const
+	?SetField@CReportGenerator@@QAEHPBVCField@@HHH@Z @ 73 NONAME ; int CReportGenerator::SetField(class CField const *, int, int, int)
+	?IsPhysical@CCollection@@QBEHXZ @ 74 NONAME ; int CCollection::IsPhysical(void) const
+	?LogicalMax@CField@@QBEHXZ @ 75 NONAME ; int CField::LogicalMax(void) const
+	?SetDesignatorMin@CField@@QAEXH@Z @ 76 NONAME ; void CField::SetDesignatorMin(int)
+	?DesignatorMax@CField@@QBEHXZ @ 77 NONAME ; int CField::DesignatorMax(void) const
+	?Type@CCollection@@QBEKXZ @ 78 NONAME ; unsigned long CCollection::Type(void) const
+	?Count@TReportTranslator@@QBEHXZ @ 79 NONAME ; int TReportTranslator::Count(void) const
+	?GetValue@TReportTranslator@@QBEHAAHHH@Z @ 80 NONAME ; int TReportTranslator::GetValue(int &, int, int) const
+	?IsVariable@CField@@QBEHXZ @ 81 NONAME ; int CField::IsVariable(void) const
+	?ValueL@TReportTranslator@@QBEHHH@Z @ 82 NONAME ; int TReportTranslator::ValueL(int, int) const
+	?SetUsageMax@CField@@QAEXH@Z @ 83 NONAME ; void CField::SetUsageMax(int)
+	?SetType@CField@@QAEXABW4TType@1@@Z @ 84 NONAME ; void CField::SetType(enum CField::TType const &)
+	?Usage@CField@@QBEHH@Z @ 85 NONAME ; int CField::Usage(int) const
+	?NewL@CReportGenerator@@SAPAV1@PBVCReportRoot@@HW4TType@CField@@@Z @ 86 NONAME ; class CReportGenerator * CReportGenerator::NewL(class CReportRoot const *, int, enum CField::TType)
+	?UsagePage@CField@@QBEHXZ @ 87 NONAME ; int CField::UsagePage(void) const
+	?SetStringIndex@CField@@QAEXH@Z @ 88 NONAME ; void CField::SetStringIndex(int)
+	?UsageMin@CField@@QBEHXZ @ 89 NONAME ; int CField::UsageMin(void) const
+	?UsageArray@CField@@QBE?AV?$TArray@H@@XZ @ 90 NONAME ; class TArray<int> CField::UsageArray(void) const
+	?SetCount@CField@@QAEXH@Z @ 91 NONAME ; void CField::SetCount(int)
+	?UsagePage@CCollection@@QBEHXZ @ 92 NONAME ; int CCollection::UsagePage(void) const
+	??1CHidDriver@@UAE@XZ @ 93 NONAME ; CHidDriver::~CHidDriver(void)
+	?Offset@CField@@QBEHXZ @ 94 NONAME ; int CField::Offset(void) const
+	?SetDesignatorMax@CField@@QAEXH@Z @ 95 NONAME ; void CField::SetDesignatorMax(int)
+	?SetReportId@CField@@QAEXH@Z @ 96 NONAME ; void CField::SetReportId(int)
+	?NewL@CParser@@SAPAV1@XZ @ 97 NONAME ; class CParser * CParser::NewL(void)
+	?UsageCount@CField@@QBEHXZ @ 98 NONAME ; int CField::UsageCount(void) const
+	?SetLogicalRange@CField@@QAEXHH@Z @ 99 NONAME ; void CField::SetLogicalRange(int, int)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/eabi/generichidu.def	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,122 @@
+EXPORTS
+	_ZN10CHidDriver4NewLE4TUidP13MDriverAccess @ 1 NONAME
+	_ZN10CHidDriverC2Ev @ 2 NONAME
+	_ZN10CHidDriverD0Ev @ 3 NONAME
+	_ZN10CHidDriverD1Ev @ 4 NONAME
+	_ZN10CHidDriverD2Ev @ 5 NONAME
+	_ZN11CGenericHid4NewLEP15MTransportLayer @ 6 NONAME
+	_ZN11CGenericHid5NewLCEP15MTransportLayer @ 7 NONAME
+	_ZN15THidFieldSearch7SearchLEPK11CReportRootP15MHidFieldFinder @ 8 NONAME
+	_ZN16CReportGenerator4NewLEPK11CReportRootiN6CField5TTypeE @ 9 NONAME
+	_ZN16CReportGenerator5NewLCEPK11CReportRootiN6CField5TTypeE @ 10 NONAME
+	_ZN16CReportGenerator6ReportEv @ 11 NONAME
+	_ZN16CReportGenerator8SetFieldEPK6CFieldiii @ 12 NONAME
+	_ZN17TReportTranslatorC1ERK6TDesC8PK6CField @ 13 NONAME
+	_ZN17TReportTranslatorC2ERK6TDesC8PK6CField @ 14 NONAME
+	_ZN24CHidInputDataHandlingReg15AddHandledEventEii @ 15 NONAME
+	_ZN24CHidInputDataHandlingReg20AllowedToHandleEventEii @ 16 NONAME
+	_ZN6CField11SetReportIdEi @ 17 NONAME
+	_ZN6CField11SetUsageMaxEi @ 18 NONAME
+	_ZN6CField11SetUsageMinEi @ 19 NONAME
+	_ZN6CField12SetStringMaxEi @ 20 NONAME
+	_ZN6CField12SetStringMinEi @ 21 NONAME
+	_ZN6CField12SetUsagePageEi @ 22 NONAME
+	_ZN6CField13SetAttributesEm @ 23 NONAME
+	_ZN6CField13SetLogicalMaxEi @ 24 NONAME
+	_ZN6CField13SetLogicalMinEi @ 25 NONAME
+	_ZN6CField13SetUsageRangeEii @ 26 NONAME
+	_ZN6CField14ClearUsageListEv @ 27 NONAME
+	_ZN6CField14SetPhysicalMaxEi @ 28 NONAME
+	_ZN6CField14SetPhysicalMinEi @ 29 NONAME
+	_ZN6CField14SetStringIndexEi @ 30 NONAME
+	_ZN6CField14SetStringRangeEii @ 31 NONAME
+	_ZN6CField15SetLogicalRangeEii @ 32 NONAME
+	_ZN6CField15SetUnitExponentEi @ 33 NONAME
+	_ZN6CField16SetDesignatorMaxEi @ 34 NONAME
+	_ZN6CField16SetDesignatorMinEi @ 35 NONAME
+	_ZN6CField16SetPhysicalRangeEii @ 36 NONAME
+	_ZN6CField18SetDesignatorIndexEi @ 37 NONAME
+	_ZN6CField18SetDesignatorRangeEii @ 38 NONAME
+	_ZN6CField7SetSizeEi @ 39 NONAME
+	_ZN6CField7SetTypeERKNS_5TTypeE @ 40 NONAME
+	_ZN6CField7SetUnitEi @ 41 NONAME
+	_ZN6CField8SetCountEi @ 42 NONAME
+	_ZN6CField9AddUsageLEi @ 43 NONAME
+	_ZN6CField9SetOffsetEi @ 44 NONAME
+	_ZN7CParser4NewLEv @ 45 NONAME
+	_ZN7CParser5NewLCEv @ 46 NONAME
+	_ZN7CParser6ParseLERK6TDesC8 @ 47 NONAME
+	_ZNK11CCollection10FieldCountEv @ 48 NONAME
+	_ZNK11CCollection10IsPhysicalEv @ 49 NONAME
+	_ZNK11CCollection12FieldByIndexEi @ 50 NONAME
+	_ZNK11CCollection12IsNamedArrayEv @ 51 NONAME
+	_ZNK11CCollection13IsApplicationEv @ 52 NONAME
+	_ZNK11CCollection13IsUsageSwitchEv @ 53 NONAME
+	_ZNK11CCollection15CollectionCountEv @ 54 NONAME
+	_ZNK11CCollection15IsUsageModifierEv @ 55 NONAME
+	_ZNK11CCollection17CollectionByIndexEi @ 56 NONAME
+	_ZNK11CCollection4TypeEv @ 57 NONAME
+	_ZNK11CCollection5UsageEv @ 58 NONAME
+	_ZNK11CCollection8IsReportEv @ 59 NONAME
+	_ZNK11CCollection9IsLogicalEv @ 60 NONAME
+	_ZNK11CCollection9UsagePageEv @ 61 NONAME
+	_ZNK11CReportRoot15ReportSizeBytesEiN6CField5TTypeE @ 62 NONAME
+	_ZNK17TReportTranslator10GetUsageIdERii @ 63 NONAME
+	_ZNK17TReportTranslator5CountEv @ 64 NONAME
+	_ZNK17TReportTranslator6ValueLEii @ 65 NONAME
+	_ZNK17TReportTranslator8GetValueERiii @ 66 NONAME
+	_ZNK17TReportTranslator8UsageIdLEi @ 67 NONAME
+	_ZNK17TReportTranslator9RawValueLEi @ 68 NONAME
+	_ZNK6CField10AttributesEv @ 69 NONAME
+	_ZNK6CField10IsConstantEv @ 70 NONAME
+	_ZNK6CField10IsInReportEi @ 71 NONAME
+	_ZNK6CField10IsVariableEv @ 72 NONAME
+	_ZNK6CField10LogicalMaxEv @ 73 NONAME
+	_ZNK6CField10LogicalMinEv @ 74 NONAME
+	_ZNK6CField10UsageArrayEv @ 75 NONAME
+	_ZNK6CField10UsageCountEv @ 76 NONAME
+	_ZNK6CField11PhysicalMaxEv @ 77 NONAME
+	_ZNK6CField11PhysicalMinEv @ 78 NONAME
+	_ZNK6CField11StringIndexEv @ 79 NONAME
+	_ZNK6CField12UnitExponentEv @ 80 NONAME
+	_ZNK6CField13DesignatorMaxEv @ 81 NONAME
+	_ZNK6CField13DesignatorMinEv @ 82 NONAME
+	_ZNK6CField15DesignatorIndexEv @ 83 NONAME
+	_ZNK6CField4SizeEv @ 84 NONAME
+	_ZNK6CField4TypeEv @ 85 NONAME
+	_ZNK6CField4UnitEv @ 86 NONAME
+	_ZNK6CField5CountEv @ 87 NONAME
+	_ZNK6CField5UsageEi @ 88 NONAME
+	_ZNK6CField6IsDataEv @ 89 NONAME
+	_ZNK6CField6OffsetEv @ 90 NONAME
+	_ZNK6CField7IsArrayEv @ 91 NONAME
+	_ZNK6CField7IsInputEv @ 92 NONAME
+	_ZNK6CField8HasUsageEi @ 93 NONAME
+	_ZNK6CField8IsOutputEv @ 94 NONAME
+	_ZNK6CField8ReportIdEv @ 95 NONAME
+	_ZNK6CField8UsageMaxEv @ 96 NONAME
+	_ZNK6CField8UsageMinEv @ 97 NONAME
+	_ZNK6CField9IsFeatureEv @ 98 NONAME
+	_ZNK6CField9LastUsageEv @ 99 NONAME
+	_ZNK6CField9StringMaxEv @ 100 NONAME
+	_ZNK6CField9StringMinEv @ 101 NONAME
+	_ZNK6CField9UsagePageEv @ 102 NONAME
+	_ZTI10CHidDriver @ 103 NONAME ; #<TI>#
+	_ZTI11CCollection @ 104 NONAME ; #<TI>#
+	_ZTI11CGenericHid @ 105 NONAME ; #<TI>#
+	_ZTI11CReportRoot @ 106 NONAME ; #<TI>#
+	_ZTI15CDriverListItem @ 107 NONAME ; #<TI>#
+	_ZTI16CReportGenerator @ 108 NONAME ; #<TI>#
+	_ZTI24CHidInputDataHandlingReg @ 109 NONAME ; #<TI>#
+	_ZTI6CField @ 110 NONAME ; #<TI>#
+	_ZTI7CParser @ 111 NONAME ; #<TI>#
+	_ZTV10CHidDriver @ 112 NONAME ; #<VT>#
+	_ZTV11CCollection @ 113 NONAME ; #<VT>#
+	_ZTV11CGenericHid @ 114 NONAME ; #<VT>#
+	_ZTV11CReportRoot @ 115 NONAME ; #<VT>#
+	_ZTV15CDriverListItem @ 116 NONAME ; #<VT>#
+	_ZTV16CReportGenerator @ 117 NONAME ; #<VT>#
+	_ZTV24CHidInputDataHandlingReg @ 118 NONAME ; #<VT>#
+	_ZTV6CField @ 119 NONAME ; #<VT>#
+	_ZTV7CParser @ 120 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for project generichid
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../rom/generichid.iby                   CORE_MW_LAYER_IBY_EXPORT_PATH(generichid.iby)
+
+PRJ_MMPFILES
+generichid.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/group/generichid.mmp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project generichid
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET                  generichid.dll
+TARGETTYPE              DLL
+UID                     0x1000008d 0x10281cfe
+
+CAPABILITY              CAP_APPLICATION CommDD ProtServ	// two latter needed by USB
+VENDORID                VID_DEFAULT
+
+SOURCEPATH              ../src
+SOURCE                  hidgeneric.cpp
+SOURCE                  hiddriveritem.cpp
+SOURCE                  hidfield.cpp
+SOURCE                  hidparser.cpp
+SOURCE	                hiditem.cpp
+SOURCE                  hidcollection.cpp
+SOURCE                  hidsearch.cpp
+SOURCE                  hidreporttranslator.cpp
+SOURCE                  hidreportroot.cpp
+SOURCE                  hidreportbase.cpp
+SOURCE                  hidreportgenerator.cpp
+SOURCE                  hidinterfaces.cpp
+SOURCE                  hidconnectioninfo.cpp
+
+USERINCLUDE              ../inc
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE           ../../../inc
+SYSTEMINCLUDE 			/epoc32/include/ecom
+
+LIBRARY       euser.lib
+LIBRARY       ecom.lib
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/group/generichid.mrp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+component	generichid
+
+source \sf\mw\remoteconn\localconnectivityservice\generichid
+
+notes_source	\component_defs\release.src
+
+ipr E 
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/inc/debug.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,175 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Logging definition
+*
+*/
+
+
+#ifndef PRJ_LOGGING_H
+#define PRJ_LOGGING_H
+
+#include "debugconfig.h"
+
+#ifdef PRJ_ENABLE_TRACE
+
+#ifdef PRJ_FILE_TRACE
+#include <flogger.h>
+#else
+#include <e32debug.h>
+#endif
+
+const TInt KMaxLogLineLength = 512;
+
+#define KPRINTERROR        0x00000001 // Tracing level: error
+#define KPRINTINFO        0x00000002 // Tracing level: function trace
+#define KPRINTSTATE        0x00000004 // Tracing level: state machine info
+#define KPRINTWARNING   0x00000008 // Tracing level: warning
+
+const TInt KTraceMask = KPRINTERROR | KPRINTINFO | KPRINTSTATE | KPRINTWARNING;
+
+NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow
+    {
+public:
+    void Overflow(TDes16& /*aDes*/) {}
+    };
+
+NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow
+    {
+public:
+    void Overflow(TDes8& /*aDes*/) {}
+    };
+
+inline void Trace(TRefByValue<const TDesC16> aFmt, ...)
+    {
+    VA_LIST list;
+    VA_START(list,aFmt);
+#ifdef PRJ_FILE_TRACE
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+#else
+    TBuf16<KMaxLogLineLength> theFinalString;
+    theFinalString.Append(KTracePrefix16);
+    TOverflowTruncate16 overflow;
+    theFinalString.AppendFormatList(aFmt,list,&overflow);
+    RDebug::Print(theFinalString);
+#endif
+    }
+
+inline void Trace(TRefByValue<const TDesC8> aFmt, ...)
+    {
+    VA_LIST list;
+    VA_START(list, aFmt);
+#ifdef PRJ_FILE_TRACE
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+#else
+    TOverflowTruncate8 overflow;
+    TBuf8<KMaxLogLineLength> buf8;
+    buf8.Append(KTracePrefix8);
+    buf8.AppendFormatList(aFmt, list, &overflow);
+    TBuf16<KMaxLogLineLength> buf16(buf8.Length());
+    buf16.Copy(buf8);
+    TRefByValue<const TDesC> tmpFmt(_L("%S"));
+    RDebug::Print(tmpFmt, &buf16);
+#endif
+    }
+
+inline void TracePanic(
+    char* aFile, 
+    TInt aLine,
+    TInt aPanicCode,
+    const TDesC& aPanicCategory)
+    {
+    TPtrC8 fullFileName((const TUint8*)aFile);
+    TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1);
+    TBuf8<KMaxLogLineLength> buf;
+    buf.Append(KPanicPrefix8);
+    buf.AppendFormat(_L8("%d at line %d in file %S"), aPanicCode, aLine, &fileName);
+    Trace(buf);
+    User::Panic(aPanicCategory, aPanicCode); 
+    }
+
+inline void TraceLeave(char* aFile, TInt aLine, TInt aReason)
+    {
+    TPtrC8 fullFileName((const TUint8*)aFile);
+    TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1);
+    TBuf8<KMaxLogLineLength> buf;
+    buf.Append(KLeavePrefix8);
+    buf.AppendFormat(_L8("%d at line %d in file %S"), aReason, aLine, &fileName);
+    Trace(buf);
+    User::LeaveIfError(aReason);
+    }
+
+#define TRACE_INFO(p) {if(KTraceMask & KPRINTINFO) Trace p;}
+
+#define TRACE_ERROR(p) {if(KTraceMask & KPRINTERROR) Trace p;}
+
+#define TRACE_STATE(p) {if(KTraceMask & KPRINTSTATE) Trace p;}
+
+#define TRACE_WARNING(p) {if(KTraceMask & KPRINTWARNING) Trace p;}
+
+#define TRACE_INFO_SEG(p) {if(KTraceMask & KPRINTINFO) p;}
+
+#define TRACE_ASSERT(GUARD, CODE) {if (!(GUARD)) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory);}
+
+#define PANIC(CODE) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory)
+
+#define LEAVE_IF_ERROR(REASON) {if (REASON) TraceLeave(__FILE__, __LINE__, REASON);}
+
+#define LEAVE(REASON) {TraceLeave(__FILE__, __LINE__, REASON);}
+
+#define TRACE_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryFormat8, &ptr8);}}
+
+#define TRACE_FUNC_ENTRY_THIS {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryThisFormat8, &ptr8, this);}}
+
+#define TRACE_FUNC_EXIT {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncExitFormat8, &ptr8);}}
+
+#define TRACE_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncFormat8, &ptr8);}}
+
+#define TRACE_FUNC_THIS {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncThisFormat8, &ptr8, this);}}
+
+#define RETURN_IF_ERR(ERR) {if(ERR) {TPtrC8 ptr8((TUint8*)__FILE__); Trace(_L8(" RETURN %d at file %S line %d"), ERR, &ptr8, __LINE__); return ERR;}}
+
+#else // PRJ_ENABLE_TRACE not defined
+
+#define TRACE_INFO(p)
+
+#define TRACE_ERROR(p)
+
+#define TRACE_STATE(p)
+
+#define TRACE_WARNING(p)
+
+#define TRACE_INFO_SEG(p)
+
+#define TRACE_ASSERT(GUARD, CODE)
+
+#define PANIC(CODE) {User::Panic(KPanicCategory, CODE);}
+
+#define LEAVE_IF_ERROR(REASON) {static_cast<void>(User::LeaveIfError(REASON));}
+
+#define LEAVE(REASON) {static_cast<void>(User::Leave(REASON));}
+
+#define TRACE_FUNC_ENTRY
+
+#define TRACE_FUNC_ENTRY_THIS
+
+#define TRACE_FUNC_EXIT
+
+#define TRACE_FUNC
+
+#define TRACE_FUNC_THIS
+
+#define RETURN_IF_ERR(ERR) {if(ERR) return ERR;}
+#endif // PRJ_ENABLE_TRACE
+
+#endif // PRJ_LOGGING_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/inc/debugconfig.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project configure file.
+*
+*/
+
+
+#ifndef GENERICHID_DEBUGCONFIG_H
+#define GENERICHID_DEBUGCONFIG_H
+
+#include "prjconfig.h"
+
+
+/**
+ * Custom logging variations.
+ */
+#ifdef PRJ_FILE_TRACE
+_LIT(KLogFile,"generichid.txt");
+_LIT(KLogDir,"generichid");
+#endif
+
+#ifdef PRJ_ENABLE_TRACE
+_LIT(KTracePrefix16, "[generichid] ");
+_LIT8(KTracePrefix8, "[generichid] ");
+_LIT8(KFuncFormat8, "><%S");
+_LIT8(KFuncThisFormat8, "><%S, [0x%08X]");
+_LIT8(KFuncEntryFormat8, ">%S");
+_LIT8(KFuncEntryThisFormat8, ">%S, [0x%08X]");
+_LIT8(KFuncExitFormat8, "<%S");
+
+_LIT(KPanicCategory, "generichid");
+_LIT8(KPanicPrefix8, "PANIC code ");
+_LIT8(KLeavePrefix8, "LEAVE code ");
+#endif
+
+#endif // OBEXSM_DEBUGCONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/inc/hidconnectioninfo.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,111 @@
+/*
+* Copyright (c) 2008-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+#ifndef C_CONNECTIONINFO_H_
+#define C_CONNECTIONINFO_H_
+
+
+#include <e32base.h>
+
+class CReportRoot;
+class CHidDriver;
+
+/**
+ *  CConnectionInfo
+ *  Connection information
+ * 
+ *
+ *  @lib generichid.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS ( CConnectionInfo ) : public CBase
+    {
+ 
+public:
+    /**
+     * Two-phased constructor.
+     * @param aConnectionID Connection identifier
+     * @param aReportRoot Connection ReportRoot
+     */
+    static CConnectionInfo* NewL(TInt aConnectionID, CReportRoot* aReportRoot);    
+    static CConnectionInfo* NewLC(TInt aConnectionID, CReportRoot* aReportRoot);
+    
+    /**
+    * Destructor.
+    */
+    virtual ~CConnectionInfo();
+    
+public:
+    /**
+     * Get Connection id
+     * 
+     * @since S60 v5.0     
+     * @return connection id
+     */
+    TInt            ConnectionID();
+    
+    /**
+     * Get report id
+     * 
+     * @since S60 v5.0      
+     * @return report id 
+     */
+    CReportRoot*    ReportRoot();
+    
+    /**
+     * Set last command handler
+     *
+     * @since S60 v5.0
+     * @param aHidDriverItem hiddriver item     
+     * @return None
+     */
+    void            SetLastCommandHandler(CHidDriver* aHidDriverItem);
+    
+    /**
+     * Set last command handler
+     *
+     * @since S60 v5.0
+     * @param aHidDriverItem hiddriver item     
+     * @return None
+     */
+    CHidDriver*     ReturnLastCommandHandler();
+    
+private:
+    CConnectionInfo(TInt aConnectionID, CReportRoot* aReportRoot);
+
+private:
+
+    /**
+     * Connection id
+     */
+    TInt  iConnectionID;
+    
+    /**
+     * Connection id
+     * Own.
+     */ 
+    CReportRoot*    iReportRoot;
+    
+    /**
+     * Pointer to last driver which handled last command
+     * Not own.
+     */
+    CHidDriver*     iLastCmdDriver;
+    };
+        
+#endif /* C_CONNECTIONINFO_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/inc/hiddriveritem.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,93 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declares driver list itemapplication class.
+*
+*/
+
+
+
+#ifndef C_DRIVERLISTITEM_H
+#define C_DRIVERLISTITEM_H
+
+#include "hidreportroot.h"
+#include "hidinterfaces.h"
+
+/**
+ *  Container class so we can maintain a list of driver instances
+ *
+ *  @lib generichid.lib
+ *  @since S60 v5.0
+ */
+class CDriverListItem : public CBase
+    {
+    // Give access to the TSglQueLink offset:
+    friend class CGenericHid;
+
+public :
+
+    explicit CDriverListItem(TInt aConnectionId);
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDriverListItem();
+
+
+    /**
+     * Set driver instance
+     *
+     * @since S60 v5.0
+     * @param aDriver Driver instance
+     * @return None
+     */
+    void SetDriver(CHidDriver* aDriver);
+
+    /**
+     * Return connection ID
+     *
+     * @since S60 v5.0
+     * @return Connection id
+     */
+    TInt ConnectionId() const;
+
+    /**
+     * Return driver instance
+     *
+     * @since S60 v5.0
+     * @return driver instance
+     */
+    CHidDriver* Driver() const;
+        
+
+private :
+
+    /**
+     * Queue link
+     */
+    TSglQueLink iSlink;
+
+    /**
+     * The transport-layer ID for the connection
+     */
+    TInt iConnectionId;
+
+    /**
+     * The device driver
+     * Own.
+     */
+    CHidDriver* iDriver;
+    
+    };
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/inc/hiditem.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,198 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  BTHid item
+*
+*/
+
+
+#ifndef T_ITEM_H
+#define T_ITEM_H
+
+#include <e32std.h>
+
+/**
+ * HID item class
+ * A HID report descriptor is comprised of a sequence of "items"
+ * that provide information about the device.  Items consist of a
+ * header and zero or more bytes of data.  The header contains the item
+ * type (main/global/local), an item "tag" (subtype) and the item size.
+ * Items can be "short" (containing a maximum of 4 bytes of data) or
+ * "long" (a maximum of 255 bytes of data).
+
+ * A TItem represents a single HID report descriptor item. It is
+ * constructed from an eight bit non-modifiable (Symbian-) descriptor,
+ * which is assumed to contain report (HID-) descriptor data.
+ *
+ * @lib generichid.lib
+ * @since S60 v5.0
+ */
+class TItem
+    {
+public:
+    /**
+     * The possible item types: main, global or local.  Item type is
+     * a two-bit field -- the 11b value is reserved for "long items", which
+     * are only used for vendor-specific commands.
+     */
+    enum TItemType
+        {
+        EMain = 0,    //!< Input, output, feature and begin or end collection
+        EGlobal = 1,  //!< Global item items affect all subsequent fields
+        ELocal = 2,   //!< Local items only persist until the next main item
+        EReserved = 3 //!< No defined use in the current HID standard (v1.11)
+        };
+
+public:
+
+    /**
+     * The constructor takes a an eight bit non-modifiable (Symbian-)
+     * descriptor containing report (HID-) descriptor data.
+     * The item tag, type, data size and offset are calculated here.
+     *
+     * @since S60 v5.0
+     * @param aRawData The raw item data, represented as a Symbian
+     * descriptor. The item data is assumed to be at the beginning of the
+     * descriptor. The size of the TDesC8 may be greater than the size
+     * of the item, as the item size will be calculated from the raw HID
+     * descriptor data.  Of course, the TDesC8 should be at least as
+     * long as the raw item data.
+     */
+    TItem(const TDesC8& aRawData);
+
+    /**
+     * DataSize() returns the size of the item data in bytes. This
+     * is the total item size minus the size of any header information.
+     * (A short item header is a single byte, a long item header is
+     * three bytes long.)
+     *
+     * @since S60 v5.0
+     * @return The size, in bytes, of the item data. Range 0-255.
+     */
+    TInt DataSize() const;
+
+    /**
+     * Tag() returns the tag (subtype) value for this item.
+     *
+     * @since S60 v5.0
+     * @return The item tag.
+     */
+    TInt Tag() const;
+
+    /**
+     * Data() returns the data associated with the item, represented as a
+     * 32-bit unsigned integer.  This is only meaningful if the data length
+     * is less than 4 bytes.
+     *
+     * @since S60 v5.0
+     * @return The item data as a 32-bit unsigned integer.
+     */
+    TUint32 Data() const;
+
+    /**
+     * SignedData() returns the data associated with the item,
+     * represented as a 32-bit signed integer.  This is only
+     * meaningful if the data length is less than 4 bytes.
+     *
+     * @since S60 v5.0
+     * @return The item data as a 32-bit signed integer.
+     */
+    TInt32 SignedData() const;
+
+    /**
+     * Returns the byte at the given offset within the item data block.     
+     *
+     * @since S60 v5.0
+     * @param aIndex The index within the data block for the current tag.
+     * @return The data at the specified index.
+     */
+    TUint8 operator[](TInt aIndex) const;
+
+    /**
+     * Type() returns the item type (e.g. "global").
+     *
+     * @since S60 v5.0     
+     * @return The item type.
+     */
+    TItemType Type() const;
+
+    /**
+     * Check if item is main
+     *
+     * @since S60 v5.0
+     * @return ETrue if item type is "main"
+     */
+    TBool IsMain() const;
+
+    /**
+     * Check if item is local
+     *
+     * @since S60 v5.0
+     * @return ETrue if item type is "local"
+     */
+    TBool IsLocal() const;
+
+    /**
+     * Check if item is global
+     *
+     * @since S60 v5.0
+     * @return ETrue if item type is "global"
+     */
+    TBool IsGlobal() const;
+
+    /**
+     * Check if item is global
+     *
+     * @since S60 v5.0
+     * @return ETrue if this is a long item
+     */
+    TBool IsLong() const;
+
+    /**
+     * ItemSize() returns the total size of this item, including the
+     * header data.
+     *
+     * @since S60 v5.0
+     * @return The total size of this item, in bytes.
+     */
+    TInt ItemSize() const;
+
+private:
+    /**
+     * Pointer to the raw report descriptor data
+     */
+    TPtrC8 iRawData;
+
+    /**
+     * Item data size
+     */
+
+    TInt iSize;
+    /**
+     * Item tag value
+     */
+    TInt iTag;
+
+    /**
+     * Offset in bytes of the data block
+     */
+    TInt iDataOffset;
+
+    /**
+     * Item type
+     */
+    TItemType iType;
+    };
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/inc/hidparser.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1041 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  BTHid item
+*
+*/
+
+#ifndef C_PARSER_H
+#define C_PARSER_H
+
+#include "hidreportroot.h"
+
+class TItem;
+
+/**
+ * HID Parser error codes.  For a description of the error code
+ * format, see "HID Parser Error Codes", Revision 1.2, USB
+ * Implementers' Forum, February 2000.
+ */
+enum THidParserError
+    {
+    // General:
+    //
+    EUnknownItem                    = 0xbf00,
+    ELongItemDefined                = 0x3e00,
+    //
+    // Global:
+    //
+    EZeroUsagePage                  = 0x8004,
+    EUsagePageOutOfRange            = 0x8104,
+    ELogicalMinInvalidForArray      = 0x8214,
+    ELogicalMaxInvalidForArray      = 0x8224,
+    ELonelyPhysicalMin              = 0x8034,
+    ELonelyPhysicalMax              = 0x8044,
+    EZeroReportId                   = 0x8084,
+    EReportIdTooBig                 = 0x8184,
+    ELateReportId                   = 0x8284,
+    EReportIdOutsideTopLevel        = 0x8484,
+    EZeroReportCount                = 0x8094,
+    EPushWithoutPop                 = 0x80a4,
+    EPushHasData                    = 0x81a4,
+    EPopWithoutPush                 = 0x80b4,
+    EPopHasData                     = 0x81b4,
+    ERedundantGlobalItem            = 0x80f4,
+    EReservedUsagePage              = 0x0004,
+    ELogicalMinExceedsMax           = 0x0014,
+    EPhysicalMinExceedsMax          = 0x0034,
+    EExponentReservedBitsNonZero    = 0x0054,
+    EUnitReservedBitsNonZero        = 0x0064,
+    //
+    // Local:
+    //
+    ELonelyUsageMin                 = 0x8018,
+    EUsageMinExceedsMax             = 0x8118,
+    EUsagePageMismatchMin           = 0x8318,
+    ELonelyUsageMax                 = 0x8028,
+    EUsagePageMismatchMax           = 0x8228,
+    ELonelyDesignatorMin            = 0x8048,
+    EDesignatorMinExceedsMax        = 0x8148,
+    ELonelyDesignatorMax            = 0x8058,
+    ELonelyStringMin                = 0x8088,
+    EStringMinExceedsMax            = 0x8188,
+    ELonelyStringMax                = 0x8098,
+    EUnknownDelimiter               = 0x80a8,
+    ENestedDelimiter                = 0x81a8,
+    ELonelyDelimiter                = 0x82a8,
+    EInvalidItemWithinDelimiter     = 0x83a8,
+    EDelimiterAtTopLevel            = 0x84a8,
+    EZeroUsage                      = 0x0008,
+    //
+    // Main:
+    //
+    EInputMissingItems              = 0x8080,
+    EInputItemWithinDelimiter       = 0x8180,
+    EInputReportSize                = 0x8280,
+    EInputMinExceedsMax             = 0x8380,
+    EOutputMissingItems             = 0x8090,
+    EOutputItemWithinDelimiter      = 0x8190,
+    EOutputReportSize               = 0x8290,
+    EOutputMinExceedsMax            = 0x8390,
+    EFeatureMissingItems            = 0x80b0,
+    EFeatureItemWithinDelimiter     = 0x81b0,
+    EFeatureReportSize              = 0x82b0,
+    EFeatureMinExceedsMax           = 0x83b0,
+    ENoMatchingBeginCollection      = 0x80c0,
+    EEndCollectionWithinDelimiter   = 0x81c0,
+    EReportMustBeEightBitMultiple   = 0x82c0,
+    ENoMatchingEndCollection        = 0x80a0,
+    EBeginCollectionWithinDelimiter = 0x81a0,
+    EApplicationCollectionLevel     = 0x82a0,
+    EInputReservedBitsNonZero       = 0x0080,
+    EInputLocalMultipleUse          = 0x0280,
+    EOutputReservedBitsNonZero      = 0x0090,
+    EOutputLocalMultipleUse         = 0x0290,
+    EFeatureReservedBitsNonZero     = 0x00b0,
+    EFeatureLocalMultipleUse        = 0x02b0,
+    ECollectionLocalUnused          = 0x00a0,
+    ECollectionTypeUnknownReserved  = 0x01a0,
+    EEndCollectionLocalUnused       = 0x00c0,
+    EEndCollectionHasData           = 0x01c0,
+    //
+    // Our ("vendor specific") codes:
+    //
+    EInvalidItemLength              = 0xC000,
+    EApplicationHasDelimiter        = 0x40a0,
+    EDelimiterWithinNamedArray      = 0x40a8,
+    ECollectionHasNoUsage           = 0x40c0,
+    ECollectionHasNoUsagePage       = 0x41c0
+    };
+
+/**
+ * HID parser panics
+ */
+enum THidParsingError
+    {
+    // ASSERT_ALWAYS:
+    //
+    EZeroLengthItem = 1,       //!< Zero descriptor length in TItem constructor
+    ENoReportRoot = 2,         //!< iReportRoot is 0 in CreateFieldL()
+    ENoCurrentCollection = 3,  //!< No current collection in Collection()
+    //
+    // ASSERT_DEBUG:
+    //
+    ENoCollectionToCheck = 10, //!< No collection in CheckForCollectionErrors()
+    EPopFailed = 11,           //!< Empty collection stack in PopCollection()
+    EIndexOutOfRange = 12,     //!< Index out of range in TItem::operator[]
+    EItemTooLong = 13          //!< Data() called for item with size > 4
+    };
+
+
+/**
+ *  Parser global states
+ *
+ *  CParser uses TParserGlobalState objects to store the global item
+ *  state during parsing. The global state can be saved and restored
+ *  using the HID descriptor POP and PUSH tags, therefore CParser
+ *  incorporates a stack of TParserGlobalState objects.
+ *
+ *
+ *  @lib  generichid.lib
+ *  @since S60 v5.0
+ */
+class TParserGlobalState
+    {
+    friend class CParser;
+
+public:
+
+    TParserGlobalState();
+
+    /**
+     * Copies all data members into a CField object. The other
+     * members of the CField object (those corresponding to local
+     * HID descriptor tags) are unaffected.
+     *
+     * @since S60 v5.0
+     * @param aField Pointer to the field object to populate.
+     * @return None.
+     */
+    void Populate(CField *aField) const;
+
+private:
+    /**
+     * Usage page
+     */
+    TInt iUsagePage;
+
+    /**
+     * Logical minimum
+     */
+    TInt iLogicalMin;
+
+    /**
+     * Logical maximum
+     */
+    TInt iLogicalMax;
+
+    /**
+     * Physical minimum
+     */
+    TInt iPhysicalMin;
+
+    /**
+     * Physical maximum
+     */
+    TInt iPhysicalMax;
+
+    /**
+     * Unit type
+     */
+    TInt iUnit;
+
+    /**
+     *  Unit exponent
+     */
+    TInt iUnitExponent;
+
+    /**
+     * Associated report ID
+     */
+    TInt iReportId;
+
+    /**
+     * Report size
+     */
+    TInt iSize;
+
+    /**
+     * Report count
+     */
+    TInt iCount;
+    };
+
+
+/**
+ *
+ * HID parser
+ * CParser parses a HID report descriptor.  It outputs a CReportRoot
+ * containing a tree of CCollection and CField objects representing
+ * the descriptor information.  A HID device driver can then use this,
+ * in conjunction with TReportTranslator and CReportGenerator objects,
+ * to facilitate communication with a HID device.
+ *
+ * The parsing process conforms to the HID class specification
+ * document: "USB Device Class Definition for Human Interface Devices
+ * (HID)", Firmware Specification, Version 1.11, USB Implementers' Forum,
+ * June 2001.
+ *
+ *
+ *  @lib generichid.lib
+ *  @since S60 v5.0
+ */
+class CParser : public CBase
+    {
+public:
+    IMPORT_C static CParser* NewL();
+    IMPORT_C static CParser* NewLC();
+
+    virtual ~CParser();
+
+    /**
+     * ParseL() parses a string of bytes representing a HID report
+     * descriptor. It returns a tree of collection and field objects (a
+     * CReportRoot). Ownership of the CReportRoot is transferred to the
+     * caller.
+     *
+     * Warning messages produced during the parse process are added to
+     * a list which the driver can retrieve using the Warnings()
+     * function. Note that the list will be overwritten by the next
+     * ParseL() operation.
+     *
+     * Errors and warnings are represented using the format described
+     * in "HID Parser Error Codes", Revision 1.2, USB Implementers'
+     * Forum, February 2000.
+     *
+     * @since S60 v5.0
+     * @param aRawData The report descriptor data to be processed
+     * @return The root collection, a tree of CCollection and CField objects
+     */
+    IMPORT_C CReportRoot* ParseL(const TDesC8& aRawData);
+
+    /**
+     * Return field count
+     *
+     * @since S60 v5.0
+     * @return field count
+     */
+    TInt FieldCount();
+     
+  
+
+        
+
+private:
+    CParser();
+    void ConstructL();
+
+    /**
+     * Handle a HID descriptor main item.  This includes the creation
+     * of new field objects in the current collection and management of
+     * the global item state stack.
+     *
+     * @since S60 v5.0
+     * @param aItem The current report descriptor tag and its associated data
+     * @return KErrNone (0) on success, otherwise a critical error code in
+     *         the standard HID format.
+     */
+    TInt MainItemL(const TItem& aItem);
+
+    /**
+     * Handle a HID descriptor local item.  Stores the data in the
+     * appropriate member of the local state object, *iLocal.
+     *
+     * @since S60 v5.0
+     * @param aItem The current report descriptor tag and its associated data
+     * @return KErrNone (0) on success, otherwise a critical error code in
+     *         the standard HID format.
+     */
+    TInt LocalItemL(const TItem& aItem);
+
+    /**
+     * Handle a HID descriptor global item. Stores the data in the
+     * appropriate member of the current global state object, iGlobal.
+     *
+     * @since S60 v5.0
+     * @param aItem The current report descriptor tag and its associated data
+     * @return KErrNone (0) on success, otherwise a critical error code in
+     *         the standard HID format.
+     */
+    TInt GlobalItemL(const TItem& aItem);
+
+    /**
+     * Used to access the current collection object, i.e. the object
+     * at the top of the collection stack (iCollectionStack).
+     *     
+     *
+     * @since S60 v5.0
+     * @return A pointer to the current collection object.
+     *
+     */
+    CCollection* Collection();
+
+    /**
+     * Pushes a pointer to the current collection object on to the
+     * collection stack.
+     *
+     * Note that the collection stack is used to create the tree of
+     * collections. It should not be confused with the global state
+     * stack, iGlobalStack.
+     *
+     * @since S60 v5.0
+     * @param aCollection The collection to be pushed onto the stack
+     * @return None.
+     *
+     */
+    void PushCollectionL(const CCollection* aCollection);
+
+    /**
+     * Pushes a pointer to the current collection object on to the
+     * collection stack.
+     *
+     * Note that the collection stack is used to create the tree of
+     * collections. It should not be confused with the global state
+     * stack, iGlobalStack.
+     *
+     * @since  S60 v5.0
+     * @return None.
+     *
+     */
+    void PopCollection();
+
+    /**
+     * CreateFieldL() is called to instantiate a new CField object
+     * when an input, output or feature item is encountered in the
+     * report descriptor.
+     *
+     * The current local and global states extracted from the report
+     * descriptor are copied to the CField, which is placed into the
+     * current CCollection.
+     *
+     * @since S60 v5.0
+     * @param aType The type of field: input, output or feature
+     * @param aAttributes The attributes for the field (e.g. Data, Array,
+     *                    Absolute.)
+     * @return KErrNone (0) on success, otherwise a critical error code
+     *                  in the standard HID format.
+     *
+     */
+    TInt CreateFieldL(CField::TType aType, TUint32 aAttributes);
+
+    /**
+     * ClearLocalState() clears the appropriate fields in the CField
+     * object that represents the current local item state.
+     *
+     * @since S60 v5.0
+     * @return None
+     *
+     */
+    void ClearLocalState();
+
+    /**
+     * DumpStateTableL() copies the current local and global item state
+     * into a CField object.
+     *
+     * @since S60 v5.0
+     * @param aField The field object to receive the data
+     * @return None
+     *
+     */
+    void DumpStateTableL(CField *aField) const;
+
+    /**
+     * CreateCollectionL() is called to instantiate a new CCollection
+     * object when a "begin collection" item is encountered in the
+     * report descriptor.
+     *
+     * @since S60 v5.0
+     * @param aType The type of the collection. This can be one of the
+     *              seven standard types defined in CCollection::TType,
+     *              or a vendor defined value.
+     * @return KErrNone (0) on success, otherwise a critical error code in
+     *         the standard HID format.
+     */
+    TInt CreateCollectionL(TUint32 aType);
+
+    /**
+     * CheckForCollectionErrors() validates the current collection
+     * object. It adds non-critical errors to the warnings list. It
+     * returns an error code if a critical error is encountered.
+     *
+     * @since S60 v5.0
+     * @param aType The type of the collection (one of the CCollection::TType
+     *              values, or vendor defined).
+     * @return KErrNone (0) if there was no error, otherwise a critical
+     *         error code in the standard HID format.
+     */
+    TInt CheckForCollectionErrors(TUint32 aType);
+
+    /**
+     * CheckForFieldErrors() validates the current global and local
+     * item state in preparation for creating a CField object.  It adds
+     * non-critical errors to the warnings list. It returns an error
+     * code if a critical error is encountered.
+     *
+     * @since S60 v5.0
+     * @param @param aType The type of the field (input, output or feature).
+     * @param aAttributes The attributes for the field (e.g. Data, Array,
+     *                    Absolute.)
+     * @return KErrNone (0) if there was no error, otherwise a critical
+     *                   error code in the standard HID format.
+     */
+    TInt CheckForFieldErrors(CField::TType aType, TUint32 aAttributes);
+
+    /**
+     * CheckForMainErrors() performs error checking common to
+     * CheckForCollectionErrors() and CheckForFieldErrors(). It adds
+     * non-critical errors to the warnings list. It returns an error
+     * code if a critical error is encountered.
+     *
+     * @since S60 v5.0
+     * @return KErrNone (0) if there was no error, otherwise a critical
+     *                  error code in the standard HID format.
+     */
+    TInt CheckForMainErrors();
+
+    /**
+     * CheckAllReportSizes() checks if all report sizes are integral
+     * multiples of 8 bits.
+     *
+     * @since S60 v5.0
+     * @return ETrue if all report sizes are integral multiples of
+     *         8 bits.
+     */
+    TBool CheckAllReportSizes() const;
+
+    /**
+     * BitsToRepresentRange() returns the number of bits required to
+     * represent all values in a given range. It is used to check
+     * that the report field size is appropriate for the given
+     * logical minimum and maximum.
+     *
+     * If the range is all positive then it is assumed that there is no
+     * sign bit, otherwise twos complement format is assumed, as per
+     * the HID class specification, v1.11, Section 6.2.2.7.
+     *
+     * @since S60 v5.0
+     * @param aMin Logical minimum
+     * @param aMax Logical maximum
+     * @return The number of bits required to represent the range aMin
+     *         to aMax (inclusive).
+     */
+    static TInt BitsToRepresentRange(TInt aMin, TInt aMax);
+
+    /**
+     * NumberOfLeadingZeros() is used by BitsToRepresentRange(). It
+     * returns the number of leading zeros in the binary representation
+     * of a number, effectively performing a log_2 operation.
+     *
+     * @since S60 v5.0
+     * @param aValue Unsigned 32-bit value
+     * @return Number of leading zeros in the binary representation of aValue
+     */
+    static TInt NumberOfLeadingZeros(TUint32 aValue);
+
+    /**
+     * IssueWarning() adds a TParserWarning to the warning list.
+     *
+     * @since S60 v5.0
+     * @param aHidWarningCode The error or warning code, which should
+     *                        be in the standard HID format.
+     * @return None
+     */
+    void IssueWarning(TInt aHidWarningCode);
+
+    /**
+     * IsReservedUsagePage() checks if the given HID usage page is
+     * listed as reserved according to the HID clas specification,
+     * v1.11.
+     *
+     * @since S60 v5.0
+     * @param aUsagePage The usage page to check.
+     * @result ETrue if the usage page is listed as reserved.
+     */
+    static TBool IsReservedUsagePage(TInt aUsagePage);
+
+
+    /**
+     * HandleMainInputTagL
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleMainInputTagL(const TItem& aItem);
+
+
+    /**
+     * HandleMainOutputTag
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleMainOutputTagL(const TItem& aItem);
+
+    /**
+     * HandleMainFeature
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleMainFeatureL( const TItem& aItem );
+
+    /**
+     * HandleMainCollection
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleMainCollectionL( const TItem& aItem );
+
+
+    /**
+     * MainEndCollection
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleMainEndCollection( const TItem& aItem);
+
+    /**
+     * HandleGlobalReportId
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleGlobalReportId( const TItem& aItem );
+
+    /**
+     * HandleGlobalUsagePage
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleGlobalUsagePage( const TItem& aItem );
+
+    /**
+     * HandleGlobalLogicalMinimum
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleGlobalLogicalMinimum( const TItem& aItem );
+
+    /**
+     * HandleGlobalLogicalMaximum
+     *
+     * @since S60 ?S60_version *** for example, S60 v3.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleGlobalLogicalMaximum( const TItem& aItem );
+
+    /**
+     * HandleGlobalPhysicalMinimum
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleGlobalPhysicalMinimum( const TItem& aItem );
+
+    /**
+     * HandleGlobalPhysicalMinimum
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleGlobalPhysicalMaximum( const TItem& aItem );
+
+    /**
+     * HandleGlobalUnit
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleGlobalUnit( const TItem& aItem );
+
+    /**
+     * HandleGlobalUnitExponent
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleGlobalUnitExponent( const TItem& aItem );
+
+    /**
+     * HandleGlobalReportSize
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleGlobalReportSize( const TItem& aItem );
+
+    /**
+     * HandleGlobalReportSize
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleGlobalReportCount( const TItem& aItem );
+
+    /**
+     * HandleGlobalPush
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleGlobalPushL( const TItem& aItem );
+
+    /**
+     * HandleGlobalPop
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleGlobalPop( const TItem& aItem );
+
+    /**
+     * HandleLocalUsage
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleLocalUsageL( const TItem& aItem );
+
+    /**
+     * HandleLocalUsageMinimum
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleLocalUsageMinimum( const TItem& aItem );
+
+    /**
+     * HandleLocalUsageMinimum
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleLocalUsageMaximum( const TItem& aItem );
+
+    /**
+     * HandleLocalDesignatorIndex
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleLocalDesignatorIndex( const TItem& aItem );
+
+    /**
+     * HandleLocalDesignatorMinimum
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleLocalDesignatorMinimum( const TItem& aItem );
+
+    /**
+     * HandleLocalDesignatorMaximum
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleLocalDesignatorMaximum( const TItem& aItem );
+
+    /**
+     * HandleLocalStringIndex
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleLocalStringIndex( const TItem& aItem );
+
+    /**
+     * HandleLocalStringMinimum
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleLocalStringMinimum( const TItem& aItem );
+
+    /**
+     * HandleLocalStringMaximum
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleLocalStringMaximum( const TItem& aItem );
+
+    /**
+     * HandleLocalDelimiter
+     *
+     * @since S60 v5.0
+     * @param aItem a Hid field item
+     * @result error code
+     */
+    TInt HandleLocalDelimiter( const TItem& aItem );
+    
+    /**
+     * CheckMandatoryFieldError
+     *
+     * @since S60 v5.0
+     * @param aType a field type
+     * @param aAttributes attributes
+     * @result error code
+     */
+    TInt CheckMandatoryFieldExistence( CField::TType aType, TUint32 aAttributes );
+    
+    /**
+     * CheckUsageMinAndMaxErrors
+     *
+     * @since S60 v5.0     
+     * @result error code
+     */
+    TInt CheckUsageMinAndMaxErrors();
+    
+    /**
+     * CheckDesignatorMinAndMaxErrors
+     *
+     * @since S60 v5.0     
+     * @result error code
+     */
+    TInt CheckDesignatorMinAndMaxErrors();
+    
+    /**
+     * CheckStringMinAndMaxErrors
+     *
+     * @since S60 v5.0     
+     * @result error code
+     */
+    TInt CheckStringMinAndMaxErrors();
+    
+    /**
+     * CheckMandatoryFieldError
+     *
+     * @since S60 v5.0
+     * @param aType a field type
+     * @param aAttributes attributes
+     * @result error code
+     */
+    TInt CheckMandatoryFieldErrors( CField::TType aType, TUint32 aAttributes );
+    
+    /**
+     * CheckLogicalMinAndMax
+     * Check if logical minimum and maximum must match the number of usage
+     * values 
+     *
+     * @since S60 v5.0     
+     * @param aAttributes attributes
+     * @result error code
+     */
+    void CheckLogicalMinAndMax( TUint32 aAttributes );
+    
+    /**
+     * CheckMandatoryFieldError
+     *
+     * @since S60 v5.0
+     * @param aType a field type
+     * @param aAttributes attributes
+     * @result error code
+     */
+    void CheckFieldBitNeeded( CField::TType aType, TUint32 aAttributes );
+    
+    /**
+     * HandleItem
+     *
+     * @since S60 v5.0     
+     * @result error code
+     */
+    void HandleItemL(TItem& aItem);
+    
+    /**
+     * CheckParseErrors
+     *
+     * @since S60 v5.0     
+     * @result error code
+     */
+    void CheckParseErrors();
+    
+    /**
+     * ResetParser
+     *
+     * @since S60 v5.0     
+     * @result error code
+     */
+    void ResetParserL();
+
+private:
+    /**
+     * A bitmask containing the THidItem flags which represent local
+     * (as opposed to main or global) items.
+     */
+    static const TUint32 KLocalItemMask;
+    
+    /**
+     * A bitmask containing the THidItem flags which represent local
+     * unused items.
+     */
+    static const TUint32 KUnusedLocalItemsMask;
+    
+    /**
+     * A bitmask containing the THidItem flags which represent mandatory
+     * items.
+     */
+    static const TUint32 KMandatoryItemMask;
+    
+    /**
+     * A bitmask containing the THidItem flags which represent report
+     * items.
+     */
+    static const TUint32 KReportItemMask;
+
+private:
+
+    /**
+     * THidItem defineds a set of flags used for keeping track of
+     * which items have been encountered in the report descriptor for
+     * the current report field. The flags are used with the
+     * iItemsDefined and iGlobalItemsDefined data members.
+     */
+    enum THidItem
+        {
+        EUsagePage       = 1<<0,
+        ELogicalMin      = 1<<1,
+        ELogicalMax      = 1<<2,
+        EReportSize      = 1<<3,
+        EReportCount     = 1<<4,
+        EReportId        = 1<<5,
+        EUsageMin        = 1<<6,
+        EUsageMax        = 1<<7,
+        EPhysicalMin     = 1<<8,
+        EPhysicalMax     = 1<<9,
+        EUnit            = 1<<10,
+        EUnitExponent    = 1<<11,
+        EDesignatorIndex = 1<<12,
+        EDesignatorMin   = 1<<13,
+        EDesignatorMax   = 1<<14,
+        EStringIndex     = 1<<15,
+        EStringMin       = 1<<16,
+        EStringMax       = 1<<17,
+        EInputReport     = 1<<18,
+        EOutputReport    = 1<<19,
+        EFeatureReport   = 1<<20,
+        EDelimiter       = 1<<21,
+        EUsageId         = 1<<22
+       };
+
+    /**
+     * HID local tags
+     */
+    enum THidLocalTags
+        {
+        ELocalUsage             = 0x00,
+        ELocalUsageMinimum      = 0x01,
+        ELocalUsageMaximum      = 0x02,
+        ELocalDesignatorIndex   = 0x03,
+        ELocalDesignatorMinimum = 0x04,
+        ELocalDesignatorMaximum = 0x05,
+        ELocalStringIndex       = 0x07,
+        ELocalStringMinimum     = 0x08,
+        ELocalStringMaximum     = 0x09,
+        ELocalDelimiter         = 0x0a
+        };
+
+    /**
+     *  HID global tags
+     */
+    enum THidGlobalTags
+        {
+        EGlobalUsagePage       = 0x00,
+        EGlobalLogicalMinimum  = 0x01,
+        EGlobalLogicalMaximum  = 0x02,
+        EGlobalPhysicalMinimum = 0x03,
+        EGlobalPhysicalMaximum = 0x04,
+        EGlobalUnitExponent    = 0x05,
+        EGlobalUnit            = 0x06,
+        EGlobalReportSize      = 0x07,
+        EGlobalReportId        = 0x08,
+        EGlobalReportCount     = 0x09,
+        EGlobalPush            = 0x0a,
+        EGlobalPop             = 0x0b
+        };
+
+    /**
+     * HID main tags
+     */
+    enum THidMainTags
+        {
+        EMainInput         = 0x08,
+        EMainOutput        = 0x09,
+        EMainFeature       = 0x0b,
+        EMainCollection    = 0x0a,
+        EMainEndCollection = 0x0c
+        };
+
+    /**
+     * The local state, cleared after each "Main" item
+     * Own.
+     */
+    CField* iLocal;
+
+    /**
+     * Current global state
+     */
+    TParserGlobalState iGlobal;
+
+    /**
+     * Global state stack, to allow HID descriptor PUSH and POP commands
+     */
+    RArray<TParserGlobalState> iGlobalStack;
+
+    // For delimiter handling:
+    //
+    /**
+     *  ETrue if currently within a delimiter pair
+     */
+    TBool iWithinDelimiter;
+
+    /**
+     *  Count of alternate USAGE declarations so far
+     */
+    TInt iAliasCount;
+
+    /**
+     *  Count of alternate USAGE_MIN declarations
+     */
+    TInt iAliasCountMin;
+
+    /**
+     *  Count of alternate USAGE_MAX declarations
+     */
+    TInt iAliasCountMax;
+
+    /**
+     * The root node of the collection tree
+     * Own.
+     */
+    CReportRoot* iReportRoot;
+
+    /**
+     * Stack used to create the collection tree
+     */
+    RPointerArray<CCollection> iCollectionStack;
+
+    // Keep track of which items have been seen in the descriptor:
+    //
+    /**
+     * All items forming the current item state
+     */
+    TUint32 iItemsDefined;
+
+    /**
+     * Global items seen since the last main tag
+     */
+    TUint32 iGlobalItemsDefined;
+
+    /**
+     * ETrue if a redundant local item is seen
+     */
+    TBool iLocalMultipleUse;
+
+    /**
+     * Number of the item we're currently processing
+     */
+    TInt iItemNumber;
+
+    /**
+     * Record of any critical error encountered
+     */
+    TInt iErrorCode;
+    
+    /**
+     * Field count
+     */
+    TInt iFieldCount;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/inc/hidreportgenerator.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,129 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Report generator
+*
+*/
+
+#ifndef C_REPORT_GENERATOR_H
+#define C_REPORT_GENERATOR_H
+
+#include "hidreportroot.h"
+#include "hidtranslate.h"
+
+/**
+ * HID report generator
+ *
+ * Class used for generating output or feature reports to send to the device.
+ *
+ * @lib  generichid.lib
+ * @since S60 v5.0
+ */
+class CReportGenerator : public CBase
+    {
+public:
+    /**
+     * Constructs a CReportGenerator.
+     *
+     * @since S60 v5.0
+     * @param aReportRoot Tree generated by CParser from the report
+     *                    descriptor.
+     * @param aReportId Report ID of the report to generate.
+     * @param aType Type of report to generate (output or feature).
+     */
+    IMPORT_C static CReportGenerator* NewLC(const CReportRoot* aReportRoot,
+        TInt aReportId, CField::TType aType);
+
+    /**
+     * Constructs a CReportGenerator.
+     *
+     * @since S60 v5.0
+     * @param aReportRoot Tree generated by CParser from the report
+     *                    descriptor.
+     * @param aReportId Report ID of the report to generate.
+     * @param aType Type of report to generate (output or feature).
+     */
+    IMPORT_C static CReportGenerator* NewL(const CReportRoot* aReportRoot,
+        TInt aReportId, CField::TType aType);
+
+    virtual ~CReportGenerator();
+
+    /**
+     * Sets the value of a single field in the report.  Stores the requested
+     * control value in a field in the report buffer.  For array fields, adds
+     * the requested usage ID to the array.
+     *
+     * @since S60 v5.0
+     * @param aField Pointer to the field in which to set a value.
+     * @param aUsageId Usage ID of the control to set.
+     * @param aValue Value to write to the field, used for variable
+     *               fields only.
+     * @param aControlOffset Which control to set when more than one
+     *                       have the same usage ID.
+     * @return Error code indicating success or reason for failure.
+     */
+    IMPORT_C TInt SetField(const CField* aField, TInt aUsageId, TInt aValue,
+        TInt aControlOffset = 0);
+
+    /**
+     * Get the buffer holding the generated report
+     *
+     * @since S60 v5.0
+     * @return pointer to buffer
+     */
+    IMPORT_C TPtr8 Report();
+
+private:
+    /**
+     * Constructor for CReportGenerator.
+     *
+     * @since S60 v5.0
+     * @param aReportId Report ID of the report to generate.
+     * @param aType Type of report to generate (output or feature).
+     */
+    CReportGenerator(TInt aReportId, CField::TType aType);
+
+    /**
+     * 2nd phase constructor for CReportGenerator.  Allocates the
+     * report buffer iBuf.
+     *
+     * @since S60 v5.0
+     * @param aReportRoot Tree generated by CParser from the report
+     *                    descriptor.
+     */
+    void ConstructL(const CReportRoot* aReportRoot);
+
+    /**
+     * Report ID of the report to generate
+     */
+    TInt iReportId;
+
+    /**
+     * Type of report to generate
+     */
+    CField::TType iType;
+
+    /**
+     * Tree of fields from the report descriptor
+     * Not own.
+     */
+    const CReportRoot* iReportRoot;
+
+    /**
+     * Buffer to hold the generated report
+     * Own.
+     */
+    HBufC8* iBuf;
+    };
+
+#endif  // __REPORT_GENERATOR_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/inc/hiduids.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  UID definitions.
+*
+*/
+
+
+#ifndef HIDUIDS_H
+#define HIDUIDS_H
+
+#define ECOM_UID 0x10009d8d
+#define REMCON_PLUGIN_IF 0x10204546
+//----- original HID uids, reserved from Symbian
+#define LAYOUT_PLUGIN_UID 0x10201d25
+#define DRIVER_PLUGIN_IF 0x10201d26
+#define LAYOUT_PLUGIN_IF 0x10201d27
+#define BTHID_SRV_UID 0x10201d28
+#define LAYOUTMGR_UID 0x10201d29
+#define BTKEYBOARD_APP_UID 0x10201d2a
+#define STARTER_UID 0x10201d2b
+#define BTHID_PLUGIN_UID 0x10201d2c
+//----- reserved from NSS list
+#define MOUSE_UID 0x10281cfc
+#define BTHID_CLIENT_UID 0x10281cfd
+#define GENERICHID_UID 0x10281cfe
+#define GSPLUGIN_IMP 0x10281cff
+#define BTHID_MAIN_IMP 0x10281d00
+#define BTHID_SETTINGS_IMP 0x10281d01
+#define BTHID_PLUGIN_IF 0x10281d02
+#define INSTALLER_UID 0x10281d03
+#define KEYBOARD_UID 0x10281d04
+#define KEYBOARD_DRIVER_IMP 0x10282bfd
+#define MOUSE_DRIVER_IMP 0x10282bfe
+#define BELGIAN_LAYOUT_IMP 0x10282bff
+#define DANISH_LAYOUT_IMP 0x10282c00
+#define DUTCH_LAYOUT_IMP 0x10282c01
+#define FINSWE_LAYOUT_IMP 0x10282c02
+#define FRENCH_LAYOUT_IMP 0x10282c03
+#define GERMAN_LAYOUT_IMP 0x10282c04
+#define ITALIAN_LAYOUT_IMP 0x10282c05
+#define NORWEGIAN_LAYOUT_IMP 0x10282c06
+#define PORTUGUESE_LAYOUT_IMP 0x10282c07
+#define SPANISH_LAYOUT_IMP 0x10282c08
+#define SU8GERMAN_LAYOUT_IMP 0x10282c09
+#define SU8RUSSIAN_LAYOUT_IMP 0x10282c0a
+#define SU8RUSSIANINT_LAYOUT_IMP 0x10282c0b
+#define SU8FINSWE_LAYOUT_IMP 0x10282c0c
+#define SU8DANNOR_LAYOUT_IMP 0x10282c0d
+#define SU8USENGLISH_LAYOUT_IMP 0x10282c0e
+#define SU8INTUSENGLISH_LAYOUT_IMP 0x10282c0f
+#define UK_LAYOUT_IMP 0x10282c10
+#define US_LAYOUT_IMP 0x10282c11
+#define USDVORAK_LAYOUT_IMP 0x10282c12
+#define USINT_LAYOUT_IMP 0x10282c13
+#define KBDCLIENT_UID 0x10282c14
+#define HEADSET_UID 0x10282c15
+#define HEADSET_DRIVER_IMP 0x10282c16
+#define HIDREMCON_UID 0x10282c17
+#define HIDREMCON_IMP 0x10282c18
+#define HIDEVENTPUBLISHER_UID 0x10282c19
+// Last reserved UID 0x10282c3c
+
+#endif // __HIDUIDS_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/inc/prjconfig.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project configure file.
+*
+*/
+
+
+#ifndef GENERICHID_PRJCONFIG_H
+#define GENERICHID_PRJCONFIG_H
+
+/**
+ * Traces are enabled via RDebug::Print() in UDEB build, by default.
+ */
+#ifdef _DEBUG
+#define PRJ_ENABLE_TRACE
+#endif
+
+/**
+ * Traces will be written to file if this is defined.
+ */
+//#define PRJ_FILE_TRACE
+
+
+/**
+ * build the project for module test purpose if this is defined
+ */
+//#define PRJ_MODULETEST_BUILD
+
+/**
+ * build the project using stubs to replace the dependencies if this is defined
+ */
+//#define PRJ_USE_STUB
+
+#endif // OBEXSM_PRJCONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/rom/generichid.iby	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2008-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Image description file for project  generichid 
+*
+*/
+
+
+#ifndef __GENERICHID_IBY__
+#define __GENERICHID_IBY__
+
+file=ABI_DIR\BUILD_DIR\generichid.dll              SHARED_LIB_DIR\generichid.dll
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/src/hidcollection.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,284 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  HID collection implementation
+*
+*/
+
+
+#include <e32std.h>
+#include <e32base.h>
+#include <e32des8.h>
+#include <e32svr.h>
+
+#include "hidreportroot.h"
+#include "debug.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// -----------------------------------------------------------------------------
+// NewLC()
+// -----------------------------------------------------------------------------
+//
+CCollection* CCollection::NewLC()
+    {
+    CCollection* self = new (ELeave) CCollection();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+// -----------------------------------------------------------------------------
+// NewL()
+// -----------------------------------------------------------------------------
+//
+CCollection* CCollection::NewL()
+    {
+    CCollection* self=NewLC();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// ConstructL()
+// -----------------------------------------------------------------------------
+//
+void CCollection::ConstructL()
+    {
+    // Nothing to do here
+    }
+
+// -----------------------------------------------------------------------------
+// CCollection()
+// -----------------------------------------------------------------------------
+//
+CCollection::CCollection()
+    {
+    // Nothing to do here
+    }
+
+// -----------------------------------------------------------------------------
+// ~CCollection()
+// -----------------------------------------------------------------------------
+//
+CCollection::~CCollection()
+    {
+    iCollections.ResetAndDestroy();
+    iFields.ResetAndDestroy();
+    }
+
+// -----------------------------------------------------------------------------
+// Type()
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TUint32 CCollection::Type() const
+    {
+    return iType;
+    }
+
+// -----------------------------------------------------------------------------
+// UsagePage()
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CCollection::UsagePage() const
+    {
+    return iUsagePage;
+    }
+
+// -----------------------------------------------------------------------------
+// Usage()
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CCollection::Usage() const
+    {
+    return iUsage;
+    }
+
+// -----------------------------------------------------------------------------
+// CollectionCount()
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CCollection::CollectionCount() const
+    {
+    return iCollections.Count();
+    }
+
+// -----------------------------------------------------------------------------
+// FieldCount()
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CCollection::FieldCount() const
+    {
+    return iFields.Count();
+    }
+
+// -----------------------------------------------------------------------------
+// CollectionByIndex
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const CCollection* CCollection::CollectionByIndex(TInt aIndex) const
+    {
+    return (0 <= aIndex && aIndex < iCollections.Count()) ?
+        iCollections[aIndex] : NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// FieldByIndex
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const CField* CCollection::FieldByIndex(TInt aIndex) const
+    {
+    return (0 <= aIndex && aIndex < iFields.Count()) ?
+        iFields[aIndex] : NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// IsPhysical()
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CCollection::IsPhysical() const
+    {
+    return iType == EPhysical;
+    }
+
+// -----------------------------------------------------------------------------
+// IsApplication()
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CCollection::IsApplication() const
+    {
+    return iType == EApplication;
+    }
+
+// -----------------------------------------------------------------------------
+// IsLogical()
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CCollection::IsLogical() const
+    {
+    return iType == ELogical;
+    }
+
+// -----------------------------------------------------------------------------
+// IsReport()
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CCollection::IsReport() const
+    {
+    return iType == EReport;
+    }
+
+// -----------------------------------------------------------------------------
+// IsNamedArray()
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CCollection::IsNamedArray() const
+    {
+    return iType == ENamedArray;
+    }
+
+// -----------------------------------------------------------------------------
+// IsUsageSwitch()
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CCollection::IsUsageSwitch() const
+    {
+    return iType == EUsageSwitch;
+    }
+
+// -----------------------------------------------------------------------------
+// IsUsageModifier()
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CCollection::IsUsageModifier() const
+    {
+    return iType == EUsageModifier;
+    }
+
+// -----------------------------------------------------------------------------
+// SetType()
+// -----------------------------------------------------------------------------
+//
+void CCollection::SetType(TUint32 aType)
+    {
+    iType = aType;
+    }
+
+// -----------------------------------------------------------------------------
+// SetUsagePage()
+// -----------------------------------------------------------------------------
+//
+void CCollection::SetUsagePage(TInt aUsagePage)
+    {
+    iUsagePage = aUsagePage;
+    }
+
+// -----------------------------------------------------------------------------
+// SetUsage()
+// -----------------------------------------------------------------------------
+//
+void CCollection::SetUsage(TInt aUsage)
+    {
+    iUsage = aUsage;
+    }
+// -----------------------------------------------------------------------------
+// AddFieldL()
+// -----------------------------------------------------------------------------
+//
+CField* CCollection::AddFieldL()
+    {
+    CField* field = CField::NewL();
+    CleanupStack::PushL(field);
+    User::LeaveIfError(iFields.Append(field));
+    CleanupStack::Pop(field);
+    return field;
+    }
+
+// -----------------------------------------------------------------------------
+// AddCollectionL()
+// -----------------------------------------------------------------------------
+//
+CCollection* CCollection::AddCollectionL()
+    {
+    CCollection* collection = CCollection::NewL();
+    CleanupStack::PushL(collection);
+    User::LeaveIfError(iCollections.Append(collection));
+    CleanupStack::Pop(collection);
+    return collection;
+    }
+
+
+
+
+
+// -----------------------------------------------------------------------------
+// Match()
+// -----------------------------------------------------------------------------
+//
+TBool TReportSize::Match(const TReportSize& aFirst,
+    const TReportSize& aSecond)
+    {
+    return (aFirst.iReportId == aSecond.iReportId) &&
+        (aFirst.iType == aSecond.iType);
+    }
+
+
+// -----------------------------------------------------------------------------
+// TReportSize()
+// -----------------------------------------------------------------------------
+//
+TReportSize::TReportSize(TInt aReportId, CField::TType aType)
+    : iReportId(aReportId), iType(aType), iSize(0)
+    {
+    // Nothing else to do
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/src/hidconnectioninfo.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,106 @@
+/*
+* Copyright (c) 2008-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#include "hidconnectioninfo.h"
+#include "hidreportroot.h"
+#include "debug.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+CConnectionInfo::CConnectionInfo(TInt aConnectionID, CReportRoot* aReportRoot):
+iConnectionID(aConnectionID),
+iReportRoot(aReportRoot)
+    { 
+    TRACE_FUNC       
+    }
+
+// ---------------------------------------------------------------------------
+// NewL
+// ---------------------------------------------------------------------------
+//
+CConnectionInfo* CConnectionInfo::NewL(TInt aConnectionID, CReportRoot* aReportRoot)
+    {
+    CConnectionInfo* self = CConnectionInfo::NewLC(aConnectionID, aReportRoot);
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// NewLC
+// ---------------------------------------------------------------------------
+//
+CConnectionInfo* CConnectionInfo::NewLC(TInt aConnectionID, CReportRoot* aReportRoot)
+    {
+    CConnectionInfo* self = new( ELeave ) CConnectionInfo( aConnectionID, aReportRoot);
+    CleanupStack::PushL( self );    
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CConnectionInfo::~CConnectionInfo()
+    {
+    TRACE_FUNC_ENTRY
+    delete iReportRoot;
+    iReportRoot = NULL;
+    TRACE_FUNC_EXIT
+    }
+
+// ---------------------------------------------------------------------------
+// ConnectionID
+// ---------------------------------------------------------------------------
+//
+TInt CConnectionInfo::ConnectionID()    
+    {
+    return iConnectionID;
+    }
+
+// ---------------------------------------------------------------------------
+// ReportRoot
+// ---------------------------------------------------------------------------
+//
+CReportRoot* CConnectionInfo::ReportRoot()
+    {    
+    return iReportRoot;
+    }
+
+// ---------------------------------------------------------------------------
+// SetLastCommandHandler
+// ---------------------------------------------------------------------------
+//
+void CConnectionInfo::SetLastCommandHandler(CHidDriver* aHidDriverItem)
+    {
+    iLastCmdDriver = aHidDriverItem;
+    }
+// ---------------------------------------------------------------------------
+// ReturnLastCommandHandler
+// ---------------------------------------------------------------------------
+//
+CHidDriver* CConnectionInfo::ReturnLastCommandHandler()
+    {
+    return iLastCmdDriver; 
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/src/hiddriveritem.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Driver list item implementation
+*
+*/
+
+
+#include <e32std.h>
+#include <e32base.h>
+#include <e32uid.h>
+
+#include "hiddriveritem.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+CDriverListItem::CDriverListItem(TInt aConnectionId)
+    : iConnectionId(aConnectionId)
+    {
+    }
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CDriverListItem::~CDriverListItem()
+    {
+    delete iDriver;    
+    }
+
+// ---------------------------------------------------------------------------
+// ConnectionId()
+// ---------------------------------------------------------------------------
+//
+TInt CDriverListItem::ConnectionId() const
+    {
+    return iConnectionId;
+    }
+
+// ---------------------------------------------------------------------------
+// Driver()
+// ---------------------------------------------------------------------------
+//
+CHidDriver* CDriverListItem::Driver() const
+    {
+    return iDriver;
+    }
+
+// ---------------------------------------------------------------------------
+// SetDriver()
+// ---------------------------------------------------------------------------
+//
+void CDriverListItem::SetDriver(CHidDriver* aDriver)
+    {
+    delete iDriver;
+    iDriver = aDriver;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/src/hidfield.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,638 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Hid field implementation
+*
+*/
+
+
+#include <e32std.h>
+#include <e32base.h>
+#include <e32des8.h>
+#include <e32svr.h>
+
+#include "hidreportroot.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// NewL()
+// ---------------------------------------------------------------------------
+//
+CField* CField::NewL()
+    {
+    CField* self = NewLC();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// NewLC()
+// ---------------------------------------------------------------------------
+//
+CField* CField::NewLC()
+    {
+    // Two-phase construction isn't necessary at present:
+    CField* self = new (ELeave) CField;
+    CleanupStack::PushL(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CField()
+// ---------------------------------------------------------------------------
+//
+CField::CField()
+    {
+    // nothing else to do
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CField::~CField()
+    {
+    iUsageList.Close();
+    }
+
+// ---------------------------------------------------------------------------
+// UsagePage()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CField::UsagePage() const
+    {
+    return iUsagePage;
+    }
+
+// ---------------------------------------------------------------------------
+// ReportId()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CField::ReportId() const
+    {
+    return iReportId;
+    }
+
+// ---------------------------------------------------------------------------
+// Offset()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CField::Offset() const
+    {
+    return (iReportId == 0) ? iPos : (iPos+KSizeOfByte);
+    }
+
+// ---------------------------------------------------------------------------
+// Size()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CField::Size() const
+    {
+    return iSize;
+    }
+
+// ---------------------------------------------------------------------------
+// Count()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CField::Count() const
+    {
+    return iCount;
+    }
+
+// ---------------------------------------------------------------------------
+// LogicalMin()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CField::LogicalMin() const
+    {
+    return iLogicalMin;
+    }
+
+// ---------------------------------------------------------------------------
+// LogicalMax()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CField::LogicalMax() const
+    {
+    return iLogicalMax;
+    }
+
+// ---------------------------------------------------------------------------
+// UsageMin()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CField::UsageMin() const
+    {
+    return iUsageMin;
+    }
+
+// ---------------------------------------------------------------------------
+// UsageMax()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CField::UsageMax() const
+    {
+    return iUsageMax;
+    }
+
+// ---------------------------------------------------------------------------
+// PhysicalMin()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CField::PhysicalMin() const
+    {
+    return iPhysicalMin;
+    }
+
+// ---------------------------------------------------------------------------
+// PhysicalMax()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CField::PhysicalMax() const
+    {
+    return iPhysicalMax;
+    }
+
+// ---------------------------------------------------------------------------
+// Unit()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CField::Unit() const
+    {
+    return iUnit;
+    }
+
+// ---------------------------------------------------------------------------
+// UnitExponent()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CField::UnitExponent() const
+    {
+    return iUnitExponent;
+    }
+
+// ---------------------------------------------------------------------------
+// DesignatorIndex()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CField::DesignatorIndex() const
+    {
+    return iDesignatorIndex;
+    }
+
+// ---------------------------------------------------------------------------
+// DesignatorMin()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CField::DesignatorMin() const
+    {
+    return iDesignatorMin;
+    }
+
+// ---------------------------------------------------------------------------
+// DesignatorMax()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CField::DesignatorMax() const
+    {
+    return iDesignatorMax;
+    }
+
+// ---------------------------------------------------------------------------
+// StringMin()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CField::StringMin() const
+    {
+    return iStringMin;
+    }
+
+// ---------------------------------------------------------------------------
+// StringMax()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CField::StringMax() const
+    {
+    return iStringMax;
+    }
+
+// ---------------------------------------------------------------------------
+// StringIndex()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CField::StringIndex() const
+    {
+    return iStringIndex;
+    }
+
+// ---------------------------------------------------------------------------
+// UsageArray()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TArray<TInt> CField::UsageArray() const
+    {
+    return iUsageList.Array();
+    }
+
+// ---------------------------------------------------------------------------
+// HasUsage()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TBool CField::HasUsage(const TInt aUsage) const
+    {
+    return iUsageList.Find(aUsage) != KErrNotFound;
+    }
+
+// ---------------------------------------------------------------------------
+// AddUsageL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::AddUsageL(const TInt aUsage)
+    {
+    User::LeaveIfError(iUsageList.Append(aUsage));
+    }
+
+// ---------------------------------------------------------------------------
+// ClearUsageList()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::ClearUsageList()
+    {
+    iUsageList.Reset();
+    }
+
+// ---------------------------------------------------------------------------
+// LastUsage()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CField::LastUsage() const
+    {
+    TInt usage = 0;
+    if (iUsageList.Count() > 0)
+        {
+        usage = iUsageList[iUsageList.Count()-1];
+        }
+    return usage;
+    }
+
+// ---------------------------------------------------------------------------
+// Attributes()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TUint32 CField::Attributes() const
+    {
+    return iAttributes;
+    }
+
+// ---------------------------------------------------------------------------
+// Type()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CField::TType CField::Type() const
+    {
+    return iType;
+    }
+
+// ---------------------------------------------------------------------------
+// IsVariable()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TBool CField::IsVariable() const
+    {
+    return (( iAttributes & KFieldAttributeVariable ) != 0);
+    }
+
+// ---------------------------------------------------------------------------
+// IsArray()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TBool CField::IsArray() const
+    {
+    return ( ( iAttributes & KFieldAttributeVariable ) == 0);
+    }
+
+// ---------------------------------------------------------------------------
+// IsConstant()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TBool CField::IsConstant() const
+    {
+    return (( iAttributes & KFieldAttributeConstant ) != 0 );
+    }
+
+// ---------------------------------------------------------------------------
+// IsData()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TBool CField::IsData() const
+    {
+    // Field atribute first bit present if data is constat or is it data.
+    // If first bit is zero field attibute data is set.
+    return ( ( iAttributes & KFieldAttributeConstant ) == 0 );
+    }
+
+// ---------------------------------------------------------------------------
+// SetType()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetType(const TType& aType)
+    {
+    iType = aType;
+    }
+
+// ---------------------------------------------------------------------------
+// SetUsagePage()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetUsagePage(const TInt aUsagePage)
+    {
+    iUsagePage = aUsagePage;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetReportId(const TInt aId)
+    {
+    iReportId = aId;
+    }
+
+// ---------------------------------------------------------------------------
+// SetOffset()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetOffset(const TInt aOffset)
+    {
+    iPos = aOffset;
+    }
+
+// ---------------------------------------------------------------------------
+// SetSize()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetSize(const TInt aSize)
+    {
+    iSize = aSize;
+    }
+
+// ---------------------------------------------------------------------------
+// SetCount()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetCount(const TInt aCount)
+    {
+    iCount = aCount;
+    }
+
+// ---------------------------------------------------------------------------
+// SetLogicalMin()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetLogicalMin(const TInt aMin)
+    {
+    iLogicalMin = aMin;
+    }
+
+// ---------------------------------------------------------------------------
+// SetLogicalMax()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetLogicalMax(const TInt aMax)
+    {
+    iLogicalMax = aMax;
+    }
+
+// ---------------------------------------------------------------------------
+// SetUsageMin()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetUsageMin(const TInt aMin)
+    {
+    iUsageMin = aMin;
+    }
+
+// ---------------------------------------------------------------------------
+// SetUsageMax()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetUsageMax(const TInt aMax)
+    {
+    iUsageMax = aMax;
+    }
+
+// ---------------------------------------------------------------------------
+// SetAttributes()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetAttributes(const TUint32 aAttributes)
+    {
+    iAttributes = aAttributes;
+    }
+
+// ---------------------------------------------------------------------------
+// SetPhysicalMin()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetPhysicalMin(TInt aValue)
+    {
+    iPhysicalMin = aValue;
+    }
+
+// ---------------------------------------------------------------------------
+// SetPhysicalMax()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetPhysicalMax(TInt aValue)
+    {
+    iPhysicalMax = aValue;
+    }
+
+// ---------------------------------------------------------------------------
+// SetUnit()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetUnit(TInt aValue)
+    {
+    iUnit = aValue;
+    }
+
+// ---------------------------------------------------------------------------
+// SetUnitExponent()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetUnitExponent(TInt aValue)
+    {
+    iUnitExponent = aValue;
+    }
+
+// ---------------------------------------------------------------------------
+// SetDesignatorIndex()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetDesignatorIndex(TInt aValue)
+    {
+    iDesignatorIndex = aValue;
+    }
+
+// ---------------------------------------------------------------------------
+// SetDesignatorMin()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetDesignatorMin(TInt aValue)
+    {
+    iDesignatorMin = aValue;
+    }
+
+// ---------------------------------------------------------------------------
+// SetDesignatorMax()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetDesignatorMax(TInt aValue)
+    {
+    iDesignatorMax = aValue;
+    }
+
+// ---------------------------------------------------------------------------
+// SetStringMin()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetStringMin(TInt aValue)
+    {
+    iStringMin = aValue;
+    }
+
+// ---------------------------------------------------------------------------
+// SetStringMax()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetStringMax(TInt aValue)
+    {
+    iStringMax = aValue;
+    }
+
+// ---------------------------------------------------------------------------
+// SetStringIndex()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetStringIndex(TInt aValue)
+    {
+    iStringIndex = aValue;
+    }
+
+// ---------------------------------------------------------------------------
+// SetLogicalRange()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetLogicalRange(TInt aMin, TInt aMax)
+    {
+    iLogicalMin = aMin;
+    iLogicalMax = aMax;
+    }
+
+// ---------------------------------------------------------------------------
+// SetUsageRange()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetUsageRange(TInt aMin, TInt aMax)
+    {
+    iUsageMin = aMin;
+    iUsageMax = aMax;
+    }
+
+// ---------------------------------------------------------------------------
+// SetPhysicalRange
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetPhysicalRange(TInt aMin, TInt aMax)
+    {
+    iPhysicalMin = aMin;
+    iPhysicalMax = aMax;
+    }
+
+// ---------------------------------------------------------------------------
+// SetStringRange()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetStringRange(TInt aMin, TInt aMax)
+    {
+    iStringMin = aMin;
+    iStringMax = aMax;
+    }
+
+// ---------------------------------------------------------------------------
+// SetDesignatorRange()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CField::SetDesignatorRange(TInt aMin, TInt aMax)
+    {
+    iDesignatorMin = aMin;
+    iDesignatorMax = aMax;
+    }
+
+// ---------------------------------------------------------------------------
+// IsInput()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TBool CField::IsInput() const
+    {
+    return iType == EInput;
+    }
+
+// ---------------------------------------------------------------------------
+// IsOutput()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TBool CField::IsOutput() const
+    {
+    return iType == EOutput;
+    }
+
+// ---------------------------------------------------------------------------
+// IsFeature()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TBool CField::IsFeature() const
+    {
+    return iType == EFeature;
+    }
+
+// ---------------------------------------------------------------------------
+// UsageCount()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CField::UsageCount() const
+    {
+    return iUsageList.Count();
+    }
+
+// ---------------------------------------------------------------------------
+// Usage()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CField::Usage(TInt aIndex) const
+    {
+    return iUsageList[aIndex];
+    }
+
+// ---------------------------------------------------------------------------
+// IsInReport()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TBool CField::IsInReport(TInt aReportId) const
+    {
+    return ( 0 == iReportId || aReportId == iReportId );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/src/hidgeneric.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,533 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Generic hid implementation
+*
+*/
+
+#include <e32std.h>
+
+#include "debug.h"
+#include "hidgeneric.h"
+#include "hidreportroot.h"
+#include "hidparser.h"
+#include "hiddriveritem.h"
+#include "hidconnectioninfo.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// NewLC
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CGenericHid* CGenericHid::NewLC(MTransportLayer* aTransportLayer)
+    {
+    TRACE_INFO((_L("[HID]\tCGenericHid::NewLC(0x%08x)"), aTransportLayer));
+    CGenericHid* self = new (ELeave) CGenericHid(aTransportLayer);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// NewL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CGenericHid* CGenericHid::NewL(MTransportLayer* aTransportLayer)
+    {
+    TRACE_INFO((_L("[HID]\tCGenericHid::NewL(0x%08x)"), aTransportLayer));
+	CGenericHid* self = NewLC(aTransportLayer);
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CGenericHid::ConstructL()
+    {
+    TRACE_INFO(_L("[HID]\tCGenericHid::ConstructL()"));
+    TRACE_INFO(_L("[HID]\tCGenericHid::ConstructL(): Creating Parser..."));
+    iParser = CParser::NewL();
+    iInputHandlingReg = CHidInputDataHandlingReg::NewL();
+    }
+
+// ---------------------------------------------------------------------------
+// CGenericHid()
+// ---------------------------------------------------------------------------
+//
+CGenericHid::CGenericHid(MTransportLayer* aTransportLayer) :
+    iDriverList(_FOFF(CDriverListItem, iSlink)),
+    iTransportLayer(aTransportLayer)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CGenericHid::~CGenericHid()
+    {
+    TRACE_FUNC_ENTRY
+    RemoveDrivers();
+    iConnectionInfo.ResetAndDestroy();
+    iConnectionInfo.Close();
+    delete iInputHandlingReg;
+    delete iParser;
+    REComSession::FinalClose();
+    TRACE_FUNC_EXIT
+    }
+
+// ---------------------------------------------------------------------------
+// From MDriverAccess
+// CountryCodeL
+// ---------------------------------------------------------------------------
+//
+TUint CGenericHid::CountryCodeL(TInt aConnID)
+    {
+    // Pass the request through to the transport layer.
+    return (iTransportLayer->CountryCodeL(aConnID));
+    }
+
+// ---------------------------------------------------------------------------
+// From MDriverAccess
+// VendorIdL
+// ---------------------------------------------------------------------------
+//
+TUint CGenericHid::VendorIdL(TInt aConnID)
+    {
+    // Pass the request through to the transport layer.
+    return (iTransportLayer->VendorIdL(aConnID));
+    }
+
+// ---------------------------------------------------------------------------
+// From MDriverAccess
+// ProductIdL()
+// ---------------------------------------------------------------------------
+//
+TUint CGenericHid::ProductIdL(TInt aConnID)
+    {
+    // Pass the request through to the transport layer.
+    return iTransportLayer->ProductIdL(aConnID);
+    }
+
+// ---------------------------------------------------------------------------
+// From MDriverAccess
+// SetProtocol
+// ---------------------------------------------------------------------------
+//
+void CGenericHid::SetProtocolL(TInt aConnectionId, TUint16 aInterface,
+                              MDriverAccess::TProtocols aProtocol, 
+                              CHidDriver* aDriver)
+    {
+    iTransportLayer->SetProtocolL(aConnectionId, static_cast<TUint16>(aProtocol), 
+            aInterface);    
+    CConnectionInfo* conninfo = SeekConnectionInfo( aConnectionId );
+        if ( conninfo )
+            {
+            conninfo->SetLastCommandHandler(aDriver);
+            }          
+    }
+
+// ---------------------------------------------------------------------------
+// From MDriverAccess
+// GetProtocol
+// ---------------------------------------------------------------------------
+//
+void CGenericHid::GetProtocolL(TInt aConnectionId,TUint16 aInterface)
+    {
+    iTransportLayer->GetProtocolL(aConnectionId, aInterface);    
+    }
+
+// ---------------------------------------------------------------------------
+// From MDriverAccess
+// GetReport
+// ---------------------------------------------------------------------------
+//
+void CGenericHid::GetReportL(TInt aConnectionId,
+    TUint8 aReportId, TUint16 aInterface, TUint16 aLength)
+    {
+    iTransportLayer->GetReportL(aConnectionId, MDriverAccess::EInput, aReportId, 
+            aInterface, aLength);    
+    }
+
+// ---------------------------------------------------------------------------
+// From MDriverAccess
+// SetReport()
+// ---------------------------------------------------------------------------
+//
+void CGenericHid::SetReportL(TInt aConnectionId, TUint8 aReportId,
+    MDriverAccess::TReportType aReportType, const TDesC8& aPayload,
+    TUint16 aInterface, CHidDriver* aDriver)
+    {
+    iTransportLayer->SetReportL(aConnectionId, static_cast<TUint8>(aReportType),
+        aReportId, aInterface, aPayload);    
+    CConnectionInfo* conninfo = SeekConnectionInfo( aConnectionId );
+        if ( conninfo )
+            {
+            conninfo->SetLastCommandHandler(aDriver);
+            }          
+    }
+
+// ---------------------------------------------------------------------------
+// From MDriverAccess
+// DataOut()
+// ---------------------------------------------------------------------------
+//
+void CGenericHid::DataOutL(TInt aConnectionId, TUint8 aReportId,
+                          const TDesC8& aPayload,
+                          TUint16 aInterface)
+    {
+    iTransportLayer->DataOutL(aConnectionId, aReportId, aInterface, aPayload);    
+    }
+
+
+// ---------------------------------------------------------------------------
+// From MDriverAccess
+// GetIdle()
+// ---------------------------------------------------------------------------
+//
+void CGenericHid::GetIdleL(TInt aConnectionId, TUint8 aReportId,
+    TUint16 aInterface )
+    {
+    iTransportLayer->GetIdleL(aConnectionId, aReportId, aInterface);    
+    }
+
+// ---------------------------------------------------------------------------
+// From MDriverAccess
+// SetIdle()
+// ---------------------------------------------------------------------------
+//
+void CGenericHid::SetIdleL(TInt aConnectionId, TUint8 aDuration,
+    TUint8 aReportId, TUint16 aInterface, CHidDriver* aDriver)
+    {
+    iTransportLayer->SetIdleL(aConnectionId, aDuration, aReportId, aInterface);
+    CConnectionInfo* conninfo = SeekConnectionInfo( aConnectionId );
+    if ( conninfo )
+        {
+        conninfo->SetLastCommandHandler(aDriver);
+        }          
+                       
+    }
+
+// ---------------------------------------------------------------------------
+// RemoveDrivers()
+// ---------------------------------------------------------------------------
+//
+void CGenericHid::RemoveDrivers()
+    {
+    TRACE_FUNC
+    // Driver instances
+    CDriverListItem* driverItem;
+    while ( !iDriverList.IsEmpty() )
+        {
+        driverItem = iDriverList.Last();
+        iDriverList.Remove( *driverItem );
+        delete driverItem;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// From CHidTransport
+// Disconnected()
+// ---------------------------------------------------------------------------
+//
+TInt CGenericHid::Disconnected( TInt aConnectionId )
+    {
+    TRACE_FUNC_ENTRY
+    TInt retVal = KErrNone;
+    
+    TSglQueIter<CDriverListItem> driverIter( iDriverList );
+    driverIter.SetToFirst();    
+
+    CDriverListItem* driverItem = driverIter;    
+    while ( driverItem )
+        {            
+        driverIter++;    
+        if ( driverItem->ConnectionId() == aConnectionId )
+            {
+            TRACE_INFO(_L("[HID]\tCGenericHid::Disconnected driver"));
+            if (driverItem->Driver())
+                {
+                driverItem->Driver()->Disconnected(0);
+                }
+            // Remove it from the list of driver instances           
+            
+            iDriverList.Remove(*driverItem);
+            delete driverItem;
+            driverItem = NULL;
+            retVal = KErrNone;
+            }                                  
+        driverItem = driverIter;
+        
+        TRACE_INFO(_L("[HID]\tCGenericHid::Disconnected next driver"));
+        }
+    TRACE_INFO(_L("[HID]\tCGenericHid::Disconnected remove connection info"));
+    TInt count = iConnectionInfo.Count();
+    for (TInt i = count-1 ; i>=0; i--)
+        {
+        TRACE_INFO((_L("[HID]\tCGenericHid::Disconnected remove connection info %d"),i));
+        CConnectionInfo* conninfo = iConnectionInfo[i];
+        TRACE_INFO((_L("[HID]\tCGenericHid::Disconnected remove connection info %d"),i));
+        if ( conninfo->ConnectionID() == aConnectionId )                
+            {
+            iConnectionInfo.Remove(i);
+            delete conninfo;
+            TRACE_INFO((_L("[HID]\tCGenericHid::Disconnected remove connection info %d removed"),i));
+            }
+        }     
+    TRACE_FUNC_EXIT
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// From CHidTransport
+// ConnectedL
+// HID device has been connected.  Attempt to find a driver that can
+// handle reports in the format specified by the report descriptor.
+// ---------------------------------------------------------------------------
+//
+TInt CGenericHid::ConnectedL( TInt aConnectionId, const TDesC8& aDescriptor )
+    {
+    TRACE_INFO((_L("[HID]\tCGenericHid::ConnectedL(%d, ...)"), aConnectionId))    
+    
+    // Place the parsed report descriptor in the driver list item:
+    
+    TBool found = EFalse;
+    CConnectionInfo* conninfo = SeekConnectionInfo( aConnectionId );
+    if ( conninfo )
+        {
+        return KErrInUse;    
+        }
+    
+    CReportRoot* reportRoot = iParser->ParseL( aDescriptor );
+    CleanupStack::PushL(reportRoot);
+        
+    TRACE_INFO(_L("[HID]\tCGenericHid::ConnectedL: evaluate driver array"));
+    // Implementation info array
+    RImplInfoPtrArray implInfoArray;
+    REComSession::ListImplementationsL( KHidDriverPluginInterfaceUid, implInfoArray );
+    CleanupClosePushL(implInfoArray);    
+    
+    TRACE_INFO((_L("[HID]\tCGenericHid::ConnectedL: %d implementations found"), implInfoArray.Count()));
+    TInt index = 0;
+    TInt retVal = KErrHidNoDriver;
+    TInt supportedfields = 0;
+    CHidDriver* driver = NULL;
+    for ( index  = 0; index < implInfoArray.Count(); index++ )
+        {
+        // parse implementation UID
+        CImplementationInformation* info = implInfoArray[ index  ];
+        TUid implUid = info->ImplementationUid();
+        TRACE_INFO((_L("[HID]\tCGenericHid::ConnectedL: load plugin 0x%08x"),implUid ));
+        // load driver
+        // Trap so other drivers will be enumerated even if
+        // this fails:
+
+        TRAPD(retTrap, driver = CHidDriver::NewL( implUid, this ));
+        if ( retTrap != KErrNone)
+            {
+            continue;    
+            }
+        CleanupStack::PushL(driver);
+        TRACE_INFO((_L("[HID]\tCGenericHid::ConnectedL: init plugin 0x%08x"),implUid ));
+        driver->InitialiseL( aConnectionId );
+        TInt ret = driver->CanHandleReportL( reportRoot );
+        if (ret == KErrNone)
+            {
+            TRACE_INFO(_L("[HID]\tCGenericHid::ConnectedL(): found driver"));            
+	        
+	        // Make a new driver list item:
+	        CDriverListItem* driverItem = new ( ELeave ) CDriverListItem( aConnectionId );	        
+	        CleanupStack::PushL( driverItem );	                
+	        driver->SetInputHandlingReg( iInputHandlingReg );
+	        supportedfields += driver->SupportedFieldCount();	        
+            iDriverList.AddLast( *driverItem );
+            CleanupStack::Pop( driverItem );
+            driverItem->SetDriver( driver );    
+            CleanupStack::Pop( driver );
+            retVal = KErrNone;
+            found = ETrue;
+            }
+        else
+        	{
+ 	        CleanupStack::PopAndDestroy( driver );
+        	}
+        }
+    TRACE_INFO((_L("[HID]\tCGenericHid::ConnectedL Partial supported hid device supported %d in report %d&"),supportedfields,iParser->FieldCount()));
+    if (supportedfields < iParser->FieldCount() && found )
+        {
+        TRACE_INFO(_L("[HID]\tCGenericHid::ConnectedL Partial supported hid device"));
+        }
+    implInfoArray.ResetAndDestroy();     
+    CleanupStack::PopAndDestroy();  // info
+    if ( found )
+        {   
+        TRACE_INFO(_L("[HID]\tCGenericHid::ConnectedL append connection info"));    
+        conninfo = CConnectionInfo::NewL(aConnectionId, reportRoot);
+        CleanupStack::Pop(reportRoot); // ownership transfered to conninfo        
+        CleanupStack::PushL(conninfo);
+        iConnectionInfo.AppendL(conninfo);
+        CleanupStack::Pop(conninfo);
+        }         
+    else
+        {
+        CleanupStack::PopAndDestroy(reportRoot);     
+        }
+    
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// From CHidTransport
+// DataIn
+// Determine which driver is handling this connection ID and pass the payload
+// reference to it
+// ---------------------------------------------------------------------------
+//
+TInt CGenericHid::DataIn(TInt aConnectionId,
+    CHidTransport::THidChannelType aChannel, const TDesC8& aPayload)
+    {
+    TRACE_FUNC_ENTRY
+    TInt retVal = KErrHidNoDriver;
+    TInt ret = KErrNone;
+    
+    TSglQueIter<CDriverListItem> driverIter( iDriverList );
+    driverIter.SetToFirst();    
+
+    CDriverListItem* item = driverIter;
+    TBool found = EFalse; 
+    while ( item )
+        {            
+        if ( item->ConnectionId() == aConnectionId )
+                {                
+                ret = item->Driver()->DataIn( aChannel, aPayload );
+                if (ret == KErrNone)
+                    {
+                    TRACE_INFO(_L("[HID]\tCGenericHid::DataIn command handled"));
+                    found = ETrue;
+                    retVal = KErrNone;
+                    }
+                }
+         TRACE_INFO(_L("[HID]\tCGenericHid::DataIn next driver"));
+         driverIter++;
+         item = driverIter;
+         }
+    if ( !found && aChannel == CHidTransport::EHidChannelCtrl )
+        {
+        retVal = KErrNone;
+        }
+    iInputHandlingReg->Reset();    
+    TRACE_FUNC_EXIT    
+    return retVal;
+    }
+
+
+// ---------------------------------------------------------------------------
+// ReportDescriptor
+// Provides access to the parsed results to the factory
+// ---------------------------------------------------------------------------
+//
+CReportRoot* CGenericHid::ReportDescriptor(TInt aConnectionId)
+    {
+    CConnectionInfo* conninfo = SeekConnectionInfo( aConnectionId );
+    if ( conninfo )
+        {
+        return conninfo->ReportRoot();
+        }
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// From CHidTransport
+// DriverActive()
+// ---------------------------------------------------------------------------
+//
+TInt CGenericHid::DriverActive(TInt aConnectionId,
+    CHidTransport::TDriverState aActive)
+    {
+    TRACE_FUNC_ENTRY
+    TInt retVal = KErrHidNoDriver;    
+    // Find the driver handling the connection and stop it    
+    TSglQueIter<CDriverListItem> driverIter( iDriverList );
+    driverIter.SetToFirst();  
+    CDriverListItem* item = driverIter;
+    
+    while ( item )
+        {
+        TRACE_INFO(_L("[HID]\tCGenericHid::DriverActive"));        
+        if ( item->ConnectionId() == aConnectionId && item->Driver() )
+            {
+            TRACE_INFO(_L("[HID]\tCGenericHid::DriverActive driver found"));
+            if ( aActive == CHidTransport::EActive )
+                {
+                TRAP(retVal, item->Driver()->StartL( aConnectionId ));
+                if (retVal != KErrNone)
+                    {
+                    break;
+                    }
+                }
+            else if ( aActive == CHidTransport::ESuspend)
+                {
+                item->Driver()->Stop();
+                retVal = KErrNone;
+                }            
+            }   
+         driverIter++;
+         item = driverIter;
+         }
+    TRACE_FUNC_EXIT
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// CommandResult()
+// ---------------------------------------------------------------------------
+//
+void CGenericHid::CommandResult(TInt aConnectionId, TInt aCmdAck)
+    {
+    // Get the driver handling this connection    
+    CConnectionInfo* conninfo = SeekConnectionInfo( aConnectionId );
+    if ( conninfo )
+        {
+        CHidDriver*  hiddriver = conninfo->ReturnLastCommandHandler();
+        if (hiddriver)
+            {
+            hiddriver->CommandResult(aCmdAck);
+            }
+        }    
+    }
+
+// ---------------------------------------------------------------------------
+// SeekConnectionInfo()
+// ---------------------------------------------------------------------------
+//
+CConnectionInfo* CGenericHid::SeekConnectionInfo(TInt aConnectionId)
+    {
+    TRACE_FUNC    
+    CConnectionInfo* conninfo = NULL;
+    TInt count = iConnectionInfo.Count();
+    TRACE_INFO((_L("[HID]\tCGenericHid::SeekConnectionInfo count %d"), count));   
+    for (TInt i = 0 ; i < count; i++)
+        {
+        conninfo = iConnectionInfo[i];
+        TRACE_INFO((_L("[HID]\tCGenericHid::SeekConnectionInfo connection info check %d %d"),aConnectionId, conninfo->ConnectionID()));    
+        if ( conninfo->ConnectionID() == aConnectionId)                
+            {
+            TRACE_INFO(_L("[HID]\tCGenericHid::SeekConnectionInfo connection info found"));    
+            return conninfo;
+            }
+        }
+    return NULL;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/src/hidinterfaces.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,135 @@
+/*
+* Copyright (c) 2007-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Hid interface implementation
+*
+*/
+
+
+#include <hidinterfaces.h>
+
+// -----------------------------------------------------------------------------
+// Constructor
+// -----------------------------------------------------------------------------
+//    
+EXPORT_C CHidDriver::CHidDriver()
+     {
+     }
+
+// -----------------------------------------------------------------------------
+// Desturctor
+// -----------------------------------------------------------------------------
+//     
+EXPORT_C CHidDriver::~CHidDriver()
+    {    
+    REComSession::DestroyedImplementation( iDtor_ID_Key );
+    }
+
+// -----------------------------------------------------------------------------
+// NewL()
+// -----------------------------------------------------------------------------
+//  
+EXPORT_C CHidDriver* CHidDriver::NewL( 
+    TUid aImplementationUid,
+    MDriverAccess* aHid )
+    {
+    TAny* ptr;
+    TInt32 keyOffset = _FOFF( CHidDriver, iDtor_ID_Key );   
+    ptr = REComSession::CreateImplementationL(
+        aImplementationUid,
+        keyOffset,
+        aHid
+        );    
+    return reinterpret_cast<CHidDriver*> (ptr);
+    }    
+    
+
+// -----------------------------------------------------------------------------
+// NewL()
+// -----------------------------------------------------------------------------
+//      
+CHidInputDataHandlingReg* CHidInputDataHandlingReg::NewL()
+    {
+    CHidInputDataHandlingReg* self = new (ELeave) CHidInputDataHandlingReg();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );    
+    return self;    
+    
+    }    
+    
+// -----------------------------------------------------------------------------
+// Constructor
+// -----------------------------------------------------------------------------
+//      
+CHidInputDataHandlingReg::CHidInputDataHandlingReg()
+    {        
+    }        
+
+// -----------------------------------------------------------------------------
+// Constructor
+// -----------------------------------------------------------------------------
+//      
+void CHidInputDataHandlingReg::ConstructL()
+    {        
+    iEventArray =  new ( ELeave ) CArrayFixFlat<THidEvent>( 2 );    
+    }        
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+//      
+CHidInputDataHandlingReg::~CHidInputDataHandlingReg()
+    { 
+    Reset();           
+    delete iEventArray;
+    }       
+
+// -----------------------------------------------------------------------------
+// AddHandledEvent
+// -----------------------------------------------------------------------------
+//    
+EXPORT_C void  CHidInputDataHandlingReg::AddHandledEvent( TInt aUsagePage, TInt aUsage )
+    {
+    THidEvent event;
+    event.iUsagePage = aUsagePage;    
+    event.iKeyCode = aUsage;
+    TRAP_IGNORE(iEventArray->AppendL( event ));
+    }
+
+// -----------------------------------------------------------------------------
+// AllowedToHandleEvent
+// -----------------------------------------------------------------------------
+//        
+EXPORT_C TBool  CHidInputDataHandlingReg::AllowedToHandleEvent(TInt aUsagePage, TInt aUsage)
+    {
+    TInt i;    
+    for (i = 0; i< iEventArray->Count() ;i++)
+        {
+        if ( iEventArray->At(i).iUsagePage == aUsagePage && iEventArray->At(i).iKeyCode == aUsage )
+            {
+            return EFalse;    
+            }
+        }   
+    return ETrue;     
+    }    
+   
+// -----------------------------------------------------------------------------
+// Reset
+// -----------------------------------------------------------------------------
+//      
+void  CHidInputDataHandlingReg::Reset()
+    {
+    iEventArray->Reset();    
+    }
+
+    
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/src/hiditem.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,263 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Item implementation
+*
+*/
+
+
+// References:
+//
+// [1] USB Device Class Definition for Human Interface Devices (HID),
+//     Firmware Specification, Version 1.11, USB Implementers' Forum,
+//     June 2001
+//
+// ----------------------------------------------------------------------
+
+#include <e32std.h>
+
+#include "hiditem.h"
+#include "hidparser.h"
+
+const TInt KSizeMask        = 0x03;
+const TInt KTypeMask        = 0x03;
+const TInt KTypePosn        = 2;
+const TInt KTagMask         = 0x0F;
+const TInt KTagPosn         = 4;
+const TInt KLongItemId      = 0xfe;
+const TInt KMaxItemlength   = 4;
+const TInt KSizeThree       = 3;
+const TInt KSizeFour        = 4;
+const TInt KLongItemMin     = 3;
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+TItem::TItem(const TDesC8& aRawData)
+    : iRawData(aRawData)
+    {    
+    if (aRawData.Length() < 1)
+        {
+        return;
+        }
+    TBool isShortItem = (aRawData[0] != KLongItemId);
+
+    if (isShortItem)
+        {
+        //  +----+----+----+----+----+----+----+----+
+        //  |        Tag        |   Type  |  Size   |    [data...]
+        //  |    .    .    .    |    .    |    .    |
+        //  +----+----+----+----+----+----+----+----+
+        //    7    6    5    4    3    2    1     0
+        //
+        // A short item is followed by 0, 1, 2 or 4 bytes of data, as
+        // specified in the size field. See [1], Section 6.2.2.2.        
+        iSize = aRawData[0] & KSizeMask;
+        if (iSize == KSizeThree)
+            {
+            iSize = KSizeFour;
+            }        
+        iType = static_cast<TItemType>((aRawData[0] >> KTypePosn) & KTypeMask);
+        iTag = (aRawData[0] >> KTagPosn) & KTagMask;
+        iDataOffset = 1;
+        }
+    else
+        {
+        //        Byte 0               Byte 1          Byte 2
+        // +------+------+------+   +-----------+   +-----------+
+        // | Tag  | Type | Size |   | Data size |   | Long item |   [data...]
+        // | 1111 |  11  |  10  |   |  (0-255)  |   |    tag    |
+        // +------+------+------+   +-----------+   +-----------+
+        //   7654    32     10
+        //
+        // A long item is followed by 0-255 bytes of data, as specified
+        // in the data size byte. See [1], Section 6.2.2.3.
+
+        iType = EReserved;
+
+        if (aRawData.Length() > KLongItemMin)
+            {
+            iSize = aRawData[1];
+            iTag = aRawData[2];
+            iDataOffset = KLongItemMin;
+            }
+        else
+            {
+            iSize = 0;
+            iTag = 0;
+            iDataOffset = 0;
+            }
+        }
+
+#ifdef DBG_ACTIVE
+    for (TInt i=0; (i<aRawData.Length()) && (i<(iSize+iDataOffset)); ++i)
+        {
+        RDebug::Print(_L("aRawData[%d] = 0x%02x"), i, aRawData[i]);
+        }
+#endif
+    }
+
+// ---------------------------------------------------------------------------
+// DataSize()
+// ---------------------------------------------------------------------------
+//
+TInt TItem::DataSize() const
+    {
+    return iSize;
+    }
+
+// ---------------------------------------------------------------------------
+// Tag()
+// ---------------------------------------------------------------------------
+//
+TInt TItem::Tag() const
+    {
+    return iTag;
+    }
+
+// ---------------------------------------------------------------------------
+// Data()
+// ---------------------------------------------------------------------------
+//
+TUint32 TItem::Data() const
+    {
+    TInt size = DataSize();
+
+    // Calling Data() makes no sense for long items that have a data
+    // size over 4 bytes, as it only returns a TUint32:
+    //
+    if (size > KMaxItemlength)
+        {
+        size = KMaxItemlength;
+        }
+
+    // Ensure we don't overrun the source buffer:
+    //
+    if (size > (iRawData.Length() - 1))
+        {
+        size = iRawData.Length() - 1;
+        }
+
+    // Concatenate each byte into a TUint32.  Note that this function must
+    // return zero if the data size is zero (see Parser.cpp, MainItemL()).
+    //
+    TUint32 tagData = 0;
+    for (TInt i=0; i<size; ++i)
+        {
+        tagData |= (iRawData[1 + i] << (KSizeOfByte*i));
+        }
+
+    return tagData;
+    }
+
+// ---------------------------------------------------------------------------
+// SignedData()
+// ---------------------------------------------------------------------------
+//
+TInt32 TItem::SignedData() const
+    {
+    TUint32 data = Data();
+
+    // For 8 and 16 bit negative values, we need to
+    // sign extend to 32-bits:
+    //
+    if ((DataSize() == 1) && (data & 0x80))
+        {
+        data |= 0xffffff00;
+        }
+    if ((DataSize() == 2) && (data & 0x8000))
+        {
+        data |= 0xffff0000;
+        }
+
+    // Note that this assumes that the machine uses 2s complement
+    // representation internally.  All current Symbian devices do,
+    // including ARM devices and the WINS emulator. This is almost
+    // certain to remain the case in the future.
+    //
+    return static_cast<TInt32>(data);
+    }
+
+// ---------------------------------------------------------------------------
+// Operator []
+// ---------------------------------------------------------------------------
+//
+TUint8 TItem::operator[](TInt aIndex) const
+    {    
+
+    TUint8 value = 0;
+    if ((aIndex >= 0) && (aIndex < iSize))
+        {
+        value = iRawData[iDataOffset + aIndex];
+        }
+    return value;
+    }
+
+// ---------------------------------------------------------------------------
+// Type()
+// ---------------------------------------------------------------------------
+//
+TItem::TItemType TItem::Type() const
+    {
+    return iType;
+    }
+
+// ---------------------------------------------------------------------------
+// IsMain()
+// ---------------------------------------------------------------------------
+//
+TBool TItem::IsMain() const
+    {
+    return iType == TItem::EMain;
+    }
+
+// ---------------------------------------------------------------------------
+// IsLocal()
+// ---------------------------------------------------------------------------
+//
+TBool TItem::IsLocal() const
+    {
+    return iType == TItem::ELocal;
+    }
+
+// ---------------------------------------------------------------------------
+// IsGlobal()
+// ---------------------------------------------------------------------------
+//
+TBool TItem::IsGlobal() const
+    {
+    return iType == TItem::EGlobal;
+    }
+
+// ---------------------------------------------------------------------------
+// IsLong()
+// ---------------------------------------------------------------------------
+//
+TBool TItem::IsLong() const
+    {
+    return iType == TItem::EReserved;
+    }
+
+// ---------------------------------------------------------------------------
+// ItemSize()
+// ---------------------------------------------------------------------------
+//
+TInt TItem::ItemSize() const
+    {
+    return iSize + iDataOffset;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/src/hidparser.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1941 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  HID parser implementation
+*
+*/
+
+
+// ----------------------------------------------------------------------
+
+// References:
+//
+// [1] USB Device Class Definition for Human Interface Devices (HID),
+//     Firmware Specification, Version 1.11, USB Implementers' Forum,
+//     June 2001
+//
+// [2] HID Parser Error Codes (HID Parser Error Checking), Revision
+//     1.2, USB Implementers' Forum, February 2000
+//
+// [3] USB HID Usage Tables, Version 1.11, USB Implementers' Forum,
+//     June 2001
+//
+// ----------------------------------------------------------------------
+
+#include <e32std.h>
+#include <e32base.h>
+#include <e32des8.h>
+#include <e32svr.h>
+
+#include "hidreportroot.h"
+#include "hiditem.h"
+#include "hidparser.h"
+#include "debug.h"
+
+
+
+
+// ----------------------------------------------------------------------
+/*
+// Define PARSER_DEBUG to activate trace output for WINS debug builds:
+#undef PARSER_DEBUG
+
+#if defined(PARSER_DEBUG) && defined(_DEBUG) && defined(__WINS__)
+#define PDBG(a) a;
+#define PDBG_ACTIVE
+#else
+#define PDBG(a)
+#endif
+*/
+#define PDBG_ACTIVE
+
+const TUint32 CParser::KLocalItemMask =
+    EUsageMin | EUsageMax | EUsageId |
+    EDesignatorIndex | EDesignatorMin | EDesignatorMax |
+    EStringIndex | EStringMin | EStringMax;
+
+
+const TUint32 KMaxStandardType   = 0x06;
+const TUint32 KMinVendorType     = 0x80;
+const TUint32 KMaxVendorType     = 0xFF;
+const TUint32 KMaxUsagePage      = 0xffff;
+const TUint32 KUnitData          = 0x0f;
+
+const TUint32 CParser::KUnusedLocalItemsMask = KLocalItemMask & ~EUsageId;
+
+const TUint32 KInputReservedBitsMask    = 0xffffff00;
+const TUint32 KOutputReservedBitsMask   = 0xffffff00;
+const TUint32 KFeatureReservedBitsMask  = 0xffffff00;
+const TUint32 KUnitReservedBitsMask     = 0xf0000000;
+
+const TInt KConstantFlag    = 1<<0;  // Constant (1) or Data (0)
+const TInt KVariableFlag    = 1<<1;  // Array (0) or Variable (1)
+const TInt KNullStateFlag   = 1<<6;
+
+const TInt KExtendedDataSize  = 4;   // 32-bit extended data size
+const TInt KExtendedDataShift = 16;  // 16 bit shift if extended usage page is used
+const TInt KMaxReportIDMax    = 255;
+const TInt K32Bit             = 32;
+
+const TUint K32BitFirstBitOn   = 1u<<31;
+const TInt  KUnitSystemMin     = 5;
+const TInt  KUnitSystem15      = 15;
+
+const TUint32 CParser::KMandatoryItemMask = EUsagePage |
+        ELogicalMin | ELogicalMax | EReportSize | EReportCount;
+        
+const TUint32 CParser::KReportItemMask = EInputReport |
+                  EOutputReport | EFeatureReport;        
+
+
+// Reserved values as per the HUT document 1.11, [3]:
+// This ranges are reserverd in future use.
+
+const TInt KReservedUsage = 0x0e;
+const TInt KReservedUsageRange1Min = 0x11;
+const TInt KReservedUsageRange1Max = 0x13;
+const TInt KReservedUsageRange2Min = 0x15;
+const TInt KReservedUsageRange2Max = 0x3f;
+const TInt KReservedUsageRange3Min = 0x41;
+const TInt KReservedUsageRange3Max = 0x7f;
+const TInt KReservedUsageRange4Min = 0x88;
+const TInt KReservedUsageRange4Max = 0x8b;
+const TInt KReservedUsageRange5Min = 0x92;
+const TInt KReservedUsageRange5Max = 0xfeff;
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// NewLC()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CParser* CParser::NewLC()
+    {
+    CParser* self = new (ELeave) CParser;
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// NewL()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CParser* CParser::NewL()
+    {
+    CParser* self = NewLC();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CParser::ConstructL()
+    {
+    TRACE_FUNC_THIS
+    iLocal = CField::NewL();
+    }
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+CParser::CParser():
+    iFieldCount(0)
+    {
+    TRACE_FUNC_THIS
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CParser:: ~CParser()
+    {
+    TRACE_FUNC_THIS
+
+    // Free all RArray storage:
+    iGlobalStack.Reset();
+
+
+    // Although iCollectionStack is an RPointerArray, we aren't doing
+    // a ResetAndDestroy() here, as all the collections are owned by
+    // the report root object, iReportRoot:
+    iCollectionStack.Reset();
+
+    delete iReportRoot;
+    delete iLocal;
+    }
+
+// ---------------------------------------------------------------------------
+// CreateCollectionL
+// ---------------------------------------------------------------------------
+//
+TInt CParser::CreateCollectionL(TUint32 aType)
+    {
+    TInt err = CheckForCollectionErrors(aType);
+
+    if (err == KErrNone)
+        {
+        CCollection* collection = Collection()->AddCollectionL(); // Created collection added
+                                                                  // Collection's collection array
+        collection->SetType(aType);
+        collection->SetUsagePage(iGlobal.iUsagePage);
+        collection->SetUsage(iLocal->LastUsage());
+        PushCollectionL(collection);         
+        }
+    return err;
+    }
+
+// ---------------------------------------------------------------------------
+// CheckForMainErrors()
+// ---------------------------------------------------------------------------
+//
+TInt CParser::CheckForMainErrors()
+    {
+    if ( ( iItemsDefined & ELogicalMin ) && ( iItemsDefined & ELogicalMax ) )
+        {
+        if ( iGlobal.iLogicalMin > iGlobal.iLogicalMax )
+            {
+            IssueWarning( ELogicalMinExceedsMax );
+            }
+        }
+    if ( iItemsDefined & (EPhysicalMin | EPhysicalMax ) )
+        {
+        if ( !( iItemsDefined & EPhysicalMax ) )
+            {
+            return ELonelyPhysicalMin;
+            }
+        if (!( iItemsDefined & EPhysicalMin ))
+            {
+            return ELonelyPhysicalMax;
+            }
+
+        if ( iGlobal.iPhysicalMin > iGlobal.iPhysicalMax )
+            {
+            IssueWarning(EPhysicalMinExceedsMax);
+            }
+        }
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CheckForCollectionErrors()
+// ---------------------------------------------------------------------------
+//
+TInt CParser::CheckForCollectionErrors(TUint32 aType)
+    {    
+    if (iCollectionStack.Count() == 0 )
+        {
+        return ENoCollectionToCheck;
+        }
+
+    if (aType > KMaxStandardType)
+        {
+        if ((aType < KMinVendorType) || (aType > KMaxVendorType))
+            {
+            IssueWarning( ECollectionTypeUnknownReserved );
+            }
+        }
+    
+    if ( iItemsDefined & KUnusedLocalItemsMask )
+        {
+        IssueWarning( ECollectionLocalUnused );
+        }
+
+    TInt numUsages = iLocal->UsageCount();
+
+    if ( numUsages > 1 )
+        {
+        // Only a single usage value can be associated with a collection:
+        IssueWarning( ECollectionLocalUnused );
+        }
+
+    if ( numUsages == 0 )
+        {
+        // A usage tag must be associated with a collection (see [1],
+        // Section 6.2.2.6):
+        IssueWarning( ECollectionHasNoUsage );
+        }
+
+    if ( !( iItemsDefined & EUsagePage ) )
+        {
+        // A usage page must be associated with a collection (see [1],
+        // Section 6.2.2.6):
+        IssueWarning( ECollectionHasNoUsagePage );
+        }
+
+    if (( aType == CCollection::EApplication ) && ( iItemsDefined & EDelimiter ))
+        {
+        // Delimiters can't be used when defining usages that apply to
+        // Application Collections ([1], Section 6.2.2.8):
+        IssueWarning(EApplicationHasDelimiter);
+
+        // It is an error to declare a delimiter for a top-level
+        // application collection, [2]:
+        if (iCollectionStack.Count() == 1)
+            {
+            return EDelimiterAtTopLevel;
+            }
+        }
+    return CheckForMainErrors();
+    }
+
+
+// ---------------------------------------------------------------------------
+// CheckForFieldErrors()
+// ---------------------------------------------------------------------------
+//
+TInt CParser::CheckForFieldErrors(CField::TType aType, TUint32 aAttributes)
+    {  
+    TInt ret = KErrNone;
+    ret = CheckMandatoryFieldErrors(aType, aAttributes);
+    if ( ret != KErrNone )
+        {
+        return ret;    
+        }
+    
+    const TInt KLimitsError[] =
+        { EInputMinExceedsMax, EOutputMinExceedsMax, EFeatureMinExceedsMax };
+
+    if ( iGlobal.iLogicalMin > iGlobal.iLogicalMax )
+        {
+        return KLimitsError[aType];
+        }
+
+    if ( ( iItemsDefined & ( EPhysicalMin | EPhysicalMax ) )
+        && ( iGlobal.iPhysicalMin > iGlobal.iPhysicalMax ))
+        {
+        return KLimitsError[aType];
+        }   
+    CheckLogicalMinAndMax( aAttributes );     
+    CheckFieldBitNeeded( aType, aAttributes );
+    return CheckForMainErrors();
+    }
+
+
+// ---------------------------------------------------------------------------
+// BitsToRepresentRange()
+// ---------------------------------------------------------------------------
+//
+TInt CParser::BitsToRepresentRange(TInt aMin, TInt aMax)
+    {
+    // The number of bits required to represent all values in the
+    // range aMin to aMax inclusive.  If the range is all positive
+    // then there is no sign bit, otherwise twos complement format is
+    // assumed. ([1], Section 6.2.2.7.)
+
+    TInt bitsNeeded = 0;
+
+    if (aMin != aMax)
+        {
+        TUint absVal = static_cast<TUint>(Max(Abs(aMin), Abs(aMax)));
+
+        bitsNeeded = K32Bit - NumberOfLeadingZeros(absVal);
+
+        // If either are negative, we'll need space for the sign bit:
+        //
+        if ((aMax < 0) || (aMin < 0))
+            {
+            bitsNeeded++;
+
+            // However, 2s complement allows us to represent one extra
+            // negative number than positive, and so our calculation
+            // may be one bit over. Catch this with a special case:
+            //
+            if (bitsNeeded > 1)
+                {
+                TInt n = 1 << (bitsNeeded - 2);
+                if ((aMin == -n) && (aMax < n))
+                    {
+                    bitsNeeded--;
+                    }
+                }
+            }
+        }
+
+    return bitsNeeded;
+    }
+
+// ---------------------------------------------------------------------------
+// NumberOfLeadingZeros()
+// ---------------------------------------------------------------------------
+//
+TInt CParser::NumberOfLeadingZeros(TUint32 aValue)
+    {
+    TInt count = 0;
+
+    TUint32 pos = K32BitFirstBitOn;
+    while ((pos != 0) && ((aValue & pos) == 0))
+        {
+        count++;
+        pos >>= 1;
+        }
+
+    return count;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CheckAllReportSizes()
+// ---------------------------------------------------------------------------
+//
+TBool CParser::CheckAllReportSizes() const
+    {
+    // Final report sizes must be an integral number of bytes, [2]:
+
+    TBool sizesOk = ETrue;
+
+    for (TInt i=0; sizesOk && (i<iReportRoot->NumberOfReports()); ++i)
+        {
+        TInt bits = iReportRoot->ReportSize(i);
+
+        if ((bits == 0) || ((bits % 8) != 0))
+            {
+            sizesOk = EFalse;
+            }
+        }
+    return sizesOk;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CreateFieldL()
+// ---------------------------------------------------------------------------
+//
+TInt CParser::CreateFieldL(CField::TType aType, TUint32 aAttributes)
+    {
+    TInt err = CheckForFieldErrors( aType, aAttributes );
+    //Microsoft Elite 2 keyboard HID bug fix
+	if ( err == EInputMissingItems && iGlobal.iUsagePage == 0x07 )
+		if ( iLocal->UsageMin( ) == 0xe0 && iLocal->UsageMax( ) == 0xe7 )
+			{
+			iGlobal.iLogicalMin = 0x0;
+			iGlobal.iLogicalMax = 0x1;
+			err = KErrNone;
+			}
+		else
+			{
+			iGlobal.iLogicalMin = 0x0;
+			err = KErrNone;
+			}
+
+    if (err == KErrNone)
+        {
+        // Create a new field object:
+        CField* field = Collection()->AddFieldL( );   // Created field added
+                                                      // to collection's field array
+        DumpStateTableL( field );
+        field->SetType( aType );
+        field->SetAttributes( aAttributes );
+
+        // Set the field offset to the current report size, and
+        // increase the report size by the size of this field:        
+        if ( !iReportRoot )
+            {
+            User::Leave(ENoReportRoot);
+            }
+        field->SetOffset( iReportRoot->ReportSize( field->ReportId( ), aType) );
+        iReportRoot->IncrementReportSizeL( field->ReportId(),
+            aType, field->Count() * field->Size() );
+        TRACE_INFO(_L("CParser::CreateFieldL Field added"));
+        if ( field->UsageCount() )
+            {
+            iFieldCount++;
+            }        
+        }
+    return err;
+    }
+
+// ---------------------------------------------------------------------------
+// DumpStateTableL()
+// ---------------------------------------------------------------------------
+//
+void CParser::DumpStateTableL(CField *aField) const
+    {
+    TRACE_INFO((_L("DumpStateTableL(0x%08x)\n"), aField));
+
+    // Copy global state:
+    //
+    iGlobal.Populate(aField);
+
+    // Copy local state:
+    //
+    aField->SetUsageRange( iLocal->UsageMin(), iLocal->UsageMax() );
+    aField->SetDesignatorIndex( iLocal->DesignatorIndex() );
+    aField->SetDesignatorRange( iLocal->DesignatorMin(),
+        iLocal->DesignatorMax() );
+    aField->SetStringIndex( iLocal->StringIndex() );
+    aField->SetStringRange( iLocal->StringMin(), iLocal->StringMax() );
+
+    // Copy usage list (local state) and calculate the usage range, if
+    // it hasn't already been explicitly specified:
+    //
+    if ( iLocal->UsageCount() > 0 )
+        {
+        TInt minUsage, maxUsage;
+        minUsage = maxUsage = iLocal->Usage( 0 );
+
+        for (TInt i=0; i<iLocal->UsageCount(); ++i)
+            {
+            TInt value = iLocal->Usage( i );
+            aField->AddUsageL( value );
+            if ( value < minUsage )
+                {
+                minUsage = value;
+                }
+            if ( value > maxUsage )
+                {
+                maxUsage = value;
+                }
+            }
+        if ( (iItemsDefined & (EUsageMin | EUsageMax) ) == 0)
+            {
+            aField->SetUsageRange( minUsage, maxUsage );
+            }
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// Collection()
+// ---------------------------------------------------------------------------
+//
+CCollection* CParser::Collection()
+    {    
+    CCollection* lastcollection = NULL;
+    if ( iCollectionStack.Count( ) > 0 )
+        {
+        lastcollection = iCollectionStack[ iCollectionStack.Count() - 1 ];
+        }
+    return lastcollection;
+    }
+
+// ---------------------------------------------------------------------------
+// PushCollectionL()
+// ---------------------------------------------------------------------------
+//
+void CParser::PushCollectionL(const CCollection* aCollection)
+    {
+    User::LeaveIfError( iCollectionStack.Append( aCollection ) );
+    }
+
+// ---------------------------------------------------------------------------
+// PopCollection()
+// ---------------------------------------------------------------------------
+//
+void CParser::PopCollection()
+    {
+    
+    if ( iCollectionStack.Count() > 0 )
+        {
+        iCollectionStack.Remove( iCollectionStack.Count() - 1 );
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// IssueWarning()
+// ---------------------------------------------------------------------------
+//
+void CParser::IssueWarning(TInt aHidWarningCode)
+    {
+    TRACE_ERROR((_L("Item %3d: Warning 0x%04x\n"), iItemNumber, aHidWarningCode));
+    (void)aHidWarningCode;
+    }
+
+// ---------------------------------------------------------------------------
+// ParseL()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CReportRoot* CParser::ParseL(const TDesC8& aRawData)
+    {
+    ResetParserL();    
+    // Now we can parse the descriptor data:
+    const TInt length = aRawData.Length();
+    TInt posn = 0;
+    TRACE_INFO((_L("CParser::ParseL() Start parsing length %d"), length));
+    while ((posn < length) && (iErrorCode == 0))
+        {
+        iItemNumber++;
+        TRACE_INFO((_L("posn is %d"), posn));
+
+        TItem item(aRawData.Right(length-posn));
+
+#ifdef PDBG_ACTIVE
+        TRACE_INFO((_L("Item: size %d, tag %d, type %d\n"),
+                   item.DataSize(), item.Tag(), item.Type()));
+        for (TInt i=0; i<item.DataSize(); ++i)
+            {
+            TRACE_INFO((_L("  Data[%d] = 0x%02x (%d)\n"),
+                       i, item[i], item[i]))
+            }
+#endif
+
+        HandleItemL( item );        
+        posn += item.ItemSize();
+        if (posn > length)
+            {
+            iErrorCode = EInvalidItemLength;
+            }
+        }
+
+    PopCollection();
+
+    // PUSH without POP:
+    CheckParseErrors();
+
+    iGlobalStack.Reset();
+    iCollectionStack.Reset();
+
+    TRACE_INFO((_L("CParser::ParseL() error code is %d"), iErrorCode));
+    // Finished, transfer ownership to caller:
+    CReportRoot* reportRoot = iReportRoot;
+    iReportRoot = 0;
+    return reportRoot;
+    }
+
+// ---------------------------------------------------------------------------
+// CParser::FieldCount()
+// ---------------------------------------------------------------------------
+//
+TInt CParser::FieldCount()
+    {
+    return iFieldCount;
+    }
+
+// ---------------------------------------------------------------------------
+// CParser::MainItemL()
+// ---------------------------------------------------------------------------
+//
+TInt CParser::MainItemL(const TItem& aItem)
+    {
+    TInt retVal = 0;
+
+    switch (aItem.Tag())
+        {
+        case EMainInput:
+            retVal = HandleMainInputTagL( aItem );
+            break;
+
+        case EMainOutput:
+            retVal = HandleMainOutputTagL( aItem );
+            break;
+
+        case EMainFeature:
+            retVal = HandleMainFeatureL( aItem );
+            break;
+
+        case EMainCollection:
+            retVal = HandleMainCollectionL( aItem );
+            break;
+
+        case EMainEndCollection:
+            retVal = HandleMainEndCollection( aItem );
+            break;
+        default:
+            TRACE_ERROR(_L("Error: unknown main item\n"));
+            retVal = EUnknownItem;
+            break;
+        }
+
+    // All main items cause local state to be cleared:
+    ClearLocalState();
+
+    // For checking if global items declared more than once between
+    // main items:
+    iGlobalItemsDefined = 0;
+
+    return retVal;
+    }
+// ---------------------------------------------------------------------------
+// ClearLocalState()
+// ---------------------------------------------------------------------------
+//
+void CParser::ClearLocalState()
+    {
+    iLocal->ClearUsageList();
+    iLocal->SetUsageRange(0, 0);
+    iLocal->SetStringIndex(0);
+    iLocal->SetStringRange(0, 0);
+    iLocal->SetDesignatorIndex(0);
+    iLocal->SetDesignatorRange(0, 0);
+
+    iItemsDefined &= ~(KLocalItemMask | EDelimiter);
+    iLocalMultipleUse = EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// GlobalItemL()
+// ---------------------------------------------------------------------------
+//
+TInt CParser::GlobalItemL(const TItem& aItem)
+    {
+    TInt retVal = 0;
+    switch (aItem.Tag())
+        {
+        case EGlobalReportId:
+            retVal = HandleGlobalReportId( aItem );
+            break;
+        case EGlobalUsagePage:
+            retVal = HandleGlobalUsagePage( aItem );
+            break;
+        case EGlobalLogicalMinimum:
+            retVal = HandleGlobalLogicalMinimum( aItem );
+            break;
+        case EGlobalLogicalMaximum:
+            retVal = HandleGlobalLogicalMaximum( aItem );
+            break;
+        case EGlobalPhysicalMinimum:
+            retVal = HandleGlobalPhysicalMinimum( aItem );
+            break;
+        case EGlobalPhysicalMaximum:
+            retVal = HandleGlobalPhysicalMaximum( aItem );
+            break;
+        case EGlobalUnit:
+            retVal = HandleGlobalUnit( aItem );
+            break;
+        case EGlobalUnitExponent:
+            retVal = HandleGlobalUnitExponent( aItem );
+            break;
+        case EGlobalReportSize:
+            retVal = HandleGlobalReportSize( aItem );
+            break;
+        case EGlobalReportCount:
+            retVal = HandleGlobalReportCount(aItem );
+            break;
+        case EGlobalPush:
+            retVal = HandleGlobalPushL( aItem );
+            break;
+        case EGlobalPop:
+            retVal = HandleGlobalPop( aItem );
+            break;
+        default:
+            TRACE_ERROR(_L("Error: unknown global item\n"));
+            retVal = EUnknownItem;
+            break;
+        }
+
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// LocalItemL()
+// ---------------------------------------------------------------------------
+//
+TInt CParser::LocalItemL(const TItem& aItem)
+    {
+    TInt retVal = 0;
+    switch (aItem.Tag())
+        {
+        case ELocalUsage:
+            retVal = HandleLocalUsageL( aItem );
+            break;
+        case ELocalUsageMinimum:
+            retVal = HandleLocalUsageMinimum( aItem );
+            break;
+        case ELocalUsageMaximum:
+            retVal = HandleLocalUsageMaximum( aItem );
+            break;
+        case ELocalDesignatorIndex:
+            retVal = HandleLocalDesignatorIndex( aItem );
+            break;
+        case ELocalDesignatorMinimum:
+            retVal = HandleLocalDesignatorMinimum( aItem );
+            break;
+        case ELocalDesignatorMaximum:
+            retVal = HandleLocalDesignatorMaximum( aItem );
+            break;
+        case ELocalStringIndex:
+            retVal = HandleLocalStringIndex( aItem );
+            break;
+        case ELocalStringMinimum:
+            retVal = HandleLocalStringMinimum( aItem );
+            break;
+        case ELocalStringMaximum:
+            retVal = HandleLocalStringMaximum( aItem );
+            break;
+        // "HID parsers must handle Delimiters however, the support
+        // for the alternative usages that they define is optional.
+        // Usages other than the first (most preferred) usage defined
+        // may not be made accessible by system software.", [1],
+        // Section 6.2.2.8.
+        //
+        // This parser only supports the first usage in a delimiter list.
+        case ELocalDelimiter:
+            retVal = HandleLocalDelimiter( aItem );
+            break;
+        default:
+            TRACE_ERROR(_L("Error: unknown local item\n"));
+            retVal = EUnknownItem;
+            break;
+        }
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// IsReservedUsagePage()
+// ---------------------------------------------------------------------------
+//
+TBool CParser::IsReservedUsagePage(TInt aId)
+    {   
+    return (aId == KReservedUsage) ||                     
+        ((aId >= KReservedUsageRange1Min ) && (aId <= KReservedUsageRange1Max)) ||     
+        ((aId >= KReservedUsageRange2Min ) && (aId <= KReservedUsageRange2Max)) ||     
+        ((aId >= KReservedUsageRange3Min) && (aId <= KReservedUsageRange3Max)) ||     
+        ((aId >= KReservedUsageRange4Min ) && (aId <= KReservedUsageRange4Max)) ||     
+        ((aId >= KReservedUsageRange5Min) && (aId <= KReservedUsageRange5Max));     
+    }
+
+// ---------------------------------------------------------------------------
+// Populate()
+// ---------------------------------------------------------------------------
+//
+void TParserGlobalState::Populate(CField *aField) const
+    {
+    aField->SetUsagePage(iUsagePage);
+    aField->SetReportId(iReportId);
+    aField->SetLogicalRange(iLogicalMin, iLogicalMax);
+    aField->SetSize(iSize);
+    aField->SetCount(iCount);
+    aField->SetUnit(iUnit);
+    aField->SetUnitExponent(iUnitExponent);
+
+    // If the physical min and max are both zero, then the HID class
+    // document specifies that they should be assumed to be equal to
+    // the corresponding logical values ([1], Section 6.2.2.7):
+    //
+    if ((iPhysicalMin == 0) && (iPhysicalMax == 0))
+        {
+        aField->SetPhysicalRange(iLogicalMin, iLogicalMax);
+        }
+    else
+        {
+        aField->SetPhysicalRange(iPhysicalMin, iPhysicalMax);
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// TParserGlobalState()
+// ---------------------------------------------------------------------------
+//
+TParserGlobalState::TParserGlobalState()
+    : iUsagePage(0), iLogicalMin(0), iLogicalMax(0),
+      iPhysicalMin(0), iPhysicalMax(0), iUnit(0),
+      iUnitExponent(0), iReportId(0), iSize(0), iCount(0)
+    {
+    // Nothing else to do
+    }
+
+// ---------------------------------------------------------------------------
+// HandleMainInputTagL
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleMainInputTagL(const TItem& aItem)
+    {
+    // Section 6.2.2.4 of the HID class specification, [1],
+    // states that an Input item may have a data size of zero
+    // bytes:
+    //
+    //   "In this case the value of each data bit for the item
+    //   can be assumed to be zero. This is functionally
+    //   identical to using a item tag that specifies a 4-byte
+    //   data item followed by four zero bytes."
+    //
+    // For a data size of zero, TItem::Data() will return zero
+    // and so we will get the required behaviour.
+    TRACE_INFO((_L("Input %d\n"), aItem.Data()));
+    TInt retVal=0;
+
+    iItemsDefined |= EInputReport;
+    
+    if ( aItem.Data() & KInputReservedBitsMask )
+        {
+        IssueWarning( EInputReservedBitsNonZero );
+        }
+    if ( iLocalMultipleUse )
+        {
+        IssueWarning( EInputLocalMultipleUse );
+        }
+    if ( iWithinDelimiter )
+        {
+        retVal = EInputItemWithinDelimiter;
+        }
+    else
+        {
+        retVal = CreateFieldL( CField::EInput, aItem.Data() );
+        }
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleMainOutputTagL
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleMainOutputTagL(const TItem& aItem)
+    {
+    TRACE_INFO((_L("Output %d\n"), aItem.Data()));
+    TInt retVal=0;
+    iItemsDefined |= EOutputReport;
+    
+    if ( aItem.Data() & KOutputReservedBitsMask )
+        {
+        IssueWarning( EOutputReservedBitsNonZero );
+        }
+
+    if ( iLocalMultipleUse )
+        {
+        IssueWarning( EOutputLocalMultipleUse );
+        }
+
+    if ( iWithinDelimiter )
+        {
+        retVal = EOutputItemWithinDelimiter;
+        }
+    else
+       {
+       retVal = CreateFieldL( CField::EOutput, aItem.Data() );
+       }
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleMainFeatureL
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleMainFeatureL( const TItem& aItem )
+    {
+    TRACE_INFO((_L("Feature %d\n"), aItem.Data()));
+    TInt retVal=0;
+    iItemsDefined |= EFeatureReport;
+        
+    if ( aItem.Data() & KFeatureReservedBitsMask )
+        {
+        IssueWarning(EFeatureReservedBitsNonZero );
+        }
+
+    if ( iLocalMultipleUse )
+        {
+        IssueWarning( EFeatureLocalMultipleUse );
+        }
+
+    if ( iWithinDelimiter )
+        {
+        retVal = EFeatureItemWithinDelimiter;
+        }
+     else
+        {
+        retVal = CreateFieldL( CField::EFeature, aItem.Data() );
+        }
+
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleMainCollectionL
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleMainCollectionL( const TItem& aItem )
+    {
+    TRACE_INFO((_L("Start collection %d\n"), aItem.Data()));
+    TInt retVal = 0;
+
+    if ( iWithinDelimiter )
+        {
+        retVal = EBeginCollectionWithinDelimiter;
+        }
+    else
+        {
+        // Application collections can only be declared at
+        // top-level:
+        if ((aItem.Data() == CCollection::EApplication) &&
+           (iCollectionStack.Count() != 1))
+            {
+            retVal = EApplicationCollectionLevel;
+            }
+        else
+            {
+            retVal = CreateCollectionL(aItem.Data());
+            }
+        }
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleMainEndCollection
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleMainEndCollection( const TItem& aItem )
+    {
+    TRACE_INFO((_L("Start collection %d\n"), aItem.Data()));
+    TInt retVal = 0;
+
+    if (aItem.DataSize() != 0)
+        {
+        IssueWarning(EEndCollectionHasData);
+        }
+
+    if (iItemsDefined & KLocalItemMask)
+        {
+        IssueWarning(EEndCollectionLocalUnused);
+        }
+
+    if (iCollectionStack.Count() > 1)
+        {
+        PopCollection();
+        }
+    else
+        {
+        retVal = ENoMatchingBeginCollection;
+        }
+
+    if (iWithinDelimiter)
+        {
+        retVal = EEndCollectionWithinDelimiter;
+        }
+
+    return  retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleGlobalReportId
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleGlobalReportId( const TItem& aItem )
+    {
+    TRACE_INFO((_L("Global report ID %d\n"), aItem.Data()));
+    TInt retVal = 0;
+    TUint reportId = aItem.Data();
+
+    if (reportId == 0)
+        {
+        retVal = EZeroReportId;
+        }
+    if (reportId > KMaxReportIDMax)
+        {
+        retVal = EReportIdTooBig;
+        }
+
+    // If there are to be any report IDs specified at all,
+    // then a report ID must be defined before the first
+    // input, output or feature report:
+    //    
+    if ((iGlobal.iReportId == 0) && (iItemsDefined & KReportItemMask))
+        {
+        retVal = ELateReportId;
+        }
+
+    // Report ID defined outside a top level collection (Microsoft
+    // restriction)
+    //
+    if (iCollectionStack.Count() == 1)
+        {
+        retVal = EReportIdOutsideTopLevel;
+        }
+
+    // Same item shouldn't have been declared since last main item:
+    //
+    if (iGlobalItemsDefined & EReportId)
+        {
+        // This is an error according to [2], but as it isn't
+        // a critical problem, and as some real-world devices
+        // fail this check, we issue a warning instead:
+        IssueWarning(ERedundantGlobalItem);
+        }
+    iGlobalItemsDefined |= EReportId;
+
+    iItemsDefined |= EReportId;
+    iGlobal.iReportId = reportId;
+
+    return  retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleGlobalUsagePage
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleGlobalUsagePage( const TItem& aItem )
+    {
+    TRACE_INFO((_L("Global usage page %d\n"), aItem.Data()));
+    TInt retVal = 0;
+
+    iGlobal.iUsagePage = aItem.Data();
+
+    if (aItem.Data() == 0)
+        {
+        retVal = EZeroUsagePage;
+        }
+    
+    if (aItem.Data() > KMaxUsagePage)
+        {
+        retVal = EUsagePageOutOfRange;
+        }
+
+    if (IsReservedUsagePage(aItem.Data()))
+        {
+        IssueWarning(EReservedUsagePage);
+        }
+
+    iItemsDefined |= EUsagePage;
+
+    if (iGlobalItemsDefined & EUsagePage)
+        {
+        retVal = ERedundantGlobalItem;
+        }
+    iGlobalItemsDefined |= EUsagePage;
+
+    return  retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleGlobalLogicalMinimum
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleGlobalLogicalMinimum( const TItem& aItem )
+    {
+    TRACE_INFO((_L("Global logical min %d\n"), aItem.SignedData()));
+    TInt retVal = 0;
+    iGlobal.iLogicalMin = aItem.SignedData();
+    iItemsDefined |= ELogicalMin;
+
+    if (iGlobalItemsDefined & ELogicalMin)
+        {
+        retVal = ERedundantGlobalItem;
+        }
+    iGlobalItemsDefined |= ELogicalMin;
+
+    // "Until Physical Minimum and Physical Maximum are
+    // declared in a report descriptor they are assumed by the
+    // HID parser to be equal to Logical Minimum and Logical
+    // Maximum, respectively.", [1], Section 6.2.2.7.
+    //
+    if (!(iItemsDefined & EPhysicalMin))
+        {
+        iGlobal.iPhysicalMin = aItem.SignedData();
+        }
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleGlobalLogicalMaximum
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleGlobalLogicalMaximum( const TItem& aItem )
+    {
+    TRACE_INFO((_L("Global logical max %d\n"), aItem.SignedData()));
+    TInt retVal = 0;
+
+    iGlobal.iLogicalMax = aItem.SignedData();
+    if ( !(iItemsDefined & EPhysicalMax) )
+        {
+        iGlobal.iPhysicalMax = aItem.SignedData();
+        }
+    iItemsDefined |= ELogicalMax;
+
+    if (iGlobalItemsDefined & ELogicalMax)
+        {
+        retVal = ERedundantGlobalItem;
+        }
+    iGlobalItemsDefined |= ELogicalMax;
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleGlobalPhysicalMinimum
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleGlobalPhysicalMinimum( const TItem& aItem )
+    {
+    TRACE_INFO((_L("Global physical min %d\n"), aItem.SignedData()));
+    TInt retVal = 0;
+    iGlobal.iPhysicalMin = aItem.SignedData();
+    iItemsDefined |= EPhysicalMin;
+
+    if (iGlobalItemsDefined & EPhysicalMin)
+        {
+        retVal = ERedundantGlobalItem;
+        }
+    iGlobalItemsDefined |= EPhysicalMin;
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleGlobalPhysicalMaximum
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleGlobalPhysicalMaximum( const TItem& aItem )
+    {
+    TRACE_INFO((_L("Global physical max %d\n"), aItem.SignedData()));
+
+    TInt retVal = 0;
+    iGlobal.iPhysicalMax = aItem.SignedData();
+    iItemsDefined |= EPhysicalMax;
+
+    if ( iGlobalItemsDefined & EPhysicalMax )
+        {
+        retVal = ERedundantGlobalItem;
+        }
+    iGlobalItemsDefined |= EPhysicalMax;
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleGlobalUnit
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleGlobalUnit( const TItem& aItem )
+    {
+    TRACE_INFO((_L("Global unit %d\n"), aItem.Data()));
+    TInt retVal = 0;
+    iGlobal.iUnit = aItem.Data();
+    iItemsDefined |= EUnit;
+
+    if (iGlobalItemsDefined & EUnit)
+        {
+        retVal = ERedundantGlobalItem;
+        }
+    iGlobalItemsDefined |= EUnit;
+
+    TInt unitSystem = aItem.Data() & KUnitData;
+    if (((unitSystem >= KUnitSystemMin ) && (unitSystem != KUnitSystem15)) ||
+        (aItem.Data() & KUnitReservedBitsMask ))
+        {               
+        IssueWarning(EUnitReservedBitsNonZero);
+        }
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleGlobalUnitExponent
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleGlobalUnitExponent( const TItem& aItem )
+    {
+    TRACE_INFO((_L("Global unit exponent %d\n"), aItem.Data()));
+    TInt retVal = 0;
+    iGlobal.iUnitExponent = aItem.Data();
+    iItemsDefined |= EUnitExponent;
+
+    if (iGlobalItemsDefined & EUnitExponent)
+        {
+        retVal = ERedundantGlobalItem;
+        }
+    iGlobalItemsDefined |= EUnitExponent;
+    const TUint32 KReservedBits = ~0x0fUL;
+    if (aItem.Data() & KReservedBits)
+        {
+        IssueWarning( EExponentReservedBitsNonZero );
+        }
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleGlobalReportSize
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleGlobalReportSize( const TItem& aItem )
+    {
+    TRACE_INFO((_L("Global report size %d\n"), aItem.Data()));
+    TInt retVal = 0;
+    iGlobal.iSize = aItem.Data();
+    iItemsDefined |= EReportSize;
+
+    if (iGlobalItemsDefined & EReportSize)
+        {
+        retVal = ERedundantGlobalItem;
+        }
+    iGlobalItemsDefined |= EReportSize;
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleGlobalReportCount
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleGlobalReportCount( const TItem& aItem )
+    {
+    TRACE_INFO((_L("Global report count %d\n"), aItem.Data()));
+    TInt retVal = 0;
+    iGlobal.iCount = aItem.Data();
+    if (aItem.Data() == 0)
+        {
+        retVal = EZeroReportCount;
+        }
+    iItemsDefined |= EReportCount;
+
+    if (iGlobalItemsDefined & EReportCount)
+        {
+        retVal = ERedundantGlobalItem;
+        }
+    iGlobalItemsDefined |= EReportCount;
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleGlobalPushL
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleGlobalPushL( const TItem& aItem )
+    {
+    TRACE_INFO(_L("Global push\n"));
+    TInt retVal = 0;
+    if (aItem.DataSize() != 0)
+        {
+        retVal = EPushHasData;
+        }
+    User::LeaveIfError(iGlobalStack.Append(iGlobal));
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleGlobalPop
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleGlobalPop( const TItem& aItem )
+    {
+    TRACE_INFO(_L("Global pop\n"));
+    TInt retVal = 0;
+    if (aItem.DataSize() != 0)
+        {
+        retVal = EPopHasData;
+        }
+
+    if (iGlobalStack.Count() > 0)
+        {
+        iGlobal = iGlobalStack[iGlobalStack.Count()-1];
+        iGlobalStack.Remove(iGlobalStack.Count()-1);
+        }
+    else
+        {
+        retVal = EPopWithoutPush;
+        }
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleLocalUsageL
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleLocalUsageL( const TItem& aItem )
+    {
+    TRACE_INFO((_L("Local usage %d\n"), aItem.Data()));
+    TInt retVal = 0;
+    
+    if (aItem.DataSize() == KExtendedDataSize )
+        {
+        // Extended (32-bit) usage:
+        TInt usagePage = (aItem.Data() >> KExtendedDataShift);
+        if (IsReservedUsagePage(usagePage))
+            {
+            IssueWarning(EReservedUsagePage);
+            }
+        }
+
+    if ((aItem.Data() & 0xffff) == 0)
+        {
+        IssueWarning(EZeroUsage);
+        }
+
+    if (!iWithinDelimiter || (iAliasCount++ == 0))
+        {
+        iLocal->AddUsageL(aItem.Data());
+        iItemsDefined |= EUsageId;
+        }
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleLocalUsageMinimum
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleLocalUsageMinimum( const TItem& aItem )
+    {
+    TRACE_INFO((_L("Local usage min %d\n"), aItem.Data()));
+    TInt retVal = 0;
+    if (!iWithinDelimiter || (iAliasCountMin++ == 0))
+        {
+        TInt usagePage = iGlobal.iUsagePage;
+
+        if (aItem.DataSize() == KExtendedDataSize )
+            {
+            // Extended usage specified.
+            usagePage = aItem.Data() >> KExtendedDataShift;
+            }
+
+        if (iItemsDefined & EUsageMax)
+            {
+            TInt maxPage =
+            static_cast<TUint32>(iLocal->UsageMax()) >> KExtendedDataShift;
+            if (maxPage == 0)
+                {
+                maxPage = iGlobal.iUsagePage;
+                }
+            if (usagePage != maxPage)
+                {
+                retVal = EUsagePageMismatchMin;
+                }
+            }
+        iLocal->SetUsageMin(aItem.Data());
+        }
+    if (iItemsDefined & EUsageMin)
+        {
+        iLocalMultipleUse = ETrue;
+        }
+    iItemsDefined |= EUsageMin;
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleLocalUsageMaximum
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleLocalUsageMaximum( const TItem& aItem )
+    {
+    TRACE_INFO((_L("Local usage max %d\n"), aItem.Data()));
+    
+    TInt retVal = 0;
+    
+    if (!iWithinDelimiter || (iAliasCountMax++ == 0))
+        {
+        TInt usagePage = iGlobal.iUsagePage;
+
+        if (aItem.DataSize() == KExtendedDataSize )
+            {
+            // Extended usage specified.
+            usagePage = aItem.Data() >> KExtendedDataShift;
+            }
+        if (iItemsDefined & EUsageMin)
+            {
+            TInt minPage =
+                static_cast<TUint32>(iLocal->UsageMin()) >> KExtendedDataShift;
+            if (minPage == 0)
+                {
+                minPage = iGlobal.iUsagePage;
+                }
+            if (usagePage != minPage)
+                {
+                retVal = EUsagePageMismatchMax;
+                }
+            }
+        iLocal->SetUsageMax(aItem.Data());
+        }
+    if (iItemsDefined & EUsageMax)
+        {
+        iLocalMultipleUse = ETrue;
+        }
+    iItemsDefined |= EUsageMax;
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleLocalDesignatorIndex
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleLocalDesignatorIndex( const TItem& aItem )
+    {
+    TRACE_INFO((_L("Local designator index %d\n"),
+            aItem.Data()));
+    TInt retVal = 0;
+    iLocal->SetDesignatorIndex(aItem.Data());
+    if (iWithinDelimiter)
+        {
+        retVal = EInvalidItemWithinDelimiter;
+        }
+    if (iItemsDefined & EDesignatorIndex)
+        {
+        iLocalMultipleUse = ETrue;
+        }
+    iItemsDefined |= EDesignatorIndex;
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleLocalDesignatorMinimum
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleLocalDesignatorMinimum( const TItem& aItem )
+    {
+    TRACE_INFO((_L("Local designator min %d\n"), aItem.Data()));
+    TInt retVal = 0;
+    iLocal->SetDesignatorMin(aItem.Data());
+    if ( iWithinDelimiter )
+        {
+        retVal = EInvalidItemWithinDelimiter;
+        }
+    if (iItemsDefined & EDesignatorMin)
+        {
+        iLocalMultipleUse = ETrue;
+        }
+    iItemsDefined |= EDesignatorMin;
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleLocalDesignatorMaximum
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleLocalDesignatorMaximum( const TItem& aItem )
+    {
+    TRACE_INFO((_L("Local designator max %d\n"), aItem.Data()));
+    TInt retVal = 0;
+    iLocal->SetDesignatorMax(aItem.Data());
+    if ( iWithinDelimiter )
+        {
+        retVal = EInvalidItemWithinDelimiter;
+        }
+    if ( iItemsDefined & EDesignatorMax )
+        {
+        iLocalMultipleUse = ETrue;
+        }
+    iItemsDefined |= EDesignatorMax;
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleLocalStringIndex
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleLocalStringIndex( const TItem& aItem )
+    {
+    TRACE_INFO((_L("Local string index %d\n"), aItem.Data()));
+    TInt retVal = 0;
+    iLocal->SetStringIndex(aItem.Data());
+    if ( iItemsDefined & EStringIndex )
+        {
+        iLocalMultipleUse = ETrue;
+        }
+    iItemsDefined |= EStringIndex;
+    if ( iWithinDelimiter )
+        {
+        retVal = EInvalidItemWithinDelimiter;
+        }
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleLocalStringMinimum
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleLocalStringMinimum( const TItem& aItem )
+    {
+    TRACE_INFO((_L("Local string min %d\n"),
+            aItem.Data()));
+    TInt retVal = 0;
+    iLocal->SetStringMin(aItem.Data());
+    if ( iItemsDefined & EStringMin)
+        {
+        iLocalMultipleUse = ETrue;
+        }
+    iItemsDefined |= EStringMin;
+    if (iWithinDelimiter)
+        {
+        retVal = EInvalidItemWithinDelimiter;
+        }
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleLocalStringMaximum
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleLocalStringMaximum( const TItem& aItem )
+    {
+    TRACE_INFO((_L("Local string max %d\n"),
+            aItem.Data()));
+    TInt retVal = 0;
+    iLocal->SetStringMax(aItem.Data());
+    if ( iItemsDefined & EStringMax )
+        {
+        iLocalMultipleUse = ETrue;
+        }
+    iItemsDefined |= EStringMax;
+    if ( iWithinDelimiter )
+        {
+        retVal = EInvalidItemWithinDelimiter;
+        }
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleLocalDelimiter
+// ---------------------------------------------------------------------------
+//
+TInt CParser::HandleLocalDelimiter( const TItem& aItem )
+    {
+    const TInt KBeginDelimiter = 1;
+    const TInt KEndDelimiter = 0;
+    TInt retVal = 0;
+
+    switch ( aItem.Data() )
+        {
+        case KBeginDelimiter:
+            if ( iWithinDelimiter )
+                {
+                retVal = ENestedDelimiter;
+                }
+            // Delimiters can't be used when defining usages
+            // that apply to array items ([1], Section 6.2.2.8):
+            //
+            if ( Collection()->Type() == CCollection::ENamedArray )
+                {
+                IssueWarning( EDelimiterWithinNamedArray );
+                }
+            iWithinDelimiter = ETrue;
+            iAliasCount = 0;
+            iAliasCountMin = 0;
+            iAliasCountMax = 0;
+            break;
+
+        case KEndDelimiter:
+            if ( !iWithinDelimiter )
+                {
+                retVal = ELonelyDelimiter;
+                }
+            iWithinDelimiter = EFalse;
+            break;
+
+        default:
+            retVal = EUnknownDelimiter;
+            TRACE_ERROR((_L("Error: Unknown delimiter type %d\n"),
+                    aItem.Data()));
+            break;
+        }
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// CheckMandatoryFieldExistence
+// ---------------------------------------------------------------------------
+//
+TInt CParser::CheckMandatoryFieldExistence( CField::TType aType, TUint32 aAttributes )
+    {
+    TInt retVal = KErrNone;
+        
+    if ( ( ( iItemsDefined & KMandatoryItemMask ) != KMandatoryItemMask )
+        && (!(aAttributes & KConstantFlag)))
+        {
+        if ( aType == CField::EInput )
+            {
+            retVal = EInputMissingItems;
+            }
+        if ( aType == CField::EOutput )
+            {
+            retVal = EOutputMissingItems;
+            }
+        if ( aType == CField::EFeature )
+            {    
+            retVal = EFeatureMissingItems;
+            }
+        }    
+    return retVal;   
+    }
+
+// ---------------------------------------------------------------------------
+// CheckUsageMinAndMaxErrors
+// ---------------------------------------------------------------------------
+//    
+TInt CParser::CheckUsageMinAndMaxErrors()
+    {
+    TInt retVal = KErrNone;
+        
+    if ( iItemsDefined & ( EUsageMin | EUsageMax ))
+        {
+        if (!( iItemsDefined & EUsageMax ))
+            {
+            retVal = ELonelyUsageMin;
+            }
+        if (!( iItemsDefined & EUsageMin ))
+            {
+            retVal = ELonelyUsageMax;
+            }
+        if ( iLocal->UsageMin() > iLocal->UsageMax() )
+            {
+            retVal = EUsageMinExceedsMax;
+            }
+        }    
+    return retVal;       
+    }
+    
+// ---------------------------------------------------------------------------
+// CheckDesignatorMinAndMaxErrors
+// ---------------------------------------------------------------------------
+//      
+TInt CParser::CheckDesignatorMinAndMaxErrors()
+    {
+    TInt retVal = KErrNone;
+        
+    if ( iItemsDefined & ( EDesignatorMin | EDesignatorMax ))
+        {
+        if ( !( iItemsDefined & EDesignatorMax ) )
+            {
+            retVal = ELonelyDesignatorMin;
+            }
+        if ( !( iItemsDefined & EDesignatorMin ) )
+            {
+            retVal = ELonelyDesignatorMax;
+            }
+        if ( iLocal->DesignatorMin( ) > iLocal->DesignatorMax( ) )
+            {
+            retVal = EDesignatorMinExceedsMax;
+            }
+        }    
+    return retVal;           
+    }    
+
+// ---------------------------------------------------------------------------
+// CheckStringMinAndMaxErrors
+// ---------------------------------------------------------------------------
+//  
+TInt CParser::CheckStringMinAndMaxErrors()
+    {
+    TInt retVal = KErrNone;
+            
+    if (iItemsDefined & (EStringMin | EStringMax))
+        {
+        if ( !( iItemsDefined & EStringMax ) )
+            {
+            retVal = ELonelyStringMin;
+            }
+        if ( !( iItemsDefined & EStringMin ) )
+            {
+            retVal = ELonelyStringMax;
+            }
+        if ( iLocal->StringMin( ) > iLocal->StringMax( ) )
+            {
+            retVal = EStringMinExceedsMax;
+            }
+        }    
+    return retVal;               
+    }
+
+
+// ---------------------------------------------------------------------------
+// CheckStringMinAndMaxErrors
+// ---------------------------------------------------------------------------
+//  
+TInt CParser::CheckMandatoryFieldErrors( CField::TType aType, TUint32 aAttributes )
+    {
+    TInt ret = KErrNone;
+    // Check for mandatory items:       
+    ret = CheckMandatoryFieldExistence( aType, aAttributes );    
+    if ( ret != KErrNone )
+        {
+        return ret;
+        }
+    ret = CheckUsageMinAndMaxErrors();
+    if ( ret != KErrNone )
+        {
+        return ret;
+        }    
+    ret = CheckDesignatorMinAndMaxErrors();
+    if ( ret != KErrNone )
+        {
+        return ret;
+        }     
+    ret = CheckStringMinAndMaxErrors();
+    if ( ret != KErrNone )
+        {
+        return ret;
+        }          
+    return KErrNone;               
+    }
+
+// ---------------------------------------------------------------------------
+// CheckLogicalMinAndMax
+// ---------------------------------------------------------------------------
+//  
+void CParser::CheckLogicalMinAndMax( TUint32 aAttributes )
+    {
+    // Logical minimum and maximum must match the number of usage
+    // values defined if the Array flag is set (Var=0).  (Ignore this
+    // check for constant fields)
+    //
+    if ( !( aAttributes & KVariableFlag ) && ( ! ( aAttributes & KConstantFlag ) ) )
+        {
+        // Logical minimum must equal 1:
+        //
+        if ( iGlobal.iLogicalMin != 1 )
+            {
+            // This is an error according to [2], but we issue a
+            // warning instead, as many devices (including the
+            // Logitech diNovo keyboard) fail this check:
+            IssueWarning( ELogicalMinInvalidForArray );
+            }
+
+        // Logical maximum must equal the number of defined usages:
+        //
+        TInt numUsages = iLocal->UsageCount();
+        if ( numUsages == 0 )
+            {
+            numUsages = iLocal->UsageMax( ) - iLocal->UsageMin( ) + 1;
+            }
+        if ( iGlobal.iLogicalMax != numUsages )
+            {
+            // Again, we issue a warning rather than an error:
+            IssueWarning( ELogicalMaxInvalidForArray );
+            }
+        }            
+    
+    }
+
+// ---------------------------------------------------------------------------
+// CheckFieldBitNeeded
+// ---------------------------------------------------------------------------
+//      
+void CParser::CheckFieldBitNeeded( CField::TType aType, TUint32 aAttributes )
+    {
+    // "The bit field declared by Report Size must be large enough to
+    // hold all values declared by Logical Minimum and Logical
+    // Maximum. This includes a sign bit if either are less than
+    // 0. Also if the Null flag is set then the field must be capable
+    // of reporting all values declared by Logical Minimum and Logical
+    // Maximum, and a null value.", [2] (footnote 5).
+
+    TInt bitsNeeded = 0;
+
+    if ( !( aAttributes & KConstantFlag ) )
+        {        
+        if ( aAttributes & KNullStateFlag )
+            {
+            // The null state flag is set, so there needs to be at
+            // least one extra "out of range" value. This could be
+            // below the lowest value or above the highest, whichever
+            // will fit better:
+            bitsNeeded = Min(
+                BitsToRepresentRange(iGlobal.iLogicalMin - 1,
+                    iGlobal.iLogicalMax),
+                BitsToRepresentRange(iGlobal.iLogicalMin,
+                    iGlobal.iLogicalMax + 1));
+            }
+        else
+            {
+            // No null state declared:
+            bitsNeeded = BitsToRepresentRange(iGlobal.iLogicalMin,
+                iGlobal.iLogicalMax);
+            }
+        }
+
+    if ( iGlobal.iSize < bitsNeeded )
+        {
+        // The Logitech diNovo is missing a Logical Min and Logical
+        // Max pair and so will trigger a range error here.  As a
+        // workaround, we will treat this as a warning rather than
+        // a critical error:
+        const TInt KRangeError[] =
+            { EInputReportSize, EOutputReportSize, EFeatureReportSize };
+        IssueWarning(KRangeError[aType]);
+        }        
+    }
+    
+// ---------------------------------------------------------------------------
+// HandleItem
+// ---------------------------------------------------------------------------
+//     
+void CParser::HandleItemL( TItem& aItem )
+    {    
+    iErrorCode = EUnknownItem;
+    if (aItem.IsLocal())
+        {
+        iErrorCode = LocalItemL(aItem);
+        }   
+    else
+        {
+        // Not allowed non-local items within a delimiter pair:
+        //
+        if ( iWithinDelimiter )
+            {
+            iErrorCode = EInvalidItemWithinDelimiter;
+            }
+        else
+            {
+            if ( aItem.IsMain() )
+                {
+                iErrorCode = MainItemL(aItem);
+                }
+
+            if ( aItem.IsGlobal() )
+                {
+                iErrorCode = GlobalItemL(aItem);
+                }
+            if ( aItem.IsLong() )
+                {
+                IssueWarning(ELongItemDefined);
+                iErrorCode = 0;
+                }
+            }
+        }        
+    }
+    
+// ---------------------------------------------------------------------------
+// CheckParseErrors()
+// ---------------------------------------------------------------------------
+//      
+void CParser::CheckParseErrors()
+    {        
+    if ( !iErrorCode && ( iGlobalStack.Count() > 0) )
+        {
+        iErrorCode = EPushWithoutPop;
+        }
+
+    // COLLECTION without END_COLLECTION:
+    if ( !iErrorCode && ( iCollectionStack.Count() != 0 ) )
+        {
+        iErrorCode = ENoMatchingEndCollection;
+        }
+
+    // DELIMITER(Open) without DELIMITER(Close):
+    if ( !iErrorCode && iWithinDelimiter )
+        {
+        iErrorCode = ELonelyDelimiter;
+        }
+
+    // Final size of all reports must be a multiple of eight bits:
+    if ( !CheckAllReportSizes() )
+        {        
+        IssueWarning( EReportMustBeEightBitMultiple );
+        }            
+    }
+    
+// ---------------------------------------------------------------------------
+// ResetParser
+// ---------------------------------------------------------------------------
+//  
+void CParser::ResetParserL()    
+    {
+    // Create the root collection, which is the container for all
+    // other collections and fields:
+    //
+    delete iReportRoot;   // may exist if there has been a Leave()
+    iReportRoot = 0;
+    iReportRoot = CReportRoot::NewL();
+    iCollectionStack.Reset();
+    PushCollectionL(iReportRoot);
+
+    // Clear the error code and the warnings list:
+    //
+    iErrorCode = 0;    
+
+    // Reset the parser internal state:
+    //
+    iGlobal = TParserGlobalState();
+    iGlobalStack.Reset();
+    iWithinDelimiter = EFalse;
+    iItemsDefined = 0;
+    iGlobalItemsDefined = 0;
+    iItemNumber = 0;    
+    ClearLocalState();
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/src/hidreportbase.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,199 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Report base class implementation
+*
+*/
+
+
+#include "hidfield.h"
+#include "hidtranslate.h"
+#include "hidinterfaces.h"
+
+const TUint KValueMask      = 0xFFFFFFFF;
+const TUint KSignBitMask    = 0x80000000;
+const TInt  KThreeLSB       = 7;
+const TInt  KThreeLSBShift  = 3;
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// GetIndexOfUsage()
+// ---------------------------------------------------------------------------
+//
+TBool TReportUtils::GetIndexOfUsage(const CField* aField,
+    TInt aUsageId, TInt& aUsageIndex)
+    {
+    TArray<TInt> usages(aField->UsageArray());
+
+    if ( usages.Count() > 0 )
+        {
+        // Find the usage in the array
+        for ( TInt i = 0; i < usages.Count(); i++ )
+            {
+            if ( usages[i] == aUsageId )
+                {
+                aUsageIndex = i;
+                return ETrue;
+                }
+            }
+        }
+    else
+        {
+        // The field includes all usages between the min and max
+        if ( aField->UsageMin() <= aUsageId && aUsageId <= aField->UsageMax() )
+            {
+            aUsageIndex = aUsageId - aField->UsageMin();
+            return ETrue;
+            }
+        }
+
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// UsageAtIndex()
+// ---------------------------------------------------------------------------
+//
+TInt TReportUtils::UsageAtIndex(const CField* aField, TInt aUsageIndex)
+    {
+    TInt usageId = 0;
+    TArray<TInt> usages(aField->UsageArray());
+
+    if ( usages.Count() > 0 )
+        {
+        if ( aUsageIndex < 0 )
+            {
+            // Null state for array control
+            }
+        else if ( aUsageIndex < usages.Count() )
+            {
+            // Get the usage ID from the set of possible usages
+            usageId = usages[aUsageIndex];
+            }
+        else
+            {
+            // If there aren't enough usages in the set, the last one repeats
+            usageId = usages[usages.Count() - 1];
+            }
+        }
+    else
+        {
+        // Get the usage ID from the range
+        if ( 0 <= aUsageIndex
+                && aUsageIndex <= (aField->UsageMax() - aField->UsageMin()) )
+            {
+            usageId = aField->UsageMin() + aUsageIndex;
+            }
+        }
+
+    return usageId;
+    }
+
+// ---------------------------------------------------------------------------
+// WriteData()
+// ---------------------------------------------------------------------------
+//
+TInt TReportUtils::WriteData(HBufC8& aData, const CField* aField,
+    TInt aIndex, TInt aValue)
+    {
+    if ( 0 <= aIndex && aIndex < aField->Count() )
+        {
+        // The offset in bits from the start of the report to the value
+        TInt offset = aField->Offset() + aIndex * aField->Size();
+
+        // How many bits in the least significant byte are not part of the value
+        TInt bitsToShift = offset & KThreeLSB;
+
+        TUint mask = KValueMask >> ((KSizeOfByte * sizeof(TInt)) - aField->Size());
+        mask <<= bitsToShift;
+        aValue <<= bitsToShift;
+
+        TPtr8 data = aData.Des();
+
+        // Write out the bytes, least significant first
+        for ( TInt i = offset >> KThreeLSBShift; mask && i < aData.Length(); i++ )
+            {
+            TUint8 maskByte = static_cast<TUint8>(mask);
+
+            // The extra cast is because MSVC6 thinks that or-ing 2
+            // TUint8s together gives an int.
+            data[i] = static_cast<TUint8>(
+                (static_cast<TUint8>(aValue) & maskByte)
+                | (aData[i] & ~maskByte));
+            mask >>= KSizeOfByte;
+            aValue >>= KSizeOfByte;
+            }
+
+        return KErrNone;
+        }
+
+    return KErrBadControlIndex;
+    }
+
+// ---------------------------------------------------------------------------
+// ReadData()
+// ---------------------------------------------------------------------------
+//
+TInt TReportUtils::ReadData(const TDesC8& aData, const CField* aField,
+    TInt aIndex, TInt& aValue)
+    {
+    if ( 0 <= aIndex && aIndex < aField->Count() )
+        {
+        // The offset in bits from the start of the report to the value
+        TInt offset = aField->Offset() + aIndex * aField->Size();
+
+        // How many bits in the least significant byte are not part of
+        // the value
+        TInt bitsToShift = offset & KThreeLSB;
+
+        // How many consecutive bytes we need to read to get the whole
+        // value. According to the HID spec, a value cannot span more
+        // than 4 bytes in a report
+        TInt bytesToRead = (bitsToShift + aField->Size() + KThreeLSB) / KSizeOfByte;
+
+        // Make sure we don't read past the end of the data
+        if ( (offset >> KThreeLSBShift) + bytesToRead > aData.Length() )
+            {
+            bytesToRead = aData.Length() - (offset >> KThreeLSBShift);
+            }
+
+        TInt value = 0;
+
+        // Read in the bytes, most significant first
+        for ( TInt i = bytesToRead - 1; i >= 0; i-- )
+            {
+            value = (value << KSizeOfByte) | aData[(offset >> KThreeLSBShift) + i];
+            }
+
+        value >>= bitsToShift;
+
+        // Make masks for the whole value and just the sign bit
+        TUint valueMask = KValueMask >> ((KSizeOfByte * sizeof(TInt)) - aField->Size());
+        TUint signMask = KSignBitMask >> ((KSizeOfByte * sizeof(TInt)) - aField->Size());
+
+        if ( aField->LogicalMin() < 0 && (value & signMask) )
+            {
+            // The value is negative, so the leading bits should be 1s
+            aValue = value | ~valueMask;
+            }
+        else
+            {
+            // The value is positive, so the leading bits should be 0s
+            aValue = value & valueMask;
+            }
+
+        return KErrNone;
+        }
+
+    return KErrBadControlIndex;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/src/hidreportgenerator.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,164 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  HID retport generator
+*
+*/
+
+
+
+#include "hidreportgenerator.h"
+#include "hidreportroot.h"
+#include "hidinterfaces.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// NewLC()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CReportGenerator* CReportGenerator::NewLC(const CReportRoot*
+    aReportRoot, TInt aReportId, CField::TType aType)
+    {
+    CReportGenerator* self = new (ELeave) CReportGenerator(aReportId, aType);
+    CleanupStack::PushL(self);
+    self->ConstructL(aReportRoot);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// NewL()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CReportGenerator* CReportGenerator::NewL(const CReportRoot*
+    aReportRoot, TInt aReportId, CField::TType aType)
+    {
+    CReportGenerator* self =
+        CReportGenerator::NewLC(aReportRoot, aReportId, aType);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+CReportGenerator::CReportGenerator(TInt aReportId, CField::TType aType)
+    : iReportId(aReportId), iType(aType)
+    {
+    // Nothing else to do
+    }
+
+// ---------------------------------------------------------------------------
+// ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CReportGenerator::ConstructL(const CReportRoot* aReportRoot)
+    {
+    User::LeaveIfNull(const_cast<CReportRoot*>(aReportRoot));
+    iReportRoot = aReportRoot;
+
+    // Allocate the buffer, initialise to all zeros, and fill in the
+    // report ID if used.  Zero should be a null value for all array fields
+    // according to the HID parser error checking spec.
+    iBuf = HBufC8::NewMaxL(aReportRoot->ReportSizeBytes(iReportId, iType));
+    TPtr8 bufptr = iBuf->Des(); 
+    bufptr.FillZ();
+    if ( 0 != iReportId )
+        {
+        bufptr[0] = static_cast<TUint8>(iReportId);
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CReportGenerator::~CReportGenerator()
+    {
+    delete iBuf;
+    }
+
+// ---------------------------------------------------------------------------
+// SetField()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CReportGenerator::SetField(const CField* aField,
+    TInt aUsageId, TInt aValue, TInt aControlOffset /*= 0*/)
+    {
+    TInt usageIndex;
+
+    if ( aField && TReportUtils::GetIndexOfUsage(aField, aUsageId, usageIndex) )
+        {
+        if ( aField->IsArray() )
+            {
+            // Convert usage ID to logical value
+            TInt logicalValue = usageIndex + aField->LogicalMin();
+
+            // Find unused position in the array and write the logical
+            // value to it
+            for ( TInt i = 0; i < aField->Count(); i++ )
+                {
+                TInt value;
+                TInt error = TReportUtils::ReadData(*iBuf, aField, i, value);
+
+                if ( KErrNone != error )
+                    {
+                    return error;
+                    }
+
+                if ( value == logicalValue )
+                    {
+                    // The array already contains this usage
+                    return KErrNone;
+                    }
+                else if ( 0 == value || value < aField->LogicalMin() ||
+                    aField->LogicalMax() < value )
+                    {
+                    // This is an unused position
+                    //
+                    // NOTE: The comparison with zero is because the buffer is
+                    // initialised to all zeros, and some reports erroneously
+                    // include zero in the logical range.
+                    //
+                    return TReportUtils::WriteData(*iBuf, aField, i, logicalValue);
+                    }
+                }
+
+            return KErrNoSpaceInArray;
+            }
+        else
+            {
+            // Check the value to set is valid
+            if ( aValue < aField->LogicalMin() ||
+                aField->LogicalMax() < aValue )
+                {
+                return KErrValueOutOfRange;
+                }
+
+            return TReportUtils::WriteData(*iBuf, aField,
+                usageIndex + aControlOffset, aValue);
+            }
+        }
+
+    return KErrUsageNotFound;
+    }
+
+// ---------------------------------------------------------------------------
+// SetField()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TPtr8 CReportGenerator::Report()
+    {
+    return iBuf->Des();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/src/hidreportroot.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,157 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Reportroot implementation
+*
+*/
+
+
+#include <e32debug.h>
+
+#include "hidreportroot.h"
+#include "debug.h"
+
+const TInt KSevenBits  = 7;
+
+// ======== MEMBER FUNCTIONS ========
+
+// -----------------------------------------------------------------------------
+// NewLC()
+// -----------------------------------------------------------------------------
+//
+CReportRoot* CReportRoot::NewLC()
+    {
+    CReportRoot* self = new (ELeave) CReportRoot();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+// -----------------------------------------------------------------------------
+// NewL()
+// -----------------------------------------------------------------------------
+//
+CReportRoot* CReportRoot::NewL()
+    {
+    CReportRoot* self = NewLC();
+    CleanupStack::Pop(self);
+    return self;
+    }
+// -----------------------------------------------------------------------------
+// ~CReportRoot()
+// -----------------------------------------------------------------------------
+//
+CReportRoot::~CReportRoot()
+    {
+    iSizes.Reset();
+    iSizes.Close();
+    }
+// -----------------------------------------------------------------------------
+// CReportRoot()
+// -----------------------------------------------------------------------------
+//
+CReportRoot::CReportRoot()
+    {
+    // Nothing to do here
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// IncrementReportSizeL()
+// Manage the report ID <-> size "map":
+// -----------------------------------------------------------------------------
+//
+void CReportRoot::IncrementReportSizeL(TInt aReportId,
+    CField::TType aType, TInt aIncrement)
+    {
+    TInt index = FindReportSizeIndex(aReportId, aType);
+
+    if ( index == KErrNotFound )
+        {
+        // Add a new entry for this report ID to the "map":
+        User::LeaveIfError(iSizes.Append(TReportSize(aReportId, aType)));
+        index = iSizes.Count() - 1;
+
+        TRACE_INFO((_L("Adding size record for report %d:%d (%d)\n"),
+                  aReportId, aType, iSizes[index].iSize));
+        }
+    TRACE_INFO((_L("Size for report %d:%d changes %d + %d\n"),
+              aReportId, aType, iSizes[index].iSize, aIncrement));
+    iSizes[index].iSize += aIncrement;
+    }
+
+// -----------------------------------------------------------------------------
+// NumberOfReports()
+// -----------------------------------------------------------------------------
+//
+TInt CReportRoot::NumberOfReports() const
+    {
+    return iSizes.Count();
+    }
+// -----------------------------------------------------------------------------
+// ReportSize()
+// -----------------------------------------------------------------------------
+//
+TInt CReportRoot::ReportSize(TInt aIndex) const
+    {
+    TInt size = 0;
+
+    if (aIndex < iSizes.Count())
+        {
+        size = iSizes[aIndex].iSize;
+        }
+
+    return size;
+    }
+// -----------------------------------------------------------------------------
+// ReportSize()
+// -----------------------------------------------------------------------------
+//
+TInt CReportRoot::ReportSize(TInt aReportId, CField::TType aType) const
+    {
+    TInt offset = 0;
+
+    TInt index = FindReportSizeIndex(aReportId, aType);
+    if (index != KErrNotFound && index < iSizes.Count() )
+        {
+        offset = iSizes[index].iSize;
+        }
+    return offset;
+    }
+
+// -----------------------------------------------------------------------------
+// ReportSizeBytes()
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CReportRoot::ReportSizeBytes(TInt aReportId,
+    CField::TType aType) const
+    {
+    TInt reportBytes = (ReportSize(aReportId, aType) + KSevenBits) / KSizeOfByte;
+
+    // Add an extra byte if the report ID is used
+    return ( aReportId ) ? reportBytes + 1 : reportBytes;
+    }
+
+// -----------------------------------------------------------------------------
+// FindReportSizeIndex()
+// -----------------------------------------------------------------------------
+//
+TInt CReportRoot::FindReportSizeIndex(TInt aReportId, CField::TType aType) const
+    {
+    TIdentityRelation<TReportSize> matcher(TReportSize::Match);
+    TInt index = iSizes.Find(TReportSize(aReportId, aType), matcher);
+
+    TRACE_INFO((_L("FindReportSizeIndex(%d, %d) = %d\n"),
+              aReportId, aType, index));
+    return index;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/src/hidreporttranslator.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,170 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Report base class implementation
+*
+*/
+
+
+#include <e32std.h>
+
+#include "hidtranslate.h"
+#include "hidreportroot.h"
+#include "hidinterfaces.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TReportTranslator::TReportTranslator(
+    const TDesC8& aData,
+    const CField *aField)
+    : iData(aData), iField(aField)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// GetValue()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt TReportTranslator::GetValue(TInt& aValue, TInt aUsageId,
+    TInt aControlOffset /*= 0*/) const
+    {
+    TInt usageIndex = 0;
+
+    if ( iField && TReportUtils::GetIndexOfUsage(iField, aUsageId, usageIndex) )
+        {
+        if ( iField->IsArray() )
+            {
+            // Convert usage ID to logical value
+            TInt logicalValue = usageIndex + iField->LogicalMin();
+
+            // Find logical value in the array
+            for ( TInt i = 0; i < iField->Count(); i++ )
+                {
+                TInt value = 0;
+                TInt error = TReportUtils::ReadData(iData, iField, i, value);
+
+                if ( KErrNone != error )
+                    {
+                    return error;
+                    }
+
+                if ( value == logicalValue )
+                    {
+                    aValue = ETrue;
+                    return KErrNone;
+                    }
+                }
+
+            aValue = EFalse;
+            return KErrNone;
+            }
+        else
+            {
+            return TReportUtils::ReadData(iData, iField, usageIndex + aControlOffset, aValue);
+            }
+        }
+
+    return KErrUsageNotFound;
+    }
+
+// ---------------------------------------------------------------------------
+// ValueL()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt TReportTranslator::ValueL(TInt aUsageId,
+    TInt aControlOffset /*= 0*/) const
+    {
+    TInt value = 0;
+
+    User::LeaveIfError(GetValue(value, aUsageId, aControlOffset));
+
+    return value;
+    }
+
+// ---------------------------------------------------------------------------
+// GetUsageId()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt TReportTranslator::GetUsageId(TInt& aUsageId, TInt aIndex) const
+    {
+    TInt logicalValue = 0;
+    TInt error = KErrNoMemory;
+
+    if ( iField )
+        {
+        error = TReportUtils::ReadData(iData, iField, aIndex, logicalValue);
+
+        if ( KErrNone == error )
+            {
+            if ( iField->IsArray() )
+                {
+                // The logical value is a usage index
+                aUsageId = TReportUtils::UsageAtIndex(iField, logicalValue -
+                    iField->LogicalMin());
+                }
+            else
+                {
+                // Treat the logical value as an on/off control for the usage
+                aUsageId = ( logicalValue ) ? TReportUtils::UsageAtIndex(iField, 
+                    aIndex) : 0;
+                }
+            }
+        }
+
+    return error;
+    }
+
+// ---------------------------------------------------------------------------
+// GetUsageId()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt TReportTranslator::UsageIdL(TInt aIndex) const
+    {
+    TInt usageId = 0;
+
+    User::LeaveIfError(GetUsageId(usageId, aIndex));
+
+    return usageId;
+    }
+
+// ---------------------------------------------------------------------------
+// RawValueL()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt TReportTranslator::RawValueL(TInt aIndex) const
+    {
+    TInt value = 0;
+    User::LeaveIfNull(const_cast<CField*>(iField));
+    User::LeaveIfError(TReportUtils::ReadData(iData, iField, aIndex, value));
+    return value;
+    }
+
+// ---------------------------------------------------------------------------
+// Count()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt TReportTranslator::Count() const
+    {
+    TInt count = 0;
+
+    if (iField)
+        {
+        count = iField->Count();
+        }
+
+    return count;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/src/hidsearch.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  HID field search
+*
+*/
+
+#include <e32std.h>
+#include <e32svr.h>
+
+#include "hidreportroot.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// SearchL()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void THidFieldSearch::SearchL(const CReportRoot* aReportRoot,
+    MHidFieldFinder* aFinder)
+    {
+    iFinder = aFinder;
+
+    if (aReportRoot)
+        {
+        TBool done = EFalse;
+        for (TInt i=0; (i < aReportRoot->CollectionCount()) && !done; ++i)
+            {
+            done = !DoSearchL(aReportRoot->CollectionByIndex(i));
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// DoSearchL()
+// ---------------------------------------------------------------------------
+//
+TBool THidFieldSearch::DoSearchL(const CCollection* aCollection)
+    {
+    if (iFinder->BeginCollection(aCollection))
+        {
+        TInt i;
+
+        for (i=0; i < aCollection->FieldCount(); ++i)
+            {
+            iFinder->Field(aCollection->FieldByIndex(i));
+            }
+
+        for (i=0; i < aCollection->CollectionCount(); ++i)
+            {
+            if (!DoSearchL(aCollection->CollectionByIndex(i)))
+                {
+                return EFalse;
+                }
+            }
+        }
+
+    return iFinder->EndCollection(aCollection);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/Bmarm/GenericHidTestU.DEF	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,3 @@
+EXPORTS
+	LibEntryL__FR13CTestModuleIf @ 1 NONAME R3UNUSED ; LibEntryL(CTestModuleIf &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/Bwins/GenericHidTestU.DEF	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,3 @@
+EXPORTS
+	?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * __cdecl LibEntryL(class CTestModuleIf &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/conf/GenericHidTest.cfg	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1749 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Test script config file
+*
+*/
+
+[StifSettings]
+CapsModifier= GenericHidTest.exe
+[EndStifSettings]
+
+// GenericHidTest Module - total ... tc
+
+// GenericHidTest Api Tests (... tc)
+/*
+	[Test]
+	title Example Api Test
+	create GenericHidTest tester
+	tester ExecuteApiTestBlock ExampleTestL API option 1 a
+	delete tester
+	[Endtest]
+*/
+// Add new api tests here
+// ...
+
+
+// GenericHidTest Module Tests (... tc)
+/*
+	[Test]
+	title Example Module Test
+	create GenericHidTest tester
+	tester ExecuteModuleTestBlock ExampleTestL MODULE option 2 b
+	delete tester
+	[Endtest]
+*/
+// Add new module tests here
+// ...
+
+
+// GenericHidTest Branch Tests (... tc)
+
+[Test] 
+title Connect/Disconnect
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\headsetconnect.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest] 
+
+[Test] 
+title Connect Unsupported
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\dummyconnect.hid
+delete tester
+[Endtest] 
+
+[Test] 
+title Multiple Connect wiht same id
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\headsetconnect.hid
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\headsetconnect.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest] 
+
+[Test] 
+title Headset Data In
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\headsetconnect.hid
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\headsetvolumeup.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest] 
+
+[Test] 
+title  Usage PoC Data In
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\headsetconnect.hid                              
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\UsagePoC.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest] 
+
+[Test] 
+title  Multipage Connect/Disconnect
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\multipagec.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest] 
+
+[Test] 
+title  Multipage Data In
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\multipagec.hid                              
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\headsetvolumeupm.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest] 
+
+[Test] 
+title  Next track
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\headsetcon2.hid
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\play.hid
+tester ExecuteBranchTestBlock Wait BRANCH 20
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\hook.hid
+tester ExecuteBranchTestBlock Wait BRANCH 1
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\empty.hid
+tester ExecuteBranchTestBlock Wait BRANCH 20
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\stop.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest] 
+
+[Test] 
+title  Next after next track
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\headsetcon2.hid
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\play.hid
+tester ExecuteBranchTestBlock Wait BRANCH 20
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\hook.hid
+tester ExecuteBranchTestBlock Wait BRANCH 1
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\empty.hid
+tester ExecuteBranchTestBlock Wait BRANCH 1
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\hook.hid
+tester ExecuteBranchTestBlock Wait BRANCH 1
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\empty.hid
+tester ExecuteBranchTestBlock Wait BRANCH 20
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\stop.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH
+tester ExecuteBranchTestBlock Wait BRANCH 2
+delete tester
+[Endtest] 
+
+[Test] 
+title  Stop Alarm when playing music
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\headsetcon2.hid
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\play.hid
+tester ExecuteBranchTestBlock Wait BRANCH 20
+tester ExecuteBranchTestBlock AddAlarm BRANCH 1000
+tester ExecuteBranchTestBlock Wait BRANCH 70
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\hook.hid
+tester ExecuteBranchTestBlock Wait BRANCH 20
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\stop.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH
+tester ExecuteBranchTestBlock DeleteAlarm BRANCH
+delete tester
+[Endtest]
+
+[Test] 
+title  Volume up
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\headsetcon2.hid
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\volup.hid
+tester ExecuteBranchTestBlock Wait BRANCH 6
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\empty.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest] 
+
+[Test] 
+title  Volume down
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\headsetcon2.hid
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\voldown.hid
+tester ExecuteBranchTestBlock Wait BRANCH 6
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\empty.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest] 
+
+[Test] 
+title  Mute
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\headsetcon2.hid
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\mute.hid
+tester ExecuteBranchTestBlock Wait BRANCH 1
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\empty.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest] 
+
+[Test] 
+title  Short next
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\headsetcon2.hid
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\play.hid
+tester ExecuteBranchTestBlock Wait BRANCH 10
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\next.hid
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\empty.hid
+tester ExecuteBranchTestBlock Wait BRANCH 20
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\stop.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest] 
+
+[Test] 
+title  Long press next
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\headsetcon2.hid
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\play.hid
+tester ExecuteBranchTestBlock Wait BRANCH 10
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\next.hid
+tester ExecuteBranchTestBlock Wait BRANCH 3
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\empty.hid
+tester ExecuteBranchTestBlock Wait BRANCH 20
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\stop.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest] 
+
+[Test] 
+title  Long press back
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\headsetcon2.hid
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\play.hid
+tester ExecuteBranchTestBlock Wait BRANCH 10
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\prev.hid
+tester ExecuteBranchTestBlock Wait BRANCH 3
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\empty.hid
+tester ExecuteBranchTestBlock Wait BRANCH 20
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\stop.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest] 
+
+[Test] 
+title  Short press back
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\headsetcon2.hid
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\play.hid
+tester ExecuteBranchTestBlock Wait BRANCH 10
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\prev.hid
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\empty.hid
+tester ExecuteBranchTestBlock Wait BRANCH 20
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\stop.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest] 
+
+
+[Test] 
+title Connect/Disconnect ad83
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock Wait BRANCH 10
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\multipagein.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest] 
+
+[Test] 
+title Contry code
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CountryCode BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest]
+
+[Test] 
+title Vendor id
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock VendorId BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest]
+
+[Test] 
+title Product ID 
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock ProductId BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest]
+
+[Test] 
+title Set Protocol 
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock SetProtocol BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest]
+
+[Test] 
+title Get Protocol 
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock GetProtocol BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest]
+
+[Test] 
+title Get Report 
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock GetReport BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest]
+
+[Test] 
+title Set Report 
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock SetReport BRANCH c:\data\others\hook.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest]
+
+[Test] 
+title Data out 
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock DataOut BRANCH c:\data\others\hook.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest]
+
+
+[Test] 
+title Get idle 
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock GetIdle BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest]
+
+[Test] 
+title Set idle 
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock SetIdle BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest]
+
+[Test] 
+title Command Result
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\multipagein.hid
+tester ExecuteBranchTestBlock CommandResult BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest]
+
+
+[Test] 
+title Report Descriptor
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock ReportDescriptor BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest]
+
+
+[Test] 
+title Translator GetValue
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CreateReportTranslator BRANCH c:\data\others\multipagein.hid
+tester ExecuteBranchTestBlock ReportTranslatorGetValue BRANCH Ok
+tester ExecuteBranchTestBlock DeleteReportTranslator BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest]
+
+
+[Test] 
+title Translator GetValue Field Null
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CreateReportTranslator_FieldNull BRANCH c:\data\others\multipagein.hid
+tester ExecuteBranchTestBlock ReportTranslatorGetValue BRANCH NotFound
+tester ExecuteBranchTestBlock DeleteReportTranslator BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest]
+
+[Test] 
+title Translator GetValue NotArray
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CreateReportTranslator_NotArray BRANCH c:\data\others\multipagein.hid
+tester ExecuteBranchTestBlock ReportTranslatorGetValue BRANCH Ok
+tester ExecuteBranchTestBlock DeleteReportTranslator BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest]
+
+[Test] 
+title Translator GetValue FieldCountZero
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CreateReportTranslator_FieldCountZero BRANCH c:\data\others\multipagein.hid
+tester ExecuteBranchTestBlock ReportTranslatorGetValue BRANCH Ok
+tester ExecuteBranchTestBlock DeleteReportTranslator BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest]
+
+
+[Test] 
+title Translator Value
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CreateReportTranslator BRANCH c:\data\others\multipagein.hid
+tester ExecuteBranchTestBlock ReportTranslatorValue BRANCH
+tester ExecuteBranchTestBlock DeleteReportTranslator BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest]
+
+
+[Test] 
+title Translator GetUsageId
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CreateReportTranslator BRANCH c:\data\others\multipagein.hid
+tester ExecuteBranchTestBlock ReportTranslatorGetUsageId BRANCH Ok
+tester ExecuteBranchTestBlock DeleteReportTranslator BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Translator GetUsageId BadIndex
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CreateReportTranslator BRANCH c:\data\others\multipagein.hid
+tester ExecuteBranchTestBlock ReportTranslatorGetUsageId BRANCH BadIndex
+tester ExecuteBranchTestBlock DeleteReportTranslator BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Translator GetUsageId Field Null
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CreateReportTranslator_FieldNull BRANCH c:\data\others\multipagein.hid
+tester ExecuteBranchTestBlock ReportTranslatorGetUsageId BRANCH Error
+tester ExecuteBranchTestBlock DeleteReportTranslator BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Translator GetUsageId NotArray
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CreateReportTranslator_NotArray BRANCH c:\data\others\multipagein.hid
+tester ExecuteBranchTestBlock ReportTranslatorGetUsageId BRANCH Ok
+tester ExecuteBranchTestBlock DeleteReportTranslator BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH
+delete tester
+[Endtest]
+
+[Test] 
+title Translator UsageId
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CreateReportTranslator BRANCH c:\data\others\multipagein.hid
+tester ExecuteBranchTestBlock ReportTranslatorUsageId BRANCH
+tester ExecuteBranchTestBlock DeleteReportTranslator BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Translator Raw value
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CreateReportTranslator BRANCH c:\data\others\multipagein.hid
+tester ExecuteBranchTestBlock ReportTranslatorRawValue BRANCH
+tester ExecuteBranchTestBlock DeleteReportTranslator BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Translator Count
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CreateReportTranslator BRANCH c:\data\others\multipagein.hid
+tester ExecuteBranchTestBlock ReportTranslatorCount BRANCH NotZero
+tester ExecuteBranchTestBlock DeleteReportTranslator BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Translator Count Field Null
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CreateReportTranslator_FieldNull BRANCH c:\data\others\multipagein.hid
+tester ExecuteBranchTestBlock ReportTranslatorCount BRANCH Zero
+tester ExecuteBranchTestBlock DeleteReportTranslator BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+
+[Test] 
+title Collection type
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock Collectiontype BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Collection IsPhysical
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CollectionIsPhysical BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Collection IsLogical
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CollectionIsLogical BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Collection IsReport
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CollectionIsReport BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Collection IsNamedArray
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CollectionIsNamedArray BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Collection IsUsageSwitch
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CollectionIsUsageSwitch BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Collection IsUsageModifier
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CollectionIsUsageModifier BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Collection IsApplication
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CollectionIsApplication BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Collection UsagePage
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CollectionUsagePage BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Collection Usage
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CollectionUsage BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Collection CollectionCount
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CollectionCollectionCount BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Collection FieldCount
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CollectionFieldCount BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Collection CollectionByIndex Present
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CollectionCollectionByIndex BRANCH Present
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Collection CollectionByIndex NotPresent
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CollectionCollectionByIndex BRANCH NotPresent
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Collection FieldByIndex
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CollectionFieldByIndex BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title ReportSizeBytes
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock ReportrootReportSizeBytes BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field Logical Max
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldLogicalMax BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field Physical min
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldPhysicalMin BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field Physical max
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldPhysicalMax BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field Unit
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldUnit BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field Unit Exponent
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldUnitExponent BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field Count
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldCount BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field Size
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldSize BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field Offset SetReport
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldOffset BRANCH SetReport
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field Offset NotSetReport
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldOffset BRANCH NotSetReport
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field Report Id
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldReportId BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field Is In Report
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldIsInReport BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field Designator Index
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldDesignatorIndex BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field String Index
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldStringIndex BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field Usage Page
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldUsagePage BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field HasUsage
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldHasUsage BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field Usage Array
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldUsageArray BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field Usage
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldUsage BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field Usage Count
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldUsageCount BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field Clear Usage List
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldClearUsageList BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field Last Usage Empty
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldLastUsage BRANCH Empty
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field Last Usage NotEmpty
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldLastUsage BRANCH NotEmpty
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field Attributes
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldAttributes BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field Type
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldType BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field IsVariable
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldIsVariable BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+
+[Test] 
+title Field IsArray
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldIsArray BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+
+
+[Test] 
+title Field IsConstant
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldIsConstant BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+
+[Test] 
+title Field IsData
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldIsData BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+
+[Test] 
+title Field SetLogicalMin
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldSetLogicalMin BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field SetLogicalMax
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldSetLogicalMax BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field SetPhysicalMin
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldSetPhysicalMin BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field SetPhysicalMax
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldSetPhysicalMax BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field SetDesignatorMin
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldSetDesignatorMin BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field SetDesignatorMax
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldSetDesignatorMax BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field SetUsageMin
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldSetUsageMin BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field SetUsageMax
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldSetUsageMax BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field SetStringMin
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldSetStringMin BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field SetStringMax
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldSetStringMax BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field SetLogicalRange
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldSetLogicalRange BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field SetUsageRange
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldSetUsageRange BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field SetPhysicalRange
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldSetPhysicalRange BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field SetStringRange
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldSetStringRange BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field SetDesignatorRange
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldSetDesignatorRange BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field IsInput
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldIsInput BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+
+[Test] 
+title Field IsOutput
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldIsOutput BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title Field IsFeature
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock FieldIsFeature BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+
+[Test] 
+title ReportGeneratorReport
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CreateReportGenerator BRANCH
+tester ExecuteBranchTestBlock ReportGeneratorReport BRANCH
+tester ExecuteBranchTestBlock DeleteReportGenerator BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title ReportGeneratorReport SetField Array
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CreateReportGenerator BRANCH
+tester ExecuteBranchTestBlock ReportGeneratorSetField BRANCH Array
+tester ExecuteBranchTestBlock DeleteReportGenerator BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title ReportGeneratorReport SetField NotArray
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CreateReportGenerator BRANCH
+tester ExecuteBranchTestBlock ReportGeneratorSetField BRANCH NotArray
+tester ExecuteBranchTestBlock DeleteReportGenerator BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title ReportGeneratorReport SetField NotArrayOutOfRange
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CreateReportGenerator BRANCH
+tester ExecuteBranchTestBlock ReportGeneratorSetField BRANCH NotArrayOutOfRange
+tester ExecuteBranchTestBlock DeleteReportGenerator BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+
+[Test] 
+title ReportGeneratorReport SetField FieldNull
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CreateReportGenerator BRANCH
+tester ExecuteBranchTestBlock ReportGeneratorSetField BRANCH FieldNull
+tester ExecuteBranchTestBlock DeleteReportGenerator BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title ReportGeneratorReport SetField FieldCountZero
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CreateReportGenerator BRANCH
+tester ExecuteBranchTestBlock ReportGeneratorSetField BRANCH FieldCountZero
+tester ExecuteBranchTestBlock DeleteReportGenerator BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title ReportGeneratorReport SetField NotExistingUsage
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CreateReportGenerator BRANCH
+tester ExecuteBranchTestBlock ReportGeneratorSetField BRANCH NotExistingUsage
+tester ExecuteBranchTestBlock DeleteReportGenerator BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title ReportGeneratorReport SetField NotExistingUsage2
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CreateReportGenerator BRANCH
+tester ExecuteBranchTestBlock ReportGeneratorSetField BRANCH NotExistingUsage2
+tester ExecuteBranchTestBlock DeleteReportGenerator BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+
+[Test] 
+title ReportGeneratorReport SetField BadIndex
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\connectad83.hid
+tester ExecuteBranchTestBlock CreateReportGenerator BRANCH
+tester ExecuteBranchTestBlock ReportGeneratorSetField BRANCH BadIndex
+tester ExecuteBranchTestBlock DeleteReportGenerator BRANCH
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+
+[Test] 
+title OutputReport
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\output.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title FeautureReport
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\feature.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Global physical
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\physicalmax.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Unit
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\unit.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Unit exponent
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\unitexponent.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Designator limit test
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\designator.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Delimiter test
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\delimiter.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  String limit test
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\string.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Push whitout pop
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\push.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Pop whitout push
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\pop.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  String index
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\stringindex.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Designator index
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\designatorindex.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Local Designator index
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\localdesignatorindex.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Local Designator minimum
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\localdesignatorminimum.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Local Designator maximum
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH  c:\data\others\localdesignatormaximum.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Local String index
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\localstringindex.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Local String minimum
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\localstringminimum.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Local String maximum
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\localstringmaximum.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+
+[Test] 
+title  Local Delimiter - unknown delimiter
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\localdelimiter.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Local Delimiter - lonely delimiter
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\localdelimiter_lonelydelimiter.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Local Delimiter - nested delimiter
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\localdelimiter_nesteddelimiter.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Local Usage
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\localusage.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Local Usage minimum
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\localusageminimum.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Local Usage maximum
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\localusagemaximum.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Local item - unknown
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\localitem_unknown.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Global Physical minimum
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\globalphysicalmin.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Global Physical maximum
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\globalphysicalmax.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Global Unit
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\globalunit.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Global Unit small value
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\globalunit_smallvalue.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Global Unit exponent
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\globalunitexponent.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Global Unit exponent2
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\globalunitexponent2.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Global push
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\globalpush.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Global pop
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\globalpop.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Global pop without push
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\globalpop_withoutpush.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Global item - unknown
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\globaitem_unknown.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Main Output Tag
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\mainoutputtag.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Main Feature
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\mainfeature.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Long Item
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\longitem.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Handle Item - within delimiter
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\handleitem_withindelimiter.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  Main Item - unknown
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\mainitem_unknown.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  check usage min and max - LonelyUsageMin
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\checkusageminandmax.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  check usage min and max - LonelyUsageMax
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\checkusageminandmax2.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  check usage min and max - UsageMinExceedsMax
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\checkusageminandmax3.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  check designator min and max - LonelyDesignatorMin
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\checkdesignatorminandmax.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  check designator min and max - LonelyDesignatorMax
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\checkdesignatorminandmax2.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  check designator min and max - DesignatorMinExceedsMax
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\checkdesignatorminandmax3.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  check string min and max - LonelyStringMin
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\checkstringminandmax.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  check string min and max - LonelyStringMax
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\checkstringminandmax2.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  check string min and max - StringMinExceedsMax
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\checkstringminandmax3.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  check mandatory field existence
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\checkmandatoryfieldexistence.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  check mandatory field existence2
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\checkmandatoryfieldexistence2.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  check mandatory field existence3
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\checkmandatoryfieldexistence3.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  check for field errors
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\checkforfielderrors.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  check for field errors2
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\checkforfielderrors2.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  check logical min and max
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\checklogicalminandmax.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  check field bit needed
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\checkfieldbitneeded.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  check for main errors
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\checkformainerrors.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  check for main errors2
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\checkformainerrors2.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  check for main errors3
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\checkformainerrors3.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  check for main errors3
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\checkformainerrors3.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  check parse errors
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\checkparseerrors.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  check parse errors2
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\checkparseerrors2.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  check parse errors3
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\checkparseerrors3.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test] 
+title  check for collection errors
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\checkforcollectionerrors.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+/////////////////////////////////
+[Test]
+title  Hangup
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\headsetconnect.hid
+tester ExecuteBranchTestBlock Wait BRANCH 2
+tester ExecuteBranchTestBlock CreateCall BRANCH +48607939016 //+358405695587
+tester ExecuteBranchTestBlock Wait BRANCH 5
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\hook.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test]
+title  Redial
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\headsetconnect.hid
+tester ExecuteBranchTestBlock Wait BRANCH 2
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\hook.hid
+tester ExecuteBranchTestBlock Wait BRANCH 1
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\hook.hid
+tester ExecuteBranchTestBlock Wait BRANCH 2
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\hook.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+delete tester
+[Endtest]
+
+[Test]
+title  Snooze Alarm
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\headsetconnect.hid
+tester ExecuteBranchTestBlock AddAlarm BRANCH 1
+tester ExecuteBranchTestBlock Wait BRANCH 80
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\hook.hid
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\hook.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+tester ExecuteBranchTestBlock DeleteAlarm BRANCH
+delete tester
+[Endtest]
+
+[Test]
+title  Stop Alarm
+create GenericHidTest tester
+tester ExecuteBranchTestBlock Connect BRANCH c:\data\others\headsetconnect.hid
+tester ExecuteBranchTestBlock AddAlarm BRANCH 1
+tester ExecuteBranchTestBlock Wait BRANCH 80
+tester ExecuteBranchTestBlock DataIn BRANCH c:\data\others\hook.hid
+tester ExecuteBranchTestBlock Disconnect BRANCH 
+tester ExecuteBranchTestBlock DeleteAlarm BRANCH
+delete tester
+[Endtest]
+//
+// Add new branch tests here
+// ...
+
+//Field SetLogicalRange
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/E000B181.rss	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <RegistryInfo.rh>
+
+// Declares info for two implementations
+RESOURCE REGISTRY_INFO theInfo
+	{
+	// UID for the DLL
+	dll_uid = 0xE000B181;
+	// Declare array of interface info
+	interfaces = 
+		{
+		INTERFACE_INFO
+			{
+			// UID of interface that is implemented
+			interface_uid = 0x10201d26; 
+			implementations = 
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0xE000B187;
+					version_no = 1;
+					display_name = "CHidDriverPlugin";
+					default_data = "";
+					opaque_data = "";
+					}
+				};
+			}
+		};
+	}
+
+//
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/UsagePoC.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,2 @@
+	0x33, 0x01
+	
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkdesignatorminandmax.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,2 @@
+0x49, 0x00, //define designator minimum
+0x91, 0x01 // main output tag - create field
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkdesignatorminandmax2.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,2 @@
+0x59, 0x00, //define designator maximum
+0x91, 0x01 // main output tag - create field
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkdesignatorminandmax3.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,3 @@
+0x49, 0x10, //define designator minimum
+0x59, 0x00, //define designator maximum
+0x91, 0x01 // main output tag - create field
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkfieldbitneeded.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,28 @@
+//0x91, 0x00, // main output tag - create field
+0x91, 0x41, // main output tag - create field KNullStateFlag
+
+
+//tests for BitsToRepresentRange
+0x15, 0x10, //define logical minimum
+0x25, 0x10, //define logical maximum
+0x91, 0x01, // main output tag - create field
+
+0x15, 0x05, //define logical minimum
+0x25, 0x10, //define logical maximum
+0x91, 0x01, // main output tag - create field
+
+
+0x17, 0xFF, 0xFF, 0xFF, 0xFF, //define logical minimum - negative minimum
+0x25, 0x10, //define logical maximum
+0x91, 0x01, // main output tag - create field
+
+0x15, 0x05, //define logical minimum
+0x25, 0x10, //define logical maximum
+
+//0x75, 0x00, // set iGlobal.iSize to 0
+0x77, 0xFF, 0xFF, 0xFF, 0xFF, // set iGlobal.iSize to -1
+
+0x91, 0x01, // main output tag - create field
+
+0x75, 0x00, // set iGlobal.iSize to 0
+0x91, 0x01 // main output tag - create field
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkforcollectionerrors.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,16 @@
+0xA1, 0x81, //main collection
+0xC0, //end collection
+
+0xA1, 0x07, //main collection
+0xC0, //end collection
+
+0x09, 0xc8, // add local usage
+0x05, 0xc8, // add local usage page
+
+0xA1, 0x01, //main collection
+0xC0, //end collection
+
+0x79, 0xc8, //local string index - KUnusedLocalItemsMask
+
+0xA1, 0x01, //main collection
+0xC0, //end collection
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkforfielderrors.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,3 @@
+0x15, 0x10, //define logical minimum
+0x25, 0x00, //define logical maximum
+0x91, 0x01 // main output tag - create field
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkforfielderrors2.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,3 @@
+0x35, 0x10, //define physical minimum
+0x45, 0x00, //define physical maximum
+0x91, 0x01 // main output tag - create field
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkformainerrors.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,15 @@
+0x35, 0x10, //define physical minimum
+0x45, 0x00, //define physical maximum
+
+0xA1, 0x01, //main collection
+0xC0 //end collection
+
+0x15, 0x10, //define logical minimum
+0x25, 0x00, //define logical maximum
+0xA1, 0x01, //main collection
+0xC0 //end collection
+
+0x15, 0x00, //define logical minimum
+0x25, 0x10, //define logical maximum
+0xA1, 0x01, //main collection
+0xC0 //end collection
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkformainerrors2.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,3 @@
+0x35, 0x00, //define physical minimum
+
+0x91, 0x01 // main output tag - create field
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkformainerrors3.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,3 @@
+0x45, 0x00, //define physical maximum
+
+0x91, 0x01 // main output tag - create field
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/checklogicalminandmax.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,9 @@
+//0x91, 0x01, // main output tag - create field
+//0x91, 0xf0, // main output tag - create field
+
+0x25, 0x20, //define logical maximum
+0x15, 0x10, //define logical minimum - wrong for array
+0x91, 0x03, // main output tag - create field ELogicalMinInvalidForArray
+
+0x09, 0xc8, // add local usage
+0x91, 0x03 // main output tag - create field ELogicalMinInvalidForArray
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkmandatoryfieldexistence.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0x91, 0x00 // main output tag - create field
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkmandatoryfieldexistence2.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0xB1, 0x00 // main feature - create field
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkmandatoryfieldexistence3.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0x81, 0x00 // main input tag - create field
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkparseerrors.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0xa9, 0x01      //   begin delimiter
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkparseerrors2.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0xA1, 0x01 //main collection
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkparseerrors3.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0xA4  //global push - no data
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkstringminandmax.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,2 @@
+0x89, 0x00, // define string minimum
+0x91, 0x01 // main output tag - create field
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkstringminandmax2.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,2 @@
+0x99, 0x00, // define string maximum
+0x91, 0x01 // main output tag - create field
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkstringminandmax3.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,3 @@
+0x89, 0x10, // define string minimum
+0x99, 0x00, // define string maximum
+0x91, 0x01 // main output tag - create field
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkusageminandmax.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,2 @@
+0x19, 0x00, //define usage min to 0
+0x91, 0x01 // main output tag - create field
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkusageminandmax2.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,2 @@
+0x29, 0x00, //define usage max to 0
+0x91, 0x01 // main output tag - create field
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/checkusageminandmax3.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,3 @@
+0x19, 0x10, //define usage min to 0
+0x29, 0x00, //define usage max to 0
+0x91, 0x01 // main output tag - create field
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/connectad83.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,36 @@
+0x05, 0x0C,
+0x09, 0x01,
+0xA1, 0x01,
+0x15, 0x00,
+0x25, 0x01,
+0x75, 0x01,
+0x09, 0xE9,
+0x09, 0xEA,
+0x95, 0x02,
+0x81, 0x02,
+0x05, 0x0B,
+0x09, 0x2F,
+0x95, 0x01,
+0x81, 0x06,
+0x09, 0x20,
+0x81, 0x02,
+0x06, 0x00, 0xFF,
+0x09, 0x01,
+0x09, 0x02,
+0x95, 0x02,
+0x81, 0x02,
+0x95, 0x02,
+0x81, 0x01,
+0x05, 0x0C,
+0x09, 0xB0,
+0x09, 0xB3,
+0x09, 0xB4,
+0x09, 0xB7,
+0x09, 0xB5,
+0x09, 0xB6,
+0x09, 0xB9,
+0x95, 0x07,
+0x81, 0x06,
+0x95, 0x01,
+0x81, 0x01,
+0xC0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/delimiter.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,36 @@
+// Filename: delimiter1.hid.txt
+// A valid delimiter Open and Close
+
+    0x05, 0x01,              // USAGE_PAGE (Generic Desktop)
+    0x09, 0x06,              // USAGE (Keyboard)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x01,              //   REPORT_ID (1)
+    0x05, 0x08,              //   USAGE_PAGE (LEDs)
+    0xA9, 0x01,              //   DELIMITER (OPEN)
+    0x19, 0x01,              //   USAGE_MINIMUM (Num Lock)
+    0x29, 0x03,              //   USAGE_MAXIMUM (Scroll Lock)
+    0x15, 0x00,              //   LOGICAL_MINIMUM (0)
+    0x25, 0x01,              //   LOGICAL_MAXIMUM (1)
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x95, 0x03,              //   REPORT_COUNT (3)
+    0xA9, 0x00,              //   DELIMITER (CLOSE)
+    0x91, 0x02,              //   OUTPUT (Data,Var,Abs)
+    0x09, 0x4B,              //   USAGE (Generic indicator)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x91, 0x02,              //   OUTPUT (Data,Var,Abs)
+    0x95, 0x04,              //   REPORT_COUNT (4)
+    0x91, 0x01,              //   OUTPUT (Cnst,Ary,Abs)
+    0x05, 0x07,              //   USAGE_PAGE (Keyboard)
+    0x19, 0xE0,              //   USAGE_MINIMUM (Keyboard LeftControl)
+    0x29, 0xE7,              //   USAGE_MAXIMUM (Keyboard Right GUI)
+    0x95, 0x08,              //   REPORT_COUNT (8)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x75, 0x08,              //   REPORT_SIZE (8)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0x19, 0x00,              //   USAGE_MINIMUM (No event)
+    0x29, 0x91,              //   USAGE_MAXIMUM (Keyboard LANG2)
+    0x26, 0xFF, 0x00,        //   LOGICAL_MAXIMUM (255)
+    0x95, 0x06,              //   REPORT_COUNT (6)
+    0x81, 0x00,              //   INPUT (Data,Ary,Abs)
+    0xC0,                    // END_COLLECTION
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/designator.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,154 @@
+// File: DesignatorMin1.hid.txt
+// Designator Min defined, but no Designator Max
+
+
+    0x05, 0x01,              // USAGE_PAGE (Generic Desktop)
+    0x09, 0x06,              // USAGE (Keyboard)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x01,              //   REPORT_ID (1)
+    0x05, 0x08,              //   USAGE_PAGE (LEDs)
+    0x19, 0x01,              //   USAGE_MINIMUM (Num Lock)
+    0x29, 0x03,              //   USAGE_MAXIMUM (Scroll Lock)
+    0x15, 0x00,              //   LOGICAL_MINIMUM (0)
+    0x25, 0x01,              //   LOGICAL_MAXIMUM (1)
+// Designator Min defined, but no Designator Max
+    0x49, 0x01,              // DESIGNATOR_MINIMUM (1)
+    0x59, 0x20               // DESIGNATOR_MAXIMUM (32)
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x95, 0x03,              //   REPORT_COUNT (3)
+    0x91, 0x02,              //   OUTPUT (Data,Var,Abs)
+    0x09, 0x4B,              //   USAGE (Generic indicator)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x91, 0x02,              //   OUTPUT (Data,Var,Abs)
+    0x95, 0x04,              //   REPORT_COUNT (4)
+    0x91, 0x01,              //   OUTPUT (Cnst,Ary,Abs)
+    0x05, 0x07,              //   USAGE_PAGE (Keyboard)
+    0x19, 0xE0,              //   USAGE_MINIMUM (Keyboard LeftControl)
+    0x29, 0xE7,              //   USAGE_MAXIMUM (Keyboard Right GUI)
+    0x95, 0x08,              //   REPORT_COUNT (8)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x75, 0x08,              //   REPORT_SIZE (8)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0x19, 0x00,              //   USAGE_MINIMUM (No event)
+    0x29, 0x91,              //   USAGE_MAXIMUM (Keyboard LANG2)
+    0x26, 0xFF, 0x00,        //   LOGICAL_MAXIMUM (255)
+    0x95, 0x06,              //   REPORT_COUNT (6)
+    0x81, 0x00,              //   INPUT (Data,Ary,Abs)
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x0C,              // USAGE_PAGE (Consumer Devices)
+    0x09, 0x01,              // USAGE (Consumer Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x02,              //   REPORT_ID (2)
+    0x05, 0x0C,              //   USAGE_PAGE (Consumer Devices)
+    0x15, 0x00,              //   LOGICAL_MINIMUM (0)
+    0x25, 0x01,              //   LOGICAL_MAXIMUM (1)
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x95, 0x1C,              //   REPORT_COUNT (28)
+    0x09, 0xE2,              //   USAGE (Mute)
+    0x09, 0xB7,              //   USAGE (Stop)
+    0x09, 0xCD,              //   USAGE (Play/pause)
+    0x09, 0xEA,              //   USAGE (Volume Down)
+    0x09, 0xE9,              //   USAGE (Volume Up)
+    0x09, 0xB6,              //   USAGE (Scan Previous Track)
+    0x09, 0xB5,              //   USAGE (Scan Next Track)
+    0x0A, 0x83, 0x01,        //   USAGE (Control config)
+    0x0A, 0x1A, 0x02,        //   USAGE (Undo)
+    0x0A, 0x79, 0x02,        //   USAGE (Redo)
+    0x0A, 0xAB, 0x01,        //   USAGE (Spell check)
+    0x0A, 0x08, 0x02,        //   USAGE (Print)
+    0x0A, 0x02, 0x02,        //   USAGE (Open)
+    0x0A, 0x03, 0x02,        //   USAGE (Close)
+    0x0A, 0x07, 0x02,        //   USAGE (Save)
+    0x0A, 0x01, 0x02,        //   USAGE (New)
+    0x0A, 0x92, 0x01,        //   USAGE (Calculator)
+    0x0A, 0x9C, 0x01,        //   USAGE (Logoff)
+    0x09, 0x95,              //   USAGE (Help)
+    0x0A, 0x23, 0x02,        //   USAGE (Home)
+    0x0A, 0x89, 0x02,        //   USAGE (Reply)
+    0x0A, 0x8B, 0x02,        //   USAGE (Sendto
+    0x0A, 0x8C, 0x02,        //   USAGE (Send)
+    0x0A, 0x8A, 0x01,        //   USAGE (Email
+    0x0A, 0x99, 0x01,        //   USAGE (Chat)
+    0x0A, 0xA7, 0x01,        //   USAGE (Documents)
+    0x0A, 0xB6, 0x01,        //   USAGE (Unknown 0x01b6)
+    0x0A, 0xB7, 0x01,        //   USAGE (Unknown 0x01b7)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x95, 0x04,              //   REPORT_COUNT (4)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0x06, 0x00, 0xFF,        //   USAGE_PAGE (Vendor Defined Page 1)
+    0x0A, 0x02, 0xFF,        //   USAGE (Unknown 0xff02)
+    0x26, 0xFF, 0x00,        //   LOGICAL_MAXIMUM (255)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x75, 0x08,              //   REPORT_SIZE (8)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x01,              // USAGE_PAGE (Generic Desktop)
+    0x09, 0x80,              // USAGE (System Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x03,              //   REPORT_ID (3)
+    0x19, 0x81,              //   USAGE_MINIMUM (System Power Down)
+    0x29, 0x83,              //   USAGE_MAXIMUM (System Wake Up)
+    0x25, 0x01,              //   LOGICAL_MAXIMUM (1)
+    0x95, 0x03,              //   REPORT_COUNT (3)
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x95, 0x05,              //   REPORT_COUNT (5)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x0C,              // USAGE_PAGE (Consumer Devices)
+    0x09, 0x01,              // USAGE (Consumer Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x04,              //   REPORT_ID (4)
+    0x05, 0x01,              //   USAGE_PAGE (Generic Desktop)
+    0x09, 0x06,              //   USAGE (Keyboard)
+    0xA1, 0x02,              //   COLLECTION (Logical)
+    0x06, 0x00, 0xFF,        //     USAGE_PAGE (Vendor Defined Page 1)
+    0x15, 0x00,              //     LOGICAL_MINIMUM (0)
+    0x25, 0x03,              //     LOGICAL_MAXIMUM (3)
+    0x95, 0x01,              //     REPORT_COUNT (1)
+    0x75, 0x02,              //     REPORT_SIZE (2)
+    0x0A, 0x01, 0xFE,        //     USAGE (Unknown 1)
+    0x81, 0x02,              //     INPUT (Data,Var,Abs)
+    0x75, 0x06,              //     REPORT_SIZE (6)
+    0x81, 0x01,              //     INPUT (Cnst,Ary,Abs)
+    0xC0,                    //   END_COLLECTION
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x0C,              // USAGE_PAGE (Consumer Devices)
+    0x09, 0x01,              // USAGE (Consumer Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x05,              //   REPORT_ID (5)
+    0x05, 0x01,              //   USAGE_PAGE (Generic Desktop)
+    0x09, 0x06,              //   USAGE (Keyboard)
+    0xA1, 0x02,              //   COLLECTION (Logical)
+    0x06, 0x00, 0xFF,        //     USAGE_PAGE (Vendor Defined Page 1)
+    0x25, 0x01,              //     LOGICAL_MAXIMUM (1)
+    0x75, 0x01,              //     REPORT_SIZE (1)
+    0x95, 0x02,              //     REPORT_COUNT (2)
+    0x0A, 0x03, 0xFE,        //     USAGE (Unknown 0xfe03)
+    0x0A, 0x04, 0xFE,        //     USAGE (Unknown 0xfe04)
+    0x81, 0x02,              //     INPUT (Data,Var,Abs)
+    0x95, 0x06,              //     REPORT_COUNT (6)
+    0x81, 0x01,              //     INPUT (Cnst,Ary,Abs)
+    0xC0,                    //   END_COLLECTION
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x0C,              // USAGE_PAGE (Consumer Devices)
+    0x09, 0x01,              // USAGE (Consumer Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0xFF,              //   REPORT_ID (255)
+    0x05, 0x06,              //   USAGE_PAGE (Generic Device Controls)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x75, 0x02,              //   REPORT_SIZE (2)
+    0x19, 0x24,              //   USAGE_MINIMUM (Unknown 0x24)
+    0x29, 0x26,              //   USAGE_MAXIMUM (Unknown 0x26)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x75, 0x06,              //   REPORT_SIZE (6)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0xC0                     // END_COLLECTION
+//    };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/designatorindex.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,155 @@
+// File: DesignatorMin1.hid.txt
+// Designator Min defined, but no Designator Max
+
+
+    0x05, 0x01,              // USAGE_PAGE (Generic Desktop)
+    0x09, 0x06,              // USAGE (Keyboard)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x01,              //   REPORT_ID (1)
+    0x05, 0x08,              //   USAGE_PAGE (LEDs)
+    0x19, 0x01,              //   USAGE_MINIMUM (Num Lock)
+    0x29, 0x03,              //   USAGE_MAXIMUM (Scroll Lock)
+    0x15, 0x00,              //   LOGICAL_MINIMUM (0)
+    0x25, 0x01,              //   LOGICAL_MAXIMUM (1)
+// Designator Min defined, but no Designator Max
+    0x49, 0x01,              // DESIGNATOR_MINIMUM (1)
+    0x59, 0x20               // DESIGNATOR_MAXIMUM (32)
+    0x39, 0x14               // DESIGNATOR_INDEX
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x95, 0x03,              //   REPORT_COUNT (3)
+    0x91, 0x02,              //   OUTPUT (Data,Var,Abs)
+    0x09, 0x4B,              //   USAGE (Generic indicator)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x91, 0x02,              //   OUTPUT (Data,Var,Abs)
+    0x95, 0x04,              //   REPORT_COUNT (4)
+    0x91, 0x01,              //   OUTPUT (Cnst,Ary,Abs)
+    0x05, 0x07,              //   USAGE_PAGE (Keyboard)
+    0x19, 0xE0,              //   USAGE_MINIMUM (Keyboard LeftControl)
+    0x29, 0xE7,              //   USAGE_MAXIMUM (Keyboard Right GUI)
+    0x95, 0x08,              //   REPORT_COUNT (8)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x75, 0x08,              //   REPORT_SIZE (8)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0x19, 0x00,              //   USAGE_MINIMUM (No event)
+    0x29, 0x91,              //   USAGE_MAXIMUM (Keyboard LANG2)
+    0x26, 0xFF, 0x00,        //   LOGICAL_MAXIMUM (255)
+    0x95, 0x06,              //   REPORT_COUNT (6)
+    0x81, 0x00,              //   INPUT (Data,Ary,Abs)
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x0C,              // USAGE_PAGE (Consumer Devices)
+    0x09, 0x01,              // USAGE (Consumer Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x02,              //   REPORT_ID (2)
+    0x05, 0x0C,              //   USAGE_PAGE (Consumer Devices)
+    0x15, 0x00,              //   LOGICAL_MINIMUM (0)
+    0x25, 0x01,              //   LOGICAL_MAXIMUM (1)
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x95, 0x1C,              //   REPORT_COUNT (28)
+    0x09, 0xE2,              //   USAGE (Mute)
+    0x09, 0xB7,              //   USAGE (Stop)
+    0x09, 0xCD,              //   USAGE (Play/pause)
+    0x09, 0xEA,              //   USAGE (Volume Down)
+    0x09, 0xE9,              //   USAGE (Volume Up)
+    0x09, 0xB6,              //   USAGE (Scan Previous Track)
+    0x09, 0xB5,              //   USAGE (Scan Next Track)
+    0x0A, 0x83, 0x01,        //   USAGE (Control config)
+    0x0A, 0x1A, 0x02,        //   USAGE (Undo)
+    0x0A, 0x79, 0x02,        //   USAGE (Redo)
+    0x0A, 0xAB, 0x01,        //   USAGE (Spell check)
+    0x0A, 0x08, 0x02,        //   USAGE (Print)
+    0x0A, 0x02, 0x02,        //   USAGE (Open)
+    0x0A, 0x03, 0x02,        //   USAGE (Close)
+    0x0A, 0x07, 0x02,        //   USAGE (Save)
+    0x0A, 0x01, 0x02,        //   USAGE (New)
+    0x0A, 0x92, 0x01,        //   USAGE (Calculator)
+    0x0A, 0x9C, 0x01,        //   USAGE (Logoff)
+    0x09, 0x95,              //   USAGE (Help)
+    0x0A, 0x23, 0x02,        //   USAGE (Home)
+    0x0A, 0x89, 0x02,        //   USAGE (Reply)
+    0x0A, 0x8B, 0x02,        //   USAGE (Sendto
+    0x0A, 0x8C, 0x02,        //   USAGE (Send)
+    0x0A, 0x8A, 0x01,        //   USAGE (Email
+    0x0A, 0x99, 0x01,        //   USAGE (Chat)
+    0x0A, 0xA7, 0x01,        //   USAGE (Documents)
+    0x0A, 0xB6, 0x01,        //   USAGE (Unknown 0x01b6)
+    0x0A, 0xB7, 0x01,        //   USAGE (Unknown 0x01b7)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x95, 0x04,              //   REPORT_COUNT (4)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0x06, 0x00, 0xFF,        //   USAGE_PAGE (Vendor Defined Page 1)
+    0x0A, 0x02, 0xFF,        //   USAGE (Unknown 0xff02)
+    0x26, 0xFF, 0x00,        //   LOGICAL_MAXIMUM (255)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x75, 0x08,              //   REPORT_SIZE (8)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x01,              // USAGE_PAGE (Generic Desktop)
+    0x09, 0x80,              // USAGE (System Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x03,              //   REPORT_ID (3)
+    0x19, 0x81,              //   USAGE_MINIMUM (System Power Down)
+    0x29, 0x83,              //   USAGE_MAXIMUM (System Wake Up)
+    0x25, 0x01,              //   LOGICAL_MAXIMUM (1)
+    0x95, 0x03,              //   REPORT_COUNT (3)
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x95, 0x05,              //   REPORT_COUNT (5)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x0C,              // USAGE_PAGE (Consumer Devices)
+    0x09, 0x01,              // USAGE (Consumer Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x04,              //   REPORT_ID (4)
+    0x05, 0x01,              //   USAGE_PAGE (Generic Desktop)
+    0x09, 0x06,              //   USAGE (Keyboard)
+    0xA1, 0x02,              //   COLLECTION (Logical)
+    0x06, 0x00, 0xFF,        //     USAGE_PAGE (Vendor Defined Page 1)
+    0x15, 0x00,              //     LOGICAL_MINIMUM (0)
+    0x25, 0x03,              //     LOGICAL_MAXIMUM (3)
+    0x95, 0x01,              //     REPORT_COUNT (1)
+    0x75, 0x02,              //     REPORT_SIZE (2)
+    0x0A, 0x01, 0xFE,        //     USAGE (Unknown 1)
+    0x81, 0x02,              //     INPUT (Data,Var,Abs)
+    0x75, 0x06,              //     REPORT_SIZE (6)
+    0x81, 0x01,              //     INPUT (Cnst,Ary,Abs)
+    0xC0,                    //   END_COLLECTION
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x0C,              // USAGE_PAGE (Consumer Devices)
+    0x09, 0x01,              // USAGE (Consumer Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x05,              //   REPORT_ID (5)
+    0x05, 0x01,              //   USAGE_PAGE (Generic Desktop)
+    0x09, 0x06,              //   USAGE (Keyboard)
+    0xA1, 0x02,              //   COLLECTION (Logical)
+    0x06, 0x00, 0xFF,        //     USAGE_PAGE (Vendor Defined Page 1)
+    0x25, 0x01,              //     LOGICAL_MAXIMUM (1)
+    0x75, 0x01,              //     REPORT_SIZE (1)
+    0x95, 0x02,              //     REPORT_COUNT (2)
+    0x0A, 0x03, 0xFE,        //     USAGE (Unknown 0xfe03)
+    0x0A, 0x04, 0xFE,        //     USAGE (Unknown 0xfe04)
+    0x81, 0x02,              //     INPUT (Data,Var,Abs)
+    0x95, 0x06,              //     REPORT_COUNT (6)
+    0x81, 0x01,              //     INPUT (Cnst,Ary,Abs)
+    0xC0,                    //   END_COLLECTION
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x0C,              // USAGE_PAGE (Consumer Devices)
+    0x09, 0x01,              // USAGE (Consumer Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0xFF,              //   REPORT_ID (255)
+    0x05, 0x06,              //   USAGE_PAGE (Generic Device Controls)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x75, 0x02,              //   REPORT_SIZE (2)
+    0x19, 0x24,              //   USAGE_MINIMUM (Unknown 0x24)
+    0x29, 0x26,              //   USAGE_MAXIMUM (Unknown 0x26)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x75, 0x06,              //   REPORT_SIZE (6)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0xC0                     // END_COLLECTION
+//    };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/dummyconnect.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,25 @@
+0x05, 0x02,                   //Global usage page 12
+0x09, 0x01,                   //Local usage page 1
+0xa1, 0x01,                   //Collection Application
+0x15, 0x00,                   //Global Locgical minimium
+0x25, 0x01,                   //Global Logical maxim
+0x75, 0x01,                   //Global Report size 1
+0x09, 0xE9,                   //Local usage Volume up           
+0x09, 0xEA,                   //Local usage Volume down          
+0x95, 0x02,                   //Global Report Count 2
+0x81, 0x02,                   //Input 2     First field    
+0x05, 0x03,                   //Global usage page 11
+0x09, 0x2F,                   //Local usage mute
+0x95, 0x01,                   //Global Report Count 1
+0x81, 0x06,                   //Input 6   2. field    
+0x09, 0x20,                   //Local usage hook
+0x95, 0x01,                   //Global Report Count 1
+0x81, 0x02,                   //Input 2   3. field
+0x05, 0x02,                   //Global usage page 12 (consumer)
+0x09, 0xCD,                   //Local usage play/pause
+0x09, 0xb5,                   //Local usage 0xb5 ScanNext
+0x09, 0xb6,                   //Local usage 0xb6 ScanPrev
+0x09, 0xb7,                   //Local usage 0xb7 Stop
+0x95, 0x04,                   //Global Report Count 4
+0x81, 0x02,                   //Input 2   6. field
+0xc0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/empty.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0x0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/feature.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,37 @@
+// File: Feature1.hid.txt
+// A Feature item defined with no Global or Local items defined
+
+    0xa1, 0x02,                    // COLLECTION (Logical)
+    0xa1, 0x02,                    //   COLLECTION (Logical)
+// No global or Local items defined
+    0xb1, 0x40,                    //     FEATURE (Data,Ary,Abs,Null)
+    0xc0,                          //   END_COLLECTION
+    0x09, 0x47,                    //   USAGE (Usage Indicator Color)
+    0xa1, 0x02,                    //   COLLECTION (Logical)
+    0x09, 0x48,                    //     USAGE (Red)
+    0x09, 0x49,                    //     USAGE (Green)
+    0x09, 0x4a,                    //     USAGE (Amber)
+    0xb1, 0x40,                    //     FEATURE (Data,Ary,Abs,Null)
+    0xc0,                          //   END_COLLECTION
+    0xc0,                          // END_COLLECTION
+    0x05, 0x0c,                    // USAGE_PAGE (Consumer Devices)
+    0x19, 0xb7,                    // USAGE_MINIMUM (Stop)
+    0xa1, 0x02,                    // COLLECTION (Logical)
+    0x05, 0x08,                    //   USAGE_PAGE (LEDs)
+    0x09, 0x3c,                    //   USAGE (Usage Multi Mode Indicator)
+    0xa1, 0x02,                    //   COLLECTION (Logical)
+    0x09, 0x3d,                    //     USAGE (Indicator On)
+    0x09, 0x3f,                    //     USAGE (Indicator Slow Blink)
+    0x09, 0x41,                    //     USAGE (Indicator Off)
+    0xb1, 0x40,                    //     FEATURE (Data,Ary,Abs,Null)
+    0xc0,                          //   END_COLLECTION
+    0x09, 0x47,                    //   USAGE (Usage Indicator Color)
+    0xa1, 0x02,                    //   COLLECTION (Logical)
+    0x09, 0x48,                    //     USAGE (Red)
+    0x09, 0x49,                    //     USAGE (Green)
+    0x09, 0x4a,                    //     USAGE (Amber)
+    0xb1, 0x40,                    //     FEATURE (Data,Ary,Abs,Null)
+    0xc0,                          //   END_COLLECTION
+    0xc0                           // END_COLLECTION
+//};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/feature1.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,37 @@
+// File: Feature1.hid.txt
+// A Feature item defined with no Global or Local items defined
+
+    0xa1, 0x02,                    // COLLECTION (Logical)
+    0xa1, 0x02,                    //   COLLECTION (Logical)
+// No global or Local items defined
+    0xb1, 0x40,                    //     FEATURE (Data,Ary,Abs,Null)
+    0xc0,                          //   END_COLLECTION
+    0x09, 0x47,                    //   USAGE (Usage Indicator Color)
+    0xa1, 0x02,                    //   COLLECTION (Logical)
+    0x09, 0x48,                    //     USAGE (Red)
+    0x09, 0x49,                    //     USAGE (Green)
+    0x09, 0x4a,                    //     USAGE (Amber)
+    0xb1, 0x40,                    //     FEATURE (Data,Ary,Abs,Null)
+    0xc0,                          //   END_COLLECTION
+    0xc0,                          // END_COLLECTION
+    0x05, 0x0c,                    // USAGE_PAGE (Consumer Devices)
+    0x19, 0xb7,                    // USAGE_MINIMUM (Stop)
+    0xa1, 0x02,                    // COLLECTION (Logical)
+    0x05, 0x08,                    //   USAGE_PAGE (LEDs)
+    0x09, 0x3c,                    //   USAGE (Usage Multi Mode Indicator)
+    0xa1, 0x02,                    //   COLLECTION (Logical)
+    0x09, 0x3d,                    //     USAGE (Indicator On)
+    0x09, 0x3f,                    //     USAGE (Indicator Slow Blink)
+    0x09, 0x41,                    //     USAGE (Indicator Off)
+    0xb1, 0x40,                    //     FEATURE (Data,Ary,Abs,Null)
+    0xc0,                          //   END_COLLECTION
+    0x09, 0x47,                    //   USAGE (Usage Indicator Color)
+    0xa1, 0x02,                    //   COLLECTION (Logical)
+    0x09, 0x48,                    //     USAGE (Red)
+    0x09, 0x49,                    //     USAGE (Green)
+    0x09, 0x4a,                    //     USAGE (Amber)
+    0xb1, 0x40,                    //     FEATURE (Data,Ary,Abs,Null)
+    0xc0,                          //   END_COLLECTION
+    0xc0                           // END_COLLECTION
+//};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/globaitem_unknown.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0xF5, 0x01 // global item - unknown
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/globalphysicalmax.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,2 @@
+0x45, 0xc8, //global physical maximum (200)
+0x45, 0xc8  //global physical maximum (200)
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/globalphysicalmin.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,2 @@
+0x35, 0xc8, //global physical minimum (200)
+0x35, 0xc8  //global physical minimum (200)
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/globalpop.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,4 @@
+0xA4,  //global push - no data
+0xB4, // global pop
+0xA4,  //global push - no data
+0xB5, 0x01 // global pop with data
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/globalpop_withoutpush.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0xB4 // global pop
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/globalpush.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,3 @@
+0xA4,  //global push - no data
+0xB4, // global pop
+0xA5, 0x01 // global push with data
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/globalunit.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,2 @@
+0x65, 0x06,  //global unit
+0x65, 0x06  //global unit
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/globalunit_smallvalue.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0x65, 0x02  //global unit
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/globalunitexponent.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,2 @@
+0x55, 0x00,  //global unit exponent
+0x55, 0x00  //global unit exponent
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/globalunitexponent2.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0x55, 0xff  //global unit exponent
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/handleitem_withindelimiter.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,3 @@
+0xa9, 0x01,      //   begin delimiter - set iWithinDelimiter
+0xB1, 0xff, // main feature
+0xa9, 0x00      //   end delimiter
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/headsetcon2.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,25 @@
+0x05, 0x0c,                   //Global usage page 12
+0x09, 0x01,                   //Local usage page 1
+0xa1, 0x01,                   //Collection Application
+0x15, 0x00,                   //Global Locgical minimium
+0x25, 0x01,                   //Global Logical maxim
+0x75, 0x01,                   //Global Report size 1
+0x09, 0xE9,                   //Local usage Volume up           
+0x09, 0xEA,                   //Local usage Volume down          
+0x95, 0x02,                   //Global Report Count 2
+0x81, 0x02,                   //Input 2     First field    
+0x05, 0x0B,                   //Global usage page 11
+0x09, 0x2F,                   //Local usage mute
+0x95, 0x01,                   //Global Report Count 1
+0x81, 0x06,                   //Input 6   2. field    
+0x09, 0x20,                   //Local usage hook
+0x95, 0x01,                   //Global Report Count 1
+0x81, 0x02,                   //Input 2   3. field
+0x05, 0x0C,                   //Global usage page 12 (consumer)
+0x09, 0xCD,                   //Local usage play/pause
+0x09, 0xb5,                   //Local usage 0xb5 ScanNext
+0x09, 0xb6,                   //Local usage 0xb6 ScanPrev
+0x09, 0xb7,                   //Local usage 0xb7 Stop
+0x95, 0x04,                   //Global Report Count 4
+0x81, 0x02,                   //Input 2   6. field
+0xc0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/headsetconnect.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,24 @@
+        0x95, 0x01,      //Report count 1
+        0x05, 0x0c,      //Usage page telephony
+        0x09, 0x01,      // Usage Phone
+        0xa1, 0x01,      // COLLECTION (Application)        
+        0x09, 0x01,      //   USAGE (Programmable Button)
+        0xa1, 0x02,      //   COLLECTION (Logical)
+        0x05, 0x0c,      //     USAGE_PAGE (Button)
+        0x19, 0x00,      //     USAGE_MINIMUM (Button 1)
+        0x29, 0x2f,      //     USAGE_MAXIMUM (Button 6)
+        0x75, 0x08,      //     REPORT_SIZE (3)
+        0x15, 0x00,      //     LOGICAL_MINIMUM (1)
+        0x25, 0x06,      //     LOGICAL_MAXIMUM (6)
+        0x81, 0x00,      //     INPUT (Data,Ary,Abs)
+        0xc0,            //   END_COLLECTION 
+        0xa1, 0x02,      //   COLLECTION (Logical)
+        0x05, 0x0b,      //     USAGE_PAGE (Button)
+        0x19, 0x20,      //     USAGE_MINIMUM (Button 1)
+        0x29, 0x2f,      //     USAGE_MAXIMUM (Button 6)
+        0x75, 0x08,      //     REPORT_SIZE (3)
+        0x15, 0x00,      //     LOGICAL_MINIMUM (1)
+        0x25, 0x2f,      //     LOGICAL_MAXIMUM (6)
+        0x81, 0x00,      //     INPUT (Data,Ary,Abs)
+        0xc0,            //   END_COLLECTION        
+        0xc0             //End collection    
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/headsetvolumeup.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+        0x2f
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/headsetvolumeupm.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+        0x01, 0x2f
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/hook.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,2 @@
+	0x20, 0x01
+	
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/hookconnect.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,24 @@
+        0x95, 0x01,      //Report count 1
+        0x05, 0x0c,      //Usage page telephony
+        0x09, 0x01,      // Usage Phone
+        0xa1, 0x01,      // COLLECTION (Application)        
+        0x09, 0x01,      //   USAGE (Programmable Button)
+        0xa1, 0x02,      //   COLLECTION (Logical)
+        0x05, 0x0c,      //     USAGE_PAGE (Button)
+        0x19, 0x00,      //     USAGE_MINIMUM (Button 1)
+        0x29, 0x2f,      //     USAGE_MAXIMUM (Button 6)
+        0x75, 0x08,      //     REPORT_SIZE (3)
+        0x15, 0x00,      //     LOGICAL_MINIMUM (1)
+        0x25, 0x06,      //     LOGICAL_MAXIMUM (6)
+        0x81, 0x00,      //     INPUT (Data,Ary,Abs)
+        0xc0,            //   END_COLLECTION 
+        0xa1, 0x02,      //   COLLECTION (Logical)
+        0x05, 0x0b,      //     USAGE_PAGE (Button)
+        0x19, 0x20,      //     USAGE_MINIMUM (Button 1)
+        0x29, 0x2f,      //     USAGE_MAXIMUM (Button 6)
+        0x75, 0x08,      //     REPORT_SIZE (3)
+        0x15, 0x00,      //     LOGICAL_MINIMUM (1)
+        0x25, 0x2f,      //     LOGICAL_MAXIMUM (6)
+        0x81, 0x00,      //     INPUT (Data,Ary,Abs)
+        0xc0,            //   END_COLLECTION        
+        0xc0             //End collection    
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/inputdata.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,5 @@
+0x01,0x48,
+0x00,0x00,
+0x00,0x00,
+0x01,0x02,
+0x02,0x03
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/localdelimiter.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0xa9, 0x01,      //   begin delimiter0xa9, 0x00,      //   end delimiter0xa9, 0x02,      //   unknown delimiter
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/localdelimiter_lonelydelimiter.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0xa9, 0x00      //   end delimiter - lonely delimiter
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/localdelimiter_nesteddelimiter.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0xa1, 0x04,      // COLLECTION (CCollection::ENamedArray) - warning 0xa9, 0x01,      //   begin delimiter0xa9, 0x01      //   begin delimiter - nested
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/localdesignatorindex.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0x39, 0xc8,0x39, 0xc8,0xa9, 0x01,      //   begin delimiter0x39, 0xc8,		 // ELocalDesignatorIndex (200)0xc0             //   END_COLLECTION
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/localdesignatormaximum.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0x59, 0xc8,0x59, 0xc8,0xa9, 0x01,      //   begin delimiter0x59, 0xc8,		 //  (200)0xc0             //   END_COLLECTION
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/localdesignatorminimum.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0x49, 0xc8,0x49, 0xc8,0xa9, 0x01,      //   begin delimiter0x49, 0xc8,		 //  (200)0xc0             //   END_COLLECTION
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/localitem_unknown.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0xf9, 0x01      //   unknow item
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/localstringindex.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0x79, 0xc8,0x79, 0xc8,0xa9, 0x01,      //   begin delimiter0x79, 0xc8,		 //  (200)0xc0             //   END_COLLECTION
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/localstringmaximum.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0x99, 0xc8,0x99, 0xc8,0xa9, 0x01,      //   begin delimiter0x99, 0xc8,		 //  (200)0xc0             //   END_COLLECTION
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/localstringminimum.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0x89, 0xc8,0x89, 0xc8,0xa9, 0x01,      //   begin delimiter0x89, 0xc8,		 // ELocalDesignatorIndex (200)0xc0             //   END_COLLECTION
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/localusage.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0x09, 0xc8,0x09, 0x00, // zero usage0xa9, 0x01,      //   begin delimiter0x09, 0xc8,0x09, 0xc8,0x0B, 0xc8, 0xc9, 0xca, 0xcb, //data size - 40x0B, 0x00, 0x00, 0x00, 0x00, //data size - 40xa9, 0x00      //   end delimiter
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/localusagemaximum.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0x29, 0x00,0x19, 0x00, //define usage min to 00x29, 0x00,0xa9, 0x01,      //   begin delimiter0x29, 0x00,0x29, 0x00,0xa9, 0x00,      //   end delimiter0x19, 0xc8, //set usage min to 0xc80x29, 0xca,0x2B, 0x00, 0x00, 0x00, 0x00, //data size - 4
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/localusageminimum.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0x19, 0x00,0x29, 0x00, //define usage max to 00x19, 0x00,0xa9, 0x01,      //   begin delimiter0x19, 0x00,0x19, 0x00,0xa9, 0x00,      //   end delimiter0x29, 0xca, //set usage max to 0xca0x19, 0xc8,0x1B, 0xc8, 0xc9, 0xca, 0xcb, //data size - 4
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/longitem.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0x0C //long item
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/mainfeature.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,11 @@
+0xB1, 0x01, // main feature
+
+0x39, 0xc8, 
+0x39, 0xc8, //local designator index - set iLocalMultipleUse
+
+0xB1, 0x01, // main feature
+0xB2, 0xff, 0xff, // main feature - EOutputReservedBitsNonZero
+
+//0xa9, 0x01,      //   begin delimiter - set iWithinDelimiter
+//0xB2, 0xff, 0xff, // main feature   EOutputReservedBitsNonZero
+//0xa9, 0x00      //   end delimiter
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/mainitem_unknown.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0xF0 //main item - unknown
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/mainoutputtag.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,11 @@
+0x91, 0x01, // main output tag
+
+0x39, 0xc8, 
+0x39, 0xc8, //local designator index - set iLocalMultipleUse
+
+0x91, 0x01, // main output tag
+0x92, 0xff, 0xff, // main output tag   EOutputReservedBitsNonZero
+
+//0xa9, 0x01,      //   begin delimiter - set iWithinDelimiter
+//0x91, 0x01, // main output tag
+//0xa9, 0x00      //   end delimiter
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/multipagec.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,53 @@
+
+        0x95, 0x01,      //Report count 1
+        0x05, 0x0c,      //Usage page telephony
+        0x09, 0x01,      // Usage Phone
+        0xa1, 0x01,      // COLLECTION (Application) 
+        0x85, 0x01,      // Report id 1 
+        0x09, 0x01,      //   USAGE (Programmable Button)
+        0xa1, 0x02,      //   COLLECTION (Logical)
+        0x05, 0x0c,      //     USAGE_PAGE (Button)
+        0x19, 0x00,      //     USAGE_MINIMUM (Button 1)
+        0x29, 0x2f,      //     USAGE_MAXIMUM (Button 6)
+        0x75, 0x08,      //     REPORT_SIZE (3)
+        0x15, 0x00,      //     LOGICAL_MINIMUM (1)
+        0x25, 0x06,      //     LOGICAL_MAXIMUM (6)
+        0x81, 0x00,      //     INPUT (Data,Ary,Abs)
+        0xc0,            //   END_COLLECTION 
+        0xa1, 0x02,      //   COLLECTION (Logical)
+        0x05, 0x0b,      //     USAGE_PAGE (Button)
+        0x19, 0x20,      //     USAGE_MINIMUM (Button 1)
+        0x29, 0x2f,      //     USAGE_MAXIMUM (Button 6)
+        0x75, 0x08,      //     REPORT_SIZE (3)
+        0x15, 0x00,      //     LOGICAL_MINIMUM (1)
+        0x25, 0x2f,      //     LOGICAL_MAXIMUM (6)
+        0x81, 0x00,      //     INPUT (Data,Ary,Abs)
+        0xc0,            //   END_COLLECTION        
+        0xc0,             //End collection                    
+0x05, 0x01,      // USAGE_PAGE (Generic Desktop)
+0x09, 0x02,                    // USAGE (Mouse)
+0xa1, 0x01,                    // COLLECTION (Application)
+0x85, 0x02,                    // Report id 2
+0x09, 0x01,                    //   USAGE (Pointer)
+0xa1, 0x00,                    //   COLLECTION (Physical)
+0x05, 0x09,                    //     USAGE_PAGE (Button)
+0x19, 0x01,                    //     USAGE_MINIMUM (Button 1)
+0x29, 0x03,                    //     USAGE_MAXIMUM (Button 3)
+0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
+0x25, 0x01,                    //     LOGICAL_MAXIMUM (1)
+0x95, 0x03,                    //     REPORT_COUNT (3)
+0x75, 0x01,                    //     REPORT_SIZE (1)
+0x81, 0x02,                    //     INPUT (Data,Var,Abs)
+0x95, 0x01,                    //     REPORT_COUNT (1)
+0x75, 0x05,                    //     REPORT_SIZE (5)
+0x81, 0x03,                    //     INPUT (Cnst,Var,Abs)
+0x05, 0x01,                    //     USAGE_PAGE (Generic Desktop)
+0x09, 0x30,                    //     USAGE (X)
+0x09, 0x31,                    //     USAGE (Y)
+0x15, 0x81,                    //     LOGICAL_MINIMUM (-127)
+0x25, 0x7f,                    //     LOGICAL_MAXIMUM (127)
+0x75, 0x08,                    //     REPORT_SIZE (8)
+0x95, 0x02,                    //     REPORT_COUNT (2)
+0x81, 0x06,                    //     INPUT (Data,Var,Rel)
+0xc0,                          //   END_COLLECTION
+0xc0                           // END_COLLECTION
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/multipagein.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,2 @@
+0x01,0x48,
+0x00
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/multiple_usage_page_connect.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,18 @@
+    0x05, 0x0c,     // Global usage page 12
+    0x09, 0x01,     // Local usage page 1
+    0xa1, 0x01,     // Start Application collection
+    0x15, 0x00,     //   Global Locgical minimium 
+    0x20, 0x01,     //   Global Locgical maximum
+    0x75, 0x01,     //   Global Report size 1
+    0x09, 0xe9,     //   Local usage Volume up
+    0x09, 0xea,     //   Local usage Volume down
+    0x95, 0x02,     //   Global Report Count 2
+    0x81, 0x02,     //   Input 2     First field
+    0x05, 0x0b,     //   Global usage page 11
+    0x09, 0x2f,     //   Local usage mute
+    0x95, 0x01,     //   Global Report Count 1
+    0x81, 0x06m     //   Input 6   2. field
+    0x81, 0x20,     //   Local usage hook
+    0x95, 0x01,     //   Global Report Count 1
+    0x81, 0x02,     //   Input 2   3. field
+    0xc0            // End collection
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/mute.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0x24, 0x01
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/next.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0xE0, 0x04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/output.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,25 @@
+// File: Output1.hid.txt
+// Output item with no Global or Local items defined
+
+    0xA1, 0x01,              // COLLECTION (Application)
+// Output item with no Global or Local items defined
+    0x91, 0x02,              //   OUTPUT (Data,Var,Abs)
+    0x09, 0x4B,              //   USAGE (Generic indicator)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x91, 0x02,              //   OUTPUT (Data,Var,Abs)
+    0x95, 0x04,              //   REPORT_COUNT (4)
+    0x91, 0x01,              //   OUTPUT (Cnst,Ary,Abs)
+    0x05, 0x07,              //   USAGE_PAGE (Keyboard)
+    0x19, 0xE0,              //   USAGE_MINIMUM (Keyboard LeftControl)
+    0x29, 0xE7,              //   USAGE_MAXIMUM (Keyboard Right GUI)
+    0x95, 0x08,              //   REPORT_COUNT (8)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x75, 0x08,              //   REPORT_SIZE (8)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0x19, 0x00,              //   USAGE_MINIMUM (No event)
+    0x29, 0x91,              //   USAGE_MAXIMUM (Keyboard LANG2)
+    0x26, 0xFF, 0x00,        //   LOGICAL_MAXIMUM (255)
+    0x95, 0x06,              //   REPORT_COUNT (6)
+    0x81, 0x00,              //   INPUT (Data,Ary,Abs)
+    0xC0,                    // END_COLLECTION
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/output1.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,25 @@
+// File: Output1.hid.txt
+// Output item with no Global or Local items defined
+
+    0xA1, 0x01,              // COLLECTION (Application)
+// Output item with no Global or Local items defined
+    0x91, 0x02,              //   OUTPUT (Data,Var,Abs)
+    0x09, 0x4B,              //   USAGE (Generic indicator)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x91, 0x02,              //   OUTPUT (Data,Var,Abs)
+    0x95, 0x04,              //   REPORT_COUNT (4)
+    0x91, 0x01,              //   OUTPUT (Cnst,Ary,Abs)
+    0x05, 0x07,              //   USAGE_PAGE (Keyboard)
+    0x19, 0xE0,              //   USAGE_MINIMUM (Keyboard LeftControl)
+    0x29, 0xE7,              //   USAGE_MAXIMUM (Keyboard Right GUI)
+    0x95, 0x08,              //   REPORT_COUNT (8)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x75, 0x08,              //   REPORT_SIZE (8)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0x19, 0x00,              //   USAGE_MINIMUM (No event)
+    0x29, 0x91,              //   USAGE_MAXIMUM (Keyboard LANG2)
+    0x26, 0xFF, 0x00,        //   LOGICAL_MAXIMUM (255)
+    0x95, 0x06,              //   REPORT_COUNT (6)
+    0x81, 0x00,              //   INPUT (Data,Ary,Abs)
+    0xC0,                    // END_COLLECTION
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/physicalmax.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,45 @@
+// File: PhysicalMax1.hid.txt
+// Physical Max defined, but no Physical Min
+
+    0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
+    0x15, 0x00,                    // LOGICAL_MINIMUM (0)
+    0x09, 0x04,                    // USAGE (Joystick)
+    0xa1, 0x01,                    // COLLECTION (Application)
+    0x05, 0x02,                    //   USAGE_PAGE (Simulation Controls)
+    0x09, 0xbb,                    //   USAGE (Throttle)
+    0x15, 0x81,                    //   LOGICAL_MINIMUM (-127)
+    0x25, 0x7f,                    //   LOGICAL_MAXIMUM (127)
+    0x75, 0x08,                    //   REPORT_SIZE (8)
+    0x95, 0x01,                    //   REPORT_COUNT (1)
+    0x81, 0x02,                    //   INPUT (Data,Var,Abs)
+    0x05, 0x01,                    //   USAGE_PAGE (Generic Desktop)
+    0x09, 0x01,                    //   USAGE (Pointer)
+    0xa1, 0x00,                    //   COLLECTION (Physical)
+    0x09, 0x30,                    //     USAGE (X)
+    0x09, 0x31,                    //     USAGE (Y)
+    0x95, 0x02,                    //     REPORT_COUNT (2)
+    0x81, 0x02,                    //     INPUT (Data,Var,Abs)
+    0xc0,                          //   END_COLLECTION
+    0x09, 0x39,                    //   USAGE (Hat switch)
+    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
+    0x25, 0x03,                    //   LOGICAL_MAXIMUM (3)
+// Physical Max defined, but no Physical Min
+//  0x35, 0x00,                    //   PHYSICAL_MINIMUM (0)
+    0x46, 0x0e, 0x01,              //   PHYSICAL_MAXIMUM (270)
+    0x65, 0x14,                    //   UNIT (Eng Rot:Angular Pos)
+    0x75, 0x04,                    //   REPORT_SIZE (4)
+    0x95, 0x01,                    //   REPORT_COUNT (1)
+    0x81, 0x02,                    //   INPUT (Data,Var,Abs)
+    0x05, 0x09,                    //   USAGE_PAGE (Button)
+    0x19, 0x01,                    //   USAGE_MINIMUM (Button 1)
+    0x29, 0x04,                    //   USAGE_MAXIMUM (Button 4)
+    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
+    0x25, 0x01,                    //   LOGICAL_MAXIMUM (1)
+    0x75, 0x01,                    //   REPORT_SIZE (1)
+    0x95, 0x04,                    //   REPORT_COUNT (4)
+    0x55, 0x00,                    //   UNIT_EXPONENT (0)
+    0x65, 0x00,                    //   UNIT (None)
+    0x81, 0x02,                    //   INPUT (Data,Var,Abs)
+    0xc0                           // END_COLLECTION
+//};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/play.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,2 @@
+ 0xB0, 0x01,
+ 0x81, 0x01
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/pop.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,152 @@
+// File: Pop1.hid.txt
+// Pop defined with no corresponding Push
+
+    0x05, 0x01,              // USAGE_PAGE (Generic Desktop)
+    0x09, 0x06,              // USAGE (Keyboard)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x01,              //   REPORT_ID (1)
+    0x05, 0x08,              //   USAGE_PAGE (LEDs)
+    0x19, 0x01,              //   USAGE_MINIMUM (Num Lock)
+    0x29, 0x03,              //   USAGE_MAXIMUM (Scroll Lock)
+    0x15, 0x00,              //   LOGICAL_MINIMUM (0)
+    0x25, 0x01,              //   LOGICAL_MAXIMUM (1)
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x95, 0x03,              //   REPORT_COUNT (3)
+    0x91, 0x02,              //   OUTPUT (Data,Var,Abs)
+    0x09, 0x4B,              //   USAGE (Generic indicator)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+// Pop defined with no corresponding Push
+    0xb4,                          //     POP
+    0x91, 0x02,              //   OUTPUT (Data,Var,Abs)
+    0x95, 0x04,              //   REPORT_COUNT (4)
+    0x91, 0x01,              //   OUTPUT (Cnst,Ary,Abs)
+    0x05, 0x07,              //   USAGE_PAGE (Keyboard)
+    0x19, 0xE0,              //   USAGE_MINIMUM (Keyboard LeftControl)
+    0x29, 0xE7,              //   USAGE_MAXIMUM (Keyboard Right GUI)
+    0x95, 0x08,              //   REPORT_COUNT (8)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x75, 0x08,              //   REPORT_SIZE (8)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0x19, 0x00,              //   USAGE_MINIMUM (No event)
+    0x29, 0x91,              //   USAGE_MAXIMUM (Keyboard LANG2)
+    0x26, 0xFF, 0x00,        //   LOGICAL_MAXIMUM (255)
+    0x95, 0x06,              //   REPORT_COUNT (6)
+    0x81, 0x00,              //   INPUT (Data,Ary,Abs)
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x0C,              // USAGE_PAGE (Consumer Devices)
+    0x09, 0x01,              // USAGE (Consumer Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x02,              //   REPORT_ID (2)
+    0x05, 0x0C,              //   USAGE_PAGE (Consumer Devices)
+    0x15, 0x00,              //   LOGICAL_MINIMUM (0)
+    0x25, 0x01,              //   LOGICAL_MAXIMUM (1)
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x95, 0x1C,              //   REPORT_COUNT (28)
+    0x09, 0xE2,              //   USAGE (Mute)
+    0x09, 0xB7,              //   USAGE (Stop)
+    0x09, 0xCD,              //   USAGE (Play/pause)
+    0x09, 0xEA,              //   USAGE (Volume Down)
+    0x09, 0xE9,              //   USAGE (Volume Up)
+    0x09, 0xB6,              //   USAGE (Scan Previous Track)
+    0x09, 0xB5,              //   USAGE (Scan Next Track)
+    0x0A, 0x83, 0x01,        //   USAGE (Control config)
+    0x0A, 0x1A, 0x02,        //   USAGE (Undo)
+    0x0A, 0x79, 0x02,        //   USAGE (Redo)
+    0x0A, 0xAB, 0x01,        //   USAGE (Spell check)
+    0x0A, 0x08, 0x02,        //   USAGE (Print)
+    0x0A, 0x02, 0x02,        //   USAGE (Open)
+    0x0A, 0x03, 0x02,        //   USAGE (Close)
+    0x0A, 0x07, 0x02,        //   USAGE (Save)
+    0x0A, 0x01, 0x02,        //   USAGE (New)
+    0x0A, 0x92, 0x01,        //   USAGE (Calculator)
+    0x0A, 0x9C, 0x01,        //   USAGE (Logoff)
+    0x09, 0x95,              //   USAGE (Help)
+    0x0A, 0x23, 0x02,        //   USAGE (Home)
+    0x0A, 0x89, 0x02,        //   USAGE (Reply)
+    0x0A, 0x8B, 0x02,        //   USAGE (Sendto
+    0x0A, 0x8C, 0x02,        //   USAGE (Send)
+    0x0A, 0x8A, 0x01,        //   USAGE (Email
+    0x0A, 0x99, 0x01,        //   USAGE (Chat)
+    0x0A, 0xA7, 0x01,        //   USAGE (Documents)
+    0x0A, 0xB6, 0x01,        //   USAGE (Unknown 0x01b6)
+    0x0A, 0xB7, 0x01,        //   USAGE (Unknown 0x01b7)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x95, 0x04,              //   REPORT_COUNT (4)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0x06, 0x00, 0xFF,        //   USAGE_PAGE (Vendor Defined Page 1)
+    0x0A, 0x02, 0xFF,        //   USAGE (Unknown 0xff02)
+    0x26, 0xFF, 0x00,        //   LOGICAL_MAXIMUM (255)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x75, 0x08,              //   REPORT_SIZE (8)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x01,              // USAGE_PAGE (Generic Desktop)
+    0x09, 0x80,              // USAGE (System Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x03,              //   REPORT_ID (3)
+    0x19, 0x81,              //   USAGE_MINIMUM (System Power Down)
+    0x29, 0x83,              //   USAGE_MAXIMUM (System Wake Up)
+    0x25, 0x01,              //   LOGICAL_MAXIMUM (1)
+    0x95, 0x03,              //   REPORT_COUNT (3)
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x95, 0x05,              //   REPORT_COUNT (5)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x0C,              // USAGE_PAGE (Consumer Devices)
+    0x09, 0x01,              // USAGE (Consumer Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x04,              //   REPORT_ID (4)
+    0x05, 0x01,              //   USAGE_PAGE (Generic Desktop)
+    0x09, 0x06,              //   USAGE (Keyboard)
+    0xA1, 0x02,              //   COLLECTION (Logical)
+    0x06, 0x00, 0xFF,        //     USAGE_PAGE (Vendor Defined Page 1)
+    0x15, 0x00,              //     LOGICAL_MINIMUM (0)
+    0x25, 0x03,              //     LOGICAL_MAXIMUM (3)
+    0x95, 0x01,              //     REPORT_COUNT (1)
+    0x75, 0x02,              //     REPORT_SIZE (2)
+    0x0A, 0x01, 0xFE,        //     USAGE (Unknown 1)
+    0x81, 0x02,              //     INPUT (Data,Var,Abs)
+    0x75, 0x06,              //     REPORT_SIZE (6)
+    0x81, 0x01,              //     INPUT (Cnst,Ary,Abs)
+    0xC0,                    //   END_COLLECTION
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x0C,              // USAGE_PAGE (Consumer Devices)
+    0x09, 0x01,              // USAGE (Consumer Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x05,              //   REPORT_ID (5)
+    0x05, 0x01,              //   USAGE_PAGE (Generic Desktop)
+    0x09, 0x06,              //   USAGE (Keyboard)
+    0xA1, 0x02,              //   COLLECTION (Logical)
+    0x06, 0x00, 0xFF,        //     USAGE_PAGE (Vendor Defined Page 1)
+    0x25, 0x01,              //     LOGICAL_MAXIMUM (1)
+    0x75, 0x01,              //     REPORT_SIZE (1)
+    0x95, 0x02,              //     REPORT_COUNT (2)
+    0x0A, 0x03, 0xFE,        //     USAGE (Unknown 0xfe03)
+    0x0A, 0x04, 0xFE,        //     USAGE (Unknown 0xfe04)
+    0x81, 0x02,              //     INPUT (Data,Var,Abs)
+    0x95, 0x06,              //     REPORT_COUNT (6)
+    0x81, 0x01,              //     INPUT (Cnst,Ary,Abs)
+    0xC0,                    //   END_COLLECTION
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x0C,              // USAGE_PAGE (Consumer Devices)
+    0x09, 0x01,              // USAGE (Consumer Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0xFF,              //   REPORT_ID (255)
+    0x05, 0x06,              //   USAGE_PAGE (Generic Device Controls)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x75, 0x02,              //   REPORT_SIZE (2)
+    0x19, 0x24,              //   USAGE_MINIMUM (Unknown 0x24)
+    0x29, 0x26,              //   USAGE_MAXIMUM (Unknown 0x26)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x75, 0x06,              //   REPORT_SIZE (6)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0xC0                     // END_COLLECTION
+//    };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/prev.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+ 0x40, 0x02 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/push.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,152 @@
+// File: Push1.hid.txt
+// Push defined with no corresponding Pop
+
+    0x05, 0x01,              // USAGE_PAGE (Generic Desktop)
+    0x09, 0x06,              // USAGE (Keyboard)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x01,              //   REPORT_ID (1)
+    0x05, 0x08,              //   USAGE_PAGE (LEDs)
+    0x19, 0x01,              //   USAGE_MINIMUM (Num Lock)
+    0x29, 0x03,              //   USAGE_MAXIMUM (Scroll Lock)
+    0x15, 0x00,              //   LOGICAL_MINIMUM (0)
+    0x25, 0x01,              //   LOGICAL_MAXIMUM (1)
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x95, 0x03,              //   REPORT_COUNT (3)
+    0x91, 0x02,              //   OUTPUT (Data,Var,Abs)
+    0x09, 0x4B,              //   USAGE (Generic indicator)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+// Push defined with no corresponding Pop
+    0xa4,                          //     PUSH
+    0x91, 0x02,              //   OUTPUT (Data,Var,Abs)
+    0x95, 0x04,              //   REPORT_COUNT (4)
+    0x91, 0x01,              //   OUTPUT (Cnst,Ary,Abs)
+    0x05, 0x07,              //   USAGE_PAGE (Keyboard)
+    0x19, 0xE0,              //   USAGE_MINIMUM (Keyboard LeftControl)
+    0x29, 0xE7,              //   USAGE_MAXIMUM (Keyboard Right GUI)
+    0x95, 0x08,              //   REPORT_COUNT (8)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x75, 0x08,              //   REPORT_SIZE (8)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0x19, 0x00,              //   USAGE_MINIMUM (No event)
+    0x29, 0x91,              //   USAGE_MAXIMUM (Keyboard LANG2)
+    0x26, 0xFF, 0x00,        //   LOGICAL_MAXIMUM (255)
+    0x95, 0x06,              //   REPORT_COUNT (6)
+    0x81, 0x00,              //   INPUT (Data,Ary,Abs)
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x0C,              // USAGE_PAGE (Consumer Devices)
+    0x09, 0x01,              // USAGE (Consumer Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x02,              //   REPORT_ID (2)
+    0x05, 0x0C,              //   USAGE_PAGE (Consumer Devices)
+    0x15, 0x00,              //   LOGICAL_MINIMUM (0)
+    0x25, 0x01,              //   LOGICAL_MAXIMUM (1)
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x95, 0x1C,              //   REPORT_COUNT (28)
+    0x09, 0xE2,              //   USAGE (Mute)
+    0x09, 0xB7,              //   USAGE (Stop)
+    0x09, 0xCD,              //   USAGE (Play/pause)
+    0x09, 0xEA,              //   USAGE (Volume Down)
+    0x09, 0xE9,              //   USAGE (Volume Up)
+    0x09, 0xB6,              //   USAGE (Scan Previous Track)
+    0x09, 0xB5,              //   USAGE (Scan Next Track)
+    0x0A, 0x83, 0x01,        //   USAGE (Control config)
+    0x0A, 0x1A, 0x02,        //   USAGE (Undo)
+    0x0A, 0x79, 0x02,        //   USAGE (Redo)
+    0x0A, 0xAB, 0x01,        //   USAGE (Spell check)
+    0x0A, 0x08, 0x02,        //   USAGE (Print)
+    0x0A, 0x02, 0x02,        //   USAGE (Open)
+    0x0A, 0x03, 0x02,        //   USAGE (Close)
+    0x0A, 0x07, 0x02,        //   USAGE (Save)
+    0x0A, 0x01, 0x02,        //   USAGE (New)
+    0x0A, 0x92, 0x01,        //   USAGE (Calculator)
+    0x0A, 0x9C, 0x01,        //   USAGE (Logoff)
+    0x09, 0x95,              //   USAGE (Help)
+    0x0A, 0x23, 0x02,        //   USAGE (Home)
+    0x0A, 0x89, 0x02,        //   USAGE (Reply)
+    0x0A, 0x8B, 0x02,        //   USAGE (Sendto
+    0x0A, 0x8C, 0x02,        //   USAGE (Send)
+    0x0A, 0x8A, 0x01,        //   USAGE (Email
+    0x0A, 0x99, 0x01,        //   USAGE (Chat)
+    0x0A, 0xA7, 0x01,        //   USAGE (Documents)
+    0x0A, 0xB6, 0x01,        //   USAGE (Unknown 0x01b6)
+    0x0A, 0xB7, 0x01,        //   USAGE (Unknown 0x01b7)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x95, 0x04,              //   REPORT_COUNT (4)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0x06, 0x00, 0xFF,        //   USAGE_PAGE (Vendor Defined Page 1)
+    0x0A, 0x02, 0xFF,        //   USAGE (Unknown 0xff02)
+    0x26, 0xFF, 0x00,        //   LOGICAL_MAXIMUM (255)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x75, 0x08,              //   REPORT_SIZE (8)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x01,              // USAGE_PAGE (Generic Desktop)
+    0x09, 0x80,              // USAGE (System Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x03,              //   REPORT_ID (3)
+    0x19, 0x81,              //   USAGE_MINIMUM (System Power Down)
+    0x29, 0x83,              //   USAGE_MAXIMUM (System Wake Up)
+    0x25, 0x01,              //   LOGICAL_MAXIMUM (1)
+    0x95, 0x03,              //   REPORT_COUNT (3)
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x95, 0x05,              //   REPORT_COUNT (5)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x0C,              // USAGE_PAGE (Consumer Devices)
+    0x09, 0x01,              // USAGE (Consumer Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x04,              //   REPORT_ID (4)
+    0x05, 0x01,              //   USAGE_PAGE (Generic Desktop)
+    0x09, 0x06,              //   USAGE (Keyboard)
+    0xA1, 0x02,              //   COLLECTION (Logical)
+    0x06, 0x00, 0xFF,        //     USAGE_PAGE (Vendor Defined Page 1)
+    0x15, 0x00,              //     LOGICAL_MINIMUM (0)
+    0x25, 0x03,              //     LOGICAL_MAXIMUM (3)
+    0x95, 0x01,              //     REPORT_COUNT (1)
+    0x75, 0x02,              //     REPORT_SIZE (2)
+    0x0A, 0x01, 0xFE,        //     USAGE (Unknown 1)
+    0x81, 0x02,              //     INPUT (Data,Var,Abs)
+    0x75, 0x06,              //     REPORT_SIZE (6)
+    0x81, 0x01,              //     INPUT (Cnst,Ary,Abs)
+    0xC0,                    //   END_COLLECTION
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x0C,              // USAGE_PAGE (Consumer Devices)
+    0x09, 0x01,              // USAGE (Consumer Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x05,              //   REPORT_ID (5)
+    0x05, 0x01,              //   USAGE_PAGE (Generic Desktop)
+    0x09, 0x06,              //   USAGE (Keyboard)
+    0xA1, 0x02,              //   COLLECTION (Logical)
+    0x06, 0x00, 0xFF,        //     USAGE_PAGE (Vendor Defined Page 1)
+    0x25, 0x01,              //     LOGICAL_MAXIMUM (1)
+    0x75, 0x01,              //     REPORT_SIZE (1)
+    0x95, 0x02,              //     REPORT_COUNT (2)
+    0x0A, 0x03, 0xFE,        //     USAGE (Unknown 0xfe03)
+    0x0A, 0x04, 0xFE,        //     USAGE (Unknown 0xfe04)
+    0x81, 0x02,              //     INPUT (Data,Var,Abs)
+    0x95, 0x06,              //     REPORT_COUNT (6)
+    0x81, 0x01,              //     INPUT (Cnst,Ary,Abs)
+    0xC0,                    //   END_COLLECTION
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x0C,              // USAGE_PAGE (Consumer Devices)
+    0x09, 0x01,              // USAGE (Consumer Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0xFF,              //   REPORT_ID (255)
+    0x05, 0x06,              //   USAGE_PAGE (Generic Device Controls)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x75, 0x02,              //   REPORT_SIZE (2)
+    0x19, 0x24,              //   USAGE_MINIMUM (Unknown 0x24)
+    0x29, 0x26,              //   USAGE_MAXIMUM (Unknown 0x26)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x75, 0x06,              //   REPORT_SIZE (6)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0xC0                     // END_COLLECTION
+//    };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/stop.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+    0xb7, 0x01
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/string.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,153 @@
+// File: StringMin1.hid.txt
+// String Min defined, but no String Max
+
+    0x05, 0x01,              // USAGE_PAGE (Generic Desktop)
+    0x09, 0x06,              // USAGE (Keyboard)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x01,              //   REPORT_ID (1)
+    0x05, 0x08,              //   USAGE_PAGE (LEDs)
+    0x19, 0x01,              //   USAGE_MINIMUM (Num Lock)
+    0x29, 0x03,              //   USAGE_MAXIMUM (Scroll Lock)
+    0x15, 0x00,              //   LOGICAL_MINIMUM (0)
+    0x25, 0x01,              //   LOGICAL_MAXIMUM (1)
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x95, 0x03,              //   REPORT_COUNT (3)
+// String Min defined, but no String Max
+    0x89, 0x01,              //   STRING_MINIMUM (1)
+    0x99, 0x20,              //   STRING_MAXIMUM (32)
+    0x91, 0x02,              //   OUTPUT (Data,Var,Abs)
+    0x09, 0x4B,              //   USAGE (Generic indicator)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x91, 0x02,              //   OUTPUT (Data,Var,Abs)
+    0x95, 0x04,              //   REPORT_COUNT (4)
+    0x91, 0x01,              //   OUTPUT (Cnst,Ary,Abs)
+    0x05, 0x07,              //   USAGE_PAGE (Keyboard)
+    0x19, 0xE0,              //   USAGE_MINIMUM (Keyboard LeftControl)
+    0x29, 0xE7,              //   USAGE_MAXIMUM (Keyboard Right GUI)
+    0x95, 0x08,              //   REPORT_COUNT (8)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x75, 0x08,              //   REPORT_SIZE (8)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0x19, 0x00,              //   USAGE_MINIMUM (No event)
+    0x29, 0x91,              //   USAGE_MAXIMUM (Keyboard LANG2)
+    0x26, 0xFF, 0x00,        //   LOGICAL_MAXIMUM (255)
+    0x95, 0x06,              //   REPORT_COUNT (6)
+    0x81, 0x00,              //   INPUT (Data,Ary,Abs)
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x0C,              // USAGE_PAGE (Consumer Devices)
+    0x09, 0x01,              // USAGE (Consumer Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x02,              //   REPORT_ID (2)
+    0x05, 0x0C,              //   USAGE_PAGE (Consumer Devices)
+    0x15, 0x00,              //   LOGICAL_MINIMUM (0)
+    0x25, 0x01,              //   LOGICAL_MAXIMUM (1)
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x95, 0x1C,              //   REPORT_COUNT (28)
+    0x09, 0xE2,              //   USAGE (Mute)
+    0x09, 0xB7,              //   USAGE (Stop)
+    0x09, 0xCD,              //   USAGE (Play/pause)
+    0x09, 0xEA,              //   USAGE (Volume Down)
+    0x09, 0xE9,              //   USAGE (Volume Up)
+    0x09, 0xB6,              //   USAGE (Scan Previous Track)
+    0x09, 0xB5,              //   USAGE (Scan Next Track)
+    0x0A, 0x83, 0x01,        //   USAGE (Control config)
+    0x0A, 0x1A, 0x02,        //   USAGE (Undo)
+    0x0A, 0x79, 0x02,        //   USAGE (Redo)
+    0x0A, 0xAB, 0x01,        //   USAGE (Spell check)
+    0x0A, 0x08, 0x02,        //   USAGE (Print)
+    0x0A, 0x02, 0x02,        //   USAGE (Open)
+    0x0A, 0x03, 0x02,        //   USAGE (Close)
+    0x0A, 0x07, 0x02,        //   USAGE (Save)
+    0x0A, 0x01, 0x02,        //   USAGE (New)
+    0x0A, 0x92, 0x01,        //   USAGE (Calculator)
+    0x0A, 0x9C, 0x01,        //   USAGE (Logoff)
+    0x09, 0x95,              //   USAGE (Help)
+    0x0A, 0x23, 0x02,        //   USAGE (Home)
+    0x0A, 0x89, 0x02,        //   USAGE (Reply)
+    0x0A, 0x8B, 0x02,        //   USAGE (Sendto
+    0x0A, 0x8C, 0x02,        //   USAGE (Send)
+    0x0A, 0x8A, 0x01,        //   USAGE (Email
+    0x0A, 0x99, 0x01,        //   USAGE (Chat)
+    0x0A, 0xA7, 0x01,        //   USAGE (Documents)
+    0x0A, 0xB6, 0x01,        //   USAGE (Unknown 0x01b6)
+    0x0A, 0xB7, 0x01,        //   USAGE (Unknown 0x01b7)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x95, 0x04,              //   REPORT_COUNT (4)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0x06, 0x00, 0xFF,        //   USAGE_PAGE (Vendor Defined Page 1)
+    0x0A, 0x02, 0xFF,        //   USAGE (Unknown 0xff02)
+    0x26, 0xFF, 0x00,        //   LOGICAL_MAXIMUM (255)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x75, 0x08,              //   REPORT_SIZE (8)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x01,              // USAGE_PAGE (Generic Desktop)
+    0x09, 0x80,              // USAGE (System Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x03,              //   REPORT_ID (3)
+    0x19, 0x81,              //   USAGE_MINIMUM (System Power Down)
+    0x29, 0x83,              //   USAGE_MAXIMUM (System Wake Up)
+    0x25, 0x01,              //   LOGICAL_MAXIMUM (1)
+    0x95, 0x03,              //   REPORT_COUNT (3)
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x95, 0x05,              //   REPORT_COUNT (5)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x0C,              // USAGE_PAGE (Consumer Devices)
+    0x09, 0x01,              // USAGE (Consumer Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x04,              //   REPORT_ID (4)
+    0x05, 0x01,              //   USAGE_PAGE (Generic Desktop)
+    0x09, 0x06,              //   USAGE (Keyboard)
+    0xA1, 0x02,              //   COLLECTION (Logical)
+    0x06, 0x00, 0xFF,        //     USAGE_PAGE (Vendor Defined Page 1)
+    0x15, 0x00,              //     LOGICAL_MINIMUM (0)
+    0x25, 0x03,              //     LOGICAL_MAXIMUM (3)
+    0x95, 0x01,              //     REPORT_COUNT (1)
+    0x75, 0x02,              //     REPORT_SIZE (2)
+    0x0A, 0x01, 0xFE,        //     USAGE (Unknown 1)
+    0x81, 0x02,              //     INPUT (Data,Var,Abs)
+    0x75, 0x06,              //     REPORT_SIZE (6)
+    0x81, 0x01,              //     INPUT (Cnst,Ary,Abs)
+    0xC0,                    //   END_COLLECTION
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x0C,              // USAGE_PAGE (Consumer Devices)
+    0x09, 0x01,              // USAGE (Consumer Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x05,              //   REPORT_ID (5)
+    0x05, 0x01,              //   USAGE_PAGE (Generic Desktop)
+    0x09, 0x06,              //   USAGE (Keyboard)
+    0xA1, 0x02,              //   COLLECTION (Logical)
+    0x06, 0x00, 0xFF,        //     USAGE_PAGE (Vendor Defined Page 1)
+    0x25, 0x01,              //     LOGICAL_MAXIMUM (1)
+    0x75, 0x01,              //     REPORT_SIZE (1)
+    0x95, 0x02,              //     REPORT_COUNT (2)
+    0x0A, 0x03, 0xFE,        //     USAGE (Unknown 0xfe03)
+    0x0A, 0x04, 0xFE,        //     USAGE (Unknown 0xfe04)
+    0x81, 0x02,              //     INPUT (Data,Var,Abs)
+    0x95, 0x06,              //     REPORT_COUNT (6)
+    0x81, 0x01,              //     INPUT (Cnst,Ary,Abs)
+    0xC0,                    //   END_COLLECTION
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x0C,              // USAGE_PAGE (Consumer Devices)
+    0x09, 0x01,              // USAGE (Consumer Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0xFF,              //   REPORT_ID (255)
+    0x05, 0x06,              //   USAGE_PAGE (Generic Device Controls)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x75, 0x02,              //   REPORT_SIZE (2)
+    0x19, 0x24,              //   USAGE_MINIMUM (Unknown 0x24)
+    0x29, 0x26,              //   USAGE_MAXIMUM (Unknown 0x26)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x75, 0x06,              //   REPORT_SIZE (6)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0xC0                     // END_COLLECTION
+//    };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/stringindex.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,154 @@
+// File: StringMin1.hid.txt
+// String Min defined, but no String Max
+
+    0x05, 0x01,              // USAGE_PAGE (Generic Desktop)
+    0x09, 0x06,              // USAGE (Keyboard)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x01,              //   REPORT_ID (1)
+    0x05, 0x08,              //   USAGE_PAGE (LEDs)
+    0x19, 0x01,              //   USAGE_MINIMUM (Num Lock)
+    0x29, 0x03,              //   USAGE_MAXIMUM (Scroll Lock)
+    0x15, 0x00,              //   LOGICAL_MINIMUM (0)
+    0x25, 0x01,              //   LOGICAL_MAXIMUM (1)
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x95, 0x03,              //   REPORT_COUNT (3)
+// String Min defined, but no String Max
+    0x89, 0x01,              //   STRING_MINIMUM (1)
+    0x99, 0x20,              //   STRING_MAXIMUM (32)
+    0x79, 0x01,              //   STRING_MINIMUM (1)
+    0x91, 0x02,              //   OUTPUT (Data,Var,Abs)
+    0x09, 0x4B,              //   USAGE (Generic indicator)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x91, 0x02,              //   OUTPUT (Data,Var,Abs)
+    0x95, 0x04,              //   REPORT_COUNT (4)
+    0x91, 0x01,              //   OUTPUT (Cnst,Ary,Abs)
+    0x05, 0x07,              //   USAGE_PAGE (Keyboard)
+    0x19, 0xE0,              //   USAGE_MINIMUM (Keyboard LeftControl)
+    0x29, 0xE7,              //   USAGE_MAXIMUM (Keyboard Right GUI)
+    0x95, 0x08,              //   REPORT_COUNT (8)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x75, 0x08,              //   REPORT_SIZE (8)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0x19, 0x00,              //   USAGE_MINIMUM (No event)
+    0x29, 0x91,              //   USAGE_MAXIMUM (Keyboard LANG2)
+    0x26, 0xFF, 0x00,        //   LOGICAL_MAXIMUM (255)
+    0x95, 0x06,              //   REPORT_COUNT (6)
+    0x81, 0x00,              //   INPUT (Data,Ary,Abs)
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x0C,              // USAGE_PAGE (Consumer Devices)
+    0x09, 0x01,              // USAGE (Consumer Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x02,              //   REPORT_ID (2)
+    0x05, 0x0C,              //   USAGE_PAGE (Consumer Devices)
+    0x15, 0x00,              //   LOGICAL_MINIMUM (0)
+    0x25, 0x01,              //   LOGICAL_MAXIMUM (1)
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x95, 0x1C,              //   REPORT_COUNT (28)
+    0x09, 0xE2,              //   USAGE (Mute)
+    0x09, 0xB7,              //   USAGE (Stop)
+    0x09, 0xCD,              //   USAGE (Play/pause)
+    0x09, 0xEA,              //   USAGE (Volume Down)
+    0x09, 0xE9,              //   USAGE (Volume Up)
+    0x09, 0xB6,              //   USAGE (Scan Previous Track)
+    0x09, 0xB5,              //   USAGE (Scan Next Track)
+    0x0A, 0x83, 0x01,        //   USAGE (Control config)
+    0x0A, 0x1A, 0x02,        //   USAGE (Undo)
+    0x0A, 0x79, 0x02,        //   USAGE (Redo)
+    0x0A, 0xAB, 0x01,        //   USAGE (Spell check)
+    0x0A, 0x08, 0x02,        //   USAGE (Print)
+    0x0A, 0x02, 0x02,        //   USAGE (Open)
+    0x0A, 0x03, 0x02,        //   USAGE (Close)
+    0x0A, 0x07, 0x02,        //   USAGE (Save)
+    0x0A, 0x01, 0x02,        //   USAGE (New)
+    0x0A, 0x92, 0x01,        //   USAGE (Calculator)
+    0x0A, 0x9C, 0x01,        //   USAGE (Logoff)
+    0x09, 0x95,              //   USAGE (Help)
+    0x0A, 0x23, 0x02,        //   USAGE (Home)
+    0x0A, 0x89, 0x02,        //   USAGE (Reply)
+    0x0A, 0x8B, 0x02,        //   USAGE (Sendto
+    0x0A, 0x8C, 0x02,        //   USAGE (Send)
+    0x0A, 0x8A, 0x01,        //   USAGE (Email
+    0x0A, 0x99, 0x01,        //   USAGE (Chat)
+    0x0A, 0xA7, 0x01,        //   USAGE (Documents)
+    0x0A, 0xB6, 0x01,        //   USAGE (Unknown 0x01b6)
+    0x0A, 0xB7, 0x01,        //   USAGE (Unknown 0x01b7)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x95, 0x04,              //   REPORT_COUNT (4)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0x06, 0x00, 0xFF,        //   USAGE_PAGE (Vendor Defined Page 1)
+    0x0A, 0x02, 0xFF,        //   USAGE (Unknown 0xff02)
+    0x26, 0xFF, 0x00,        //   LOGICAL_MAXIMUM (255)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x75, 0x08,              //   REPORT_SIZE (8)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x01,              // USAGE_PAGE (Generic Desktop)
+    0x09, 0x80,              // USAGE (System Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x03,              //   REPORT_ID (3)
+    0x19, 0x81,              //   USAGE_MINIMUM (System Power Down)
+    0x29, 0x83,              //   USAGE_MAXIMUM (System Wake Up)
+    0x25, 0x01,              //   LOGICAL_MAXIMUM (1)
+    0x95, 0x03,              //   REPORT_COUNT (3)
+    0x75, 0x01,              //   REPORT_SIZE (1)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x95, 0x05,              //   REPORT_COUNT (5)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x0C,              // USAGE_PAGE (Consumer Devices)
+    0x09, 0x01,              // USAGE (Consumer Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x04,              //   REPORT_ID (4)
+    0x05, 0x01,              //   USAGE_PAGE (Generic Desktop)
+    0x09, 0x06,              //   USAGE (Keyboard)
+    0xA1, 0x02,              //   COLLECTION (Logical)
+    0x06, 0x00, 0xFF,        //     USAGE_PAGE (Vendor Defined Page 1)
+    0x15, 0x00,              //     LOGICAL_MINIMUM (0)
+    0x25, 0x03,              //     LOGICAL_MAXIMUM (3)
+    0x95, 0x01,              //     REPORT_COUNT (1)
+    0x75, 0x02,              //     REPORT_SIZE (2)
+    0x0A, 0x01, 0xFE,        //     USAGE (Unknown 1)
+    0x81, 0x02,              //     INPUT (Data,Var,Abs)
+    0x75, 0x06,              //     REPORT_SIZE (6)
+    0x81, 0x01,              //     INPUT (Cnst,Ary,Abs)
+    0xC0,                    //   END_COLLECTION
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x0C,              // USAGE_PAGE (Consumer Devices)
+    0x09, 0x01,              // USAGE (Consumer Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0x05,              //   REPORT_ID (5)
+    0x05, 0x01,              //   USAGE_PAGE (Generic Desktop)
+    0x09, 0x06,              //   USAGE (Keyboard)
+    0xA1, 0x02,              //   COLLECTION (Logical)
+    0x06, 0x00, 0xFF,        //     USAGE_PAGE (Vendor Defined Page 1)
+    0x25, 0x01,              //     LOGICAL_MAXIMUM (1)
+    0x75, 0x01,              //     REPORT_SIZE (1)
+    0x95, 0x02,              //     REPORT_COUNT (2)
+    0x0A, 0x03, 0xFE,        //     USAGE (Unknown 0xfe03)
+    0x0A, 0x04, 0xFE,        //     USAGE (Unknown 0xfe04)
+    0x81, 0x02,              //     INPUT (Data,Var,Abs)
+    0x95, 0x06,              //     REPORT_COUNT (6)
+    0x81, 0x01,              //     INPUT (Cnst,Ary,Abs)
+    0xC0,                    //   END_COLLECTION
+    0xC0,                    // END_COLLECTION
+    //...                    //
+    0x05, 0x0C,              // USAGE_PAGE (Consumer Devices)
+    0x09, 0x01,              // USAGE (Consumer Control)
+    0xA1, 0x01,              // COLLECTION (Application)
+    0x85, 0xFF,              //   REPORT_ID (255)
+    0x05, 0x06,              //   USAGE_PAGE (Generic Device Controls)
+    0x95, 0x01,              //   REPORT_COUNT (1)
+    0x75, 0x02,              //   REPORT_SIZE (2)
+    0x19, 0x24,              //   USAGE_MINIMUM (Unknown 0x24)
+    0x29, 0x26,              //   USAGE_MAXIMUM (Unknown 0x26)
+    0x81, 0x02,              //   INPUT (Data,Var,Abs)
+    0x75, 0x06,              //   REPORT_SIZE (6)
+    0x81, 0x01,              //   INPUT (Cnst,Ary,Abs)
+    0xC0                     // END_COLLECTION
+//    };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/unit.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,44 @@
+// File: UnitExponent1.hid.txt
+// Unit Exponent with non-zero data in the reserved field
+
+    0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
+    0x15, 0x00,                    // LOGICAL_MINIMUM (0)
+    0x09, 0x04,                    // USAGE (Joystick)
+    0xa1, 0x01,                    // COLLECTION (Application)
+    0x05, 0x02,                    //   USAGE_PAGE (Simulation Controls)
+    0x09, 0xbb,                    //   USAGE (Throttle)
+    0x15, 0x81,                    //   LOGICAL_MINIMUM (-127)
+    0x25, 0x7f,                    //   LOGICAL_MAXIMUM (127)
+    0x75, 0x08,                    //   REPORT_SIZE (8)
+    0x95, 0x01,                    //   REPORT_COUNT (1)
+    0x81, 0x02,                    //   INPUT (Data,Var,Abs)
+    0x05, 0x01,                    //   USAGE_PAGE (Generic Desktop)
+    0x09, 0x01,                    //   USAGE (Pointer)
+    0xa1, 0x00,                    //   COLLECTION (Physical)
+    0x09, 0x30,                    //     USAGE (X)
+    0x09, 0x31,                    //     USAGE (Y)
+    0x95, 0x02,                    //     REPORT_COUNT (2)
+    0x81, 0x02,                    //     INPUT (Data,Var,Abs)
+    0xc0,                          //   END_COLLECTION
+    0x09, 0x39,                    //   USAGE (Hat switch)
+    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
+    0x25, 0x03,                    //   LOGICAL_MAXIMUM (3)
+    0x35, 0x00,                    //   PHYSICAL_MINIMUM (0)
+    0x46, 0x0e, 0x01,              //   PHYSICAL_MAXIMUM (270)
+    0x65, 0x14,                    //   UNIT (Eng Rot:Angular Pos)
+    0x75, 0x04,                    //   REPORT_SIZE (4)
+    0x95, 0x01,                    //   REPORT_COUNT (1)
+    0x81, 0x02,                    //   INPUT (Data,Var,Abs)
+    0x05, 0x09,                    //   USAGE_PAGE (Button)
+    0x19, 0x01,                    //   USAGE_MINIMUM (Button 1)
+    0x29, 0x04,                    //   USAGE_MAXIMUM (Button 4)
+    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
+    0x25, 0x01,                    //   LOGICAL_MAXIMUM (1)
+    0x75, 0x01,                    //   REPORT_SIZE (1)
+    0x95, 0x04,                    //   REPORT_COUNT (4)
+    0x55, 0x00,                    //   UNIT_EXPONENT (16)
+// Non-zero data in the Reserved field
+//  0x65, 0x00,                    //   UNIT (None)
+    0x67, 0x00, 0x00, 0x00, 0x80,  //   UNIT (Non-zero value in reserverd)
+    0x81, 0x02,                    //   INPUT (Data,Var,Abs)
+    0xc0                           // END_COLLECTION
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/unitexponent.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,43 @@
+// File: UnitExponent1.hid.txt
+// Unit Exponent with non-zero data in the reserved field
+
+    0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
+    0x15, 0x00,                    // LOGICAL_MINIMUM (0)
+    0x09, 0x04,                    // USAGE (Joystick)
+    0xa1, 0x01,                    // COLLECTION (Application)
+    0x05, 0x02,                    //   USAGE_PAGE (Simulation Controls)
+    0x09, 0xbb,                    //   USAGE (Throttle)
+    0x15, 0x81,                    //   LOGICAL_MINIMUM (-127)
+    0x25, 0x7f,                    //   LOGICAL_MAXIMUM (127)
+    0x75, 0x08,                    //   REPORT_SIZE (8)
+    0x95, 0x01,                    //   REPORT_COUNT (1)
+    0x81, 0x02,                    //   INPUT (Data,Var,Abs)
+    0x05, 0x01,                    //   USAGE_PAGE (Generic Desktop)
+    0x09, 0x01,                    //   USAGE (Pointer)
+    0xa1, 0x00,                    //   COLLECTION (Physical)
+    0x09, 0x30,                    //     USAGE (X)
+    0x09, 0x31,                    //     USAGE (Y)
+    0x95, 0x02,                    //     REPORT_COUNT (2)
+    0x81, 0x02,                    //     INPUT (Data,Var,Abs)
+    0xc0,                          //   END_COLLECTION
+    0x09, 0x39,                    //   USAGE (Hat switch)
+    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
+    0x25, 0x03,                    //   LOGICAL_MAXIMUM (3)
+    0x35, 0x00,                    //   PHYSICAL_MINIMUM (0)
+    0x46, 0x0e, 0x01,              //   PHYSICAL_MAXIMUM (270)
+    0x65, 0x14,                    //   UNIT (Eng Rot:Angular Pos)
+    0x75, 0x04,                    //   REPORT_SIZE (4)
+    0x95, 0x01,                    //   REPORT_COUNT (1)
+    0x81, 0x02,                    //   INPUT (Data,Var,Abs)
+    0x05, 0x09,                    //   USAGE_PAGE (Button)
+    0x19, 0x01,                    //   USAGE_MINIMUM (Button 1)
+    0x29, 0x04,                    //   USAGE_MAXIMUM (Button 4)
+    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
+    0x25, 0x01,                    //   LOGICAL_MAXIMUM (1)
+    0x75, 0x01,                    //   REPORT_SIZE (1)
+    0x95, 0x04,                    //   REPORT_COUNT (4)
+// Non-zero data in the Reserved field
+    0x55, 0x10,                    //   UNIT_EXPONENT (16)
+    0x65, 0x00,                    //   UNIT (None)
+    0x81, 0x02,                    //   INPUT (Data,Var,Abs)
+    0xc0                           // END_COLLECTION
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/voldown.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0x22, 0x01
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/data/volup.hid	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1 @@
+0x21,0x01
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/eabi/GenericHidTestU.def	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,3 @@
+EXPORTS
+	_Z9LibEntryLR13CTestModuleIf @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/group/CHidDriverPlugin.mmp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+#include <platform_paths.hrh>
+
+//CAPABILITY 	CAP_ECOM_PLUGIN
+CAPABILITY      CAP_APPLICATION CommDD ProtServ 
+
+VENDORID VID_DEFAULT
+
+TARGET      chiddriverplugin.dll
+TARGETTYPE	PLUGIN
+UID         0x10009D8D 0xE000B181 
+
+SOURCEPATH  ../src
+SOURCE      CHidDriverPluginProxy.cpp
+SOURCE      CHidDriverPlugin.cpp
+
+USERINCLUDE     ../inc 
+USERINCLUDE     ../../../inc 
+
+SYSTEMINCLUDE /epoc32/include/ecom 
+MW_LAYER_SYSTEMINCLUDE
+
+
+START RESOURCE  ../data/E000B181.RSS
+TARGET chiddriverplugin.rsc
+END
+
+LIBRARY	ECom.lib
+LIBRARY euser.lib
+LIBRARY	generichid.lib
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/group/GenericHidTest.mmp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,64 @@
+/*TYPE TESTCLASS*/
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#if defined(__S60_)
+        // To get the OSEXT_LAYER_SYSTEMINCLUDE-definition
+        #include <platform_paths.hrh>
+#endif
+
+TARGET          GenericHidTest.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x101FB3E3
+
+//CAPABILITY      ALL -TCB
+CAPABILITY      CAP_APPLICATION CommDD ProtServ
+
+DEFFILE         GenericHidTest.def
+
+MW_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE	../inc 
+USERINCLUDE     ../../../inc 
+
+SYSTEMINCLUDE 	/epoc32/include/internal
+
+SOURCEPATH      ../src
+SOURCE          GenericHidTest.cpp
+SOURCE          GenericHidTestBlocks.cpp
+SOURCE  		tGenericHIDAPI.cpp
+SOURCE			tdialclient.cpp 
+SOURCE			alarmcontrol.cpp
+SOURCE          timer.cpp
+SOURCE          CHidDriverPlugin.cpp
+
+LIBRARY         euser.lib
+LIBRARY         stiftestinterface.lib
+LIBRARY         stiftestengine.lib
+
+LIBRARY         sysutil.lib
+LIBRARY         efsrv.lib
+LIBRARY			generichid.lib
+LIBRARY			etel3rdparty.lib
+LIBRARY			alarmclient.lib 
+LIBRARY			alarmshared.lib 
+
+
+LANG            SC
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/group/GenericHidTest_ats.pkg	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,171 @@
+;
+; Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:  
+;
+;
+
+; Languages
+&EN
+
+; Provide value for uid
+#{"STIF"},(0x00000000),1,1,0,TYPE=SA
+
+; Series60 product id for S60 5.1
+[0x10283160], 0, 0, 0, {"Series60ProductID"}
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+; Logo
+; None
+
+; Package signature - Optional
+; None
+
+; Start of Package body
+
+; Condition blocks
+; None
+
+; Options list
+; None
+
+; Install files
+"\epoc32\release\armv5\udeb\GenericHidTest.dll"-"c:\Sys\Bin\GenericHidTest.dll"
+"\epoc32\release\armv5\udeb\GenericHidTest.exe"   -   "C:\Sys\Bin\GenericHidTest.exe"
+
+"\epoc32\release\armv5\udeb\chiddriverplugin.dll"-"C:\Sys\Bin\chiddriverplugin.dll"
+"\epoc32\data\Z\resource\plugins\chiddriverplugin.rsc"-"C:\resource\plugins\chiddriverplugin.rsc"
+
+"..\init\GenericHidTest_ats.ini"-"e:\testing\init\GenericHidTest.ini"
+"..\conf\GenericHidTest.cfg"-"e:\testing\conf\GenericHidTest.cfg"
+
+"..\data\connectad83.hid"-"c:\data\others\connectad83.hid"
+"..\data\delimiter.hid"-"c:\data\others\delimiter.hid"
+"..\data\designator.hid"-"c:\data\others\designator.hid"
+"..\data\designatorindex.hid"-"c:\data\others\designatorindex.hid"
+"..\data\dummyconnect.hid"-"c:\data\others\dummyconnect.hid"
+"..\data\empty.hid"-"c:\data\others\empty.hid"
+"..\data\feature.hid"-"c:\data\others\feature.hid"
+"..\data\feature1.hid"-"c:\data\others\feature1.hid"
+"..\data\headsetcon2.hid"-"c:\data\others\headsetcon2.hid"
+"..\data\headsetconnect.hid"-"c:\data\others\headsetconnect.hid"
+"..\data\headsetvolumeup.hid"-"c:\data\others\headsetvolumeup.hid"
+"..\data\headsetvolumeupm.hid"-"c:\data\others\headsetvolumeupm.hid"
+"..\data\hook.hid"-"c:\data\others\hook.hid"
+"..\data\hookconnect.hid"-"c:\data\others\hookconnect.hid"
+"..\data\inputdata.hid"-"c:\data\others\inputdata.hid"
+"..\data\multipagec.hid"-"c:\data\others\multipagec.hid"
+"..\data\multipagein.hid"-"c:\data\others\multipagein.hid"
+"..\data\multiple_usage_page_connect.hid"-"c:\data\others\multiple_usage_page_connect.hid"
+"..\data\mute.hid"-"c:\data\others\mute.hid"
+"..\data\next.hid"-"c:\data\others\next.hid"
+"..\data\output.hid"-"c:\data\others\output.hid"
+"..\data\output1.hid"-"c:\data\others\output1.hid"
+"..\data\physicalmax.hid"-"c:\data\others\physicalmax.hid"
+"..\data\play.hid"-"c:\data\others\play.hid"
+"..\data\pop.hid"-"c:\data\others\pop.hid"
+"..\data\prev.hid"-"c:\data\others\prev.hid"
+"..\data\push.hid"-"c:\data\others\push.hid"
+"..\data\stop.hid"-"c:\data\others\stop.hid"
+"..\data\string.hid"-"c:\data\others\string.hid"
+"..\data\stringindex.hid"-"c:\data\others\stringindex.hid"
+"..\data\unit.hid"-"c:\data\others\unit.hid"
+"..\data\unitexponent.hid"-"c:\data\others\unitexponent.hid"
+"..\data\voldown.hid"-"c:\data\others\voldown.hid"
+"..\data\volup.hid"-"c:\data\others\volup.hid"
+
+"..\data\localdesignatorindex.hid"-"c:\data\others\localdesignatorindex.hid"
+"..\data\localdesignatorminimum.hid"-"c:\data\others\localdesignatorminimum.hid"
+"..\data\localdesignatormaximum.hid"-"c:\data\others\localdesignatormaximum.hid"
+
+"..\data\localstringindex.hid"-"c:\data\others\localstringindex.hid"
+"..\data\localstringminimum.hid"-"c:\data\others\localstringminimum.hid"
+"..\data\localstringmaximum.hid"-"c:\data\others\localstringmaximum.hid"
+
+"..\data\localdelimiter.hid"-"c:\data\others\localdelimiter.hid"
+"..\data\localdelimiter_lonelydelimiter.hid"-"c:\data\others\localdelimiter_lonelydelimiter.hid"
+"..\data\localdelimiter_nesteddelimiter.hid"-"c:\data\others\localdelimiter_nesteddelimiter.hid"
+
+"..\data\localusage.hid"-"c:\data\others\localusage.hid"
+"..\data\localusageminimum.hid"-"c:\data\others\localusageminimum.hid"
+"..\data\localusagemaximum.hid"-"c:\data\others\localusagemaximum.hid"
+
+"..\data\localitem_unknown.hid"-"c:\data\others\localitem_unknown.hid"
+
+"..\data\globalphysicalmin.hid"-"c:\data\others\globalphysicalmin.hid"
+"..\data\globalphysicalmax.hid"-"c:\data\others\globalphysicalmax.hid"
+"..\data\globalunit.hid"-"c:\data\others\globalunit.hid"
+"..\data\globalunit_smallvalue.hid"-"c:\data\others\globalunit_smallvalue.hid"
+"..\data\globalunitexponent.hid"-"c:\data\others\globalunitexponent.hid"
+"..\data\globalunitexponent2.hid"-"c:\data\others\globalunitexponent2.hid"
+"..\data\globalpush.hid"-"c:\data\others\globalpush.hid"
+"..\data\globalpop.hid"-"c:\data\others\globalpop.hid"
+"..\data\globalpop_withoutpush.hid"-"c:\data\others\globalpop_withoutpush.hid"
+"..\data\globaitem_unknown.hid"-"c:\data\others\globaitem_unknown.hid"
+
+"..\data\mainoutputtag.hid"-"c:\data\others\mainoutputtag.hid"
+"..\data\mainfeature.hid"-"c:\data\others\mainfeature.hid"
+
+"..\data\longitem.hid"-"c:\data\others\longitem.hid"
+"..\data\handleitem_withindelimiter.hid"-"c:\data\others\handleitem_withindelimiter.hid"
+
+"..\data\mainitem_unknown.hid"-"c:\data\others\mainitem_unknown.hid"
+
+"..\data\checkusageminandmax.hid"-"c:\data\others\checkusageminandmax.hid"
+"..\data\checkusageminandmax2.hid"-"c:\data\others\checkusageminandmax2.hid"
+"..\data\checkusageminandmax3.hid"-"c:\data\others\checkusageminandmax3.hid"
+
+"..\data\checkdesignatorminandmax.hid"-"c:\data\others\checkdesignatorminandmax.hid"
+"..\data\checkdesignatorminandmax2.hid"-"c:\data\others\checkdesignatorminandmax2.hid"
+"..\data\checkdesignatorminandmax3.hid"-"c:\data\others\checkdesignatorminandmax3.hid"
+
+"..\data\checkstringminandmax.hid"-"c:\data\others\checkstringminandmax.hid"
+"..\data\checkstringminandmax2.hid"-"c:\data\others\checkstringminandmax2.hid"
+"..\data\checkstringminandmax3.hid"-"c:\data\others\checkstringminandmax3.hid"
+
+"..\data\checkmandatoryfieldexistence.hid"-"c:\data\others\checkmandatoryfieldexistence.hid"
+"..\data\checkmandatoryfieldexistence2.hid"-"c:\data\others\checkmandatoryfieldexistence2.hid"
+"..\data\checkmandatoryfieldexistence3.hid"-"c:\data\others\checkmandatoryfieldexistence3.hid"
+
+"..\data\checkforfielderrors.hid"-"c:\data\others\checkforfielderrors.hid"
+"..\data\checkforfielderrors2.hid"-"c:\data\others\checkforfielderrors2.hid"
+
+"..\data\checklogicalminandmax.hid"-"c:\data\others\checklogicalminandmax.hid"
+
+"..\data\checkfieldbitneeded.hid"-"c:\data\others\checkfieldbitneeded.hid"
+
+"..\data\checkformainerrors.hid"-"c:\data\others\checkformainerrors.hid"
+"..\data\checkformainerrors2.hid"-"c:\data\others\checkformainerrors2.hid"
+"..\data\checkformainerrors3.hid"-"c:\data\others\checkformainerrors3.hid"
+
+"..\data\checkparseerrors.hid"-"c:\data\others\checkparseerrors.hid"
+"..\data\checkparseerrors2.hid"-"c:\data\others\checkparseerrors2.hid"
+"..\data\checkparseerrors3.hid"-"c:\data\others\checkparseerrors3.hid"
+
+"..\data\checkforcollectionerrors.hid"-"c:\data\others\checkforcollectionerrors.hid"
+  
+; Embedded SIS 
+; None
+
+; End of Package body
+
+; PKG dependencies
+; None
+
+; PKG capabilities
+; None
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/group/GenericHidTest_exe.mmp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,42 @@
+/*TYPE TESTCLASS*/
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#if defined(__S60_)
+        #include <platform_paths.hrh>
+#endif
+
+TARGET          GenericHidTest.exe
+TARGETTYPE      exe
+UID		0 0xEF4892C6
+
+CAPABILITY      LocalServices CommDD
+
+
+MW_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH      ../src
+
+SOURCE          GenericHidTest_exe.cpp
+
+LIBRARY         euser.lib
+LIBRARY         stiftestinterface.lib
+
+EPOCSTACKSIZE   40960
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/group/GenericHidTest_phone.pkg	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,172 @@
+;
+; Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:  
+;
+;
+
+; Languages
+&EN
+
+; Provide value for uid
+#{"STIF"},(0x00000000),1,1,0,TYPE=SA
+
+; Series60 product id for S60 5.1
+[0x10283160], 0, 0, 0, {"Series60ProductID"}
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+; Logo
+; None
+
+; Package signature - Optional
+; None
+
+; Start of Package body
+
+; Condition blocks
+; None
+
+; Options list
+; None
+
+; Install files
+"\epoc32\release\armv5\udeb\GenericHidTest.dll"-"c:\Sys\Bin\GenericHidTest.dll"
+"\epoc32\release\armv5\udeb\GenericHidTest.exe"   -   "C:\Sys\Bin\GenericHidTest.exe"
+
+"\epoc32\release\armv5\udeb\chiddriverplugin.dll"-"C:\Sys\Bin\chiddriverplugin.dll"
+"\epoc32\data\Z\resource\plugins\chiddriverplugin.rsc"-"C:\resource\plugins\chiddriverplugin.rsc"
+
+"..\init\GenericHidTest_phone.ini"-"c:\testframework\testframework.ini"
+"..\conf\GenericHidTest.cfg"-"c:\testframework\GenericHidTest.cfg"
+
+"..\data\connectad83.hid"-"c:\data\others\connectad83.hid"
+"..\data\delimiter.hid"-"c:\data\others\delimiter.hid"
+"..\data\designator.hid"-"c:\data\others\designator.hid"
+"..\data\designatorindex.hid"-"c:\data\others\designatorindex.hid"
+"..\data\dummyconnect.hid"-"c:\data\others\dummyconnect.hid"
+"..\data\empty.hid"-"c:\data\others\empty.hid"
+"..\data\feature.hid"-"c:\data\others\feature.hid"
+"..\data\feature1.hid"-"c:\data\others\feature1.hid"
+"..\data\headsetcon2.hid"-"c:\data\others\headsetcon2.hid"
+"..\data\headsetconnect.hid"-"c:\data\others\headsetconnect.hid"
+"..\data\headsetvolumeup.hid"-"c:\data\others\headsetvolumeup.hid"
+"..\data\headsetvolumeupm.hid"-"c:\data\others\headsetvolumeupm.hid"
+"..\data\hook.hid"-"c:\data\others\hook.hid"
+"..\data\hookconnect.hid"-"c:\data\others\hookconnect.hid"
+"..\data\inputdata.hid"-"c:\data\others\inputdata.hid"
+"..\data\multipagec.hid"-"c:\data\others\multipagec.hid"
+"..\data\multipagein.hid"-"c:\data\others\multipagein.hid"
+"..\data\multiple_usage_page_connect.hid"-"c:\data\others\multiple_usage_page_connect.hid"
+"..\data\mute.hid"-"c:\data\others\mute.hid"
+"..\data\next.hid"-"c:\data\others\next.hid"
+"..\data\output.hid"-"c:\data\others\output.hid"
+"..\data\output1.hid"-"c:\data\others\output1.hid"
+"..\data\physicalmax.hid"-"c:\data\others\physicalmax.hid"
+"..\data\play.hid"-"c:\data\others\play.hid"
+"..\data\pop.hid"-"c:\data\others\pop.hid"
+"..\data\prev.hid"-"c:\data\others\prev.hid"
+"..\data\push.hid"-"c:\data\others\push.hid"
+"..\data\stop.hid"-"c:\data\others\stop.hid"
+"..\data\string.hid"-"c:\data\others\string.hid"
+"..\data\stringindex.hid"-"c:\data\others\stringindex.hid"
+"..\data\unit.hid"-"c:\data\others\unit.hid"
+"..\data\unitexponent.hid"-"c:\data\others\unitexponent.hid"
+"..\data\voldown.hid"-"c:\data\others\voldown.hid"
+"..\data\volup.hid"-"c:\data\others\volup.hid"
+"..\data\UsagePoC.hid"-"c:\data\others\UsagePoC.hid"
+
+"..\data\localdesignatorindex.hid"-"c:\data\others\localdesignatorindex.hid"
+"..\data\localdesignatorminimum.hid"-"c:\data\others\localdesignatorminimum.hid"
+"..\data\localdesignatormaximum.hid"-"c:\data\others\localdesignatormaximum.hid"
+
+"..\data\localstringindex.hid"-"c:\data\others\localstringindex.hid"
+"..\data\localstringminimum.hid"-"c:\data\others\localstringminimum.hid"
+"..\data\localstringmaximum.hid"-"c:\data\others\localstringmaximum.hid"
+
+"..\data\localdelimiter.hid"-"c:\data\others\localdelimiter.hid"
+"..\data\localdelimiter_lonelydelimiter.hid"-"c:\data\others\localdelimiter_lonelydelimiter.hid"
+"..\data\localdelimiter_nesteddelimiter.hid"-"c:\data\others\localdelimiter_nesteddelimiter.hid"
+
+"..\data\localusage.hid"-"c:\data\others\localusage.hid"
+"..\data\localusageminimum.hid"-"c:\data\others\localusageminimum.hid"
+"..\data\localusagemaximum.hid"-"c:\data\others\localusagemaximum.hid"
+
+"..\data\localitem_unknown.hid"-"c:\data\others\localitem_unknown.hid"
+
+"..\data\globalphysicalmin.hid"-"c:\data\others\globalphysicalmin.hid"
+"..\data\globalphysicalmax.hid"-"c:\data\others\globalphysicalmax.hid"
+"..\data\globalunit.hid"-"c:\data\others\globalunit.hid"
+"..\data\globalunit_smallvalue.hid"-"c:\data\others\globalunit_smallvalue.hid"
+"..\data\globalunitexponent.hid"-"c:\data\others\globalunitexponent.hid"
+"..\data\globalunitexponent2.hid"-"c:\data\others\globalunitexponent2.hid"
+"..\data\globalpush.hid"-"c:\data\others\globalpush.hid"
+"..\data\globalpop.hid"-"c:\data\others\globalpop.hid"
+"..\data\globalpop_withoutpush.hid"-"c:\data\others\globalpop_withoutpush.hid"
+"..\data\globaitem_unknown.hid"-"c:\data\others\globaitem_unknown.hid"
+
+"..\data\mainoutputtag.hid"-"c:\data\others\mainoutputtag.hid"
+"..\data\mainfeature.hid"-"c:\data\others\mainfeature.hid"
+
+"..\data\longitem.hid"-"c:\data\others\longitem.hid"
+"..\data\handleitem_withindelimiter.hid"-"c:\data\others\handleitem_withindelimiter.hid"
+
+"..\data\mainitem_unknown.hid"-"c:\data\others\mainitem_unknown.hid"
+
+"..\data\checkusageminandmax.hid"-"c:\data\others\checkusageminandmax.hid"
+"..\data\checkusageminandmax2.hid"-"c:\data\others\checkusageminandmax2.hid"
+"..\data\checkusageminandmax3.hid"-"c:\data\others\checkusageminandmax3.hid"
+
+"..\data\checkdesignatorminandmax.hid"-"c:\data\others\checkdesignatorminandmax.hid"
+"..\data\checkdesignatorminandmax2.hid"-"c:\data\others\checkdesignatorminandmax2.hid"
+"..\data\checkdesignatorminandmax3.hid"-"c:\data\others\checkdesignatorminandmax3.hid"
+
+"..\data\checkstringminandmax.hid"-"c:\data\others\checkstringminandmax.hid"
+"..\data\checkstringminandmax2.hid"-"c:\data\others\checkstringminandmax2.hid"
+"..\data\checkstringminandmax3.hid"-"c:\data\others\checkstringminandmax3.hid"
+
+"..\data\checkmandatoryfieldexistence.hid"-"c:\data\others\checkmandatoryfieldexistence.hid"
+"..\data\checkmandatoryfieldexistence2.hid"-"c:\data\others\checkmandatoryfieldexistence2.hid"
+"..\data\checkmandatoryfieldexistence3.hid"-"c:\data\others\checkmandatoryfieldexistence3.hid"
+
+"..\data\checkforfielderrors.hid"-"c:\data\others\checkforfielderrors.hid"
+"..\data\checkforfielderrors2.hid"-"c:\data\others\checkforfielderrors2.hid"
+
+"..\data\checklogicalminandmax.hid"-"c:\data\others\checklogicalminandmax.hid"
+
+"..\data\checkfieldbitneeded.hid"-"c:\data\others\checkfieldbitneeded.hid"
+
+"..\data\checkformainerrors.hid"-"c:\data\others\checkformainerrors.hid"
+"..\data\checkformainerrors2.hid"-"c:\data\others\checkformainerrors2.hid"
+"..\data\checkformainerrors3.hid"-"c:\data\others\checkformainerrors3.hid"
+
+"..\data\checkparseerrors.hid"-"c:\data\others\checkparseerrors.hid"
+"..\data\checkparseerrors2.hid"-"c:\data\others\checkparseerrors2.hid"
+"..\data\checkparseerrors3.hid"-"c:\data\others\checkparseerrors3.hid"
+
+"..\data\checkforcollectionerrors.hid"-"c:\data\others\checkforcollectionerrors.hid"
+  
+; Embedded SIS 
+; None
+
+; End of Package body
+
+; PKG dependencies
+; None
+
+; PKG capabilities
+; None
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Build file
+*
+*/
+
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_TESTEXPORTS
+
+PRJ_EXPORTS
+
+PRJ_TESTMMPFILES
+GenericHidTest.mmp
+GenericHidTest_exe.mmp
+CHidDriverPlugin.mmp
+
+
+PRJ_MMPFILES
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/group/build_sis_ats.bat	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,22 @@
+@rem
+@rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description: Test script config file
+@rem
+@rem
+
+
+call bldmake bldfiles
+call abld test build armv5
+call makesis GenericHidTest_ats.pkg
+call signsis GenericHidTest_ats.sis GenericHidTest_ats.sisx rd.cer rd-key.pem
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/group/build_sis_phone.bat	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,27 @@
+@rem
+@rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description: Test script config file
+@rem
+@rem
+
+rd /q /s x:\epoc32\build
+del GenericHidTest_phone.sisx
+
+call bldmake bldfiles
+call abld test build armv5 udeb
+call makesis GenericHidTest_phone.pkg
+call signsis GenericHidTest_phone.sis GenericHidTest_phone.sisx rd.cer rd-key.pem
+
+del GenericHidTest_phone.sis
+call pause
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/inc/CHidDriverPlugin.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef REFERENCE_HIDDRIVER_IMPL_H
+#define REFERENCE_HIDDRIVER_IMPL_H
+
+#include <hidinterfaces.h>
+
+NONSHARABLE_CLASS(CHidDriverPlugin) : public CHidDriver
+  	{
+  	public:
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CHidDriverPlugin* NewL(MDriverAccess* aHid);
+          
+        TInt CanHandleReportL(CReportRoot* aReportDescriptor);
+        
+        TInt DataIn(CHidTransport::THidChannelType aChannel,
+                const TDesC8& aPayload);
+        
+        void Disconnected(TInt aReason);
+        void InitialiseL(TInt aConnectionId);
+        void StartL(TInt aConnectionId);
+        void Stop();
+        void CommandResult(TInt aCmdAck);
+        TInt SupportedFieldCount();
+        void SetInputHandlingReg(CHidInputDataHandlingReg* aHandlingReg);
+
+private:
+		CHidDriverPlugin();
+    
+private:    // Data
+
+    };
+
+#endif      // REFERENCE_HIDDRIVER_IMPL_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/inc/GenericHidTest.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,377 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef GENERICHIDTEST_H
+#define GENERICHIDTEST_H
+
+//  INCLUDES
+#include <StifLogger.h>
+#include <TestScripterInternal.h>
+#include <StifTestModule.h>
+#include <TestclassAssert.h>
+
+#include "hidparser.h"
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+#define TEST_CLASS_VERSION_MAJOR 0
+#define TEST_CLASS_VERSION_MINOR 0
+#define TEST_CLASS_VERSION_BUILD 0
+
+#ifdef STIF_LOG
+#undef STIF_LOG
+#endif
+
+#define STIF_LOG( s )\
+    {\
+    TBuf<KMaxLogData> traceBuf;\
+    traceBuf.Append( _L( "[STIF_LOG] " ) );\
+    traceBuf.Append( _L( s ) );\
+    iLog->Log( _L( s ) );\
+    RDebug::Print( traceBuf );\
+    }
+
+#define STIF_LOG1( s, v ) \
+    {\
+    TBuf<KMaxLogData> traceBuf;\
+    traceBuf.Append( _L( "[STIF_LOG] " ) );\
+    traceBuf.Append( _L( s ) );\
+    iLog->Log( _L( s ), v );\
+    RDebug::Print( traceBuf, v );\
+    }
+
+#define STIF_LOG2( s, v1, v2 ) \
+    {\
+    TBuf<KMaxLogData> traceBuf;\
+    traceBuf.Append( _L( "[STIF_LOG] " ) );\
+    traceBuf.Append( _L( s ) );\
+    iLog->Log( _L( s ), v1, v2 );\
+    RDebug::Print( traceBuf, v1, v2 );\
+    }
+
+#define STIF_LOG3( s, v1, v2, v3 ) \
+    {\
+    TBuf<KMaxLogData> traceBuf;\
+    traceBuf.Append( _L( "[STIF_LOG] " ) );\
+    traceBuf.Append( _L( s ) );\
+    iLog->Log( _L( s ), v1, v2, v3 );\
+    RDebug::Print( traceBuf, v1, v2, v3 );\
+    }
+
+// Logging path
+//_LIT( KGenericHidTestLogPath, "\\logs\\testframework\\GenericHidTest\\" );
+
+// Logging path for ATS - for phone builds comment this line
+_LIT( KGenericHidTestLogPath, "e:\\testing\\stiflogs\\" );
+
+// Log file
+_LIT( KGenericHidTestLogFile, "GenericHidTest.txt" ); 
+_LIT( KGenericHidTestLogFileWithTitle, "GenericHidTest_[%S].txt" );
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+class CGenericHidTest;
+
+class CHidTestLogger;
+class CtGenericHIDAPI;
+//class CMediaControl;
+class CDialClient;  
+class CAlarmControl;
+
+// DATA TYPES
+//enum ?declaration
+
+enum TGenericHidTestResult
+    {
+    ETestCasePassed,
+    ETestCaseFailed
+    };
+
+//typedef ?declaration
+//extern ?data_type;
+
+// CLASS DECLARATION
+
+NONSHARABLE_CLASS( TGenericHidTestBlockParams )
+    {
+    public:
+        TPtrC iTestBlockName;
+        
+        TPtrC iTestOption1;
+        TPtrC iTestOption2;
+        TPtrC iTestOption3;
+        
+        TInt iTestIntOption1;
+        TInt iTestIntOption2;
+        
+        TChar iTestCharOption1;
+        TChar iTestCharOption2;
+    };
+
+/**
+*  CGenericHidTest test class for STIF Test Framework TestScripter.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+NONSHARABLE_CLASS( CGenericHidTest ) : public CScriptBase
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CGenericHidTest* NewL( CTestModuleIf& aTestModuleIf );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CGenericHidTest();
+
+    public: // New functions
+
+        /**
+        * ?member_description.
+        * @since ?Series60_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From CScriptBase Runs a script line.
+        * @since ?Series60_version
+        * @param aItem Script line containing method name and parameters
+        * @return Symbian OS error code
+        */
+        virtual TInt RunMethodL( CStifItemParser& aItem );
+
+    protected:  // New functions
+
+        /**
+        * ?member_description.
+        * @since ?Series60_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CGenericHidTest( CTestModuleIf& aTestModuleIf );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // ?classname( const ?classname& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // ?classname& operator=( const ?classname& );
+
+        /**
+        * Frees all resources allocated from test methods.
+        * @since ?Series60_version
+        */
+        void Delete();
+
+        /**
+        * Test methods are listed below. 
+        */
+
+        virtual TInt ExecuteApiTestBlock( CStifItemParser& aItem );
+        virtual TInt ExecuteModuleTestBlock( CStifItemParser& aItem );
+        virtual TInt ExecuteBranchTestBlock( CStifItemParser& aItem );
+        
+        /**
+         * Method used to log version of test class
+         */
+        void SendTestClassVersion();
+
+        //ADD NEW METHOD DEC HERE
+        //[TestMethods] - Do not remove
+
+        void GetTestBlockParamsL( CStifItemParser& aItem );
+        
+    	void DoExecuteApiTestBlockL( CStifItemParser& aItem, TGenericHidTestResult& aTestResult );    	
+    	void DoExecuteModuleTestBlockL( CStifItemParser& aItem, TGenericHidTestResult& aTestResult );    
+    	void DoExecuteBranchTestBlockL( CStifItemParser& aItem, TGenericHidTestResult& aTestResult );
+    	
+        void ExampleTestL( TPtrC aTestOption, TPtrC aTestSubOption, 
+                 TInt aTestIntOption, TInt aTestCharOption, TGenericHidTestResult& aTestResult );
+        
+        virtual TInt ConnectL( TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult );							  
+		virtual TInt DisconnectL( TPtrC aTestOption, TGenericHidTestResult& aTestResult );		
+		virtual TInt DataIn( TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt WaitL( TPtrC aTestOption, TInt aTestIntOption, TGenericHidTestResult& aTestResult );		
+		virtual TInt CreateCallL( TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult );		
+		virtual TInt AddAlarmL( TPtrC aTestOption, TInt aTestIntOption, TGenericHidTestResult& aTestResult  );		
+		virtual TInt DeleteAlarm( TPtrC aTestOption, TGenericHidTestResult& aTestResult );	
+		virtual TInt CountryCodeL( TPtrC aTestOption, TGenericHidTestResult& aTestResult );		
+		virtual TInt VendorIdL( TPtrC aTestOption, TGenericHidTestResult& aTestResult );		
+		virtual TInt ProductIdL( TPtrC aTestOption, TGenericHidTestResult& aTestResult );		
+		virtual TInt SetProtocolL( TPtrC aTestOption, TGenericHidTestResult& aTestResult );		
+		virtual TInt GetProtocoL( TPtrC aTestOption, TGenericHidTestResult& aTestResult );		
+		virtual TInt GetReportL( TPtrC aTestOption, TGenericHidTestResult& aTestResult );		
+		virtual TInt SetReportL( TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult );			   
+		virtual TInt DataOutL( TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult);		
+		virtual TInt GetIdleL( TPtrC aTestOption, TGenericHidTestResult& aTestResult );		
+		virtual TInt SetIdleL( TPtrC aTestOption, TGenericHidTestResult& aTestResult );
+		
+		virtual TInt CommandResultL( TPtrC aTestOption, TGenericHidTestResult& aTestResult );		
+		virtual TInt ReportDescriptorL( TPtrC aTestOption, TGenericHidTestResult& aTestResult );		
+		virtual TInt CreateReportGeneratorL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult );		
+		virtual TInt DeleteReportGeneratorL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult );		
+		virtual TInt ReportGeneratorReportL( TPtrC aTestOption, TGenericHidTestResult& aTestResult );		
+		virtual TInt ReportGeneratorSetFieldL(  TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult );		
+		virtual TInt CreateReportTranslatorL( TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult );	
+		virtual TInt CreateReportTranslator_FieldNullL( TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult );		
+		virtual TInt CreateReportTranslator_NotArrayL(  TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult );		
+		virtual TInt CreateReportTranslator_FieldCountZeroL(  TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult );		
+		virtual TInt DeleteReportTranslatorL( TPtrC aTestOption, TGenericHidTestResult& aTestResult );		
+		virtual TInt ReportTranslatorGetValueL( TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult );		
+		virtual TInt ReportTranslatorValueL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult  );		
+		virtual TInt ReportTranslatorGetUsageIdL(  TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult );		
+		virtual TInt ReportTranslatorUsageIdL( TPtrC aTestOption, TGenericHidTestResult& aTestResult );		
+		virtual TInt ReportTranslatorRawValueL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult );		
+		virtual TInt ReportTranslatorCountL( TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult );
+		
+		virtual TInt CollectiontypeL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt CollectionIsPhysicalL( TPtrC aTestOption, TGenericHidTestResult& aTestResult   );
+		virtual TInt CollectionIsLogicalL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt CollectionIsReportL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult );
+		virtual TInt CollectionIsNamedArrayL(   TPtrC aTestOption, TGenericHidTestResult& aTestResult );
+		virtual TInt CollectionIsUsageSwitchL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt CollectionIsUsageModifierL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult  );		
+		
+		virtual TInt CollectionIsApplicationL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt CollectionUsagePageL( TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt CollectionUsageL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt CollectionCollectionCountL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt CollectionFieldCountL( TPtrC aTestOption, TGenericHidTestResult& aTestResult   );
+		virtual TInt CollectionCollectionByIndexL( TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult );
+		virtual TInt CollectionFieldByIndexL( TPtrC aTestOption, TGenericHidTestResult& aTestResult );		
+		
+		virtual TInt ReportrootReportSizeBytes(  TPtrC aTestOption, TGenericHidTestResult& aTestResult );
+		
+		virtual TInt FieldLogicalMaxL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt FieldPhysicalMinL( TPtrC aTestOption, TGenericHidTestResult& aTestResult   );
+		virtual TInt FieldPhysicalMaxL( TPtrC aTestOption, TGenericHidTestResult& aTestResult );
+		virtual TInt FieldUnitL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt FieldUnitExponentL(   TPtrC aTestOption, TGenericHidTestResult& aTestResult);
+		
+		virtual TInt FieldCountL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt FieldSizeL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt FieldOffsetL( TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult );
+		virtual TInt FieldReportIdL(   TPtrC aTestOption, TGenericHidTestResult& aTestResult );
+		virtual TInt FieldIsInReportL( TPtrC aTestOption, TGenericHidTestResult& aTestResult   );
+		virtual TInt FieldDesignatorIndexL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt FieldStringIndexL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult );
+		virtual TInt FieldUsagePageL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult );
+		
+		virtual TInt FieldHasUsageL( TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		
+		virtual TInt FieldUsageArrayL( TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt FieldUsageL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult );
+		virtual TInt FieldUsageCountL( TPtrC aTestOption, TGenericHidTestResult& aTestResult );
+		virtual TInt FieldClearUsageListL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult );
+		virtual TInt FieldLastUsageL( TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult );
+		
+		virtual TInt FieldAttributesL( TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt FieldTypeL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt FieldIsVariableL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt FieldIsArrayL( TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt FieldIsConstantL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult );
+		virtual TInt FieldIsDataL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt FieldSetLogicalMinL( TPtrC aTestOption, TGenericHidTestResult& aTestResult   );
+		virtual TInt FieldSetLogicalMaxL( TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt FieldSetPhysicalMinL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt FieldSetPhysicalMaxL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt FieldSetDesignatorMinL( TPtrC aTestOption, TGenericHidTestResult& aTestResult   );
+		virtual TInt FieldSetDesignatorMaxL( TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt FieldSetUsageMinL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult );
+		virtual TInt FieldSetUsageMaxL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult );
+		virtual TInt FieldSetStringMinL( TPtrC aTestOption, TGenericHidTestResult& aTestResult   );
+		virtual TInt FieldSetStringMaxL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		
+		virtual TInt FieldSetLogicalRangeL( TPtrC aTestOption, TGenericHidTestResult& aTestResult   );
+		virtual TInt FieldSetUsageRangeL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt FieldSetPhysicalRangeL( TPtrC aTestOption, TGenericHidTestResult& aTestResult   );
+		virtual TInt FieldSetStringRangeL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt FieldSetDesignatorRangeL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		virtual TInt FieldIsInputL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+		
+		virtual TInt FieldIsOutputL(   TPtrC aTestOption, TGenericHidTestResult& aTestResult );
+		virtual TInt FieldIsFeatureL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult  );
+					   
+		HBufC8* ConvertArray(const TPtrC& aFilename);		
+		TUint ConvSingleItem(TBuf8<2>& singleItem);
+		
+    public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        TGenericHidTestBlockParams iTestBlockParams;
+
+        CtGenericHIDAPI*    iGenericHIDTest;
+        CDialClient*        iDialClient;
+        CAlarmControl*      iAlarmControl;
+        
+        CParser* iParser;
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+        
+    };
+
+#endif      // GENERICHIDTEST_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/inc/alarmcontrol.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Dialhandling class for hid test application
+*
+*/
+
+
+#ifndef C_ALARMCONTROL_H
+#define C_ALARMCONTROL_H
+
+#include <e32base.h>
+#include <ASCliSession.h>
+#include <TestScripterInternal.h>
+#include <StifLogger.h>
+#include "GenericHidTest.h"
+
+// RDebug
+#include <e32debug.h>
+
+NONSHARABLE_CLASS ( CAlarmControl ): public CBase
+{
+public:
+    static CAlarmControl* NewL(CStifLogger* aLogger);
+    static CAlarmControl* NewLC(CStifLogger* aLogger);
+    
+    void CreateClockAlarm( TInt aTime );
+    void DeleteAlarm();
+public:
+
+	virtual ~CAlarmControl();
+	
+private:
+    CAlarmControl(CStifLogger* aLogger);
+    void ConstructL();
+    
+    RASCliSession iAlarmServer;
+    TInt iAlarmID;
+    CStifLogger * iLog;
+};
+
+#endif /*ALARMCONTROL_H*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/inc/hidreports.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  HID field descriptor definition
+*
+*/
+
+#ifndef __HIDREPORTS_H
+#define __HIDREPORTS_H
+
+
+#include <e32base.h>
+#include <e32cmn.h>
+
+const TUint headsetconnnection[]={
+        0x95, 0x01,      //Report count 1
+        0x05, 0x0b,      //Usage page telephony
+        0x09, 0x01,      // Usage Phone
+        0xa1, 0x02,      // Collection (logical)
+        0x05, 0x09,      //Usage button
+        0xc0             //End collection        
+};
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/inc/tdialclient.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Dialhandling class for hid test application
+*
+*/
+
+
+#ifndef TDIALCLIENT_H_
+#define TDIALCLIENT_H_
+
+#include <e32base.h>
+#include <Etel3rdParty.h>
+
+NONSHARABLE_CLASS ( CDialClient ): public CActive
+    {
+
+public:
+
+    static CDialClient* NewL();
+    static CDialClient* NewLC();
+    
+    void ConstructL();
+    ~CDialClient();
+    
+    void CreateCall(const TDesC& aNumber);
+    void HangUp();
+    
+    
+private:
+     void RunL();
+     void DoCancel();
+
+private:
+     CDialClient(); 
+     
+ private:     
+     CTelephony*                         iTelephony;
+     CTelephony::TCallId                 iCallId;
+     CTelephony::TCallParamsV1           iCallParams;
+     CTelephony::TCallParamsV1Pckg       iCallParamsPckg;
+     CActiveSchedulerWait                iSyncWaiter;
+     TBool                               iCallStarted;
+    };
+
+#endif /*TDIALCLIENT_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/inc/tgenerichidapi.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,340 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  HID generic api test class
+*
+*/
+
+#ifndef __TESTGEHERICHIDAPI_H
+#define __TESTGEHERICHIDAPI_H
+
+
+#include <e32base.h>
+#include <hidinterfaces.h>
+#include <hidgeneric.h>
+#include "hidreportgenerator.h"
+#include "hidtranslate.h"
+
+#include "CHidDriverPlugin.h"
+#include "hiduids.h"
+
+
+/**
+ *  HID generic api test class 
+ *
+ *  @lib 
+ *  @since S60 v.3.2
+ */
+NONSHARABLE_CLASS(CtGenericHIDAPI): public CBase, public MTransportLayer
+    { 
+    public:
+        static CtGenericHIDAPI* NewL();
+        static CtGenericHIDAPI* NewLC();
+
+    /**
+     * Destructor.
+     */
+    virtual ~CtGenericHIDAPI();
+
+    public:  
+
+    /**
+     * Connect
+     *
+     * @since S60 v.3.2
+     * @param aConnectionId connection id 
+     * @param aDescriptor report descriptor
+     * @return None
+     */
+    void ConnectL(TInt aConnectionId, const TDesC8& aDescriptor);
+
+    /**
+     * Disconnect
+     *
+     * @since S60 v.3.2
+     * @param aConnectionId a connection id 
+     * @return None
+     */
+    void DisconnectL(TInt aConnectionId);
+  
+    /**
+     * DataIn
+     *
+     * @since S60 v.3.2
+     * @param aConnectionId connection id 
+     * @param aDescriptor report descriptor
+     * @return error code
+     */
+    TInt DataInL(TInt aConnectionId, const TDesC8& aDescriptor);
+    
+    TInt RunCountryCodeL();
+        
+    TInt RunVendorIdL();
+        
+    TInt RunProductIdL( );
+        
+    TInt RunSetProtocolL();
+        
+    TInt RunGetProtocoL( );
+        
+    TInt RunGetReportL( );
+        
+    TInt RunSetReportL(const TDesC8& aDescriptor );
+                
+    TInt RunDataOutL( const TDesC8& aDescriptor );
+        
+    TInt GetGetIdleL( );
+        
+    TInt RunSetIdleL( );
+        
+    TInt GetCommandResultL( );
+        
+    TInt GetReportDescriptorL();
+    
+    TInt CreateReportGeneratorL();
+    
+    TInt DeleteReportGeneratorL();
+    
+    TInt ReportGeneratorReport();
+    
+    TInt ReportGeneratorSetFieldL(  TBool aIsArray, TBool aOutOfRange, TBool aFieldNull, TBool aFieldCountZero, TBool aExistingUsageId, TBool aBadIndex  );
+    
+    TInt CreateReportTranslatorL( const TDesC8& aDescriptor, TBool aIsArray, TBool aFieldNull, TBool aFieldCountZero);
+    
+    //TInt CreateReportTranslator_FieldNullL( const TDesC8& aDescriptor  );
+            
+    TInt DeleteReportTranslatorL( );
+    
+    TInt ReportTranslatorGetValueL( );
+            
+    TInt ReportTranslatorValueL(  );
+            
+    TInt ReportTranslatorGetUsageIdL( TBool aBadControlIndex );
+            
+    TInt ReportTranslatorUsageIdL( );
+            
+    TInt ReportTranslatorRawValueL( );
+            
+    TInt ReportTranslatorCountL( );
+    
+   TInt CollectiontypeL( );
+   TInt CollectionIsPhysicalL( );
+   TInt CollectionIsLogicalL( );
+   TInt CollectionIsReportL( );
+   TInt CollectionIsNamedArrayL( );
+   TInt CollectionIsUsageSwitchL( );
+   TInt CollectionIsUsageModifierL( );
+   
+   TInt CollectionIsApplicationL( );
+   TInt CollectionUsagePageL( );
+   TInt CollectionUsageL( );
+   TInt CollectionCollectionCountL( );
+   TInt CollectionFieldCountL( );
+   TInt CollectionCollectionByIndexL( TBool aPresent );
+   TInt CollectionFieldByIndexL( );
+   
+   TInt ReportrootReportSizeBytes( );
+   
+
+   TInt FieldLogicalMaxL( );
+   TInt FieldPhysicalMinL( );
+   TInt FieldPhysicalMaxL( );
+   TInt FieldUnitL( );
+   TInt FieldUnitExponentL( );
+   TInt FieldCountL( );
+   TInt FieldSizeL( );
+   TInt FieldOffsetL( TBool setReport );
+   TInt FieldReportIdL( );
+   TInt FieldIsInReportL( );
+   TInt FieldUsagePageL( );
+   TInt FieldDesignatorIndexL( );
+   TInt FieldStringIndexL( );
+   TInt FieldHasUsageL( );
+   TInt FieldUsageArrayL( );
+   TInt FieldUsageL( );
+   TInt FieldUsageCountL( );
+   TInt FieldClearUsageListL( );
+   TInt FieldLastUsageL( TBool empty );
+   TInt FieldAttributesL( );
+   TInt FieldTypeL( );
+   TInt FieldIsArrayL(  );
+   TInt FieldIsVariableL( );
+   TInt FieldIsConstantL(  );
+   TInt FieldIsDataL(  );
+   TInt FieldSetLogicalMinL();
+   TInt FieldSetLogicalMaxL( );
+   TInt FieldSetPhysicalMinL( );
+   TInt FieldSetPhysicalMaxL( );
+   TInt FieldSetDesignatorMinL( );
+   TInt FieldSetDesignatorMaxL(  );
+   TInt FieldSetUsageMinL( );
+   TInt FieldSetUsageMaxL( );
+   TInt FieldSetStringMinL( );
+   TInt FieldSetStringMaxL( );
+   TInt FieldSetLogicalRangeL( );
+   TInt FieldSetUsageRangeL( );
+   TInt FieldSetPhysicalRangeL( );
+   TInt FieldSetStringRangeL( );
+   TInt FieldSetDesignatorRangeL( );
+   TInt FieldIsInputL( );
+   TInt FieldIsOutputL( );
+   TInt FieldIsFeatureL( );
+
+    
+  
+private: //from MTransportLayer
+
+    /**
+     * Request for the country code of the given device.
+     *
+     * @since S60 v3.2
+     * @param aConnID The device identifier
+     * @return country code.
+     */
+    TUint CountryCodeL(TInt aConnID);
+
+    /**
+     * Request for the vendor identifier for the given device.
+     *
+     * @since S60 v3.2
+     * @param aConnID The device identifier
+     * @return vendor id.
+     */
+    TUint VendorIdL(TInt aConnID);
+
+    /**
+     * Request for the product identifier for the given device.
+     *
+     * @since S60 v3.2
+     * @param aConnID The device identifier
+     * @return product id.
+     */
+    TUint ProductIdL(TInt aConnID);
+
+    /**
+     * Request for the current device report protocol. The protocol will be
+     * received as a control report via the CHidTransport::DataIn function
+     *
+     * @since S60 v3.2
+     * @param aConnID The device identifier
+     * @param aInterface The interface we want to get the protocol from
+     * @return None.
+     */
+    void GetProtocolL(TInt aConnID,  TUint16 aInterface);
+
+    /**
+     * Request to put the device in the specified protocol
+     *
+     * @since S60 v3.2
+     * @param aConnID The device identifier
+     * @param aValue The requested protocol for the device (boot or report)
+     * @param aInterface The interface we want to set the protocol for
+     * @return None.
+     */
+    void SetProtocolL(TInt aConnID, TUint16 aValue,
+            TUint16 aInterface);
+
+    /**
+     * Request for a device report. The data will be received as a control report
+     * via the CHidTransport::DataIn function
+     *
+     * @since S60 v3.2
+     * @param aConnID The device identifier
+     * @param aReportType The type of report (input/output/feature) requested
+     * @param aReportID The specific report required
+     * @param aInterface The interface we want the report from
+     * @param aLength The expected length of the report buffer
+     * @return None.
+     */
+    void GetReportL(TInt aConnID, TUint8 aReportType,TUint8 aReportID,
+            TUint16 aInterface, TUint16 aLength);
+
+    /**
+     * Request to send a report to a device. The response will be reported via the
+     * CHidTransport::CommandResult function
+     *
+     * @since S60 v3.2
+     * @param aConnID The device identifier
+     * @param aReportType The type of report (input/output/feature) requested
+     * @param aReportID The specific report required to set
+     * @param aInterface The interface we want to send the report to
+     * @param aReport The report payload to be sent to the device
+     * @return None.
+     */
+    void SetReportL(TInt aConnID, TUint8 aReportType,TUint8 aReportID,
+        TUint16 aInterface, const TDesC8& aReport);
+
+    /**
+     * Request to send data to a device. There are no responses to this report from device.
+     *
+     * @since S60 v3.2
+     * @param aConnID The device identifier
+     * @param @param aReportID The specific report required
+     * @param aInterface The interface we want to send the report to
+     * @param aReport The report payload to be sent to the device   
+     * @return None.
+     */
+    void DataOutL(TInt aConnID, TUint8 aReportID,
+            TUint16 aInterface, const TDesC8& aReport);
+
+    /**
+     * Request for the current idle rate of a report from the device. The response
+     * will be recevied via the CHidTransport::DataIn function
+     *
+     * @since S60 v3.2
+     * @param aConnID The device identifier
+     * @param aReportID The specific report to be queried
+     * @param aInterface The interface we want to query for idle rate
+     * @return None.
+     */
+    void GetIdleL(TInt aConnID, TUint8 aReportID,
+            TUint16 aInterface);
+
+    /**
+     * Request to set the current idle rate for a report on the device.
+     * The response will be received via the CHidTransport::CommandResult function
+     *
+     * @since S60 v3.2
+     * @param aConnID The device identifier
+     * @param aReportID The specific report to be queried
+     * @param aDuration The time period between idle reports (4ms per bit. An
+     *        interval of 0 disables idle reports so that Interrupt reports are only ever
+     *        received when the reported data has changed
+     * @param aReportID The specific report to be queried
+     * @param aInterface The interface we want to query for idle rate
+     * @return None.
+     */
+    void SetIdleL(TInt aConnID,  TUint8 aDuration, TUint8 aReportID,
+            TUint16 aInterface);
+  
+
+private:
+    CtGenericHIDAPI();    
+    void ConstructL();    
+    
+    const CField* CreateConstCFieldL();
+    CField* CreateCFieldL();
+    
+private:
+    CGenericHid*        iGenHID;   
+    MDriverAccess*      iDriverAcces;
+    CReportGenerator*   iReportGenerator;
+    TReportTranslator*  iTranslator;
+    
+    CHidDriver* iHidDriver;
+    
+    RPointerArray<CField> iFieldList;
+  };
+#endif
+ 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/inc/timer.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,72 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Hid timeout timer
+*
+*/
+
+#ifndef C_TIMER_H
+#define C_TIMER_H
+
+#include <e32base.h>
+
+
+/**
+ * HID headset driver class
+ *
+ * This class will notify an object after a specified timeout.
+ * 
+ * @since S60 v3.2
+ */        
+NONSHARABLE_CLASS ( CWaitTimer ) : public CTimer
+    {
+public:
+    /**
+     * Two-phased constructor.
+     * @param aPriority priority to use for this timer
+     * @param aTimeOutNotify object to notify of timeout event
+     */
+    static CWaitTimer* NewL( TTimeIntervalMicroSeconds32 aTimeOutTime );
+
+    /**
+     * Two-phased constructor.
+     * @param aPriority priority to use for this timer
+     * @param aTimeOutNotify object to notify of timeout event
+     */    
+    static CWaitTimer* NewLC(TTimeIntervalMicroSeconds32 aTimeOutTime );
+
+    /**
+    * Destructor
+    */
+    ~CWaitTimer();
+
+protected: 
+
+    /**
+     * From CTimer
+     * Invoked when a timeout occurs
+     * 
+     * @since S60 v3.2
+     * @return None.
+     */
+    virtual void RunL();
+
+private:
+    CWaitTimer();
+    void ConstructL( TTimeIntervalMicroSeconds32 aTimeOutTime );
+
+private: // Member variables
+    CActiveSchedulerWait    iSyncWaiter;
+    
+    };
+#endif // C_TIMER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/init/GenericHidTest_ats.ini	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,235 @@
+#
+# Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:  
+#
+#
+
+#
+# This is STIF initialization file
+# Comment lines start with '#'-character.
+# See STIF TestFramework users guide.doc for instructions
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set following test engine settings:
+#	- Set Test Reporting mode. TestReportMode's possible values are:
+#		+ 'Summary': Summary of the tested test cases.
+#		+ 'Environment': Hardware and software info.
+#		+ 'TestCases': Test case report.
+#		+ 'FullReport': Set of all above ones.
+#		+ Example 'TestReportMode= Summary TestCases'
+#
+# 	- CreateTestReport setting controls report creation mode
+#		+ YES, Test report will created.
+#		+ NO, No Test report.
+#
+# 	- File path indicates the base path of the test report.
+# 	- File name indicates the name of the test report.
+#
+# 	- File format indicates the type of the test report.
+#		+ TXT, Test report file will be txt type, for example 'TestReport.txt'.
+#		+ HTML, Test report will be html type, for example 'TestReport.html'.
+#   + XML, Test report will be xml type, for example 'TestReport.xml'.
+#          Note, that xml format is available only when output is set to FILE.
+#
+# 	- File output indicates output source of the test report.
+#		+ FILE, Test report logging to file.
+#		+ RDEBUG, Test report logging to using rdebug.
+#
+# 	- File Creation Mode indicates test report overwriting if file exist.
+#		+ OVERWRITE, Overwrites if the Test report file exist.
+#		+ APPEND, Continue logging after the old Test report information if
+#                 report exist.
+# 	- Sets a device reset module's dll name(Reboot).
+#		+ If Nokia specific reset module is not available or it is not correct one
+#		  StifHWResetStub module may use as a template for user specific reset
+#		  module.
+# 	- Sets STIF test measurement disable options. e.g. pluging1 and pluging2 disablation
+#		DisableMeasurement= stifmeasurementplugin01 stifmeasurementplugin02
+#
+
+[Engine_Defaults]
+
+TestReportMode= FullReport    # Possible values are: 'Empty', 'Summary', 'Environment',
+                                                     'TestCases' or 'FullReport'
+
+CreateTestReport= YES         # Possible values: YES or NO
+
+TestReportFilePath= e:\testing\logs\
+TestReportFileName= GenericHidTest_TestReport
+
+TestReportFormat= TXT         # Possible values: TXT, HTML or XML
+TestReportOutput= FILE        # Possible values: FILE or RDEBUG
+TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND
+
+DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting
+
+DisableMeasurement= stifmeasurementdisablenone  # Possible values are:
+              # 'stifmeasurementdisablenone', 'stifmeasurementdisableall'
+              # 'stifmeasurementplugin01', 'stifmeasurementplugin02',
+              # 'stifmeasurementplugin03', 'stifmeasurementplugin04',
+              # 'stifmeasurementplugin05' or 'stifbappeaprofiler'
+
+Timeout= 0                    # Default timeout value for each test case. In milliseconds
+UITestingSupport= YES        # Possible values: YES or NO
+#SeparateProcesses= YES       # Possible values: YES or NO (default: NO)
+[End_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Module configurations start
+# Modules are added between module tags
+# tags. Module name is specified after ModuleName= tag, like
+# ModuleName= GenericHidTestGenericHidTestGenericHidTest
+# Modules might have initialisation file, specified as
+# IniFile= c:\testframework\YYYYYY
+# Modules might have several configuration files, like
+# TestCaseFile= c:\testframework\NormalCases.txt
+# TestCaseFile= c:\testframework\SmokeCases.txt
+# TestCaseFile= c:\testframework\ManualCases.txt
+
+# (TestCaseFile is synonym for old term ConfigFile)
+
+# Following case specifies demo module settings. Demo module
+# does not read any settings from file, so tags 
+# IniFile and TestCaseFile are not used.
+# In the simplest case it is enough to specify only the
+# name of the test module when adding new test module
+
+[New_Module]
+ModuleName= testscripter
+TestCaseFile= e:\testing\conf\GenericHidTest.cfg
+[End_Module]
+
+
+# Load testmoduleGenericHidTest, optionally with initialization file and/or test case files
+#[New_Module]
+#ModuleName= testmodulexxx
+
+#TestModuleGenericHidTest used initialization file
+#IniFile= c:\testframework\init.txt
+
+#TestModuleGenericHidTest used configuration file(s)
+#TestCaseFile= c:\testframework\testcases1.cfg
+#TestCaseFile= c:\testframework\testcases2.cfg
+#TestCaseFile= c:\testframework\manualtestcases.cfg
+
+#[End_Module]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set STIF logging overwrite parameters for Logger.
+# 	Hardware and emulator environment logging path and styles can
+# 	be configured from here to overwrite the Logger's implemented values.
+#	
+#	Settings description:
+#	- Indicates option for creation log directory/directories. If log directory/directories
+#         is/are not created by user they will make by software.
+#		+ YES, Create log directory/directories if not allready exist.
+#		+ NO, Log directory/directories not created. Only created one is used.
+#
+#	- Overwrite emulator path setting.
+#		+ Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined 
+#		           Logger's path 'D:\\LOGS\\Module\\' with those definition the path
+#		           will be 'C:\LOGS\TestFramework\LOGS\Module\'
+#
+#	- Overwrite emulator's logging format.
+#		+ TXT, Log file(s) will be txt type(s), for example 'Module.txt'.
+#		+ HTML, Log file(s) will be html type(s), for example 'Module.html'.
+#
+#	- Overwrited emulator logging output source.
+#		+ FILE, Logging to file(s).
+#		+ RDEBUG, Logging to using rdebug(s).
+#
+#	- Overwrite hardware path setting (Same description as above in emulator path).
+#	- Overwrite hardware's logging format(Same description as above in emulator format).
+#	- Overwrite hardware's logging output source(Same description as above in emulator output).
+#
+#	- File Creation Mode indicates file overwriting if file exist.
+#		+ OVERWRITE, Overwrites if file(s) exist.
+#		+ APPEND, Continue logging after the old logging information if file(s) exist.
+#
+#	- Will thread id include to the log filename.
+#		+ YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'.
+#		+ NO, No thread id to log file(s), Example filename 'Module.txt'.
+#
+#	- Will time stamps include the to log file.
+#		+ YES, Time stamp added to each line in log file(s). Time stamp is 
+#                 for example'12.Nov.2003 115958    LOGGING INFO'
+#		+ NO, No time stamp(s).
+#
+#	- Will line breaks include to the log file.
+#		+ YES, Each logging event includes line break and next log event is in own line.
+#		+ NO, No line break(s).
+#
+#	- Will event ranking include to the log file.
+#		+ YES, Event ranking number added to each line in log file(s). Ranking number
+#                 depends on environment's tics, for example(includes time stamp also)
+#                 '012   12.Nov.2003 115958    LOGGING INFO'
+#		+ NO, No event ranking.
+#
+#	- Will write log file in unicode format.
+#		+ YES, Log file will be written in unicode format
+#		+ NO, Log will be written as normal, not unicode, file.
+#
+
+[Logger_Defaults]
+
+#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#'
+#NOTE: TestEngine and TestServer logging settings cannot change here
+
+#CreateLogDirectories= YES    # Possible values: YES or NO
+
+#EmulatorBasePath= C:\LOGS\TestFramework\
+#EmulatorFormat= HTML         # Possible values: TXT or HTML
+#EmulatorOutput= FILE         # Possible values: FILE or RDEBUG
+
+#HardwareBasePath= D:\LOGS\TestFramework\
+#HardwareFormat= HTML         # Possible values: TXT or HTML
+#HardwareOutput= FILE         # Possible values: FILE or RDEBUG
+
+#FileCreationMode= OVERWRITE  # Possible values: OVERWRITE or APPEND
+
+#ThreadIdToLogFile= YES       # Possible values: YES or NO
+#WithTimeStamp= YES           # Possible values: YES or NO
+#WithLineBreak= YES           # Possible values: YES or NO
+#WithEventRanking= YES        # Possible values: YES or NO
+
+#FileUnicode= YES             # Possible values: YES or NO
+#AddTestCaseTitle= YES        # Possible values: YES or NO
+[End_Logger_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set filters to be used by ConsoleUI.
+# 	If you want to use filter with ConsoleUI, simply remove comments
+# 	from section below and provide valid filter entries.
+#   Each filter line has to start with "filter= " keyword.
+#   Filter can contain special wildcard characters:
+#     *  which stands for none or any literal;
+#     ?  which stands for single character.
+#   Filters are not case-sensitive.
+
+#[Filters]
+#filter= *math*
+#filter= *radio*
+#[End_Filters]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+# End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/init/GenericHidTest_phone.ini	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,235 @@
+#
+# Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:  
+#
+#
+
+#
+# This is STIF initialization file
+# Comment lines start with '#'-character.
+# See STIF TestFramework users guide.doc for instructions
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set following test engine settings:
+#	- Set Test Reporting mode. TestReportMode's possible values are:
+#		+ 'Summary': Summary of the tested test cases.
+#		+ 'Environment': Hardware and software info.
+#		+ 'TestCases': Test case report.
+#		+ 'FullReport': Set of all above ones.
+#		+ Example 'TestReportMode= Summary TestCases'
+#
+# 	- CreateTestReport setting controls report creation mode
+#		+ YES, Test report will created.
+#		+ NO, No Test report.
+#
+# 	- File path indicates the base path of the test report.
+# 	- File name indicates the name of the test report.
+#
+# 	- File format indicates the type of the test report.
+#		+ TXT, Test report file will be txt type, for example 'TestReport.txt'.
+#		+ HTML, Test report will be html type, for example 'TestReport.html'.
+#   + XML, Test report will be xml type, for example 'TestReport.xml'.
+#          Note, that xml format is available only when output is set to FILE.
+#
+# 	- File output indicates output source of the test report.
+#		+ FILE, Test report logging to file.
+#		+ RDEBUG, Test report logging to using rdebug.
+#
+# 	- File Creation Mode indicates test report overwriting if file exist.
+#		+ OVERWRITE, Overwrites if the Test report file exist.
+#		+ APPEND, Continue logging after the old Test report information if
+#                 report exist.
+# 	- Sets a device reset module's dll name(Reboot).
+#		+ If Nokia specific reset module is not available or it is not correct one
+#		  StifHWResetStub module may use as a template for user specific reset
+#		  module.
+# 	- Sets STIF test measurement disable options. e.g. pluging1 and pluging2 disablation
+#		DisableMeasurement= stifmeasurementplugin01 stifmeasurementplugin02
+#
+
+[Engine_Defaults]
+
+TestReportMode= FullReport    # Possible values are: 'Empty', 'Summary', 'Environment',
+                                                     'TestCases' or 'FullReport'
+
+CreateTestReport= YES         # Possible values: YES or NO
+
+TestReportFilePath= c:\logs\testframework\GenericHidTest\
+TestReportFileName= testreport
+
+TestReportFormat= TXT         # Possible values: TXT, HTML or XML
+TestReportOutput= FILE        # Possible values: FILE or RDEBUG
+TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND
+
+DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting
+
+DisableMeasurement= stifmeasurementdisablenone  # Possible values are:
+              # 'stifmeasurementdisablenone', 'stifmeasurementdisableall'
+              # 'stifmeasurementplugin01', 'stifmeasurementplugin02',
+              # 'stifmeasurementplugin03', 'stifmeasurementplugin04',
+              # 'stifmeasurementplugin05' or 'stifbappeaprofiler'
+
+Timeout= 0                    # Default timeout value for each test case. In milliseconds
+UITestingSupport= YES        # Possible values: YES or NO
+#SeparateProcesses= YES       # Possible values: YES or NO (default: NO)
+[End_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Module configurations start
+# Modules are added between module tags
+# tags. Module name is specified after ModuleName= tag, like
+# ModuleName= GenericHidTestGenericHidTestGenericHidTest
+# Modules might have initialisation file, specified as
+# IniFile= c:\testframework\YYYYYY
+# Modules might have several configuration files, like
+# TestCaseFile= c:\testframework\NormalCases.txt
+# TestCaseFile= c:\testframework\SmokeCases.txt
+# TestCaseFile= c:\testframework\ManualCases.txt
+
+# (TestCaseFile is synonym for old term ConfigFile)
+
+# Following case specifies demo module settings. Demo module
+# does not read any settings from file, so tags 
+# IniFile and TestCaseFile are not used.
+# In the simplest case it is enough to specify only the
+# name of the test module when adding new test module
+
+[New_Module]
+ModuleName= testscripter
+TestCaseFile= c:\testframework\GenericHidTest.cfg
+[End_Module]
+
+
+# Load testmoduleGenericHidTest, optionally with initialization file and/or test case files
+#[New_Module]
+#ModuleName= testmodulexxx
+
+#TestModuleGenericHidTest used initialization file
+#IniFile= c:\testframework\init.txt
+
+#TestModuleGenericHidTest used configuration file(s)
+#TestCaseFile= c:\testframework\testcases1.cfg
+#TestCaseFile= c:\testframework\testcases2.cfg
+#TestCaseFile= c:\testframework\manualtestcases.cfg
+
+#[End_Module]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set STIF logging overwrite parameters for Logger.
+# 	Hardware and emulator environment logging path and styles can
+# 	be configured from here to overwrite the Logger's implemented values.
+#	
+#	Settings description:
+#	- Indicates option for creation log directory/directories. If log directory/directories
+#         is/are not created by user they will make by software.
+#		+ YES, Create log directory/directories if not allready exist.
+#		+ NO, Log directory/directories not created. Only created one is used.
+#
+#	- Overwrite emulator path setting.
+#		+ Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined 
+#		           Logger's path 'D:\\LOGS\\Module\\' with those definition the path
+#		           will be 'C:\LOGS\TestFramework\LOGS\Module\'
+#
+#	- Overwrite emulator's logging format.
+#		+ TXT, Log file(s) will be txt type(s), for example 'Module.txt'.
+#		+ HTML, Log file(s) will be html type(s), for example 'Module.html'.
+#
+#	- Overwrited emulator logging output source.
+#		+ FILE, Logging to file(s).
+#		+ RDEBUG, Logging to using rdebug(s).
+#
+#	- Overwrite hardware path setting (Same description as above in emulator path).
+#	- Overwrite hardware's logging format(Same description as above in emulator format).
+#	- Overwrite hardware's logging output source(Same description as above in emulator output).
+#
+#	- File Creation Mode indicates file overwriting if file exist.
+#		+ OVERWRITE, Overwrites if file(s) exist.
+#		+ APPEND, Continue logging after the old logging information if file(s) exist.
+#
+#	- Will thread id include to the log filename.
+#		+ YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'.
+#		+ NO, No thread id to log file(s), Example filename 'Module.txt'.
+#
+#	- Will time stamps include the to log file.
+#		+ YES, Time stamp added to each line in log file(s). Time stamp is 
+#                 for example'12.Nov.2003 115958    LOGGING INFO'
+#		+ NO, No time stamp(s).
+#
+#	- Will line breaks include to the log file.
+#		+ YES, Each logging event includes line break and next log event is in own line.
+#		+ NO, No line break(s).
+#
+#	- Will event ranking include to the log file.
+#		+ YES, Event ranking number added to each line in log file(s). Ranking number
+#                 depends on environment's tics, for example(includes time stamp also)
+#                 '012   12.Nov.2003 115958    LOGGING INFO'
+#		+ NO, No event ranking.
+#
+#	- Will write log file in unicode format.
+#		+ YES, Log file will be written in unicode format
+#		+ NO, Log will be written as normal, not unicode, file.
+#
+
+[Logger_Defaults]
+
+#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#'
+#NOTE: TestEngine and TestServer logging settings cannot change here
+
+#CreateLogDirectories= YES    # Possible values: YES or NO
+
+#EmulatorBasePath= C:\LOGS\TestFramework\
+#EmulatorFormat= HTML         # Possible values: TXT or HTML
+#EmulatorOutput= FILE         # Possible values: FILE or RDEBUG
+
+#HardwareBasePath= D:\LOGS\TestFramework\
+#HardwareFormat= HTML         # Possible values: TXT or HTML
+#HardwareOutput= FILE         # Possible values: FILE or RDEBUG
+
+#FileCreationMode= OVERWRITE  # Possible values: OVERWRITE or APPEND
+
+#ThreadIdToLogFile= YES       # Possible values: YES or NO
+#WithTimeStamp= YES           # Possible values: YES or NO
+#WithLineBreak= YES           # Possible values: YES or NO
+#WithEventRanking= YES        # Possible values: YES or NO
+
+#FileUnicode= YES             # Possible values: YES or NO
+#AddTestCaseTitle= YES        # Possible values: YES or NO
+[End_Logger_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set filters to be used by ConsoleUI.
+# 	If you want to use filter with ConsoleUI, simply remove comments
+# 	from section below and provide valid filter entries.
+#   Each filter line has to start with "filter= " keyword.
+#   Filter can contain special wildcard characters:
+#     *  which stands for none or any literal;
+#     ?  which stands for single character.
+#   Filters are not case-sensitive.
+
+#[Filters]
+#filter= *math*
+#filter= *radio*
+#[End_Filters]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+# End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/src/CHidDriverPlugin.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,86 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#include "CHidDriverPlugin.h"
+
+CHidDriverPlugin* CHidDriverPlugin::NewL(MDriverAccess* /*aHid*/)
+    {
+    CHidDriverPlugin* self = new (ELeave) CHidDriverPlugin();
+    return self;
+    }
+
+
+CHidDriverPlugin::CHidDriverPlugin() : CHidDriver()
+    {
+    }
+
+TInt CHidDriverPlugin::CanHandleReportL(CReportRoot* aReportDescriptor)
+	{
+	return KErrNone;
+	}
+
+TInt CHidDriverPlugin::DataIn(CHidTransport::THidChannelType aChannel,
+        const TDesC8& aPayload)
+	{
+	return KErrNone;
+	}
+
+void CHidDriverPlugin::Disconnected(TInt aReason)
+	{
+	
+	}
+void CHidDriverPlugin::InitialiseL(TInt aConnectionId)
+	{
+	
+	}
+void CHidDriverPlugin::StartL(TInt aConnectionId)
+	{
+	
+	}
+void CHidDriverPlugin::Stop()
+	{
+	
+	}
+void CHidDriverPlugin::CommandResult(TInt aCmdAck)
+	{
+	
+	}
+TInt CHidDriverPlugin::SupportedFieldCount()
+	{
+	return KErrNone;
+	}
+void CHidDriverPlugin::SetInputHandlingReg(CHidInputDataHandlingReg* aHandlingReg)
+	{
+	///////todo!!
+		aHandlingReg->AddHandledEvent(1,1);
+		TBool allowed = aHandlingReg->AllowedToHandleEvent(1,1);
+		if(allowed == EFalse)
+			{
+			//User::Leave(1);
+			}
+		allowed = aHandlingReg->AllowedToHandleEvent(2,2);
+		if(allowed != EFalse)
+			{
+			//User::Leave(1);
+			}
+		
+	}
+
+    
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/src/CHidDriverPluginProxy.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef REFERENCE_HIDDRIVER_H
+#define REFERENCE_HIDDRIVER_H
+
+#include <e32base.h>
+#include <ECom/ImplementationProxy.h>
+#include "CHidDriverPlugin.h"
+
+const TImplementationProxy ImplementationTable[] =
+	{
+	IMPLEMENTATION_PROXY_ENTRY(0xE000B187, CHidDriverPlugin::NewL),
+	};
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+	{
+	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+
+	return ImplementationTable;
+	}
+
+#endif //REFERENCE_HIDDRIVER_H
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/src/GenericHidTest.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,210 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <Stiftestinterface.h>
+#include "GenericHidTest.h"
+#include <SettingServerClient.h>
+
+//#include "testlogger.h"
+
+// EXTERNAL DATA STRUCTURES
+//extern  ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES  
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type );
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+//          ?value_n: ?description_line1
+//                    ?description_line2
+// -----------------------------------------------------------------------------
+//
+/*
+?type ?function_name(
+    ?arg_type arg,  // ?description
+    ?arg_type arg)  // ?description
+    {
+
+    ?code  // ?comment
+
+    // ?comment
+    ?code
+    }
+*/
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::CGenericHidTest
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CGenericHidTest::CGenericHidTest( 
+    CTestModuleIf& aTestModuleIf ):
+        CScriptBase( aTestModuleIf )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CGenericHidTest::ConstructL()
+    {
+    //iTestLogger = CHidTestLogger::NewL( &TestModuleIf() ); 
+    
+    //Read logger settings to check whether test case name is to be
+    //appended to log file name.
+    RSettingServer settingServer;
+    TInt ret = settingServer.Connect();
+    if(ret != KErrNone)
+        {
+        User::Leave(ret);
+        }
+    // Struct to StifLogger settigs.
+    TLoggerSettings loggerSettings; 
+    // Parse StifLogger defaults from STIF initialization file.
+    ret = settingServer.GetLoggerSettings(loggerSettings);
+    if(ret != KErrNone)
+        {
+        User::Leave(ret);
+        } 
+    // Close Setting server session
+    settingServer.Close();
+
+    TFileName logFileName;
+    
+    if(loggerSettings.iAddTestCaseTitle)
+        {
+        TName title;
+        TestModuleIf().GetTestCaseTitleL(title);
+        logFileName.Format(KGenericHidTestLogFileWithTitle, &title);
+        }
+    else
+        {
+        logFileName.Copy(KGenericHidTestLogFile);
+        }
+
+    iLog = CStifLogger::NewL( KGenericHidTestLogPath, 
+                          logFileName,
+                          CStifLogger::ETxt,
+                          CStifLogger::EFile,
+                          EFalse ); 
+    
+    SendTestClassVersion();
+    
+    iParser = CParser::NewL();
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CGenericHidTest* CGenericHidTest::NewL( 
+    CTestModuleIf& aTestModuleIf )
+    {
+    CGenericHidTest* self = new (ELeave) CGenericHidTest( aTestModuleIf );
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+
+    }
+
+// Destructor
+CGenericHidTest::~CGenericHidTest()
+    { 
+
+    // Delete resources allocated from test methods
+    Delete();
+
+    // Delete logger
+    delete iLog;
+    
+    delete iParser;
+
+    }
+
+//-----------------------------------------------------------------------------
+// CGenericHidTest::SendTestClassVersion
+// Method used to send version of test class
+//-----------------------------------------------------------------------------
+//
+void CGenericHidTest::SendTestClassVersion()
+	{
+	TVersion moduleVersion;
+	moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
+	moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
+	moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
+	
+	TFileName moduleName;
+	moduleName = _L("GenericHidTest.dll");
+
+	TBool newVersionOfMethod = ETrue;
+	TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod);
+	}
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// LibEntryL is a polymorphic Dll entry point.
+// Returns: CScriptBase: New CScriptBase derived object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CScriptBase* LibEntryL( 
+    CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
+    {
+
+    return ( CScriptBase* ) CGenericHidTest::NewL( aTestModuleIf );
+
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/src/GenericHidTestBlocks.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,2839 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// [INCLUDE FILES] - do not remove
+#include <e32svr.h>
+#include <StifParser.h>
+#include <Stiftestinterface.h>
+#include "GenericHidTest.h"
+
+#include "hidreports.h"
+#include "tGenericHIDAPI.h"
+#include "tdialclient.h"
+#include "alarmcontrol.h"
+#include "timer.h"
+
+// EXTERNAL DATA STRUCTURES
+//extern  ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES  
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type );
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+//          ?value_n: ?description_line1
+//                    ?description_line2
+// -----------------------------------------------------------------------------
+//
+/*
+?type ?function_name(
+    ?arg_type arg,  // ?description
+    ?arg_type arg)  // ?description
+    {
+
+    ?code  // ?comment
+
+    // ?comment
+    ?code
+    }
+*/
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::Delete
+// Delete here all resources allocated and opened from test methods. 
+// Called from destructor. 
+// -----------------------------------------------------------------------------
+//
+void CGenericHidTest::Delete() 
+    {
+    if ( iGenericHIDTest )
+		{
+		delete iGenericHIDTest;
+		iGenericHIDTest = NULL;
+		}
+        	
+	if ( iDialClient )
+		{
+		delete iDialClient;
+		iDialClient = NULL;
+		}
+	
+	if ( iAlarmControl )
+		{
+		delete iAlarmControl;
+		iAlarmControl = NULL;
+		}
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::RunMethodL
+// Run specified method. Contains also table of test mothods and their names.
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::RunMethodL( 
+    CStifItemParser& aItem ) 
+    {
+
+    static TStifFunctionInfo const KFunctions[] =
+        {  
+        //ADD NEW ENTRY HERE
+        // [test cases entries] - Do not remove
+		ENTRY( "ExecuteApiTestBlock", CGenericHidTest::ExecuteApiTestBlock ),
+        ENTRY( "ExecuteModuleTestBlock", CGenericHidTest::ExecuteModuleTestBlock ),
+        ENTRY( "ExecuteBranchTestBlock", CGenericHidTest::ExecuteBranchTestBlock ),
+        };
+
+    const TInt count = sizeof( KFunctions ) / 
+                        sizeof( TStifFunctionInfo );
+
+    return RunInternalL( KFunctions, count, aItem );
+
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::GetTestBlockParamsL
+// -----------------------------------------------------------------------------
+
+void CGenericHidTest::GetTestBlockParamsL( CStifItemParser& aItem )
+    {
+    STIF_LOG( ">>> GetTestBlockParamsL" );
+    
+    // Add new test block branches below, get all required test parameters    
+    if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ExampleTestL" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );        
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );
+        User::LeaveIfError( aItem.GetNextInt( iTestBlockParams.iTestIntOption1 ) );        
+        User::LeaveIfError( aItem.GetNextChar( iTestBlockParams.iTestCharOption1 ) );        
+        }   
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "Connect" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );        
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );       
+        } 
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "Disconnect" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "DataIn" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );        
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "Wait" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) ); 
+        User::LeaveIfError( aItem.GetNextInt( iTestBlockParams.iTestIntOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CreateCall" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );        
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );      
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "AddAlarm" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );
+        User::LeaveIfError( aItem.GetNextInt( iTestBlockParams.iTestIntOption1 ) );        
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "DeleteAlarm" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CountryCode" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "VendorId" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ProductId" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "SetProtocol" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "GetProtocol" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "GetReport" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "SetReport" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );      
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );         
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "DataOut" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );     
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "GetIdle" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "SetIdle" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CommandResult" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ReportDescriptor" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CreateReportGenerator" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "DeleteReportGenerator" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ReportGeneratorReport" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ReportGeneratorSetField" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );     
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );      
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CreateReportTranslator" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );      
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );      
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CreateReportTranslator_FieldNull" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );        
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );    
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CreateReportTranslator_NotArray" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );        
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CreateReportTranslator_FieldCountZero" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );        
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "DeleteReportTranslator" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ReportTranslatorGetValue" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );     
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ReportTranslatorValue" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ReportTranslatorGetUsageId" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );         
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ReportTranslatorUsageId" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ReportTranslatorRawValue" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ReportTranslatorCount" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "Collectiontype" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionIsPhysical" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionIsLogical" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionIsReport" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionIsNamedArray" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionIsUsageSwitch" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionIsUsageModifier" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionIsApplication" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionUsagePage" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionUsage" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionCollectionCount" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionFieldCount" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionCollectionByIndex" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );         
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );        
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionFieldByIndex" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ReportrootReportSizeBytes" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldLogicalMax" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldPhysicalMin" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldPhysicalMax" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldUnit" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldUnitExponent" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldCount" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSize" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldOffset" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );        
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );        
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldReportId" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldIsInReport" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldDesignatorIndex" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldStringIndex" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldUsagePage" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldHasUsage" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldUsageArray" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldUsage" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldUsageCount" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldClearUsageList" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldLastUsage" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );         
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldAttributes" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldType" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldIsVariable" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldIsArray" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldIsConstant" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldIsData" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetLogicalMin" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetLogicalMax" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetPhysicalMin" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetPhysicalMax" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetDesignatorMin" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetDesignatorMax" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetUsageMin" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetUsageMax" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetStringMin" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetStringMax" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetLogicalRange" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetUsageRange" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetPhysicalRange" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetStringRange" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetDesignatorRange" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldIsInput" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldIsOutput" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldIsFeature" ) ) )
+        {          
+        User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );       
+        }
+    else
+        {
+        STIF_LOG( "GetTestBlockParamsL, Test type: not found" );
+        User::Leave( KErrNotFound );
+        }
+    STIF_LOG( "<<< GetTestBlockParams" );
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::ExecuteApiTestBlock
+// -----------------------------------------------------------------------------
+
+TInt CGenericHidTest::ExecuteApiTestBlock( CStifItemParser& aItem )
+    {
+	STIF_LOG( ">>>ExecuteApiTestBlock" );
+	
+	TInt res;
+    TGenericHidTestResult testResult;
+	
+    TRAP( res, DoExecuteApiTestBlockL( aItem, testResult ) );
+    if ( res != KErrNone )
+        {
+        STIF_LOG1( "DoExecuteApiTestBlockL error: %d", res );
+        return res;
+        }
+    
+    STIF_ASSERT_EQUALS( ETestCasePassed, testResult );
+    STIF_LOG( "Test case passed" );
+	STIF_LOG( "<<<ExecuteApiTestBlock" );
+	
+    return KErrNone;
+    }
+	
+	
+void CGenericHidTest::DoExecuteApiTestBlockL( CStifItemParser& aItem, TGenericHidTestResult& aTestResult )
+    {
+	STIF_LOG( ">>>DoExecuteApiTestBlock" );
+
+	User::LeaveIfError( aItem.GetString( _L( "ExecuteApiTestBlock" ), iTestBlockParams.iTestBlockName ) );
+	STIF_LOG1( "Api test type: %S", &iTestBlockParams.iTestBlockName );
+	
+	GetTestBlockParamsL( aItem );
+	
+	// Add new API test block branches with optional test parameters here	
+    if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ExampleTestL" ) ) )
+        {      
+        ExampleTestL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, 
+                iTestBlockParams.iTestIntOption1, iTestBlockParams.iTestCharOption1, aTestResult );
+        }
+    else
+        {
+        STIF_LOG( "Test type: not found" );
+        User::Leave( KErrNotFound );
+        }
+	
+	STIF_LOG( "<<<DoExecuteApiTestBlockL" );
+    }
+	
+// -----------------------------------------------------------------------------
+// CGenericHidTest::ExecuteModuleTestBlock
+// -----------------------------------------------------------------------------	
+
+TInt CGenericHidTest::ExecuteModuleTestBlock( CStifItemParser& aItem )
+    {
+	STIF_LOG( "[STIF_LOG] >>>ExecuteModuleTestBlock" );
+	
+    TInt res;
+    TGenericHidTestResult testResult;
+    
+    TRAP( res, DoExecuteModuleTestBlockL( aItem, testResult ) );
+    if ( res != KErrNone )
+        {
+        STIF_LOG1( "DoExecuteModuleTestBlockL error: %d", res );
+        return res;
+        }
+    
+    STIF_ASSERT_EQUALS( ETestCasePassed, testResult );
+    STIF_LOG( "[STIF_LOG] Test case passed" );
+	STIF_LOG( "[STIF_LOG] <<<ExecuteModuleTestBlock" );
+    return KErrNone;
+    }	
+	
+	
+void CGenericHidTest::DoExecuteModuleTestBlockL( CStifItemParser& aItem, TGenericHidTestResult& aTestResult )
+    {
+	STIF_LOG( "[STIF_LOG] >>>DoExecuteModuleTestBlockL" );
+	
+    User::LeaveIfError( aItem.GetString( _L( "ExecuteModuleTestBlock" ), iTestBlockParams.iTestBlockName ) );
+    STIF_LOG1( "Module test type: %S", &iTestBlockParams.iTestBlockName );
+    
+    GetTestBlockParamsL( aItem );
+    
+    // Add new module test block branches with optional test parameters here   
+    if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ExampleTestL" ) ) )
+        {      
+        ExampleTestL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, 
+                iTestBlockParams.iTestIntOption1, iTestBlockParams.iTestCharOption1, aTestResult );
+        }
+    else
+        {
+        STIF_LOG( "Test type: not found" );
+        User::Leave( KErrNotFound );
+        }
+    
+	STIF_LOG( "[STIF_LOG] <<<DoExecuteModuleTestBlockL" );
+    }
+	
+// -----------------------------------------------------------------------------
+// CGenericHidTest::ExecuteBranchTestBlock
+// -----------------------------------------------------------------------------
+	
+TInt CGenericHidTest::ExecuteBranchTestBlock( CStifItemParser& aItem )
+    {
+	STIF_LOG( "[STIF_LOG] >>>ExecuteBranchTestBlock" );
+	
+    TInt res;
+    TGenericHidTestResult testResult = ETestCaseFailed;
+    
+    TRAP( res, DoExecuteBranchTestBlockL( aItem, testResult ) );
+    if ( res != KErrNone )
+        {
+        STIF_LOG1( "DoExecuteBranchTestBlockL error: %d", res );
+        return res;
+        }   
+    
+    STIF_ASSERT_EQUALS( ETestCasePassed, testResult );
+    STIF_LOG( "[STIF_LOG] Test case passed" );
+	STIF_LOG( "[STIF_LOG] <<<ExecuteBranchTestBlock" );
+    return KErrNone;
+    }
+
+	
+void CGenericHidTest::DoExecuteBranchTestBlockL( CStifItemParser& aItem, TGenericHidTestResult& aTestResult )
+    {
+	STIF_LOG( "[STIF_LOG] >>>DoExecuteBranchTestBlockL" );
+	
+    User::LeaveIfError( aItem.GetString( _L( "ExecuteBranchTestBlock" ), iTestBlockParams.iTestBlockName ) );
+    STIF_LOG1( "Branch test type: %S", &iTestBlockParams.iTestBlockName );
+    
+    GetTestBlockParamsL( aItem );
+    
+    // Add new branch test block branches with optional test parameters here   
+    if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ExampleTestL" ) ) )
+        {      
+        ExampleTestL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, 
+                iTestBlockParams.iTestIntOption1, iTestBlockParams.iTestCharOption1, aTestResult );
+        }  
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "Connect" ) ) )
+        {      
+        ConnectL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, aTestResult );
+        }  
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "Disconnect" ) ) )
+        {      
+        DisconnectL( iTestBlockParams.iTestOption1, aTestResult );
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "DataIn" ) ) )
+        {      
+        DataIn( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, aTestResult );
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "Wait" ) ) )
+        {          
+        WaitL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestIntOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CreateCall" ) ) )
+        {          
+        CreateCallL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, aTestResult ); 
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "AddAlarm" ) ) )
+        {          
+        AddAlarmL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestIntOption1, aTestResult );      
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "DeleteAlarm" ) ) )
+        {          
+        DeleteAlarm( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CountryCode" ) ) )
+        {          
+        CountryCodeL( iTestBlockParams.iTestOption1, aTestResult );     
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "VendorId" ) ) )
+        {          
+        VendorIdL( iTestBlockParams.iTestOption1, aTestResult );      
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ProductId" ) ) )
+        {          
+        ProductIdL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "SetProtocol" ) ) )
+        {          
+        SetProtocolL( iTestBlockParams.iTestOption1, aTestResult );     
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "GetProtocol" ) ) )
+        {          
+        GetProtocoL( iTestBlockParams.iTestOption1, aTestResult );      
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "GetReport" ) ) )
+        {          
+        GetReportL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "SetReport" ) ) )
+        {          
+        SetReportL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, aTestResult );         
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "DataOut" ) ) )
+        {          
+        DataOutL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, aTestResult );   
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "GetIdle" ) ) )
+        {          
+        GetIdleL( iTestBlockParams.iTestOption1, aTestResult );  
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "SetIdle" ) ) )
+        {          
+        SetIdleL( iTestBlockParams.iTestOption1, aTestResult );   
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CommandResult" ) ) )
+        {          
+        CommandResultL( iTestBlockParams.iTestOption1, aTestResult );
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ReportDescriptor" ) ) )
+        {          
+        ReportDescriptorL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CreateReportGenerator" ) ) )
+        {          
+        CreateReportGeneratorL( iTestBlockParams.iTestOption1, aTestResult );      
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "DeleteReportGenerator" ) ) )
+        {          
+        DeleteReportGeneratorL( iTestBlockParams.iTestOption1, aTestResult );     
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ReportGeneratorReport" ) ) )
+        {          
+        ReportGeneratorReportL( iTestBlockParams.iTestOption1, aTestResult ); 
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ReportGeneratorSetField" ) ) )
+        {          
+        ReportGeneratorSetFieldL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, aTestResult );     
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CreateReportTranslator" ) ) )
+        {          
+        CreateReportTranslatorL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, aTestResult );   
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CreateReportTranslator_FieldNull" ) ) )
+        {          
+        CreateReportTranslator_FieldNullL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, aTestResult );  
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CreateReportTranslator_NotArray" ) ) )
+        {          
+        CreateReportTranslator_NotArrayL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, aTestResult );     
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CreateReportTranslator_FieldCountZero" ) ) )
+        {          
+        CreateReportTranslator_FieldCountZeroL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "DeleteReportTranslator" ) ) )
+        {          
+        DeleteReportTranslatorL( iTestBlockParams.iTestOption1, aTestResult );     
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ReportTranslatorGetValue" ) ) )
+        {          
+        ReportTranslatorGetValueL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, aTestResult );     
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ReportTranslatorValue" ) ) )
+        {          
+        ReportTranslatorValueL( iTestBlockParams.iTestOption1, aTestResult );    
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ReportTranslatorGetUsageId" ) ) )
+        {          
+        ReportTranslatorGetUsageIdL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, aTestResult );      
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ReportTranslatorUsageId" ) ) )
+        {          
+        ReportTranslatorUsageIdL( iTestBlockParams.iTestOption1, aTestResult );     
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ReportTranslatorRawValue" ) ) )
+        {          
+        ReportTranslatorRawValueL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ReportTranslatorCount" ) ) )
+        {          
+        ReportTranslatorCountL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, aTestResult );      
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "Collectiontype" ) ) )
+        {          
+        CollectiontypeL( iTestBlockParams.iTestOption1, aTestResult );   
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionIsPhysical" ) ) )
+        {          
+        CollectionIsPhysicalL( iTestBlockParams.iTestOption1, aTestResult );     
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionIsLogical" ) ) )
+        {          
+        CollectionIsLogicalL( iTestBlockParams.iTestOption1, aTestResult );    
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionIsReport" ) ) )
+        {          
+        CollectionIsReportL( iTestBlockParams.iTestOption1, aTestResult );      
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionIsNamedArray" ) ) )
+        {          
+        CollectionIsNamedArrayL( iTestBlockParams.iTestOption1, aTestResult );      
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionIsUsageSwitch" ) ) )
+        {          
+        CollectionIsUsageSwitchL( iTestBlockParams.iTestOption1, aTestResult );   
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionIsUsageModifier" ) ) )
+        {          
+        CollectionIsUsageModifierL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionIsApplication" ) ) )
+        {          
+        CollectionIsApplicationL( iTestBlockParams.iTestOption1, aTestResult );   
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionUsagePage" ) ) )
+        {          
+        CollectionUsagePageL( iTestBlockParams.iTestOption1, aTestResult );      
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionUsage" ) ) )
+        {          
+        CollectionUsageL( iTestBlockParams.iTestOption1, aTestResult );    
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionCollectionCount" ) ) )
+        {          
+        CollectionFieldCountL( iTestBlockParams.iTestOption1, aTestResult ); 
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionFieldCount" ) ) )
+        {          
+        CollectionFieldCountL( iTestBlockParams.iTestOption1, aTestResult );      
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionCollectionByIndex" ) ) )
+        {          
+        CollectionCollectionByIndexL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, aTestResult );        
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CollectionFieldByIndex" ) ) )
+        {          
+        CollectionFieldByIndexL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ReportrootReportSizeBytes" ) ) )
+        {          
+        ReportrootReportSizeBytes( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldLogicalMax" ) ) )
+        {          
+        FieldLogicalMaxL( iTestBlockParams.iTestOption1, aTestResult );  
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldPhysicalMin" ) ) )
+        {          
+        FieldPhysicalMinL( iTestBlockParams.iTestOption1, aTestResult );      
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldPhysicalMax" ) ) )
+        {          
+        FieldPhysicalMaxL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldUnit" ) ) )
+        {          
+        FieldUnitL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldUnitExponent" ) ) )
+        {          
+        FieldUnitExponentL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldCount" ) ) )
+        {          
+        FieldCountL( iTestBlockParams.iTestOption1, aTestResult );      
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSize" ) ) )
+        {          
+        FieldSizeL( iTestBlockParams.iTestOption1, aTestResult );      
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldOffset" ) ) )
+        {          
+        FieldOffsetL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, aTestResult );        
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldReportId" ) ) )
+        {          
+        FieldReportIdL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldIsInReport" ) ) )
+        {          
+        FieldIsInReportL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldDesignatorIndex" ) ) )
+        {          
+        FieldDesignatorIndexL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldStringIndex" ) ) )
+        {          
+        FieldStringIndexL( iTestBlockParams.iTestOption1, aTestResult );      
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldUsagePage" ) ) )
+        {          
+        FieldUsagePageL( iTestBlockParams.iTestOption1, aTestResult );     
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldHasUsage" ) ) )
+        {          
+        FieldHasUsageL( iTestBlockParams.iTestOption1, aTestResult ); 
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldUsageArray" ) ) )
+        {          
+        FieldUsageArrayL( iTestBlockParams.iTestOption1, aTestResult );        
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldUsage" ) ) )
+        {          
+        FieldUsageL( iTestBlockParams.iTestOption1, aTestResult );        
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldUsageCount" ) ) )
+        {          
+        FieldUsageCountL( iTestBlockParams.iTestOption1, aTestResult );        
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldClearUsageList" ) ) )
+        {          
+        FieldClearUsageListL( iTestBlockParams.iTestOption1, aTestResult );        
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldLastUsage" ) ) )
+        {          
+        FieldLastUsageL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldAttributes" ) ) )
+        {          
+        FieldAttributesL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldType" ) ) )
+        {          
+        FieldTypeL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldIsVariable" ) ) )
+        {          
+        FieldIsVariableL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldIsArray" ) ) )
+        {          
+        FieldIsArrayL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldIsConstant" ) ) )
+        {          
+        FieldIsConstantL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldIsData" ) ) )
+        {          
+        FieldIsDataL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetLogicalMin" ) ) )
+        {          
+        FieldSetLogicalMinL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetLogicalMax" ) ) )
+        {          
+        FieldSetPhysicalMinL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetPhysicalMin" ) ) )
+        {          
+        FieldSetPhysicalMinL( iTestBlockParams.iTestOption1, aTestResult );        
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetPhysicalMax" ) ) )
+        {          
+        FieldSetPhysicalMaxL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetDesignatorMin" ) ) )
+        {          
+        FieldSetDesignatorMinL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetDesignatorMax" ) ) )
+        {          
+        FieldSetUsageMinL( iTestBlockParams.iTestOption1, aTestResult );        
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetUsageMin" ) ) )
+        {          
+        FieldSetUsageMinL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetUsageMax" ) ) )
+        {          
+        FieldSetUsageMaxL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetStringMin" ) ) )
+        {          
+        FieldSetStringMinL( iTestBlockParams.iTestOption1, aTestResult );      
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetStringMax" ) ) )
+        {          
+        FieldSetStringMaxL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetLogicalRange" ) ) )
+        {          
+        FieldSetLogicalRangeL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetUsageRange" ) ) )
+        {          
+        FieldSetUsageRangeL( iTestBlockParams.iTestOption1, aTestResult );      
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetPhysicalRange" ) ) )
+        {          
+        FieldSetPhysicalRangeL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetStringRange" ) ) )
+        {          
+        FieldSetStringRangeL( iTestBlockParams.iTestOption1, aTestResult );        
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldSetDesignatorRange" ) ) )
+        {          
+        FieldSetDesignatorRangeL( iTestBlockParams.iTestOption1, aTestResult );        
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldIsInput" ) ) )
+        {          
+        FieldIsInputL( iTestBlockParams.iTestOption1, aTestResult );        
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldIsOutput" ) ) )
+        {          
+        FieldIsOutputL( iTestBlockParams.iTestOption1, aTestResult );       
+        }
+    else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FieldIsFeature" ) ) )
+        {          
+        FieldIsFeatureL( iTestBlockParams.iTestOption1, aTestResult );      
+        }
+    else
+        {
+        STIF_LOG( "DoExecuteBranchTestBlockL; Test type: not found" );
+        User::Leave( KErrNotFound );
+        }
+    
+	STIF_LOG( "[STIF_LOG] <<<DoExecuteBranchTestBlock" );
+    }
+
+// Add test block methods implementation here
+// -----------------------------------------------------------------------------
+// CGenericHidTest::ExampleTestL
+// -----------------------------------------------------------------------------
+
+void CGenericHidTest::ExampleTestL( TPtrC aTestOption, TPtrC aTestSubOption, 
+        TInt aTestIntOption, TInt aTestCharOption, TGenericHidTestResult& aTestResult )
+    {
+    STIF_LOG( ">>>ExampleTest" );
+    
+    if ( !aTestOption.Compare( _L( "API" ) ) )
+        {
+        STIF_LOG1( "Api test option: %S", &aTestOption );
+        STIF_LOG1( "Api test sub-option: %S", &aTestSubOption );
+        STIF_LOG1( "Api test int option: %d", aTestIntOption );
+        STIF_LOG1( "Api test char option: %c", aTestCharOption );
+        }
+    else if ( !aTestOption.Compare( _L( "MODULE" ) ) )
+        {
+        STIF_LOG1( "Module test option: %S", &aTestOption );
+        STIF_LOG1( "Module test sub-option: %S", &aTestSubOption );
+        STIF_LOG1( "Module test int option: %d", aTestIntOption );
+        STIF_LOG1( "Module test char option: %c", aTestCharOption );
+        }
+    else if ( !aTestOption.Compare( _L( "BRANCH" ) ) )
+        {
+        STIF_LOG1( "Branch test option: %S", &aTestOption );
+        STIF_LOG1( "Branch test sub-option: %S", &aTestSubOption );
+        STIF_LOG1( "Branch test int option: %d", aTestIntOption );
+        STIF_LOG1( "Branch test char option: %c", aTestCharOption );
+        }
+    else
+        {
+        STIF_LOG( "Invalid test parameter" );
+        User::Leave( KErrNotFound );
+        }
+    
+    aTestResult = ETestCasePassed;
+    
+    STIF_LOG( "<<<ExampleTest" );
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::ConnectL
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::ConnectL( TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult )
+    {
+    STIF_LOG( "Connect" );
+    
+    if ( !iGenericHIDTest )
+        {
+        iGenericHIDTest = CtGenericHIDAPI::NewL();
+        }
+    HBufC8* report = ConvertArray(aTestSubOption); 
+    
+    CleanupStack::PushL( report );
+    iGenericHIDTest->ConnectL(0,*report);
+    CleanupStack::PopAndDestroy();
+    
+    STIF_LOG( "Connect passed" );
+    
+    aTestResult = ETestCasePassed;
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::DisconnectL
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::DisconnectL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+   {
+   iGenericHIDTest->DisconnectL(0);   
+   delete iGenericHIDTest;   
+   iGenericHIDTest = NULL;
+   
+   STIF_LOG( "Disconnect passed" );
+   
+   aTestResult = ETestCasePassed;
+   
+   return KErrNone;
+   }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::DataIn
+// -----------------------------------------------------------------------------
+//  
+TInt CGenericHidTest::DataIn( TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult ) 
+   {
+   TInt retVal = KErrNone;
+   HBufC8* report = ConvertArray(aTestSubOption);
+   TInt firstByte = (*report)[0];
+   STIF_LOG1("aTestSubOption >> report: %d", firstByte);
+   
+   retVal = iGenericHIDTest->DataInL(0,*report);
+   STIF_LOG1( "DataInL return value: %d" , retVal);
+   
+   delete report;
+   report = NULL;
+   
+   STIF_LOG( "Test case passed" );
+   
+   aTestResult = ETestCasePassed;
+   
+   return retVal;
+   }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::Wait
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::WaitL( TPtrC aTestOption, TInt aTestIntOption, TGenericHidTestResult& aTestResult )
+    {
+    CWaitTimer* timer = CWaitTimer::NewLC(aTestIntOption * 1000000);
+    CleanupStack::PopAndDestroy(timer);
+    
+    STIF_LOG( "Test case passed" );
+    
+    aTestResult = ETestCasePassed;
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::CreateCallL
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::CreateCallL( TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult )
+    {
+    TInt err = KErrNone;
+    
+    if ( iDialClient )
+        {
+        delete iDialClient;
+        iDialClient = NULL;
+        }
+    iDialClient = CDialClient::NewL();     
+    
+    iDialClient->CreateCall( aTestSubOption );
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::AddAlarm
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::AddAlarmL( TPtrC aTestOption, TInt aTestIntOption, TGenericHidTestResult& aTestResult  )
+    {
+    STIF_LOG( ">>AddAlarmL" ); 
+
+    if ( !iAlarmControl )
+        {
+        iAlarmControl = CAlarmControl::NewL( iLog );
+        }
+
+    STIF_LOG( "Create alarm" ); 
+    
+    iAlarmControl->CreateClockAlarm( aTestIntOption );
+
+    STIF_LOG( "Test case passed" ); 
+    
+    aTestResult = ETestCasePassed;
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::DeleteAlarm
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::DeleteAlarm( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {    
+    iAlarmControl->DeleteAlarm();
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::CountryCodeL
+// -----------------------------------------------------------------------------
+//    
+TInt CGenericHidTest::CountryCodeL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    TInt ret = iGenericHIDTest->RunCountryCodeL();
+    STIF_LOG2( "RunCountryCodeL return value: %d, expected: %d", ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::VendorIdL
+// -----------------------------------------------------------------------------
+//            
+TInt CGenericHidTest::VendorIdL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    TInt ret = iGenericHIDTest->RunVendorIdL();
+    STIF_LOG2( "RunVendorIdL return value: %d, expected: %d", ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::ProductIdL
+// -----------------------------------------------------------------------------
+//            
+TInt CGenericHidTest::ProductIdL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    TInt ret = iGenericHIDTest->RunProductIdL();  
+    STIF_LOG2( "RunProductIdL return value: %d, expected: %d", ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::SetProtocol
+// -----------------------------------------------------------------------------
+//            
+TInt CGenericHidTest::SetProtocolL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    iGenericHIDTest->RunSetProtocolL();
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+       
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::GetProtocoL
+// -----------------------------------------------------------------------------
+//            
+TInt CGenericHidTest::GetProtocoL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    iGenericHIDTest->RunGetProtocoL(); 
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+       
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::GetReportL
+// -----------------------------------------------------------------------------
+//            
+TInt CGenericHidTest::GetReportL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    iGenericHIDTest->RunGetReportL();
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+        
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CGenericHidTest::SetReportL
+// -----------------------------------------------------------------------------
+//            
+TInt CGenericHidTest::SetReportL( TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult )
+    { 
+    HBufC8* report = ConvertArray(aTestSubOption);    
+    CleanupStack::PushL( report );
+    iGenericHIDTest->RunSetReportL( *report );  
+    CleanupStack::PopAndDestroy();
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }            
+ 
+// -----------------------------------------------------------------------------
+// CGenericHidTest::DataOutL
+// -----------------------------------------------------------------------------
+//        
+TInt CGenericHidTest::DataOutL( TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult )
+    {   
+    HBufC8* report = ConvertArray(aTestSubOption);    
+    CleanupStack::PushL( report );        
+    iGenericHIDTest->RunDataOutL( *report );        
+    CleanupStack::PopAndDestroy();
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    } 
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::GetIdleL
+// -----------------------------------------------------------------------------
+//          
+TInt CGenericHidTest::GetIdleL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    iGenericHIDTest->GetGetIdleL(); 
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+       
+    return KErrNone;
+    } 
+    
+// -----------------------------------------------------------------------------
+// CGenericHidTest::SetIdleL
+// -----------------------------------------------------------------------------
+//           
+TInt CGenericHidTest::SetIdleL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    iGenericHIDTest->RunSetIdleL(); 
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+       
+    return KErrNone;
+    } 
+// -----------------------------------------------------------------------------
+// CGenericHidTest::CommandResultL
+// -----------------------------------------------------------------------------
+//           
+TInt CGenericHidTest::CommandResultL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    iGenericHIDTest->GetCommandResultL();  
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    } 
+// -----------------------------------------------------------------------------
+// CGenericHidTest::ReportDescriptorL
+// -----------------------------------------------------------------------------
+//           
+TInt CGenericHidTest::ReportDescriptorL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    TInt ret = iGenericHIDTest->GetReportDescriptorL();  
+    STIF_LOG2( "GetReportDescriptorL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+        
+// -----------------------------------------------------------------------------
+// CGenericHidTest::ReportDescriptorL
+// -----------------------------------------------------------------------------
+//           
+TInt CGenericHidTest::CreateReportGeneratorL( TPtrC aTestOption, TGenericHidTestResult& aTestResult  )
+    {
+    TInt ret = iGenericHIDTest->CreateReportGeneratorL();
+    STIF_LOG2( "CreateReportGeneratorL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }        
+    
+// -----------------------------------------------------------------------------
+// CGenericHidTest::ReportDescriptorL
+// -----------------------------------------------------------------------------
+//           
+TInt CGenericHidTest::DeleteReportGeneratorL( TPtrC aTestOption, TGenericHidTestResult& aTestResult  )
+    {
+    iGenericHIDTest->DeleteReportGeneratorL();
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }        
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::ReportDescriptorL
+// -----------------------------------------------------------------------------
+//      
+TInt CGenericHidTest::ReportGeneratorReportL( TPtrC aTestOption, TGenericHidTestResult& aTestResult  )
+    {
+    iGenericHIDTest->ReportGeneratorReport();
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CGenericHidTest::ReportGeneratorSetFieldL
+// -----------------------------------------------------------------------------
+//      
+TInt CGenericHidTest::ReportGeneratorSetFieldL( TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult )
+    {
+    TInt ret;
+    TInt expectedResult = KErrNone;
+    
+	if ( !aTestSubOption.Compare( _L( "Array" ) ) )
+		{
+		iLog -> Log( _L("Test type: Array") );
+		ret = iGenericHIDTest->ReportGeneratorSetFieldL( ETrue, EFalse, EFalse, EFalse, ETrue, EFalse );
+		}
+	else if ( !aTestSubOption.Compare( _L( "NotArray" ) ) )
+		{
+		iLog -> Log( _L("Test type: NotArray") );
+		ret = iGenericHIDTest->ReportGeneratorSetFieldL( EFalse, EFalse, EFalse, EFalse, ETrue, EFalse );
+		}
+	else if ( !aTestSubOption.Compare( _L( "NotArrayOutOfRange" ) ) )
+		{
+		iLog -> Log( _L("Test type: NotArrayOutOfRange") );
+		ret = iGenericHIDTest->ReportGeneratorSetFieldL( EFalse, ETrue, EFalse, EFalse, ETrue, EFalse );
+		expectedResult = KErrValueOutOfRange;
+		}
+	else if ( !aTestSubOption.Compare( _L( "FieldNull" ) ) )
+		{
+		iLog -> Log( _L("Test type: FieldNull") );
+		ret = iGenericHIDTest->ReportGeneratorSetFieldL( EFalse, EFalse, ETrue, EFalse, ETrue, EFalse );
+		expectedResult = KErrUsageNotFound;
+		}
+	else if ( !aTestSubOption.Compare( _L( "FieldCountZero" ) ) )
+		{
+		iLog -> Log( _L("Test type: FieldCountZero") );
+		ret = iGenericHIDTest->ReportGeneratorSetFieldL( ETrue, EFalse, EFalse, ETrue, ETrue, EFalse );
+		expectedResult = KErrNoSpaceInArray;
+		}
+	else if ( !aTestSubOption.Compare( _L( "NotExistingUsage" ) ) )
+		{
+		iLog -> Log( _L("Test type: NotExistingUsage") );
+		ret = iGenericHIDTest->ReportGeneratorSetFieldL( ETrue, EFalse, EFalse, ETrue, EFalse, EFalse );//getIndexOfUsage
+		expectedResult = KErrUsageNotFound;
+		}
+	else if ( !aTestSubOption.Compare( _L( "NotExistingUsage2" ) ) )
+		{
+		iLog -> Log( _L("Test type: NotExistingUsage2") );
+		ret = iGenericHIDTest->ReportGeneratorSetFieldL( ETrue, EFalse, EFalse, EFalse, EFalse, EFalse );//getIndexOfUsage
+		expectedResult = KErrUsageNotFound;
+		}
+	else if ( !aTestSubOption.Compare( _L( "BadIndex" ) ) )
+		{
+		iLog -> Log( _L("Test type: BadIndex") );
+		ret = iGenericHIDTest->ReportGeneratorSetFieldL( EFalse, EFalse, EFalse, EFalse, ETrue, ETrue );
+		expectedResult = KErrBadControlIndex;
+		}
+	else
+		{
+		iLog -> Log( _L("Test type: not supported") );
+		return KErrNotFound;
+		}
+	
+
+    STIF_LOG2( "ReportGeneratorSetFieldL return value: %d, expected: %d" , ret, expectedResult);
+    STIF_ASSERT_EQUALS(ret, expectedResult);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    
+    return KErrNone;    
+    }   
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::CreateReportTranslatorL
+// -----------------------------------------------------------------------------
+//   
+TInt CGenericHidTest::CreateReportTranslatorL(  TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult )
+    {   
+    HBufC8* report = ConvertArray(aTestSubOption);    
+    CleanupStack::PushL( report ); 
+    iGenericHIDTest->CreateReportTranslatorL( *report , ETrue, EFalse, EFalse);  
+    CleanupStack::PopAndDestroy();
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::CreateReportTranslator_FieldNullL(  TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult )
+    {   
+    HBufC8* report = ConvertArray(aTestSubOption);    
+    CleanupStack::PushL( report ); 
+    iGenericHIDTest->CreateReportTranslatorL( *report, EFalse, ETrue, EFalse );  
+    CleanupStack::PopAndDestroy();
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::CreateReportTranslator_NotArrayL(  TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult )
+    { 
+    HBufC8* report = ConvertArray(aTestSubOption);    
+    CleanupStack::PushL( report ); 
+    iGenericHIDTest->CreateReportTranslatorL( *report , EFalse, EFalse, EFalse);  
+    CleanupStack::PopAndDestroy();
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::CreateReportTranslator_FieldCountZeroL(  TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult )
+    {   
+    HBufC8* report = ConvertArray(aTestSubOption);    
+    CleanupStack::PushL( report ); 
+    iGenericHIDTest->CreateReportTranslatorL( *report , ETrue, EFalse, ETrue);  
+    CleanupStack::PopAndDestroy();
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::DeleteReportTranslatorL
+// -----------------------------------------------------------------------------
+//   
+TInt CGenericHidTest::DeleteReportTranslatorL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    iGenericHIDTest->DeleteReportTranslatorL();
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::ReportTranslatorGetValueL(  TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult )
+    {
+    TInt ret;
+    TInt expectedResult = KErrNone;
+    
+	if ( !aTestSubOption.Compare( _L( "Ok" ) ) )
+		{
+		iLog -> Log( _L("Test type: Ok") );
+		}
+	else if ( !aTestSubOption.Compare( _L( "NotFound" ) ) )
+		{
+		iLog -> Log( _L("Test type: NotFound") );
+		expectedResult = KErrUsageNotFound;
+		}
+	else
+		{
+		iLog -> Log( _L("Test type: not supported") );
+		return KErrNotFound;
+		}
+    
+    ret = iGenericHIDTest->ReportTranslatorGetValueL();
+    STIF_LOG2( "ReportTranslatorGetValueL return value: %d, expected: %d" , ret, expectedResult);
+    STIF_ASSERT_EQUALS(ret, expectedResult);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::ReportTranslatorValueL
+// -----------------------------------------------------------------------------
+//   
+TInt CGenericHidTest::ReportTranslatorValueL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    iGenericHIDTest->ReportTranslatorValueL();
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::ReportTranslatorGetUsageIdL
+// -----------------------------------------------------------------------------
+//   
+TInt CGenericHidTest::ReportTranslatorGetUsageIdL(  TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult )
+    {
+    TInt ret;
+    TInt expectedResult = KErrNone;
+    TInt badIndex = EFalse;
+    
+	if ( !aTestSubOption.Compare( _L( "Ok" ) ) )
+		{
+		iLog -> Log( _L("Test type: Ok") );
+		}
+	else if ( !aTestSubOption.Compare( _L( "Error" ) ) )
+		{
+		iLog -> Log( _L("Test type: Error") );
+		expectedResult = KErrNoMemory;
+		}
+	else if ( !aTestSubOption.Compare( _L( "BadIndex" ) ) )
+		{
+		iLog -> Log( _L("Test type: BadIndex") );
+		badIndex = ETrue;
+		expectedResult = KErrBadControlIndex;
+		}
+	else
+		{
+		iLog -> Log( _L("Test type: not supported") );
+		return KErrNotFound;
+		}
+    
+    ret = iGenericHIDTest->ReportTranslatorGetUsageIdL( badIndex );
+    STIF_LOG2( "ReportTranslatorGetUsageIdL return value: %d, expected: %d" , ret, expectedResult);
+    STIF_ASSERT_EQUALS(ret, expectedResult);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::ReportTranslatorUsageIdL
+// -----------------------------------------------------------------------------
+//   
+TInt CGenericHidTest::ReportTranslatorUsageIdL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    iGenericHIDTest->ReportTranslatorUsageIdL();
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::ReportTranslatorRawValueL
+// -----------------------------------------------------------------------------
+//   
+TInt CGenericHidTest::ReportTranslatorRawValueL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    iGenericHIDTest->ReportTranslatorRawValueL();
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::ReportTranslatorCountL
+// -----------------------------------------------------------------------------
+//   
+TInt CGenericHidTest::ReportTranslatorCountL(  TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult)
+    {    
+    TInt zeroExpected = EFalse;
+    
+	if ( !aTestSubOption.Compare( _L( "Zero" ) ) )
+		{
+		iLog -> Log( _L("Test type: Zero") );
+		zeroExpected = ETrue;
+		}
+	else if ( !aTestSubOption.Compare( _L( "NotZero" ) ) )
+		{
+		iLog -> Log( _L("Test type: NotZero") );
+		}
+	else
+		{
+		iLog -> Log( _L("Test type: not supported") );
+		return KErrNotFound;
+		}
+    
+    TInt count = iGenericHIDTest->ReportTranslatorCountL();
+    
+    STIF_LOG1( "ReportTranslatorCountL return value: %d" , count);
+    if(zeroExpected != EFalse)
+    	{
+    	STIF_ASSERT_EQUALS(0, count)
+    	}
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::CollectiontypeL
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::CollectiontypeL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    iGenericHIDTest->CollectiontypeL();
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::CollectionIsPhysicalL
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::CollectionIsPhysicalL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    iGenericHIDTest->CollectionIsPhysicalL();
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;    
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::CollectionIsLogicalL
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::CollectionIsLogicalL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    iGenericHIDTest->CollectionIsLogicalL();
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::CollectionIsReportL
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::CollectionIsReportL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    iGenericHIDTest->CollectionIsReportL();
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;    
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::CollectionIsNamedArrayL
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::CollectionIsNamedArrayL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    iGenericHIDTest->CollectionIsNamedArrayL();
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;    
+    }
+// -----------------------------------------------------------------------------
+// CGenericHidTest::CollectionIsUsageSwitchL
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::CollectionIsUsageSwitchL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    iGenericHIDTest->CollectionIsUsageSwitchL();
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;    
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::CollectionIsUsageModifierL
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::CollectionIsUsageModifierL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    iGenericHIDTest->CollectionIsUsageModifierL();
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;    
+    }
+
+TInt CGenericHidTest::CollectionIsApplicationL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    iGenericHIDTest->CollectionIsApplicationL();
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;    
+    }
+
+
+TInt CGenericHidTest::CollectionUsagePageL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    iGenericHIDTest->CollectionUsagePageL();
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;    
+    }
+
+TInt CGenericHidTest::CollectionUsageL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    iGenericHIDTest->CollectionUsageL();
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;    
+    }
+
+TInt CGenericHidTest::CollectionCollectionCountL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    iGenericHIDTest->CollectionCollectionCountL();
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;    
+    }
+
+TInt CGenericHidTest::CollectionFieldCountL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    iGenericHIDTest->CollectionFieldCountL();
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;    
+    }
+
+TInt CGenericHidTest::CollectionCollectionByIndexL( TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult )
+    {
+    TInt ret;
+    
+	if ( !aTestSubOption.Compare( _L( "Present" ) ) )
+		{
+		iLog -> Log( _L("Test type: Present") );
+		ret = iGenericHIDTest->CollectionCollectionByIndexL(ETrue);
+		}
+	else if ( !aTestSubOption.Compare( _L( "NotPresent" ) ) )
+		{
+		iLog -> Log( _L("Test type: NotPresent") );
+		ret = iGenericHIDTest->CollectionCollectionByIndexL(EFalse);
+		}
+	else
+		{
+		iLog -> Log( _L("Test type: not supported") );
+		return KErrNotFound;
+		}
+
+    STIF_LOG2( "CollectionCollectionByIndexL return value: %d, expected: %d", ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::CollectionFieldByIndexL(  TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    TInt ret = iGenericHIDTest->CollectionFieldByIndexL();
+    STIF_LOG2( "CollectionFieldByIndexL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;   
+    }
+
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::ReportrootReportSizeBytes
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::ReportrootReportSizeBytes( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    iGenericHIDTest->ReportrootReportSizeBytes();
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;    
+    }
+// -----------------------------------------------------------------------------
+// CGenericHidTest::FieldLogicalMax
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::FieldLogicalMaxL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    TInt ret = iGenericHIDTest->FieldLogicalMaxL();
+    STIF_LOG2( "FieldLogicalMaxL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+// -----------------------------------------------------------------------------
+// CGenericHidTest::FieldPhysicalMin
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::FieldPhysicalMinL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    TInt ret = iGenericHIDTest->FieldPhysicalMinL();
+    STIF_LOG2( "FieldPhysicalMinL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+// -----------------------------------------------------------------------------
+// CGenericHidTest::FieldPhysicalMax
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::FieldPhysicalMaxL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldPhysicalMaxL();
+    STIF_LOG2( "FieldPhysicalMaxL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+// -----------------------------------------------------------------------------
+// CGenericHidTest::FieldUnit
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::FieldUnitL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldUnitL();
+    STIF_LOG2( "FieldUnitL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+// -----------------------------------------------------------------------------
+// CGenericHidTest::FieldUnitExponent
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::FieldUnitExponentL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldUnitExponentL();
+    STIF_LOG2( "FieldUnitExponentL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::FieldCountL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldCountL();
+    STIF_LOG2( "FieldCountL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::FieldSizeL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldSizeL();
+    STIF_LOG2( "FieldSizeL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::FieldOffsetL( TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult )
+    {  
+    TInt ret;
+    
+	if ( !aTestSubOption.Compare( _L( "SetReport" ) ) )
+		{
+		iLog -> Log( _L("Test type: SetReport") );
+		ret = iGenericHIDTest->FieldOffsetL(ETrue);
+		}
+	else if ( !aTestSubOption.Compare( _L( "NotSetReport" ) ) )
+		{
+		iLog -> Log( _L("Test type: NotSetReport") );
+		ret = iGenericHIDTest->FieldOffsetL(EFalse);
+		}
+	else
+		{
+		iLog -> Log( _L("Test type: not supported") );
+		return KErrNotFound;
+		}
+
+    STIF_LOG2( "FieldOffsetL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::FieldReportIdL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldReportIdL();
+    STIF_LOG2( "FieldReportIdL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::FieldIsInReportL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldIsInReportL();
+    STIF_LOG2( "FieldIsInReportL return value: %d, expected: %d", ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::FieldDesignatorIndexL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldDesignatorIndexL();
+    STIF_LOG2( "FieldDesignatorIndexL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::FieldStringIndexL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldStringIndexL();
+    STIF_LOG2( "FieldStringIndexL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::FieldUsagePageL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldUsagePageL();
+    STIF_LOG2( "FieldUsagePageL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::FieldHasUsage
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::FieldHasUsageL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldHasUsageL();
+    STIF_LOG2( "FieldHasUsageL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::FieldUsageArrayL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldUsageArrayL();
+    STIF_LOG2( "FieldUsageArrayL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::FieldUsageL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldUsageL();
+    STIF_LOG2( "FieldUsageL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::FieldUsageCountL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldUsageCountL();
+    STIF_LOG2( "FieldUsageCountL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::FieldClearUsageListL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldClearUsageListL();
+    STIF_LOG2( "FieldClearUsageListL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::FieldLastUsageL( TPtrC aTestOption, TPtrC aTestSubOption, TGenericHidTestResult& aTestResult )
+    {        
+    TInt ret;
+
+	if ( !aTestSubOption.Compare( _L( "Empty" ) ) )
+		{
+		iLog -> Log( _L("Test type: Empty") );
+		ret = iGenericHIDTest->FieldLastUsageL( ETrue );
+		}
+	else if ( !aTestSubOption.Compare( _L( "NotEmpty" ) ) )
+		{
+		iLog -> Log( _L("Test type: NotEmpty") );
+		ret = iGenericHIDTest->FieldLastUsageL( EFalse );
+		}
+	else
+		{
+		iLog -> Log( _L("Test type: not supported") );
+		return KErrNotFound;
+		}
+
+    STIF_LOG2( "FieldLastUsageL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::FieldAttributes
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::FieldAttributesL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {
+    TInt ret = iGenericHIDTest->FieldAttributesL();
+    STIF_LOG2( "FieldAttributesL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::FieldType
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::FieldTypeL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldTypeL();
+    STIF_LOG2( "FieldTypeL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::FieldIsVariable
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::FieldIsVariableL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldIsVariableL();
+    STIF_LOG2( "FieldIsVariableL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::FieldIsArrayL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldIsArrayL();
+    STIF_LOG2( "FieldIsArrayL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::FieldIsConstant
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::FieldIsConstantL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldIsConstantL();
+    STIF_LOG2( "FieldIsConstantL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::FieldIsDataL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldIsDataL();
+    STIF_LOG2( "FieldIsDataL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::FieldSetLogicalMin
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::FieldSetLogicalMinL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldSetLogicalMinL();
+    STIF_LOG2( "FieldSetLogicalMinL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::FieldSetLogicalMax
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::FieldSetLogicalMaxL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldSetLogicalMaxL();
+    STIF_LOG2( "FieldSetLogicalMaxL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::FieldSetPhysicalMin
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::FieldSetPhysicalMinL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldSetPhysicalMinL();
+    STIF_LOG2( "FieldSetPhysicalMinL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::FieldSetPhysicalMax
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::FieldSetPhysicalMaxL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldSetPhysicalMaxL();
+    STIF_LOG2( "FieldSetPhysicalMaxL return value: %d, expected: %d", ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::FieldSetDesignatorMin
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::FieldSetDesignatorMinL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldSetDesignatorMinL();
+    STIF_LOG2( "FieldSetDesignatorMinL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+// -----------------------------------------------------------------------------
+// CGenericHidTest::FieldSetDesignatorMax
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::FieldSetDesignatorMaxL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldSetDesignatorMaxL();
+    STIF_LOG2( "FieldSetDesignatorMaxL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::FieldSetUsageMinL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldSetUsageMinL();
+    STIF_LOG2( "FieldSetUsageMinL return value: %d, expected: %d" , ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::FieldSetUsageMaxL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldSetUsageMaxL();
+    STIF_LOG2( "FieldSetUsageMaxL return value: %d, expected: %d", ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::FieldSetStringMin
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::FieldSetStringMinL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldSetStringMinL();
+    STIF_LOG2( "FieldSetStringMinL return value: %d, expected: %d", ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::FieldSetStringMax
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::FieldSetStringMaxL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldSetStringMaxL();
+    STIF_LOG2( "FieldSetStringMaxL return value: %d, expected: %d", ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::FieldSetLogicalRangeL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldSetLogicalRangeL();
+    STIF_LOG2( "FieldSetLogicalRangeL return value: %d, expected: %d", ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+        
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::FieldSetUsageRangeL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldSetUsageRangeL();
+    STIF_LOG2( "FieldSetUsageRangeL return value: %d, expected: %d", ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::FieldSetPhysicalRangeL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldSetPhysicalRangeL();
+    STIF_LOG2( "FieldSetPhysicalRangeL return value: %d, expected: %d", ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::FieldSetStringRangeL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldSetStringRangeL();
+    STIF_LOG2( "FieldSetStringRangeL return value: %d, expected: %d", ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::FieldSetDesignatorRangeL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldSetDesignatorRangeL();
+    STIF_LOG2( "FieldSetDesignatorRangeL return value: %d, expected: %d", ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+TInt CGenericHidTest::FieldIsInputL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldIsInputL();
+    STIF_LOG2( "FieldIsInputL return value: %d, expected: %d", ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::FieldIsOutput
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::FieldIsOutputL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldIsOutputL();
+    STIF_LOG2( "FieldIsOutputL return value: %d, expected: %d", ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::FieldIsFeature
+// -----------------------------------------------------------------------------
+//
+TInt CGenericHidTest::FieldIsFeatureL( TPtrC aTestOption, TGenericHidTestResult& aTestResult )
+    {            
+    TInt ret = iGenericHIDTest->FieldIsFeatureL();
+    STIF_LOG2( "FieldIsFeatureL return value: %d, expected: %d", ret, KErrNone);
+    STIF_ASSERT_EQUALS(ret, KErrNone);
+    
+    aTestResult = ETestCasePassed;
+
+    STIF_LOG( "Test case passed" );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::ConvSingleItem
+// -----------------------------------------------------------------------------
+//
+TUint CGenericHidTest::ConvSingleItem(TBuf8<2>& singleItem)
+    {
+    TLex8 lex(singleItem);
+    TUint value;    
+    lex.Val(value,EHex);
+    singleItem.Delete(0,2);    
+    return value;
+    }
+
+// -----------------------------------------------------------------------------
+// CGenericHidTest::ConvertArray
+// -----------------------------------------------------------------------------
+//
+HBufC8* CGenericHidTest::ConvertArray( const TPtrC& aFilename )
+   {
+   RFs theFs; 
+   
+   RFile someFile;
+   if(theFs.Connect() != KErrNone)
+    {
+    return NULL;    
+    }
+   TInt error = someFile.Open(theFs, aFilename, EFileShareExclusive);
+
+   RArray<TUint> arrDesc;       
+   if (!error)
+       {
+       TBool seekEOL = EFalse;
+       TBuf8<2> singleItem;
+
+       TInt hexByte = 0;
+
+       TBool bTerminator = EFalse;
+
+       TBuf8<1>   oneChar;
+       someFile.Read(oneChar, 1);
+
+       while ( (!error) && (oneChar.Size()) )
+           {
+           switch ( oneChar[0] )
+               {
+               case 10:
+               case 13:
+                   seekEOL = EFalse;
+                   break;
+
+               case '/':
+                   seekEOL = ETrue;
+                   // Comments are special case terminators
+                   // interntional drop through to the next case line
+               case ' ':
+               case '\t':
+               case ',':
+                   // whitespace - ignore, unless we've started storing a value
+                   // (in which case treat the char as a terminator)
+                   bTerminator = ETrue;
+                   break;
+
+               default:
+                   if (!seekEOL)
+                       {
+                       if (4==hexByte)
+                           {
+                           error = KErrGeneral;    // Can't store more than two digits
+                           }
+                       else if (hexByte>1)
+                           {
+                           singleItem.Append(oneChar);
+                           }
+
+                       hexByte++;
+                       }
+                   break;
+                   }
+
+               if ( bTerminator && singleItem.Size() )
+                   {
+                   TUint value = ConvSingleItem(singleItem);
+                   arrDesc.Append(value);
+                   hexByte = 0;
+                   }
+
+               bTerminator = EFalse;
+
+               someFile.Read(oneChar, 1);
+               }
+
+           if (singleItem.Size())
+               {
+               TUint value = ConvSingleItem(singleItem);
+               arrDesc.Append(value);
+               }
+
+           someFile.Close();
+           }
+
+       theFs.Close();
+
+       HBufC8* theDesc = 0;
+       
+       if (!error)
+           {
+           TInt size = arrDesc.Count();
+           TRAPD( error, theDesc = HBufC8::NewL(size) );
+           if ( error != KErrNone )
+                {
+                return NULL;    
+                }
+           TPtr8 des = theDesc->Des();
+           for(TInt x=0; x<size; x++)
+               {
+               des.Append(TUint8(arrDesc[x]));
+               }
+           }
+   arrDesc.Close();
+   return theDesc;   
+   }
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+// None
+
+//  [End of File] - Do not remove
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/src/GenericHidTest_exe.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation
+ *
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <e32svr.h>
+#include <StifTestInterface.h>
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// ================= OTHER EXPORTED FUNCTIONS =================================
+
+/*
+-------------------------------------------------------------------------------
+
+    Class: -
+
+    Method: E32Main
+
+    Description: 
+
+    Parameters: None
+
+    Return Values: TInt: Symbian error code
+
+    Errors/Exceptions: None
+
+    Status: Draft
+
+-------------------------------------------------------------------------------
+*/
+GLDEF_C TInt E32Main()
+    {
+    _LIT( KProcessMsgStart, "New process starting" );
+    RDebug::Print( KProcessMsgStart );
+
+
+    // This starts a new session that get capabilites that is used in 
+    // GenericHidTest_exe.mmp file.
+    TInt r = StartSession();
+
+    _LIT( KProcessMsgEnd, "New process ends" );
+    RDebug::Print( KProcessMsgEnd );
+
+    return r;
+
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/src/alarmcontrol.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,122 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Dialhandling class for hid test application
+*
+*/
+
+
+#include "alarmcontrol.h"
+#include "ASShdAlarm.h"
+#include "asshddefs.h"
+
+_LIT(KSoundName, "a");    // For the alarm alert note.
+const TUid KAlarmClockOne = { 0x101F793A };
+
+// ---------------------------------------------------------------------------
+// NewL
+// ---------------------------------------------------------------------------
+//
+CAlarmControl* CAlarmControl::NewL( CStifLogger* aLogger )
+    {
+    CAlarmControl* self = CAlarmControl::NewLC(aLogger);
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// NewLC
+// ---------------------------------------------------------------------------
+//
+CAlarmControl* CAlarmControl::NewLC( CStifLogger* aLogger )
+    {
+    CAlarmControl* self = new( ELeave ) CAlarmControl(aLogger);
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+CAlarmControl::CAlarmControl( CStifLogger* aLogger ):
+iLog(aLogger)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// destructor
+// ---------------------------------------------------------------------------
+//
+CAlarmControl::~CAlarmControl()
+    {
+    if (iAlarmServer.Handle() != KNullHandle)
+        {
+        iAlarmServer.Close();    
+        }    
+    }
+
+// ---------------------------------------------------------------------------
+// ConstructL
+// ---------------------------------------------------------------------------
+//
+void CAlarmControl::ConstructL()
+    {   
+    User::LeaveIfError(iAlarmServer.Connect());
+    }
+// ---------------------------------------------------------------------------
+// CreateClockAlarm
+// ---------------------------------------------------------------------------
+//
+void CAlarmControl::CreateClockAlarm( TInt aTime )
+    {
+    STIF_LOG("CreateClockAlarm");
+    TInt minute;
+    TTime tmp;
+    tmp.HomeTime();
+    TDateTime alarmdtime = tmp.DateTime();
+    minute = alarmdtime.Minute();
+    minute = minute+aTime;
+    alarmdtime.SetMinute(minute);
+    
+    STIF_LOG("CreateClockAlarm solve minutes");
+    TASShdAlarm alarm;
+    alarm.Category() = KAlarmClockOne;
+    alarm.RepeatDefinition() = EAlarmRepeatDefintionRepeatOnce;
+    alarm.OriginalExpiryTime() = alarmdtime;
+    alarm.NextDueTime() = alarmdtime;
+    alarm.SoundName() = KSoundName;
+    
+    STIF_LOG("CreateClockAlarm solve data");
+    alarm.ClientFlags().Set( 0 );
+    
+    STIF_LOG("CreateClockAlarm solve add alarm");
+    iAlarmServer.AlarmAdd(alarm);
+    iAlarmID = alarm.Id();
+    
+    STIF_LOG("CreateClockAlarm solve add activate alarm");
+    iAlarmServer.SetAlarmStatus(iAlarmID, EAlarmStatusEnabled);
+    
+    STIF_LOG("CreateClockAlarm completed");
+    }
+
+// ---------------------------------------------------------------------------
+// CreateClockAlarm
+// ---------------------------------------------------------------------------
+//
+void CAlarmControl::DeleteAlarm()
+    {
+    iAlarmServer.AlarmDelete(iAlarmID);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/src/tdialclient.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,123 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Dialhandling class for hid test application
+*
+*/
+
+
+#include "tdialclient.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+CDialClient* CDialClient::NewL()
+    {
+    CDialClient* self = CDialClient::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// ?description_if_needed
+// ---------------------------------------------------------------------------
+//
+CDialClient* CDialClient::NewLC()
+    {
+    CDialClient* self = new( ELeave ) CDialClient;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+CDialClient::CDialClient()
+: CActive(EPriorityNormal), iCallParamsPckg(iCallParams),
+  iCallStarted(EFalse)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+// ---------------------------------------------------------------------------
+// ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDialClient::ConstructL()
+    {
+    iTelephony = CTelephony::NewL();
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CDialClient::~CDialClient()
+    {
+    Cancel();
+    delete iTelephony;
+    }
+
+// ---------------------------------------------------------------------------
+// RunL
+// ---------------------------------------------------------------------------
+//
+void CDialClient::RunL()
+    {
+    if ( iSyncWaiter.IsStarted() )
+        {
+        iSyncWaiter.AsyncStop();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// DoCancel()
+// ---------------------------------------------------------------------------
+//
+void CDialClient::DoCancel()
+    {
+        
+    }
+// ---------------------------------------------------------------------------
+// CreateCall()
+// ---------------------------------------------------------------------------
+//
+void CDialClient::CreateCall(const TDesC& aNumber)
+    {
+    if ( IsActive() )
+        {
+        return;
+        }
+    CTelephony::TTelNumber telNumber(aNumber);       
+    iCallParams.iIdRestrict = CTelephony::ESendMyId;        
+    iTelephony->DialNewCall(iStatus, iCallParamsPckg, telNumber, iCallId);
+    
+    SetActive();    
+    iSyncWaiter.Start();    
+    }
+
+// ---------------------------------------------------------------------------
+// HangUp()
+// ---------------------------------------------------------------------------
+//
+void CDialClient::HangUp()
+    {    
+    iTelephony->Hangup( iStatus , iCallId );    
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/src/tgenerichidapi.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1540 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  HID field search
+*
+*/
+
+#include <e32std.h>
+
+#include "tGenericHIDAPI.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// NewLC
+// ---------------------------------------------------------------------------
+//
+CtGenericHIDAPI* CtGenericHIDAPI::NewLC()
+    {    
+    CtGenericHIDAPI* self = new (ELeave) CtGenericHIDAPI();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// NewL
+// ---------------------------------------------------------------------------
+//
+CtGenericHIDAPI* CtGenericHIDAPI::NewL()
+    {
+    CtGenericHIDAPI* self = NewLC();
+    CleanupStack::Pop();
+    return self;    
+    }
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+CtGenericHIDAPI::CtGenericHIDAPI()
+    {    
+    }
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//    
+CtGenericHIDAPI::~CtGenericHIDAPI()
+    {
+    delete iHidDriver;
+    iFieldList.Close();
+    delete iGenHID;
+    }
+// ---------------------------------------------------------------------------
+// ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CtGenericHIDAPI::ConstructL()
+    {
+    iGenHID = CGenericHid::NewL( this );
+    iDriverAcces=iGenHID;
+
+    iHidDriver = CHidDriver::NewL(TUid::Uid(0xE000B187),iGenHID);
+    }
+// ---------------------------------------------------------------------------
+// ConnectL()
+// ---------------------------------------------------------------------------
+//
+void CtGenericHIDAPI::ConnectL(TInt aConnectionId, const TDesC8& aDescriptor)
+    {
+    TInt16 ret = iGenHID->ConnectedL( aConnectionId, aDescriptor );
+    ret = iGenHID->DriverActive( aConnectionId , CHidTransport::EActive);
+    
+    //todo retval
+    }
+
+// ---------------------------------------------------------------------------
+// DisconnectL()
+// ---------------------------------------------------------------------------
+//
+void CtGenericHIDAPI::DisconnectL(TInt aConnectionId )
+    {    
+    TInt16 ret = iGenHID->Disconnected( aConnectionId );
+    //todo retval
+    }
+
+// ---------------------------------------------------------------------------
+// DataInL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::DataInL(TInt aConnectionId, const TDesC8& aDescriptor)
+    {
+    TInt16 ret = iGenHID->DataIn(aConnectionId, CHidTransport::EHidChannelInt, aDescriptor);
+    return ret;
+    }
+
+// ---------------------------------------------------------------------------
+// RunCountryCodeL()
+// ---------------------------------------------------------------------------
+//    
+TInt CtGenericHIDAPI::RunCountryCodeL()
+    {
+    TInt16 countryCode = iGenHID->CountryCodeL(0);
+    if(countryCode != 0)
+    	return KErrNotFound;
+    
+    return KErrNone;
+    }
+ 
+// ---------------------------------------------------------------------------
+// RunVendorIdL()
+// ---------------------------------------------------------------------------
+//        
+TInt CtGenericHIDAPI::RunVendorIdL()
+    {
+    TUint vendorId = iGenHID->VendorIdL(0);
+    if(vendorId != 0x0421)
+    	return KErrNotFound;
+    return KErrNone;
+    }
+        
+// ---------------------------------------------------------------------------
+// RunProductIdL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::RunProductIdL()
+    {
+    TUint productId = iGenHID->ProductIdL(0);
+    if(productId != 0x0083)
+    	return KErrNotFound;
+    
+    return KErrNone;
+    }
+ 
+// ---------------------------------------------------------------------------
+// RunSetProtocol()
+// ---------------------------------------------------------------------------
+//        
+TInt CtGenericHIDAPI::RunSetProtocolL()
+    {
+    iGenHID->SetProtocolL(0,0,MDriverAccess::EReport,iHidDriver);
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// RunGetProtocoL()
+// ---------------------------------------------------------------------------
+//        
+TInt CtGenericHIDAPI::RunGetProtocoL()
+    {
+    iGenHID->GetProtocolL(0,0);    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// RunGetReportL()
+// ---------------------------------------------------------------------------
+//        
+TInt CtGenericHIDAPI::RunGetReportL()
+    {
+    iGenHID->GetReportL(0, 0 ,0 , 0);    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// RunSetReportL()
+// ---------------------------------------------------------------------------
+//        
+TInt CtGenericHIDAPI::RunSetReportL(const TDesC8& aDescriptor)
+    {
+    iGenHID->SetReportL(0,0, MDriverAccess::EOutput, aDescriptor,0, iHidDriver);
+    return KErrNone;
+    }
+                
+// ---------------------------------------------------------------------------
+// GetDataOutL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::RunDataOutL(const TDesC8& aDescriptor)
+    {
+    iGenHID->DataOutL( 0, 0,  aDescriptor, 0);    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// GetGetIdleL()
+// ---------------------------------------------------------------------------
+//        
+TInt CtGenericHIDAPI::GetGetIdleL()
+    {
+    iGenHID->GetIdleL(0, 0, 0);
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// RunSetIdleL()
+// ---------------------------------------------------------------------------
+//        
+TInt CtGenericHIDAPI::RunSetIdleL()
+    {
+    iGenHID->SetIdleL(0, 10, 0, 0, iHidDriver);
+    return KErrNone;
+    }
+        
+// ---------------------------------------------------------------------------
+// GetCommandResultL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::GetCommandResultL()
+    {
+    iGenHID->CommandResult(0, 1);
+    return KErrNone;
+    }
+        
+// ---------------------------------------------------------------------------
+// GetReportDescriptorL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::GetReportDescriptorL()
+    {
+    CReportRoot* tmp=iGenHID->ReportDescriptor(0);
+    if(tmp == NULL)
+    	return KErrNotFound;
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CreateReportGeneratorL
+// ---------------------------------------------------------------------------
+//    
+TInt CtGenericHIDAPI::CreateReportGeneratorL()   
+    {
+    CReportRoot* tmp=iGenHID->ReportDescriptor(0);
+    
+    if(tmp == NULL)
+    	return KErrNotFound;
+    
+    iReportGenerator = CReportGenerator::NewL(tmp, 0, CField::EInput);
+    
+    if(iReportGenerator == NULL)
+    	return KErrNotFound;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// DeleteReportGeneratorL()
+// ---------------------------------------------------------------------------
+//        
+TInt CtGenericHIDAPI::DeleteReportGeneratorL()   
+    {    
+    delete iReportGenerator;
+    iReportGenerator = NULL;
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// ReportGeneratorReport()
+// ---------------------------------------------------------------------------
+//   
+TInt CtGenericHIDAPI::ReportGeneratorReport()
+    {
+    iReportGenerator->Report();    
+    //todo check return value???
+    return KErrNone;
+    }    
+
+// ---------------------------------------------------------------------------
+// ReportGeneratorReport()
+// ---------------------------------------------------------------------------
+//   
+TInt CtGenericHIDAPI::ReportGeneratorSetFieldL( TBool aIsArray, TBool aOutOfRange, TBool aFieldNull, TBool aFieldCountZero, TBool aExistingUsageId, TBool aBadIndex )
+    {
+    CField* field = CreateCFieldL();
+    
+    TInt usageId = EConsumerUsageVolumeInc;//233;//0xE9
+    TInt indexOffset = 0;
+    
+    if(aBadIndex != EFalse)
+    	{
+    	indexOffset = 1000;
+    	}
+    
+    if(aExistingUsageId == EFalse)
+    	{
+    	usageId = EConsumerUsagePlayPause;//205
+    	field->SetUsageRange(0,255);
+    	}
+    
+    if(aIsArray == EFalse)
+    	{
+    	field->SetAttributes(KFieldAttributeVariable);
+    	if(field->IsArray() != EFalse)
+    		{
+    		return KErrGeneral;
+    		}
+    	}
+    else 
+    {
+		field->SetAttributes(!KFieldAttributeVariable);
+		if(field->IsArray() == EFalse)
+    	{
+    	return KErrGeneral;
+    	}
+    }
+    
+    field->SetLogicalMax(10);
+    if(aOutOfRange != EFalse)
+    	{
+    	field->SetLogicalMin(5);
+    	}
+    
+    if(aFieldCountZero != EFalse)
+    	{
+    	field->SetCount(0);
+    	}
+    
+    const CField* constField;
+    if(aFieldNull == EFalse)
+    	{
+    	constField = (const CField*)field;
+    	}
+    else
+    	{
+    	constField = NULL;
+    	}
+    TInt16 ret = iReportGenerator->SetField(constField, usageId, 1, indexOffset);
+    return ret;
+    }    
+            
+// -----------------------------------------------------------------------------
+// CtGenericHid::CreateReportTranslatorL
+// -----------------------------------------------------------------------------
+//   
+TInt CtGenericHIDAPI::CreateReportTranslatorL( const TDesC8& aDescriptor, TBool aIsArray, TBool aFieldNull, TBool aFieldCountZero)
+    {
+    CField* field = CreateCFieldL();
+    
+    
+    if(aIsArray == EFalse)
+    	{
+    	field->SetAttributes(KFieldAttributeVariable);
+    	if(field->IsArray() != EFalse)
+    		{
+    		return KErrGeneral;
+    		}
+    	}
+    else 
+    {
+		field->SetAttributes(!KFieldAttributeVariable);
+		if(field->IsArray() == EFalse)
+    	{
+    	return KErrGeneral;
+    	}
+    }
+    
+   /* field->SetLogicalMax(10);
+    if(aOutOfRange != EFalse)
+    	{
+    	field->SetLogicalMin(5);
+    	}*/
+    
+    if(aFieldCountZero != EFalse)
+    	{
+    	field->SetCount(0);
+    	}
+    
+    const CField* constField;
+    if(aFieldNull == EFalse)
+    	{
+    	constField = (const CField*)field;
+    	}
+    else
+    	{
+    	constField = NULL;
+    	}
+    
+    
+    
+    
+    //const CField* field = CreateConstCFieldL();
+    iTranslator = new (ELeave) TReportTranslator(aDescriptor, constField);
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CtGenericHid::CreateReportTranslator_FieldNullL
+// -----------------------------------------------------------------------------
+//   
+/*TInt CtGenericHIDAPI::CreateReportTranslator_FieldNullL( const TDesC8& aDescriptor  )
+    {
+    const CField* field = NULL;
+    iTranslator = new (ELeave) TReportTranslator(aDescriptor, field);
+    return KErrNone;
+    }*/
+
+// -----------------------------------------------------------------------------
+// CtGenericHid::DeleteReportTranslatorL
+// -----------------------------------------------------------------------------
+//   
+TInt CtGenericHIDAPI::DeleteReportTranslatorL(  )
+    {
+    delete iTranslator;    
+    iTranslator =NULL;
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CtGenericHid::ReportTranslatorGetValueL
+// -----------------------------------------------------------------------------
+//   
+TInt CtGenericHIDAPI::ReportTranslatorGetValueL()
+    {
+    //todo if
+    TInt value = 0;
+    TInt res = iTranslator->GetValue(value,EConsumerUsageVolumeInc);
+
+    return res;
+    }
+
+// -----------------------------------------------------------------------------
+// CtGenericHid::ReportTranslatorValueL
+// -----------------------------------------------------------------------------
+//   
+TInt CtGenericHIDAPI::ReportTranslatorValueL()
+    {
+    TInt value = iTranslator->ValueL(EConsumerUsageVolumeInc); 
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CtGenericHid::ReportTranslatorGetUsageIdL
+// -----------------------------------------------------------------------------
+//   
+TInt CtGenericHIDAPI::ReportTranslatorGetUsageIdL( TBool aBadControlIndex )
+    {
+    TInt id;
+    TInt index = 0;
+    
+    if(aBadControlIndex != EFalse)
+    	{
+    	index = -1;//bad index
+    	}
+    //todo if
+    TInt ret = iTranslator->GetUsageId(id,index);
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CtGenericHid::ReportTranslatorUsageIdL
+// -----------------------------------------------------------------------------
+//   
+TInt CtGenericHIDAPI::ReportTranslatorUsageIdL( )
+    {
+    TInt value = iTranslator->UsageIdL(0);  
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CtGenericHid::ReportTranslatorRawValueL
+// -----------------------------------------------------------------------------
+//   
+TInt CtGenericHIDAPI::ReportTranslatorRawValueL(   )
+    {
+    TInt value = iTranslator->RawValueL(0);  
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CtGenericHid::ReportTranslatorCountL
+// -----------------------------------------------------------------------------
+//   
+TInt CtGenericHIDAPI::ReportTranslatorCountL( )
+    {
+    TInt count =iTranslator->Count();  
+    //todo if, retval
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CtGenericHid::CollectiontypeL
+// -----------------------------------------------------------------------------
+// 
+TInt CtGenericHIDAPI::CollectiontypeL( )
+    {
+    CReportRoot* tmp=iGenHID->ReportDescriptor(0);
+    User::LeaveIfNull(tmp);
+    TUint32 type=tmp->Type();
+    //todo check type?
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CtGenericHid::CollectionIsPhysicalL
+// -----------------------------------------------------------------------------
+// 
+TInt CtGenericHIDAPI::CollectionIsPhysicalL( )
+    {
+    CReportRoot* tmp=iGenHID->ReportDescriptor(0);
+    User::LeaveIfNull(tmp);
+    TBool result=tmp->IsPhysical();
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CtGenericHid::CollectionIsLogicalL
+// -----------------------------------------------------------------------------
+// 
+TInt CtGenericHIDAPI::CollectionIsLogicalL( )
+    {
+    CReportRoot* tmp=iGenHID->ReportDescriptor(0);
+    User::LeaveIfNull(tmp);
+    TBool result=tmp->IsLogical();
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CtGenericHid::CollectionIsReportL
+// -----------------------------------------------------------------------------
+// 
+TInt CtGenericHIDAPI::CollectionIsReportL( )
+    {
+    CReportRoot* tmp=iGenHID->ReportDescriptor(0);
+    User::LeaveIfNull(tmp);
+    TBool result=tmp->IsReport();   
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CtGenericHid::CollectionIsNamedArrayL
+// -----------------------------------------------------------------------------
+// 
+TInt CtGenericHIDAPI::CollectionIsNamedArrayL( )
+    {
+    CReportRoot* tmp=iGenHID->ReportDescriptor(0);
+    User::LeaveIfNull(tmp);
+    TBool result =tmp->IsNamedArray();
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CtGenericHid::CollectionIsUsageSwitchL
+// -----------------------------------------------------------------------------
+// 
+TInt CtGenericHIDAPI::CollectionIsUsageSwitchL( )
+    {
+    CReportRoot* tmp=iGenHID->ReportDescriptor(0);
+    User::LeaveIfNull(tmp);
+    TBool resul = tmp->IsUsageSwitch();
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CtGenericHid::CollectionIsUsageModifierL
+// -----------------------------------------------------------------------------
+// 
+TInt CtGenericHIDAPI::CollectionIsUsageModifierL( )
+    {
+    CReportRoot* tmp=iGenHID->ReportDescriptor(0);
+    User::LeaveIfNull(tmp);
+    TInt result = tmp->IsUsageModifier();
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CtGenericHid::CollectionIsApplicationL
+// -----------------------------------------------------------------------------
+// 
+TInt CtGenericHIDAPI::CollectionIsApplicationL( )
+    {
+    CReportRoot* tmp=iGenHID->ReportDescriptor(0);
+    User::LeaveIfNull(tmp);
+    TInt result = tmp->IsApplication();
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CtGenericHid::CollectionUsagePageL
+// -----------------------------------------------------------------------------
+// 
+TInt CtGenericHIDAPI::CollectionUsagePageL( )
+    {
+    CReportRoot* tmp=iGenHID->ReportDescriptor(0);
+    User::LeaveIfNull(tmp);
+    TInt result = tmp->UsagePage();
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CtGenericHid::CollectionUsageL
+// -----------------------------------------------------------------------------
+// 
+TInt CtGenericHIDAPI::CollectionUsageL( )
+    {
+    CReportRoot* tmp=iGenHID->ReportDescriptor(0);
+    User::LeaveIfNull(tmp);
+    TInt result = tmp->Usage();
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CtGenericHid::CollectionCollectionCountL
+// -----------------------------------------------------------------------------
+// 
+TInt CtGenericHIDAPI::CollectionCollectionCountL( )
+    {
+    CReportRoot* tmp=iGenHID->ReportDescriptor(0);
+    User::LeaveIfNull(tmp);
+    TInt result = tmp->CollectionCount();
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CtGenericHid::CollectionFieldCountL
+// -----------------------------------------------------------------------------
+// 
+TInt CtGenericHIDAPI::CollectionFieldCountL( )
+    {
+    CReportRoot* tmp=iGenHID->ReportDescriptor(0);
+    User::LeaveIfNull(tmp);
+    TInt result = tmp->FieldCount();
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CtGenericHid::CollectionCollectionByIndexL
+// -----------------------------------------------------------------------------
+// 
+TInt CtGenericHIDAPI::CollectionCollectionByIndexL( TBool aPresent )
+    {
+    CReportRoot* tmp=iGenHID->ReportDescriptor(0);
+    User::LeaveIfNull(tmp);
+    TInt index;
+    
+    index = (aPresent != EFalse) ? 0 : -1;
+
+    const CCollection* result = tmp->CollectionByIndex(index);
+    
+    if(aPresent != EFalse && result == NULL)
+    	return KErrGeneral;
+    
+    if(aPresent == EFalse && result != NULL)
+    	return KErrGeneral;
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CtGenericHid::CollectionFieldByIndexL
+// -----------------------------------------------------------------------------
+// 
+TInt CtGenericHIDAPI::CollectionFieldByIndexL( )
+    {
+    CReportRoot* tmp=iGenHID->ReportDescriptor(0);
+    User::LeaveIfNull(tmp);
+    const CField* result = tmp->FieldByIndex(-1);
+    
+    if(result != NULL)
+    	return KErrGeneral;
+    //todo if
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CtGenericHid::ReportrootReportSizeBytes
+// -----------------------------------------------------------------------------
+// 
+TInt CtGenericHIDAPI::ReportrootReportSizeBytes( )
+    {
+    CReportRoot* tmp=iGenHID->ReportDescriptor(0);
+    User::LeaveIfNull(tmp);
+    TInt16 size = tmp->ReportSizeBytes(0,CField::EInput);  
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldLogicalMaxL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldLogicalMaxL( )//todo remove
+    {
+    CField* field = CreateCFieldL();
+    const TInt max = 5;
+    field->SetLogicalMax(max);
+    TInt ret = field->LogicalMax();
+    if(ret != max)
+    	return KErrGeneral;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldPhysicalMinL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldPhysicalMinL( )//todo remove
+    {
+    CField* field = CreateCFieldL();
+    const TInt min = 0;
+    field->SetPhysicalMin(min);
+    TInt ret = field->PhysicalMin();
+    if(ret != min)
+    	return KErrGeneral;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldPhysicalMaxL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldPhysicalMaxL( )//todo remove    
+    {    
+    CField* field = CreateCFieldL();
+    const TInt max = 5;
+    field->SetPhysicalMax(max);
+    TInt ret=field->PhysicalMax();
+    if(ret != max)
+    	return KErrGeneral;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldUnitL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldUnitL( )
+    {
+    CField* field = CreateCFieldL();
+    TInt unit = 5;
+    field->SetUnit(unit);
+    TInt ret = field->Unit();
+    if(ret != unit)
+    	return KErrGeneral;
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldUnitExponentL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldUnitExponentL( )
+    {    
+    CField* field = CreateCFieldL();
+    TInt unitExponent = 5;
+    field->SetUnitExponent(unitExponent);
+    TInt ret = field->UnitExponent();
+    if(ret != unitExponent)
+    	return KErrGeneral;
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldCountL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldCountL( )
+    {    
+    CField* field = CreateCFieldL();
+    TInt count = 5;
+    field->SetCount(count);
+    TInt ret = field->Count();
+    if(ret != count)
+    	return KErrGeneral;
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldSizeL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldSizeL( )
+    {    
+    CField* field = CreateCFieldL();
+    TInt size = 5;
+    field->SetSize(size);
+    TInt ret = field->Size();
+    if(ret != size)
+    	return KErrGeneral;
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldOffsetL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldOffsetL(TBool setReport )
+    {    
+    CField* field = CreateCFieldL();
+    
+    if(setReport != EFalse)
+    	{
+    	field->SetReportId(5);
+    	}
+    
+    TInt offset = 5;
+    field->SetOffset(offset);
+    TInt ret = field->Offset();
+    
+    if(setReport != EFalse)
+    	{
+    	offset += KSizeOfByte;
+    	}
+    
+    if(ret != offset)
+    	return KErrGeneral;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldReportIdL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldReportIdL( )
+    {    
+    CField* field = CreateCFieldL();
+    TInt reportId = 5;
+    field->SetReportId(reportId);
+    TInt ret = field->ReportId();
+    if(ret != reportId)
+    	return KErrGeneral;
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldIsInReportL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldIsInReportL( )
+    {    
+    CField* field = CreateCFieldL();
+    TInt reportId = 5;
+    field->SetReportId(reportId);
+    TBool ret = field->IsInReport(reportId);
+    if(!ret)
+    	return KErrGeneral;
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldDesignatorIndexL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldDesignatorIndexL( )
+    {    
+    CField* field = CreateCFieldL();
+    TInt designatorIndex = 5;
+    field->SetDesignatorIndex(designatorIndex);
+    TInt ret = field->DesignatorIndex();
+    if(ret != designatorIndex)
+    	return KErrGeneral;
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldStringIndexL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldStringIndexL( )
+    {    
+    CField* field = CreateCFieldL();
+    TInt stringIndex = 5;
+    field->SetStringIndex(stringIndex);
+    TInt ret = field->StringIndex();
+    if(ret != stringIndex)
+    	return KErrGeneral;
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldUsagePageL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldUsagePageL( )
+    {    
+    CField* field = CreateCFieldL();
+    TInt usagePage = 5;
+    field->SetUsagePage(usagePage);
+    TInt ret = field->UsagePage();
+    if(ret != usagePage)
+    	return KErrGeneral;
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldHasUsageL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldHasUsageL( )
+    {    
+    CField* field = CreateCFieldL();
+    TInt usage = 233;
+    field->AddUsageL(usage);
+    TBool ret = field->HasUsage(usage);
+    if(!ret)
+    	return KErrGeneral;
+    //todo check EFalse
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldUsageArrayL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldUsageArrayL( )
+    {    
+    CField* field = CreateCFieldL();
+    TInt usage = 233;
+    field->AddUsageL(usage);
+    TArray<TInt> usageArray = field->UsageArray();
+    
+    if(usageArray[0] != usage)
+    	return KErrGeneral;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldUsageL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldUsageL( )
+    {    
+    CField* field = CreateCFieldL();
+    TInt usage = 233;
+    field->AddUsageL(usage);
+    TInt ret = field->Usage(0);
+    
+    if(ret != usage)
+    	return KErrGeneral;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldUsageCountL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldUsageCountL( )
+    {    
+    CField* field = CreateCFieldL();
+    TInt firstCount = field->UsageCount();
+    TInt usage = 233;
+    field->AddUsageL(usage);
+    TInt secondCount = field->UsageCount();
+    
+    if(secondCount != firstCount+1)
+    	return KErrGeneral;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldClearUsageListL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldClearUsageListL( )
+    {    
+    CField* field = CreateCFieldL();
+    TInt usage = 233;
+    field->AddUsageL(usage);
+    TInt ret = field->UsageCount();
+    
+    if(ret == 0)
+    	return KErrGeneral;
+    
+    field->ClearUsageList();
+    ret = field->UsageCount();
+    if(ret != 0)
+    	return KErrGeneral;
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldLastUsageL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldLastUsageL( TBool empty )
+    {    
+    CField* field = CreateCFieldL();
+    //todo if - without add
+    TInt usage = 233;
+    
+    if(empty != EFalse)
+    	{
+    	field->ClearUsageList();
+    	usage = 0;
+    	}
+    else
+    	{
+    	field->AddUsageL(usage);
+    	}
+    
+    TInt ret = field->LastUsage();
+    
+    if(ret != usage)
+    	return KErrGeneral;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldAttributesL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldAttributesL( )
+    {
+    CField* field = CreateCFieldL();
+    TUint32 attributes = KFieldAttributeConstant;
+    field->SetAttributes(attributes);
+    TUint32 ret = field->Attributes();
+    if(ret != attributes)
+    	return KErrGeneral;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldTypeL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldTypeL( )
+    {
+    CField* field = CreateCFieldL();
+    CField::TType type = CField::EInput;
+    field->SetType(type);
+    CField::TType ret = field->Type();
+    if(ret != type)
+    	return KErrGeneral;
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldIsVariableL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldIsVariableL( )
+    {
+    CField* field = CreateCFieldL();
+    TUint32 attributes = KFieldAttributeVariable;
+    field->SetAttributes(attributes);
+    TBool ret = field->IsVariable();
+    if(!ret)
+    	return KErrGeneral;
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldIsArrayL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldIsArrayL( )
+    {
+    CField* field = CreateCFieldL();
+    TUint32 attributes = KFieldAttributeVariable;
+    field->SetAttributes(attributes);
+    TBool ret = field->IsArray();
+    if(ret)
+    	return KErrGeneral;
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldIsConstantL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldIsConstantL(  )
+    {    
+    CField* field = CreateCFieldL();
+    TUint32 attributes = KFieldAttributeConstant;
+    field->SetAttributes(attributes);
+    TBool ret = field->IsConstant();
+    if(!ret)
+    	return KErrGeneral;
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldIsDataL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldIsDataL(  )
+    {    
+    CField* field = CreateCFieldL();
+    TUint32 attributes = KFieldAttributeConstant;
+    field->SetAttributes(attributes);
+    TBool ret = field->IsData();
+    if(ret)
+    	return KErrGeneral;
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldSetLogicalMinL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldSetLogicalMinL()
+    {
+    CField* field = CreateCFieldL();
+    
+    TInt value = 0;
+    field->SetLogicalMin(value);
+    
+    TInt ret = field->LogicalMin();
+    if(ret != value)
+    	return KErrGeneral;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldSetLogicalMaxL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldSetLogicalMaxL( )
+    {    
+    CField* field = CreateCFieldL();
+    TInt value = 10;
+    field->SetLogicalMax(value);
+    
+    TInt ret = field->LogicalMax();
+    if(ret != value)
+    	return KErrGeneral;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldSetPhysicalMinL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldSetPhysicalMinL( )
+    {
+    CField* field = CreateCFieldL();
+    TInt value = 0;
+    field->SetPhysicalMin(value);
+    TInt ret = field->PhysicalMin();
+    if(ret != value)
+    	return KErrGeneral;
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldSetPhysicalMaxL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldSetPhysicalMaxL( ) 
+    {
+    CField* field = CreateCFieldL();
+    TInt value = 2;
+    field->SetPhysicalMax(value);
+    TInt ret = field->PhysicalMax();
+    if(ret != value)
+    	return KErrGeneral;
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldSetDesignatorMinL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldSetDesignatorMinL( )
+    {
+    CField* field = CreateCFieldL();
+    TInt value = 0;
+    field->SetDesignatorMin(value);
+    TInt ret = field->DesignatorMin();
+    if(ret != value)
+    	return KErrGeneral;
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldSetDesignatorMaxL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldSetDesignatorMaxL(  )
+    {
+    CField* field = CreateCFieldL();
+    TInt value = 2;
+    field->SetDesignatorMax(value);
+    TInt ret = field->DesignatorMax();
+    if(ret != value)
+    	return KErrGeneral;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldSetUsageMinL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldSetUsageMinL( )
+    {
+    CField* field = CreateCFieldL();
+    TInt value = 0;
+    field->SetUsageMin(value);
+    TInt ret = field->UsageMin();
+    if(ret != value)
+    	return KErrGeneral;
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldSetUsageMaxL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldSetUsageMaxL(  )
+    {
+    CField* field = CreateCFieldL();
+    TInt value = 2;
+    field->SetUsageMax(value);
+    TInt ret = field->UsageMax();
+    if(ret != value)
+    	return KErrGeneral;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldSetStringMinL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldSetStringMinL( )
+    {    
+    CField* field = CreateCFieldL();
+    TInt value = 0;
+    field->SetStringMin(value);
+    TInt ret = field->StringMin();
+    if(ret != value)
+    	return KErrGeneral;
+
+    return KErrNone;
+    }
+// ---------------------------------------------------------------------------
+// FieldSetStringMaxL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldSetStringMaxL( )
+    {
+    CField* field = CreateCFieldL();
+    TInt value = 2;
+    field->SetStringMax(value);
+    TInt ret = field->StringMax();
+    if(ret != value)
+    	return KErrGeneral;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldSetLogicalRangeL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldSetLogicalRangeL( )
+    {
+    CField* field = CreateCFieldL();
+    TInt min = 0;
+    TInt max = 5;
+    field->SetLogicalRange(min,max);
+    TInt retMin = field->LogicalMin();
+    TInt retMax = field->LogicalMax();
+    if(min != retMin || max != retMax)
+    	return KErrGeneral;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldSetUsageRangeL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldSetUsageRangeL( )
+    {
+    CField* field = CreateCFieldL();
+    TInt min = 0;
+    TInt max = 5;
+    field->SetUsageRange(min,max);
+    TInt retMin = field->UsageMin();
+    TInt retMax = field->UsageMax();
+    if(min != retMin || max != retMax)
+    	return KErrGeneral;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldSetPhysicalRangeL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldSetPhysicalRangeL( )
+    {
+    CField* field = CreateCFieldL();
+    TInt min = 0;
+    TInt max = 5;
+    field->SetPhysicalRange(min,max);
+    TInt retMin = field->PhysicalMin();
+    TInt retMax = field->PhysicalMax();
+    if(min != retMin || max != retMax)
+    	return KErrGeneral;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldSetStringRangeL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldSetStringRangeL( )
+    {
+    CField* field = CreateCFieldL();
+    TInt min = 0;
+    TInt max = 5;
+    field->SetStringRange(min,max);
+    TInt retMin = field->StringMin();
+    TInt retMax = field->StringMax();
+    if(min != retMin || max != retMax)
+    	return KErrGeneral;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldSetDesignatorRangeL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldSetDesignatorRangeL( )
+    {
+    CField* field = CreateCFieldL();
+    TInt min = 0;
+    TInt max = 5;
+    field->SetDesignatorRange(min,max);
+    TInt retMin = field->DesignatorMin();
+    TInt retMax = field->DesignatorMax();
+    if(min != retMin || max != retMax)
+    	return KErrGeneral;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldIsInputL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldIsInputL( )
+    {
+    CField* field = CreateCFieldL();
+    CField::TType type = CField::EInput;
+    field->SetType(type);
+    TBool ret = field->IsInput();
+    if(!ret)
+    	return KErrGeneral;
+    //todo check EFalse
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldIsOutputL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldIsOutputL( )
+    {
+    CField* field = CreateCFieldL();
+    CField::TType type = CField::EOutput;
+    field->SetType(type);
+    TBool ret = field->IsOutput();
+    if(!ret)
+    	return KErrGeneral;
+    //todo check EFalse
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// FieldIsFeatureL()
+// ---------------------------------------------------------------------------
+//
+TInt CtGenericHIDAPI::FieldIsFeatureL( )
+    {    
+    CField* field = CreateCFieldL();
+    CField::TType type = CField::EFeature;
+    field->SetType(type);
+    TBool ret = field->IsFeature();
+    if(!ret)
+    	return KErrGeneral;
+    //todo check EFalse
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CountryCodeL()
+// ---------------------------------------------------------------------------
+//
+TUint CtGenericHIDAPI::CountryCodeL(TInt /*aConnID*/)
+    {    
+    return 0;
+    }
+
+// ---------------------------------------------------------------------------
+// VendorIdL
+// ---------------------------------------------------------------------------
+//
+TUint CtGenericHIDAPI::VendorIdL(TInt /*aConnID*/)
+    {
+    return 0x0421;
+    }
+
+// ---------------------------------------------------------------------------
+// ProductIdL
+// ---------------------------------------------------------------------------
+//
+TUint CtGenericHIDAPI::ProductIdL(TInt /*aConnID*/)
+    {    
+    return 0x0083;
+    }
+
+// ---------------------------------------------------------------------------
+// GetProtocolL
+// ---------------------------------------------------------------------------
+//
+void CtGenericHIDAPI::GetProtocolL(TInt /*aConnID*/,  TUint16 /*aInterface*/)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// SetProtocolL
+// ---------------------------------------------------------------------------
+//
+void CtGenericHIDAPI::SetProtocolL(TInt /*aConnID*/, TUint16 /*aValue*/,
+        TUint16 /*aInterface*/)
+    {    
+    }
+
+// ---------------------------------------------------------------------------
+// GetReportL
+// ---------------------------------------------------------------------------
+//
+void CtGenericHIDAPI::GetReportL(TInt /*aConnID*/, TUint8 /*aReportType*/,
+        TUint8 /*aReportID*/, TUint16 /*aInterface*/, TUint16 /*aLength*/)
+    {    
+    }
+
+// ---------------------------------------------------------------------------
+// SetReportL
+// ---------------------------------------------------------------------------
+//
+void CtGenericHIDAPI::SetReportL(TInt /*aConnID*/, TUint8 /*aReportType*/,TUint8 /*aReportID*/,
+    TUint16 /*aInterface*/, const TDesC8& /*aReport*/)
+    {    
+    }
+
+// ---------------------------------------------------------------------------
+// DataOutL()
+// ---------------------------------------------------------------------------
+//
+void CtGenericHIDAPI::DataOutL(TInt /*aConnID*/, TUint8 /*aReportID*/,
+        TUint16 /*aInterface*/, const TDesC8& /*aReport*/)
+    {    
+    }
+
+// ---------------------------------------------------------------------------
+// GetIdleL
+// ---------------------------------------------------------------------------
+//
+void CtGenericHIDAPI::GetIdleL(TInt /*aConnID*/, TUint8 /*aReportID*/,
+        TUint16 /*aInterface*/)
+    {    
+    }
+
+// ---------------------------------------------------------------------------
+// SetIdleL
+// ---------------------------------------------------------------------------
+//
+void CtGenericHIDAPI::SetIdleL(TInt /*aConnID*/,  TUint8 /*aDuration*/, TUint8 /*aReportID*/,
+        TUint16 /*aInterface*/)
+    {    
+    }
+
+const CField* CtGenericHIDAPI::CreateConstCFieldL()
+	{
+    CReportRoot* tmp=iGenHID->ReportDescriptor(0);  
+    User::LeaveIfNull(tmp);
+    const CCollection* collection = tmp->CollectionByIndex(0);
+    if(collection == NULL)
+    	User::Leave(KErrGeneral);
+    const CField* field=collection->FieldByIndex(0);
+	return field;
+	}
+
+CField* CtGenericHIDAPI::CreateCFieldL()
+	{
+	return (CField*)CreateConstCFieldL();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/generichid/tsrc/GenericHidTest/src/timer.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,83 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  HID Heaset plugin timeouttimer
+*
+*/
+
+
+#include "timer.h"
+
+// ======== MEMBER FUNCTIONS ========
+// ---------------------------------------------------------------------------
+// NewL
+// ---------------------------------------------------------------------------
+//
+CWaitTimer* CWaitTimer::NewL( TTimeIntervalMicroSeconds32 aTimeOutTime )
+    {
+    CWaitTimer* self = CWaitTimer::NewLC( aTimeOutTime );
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// NewLC
+// ---------------------------------------------------------------------------
+//    
+CWaitTimer* CWaitTimer::NewLC( TTimeIntervalMicroSeconds32 aTimeOutTime )
+    {
+    CWaitTimer* self = new (ELeave) CWaitTimer();
+    CleanupStack::PushL(self);
+    self->ConstructL( aTimeOutTime );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CTimeOutTimer()
+// ---------------------------------------------------------------------------
+//
+CWaitTimer::CWaitTimer():
+    CTimer( EPriorityStandard )    
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CWaitTimer::~CWaitTimer()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CWaitTimer::ConstructL( TTimeIntervalMicroSeconds32 aTimeOutTime  )
+    {
+    CTimer::ConstructL();
+    CActiveScheduler::Add(this);
+    After( aTimeOutTime );
+    iSyncWaiter.Start();
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive
+// RunL()
+// ---------------------------------------------------------------------------
+//
+void CWaitTimer::RunL()
+    {
+    // Timer request has completed, so notify the timer's owner
+    iSyncWaiter.AsyncStop();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for project ?myapp
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+#include "../locod/group/bld.inf"
+#include "../dun/group/bld.inf"
+#include "../generichid/group/bld.inf"
+#include "../headset/group/bld.inf"
+
+PRJ_EXPORTS
+
+
+PRJ_MMPFILES
+
+PRJ_TESTMMPFILES
+
+PRJ_TESTEXPORTS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/data/hidheadset.rss	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ECOM plugin resource file for headset driver.
+*
+*/
+
+#include <ecom/registryinfo.rh>
+#include "headsetuids.h"
+
+RESOURCE REGISTRY_INFO theInfo
+	{
+	dll_uid     = HEADSET_UID; 
+	interfaces  = 
+		{
+		INTERFACE_INFO
+			{
+			interface_uid   = DRIVER_PLUGIN_IF;
+			implementations = 
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid  = HEADSET_DRIVER_IMP; 
+					version_no          = 1;
+					display_name        = "HID Headset Driver Plugin"; 
+					}
+				};
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for project headset
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_MMPFILES
+hidheadset.mmp
+
+PRJ_PLATFORMS
+WINSCW ARMV5
+
+#include "../hidremconbearer/group/bld.inf"
+
+PRJ_EXPORTS
+../rom/hidheadset.iby CORE_MW_LAYER_IBY_EXPORT_PATH(hidheadset.iby)
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/group/headset.mrp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+component	headset
+
+source \sf\mw\remoteconn\localconnectivityservice\headset
+
+notes_source	\component_defs\release.src
+
+ipr E 
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/group/hidheadset.mmp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project hidheadset
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include "../inc/headsetuids.h"
+
+TARGET        hidheadset.dll
+TARGETTYPE    PLUGIN
+UID           ECOM_UID HEADSET_UID
+
+CAPABILITY    CAP_APPLICATION CommDD ProtServ
+VENDORID      VID_DEFAULT
+
+SOURCEPATH    ../src
+SOURCE        headset.cpp
+SOURCE        finder.cpp
+SOURCE        hidheadsetdriverproxy.cpp
+SOURCE        keypresstimer.cpp
+
+START RESOURCE          ../data/hidheadset.rss
+    TARGET                  hidheadset.rsc  
+END // ECOM resource definition
+
+USERINCLUDE   ../inc ../hidremconbearer/inc
+
+#ifdef NO101APPDEPFIXES
+APP_LAYER_SYSTEMINCLUDE
+#else   //NO101APPDEPFIXES
+MW_LAYER_SYSTEMINCLUDE
+#endif  //NO101APPDEPFIXES
+SYSTEMINCLUDE  ../../../inc
+
+LIBRARY       euser.lib
+LIBRARY       ecom.lib
+LIBRARY       generichid.lib
+LIBRARY       etel3rdparty.lib
+LIBRARY       alarmclient.lib
+LIBRARY       mpxplaybackutility.lib
+LIBRARY       mpxcommon.lib
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/hidremconbearer/data/hidremconbearer.rss	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,54 @@
+/*
+* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource definitions for project hidremconbearer
+*
+*/
+
+
+//  INCLUDES
+#include <ecom/registryinfov2.rh>
+#include "headsetuids.h"
+ 
+//  RESOURCE DEFINITIONS 
+// -----------------------------------------------------------------------------
+//   
+// REGISTRY_INFO theInfo
+// Information needed for Ecom Plugin
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE REGISTRY_INFO theInfo
+	{
+	resource_format_version = RESOURCE_FORMAT_VERSION_2;
+	dll_uid = HIDREMCON_UID;
+	interfaces =
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = REMCON_PLUGIN_IF;
+			implementations =
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = HIDREMCON_IMP;
+					version_no = 1;
+					display_name = "HidRemconBearer";
+					default_data = "";
+					opaque_data = "";
+					}
+				};
+			}
+		};
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/hidremconbearer/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2007-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for project hidremconbearer
+*
+*/
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+hidremconbearer.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/hidremconbearer/group/hidremconbearer.mmp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2007-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project hidremconbearer
+*
+*/
+
+#include <data_caging_paths.hrh>
+#include <remcon/remconservercaps.mmh>
+#include <platform_paths.hrh>
+#include "../../inc/headsetuids.h"
+
+
+TARGET			hidremconbearer.dll
+
+// CAPABILITY      CAP_ECOM_PLUGIN 
+// capabilities are required as that of remconbearerplugin.dll
+// getting it from #include <remcon/remconservercaps.mmh>
+
+TARGETTYPE		PLUGIN
+UID 			0x10009d8d HIDREMCON_UID
+VENDORID		VID_DEFAULT
+
+SOURCEPATH		../src
+SOURCE			hidremconbearermain.cpp
+SOURCE			hidremconbearerimplementation.cpp
+SOURCE			hidremconbearerobserver.cpp
+
+
+START RESOURCE ../data/hidremconbearer.rss
+TARGET hidremconbearer.rsc
+END // ECOM resource definition
+
+
+USERINCLUDE 	. ../inc ../../inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY 		euser.lib 
+LIBRARY			ecom.lib
+LIBRARY 		remconbearerplugin.lib 
+LIBRARY 		remcontypes.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/hidremconbearer/inc/debug.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,174 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Logging definition
+*
+*/
+
+#ifndef DEBUG_H
+#define DEBUG_H
+
+#include "debugconfig.h"
+
+#ifdef PRJ_ENABLE_TRACE
+
+#ifdef PRJ_FILE_TRACE
+#include <flogger.h>
+#else
+#include <e32debug.h>
+#endif
+
+const TInt KMaxLogLineLength = 512;
+
+#define KPRINTERROR        0x00000001 // Tracing level: error
+#define KPRINTINFO        0x00000002 // Tracing level: function trace
+#define KPRINTSTATE        0x00000004 // Tracing level: state machine info
+#define KPRINTWARNING   0x00000008 // Tracing level: warning
+
+const TInt KTraceMask = KPRINTERROR | KPRINTINFO | KPRINTSTATE | KPRINTWARNING;
+
+NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow
+    {
+public:
+    void Overflow(TDes16& /*aDes*/) {}
+    };
+
+NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow
+    {
+public:
+    void Overflow(TDes8& /*aDes*/) {}
+    };
+
+inline void Trace(TRefByValue<const TDesC16> aFmt, ...)
+    {
+    VA_LIST list;
+    VA_START(list,aFmt);
+#ifdef PRJ_FILE_TRACE
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+#else
+    TBuf16<KMaxLogLineLength> theFinalString;
+    theFinalString.Append(KTracePrefix16);
+    TOverflowTruncate16 overflow;
+    theFinalString.AppendFormatList(aFmt,list,&overflow);
+    RDebug::Print(theFinalString);
+#endif
+    }
+
+inline void Trace(TRefByValue<const TDesC8> aFmt, ...)
+    {
+    VA_LIST list;
+    VA_START(list, aFmt);
+#ifdef PRJ_FILE_TRACE
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+#else
+    TOverflowTruncate8 overflow;
+    TBuf8<KMaxLogLineLength> buf8;
+    buf8.Append(KTracePrefix8);
+    buf8.AppendFormatList(aFmt, list, &overflow);
+    TBuf16<KMaxLogLineLength> buf16(buf8.Length());
+    buf16.Copy(buf8);
+    TRefByValue<const TDesC> tmpFmt(_L("%S"));
+    RDebug::Print(tmpFmt, &buf16);
+#endif
+    }
+
+inline void TracePanic(
+    char* aFile, 
+    TInt aLine,
+    TInt aPanicCode,
+    const TDesC& aPanicCategory)
+    {
+    TPtrC8 fullFileName((const TUint8*)aFile);
+    TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1);
+    TBuf8<KMaxLogLineLength> buf;
+    buf.Append(KPanicPrefix8);
+    buf.AppendFormat(_L8("%d at line %d in file %S"), aPanicCode, aLine, &fileName);
+    Trace(buf);
+    User::Panic(aPanicCategory, aPanicCode); 
+    }
+
+inline void TraceLeave(char* aFile, TInt aLine, TInt aReason)
+    {
+    TPtrC8 fullFileName((const TUint8*)aFile);
+    TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1);
+    TBuf8<KMaxLogLineLength> buf;
+    buf.Append(KLeavePrefix8);
+    buf.AppendFormat(_L8("%d at line %d in file %S"), aReason, aLine, &fileName);
+    Trace(buf);
+    User::LeaveIfError(aReason);
+    }
+
+#define TRACE_INFO(p) {if(KTraceMask & KPRINTINFO) Trace p;}
+
+#define TRACE_ERROR(p) {if(KTraceMask & KPRINTERROR) Trace p;}
+
+#define TRACE_STATE(p) {if(KTraceMask & KPRINTSTATE) Trace p;}
+
+#define TRACE_WARNING(p) {if(KTraceMask & KPRINTWARNING) Trace p;}
+
+#define TRACE_INFO_SEG(p) {if(KTraceMask & KPRINTINFO) p;}
+
+#define TRACE_ASSERT(GUARD, CODE) {if (!(GUARD)) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory);}
+
+#define PANIC(CODE) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory)
+
+#define LEAVE_IF_ERROR(REASON) {if (REASON) TraceLeave(__FILE__, __LINE__, REASON);}
+
+#define LEAVE(REASON) {TraceLeave(__FILE__, __LINE__, REASON);}
+
+#define TRACE_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryFormat8, &ptr8);}}
+
+#define TRACE_FUNC_ENTRY_THIS {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryThisFormat8, &ptr8, this);}}
+
+#define TRACE_FUNC_EXIT {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncExitFormat8, &ptr8);}}
+
+#define TRACE_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncFormat8, &ptr8);}}
+
+#define TRACE_FUNC_THIS {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncThisFormat8, &ptr8, this);}}
+
+#define RETURN_IF_ERR(ERR) {if(ERR) {TPtrC8 ptr8((TUint8*)__FILE__); Trace(_L8(" RETURN %d at file %S line %d"), ERR, &ptr8, __LINE__); return ERR;}}
+
+#else // PRJ_ENABLE_TRACE not defined
+
+#define TRACE_INFO(p)
+
+#define TRACE_ERROR(p)
+
+#define TRACE_STATE(p)
+
+#define TRACE_WARNING(p)
+
+#define TRACE_INFO_SEG(p)
+
+#define TRACE_ASSERT(GUARD, CODE)
+
+#define PANIC(CODE) {User::Panic(KPanicCategory, CODE);}
+
+#define LEAVE_IF_ERROR(REASON) {static_cast<void>(User::LeaveIfError(REASON));}
+
+#define LEAVE(REASON) {static_cast<void>(User::Leave(REASON));}
+
+#define TRACE_FUNC_ENTRY
+
+#define TRACE_FUNC_ENTRY_THIS
+
+#define TRACE_FUNC_EXIT
+
+#define TRACE_FUNC
+
+#define TRACE_FUNC_THIS
+
+#define RETURN_IF_ERR(ERR) {if(ERR) return ERR;}
+#endif // PRJ_ENABLE_TRACE
+
+#endif // PRJ_LOGGING_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/hidremconbearer/inc/debugconfig.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project configure file.
+*
+*/
+
+#ifndef DEBUGCONFIG_H
+#define DEBUGCONFIG_H
+
+#include "prjconfig.h"
+
+
+/**
+ * Custom logging variations.
+ */
+#ifdef PRJ_FILE_TRACE
+_LIT(KLogFile,"hidremcon.txt");
+_LIT(KLogDir,"hidremcon");
+#endif
+
+#ifdef PRJ_ENABLE_TRACE
+_LIT(KTracePrefix16, "[hidremcon] ");
+_LIT8(KTracePrefix8, "[hidremcon] ");
+_LIT8(KFuncFormat8, "><%S");
+_LIT8(KFuncThisFormat8, "><%S, [0x%08X]");
+_LIT8(KFuncEntryFormat8, ">%S");
+_LIT8(KFuncEntryThisFormat8, ">%S, [0x%08X]");
+_LIT8(KFuncExitFormat8, "<%S");
+
+_LIT(KPanicCategory, "hidremcon");    
+_LIT8(KPanicPrefix8, "PANIC code ");
+_LIT8(KLeavePrefix8, "LEAVE code ");
+#endif
+
+#endif // REMCONBEARER_DEBUGCONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/hidremconbearer/inc/hidremconbearerimplementation.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,287 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declaration of class CHidRemconBearer.
+ *
+*/
+
+
+#ifndef C_HIDREMCONBEARER_H
+#define C_HIDREMCONBEARER_H
+
+#include <e32base.h>
+#include <c32comm.h>
+#include <e32property.h>
+#include <remcon/remconbearerplugin.h>
+#include <remcon/remconbearerinterface.h>
+#include <remcon/messagetype.h>
+#include <AknCapServerClient.h>
+
+#include "hidremconbearerobserver.h"
+
+//CONSTANTS
+const TInt KDataBufferSize = 10;
+
+/**
+ *  CHidRemconBearer
+ *  Implementation of the Rem Con Bearer Plugin
+ * 
+ */
+class CHidRemconBearer : public CRemConBearerPlugin,
+        public MRemConBearerInterface,
+        public MCallBackReceiver
+    {
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param  aParams required for the CRemConBearerPlugin
+     * @return hidremconbearer plugin
+     */
+    static CHidRemconBearer* NewL( TBearerParams& aParams );
+
+    /**
+     * Destructor.
+     */
+    virtual ~CHidRemconBearer();
+
+private:
+
+    /**
+     * Constructor
+     * @param  aParams bearer parameters
+     */
+    CHidRemconBearer( TBearerParams& aParams );
+
+    /**
+     * Two - phase construction.
+     */
+    void ConstructL();
+
+private:
+    // from CRemConBearerPlugin
+
+    /** 
+     * From class CRemConBearerPlugin
+     * Called by RemCon server to get a pointer to an object which implements
+     * the bearer API with UID aUid. This is a mechanism for allowing future 
+     * change to the bearer API without breaking BC in existing (non-updated) 
+     * bearer plugins.
+     *         
+     * @param aUid Inteface uid
+     * @return  Return pointer to interface
+     */
+    TAny* GetInterface( TUid aUid );
+
+private:
+    // from MRemConBearerInterface
+
+    /** 
+     * From class MRemConBearerInterface
+     * Called by RemCon to retrieve a response on a connection.
+     *         
+     * @param  aInterfaceUid Inteface uid
+     * @param  aTransactionId Transaction id
+     * @param  aOperationId operation ID
+     * @param  aData API-specific message data.
+     * @param  aAddr The connection.
+     * @return Error code
+     */
+    TInt GetResponse( TUid& aInterfaceUid, TUint& aTransactionId,
+            TUint& aOperationId, RBuf8& aData, TRemConAddress& aAddr );
+
+    /** 
+     * From class MRemConBearerInterface
+     * Send Remcon command
+     *         
+     * @param  aInterfaceUid Inteface uid
+     * @param  aCommand command id
+     * @param  aTransactionId Transaction id         
+     * @param  aData API-specific message data.
+     * @param  aAddr The connection.
+     * @return Error code
+     */
+    TInt SendCommand( TUid aInterfaceUid, TUint aCommand,
+            TUint aTransactionId, RBuf8& aData, const TRemConAddress& aAddr );
+
+    /** 
+     * From class MRemConBearerInterface
+     * Get Remcon command
+     *
+     * @param  aInterfaceUid Inteface uid
+     * @param  aTransactionId Transaction id                  
+     * @param  aCommand command id
+     * @param  aData API-specific message data.
+     * @param  aAddr The connection.
+     * @return Error code
+     */
+    TInt GetCommand( TUid& aInterfaceUid, TUint& aTransactionId,
+            TUint& aCommand, RBuf8& aData, TRemConAddress& aAddr );
+
+    /** 
+     * From class MRemConBearerInterface
+     * Send Response
+     *         
+     * @param  aInterfaceUid Inteface uid
+     * @param  aOperationID operation id
+     * @param  aTransactionId Transaction id                  
+     * @param  aData API-specific message data.
+     * @param  aAddr The connection.
+     * @return Error code
+     */
+    TInt SendResponse( TUid aInterfaceUid, TUint aOperationId,
+            TUint aTransactionId, RBuf8& aData, const TRemConAddress& aAddr );
+
+    /** 
+     * From class MRemConBearerInterface
+     * Connect request
+     *         
+     * @param  aAddr The connection.         
+     */
+    void ConnectRequest( const TRemConAddress& aAddr );
+
+    /** 
+     * From class MRemConBearerInterface
+     * Disconnect request
+     *         
+     * @param  aAddr The connection.         
+     */
+    void DisconnectRequest( const TRemConAddress& aAddr );
+
+    /** 
+     * From class MRemConBearerInterface
+     * Clientstatus
+     *
+     * @param  aControllerPresent Controllerpresent status
+     * @param  aTargetPresent Target present status         
+     */
+    void ClientStatus( TBool aControllerPresent, TBool aTargetPresent );
+
+    /** 
+     * From class MRemConBearerInterface
+     * Return security policy
+     *
+     * @return Security policy
+     */
+    TSecurityPolicy SecurityPolicy() const;
+
+private:
+    // from MCallBackReceiver    
+
+    /** 
+     * From class MCallBackReceiver
+     * Return security policy
+     *
+     * @param aScanCode a scancode
+     * @param aKeyType a Keytype         
+     */
+    void ReceivedKeyEvent( TInt aScanCode, TInt aKeyType );
+
+private:
+    /** 
+     * From class MCallBackReceiver
+     * Set SVK Operation ID and Data
+     *
+     * @param aEnumValue OperationID and data field
+     */
+    void SetSVKOperationIdAndData( TInt aEnumValue );
+
+    /** 
+     * From class MCallBackReceiver
+     * Set Mute Operation ID and Data
+     *
+     * @param aEnumValue OperationID and data field         
+     */
+    void SetMuteKeyOperationIdAndData( TInt aEnumValue );
+
+    /** 
+     * From class MCallBackReceiver
+     * Set Media key Operation ID and Data
+     *
+     * @param aEnumValue OperationID and data field         
+     */
+    void SetMediaKeyOperationIdAndData( TInt aEnumValue );
+
+    /** 
+     * From class MCallBackReceiver
+     * Set Media key Operation ID and Data
+     *         
+     * @param aEnumValue OperationID and data field         
+     */
+    void SetPhoneKeyOperationIdAndData( TInt aEnumValue );
+
+    /**
+     * RestartExpired observer
+     *
+     * @param aKeyType type of key         
+     */
+    void RestartKeyObeserver( TInt aKeyType );
+
+    /**
+     * Restart Expired observer
+     *         
+     * @param aEnumValue a value of key
+     * @param aKeyType  A type of key         
+     */
+    void HandleKeyOperation( TInt aEnumValue, TInt aKeyType );
+
+private:
+    // Data
+
+    /**
+     * Interface uid of last correct-decoded message
+     */
+    TUid iInterfaceUid;
+
+    /**
+     * Operation uid of last correct-decoded message
+     */
+    TUint iOperationId;
+
+    /**
+     * Data of last correct-decoded message
+     */
+    TBuf8<KDataBufferSize> iData;
+
+    /**
+     * Transactionid uid of last correct-decoded message
+     */
+    TUint iTransactionId;
+
+    /**
+     * Media key observer
+     * Own.
+     */
+    CHidRemconBearerObserver* iMediaKeyObserver;
+
+    /**
+     * Accessory volume key observer
+     * Own.
+     */
+    CHidRemconBearerObserver* iAccessoryVolKeyObserver;
+
+    /**
+     * Mute key observer
+     * Own.
+     */
+    CHidRemconBearerObserver* iMuteKeyObserver;
+
+    /**
+     * Phone key observer
+     * Own.
+     */
+    CHidRemconBearerObserver* iHookKeyObserver;
+
+    };
+
+#endif // HIDREMCONBEARERIMPLEMENTATION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/hidremconbearer/inc/hidremconbearerinternalpskeys.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  HidRemconBearer internal Publish & Subscribe keys.
+ *
+*/
+
+
+#ifndef HIDREMCONBEARERINTERNALPSKEYS_H
+#define HIDREMCONBEARERINTERNALPSKEYS_H
+
+const TUid KPSUidHidEventNotifier =
+    {
+    0x101f9067
+    /*0x10282c19*/}; // hid event publisher uid
+
+// Media Keys Notification API
+
+const TUint32 KHidControlKeyEvent = 0x00000001;
+const TUint32 KHidAccessoryVolumeEvent = 0x00000002;
+const TUint32 KHidMuteKeyEvent = 0x00000003;
+const TUint32 KHidHookKeyEvent = 0x00000004;
+
+#endif      // __HIDREMCONBEARERINTERNALPSKEYS_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/hidremconbearer/inc/hidremconbearerobserver.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,147 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declaration of class CHidRemconBearerObserver
+ *
+*/
+
+
+#ifndef C_HIDREMCONBEAREROBSERVER_H
+#define C_HIDREMCONBEAREROBSERVER_H
+
+#include <e32svr.h>
+#include <e32property.h>
+
+/**
+ * Observer key types
+ */
+enum TObserverKeyType
+    {
+    EMediaKeys = 0, 
+    EAccessoryVolumeKeys, 
+    EMuteKey, 
+    EHookKeys
+    };
+
+/**
+ *  Call Back Receiver
+ *  On receiving event from the P & S, CHidRemconBearerObserver calls 
+ *  this function
+ * 
+ */
+class MCallBackReceiver
+    {
+public:
+    /**
+     * Called when event has arrived from P&S.
+     *  
+     * @param aEnumValue Enum value representing the key and action
+     * @param aKeyType will indicate whether it is Volume key or Media key     
+     */
+    virtual void ReceivedKeyEvent( TInt aEnumValue, TInt aKeyType ) = 0;
+    };
+
+/**
+ *  Hid remcon bearer observer
+ *  This class inplements the Active Object. There will be two instance 
+ *  of this ,one for handling Volume keys and other for Media Keys
+ * 
+ */
+class CHidRemconBearerObserver : public CActive
+    {
+public:
+    // Constructors and destructor       
+
+    /**
+     * Two-phased constructor.
+     * @param aCallback reference of the class which implements 
+     *                  MCallBackReceiver for handling call back 
+     *                  functions
+     * @param aKeyType  Indiacates whether it is side volume key or 
+     *                   media key
+     * @return remconbearer observer                   
+     */
+    static CHidRemconBearerObserver* NewL( MCallBackReceiver& aCallback,
+            TInt aKeyType );
+    /**
+     * Destructor.
+     */
+    virtual ~CHidRemconBearerObserver();
+
+public:
+    /**
+     * Start remconbearer observer key events
+     *  
+     * @return Error code
+     */
+    TInt Start();
+
+    /**
+     * Stop remconbearer observer key events
+     *
+     */
+    void Stop();
+
+private:
+    /**
+     * Two-phased constructor.
+     * @param aCallback reference of the class which implements 
+     *                  MCallBackReceiver for handling call back 
+     *                  functions
+     */
+    CHidRemconBearerObserver( MCallBackReceiver& aCallback );
+
+    /**
+     * Two-phased constructor.
+     * @param aKeyType  Indiacates whether it is side volume key or 
+     *                   media key                            
+     */
+    void ConstructL( TInt aKeyType );
+
+private:
+    // From Base class CActive       
+
+    /**
+     * From CActive
+     * Handles an active object's request completion event.
+     *         
+     */
+    void RunL();
+
+    /**
+     * From CActive
+     * Canceling outstanding request
+     *         
+     */
+    void DoCancel();
+
+private:
+    // Data
+    /**
+     * RProperty for key subscribing key values
+     */
+    RProperty iProperty;
+
+    /**
+     * Callback to request handler
+     */
+    MCallBackReceiver& iCallback;
+
+    /**
+     * Key type
+     */
+    TInt iKeyType; // Vol key or media Key
+    };
+
+#endif // HIDREMCONBEAREROBSERVER_H
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/hidremconbearer/inc/hidremconbearerscancodes.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,70 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Hid remconbearer scan codes
+ *
+*/
+
+
+#ifndef HIDREMCONBEARERBEARERSCANCODES_H
+#define HIDREMCONBEARERBEARERSCANCODES_H
+
+/**
+ *  Side volume Key Codes
+ */
+const TInt KPSVolumeDownReleased = -3;
+const TInt KPSVolumeDownPressed = -2;
+const TInt KPSVolumeDownClicked = -1;
+const TInt KPSVolumeNoKey = 0;
+const TInt KPSVolumeUpClicked = 1;
+const TInt KPSVolumeUpPressed = 2;
+const TInt KPSVolumeUpReleased = 3;
+const TInt KPSMuteClicked = 4;
+const TInt KPSMutePressed = 5;
+const TInt KPSMuteReleased = 6;
+// Hook keys keys
+const TInt KPSAnsweClicked = 1;
+const TInt KPSHangUpClicked = 2;
+const TInt KPSRedial = 3;
+const TInt KPSVoiceDial = 4;
+
+/**
+ *  Media Key codes
+ */
+enum TMediaKeyValues
+    {
+    EPlayReleased = 0,
+    EPlayPressed,
+    EPlayClicked,
+    EStopReleased,
+    EStopPressed,
+    EStopClicked,
+    EForwardReleased,
+    EForwardPressed,
+    EForwardClicked,
+    ERewindReleased,
+    ERewindPressed,
+    ERewindClicked,
+    EFastForwardReleased,
+    EFastForwardPressed,
+    EFastForwardClicked,
+    EBackwardReleased,
+    EBackwardPressed,
+    EBackwardClicked,
+    EMuteReleased,
+    EMutePressed,
+    EMuteClicked
+    };
+
+#endif // HIDREMCONBEARERBEARERSCANCODE_H
+//End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/hidremconbearer/inc/prjconfig.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project configure file.
+*
+*/
+
+
+#ifndef PRJCONFIG_H
+#define PRJCONFIG_H
+
+/**
+ * Traces are enabled via RDebug::Print() in UDEB build, by default.
+ */
+#ifdef _DEBUG
+#define PRJ_ENABLE_TRACE
+#endif
+
+/**
+ * Traces will be written to file if this is defined.
+ */
+//#define PRJ_FILE_TRACE
+
+
+/**
+ * build the project for module test purpose if this is defined
+ */
+//#define PRJ_MODULETEST_BUILD
+
+/**
+ * build the project using stubs to replace the dependencies if this is defined
+ */
+//#define PRJ_USE_STUB
+
+#endif // PRJCONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/hidremconbearer/src/hidremconbearerimplementation.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,522 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Bearer plugin API Implementation file
+ *
+*/
+
+#include <e32def.h>
+#include <remcon/remconbearerobserver.h>
+#include <remcon/remconconverterplugin.h>
+#include <remconaddress.h>
+#include <remconcoreapi.h>
+#include <RemConExtensionApi.h>
+#include <PSVariables.h>   // Property values
+#include <coreapplicationuisdomainpskeys.h>
+#include "hidremconbearerinternalpskeys.h"
+#include "hidremconbearerscancodes.h"
+#include "hidremconbearerimplementation.h"
+#include "hidremconbearerobserver.h"
+#include "debug.h"
+                                  
+_LIT8(KFormatString,"%c");
+_LIT8(KVoiceFormatString,"%d");
+_LIT_SECURITY_POLICY_C1(KHidRemconBearerReadPolicy, ECapability_None);
+_LIT_SECURITY_POLICY_C1(KHidRemconBearerWritePolicy, ECapability_None);
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CHidRemconBearer::NewL()
+// Description: Factory function.
+// return: Ownership of a new CHidRemconBearer.
+// ---------------------------------------------------------------------------
+//
+CHidRemconBearer* CHidRemconBearer::NewL( TBearerParams& aParams )
+    {
+    CHidRemconBearer* self = new ( ELeave ) CHidRemconBearer( aParams );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CHidRemconBearer::~CHidRemconBearer()
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CHidRemconBearer::~CHidRemconBearer()
+    {
+    delete iMediaKeyObserver;
+    delete iAccessoryVolKeyObserver;
+    delete iMuteKeyObserver;
+    delete iHookKeyObserver;
+    }
+
+// ---------------------------------------------------------------------------
+// CHidRemconBearer::CHidRemconBearer()
+// construction.
+// ---------------------------------------------------------------------------
+//
+CHidRemconBearer::CHidRemconBearer( TBearerParams& aParams ) :
+    CRemConBearerPlugin( aParams )
+    {
+    //Pass
+    }
+
+// ---------------------------------------------------------------------------
+// CHidRemconBearer::ConstructL()
+// 2nd-phase construction.
+// ---------------------------------------------------------------------------
+//
+void CHidRemconBearer::ConstructL()
+    {
+        TRACE_FUNC_ENTRY
+    // throw an indication up to RemCon.
+    TRemConAddress addr;
+    addr.BearerUid() = Uid();
+    TInt err = Observer().ConnectIndicate( addr );
+
+    //Define the P&S for Volume keys and Media Keys    
+    RProperty::Define( KPSUidHidEventNotifier, KHidControlKeyEvent,
+            RProperty::EInt, KHidRemconBearerReadPolicy,
+            KHidRemconBearerWritePolicy );
+    // Define P&S Key for Volume keys from Accessory device
+    RProperty::Define( KPSUidHidEventNotifier, KHidAccessoryVolumeEvent,
+            RProperty::EInt, KHidRemconBearerReadPolicy,
+            KHidRemconBearerWritePolicy );
+    // Define P&S Key for Mute key from Accessory device
+    RProperty::Define( KPSUidHidEventNotifier, KHidMuteKeyEvent,
+            RProperty::EInt, KHidRemconBearerReadPolicy,
+            KHidRemconBearerWritePolicy );
+
+    // Define P&S Key for phone keys from Accessory device
+    RProperty::Define( KPSUidHidEventNotifier, KHidHookKeyEvent,
+            RProperty::EInt, KHidRemconBearerReadPolicy,
+            KHidRemconBearerWritePolicy );
+
+    // Start Active object for listening key events from P&S
+
+    iMediaKeyObserver = CHidRemconBearerObserver::NewL( *this, EMediaKeys );
+    iAccessoryVolKeyObserver = CHidRemconBearerObserver::NewL( *this,
+            EAccessoryVolumeKeys );
+
+    iMuteKeyObserver = CHidRemconBearerObserver::NewL( *this, EMuteKey );
+
+    iHookKeyObserver = CHidRemconBearerObserver::NewL( *this, EHookKeys );
+    }
+// ---------------------------------------------------------------------------
+// CHidRemconBearer::ConnectRequest()
+// Rem Con server send connect request to Bearer Plugin
+// ---------------------------------------------------------------------------
+//
+void CHidRemconBearer::ConnectRequest( const TRemConAddress& /*aAddr*/)
+    {
+    TRACE_FUNC
+    // Pass
+    }
+// ---------------------------------------------------------------------------
+// CHidRemconBearer::DisconnectRequest()
+// Rem Con server send disconnect request to Bearer Plugin
+// ---------------------------------------------------------------------------
+//
+void CHidRemconBearer::DisconnectRequest( const TRemConAddress& /*aAddr*/)
+    {
+    TRACE_FUNC
+    // Pass
+    }
+
+// ---------------------------------------------------------------------------
+// CHidRemconBearer::SendResponse()
+// 
+// ---------------------------------------------------------------------------
+//
+TInt CHidRemconBearer::SendResponse( TUid /* aInterfaceUid */,
+        TUint /*aOperationId*/, 
+        TUint /*aTransactionId*/, // we don't care about this transaction ID
+        RBuf8& aData, 
+        const TRemConAddress& /*aAddr*/)
+    {
+    TRACE_FUNC
+    aData.Close();
+    return KErrNone;
+    }
+// ---------------------------------------------------------------------------
+// CHidRemconBearer::SendCommand()
+// 
+// ---------------------------------------------------------------------------
+//
+TInt CHidRemconBearer::SendCommand( TUid /* aInterfaceUid */,
+        TUint /* aOperationId */, TUint /* aTransactionId */,
+        RBuf8& /* aData */, const TRemConAddress& /*aAddr*/)
+    {
+    TRACE_FUNC
+    return KErrNone;
+    }
+// ---------------------------------------------------------------------------
+// CHidRemconBearer::GetResponse()
+// 
+// ---------------------------------------------------------------------------
+//
+TInt CHidRemconBearer::GetResponse( TUid& /* aInterfaceUid */,
+        TUint& /* aTransactionId*/, TUint& /* aOperationId */,
+        RBuf8& /* aData */, TRemConAddress& /*aAddr */)
+    {
+    TRACE_FUNC
+    return KErrNone;
+    }
+// ---------------------------------------------------------------------------
+// CHidRemconBearer::GetCommand()
+// 
+// ---------------------------------------------------------------------------
+//
+TInt CHidRemconBearer::GetCommand( TUid& aInterfaceUid,
+        TUint& aTransactionId, TUint& aOperationId, RBuf8& aData,
+        TRemConAddress& aAddr )
+    {
+        TRACE_FUNC
+    aInterfaceUid = iInterfaceUid;
+    aOperationId = iOperationId;
+    // Pass ownership of this to RemCon.
+    TRAPD(retTrap, aData.CreateL(iData));
+    if ( retTrap != KErrNone )
+        {
+        return retTrap;
+        }
+    aAddr.BearerUid() = Uid();
+    aAddr.Addr() = KNullDesC8();
+    aTransactionId = iTransactionId;
+    return KErrNone;
+    }
+// ---------------------------------------------------------------------------
+// CHidRemconBearer::SetSVKOperationIdAndData()
+// ---------------------------------------------------------------------------
+//
+void CHidRemconBearer::SetSVKOperationIdAndData( TInt aEnumValue )
+    {
+        TRACE_FUNC
+    // 1. Interface ID is required when Getcommand is called
+    iInterfaceUid = TUid::Uid( KRemConCoreApiUid ); // from Remconcoreapi.h
+    switch ( aEnumValue )
+        {
+        case KPSVolumeUpPressed:
+            iOperationId = ERemConCoreApiVolumeUp;
+            iData.Format( KFormatString, ERemConCoreApiButtonPress );
+            break;
+        case KPSVolumeUpReleased:
+            iOperationId = ERemConCoreApiVolumeUp;
+            iData.Format( KFormatString, ERemConCoreApiButtonRelease );
+            break;
+        case KPSVolumeUpClicked:
+            iOperationId = ERemConCoreApiVolumeUp;
+            iData.Format( KFormatString, ERemConCoreApiButtonClick );
+            break;
+        case KPSVolumeDownPressed:
+            iOperationId = ERemConCoreApiVolumeDown;
+            iData.Format( KFormatString, ERemConCoreApiButtonPress );
+            break;
+        case KPSVolumeDownReleased:
+            iOperationId = ERemConCoreApiVolumeDown;
+            iData.Format( KFormatString, ERemConCoreApiButtonRelease );
+            break;
+        case KPSVolumeDownClicked:
+            iOperationId = ERemConCoreApiVolumeDown;
+            iData.Format( KFormatString, ERemConCoreApiButtonClick );
+            break;
+        case KPSVolumeNoKey: // This should never execute
+            break;
+        default:
+            iOperationId = aEnumValue;
+            iData.Format( KFormatString, ERemConCoreApiButtonClick );
+            break;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CHidRemconBearer::SetMuteKeyOperationIdAndData
+// ---------------------------------------------------------------------------
+//
+void CHidRemconBearer::SetMuteKeyOperationIdAndData( TInt aEnumValue )
+    {
+        TRACE_INFO((_L("[HID]\tCHidRemconBearer::SetMuteKeyOperation \
+                IdAndData( %d )"), aEnumValue));
+    // 1. Interface ID is required when Getcommand is called
+    iInterfaceUid = TUid::Uid( KRemConCoreApiUid ); // from Remconcoreapi.h
+    switch ( aEnumValue )
+        {
+        case KPSMutePressed:
+            iOperationId = ERemConCoreApiMute;
+            iData.Format( KFormatString, ERemConCoreApiButtonPress );
+            break;
+        case KPSMuteReleased:
+            iOperationId = ERemConCoreApiMute;
+            iData.Format( KFormatString, ERemConCoreApiButtonRelease );
+            break;
+        case KPSMuteClicked:
+            iOperationId = ERemConCoreApiMute;
+            iData.Format( KFormatString, ERemConCoreApiButtonClick );
+            break;
+        default:
+            TRACE_INFO(_L("CHidRemconBearer::SetMuteKeyOperationIdAndData : \
+                    Not supported"))
+            ;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CHidRemconBearer::SetMediaKeyOperationIdAndData()
+// ---------------------------------------------------------------------------
+//
+void CHidRemconBearer::SetMediaKeyOperationIdAndData( TInt aEnumValue )
+    {
+        TRACE_FUNC
+    // 1. Interface ID is required when Getcommand is called
+    iInterfaceUid = TUid::Uid( KRemConCoreApiUid ); // from Remconcoreapi.h
+    switch ( aEnumValue )
+        {
+        case EPlayReleased:
+            iOperationId = ERemConCoreApiPausePlayFunction;
+            iData.Format( KFormatString, ERemConCoreApiButtonRelease );
+            break;
+        case EPlayPressed:
+            iOperationId = ERemConCoreApiPausePlayFunction;
+            iData.Format( KFormatString, ERemConCoreApiButtonPress );
+            break;
+        case EPlayClicked:
+            iOperationId = ERemConCoreApiPausePlayFunction;
+            iData.Format( KFormatString, ERemConCoreApiButtonClick );
+            break;
+        case EStopReleased:
+            iOperationId = ERemConCoreApiStop;
+            iData.Format( KFormatString, ERemConCoreApiButtonRelease );
+            break;
+        case EStopPressed:
+            iOperationId = ERemConCoreApiStop;
+            iData.Format( KFormatString, ERemConCoreApiButtonPress );
+            break;
+        case EStopClicked:
+            iOperationId = ERemConCoreApiStop;
+            iData.Format( KFormatString, ERemConCoreApiButtonClick );
+            break;
+        case EForwardReleased:
+            iOperationId = ERemConCoreApiForward;
+            iData.Format( KFormatString, ERemConCoreApiButtonRelease );
+            break;
+        case EForwardPressed:
+            iOperationId = ERemConCoreApiForward;
+            iData.Format( KFormatString, ERemConCoreApiButtonPress );
+            break;
+        case EForwardClicked:
+            iOperationId = ERemConCoreApiForward;
+            iData.Format( KFormatString, ERemConCoreApiButtonClick );
+            break;
+        case ERewindReleased:
+            iOperationId = ERemConCoreApiRewind;
+            iData.Format( KFormatString, ERemConCoreApiButtonRelease );
+            break;
+        case ERewindPressed:
+            iOperationId = ERemConCoreApiRewind;
+            iData.Format( KFormatString, ERemConCoreApiButtonPress );
+            break;
+        case ERewindClicked:
+            iOperationId = ERemConCoreApiRewind;
+            iData.Format( KFormatString, ERemConCoreApiButtonClick );
+            break;
+        case EFastForwardReleased:
+            iOperationId = ERemConCoreApiFastForward;
+            iData.Format( KFormatString, ERemConCoreApiButtonRelease );
+            break;
+        case EFastForwardPressed:
+            iOperationId = ERemConCoreApiFastForward;
+            iData.Format( KFormatString, ERemConCoreApiButtonPress );
+            break;
+        case EFastForwardClicked:
+            iOperationId = ERemConCoreApiFastForward;
+            iData.Format( KFormatString, ERemConCoreApiButtonClick );
+            break;
+        case EBackwardReleased:
+            iOperationId = ERemConCoreApiBackward;
+            iData.Format( KFormatString, ERemConCoreApiButtonRelease );
+            break;
+        case EBackwardPressed:
+            iOperationId = ERemConCoreApiBackward;
+            iData.Format( KFormatString, ERemConCoreApiButtonPress );
+            break;
+        case EBackwardClicked:
+            iOperationId = ERemConCoreApiBackward;
+            iData.Format( KFormatString, ERemConCoreApiButtonClick );
+            break;
+            // This should never execute
+        default:
+            iOperationId = aEnumValue;
+            iData.Format( KFormatString, ERemConCoreApiButtonClick );
+            break;
+
+        }
+    }
+// ---------------------------------------------------------------------------
+// CHidRemconBearer::ReceivedKeyEvent()
+// ---------------------------------------------------------------------------
+//
+void CHidRemconBearer::SetPhoneKeyOperationIdAndData( TInt aEnumValue )
+    {
+    TRACE_FUNC_ENTRY
+    iInterfaceUid = TUid::Uid( KRemConExtCallHandlingApiUid );
+    switch ( aEnumValue )
+        {
+        case KPSAnsweClicked:
+            TRACE_INFO((_L("[HID]\tCHidRemconBearer::SetPhoneKey \
+                    OperationIdAndData Answer")));
+            iOperationId = ERemConExtAnswerCall;
+            iData.Format( KFormatString, ERemConCoreApiButtonClick );
+            break;
+        case KPSHangUpClicked:
+            iOperationId = ERemConExtEndCall;
+            iData.Format( KFormatString, ERemConCoreApiButtonClick );
+            break;
+        case KPSRedial:
+            iOperationId = ERemConExtLastNumberRedial;
+            iData.Format( KFormatString, ERemConCoreApiButtonClick );
+            break;
+        case KPSVoiceDial:
+            iOperationId = ERemConExtVoiceDial;
+            iData.Format( KVoiceFormatString, ERemConCoreApiButtonRelease );
+            break;
+        default:
+            TRACE_INFO(_L("CHidRemconBearer::SetPhoneKeyOperationIdAndData \
+                    : Not supported"));        }
+    TRACE_FUNC_EXIT
+    }
+// ---------------------------------------------------------------------------
+// CHidRemconBearer::ReceivedKeyEvent()
+// ---------------------------------------------------------------------------
+//
+void CHidRemconBearer::ReceivedKeyEvent( TInt aEnumValue, TInt aKeyType )
+    {
+    TRACE_INFO((_L("[HID]\tCHidRemconBearer::ReceivedKeyEvent: value %d, \
+            type %d )"), aEnumValue, aKeyType));
+
+    /* To keep the background light on */
+    User::ResetInactivityTime();
+
+    // 2. Transaction ID
+    iTransactionId = Observer().NewTransactionId();
+
+    // 3. Addr 
+    TRemConAddress addr;
+    addr.BearerUid() = Uid();
+    addr.Addr() = KNullDesC8();
+
+    // 4 & 5. Operation ID and Data
+    HandleKeyOperation( aEnumValue, aKeyType );
+
+    // Msgtype  is ERemConCommand
+    TInt error = Observer().NewCommand( addr );
+    TRACE_INFO((_L("[HID]\tCHidRemconBearer::ReceivedKeyEvent: error %d )"), 
+            error));
+    //Start the listener once again     
+    RestartKeyObeserver( aKeyType );
+
+    }
+
+// ---------------------------------------------------------------------------
+// CHidRemconBearer::RestartKeyObeserver
+// ---------------------------------------------------------------------------
+//
+void CHidRemconBearer::RestartKeyObeserver( TInt aKeyType )
+    {
+    TRACE_FUNC_ENTRY
+    switch ( aKeyType )
+        {
+        case EMediaKeys:
+            iMediaKeyObserver->Start();
+            break;
+        case EAccessoryVolumeKeys:
+            iAccessoryVolKeyObserver->Start();
+            break;
+        case EMuteKey:
+            iMuteKeyObserver->Start();
+            break;
+        case EHookKeys:
+            iHookKeyObserver->Start();
+            break;
+        default:
+            TRACE_INFO(_L("CHidRemconBearer::RestartKeyObeserver : Not supported"))
+            ;
+        }
+        TRACE_FUNC_EXIT
+    }
+
+// ---------------------------------------------------------------------------
+// CHidRemconBearer::RestartObexserver
+// ---------------------------------------------------------------------------
+//
+void CHidRemconBearer::HandleKeyOperation( TInt aEnumValue, TInt aKeyType )
+    {
+    TRACE_FUNC_ENTRY
+    switch ( aKeyType )
+        {
+        case EAccessoryVolumeKeys:
+            SetSVKOperationIdAndData( aEnumValue );
+            break;
+        case EMuteKey:
+            SetMuteKeyOperationIdAndData( aEnumValue );
+            break;
+        case EMediaKeys:
+            SetMediaKeyOperationIdAndData( aEnumValue );
+            break;
+        case EHookKeys:
+            SetPhoneKeyOperationIdAndData( aEnumValue );
+            break;
+        default:
+            TRACE_INFO(_L("CHidRemconBearer::HandleKeyOperation : Not \
+                    supported"))
+            ;
+        }
+    TRACE_FUNC_EXIT
+    }
+// ---------------------------------------------------------------------------
+// CHidRemconBearer::SecurityPolicy()
+// ---------------------------------------------------------------------------
+//
+TSecurityPolicy CHidRemconBearer::SecurityPolicy() const
+    {
+    return TSecurityPolicy( ECapabilityLocalServices );
+    }
+
+// ---------------------------------------------------------------------------
+// CHidRemconBearer::ClientStatus()
+// ---------------------------------------------------------------------------
+//
+void CHidRemconBearer::ClientStatus( TBool /*aControllerPresent*/, TBool /*aTargetPresent*/)
+    {
+        //Pass
+    TRACE_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// CHidRemconBearer::GetInterface()
+// ---------------------------------------------------------------------------
+//
+TAny* CHidRemconBearer::GetInterface( TUid aUid )
+    {
+    TRACE_FUNC
+    TAny* ret = NULL;
+    if ( aUid == TUid::Uid( KRemConBearerInterface1 ) )
+        {
+        ret = reinterpret_cast<TAny*> ( 
+                        static_cast<MRemConBearerInterface*> ( this ) );
+        }
+    return ret;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/hidremconbearer/src/hidremconbearermain.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Bearer plugin implementation proxy
+ *
+*/
+
+
+#include <ecom/implementationproxy.h>
+#include "hidremconbearerimplementation.h"
+#include "headsetuids.h"
+
+/**
+ * Implementation table
+ */
+const TImplementationProxy ImplementationTable[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY(HIDREMCON_IMP, CHidRemconBearer::NewL),
+    };
+
+// ---------------------------------------------------------------------------
+// ImplementationGroupProxy ()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/hidremconbearer/src/hidremconbearerobserver.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,156 @@
+/*
+* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Remcon bearer observer implementation
+ *
+*/
+
+
+//INCLUDE
+#include <e32def.h>
+#include <e32cmn.h>
+#include <coreapplicationuisdomainpskeys.h>
+
+#include "hidremconbearerinternalpskeys.h"
+#include "hidremconbearerobserver.h"
+#include "debug.h"
+// ======== MEMBER FUNCTIONS ========
+//
+// ---------------------------------------------------------------------------
+// CHidRemconBearerObserver::NewL()
+// Constructs a new entry with given values.
+// ---------------------------------------------------------------------------
+//
+CHidRemconBearerObserver* CHidRemconBearerObserver::NewL(
+        MCallBackReceiver& aCallback, TInt aKeyType )
+    {
+    CHidRemconBearerObserver* self = new ( ELeave ) CHidRemconBearerObserver(
+            aCallback );
+    CleanupStack::PushL( self );
+    self->ConstructL( aKeyType );
+    CleanupStack::Pop();
+    return self;
+    }
+// ---------------------------------------------------------------------------
+// CHidRemconBearerObserver::CHidRemconBearerObserver()
+// C++ constructor
+// ---------------------------------------------------------------------------
+// 
+CHidRemconBearerObserver::CHidRemconBearerObserver(
+        MCallBackReceiver& aCallback ) :
+    CActive( EPriorityStandard ), iCallback( aCallback )
+    {
+    //Pass        
+    TRACE_FUNC
+    }
+// ---------------------------------------------------------------------------
+// CHidRemconBearerObserver::CHidRemconBearerObserver()
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CHidRemconBearerObserver::~CHidRemconBearerObserver()
+    {
+    TRACE_FUNC
+    Stop();
+    if ( iProperty.Handle() != KNullHandle )
+        {
+        iProperty.Close();
+        }
+    }
+// ---------------------------------------------------------------------------
+// CHidRemconBearerObserver::ConstructL()
+// Symbian OS default constructor
+// ---------------------------------------------------------------------------
+// 
+void CHidRemconBearerObserver::ConstructL( TInt aKeyType )
+    {
+    TRACE_FUNC
+    iKeyType = aKeyType;
+    // Add this active object to the scheduler.
+    CActiveScheduler::Add( this );
+    switch ( iKeyType )
+        {
+        case EMediaKeys:
+            User::LeaveIfError( iProperty.Attach( KPSUidHidEventNotifier,
+                    KHidControlKeyEvent ) );
+            break;
+        case EAccessoryVolumeKeys:
+            User::LeaveIfError( iProperty.Attach( KPSUidHidEventNotifier,
+                    KHidAccessoryVolumeEvent ) );
+            break;
+        case EMuteKey:
+            User::LeaveIfError( iProperty.Attach( KPSUidHidEventNotifier,
+                    KHidMuteKeyEvent ) );
+            break;
+        case EHookKeys:
+            User::LeaveIfError( iProperty.Attach( KPSUidHidEventNotifier,
+                    KHidHookKeyEvent ) );
+            break;
+        default:
+            User::Leave( KErrArgument );
+        }
+    Start();
+    }
+// ---------------------------------------------------------------------------
+// CHidRemconBearerObserver::Start()
+// Starts listening KUidCurrentCall event  
+// ---------------------------------------------------------------------------
+//
+TInt CHidRemconBearerObserver::Start()
+    {
+    TRACE_FUNC
+    if ( IsActive() )
+        {
+        return KErrInUse;
+        }
+    iStatus = KRequestPending;
+    iProperty.Subscribe( iStatus );
+    SetActive();
+    return KErrNone;
+    }
+// ---------------------------------------------------------------------------
+// CHidRemconBearerObserver::Stop()
+// Stops listening KUidCurrentCall event 
+// ---------------------------------------------------------------------------
+//
+void CHidRemconBearerObserver::Stop()
+    {
+    TRACE_FUNC
+    Cancel();
+    }
+// ---------------------------------------------------------------------------
+// CHidRemconBearerObserver::RunL()
+// ---------------------------------------------------------------------------
+// 
+void CHidRemconBearerObserver::RunL()
+    {
+    TInt scanCode;
+    TInt ret = 0;
+    ret = iProperty.Get( scanCode );
+    if ( ret == KErrNone )
+        {
+        // If this Active Object is for receiving the USB MTP status, the
+        // scanCode varibale contains the status whether transfer is 
+        // happening now(active) or not(not active).    
+        iCallback.ReceivedKeyEvent( scanCode, iKeyType );
+        }
+    }
+// ---------------------------------------------------------------------------
+// CHidRemconBearerObserver::DoCancel()
+// Cancels event listening
+// ---------------------------------------------------------------------------
+// 
+void CHidRemconBearerObserver::DoCancel()
+    {
+    iProperty.Cancel();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/inc/debug.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,176 @@
+/*
+* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Logging definition
+ *
+*/
+
+
+#ifndef DEBUG_H
+#define DEBUG_H
+
+#include "debugconfig.h"
+
+#ifdef PRJ_ENABLE_TRACE
+
+#ifdef PRJ_FILE_TRACE
+#include <flogger.h>
+#else
+#include <e32debug.h>
+#endif
+
+const TInt KMaxLogLineLength = 512;
+
+#define KPRINTERROR        0x00000001 // Tracing level: error
+#define KPRINTINFO        0x00000002 // Tracing level: function trace
+#define KPRINTSTATE        0x00000004 // Tracing level: state machine info
+#define KPRINTWARNING   0x00000008 // Tracing level: warning
+const TInt KTraceMask = KPRINTERROR | KPRINTINFO | KPRINTSTATE
+        | KPRINTWARNING;
+
+NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow
+    {
+public:
+    void Overflow( TDes16& /*aDes*/)
+        {
+        }
+    };
+
+NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow
+    {
+public:
+    void Overflow( TDes8& /*aDes*/)
+        {
+        }
+    };
+
+inline void Trace( TRefByValue<const TDesC16> aFmt, ... )
+    {
+    VA_LIST list;
+    VA_START(list,aFmt);
+#ifdef PRJ_FILE_TRACE
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+#else
+    TBuf16<KMaxLogLineLength> theFinalString;
+    theFinalString.Append( KTracePrefix16 );
+    TOverflowTruncate16 overflow;
+    theFinalString.AppendFormatList( aFmt, list, &overflow );
+    RDebug::Print( theFinalString );
+#endif
+    }
+
+inline void Trace( TRefByValue<const TDesC8> aFmt, ... )
+    {
+    VA_LIST list;
+    VA_START(list, aFmt);
+#ifdef PRJ_FILE_TRACE
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+#else
+    TOverflowTruncate8 overflow;
+    TBuf8<KMaxLogLineLength> buf8;
+    buf8.Append( KTracePrefix8 );
+    buf8.AppendFormatList( aFmt, list, &overflow );
+    TBuf16<KMaxLogLineLength> buf16( buf8.Length() );
+    buf16.Copy( buf8 );
+    TRefByValue<const TDesC> tmpFmt( _L("%S"));
+    RDebug::Print( tmpFmt, &buf16 );
+#endif
+    }
+
+inline void TracePanic( char* aFile, TInt aLine, TInt aPanicCode,
+        const TDesC& aPanicCategory )
+    {
+    TPtrC8 fullFileName( (const TUint8*) aFile );
+    TPtrC8 fileName( fullFileName.Ptr() + fullFileName.LocateReverse( '\\' )
+            + 1 );
+    TBuf8<KMaxLogLineLength> buf;
+    buf.Append( KPanicPrefix8 );
+    buf.AppendFormat( _L8("%d at line %d in file %S"), aPanicCode, aLine, &fileName );
+    Trace( buf );
+    User::Panic( aPanicCategory, aPanicCode );
+    }
+
+inline void TraceLeave( char* aFile, TInt aLine, TInt aReason )
+    {
+    TPtrC8 fullFileName( (const TUint8*) aFile );
+    TPtrC8 fileName( fullFileName.Ptr() + fullFileName.LocateReverse( '\\' )
+            + 1 );
+    TBuf8<KMaxLogLineLength> buf;
+    buf.Append( KLeavePrefix8 );
+    buf.AppendFormat( _L8("%d at line %d in file %S"), aReason, aLine, &fileName );
+    Trace( buf );
+    User::LeaveIfError( aReason );
+    }
+
+#define TRACE_INFO(p) {if(KTraceMask & KPRINTINFO) Trace p;}
+
+#define TRACE_ERROR(p) {if(KTraceMask & KPRINTERROR) Trace p;}
+
+#define TRACE_STATE(p) {if(KTraceMask & KPRINTSTATE) Trace p;}
+
+#define TRACE_WARNING(p) {if(KTraceMask & KPRINTWARNING) Trace p;}
+
+#define TRACE_INFO_SEG(p) {if(KTraceMask & KPRINTINFO) p;}
+
+#define TRACE_ASSERT(GUARD, CODE) {if (!(GUARD)) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory);}
+
+#define PANIC(CODE) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory)
+
+#define LEAVE_IF_ERROR(REASON) {if (REASON) TraceLeave(__FILE__, __LINE__, REASON);}
+
+#define LEAVE(REASON) {TraceLeave(__FILE__, __LINE__, REASON);}
+
+#define TRACE_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryFormat8, &ptr8);}}
+
+#define TRACE_FUNC_ENTRY_THIS {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryThisFormat8, &ptr8, this);}}
+
+#define TRACE_FUNC_EXIT {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncExitFormat8, &ptr8);}}
+
+#define TRACE_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncFormat8, &ptr8);}}
+
+#define TRACE_FUNC_THIS {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncThisFormat8, &ptr8, this);}}
+
+#define RETURN_IF_ERR(ERR) {if(ERR) {TPtrC8 ptr8((TUint8*)__FILE__); Trace(_L8(" RETURN %d at file %S line %d"), ERR, &ptr8, __LINE__); return ERR;}}
+
+#else // PRJ_ENABLE_TRACE not defined
+#define TRACE_INFO(p)
+
+#define TRACE_ERROR(p)
+
+#define TRACE_STATE(p)
+
+#define TRACE_WARNING(p)
+
+#define TRACE_INFO_SEG(p)
+
+#define TRACE_ASSERT(GUARD, CODE)
+
+#define PANIC(CODE) {User::Panic(KPanicCategory, CODE);}
+
+#define LEAVE_IF_ERROR(REASON) {static_cast<void>(User::LeaveIfError(REASON));}
+
+#define LEAVE(REASON) {static_cast<void>(User::Leave(REASON));}
+
+#define TRACE_FUNC_ENTRY
+
+#define TRACE_FUNC_ENTRY_THIS
+
+#define TRACE_FUNC_EXIT
+
+#define TRACE_FUNC
+
+#define TRACE_FUNC_THIS
+
+#define RETURN_IF_ERR(ERR) {if(ERR) return ERR;}
+#endif // PRJ_ENABLE_TRACE
+#endif // PRJ_LOGGING_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/inc/debugconfig.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project configure file.
+*
+*/
+
+
+#ifndef DEBUGCONFIG_H
+#define DEBUGCONFIG_H
+
+#include "prjconfig.h"
+
+
+/**
+ * Custom logging variations.
+ */
+#ifdef PRJ_FILE_TRACE
+_LIT(KLogFile,"headset.txt");
+_LIT(KLogDir,"headset");
+#endif
+
+#ifdef PRJ_ENABLE_TRACE
+_LIT(KTracePrefix16, "[headset] ");
+_LIT8(KTracePrefix8, "[headset] ");
+_LIT8(KFuncFormat8, "><%S");
+_LIT8(KFuncThisFormat8, "><%S, [0x%08X]");
+_LIT8(KFuncEntryFormat8, ">%S");
+_LIT8(KFuncEntryThisFormat8, ">%S, [0x%08X]");
+_LIT8(KFuncExitFormat8, "<%S");
+
+_LIT(KPanicCategory, "headsetS");    
+_LIT8(KPanicPrefix8, "PANIC code ");
+_LIT8(KLeavePrefix8, "LEAVE code ");
+#endif
+
+#endif // HEADSET_DEBUGCONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/inc/finder.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,141 @@
+/*
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Hid headset field finder 
+ *
+*/
+
+#ifndef T_FINDER_H
+#define T_FINDER_H
+
+#include <e32std.h>
+#include "hidreportroot.h"
+
+/**
+ * Headset finder
+ *
+ * Field finder for the consumer/multimedia keys field.
+ *
+ */
+class THeadsetFinder : public MHidFieldFinder
+    {
+public:
+    // From MHidFieldFinder
+    /**
+     * From MHidFieldFinder
+     * Called by THidFieldSearch::SearchL() during traversal of the
+     * report descriptor tree when a CCollection is encountered. It
+     * will be called once, and only once, for every CCollection in the
+     * descriptor. It is not called for the root collection
+     * (the CReportRoot).
+     *     
+     * @param aCollection A pointer to the collection object.     
+     * @return ETrue if the contents of this collection (any child CField
+     *         or CCollection objects) should be examined.  A driver would return
+     *         EFalse if a collection was not of a compatible type, for
+     *         example if the usage page was inappropriate.
+     */
+    virtual TBool BeginCollection( const CCollection *aCollection );
+
+    /**
+     * From MHidFieldFinder
+     * Called by THidFieldSearch::SearchL() during traversal of the
+     * report descriptor tree when all CFields and child CCollections
+     * of a CCollection have been examined.  It will be called once,
+     * and only once, for every CCollection in the descriptor. It is
+     * not called for the root collection (the CReportRoot).
+     *     
+     * @param aCollection Collection pointer
+     * @return ETrue if the search (tree traversal) should
+     *         continue. A driver returns EFalse if it has finished examining
+     *         the whole descriptor, in general this will be if it has
+     *         established that it is compatible with the report descriptor.
+     */
+    virtual TBool EndCollection( const CCollection *aCollection );
+
+    /**
+     * From MHidFieldFinder
+     * Called once for each CField in a CCollection by
+     * THidFieldSearch::SearchL() during the traversal of a report
+     * descriptor tree.
+     *     
+     * @param aField THe pointer to field     
+     */
+    virtual void Field( const CField* aField );
+
+public:
+
+    /** 
+     * Constructor 
+     */
+    THeadsetFinder();
+
+    /**
+     * Check whether supported fields has been found.
+     *     
+     * @return ETrue if it has.
+     */
+    TBool Found() const;
+
+    /**
+     * Check whether a given field contains the consumer usages.
+     *     
+     * @param aField Pointer to the field to test.
+     * @return ETrue if it does.
+     */
+    TBool IsConsumer( const CField* aField ) const;
+
+    /**
+     * Check whether a given field contains the telephony usages.
+     *     
+     * @param aField Pointer to the field to test.
+     * @return ETrue if it does.
+     */
+    TBool IsTelephony( const CField* aField ) const;
+
+    /**
+     * Reset the field pointer array
+     *
+     */
+    void EmptyList();
+
+    /**
+     * Returns number of supported fields.
+     *
+     * @return Field count
+     */
+    TInt FieldCount();
+
+    /**
+     * Read the field pointer from array at specified index
+     *     
+     * @param aIndex Index to the field pointer array
+     * @return Pointer to the desired field
+     */
+    CField* GetFieldAtIndex( TInt aIndex );
+
+private:
+
+    /**
+     *  Pointer to the top level application collection being searched. 
+     *  Not own.
+     */
+    const CCollection* iAppCollection;
+
+    /**
+     *  Array of field pointers:
+     *  Not own.
+     */
+    RPointerArray<CField> iFieldList;
+    };
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/inc/headset.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,523 @@
+/*
+* Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Hid headset driver 
+ *
+*/
+
+
+#ifndef C_HIDHEADSETDRIVER_H
+#define C_HIDHEADSETDRIVER_H
+
+#include <e32std.h>
+#include <asclisession.h>
+#include <mpxplaybackutility.h>
+#include <mpxplaybackobserver.h>
+#include <mpxmessage.h>
+#include <hidinterfaces.h>
+#include <hidtranslate.h>
+#include "keypresstimer.h"
+
+class CField;
+class CHidHeadsetDriver;
+class CTelephony;
+
+/**
+ *  Scan status
+ */
+enum TScanStatus
+    {
+    EScanNotPressed, EScanPressed, EScanLongPress
+    };
+
+/**
+ * HID headset driver class
+ *
+ * HidDriver interface for handlign headset related 
+ * functionality.
+ *
+ */
+
+class CHidHeadsetDriver : public CHidDriver,
+        public MTimerNotifier,
+        public MMPXPlaybackObserver
+    {
+
+private:
+    /**
+     *  Initialisation states 
+     */
+    enum THeadsetDriverState
+        {
+        EUninitialised, // Driver has not been initialised 
+        EInitialised, // Driver is initialised 
+        EDisabled
+        // The driver will not respond to interrupt data 
+        };
+
+    /**
+     * Hook handling
+     */
+    enum THookHandling
+        {
+        EOnHook, EOffHook, ENoHook
+        };
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aHid The generic HID layer that requested the driver     
+     */
+    static CHidHeadsetDriver* NewL( MDriverAccess* aHid );
+
+    /**
+     * Two-phased constructor.
+     * @param aHid The generic HID layer that requested the driver     
+     */
+    static CHidHeadsetDriver* NewLC( MDriverAccess* aHid );
+
+    /**
+     * Destructor
+     */
+    virtual ~CHidHeadsetDriver();
+
+private:
+
+    // from base class CHidDriver
+    /**     
+     * From class CHidDriver
+     * Called by the Generic HID layer to see if the driver can is able to
+     * use reports from a newly-connected device. Supported hid fields van 
+     * be later request with SupportedFieldCount function
+     *  
+     * @param aReportRoot HID report descriptor
+     * @return KErrNone The driver will handle reports from the report 
+     *         descriptor and KErrHidUnrecognised The driver cannot 
+     *         handle reports from the device
+     */
+    TInt CanHandleReportL( CReportRoot* aReportRoot );
+
+    /**     
+     * From class CHidDriver
+     * Called by the Generic HID layer when a device has been removed, prior
+     * to the driver being removed.  This allows the driver to notify any 
+     * applications of disconnection, if required
+     *     
+     * @param aReason The reason for device disconnection     
+     */
+    void Disconnected( TInt aReason );
+
+    /**     
+     * From class CHidDriver
+     * Called by the Generic HID layer when data has been received from the 
+     * device handled by this driver. 
+     *     
+     * @param aChannel The channel on which the data was received 
+     *                                   (as defined by the transport layer)
+     * @param aPayload A pointer to the data buffer     
+     */
+    TInt DataIn( CHidTransport::THidChannelType aChannel,
+            const TDesC8& aPayload );
+
+    /**     
+     * From class CHidDriver
+     * Called by the transport layers to inform the generic HID of the 
+     * success of the last Set... command. 
+     *     
+     * @param aCmdAck Status of the last Set... command     
+     */
+    void CommandResult( TInt aCmdAck );
+
+    /**     
+     * From class CHidDriver
+     * Called after a driver is sucessfully created by the Generic HID, when 
+     * a device is connected 
+     *     
+     * @param aConnectionId An number used to identify the device in
+     *                      subsequent calls from the driver to the 
+     *                      generic HI     
+     */
+    void InitialiseL( TInt aConnectionId );
+
+    /**     
+     * From class CHidDriver
+     * Resets the internal state of the driver (any pressed keys are released) 
+     * and enables the driver  
+     *     
+     * @param aConnectionId An number used to identify the device in
+     *                      subsequent calls from the driver to the 
+     *                      generic HI     
+     */
+    void StartL( TInt aConnectionId );
+
+    /**     
+     * From class CHidDriver
+     * Cancels all pressed keys and disables the driver (so it will not
+     * process interrupt data)  
+     *
+     */
+    void Stop();
+
+    /**
+     * From class CHidDriver
+     * Return count of supported fields
+     *          
+     * @return Number of supported fields
+     */
+    TInt SupportedFieldCount();
+
+    /**
+     * From class CHidDriver
+     * Set input handling registy 
+     *          
+     * @param aHandlingReg  a Input handling registry     
+     */
+    void SetInputHandlingReg( CHidInputDataHandlingReg* aHandlingReg );
+
+    // from base class MTimerNotifier    
+    /**     
+     * From class MTimerNotifier
+     * The function to be called when a timeout occurs.
+     *     
+     * @param aTimerType a Type of timer
+     */
+    void TimerExpired( TTimerType aTimerType );
+
+    /**
+     *  From class MMPXPlaybackObserver
+     *  Handle playback message.    
+     *   
+     *  @param aMsg playback message, ownership not transferred. 
+     *         Please check aMsg is not NULL before using it. If aErr is not 
+     *         KErrNone, plugin might still call back with more info in the 
+     *         aMsg.
+     *  @param aErr system error code.
+     */
+    void HandlePlaybackMessage( CMPXMessage* aMsg, TInt /*aErr*/);
+
+private:
+    /**
+     * Constructor
+     * @param aHid The generic HID layer that requested the driver 
+     */
+    CHidHeadsetDriver( MDriverAccess* aHid );
+    /**
+     * ConstructL
+     */
+    void ConstructL();
+
+private:
+
+    /**
+     * Called from within DataIn to handle interrupt and control channel data
+     *
+     * @param aPayload a Payload data
+     * @return error if data can't be handled
+     */
+    TInt InterruptData( const TDesC8& aPayload );
+
+    /**
+     * Handles the report
+     *
+     * @param aReport HID report descriptor
+     * @param aField HID field
+     * @return KErrNotSupported if report can't be handled
+     */
+    TInt HandleReport( const TDesC8& aReport, const CField* aField );
+
+    /**
+     * Handles the report
+     *
+     * @param aReportTranslator Report Translator
+     */
+    void ReleasePressedKeys( TReportTranslator& aReportTranslator );
+
+    /**
+     * Handle hook key pres
+     *     
+     * @param aStatus Hook key status
+     */
+    void HookKeyPres( TBool aStatus );
+
+    /**
+     * Release hook key 
+     *
+     */
+    void ReleaseHookKey();
+
+    /**
+     * Get Hook Status
+     *     
+     * @return hook handling status. 
+     */
+    THookHandling HookStatus();
+
+    /**
+     * Get alarm status
+     *     
+     * @return ETrue if ui is showing alarm, EFalse if not. 
+     */
+    TBool AlarmStatus();
+
+    /**
+     * MusicPlayingStatus
+     *    
+     * @return ETrue if plyaer is playing, EFalse if not. 
+     */
+    TBool MusicPlayingStatus();
+
+    /**
+     * HandleNoneHookPress
+     * Handle hook press when there are phone call is in idle state
+     *      
+     */
+    void HandleNoneHookPressL();
+
+    /**
+     * ReleasePressedVolumeKeys
+     * Release volume keys if they are pressed
+     *     
+     * @param aReportTranslator HID report translator
+     */
+    void ReleasePressedVolumeKeys( TReportTranslator& aReportTranslator );
+
+    /**
+     * ReleasePressedScanKeys
+     * Release scan keys if they are pressed
+     *     
+     * @param aReportTranslator HID report report translator     
+     */
+    void ReleasePressedScanKeys( TReportTranslator& aReportTranslator );
+    /**
+     * HandleAlarmHookReleaseL
+     * Handle hook release when phone is alarming
+     *     
+     */
+    void HandleAlarmHookReleaseL();
+
+    /**
+     * HandleIdleHookReleaseL
+     * Handle hook release when phone is not alarming 
+     * and call is in idle state
+     *  
+     */
+    void HandleIdleHookReleaseL();
+
+    /**
+     * Handle doubleclick timer expiration
+     *      
+     */
+    void ExpiredDoubleClickTimer();
+
+    /**
+     * Handle long press timer expiration
+     *      
+     */
+    void ExpiredLongClickTimer();
+
+    /**
+     * Handle scan next pressed
+     *      
+     */
+    void HandleScanNextPressL();
+
+    /**
+     * Handle scan prev pressed
+     *      
+     */
+    void HandleScanPrevPressL();
+
+    /**
+     * Handle scan next release  
+     *   
+     * @param aKeyCode a Key id
+     * @param aValue  a Key value      
+     */
+    void HandleScanNextRelease( TUint& aKeyCode, TInt& aValue );
+
+    /**
+     * Handle scan previous release  
+     *    
+     * @param aKeyCode a Key id
+     * @param aValue a Key value    
+     */
+    void HandleScanPreviousRelease( TUint& aKeyCode, TInt& aValue );
+
+    /**
+     * Handle telephony usage page
+     *   
+     * @param aReport a Report translator
+     * @return KErrNone if report can be handled.  
+     */
+    TInt HandleTelephonyUsage( TReportTranslator& aReport );
+
+    /**
+     * Handle controller usage page
+     *    
+     * @param aReport a Report translator
+     * @return KErrNone if report can be handled.  
+     */
+    TInt HandleControlUsage( TReportTranslator& aReport );
+
+    /**
+     * Handle volume usage
+     *    
+     * @param aReport a Report translator
+     * @return KErrNone if report can be handled.  
+     */
+    TInt HandleVolumeUsage( TReportTranslator& aReport );
+
+private:
+
+    /**
+     * The Generic HID layer
+     * Not own.
+     */
+    MDriverAccess *iGenericHid;
+
+    /**
+     * Field list array
+     * Own. 
+     */
+    RPointerArray<CField> iFieldList;
+
+    /**
+     * Driver state
+     */
+    THeadsetDriverState iDriverState;
+
+    /**
+     * Connection id
+     */
+    TInt iConnectionId;
+
+    /**
+     * Application menu id 
+     */
+    TInt iAppMenuId;
+
+    /**
+     * On hook status 
+     */
+    TBool iOnHookPressed;
+
+    /**
+     * Off hook 
+     */
+    TBool iOffHookPressed;
+
+    /**
+     * No active calls
+     */
+    TBool iNoneHookPressed;
+
+    /**
+     * Telephony service
+     * Own.
+     */
+    CTelephony* iTelephony;
+
+    /**
+     * Double click timer
+     * Own.
+     */
+    CKeyPressTimer* iDoubleClicktimer;
+
+    /**
+     * Long click timer
+     * Own.
+     */
+    CKeyPressTimer* iLongClicktimer;
+
+    /**
+     * Long click timer     
+     */
+    TBool iLongPress;
+
+    /**
+     * Alarm server session     
+     */
+    RASCliSession iAlarmServerSession;
+
+    /**
+     * Incoming call status
+     */
+     TBool iIncomingCallStatus;
+
+    /**
+     * Alarm statusd     
+     */
+    TBool iAlarmStatus;
+
+    /**
+     * Music player utility
+     * Own.     
+     */
+    MMPXPlaybackUtility* iMusicPlayer;
+
+    /**
+     * Playing status     
+     */
+    TBool iPlayingStatus;
+
+    /**
+     * Double next Click  status
+     */
+    TBool iDoubleNextClick;
+
+    /**
+     * Count of supported fields
+     */
+    TInt iSupportedFieldCount;
+
+    /**
+     * Volume up key pressed down
+     */
+    TBool iVolumeUpPressed;
+
+    /**
+     * Volume down key pressed down
+     */
+    TBool iVolumeDownPressed;
+
+    /**
+     * Forward press status
+     */
+    TScanStatus iForwardStatus;
+
+    /**
+     * Backward press status
+     */
+    TScanStatus iBackwardStatus;
+
+    /**
+     * Scan next timer
+     * Own.
+     */
+    CKeyPressTimer* iScanNextTimer;
+
+    /**
+     * Scan previous timer
+     * Own.
+     */
+    CKeyPressTimer* iScanPreviousTimer;
+
+    /**
+     * Input handling reg
+     * Not own.
+     */
+    CHidInputDataHandlingReg* iInputHandlingReg;
+
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/inc/headsetuids.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Hid headset driver 
+ *
+*/
+
+
+#ifndef HEADSETUIDS_H
+#define HEADSETUIDS_H
+
+#define ECOM_UID            0x10009d8d
+#define REMCON_PLUGIN_IF    0x10204546
+#define HEADSET_UID         0x10282c15
+#define HEADSET_DRIVER_IMP  0x10282c16
+#define HIDREMCON_UID       0x10282c17
+#define HIDREMCON_IMP       0x10282c18
+#define DRIVER_PLUGIN_IF    0x10201d26
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/inc/keypresstimer.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,120 @@
+/*
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Hid timeout timer
+ *
+*/
+
+#ifndef C_KEYPRESSTIMER_H
+#define C_KEYPRESSTIMER_H
+
+#include <e32base.h>
+
+enum TTimerType
+    {
+    EDoubleClickTimer,
+    ELongPressTimer,
+    EScanNextPressTimer,
+    EScanPrevPressTimer
+    };
+
+/**
+ * HID headset driver class
+ *
+ * This class specifies the function to be called when a timeout occurs.
+ * Used in conjunction with CTimeOutTimer class
+ * 
+ */
+class MTimerNotifier
+    {
+public:
+    /**     
+     * The function to be called when a timeout occurs.
+     *     
+     * @param aTimerType a Type of timer
+     */
+    virtual void TimerExpired( TTimerType aTimerType ) = 0;
+    };
+
+/**
+ * HID headset driver class
+ *
+ * This class will notify an object after a specified timeout.
+ *
+ */
+class CKeyPressTimer : public CTimer
+    {
+public:
+    /**
+     * Two-phased constructor.     
+     * @param aTimeOutNotify object to notify of timeout event
+     * @param aTimeOutTime a Timeout time
+     * @paran aTimerType a Type of timer
+     * @return keypress timer
+     */
+    static CKeyPressTimer* NewL( MTimerNotifier* aTimeOutNotify,
+            TTimeIntervalMicroSeconds32 aTimeOutTime, TTimerType aTimerType );
+
+    /**
+     * Two-phased constructor.
+     * @param aTimeOutNotify object to notify of timeout event
+     * @param aTimeOutTime a Timeout time
+     * @paran aTimerType a Type of timer
+     * @return keypress timer 
+     */
+    static CKeyPressTimer* NewLC( MTimerNotifier* aTimeOutNotify,
+            TTimeIntervalMicroSeconds32 aTimeOutTime, TTimerType aTimerType );
+
+    /**
+     * Destructor
+     */
+    virtual ~CKeyPressTimer();
+
+protected:
+
+    /**
+     * From CTimer
+     * Invoked when a timeout occurs
+     *     
+     */
+    virtual void RunL();
+
+private:
+
+    /**
+     * Constructor
+     * @param aTimeOutNotify object to notify of timeout event
+     * @paran aTimerType a Type of timer
+     */
+    CKeyPressTimer( MTimerNotifier* aTimeOutNotify, TTimerType aTimerType );
+    /**
+     * Two-phased constructor.     
+     * @param aTimeOutTime a Timeout time     
+     */
+    void ConstructL( TTimeIntervalMicroSeconds32 aTimeOutTime );
+
+private:
+    // Member variables
+
+    /**
+     *  The observer for this objects events
+     *  Not own. 
+     */
+    MTimerNotifier* iNotify;
+
+    /**
+     * Type of timer
+     */
+    TTimerType iTimerType;
+    };
+#endif // C_KEYPRESSTIMER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/inc/prjconfig.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project configure file.
+ *
+*/
+
+
+#ifndef PRJCONFIG_H
+#define PRJCONFIG_H
+
+/**
+ * Traces are enabled via RDebug::Print() in UDEB build, by default.
+ */
+#ifdef _DEBUG
+#define PRJ_ENABLE_TRACE
+#endif
+
+/**
+ * Traces will be written to file if this is defined.
+ */
+//#define PRJ_FILE_TRACE
+
+
+/**
+ * build the project for module test purpose if this is defined
+ */
+//#define PRJ_MODULETEST_BUILD
+
+/**
+ * build the project using stubs to replace the dependencies if this is defined
+ */
+//#define PRJ_USE_STUB
+
+#endif // OBEXSM_PRJCONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/rom/hidheadset.iby	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Image description file for project  generichid 
+*
+*/
+
+
+#ifndef HIDHEADSET_IBY__
+#define HIDHEADSET_IBY__
+
+ECOM_PLUGIN(hidheadset.dll, hidheadset.rsc)
+ECOM_PLUGIN(hidremconbearer.dll, hidremconbearer.rsc)
+
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/src/finder.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,244 @@
+/*
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Generic hid finder implementation
+ *
+*/
+
+
+#include <e32std.h>
+#include <e32svr.h>
+
+#include "finder.h"
+#include "debug.h"
+
+// ----------------------------------------------------------------------
+
+// Define this for additional debug output (this file only):
+#define EXTRA_DEBUG
+
+#ifdef EXTRA_DEBUG
+#define DBG(a) a;
+#else
+#define DBG(a)
+#endif
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// THeadsetFinder()
+// ---------------------------------------------------------------------------
+//
+THeadsetFinder::THeadsetFinder() :
+    iAppCollection( 0 ), iFieldList()
+    {
+    // Nothing else to do
+    }
+
+// --------------------------------------------------------------------------
+// From class MHidFieldFinder
+// BeginCollection()
+// --------------------------------------------------------------------------
+//
+TBool THeadsetFinder::BeginCollection( const CCollection* aCollection )
+    {
+    TBool examineCollection = ETrue;
+
+    const TInt KConsumerControl = 0x01;
+
+    // Only look at top-level application (consumer devices: consumer
+    // control) collections:
+    //
+
+    if ( ( aCollection->IsApplication() ) && ( iAppCollection == 0 ) )
+        {
+        // Top-level application collection.
+
+        if ( ( aCollection->UsagePage() == EUsagePageConsumer )
+                && ( aCollection->Usage() == KConsumerControl ) )
+            {
+            TRACE_INFO(_L("[HID]\tTHeadsetFinder::BeginCollection: this is \
+                    consumer collection "));
+            // Collection is a consumer device:
+            iAppCollection = aCollection;
+            iFieldList.Reset();
+            }
+        else
+            {
+            TRACE_INFO(_L("[HID]\tTHeadsetFinder::BeginCollection: not \
+                    consumer collection"));
+            // Skip other types of top-level application collection:
+            examineCollection = EFalse;
+            }
+        }
+    return examineCollection;
+
+    }
+
+// ---------------------------------------------------------------------------
+// From class MHidFieldFinder
+// EndCollection()
+// ---------------------------------------------------------------------------
+//
+TBool THeadsetFinder::EndCollection( const CCollection* aCollection )
+    {
+    TBool continueSearch = ETrue;
+
+    TRACE_INFO(_L("[HID]\tTHeadsetFinder::EndCollection"));
+    if ( aCollection == iAppCollection )
+        {
+        // Top-level application(Consumer Devices:Consumer Control) finished:
+        //
+        iAppCollection = 0;
+
+        // Stop if we've found a device we can use in this
+        // application collection:
+        //
+        continueSearch = !Found();
+        }
+
+    return continueSearch;
+    }
+
+// ---------------------------------------------------------------------------
+// From class MHidFieldFinder
+// Field()
+// ---------------------------------------------------------------------------
+//
+void THeadsetFinder::Field( const CField* aField )
+    {
+    TRACE_INFO((_L("[HID]\tTHeadsetFinder::Field( 0x%08x)"),aField));
+    TInt error = KErrNone;
+    if ( iAppCollection )
+        {
+
+        if ( IsTelephony( aField ) )
+            {
+            TRACE_INFO((_L("[HID]\tTHeadsetFinder::Field, telephony")));
+            error = iFieldList.Append( aField );
+            if ( error != KErrNone )
+                {
+                TRACE_INFO((_L("[HID]\tTHeadsetFinder::Field, telephony \
+                        failed")));
+                }
+            }
+        else if ( IsConsumer( aField ) )
+            {
+            TRACE_INFO(_L("[HID]\tTHeadsetFinder::Field, consumer"));
+            error = iFieldList.Append( aField );
+            if ( error != KErrNone )
+                {
+                TRACE_INFO((_L("[HID]\tTHeadsetFinder::Field, telephony \
+                        failed")));
+                }
+            }
+        else
+            {
+            TRACE_INFO(_L("[HID]\tTHeadsetFinder::Field, other, or empty \
+                    field"));
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// IsConsumer()
+// ---------------------------------------------------------------------------
+//
+TBool THeadsetFinder::IsConsumer( const CField* aField ) const
+    {
+    TBool found = EFalse;
+
+    if ( aField->IsInput() && aField->IsData() && ( aField->UsagePage()
+            == EUsagePageConsumer ) )
+        {
+#ifdef _DEBUG
+        for ( TInt i = 0; i < aField->UsageCount(); i++ )
+            {
+            TRACE_INFO((_L("[HID]\tTHeadsetFinder::IsConsumer: Usage %d: \
+                    %02x"),i,aField->Usage(i)));
+            }
+#endif
+            // *** Add usage test here ***
+        TRACE_INFO(_L("[HID]\tTHeadsetFinder::IsConsumer:  Consumer keys \
+                field found\r\n"));
+        found = ETrue;
+        }
+    return found;
+    }
+
+// ---------------------------------------------------------------------------
+// IsTelephony()
+// ---------------------------------------------------------------------------
+//
+TBool THeadsetFinder::IsTelephony( const CField* aField ) const
+    {
+    TBool found = EFalse;
+
+    if ( aField->IsInput() && aField->IsData() && ( aField->UsagePage()
+            == EUsagePageTelephony ) )
+        {
+        const TInt KHookSwitch = 0x20;
+        const TInt KPhoneMute = 0x2F;
+#ifdef _DEBUG
+        for ( TInt i = 0; i < aField->UsageCount(); i++ )
+            {
+            TRACE_INFO((_L("[HID]\tTHeadsetFinder::IsTelephony: \
+                    Usage %d: %02x"),i,aField->Usage(i)));
+            }
+#endif
+        if ( ( aField->UsageMin() <= KPhoneMute ) && ( aField->UsageMax()
+                >= KHookSwitch ) )
+            {
+            TRACE_INFO(_L("[HID]\tTHeadsetFinder::IsTelephony:  Telephony \
+                    field found"));
+            found = ETrue;
+            }
+        }
+    return found;
+    }
+
+// ---------------------------------------------------------------------------
+// EmptyList()
+// ---------------------------------------------------------------------------
+//
+void THeadsetFinder::EmptyList()
+    {
+    iFieldList.Reset();
+    }
+
+// ---------------------------------------------------------------------------
+// FieldCount()
+// ---------------------------------------------------------------------------
+//
+TInt THeadsetFinder::FieldCount()
+    {
+    return iFieldList.Count();
+    }
+
+// ---------------------------------------------------------------------------
+// GetFieldAtIndex()
+// ---------------------------------------------------------------------------
+//
+CField* THeadsetFinder::GetFieldAtIndex( TInt aIndex )
+    {
+    return iFieldList[aIndex];
+    }
+
+// ---------------------------------------------------------------------------
+// Found()
+// ---------------------------------------------------------------------------
+//
+TBool THeadsetFinder::Found() const
+    {
+    return ( iFieldList.Count() != 0 );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/src/headset.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,1222 @@
+/*
+* Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Generic hid implementation
+ *
+*/
+
+
+#include <etel3rdparty.h>
+#include <e32std.h>
+#include <e32svr.h>
+#include <coedef.h>
+#include <eiksvdef.h>
+#include <apgcli.h>
+#include <apgtask.h>
+#include <e32property.h>
+#ifdef NO101APPDEPFIXES
+#include <alarmuidomainpskeys.h>
+#else   //NO101APPDEPFIXES
+const TUid KPSUidAlarmExtCntl = { 0x102072D4 }; // reusing an AlarmUI dll UID
+const TUint32 KAlarmStopKey = 0x00000001;
+enum TAlarmUIStopAlarm
+    {
+    EAlarmUIStopAlarmUninitialized = 0,
+    EAlarmUIStopAlarm
+    };
+const TUint32 KAlarmSnoozeKey = 0x00000002;
+enum TAlarmUISnoozeAlarm
+    {
+    EAlarmUISnoozeAlarmUninitialized = 0,
+    EAlarmUISnoozeAlarm
+    };
+#endif  //NO101APPDEPFIXES
+
+#include <mpxplaybackmessage.h>
+#include <mpxmessagegeneraldefs.h>
+#include <mpxplaybackmessagedefs.h>
+
+#include "hidremconbearerinternalpskeys.h"
+#include "hidremconbearerscancodes.h"
+#include "headset.h"
+#include "finder.h"
+
+#include "debug.h"
+
+const TInt KHidUndefinedKeyCode = 0;
+const TInt KHidNotSetKeyValue = 0;
+const TInt KDoubleClickTimeout = 900000; // 0,9 seconds
+const TInt KDoubleClickTimeoutRing = 500000; // 0,5 seconds
+const TInt KScanClickTimeout = 500000; // 0,5 seconds
+const TInt KLongClickTimeout = 3000000; // 3 seconds
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CHidHeadsetDriver()
+// ---------------------------------------------------------------------------
+//
+CHidHeadsetDriver::CHidHeadsetDriver( MDriverAccess* aGenericHid ) :
+    iGenericHid( aGenericHid ), iFieldList(), iDriverState( EUninitialised ),
+            iConnectionId( 0 ), iSupportedFieldCount( 0 ), iForwardStatus(
+                    EScanNotPressed ), iBackwardStatus( EScanNotPressed )
+    {
+    TRACE_FUNC_ENTRY_THIS
+    TRACE_FUNC_EXIT
+    }
+
+// ---------------------------------------------------------------------------
+// NewLC
+// ---------------------------------------------------------------------------
+//
+CHidHeadsetDriver* CHidHeadsetDriver::NewLC( MDriverAccess* aGenericHid )
+    {
+    TRACE_INFO((_L("[HID]\tCHidHeadsetDriver::NewLC(0x%08x)"), aGenericHid));
+    CHidHeadsetDriver* self = new ( ELeave ) CHidHeadsetDriver( aGenericHid );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// NewL
+// ---------------------------------------------------------------------------
+//
+CHidHeadsetDriver* CHidHeadsetDriver::NewL( MDriverAccess* aGenericHid )
+    {
+    CHidHeadsetDriver* self = CHidHeadsetDriver::NewLC( aGenericHid );
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CHidHeadsetDriver::ConstructL()
+    {
+    TRACE_FUNC_THIS
+    iTelephony = CTelephony::NewL();
+    User::LeaveIfError( iAlarmServerSession.Connect() );
+    iMusicPlayer = MMPXPlaybackUtility::UtilityL( KPbModeActivePlayer );
+    iMusicPlayer->AddObserverL( *this );
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CHidHeadsetDriver::~CHidHeadsetDriver()
+    {
+    TRACE_FUNC_THIS
+    iAlarmServerSession.Close();
+    delete iTelephony;
+    iFieldList.Reset();
+    iFieldList.Close();
+    delete iDoubleClicktimer;
+    if ( iMusicPlayer )
+        {
+        iMusicPlayer->Close();
+        }
+    delete iScanPreviousTimer;
+    delete iScanNextTimer;
+    delete iLongClicktimer;
+    }
+
+// ---------------------------------------------------------------------------
+// From class CHidDriver
+// StartL()
+// ---------------------------------------------------------------------------
+//
+void CHidHeadsetDriver::StartL( TInt /*aConnectionId*/)
+    {
+    TRACE_FUNC
+    // Ready to process headset events:
+    iDriverState = EInitialised;
+    }
+
+// ---------------------------------------------------------------------------
+// From class CHidDriver
+// InitialiseL()
+// ---------------------------------------------------------------------------
+//
+void CHidHeadsetDriver::InitialiseL( TInt aConnectionId )
+    {
+    TRACE_FUNC
+    TRACE_INFO((_L("[HID]\tCHidHeadsetDriver::InitialiseL(%d)"),
+                        aConnectionId));
+    // Store the connection ID:
+    iConnectionId = aConnectionId;
+    }
+
+// ---------------------------------------------------------------------------
+// From class CHidDriver
+// Stop()
+// ---------------------------------------------------------------------------
+//
+void CHidHeadsetDriver::Stop()
+    {
+    TRACE_FUNC
+    iDriverState = EDisabled;
+    }
+
+// ---------------------------------------------------------------------------
+// From class CHidDriver
+// DataIn()
+// ---------------------------------------------------------------------------
+//
+TInt CHidHeadsetDriver::DataIn( CHidTransport::THidChannelType aChannel,
+        const TDesC8& aPayload )
+    {
+    TInt retVal = KErrNone;
+    switch ( aChannel )
+        {
+        case CHidTransport::EHidChannelInt:
+            if ( EInitialised == iDriverState )
+                {
+                retVal = InterruptData( aPayload );
+                }
+            break;
+
+        case CHidTransport::EHidChannelCtrl:
+            retVal = KErrNotSupported;
+            break;
+
+        default:
+            retVal = KErrNotSupported;
+            break;
+        }
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// From class CHidDriver
+// CommandResult()
+// ---------------------------------------------------------------------------
+//
+void CHidHeadsetDriver::CommandResult( TInt /*aCmdAck*/)
+    {
+    // No implementation as we don't issue any requests to be acknowledged
+    }
+
+// ---------------------------------------------------------------------------
+// From class CHidDriver
+// Disconnected()
+// ---------------------------------------------------------------------------
+//
+void CHidHeadsetDriver::Disconnected( TInt aReason )
+    {
+    TRACE_INFO((_L("[HID]\tCHidHeadsetDriver::Disconnected(%d)"), aReason));
+    aReason = aReason;
+    Stop();
+    }
+
+// ---------------------------------------------------------------------------
+// From class CHidDriver
+// SetInputHandlingReg()
+// ---------------------------------------------------------------------------
+//
+void CHidHeadsetDriver::SetInputHandlingReg(
+        CHidInputDataHandlingReg* aHandlingReg )
+    {
+    iInputHandlingReg = aHandlingReg;
+    }
+
+// ---------------------------------------------------------------------------
+// From class CHidDriver
+// InterruptData()
+// ---------------------------------------------------------------------------
+//
+TInt CHidHeadsetDriver::InterruptData( const TDesC8& aPayload )
+    {
+    // If the report has a report ID, it is in the first byte.
+    // If not, this value is ignored (see CField::IsInReport()).
+    //
+    TInt retVal = KErrNone;
+    TInt ret = KErrNotSupported;
+    TInt firstByte = aPayload[0];
+
+    TRACE_INFO((_L("[HID]\tCHidHeadsetDriver::InterruptData(), report \
+            0x%x (%d), length %d"),firstByte, firstByte, aPayload.Length()));
+
+    if ( iFieldList.Count() == 0 )
+        {
+        retVal = KErrNotSupported;
+        }
+    for ( TInt i = 0; i < iFieldList.Count(); i++ )
+        {
+        if ( iFieldList[i]->IsInReport( firstByte ) )
+            {
+            ret = HandleReport( aPayload, iFieldList[i] );
+            if ( ret == KErrNone )
+                {
+                retVal = KErrNone;
+                }
+            }
+        else
+            {
+            retVal = KErrNotSupported;
+            }
+        }
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleReport()
+// ---------------------------------------------------------------------------
+//
+TInt CHidHeadsetDriver::HandleReport( const TDesC8& aReport,
+        const CField* aField )
+    {
+    TRACE_FUNC_ENTRY
+    TReportTranslator report( aReport, aField );
+    TInt retVal = KErrNotSupported;
+
+    // release if key if it pressed and relased
+    ReleasePressedKeys( report );
+
+    if ( HandleTelephonyUsage( report ) == KErrNone )
+        {
+        retVal = KErrNone;
+        }
+
+    if ( HandleControlUsage( report ) == KErrNone )
+        {
+        retVal = KErrNone;
+        }
+
+    if ( HandleVolumeUsage( report ) == KErrNone )
+        {
+        retVal = KErrNone;
+        }
+    TRACE_FUNC_EXIT
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleTelephonyUsage()
+// ---------------------------------------------------------------------------
+//
+TInt CHidHeadsetDriver::HandleTelephonyUsage( TReportTranslator& aReport )
+    {
+    TRACE_FUNC_ENTRY
+    TInt retVal = KErrNotSupported;
+    TInt hookSwitch = 0;
+    TInt mute = 0;
+    TInt poc = 0;
+
+    // P&S key variables
+    TUint key = KHidUndefinedKeyCode;
+    TInt value = KHidNotSetKeyValue;
+
+    if ( aReport.GetValue( mute, ETelephonyUsagePhoneMute ) == KErrNone
+            && mute == 1 )
+        {
+        TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): Send mute \
+                command"));
+        if ( iInputHandlingReg->AllowedToHandleEvent( EUsagePageTelephony,
+                ETelephonyUsagePhoneMute ) )
+            {
+            key = KHidMuteKeyEvent;
+            value = KPSMuteClicked;
+            iInputHandlingReg->AddHandledEvent( EUsagePageTelephony,
+                    ETelephonyUsagePhoneMute );
+            }
+        }
+    else if ( aReport.GetValue( hookSwitch, ETelephonyUsageHookSwitch )
+            == KErrNone && hookSwitch == 1 )
+        {
+        TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): Send hook \
+                switch command (disabled)"));
+        if ( iInputHandlingReg->AllowedToHandleEvent( EUsagePageTelephony,
+                ETelephonyUsageHookSwitch ) )
+            {
+            HookKeyPres( ETrue );
+            iInputHandlingReg->AddHandledEvent( EUsagePageTelephony,
+                    ETelephonyUsageHookSwitch );
+            }
+        }
+    else if ( aReport.GetValue( poc, ETelephonyUsagePoC ) == KErrNone && poc
+            == 1 )
+        {
+        TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): Send PoC \
+                command (disabled)"));
+        if ( iInputHandlingReg->AllowedToHandleEvent( EUsagePageTelephony,
+                ETelephonyUsagePoC ) )
+            {
+            key = KHidMuteKeyEvent;
+            value = KPSMuteClicked;
+            iInputHandlingReg->AddHandledEvent( EUsagePageTelephony,
+                    ETelephonyUsagePoC );
+            }
+        }
+    if ( key != KHidUndefinedKeyCode && value != KHidNotSetKeyValue )
+        {
+        TInt err = RProperty::Set( KPSUidHidEventNotifier, key, value );
+        retVal = KErrNone;
+        }
+
+    TRACE_FUNC_EXIT
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleTelephonyUsage()
+// ---------------------------------------------------------------------------
+//
+TInt CHidHeadsetDriver::HandleControlUsage( TReportTranslator& aReport )
+    {
+    TRACE_FUNC_ENTRY
+    TInt retVal = KErrNotSupported;
+    TInt playPause = 0;
+    TInt scanNext = 0;
+    TInt scanPrev = 0;
+    TInt stop = 0;
+
+    // P&S key variables
+    TUint key = KHidUndefinedKeyCode;
+    TInt value = KHidNotSetKeyValue;
+
+    if ( aReport.GetValue( playPause, EConsumerUsagePlayPause ) == KErrNone
+            && playPause )
+        {
+        if ( iInputHandlingReg->AllowedToHandleEvent( EUsagePageConsumer,
+                EConsumerUsagePlayPause ) )
+            {
+            TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): Send \
+                    play/pause command (currently only play)"));
+            key = KHidControlKeyEvent;
+            value = EPlayClicked;
+            iInputHandlingReg->AddHandledEvent( EUsagePageConsumer,
+                    EConsumerUsagePlayPause );
+            }
+        }
+    else if ( aReport.GetValue( scanNext, EConsumerUsageScanNext )
+            == KErrNone && scanNext )
+        {
+        if ( iInputHandlingReg->AllowedToHandleEvent( EUsagePageConsumer,
+                EConsumerUsageScanNext ) )
+            {
+            TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): Send \
+                    scan next command"));
+            TRAP_IGNORE( HandleScanNextPressL() );
+            iInputHandlingReg->AddHandledEvent( EUsagePageConsumer,
+                    EConsumerUsageScanNext );
+            }
+        }
+    else if ( aReport.GetValue( scanPrev, EConsumerUsageScanPrev )
+            == KErrNone && scanPrev )
+        {
+        if ( iInputHandlingReg->AllowedToHandleEvent( EUsagePageConsumer,
+                EConsumerUsageScanPrev ) )
+            {
+            TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): Scan \
+                    prev command"));
+            TRAP_IGNORE( HandleScanPrevPressL());
+            iInputHandlingReg->AddHandledEvent( EUsagePageConsumer,
+                    EConsumerUsageScanPrev );
+            }
+        }
+    else if ( aReport.GetValue( stop, EConsumerUsageStop ) == KErrNone
+            && stop )
+        {
+        if ( iInputHandlingReg->AllowedToHandleEvent( EUsagePageConsumer,
+                EConsumerUsageStop ) )
+            {
+            TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): Send \
+                    stop command"));
+            key = KHidControlKeyEvent;
+            value = EStopClicked;
+            iInputHandlingReg->AddHandledEvent( EUsagePageConsumer,
+                    EConsumerUsageScanPrev );
+            }
+        }
+    if ( key != KHidUndefinedKeyCode && value != KHidNotSetKeyValue )
+        {
+        TInt err = RProperty::Set( KPSUidHidEventNotifier, key, value );
+        retVal = KErrNone;
+        }
+
+    TRACE_FUNC_EXIT
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleVolumeUsage()
+// ---------------------------------------------------------------------------
+//
+TInt CHidHeadsetDriver::HandleVolumeUsage( TReportTranslator& aReport )
+    {
+    TRACE_FUNC_ENTRY
+    TInt retVal = KErrNotSupported;
+
+    TInt volUp = 0;
+    TInt volDown = 0;
+    TInt speakermute = 0;
+
+    // P&S key variables
+    TUint key = KHidUndefinedKeyCode;
+    TInt value = KHidNotSetKeyValue;
+
+    if ( aReport.GetValue( volUp, EConsumerUsageVolumeInc ) == KErrNone
+            && volUp )
+        {
+        if ( iInputHandlingReg->AllowedToHandleEvent( EUsagePageConsumer,
+                EConsumerUsageVolumeInc ) )
+            {
+            TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): \
+                    Send volume up command"));
+            key = KHidAccessoryVolumeEvent;
+            iVolumeUpPressed = ETrue;
+            value = KPSVolumeUpPressed;
+            iInputHandlingReg->AddHandledEvent( EUsagePageConsumer,
+                    EConsumerUsageScanPrev );
+            }
+        }
+    else if ( aReport.GetValue( volDown, EConsumerUsageVolumeDec )
+            == KErrNone && volDown )
+        {
+        if ( iInputHandlingReg->AllowedToHandleEvent( EUsagePageConsumer,
+                EConsumerUsageVolumeDec ) )
+            {
+            TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): Send \
+                    volume down command"));
+            key = KHidAccessoryVolumeEvent;
+            iVolumeDownPressed = ETrue;
+            value = KPSVolumeDownPressed;
+            iInputHandlingReg->AddHandledEvent( EUsagePageConsumer,
+                    EConsumerUsageVolumeDec );
+            }
+        }
+    else if ( ( aReport.GetValue( speakermute, EConsumerUsageMute )
+            == KErrNone && speakermute == 1 ) )
+        {
+        if ( iInputHandlingReg->AllowedToHandleEvent( EUsagePageConsumer,
+                EConsumerUsageMute ) )
+            {
+            TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): Send \
+                    mute command"));
+            key = KHidMuteKeyEvent;
+            value = KPSMuteClicked;
+            iInputHandlingReg->AddHandledEvent( EUsagePageConsumer,
+                    EConsumerUsageMute );
+            }
+        }
+
+    if ( key != KHidUndefinedKeyCode && value != KHidNotSetKeyValue )
+        {
+        TInt err = RProperty::Set( KPSUidHidEventNotifier, key, value );
+        retVal = KErrNone;
+        }
+
+    TRACE_FUNC_EXIT
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandleScanNextPressL()
+// ---------------------------------------------------------------------------
+//
+void CHidHeadsetDriver::HandleScanNextPressL()
+    {
+    TRACE_FUNC_ENTRY
+    iForwardStatus = EScanPressed;
+
+    delete iScanNextTimer;
+    iScanNextTimer = NULL;
+
+    /**
+     * Scan key has two different behaviour if you are short click buttun or long 
+     * click button. In short press next track command is sent and whit long press
+     * is sending seek forward command. iScanNextTimer is used to detect if click
+     * is long click or short click.
+     */
+
+    iScanNextTimer = CKeyPressTimer::NewL( this, TTimeIntervalMicroSeconds32(
+            KScanClickTimeout ), EScanNextPressTimer );
+
+    TRACE_FUNC_EXIT
+    }
+
+// ---------------------------------------------------------------------------
+// HandleScanNextPressL()
+// ---------------------------------------------------------------------------
+//
+void CHidHeadsetDriver::HandleScanPrevPressL()
+    {
+    TRACE_FUNC_ENTRY
+    iBackwardStatus = EScanPressed;
+
+    delete iScanPreviousTimer;
+    iScanPreviousTimer = NULL;
+
+    /**
+     * Scan key has two different behaviour if you are short click buttun or 
+     * long click button. In short press previous track command is sent and 
+     * whit long press is sending seek forward command. iScanPreviousTimer 
+     * is used to detect if click is long click or short click.
+     */
+    iScanPreviousTimer = CKeyPressTimer::NewL( this,
+            TTimeIntervalMicroSeconds32( KScanClickTimeout ),
+            EScanPrevPressTimer );
+    TRACE_FUNC_EXIT
+    }
+
+// ---------------------------------------------------------------------------
+// ReleasePressedVolumeKeys
+// ---------------------------------------------------------------------------
+//
+void CHidHeadsetDriver::ReleasePressedVolumeKeys(
+        TReportTranslator& aReportTranslator )
+    {
+    TInt volUp = 0;
+    TInt volDown = 0;
+    TUint key = KHidUndefinedKeyCode;
+    TInt value = KHidNotSetKeyValue;
+
+    if ( iVolumeUpPressed )
+        {
+        if ( aReportTranslator.GetValue( volUp, EConsumerUsageVolumeInc )
+                == KErrNone && volDown == 0 )
+            {
+            TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::ReleasepressedKeys(): \
+                    Volume up released"));
+            key = KHidAccessoryVolumeEvent;
+            iVolumeUpPressed = EFalse;
+            value = KPSVolumeUpReleased;
+            }
+        }
+    else if ( iVolumeDownPressed )
+        {
+        if ( aReportTranslator.GetValue( volDown, EConsumerUsageVolumeDec )
+                == KErrNone && volDown == 0 )
+            {
+            TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::ReleasepressedKeys(): \
+                    Volume downkey realeased"));
+            key = KHidAccessoryVolumeEvent;
+            iVolumeDownPressed = EFalse;
+            value = KPSVolumeDownReleased;
+            }
+        }
+    if ( key != KHidUndefinedKeyCode && value != KHidNotSetKeyValue )
+        {
+        TInt err = RProperty::Set( KPSUidHidEventNotifier, key, value );
+
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// ReleasePressedScanKeys()
+// ---------------------------------------------------------------------------
+//
+void CHidHeadsetDriver::ReleasePressedScanKeys(
+        TReportTranslator& aReportTranslator )
+    {
+    TInt scanNext = 0;
+    TInt scanPrev = 0;
+    TUint key = KHidUndefinedKeyCode;
+    TInt value = KHidNotSetKeyValue;
+
+    if ( iForwardStatus != EScanNotPressed )
+        {
+        if ( aReportTranslator.GetValue( scanNext, EConsumerUsageScanNext )
+                == KErrNone && scanNext == 0 )
+            {
+            TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): Scan \
+                    next command released"));
+            HandleScanNextRelease( key, value );
+            }
+        }
+    else if ( iBackwardStatus != EScanNotPressed )
+        {
+        if ( aReportTranslator.GetValue( scanPrev, EConsumerUsageScanPrev )
+                == KErrNone && scanPrev == 0 )
+            {
+            TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): Scan \
+                    prev command released"));
+            HandleScanPreviousRelease( key, value );
+            }
+        }
+    if ( key != KHidUndefinedKeyCode && value != KHidNotSetKeyValue )
+        {
+        TInt err = RProperty::Set( KPSUidHidEventNotifier, key, value );
+        }
+    }
+// ---------------------------------------------------------------------------
+// ReleasePressedKeys()
+// ---------------------------------------------------------------------------
+//
+void CHidHeadsetDriver::ReleasePressedKeys(
+        TReportTranslator& aReportTranslator )
+    {
+    TRACE_FUNC_ENTRY
+
+    TInt hookSwitch = 0;
+    /*
+     * Check hook key release here, because hook key long press
+     * is handled different way.
+     */
+    if ( iOnHookPressed || iOffHookPressed || iNoneHookPressed )
+        {
+        if ( aReportTranslator.GetValue( hookSwitch,
+                ETelephonyUsageHookSwitch ) == KErrNone && hookSwitch == 0 )
+            {
+            ReleaseHookKey();
+            }
+        }
+    ReleasePressedVolumeKeys( aReportTranslator );
+
+    ReleasePressedScanKeys( aReportTranslator );
+
+    TRACE_FUNC_EXIT
+    }
+
+// ---------------------------------------------------------------------------
+// HandleScanNextRelease()
+// ---------------------------------------------------------------------------
+//
+void CHidHeadsetDriver::HandleScanNextRelease( TUint& aKeyCode, TInt& aValue )
+    {
+    TRACE_FUNC_ENTRY
+    aKeyCode = KHidControlKeyEvent;
+    if ( iForwardStatus == EScanPressed )
+        {
+        aValue = EForwardClicked;
+        }
+    else //long press
+        {
+        aValue = EFastForwardReleased;
+        }
+    iForwardStatus = EScanNotPressed;
+
+    delete iScanNextTimer;
+    iScanNextTimer = NULL;
+
+    TRACE_FUNC_EXIT
+    }
+
+// ---------------------------------------------------------------------------
+// HandleScanPreviousRelease()
+// ---------------------------------------------------------------------------
+//
+void CHidHeadsetDriver::HandleScanPreviousRelease( TUint& aKeyCode,
+        TInt& aValue )
+    {
+    TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): Scan prev \
+            command released"));
+    aKeyCode = KHidControlKeyEvent;
+    if ( iBackwardStatus == EScanPressed )
+        {
+        aValue = EBackwardClicked;
+        }
+    else //long press
+        {
+        aValue = ERewindReleased;
+        }
+    iBackwardStatus = EScanNotPressed;
+
+    delete iScanPreviousTimer;
+    iScanPreviousTimer = NULL;
+
+    TRACE_FUNC_EXIT
+    }
+// ---------------------------------------------------------------------------
+// HookKeyPres()
+// ---------------------------------------------------------------------------
+//
+void CHidHeadsetDriver::HookKeyPres( TBool aStatus )
+    {
+    TRACE_FUNC_ENTRY
+
+    THookHandling hookStatus = HookStatus();
+    if ( !iAlarmStatus )
+        {
+        iAlarmStatus = AlarmStatus();
+        }
+
+    iPlayingStatus = MusicPlayingStatus();
+
+    if ( aStatus )
+        {
+        switch ( hookStatus )
+            {
+            case EOnHook:
+                if ( !iIncomingCallStatus )
+                    {
+                    // For the first click, trigger the timer 
+                    // single click is handled in ExpiredDoubleClickTimer
+                    if ( iDoubleClicktimer )
+                        {
+                        delete iDoubleClicktimer;
+                        iDoubleClicktimer = NULL;
+                        }
+                    TRAP_IGNORE( iDoubleClicktimer = CKeyPressTimer::NewL( this,
+                        TTimeIntervalMicroSeconds32( KDoubleClickTimeoutRing ),
+                        EDoubleClickTimer ) );
+                    if ( iDoubleClicktimer )
+                        {
+                        iIncomingCallStatus = ETrue;
+                        }
+                    else // If fail to create timer, handle as single click, 
+                    // for double click case, the next click will hang off
+                        {
+                        iIncomingCallStatus = EFalse;
+                        iOnHookPressed = ETrue;
+                        }
+                    break; // switch
+                    }
+                else
+                    {
+                    iIncomingCallStatus = EFalse;
+                    if ( iDoubleClicktimer )
+                        {
+                        delete iDoubleClicktimer;
+                        iDoubleClicktimer = NULL;
+                        }
+                    // This is the double click case, handle as EOffHook
+                    }
+                // No break here
+            case EOffHook:
+                TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook Off Pressed"));
+                iOffHookPressed = ETrue;
+                break;
+            case ENoHook:
+                TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook None Pressed")); 
+                TRAP_IGNORE( HandleNoneHookPressL() );                
+                break;
+            default:
+                TRACE_INFO(_L("CHidHeadsetDriver::HookKeyPres : Not \
+                        supported"));                
+            }
+        }
+    else
+        {
+        ReleaseHookKey();
+        }
+    TRACE_FUNC_EXIT
+    }
+
+// ---------------------------------------------------------------------------
+// ReleaseHookKey()
+// ---------------------------------------------------------------------------
+//
+void CHidHeadsetDriver::ReleaseHookKey()
+    {
+    TRACE_FUNC_ENTRY
+
+    if ( iOnHookPressed )
+        {
+        TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook On released"));
+        iOnHookPressed = EFalse;
+        // Incoming call
+        RProperty::Set( KPSUidHidEventNotifier, KHidHookKeyEvent,
+                KPSAnsweClicked );
+        }
+    if ( iOffHookPressed )
+        {
+        TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook Off released"));
+        iOffHookPressed = EFalse;
+        // Disconnect connected call
+        RProperty::Set( KPSUidHidEventNotifier, KHidHookKeyEvent,
+                KPSHangUpClicked );
+        }
+    if ( iNoneHookPressed && !iAlarmStatus )
+        {
+        TRAP_IGNORE( HandleIdleHookReleaseL() );
+        }
+    if ( iNoneHookPressed && iAlarmStatus )
+        {
+        TRAP_IGNORE( HandleAlarmHookReleaseL() );
+        }
+    if ( iLongClicktimer )
+        {
+        iLongPress = EFalse;
+        }
+    delete iLongClicktimer;
+    iLongClicktimer = NULL;
+    TRACE_FUNC_EXIT
+    }
+
+// ---------------------------------------------------------------------------
+// HandleNoneHook()
+// ---------------------------------------------------------------------------
+//
+void CHidHeadsetDriver::HandleNoneHookPressL()
+    {
+    TRACE_FUNC_ENTRY
+    /**  Start long press timer is alarm is ongoing, or phone
+     *   is not alarming and thre are no hook key press whitout
+     *   release
+     */
+    if ( iAlarmStatus || ( !iNoneHookPressed && !iAlarmStatus ) )
+        {
+        iNoneHookPressed = ETrue;
+        iLongPress = EFalse;
+
+        delete iLongClicktimer;
+        iLongClicktimer = NULL;
+
+        iLongClicktimer = CKeyPressTimer::NewL( this,
+                TTimeIntervalMicroSeconds32( KLongClickTimeout ),
+                ELongPressTimer );
+        }
+    TRACE_FUNC_EXIT
+    }
+
+// ---------------------------------------------------------------------------
+// HandleAlarmHookReleaseL()
+// ---------------------------------------------------------------------------
+//
+void CHidHeadsetDriver::HandleAlarmHookReleaseL()
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook None released"));
+    /**
+     * Hook key is released when there is active alarm. Start double
+     * click timer for monitoring double click.
+     */
+    if ( !iDoubleClicktimer && !iLongPress )
+        {
+        iDoubleClicktimer = CKeyPressTimer::NewL( this,
+                TTimeIntervalMicroSeconds32( KDoubleClickTimeout ),
+                EDoubleClickTimer );
+        }
+    /**
+     * Stot alar when hook key is pressed long time during alarm.
+     */
+    else if ( iLongPress )
+        {
+        TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Stop alarm"));
+        RProperty::Set( KPSUidAlarmExtCntl, KAlarmStopKey, 
+                EAlarmUIStopAlarm );
+        iAlarmStatus = EFalse;
+        iLongPress = EFalse;
+        }
+    /**
+     * Double click timer exsist and is it not long press, so 
+     * this is double click release. Then snooze alarm.
+     */
+    else if ( !iLongPress )
+        {
+        delete iDoubleClicktimer;
+        iDoubleClicktimer = NULL;
+        iAlarmStatus = EFalse;
+        TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Snooze"));
+        RProperty::Set( KPSUidAlarmExtCntl, KAlarmSnoozeKey,
+                EAlarmUISnoozeAlarm );
+        }
+    TRACE_FUNC_EXIT
+    }
+
+// ---------------------------------------------------------------------------
+// HandleIdleHookReleaseL
+// ---------------------------------------------------------------------------
+//
+void CHidHeadsetDriver::HandleIdleHookReleaseL()
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook None released"));
+    iNoneHookPressed = EFalse;
+    /**
+     * Hook key is released when there is music playing ongoing. Start double
+     * click timer for monitoring double click.
+     */
+    if ( !iDoubleClicktimer && !iLongPress )
+        {
+        iDoubleClicktimer = CKeyPressTimer::NewL( this,
+                TTimeIntervalMicroSeconds32( KDoubleClickTimeout ),
+                EDoubleClickTimer );
+        }
+    /**
+     * Hook key is released when there is not music playing ongoing. 
+     * Because double click timer is active this is second release in
+     * short beriod and redial needs to be issued.
+     */
+    else if ( !iLongPress && !iPlayingStatus )
+        {
+        delete iDoubleClicktimer;
+        iDoubleClicktimer = NULL;
+        TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Redial"));
+        RProperty::Set( KPSUidHidEventNotifier, KHidHookKeyEvent, 
+                KPSRedial );
+        }
+    /**
+     * Hook key is released when there is music playing ongoing. 
+     * Because double click timer is active, is send forward command sent
+     * and DoubleNextClick set to true for sending next command.
+     */
+    else if ( iPlayingStatus && !iLongPress )
+        {
+        delete iDoubleClicktimer;
+        iDoubleClicktimer = NULL;
+        TRACE_INFO(_L("[HID]\tCHidHeadsetDriver next after next"));
+        if ( !iLongPress )
+            {
+            iDoubleNextClick = ETrue; //set to true and when player change 
+                                      //track press next again 
+            }
+        RProperty::Set( KPSUidHidEventNotifier, KHidControlKeyEvent,
+                EForwardClicked ); //next after next
+        }
+    /**
+     * Long press release when there are no actie calls, alarms, and music
+     * playing is stopped, activates voice dialing.
+     */
+    else if ( iLongPress )
+        {
+        delete iDoubleClicktimer;
+        iDoubleClicktimer = NULL;
+        TRACE_INFO(_L("[HID]\tCHidHeadsetDriver VoiceDial"));
+        RProperty::Set( KPSUidHidEventNotifier, KHidHookKeyEvent,
+                KPSVoiceDial );
+        iLongPress = EFalse;
+        }
+    TRACE_FUNC_EXIT
+    }
+
+// ---------------------------------------------------------------------------
+// GetHookStatus()
+// ---------------------------------------------------------------------------
+//
+CHidHeadsetDriver::THookHandling CHidHeadsetDriver::HookStatus()
+    {
+    TRACE_FUNC_ENTRY
+    THookHandling retVal = EOffHook;
+    TInt ret = KErrNone;
+    CTelephony::TCallStatusV1 callStatusV1;
+    CTelephony::TCallStatusV1Pckg callStatusV1Pckg( callStatusV1 );
+    ret = iTelephony->GetLineStatus( CTelephony::EVoiceLine,
+                    callStatusV1Pckg );
+    if ( ret != KErrNone )
+        {
+        retVal = ENoHook;
+        }
+    CTelephony::TCallStatus voiceLineStatus = callStatusV1.iStatus;
+    TRACE_INFO((_L("[HID]\tCHidHeadsetDriver GetHookStatus voiceline \
+            status %d"), voiceLineStatus));
+
+    if ( voiceLineStatus == CTelephony::EStatusHold || voiceLineStatus
+            == CTelephony::EStatusRinging )
+        {
+            TRACE_INFO(_L("[HID]\tCHidHeadsetDriver GetHookStatus on hook"));
+        retVal = EOnHook;
+        }
+    else if ( voiceLineStatus == CTelephony::EStatusUnknown
+            || voiceLineStatus == CTelephony::EStatusIdle )
+        {
+            TRACE_INFO(_L("[HID]\tCHidHeadsetDriver GetHookStatus no hook"));
+        retVal = ENoHook;
+        }
+        TRACE_FUNC_EXIT
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// From class CHidDriver
+// CanHandleReportL()
+// ---------------------------------------------------------------------------
+//
+TInt CHidHeadsetDriver::CanHandleReportL( CReportRoot* aReportRoot )
+    {
+    TRACE_INFO((_L("[HID]\tCHidHeadsetDriver::CanHandleReport(0x%08x)"),
+                        aReportRoot));
+
+    THidFieldSearch search;
+
+    THeadsetFinder headsetFinder;
+    search.SearchL( aReportRoot, &headsetFinder );
+
+    iSupportedFieldCount = headsetFinder.FieldCount();
+    for ( TInt i = 0; i < headsetFinder.FieldCount(); i++ )
+        {
+        User::LeaveIfError( iFieldList.Append( headsetFinder.GetFieldAtIndex(
+                i ) ) );
+        TRACE_INFO((_L("[HID]\tCHidHeadsetDriver::CanHandleReportL, field \
+                pointer: 0x%08x"), iFieldList[i]));
+        }
+
+    TInt valid = KErrHidUnrecognised;
+
+    if ( headsetFinder.Found() )
+        {
+        valid = KErrNone;
+        }
+    // empty finder's field list before going out of scope.
+    headsetFinder.EmptyList();
+
+    TRACE_INFO((_L("[HID]\tCHidHeadsetDriver::CanHandleReport() returning \
+            %d"), valid));
+    return valid;
+    }
+
+// ---------------------------------------------------------------------------
+// From class CHidDriver
+// SupportedFieldCount
+// ---------------------------------------------------------------------------
+//
+TInt CHidHeadsetDriver::SupportedFieldCount()
+    {
+    return iSupportedFieldCount;
+    }
+// ---------------------------------------------------------------------------
+// From class MTimerNotifier
+// TimerExpired()
+// ---------------------------------------------------------------------------
+//
+void CHidHeadsetDriver::TimerExpired( TTimerType aTimerType )
+    {
+    TRACE_FUNC_ENTRY
+    switch ( aTimerType )
+        {
+        case EDoubleClickTimer:
+            ExpiredDoubleClickTimer();
+            break;
+        case ELongPressTimer:
+            ExpiredLongClickTimer();
+            break;
+        case EScanNextPressTimer:
+            iForwardStatus = EScanLongPress;
+            RProperty::Set( KPSUidHidEventNotifier, KHidControlKeyEvent,
+                    EFastForwardPressed );
+            break;
+        case EScanPrevPressTimer:
+            iBackwardStatus = EScanLongPress;
+            RProperty::Set( KPSUidHidEventNotifier, KHidControlKeyEvent,
+                    ERewindPressed );
+            break;
+        default:
+            TRACE_INFO(_L("CHidHeadsetDriver::TimerExpired : Not supported"))
+            ;
+        }
+    TRACE_FUNC_EXIT
+    }
+
+// ---------------------------------------------------------------------------
+// ExpiredDoubleClickTimer()
+// ---------------------------------------------------------------------------
+//
+void CHidHeadsetDriver::ExpiredDoubleClickTimer()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iDoubleClicktimer )
+        {
+        delete iDoubleClicktimer;
+        iDoubleClicktimer = NULL;
+        
+        if ( iIncomingCallStatus )
+            {
+            iIncomingCallStatus = EFalse;
+            iOnHookPressed = ETrue;
+            ReleaseHookKey();
+            }
+        if ( iAlarmStatus )
+            {
+            RProperty::Set( KPSUidAlarmExtCntl, KAlarmStopKey,
+                    EAlarmUIStopAlarm );
+            iAlarmStatus = EFalse;
+            }
+        if ( iPlayingStatus )
+            {
+            RProperty::Set( KPSUidHidEventNotifier, KHidControlKeyEvent,
+                    EForwardClicked );
+            iPlayingStatus = EFalse;
+            }
+        }
+    TRACE_FUNC_EXIT
+    }
+
+// ---------------------------------------------------------------------------
+// ExpiredLongClickTimer()
+// ---------------------------------------------------------------------------
+//
+void CHidHeadsetDriver::ExpiredLongClickTimer()
+    {
+    TRACE_FUNC_ENTRY
+    if ( iLongClicktimer )
+        {
+        TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::TimerExpired long click"));
+        delete iLongClicktimer;
+        iLongClicktimer = NULL;
+        iLongPress = ETrue;
+        ReleaseHookKey();
+        }
+    TRACE_FUNC_EXIT
+    }
+
+// ---------------------------------------------------------------------------
+// AlarmStatus()
+// ---------------------------------------------------------------------------
+//
+TBool CHidHeadsetDriver::AlarmStatus()
+    {
+    TRACE_FUNC_ENTRY
+    TInt activealarmcount = 0;
+    TBool retVal = EFalse;
+    activealarmcount = iAlarmServerSession.AlarmCountByState(
+            EAlarmStateNotifying );
+    if ( activealarmcount > 0 )
+        {
+        TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::AlarmStatus active alarms"));
+        retVal = ETrue;
+        }
+    else
+        {
+        TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::AlarmStatus no active \
+                alarms"));
+        retVal = EFalse;
+        }
+    TRACE_FUNC_EXIT
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// AlarmStatus()
+// ---------------------------------------------------------------------------
+//
+TBool CHidHeadsetDriver::MusicPlayingStatus()
+    {
+    TRACE_FUNC_ENTRY
+    TBool retVal = EFalse;
+    TMPXPlaybackState state = EPbStateNotInitialised;
+    TRAPD( err, state = iMusicPlayer->StateL() );
+    if ( state == EPbStatePlaying && err == KErrNone )
+        {
+        TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::MusicPlayingStatus play \
+                active"));
+        retVal = ETrue;
+        }
+    TRACE_FUNC_EXIT
+    return retVal;
+    }
+
+// ---------------------------------------------------------------------------
+// HandlePlaybackMessage
+// ---------------------------------------------------------------------------
+//
+void CHidHeadsetDriver::HandlePlaybackMessage( CMPXMessage* aMsg, TInt /*aErr*/)
+    {
+    TRACE_FUNC_ENTRY
+
+    TMPXMessageId id( aMsg->ValueTObjectL<TMPXMessageId> (
+            KMPXMessageGeneralId ) );
+    // send nect track whit double hook click when track is changed
+    if ( id == KMPXMessagePbMediaChanged && iDoubleNextClick )
+        {
+        TRACE_INFO(_L("[HID]\tHandlePlaybackMessage: PbMediaChangeg"));
+        RProperty::Set( KPSUidHidEventNotifier, KHidControlKeyEvent,
+                EForwardClicked );
+        iDoubleNextClick = EFalse;
+        }
+    TRACE_FUNC_EXIT
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/src/hidheadsetdriverproxy.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Heaset plugin implementation table
+ *
+*/
+
+
+#include <e32std.h>
+#include <ecom/implementationproxy.h>
+#include "headset.h"
+#include "headsetuids.h"
+
+// Constantshrr
+//
+const TImplementationProxy KHidHeadsetDriverProxy[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY( HEADSET_DRIVER_IMP, CHidHeadsetDriver::NewL )
+    };
+
+// ---------------------------------------------------------------------------
+// ImplementationGroupProxy
+// ---------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(
+        TInt& aTableCount )
+    {
+    aTableCount = sizeof( KHidHeadsetDriverProxy )
+            / sizeof(TImplementationProxy);
+    return KHidHeadsetDriverProxy;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/headset/src/keypresstimer.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,94 @@
+/*
+* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  HID Heaset plugin timeouttimer
+ *
+*/
+
+
+#include "keypresstimer.h"
+#include "debug.h"
+
+// ======== MEMBER FUNCTIONS ========
+// ---------------------------------------------------------------------------
+// NewL
+// ---------------------------------------------------------------------------
+//
+CKeyPressTimer* CKeyPressTimer::NewL( MTimerNotifier* aTimeOutNotify,
+        TTimeIntervalMicroSeconds32 aTimeOutTime, TTimerType aTimerType )
+    {
+    CKeyPressTimer* self = CKeyPressTimer::NewLC( aTimeOutNotify,
+            aTimeOutTime, aTimerType );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// NewLC
+// ---------------------------------------------------------------------------
+//    
+CKeyPressTimer* CKeyPressTimer::NewLC( MTimerNotifier* aTimeOutNotify,
+        TTimeIntervalMicroSeconds32 aTimeOutTime, TTimerType aTimerType )
+    {
+    CKeyPressTimer* self = new ( ELeave ) CKeyPressTimer( aTimeOutNotify,
+            aTimerType );
+    CleanupStack::PushL( self );
+    self->ConstructL( aTimeOutTime );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CTimeOutTimer()
+// ---------------------------------------------------------------------------
+//
+CKeyPressTimer::CKeyPressTimer( MTimerNotifier* aTimeOutNotify,
+        TTimerType aTimerType ) :
+    CTimer( EPriorityStandard ), iNotify( aTimeOutNotify ), iTimerType(
+            aTimerType )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CKeyPressTimer::~CKeyPressTimer()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CKeyPressTimer::ConstructL( TTimeIntervalMicroSeconds32 aTimeOutTime )
+    {
+    TRACE_FUNC
+    CTimer::ConstructL();
+    CActiveScheduler::Add( this );
+    After( aTimeOutTime );
+    }
+
+// ---------------------------------------------------------------------------
+// From class CActive
+// RunL()
+// ---------------------------------------------------------------------------
+//
+void CKeyPressTimer::RunL()
+    {
+    TRACE_FUNC
+    // Timer request has completed, so notify the timer's owner
+    if ( iNotify )
+        {
+        iNotify->TimerExpired( iTimerType );
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/commoninc/locodbearer.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Defines the LCD Bearer Plugin identifier.
+*
+*/
+
+
+#ifndef T_LOCODBEARER_H
+#define T_LOCODBEARER_H
+
+#include <e32base.h>
+
+/**  bearer value in LC */
+enum TLocodBearer
+    {
+    ELocodBearerBT =  0x0001,
+	ELocodBearerIR =  0x0010,
+	ELocodBearerUSB = 0x0100,
+    };
+
+#endif // T_LOCODBEARER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/commoninc/locodbearerplugin.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,87 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Bearer Plugin base class declaration.
+*
+*/
+
+
+#ifndef C_LOCODBEARERPLUGIN_H
+#define C_LOCODBEARERPLUGIN_H
+
+#include <e32base.h>
+#include "locodbearerpluginparams.h"
+
+/**
+ *  Bearer Plugin base class
+ *
+ *  This is the base class from which bearer plugins inherit.
+ *
+ * See locodplugin.hrh for the resource registration definitions.
+ * 
+ *  @lib euser.lib
+ *  @since S60 v3.2
+ */
+class CLocodBearerPlugin : public CBase
+    {
+public:
+
+    static CLocodBearerPlugin* NewL(TLocodBearerPluginParams& aParams);
+
+    virtual ~CLocodBearerPlugin();
+
+    /**
+     * Gets the implementation uid of this plugin
+     *
+     * @since S60 v3.2
+     * @return The implementation uid
+     */
+    TUid ImplementationUid() const;
+    
+protected:
+
+    CLocodBearerPlugin(TLocodBearerPluginParams& aParams);
+
+    /**
+     * Gets the observer interface object associated with this plugin
+     *
+     * @since S60 v3.2
+     * @return The observer object
+     */
+    MLocodBearerPluginObserver& Observer() const;
+
+private: // data
+
+    /**
+     * UID set by ECOM when the instance is created.  Used when the instance
+     * is destroyed.
+     */
+    TUid iInstanceUid;
+
+    /**
+     * Implementation UID of the concrete instance.
+     */
+    TUid iImplementationUid;
+
+    /**
+     * Holds the observer object which will be notified when the operations
+     * complete
+     * Not own.
+     */
+    MLocodBearerPluginObserver& iObserver;
+
+    };
+
+#include "locodbearerplugin.inl"
+
+#endif // C_LOCODBEARERPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/commoninc/locodbearerplugin.inl	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Bearer Plugin construction parameters
+*                declaration
+*
+*/
+
+
+#include <ecom.h>
+
+// -----------------------------------------------------------------------------
+// Creates the bearer plug ins and return it to caller
+// -----------------------------------------------------------------------------
+//
+inline CLocodBearerPlugin* CLocodBearerPlugin::NewL(TLocodBearerPluginParams& aParams)
+    {
+	CLocodBearerPlugin* self = reinterpret_cast<CLocodBearerPlugin*>(
+		REComSession::CreateImplementationL(
+			aParams.ImplementationUid(),
+			_FOFF(CLocodBearerPlugin, iInstanceUid),
+			(TAny*)&aParams)
+		);
+
+	return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+//
+inline CLocodBearerPlugin::~CLocodBearerPlugin()
+    {
+    REComSession::DestroyedImplementation(iInstanceUid);
+    }
+
+// -----------------------------------------------------------------------------
+// Return the implemtation uid
+// -----------------------------------------------------------------------------
+//
+inline TUid CLocodBearerPlugin::ImplementationUid() const
+    {
+    return iImplementationUid;
+    }
+
+// -----------------------------------------------------------------------------
+// Constructor method, just saves the arguments into member variables
+// -----------------------------------------------------------------------------
+//
+inline CLocodBearerPlugin::CLocodBearerPlugin(TLocodBearerPluginParams& aParams)
+    : iImplementationUid(aParams.ImplementationUid()),
+      iObserver(aParams.Observer())
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Return the observer class
+// -----------------------------------------------------------------------------
+//
+inline MLocodBearerPluginObserver& CLocodBearerPlugin::Observer() const
+    {
+    return iObserver;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/commoninc/locodbearerpluginobserver.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Bearer Plugin observer interface definition.
+*
+*/
+
+
+#ifndef M_LOCODBEARERPLUGINOBSERVER_H
+#define M_LOCODBEARERPLUGINOBSERVER_H
+
+#include "locodbearer.h"
+
+/**
+ *  LCD Bearer Plugin Observer interface class
+ *
+ *  This is the bearer plugin observer interface definition used by LCD
+ *  Bearer Plugins to inform the daemon about the plugin's event.
+ *
+ *  @euser.lib
+ *  @since S60 v3.2
+ */
+class MLocodBearerPluginObserver
+    {
+public:
+
+    /**
+     * This is a callback function used by the plugins to inform when the
+     * bearer's availability changes.
+     *
+     * @since S60 v3.2
+     * @param  aBearer the bearer which calls this nothification
+     * @param  aStatus the status of this bearer, ETrue if it is available;
+     *                 EFalse otherwise.
+     */
+    virtual void NotifyBearerStatus(TLocodBearer aBearer, TBool aStatus) = 0;
+    };
+
+#endif // M_LOCODBEARERPLUGINOBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/commoninc/locodbearerpluginparams.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Bearer Plugin construction parameters
+*                declaration
+*
+*/
+
+
+#ifndef T_LOCODBEARERPLUGINPARAMS_H
+#define T_LOCODBEARERPLUGINPARAMS_H
+
+class MLocodBearerPluginObserver;
+
+/**
+ *  LCD Bearer Plugin Callback construction parameters
+ *
+ *  This interface class is used to pass construction parameters to the
+ *  plugins.  These parameters include the callback interface and the ECOM 
+ *  plugin implementation UID 
+ *
+ *  @euser.lib
+ *  @since S60 v3.2
+ */
+class TLocodBearerPluginParams
+    {
+public:
+
+    /**
+     * Constructor.
+     *
+     * @since S60 v3.2
+     * @param  aUid      Implementation UID of the plugin being constructed
+     * @param  aObserver Callback interface object
+     */
+    TLocodBearerPluginParams(const TUid aUid, MLocodBearerPluginObserver& aObserver);
+
+    /**
+     * Gets the implementation UID of the plugin
+     *
+     * @since S60 v3.2
+     * @return Implementaion UID
+     */
+    TUid ImplementationUid() const;
+
+    /**
+     * Gets the observer interface object
+     *
+     * @since S60 v3.2
+     * @return The observer object
+     */
+    MLocodBearerPluginObserver& Observer() const;    
+
+private: // data
+
+    /**
+     * The implementation UID
+     */
+    const TUid iImplementationUid;
+
+    /**
+     * Reference to the observer object
+     */
+    MLocodBearerPluginObserver& iObserver;
+
+    };
+
+#include "locodbearerpluginparams.inl"
+
+#endif // T_LOCODBEARERPLUGINPARAMS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/commoninc/locodbearerpluginparams.inl	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Bearer Plugin construction parameters
+*                declaration
+*
+*/
+
+
+// -----------------------------------------------------------------------------
+// Constructor method, just saves the arguments into member variables
+// -----------------------------------------------------------------------------
+//
+inline TLocodBearerPluginParams::TLocodBearerPluginParams(const TUid aUid, MLocodBearerPluginObserver& aObserver)
+    : iImplementationUid(aUid),
+      iObserver(aObserver)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// returns the implementation UID
+// -----------------------------------------------------------------------------
+//
+inline TUid TLocodBearerPluginParams::ImplementationUid() const
+    {
+    return iImplementationUid;
+    }
+
+// -----------------------------------------------------------------------------
+// returns the  observer class
+// -----------------------------------------------------------------------------
+//
+inline MLocodBearerPluginObserver& TLocodBearerPluginParams::Observer() const
+    {
+    return iObserver;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/commoninc/locodplugin.hrh	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definitions for plugin resource registration.
+*
+*/
+
+
+#ifndef LOCODPLUGIN_HRH
+#define LOCODPLUGIN_HRH
+
+/**
+ * This file contains the defintions for plugin resource registration.
+ *
+ * All plugins should use version 2 registration resource file and set the
+ * rom_only field to 1 to prevent it from being overridden by RAM-based plugins.
+ *
+ * All bearer plugins should use KLOCODBEARERINTERFACEUID as the interface UID.
+ *
+ * A bearer plugin should use its corresponding feature ID (from features.hrh) as the
+ * implementation UID,  that is, 
+ *  Implementation UID of IR bearer is KFeatureIdIrda,
+ *  Implementation UID of BT bearer is KFeatureIdBt,
+ *  Implementation UID of USB bearer is KFeatureIdUsb.
+ *
+ * All service plugins should use KLOCODSERVICEINTERFACEUID as the interface UID.
+ *
+ * A service plugin should use its corresponding feature ID (from features.hrh) as the
+ * implementation UID,  that is, 
+ *  Implementation UID of Dun is KFeatureIdDun, (not exist yet, CR created)
+ *  Implementation UID of Obex is KFeatureIdSrcs,
+ * 
+ */
+
+// Interface UID of bearer plugins
+#define  KLOCODBEARERINTERFACEUID 0x20002771
+
+// Interface UID of service plugins
+#define  KLOCODSERVICEINTERFACEUID 0x20002772
+
+#endif // LOCODPLUGIN_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/commoninc/locodserviceplugin.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,98 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Service Plugin base class declaration.
+*
+*/
+
+
+#ifndef C_LOCODSERVICEPLUGIN_H
+#define C_LOCODSERVICEPLUGIN_H
+
+#include <e32base.h>
+
+#include "locodservicepluginparams.h"
+#include "locodbearer.h"
+    
+/**
+ *  Service Plugin base class
+ *
+ *  This is the base class from which service plugins inherit.
+ *
+ * When a service plugin is constructed, it should not start any service by default.
+ * A service is started on demand when the bearer is available.
+ *
+ *  @euser.lib
+ *  @since S60 v3.2
+ */
+class CLocodServicePlugin : public CBase
+    {
+public:
+
+    static CLocodServicePlugin* NewL(TLocodServicePluginParams& aParams);
+
+    virtual ~CLocodServicePlugin();
+
+    /**
+     * Tell service plugin which service should be enabled or disabled according to
+     * specified bearer and its status.
+     * 
+     * On completion, the plugin should call 
+     * MLocodServicePluginObserver::ManageServiceCompleted() to inform the result.
+     *
+     * @since S60 v3.2
+     * @param  aBearer the bearer identification 
+     * @param  aStatus the status of this bearer, ETrue if it is available;
+     *                 EFalse otherwise.
+     */
+    virtual void ManageService(TLocodBearer aBearer, TBool aStatus) = 0;
+
+    TUid ImplementationUid() const;
+    
+protected:
+
+    CLocodServicePlugin(TLocodServicePluginParams& aParams);
+
+    /**
+     * Gets the observer interface object associated with this plugin
+     *
+     * @since S60 v3.2
+     * @return The observer object
+     */
+    MLocodServicePluginObserver& Observer() const;
+
+private: // data
+
+    /**
+     * UID set by ECOM when the instance is created.  Used when the instance
+     * is destroyed.
+     */
+    TUid iInstanceUid;
+
+    /**
+     * Implementation UID of the concrete instance.
+     */
+    const TUid iImplementationUid;
+
+    /**
+     * Holds the observer object which will be notified when the operations
+     * complete
+     * Not own.
+     */
+    MLocodServicePluginObserver& iObserver;
+
+    };
+
+#include <locodserviceplugin.inl>
+
+#endif // C_LOCODSERVICEPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/commoninc/locodserviceplugin.inl	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Service Plugin construction parameters
+*                declaration
+*
+*/
+
+
+#include <ecom.h>
+
+// -----------------------------------------------------------------------------
+// Constructor method, just saves the arguments into member variables
+// -----------------------------------------------------------------------------
+//
+inline CLocodServicePlugin* CLocodServicePlugin::NewL(TLocodServicePluginParams& aParams)
+    {
+	CLocodServicePlugin* self = reinterpret_cast<CLocodServicePlugin*>(
+		REComSession::CreateImplementationL(
+			aParams.ImplementationUid(),
+			_FOFF(CLocodServicePlugin, iInstanceUid),
+			(TAny*)&aParams)
+		);
+
+	return self;
+    }
+    
+
+// -----------------------------------------------------------------------------
+// Service plug ins destructor
+// -----------------------------------------------------------------------------
+//
+inline CLocodServicePlugin::~CLocodServicePlugin()
+    {
+    REComSession::DestroyedImplementation(iInstanceUid);
+    }
+    
+// -----------------------------------------------------------------------------
+// returns the implementation UID
+// -----------------------------------------------------------------------------
+//
+inline TUid CLocodServicePlugin::ImplementationUid() const
+    {
+    return iImplementationUid;
+    }
+
+// -----------------------------------------------------------------------------
+// CLocodServicePlugin C++ constructor
+// -----------------------------------------------------------------------------
+//
+inline CLocodServicePlugin::CLocodServicePlugin(TLocodServicePluginParams& aParams)
+    : iImplementationUid(aParams.ImplementationUid()),
+      iObserver(aParams.Observer())
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// return the observer class
+// -----------------------------------------------------------------------------
+//
+inline MLocodServicePluginObserver& CLocodServicePlugin::Observer() const
+    {
+    return iObserver;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/commoninc/locodservicepluginobserver.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Service Plugin observer interface definition.
+*
+*/
+
+
+#ifndef M_LOCODSERVICEPLUGINOBSERVER_H
+#define M_LOCODSERVICEPLUGINOBSERVER_H
+
+#include "locodbearer.h"
+
+/**
+ *  LCD Service Plugin Observer interface class
+ *
+ *  This is the service plugin observer interface definition used by LCD
+ *  Service Plugins to inform the daemon when an action is complete.
+ *
+ *  @lib 
+ *  @since S60 v3.2
+ */
+class MLocodServicePluginObserver
+    {
+public:
+
+    /**
+     * This is a callback function used by the plugins to inform when
+     * managing the service have completed.  The parameters passed should be
+     * identical to the ones used when the plugin's ManageService() was called,
+     * plus this service plugin's implemnetation UID and the completion status.
+     *
+     * @since S60 v3.2
+     * @param  aBearer the bearer identification passed in ManageService()
+     * @param  aStatus the status of this bearer passed in ManageService()
+     * @param  aServiceImplUid, the implementation UID of this service plugin.
+     * @param  err     KErrNone if the operation succeeded; otherwise a Symbian
+     *                 error code.
+     */
+    virtual void ManageServiceCompleted(
+        TLocodBearer aBearer,
+        TBool aStatus,
+        TUid aServiceImplUid,
+        TInt err) = 0;
+    };
+
+#endif // M_LOCODSERVICEPLUGINOBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/commoninc/locodservicepluginparams.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Service Plugin construction parameters
+*                declaration
+*
+*/
+
+
+#ifndef T_LOCODSERVICEPLUGINPARAMS_H
+#define T_LOCODSERVICEPLUGINPARAMS_H
+
+class MLocodServicePluginObserver;
+
+/**
+ *  LCD Service Plugin Callback construction parameters
+ *
+ *  This interface class is used to pass construction parameters to the
+ *  plugins.  These parameters include the callback interface (usually
+ *  implemented by the LCD) and the ECOM plugin implementation UID 
+ *
+ *  @lib ?library
+ *  @since S60 v3.2
+ */
+class TLocodServicePluginParams
+    {
+public:
+    /**
+     * Constructor.
+     *
+     * @since S60 v3.2
+     * @param  aUid      Implementation UID of the plugin being constructed
+     * @param  aObserver Callback interface object
+     */
+    TLocodServicePluginParams(TUid aUid, MLocodServicePluginObserver& aObserver);
+
+    /**
+     * Gets the implementation UID of the plugin
+     *
+     * @since S60 v3.2
+     * @return Implementaion UID
+     */
+    TUid ImplementationUid() const;
+
+    /**
+     * Gets the observer interface object
+     *
+     * @since S60 v3.2
+     * @return The observer object
+     */
+    MLocodServicePluginObserver& Observer() const;    
+
+private: // data
+
+    /**
+     * The implementation UID
+     */
+    const TUid iImplementationUid;
+
+    /**
+     * Reference to the observer object
+     */
+    MLocodServicePluginObserver& iObserver;
+
+    };
+
+#include "locodservicepluginparams.inl"
+
+#endif // T_LOCODSERVICEPLUGINPARAMS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/commoninc/locodservicepluginparams.inl	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Service Plugin construction parameters
+*                declaration
+*
+*/
+
+
+// -----------------------------------------------------------------------------
+// Constructor method, just saves the arguments into member variables
+// -----------------------------------------------------------------------------
+//
+inline TLocodServicePluginParams::TLocodServicePluginParams(TUid aUid, MLocodServicePluginObserver& aObserver)
+    : iImplementationUid(aUid),
+      iObserver(aObserver)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Returns the implementation UID
+// -----------------------------------------------------------------------------
+//
+inline TUid TLocodServicePluginParams::ImplementationUid() const
+    {
+    return iImplementationUid;
+    }
+
+// -----------------------------------------------------------------------------
+// return the observer class
+// -----------------------------------------------------------------------------
+//
+inline MLocodServicePluginObserver& TLocodServicePluginParams::Observer() const
+    {
+    return iObserver;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for project Local Connectivity Daemon.
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+locod.mmp
+
+PRJ_TESTMMPFILES
+
+PRJ_EXPORTS
+../commoninc/locodbearer.h                  |../../../inc/locodbearer.h
+../commoninc/locodplugin.hrh                |../../../inc/locodplugin.hrh
+../commoninc/locodbearerplugin.h            |../../../inc/locodbearerplugin.h
+../commoninc/locodbearerplugin.inl          |../../../inc/locodbearerplugin.inl
+../commoninc/locodbearerpluginobserver.h    |../../../inc/locodbearerpluginobserver.h
+../commoninc/locodbearerpluginparams.h      |../../../inc/locodbearerpluginparams.h
+../commoninc/locodbearerpluginparams.inl    |../../../inc/locodbearerpluginparams.inl
+../commoninc/locodserviceplugin.h           |../../inc/locodserviceplugin.h
+../commoninc/locodserviceplugin.inl         |../../inc/locodserviceplugin.inl
+../commoninc/locodservicepluginobserver.h   |../../inc/locodservicepluginobserver.h
+../commoninc/locodservicepluginparams.h     |../../inc/locodservicepluginparams.h
+../commoninc/locodservicepluginparams.inl   |../../inc/locodservicepluginparams.inl
+../rom/locod.iby        CORE_MW_LAYER_IBY_EXPORT_PATH(locod.iby)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/group/locod.mmp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project Local Connectivity Daemon.
+*
+*/
+
+#include <platform_paths.hrh>
+#include "../inc/prjconfig.h"
+
+TARGET        locod.exe
+TARGETTYPE    exe
+
+UID           0x1000008d 0x2000276D
+
+VENDORID      VID_DEFAULT
+
+CAPABILITY    LocalServices ReadDeviceData NetworkControl WriteDeviceData ReadUserData WriteUserData NetworkServices
+
+SOURCEPATH    ../src
+SOURCE        locodmain.cpp
+SOURCE        locodaemon.cpp
+SOURCE        locodserviceman.cpp
+SOURCE        locodservice.cpp
+
+USERINCLUDE         ../inc
+SYSTEMINCLUDE       ../../inc ../../../inc 
+SYSTEMINCLUDE       /epoc32/include/ecom
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY     ecom.lib
+LIBRARY         featmgr.lib
+LIBRARY     centralrepository.lib
+LIBRARY     cenrepnotifhandler.lib
+
+#ifdef PRJ_FILE_TRACE
+LIBRARY  flogger.lib
+#endif
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/group/locod.mrp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+component	locod
+
+source \sf\mw\remoteconn\localconnectivityservice\locod
+
+notes_source	\component_defs\release.src
+
+ipr E 
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/inc/debug.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,167 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Logging definition
+*
+*/
+
+
+#ifndef PRJ_LOGGING_H
+#define PRJ_LOGGING_H
+
+#include <e32base.h>
+#include "debugconfig.h"
+
+#ifdef PRJ_ENABLE_TRACE
+
+#ifdef PRJ_FILE_TRACE
+#include <flogger.h>
+#else
+#include <e32debug.h>
+#endif
+
+NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow
+    {
+public:
+    void Overflow(TDes16& /*aDes*/) {}
+    };
+
+NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow
+    {
+public:
+    void Overflow(TDes8& /*aDes*/) {}
+    };
+
+inline void Trace(TRefByValue<const TDesC16> aFmt, ...)
+    {
+    VA_LIST list;
+    VA_START(list,aFmt);
+#ifdef PRJ_FILE_TRACE
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+#else
+    TBuf16<KMaxLogLineLength> theFinalString;
+    theFinalString.Append(KTracePrefix16);
+    TOverflowTruncate16 overflow;
+    theFinalString.AppendFormatList(aFmt,list,&overflow);
+    RDebug::Print(theFinalString);
+#endif
+    }
+
+inline void Trace(TRefByValue<const TDesC8> aFmt, ...)
+    {
+    VA_LIST list;
+    VA_START(list, aFmt);
+#ifdef PRJ_FILE_TRACE
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+#else
+    TOverflowTruncate8 overflow;
+    TBuf8<KMaxLogLineLength> buf8;
+    buf8.Append(KTracePrefix8);
+    buf8.AppendFormatList(aFmt, list, &overflow);
+    TBuf16<KMaxLogLineLength> buf16(buf8.Length());
+    buf16.Copy(buf8);
+    TRefByValue<const TDesC> tmpFmt(_L("%S"));
+    RDebug::Print(tmpFmt, &buf16);
+#endif
+    }
+
+inline void TracePanic(
+    char* aFile, 
+    TInt aLine,
+    TInt aPanicCode,
+    const TDesC& aPanicCategory)
+    {
+    TPtrC8 fullFileName((const TUint8*)aFile);
+    TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1);
+    TBuf8<KMaxLogLineLength> buf;
+    buf.Append(KPanicPrefix8);
+    buf.AppendFormat(_L8("%d at line %d in file %S"), aPanicCode, aLine, &fileName);
+    Trace(buf);
+    User::Panic(aPanicCategory, aPanicCode); 
+    }
+
+inline void TraceLeave(char* aFile, TInt aLine, TInt aReason)
+    {
+    TPtrC8 fullFileName((const TUint8*)aFile);
+    TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1);
+    TBuf8<KMaxLogLineLength> buf;
+    buf.Append(KLeavePrefix8);
+    buf.AppendFormat(_L8("%d at line %d in file %S"), aReason, aLine, &fileName);
+    Trace(buf);
+    User::LeaveIfError(aReason);
+    }
+
+#define TRACE_INFO(p) {if(KTraceMask & KPRINTINFO) Trace p;}
+
+#define TRACE_ERROR(p) {if(KTraceMask & KPRINTERROR) Trace p;}
+
+#define TRACE_STATE(p) {if(KTraceMask & KPRINTSTATE) Trace p;}
+
+#define TRACE_WARNING(p) {if(KTraceMask & KPRINTWARNING) Trace p;}
+
+#define TRACE_INFO_SEG(p) {if(KTraceMask & KPRINTINFO) p;}
+
+#define TRACE_ASSERT(GUARD, CODE) {if (!(GUARD)) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory);}
+
+#define PANIC(CODE) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory)
+
+#define LEAVE_IF_ERROR(REASON) {if (REASON) TraceLeave(__FILE__, __LINE__, REASON);}
+
+#define LEAVE(REASON) {TraceLeave(__FILE__, __LINE__, REASON);}
+
+#define TRACE_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryFormat8, &ptr8);}}
+
+#define TRACE_FUNC_ENTRY_THIS {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryThisFormat8, &ptr8, this);}}
+
+#define TRACE_FUNC_EXIT {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncExitFormat8, &ptr8);}}
+
+#define TRACE_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncFormat8, &ptr8);}}
+
+#define TRACE_FUNC_THIS {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncThisFormat8, &ptr8, this);}}
+
+#define RETURN_IF_ERR(ERR) {if(ERR) {TPtrC8 ptr8((TUint8*)__FILE__); Trace(_L8(" RETURN %d at file %S line %d"), ERR, &ptr8, __LINE__); return ERR;}}
+
+#else // PRJ_ENABLE_TRACE not defined
+
+#define TRACE_INFO(p)
+
+#define TRACE_ERROR(p)
+
+#define TRACE_STATE(p)
+
+#define TRACE_WARNING(p)
+
+#define TRACE_INFO_SEG(p)
+
+#define TRACE_ASSERT(GUARD, CODE)
+
+#define PANIC(CODE) {User::Panic(KPanicCategory, CODE);}
+
+#define LEAVE_IF_ERROR(REASON) {static_cast<void>(User::LeaveIfError(REASON));}
+
+#define LEAVE(REASON) {static_cast<void>(User::Leave(REASON));}
+
+#define TRACE_FUNC_ENTRY
+
+#define TRACE_FUNC_ENTRY_THIS
+
+#define TRACE_FUNC_EXIT
+
+#define TRACE_FUNC
+
+#define TRACE_FUNC_THIS
+
+#define RETURN_IF_ERR(ERR) {if(ERR) return ERR;}
+#endif // PRJ_ENABLE_TRACE
+
+#endif // PRJ_LOGGING_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/inc/debugconfig.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project configure file.
+*
+*/
+
+
+#ifndef LOCOD_DEBUGCONFIG_H
+#define LOCOD_DEBUGCONFIG_H
+
+#include "prjconfig.h"
+
+/**
+ * Custom logging variations.
+ */
+#ifdef PRJ_FILE_TRACE
+_LIT(KLogFile,"locod.txt");
+_LIT(KLogDir,"locod");
+#endif
+
+#ifdef PRJ_ENABLE_TRACE
+_LIT(KTracePrefix16, "[Locod] ");
+_LIT8(KTracePrefix8, "[Locod] ");
+_LIT8(KFuncFormat8, "><%S");
+_LIT8(KFuncThisFormat8, "><%S, [0x%08X]");
+_LIT8(KFuncEntryFormat8, ">%S");
+_LIT8(KFuncEntryThisFormat8, ">%S, [0x%08X]");
+_LIT8(KFuncExitFormat8, "<%S");
+
+_LIT(KPanicCategory, "LC Daemon");    
+_LIT8(KPanicPrefix8, "PANIC code ");
+_LIT8(KLeavePrefix8, "LEAVE code ");
+#endif
+
+const TInt KMaxLogLineLength = 512;
+
+#define KPRINTERROR        0x00000001 // Tracing level: error
+#define KPRINTINFO        0x00000002 // Tracing level: function trace
+#define KPRINTSTATE        0x00000004 // Tracing level: state machine info
+#define KPRINTWARNING   0x00000008 // Tracing level: warning
+
+const TInt KTraceMask = KPRINTERROR | KPRINTINFO | KPRINTSTATE | KPRINTWARNING;
+
+#endif // LOCOD_DEBUGCONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/inc/locodaemon.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Defines the Daemon class.
+*
+*/
+
+
+#ifndef T_LOCODAEMON_H
+#define T_LOCODAEMON_H
+
+#include <e32base.h>
+#include <e32property.h>
+class CLocodBearerPlugin;
+class CLocodServiceMan;
+
+/**
+ *  The root of Daemon.
+ *
+ *  It monitors system state, constructs service manager and loads all bearer
+ *  plugins when system is up.
+ *  It unloads all bearer and service plugins when system is shuting down.
+ *
+ *  @euser.lib
+ *  @since S60 v3.2
+ */
+class CLocoDaemon : public CActive
+    {
+public:
+
+    /**
+     *  Factory method, leave the object in cleanupstack.    
+     *  @since S60 v3.2
+     */
+    static CLocoDaemon* NewLC();
+
+    ~CLocoDaemon();
+
+private:
+    
+    // From CActive
+    
+    void RunL();
+    
+    void DoCancel();
+    
+    TInt RunError(TInt aReason);
+
+private:
+
+    CLocoDaemon();
+
+    void ConstructL();
+
+    /**
+     *  Loads the bearer plug ins
+     *  @since S60 v3.2
+     */
+    void LoadBearesL();
+
+private: // data
+
+    // the bearer plugins
+    RPointerArray<CLocodBearerPlugin> iBearers;
+    
+    // the service manager
+    CLocodServiceMan* iServiceMan;
+    
+    // for system state monitoring
+    RProperty iSystemPS;
+    TInt iSystemState;
+    };
+
+
+#endif // T_LOCODAEMON_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/inc/locodservice.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,118 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  A service which constains a service plugin and its status.
+*
+*/
+
+
+#ifndef C_LOCODSERVICE_H
+#define C_LOCODSERVICE_H
+
+#include <e32base.h>
+#include <startupdomainpskeys.h>
+#include <locodbearerpluginobserver.h>
+#include <locodservicepluginobserver.h>
+
+class CLocodServicePlugin;
+class TLocodServiceRequest;
+
+/**
+ *  Specific service that is managed by locod
+ *   Locod creates all service and add it to 
+ *   a an array
+ *  @ euser.lib
+ *  @since S60 3.2
+ */        
+class CLocodService : public CBase
+    {
+public:
+
+    /**
+     *  Factory function
+     * @since S60 3.2
+     * @param aPlugin  the sevice plug ins that will be managed (for example DUN, obex)
+     * @return an instance of CLocodService
+     */
+    static CLocodService* NewL(CLocodServicePlugin& aPlugin);
+    
+    ~CLocodService();
+    
+    CLocodServicePlugin& Plugin();
+    
+    /**
+     *  Called to manage service when the bearer status has been changed
+     * @since S60 3.2
+     * @param aBearer  the bearer whose status has been changed
+     * @param aStatus  status of the bearer connected, disconnected or on or off
+     * @return  TInt
+     */
+    TInt ManageService(TLocodBearer aBearer, 
+        TBool aStatus); 
+
+    /**
+     *  Called when the service has been managed by service plug ins
+     * @since S60 3.2
+     * @param aBearer  the bearer whose service has been managed
+     * @param aStatus  status of the bearer connected, disconnected or on or off
+     * @param err   error code that may occured during managing the service
+     * @return  TInt
+     */
+    void ManageServiceCompleted(TLocodBearer aBearer, 
+        TBool aStatus,
+        TInt err); 
+
+    /**
+     *  Check if there are any service pending
+     * @since S60 3.2
+     * @return  TBool if there are service pending
+     */
+    TBool HasServiceToManage() const;
+
+private:
+
+    CLocodService(CLocodServicePlugin& aPlugin);
+    
+    void ConstructL();
+
+private:
+    // the service plugin, owned
+    CLocodServicePlugin* iPlugin;
+    
+    // The latest status of this service plugin
+    TInt iServiceStatus;
+    
+    // Queue of ManageService request
+    RArray<TLocodServiceRequest> iRequests;
+    };
+    
+/**
+ * A ManageService request
+ */
+class TLocodServiceRequest
+    {
+public:
+
+    TLocodServiceRequest(TLocodBearer aBearer, TBool aStatus);
+    
+    // The bearer whose status has changed
+    TLocodBearer iBearer;
+    
+    // The new bearer status
+    TBool iStatus;
+    
+    // The request status
+    TBool iRequesting;
+    };
+
+#endif // C_LOCODSERVICE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/inc/locodserviceman.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,117 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Defines the service manager class.
+*
+*/
+
+
+#ifndef T_LOCODSERVICEMAN_H
+#define T_LOCODSERVICEMAN_H
+
+#include <e32base.h>
+#include <cenrepnotifyhandler.h>          
+#include <CoreApplicationUIsSDKCRKeys.h>
+#include <startupdomainpskeys.h>
+#include <locodbearerpluginobserver.h>
+#include <locodservicepluginobserver.h>
+
+class CLocodService;
+
+/**
+ *  The service plugin manager.
+ *
+ *  It loads, unloads service plugins on demand and manages a service availability
+ *  according to bearer status.
+ *  @euser.lib
+ *  @since S60 v3.2
+ */
+class CLocodServiceMan : 
+    public CActive, 
+    public MLocodBearerPluginObserver, 
+    public MLocodServicePluginObserver
+    {
+public:
+
+    /**
+     *  Factory method, leave the object in cleanupstack.
+     *
+     *  @lib ?library
+     *  @since S60 v3.2
+     */
+    static CLocodServiceMan* NewL();
+
+    ~CLocodServiceMan();
+
+public:
+
+private:
+    
+    // From CActive
+    
+    void RunL();
+    
+    void DoCancel();
+    
+    TInt RunError(TInt aReason);
+
+private:
+
+    // From MLocodBearerPluginObserver
+    /**
+     * This is a callback function used by the plugins to inform when the
+     * bearer's availability changes.
+     *
+     * @since S60 v3.2
+     * @param  aBearer the bearer which calls this nothification
+     * @param  aStatus the status of this bearer, ETrue if it is available;
+     *                 EFalse otherwise.
+     */
+    void NotifyBearerStatus(TLocodBearer aBearer, 
+        TBool aStatus);
+        
+    // From MLocodServicePluginObserver
+    /**
+     * This is a callback function used by the plugins to inform when
+     * managing the service have completed.  The parameters passed should be
+     * identical to the ones used when the plugin's ManageService() was called,
+     * plus this service plugin's implemnetation UID and the completion status.
+     *
+     * @since  S60 v3.2
+     * @param  aBearer the bearer identification passed in ManageService()
+     * @param  aStatus the status of this bearer passed in ManageService()
+     * @param  aServiceImplUid, the implementation UID of this service plugin.
+     * @param  err     KErrNone if the operation succeeded; otherwise a Symbian
+     *                 error code.
+     */
+    void ManageServiceCompleted(TLocodBearer aBearer, 
+        TBool aStatus,
+        TUid aServiceImplUid,
+        TInt err);
+
+private:
+
+    CLocodServiceMan();
+
+    void ConstructL();
+    
+    void LoadServicesL();    
+
+private: // data
+    RPointerArray<CLocodService> iServices;
+    TInt iBearerStatus;
+    TUid iUidDun;  // DUN id
+    };
+
+
+#endif // T_LOCODSERVICEMAN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/inc/prjconfig.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project configure file.
+*
+*/
+
+
+#ifndef LOCOD_PRJCONFIG_H
+#define LOCOD_PRJCONFIG_H
+
+/**
+ * Traces are enabled in _DEBUG build, by default.
+ */
+#ifdef _DEBUG
+#define PRJ_ENABLE_TRACE
+#endif
+
+/**
+ * traces to file if this is defined.
+ */
+//#define PRJ_FILE_TRACE
+
+
+/**
+ * build the project for module test purpose if this is defined
+ */
+//#define PRJ_MODULETEST_BUILD
+
+/**
+ * build the project using stubs to replace the dependencies if this is defined
+ */
+//#define PRJ_USE_STUB
+
+
+#endif // LOCOD_PRJCONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/inc/utils.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Defines utility functions.
+*
+*/
+
+
+#ifndef LOCODUTIL_H
+#define LOCODUTIL_H
+
+#include <e32base.h>
+
+template <class T>
+class CleanupResetDestroyClose
+	{
+public:
+	inline static void PushL(T& aRef) 
+	    {
+	    CleanupStack::PushL(TCleanupItem(&ResetDestroyClose,&aRef));
+	    }
+private:
+	static void ResetDestroyClose(TAny *aPtr)
+    	{
+    	static_cast<T*>(aPtr)->ResetAndDestroy();
+    	static_cast<T*>(aPtr)->Close();
+    	}
+	};
+
+/**
+ * Pushes an object into CleanupStack and specifies the cleanup 
+ * function as ResetAndDestroy() and Close().
+*/
+template <class T>
+inline void CleanupResetDestroyClosePushL(T& aRef)
+	{CleanupResetDestroyClose<T>::PushL(aRef);}
+
+#endif // LOCODUTIL_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/rom/locod.iby	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef LOCALCONNECTIVITYDAEMON_IBY
+#define LOCALCONNECTIVITYDAEMON_IBY
+
+file=ABI_DIR\BUILD_DIR\locod.exe		PROGRAMS_DIR\locod.exe
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/src/locodaemon.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,188 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Daemon class implementation.
+*
+*/
+
+
+#include <startupdomainpskeys.h>
+
+#include <featmgr.h>
+#include <locodplugin.hrh>
+#include <locodbearerplugin.h>
+
+#include "locodaemon.h"
+#include "locodserviceman.h"
+#include "utils.h"
+#include "debug.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// NewLC
+// ---------------------------------------------------------------------------
+//
+CLocoDaemon* CLocoDaemon::NewLC()
+    {
+    CLocoDaemon* self = new (ELeave) CLocoDaemon();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// C++ destrctor
+// ---------------------------------------------------------------------------
+//
+CLocoDaemon::~CLocoDaemon()
+    {
+    FeatureManager::UnInitializeLib();    
+    Cancel();
+    iSystemPS.Close();
+    delete iServiceMan;
+    iBearers.ResetAndDestroy();
+    iBearers.Close();
+    REComSession::FinalClose();
+    TRACE_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// Called when the status of system pubsub keys are 
+// changed. Normally this is called after the system boot.
+// ---------------------------------------------------------------------------
+//
+void CLocoDaemon::RunL()
+    {
+    TRACE_INFO((_L(" RunL %d"), iStatus.Int()))
+    if (iStatus == KErrNone)
+        {
+		iSystemPS.Subscribe(iStatus);
+		SetActive();
+
+        TRACE_INFO((_L(" [SYSTEM] prev %d"), iSystemState))
+        LEAVE_IF_ERROR(iSystemPS.Get(iSystemState));
+        TRACE_INFO((_L(" [SYSTEM] now %d"), iSystemState))
+        
+        if (iSystemState == ESwStateNormalRfOn ||
+             iSystemState == ESwStateNormalRfOff ||
+            iSystemState == ESwStateCharging ||  
+            iSystemState == ESwStateNormalBTSap)
+            { // System is up, construct service man and load bearers.
+            if(!iServiceMan)
+                {
+                iServiceMan = CLocodServiceMan::NewL();
+                }
+            if (!iBearers.Count())
+                {
+                LoadBearesL();
+                }
+            }
+  /*
+     ESwStateShuttingDown and  ESWStateShuttingDown event is received when 
+     the device is about to shut down
+  */
+        else if (iSystemState == ESwStateShuttingDown)
+            {
+            TRACE_INFO((_L(" [SYSTEM] Shuting down and deleting")))
+            delete iServiceMan;
+            iServiceMan = NULL;
+            iBearers.ResetAndDestroy();
+            return;
+            }        
+        }
+        RProcess::Rendezvous(KErrNone);
+    }
+
+// ---------------------------------------------------------------------------
+// CActive method cancel listening pubsub keys
+// ---------------------------------------------------------------------------
+//
+void CLocoDaemon::DoCancel()
+    {
+    TRACE_FUNC
+    iSystemPS.Cancel();
+    }
+  
+// ---------------------------------------------------------------------------
+// CActive method
+// ---------------------------------------------------------------------------
+//  
+TInt CLocoDaemon::RunError(TInt /*aReason*/)
+    {
+    TRACE_FUNC
+    return KErrNone;
+    }
+  
+// ---------------------------------------------------------------------------
+// C++ Constructor
+// ---------------------------------------------------------------------------
+//  
+CLocoDaemon::CLocoDaemon() : CActive(CActive::EPriorityStandard)
+    {
+    CActiveScheduler::Add(this);
+    TRACE_FUNC_THIS
+    }
+
+// ---------------------------------------------------------------------------
+// 2nd phase construction
+// ---------------------------------------------------------------------------
+//    
+void CLocoDaemon::ConstructL()
+    {
+    FeatureManager::InitializeLibL();
+    LEAVE_IF_ERROR(iSystemPS.Attach(KPSUidStartup, KPSGlobalSystemState));
+    iStatus = KRequestPending;
+    SetActive();
+    TRequestStatus* sta = &iStatus;
+    User::RequestComplete(sta, KErrNone);
+    TRACE_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// LoadBearesL Loads the bearer plug ins
+// ---------------------------------------------------------------------------
+//
+void CLocoDaemon::LoadBearesL()
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO((_L("Load interface 0x%08X"), KLOCODBEARERINTERFACEUID))
+	const TUid KBearerPluginInterface = TUid::Uid(KLOCODBEARERINTERFACEUID);
+	RImplInfoPtrArray implementations;
+	const TEComResolverParams noResolverParams;
+	REComSession::ListImplementationsL(KBearerPluginInterface, 
+		noResolverParams,
+		KRomOnlyResolverUid,
+		implementations);
+	CleanupResetDestroyClosePushL(implementations);
+	const TUint count = implementations.Count();
+    TRACE_INFO((_L(" Bearer count = %d"), count))
+	for ( TUint ii = 0 ; ii < count ; ++ii )
+		{
+		CImplementationInformation* impl = implementations[ii];
+		TRACE_INFO((_L("Bearer: feature %d, name '%S', ROM only %d"), 
+		    impl->ImplementationUid().iUid, &(impl->DisplayName()), impl->RomOnly()))
+    	if (FeatureManager::FeatureSupported(impl->ImplementationUid().iUid))
+    		{
+    		TRACE_INFO((_L("Feature found")))
+    		TLocodBearerPluginParams params(impl->ImplementationUid(), *iServiceMan);
+    		CLocodBearerPlugin* bearer = CLocodBearerPlugin::NewL(params);
+    		CleanupStack::PushL(bearer);
+    		iBearers.AppendL(bearer);
+    		CleanupStack::Pop(bearer);
+    		}
+		}
+	CleanupStack::PopAndDestroy(&implementations);
+    TRACE_FUNC_EXIT
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/src/locodmain.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Global functions for Local Connectivity Daemon.
+*
+*/
+
+
+#include "locodaemon.h"
+#include "debug.h"
+
+_LIT( KLocodName, "LocalConnectivityDaemon" );
+
+static void StartDaemonL();
+
+// ======== LOCAL FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// E32Main.
+// Entry-point for LCD.
+// ---------------------------------------------------------------------------
+//
+TInt E32Main()
+    {
+    TInt ret;
+    User::RenameThread( KLocodName );
+
+    __UHEAP_MARK;
+    
+    // create clean-up stack
+    CTrapCleanup* cleanup = CTrapCleanup::New();
+    TRAP( ret, StartDaemonL() );
+    delete cleanup; // destroy clean-up stack
+    __UHEAP_MARKEND;
+
+    return ret;
+    }
+
+// ----------------------------------------------------------------------------
+// StartDaemonL().
+// Constructs and installs the active scheduler, constructs Daemon object.
+// ----------------------------------------------------------------------------
+//
+static void StartDaemonL()
+    {
+    TRACE_FUNC
+    
+    // Construct and install the active scheduler
+    CActiveScheduler *myScheduler = new ( ELeave ) CActiveScheduler();
+
+    // Push onto the cleanup stack
+    CleanupStack::PushL( myScheduler );
+
+    // Install as the active scheduler
+    CActiveScheduler::Install( myScheduler );
+
+    CLocoDaemon* daemon = NULL;
+    daemon = CLocoDaemon::NewLC();
+    CActiveScheduler::Start();
+
+    CleanupStack::PopAndDestroy( daemon );
+    CleanupStack::PopAndDestroy( myScheduler );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/src/locodservice.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,220 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The implementation of LCD service
+*
+*/
+
+
+#include <locodserviceplugin.h>
+
+#include "locodservice.h"
+#include "debug.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Creates a service object based on the service plug in objects
+// ---------------------------------------------------------------------------
+//
+CLocodService* CLocodService::NewL(CLocodServicePlugin& aPlugin)
+    {
+    CLocodService* self = new (ELeave) CLocodService(aPlugin);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// C++ destructor
+// ---------------------------------------------------------------------------
+//
+CLocodService::~CLocodService()
+    {
+    delete iPlugin;
+    iRequests.Close();
+    TRACE_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// return the plugin instance
+// ---------------------------------------------------------------------------
+//
+CLocodServicePlugin& CLocodService::Plugin()
+    {
+    return *iPlugin;
+    }
+
+
+// ---------------------------------------------------------------------------
+// A request is sent to service plug in to manage their services
+// ---------------------------------------------------------------------------
+//
+TInt CLocodService::ManageService(TLocodBearer aBearer, TBool aStatus)
+    {
+    TRACE_INFO((_L("[Srvc %d] [SrvcState 0x%04x]"), iPlugin->ImplementationUid().iUid, iServiceStatus))
+    
+    // if there is an outstanding request which has the same bearer,
+    // remove all later enqueued request, and
+    // enqueue this request if the bearer status is different from the ongoing one.
+    TInt count = iRequests.Count();
+    for (TInt i = 0; i < count; i++)
+        {
+        if (iRequests[i].iBearer == aBearer && iRequests[i].iRequesting)
+            {
+            for (TInt j = count - 1; j > i; j--)
+                {
+                if (iRequests[j].iBearer == aBearer)
+                    {
+                    TRACE_INFO((_L("[Srvc %d] [ManSrvc] Remove buffered request(Bearer 0x%04x status %d)"), 
+                        iPlugin->ImplementationUid().iUid, aBearer, iRequests[j].iStatus))
+                    iRequests.Remove(j);
+                    }
+                }
+            if ((!iRequests[i].iStatus && aStatus) || (iRequests[i].iStatus && !aStatus))
+                {
+                TRACE_INFO((_L("[Srvc %d] [ManSrvc] Buffer request(Bearer 0x%04x status %d)"), 
+                    iPlugin->ImplementationUid().iUid, aBearer, aStatus))
+                return iRequests.Append(TLocodServiceRequest(aBearer, aStatus));
+                }
+            else
+                {
+                TRACE_INFO((_L("[Srvc %d] [ManSrvc] Request(Bearer 0x%04x status %d) discarded"), 
+                    iPlugin->ImplementationUid().iUid, aBearer, aStatus))
+                return KErrNone;
+                }
+            }
+        }
+    
+    // else if the latest bearer status in this service plugin is different,
+    // Start ManageService()
+    if ( aStatus && !(iServiceStatus & aBearer) ||
+        !aStatus && (iServiceStatus & aBearer))
+        {
+        TLocodServiceRequest request(aBearer, aStatus);
+        request.iRequesting = ETrue;
+        TInt err = iRequests.Append(request);
+        TRACE_INFO((_L("[Srvc %d] [ManSrvc] Issue request(Bearer 0x%04x status %d)"), 
+            iPlugin->ImplementationUid().iUid, aBearer, aStatus))
+        if (!err)
+            {
+            iPlugin->ManageService(aBearer, aStatus);
+            }
+        return err;
+        }
+    
+    // else the latest bearer status in this service plugin is the same,
+    // do nothing
+    TRACE_INFO((_L("[Srvc %d] [ManSrvc] Request(Bearer 0x%04x status %d) discarded"), 
+        iPlugin->ImplementationUid().iUid, aBearer, aStatus))
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Based on the status of bearer either the request is removed or a new manage 
+// service is issued
+// ---------------------------------------------------------------------------
+//
+void CLocodService::ManageServiceCompleted(TLocodBearer aBearer, 
+    TBool aStatus, TInt err)
+    {
+    TRACE_INFO((_L("[Srvc %d] [ManSrvc complete] (Bearer 0x%04x status %d) return %d"), 
+        iPlugin->ImplementationUid().iUid, aBearer, aStatus, err))    
+    // Save the latest status of this bearer
+    if (!err)
+        {
+        if (aStatus)
+            {
+            iServiceStatus |= aBearer;
+            }
+        else
+            {
+            iServiceStatus &= (~aBearer);
+            }
+        TRACE_INFO((_L("[Srvc %d] [SrvcState 0x%04x]"), iPlugin->ImplementationUid().iUid, iServiceStatus))
+        }
+    
+    // Find the completed request and remove it from the request list.
+    TInt count = iRequests.Count();
+    for (TInt i = 0; i < count; i++)
+        {
+        if (iRequests[i].iBearer == aBearer && iRequests[i].iRequesting)
+            {
+            TRACE_INFO((_L("[Srvc %d] [ManSrvc completed] Remove completed request(Bearer 0x%04x status %d)"), 
+                iPlugin->ImplementationUid().iUid, aBearer, iRequests[i].iStatus))            
+            iRequests.Remove(i);
+            break;
+            }
+        }
+    
+    // Find the next request and start ManageService if the status is changed.
+    count = iRequests.Count();
+    for (TInt i = 0; i < count; i++)
+        {
+        if (iRequests[i].iBearer == aBearer)
+            {
+            if ( (iRequests[i].iStatus && !(iServiceStatus & aBearer)) ||
+                 (!iRequests[i].iStatus && (iServiceStatus & aBearer)))
+                {
+                iRequests[i].iRequesting = ETrue;
+                TRACE_INFO((_L("[Srvc %d] [ManSrvc completed] Issue buffered request(Bearer 0x%04x status %d)"), 
+                    iPlugin->ImplementationUid().iUid, aBearer, iRequests[i].iStatus))
+                iPlugin->ManageService(iRequests[i].iBearer, iRequests[i].iStatus);
+                }
+            else
+                {
+                TRACE_INFO((_L("[Srvc %d] [ManSrvc completed] Remove buffered request(Bearer 0x%04x status %d)"), 
+                    iPlugin->ImplementationUid().iUid, aBearer, iRequests[i].iStatus))            
+                iRequests.Remove(i);
+                }
+            break;
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// return if there are request pending
+// ---------------------------------------------------------------------------
+//
+TBool CLocodService::HasServiceToManage() const
+    {
+    return iRequests.Count();
+    }
+
+// ---------------------------------------------------------------------------
+// C++ default constructor
+// ---------------------------------------------------------------------------
+//
+CLocodService::CLocodService(CLocodServicePlugin& aPlugin) : iPlugin(&aPlugin)
+    {
+    TRACE_FUNC_THIS
+    }
+    
+// ---------------------------------------------------------------------------
+// C++ 2nd phase construction
+// ---------------------------------------------------------------------------
+//
+void CLocodService::ConstructL()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// C++ default constructor
+// ---------------------------------------------------------------------------
+//
+TLocodServiceRequest::TLocodServiceRequest(TLocodBearer aBearer, TBool aStatus)
+:   iBearer(aBearer), iStatus(aStatus), iRequesting(EFalse)
+    {
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/src/locodserviceman.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,220 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Daemon class implementation.
+*
+*/
+
+
+#include <featmgr.h> 
+#include <locodplugin.hrh>
+#include <locodserviceplugin.h>
+
+#include "locodserviceman.h"
+#include "locodservice.h"
+#include "debug.h"
+#include "utils.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// NewL
+// ---------------------------------------------------------------------------
+//
+CLocodServiceMan* CLocodServiceMan::NewL()
+    {
+    CLocodServiceMan* self = new (ELeave) CLocodServiceMan();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// C++ destructor
+// ---------------------------------------------------------------------------
+//
+CLocodServiceMan::~CLocodServiceMan()
+    {
+    Cancel();
+    iServices.ResetAndDestroy();
+    iServices.Close();
+
+    TRACE_FUNC
+    }
+
+// ---------------------------------------------------------------------------
+// CActive method, the request is only completed when there is no service
+// to manage, so all the service plugins are destroyed
+// ---------------------------------------------------------------------------
+//
+void CLocodServiceMan::RunL()
+    {
+    TRACE_FUNC_ENTRY
+        if(iStatus ==KErrNone)
+        {
+        iServices.ResetAndDestroy();
+        }
+        TRACE_FUNC_EXIT
+    }
+
+// ---------------------------------------------------------------------------
+// CActive method
+// ---------------------------------------------------------------------------
+//
+void CLocodServiceMan::DoCancel()
+    {
+    
+    }
+  
+// ---------------------------------------------------------------------------
+// CActive method
+// ---------------------------------------------------------------------------
+//  
+TInt CLocodServiceMan::RunError(TInt/* aReason */)
+    {
+    return KErrNone;
+    }
+
+
+// ---------------------------------------------------------------------------
+// NotifyBearerStatus
+// ---------------------------------------------------------------------------
+//
+void CLocodServiceMan::NotifyBearerStatus(TLocodBearer aBearer, TBool aStatus)
+    {
+    TRACE_INFO((_L(" [BRRST] status of 0x%04x changes to %d"), aBearer, aStatus))
+    TInt oldStatus = iBearerStatus;
+    if (aStatus)
+        {
+        iBearerStatus |= aBearer;
+        }
+    else
+        {
+        iBearerStatus &= (~aBearer);
+        }
+    TRACE_INFO((_L(" [BRRST] [OLD] 0x%08x [NEW] 0x%08x"), oldStatus, iBearerStatus))
+    if (iBearerStatus && !iServices.Count())
+        {
+        TRAP_IGNORE(LoadServicesL());
+        }
+    TInt count = iServices.Count();
+    for (TInt i = 0; i < count; i++)
+        {
+        if(iBearerStatus != oldStatus)
+	        {
+            iServices[i]->ManageService(aBearer, aStatus);
+	        }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// Call back method from service plugins. This is called when the services has been 
+// managed by the plug ins.
+// ---------------------------------------------------------------------------
+//
+void CLocodServiceMan::ManageServiceCompleted(TLocodBearer aBearer, 
+    TBool aStatus, TUid aServiceImplUid, TInt err)
+    {
+    TInt count = iServices.Count();
+    for (TInt i = 0; i < count; i++)
+        {
+        if (iServices[i]->Plugin().ImplementationUid() == aServiceImplUid)
+            {
+            iServices[i]->ManageServiceCompleted(aBearer, aStatus, err);
+            break;
+            }
+        }
+
+    if (!iBearerStatus)
+        {
+        for (TInt i = 0; i < count; i++)
+            {
+            if (iServices[i]->HasServiceToManage())
+                {
+                return;
+                }
+            }
+    
+        if(!IsActive())
+        {
+            iStatus = KRequestPending;
+            SetActive();
+            TRequestStatus* status = &iStatus;
+            User::RequestComplete(status, KErrNone);
+        }
+
+        }
+    }
+  
+// ---------------------------------------------------------------------------
+// c++ constructor
+// ---------------------------------------------------------------------------
+//          
+CLocodServiceMan::CLocodServiceMan() : CActive(CActive::EPriorityStandard),iUidDun(TUid::Uid(KFeatureIdDialupNetworking))
+    {        
+    CActiveScheduler::Add(this);
+    TRACE_FUNC_THIS
+    }
+  
+// ---------------------------------------------------------------------------
+// 2nd phase construction
+// ---------------------------------------------------------------------------
+//  
+void CLocodServiceMan::ConstructL()
+    {
+
+    }
+
+// ---------------------------------------------------------------------------
+// Loaded all service plug ins who has implemented the KLOCODSERVICEINTERFACEUID
+// ---------------------------------------------------------------------------
+//
+void CLocodServiceMan::LoadServicesL()
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_INFO((_L("Load interface 0x%08X"), KLOCODSERVICEINTERFACEUID))
+	const TUid KServicePluginInterface = TUid::Uid(KLOCODSERVICEINTERFACEUID);
+	RImplInfoPtrArray implementations;
+	const TEComResolverParams noResolverParams;
+	REComSession::ListImplementationsL(KServicePluginInterface, 
+		noResolverParams,
+		KRomOnlyResolverUid,
+		implementations);
+	CleanupResetDestroyClosePushL(implementations);
+	const TUint count = implementations.Count();
+    TRACE_INFO((_L(" [BRRST] Service Plug in found %d"), count))
+	for ( TUint ii = 0 ; ii < count ; ++ii )
+		{
+		CImplementationInformation* impl = implementations[ii];
+		TRACE_INFO((_L("Service: feature %d, name '%S', ROM only %d"), 
+		    impl->ImplementationUid().iUid, &(impl->DisplayName()), impl->RomOnly()))
+    	if (FeatureManager::FeatureSupported(impl->ImplementationUid().iUid))
+    		{
+    		TRACE_INFO((_L("Feature found")))
+            TLocodServicePluginParams params(impl->ImplementationUid(), *this);
+    		CLocodServicePlugin* srvcplugin = CLocodServicePlugin::NewL(params);
+    		CleanupStack::PushL(srvcplugin);
+    		CLocodService* service = CLocodService::NewL(*srvcplugin);
+    		CleanupStack::Pop(srvcplugin);
+    		CleanupStack::PushL(service);
+    		iServices.AppendL(service);
+    		CleanupStack::Pop(service);
+    		}
+		}
+	CleanupStack::PopAndDestroy(&implementations);
+    TRACE_FUNC_EXIT    
+    }
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/locod/src/utils.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,22 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  utility function implementation.
+*
+*/
+
+
+#include "utils.h"
+#include "debug.h"
+
+
--- a/mtpdataproviders/mtpimagedp/group/bld.inf	Thu May 27 13:42:43 2010 +0300
+++ b/mtpdataproviders/mtpimagedp/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -31,8 +31,6 @@
 PRJ_EXPORTS
 // Note: these files are exported for testing and techview only. Not used in a device
 2001fca2.txt /epoc32/data/z/private/10202be9/2001fca2.txt
-2001fca2.txt /epoc32/release/winscw/udeb/z/private/10202be9/2001fca2.txt
-2001fca2.txt /epoc32/release/winscw/urel/z/private/10202be9/2001fca2.txt
 
 ../group/mtp_imagedp.iby  /epoc32/rom/include/mtp_imagedp.iby
 
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedp.cpp	Thu May 27 13:42:43 2010 +0300
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedp.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -121,7 +121,7 @@
     
     //Define RProperty of new pictures for status data provider
     _LIT_SECURITY_POLICY_PASS(KAllowReadAll);
-    TInt error = RProperty::Define(TUid::Uid(KMTPServerUID), KMTPNewPicKey, RProperty::EInt, KAllowReadAll, KAllowReadAll);
+    TInt error = RProperty::Define(KMTPNewPicKey, RProperty::EInt, KAllowReadAll, KAllowReadAll);
     if (error != KErrNone && error != KErrAlreadyExists)
         {
         __FLOG_1(_L8("CMTPImageDataProvider::ConstructL - RProperty define error:%d"), error);
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpsendobjectinfo.cpp	Thu May 27 13:42:43 2010 +0300
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpsendobjectinfo.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -23,6 +23,7 @@
 #include <e32const.h>
 
 #include <mtp/mmtpdataproviderframework.h>
+
 #include <mtp/cmtpobjectmetadata.h>
 #include <mtp/cmtptypefile.h>
 #include <mtp/cmtptypeobjectinfo.h>
@@ -752,6 +753,9 @@
     {
     __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleSendObjectCompleteL - Entry"));    
     TBool result(ETrue);
+
+    delete iFileReceived;
+    iFileReceived = NULL;  
     
 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
     TInt64 objectsize = 0;
@@ -759,8 +763,10 @@
     TInt objectsize = 0;
 #endif
     
-    iFileReceived->File().Size(objectsize);    
-    
+    TEntry entry;
+    User::LeaveIfError(iFramework.Fs().Entry(iFullPath, entry));
+    objectsize = entry.FileSize();
+   
     if (objectsize != iObjectSize)
         {
         __FLOG_VA((_L8("object sizes differ %lu != %lu"), objectsize, iObjectSize));
@@ -789,34 +795,31 @@
         if (iProtectionStatus ==  EMTPProtectionNoProtection ||
             iProtectionStatus == EMTPProtectionReadOnly)
             {
-            TUint attValue = 0;
-            User::LeaveIfError(iFileReceived->File().Att(attValue));
-            attValue &= ~(KEntryAttNormal | KEntryAttReadOnly);
-            
+            entry.iAtt &= ~(KEntryAttNormal | KEntryAttReadOnly);
             if (iProtectionStatus == EMTPProtectionNoProtection)
                 {                        
-                attValue |= KEntryAttNormal;
+                entry.iAtt |= KEntryAttNormal;
                 }
             else
                 {
-                attValue |= KEntryAttReadOnly;
+                entry.iAtt |= KEntryAttReadOnly;
                 }
-            User::LeaveIfError(iFileReceived->File().SetAtt(attValue, ~attValue));
+            User::LeaveIfError(iFramework.Fs().SetAtt(iFullPath, entry.iAtt, ~entry.iAtt));
             }
+
         TTime modifiedTime;
         //update datemodified property.
         if(iDateMod != NULL && iDateMod->Length())
            {           
            iObjectPropertyMgr.ConvertMTPTimeStr2TTimeL(*iDateMod, modifiedTime);
-           User::LeaveIfError(iFileReceived->File().SetModified(modifiedTime));
            }
         else if(iDateCreated != NULL && iDateCreated->Length())
            {
            iObjectPropertyMgr.ConvertMTPTimeStr2TTimeL(*iDateCreated, modifiedTime);
-           User::LeaveIfError(iFileReceived->File().SetModified(modifiedTime));
            }
-                                   
-	     iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
+        User::LeaveIfError(iFramework.Fs().SetModified(iFullPath, modifiedTime));
+
+        iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
         
         //The MTP spec states that it is not mandatory for SendObjectInfo/SendObjectPropList
         //to be followed by a SendObject.  An object is reserved in the ObjectStore on 
@@ -827,10 +830,8 @@
 		
         CleanUndoList();
         SendResponseL(EMTPRespCodeOK);
-	    }        
+	    }
     
-    delete iFileReceived;
-    iFileReceived = NULL;  
     
     iSuccessful = result;
     __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleSendObjectCompleteL - Exit"));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/BWINS/pictbridgeU.DEF	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,27 @@
+EXPORTS
+	?CancelDpsEventNotify@CDpsEngine@@QAEXXZ @ 1 NONAME ; void CDpsEngine::CancelDpsEventNotify(void)
+	?CancelDpsRequest@CDpsEngine@@QAEXXZ @ 2 NONAME ; void CDpsEngine::CancelDpsRequest(void)
+	?CancelPrintMode@CDpsEngine@@QAEXXZ @ 3 NONAME ; void CDpsEngine::CancelPrintMode(void)
+	?ConnectStateNotify@CDpsEngine@@QAEXAAVTRequestStatus@@@Z @ 4 NONAME ; void CDpsEngine::ConnectStateNotify(class TRequestStatus &)
+	?CreateReqScriptL@TDpsGetCapability@@EAEXABV?$RArray@UTDpsArg@@@@ABV?$RArray@UTDpsEle@@@@IAAVRWriteStream@@PAVCDpsTransaction@@@Z @ 5 NONAME ; void TDpsGetCapability::CreateReqScriptL(class RArray<struct TDpsArg> const &, class RArray<struct TDpsEle> const &, unsigned int, class RWriteStream &, class CDpsTransaction *)
+	?CreateReqScriptL@TDpsStartJob@@EAEXABV?$RArray@UTDpsArg@@@@ABV?$RArray@UTDpsEle@@@@IAAVRWriteStream@@PAVCDpsTransaction@@@Z @ 6 NONAME ; void TDpsStartJob::CreateReqScriptL(class RArray<struct TDpsArg> const &, class RArray<struct TDpsEle> const &, unsigned int, class RWriteStream &, class CDpsTransaction *)
+	?CreateReqScriptL@TMDpsOperation@@MAEXABV?$RArray@UTDpsArg@@@@ABV?$RArray@UTDpsEle@@@@IAAVRWriteStream@@PAVCDpsTransaction@@@Z @ 7 NONAME ; void TMDpsOperation::CreateReqScriptL(class RArray<struct TDpsArg> const &, class RArray<struct TDpsEle> const &, unsigned int, class RWriteStream &, class CDpsTransaction *)
+	?Delete@CDpsEngine@@QAEXXZ @ 8 NONAME ; void CDpsEngine::Delete(void)
+	?DoDpsRequestL@CDpsEngine@@QAEXPAVTMDpsOperation@@AAVTRequestStatus@@@Z @ 9 NONAME ; void CDpsEngine::DoDpsRequestL(class TMDpsOperation *, class TRequestStatus &)
+	?DpsEventNotify@CDpsEngine@@QAEXAAVTDpsEvents@@AAVTRequestStatus@@@Z @ 10 NONAME ; void CDpsEngine::DpsEventNotify(class TDpsEvents &, class TRequestStatus &)
+	?DpsFolder@CDpsEngine@@QBEABVTDesC16@@XZ @ 11 NONAME ; class TDesC16 const & CDpsEngine::DpsFolder(void) const
+	?FillRepArgs@TDpsConfigPrintService@@EAEHABV?$RArray@UTDpsArg@@@@PAVCDpsTransaction@@@Z @ 12 NONAME ; int TDpsConfigPrintService::FillRepArgs(class RArray<struct TDpsArg> const &, class CDpsTransaction *)
+	?FillRepArgs@TDpsGetCapability@@EAEHABV?$RArray@UTDpsArg@@@@PAVCDpsTransaction@@@Z @ 13 NONAME ; int TDpsGetCapability::FillRepArgs(class RArray<struct TDpsArg> const &, class CDpsTransaction *)
+	?FillRepArgs@TDpsGetJobStatus@@EAEHABV?$RArray@UTDpsArg@@@@PAVCDpsTransaction@@@Z @ 14 NONAME ; int TDpsGetJobStatus::FillRepArgs(class RArray<struct TDpsArg> const &, class CDpsTransaction *)
+	?FillRepArgs@TDpsGetPrinterStatus@@EAEHABV?$RArray@UTDpsArg@@@@PAVCDpsTransaction@@@Z @ 15 NONAME ; int TDpsGetPrinterStatus::FillRepArgs(class RArray<struct TDpsArg> const &, class CDpsTransaction *)
+	?FillReqArgs@TDpsAbortJob@@EAEHAAV?$RArray@UTDpsArg@@@@AAV?$RArray@UTDpsEle@@@@AAIPAVCDpsTransaction@@@Z @ 16 NONAME ; int TDpsAbortJob::FillReqArgs(class RArray<struct TDpsArg> &, class RArray<struct TDpsEle> &, unsigned int &, class CDpsTransaction *)
+	?FillReqArgs@TDpsConfigPrintService@@EAEHAAV?$RArray@UTDpsArg@@@@AAV?$RArray@UTDpsEle@@@@AAIPAVCDpsTransaction@@@Z @ 17 NONAME ; int TDpsConfigPrintService::FillReqArgs(class RArray<struct TDpsArg> &, class RArray<struct TDpsEle> &, unsigned int &, class CDpsTransaction *)
+	?FillReqArgs@TDpsGetCapability@@EAEHAAV?$RArray@UTDpsArg@@@@AAV?$RArray@UTDpsEle@@@@AAIPAVCDpsTransaction@@@Z @ 18 NONAME ; int TDpsGetCapability::FillReqArgs(class RArray<struct TDpsArg> &, class RArray<struct TDpsEle> &, unsigned int &, class CDpsTransaction *)
+	?FillReqArgs@TDpsStartJob@@EAEHAAV?$RArray@UTDpsArg@@@@AAV?$RArray@UTDpsEle@@@@AAIPAVCDpsTransaction@@@Z @ 19 NONAME ; int TDpsStartJob::FillReqArgs(class RArray<struct TDpsArg> &, class RArray<struct TDpsEle> &, unsigned int &, class CDpsTransaction *)
+	?GetDpsConfigL@CDpsEngine@@QAEXAAVTDpsConfigPrintReq@@@Z @ 20 NONAME ; void CDpsEngine::GetDpsConfigL(class TDpsConfigPrintReq &)
+	?GetEngineL@CDpsEngine@@SAPAV1@XZ @ 21 NONAME ; class CDpsEngine * CDpsEngine::GetEngineL(void)
+	?GetParamNum@TDpsStartJobReq@@QAEHXZ @ 22 NONAME ; int TDpsStartJobReq::GetParamNum(void)
+	?Reset@TDpsJobStatusRep@@QAEXXZ @ 23 NONAME ; void TDpsJobStatusRep::Reset(void)
+	?Reset@TDpsPrintInfo@@QAEXXZ @ 24 NONAME ; void TDpsPrintInfo::Reset(void)
+	?SetPrintMode@CDpsEngine@@QAEXAAVTRequestStatus@@@Z @ 25 NONAME ; void CDpsEngine::SetPrintMode(class TRequestStatus &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/eabi/pictbridgeU.DEF	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,41 @@
+EXPORTS
+	_ZN10CDpsEngine10GetEngineLEv @ 1 NONAME
+	_ZN10CDpsEngine12SetPrintModeER14TRequestStatus @ 2 NONAME
+	_ZN10CDpsEngine13DoDpsRequestLEP14TMDpsOperationR14TRequestStatus @ 3 NONAME
+	_ZN10CDpsEngine13GetDpsConfigLER18TDpsConfigPrintReq @ 4 NONAME
+	_ZN10CDpsEngine14DpsEventNotifyER10TDpsEventsR14TRequestStatus @ 5 NONAME
+	_ZN10CDpsEngine15CancelPrintModeEv @ 6 NONAME
+	_ZN10CDpsEngine16CancelDpsRequestEv @ 7 NONAME
+	_ZN10CDpsEngine18ConnectStateNotifyER14TRequestStatus @ 8 NONAME
+	_ZN10CDpsEngine20CancelDpsEventNotifyEv @ 9 NONAME
+	_ZN10CDpsEngine6DeleteEv @ 10 NONAME
+	_ZN12TDpsAbortJob11FillReqArgsER6RArrayI7TDpsArgERS0_I7TDpsEleERjP15CDpsTransaction @ 11 NONAME
+	_ZN12TDpsStartJob11FillReqArgsER6RArrayI7TDpsArgERS0_I7TDpsEleERjP15CDpsTransaction @ 12 NONAME
+	_ZN12TDpsStartJob16CreateReqScriptLERK6RArrayI7TDpsArgERKS0_I7TDpsEleEjR12RWriteStreamP15CDpsTransaction @ 13 NONAME
+	_ZN13TDpsPrintInfo5ResetEv @ 14 NONAME
+	_ZN14TMDpsOperation16CreateReqScriptLERK6RArrayI7TDpsArgERKS0_I7TDpsEleEjR12RWriteStreamP15CDpsTransaction @ 15 NONAME
+	_ZN15TDpsStartJobReq11GetParamNumEv @ 16 NONAME
+	_ZN16TDpsGetJobStatus11FillRepArgsERK6RArrayI7TDpsArgEP15CDpsTransaction @ 17 NONAME
+	_ZN16TDpsJobStatusRep5ResetEv @ 18 NONAME
+	_ZN17TDpsGetCapability11FillRepArgsERK6RArrayI7TDpsArgEP15CDpsTransaction @ 19 NONAME
+	_ZN17TDpsGetCapability11FillReqArgsER6RArrayI7TDpsArgERS0_I7TDpsEleERjP15CDpsTransaction @ 20 NONAME
+	_ZN17TDpsGetCapability16CreateReqScriptLERK6RArrayI7TDpsArgERKS0_I7TDpsEleEjR12RWriteStreamP15CDpsTransaction @ 21 NONAME
+	_ZN20TDpsGetPrinterStatus11FillRepArgsERK6RArrayI7TDpsArgEP15CDpsTransaction @ 22 NONAME
+	_ZN22TDpsConfigPrintService11FillRepArgsERK6RArrayI7TDpsArgEP15CDpsTransaction @ 23 NONAME
+	_ZN22TDpsConfigPrintService11FillReqArgsER6RArrayI7TDpsArgERS0_I7TDpsEleERjP15CDpsTransaction @ 24 NONAME
+	_ZNK10CDpsEngine9DpsFolderEv @ 25 NONAME
+	_ZTI12TDpsAbortJob @ 26 NONAME ; #<TI>#
+	_ZTI12TDpsStartJob @ 27 NONAME ; #<TI>#
+	_ZTI14TMDpsOperation @ 28 NONAME ; #<TI>#
+	_ZTI16TDpsGetJobStatus @ 29 NONAME ; #<TI>#
+	_ZTI17TDpsGetCapability @ 30 NONAME ; #<TI>#
+	_ZTI20TDpsGetPrinterStatus @ 31 NONAME ; #<TI>#
+	_ZTI22TDpsConfigPrintService @ 32 NONAME ; #<TI>#
+	_ZTV12TDpsAbortJob @ 33 NONAME ; #<VT>#
+	_ZTV12TDpsStartJob @ 34 NONAME ; #<VT>#
+	_ZTV14TMDpsOperation @ 35 NONAME ; #<VT>#
+	_ZTV16TDpsGetJobStatus @ 36 NONAME ; #<VT>#
+	_ZTV17TDpsGetCapability @ 37 NONAME ; #<VT>#
+	_ZTV20TDpsGetPrinterStatus @ 38 NONAME ; #<VT>#
+	_ZTV22TDpsConfigPrintService @ 39 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,24 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the build info file for PictBridge engine. 
+*
+*/
+
+
+#include <platform_paths.hrh>
+PRJ_MMPFILES
+pictbridge.mmp
+
+PRJ_EXPORTS
+../rom/pictbridge.iby CORE_MW_LAYER_IBY_EXPORT_PATH(pictbridge.iby)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/group/pictbridge.mmp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the project file for PictBridge engine
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET        	pictbridge.dll
+TARGETTYPE      dll
+UID             0x1000008d 0x10274798
+CAPABILITY 	    CAP_GENERAL_DLL
+VENDORID 	    VID_DEFAULT
+
+USERINCLUDE 	../inc
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include/xml 
+
+SOURCEPATH      ../src
+SOURCE          pictbridge.cpp
+SOURCE          dpsxmlstring.cpp
+SOURCE		    dpsxmlparser.cpp
+SOURCE		    dpsxmlgenerator.cpp
+SOURCE          dpsstatemachine.cpp
+SOURCE          dpsoperation.cpp
+SOURCE          dpsparam.cpp
+SOURCE          dpstransaction.cpp
+SOURCE          dpsstate.cpp
+SOURCE			dpsfile.cpp
+SOURCE			dpsusbnotifier.cpp
+SOURCE 			dpsscriptsender.cpp
+SOURCE			dpsscriptreceiver.cpp
+SOURCE			dpsptpnotifier.cpp
+SOURCE			dpsconnectnotifier.cpp
+
+START RESOURCE dps.rss
+TARGETPATH resource
+HEADER
+END
+
+LIBRARY     euser.lib xmlframework.lib efsrv.lib bafl.lib platformenv.lib
+LIBRARY     rptp.lib usbman.lib usbwatcher.lib centralrepository.lib estor.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/group/pictbridgeengine.mrp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+component	pictbridgeengine
+
+source \sf\mw\remoteconn\localconnectivityservice\pictbridgeengine
+
+notes_source	\component_defs\release.src
+
+ipr E 
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dps.rh	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The resource header file for Dps configuration. 
+*
+*/
+
+
+STRUCT dps_configuration
+    {
+    BYTE numOfVersions = 1;
+    BYTE versionMajor = 1;
+    BYTE versionMinor = 0;
+    LTEXT vendorName = "Nokia";
+    BYTE vendorSpecificVersionMajor = 1;
+    BYTE vendorSpecificVersionMinor = 0;
+    LTEXT productName = "S60";
+    LTEXT serialNo = "0123456";
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsconnectnotifier.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,83 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class defines functions of the notification of the 
+*                PTP printer connction and disconnection. 
+*
+*/
+
+
+#ifndef DPSCONNECTNOTIFIER_H
+#define DPSCONNECTNOTIFIER_H
+
+#include <e32base.h>
+#include <usbstates.h>
+
+class CDpsUsbNotifier;
+
+/**
+*   Class for monitoring usb cable connection/disconnection 
+*/
+NONSHARABLE_CLASS(CDpsConnectNotifier) : public CActive
+    {
+    public:
+        /**
+        *   Two phase constructor
+        *   @param aParent the pointer to UsbNotifier object
+        *   @return a new created ConnectNotifier object
+        */
+        static CDpsConnectNotifier* NewL(CDpsUsbNotifier* aParent);
+        
+        /**
+        *   Destructor
+        */
+        ~CDpsConnectNotifier();
+        
+        /**
+        *   Called by UsbNotifier to subscribe connection notification
+        */
+        void ConnectNotify();
+        
+    private: // Functions derived from CActive.
+	    /**
+	    *   @see CActive
+	    */
+    	void RunL();
+    	
+    	/**
+    	*   @see CActive
+    	*/
+	    void DoCancel();
+	    
+	    /**
+	    *   @see CActive
+	    */
+	    TInt RunError(TInt aError);
+	    
+	private:
+	    /**
+	    *   Second phase constructor
+	    */
+		void ConstructL();
+	    
+	    /**
+	    *   Default constructor
+	    */
+	    CDpsConnectNotifier(CDpsUsbNotifier* aParent);
+	    
+	private:
+	    // not owned by this class
+	    CDpsUsbNotifier* iNotifier;    
+    };
+    
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsconst.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,101 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class defines the dps constance. 
+*
+*/
+
+
+
+#ifndef DPSCONST_H
+#define DPSCONST_H
+#include <e32base.h>
+#include <usbpersonalityids.h>
+
+_LIT(KDpsEnginePanicCat, "Dps Engine");
+const TInt KShiftLength = 16;
+const TInt KFullWordWidth = 8;
+
+// <dps><input|output><operation|event|result></result|/event|/operation>
+//	</output|/input></dps> 
+enum TDpsXmlAction
+    {
+    EDpsXmlEmpty = 0,
+    EDpsXmlStart,
+    EDpsXmlInput,
+    EDpsXmlOutput,
+    EDpsXmlOperation,
+    EDpsXmlEvent,
+    EDpsXmlResult
+    };    
+
+enum TDpsOperation
+    {
+    EDpsOpEmpty = 0,
+    EDpsOpConfigPrintService,
+    EDpsOpGetCapability,
+    EDpsOpGetJobStatus,
+    EDpsOpGetDeviceStatus,
+    EDpsOpStartJob,
+    EDpsOpAbortJob,
+    EDpsOpContinueJob,
+    EDpsOpGetFileID,
+    EDpsOpGetFileInfo,
+    EDpsOpGetFile,
+    EDpsOpGetPartialFile,
+    EDpsOpGetFileList,
+    EDpsOpGetThumb,
+    EDpsOpMax
+    };
+
+_LIT8(KDpsXmlResult, "result");
+_LIT8(KDpsXmlInput, "input");
+_LIT8(KDpsXmlOutput, "output");
+_LIT8(KDpsXmlPaperTypes, "paperTypes");
+_LIT8(KDpsXmlLayouts, "layouts");
+_LIT8(KDpsXmlPaperSize, "paperSize");
+_LIT8(KDpsXml, "dps");
+
+_LIT8(KDpsXmlHeader, "<?xml version=\"1.0\"?>");
+_LIT8(KDpsXmlNS, "<dps xmlns=\"http://www.cipa.jp/dps/schema/\">");
+_LIT8(KDpsXmlBraceOpen, "<");
+_LIT8(KDpsXmlBraceClose, ">");
+_LIT8(KDpsXmlSlash, "/");
+_LIT8(KDpsXmlSpace, " ");
+_LIT8(KDpsXmlEqual, "=");
+_LIT8(KDpsXmlQuote, "\"");
+
+const TUint KSlash = 0x2F;
+const TUint KBackSlash = 0x5C;
+const TUint KSOH = 0x1;
+const TUint KSpace = 0x20;
+
+const TUint32 KDpsMajorMask = 0xffff0000;
+const TUint32 KDpsMinorMask = 0x0000ffff;
+
+
+_LIT8(KDpsLowZero, "0000");
+_LIT(KDpsScriptFile, ".DPS" );
+_LIT(KDpsDeviceResponseFileName, "DRSPONSE.DPS");
+_LIT(KDpsDeviceRequestFileName, "DREQUEST.DPS");
+_LIT(KDpsHostResponseFileName, "HRSPONSE.DPS");
+_LIT(KDpsHostRequestFileName, "HREQUEST.DPS");
+_LIT8(KDpsXmlMimeType, "text/xml");
+
+const TInt KDpsResourceVersion = 0;
+_LIT(KDpsResource, "resource\\dps.rsc");
+
+
+#endif // DPSDEFS_H
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsdefs.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,483 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class defines the dps definations. 
+*
+*/
+
+
+#ifndef DPSDEFS_H
+#define DPSDEFS_H
+
+#include <e32base.h>
+
+const TInt KMaxArgLen = 256;
+const TInt KDateLen = 32;
+
+// special element which has sub-elements, only startJob and 
+// getCapability have this field
+enum TDpsElement
+    {
+    EDpsEleEmpty = 0,
+    EDpsCapability,
+    EDpsJobConfig,
+    EDpsPrintInfo,
+    KDpsEleMax
+    };
+    
+enum TDpsEvent
+    {
+    EDpsEvtEmpty = 0,
+    EDpsEvtNotifyJobStatus,
+    EDpsEvtNotifyDeviceStatus,
+    KDpsEvtMax
+    };
+	
+enum TDpsArgument
+    {
+    EDpsArgDpsVersions = 0,
+    EDpsArgVendorName,
+    EDpsArgVendorSpecificVersion,
+    EDpsArgProductName,
+    EDpsArgSerialNo,
+    EDpsArgPrintServiceAvailable,
+    EDpsArgQualities,
+    EDpsArgPaperSizes,
+    EDpsArgPaperTypes,
+    EDpsArgFileTypes,
+    EDpsArgDatePrints,
+    EDpsArgFileNamePrints,
+    EDpsArgImageOptimizes,
+    EDpsArgLayouts,
+    EDpsArgFixedSizes,
+    EDpsArgChroppings,
+    EDpsArgPrtPID,
+    EDpsArgFilePath,
+    EDpsArgCopyID,
+    EDpsArgProgress,
+    EDpsArgImagePrinted,
+    EDpsArgDpsPrintServiceStatus,
+    EDpsArgJobEndReason,
+    EDpsArgErrorStatus,
+    EDpsArgErrorReason,
+    EDpsArgDisconnectEnable,
+    EDpsArgCapabilityChanged,
+    EDpsArgNewJobOk,
+    EDpsArgQuality,
+    EDpsArgPaperSize,
+    EDpsArgPaperType,
+    EDpsArgFileType,
+    EDpsArgDatePrint,
+    EDpsArgFileNamePrint,
+    EDpsArgImageOptimize,
+    EDpsArgLayout,
+    EDpsArgFixedSize,
+    EDpsArgCropping,
+    EDpsArgCroppingArea,
+    EDpsArgFileID,
+    EDpsArgFileName,
+    EDpsArgDate,
+    EDpsArgCopies,
+    EDpsArgAbortStyle,
+    EDpsArgImagesPrinted,
+    EDpsArgBasePathID,
+    EDpsArgFileSize,
+    EDpsArgThumbFormat,
+    EDpsArgThumbSize,
+    EDpsArgBytesRead,
+    EDpsArgOffset,
+    EDpsArgMaxSize,
+    EDpsArgParentFileID,
+    EDpsArgMaxNumIDs,
+    EDpsArgFileIDs,
+    EDpsArgNumIDs,
+    EDpsArgMax
+    };
+
+// define the DPS action result
+// ref: DPS spec page 52
+// high bits
+enum TDpsResultMajorCode
+    {
+    EDpsResultOk = 0x1000,
+    EDpsResultNotExecuted = 0x1001,
+    EDpsResultNotSupported = 0x1002,
+    EDpsResultNotRecognized = 0x1003
+    };
+	
+// define the DPS action result minor code
+// ref: DPS spec page 52
+// low bits
+enum TDpsResultMinorCode
+    {
+    EDpsResultNone = 0x0000,
+    EDpsResultUnrecognizedParam = 0x0001,
+    EDpsResultillegalParam = 		0x0002,
+    EDpsResultMissingParam = 		0x0003,
+    EDpsResultBufferOverflow = 	0x0004	
+    };
+
+// define the DPS service availability
+// ref: DPS spec page 53
+// only high bits are useful
+enum TDpsServiceAvailability
+    {
+    EDpsPrintServiceAvailableFalse = 0x3000,
+    EDpsPrintServiceAvailableTrue = 0x3001	
+    };
+
+// define printing qualities
+// ref: DPS spec page 54
+// only high bits are useful
+enum TDpsPrintQuality
+    {
+    EDpsPrintQualityDefault = 0x5000,
+    EDpsPrintQualityNormal = 	0x5001,
+    EDpsPrintQualityDraft = 	0x5002,
+    EDpsPrintQualityFine = 	0x5003	
+    };
+
+// define paper sizes
+// ref: DPS spec page 54
+// only high bits are useful
+enum TDpsPaperSizes
+    {
+    EDpsPaperSizeDefault = 	0x5100,
+    EDpsPaperSizeL = 		0x5101,
+    EDpsPaperSize2L = 		0x5102,
+    EDpsPaperSizePostcard = 0x5103,
+    EDpsPaperSizeCard = 	0x5104,
+    EDpsPaperSize100x150 = 	0x5105,
+    EDpsPaperSize4x6 = 		0x5106,
+    EDpsPaperSize8x10 = 	0x5107,
+    EDpsPaperSizeLetter = 	0x5108,
+    EDpsPaperSize11x17 = 	0x510A,
+    EDpsPaperSizeA0 = 		0x5110,
+    EDpsPaperSizeA1 = 		0x5111,
+    EDpsPaperSizeA2 = 		0x5112,
+    EDpsPaperSizeA3 = 		0x5113,
+    EDpsPaperSizeA4 = 		0x5114,
+    EDpsPaperSizeA5 = 		0x5115,
+    EDpsPaperSizeA6 = 		0x5116,
+    EDpsPaperSizeA7 = 		0x5117,
+    EDpsPaperSizeA8 = 		0x5118,
+    EDpsPaperSizeA9 = 		0x5119,
+    EDpsPaperSizeB0 = 		0x5120,
+    EDpsPaperSizeB1 = 		0x5121,
+    EDpsPaperSizeB2 = 		0x5122,
+    EDpsPaperSizeB3 = 		0x5123,
+    EDpsPaperSizeB4 = 		0x5124,
+    EDpsPaperSizeB5 = 		0x5125,
+    EDpsPaperSizeB6 = 		0x5126,
+    EDpsPaperSizeB7 = 		0x5127,
+    EDpsPaperSizeB8 = 		0x5128,
+    EDpsPaperSizeB9 = 		0x5129,
+    EDpsPaperSize89 = 		0x5181,
+    EDpsPaperSize127 = 		0x5182,
+    EDpsPaperSize100 = 		0x5186,
+    EDpsPaperSize210 = 		0x5194
+    };
+// define paper types
+// ref: DPS spec page 54
+// only high bits are useful
+enum TDpsPaperTypeMajor
+    {
+    EDpsPaperTypeDefault = 		0x5200,
+    EDpsPaperTypePlainPaper = 	0x5201,
+    EDpsPaperTypePhotoPaper = 	0x5202,
+    EDpsPaperTypeFastPhotopaper = 	0x5203	
+    };
+
+enum TDpsPaperTypeMinor
+    {
+    EDpsPaperTypeStationery = 1,
+    EDpsPaperTypeStationeryCoated,
+    EDpsPaperTypeStationeryInkjet,
+    EDpsPaperTypeStationeryPreprinted,
+    EDpsPaperTypeStationeryLetterhead,
+    EDpsPaperTypeStationeryPrepunched,
+    EDpsPaperTypeStationeryFine,
+    EDpsPaperTypeStationeryHeavyweight,
+    EDpsPaperTypeStationeryLightweight,
+    EDpsPaperTypeTransparency,
+    EDpsPaperTypeEnvelope,
+    EDpsPaperTypeEnvelopePlain,
+    EDpsPaperTypeEnvelopeWindow,
+    EDpsPaperTypeContinuous,
+    EDpsPaperTypeContinuousLong,
+    EDpsPaperTypeContinuousShort,
+    EDpsPaperTypeTabStock,
+    EDpsPaperTypePreCutTabs,
+    EDpsPaperTypeFullCutTabs,
+    EDpsPaperTypeMultiPartForm,
+    EDpsPaperTypeLabels,
+    EDpsPaperTypeMultiLayer,
+    EDpsPaperTypeScreen,
+    EDpsPaperTypeScreenPaged,
+    EDpsPaperTypePhotographic,
+    EDpsPaperTypePhotographicGlossy,
+    EDpsPaperTypePhotographicHighGloss,
+    EDpsPaperTypePhotographicSemiGloss,
+    EDpsPaperTypePhotographicSatin,
+    EDpsPaperTypePhotographicMatte,
+    EDpsPaperTypePhotographicFilm,
+    EDpsPaperTypeBackPrintFilm,
+    EDpsPaperTypeCardStock
+    };
+    
+struct TDpsPaperType
+    {
+    TDpsPaperTypeMajor iMajor;
+    TDpsPaperTypeMinor iMinor;
+    };
+
+// define file types
+// ref: DPS sepc page 55
+// only high bits are useful
+enum TDpsFileType
+    {
+    EDpsFileTypeDefault =   0x5300,
+    EDpsFileTypeEXIF =      0x5301,
+    EDpsFileTypeJPEG =      0x5303	
+    };
+
+// define date print
+// ref: DPS sepc page 55
+// only high bits are useful
+enum TDpsDatePrint
+    {
+    EDpsDatePrintDefault = 0x5400,
+    EDpsDatePrintOff = 0x5401,
+    EDpsDatePrintOn = 0x5402
+    };
+
+// define fle name print
+// ref: DPS sepc page 56
+// only high bits are useful
+enum TDpsFileNamePrint
+    {
+    EDpsFileNamePrintDefault = 	0x5500,
+    EDpsFileNamePrintOff = 		0x5501,
+    EDpsFileNamePrintOn = 		0x5503	
+    };
+
+// define image optimization
+// ref: DPS sepc page 56
+// only high bits are useful
+enum TDpsImageOptimize
+    {
+    EDpsImageOptimizeDefault = 	0x5600,
+    EDpsImageOptimizeOff = 		0x5601,
+    EDpsImageOptimizeOn = 		0x5603	
+    };
+
+// define layouts
+// ref: DPS sepc page 56
+// only high bits are useful
+enum TDpsLayout
+    {
+    EDpsLayoutDefault = 	0x5700,
+    EDpsLayout1Up = 		0x5701,
+    EDpsLayout2Up = 		0x5702,
+    EDpsLayout3Up = 		0x5703,
+    EDpsLayout4Up = 		0x5704,
+    EDpsLayout5Up = 		0x5705,
+    EDpsLayout6Up = 		0x5706,
+    EDpsLayout7Up = 		0x5707,
+    EDpsLayout8Up = 		0x5708,
+    EDpsLayout9Up = 		0x5709,
+    EDpsLayoutIndex = 		0x57FE,
+    EDpsLayoutBorderless =  0x57FF	
+    };
+
+// define fixed sizes
+// ref: DPS sepc page 57
+// only high bits are useful
+enum TDpsFixedSizes
+    {
+    EDpsFixedSizeDefault =  0x5800,
+    EDpsFixedSize4x6 =      0x5803,
+    EDpsFixedSize5x7 =      0x5804,
+    EDpsFixedSizeA4 =       0x5811,
+    EDpsFixedSizeLetter =   0x5812
+    };
+
+// define croppings
+// ref: DPS sepc page 57
+// only high bits are useful
+enum TDpsCropping
+    {
+    EDpsCroppingDefault = 	0x5900,
+    EDpsCroppingOff = 		0x5901,
+    EDpsCroppingOn = 		0x5902	
+    };
+
+// define Device status
+// ref: DPS sepc page 61
+// only high bits are useful
+// 1. Print service status
+enum TDpsPrintServiceStatus
+    {
+    EDpsPrintServiceStatusInit = 0,
+    EDpsPrintServiceStatusPrinting = 	0x7000,
+    EDpsPrintServiceStatusIdle = 		0x7001,
+    EDpsPrintServiceStatusPaused = 		0x7002
+    };
+    
+enum TDpsJobStatus
+    {
+    // 2. Job end reasons
+    EDpsJobStatusNotEnded = 					0x7100,
+    EDpsJobStatusEndedOk = 						0x7101,
+    EDpsJobStatusEndedAbortImmediately = 		0x7102,
+    EDpsJobStatusEndedAbortCompleteCurrent = 	0x7103,
+    EDpsJobStatusEndedOther = 					0x7104    
+    };	
+	
+	// 3. Error status
+enum TDpsErrorStatus
+    {
+    EDpsErrorStatusOk =         0x7200,
+    EDpsErrorStatusWarning = 	0x7201,
+    EDpsErrorStatusFatal = 	    0x7202
+    };
+         
+enum TDpsJobEndReasonMajor
+    {
+    // 4. Job end reasons
+    EDpsJobErrorNone = 		0x7300,
+    EDpsJobErrorPaper = 	0x7301,
+    EDpsJobErrorInk = 		0x7302,
+    EDpsJobErrorHardware = 	0x7303,
+    EDpsJobErrorFile = 		0x7304    
+    };
+
+enum TDpsJobEndReasonPaper
+    {
+    EDpsPaperDefault = 0,
+    EDpsPaperEmpty = 0x0100,
+    EDpsPaperLoad = 0x200,
+    EDpsPaperEject = 0x300,
+    EDpsPaperMedia = 0x400,
+    EDpsPaperJam = 0x500,
+    EDpsPaperNearlyEmpty = 0x600,
+    EDpsPaperTypeSizeNoMatch = 0x700
+    };
+ 
+enum TDpsJobEndReasonInk
+    {
+    EDpsInkDefault = 0,
+    EDpsInkEmpty = 0x100,
+    EDpsInkLow = 0x200,
+    EDpsInkWaste = 0x300   
+    };
+   
+enum TDpsJobEndReasonHard
+    {
+    EDpsHardDefault = 0,
+    EDpsHardFatal = 0x0100,
+    EDpsHardServiceCall = 0x0200,
+    EDpsHardNotAvailable = 0x0300,
+    EDpsHardBusy = 0x0400,
+    EDpsHardLever = 0x0500,
+    EDpsHardCoverOpen = 0x0600,
+    EDpsHardNoMarkingHead = 0x0700,
+    EDpsHardInkCoverOpen = 0x0800,
+    EDpsHardNoInkCartridge = 0x0900
+    };
+    
+enum TDpsJobEndReasonFile
+    {
+    EDpsFileDefault = 0,
+    EDpsFilePrintInfo = 0x0100,
+    EDpsFileDecode = 0x0200
+    };
+    
+struct TDpsJobEndReason 
+    {
+    TDpsJobEndReasonMajor iMajor;
+    TDpsJobEndReasonPaper iPaperMinor;
+    TDpsJobEndReasonInk iInkMinor;
+    TDpsJobEndReasonHard iHardMinor;
+    TDpsJobEndReasonFile iFileMinor;
+    };
+    
+enum TDpsDisconnectEnable
+    {
+    // 5. Disconnect Enable
+    EDpsDisconnectEnableFalse = 0x7400,
+    EDpsDisconnectEnableTrue = 	0x7401    
+    };
+    
+enum TDpsCapabilityChanged
+    {
+	// 6. Capability changes
+    EDpsCapabilityChangedFalse = 	0x7500,
+    EDpsCapabilityChangedTrue = 	0x7501
+    };
+    
+enum TDpsNewJobOk
+    {
+    // 7. New Job Ok
+    EDpsNewJobOkFalse = 	0x7600,
+    EDpsNewJobOkTrue = 		0x7601	
+    };
+
+
+// define error reason minor codes
+// ref: DPS sepc page 62
+enum TDpsErrorMinorCode
+    {
+    EDpsErrorPaperEmpty =       0x0100,
+    EDpsErrorPaperJam =         0x0500,
+    EDpsErrorPaperUnsupport =   0x0700,
+    EDpsErrorInkEmpty =         0x0100
+    };
+
+// define About style
+// ref: DPS spec page 68
+// only high bits are useful
+enum TDpsAbortStyle
+    {
+    EDpsAbortStyleImmediately = 		0x9000,
+    EDpsAbortStyleCompleteCurrent = 	0x9001	
+    };
+
+typedef TUint TDpsAttribute;
+
+struct TDpsEle
+    {
+    TDpsElement iElement;
+    // number of arguments included in this element
+    TInt		iNum;
+    };
+    
+typedef RArray<TDpsEle> TDpsEleArray;
+
+struct TDpsArg
+    {
+    TDpsArgument 	iElement;
+    TBuf8<KMaxArgLen>		iContent;
+    };
+	 
+// used for get DPS respond	
+typedef RArray<TDpsArg> TDpsArgArray;
+
+struct TDpsResult
+    {
+    TDpsResultMajorCode iMajorCode;
+    TDpsResultMinorCode iMinorCode;	
+    };
+	
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsfile.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,90 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class reads and writes the file content. 
+*
+*/
+
+
+#ifndef DPSFILE_H
+#define DPSFILE_H
+
+#include <e32base.h>
+#include <f32file.h>
+
+/**
+*   This class creates, reads, writes and deletes dps files.
+*/
+NONSHARABLE_CLASS(CDpsFile) : public CBase
+    {
+public:
+    /**
+    * Two-phased constructor.
+    * @return An instance of CDpsFile.
+    */
+    static CDpsFile* NewL();
+	
+    /**
+    * C++ destructor.
+    */
+    ~CDpsFile();
+
+public: 
+    /**
+    *   Creates the dps script file
+    *   @param aFileName the script file name
+    *   @param aScript the script file content
+    *   @aFileSize the file size
+    *   @return KErrNone if successful or systme wide error if failed
+    */
+    TInt CreateScriptFile(const TDesC& aFileName, const TDesC8& aScript, 
+                          const TInt aFileSize);
+
+    /**
+    *   Gets the content of the script file
+    *   @param aFileName the file name
+    *   @param aScript the file content. It has the valid content after this 
+    *   call is returned.
+    *   @return KErrNone if successful or systme wide error if failed
+    */						  
+    void GetContentL(const TDesC& aFileName, TDes8& aScript);
+	
+    /**
+    *   Deletes the file
+    *   @param aFileName the name of the file to be delted.
+    *   @return KErrNone if successful or systme wide error if failed
+    */
+    TInt Delete(const TDesC& aFileName);
+    
+    /**
+    *   @return RFs& the reference to the file server session, which
+    *   is shared by the whole component (dps engine binary)
+    */
+    inline RFs& FileSession();
+    
+    void FileSizeL(const TDesC& aFileName, TInt& aSize);
+	
+private:
+    
+    /**
+    *   Second phase constructor
+    */
+    void ConstructL();
+    
+private:
+    // file server session, owned by this class
+    RFs iFs;
+    };
+    
+#include "dpsfile.inl"
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsfile.inl	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class reads and writes the file content. 
+*
+*/
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+RFs& CDpsFile::FileSession()
+    {
+    return iFs;
+    }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsoperation.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,312 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This classes define dps operations requests and replys. 
+*
+*/
+
+
+#ifndef DPSOPERATION_H
+#define DPSOPERATION_H
+
+#include <s32file.h>
+#include "dpsparam.h"
+
+class CDpsTransaction;
+/**
+*   This is the base class for all dps operations. 
+*/
+class TMDpsOperation
+    {
+    friend class CDpsTransaction;
+    public:
+        inline TMDpsOperation();
+        /**
+        *   Fills in dps operation request parameters. Dps engine must
+        *   call this function to fill the dps operation request parameters.
+        *   @param aArgs the dps operation request arguments
+        *   @param aElems the dps operation elements
+        *   @param aAttrib the dps operation attributes
+        *   @param aTrader the pointer to CDpsTransaction object for filling 
+        *   the request arguments for Dps Engine
+        *   @return TInt KErrNone if successful or other system error if failed
+        */
+    
+    protected:
+        inline virtual TInt FillReqArgs(TDpsArgArray& aArgs, 
+                                        TDpsEleArray& aElems,
+                                        TDpsAttribute& aAttrib, 
+                                        CDpsTransaction* aTrader);
+            
+       
+        /**
+        *   Fills in the dps operation reply parameters. Dps engine uses this
+        *   function after the dps operation gets responsed. After this call,
+        *   dps engine will call RequestComplete() to inform the client the
+        *   completion of the dps operation.
+        *   @param aArgs dps operation reply arguments.
+        *   @param aParam the pointer to CDpsTransacton object for filling 
+        *   the reply arguments for the client (print UI engine)
+        *   @return TInt KErrNone if successful or other system error if failed
+        */    
+        inline virtual TInt FillRepArgs(const TDpsArgArray& aArguments, 
+                                        CDpsTransaction* aTrader);
+                                        
+           
+        /**
+        *   Creates the Dps request script
+        *   @param aArgs the arguments of the Dps request
+        *   @param aElements the elements of the Dps request
+        *   @param aAttribute the attribute of the Dps request
+        *   @param aScript the buffer of the script
+        *   @param aTrader the pointer to the CDpsTransaction object for 
+        *   creating the Dps script
+        */
+        IMPORT_C virtual void CreateReqScriptL(const TDpsArgArray& aArguments, 
+                                              const TDpsEleArray& aElements,
+                                              TDpsAttribute aAttribute, 
+                                              RWriteStream& aScript, 
+                                              CDpsTransaction* aTrader); 
+        
+        
+    public:
+        // the dps operation result
+        TDpsResult iResult;
+        // the dps operaton enumeration
+        TDpsSupportedOp iOperation;
+    };
+
+/**
+*   The class for dps startJob operation
+*/
+class TDpsStartJob : public TMDpsOperation
+    {
+    friend class CDpsTransaction;
+    public:
+        /**
+        *   Default constructor
+        */
+        inline TDpsStartJob();
+            
+    private:
+        /**
+        *   @see TMDpsOperation 
+        */
+        IMPORT_C TInt FillReqArgs(TDpsArgArray& aArgs, TDpsEleArray& aElems,
+                                  TDpsAttribute& aAttrib, 
+                                  CDpsTransaction* aTrader);
+        
+        /**
+        *   @see TMDpsOperation 
+        */                          
+        IMPORT_C void CreateReqScriptL(const TDpsArgArray& aArgs, 
+                                      const TDpsEleArray& aElements, 
+                                      TDpsAttribute aAttribute, 
+                                      RWriteStream& aScript, 
+                                      CDpsTransaction* aTrader); 
+        
+    public:    
+        // the request operation parameter which needed to be filled by 
+        // the client    
+        TDpsStartJobReq iReqParam;
+        
+    };
+
+/**
+*   The class for dps abortJob operation
+*/    
+class TDpsAbortJob : public TMDpsOperation
+    {
+    friend class CDpsTransaction;
+    public:
+        /**
+        *   Default constructor
+        */
+        inline TDpsAbortJob();
+        
+    private:
+        /**
+        *   @see TMDpsOperation 
+        */
+        IMPORT_C TInt FillReqArgs(TDpsArgArray& aArgs, TDpsEleArray& aElems,
+                                 TDpsAttribute& aAttrib, 
+                                 CDpsTransaction* aTrader);
+        
+    public:    
+        // the request operation parameter which needed to be filled by 
+        // the client        
+        TDpsAbortJobReq iReqParam;
+        
+    };
+
+/**
+*   The class for dps continueJob operation
+*/        
+class TDpsContinueJob : public TMDpsOperation
+    {
+    friend class CDpsTransaction;
+    public:
+        /**
+        *   Default constructor
+        */
+        inline TDpsContinueJob();           
+    };
+
+/**
+*   The class for dps continueJob operation
+*/    
+class TDpsGetJobStatus : public TMDpsOperation
+    {
+    friend class CDpsTransaction;
+    public:    
+        /**
+        *   Default constructor
+        */
+        inline TDpsGetJobStatus();
+        
+    private:        
+        /**
+        *   @see TMDpsOperation 
+        */    
+        IMPORT_C TInt FillRepArgs(const TDpsArgArray& aArgs, 
+                                  CDpsTransaction* aTrader);
+        
+    public:    
+        // the request operation parameter which needed to be filled by 
+        // the client
+        TDpsJobStatusRep iRepParam;
+        
+    };
+ 
+/**
+*   The class for dps continueJob operation
+*/    
+class TDpsGetPrinterStatus : public TMDpsOperation
+    {
+    friend class CDpsTransaction;
+    public:    
+        /**
+        *   Default constructor
+        */
+        inline TDpsGetPrinterStatus();
+        
+    private:        
+        /**
+        *   @see TMDpsOperation 
+        */    
+        IMPORT_C TInt FillRepArgs(const TDpsArgArray& aArgs, 
+                                  CDpsTransaction* aTrader);
+        
+    public:    
+        // the request operation parameter which needed to be filled by 
+        // the client
+        TDpsPrinterStatusRep iRepParam;
+        
+    };
+    
+/**
+*   The class for dps continueJob operation
+*/
+class TDpsGetCapability : public TMDpsOperation
+    {
+    friend class CDpsTransaction;
+    public:
+        /**
+        *   Default constructor
+        */
+        inline TDpsGetCapability();
+        
+    private:        
+        /**
+        *   @see TMDpsOperation 
+        */
+        IMPORT_C TInt FillReqArgs(TDpsArgArray& aArgs, TDpsEleArray& aElems,
+                                 TDpsAttribute& aAttrib, 
+                                 CDpsTransaction* aTrader);
+        /**
+        *   @see TMDpsOperation 
+        */                                 
+        IMPORT_C TInt FillRepArgs(const TDpsArgArray& aArgs, 
+                                  CDpsTransaction* aParam);
+        
+        /**
+        *   @see TMDpsOperation 
+        */                          
+        IMPORT_C void CreateReqScriptL(const TDpsArgArray& aArgs, 
+                                       const TDpsEleArray& aElements,
+                                       TDpsAttribute aAttribute, 
+                                       RWriteStream& aScript, 
+                                       CDpsTransaction* aTrader);
+        
+    public:    
+        // the request operation parameter which needed to be filled by 
+        // the client
+        TDpsCapReq iReqParam;
+        // the request operation parameter which needed to be filled by 
+        // the client
+        TDpsCapRep iRepParam;
+        
+    };
+
+/**
+*   The class for dps continueJob operation
+*/    
+class TDpsConfigPrintService : public TMDpsOperation
+    {
+    friend class CDpsTransaction;
+    public:
+        /**
+        *   Default constructor
+        */
+        inline TDpsConfigPrintService();
+        
+    private:        
+        /**
+        *   @see TMDpsOperation 
+        */
+        IMPORT_C TInt FillReqArgs(TDpsArgArray& aArgs, TDpsEleArray& aElems,
+                                 TDpsAttribute& aAttrib, 
+                                 CDpsTransaction* aTrader);
+        /**
+        *   @see TMDpsOperation 
+        */                                 
+        IMPORT_C TInt FillRepArgs(const TDpsArgArray& aArgs, 
+                                  CDpsTransaction* aTrader);
+                                                                           
+    public:    
+        // the request operation parameter which needed to be filled by 
+        // the client
+        TDpsConfigPrintReq iReqParam;
+        
+        // the request operation parameter which needed to be filled by 
+        // the client
+        TDpsConfigPrintRep iRepParam;
+
+    };
+
+/**
+*   The class defines dps events
+*/    
+NONSHARABLE_CLASS(TDpsEvents) 
+	{
+	public:
+	    // the event enumeration
+		TDpsEvent iEvent;
+		// jobStatus event
+		TDpsGetJobStatus iJobEvent;
+		// printerStatus event
+		TDpsGetPrinterStatus iPrinterEvent;
+	};    
+	
+#include "dpsoperation.inl"	
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsoperation.inl	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,113 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  inline functions of TMDpsOperation
+*
+*/
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TMDpsOperation::TMDpsOperation()
+    {
+    iOperation = EDpsEmptyRequest;
+    iResult.iMajorCode = EDpsResultOk;
+    iResult.iMinorCode = EDpsResultNone;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TInt TMDpsOperation::FillReqArgs(TDpsArgArray&, TDpsEleArray&,
+                                 TDpsAttribute&, CDpsTransaction*)
+    {
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TInt TMDpsOperation::FillRepArgs(const TDpsArgArray&, CDpsTransaction*)
+     {
+     return KErrNone;
+     } 
+ 
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TDpsStartJob::TDpsStartJob() : TMDpsOperation()
+    {
+    iOperation = EDpsStartJob;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TDpsAbortJob::TDpsAbortJob() : TMDpsOperation()
+    {
+    iOperation = EDpsAbortJob;
+    iReqParam.iAbortStyle = EDpsAbortStyleImmediately;
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+TDpsContinueJob::TDpsContinueJob() : TMDpsOperation()
+    {
+    iOperation = EDpsContinueJob;
+    }
+  
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+TDpsGetJobStatus::TDpsGetJobStatus() : TMDpsOperation()
+    {
+    iOperation = EDpsGetJobStatus;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+TDpsGetPrinterStatus::TDpsGetPrinterStatus() : TMDpsOperation()
+    {
+    iOperation = EDpsGetPrinterStatus;
+    iRepParam = TDpsPrinterStatusRep();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+TDpsGetCapability::TDpsGetCapability() : TMDpsOperation()
+    {
+    iOperation = EDpsGetCapability;
+    iReqParam = TDpsCapReq();
+    }
+ 
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+TDpsConfigPrintService::TDpsConfigPrintService() : TMDpsOperation()
+    {
+    iOperation = EDpsConfigPrintService;         
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsparam.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,225 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  These classes define the dps operation parameters. 
+*
+*/
+
+
+#ifndef DPSPARAM_H
+#define DPSPARAM_H
+
+#include "dpsdefs.h"
+
+enum TDpsSupportedOp
+    {
+    EDpsEmptyRequest = 0,
+    EDpsConfigPrintService,
+    EDpsGetCapability,
+    EDpsGetJobStatus,
+    EDpsGetPrinterStatus,
+    EDpsStartJob,
+    EDpsAbortJob,
+    EDpsContinueJob
+    };
+
+struct TDpsArgsInt
+    {
+    TDpsArgument 	iElement;
+    TUint32		iContent;
+    };
+
+/**
+*   The class defines the print job information which is needed by
+*   startJob operation
+*/
+NONSHARABLE_CLASS(TDpsPrintInfo)
+    {
+public:
+    /**
+    *
+    */
+    inline TDpsPrintInfo();
+    
+    /**
+    *   Resets all parameters
+    */    
+    IMPORT_C  void Reset();
+    
+    // the file name        
+    TBuf<KMaxArgLen> iFile; 
+               
+    TBool isDPOF;
+    // this is 0 when UI passed it to dps. Dps engine must find the ID
+    // for this file by asking ptp server
+    TUint32 iFileID; 
+    // if don't need to print file name, this is EFalse
+    TBool iFileName;
+    // if don't need to print date, this is empty
+    TBuf<KDateLen> iDate;
+    // if only one cope, this is emtpy
+    TInt iCopies;
+    // if not DPOF, this is emtpy
+    TInt iPrtPID;
+    // if not DPOF, this is emtpy
+    TInt iCopyID;
+    };
+
+/**
+*   Dps version defination
+*/
+NONSHARABLE_CLASS(TDpsVersion)
+    {
+    public:
+        TInt iMajor;
+        TInt iMinor;
+    };
+
+/**
+*   AbortJob request
+*/	
+NONSHARABLE_CLASS(TDpsAbortJobReq)
+    {
+    public:
+        TInt iAbortStyle;
+    };
+    
+/**
+*   ConfigurePrintService request
+*/
+class TDpsConfigPrintReq
+    {
+    public:
+        RArray<TDpsVersion> iDpsVersions;
+        TBuf8<KMaxArgLen> iVendorName;
+        TDpsVersion iVendorVersion;
+        TBuf8<KMaxArgLen> iProductName;
+        TBuf8<KMaxArgLen> iSerialNo;
+        
+        /**
+        *   Destructor. Declared as virtual so that it will be called by 
+        *   its derived class.
+        */
+        inline virtual ~TDpsConfigPrintReq();
+        
+        /**
+        *   Resets all class variables.
+        */
+        inline void Reset();        
+    };
+
+/**
+*   ConfigurePrintService reply
+*/
+NONSHARABLE_CLASS(TDpsConfigPrintRep) : public TDpsConfigPrintReq
+    {
+    public:
+        TInt iPrintAvailable;      
+    };
+    
+/**
+*	GetCapability request.
+*/
+NONSHARABLE_CLASS(TDpsCapReq)
+    {
+    public:
+        TDpsArgument iCap;
+        // layouts and paperTypes requests attributes
+        TDpsAttribute iAttribute;
+    };	
+	    
+/**
+*   GetCapability reply
+*/
+NONSHARABLE_CLASS(TDpsCapRep) : public TDpsCapReq
+    {
+    public:
+        RArray<TUint> iContent;
+        RArray<TDpsPaperType> iPaperType;
+        /**
+        *   Destructor
+        */
+        inline ~TDpsCapRep();
+        
+        /**
+        *   Resets all class variables
+        */ 
+        inline void Reset();
+    };
+                                	
+/**
+*	StartJob request has printInfo and jobConfig parameters.
+*/
+NONSHARABLE_CLASS(TDpsStartJobReq)
+    {
+    public:
+        /**
+	    *   Resets all member variables
+        */
+        inline void Reset();
+	    	        
+        /**
+        *   Gets the number of all parameters, including ones under elements
+        *   @return the number of parameters
+        */
+        IMPORT_C TInt GetParamNum();
+		
+        /**
+        *   Destructor
+        */    
+        inline ~TDpsStartJobReq(); 
+        RArray<TDpsArgsInt> iJobConfig;
+        //there might be multiple printInfo in case of several pictures are 
+        //selected to be printed 
+        RArray<TDpsPrintInfo> iPrintInfo;		
+    };	
+
+/**
+*   This class is for job status reply
+*/	
+NONSHARABLE_CLASS(TDpsJobStatusRep)
+    {
+    public:
+        
+        /**
+        *   
+        */
+        inline TDpsJobStatusRep();
+        /**
+        *   Resets all memeber variables
+        */
+        IMPORT_C void Reset();
+        
+        TInt iProgress;
+        TInt iImagesPrinted;
+        TFileName iFilePath;
+        TInt iPrtPID;
+        TInt iCopyID;
+    };
+    
+/**
+*   This class is for device status reply
+*/    
+NONSHARABLE_CLASS(TDpsPrinterStatusRep)
+    {
+    public:
+        TDpsPrintServiceStatus iPrintStatus;
+        TDpsJobStatus iJobStatus;
+        TDpsErrorStatus iErrorStatus;
+        TDpsJobEndReason iJobEndReason;
+        TBool iDisconnectEnable;
+        TBool iCapabilityChange;
+        TBool  iNewJobOk;
+    };
+#include "dpsparam.inl"    
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsparam.inl	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  inline functions of dps parameter. 
+*
+*/
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TDpsPrintInfo::TDpsPrintInfo()
+    {
+    Reset();
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+void TDpsConfigPrintReq::Reset()
+    {
+    iDpsVersions.Reset();
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+TDpsConfigPrintReq::~TDpsConfigPrintReq()
+    {
+    iDpsVersions.Close();
+    }       
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+TDpsCapRep::~TDpsCapRep()    
+    {
+    Reset();
+    }    
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+void TDpsStartJobReq::Reset()
+    {
+    iJobConfig.Reset();
+    iPrintInfo.Reset();
+    }   
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+TDpsStartJobReq::~TDpsStartJobReq() 
+    {
+	iJobConfig.Close();
+	iPrintInfo.Close();
+	}
+	
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//			    
+void TDpsCapRep::Reset()
+    {
+    iContent.Reset();
+    iPaperType.Close();
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//			        
+TDpsJobStatusRep::TDpsJobStatusRep()    
+    {
+    Reset();
+    }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsptpnotifier.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class defines functions of setting personality to 
+*                PTP. 
+*
+*/
+
+
+#ifndef DPSPTPNOTIFIER_H
+#define DPSPTPNOTIFIER_H
+
+#include <e32base.h>
+
+class CDpsUsbNotifier;
+
+/**
+*   Class for monitoring Ptp personality setting
+*/
+NONSHARABLE_CLASS(CDpsPtpNotifier) : public CActive
+    {
+    public:
+        /**
+        *   Two phase constructor
+        *   @param aParent the pointer to UsbNotifier object
+        *   @return a new created PtpNotifier object
+        */
+        static CDpsPtpNotifier* NewL(CDpsUsbNotifier* aParent);
+        
+        /**
+        *   Destructor
+        */
+        ~CDpsPtpNotifier();
+        
+        /**
+        *   Called by UsbNotifier to subscribe set personality notification
+        */
+        void ChangePtpPersonality();
+                            
+    private: // Functions derived from CActive.
+	    /**
+	    *   @see CActive
+	    */
+    	void RunL();
+    	
+    	/**
+    	*   @see CActive
+    	*/
+	    void DoCancel();
+	    
+	    /**
+	    *   @see CActive
+	    */
+	    TInt RunError(TInt aError);
+	    
+	private:
+	    /**
+	    * Default constructor
+	    */
+	    CDpsPtpNotifier(CDpsUsbNotifier* aParent);
+	    
+	private:
+	    // not owned by this class
+	    CDpsUsbNotifier* iNotifier;  
+	    
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsscriptreceiver.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,97 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class defines the dps script receiving function. 
+*
+*/
+
+
+#ifndef DPSSCRIPTRECEIVER_H
+#define DPSSCRIPTRECEIVER_H
+
+#include <e32base.h>
+
+class CDpsEngine;
+class CDpsStateMachine;
+
+/**
+*   This class is an active object. It listens on the ptp server
+*   object receiving notification.
+*/
+NONSHARABLE_CLASS(CDpsScriptReceiver) : public CActive
+    {	
+    public:
+       /**
+        *   Two phase constructor
+        *   
+        *   @param aOperator the pointer to the dps state machine
+        *   @return a CDpsScriptReceiver instance
+        */
+        static CDpsScriptReceiver* NewL(CDpsStateMachine* aOperator);
+								       
+        /**
+        *   Destructor
+        */								       
+        ~CDpsScriptReceiver();
+		
+        /**
+        *   Issues the request of receiving.
+        */
+        void WaitForReceive();
+		
+        /**
+        *   @return the file name of the object been received
+        */
+        const TDesC& FileNameAndPath();
+			
+    private: // Functions derived from CActive.
+        /**
+        *   @see CActive
+        */
+    	void RunL();
+    	
+    	/**
+    	*   @see CActive
+    	*/
+        void DoCancel();
+	    
+        /**
+        *   @see CActive
+        */
+        TInt RunError(TInt aError);
+	    
+    private:
+        
+        /**
+        *   Default constructor
+        *   
+        *   @param aOperator the pointer to the dps state machine
+        */
+        CDpsScriptReceiver(CDpsStateMachine* aOperator);    
+	    
+        /**
+        *   Gets the file name from the full filename
+        *   @param aFileName the full filename including file path
+        *   @return KErrNone if Ok, otherwise the system wide error
+        */
+        TInt GetFileName(TDes& aFileName);
+		
+    private:
+        
+        // not owned by this class
+        CDpsStateMachine* iOperator;   
+        // file name of received script file 
+        TFileName iFileNameAndPath;
+    };
+						
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsscriptsender.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,87 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class defines the dps script sending function. 
+*
+*/
+
+
+#ifndef DPSSCRIPTSENDER_H
+#define DPSSCRIPTSENDER_H
+
+#include <e32base.h>
+
+class CDpsEngine;
+class CDpsStateMachine;
+
+/**
+*   This class is an active object. It sends the script to ptp server and 
+*   listens on the ptp server for notification of sending result.
+*/
+NONSHARABLE_CLASS(CDpsScriptSender) : public CActive
+    {
+    public:
+        /**
+        *   Two phase constructor
+        *   
+        *   @param aOperator the pointer to the dps state machine
+        *   @return a CDpsScriptSender instance
+        */
+        static CDpsScriptSender* NewL(CDpsStateMachine* aOperator);
+		
+        /**
+        *   Destructor
+        */
+        ~CDpsScriptSender();
+		
+        /**
+        *   Issues sending request
+        *   @param aReply ETrue is the script is the reply, EFalse if the 
+        *   script is the request.
+        */
+        TInt SendScript(TBool aReply);
+	
+    private: // Functions derived from CActive.
+        /**
+        *   @see CActive
+        */
+    	void RunL();
+    	
+        /**
+        *   @see CActive
+        */
+        void DoCancel();
+	    
+        /**
+        *   @see CActive
+        */
+        TInt RunError(TInt aError);
+	    
+    private:
+        /**
+        *   Default constructor
+        *   
+        *   @param aOperator the pointer to the dps state machine
+        */
+        CDpsScriptSender(CDpsStateMachine* aOperator);    
+	
+    private:
+        
+        // not owned by this class
+        CDpsStateMachine* iOperator;
+	   
+        // telling if the current sending session is a reply or a request
+        TBool iReply;
+    };
+				
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsstate.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,179 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  These classes define the dps states. 
+*
+*/
+
+
+#ifndef DPSSTATE_H
+#define DPSSTATE_H
+
+#include <e32base.h>
+class CDpsStateMachine;
+
+/**
+*   This class is the base classes for all dps state classes.
+*   We follow state design pattern here so the state class defines all
+*   transactions among states as member functions.
+*/
+class MDpsState
+    {
+    public:
+                
+        /**
+        *   Script sent notification
+        */
+        virtual void ScriptSentNotifyL(TBool aReply) = 0;
+        
+        /**
+        *   Script received notification
+        */
+        virtual void ScriptReceivedNotifyL(TBool aReply) = 0;
+        
+        /**
+        *   Error handling of the transaction
+        */
+        virtual void Error(TInt aErr) = 0; 
+    };
+
+/**
+*   Idle state class
+*/
+NONSHARABLE_CLASS(TDpsIdleState) : public MDpsState
+    {
+    public:
+        /**
+        *   Constructor
+        */
+        TDpsIdleState(CDpsStateMachine* aStateMachine);
+    public:
+                
+        /**
+        *   @see MDpsState
+        */
+        void ScriptSentNotifyL(TBool aReply);
+        
+        /**
+        *   @see MDpsState
+        */
+        void ScriptReceivedNotifyL(TBool aReply);
+        
+        /**
+        *   @see MDpsState
+        */    
+        void Error(TInt aErr);
+
+        
+    private:
+        CDpsStateMachine* iStateMachine;
+    };
+
+/**
+*   Sending Request state class. Device sending request starts form this state
+*/
+NONSHARABLE_CLASS(TDpsSendingReqState) : public MDpsState
+    {
+    public:
+        /**
+        *   Constructor
+        */
+        TDpsSendingReqState(CDpsStateMachine* aStateMachine);
+            
+    public:
+        
+        /**
+        *   @see MDpsState
+        */    
+        void ScriptSentNotifyL(TBool aReply);
+        
+        /**
+        *   @see MDpsState
+        */    
+        void ScriptReceivedNotifyL(TBool aReply);
+        
+        /**
+        *   @see MDpsState
+        */    
+        void Error(TInt aErr);        
+            
+    private:
+        CDpsStateMachine* iStateMachine;
+    };
+
+/**
+*   Waiting Reply state class (script has been sent)
+*/    
+NONSHARABLE_CLASS(TDpsWaitingRepState) : public MDpsState
+    {
+    public:
+        /**
+        *   Constructor
+        */
+        TDpsWaitingRepState(CDpsStateMachine* aStateMachine);
+            
+    public:
+               
+        /**
+        *   @see MDpsState
+        */    
+        void ScriptSentNotifyL(TBool aReply);
+        
+        /**
+        *   @see MDpsState
+        */
+        void ScriptReceivedNotifyL(TBool aReply);
+        
+        /**
+        *   @see MDpsState
+        */    
+        void Error(TInt aErr);        
+            
+    private:
+        CDpsStateMachine* iStateMachine;
+    };
+    
+/**
+*   Sending Reply state class. The device starts replying the host request 
+*   in this state.
+*/     
+NONSHARABLE_CLASS(TDpsSendingRepState) : public MDpsState
+    {
+    public:
+        /**
+        *   Constructor
+        */
+        TDpsSendingRepState(CDpsStateMachine* aStateMachine);
+            
+    public:
+          
+        /**
+        *   @see MDpsState
+        */    
+        void ScriptSentNotifyL(TBool aReply);
+         
+        /**
+        *   @see MDpsState
+        */    
+        void ScriptReceivedNotifyL(TBool aReply);
+        
+        /**
+        *   @see MDpsState
+        */    
+        void Error(TInt aErr);
+                    
+    private:
+        CDpsStateMachine* iStateMachine;
+    };
+    
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsstatemachine.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,209 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class defines the dps state machine. 
+*
+*/
+
+
+#ifndef DPSSTATEMACHINE_H
+#define DPSSTATEMACHINE_H
+
+#include "dpsconst.h"
+#include "dpsdefs.h"
+
+class CDpsTransaction;
+class CDpsEngine;
+class CDpsScriptReceiver;
+class MDpsState;
+class TMDpsOperation;
+class CDpsScriptSender;
+
+/**
+*   This class defines the dps state machine using the state design pattern
+*/
+NONSHARABLE_CLASS(CDpsStateMachine) : public CBase
+    {
+	    
+    public:
+        /**
+        *   Two phase constructor
+        *   @param aEngine a pointer to dps engine object
+        *   @return the CDpsOperator instance
+        */
+        static CDpsStateMachine* NewL(CDpsEngine *aEngine);
+        
+        /**
+        *   Destructor
+        */
+        ~CDpsStateMachine();   
+        
+        /**
+        *   Creates the dps transaction. It further calls CreateRequest()
+        *   to create dps device request script.
+        *   @param aParam the dps operation object, passed from UI
+        */
+        void StartTransactionL(TMDpsOperation* aOperation);
+        
+        /**
+        *   Initializes the state machine
+        */
+        void Initialize();
+        
+        /**
+        *   Handles errors
+        */    
+        inline void Error(TInt err);
+                
+        /**
+        *   Notifies script sent
+        */
+        inline void ScriptSentNotifyL(TBool aReply);
+            
+        /**
+        *   Notifies script received
+        */    
+        inline void ScriptReceivedNotifyL(TBool aReply);
+         
+        /**
+        *   Sets the current state
+        *   @param aState the state to be set
+        */    
+        inline void SetState(MDpsState* aState);
+          
+        /**
+        *   Gets the idle state
+        */    
+        inline MDpsState* IdleState() const; 
+          
+        /**
+        *   @return the sending request state object
+        */    
+        inline MDpsState* SendingReqState() const;
+          
+        /**
+        *   @return the waiting for reply state object
+        */    
+        inline MDpsState* WaitingRepState() const;
+             
+        /**
+        *   @return the sending reply state object
+        */    
+        inline MDpsState* SendingRepState() const;
+          
+        /**
+        *   @return the CDpsScriptReceiver object
+        */    
+        inline CDpsScriptReceiver* ScriptReceiver() const;
+        
+        /**
+        *   @return CDpsScriptSender pointer 
+        */
+        inline CDpsScriptSender* ScriptSender() const;
+          
+        /**
+        *   @return the CDpsTransaction object
+        */    
+        inline CDpsTransaction* Trader() const;
+          
+        /**
+        *   @return the current Dps operation enum 
+        */    
+        inline TDpsOperation Operation() const;
+          
+        /**
+        *   Sets the current Dps operation enum
+        *   @param aOp the Dps operation enum to be set
+        */    
+        inline void SetOperation(TDpsOperation aOp);
+          
+        /**
+        *   @return the Dps operation object
+        */    
+        inline TMDpsOperation* MOperation() const;
+          
+        /**
+        *   @return the Dps event enum
+        */    
+        inline TDpsEvent Event() const;
+          
+        /**
+        *   Sets the current Dps event
+        *   @param aEvent the Dps event to be set
+        */    
+        inline void SetEvent(TDpsEvent aEvent);
+        
+        /**
+        *   @return the current state.
+        */
+        inline MDpsState* CurState() const;
+        
+        /**
+        *   @return the dps engine object.
+        */
+        inline CDpsEngine* DpsEngine() const;
+        
+        /**
+        *
+        */
+        inline TInt CurError() const;
+            
+    private:
+        /**
+        *   Default constructor
+        *   @param aEngine a pointer to dps engine object
+        */
+        CDpsStateMachine(CDpsEngine* aEngine);
+        
+        /**
+        *   Two phase constructor. The functions which called in constructor
+        *   and might leave should be called here
+        */
+        void ConstructL();     
+        
+                                    
+    private:
+        // owned by this class
+        MDpsState* iIdleState;
+        // owned by this class
+        MDpsState* iSendingReqState;
+        // owned by this class
+        MDpsState* iWaitingRepState;
+        // owned by this class
+        MDpsState* iSendingRepState;
+        // pointer to the current state object
+        MDpsState* iCurState;
+        // not owned by this class
+        TMDpsOperation* iMOperation;
+     
+        // not owned by this class  
+        CDpsEngine  *iEngine;
+        // the current dps operation, can be empty
+        TDpsOperation iOperation;
+        // the current dps event, can be empty
+        TDpsEvent iEvent;
+        // the pointer to dps operation object, which takes
+        // care of creating and parsing dps script
+         // owned by this class
+        CDpsTransaction *iTrader;
+        // the pointer to dps script receiving notifier
+        // owned by this class
+        CDpsScriptReceiver* iScriptReceiver;
+        
+        // the pointer to script sender object, owned by this class
+        CDpsScriptSender* iScriptSender;
+        TInt iCurError;
+    };
+
+#include "dpsstatemachine.inl"
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsstatemachine.inl	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,191 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  inline functions of CDpsStatemachine
+*
+*/
+
+
+#include "dpsstate.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+void CDpsStateMachine::ScriptSentNotifyL(TBool aReply)
+    {
+    iCurState->ScriptSentNotifyL(aReply);
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsStateMachine::ScriptReceivedNotifyL(TBool aReply)
+    {
+    iCurState->ScriptReceivedNotifyL(aReply);
+    }
+        
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsStateMachine::Error(TInt err)
+    {
+    iCurError = err;
+    iCurState->Error(err);
+    }
+        
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+void CDpsStateMachine::SetState(MDpsState* aState)
+    {
+    iCurState = aState;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+MDpsState* CDpsStateMachine::IdleState() const
+    {
+    return iIdleState;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+MDpsState* CDpsStateMachine::SendingReqState() const
+    {
+    return iSendingReqState;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+MDpsState* CDpsStateMachine::WaitingRepState() const
+    {
+    return iWaitingRepState; 
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+MDpsState* CDpsStateMachine::SendingRepState() const
+    {
+    return iSendingRepState;
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CDpsScriptReceiver* CDpsStateMachine::ScriptReceiver() const
+    {
+    return iScriptReceiver;
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//                
+CDpsScriptSender* CDpsStateMachine::ScriptSender() const
+    {
+    return iScriptSender;
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CDpsTransaction* CDpsStateMachine::Trader() const
+    {
+    return iTrader;
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TDpsOperation CDpsStateMachine::Operation() const
+    {
+    return iOperation;
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsStateMachine::SetOperation(TDpsOperation aOp)
+    {
+    iOperation = aOp;
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TMDpsOperation* CDpsStateMachine::MOperation() const
+    {
+    return iMOperation;
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TDpsEvent CDpsStateMachine::Event() const
+    {
+    return iEvent;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+void CDpsStateMachine::SetEvent(TDpsEvent aEvent)
+    {
+    iEvent = aEvent;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+MDpsState* CDpsStateMachine::CurState() const
+    {
+    return iCurState;
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//        
+CDpsEngine* CDpsStateMachine::DpsEngine() const
+    {
+    return iEngine;
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//            
+TInt CDpsStateMachine::CurError() const
+    {
+    return iCurError;
+    }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpstransaction.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,192 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class creates and parses dps operations. 
+*
+*/
+
+
+#ifndef DPSTRANSACTION_H
+#define DPSTRANSACTION_H
+
+#include <e32base.h>
+#include "dpsdefs.h"
+#include "dpsoperation.h"
+
+class 	CDpsFile;
+class 	CDpsEngine;
+class   CDpsXmlGenerator;
+class	CDpsXmlParser;
+class 	CDpsScriptSender;
+class   TDpsVersion;
+class   CDpsStateMachine;
+class   TMDpsOperation;
+
+/**
+*   This class creates and parses dps operation (request and reply)
+*/
+NONSHARABLE_CLASS(CDpsTransaction) : public CBase
+    {
+    public:
+        /**
+        *   Two phase constructor
+        *   
+        *   @param iOperator the pointer to dps operation object
+        *   @return the dps transaction instance
+        */
+        static CDpsTransaction* NewL(CDpsStateMachine* iOperator);    
+
+        /**
+        *   Destructor
+        */        							 
+        ~CDpsTransaction();
+        
+    public:
+        /**
+        *   Creates the dps operation request
+        *   @param aParam the dps operation parameters
+        */
+    	void CreateRequestL(TMDpsOperation* aOperation);
+    	
+    	/**
+    	*   Parses dps operation script
+    	*   @param aReply if the script is the reply from the host
+    	*   aReply is ETrue, otherwise the script must be the request
+    	*   from the device and aReply is EFalse
+    	*/
+    	void ParseScriptL(TBool aReply);
+    	
+    	/**
+    	*   @return ETrue if the script is the reply from the host,
+    	*   EFalse if the script is the request from the host
+    	*/
+    	inline TBool IsReply();
+    	
+    	/**
+    	*   @return the CDpsXmlParser object
+    	*/
+    	inline CDpsXmlParser* Parser();
+    	    
+    	/**
+    	*   @return the CDpsXmlGenerator object
+    	*/
+    	inline CDpsXmlGenerator* Generator();    
+    	    
+    	/**
+    	*   @return the CDpsEngine object
+    	*/    
+        inline CDpsEngine* Engine();
+    	
+    	    					 
+		/**
+    	*   Converts the version in descriptor tpye to TDpsVersion type
+    	*   @param aParser the version in descriptor 
+    	*   @param aVersoin the version in TDpsVersion and will be returned
+    	*   @return KErrNone if OK, other system error if failed
+    	*/        
+        TInt ConvertVersion(TLex8& aParser, TDpsVersion& aVersion);    
+        
+        /**
+        *   @return CDpsStateMachine pointer to dps state machine object
+        */
+        inline CDpsStateMachine* Operator();
+        
+        /**
+        *   Parses the string of percentage to integer
+        *   @param aPer the string of percentage to be parsed
+        *   @return TInt the percentage in integer
+        */    			
+        TInt ParsePercentage(const TDes8& aPer);
+        
+        /**
+        *   @return the error of result in integer
+        */
+        inline TInt ResultErr();
+                    
+            
+        /**
+        *   @return CDpsFile pointer to dps file object
+        */
+        inline CDpsFile* FileHandle();
+        
+        /**
+        *
+        */
+        void HandleHostRequestError(TInt aErr);
+                    
+    private:
+        /**
+        *   Default constructor
+        *   
+        *   @param iOperator the pointer to the dps operator 
+        */	
+    	CDpsTransaction(CDpsStateMachine* iOperator);    
+    	
+    	/**
+    	*   Second phase constructor. 
+    	*/
+    	void ConstructL();
+    	
+    	/**
+    	*   Creates the dps event reply.
+    	*   @param aArguments dps event arguments
+    	*   @param aResult the result of the reply. See Dps spec for
+    	*   detail result value
+    	*/
+    	void CreateEventReplyL(TDpsEvent aEvent, const TDpsResult& aResult);
+    	
+    	/**
+    	*   Creates the dps request reply based on host dps request.
+    	*   There is only one dps request from host (others are from device) -
+    	*   GetFileID
+    	*   @param aArgs the dps argument from the dps xml script
+    	*   @param aResult the reply result to be filling to the dps xml script
+    	*/
+    	void CreateRequestReplyL(const TDpsArgArray& aArgs, 
+                                 const TDpsResult& result);
+        
+        /**
+        *   Removes the unprintable chars (LF, CR, TAB and spaces) between 
+        *   two XML attributes. It seems
+        *   sybmian XML framework does filter out these character even though
+        *   they are not belong to the attribute. Some printers (Cannon) send
+        *   Dps request (XML script) in human readable format, e.g. including
+        *   LF, CR and spaces among XML attributes.
+        *   @param aScript the XML script to be filtered out
+        */
+    	void Filter(TDes8& aScript);
+    	
+    	/**
+    	*   Changes the file path for GetFileID request
+    	*
+    	*/
+    	void SubstitutePath(TDes8& aPath);
+    	
+    private:
+        
+    	// the pointer to dps operator object
+    	// not owned by this class
+        CDpsStateMachine* iOperator;
+        // the pointer to xml generator object, owned by this class
+        CDpsXmlGenerator *iXmlGen;
+        // the pointer to xml parser object, owned by this class
+        CDpsXmlParser *iXmlPar; 
+        // the pointer to file generator object, owned by this class
+        CDpsFile *iFile;
+                
+        // the current parsed script is reply or request
+        TBool iReply;  
+    };
+
+#include "dpstransaction.inl"
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpstransaction.inl	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class creates and parses dps operations. 
+*
+*/
+
+#include "dpsstatemachine.h"
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+TBool CDpsTransaction::IsReply()
+	{
+	return iReply;
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+CDpsXmlParser* CDpsTransaction::Parser()
+    {
+    return iXmlPar;
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//        
+CDpsEngine* CDpsTransaction::Engine()
+    {
+    return iOperator->DpsEngine();
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//        
+CDpsXmlGenerator* CDpsTransaction::Generator()
+    {
+    return iXmlGen;
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//        
+CDpsStateMachine* CDpsTransaction::Operator()
+    {
+    return iOperator;
+    }
+          
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//            
+CDpsFile* CDpsTransaction::FileHandle()
+    {
+    return iFile;
+    }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsusbnotifier.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,158 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class implements functions of set ptp personality, the 
+*                notification of the PTP printer connection and the
+*				 notification of the PTP printer disconnection. 
+*
+*/
+
+
+#ifndef DPSUSBNOTIFIER_H
+#define DPSUSBNOTIFIER_H
+
+#include <e32base.h>
+#include <usbstates.h>
+#include "pictbridge.h"
+#include <usbman.h>
+#include <usbwatcher.h>
+
+class CDpsPtpNotifier;
+class CDpsConnectNotifier;
+class CDpsPersonalityWatcher;
+
+/**
+*   Class for monitoring the usb personality change and cable 
+*   connection/disconnectin
+*/
+NONSHARABLE_CLASS(CDpsUsbNotifier) : public CActive
+    {
+    friend class CDpsPtpNotifier;
+    friend class CDpsConnectNotifier;
+    friend class CDpsPersonalityWatcher;
+	
+    public:
+        /**
+        *   Two phase constructor
+        *   @param aEngine the pointer to the dps engine object
+        *   @param the CDpsUsbNotifier instance 
+        */
+        static CDpsUsbNotifier* NewL(CDpsEngine* aEngine);
+		
+        /**
+        *   Destructor
+        */
+        ~CDpsUsbNotifier();
+		
+        /**
+        *   Issues the request for printer connection notification
+        */
+        void WaitForPrinterNotify();
+		
+        /**
+        *   Cancels the request for printer connection notification
+        */
+        void CancelPrinterNotify();
+		
+        /**
+        *   Issues the request for printer connect/disconnect notification
+        */
+        void ConnectNotify();
+		
+		/**
+		*   @return TBool Checks if the PTP printer is connected
+		*/		
+	    TBool IsConfigured() const;
+	    
+	    /**
+	    *
+	    */
+	    TBool IsSetPrintModeIssued();
+	    
+    private:
+        /**
+        *   Second phase constructor
+        */
+        void ConstructL();
+		
+        /**
+        *   Default constructor
+        *   @param aEngine the pointer to the dps engine
+        */
+        CDpsUsbNotifier(CDpsEngine *aEngine);
+		
+        /**
+        *   Called by PtpNotifier to indicate a ptp printer/pc is connected
+        */
+        void PtpNotify(TInt aErr);
+		
+		/**
+		*
+		*/
+		void PersonalityChanged();
+		
+        /**
+        *   Called by ConnectNotifier to indeicate the cable disconnect
+        */
+        void DisconnectNotify(TUsbDeviceState aState);
+		
+        /**
+        *   Updates the current device state
+        *   @return ETrue if OK, EFalse if failed
+        */
+        TInt ConnectState();
+		        
+        /**
+        *   Changes back to the previous personality       
+        */
+        void Rollback();
+        
+    private: // from CActive		
+        /**
+        *   @See CActive::RunL
+        */
+        void RunL();
+		
+        /**
+        *   @See CActive::RunError
+        */
+        TInt RunError(TInt aErr);
+		
+        /**
+        *   @See CActive::DoCancel
+        */
+        void DoCancel();
+		
+    private:
+        // not owned by this class
+        CDpsEngine* iEngine;
+        // owned by this class
+        CDpsPtpNotifier* iPtpP;
+        // owned by this class
+        CDpsConnectNotifier* iConnectP;
+        // owned by this class
+        CDpsPersonalityWatcher* iPersonalityWatcher;
+        TInt	iPersonality;
+        TUsbDeviceState iConnectState;
+        // indication of whether the PTP printer has connected
+        TBool iConfigured;	
+        CDpsEngine::TConnectionStatus iConnection;	
+        // owned by this class
+        RUsbWatcher iUsbW;
+        // owned by this class
+        RUsb    iUsbM;
+        // if rollback to previous personality is needed when application quits
+        TBool iRollback;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsxmlgenerator.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,163 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class creates the dps xml script. 
+*
+*/
+
+
+#ifndef DPSXMLGENERATOR_H
+#define DPSXMLGENERATOR_H
+
+#include <e32base.h>
+#include <s32file.h>
+#include "dpsdefs.h"
+#include "dpsconst.h"
+
+class CDpsEngine;
+
+/**
+*   This class creates dps scripts.
+*/
+NONSHARABLE_CLASS(CDpsXmlGenerator) : public CBase
+    {
+    public:
+        /**
+        *   Two phase constructor
+        *   @param aEngine a pointer to dps engine
+        *   @return a CDpsXmlGenerator instance
+        */
+        static CDpsXmlGenerator* NewL(CDpsEngine* aEngine);    
+    	
+        /**
+        *   Destructor
+        */
+        ~CDpsXmlGenerator();
+    	
+        /**
+        *	Creates the Dps result script
+        *   @param aEvent a dps event, can be empty
+        *   @param aScript dps script content. after this function is
+        *   returned, aScript has the valid content
+        *   @param aResult the operation result
+        */
+        void CreateResultScriptL(TDpsEvent aEvent,
+		                         RWriteStream& aScript,
+	           		             const TDpsResult& aResult) const;
+	    
+        /**
+        *   Creates the dps reply script
+        */ 
+        void CreateReplyScriptL(TDpsOperation aOperation, 
+                               RWriteStream& aScript,
+                               const TDpsResult& aResult,
+                               const TDpsArg& aArg) const;
+       		         	
+    private:
+        /**
+        *   Default constructor
+        *   @param aEngine a pointer to dps engine
+        */
+        CDpsXmlGenerator(CDpsEngine* aEngine);
+	      
+    public:	      
+        /**
+        *   Fillin the start part of a script
+        *   @param aScript the content of a script
+        */                 
+        void StartDocumentL(RWriteStream& aScript) const;
+	    
+        /**
+        *   Fillin the end part of a script
+        *   @param aScript the content of a script
+        */
+        void EndDocumentL(RWriteStream& aScript) const;
+	    
+        /**
+        *   Fillin the start part of a input in the script
+        *   @param aScript the content of a script
+        */
+        void StartInputL(RWriteStream& aScript) const;          	 
+		
+        /**
+        *   Fillin the end part of a input in the script
+        *   @param aScript the content of a script
+        */
+        void EndInputL(RWriteStream& aScript) const;
+		
+        /**
+        *   Fillin the start part of the result in the script
+        *   @param aScript the content of a script
+        *   @param aResult the result to be filled
+        */
+        void StartResultL(RWriteStream& aScript, const TDpsResult& aResult) const;
+		
+        /**
+        *   Fillin the end part of the result in the script
+        *   @param aScript the content of a script
+        */
+        void EndResultL(RWriteStream& aScript) const;
+		
+        /**
+        *   Fillin the start part of the operation in the script
+        *   @param aOperation the operation enumeration
+        *   @param aScript the content of a script
+        *   @param aEnd ETrue if the operation does not have an argument,
+        *   EFalse otherwise	       
+        */
+        void StartOperationL(TDpsOperation aOperation, RWriteStream& aScript, 
+                            TBool aEnd = EFalse) const; 
+		
+        /**
+        *   Fillin the end part of the operation in the script
+        *   @param aOperation the operation enumeration
+        *   @param aScript the content of a script
+        */
+        void EndOperationL(TDpsOperation aOperation, RWriteStream& aScript) const;
+		
+        /**
+        *   Fillin the event parameter in the script
+        *   @param aScript the content of a script.
+        *   @param aEvent the event enumeration
+        */
+        void CreateEventL(RWriteStream& aScript, TDpsEvent aEvent) const;
+		
+        /**
+        *   Fillin the arguments
+        *   @param aScript the content of a script
+        *   @param aArgument arguments to be used to fill the script
+        *   @param aAttrib the attribute
+        */
+        void CreateArgL(RWriteStream& aScript, const TDpsArg& aArgument, 
+                        TDpsAttribute aAttrib = 0) const;
+        
+        /**
+        *   Fillin the start part of an element
+        *   @param aElement the element enumeration
+        *   @param aScript the content of a script
+        */
+        void StartElementL(TDpsElement aElement, RWriteStream& aScript) const;
+		
+        /**
+        *   Fillin the end part of an element
+        *   @param aElement the element enumeration
+        *   @param aScript the content of a script
+        */
+        void EndElementL(TDpsElement aElement, RWriteStream& aScript) const;
+							
+    private:
+        // not owned by this class
+        CDpsEngine* iEngine;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsxmlparser.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,215 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class parses the dps xml script. 
+*
+*/
+
+
+#ifndef DPSXMLPARSER_H
+#define DPSXMLPARSER_H
+
+#include <e32base.h>
+#include <xml/wbxmlextensionhandler.h>
+#include <contenthandler.h>
+#include "dpsdefs.h"
+#include "dpsconst.h"
+
+using namespace Xml;
+
+class CDpsEngine;
+
+/**
+*   The interface acts as a hook between the xml framework and the detailed 
+*   implementation
+*/
+class MDpsExtensionHandler
+    {
+    public:
+        enum 
+        {
+        // dps engine dll uid 
+        EInterfaceUid = 0x10274798
+        };
+    };
+
+/**
+*   The parser for dps script
+*/
+NONSHARABLE_CLASS(CDpsXmlParser) : public CBase, public MContentHandler, 
+                                   public MDpsExtensionHandler
+    {
+    public:
+        /**
+        *   Two phase constructor
+        *   @param aEngine the dps engine pointer
+        *   @return a CDpsXmlParaser instance
+        */
+        static CDpsXmlParser* NewL(CDpsEngine* aEngine);
+    	
+        /**
+        *   Destructor
+        */
+        ~CDpsXmlParser();  
+    	
+        /**
+        *   @return ETrue if the script is a dps notification, 
+        *   otherwise EFalse
+        */
+        inline TBool IsEvent() const;
+    	
+        /**
+        *   Gets the dps operation result from the parser and sets it to the 
+        *   dps reply
+        *   @param aResult the dps operatoin result
+        */
+        inline void SetOperationResult(TDpsResult& aResult) const;
+    	
+        /**
+        *   Gets the dps operation enumeration of this script
+        *   @return the dps operation enumeration
+        */
+        inline TDpsOperation Operation() const;
+    	    
+        /**
+        *   Sets the dps operation arguments
+        *   @param aParams the arguments to be set
+        */
+        inline void SetParameters(TDpsArgArray& aParams);
+    	
+        /**
+        *   Gets the dps event of this script
+        *   @return the dps event enumeration
+        */
+        inline TDpsEvent Event() const;
+    	    
+        /**
+        *   Gets the dps attribute
+        *   @param aAttrib the attribute got
+        */
+        inline void GetAttribute(TDpsAttribute& aAttrib) const;
+    	
+        /**
+        *   @return ETrue if this dps operation has attribue, othewise EFalse
+        */
+        inline TBool HasAttribute() const;
+    	
+        /**
+        *   Gets the dps arguments
+        *   @param aParams the arguments to be returned
+        */
+        inline void GetParameters(TDpsArgArray& aParams) const;
+        
+        /**
+        *   Resets the member variables 
+        */
+        void Reset();
+		
+    	    
+    private:
+    // From MContentHandler
+        /**
+        *   @see MContentHandler
+        */
+        void OnStartDocumentL(const RDocumentParameters& aDocParam, 
+                              TInt aErrorCode);
+		
+        /**
+        *   @see MContentHandler
+        */
+        void OnEndDocumentL(TInt aErrorCode);
+		
+        /**
+        *   @see MContentHandler
+        */
+        void OnStartElementL(const RTagInfo& aElement, 
+                             const RAttributeArray& aAttributes, 
+                             TInt aErrCode);
+		
+        /**
+        *   @see MContentHandler
+        */
+        void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode);
+		
+        /**
+        *   @see MContentHandler
+        */
+        void OnContentL(const TDesC8& aBytes, TInt aErrorCode);
+		
+        /**
+        *   @see MContentHandler
+        */
+        void OnStartPrefixMappingL(const RString& aPrefix, 
+                                   const RString& aUri, 
+                                   TInt aErrorCode);
+		
+        /**
+        *   @see MContentHandler
+        */
+        void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
+		
+        /**
+        *   @see MContentHandler
+        */
+        void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode);
+		
+        /**
+        *   @see MContentHandler
+        */
+        void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
+		
+        /**
+        *   @see MContentHandler
+        */
+        void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, 
+                                      TInt aErrorCode);
+		
+        /**
+        *   @see MContentHandler
+        */
+        void OnError(TInt aErrorCode);
+		
+        /**
+        *   @see MContentHandler
+        */
+        TAny* GetExtendedInterface(const TInt32 aUid); 
+		        				
+    private:
+        /**
+        *   Default constructor
+        *   @param aEngine a pointer to the dps engine
+        */
+        CDpsXmlParser(CDpsEngine* aEngine);
+        
+        /**
+        *
+        */
+        void ParseAttributesL(const RAttributeArray& aAttributes, 
+                              const TDesC8& aTag);
+
+		
+    private:
+        TDpsXmlAction iAction;
+        TDpsAttribute iAttrib;
+		
+        TDpsEvent iDpsEvent;
+        TDpsOperation iDpsOperation;	
+        TDpsResult iDpsResult;
+        // only one
+        TDpsElement iElement; 
+        TDpsArgArray iDpsArgs;
+        // not owned by this class
+        CDpsEngine* iEngine;
+    };
+#include "dpsxmlparser.inl"
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsxmlparser.inl	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,97 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class parses the dps xml script. 
+*
+*/
+
+
+#ifdef _DEBUG
+#	define __IF_DEBUG(t) {RDebug::t;}
+#else
+#	define __IF_DEBUG(t)
+#endif
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsXmlParser::GetAttribute(TDpsAttribute& aAttrib) const
+    {
+    aAttrib = iAttrib;
+    }
+  
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//  
+TBool CDpsXmlParser::HasAttribute() const
+    {
+    return iAttrib != 0;
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+TDpsOperation CDpsXmlParser::Operation() const
+    {
+    return iDpsOperation;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TDpsEvent CDpsXmlParser::Event() const
+    {
+    return iDpsEvent;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsXmlParser::GetParameters(TDpsArgArray& aParams) const
+    {
+    aParams = iDpsArgs;
+    }
+ 
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TBool CDpsXmlParser::IsEvent() const
+	{
+	return iDpsEvent != EDpsEvtEmpty;
+	}
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsXmlParser::SetParameters(TDpsArgArray& aParams)
+    {
+    iDpsArgs = aParams;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CDpsXmlParser::SetOperationResult(TDpsResult& aResult) const
+    {
+    aResult.iMajorCode = iDpsResult.iMajorCode;
+    aResult.iMinorCode = iDpsResult.iMinorCode;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsxmlstring.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class defines the dps constant strings. 
+*
+*/
+
+
+#ifndef DPSXMLSTRING_H
+#define DPSXMLSTRING_H
+
+#include <e32base.h>
+
+typedef RArray<TPtrC8> TDpsStrings;
+
+/**
+* The class for the dps string
+*/
+class TDpsXmlString
+    {
+    public:
+        /**
+        *
+        */
+        static TDpsXmlString* NewL();
+        
+        /**
+        *
+        */
+        ~TDpsXmlString();
+        
+    private:
+        /**
+        *
+        */
+        void ConstructL();
+        
+        /**
+        *
+        */
+        TDpsXmlString();    
+        
+    public:    
+        TDpsStrings iDpsOperationStrings;
+        TDpsStrings iDpsElementStrings;
+        TDpsStrings iDpsEventStrings;
+        TDpsStrings iDpsArgStrings;
+    };
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/pictbridge.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,274 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class defines and implements the API for UI engine. 
+*
+*/
+
+
+#ifndef PICTBRIDGE_H
+#define PICTBRIDGE_H
+
+#include "dpsdefs.h"
+#include <rptp.h>
+
+class TDpsXmlString;
+class CDpsUsbNotifier;
+class TMDpsOperation;
+class TDpsEvents;
+class CDpsStateMachine;
+class TDpsConfigPrintReq;
+
+NONSHARABLE_CLASS(CDpsEngine) : public CBase
+    {
+    public:
+        enum TConnectionStatus
+            {
+            ENotConnected = 1,
+            // ptp printer is connected
+            EPrinterConnected,
+            // ptp printer is disconnected
+            EPrinterDisconnected,
+            // in ptp personality, but device other than printer connected
+            EOtherConnected,
+            // in personality other than ptp and device is connected 
+            EWrongPrintModeConnected
+            };
+	        
+    public:
+        /**
+        *   @since 3.2
+        *   @lib pictbridge.lib
+        *
+        *   The client should always call this function to get the Dps 
+        *   engine object.
+        *   This function guarantees there is only one engine in the 
+        *   thread, a singleton.  	
+        *   @return CDpsEngine* the only Dps Engine instance in a thread
+        *   
+        */
+        IMPORT_C static CDpsEngine* GetEngineL();
+        
+        /**
+        *   @since 3.2
+        *   @lib pictbridge.lib
+        *
+        *	Deletes the dps engine object. 
+        */
+        IMPORT_C void Delete();
+        
+        /**
+        *   @since 3.2
+        *   @lib pictbridge.lib
+        *
+        *	Sets the personality to PTP. This must be the first call after 
+        *   the client has got the CDpsEngine object and should only be
+        *   called once.
+        *   @param aStatus the asynchronous request and it has the connect
+        *   state after returned. The client can use this value to get the
+        *   current connect status.        
+        */
+        IMPORT_C void SetPrintMode(TRequestStatus& aStatus);
+        							 
+        /**
+        *   @since 3.2
+        *   @lib pictbridge.lib
+        *
+        *   Cancels the SetPrintMode request        
+        */        							 
+        IMPORT_C void CancelPrintMode();
+						     
+        /**
+        *   @since 3.2
+        *   @lib pictbridge.lib
+        *
+        *   Registers connection notification. This function can inform 
+        *   the connection and the disconnect, two states. Connection: the
+        *   personality has been set to PTP by SetPrintMode, but the cable
+        *   is not connected at the moment. The connection will be informed
+        *   by this function. 
+        *   Disconnect: the user has unplugged the cable or changed 
+        *   personality.    
+        *   
+        *   @param aStatus the asynchronous request status and it has the 
+        *   connect state after returned.
+        */     
+        IMPORT_C void ConnectStateNotify(TRequestStatus& aStatus);
+				     					
+        /**
+        *   @since 3.2
+        *   @lib pictbridge.lib
+        *
+        *   Registers Dps event notification. There are two events: jobStatus
+        *   and deviceStatus. This function is called immediately after 
+        *   ConnecSatetNotify call. After this call, the client should issue 
+        *   ConfigPrintService request to configure the printer.
+        *   @param aParam this parameter serves as out parameter. After
+        *   processing the event from the printer, Dps engine will put
+        *   the correct value to this parameter. As the result, the client
+        *   can get the event by accessing this parameter after this request
+        *   gets answered. So the client should have it as a class variable
+        *   @param aStatus the asynchronous status. 
+        */
+        IMPORT_C void DpsEventNotify(TDpsEvents& aParam, 
+                                     TRequestStatus& aStatus);
+        
+        /**
+        *   @since 3.2
+        *   @lib pictbridge.lib
+        *
+        *   Cancels Dps event notification. The client only needs to call
+        *   this to reset the state of the dps engine and it must be called
+        *   after CancelDpsRequest().
+        */
+        IMPORT_C void CancelDpsEventNotify();
+        
+        /**
+        *   @since 3.2
+        *   @lib pictbridge.lib
+        *
+        *   Starts a Dps operation.
+        *   If this function returned with error, e.g. leaving, the client
+        *   should call CancelDpsRequest(), to cancel the pending request.
+        *   @param aRequest the Dps operation. It includes both request and 
+        *   reply. The client should fill in the request parameter and the 
+        *   Dps engine will fill in the reply paramter when this operation
+        *   is finished. The client should declare it as a class variable.
+        *   @param aStatus the asynchronous status
+        */
+        IMPORT_C void DoDpsRequestL(TMDpsOperation* aRequest, 
+                                    TRequestStatus& aStatus);
+		
+        /**
+        *   @since 3.2
+        *   @lib pictbridge.lib
+        *
+        *   Cancels the dps operation. Calling this will reset the state of 
+        *   the dps engine, either because of error happened or the client
+        *   wants to do this on purpose. In most cases, the client never need
+        *   to cancel the ongoing request because the request will end very 
+        *   quick, normally within several million seconds. The client normally
+        *   waits until the request is finished, either succesfully or
+        *   failed indicated by timeout.
+        */        
+        IMPORT_C void CancelDpsRequest();
+        
+        /**
+        *   @since 3.2
+        *   @lib pictbridge.lib
+        *
+        *   Reads the phone dps configuration from the resource file
+        *   @param aConfig the dps configuration is returned by this parameter
+        */
+        IMPORT_C void GetDpsConfigL(TDpsConfigPrintReq& aConfig);
+        
+        /**
+        *   @since 3.2
+        *   @lib pictbridge.lib
+        *
+        *   Gets the folder where the printer configure file should be kept. 
+        *   The print App needs a file to store the printer configure when it
+        *   first calls configPrintService Dps request. The print app can 
+        *   quit at anytime while the ptpserver (stack) is still running. 
+        *   Since the ptpstack is keeping the session with the printer, the 
+        *   printer always does not excute the second onward 
+        *   configPrintService request. As the result, the restarted print app
+        *   cannot get the printer configure. So there must be a file for 
+        *   keeping this information and it will be deleted by ptpserver when
+        *   it quits, e.g. when the connection with the printer is lost.
+        *   @return TDesC& the folder descriptor
+        */
+        IMPORT_C const TDesC& DpsFolder() const;
+            
+        /**
+        *   Gets the Dps event object
+        *   @return TDpsEvents* the pointer to the Dps event.
+        */
+        TDpsEvents* Event() const;
+            
+        /**
+        *  Gets the ptp server reference
+        *  @return RPtp& the reference to ptp server.
+        */
+        RPtp& Ptp();
+            
+        /**
+        *  Gets the dps constant strings
+        *  @return TDpsGlobalData* the pointer to dps constant strings.
+        */
+        TDpsXmlString* DpsParameters() const;
+         
+        /**
+        * @return dps event notify AO status
+        *   
+        */
+        TRequestStatus*& EventRequest();
+            
+        /**
+        * @return dps request AO status
+        */
+        TRequestStatus*& OperationRequest();
+         
+        /**
+        * @return connection notify AO status
+        */               
+        TRequestStatus*& PrinterConnectRequest();
+        
+        /**
+        *  Sets the Dps file folder. 
+        *  @param aFolder the foler location, readed from Ptp server/stack 
+        */
+        void SetDpsFolder(const TDesC& aFolder);
+        
+            
+    private:
+        
+        /**
+        *   Prohibits the destructor called by the client. To delete engine object
+        *   Delete() must be called
+        */
+        ~CDpsEngine();  
+        
+        /**
+        *   Second phase constructor. Operations which might leave should 
+        *   be called here
+        */
+        void ConstructL();
+              
+    private:
+        // string constant, owned by this class
+        TDpsXmlString* iDpsParameters;
+        // dps engine state machine, owned by this class
+        CDpsStateMachine *iDpsOperator;
+        // dps operation AO request, owned by this class
+        TRequestStatus* iDpsOperationRequest;
+        // dps event AO request, owned by this class
+        TRequestStatus* iDpsEventRequest;
+        // printer connection/disconnection AO request, owned by this class
+        TRequestStatus* iPrinterConnectRequest;
+        
+        // usb cable connection/disconnection notifier, owned by this class
+        CDpsUsbNotifier *iUsbNotifier;
+                
+        // out parameter for events (NotifyJobStatus and
+        // NotifyDeviceStauts), it is
+        // passed from UI engine, not owned by this class  
+        TDpsEvents* iOutEvent;
+        
+        // Ptp Server session, owned by this class
+        RPtp    iPtp;
+        // the folder where all dps releated files should be stored              
+        TFileName iDpsFolder;  
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/rom/pictbridge.iby	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  iby file for pictbrige engine
+*
+*/
+
+#ifndef __PICTBRIDGE_IBY
+#define __PICTBRIDGE_IBY
+#ifdef __USB_PICTBRIDGE
+file=ABI_DIR\BUILD_DIR\pictbridge.dll			SHARED_LIB_DIR\pictbridge.dll
+
+data=DATAZ_\RESOURCE_FILES_DIR\dps.RSC         RESOURCE_FILES_DIR\dps.RSC
+#endif __USB_PICTBRIDGE
+#endif __PICTBRIDGE_IBY
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dps.rss	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The dps resource file. 
+*
+*/
+
+
+#include <badef.rh>
+#include "dps.rh"
+
+
+RESOURCE BA_RSS_SIGNATURE
+	{
+	signature = 1;
+	}
+
+RESOURCE dps_configuration dps_config
+	{
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsconnectnotifier.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,144 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class implements functions of the notification of the 
+*                PTP printer connction and disconnection. 
+*
+*/
+
+
+#include <e32debug.h>
+#include "dpsconnectnotifier.h"
+#include "dpsusbnotifier.h"
+
+#ifdef _DEBUG
+#	define IF_DEBUG(t) {RDebug::t;}
+#else
+#	define IF_DEBUG(t)
+#endif
+
+const TUint KUsbAllStates = 0xFFFFFFFF;
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+// 
+CDpsConnectNotifier* CDpsConnectNotifier::NewL(CDpsUsbNotifier* aParent)
+    {
+    IF_DEBUG(Print(_L("CDpsConnectNotifier::NewL")));
+    CDpsConnectNotifier* self = new(ELeave) CDpsConnectNotifier(aParent);
+    return self;	    
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//     
+CDpsConnectNotifier::CDpsConnectNotifier(CDpsUsbNotifier* aParent) :
+    CActive(EPriorityNormal), iNotifier(aParent) 
+    {
+    IF_DEBUG(Print(_L(">>>CDpsConnectNotifier::Ctor")));    
+    CActiveScheduler::Add(this);
+    IF_DEBUG(Print(_L("<<<CDpsConnectNotifier::Ctor")));    
+    }
+   
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//     
+CDpsConnectNotifier::~CDpsConnectNotifier()
+    {
+    IF_DEBUG(Print(_L(">>>CDpsConnectNotifier::~")));   
+    Cancel();
+    IF_DEBUG(Print(_L("<<<CDpsConnectNotifier::~")));   
+    }
+   
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//     
+void CDpsConnectNotifier::ConnectNotify()
+    {
+    IF_DEBUG(Print(_L(">>>CDpsConnectNotifier::ConnectNotify")));    
+    if (!IsActive())
+        {
+	    iNotifier->iUsbM.DeviceStateNotification(KUsbAllStates, 
+	                                             iNotifier->iConnectState, 
+	                                             iStatus);
+        SetActive();			
+        }
+    IF_DEBUG(Print(_L("<<<CDpsConnectNotifier::ConnectNotify")));    	
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+// 
+void CDpsConnectNotifier::RunL()
+    {
+    IF_DEBUG(Print(_L
+        (">>>CDpsConnectNotifier::RunL %x"), iNotifier->iConnectState));
+    if (KErrNone == iStatus.Int())
+        {
+        
+        // notify connect (by set personality)
+        if (iNotifier->iConnectState == EUsbDeviceStateConfigured && 
+            !iNotifier->iConfigured)
+            {
+            iNotifier->PtpNotify(KErrNone);
+            }
+        // Notify disconnect on cable disconnection and for compatible printer
+        // also when other device state than configured or suspended is entered. 
+        else if (  (iNotifier->iConnectState == EUsbDeviceStateUndefined) ||
+                ( iNotifier->IsConfigured() && 
+                        (iNotifier->iConnectState != EUsbDeviceStateConfigured) &&
+                        (iNotifier->iConnectState != EUsbDeviceStateSuspended) )  )
+            {
+            iNotifier->DisconnectNotify(iNotifier->iConnectState);
+            } 
+        else // not the state we are interested, keep on listening
+            {
+            iNotifier->iUsbM.DeviceStateNotification(KUsbAllStates, 
+	                                                 iNotifier->iConnectState, 
+	                                                 iStatus);
+            SetActive();	                                             
+            }
+        
+        }
+    else
+        {
+        IF_DEBUG(Print(_L("\tthe iStatus is wrong!!!")));
+        }    
+    IF_DEBUG(Print(_L("<<<CDpsConnectNotifier::RunL")));    
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+// 
+void CDpsConnectNotifier::DoCancel()
+    {
+    IF_DEBUG(Print(_L(">>>CDpsConnectNotifier::DoCancel")));    
+    iNotifier->iUsbM.DeviceStateNotificationCancel();
+    IF_DEBUG(Print(_L("<<<CDpsConnectNotifier::DoCancel")));
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+// 
+TInt CDpsConnectNotifier::RunError(TInt aErr)
+    {
+    IF_DEBUG(Print(_L("CDpsConnectNotifier::RunError is %d"), aErr));    
+    return aErr;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsfile.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,139 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class reads and writes the file content. 
+*
+*/
+
+
+#include "dpsfile.h"
+#include "dpsdefs.h"
+#include "dpsconst.h"
+
+#ifdef _DEBUG
+#	define IF_DEBUG(t) {RDebug::t;}
+#else
+#	define IF_DEBUG(t)
+#endif
+
+    
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//
+CDpsFile* CDpsFile::NewL()
+	{
+	IF_DEBUG(Print(_L("CDpsFile::NewL")));
+	CDpsFile* self = new (ELeave) CDpsFile();
+	CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(); 
+	return self;
+	}
+
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//
+void CDpsFile::ConstructL()
+    {
+    IF_DEBUG(Print(_L(">>>CDpsFile::ConstructL")));    
+	User::LeaveIfError(iFs.Connect());
+    IF_DEBUG(Print(_L("<<<CDpsFile::ConstructL")));    
+    }
+    
+// --------------------------------------------------------------------------
+// 
+// --------------------------------------------------------------------------
+//
+CDpsFile::~CDpsFile()
+	{
+	IF_DEBUG(Print(_L(">>>CDpsFile::~")));        
+	iFs.Close();
+	IF_DEBUG(Print(_L("<<<CDpsFile::~")));        
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TInt CDpsFile::CreateScriptFile(const TDesC& aFileName, const TDesC8& aScript,
+								const TInt aFileSize)
+    {
+    IF_DEBUG(Print(_L(">>>CDpsFile::CreateScriptFile size %d"), aFileSize));            
+    RFile file;
+    TInt err = file.Replace(iFs, aFileName, EFileShareExclusive);
+    IF_DEBUG(Print(_L("---the error is %d"), err));
+    if (err != KErrNone)
+        {
+        return err;
+        }
+        
+    TInt fileSize = aScript.Size();
+    if (!fileSize)
+        {
+        err = file.Write(_L8(""), 0);
+        }
+    else if ( fileSize <= aFileSize)
+        {
+        err = file.Write(aScript, fileSize);
+        }
+    else
+        {
+        err = file.Write(aScript, aFileSize);
+        }
+        
+    file.Close();
+    IF_DEBUG(Print(_L("<<<CDpsFile::CreateScriptFile %d"), err));            
+    return err;   
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsFile::GetContentL(const TDesC& aFileName, TDes8& aScript)
+    {
+    IF_DEBUG(Print(_L(">>>CDpsFile::GetContent %S"), &aFileName));                
+    RFile file;
+    CleanupClosePushL(file);
+    User::LeaveIfError(file.Open(iFs, aFileName, EFileRead));
+    User::LeaveIfError(file.Read(aScript));
+    CleanupStack::PopAndDestroy();
+    IF_DEBUG(Print(_L("<<<CDpsFile::GetContent")));                       
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+void CDpsFile::FileSizeL(const TDesC& aFileName, TInt& aSize)
+    {
+    IF_DEBUG(Print(_L(">>>CDpsFile::FileSize %S"), &aFileName));       
+    RFile file;
+    CleanupClosePushL(file);
+    User::LeaveIfError(file.Open(iFs, aFileName, EFileRead)); 
+    User::LeaveIfError(file.Size(aSize));    
+    CleanupStack::PopAndDestroy();
+    IF_DEBUG(Print(_L("<<<CDpsFile::FileSize %d"), aSize));                
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+TInt CDpsFile::Delete(const TDesC& aFileName)
+    {
+    IF_DEBUG(Print(_L("CDpsFile::Delete")));                    
+    return iFs.Delete(aFileName);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsoperation.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,957 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  These classes implement dps operations replies. 
+*
+*/
+
+
+#include <e32debug.h>
+#include "dpsoperation.h"
+#include "dpsconst.h"
+#include "dpstransaction.h"
+#include "pictbridge.h"
+#include "dpsxmlparser.h"
+#include "dpsxmlgenerator.h"
+#include "dpsstatemachine.h"
+
+#ifdef _DEBUG
+#	define IF_DEBUG(t) {RDebug::t;}
+#else
+#	define IF_DEBUG(t)
+#endif
+
+const TInt KConfigPrintService = 5;
+const TInt KCopyFileWidth = 3;
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void TMDpsOperation::CreateReqScriptL(
+                                      const TDpsArgArray& aArguments, 
+                                      const TDpsEleArray& /*aElements*/,
+                                      TDpsAttribute /*aAttribute*/, 
+                                      RWriteStream& aScript, 
+                                      CDpsTransaction* aTrader)
+    {
+    IF_DEBUG(Print(_L(">>>TMDpsOperation::CreateReqScript")));        
+    CDpsXmlGenerator* g = aTrader->Generator();
+    g->StartDocumentL(aScript);
+    g->StartInputL(aScript);
+    TInt count = aArguments.Count();
+    if (!count)
+	    {
+		g->StartOperationL((TDpsOperation)iOperation, aScript, ETrue);
+		}
+	else
+		{
+		g->StartOperationL((TDpsOperation)iOperation, aScript);
+		for (TInt i = 0; i < count; i++)
+			{
+			g->CreateArgL(aScript, aArguments[i]);
+			}
+		g->EndOperationL((TDpsOperation)iOperation, aScript);	
+		}
+			
+    g->EndInputL(aScript);
+	g->EndDocumentL(aScript);	
+	IF_DEBUG(Print(_L("<<<TMDpsOperation::CreateReqScript")));        	
+    }
+    
+// ---------------------------------------------------------------------------
+// Some request parameters should be checked
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt TDpsStartJob::FillReqArgs(TDpsArgArray& aArgs, 
+                                        TDpsEleArray& aElements,
+                                        TDpsAttribute& /*aAttrib*/, 
+                                        CDpsTransaction* aTrader)
+    {
+    IF_DEBUG(Print(_L(">>>TDpsStartJob::FillReqArgs")));                    
+    TInt imageCount = iReqParam.iPrintInfo.Count();
+    if (!imageCount) 
+        {
+        return KErrUnknown;
+        }
+    TUint32* objectHandles = new TUint32[imageCount];
+    if (!objectHandles)
+        {
+        return KErrNoMemory;
+        }
+    for (TInt i = 0; i < imageCount; i++)
+        {
+        TInt err = aTrader->Engine()->Ptp().
+             GetObjectHandleByName(
+                 iReqParam.iPrintInfo[i].iFile, objectHandles[i], ETrue); 
+        if (err != KErrNone)
+            {
+            IF_DEBUG(Print(_L("---error %d"), err));
+            
+            delete[] objectHandles;
+            return err;
+            }
+        }
+    TDpsArg* argsP = new TDpsArg[iReqParam.GetParamNum()];
+    if (!argsP)
+        {
+		delete[] objectHandles;
+        return KErrNoMemory;
+        }
+    TDpsEle* elemsP = new TDpsEle[1 + imageCount];
+    if (!elemsP)
+        {
+		delete[] argsP;
+		delete[] objectHandles;
+        return KErrNoMemory;
+        }
+    // jobConfig    
+    TInt count = iReqParam.iJobConfig.Count();
+              
+    elemsP[0].iElement = EDpsJobConfig;
+    elemsP[0].iNum = count;
+    aElements.Append(elemsP[0]);
+    for (TInt i = 0; i < count; i++)
+        {
+        argsP[i].iElement = iReqParam.iJobConfig[i].iElement;
+    	// the parameter only has high bytes (0x1234)
+    	argsP[i].iContent.AppendNumUC(iReqParam.iJobConfig[i].iContent, EHex);
+    	// we have to append the low bytes (0000)
+    	argsP[i].iContent.Append(KDpsLowZero);
+    	aArgs.Append(argsP[i]);
+    	IF_DEBUG(Print(_L("the element is %d"), argsP[i].iElement));
+    	IF_DEBUG(Print(_L("the content is %S"), &(argsP[i].iContent)));
+    	}    
+    	
+    // printInfo
+    for (TInt j = 0; j < imageCount; j++)
+        {
+    	// there is at least one argument for fileID
+    	TInt k = 1;
+    	elemsP[j + 1].iElement = EDpsPrintInfo;
+    	argsP[count].iElement = EDpsArgFileID;
+    	argsP[count].iContent.AppendNumFixedWidth(objectHandles[j], EHex, 
+    	                                          KFullWordWidth);
+    	aArgs.Append(argsP[count]);
+    
+    	IF_DEBUG(Print(_L("the element is %d"), argsP[count].iElement));
+    	IF_DEBUG(Print(_L("the content is %S"), &(argsP[count].iContent)));
+    	count++;
+    	
+    	// not empty
+    	if (iReqParam.iPrintInfo[j].iFileName)
+    	    {
+    	    argsP[count].iElement = EDpsArgFileName;
+    	    argsP[count].iContent.Copy(iReqParam.iPrintInfo[j].iFile);
+    	    aArgs.Append(argsP[count]);
+    	    
+    	    IF_DEBUG(Print(_L("the element is %d"), argsP[count].iElement));
+    	    IF_DEBUG(Print(_L("the content is %S"), &(argsP[count].iContent)));
+    	    
+    	    k++; count++;
+    	    }
+    	// not empty    
+    	if (iReqParam.iPrintInfo[j].iDate.Size())
+    	    {
+            argsP[count].iElement = EDpsArgDate;
+            argsP[count].iContent.Copy(iReqParam.iPrintInfo[j].iDate);
+            aArgs.Append(argsP[count]);
+            IF_DEBUG(Print(_L("the element is %d"), argsP[count].iElement));
+    	    IF_DEBUG(Print(_L("the content is %S"), &(argsP[count].iContent)));
+            k++; count++;
+    	    }
+    	if (iReqParam.iPrintInfo[j].iCopies != 0)
+    	    {
+            argsP[count].iElement = EDpsArgCopies;
+            argsP[count].iContent.AppendNumFixedWidthUC(
+                iReqParam.iPrintInfo[j].iCopies, EDecimal, KCopyFileWidth);
+            aArgs.Append(argsP[count]);
+            IF_DEBUG(Print(_L("the element is %d"), argsP[count].iElement));
+    	    IF_DEBUG(Print(_L("the content is %S"), &(argsP[count].iContent)));
+    	    k++; count++;
+    	    }    
+    	if (iReqParam.iPrintInfo[j].iPrtPID != 0)
+    	    {
+            argsP[count].iElement = EDpsArgPrtPID;
+            argsP[count].iContent.AppendNumUC(iReqParam.iPrintInfo[j].iPrtPID);
+            aArgs.Append(argsP[count]);
+            IF_DEBUG(Print(_L("the element is %d"), argsP[count].iElement));
+    	    IF_DEBUG(Print(_L("the content is %S"), &(argsP[count].iContent)));
+    	    k++; count++;
+    	    }
+    	if (iReqParam.iPrintInfo[j].iCopyID != 0)
+    	    {
+            argsP[count].iElement = EDpsArgCopyID;
+            argsP[count].iContent.AppendNumUC(iReqParam.iPrintInfo[j].iCopyID);
+            aArgs.Append(argsP[count]);
+            IF_DEBUG(Print(_L("the element is %d"), argsP[count].iElement));
+    	    IF_DEBUG(Print(_L("the content is %S"), &(argsP[count].iContent)));
+    	    k++; count++;
+    	    }
+        
+    	elemsP[j + 1].iNum = k;
+    	aElements.Append(elemsP[j + 1]);    
+    	}
+    	        
+    delete[] objectHandles;	
+    delete[] argsP;
+    delete[] elemsP;
+    IF_DEBUG(Print(_L("<<<TDpsStartJob::FillReqArgs")));                        
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+// 
+EXPORT_C void TDpsStartJob::CreateReqScriptL(const TDpsArgArray& aArguments, 
+                                            const TDpsEleArray& aElements,
+                                            TDpsAttribute /*aAttribute*/,  
+                                            RWriteStream& aScript, 
+                                            CDpsTransaction* aTrader)
+    {
+    IF_DEBUG(Print(_L(">>>TDpsStartJob::CreateReqScript")));                        
+    CDpsXmlGenerator* g = aTrader->Generator();
+    g->StartDocumentL(aScript);
+    g->StartInputL(aScript);
+    g->StartOperationL((TDpsOperation)iOperation, aScript);
+    TInt count = aElements.Count();
+    TInt limit = 0;
+    for (TInt i = 0; i < count; i++)
+	    {
+		g->StartElementL(aElements[i].iElement, aScript);
+		TInt init = limit;
+		limit = (i == 0 ? aElements[0].iNum : limit + aElements[i].iNum);
+		for (TInt j = init; j < limit; j++)
+			{
+			g->CreateArgL(aScript,aArguments[j]);
+			}
+		g->EndElementL(aElements[i].iElement, aScript);	
+		}
+	g->EndOperationL((TDpsOperation)iOperation, aScript);
+	g->EndInputL(aScript);
+	g->EndDocumentL(aScript);	
+	IF_DEBUG(Print(_L("<<<TDpsStartJob::CreateReqScript")));                        	
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+EXPORT_C TInt TDpsAbortJob::FillReqArgs(TDpsArgArray& aArgs, 
+                                        TDpsEleArray& /*aElems*/,
+                                        TDpsAttribute& /*aAttrib*/, 
+                                        CDpsTransaction* /*aParam*/)
+    {
+    IF_DEBUG(Print(_L(">>>TDpsAbortJob::FillReqArgs")));                            
+    TDpsArg arg;
+    arg.iElement = EDpsArgAbortStyle;
+    arg.iContent.AppendNumUC(iReqParam.iAbortStyle, EHex);
+    arg.iContent.Append(KDpsLowZero);
+    aArgs.Append(arg);
+    IF_DEBUG(Print(_L("<<<TDpsAbortJob::FillReqArgs")));                            
+    return KErrNone;
+    }
+    
+// ---------------------------------------------------------------------------
+// Some request parameters should be checked
+// ---------------------------------------------------------------------------
+//    
+EXPORT_C TInt TDpsGetCapability::FillReqArgs(TDpsArgArray& aArgs, 
+                                             TDpsEleArray& aElements,
+                                             TDpsAttribute& aAttrib, 
+                                             CDpsTransaction* /*aParam*/)
+    {
+    IF_DEBUG(Print(_L(">>>TDpsGetCapability::FillReqArgs")));                                
+    // only one element
+    TDpsEle elems;
+    elems.iElement = EDpsCapability;
+    elems.iNum = 1;
+    aElements.Append(elems);
+    
+    // only one parameter
+    TDpsArg argsP;
+    argsP.iElement = iReqParam.iCap;
+    aArgs.Append(argsP);
+    if (EDpsArgPaperTypes == iReqParam.iCap || EDpsArgLayouts == iReqParam.iCap)
+        {
+        if (iReqParam.iAttribute != 0)
+            {
+            aAttrib = iReqParam.iAttribute;
+            }
+        }
+    IF_DEBUG(Print(_L("<<<TDpsGetCapability::FillReqArgs")));                                    
+    return KErrNone;    
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+EXPORT_C void TDpsGetCapability::CreateReqScriptL(
+                                             const TDpsArgArray& aArguments, 
+                                             const TDpsEleArray& aElements,
+                                             TDpsAttribute aAttribute, 
+                                             RWriteStream& aScript, 
+                                             CDpsTransaction* aTrader)
+    {
+    IF_DEBUG(Print(_L(">>>TDpsGetCapability::CreateReqScript")));    
+    CDpsXmlGenerator* g = aTrader->Generator();
+    g->StartDocumentL(aScript);
+    g->StartInputL(aScript);
+    g->StartOperationL((TDpsOperation)iOperation, aScript);
+	g->StartElementL(aElements[0].iElement, aScript);
+	const TInt count = aArguments.Count();
+	for (TInt i = 0; i < count; i++)
+		{
+		g->CreateArgL(aScript, aArguments[i], aAttribute);
+		}
+	g->EndElementL(aElements[0].iElement, aScript);
+	g->EndOperationL((TDpsOperation)iOperation, aScript);	
+	g->EndInputL(aScript);
+	g->EndDocumentL(aScript);
+	IF_DEBUG(Print(_L("<<<TDpsGetCapability::CreateReqScript")));    		
+    }
+        
+// ---------------------------------------------------------------------------
+// Some request parameters should be checked
+// ---------------------------------------------------------------------------
+//    
+EXPORT_C TInt TDpsConfigPrintService::FillReqArgs(TDpsArgArray& aArgs, 
+                                                  TDpsEleArray& /*aElems*/,
+                                                  TDpsAttribute& /*aAttrib*/, 
+                                                  CDpsTransaction* /*aParam*/)
+    {
+    IF_DEBUG(Print(_L(">>>TDpsConfigPrintService::FillReqArgs")));
+    TDpsArg* argsP = new TDpsArg[KConfigPrintService]; 
+    if (!argsP)
+        {
+        return KErrNoMemory;
+        }
+    TInt count;     
+    for (TInt i = 0; i < KConfigPrintService; i++)
+        {
+        switch (i)
+            {
+        // there might be several versions
+        case EDpsArgDpsVersions:
+            argsP[i].iElement = EDpsArgDpsVersions;
+            count = iReqParam.iDpsVersions.Count();
+            for (TInt j = 0; j < count; j++)
+                {
+                argsP[i].iContent.AppendNumUC
+                    (iReqParam.iDpsVersions[j].iMajor);
+                argsP[i].iContent.Append(_L("."));    
+                argsP[i].iContent.AppendNumUC
+                    (iReqParam.iDpsVersions[j].iMinor);    
+                }
+            aArgs.Append(argsP[i]);
+        break;    
+        
+        case EDpsArgVendorName: // vender name
+            
+            argsP[i].iElement = EDpsArgVendorName;
+            argsP[i].iContent.Append(iReqParam.iVendorName);
+            aArgs.Append(argsP[i]);
+                        
+        break;  
+        
+        case EDpsArgVendorSpecificVersion: // vender version (optional)
+            if (iReqParam.iVendorVersion.iMajor && 
+                iReqParam.iVendorVersion.iMinor)
+                {
+                argsP[i].iElement = EDpsArgVendorSpecificVersion;
+                argsP[i].iContent.AppendNumUC(iReqParam.iVendorVersion.iMajor);
+                argsP[i].iContent.Append(_L("."));    
+                argsP[i].iContent.AppendNumUC(iReqParam.iVendorVersion.iMinor);
+                aArgs.Append(argsP[i]);        
+                }
+            
+        break;
+        
+        case EDpsArgProductName: // produce name
+            argsP[i].iElement = EDpsArgProductName;
+            argsP[i].iContent.Append(iReqParam.iProductName);
+            aArgs.Append(argsP[i]);
+        break;
+        
+        case EDpsArgSerialNo: // serialNo (optional)
+            if (iReqParam.iSerialNo.Length())
+                {
+                argsP[i].iElement = EDpsArgSerialNo;
+                argsP[i].iContent.Append(iReqParam.iSerialNo);    
+                aArgs.Append(argsP[i]);
+                }
+            
+        break;
+        
+        default:
+            IF_DEBUG(Print(_L("***Wrong parameter")));
+            delete[] argsP;
+            return KErrArgument;
+            }
+        
+        }
+    delete[] argsP;
+    IF_DEBUG(Print(_L("<<<TDpsConfigPrintService::FillReqArgs")));    
+    return KErrNone;    
+    }
+
+// ---------------------------------------------------------------------------
+//  Not all parameters are checked. If the invalid parameter can pass the 
+//  the complaint test, it should not be checked. Instead, the client will see
+//  it as unknown error. Otherwise, there might be unnecessary code and the
+//  client cannot be informed. 
+// ---------------------------------------------------------------------------
+//    
+EXPORT_C TInt TDpsGetCapability::FillRepArgs(const TDpsArgArray& aArgs, 
+                                             CDpsTransaction* aTrader)
+    {
+    IF_DEBUG(Print(_L(">>>TDpsGetCapability::FillRepArgs")));    
+    CDpsXmlParser* XmlPar = aTrader->Parser();
+    
+    if (aArgs.Count())
+        {
+        if (EDpsArgPaperTypes == aArgs[0].iElement || 
+            EDpsArgLayouts == aArgs[0].iElement)
+            {
+            if (XmlPar->HasAttribute())
+                {
+                TDpsAttribute attrib;
+		        XmlPar->GetAttribute(attrib);
+		        iRepParam.iContent.Append(attrib);            
+                }
+            else
+                {
+                iRepParam.iContent.Append(0);
+                }    
+            }
+        TUint32 value;
+        TLex8 converter;
+        TLex8 parser(aArgs[0].iContent);
+        parser.SkipSpace();
+        while (!parser.Eos())
+            {
+            parser.Mark();
+            parser.SkipCharacters();
+            if (KFullWordWidth == parser.TokenLength())
+                {
+                TPtrC8 token = parser.MarkedToken();
+                converter.Assign(token);
+                parser.SkipSpace();  
+                }
+            else
+                {
+                IF_DEBUG(Print(_L("***Wrong argument")));
+                return KErrArgument;
+                }
+            TInt error = converter.Val(value, EHex);
+            if (error != KErrNone)
+                {
+                IF_DEBUG(Print(_L("convert error %d"), error));
+                return error;
+                }
+            if (EDpsArgPaperTypes == aArgs[0].iElement)
+                {
+                TDpsPaperType paperType;
+                TInt major = value >> KShiftLength;
+                paperType.iMajor = (TDpsPaperTypeMajor)major;
+                paperType.iMinor = (TDpsPaperTypeMinor)(value & KDpsMinorMask);
+                iRepParam.iPaperType.Append(paperType);
+                }
+            else
+                {
+                // remove the extra zeros
+                value = value >> KShiftLength; 
+                iRepParam.iContent.Append(value);
+                IF_DEBUG(Print(_L("the value is %x"), value));
+                }
+            
+            }
+        iRepParam.iCap = aArgs[0].iElement;
+           
+        }
+    
+    IF_DEBUG(Print(_L("<<<TDpsGetCapability::FillRepArgs")));
+    return KErrNone;    
+    }
+
+// ---------------------------------------------------------------------------
+//  Not all parameters are checked. If the invalid parameter can pass the 
+//  the complaint test, it should not be checked. Instead, the client will see
+//  it as unknown error. Otherwise, there might be unnecessary code and the
+//  client cannot be informed. 
+// ---------------------------------------------------------------------------
+//    
+EXPORT_C TInt TDpsConfigPrintService::FillRepArgs(const TDpsArgArray& aArgs, 
+                                                  CDpsTransaction* aTrader)
+    {
+    IF_DEBUG(Print(_L(">>>TDpsConfigPrintService::FillRepArgs")));    
+    TInt error = KErrNone;
+    TLex8 converter, parser;
+    const TInt count = aArgs.Count();
+    
+    for (TInt i = 0; i < count; i++)
+        {
+        switch (aArgs[i].iElement)
+            {
+            case EDpsArgPrintServiceAvailable: 
+                converter.Assign(aArgs[i].iContent);
+                TInt64 result;
+                error = converter.Val(result, EHex);
+                if (error != KErrNone)
+                    {
+                    IF_DEBUG(Print(_L("*** convert error")));
+                    return error;
+                    }
+                // removes the low four bytes zeros. 
+                IF_DEBUG(Print(_L("--Printer available is %x"), result));   
+                result = result >> KShiftLength;    
+                iRepParam.iPrintAvailable = result;
+            break;
+        
+            case EDpsArgDpsVersions:
+                TDpsVersion version;
+            
+                parser.Assign(aArgs[i].iContent);
+                while (!parser.Eos())
+                    {
+                    parser.Mark();
+                    parser.SkipCharacters();
+                    if (parser.TokenLength())
+                        {
+                        TPtrC8 token = parser.MarkedToken();
+                        converter.Assign(token);
+                        parser.SkipSpace();
+                        }
+                    else
+                        {
+                        IF_DEBUG(Print(_L("***wrong !!!")));
+                        return KErrArgument;
+                        }
+                    error = aTrader->ConvertVersion(converter, version);
+                    if (error != KErrNone)
+                        {
+                        return error;
+                        }
+                    iRepParam.iDpsVersions.Append(version);            
+                    }
+            break;
+        
+            case EDpsArgVendorName:
+                iRepParam.iVendorName.Copy(aArgs[i].iContent);
+                IF_DEBUG(Print(_L
+                                ("vendor name is %S"), &iRepParam.iVendorName));
+            break;
+        
+            case EDpsArgVendorSpecificVersion:
+                parser.Assign(aArgs[i].iContent);
+                aTrader->ConvertVersion(parser, version);
+                iRepParam.iVendorVersion = version;
+                IF_DEBUG(Print(_L
+                        ("vendor version is %x"), iRepParam.iVendorVersion));
+            break;
+       
+            case EDpsArgProductName:
+                iRepParam.iProductName.Copy(aArgs[i].iContent);
+                IF_DEBUG(Print(_L
+                        ("product name is %S"), &iRepParam.iProductName));
+            break;
+        
+            case EDpsArgSerialNo:
+                iRepParam.iSerialNo.Copy(aArgs[i].iContent);
+                IF_DEBUG(Print(_L("SerialNo is %S"), &iRepParam.iSerialNo));
+            break;
+        
+            default:
+                IF_DEBUG(Print(_L("--Unknown param!!")));
+                return KErrArgument;
+            }
+        }
+        
+    IF_DEBUG(Print(_L("<<<TDpsConfigPrintService::FillRepArgs")));
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+//  Not all parameters are checked. If the invalid parameter can pass the 
+//  the complaint test, it should not be checked. Instead, the client will see
+//  it as unknown error. Otherwise, there might be unnecessary code and the
+//  client cannot be informed. 
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt TDpsGetJobStatus::FillRepArgs(const TDpsArgArray& aArgs, 
+                                            CDpsTransaction* aTrader)
+    {
+    IF_DEBUG(Print(_L(">>>TDpsGetJobStatus::FillRepArgs")));
+    TInt value, error, per;
+    TBuf<KMaxArgLen> fileName;
+    TLex8 converter;    
+    TInt count = aArgs.Count();
+    TBool reply = aTrader->IsReply();
+    if (!reply)
+        {
+        aTrader->Engine()->Event()->iEvent = EDpsEvtNotifyJobStatus;
+        }
+    else
+        {
+        aTrader->Engine()->Event()->iEvent = EDpsEvtEmpty;
+        }
+    for (TInt i = 0; i < count; i++)
+        {
+        switch (aArgs[i].iElement)
+            {
+            case EDpsArgPrtPID:
+                converter.Assign(aArgs[i].iContent);
+                error = converter.Val(value);
+                if (error != KErrNone)
+                    {
+                    return error;
+                    }
+                if (reply)
+                    {
+                    iRepParam.iPrtPID = value;
+                    }
+                else
+                    {
+                    aTrader->Engine()->Event()->iJobEvent.iRepParam.iPrtPID = 
+                        value;
+                    }
+            break;
+                
+            case EDpsArgFilePath:
+                if (reply)
+                    {
+                    iRepParam.iFilePath.Copy(aArgs[i].iContent);
+                    }
+                else
+                    {
+                    aTrader->Engine()->Event()->iJobEvent.iRepParam.iFilePath. 
+                    Copy(aArgs[i].iContent);
+                    }
+            break;
+                
+            case EDpsArgCopyID:
+                converter.Assign(aArgs[i].iContent);
+                error = converter.Val(value);
+                if (error != KErrNone)
+                    {
+                     return error;
+                    }
+                if (reply)
+                    {
+                    iRepParam.iCopyID = value;
+                    }
+                else
+                    {
+                    aTrader->Engine()->Event()->iJobEvent.iRepParam.iCopyID = 
+                        value;
+                    }    
+            break;
+                
+            case EDpsArgProgress:
+                per = aTrader->ParsePercentage(aArgs[i].iContent);
+                if (per < KErrNone)
+                    {
+                    return per;
+                    }
+                
+                if (reply)
+                    {
+                    iRepParam.iProgress = per;
+                    }
+                else
+                    {
+                    aTrader->Engine()->Event()->iJobEvent.iRepParam.iProgress = 
+                        per;
+                    }
+            break;
+               
+            case EDpsArgImagesPrinted:
+                converter.Assign(aArgs[i].iContent);
+                error = converter.Val(value);
+                if (error != KErrNone)
+                    {
+                     return error;
+                    }
+                if (reply)
+                    {
+                    iRepParam.iImagesPrinted = value;
+                    }
+                else
+                    {
+                    aTrader->Engine()->Event()->iJobEvent.iRepParam.
+                        iImagesPrinted = value;
+                    }                                                                  
+            break;
+            
+            default:
+                IF_DEBUG(Print(_L("***wrong param!!!")));
+                return KErrArgument;                
+            }
+        }
+    IF_DEBUG(Print(_L("<<<TDpsGetJobStatus::FillRepArgs")));    
+    return KErrNone;    
+    }
+
+// ---------------------------------------------------------------------------
+//  Not all parameters are checked. If the invalid parameter can pass the 
+//  the complaint test, it should not be checked. Instead, the client will see
+//  it as unknown error. Otherwise, there might be unnecessary code and the
+//  client cannot be informed. 
+// ---------------------------------------------------------------------------
+//    
+EXPORT_C TInt TDpsGetPrinterStatus::FillRepArgs(const TDpsArgArray& aArgs, 
+                                                CDpsTransaction* aTrader)
+    {
+    IF_DEBUG(Print(_L(">>>TDpsGetPrinterStatus::FillRepArgs")));
+    // if UI has not pass the event pointer, we do need to fill in it
+    if (!aTrader->Engine()->Event())
+        {
+        return KErrNone;
+        }
+    TLex8 converter;
+    TDpsPrinterStatusRep param;
+    const TInt count = aArgs.Count();
+    TUint32 value, temp;
+    TBool reply = aTrader->IsReply();
+    if (!reply)
+        {
+        aTrader->Engine()->Event()->iEvent = EDpsEvtNotifyDeviceStatus;
+        }
+    else
+        {
+        aTrader->Engine()->Event()->iEvent = EDpsEvtEmpty;
+        }
+    for (TInt i = 0; i < count; i++)
+        {
+        converter.Assign(aArgs[i].iContent);
+        TInt error = converter.Val(value, EHex);
+        if (error != KErrNone)
+            {
+            return error;
+            }
+        IF_DEBUG(Print(_L("--the value is %x"), value));
+        
+        switch (aArgs[i].iElement)
+            {
+            case EDpsArgDpsPrintServiceStatus:
+                value = value >> KShiftLength;
+                if (EDpsPrintServiceStatusPrinting == value ||
+                    EDpsPrintServiceStatusIdle == value ||
+                    EDpsPrintServiceStatusPaused == value)
+                    {
+                    if (reply)
+                        {
+                        iRepParam.iPrintStatus = 
+                            (TDpsPrintServiceStatus)(value);
+                        }
+                    else
+                        {
+                        aTrader->Engine()->Event()->iPrinterEvent.iRepParam.
+                            iPrintStatus = (TDpsPrintServiceStatus)(value);
+                        }
+                    }
+                else
+                    {
+                    return KErrArgument;
+                    }
+                    
+            break;
+            
+            case EDpsArgJobEndReason:
+                value = value >> KShiftLength;
+                if (EDpsJobStatusNotEnded == value ||
+                    EDpsJobStatusEndedOk == value ||
+                    EDpsJobStatusEndedAbortImmediately == value ||
+                    EDpsJobStatusEndedAbortCompleteCurrent == value ||
+                    EDpsJobStatusEndedOther == value)
+                    {
+                    if (reply)
+                        {
+                        iRepParam.iJobStatus = (TDpsJobStatus)(value);    
+                        }
+                    else
+                        {
+                        aTrader->Engine()->Event()->iPrinterEvent.iRepParam.
+                            iJobStatus = (TDpsJobStatus)(value);    
+                        }    
+                    }
+                else
+                    {
+                    return KErrArgument;
+                    }
+                
+            break;
+            
+            case EDpsArgErrorStatus:
+                value = value >> KShiftLength;
+                if (EDpsErrorStatusOk == value ||
+                    EDpsErrorStatusWarning == value ||
+                    EDpsErrorStatusFatal == value)
+                    {
+                    if (reply)
+                        {
+                        iRepParam.iErrorStatus = (TDpsErrorStatus)(value);    
+                        }
+                    else
+                        {
+                        aTrader->Engine()->Event()->iPrinterEvent.iRepParam.
+                            iErrorStatus = (TDpsErrorStatus)(value);
+                        }    
+                    }
+                else
+                    {
+                    return KErrArgument;
+                    }
+                
+            break;
+            
+            case EDpsArgErrorReason:
+                temp = value >> KShiftLength;
+                if (EDpsJobErrorNone == temp ||
+                    EDpsJobErrorPaper == temp ||
+                    EDpsJobErrorInk == temp ||
+                    EDpsJobErrorHardware == temp ||
+                    EDpsJobErrorFile == temp)
+                    {
+                    param.iJobEndReason.iMajor = 
+                        (TDpsJobEndReasonMajor)(temp);
+                    IF_DEBUG(Print(_L("the end reason is %x"), temp));
+                    value = value & KDpsMinorMask;
+                    switch (param.iJobEndReason.iMajor)
+                        {
+                        case EDpsJobErrorPaper:
+                            param.iJobEndReason.iPaperMinor = 
+                                (TDpsJobEndReasonPaper)(value);
+                        break;
+        
+                        case EDpsJobErrorInk:
+                            param.iJobEndReason.iInkMinor = 
+                                (TDpsJobEndReasonInk)(value);
+                        break;
+        
+                        case EDpsJobErrorHardware:
+                            param.iJobEndReason.iHardMinor = 
+                                (TDpsJobEndReasonHard)(value);
+                        break;
+        
+                        case EDpsJobErrorFile:
+                            param.iJobEndReason.iFileMinor = 
+                                (TDpsJobEndReasonFile)(value);
+                        break;
+        
+                        default:
+                            IF_DEBUG(Print(_L("no minor error")));
+                        break; 
+                        }
+                    if (reply)
+                        {
+                        iRepParam.iJobEndReason = param.iJobEndReason;
+                        }
+                    else
+                        {
+                        aTrader->Engine()->Event()->iPrinterEvent.iRepParam.
+                            iJobEndReason = param.iJobEndReason;
+                        }
+                    }
+                else
+                    {
+                    return KErrArgument;
+                    }
+                
+            break;
+            
+            case EDpsArgDisconnectEnable:
+                value = value >> KShiftLength;
+                if (EDpsDisconnectEnableFalse == value)
+                    {
+                    param.iDisconnectEnable = EFalse;    
+                    }
+                else if (EDpsDisconnectEnableTrue == value)
+                    {
+                    param.iDisconnectEnable = ETrue;
+                    }
+                else
+                    {
+                    return KErrArgument;
+                    }
+                if (reply)
+                    {
+                    iRepParam.iDisconnectEnable = param.iDisconnectEnable; 
+                    }
+                else
+                    {
+                    aTrader->Engine()->Event()->iPrinterEvent.iRepParam.
+                        iDisconnectEnable = param.iDisconnectEnable; 
+                    }    
+            break;
+            
+            case EDpsArgCapabilityChanged:
+                value = value >> KShiftLength;
+                if (EDpsCapabilityChangedFalse == value)
+                    {
+                    param.iCapabilityChange = EFalse;    
+                    }
+                else if (EDpsCapabilityChangedTrue == value)
+                    {
+                    param.iCapabilityChange = ETrue;
+                    }
+                else
+                    {
+                    return KErrArgument;
+                    }
+                if (reply)
+                    {
+                    iRepParam.iCapabilityChange = param.iCapabilityChange;
+                    }
+                else
+                    {
+                    aTrader->Engine()->Event()->iPrinterEvent.iRepParam.
+                        iCapabilityChange = param.iCapabilityChange;
+                    }
+            break;
+            
+            case EDpsArgNewJobOk:
+                value = value >> KShiftLength;
+                if (EDpsNewJobOkTrue == value)
+                    {
+                    param.iNewJobOk = ETrue;    
+                    }
+                else if (EDpsNewJobOkFalse == value)
+                    {
+                    param.iNewJobOk = EFalse;   
+                    }
+                else
+                    {
+                    return KErrArgument;
+                    }
+                if (reply)
+                    {
+                    iRepParam.iNewJobOk = param.iNewJobOk;
+                    }
+                else
+                    {
+                    aTrader->Engine()->Event()->iPrinterEvent.iRepParam.
+                        iNewJobOk = param.iNewJobOk;
+                    }    
+            break;
+            
+            default:
+                IF_DEBUG(Print(_L("***wrong param")));
+                return KErrArgument;
+            }
+        }
+ 
+    IF_DEBUG(Print(_L("<<<TDpsGetPrinterStatus::FillRepArgs")));    
+    return KErrNone;    
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsparam.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  inline functions of dps parameter. 
+*
+*/
+
+
+#include "dpsparam.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+EXPORT_C void TDpsPrintInfo::Reset()
+    {
+    isDPOF = EFalse; iFileID = 0; iFileName = EFalse; iDate.Zero(); 
+    iCopies = 0; iPrtPID = 0; iCopyID = 0;
+    }
+ 
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+EXPORT_C TInt TDpsStartJobReq::GetParamNum()
+    {
+    TInt num = iJobConfig.Count(), count = iPrintInfo.Count();
+	for (TInt i = 0; i < count; i++)
+	    {
+	    // there is always fileID field
+	    num++;
+	    if (iPrintInfo[i].iFileName)
+	        {
+	        num++;
+	        }
+	    if (iPrintInfo[i].iDate.Size())
+	        {
+	        num++;
+	        }
+	    if (iPrintInfo[i].iCopies !=0)
+	        {
+	        num++;
+	        }
+	    if (iPrintInfo[i].iPrtPID != 0)
+	        {
+	        num++;
+	        }             
+	        
+	    if (iPrintInfo[i].iCopyID != 0)
+	        {
+	        num++;
+	        }    
+	    }
+	return num;   
+	}
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    	
+EXPORT_C void TDpsJobStatusRep::Reset()
+    {
+    iProgress = 0; iImagesPrinted = 0; iFilePath.Zero(); 
+    iPrtPID = 0; iCopyID = 0;
+    }    
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsptpnotifier.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,132 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class implements functions of setting personality to 
+*                MTP. 
+*  Version     : %version: 1 % 
+*
+*/
+
+
+#include <e32debug.h>
+#include "dpsptpnotifier.h"
+#include "dpsusbnotifier.h"
+#include "dpsconst.h"
+
+#ifdef _DEBUG
+#	define IF_DEBUG(t) {RDebug::t;}
+#else
+#	define IF_DEBUG(t)
+#endif
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CDpsPtpNotifier* CDpsPtpNotifier::NewL(CDpsUsbNotifier* aParent)
+    {
+    IF_DEBUG(Print(_L("CDpsPtpNotifier::NewL")));
+    CDpsPtpNotifier* self = new(ELeave) CDpsPtpNotifier(aParent);
+    return self;	    
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CDpsPtpNotifier::CDpsPtpNotifier(CDpsUsbNotifier* aParent) :
+    CActive(EPriorityNormal), iNotifier(aParent)
+    {
+    IF_DEBUG(Print(_L(">>>CDpsPtpNotifier::Ctor")));    
+    CActiveScheduler::Add(this);
+    IF_DEBUG(Print(_L("<<<CDpsPtpNotifier::Ctor")));    
+    }    
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CDpsPtpNotifier::~CDpsPtpNotifier()
+    {
+    IF_DEBUG(Print(_L(">>>CDpsPtpNotifier::")));        
+    Cancel();
+    IF_DEBUG(Print(_L("<<<CDpsPtpNotifier::~")));        
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+void CDpsPtpNotifier::ChangePtpPersonality()    
+    {
+    IF_DEBUG(Print(_L(">>>CDpsPtpNotifier::ChangePtpPersonality")));            
+    if (!IsActive())
+        {
+        TInt personalityId = KUsbPersonalityIdMTP;
+        iNotifier->iUsbM.GetCurrentPersonalityId(personalityId);
+        IF_DEBUG(Print(_L("CDpsPtpNotifier::ChangePtpPersonality, current personality= %d"), personalityId));
+        if(KUsbPersonalityIdPCSuiteMTP == personalityId)
+            {
+            TRequestStatus* statusPtr = &iStatus;
+            User::RequestComplete(statusPtr, KErrNone);
+            SetActive();            
+            }
+        else                
+            {
+            iNotifier->iUsbW.SetPersonality(iStatus, KUsbPersonalityIdMTP, ETrue);
+            SetActive();
+            }
+        }
+    IF_DEBUG(Print(_L("<<<CDpsPtpNotifier::ChangePtpPersonality")));        
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsPtpNotifier::RunL()
+    {
+    IF_DEBUG(Print(_L(">>>CDpsPtpNotifier::RunL %d"), iStatus.Int()));            
+    if (KErrNone == iStatus.Int())
+        {
+        iNotifier->iPersonality = KUsbPersonalityIdMTP;
+        TInt ret = iNotifier->ConnectState();
+        if (ret != KErrNone)
+            {
+            IF_DEBUG(Print(_L("error happened %d"), ret));
+            }
+        }
+    iNotifier->PtpNotify(iStatus.Int());        
+    IF_DEBUG(Print(_L("<<<CDpsPtpNotifier::RunL")));
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsPtpNotifier::DoCancel()
+    {
+    IF_DEBUG(Print(_L(">>>CDpsPtpNotifier::DoCancel")));                
+    iNotifier->iUsbW.CancelSetPersonality();
+    IF_DEBUG(Print(_L("<<<CDpsPtpNotifier::DoCancel")));                
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TInt CDpsPtpNotifier::RunError(TInt aErr)
+    {
+    IF_DEBUG(Print(_L("CDpsPtpNotifier::RunError")));                    
+    return aErr;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsscriptreceiver.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,174 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class implements the dps script receiving function. 
+*
+*/
+
+
+#include <e32debug.h>
+#include <f32file.h>
+#include "dpsscriptreceiver.h"
+#include "dpsstatemachine.h"
+#include "pictbridge.h"
+#include "dpsconst.h"
+
+#ifdef _DEBUG
+#	define IF_DEBUG(t) {RDebug::t;}
+#else
+#	define IF_DEBUG(t)
+#endif
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CDpsScriptReceiver* CDpsScriptReceiver::NewL(CDpsStateMachine* aOperator)								 	     
+    {
+    IF_DEBUG(Print(_L("CDpsScriptReceiver::NewL")));
+    CDpsScriptReceiver* self = new(ELeave) CDpsScriptReceiver(aOperator);
+    return self;	
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CDpsScriptReceiver::CDpsScriptReceiver(CDpsStateMachine* aOperator) :
+    CActive(EPriorityNormal), iOperator(aOperator),
+    iFileNameAndPath(KDpsHostResponseFileName)
+    {
+    IF_DEBUG(Print(_L(">>>CDpsScriptReceiver::Ctor")));
+    CActiveScheduler::Add(this);  
+    WaitForReceive();
+    IF_DEBUG(Print(_L("<<<CDpsScriptReceiver::Ctor")));
+    }  
+ 
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+CDpsScriptReceiver::~CDpsScriptReceiver()
+    {
+    IF_DEBUG(Print(_L(">>>~CDpsScriptReceiver")));
+    Cancel();
+    IF_DEBUG(Print(_L("<<<~CDpsScriptReceiver")));
+    }
+ 
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//   
+void CDpsScriptReceiver::WaitForReceive()
+    {
+    IF_DEBUG(Print(_L(">>>CDpsScriptReceiver::WaitForReceive"))); 
+    if (!IsActive())
+        {	
+        iOperator->DpsEngine()->Ptp().ObjectReceivedNotify(KDpsScriptFile, 
+            iFileNameAndPath, iStatus, EFalse);        
+        SetActive();		    	
+        }
+    IF_DEBUG(Print(_L("<<<CDpsScriptReceiver::WaitForReceive"))); 		
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+TInt CDpsScriptReceiver::GetFileName(TDes& aFileName)
+    {
+    TParse p;
+    TInt err = p.Set(iFileNameAndPath, NULL, NULL);
+    if (KErrNone == err)
+        {
+        aFileName.Copy(p.NameAndExt());
+        }
+    return err;    
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+const TDesC& CDpsScriptReceiver::FileNameAndPath()
+    {
+    return iFileNameAndPath;
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CDpsScriptReceiver::RunL()
+    {
+    IF_DEBUG(Print(_L(">>>CDpsScriptReceiver::RunL %S"), &iFileNameAndPath));
+    // in the certain error case, it is possible that the printer sending
+    // the device status before the UI is ready to receive this event.
+    // in this case, pictbridge engine still does not get the ptp folder
+    // setting from the stack. 
+    // if we receive script from host, the stack has started. so we check if
+    // we already get the ptp folder here.
+    if (!iOperator->DpsEngine()->DpsFolder().Length())
+        {
+        iOperator->DpsEngine()->SetDpsFolder(
+            iOperator->DpsEngine()->Ptp().PtpFolder());
+        }
+    if (KErrNone == iStatus.Int())
+        {
+        TFileName receive;
+        User::LeaveIfError(GetFileName(receive));
+        IF_DEBUG(Print(_L("received file is %S"), &receive));
+         // reply from Host is received    
+        if (!receive.Compare(KDpsHostResponseFileName))
+            {
+            iOperator->ScriptReceivedNotifyL(ETrue);    
+            }
+        // request from Host is received    
+        else if (!receive.Compare(KDpsHostRequestFileName))
+            {
+            iOperator->ScriptReceivedNotifyL(EFalse);    
+            }
+        WaitForReceive();    
+        }                
+    else
+    	{
+        IF_DEBUG(Print(_L("the iStatus is wrong!!! %d"), iStatus.Int()));
+        iOperator->Error(iStatus.Int());
+        }    
+    IF_DEBUG(Print(_L("<<<CDpsScriptReceiver::RunL")));
+    }
+ 
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+void CDpsScriptReceiver::DoCancel()
+    {
+    IF_DEBUG(Print(_L(">>>CDpsScriptReceiver::DoCancel")));
+    iOperator->DpsEngine()->Ptp().CancelObjectReceivedNotify();
+    IF_DEBUG(Print(_L("<<<CDpsScriptReceiver::DoCancel")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+TInt CDpsScriptReceiver::RunError(TInt aError)	
+    {
+    IF_DEBUG(Print(_L(">>>CDpsScriptReceiver::RunError is %d"), aError));
+    // if error happened cancel the outstanding request
+    Cancel();
+    iOperator->Error(aError);
+    IF_DEBUG(Print(_L("<<<CDpsScriptReceiver::RunError")));
+    return KErrNone;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsscriptsender.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,168 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class implements the dps script sending function. 
+*
+*/
+
+
+#include <e32debug.h>
+#include <f32file.h>
+#include "dpsscriptsender.h"
+#include "dpsstatemachine.h"
+#include "pictbridge.h"
+#include "dpstransaction.h"
+#include "dpsfile.h"
+
+#ifdef _DEBUG
+#	define IF_DEBUG(t) {RDebug::t;}
+#else
+#	define IF_DEBUG(t)
+#endif
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CDpsScriptSender* CDpsScriptSender::NewL(CDpsStateMachine* aOperator)
+    {
+    IF_DEBUG(Print(_L("CDpsScriptSender::NewL")));
+    CDpsScriptSender* self = new(ELeave) CDpsScriptSender(aOperator);
+    return self;	
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CDpsScriptSender::CDpsScriptSender(CDpsStateMachine* aOperator) : 
+    CActive(EPriorityNormal), iOperator(aOperator), 
+    iReply(EFalse) 
+    {
+    IF_DEBUG(Print(_L(">>>CDpsScriptSender::Ctor")));
+    CActiveScheduler::Add(this);  
+    IF_DEBUG(Print(_L("<<<CDpsScriptSender::Ctor")));
+    }  
+  
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+CDpsScriptSender::~CDpsScriptSender()
+    {
+    IF_DEBUG(Print(_L(">>>~CDpsScriptSender")));
+    Cancel();
+    IF_DEBUG(Print(_L("<<<~CDpsScriptSender")));	
+    }
+ 
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//  
+TInt CDpsScriptSender::SendScript(TBool aReply)
+    {
+    IF_DEBUG(Print(_L(">>>CDpsScriptSender::SendScript")));  
+    if (!IsActive())
+        {
+        iReply = aReply;  
+        TFileName file(iOperator->DpsEngine()->DpsFolder());
+        RFile script;
+        if (aReply)
+            {
+            file.Append(KDpsDeviceResponseFileName);
+            }
+        else
+            {
+            file.Append(KDpsDeviceRequestFileName);
+            }
+        TInt err = script.Open(iOperator->Trader()->
+            FileHandle()->FileSession(), file, EFileRead);
+        if (err != KErrNone)
+            {
+            return err;
+            }
+        TInt size;    
+        script.Size(size);
+        script.Close();
+        if (aReply)
+            {
+            iOperator->DpsEngine()->
+                Ptp().SendObject(file, iStatus, EFalse, size);       
+            }
+        else
+            {            
+            iOperator->DpsEngine()->
+                Ptp().SendObject(file, iStatus, ETrue, size);
+            }
+        SetActive();    
+        IF_DEBUG(Print(_L("<<<CDpsScriptSender::SendScript")));
+	    return KErrNone;
+        }
+    else
+        {
+        return KErrInUse;
+        }
+    }
+ 
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsScriptSender::RunL()
+    {
+    IF_DEBUG(Print(_L(">>>CDpsScriptSender::RunL")));
+    
+    if (KErrNone == iStatus.Int())
+        {
+        // the device request is sent
+        if (!iReply)
+            {
+            iOperator->ScriptSentNotifyL(EFalse);      
+            }    
+        // the device response is sent    
+        else 
+            {
+            iOperator->ScriptSentNotifyL(ETrue);      
+            }
+        }                
+    else
+    	{
+        IF_DEBUG(Print(_L("the iStatus is wrong %d!!!"), iStatus.Int()));
+        iOperator->Error(iStatus.Int());
+    	}
+    IF_DEBUG(Print(_L("<<<CDpsScriptSender::RunL")));
+    }
+  
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//  
+void CDpsScriptSender::DoCancel()
+    {
+    IF_DEBUG(Print(_L(">>>CDpsScriptSender::DoCancel")));
+    iOperator->DpsEngine()->Ptp().CancelSendObject();
+    IF_DEBUG(Print(_L("<<<CDpsScriptSender::DoCancel")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+TInt CDpsScriptSender::RunError(TInt aError)	
+    {
+    IF_DEBUG(Print(_L(">>>CDpsScriptSender::RunError is %d"), aError));
+    Cancel();
+    iOperator->Error(aError);
+    IF_DEBUG(Print(_L("<<<CDpsScriptSender::RunError")));
+    return KErrNone;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsstate.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,235 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  These classes implement dps states. 
+*
+*/
+
+#include <e32debug.h>
+#include "dpsstate.h"
+#include "dpsstatemachine.h"
+#include "dpstransaction.h"
+#include "dpsscriptreceiver.h"
+#include <pictbridge.h>
+ 
+#ifdef _DEBUG
+#	define IF_DEBUG(t) {RDebug::t;}
+#else
+#	define IF_DEBUG(t)
+#endif
+  
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TDpsIdleState::TDpsIdleState(CDpsStateMachine* aStateMachine) :
+    iStateMachine(aStateMachine) {}
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void TDpsIdleState::ScriptSentNotifyL(TBool /*aReply*/)
+    {
+    IF_DEBUG(Print(_L("TDpsIdleState::ScriptSentNotify")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void TDpsIdleState::ScriptReceivedNotifyL(TBool aReply)
+    {
+    if (!aReply)
+        {
+        IF_DEBUG(Print(_L("TDpsIdleState::ScriptReceived request got")));            
+        iStateMachine->Trader()->ParseScriptL(aReply);    
+        iStateMachine->SetState(iStateMachine->SendingRepState());
+        }
+    else
+        {
+        IF_DEBUG(Print(_L(
+            "TDpsIdleState::ScriptReceived should not get reply!!!")));    
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void TDpsIdleState::Error(TInt aErr)
+    {
+    IF_DEBUG(Print(_L("TDpsIdleState::Error %d"), aErr));
+    if ((aErr != KErrCancel) && (aErr != KErrNotReady))
+        {
+        iStateMachine->Trader()->HandleHostRequestError(aErr);
+        iStateMachine->SetState(iStateMachine->SendingRepState());    
+        }
+    
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TDpsSendingReqState::TDpsSendingReqState(CDpsStateMachine* aStateMachine) :
+    iStateMachine(aStateMachine) {}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void TDpsSendingReqState::ScriptSentNotifyL(TBool aReply)
+    {
+    if (!aReply)
+        {
+        IF_DEBUG(Print(_L("TDpsSendingReqState::ScriptSent request")));
+        iStateMachine->SetState(iStateMachine->WaitingRepState());
+        }
+    else
+        {
+        IF_DEBUG(Print(_L(
+            "TDpsSendingReqState::ScriptSent should not get reply!!")));
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void TDpsSendingReqState::ScriptReceivedNotifyL(TBool /*aReply*/)
+    {
+    IF_DEBUG(Print(_L("TDpsSendingReqState::ScriptReceived")));
+    IF_DEBUG(Print(_L("**should not reply to the request/reply from host")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void TDpsSendingReqState::Error(TInt aErr)
+    {
+    User::RequestComplete(iStateMachine->DpsEngine()->OperationRequest(), 
+                          aErr);
+    iStateMachine->Initialize();                          
+    return;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TDpsWaitingRepState::TDpsWaitingRepState(CDpsStateMachine* aStateMachine) :
+    iStateMachine(aStateMachine) {}
+
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void TDpsWaitingRepState::ScriptSentNotifyL(TBool /*aReply*/)
+    {    
+    IF_DEBUG(Print(_L("TDpsWaitingRepState::ScriptSent")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void TDpsWaitingRepState::ScriptReceivedNotifyL(TBool aReply)
+    {
+    if (aReply)
+        {
+        IF_DEBUG(Print(_L("WaitingRepState reply")))
+        
+        iStateMachine->Trader()->ParseScriptL(aReply);      
+        User::RequestComplete(
+            iStateMachine->DpsEngine()->OperationRequest(), KErrNone);        
+        iStateMachine->Initialize();        
+        }
+    else
+        {
+        IF_DEBUG(Print(_L("WaitingRepState should not get request")));
+        // collision happened, we do nothing because the host will
+        // eventually handle this by sending the correct response. but we need
+        // to subscribe for the event again.
+        iStateMachine->ScriptReceiver()->WaitForReceive();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void TDpsWaitingRepState::Error(TInt aErr)
+    {
+    // this is not tested
+    User::RequestComplete(iStateMachine->DpsEngine()->OperationRequest(), 
+                          aErr);
+    iStateMachine->Initialize();                          
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TDpsSendingRepState::TDpsSendingRepState(CDpsStateMachine* aStateMachine) :
+    iStateMachine(aStateMachine) {}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void TDpsSendingRepState::ScriptSentNotifyL(TBool aReply)
+    {
+    if (aReply)
+        {
+        IF_DEBUG(Print(_L("TDpsSendingRepState::ScriptSent reply")));
+        if (KErrNone == iStateMachine->CurError())
+            {
+            // this is the normal situation, inform the client
+            User::RequestComplete(iStateMachine->DpsEngine()->EventRequest(), 
+                              KErrNone);    
+            }
+        else
+            {
+            // this is the error situation, do not inform the client. and
+            // we need to subscribe for the new event.
+            iStateMachine->ScriptReceiver()->WaitForReceive();
+            }
+        iStateMachine->Initialize();
+        }
+    else
+        {
+        IF_DEBUG(Print(_L(
+            "TDpsSendingRepState::ScriptSent shoul not get request!!!")));
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void TDpsSendingRepState::ScriptReceivedNotifyL(TBool /*aReply*/)
+    {
+    IF_DEBUG(Print(_L("TDpsSendingRepState::ScriptReceived")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void TDpsSendingRepState::Error(TInt /*aErr*/)
+    {
+    return;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsstatemachine.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,130 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class implements the dps state machine. 
+*
+*/
+
+
+#include <e32debug.h>
+#include "dpsstatemachine.h"
+#include "dpsscriptreceiver.h"
+#include "dpsscriptsender.h"
+#include "dpstransaction.h"
+#include "dpsconst.h"
+#include "pictbridge.h"
+#include "dpsparam.h"
+#include "dpsoperation.h"
+
+#ifdef _DEBUG
+#	define IF_DEBUG(t) {RDebug::t;}
+#else
+#	define IF_DEBUG(t)
+#endif
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CDpsStateMachine* CDpsStateMachine::NewL(CDpsEngine* aEngine)
+    {
+    IF_DEBUG(Print(_L("CDpsStateMachine::NewL")));
+    CDpsStateMachine* self = new(ELeave) CDpsStateMachine(aEngine);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;	
+    }
+	
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CDpsStateMachine::~CDpsStateMachine()
+    {
+    IF_DEBUG(Print(_L(">>>~CDpsStateMachine")));
+    delete iTrader;
+    iTrader = NULL;
+    delete iScriptReceiver;
+    iScriptReceiver = NULL;
+    delete iScriptSender;
+    iScriptSender = NULL;
+    
+    delete iIdleState; iIdleState = NULL;
+    delete iSendingReqState; iSendingReqState = NULL;
+    delete iWaitingRepState; iWaitingRepState = NULL;
+    delete iSendingRepState; iSendingRepState = NULL;	
+    IF_DEBUG(Print(_L("<<<~CDpsStateMachine")));	
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+CDpsStateMachine::CDpsStateMachine(CDpsEngine* aEngine) : 
+    iEngine(aEngine),iOperation(EDpsOpEmpty), iEvent(EDpsEvtEmpty), 
+    iCurError(KErrNone)
+    {
+    IF_DEBUG(Print(_L(">>>CDpsStateMachine::Ctor")));
+    
+    IF_DEBUG(Print(_L("<<<CDpsStateMachine::Ctor")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsStateMachine::ConstructL()
+    {
+    IF_DEBUG(Print(_L(">>>CDpsStateMachine::ConstructL")));	
+    iIdleState = new(ELeave) TDpsIdleState(this);
+    iSendingReqState = new(ELeave) TDpsSendingReqState(this);
+    iWaitingRepState = new(ELeave) TDpsWaitingRepState(this);
+    iSendingRepState = new(ELeave) TDpsSendingRepState(this);
+    iCurState = iIdleState;
+    iTrader = CDpsTransaction::NewL(this);
+    iScriptReceiver = CDpsScriptReceiver::NewL(this);
+    iScriptSender = CDpsScriptSender::NewL(this);	
+    IF_DEBUG(Print(_L("<<<CDpsOperator::ConstructL")));	
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsStateMachine::StartTransactionL(TMDpsOperation* aRequest)
+    {
+    IF_DEBUG(Print(_L(">>>CDpsStateMachine::StartTransaction")));
+    iMOperation = aRequest;
+    iOperation = (TDpsOperation)iMOperation->iOperation;    
+    iTrader->CreateRequestL(aRequest);
+    iCurState = iSendingReqState;
+    IF_DEBUG(Print(_L("<<<CDpsStateMachine::StartTransaction")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsStateMachine::Initialize()
+    {
+    IF_DEBUG(Print(_L(">>>CDpsStateMachine::Initialize")));
+    iOperation = EDpsOpEmpty;
+    iEvent = EDpsEvtEmpty;
+    iCurError = KErrNone;
+    if (CurState() != IdleState())
+        {
+        SetState(IdleState());
+        }
+    IF_DEBUG(Print(_L("<<<CDpsStateMachine::Initialize")));    
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpstransaction.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,455 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class creates and parses dps operations. 
+*
+*/
+
+
+#include <e32base.h>
+#include <e32debug.h>
+#include <pathinfo.h>
+#include <s32file.h>
+#include "dpstransaction.h"
+#include "dpsscriptsender.h"
+#include "dpsdefs.h"
+#include "dpsxmlparser.h"
+#include "dpsxmlgenerator.h"
+#include "dpsconst.h"
+#include "dpsfile.h"
+#include "dpsstatemachine.h"
+#include "dpsscriptreceiver.h"
+#include "pictbridge.h"
+#include <xml/parser.h>
+#include "dpsparam.h"
+#include "dpsoperation.h"
+#include "dpsxmlstring.h"
+
+#ifdef _DEBUG
+#	define IF_DEBUG(t) {RDebug::t;}
+#else
+#	define IF_DEBUG(t)
+#endif
+
+const TInt KPathLength = 3;
+const TInt KPercentagePosition = 3;
+const TInt KPercentage = 100;
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CDpsTransaction* CDpsTransaction::NewL(CDpsStateMachine* aOperator)
+    {
+    IF_DEBUG(Print(_L("CDpsTransaction::NewL")));
+    CDpsTransaction* self = new(ELeave) CDpsTransaction(aOperator);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;	
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+CDpsTransaction::CDpsTransaction(CDpsStateMachine* aOperator) :
+    iOperator(aOperator), iReply(EFalse)
+	{
+    IF_DEBUG(Print(_L("CDpsTransaction::Ctor")));
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsTransaction::ConstructL()
+    {
+    IF_DEBUG(Print(_L(">>>CDpsTransaction::ConstructL")));	
+    iFile = CDpsFile::NewL();
+    iXmlGen = CDpsXmlGenerator::NewL(iOperator->DpsEngine());
+    iXmlPar = CDpsXmlParser::NewL(iOperator->DpsEngine());
+    IF_DEBUG(Print(_L("<<<CDpsTransaction::ConstructL")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+CDpsTransaction::~CDpsTransaction()
+	{
+    IF_DEBUG(Print(_L(">>>~CDpsTransaction")));
+    delete iXmlPar;
+    iXmlPar = NULL;
+	
+    delete iXmlGen;
+    iXmlGen = NULL;
+	
+    delete iFile;
+    iFile = NULL;
+	
+    IF_DEBUG(Print(_L("<<<~CDpsTransaction")));
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CDpsTransaction::CreateRequestL(TMDpsOperation* aOperation)
+	{
+    IF_DEBUG(Print(_L(">>>CDpsTransaction::CreateRequest ")));
+    IF_DEBUG(Print(_L("  the request is %d"), aOperation->iOperation));
+    TDpsArgArray args;
+    TDpsEleArray elements; 
+    TDpsAttribute attrib = 0;
+    CleanupClosePushL(args);
+    CleanupClosePushL(elements);
+    RFileWriteStream writer;
+    writer.PushL();
+    TFileName defaultPath = iOperator->DpsEngine()->DpsFolder();
+    defaultPath.Append(KDpsDeviceRequestFileName);
+    User::LeaveIfError(writer.Replace(iFile->FileSession(), defaultPath, 
+                                      EFileWrite));
+    IF_DEBUG(Print(_L("*** file created  ")));                                  
+    User::LeaveIfError(aOperation->FillReqArgs(args, elements, attrib, this));
+    aOperation->CreateReqScriptL(args, elements, attrib, writer, this);    
+    writer.CommitL();
+    writer.Pop();
+    writer.Release();
+    User::LeaveIfError(iOperator->ScriptSender()->SendScript(EFalse));
+    CleanupStack::PopAndDestroy(&elements);
+    CleanupStack::PopAndDestroy(&args);
+    IF_DEBUG(Print(_L("<<<CDpsTransaction::CreateRequest "))); 
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CDpsTransaction::Filter(TDes8& aScript)
+    {    
+    TInt size = aScript.Size();
+    IF_DEBUG(Print(_L(">>>CDpsTransaction::Filter size %d"), size));
+    
+    for (TInt i = 0; i < size; )
+        {
+        // removes any unprintalbe char between two XML attributes, e.g. 
+        // between > and <            
+        if (aScript[i] >= KSOH && aScript[i] <= KSpace && aScript[i -1] == '>')    
+            {
+            aScript.Delete(i, 1);
+            size--;
+            }
+        else
+            {
+            i++;
+            }
+        }
+    IF_DEBUG(Print(_L("<<<CDpsTransaction::Filter size %d"), size));
+    }
+ 
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsTransaction::ParseScriptL(TBool aReply)
+    {
+    IF_DEBUG(Print(_L(">>>CDpsTransaction::ParseScript")));
+    iReply = aReply;
+    TInt size;
+    iFile->FileSizeL(iOperator->ScriptReceiver()->FileNameAndPath(), size);
+    HBufC8* script = HBufC8::NewLC(size);
+    TPtr8 ptr_script = script->Des();
+    iFile->GetContentL(iOperator->ScriptReceiver()->FileNameAndPath(), 
+                       ptr_script);
+    Filter(ptr_script);    
+	iXmlPar->Reset();
+    CParser* parser = CParser::NewLC(KDpsXmlMimeType, *iXmlPar);
+    Xml::ParseL(*parser, ptr_script);
+    TDpsArgArray args; iXmlPar->GetParameters(args);
+    
+#ifdef _DEBUG
+    //print what we get now
+    TBuf<KMaxArgLen> print;
+    for (TInt i = 0; i < args.Count(); i++)
+        {
+        print.Copy(args[i].iContent);
+        IF_DEBUG(Print(_L("element %d content %S"), 
+            args[i].iElement, &print));
+        }
+#endif
+   
+    if (aReply)
+        {
+        TMDpsOperation* op = iOperator->MOperation();
+        User::LeaveIfError(op->FillRepArgs(args, this));
+        iXmlPar->SetOperationResult(op->iResult);    
+        }  
+    else 
+        {
+        TDpsResult result; 
+   	    result.iMajorCode = EDpsResultOk; 
+        result.iMinorCode = EDpsResultNone;       			
+        if (iXmlPar->IsEvent())
+            {
+            TDpsEvent event = iXmlPar->Event();
+            iOperator->SetEvent(event);
+            if (event == EDpsEvtNotifyJobStatus)
+                {
+                User::LeaveIfError(iOperator->DpsEngine()->Event()->
+                    iJobEvent.FillRepArgs(args, this));
+                }
+            else
+                {
+                User::LeaveIfError(iOperator->DpsEngine()->Event()->
+                    iPrinterEvent.FillRepArgs(args, this));
+                }
+            CreateEventReplyL(event, result);    
+            }
+        else
+            {
+            // the request from the host is only this one:
+            // GetFileID and used by DPOF printing 
+            TDpsOperation ope = iXmlPar->Operation();
+            iOperator->SetOperation(ope);
+            if (iOperator->Operation() != EDpsOpGetFileID)
+                {
+                User::Leave(KErrNotSupported);
+                }    		    
+            CreateRequestReplyL(args, result);    
+            }	
+        }
+    CleanupStack::PopAndDestroy(parser);
+    CleanupStack::PopAndDestroy(script);
+    IF_DEBUG(Print(_L("<<<CDpsTransaction::ParseScript")));	
+    }
+        
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CDpsTransaction::HandleHostRequestError(TInt aErr)
+    {
+    IF_DEBUG(Print(_L(">>>CDpsTransaction::HandleHostRequestError %d"), aErr));
+    TDpsResult result; 
+    // here we need to map the aErr to Dps standard error
+    switch (aErr)
+        {
+        case KErrNotSupported: 
+            result.iMajorCode = EDpsResultNotRecognized; 
+            result.iMinorCode = EDpsResultNone;         
+        break;
+        
+        case KErrArgument:
+            result.iMajorCode = EDpsResultNotSupported; 
+            result.iMinorCode = EDpsResultillegalParam;         
+        break;
+        
+        default:
+            IF_DEBUG(Print(_L("unknown err")));
+            return;    
+        }
+    TRAP_IGNORE(CreateEventReplyL(iXmlPar->Event(), result));
+    
+    IF_DEBUG(Print(_L("<<<CDpsTransaction::HandleHostRequestError")));    
+    return;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+TInt CDpsTransaction::ConvertVersion(TLex8& aParser, TDpsVersion& aVersion)
+    {
+    aParser.Mark();
+    while (!aParser.Eos())
+        {
+        TChar c = aParser.Peek();
+        if (!c.IsDigit())
+            {
+            break;
+            }
+        aParser.Inc();    
+        }
+    TPtrC8 token = aParser.MarkedToken();
+    TLex8 converter(token);    
+    TInt error = converter.Val(aVersion.iMajor);
+                        
+    if (error != KErrNone)
+        {
+         IF_DEBUG(Print(_L("\t convert error 1")));
+         return error;
+        }
+    IF_DEBUG(Print(_L("verion major %d"), aVersion.iMajor));
+    aParser.Inc();
+    TPtrC8 tokenDe = aParser.Remainder();
+    converter.Assign(tokenDe);
+    error = converter.Val(aVersion.iMinor);
+    if (error != KErrNone)
+        {
+        IF_DEBUG(Print(_L("\t convert error 2")));
+        return error;
+        }
+    IF_DEBUG(Print(_L("verion minor %d"), aVersion.iMinor));        
+    return KErrNone;
+    }
+ 
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+TInt CDpsTransaction::ParsePercentage(const TDes8& aPer)  
+    {
+    TLex8 parser(aPer);
+    parser.Mark();
+    parser.Inc(KPercentagePosition);
+    TPtrC8 digital = parser.MarkedToken();
+    TLex8 converter(digital);
+    TInt num1; 
+    TInt error = converter.Val(num1);
+    if (error != KErrNone)
+        {
+        return error;
+        }
+    
+    parser.Inc(1);
+    parser.Mark();
+    parser.Inc(KPercentagePosition);
+    digital.Set(parser.MarkedToken());
+    converter.Assign(digital);
+    TInt num2; 
+    error = converter.Val(num2);    
+    if (error != KErrNone)
+        {
+        return error;
+        }
+    
+    TReal per = (TReal)num1 / (TReal)num2 * KPercentage;
+    return (TInt)per;
+    }
+ 
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+void CDpsTransaction::CreateEventReplyL(TDpsEvent aEvent, 
+                                        const TDpsResult& aResult)
+                                   
+	{
+	IF_DEBUG(Print(_L(">>>CDpsTransaction::CreateReply")));
+	IF_DEBUG(Print(_L
+	    ("  the operation reply is %d"), iOperator->Operation()));
+	IF_DEBUG(Print(_L("\t the event reply is %d"), iOperator->Event()));
+    RFileWriteStream writer;
+    writer.PushL();
+    TFileName defaultPath = iOperator->DpsEngine()->DpsFolder();
+    defaultPath.Append(KDpsDeviceResponseFileName);
+    User::LeaveIfError(writer.Replace(iFile->FileSession(), defaultPath, 
+                                      EFileWrite));
+    IF_DEBUG(Print(_L("*** file created  ")));     
+    iXmlGen->CreateResultScriptL(aEvent, writer, aResult);
+    writer.CommitL();
+    writer.Pop();
+    writer.Release();
+	User::LeaveIfError(iOperator->ScriptSender()->SendScript(ETrue));
+    IF_DEBUG(Print(_L("<<<CDpsTransaction::CreateReply")));
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+void CDpsTransaction::CreateRequestReplyL(const TDpsArgArray& aArgs, 
+                                          const TDpsResult& aResult)
+    {
+    IF_DEBUG(Print(_L(">>>CDpsTransaction::CreateRequestReply")));
+    TInt count = aArgs.Count();
+    TInt basePathId;
+    TBuf8<KMaxArgLen> filePath;
+    TLex8 converter;
+    
+    for (TInt i = 0; i < count; i++)
+        {
+        switch (aArgs[i].iElement)
+            {
+            case EDpsArgBasePathID:
+                converter.Assign(aArgs[i].iContent);
+                User::LeaveIfError(converter.Val(basePathId));
+            break;
+            
+            case EDpsArgFilePath:
+                filePath.Copy(aArgs[i].iContent);
+            break;
+            
+            default:
+                __IF_DEBUG(Print(_L("***wrong args")));
+                User::Leave(KErrArgument);
+            break;
+            }
+        TUint32 fileId;
+        
+        SubstitutePath(filePath);
+        TBuf<KMaxArgLen> file;  
+        file.Copy(filePath);
+        User::LeaveIfError(iOperator->DpsEngine()->
+            Ptp().GetObjectHandleByName(file, fileId));
+        TDpsArg arg;
+        arg.iElement = EDpsArgFileID;
+        arg.iContent.AppendNumFixedWidth(fileId, EHex, KFullWordWidth);
+        RFileWriteStream writer;
+        writer.PushL();
+        TFileName defaultPath = iOperator->DpsEngine()->DpsFolder();
+        defaultPath.Append(KDpsDeviceResponseFileName);
+        User::LeaveIfError(writer.Replace(iFile->FileSession(), defaultPath, 
+                                          EFileWrite));
+        IF_DEBUG(Print(_L("*** file created  ")));        
+        iXmlGen->CreateReplyScriptL(EDpsOpGetFileID, writer, aResult, arg);   
+	    User::LeaveIfError(iOperator->ScriptSender()->SendScript(ETrue));
+	    writer.CommitL();
+        writer.Pop();
+        writer.Release();    
+        } 
+    IF_DEBUG(Print(_L("<<<CDpsTransaction::CreateRequestReply")));
+    }
+    
+// ---------------------------------------------------------------------------
+// The aPath is not the full file path, at least the
+// driver letter is not included. The structure of the DPOF filePath is
+// ../path/childpath/imagePrinted.jpg and GetObjectHandleByName
+// requires the full path file as e:\images\image1.jpg
+// the basePathId is not useful because it is always the fileId
+// of AUTPRINT.MRK. But since DPOF is always used for the removable
+// media, we assume that images are only stored in removable media.
+// If the assumption is true (must be true), we need here first to
+// get the removable drive (hopefully only one). Then substitute
+// the / by the \ in the filePath. Finally, insert the removable drive
+// letter and : at the beginning of the filePath. The new full path
+// file can be used by GetObjectHandleByName
+// ---------------------------------------------------------------------------
+//        
+void CDpsTransaction::SubstitutePath(TDes8& aPath)
+    {
+    IF_DEBUG(Print(_L(">>>CDpsTransaction::SubstitutePath %S"), &aPath));
+    TInt size = aPath.Size();
+    for (TInt i = 0; i < size; i++)
+        {
+        if (aPath[i] == KSlash)
+            {
+            aPath[i] = KBackSlash;
+            }
+        }
+    TBuf<KPathLength> driveEWide = PathInfo::MemoryCardRootPath();
+    TBuf8<KPathLength> driveENarrow;
+    driveENarrow.Copy(driveEWide);    
+    aPath.Replace(0, KPathLength - 1, driveENarrow);
+    IF_DEBUG(Print(_L("<<<CDpsTransaction::SubstitutePath %S"), &aPath));
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsusbnotifier.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,329 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class implements functions of set mtp personality, the 
+*                notification of the MTP printer connection and the
+*				 notification of the MTP printer disconnection. 
+*
+*/
+
+
+#include <e32debug.h>
+#include <usbstates.h>
+#include <rptp.h>
+#include "dpsusbnotifier.h"
+#include "dpsconst.h"
+#include "dpsptpnotifier.h"
+#include "dpsconnectnotifier.h"
+
+#ifdef _DEBUG
+#	define IF_DEBUG(t) {RDebug::t;}
+#else
+#	define IF_DEBUG(t)
+#endif
+
+const TInt KUnknownPersonality = 0;
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CDpsUsbNotifier* CDpsUsbNotifier::NewL(CDpsEngine* aEngine)
+	{
+	IF_DEBUG(Print(_L("CDpsUsbNotifier::NewL")));
+	CDpsUsbNotifier* self = new(ELeave) CDpsUsbNotifier(aEngine);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();
+	return self;	
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CDpsUsbNotifier::CDpsUsbNotifier(CDpsEngine* aEngine) :
+    CActive(EPriorityNormal), iEngine(aEngine), 
+    iPersonality(KUnknownPersonality), 
+    iConnectState(EUsbDeviceStateUndefined), iConfigured(EFalse), 
+    iConnection(CDpsEngine::ENotConnected), iRollback(EFalse)
+    {
+    IF_DEBUG(Print(_L(">>>CDpsUsbNotifier::Ctor")));
+    CActiveScheduler::Add(this);        
+    IF_DEBUG(Print(_L("<<<CDpsUsbNotifier::Ctor")));
+    }  
+  
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+CDpsUsbNotifier::~CDpsUsbNotifier()
+	{
+	IF_DEBUG(Print(_L(">>>~CDpsUsbNotifier")));
+	Cancel();
+	Rollback();
+    delete iPtpP; iPtpP = NULL;
+    delete iConnectP; iConnectP = NULL;	
+    iUsbM.Close();
+    iUsbW.Close();
+    IF_DEBUG(Print(_L("<<<~CDpsUsbNotifier")));
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CDpsUsbNotifier::ConstructL()
+    {
+    IF_DEBUG(Print(_L(">>>CDpsUsbNotifier::ConstructL")));
+    User::LeaveIfError(iUsbM.Connect());
+    User::LeaveIfError(iUsbW.Connect());
+    iPtpP = CDpsPtpNotifier::NewL(this);
+    iConnectP = CDpsConnectNotifier::NewL(this);
+    IF_DEBUG(Print(_L("<<<CDpsUsbNotifier::ConstructL")));
+    }    
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsUsbNotifier::WaitForPrinterNotify()
+    {
+    IF_DEBUG(Print(_L("CDpsUsbNotifier::WaitForPrinterNotify")));
+    iPtpP->ChangePtpPersonality();
+    }
+  
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//  
+void CDpsUsbNotifier::CancelPrinterNotify()
+    {
+    IF_DEBUG(Print(_L(">>>CDpsUsbNotifier::CancelPrinterNotify")));
+    if (CDpsEngine::ENotConnected == iConnection)
+        {
+        iPtpP->Cancel(); 
+        iConfigured = EFalse;    
+        }
+    else if (CDpsEngine::EPrinterConnected == iConnection)
+        {
+        iConnectP->Cancel();
+        }
+    // if the request is replied through RunL before the cancel
+    // iPrinterConnectRequest will be NULL and we don't need to cancel anything
+    if (iEngine->PrinterConnectRequest())
+        {
+	    User::RequestComplete(iEngine->PrinterConnectRequest(), KErrCancel);   
+        }    
+    IF_DEBUG(Print(_L("<<<CDpsUsbNotifier::CancelWaitForPrinterNotify")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsUsbNotifier::ConnectNotify()
+    {
+    IF_DEBUG(Print(_L(">>>CDpsUsbNotifier::ConnectNotify")));
+    iConnectP->ConnectNotify();
+    IF_DEBUG(Print(_L("<<<CDpsUsbNotifier::ConnectNotify")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CDpsUsbNotifier::Rollback()
+    {
+    IF_DEBUG(Print(_L(">>>CDpsUsbNotifier::Rollback")));
+    // only when the personality has changed, we switch back to the previous
+    // personality
+    if (iPersonality)
+        {
+        TInt personalityId = KUsbPersonalityIdMTP;
+        iUsbM.GetCurrentPersonalityId(personalityId);
+        IF_DEBUG(Print(_L("CDpsUsbNotifier::Rollback, current personality= %d"), personalityId));
+        if(KUsbPersonalityIdPCSuiteMTP != personalityId)
+            {
+            if (!iConfigured || iRollback)
+                {
+                iUsbW.SetPreviousPersonality();
+                }
+            else
+                {
+                iUsbW.SetPreviousPersonalityOnDisconnect();
+                }
+            }
+        }
+    IF_DEBUG(Print(_L("<<<CDpsUsbNotifier::Rollback")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsUsbNotifier::PtpNotify(TInt aErr)
+    {
+    IF_DEBUG(Print(_L(">>>CDpsUsbNotifier::PtpNotify %x %d"), 
+        iConnectState, aErr));
+    if (aErr == KErrNone)
+        {
+        // personality changed to MTP, but cable is not connected        
+        if (iConnectState != EUsbDeviceStateUndefined)
+            {
+            if (!IsActive())
+                {
+                iEngine->Ptp().IsDpsPrinter(iStatus);
+                SetActive();    
+                }
+            }
+        else
+            {
+            iConnection = CDpsEngine::ENotConnected;
+            User::RequestComplete(iEngine->PrinterConnectRequest(), iConnection);
+            }    
+        }
+    else
+        {
+        iConnection = CDpsEngine::EWrongPrintModeConnected;
+        User::RequestComplete(iEngine->PrinterConnectRequest(), iConnection); 
+        }
+        	
+    IF_DEBUG(Print(_L("<<<CDpsUsbNotifier::PtpNotify")));        
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+void CDpsUsbNotifier::PersonalityChanged()
+    {
+    IF_DEBUG(Print(_L(">>>CDpsUsbNotifier::PersonalityChanged %x"), 
+                                                              iPersonality));     
+    if (iPersonality != KUsbPersonalityIdMTP)
+        {
+        iConnection = CDpsEngine::EWrongPrintModeConnected;
+        iConfigured = EFalse;
+        if (iEngine->PrinterConnectRequest())
+            {
+            User::RequestComplete(iEngine->PrinterConnectRequest(), 
+                iConnection);     
+            }
+        }
+    // when UI gets this notification, it must quit. As the result, the dps 
+    // engine will be deleted so we do not need to care the further change.
+    
+    IF_DEBUG(Print(_L(">>>CDpsUsbNotifier::PersonalityChanged ")));     
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+void CDpsUsbNotifier::RunL()
+    {
+    IF_DEBUG(Print(_L(">>>CDpsUsbNotifier::RunL")));
+    
+    if (EPrinterAvailable == iStatus.Int())
+        {
+        iConnection = CDpsEngine::EPrinterConnected;
+        iConfigured = ETrue;	
+        iEngine->SetDpsFolder(iEngine->Ptp().PtpFolder());			            
+        }
+    else if (iStatus.Int() != KErrCancel)
+        {
+        iConnection = CDpsEngine::EOtherConnected;
+        }
+    User::RequestComplete(iEngine->PrinterConnectRequest(), iConnection);    
+        
+    IF_DEBUG(Print(_L("<<<CDpsUsbNotifier::RunL")));
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//       
+void CDpsUsbNotifier::DoCancel()
+    {
+    IF_DEBUG(Print(_L(">>>CDpsUsbNotifier::DoCancel")));
+    iEngine->Ptp().CancelIsDpsPrinter();
+    IF_DEBUG(Print(_L(">>>CDpsUsbNotifier::DoCancel")));
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//       
+TInt CDpsUsbNotifier::RunError(TInt aErr)
+    {
+    IF_DEBUG(Print(_L("CDpsUsbNotifier::RunError is %d"), aErr));
+    return aErr;
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+void CDpsUsbNotifier::DisconnectNotify(TUsbDeviceState aState)
+    {
+    IF_DEBUG(Print(_L(">>>CDpsUsbNotifier::DisconnectNotify %d"), aState));
+    if (iConfigured)
+        {
+        iConnection = CDpsEngine::EPrinterDisconnected;
+        }
+    else
+        {
+        iConnection = CDpsEngine::ENotConnected;
+        }
+    iConfigured = EFalse;
+    if (EUsbDeviceStateUndefined == aState)
+        {
+        iRollback = ETrue;
+        }
+    if (iEngine->PrinterConnectRequest())
+        {
+        User::RequestComplete(iEngine->PrinterConnectRequest(), iConnection);    
+        }
+    
+    IF_DEBUG(Print(_L("<<<CDpsUsbNotifier::DisconnectNotify")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TInt CDpsUsbNotifier::ConnectState()
+    {
+    IF_DEBUG(Print(_L(">>>CDpsUsbNotifier::ConnectState")));    
+    TInt ret = iUsbM.GetDeviceState(iConnectState);
+	IF_DEBUG(Print(_L("<<<CDpsUsbNotifier::ConnectState %x"), iConnectState));    
+	return ret;    
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TBool CDpsUsbNotifier::IsSetPrintModeIssued()
+    {
+    return (iPersonality != KUnknownPersonality);
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TBool CDpsUsbNotifier::IsConfigured() const
+    {
+    return iConfigured;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsxmlgenerator.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,333 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class creates the dps xml script. 
+*
+*/
+
+
+#include <e32debug.h>
+#include "dpsxmlgenerator.h"
+#include "pictbridge.h"
+#include "dpsconst.h"
+#include "dpsxmlstring.h"
+#include <e32debug.h>
+
+#ifdef _DEBUG
+#	define IF_DEBUG(t) {RDebug::t;}
+#else
+#	define IF_DEBUG(t)
+#endif
+
+const TInt KCodeSize = 4;
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CDpsXmlGenerator* CDpsXmlGenerator::NewL(CDpsEngine* aEngine)
+    {
+    IF_DEBUG(Print(_L("CDpsXmlGenerator::NewL")));
+    CDpsXmlGenerator* self= new (ELeave) CDpsXmlGenerator(aEngine);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CDpsXmlGenerator::~CDpsXmlGenerator()
+    {
+    IF_DEBUG(Print(_L("~CDpsXmlGenerator")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CDpsXmlGenerator::CDpsXmlGenerator(CDpsEngine* aEngine) : 
+    iEngine(aEngine)
+    {        
+    IF_DEBUG(Print(_L("CDpsXmlGenerator::Ctor")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CDpsXmlGenerator::CreateResultScriptL(TDpsEvent aEvent,
+		                     			  RWriteStream& aScript,
+	           		         			  const TDpsResult& aResult) const
+    {
+    IF_DEBUG(Print(_L(">>>CDpsXmlGenerator::CreateResultScript")));    
+    StartDocumentL(aScript);       
+    StartResultL(aScript, aResult);       
+    if (aEvent != EDpsEvtEmpty)
+        {
+        CreateEventL(aScript, aEvent);          
+        }    
+    EndResultL(aScript);    
+    EndDocumentL(aScript);    
+    IF_DEBUG(Print(_L("<<<CDpsXmlGenerator::CreateResultScript")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CDpsXmlGenerator::CreateReplyScriptL(TDpsOperation aOperation, 
+                                         RWriteStream& aScript,
+                                         const TDpsResult& aResult,
+                                         const TDpsArg& aArg) const
+    {
+    StartDocumentL(aScript);
+    StartResultL(aScript, aResult);
+    StartOperationL(aOperation, aScript);
+    CreateArgL(aScript, aArg);
+    EndOperationL(aOperation, aScript);
+    EndResultL(aScript);
+    EndDocumentL(aScript);
+    }                                            
+                                            
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//		           		         		
+void CDpsXmlGenerator::StartDocumentL(RWriteStream& aScript) const
+	{
+    IF_DEBUG(Print(_L(">>>CDpsXmlGenerator::StatrDocument")));
+    aScript.WriteL(KDpsXmlHeader);
+    aScript.WriteL(KDpsXmlNS);
+    aScript.WriteL(KDpsXmlSpace);
+    IF_DEBUG(Print(_L("<<<CDpsXmlGenerator::StartDocument")));	
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsXmlGenerator::EndDocumentL(RWriteStream& aScript) const
+    {
+    IF_DEBUG(Print(_L(">>>CDpsXmlGenerator::EndDocument")));
+    aScript.WriteL(KDpsXmlBraceOpen);
+    aScript.WriteL(KDpsXmlSlash);
+    aScript.WriteL(KDpsXml);
+    aScript.WriteL(KDpsXmlBraceClose);
+    IF_DEBUG(Print(_L("<<<CDpsXmlGenerator::EndDocument")));		
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsXmlGenerator::StartInputL(RWriteStream& aScript) const
+    {
+    IF_DEBUG(Print(_L(">>>CDpsXmlGenerator::StartInput")));
+    aScript.WriteL(KDpsXmlBraceOpen);
+    aScript.WriteL(KDpsXmlInput);
+    aScript.WriteL(KDpsXmlBraceClose);
+    aScript.WriteL(KDpsXmlSpace);
+    IF_DEBUG(Print(_L("<<<CDpsXmlGenerator::StartInput")));	
+    }
+  
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//  
+void CDpsXmlGenerator::EndInputL(RWriteStream& aScript) const
+    {
+    IF_DEBUG(Print(_L(">>>CDpsXmlGenerator::EndInput")));
+    aScript.WriteL(KDpsXmlBraceOpen);
+    aScript.WriteL(KDpsXmlSlash);
+    aScript.WriteL(KDpsXmlInput);
+    aScript.WriteL(KDpsXmlBraceClose);
+    aScript.WriteL(KDpsXmlSpace);
+    IF_DEBUG(Print(_L("<<<CDpsXmlGenerator::EndInput")));		
+    }
+  
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//  
+void CDpsXmlGenerator::StartResultL(RWriteStream& aScript, 
+								   const TDpsResult& aResult) const
+    {
+    IF_DEBUG(Print(_L(">>>CDpsXmlGenerator::StartResult")));
+    aScript.WriteL(KDpsXmlBraceOpen);
+    aScript.WriteL(KDpsXmlOutput);
+    aScript.WriteL(KDpsXmlBraceClose);
+    aScript.WriteL(KDpsXmlSpace);
+    aScript.WriteL(KDpsXmlBraceOpen);
+    aScript.WriteL(KDpsXmlResult);
+    aScript.WriteL(KDpsXmlBraceClose);
+    TBuf8<KCodeSize> major;
+    major.NumUC(aResult.iMajorCode, EHex);
+    aScript.WriteL(major);
+    major.Zero();
+    major.NumFixedWidthUC(aResult.iMinorCode, EHex, KCodeSize);
+    aScript.WriteL(major);    
+    aScript.WriteL(KDpsXmlBraceOpen);
+    aScript.WriteL(KDpsXmlSlash);
+    aScript.WriteL(KDpsXmlResult);
+    aScript.WriteL(KDpsXmlBraceClose);
+    aScript.WriteL(KDpsXmlSpace);
+    IF_DEBUG(Print(_L("<<<CDpsXmlGenerator::StartResult")));		
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsXmlGenerator::EndResultL(RWriteStream& aScript) const
+	{
+    IF_DEBUG(Print(_L(">>>CDpsXmlGenerator::EndResult")));
+    aScript.WriteL(KDpsXmlBraceOpen);
+    aScript.WriteL(KDpsXmlSlash);
+    aScript.WriteL(KDpsXmlOutput);
+    aScript.WriteL(KDpsXmlBraceClose);
+    aScript.WriteL(KDpsXmlSpace);
+    IF_DEBUG(Print(_L("<<<CDpsXmlGenerator::EndResult")));		
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CDpsXmlGenerator::StartOperationL(TDpsOperation aOperation, 
+                                       RWriteStream& aScript, 
+									   TBool aEnd) const
+    {
+    IF_DEBUG(Print(_L(">>>CDpsXmlGenerator::StartOperation %d"), aOperation));
+    aScript.WriteL(KDpsXmlBraceOpen);
+    aScript.WriteL(iEngine->DpsParameters()->
+        iDpsOperationStrings[aOperation - 1]);
+    if (aEnd)
+        {
+        aScript.WriteL(KDpsXmlSlash);
+        }
+    aScript.WriteL(KDpsXmlBraceClose);	
+    aScript.WriteL(KDpsXmlSpace);
+    IF_DEBUG(Print(_L("<<<CDpsXmlGenerator::StartOperation")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//			
+void CDpsXmlGenerator::EndOperationL(TDpsOperation aOperation, 
+                                     RWriteStream& aScript) const 
+    {
+    IF_DEBUG(Print(_L(">>>CDpsXmlGenerator::EndOperation")));
+    aScript.WriteL(KDpsXmlBraceOpen);
+    aScript.WriteL(KDpsXmlSlash);
+    // there is an empty op in the op enum so we must reduce one
+    aScript.WriteL(iEngine->DpsParameters()->
+        iDpsOperationStrings[aOperation - 1]);
+    aScript.WriteL(KDpsXmlBraceClose);	
+    aScript.WriteL(KDpsXmlSpace);
+    IF_DEBUG(Print(_L("<<<CDpsXmlGenerator::EndOperation")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CDpsXmlGenerator::CreateEventL(RWriteStream& aScript, TDpsEvent aEvent) const
+    {
+    IF_DEBUG(Print(_L(">>>CDpsXmlGenerator::CreatEvent")));
+    aScript.WriteL(KDpsXmlBraceOpen);
+    aScript.WriteL(iEngine->DpsParameters()->
+        iDpsEventStrings[aEvent - 1]);
+    aScript.WriteL(KDpsXmlSlash);
+    aScript.WriteL(KDpsXmlBraceClose);
+    aScript.WriteL(KDpsXmlSpace);
+    IF_DEBUG(Print(_L("<<<CDpsXmlGenerator::CreatEvent")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsXmlGenerator::CreateArgL(RWriteStream& aScript, 
+								  const TDpsArg& aArgument, 
+					   			  TDpsAttribute aAttribute) const           
+    {
+    IF_DEBUG(Print(_L(">>>CDpsXmlGenerator::CreatArg")));
+    aScript.WriteL(KDpsXmlBraceOpen); //<
+    aScript.WriteL(iEngine->DpsParameters()->
+        iDpsArgStrings[aArgument.iElement]);	
+    if (aAttribute != 0)
+        {
+        aScript.WriteL(KDpsXmlSpace); // space
+        aScript.WriteL(KDpsXmlPaperSize); // paperSize
+        aScript.WriteL(KDpsXmlEqual); // =
+        aScript.WriteL(KDpsXmlQuote); // "
+        // patch the lower four bytes zero
+        aAttribute = aAttribute << KShiftLength;
+        TBuf8<KFullWordWidth> string;
+        string.AppendNumUC(aAttribute, EHex);
+        aScript.WriteL(string); // 12345678
+        aScript.WriteL(KDpsXmlQuote); // "
+        }
+    if (!aArgument.iContent.Compare(KNullDesC8))
+        {
+        aScript.WriteL(KDpsXmlSlash); // /
+        aScript.WriteL(KDpsXmlBraceClose); // >
+        }
+    else
+        {
+        aScript.WriteL(KDpsXmlBraceClose); // >
+        aScript.WriteL(aArgument.iContent); // 123 345 567
+        aScript.WriteL(KDpsXmlBraceOpen); // <
+        aScript.WriteL(KDpsXmlSlash); // /
+        aScript.WriteL(iEngine->DpsParameters()->
+            iDpsArgStrings[aArgument.iElement]);
+        aScript.WriteL(KDpsXmlBraceClose); // >
+        }
+    aScript.WriteL(KDpsXmlSpace);	
+    IF_DEBUG(Print(_L("<<<CDpsXmlGenerator::CreatArg")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CDpsXmlGenerator::StartElementL(TDpsElement aElement, 
+                                     RWriteStream& aScript) const
+    {
+    IF_DEBUG(Print(_L(">>>CDpsXmlGenerator::StartElement")));
+    aScript.WriteL(KDpsXmlBraceOpen); //<
+    aScript.WriteL(iEngine->DpsParameters()->
+        iDpsElementStrings[aElement - 1]);	
+    aScript.WriteL(KDpsXmlBraceClose); // >
+    aScript.WriteL(KDpsXmlSpace);
+    IF_DEBUG(Print(_L("<<<CDpsXmlGenerator::StartElement")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CDpsXmlGenerator::EndElementL(TDpsElement aElement, 
+                                   RWriteStream& aScript) const
+    {
+    IF_DEBUG(Print(_L(">>>CDpsXmlGenerator::EndElement")));
+    aScript.WriteL(KDpsXmlBraceOpen); //<
+    aScript.WriteL(KDpsXmlSlash);
+    aScript.WriteL(iEngine->DpsParameters()->
+        iDpsElementStrings[aElement - 1]);	
+    aScript.WriteL(KDpsXmlBraceClose); // >
+    aScript.WriteL(KDpsXmlSpace);
+    IF_DEBUG(Print(_L("<<<CDpsXmlGenerator::EndElement")));
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsxmlparser.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,445 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class parses the dps xml script. 
+*
+*/
+
+
+#include <e32debug.h>
+#include "dpsxmlparser.h"
+#include "dpsconst.h"
+#include "pictbridge.h"
+#include "dpsxmlstring.h"
+
+#ifdef _DEBUG
+#	define IF_DEBUG(t) {RDebug::t;}
+#   define PRINT_DES(t)\
+ {TBuf<KMaxArgLen> _buf; _buf.Copy(t);RDebug::Print(_L("---%S"), &_buf);}
+#else
+#	define IF_DEBUG(t)
+#   define PRINT_DES(t)
+#endif
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+CDpsXmlParser* CDpsXmlParser::NewL(CDpsEngine* aEngine)
+	{
+    IF_DEBUG(Print(_L("CDpsXmlParser::NewL")));
+    CDpsXmlParser* self = new (ELeave) CDpsXmlParser(aEngine);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+CDpsXmlParser::~CDpsXmlParser()
+    {
+    IF_DEBUG(Print(_L(">>>~CDpsXmlParser")));
+    iDpsArgs.Close();
+    __IF_DEBUG(Print(_L("<<<~CDpsXmlParser")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+CDpsXmlParser::CDpsXmlParser(CDpsEngine* aEngine) : iEngine(aEngine)
+    {
+    IF_DEBUG(Print(_L(">>>CDpsXmlParser::Ctor")));
+	Reset();
+    IF_DEBUG(Print(_L("<<<CDpsXmlParser::Ctor")));
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsXmlParser::OnStartDocumentL(
+		const RDocumentParameters& /*aDocParam*/, TInt aErrorCode)
+    {
+    IF_DEBUG(Print(_L(">>>CDpsXmlParser::OnStartDocumentL")));
+    if (aErrorCode != KErrNone)
+        {
+        IF_DEBUG(Print(_L("---, error code is %d"), aErrorCode));
+        User::Leave(aErrorCode);
+        }
+    IF_DEBUG(Print(_L("<<<CDpsXmlParser::OnStartDocumentL")));
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsXmlParser::OnEndDocumentL(TInt aErrorCode)
+	{
+    IF_DEBUG(Print(_L(">>>CDpsXmlParser::OnEndDocumentL")));
+    if (aErrorCode != KErrNone)
+        {
+        IF_DEBUG(Print(_L("---, error code is %d"), aErrorCode));
+        User::Leave(aErrorCode);
+        }
+    
+    IF_DEBUG(Print(_L("<<<CDpsXmlParser::OnEndDocumentL")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CDpsXmlParser::OnStartElementL(const RTagInfo& aElement, 
+									const RAttributeArray& aAttributes, 
+									TInt aErrCode)
+    {
+    IF_DEBUG(Print(_L(">>>CDpsXmlParser::OnStartElementL")));
+    
+    if (aErrCode != KErrNone)
+        {
+        IF_DEBUG(Print(_L("---, error code is %d"), aErrCode));
+        User::Leave(aErrCode);
+        }
+    if (aAttributes.Count() > 1)
+        {
+        IF_DEBUG(Print(_L("---cannot have more than one attribute!")));
+        User::Leave(KErrArgument);
+        }
+    	
+    // Gets the name of the tag
+    const TDesC8& name = aElement.LocalName().DesC();
+    
+    IF_DEBUG(Print(_L("---Start"))); PRINT_DES(name);
+	
+    //Checks the element
+    // this is the first layer <dps>
+    if (!name.Compare(KDpsXml))
+        {
+        iAction = EDpsXmlStart;
+        }
+    // this is the second layer	<input|output>
+    else if (!name.Compare(KDpsXmlOutput))
+        {
+        iAction = EDpsXmlOutput;
+        }
+    else if (!name.Compare(KDpsXmlInput))
+        {
+        // operation and event cannot be distiguised here
+        iAction = EDpsXmlInput;
+        }
+    // this is the third layer <operation|event|result>	
+    else if (iAction == EDpsXmlOutput && !name.Compare(KDpsXmlResult))
+        {
+        // output must be result
+        iAction = EDpsXmlResult;
+        }		
+    else if (iAction == EDpsXmlInput &&
+        (!name.Compare(iEngine->DpsParameters()->iDpsEventStrings[0]) ||
+        !name.Compare(iEngine->DpsParameters()->iDpsEventStrings[1])))
+        {
+        if (!name.Compare(iEngine->DpsParameters()->iDpsEventStrings[0]))
+            {
+            iDpsEvent = EDpsEvtNotifyJobStatus;
+            }
+        else
+            {
+            iDpsEvent = EDpsEvtNotifyDeviceStatus;	
+            }
+        iAction = EDpsXmlEvent;	
+        }
+    else if (iAction == EDpsXmlInput || iAction == EDpsXmlResult)
+        {
+        iAction = EDpsXmlOperation;
+        for (TInt i= 0; i < EDpsOpMax-1; i++) //i=0 as AppendL() method adds item on first free position in array
+            {
+            if (!name.Compare(iEngine->DpsParameters()->iDpsOperationStrings[i]))
+                {
+                IF_DEBUG(Print(_L("---found the operation")));
+                PRINT_DES(name);
+                iDpsOperation = (TDpsOperation)(i+1);// i+1 to by pass first operation EDpsOpEmpty in enum which is not added to array
+                break;
+                }
+            }
+        }
+		
+    // below is the fourth layer, e.g. the argument list/element. there
+    // could be many arugments, but only one element	
+    else if (iAction == EDpsXmlOperation || iAction == EDpsXmlEvent)
+        {
+        // only element in output is capability
+        if (!name.Compare(iEngine->DpsParameters()->iDpsElementStrings[0]))
+            {
+            IF_DEBUG(Print(_L("---the element is")));
+            PRINT_DES(name);
+            iElement = EDpsCapability;
+            }
+        else
+            {
+            for (TInt i = 0; i < EDpsArgMax; i++)
+                {
+                if (!name.Compare(iEngine->DpsParameters()->iDpsArgStrings[i]))
+                    {
+                    IF_DEBUG(Print(_L("---the argument is ")));
+                    PRINT_DES(name);	
+                    TDpsArg arg;
+                    arg.iElement = (TDpsArgument)i;
+                    arg.iContent.Copy(_L(""));
+                    iDpsArgs.Append(arg);
+                    break;
+                    }
+                }
+            }
+		
+        }
+    else
+        {
+        // something wrong
+        IF_DEBUG(Print(_L("--- non-PB element! %S"), &name));
+        User::Leave(KErrNotSupported);
+        }
+    if (aAttributes.Count() == 1)
+        {
+        ParseAttributesL(aAttributes, name);
+        }
+    IF_DEBUG(Print(_L("<<<CDpsXmlParser::OnStartElementL")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	     
+void CDpsXmlParser::ParseAttributesL(const RAttributeArray& aAttributes, 
+                                     const TDesC8& tag)
+    {
+    // element
+    const TDesC8& name = aAttributes[0].Attribute().LocalName().DesC();
+    // only "layouts" and "paperTypes" have attributes
+    if (tag.Compare(KDpsXmlPaperTypes) && tag.Compare(KDpsXmlLayouts))
+        {
+        // error
+        IF_DEBUG(Print(_L("--- this tag have no attribute")));
+        PRINT_DES(name);
+        User::Leave(KErrArgument);
+        }
+    // the element of the attributes must be "paperSize"	
+    if (name.Compare(KDpsXmlPaperSize))
+        {
+        // error
+        IF_DEBUG(Print(_L("--- wrong attribute")))
+        PRINT_DES(name);
+        User::Leave(KErrArgument);
+        }
+    // value
+    HBufC8* value = aAttributes[0].Value().DesC().AllocLC();
+    TUint32 result;    
+    TLex8 converter(*value);
+    TInt error = converter.Val(result, EHex);
+    if (error != KErrNone)
+        {
+        IF_DEBUG(Print(_L("--- convert error %d"), error));
+        User::Leave(error);
+        }
+    iAttrib = result >> KShiftLength; 
+    CleanupStack::PopAndDestroy(value);
+    IF_DEBUG(Print(_L("--- attribte value %x"), result));
+     
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CDpsXmlParser::OnEndElementL(const RTagInfo& aElement, 
+								  TInt aErrorCode)
+    {
+    IF_DEBUG(Print(_L(">>>CDpsXmlParser::OnEndElementL")));
+    
+    if (aErrorCode != KErrNone)
+        {
+        IF_DEBUG(Print(_L("--- error code is %d"), aErrorCode));
+        User::Leave(aErrorCode);
+        }
+        
+    // Get the name of the tag
+    const TDesC8& name = aElement.LocalName().DesC();
+    PRINT_DES(name);
+    IF_DEBUG(Print(_L("<<<CDpsXmlParser::OnEndElementL")));	
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsXmlParser::OnContentL(const TDesC8& aBytes, TInt aErrorCode)
+	{
+    IF_DEBUG(Print(_L(">>>CDpsXmlParser::OnContentL content is")));
+    PRINT_DES(aBytes);
+    
+    if (aErrorCode != KErrNone)
+   	    {
+        IF_DEBUG(Print(_L("--- error code %d"), aErrorCode));
+        User::Leave(aErrorCode);
+        }	
+    if (aBytes[0] >= KSOH && aBytes[0] <= KSpace)
+        {
+        IF_DEBUG(Print(_L("the unprintable char %d"), aBytes[0]));
+        return; 
+        }
+    // parses the result	
+    if (iAction == EDpsXmlResult)
+        {
+        TUint32 value;
+        TLex8 converter(aBytes);
+        TInt error = converter.Val(value, EHex);
+        if (error != KErrNone)
+            {
+            IF_DEBUG(Print(_L("--- convert error %d"), error));
+            User::Leave(error);
+            }
+        IF_DEBUG(Print(_L("--- result %x"), value));
+        // we have got the result
+        iDpsResult.iMajorCode = 
+            static_cast<TDpsResultMajorCode>(value >> KShiftLength);
+        iDpsResult.iMinorCode = 
+            static_cast<TDpsResultMinorCode>(value & KDpsMinorMask);
+        }
+    // gets the argument	
+    else if (iAction == EDpsXmlOperation || iAction == EDpsXmlEvent)
+        {
+        iDpsArgs[iDpsArgs.Count() - 1].iContent.Copy(aBytes);
+        }
+    IF_DEBUG(Print(_L("<<<CDpsXmlParser::OnContentL")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsXmlParser::OnStartPrefixMappingL(const RString& /*aPrefix*/, 
+										  const RString& /*aUri*/, 
+										  TInt aErrorCode)
+    {
+    IF_DEBUG(Print(_L(">>>CDpsXmlParser::OnStartPrefixMappingL")));
+    if (aErrorCode != KErrNone)
+        {
+        IF_DEBUG(Print(_L("--- error code %d"), aErrorCode));
+        User::Leave(aErrorCode);
+        }
+    IF_DEBUG(Print(_L("<<<CDpsXmlParser::OnStartPrefixMappingL")));	
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CDpsXmlParser::OnEndPrefixMappingL(const RString& /*aPrefix*/, 
+									    TInt aErrorCode)
+    {
+    IF_DEBUG(Print(_L(">>>CDpsXmlParser::OnEndPrefixMappingL")));
+    if (aErrorCode != KErrNone)
+        {
+        IF_DEBUG(Print(_L("--- error code %d"), aErrorCode));
+        User::Leave(aErrorCode);
+        }
+    IF_DEBUG(Print(_L("<<<CDpsXmlParser::OnEndPrefixMappingL")));	
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CDpsXmlParser::OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/, 
+                                           TInt aErrorCode)
+    {
+    IF_DEBUG(Print(_L(">>>CDpsXmlParser::OnIgnorableWhiteSpaceL")));
+    if (aErrorCode != KErrNone)
+        {
+        IF_DEBUG(Print(_L("---error code %d"), aErrorCode));
+        User::Leave(aErrorCode);
+        }
+    IF_DEBUG(Print(_L("<<<CDpsXmlParser::OnIgnorableWhiteSpaceL")));	
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CDpsXmlParser::OnSkippedEntityL(const RString& /*aName*/, 
+								     TInt aErrorCode)
+	{
+    IF_DEBUG(Print(_L(">>>CDpsXmlParser::OnSkippedEntityL")));
+    if (aErrorCode != KErrNone)
+        {
+        IF_DEBUG(Print(_L("--- error code %d"), aErrorCode));
+        User::Leave(aErrorCode);
+        }
+    IF_DEBUG(Print(_L("<<<CDpsXmlParser::OnSkippedEntityL")));	
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CDpsXmlParser::OnProcessingInstructionL(const TDesC8& /*aTarget*/, 
+											 const TDesC8& /*aData*/, 
+											 TInt aErrorCode)
+    {
+    IF_DEBUG(Print(_L(">>>CDpsXmlParser::OnProcessingInstructionL")));
+    if (aErrorCode != KErrNone)
+        {
+        IF_DEBUG(Print(_L("--- error code %d"), aErrorCode));
+        User::Leave(aErrorCode);
+        }
+    IF_DEBUG(Print(_L("<<<CDpsXmlParser::OnProcessingInstructionL")));	
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CDpsXmlParser::OnError(TInt aErrorCode)
+    {
+    IF_DEBUG(Print(_L(">>>CDpsXmlParser::OnError()")));
+    if (aErrorCode != KErrNone)
+        {
+        IF_DEBUG(Print(_L("---error code %d"), aErrorCode));
+        }
+    IF_DEBUG(Print(_L("<<<CDpsXmlParser::OnError()")));	
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+
+TAny* CDpsXmlParser::GetExtendedInterface(const TInt32 aUid)
+    {
+    return aUid == MDpsExtensionHandler::EInterfaceUid ?
+    static_cast<MDpsExtensionHandler*>(this) : 0;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//  
+void CDpsXmlParser::Reset()
+    {
+    iDpsArgs.Reset();
+    iAction = EDpsXmlEmpty;
+    iDpsEvent = EDpsEvtEmpty; 
+    iDpsOperation = EDpsOpEmpty;
+    iElement = EDpsEleEmpty; 
+    iAttrib = 0;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsxmlstring.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,419 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class implements the dps constant strings. 
+*
+*/
+
+
+#include "dpsxmlstring.h"
+#include "dpsdefs.h"
+#include "dpsconst.h"
+#include <e32debug.h>
+
+#ifdef _DEBUG
+#	define IF_DEBUG(t) {RDebug::t;}
+#else
+#	define IF_DEBUG(t)
+#endif
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TDpsXmlString* TDpsXmlString::NewL()
+    {
+    TDpsXmlString* self = new (ELeave) TDpsXmlString();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TDpsXmlString::TDpsXmlString() 
+    {
+    iDpsOperationStrings = TDpsStrings(EDpsOpMax - 1);
+    iDpsElementStrings = TDpsStrings(KDpsEleMax - 1);
+    iDpsEventStrings = TDpsStrings(KDpsEvtMax - 1);
+    iDpsArgStrings = TDpsStrings(EDpsArgMax);
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void TDpsXmlString::ConstructL()
+    {
+    // define Print Service Operations
+    // ref: DPS spec page 14
+    for (TInt i = 1; i < EDpsOpMax; i++)
+        {
+        switch (i)
+            {
+            case EDpsOpConfigPrintService:
+                iDpsOperationStrings.AppendL(_L8("configurePrintService"));           
+            break;
+            
+            case EDpsOpGetCapability:
+                iDpsOperationStrings.AppendL(_L8("getCapability"));           
+            break;
+            
+            case EDpsOpGetJobStatus:
+                iDpsOperationStrings.AppendL(_L8("getJobStatus"));           
+            break;
+            
+            case EDpsOpGetDeviceStatus:
+                iDpsOperationStrings.AppendL(_L8("getDeviceStatus"));           
+            break;
+            
+            case EDpsOpStartJob:
+                iDpsOperationStrings.AppendL(_L8("startJob"));           
+            break;
+            
+            case EDpsOpAbortJob:
+                iDpsOperationStrings.AppendL(_L8("abortJob"));           
+            break;
+            
+    // define Storage Service Operation
+    // ref: DPS spec page 34
+            case EDpsOpContinueJob:
+                iDpsOperationStrings.AppendL(_L8("continueJob"));           
+            break;
+            
+            case EDpsOpGetFileID:
+                iDpsOperationStrings.AppendL(_L8("getFileID"));           
+            break;
+            
+            case EDpsOpGetFileInfo:
+                iDpsOperationStrings.AppendL(_L8("getFileInfo"));           
+            break;
+            
+            case EDpsOpGetFile:
+                iDpsOperationStrings.AppendL(_L8("getFile"));           
+            break;
+            
+            case EDpsOpGetPartialFile:
+                iDpsOperationStrings.AppendL(_L8("getPartialFile"));           
+            break;
+            
+            case EDpsOpGetFileList:
+                iDpsOperationStrings.AppendL(_L8("getFileList"));           
+            break;
+            
+            case EDpsOpGetThumb:
+                iDpsOperationStrings.AppendL(_L8("getThumb"));           
+            break;
+            
+            default:
+                IF_DEBUG(Print(_L("wrong in OperationString")));
+                User::Leave(KErrArgument);
+            break;                        
+            }
+        }
+        
+    // define the special element which includes other elements
+    for (TInt i = 1; i < KDpsEleMax; i++)
+        {
+        switch(i)
+            {
+            case EDpsCapability:
+                iDpsElementStrings.AppendL(_L8("capability")); 
+            break;
+            
+            case EDpsJobConfig:
+                iDpsElementStrings.AppendL(_L8("jobConfig")); 
+            break;
+            
+            case EDpsPrintInfo:
+                iDpsElementStrings.AppendL(_L8("printInfo")); 
+            break;
+                
+            default:
+                IF_DEBUG(Print(_L("wrong in ElementString")));
+                User::Leave(KErrArgument);
+            break;    
+            }
+        }
+        
+    // define Print Service Event Notification
+    // ref: DPS spec page 14
+    for (TInt i = 1; i < KDpsEvtMax; i++)
+        {
+        switch(i)
+            {
+            case EDpsEvtNotifyJobStatus:
+                iDpsEventStrings.AppendL(_L8("notifyJobStatus")); 
+            break;
+            
+            case EDpsEvtNotifyDeviceStatus:
+                iDpsEventStrings.AppendL(_L8("notifyDeviceStatus")); 
+            break;
+               
+            default:
+                IF_DEBUG(Print(_L("wrong in Event String")));
+                User::Leave(KErrArgument);
+            break;    
+            }
+        }
+     
+    for (TInt i = 0; i < EDpsArgMax; i++)
+        {
+        switch (i)
+            {
+            case EDpsArgDpsVersions:
+                iDpsArgStrings.AppendL(_L8("dpsVersions")); 
+            break;
+        
+            case EDpsArgVendorName:
+                iDpsArgStrings.AppendL(_L8("vendorName")); 
+            break;
+        
+            case EDpsArgVendorSpecificVersion:
+                iDpsArgStrings.AppendL(_L8("vendorSpecificVersion")); 
+            break;
+        
+            case EDpsArgProductName:
+                iDpsArgStrings.AppendL(_L8("productName")); 
+            break;
+        
+            case EDpsArgSerialNo:
+                iDpsArgStrings.AppendL(_L8("serialNo")); 
+            break;
+        
+            case EDpsArgPrintServiceAvailable:
+                iDpsArgStrings.AppendL(_L8("printServiceAvailable")); 
+            break;
+        
+            case EDpsArgQualities:
+                iDpsArgStrings.AppendL(_L8("qualities")); 
+            break;
+        
+            case EDpsArgPaperSizes:
+                iDpsArgStrings.AppendL(_L8("paperSizes")); 
+            break;
+        
+            case EDpsArgPaperTypes:
+                iDpsArgStrings.AppendL(_L8("paperTypes")); 
+            break;
+        
+            case EDpsArgFileTypes:
+                iDpsArgStrings.AppendL(_L8("fileTypes")); 
+            break;
+        
+            case EDpsArgDatePrints:
+                iDpsArgStrings.AppendL(_L8("datePrints")); 
+            break;
+        
+            case EDpsArgFileNamePrints:
+                iDpsArgStrings.AppendL(_L8("fileNamePrints")); 
+            break;
+        
+            case EDpsArgImageOptimizes:
+                iDpsArgStrings.AppendL(_L8("imageOptimizes")); 
+            break;
+        
+            case EDpsArgLayouts:
+                iDpsArgStrings.AppendL(_L8("layouts")); 
+            break;
+        
+            case EDpsArgFixedSizes:
+                iDpsArgStrings.AppendL(_L8("fixedSizes")); 
+            break;
+        
+            case EDpsArgChroppings:
+                iDpsArgStrings.AppendL(_L8("chroppings")); 
+            break;
+        
+            case EDpsArgPrtPID:
+                iDpsArgStrings.AppendL(_L8("prtPID")); 
+            break;
+        
+            case EDpsArgFilePath:
+                iDpsArgStrings.AppendL(_L8("filePath")); 
+            break;
+        
+            case EDpsArgCopyID:
+                iDpsArgStrings.AppendL(_L8("copyID")); 
+            break;
+        
+            case EDpsArgProgress:
+                iDpsArgStrings.AppendL(_L8("progress")); 
+            break;
+        
+            case EDpsArgImagePrinted:
+                iDpsArgStrings.AppendL(_L8("imagePrinted")); 
+            break;
+        
+            case EDpsArgDpsPrintServiceStatus:
+                iDpsArgStrings.AppendL(_L8("dpsPrintServiceStatus")); 
+            break;
+        
+            case EDpsArgJobEndReason:
+                iDpsArgStrings.AppendL(_L8("jobEndReason")); 
+            break;
+        
+            case EDpsArgErrorStatus:
+                iDpsArgStrings.AppendL(_L8("errorStatus")); 
+            break;
+        
+            case EDpsArgErrorReason:
+                iDpsArgStrings.AppendL(_L8("errorReason")); 
+            break;
+        
+            case EDpsArgDisconnectEnable:
+                iDpsArgStrings.AppendL(_L8("disconnectEnable")); 
+            break;
+        
+            case EDpsArgCapabilityChanged:
+                iDpsArgStrings.AppendL(_L8("capabilityChanged")); 
+            break;
+        
+            case EDpsArgNewJobOk:
+                iDpsArgStrings.AppendL(_L8("newJobOK")); 
+            break;
+        
+            case EDpsArgQuality:
+                iDpsArgStrings.AppendL(_L8("quality")); 
+            break;
+        
+            case EDpsArgPaperSize:
+                iDpsArgStrings.AppendL(_L8("paperSize")); 
+            break;
+        
+            case EDpsArgPaperType:
+                iDpsArgStrings.AppendL(_L8("paperType")); 
+            break;
+        
+            case EDpsArgFileType:
+                iDpsArgStrings.AppendL(_L8("fileType")); 
+            break;
+        
+            case EDpsArgDatePrint:
+                iDpsArgStrings.AppendL(_L8("datePrint")); 
+            break;
+        
+            case EDpsArgFileNamePrint:
+                iDpsArgStrings.AppendL(_L8("fileNamePrint")); 
+            break;
+        
+            case EDpsArgImageOptimize:
+                iDpsArgStrings.AppendL(_L8("imageOptimize")); 
+            break;
+        
+            case EDpsArgLayout:
+                iDpsArgStrings.AppendL(_L8("layout")); 
+            break;
+        
+            case EDpsArgFixedSize:
+                iDpsArgStrings.AppendL(_L8("fixedSize")); 
+            break;
+        
+            case EDpsArgCropping:
+                iDpsArgStrings.AppendL(_L8("cropping")); 
+            break;
+        
+            case EDpsArgCroppingArea:
+                iDpsArgStrings.AppendL(_L8("croppingArea")); 
+            break;
+        
+            case EDpsArgFileID:
+                iDpsArgStrings.AppendL(_L8("fileID")); 
+            break;
+        
+            case EDpsArgFileName:
+                iDpsArgStrings.AppendL(_L8("fileName")); 
+            break;
+        
+            case EDpsArgDate:
+                iDpsArgStrings.AppendL(_L8("date")); 
+            break;
+        
+            case EDpsArgCopies:
+                iDpsArgStrings.AppendL(_L8("copies")); 
+            break;
+        
+            case EDpsArgAbortStyle:
+                iDpsArgStrings.AppendL(_L8("abortStyle")); 
+            break;
+        
+            case EDpsArgImagesPrinted:
+                iDpsArgStrings.AppendL(_L8("imagesPrinted")); 
+            break;
+        
+            case EDpsArgBasePathID:
+                iDpsArgStrings.AppendL(_L8("basePathID")); 
+            break;
+        
+            case EDpsArgFileSize:
+                iDpsArgStrings.AppendL(_L8("fileSize")); 
+            break;
+        
+            case EDpsArgThumbFormat:
+                iDpsArgStrings.AppendL(_L8("thumbFormat")); 
+            break;
+        
+            case EDpsArgThumbSize:
+                iDpsArgStrings.AppendL(_L8("thumbSize")); 
+            break;
+ 
+            case EDpsArgBytesRead:
+                iDpsArgStrings.AppendL(_L8("bytesRead")); 
+            break;
+        
+            case EDpsArgOffset:
+                iDpsArgStrings.AppendL(_L8("offset")); 
+            break;
+        
+            case EDpsArgMaxSize:
+                iDpsArgStrings.AppendL(_L8("maxSize")); 
+            break;
+        
+            case EDpsArgParentFileID:
+                iDpsArgStrings.AppendL(_L8("parentFileID")); 
+            break;
+        
+            case EDpsArgMaxNumIDs:
+                iDpsArgStrings.AppendL(_L8("maxNumIDs")); 
+            break;
+        
+            case EDpsArgFileIDs:
+                iDpsArgStrings.AppendL(_L8("fileIDs")); 
+            break;
+        
+            case EDpsArgNumIDs:
+                iDpsArgStrings.AppendL(_L8("numIDs")); 
+            break;
+        
+            default:
+                IF_DEBUG(Print(_L("wrong in ArgString")));
+                User::Leave(KErrArgument);
+            break;
+            }
+        }
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TDpsXmlString::~TDpsXmlString()
+    {
+    iDpsArgStrings.Close();
+    iDpsElementStrings.Close();
+    iDpsEventStrings.Close();
+    iDpsOperationStrings.Close();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/pictbridge.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,384 @@
+/*
+* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class defines and implements the API for UI engine. 
+*
+*/
+
+
+#include <e32base.h>
+#include <e32debug.h>
+#include <dps.rsg>
+#include <f32file.h>
+#include <barsc.h>
+#include <barsread.h>
+#include <bautils.h>
+#include <pathinfo.h>
+
+#include "pictbridge.h"
+#include "dpsdefs.h"
+#include "dpsxmlstring.h"
+#include "dpsconst.h"
+#include "dpsstatemachine.h"
+#include "dpsscriptreceiver.h"
+#include "dpsusbnotifier.h"
+#include "dpsparam.h"
+#include "dpsscriptsender.h"
+#include "dpstransaction.h"
+#include "dpsfile.h"
+
+#ifdef _DEBUG
+#	define IF_DEBUG(t) {RDebug::t;}
+#else
+#	define IF_DEBUG(t)
+#endif
+
+const TInt KResource = 32;
+const TInt KDriver = 3;
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CDpsEngine* CDpsEngine::GetEngineL()
+    {
+    IF_DEBUG(Print(_L("CDpsEngine::GetEngineL")));
+    CDpsEngine* me;
+    me = static_cast<CDpsEngine*>(Dll::Tls());
+    if (!me)
+        {
+        CDpsEngine* self = new(ELeave) CDpsEngine();
+        
+        CleanupStack::PushL(self);
+        self->ConstructL();
+        CleanupStack::Pop();
+        User::LeaveIfError(Dll::SetTls(self));
+        return self;	
+        }
+    else
+        {
+        return me;	
+        }			    
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+EXPORT_C void CDpsEngine::Delete()
+    {
+    IF_DEBUG(Print(_L(">>>DpsEngine::Delete")));
+    CDpsEngine *me; me = static_cast<CDpsEngine*>(Dll::Tls());
+    if (me)
+        {
+        delete me;
+        Dll::SetTls(NULL);
+        }
+    IF_DEBUG(Print(_L("<<<DpsEngine::Delete")));	
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+void CDpsEngine::ConstructL()	
+    {
+    IF_DEBUG(Print(_L(">>>CDpsEngine::ConstructL")));
+    iDpsParameters = TDpsXmlString::NewL();
+    User::LeaveIfError(iPtp.Connect());    
+    iDpsOperator = CDpsStateMachine::NewL(this);
+    iUsbNotifier = CDpsUsbNotifier::NewL(this);
+    IF_DEBUG(Print(_L("<<<DpsEngine::ConstructL")));		
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+CDpsEngine::~CDpsEngine()
+	{
+    IF_DEBUG(Print(_L(">>>~CDpsEngine")));
+	
+    delete iDpsOperator;
+    iDpsOperator = NULL;
+	
+    delete iUsbNotifier;
+    iUsbNotifier = NULL;
+		
+    if (iDpsOperationRequest)
+        {
+        User::RequestComplete(iDpsOperationRequest, KErrCancel);
+        }
+    if (iDpsEventRequest)
+        {
+        User::RequestComplete(iDpsEventRequest, KErrCancel);
+        }    
+    if (iPrinterConnectRequest)
+        {
+        User::RequestComplete(iPrinterConnectRequest, KErrCancel);
+        }	    
+    delete iDpsParameters;
+    iDpsParameters = NULL;
+    iPtp.Close();
+    IF_DEBUG(Print(_L("<<<~CDpsEngine")));
+	}
+	
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CDpsEngine::SetPrintMode(TRequestStatus& aStatus)
+    {
+    IF_DEBUG(Print(_L(">>>DpsEngine::SearchPrinter")));
+    
+    iPrinterConnectRequest = &aStatus;
+    *iPrinterConnectRequest = KRequestPending;		
+    iUsbNotifier->WaitForPrinterNotify();
+    IF_DEBUG(Print(_L("<<<DpsEngine::SearchPrinter")));
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+EXPORT_C void CDpsEngine::CancelPrintMode()
+    {
+    IF_DEBUG(Print(_L(">>>DpsEngine::CancelSearchPrinter")));
+    iUsbNotifier->CancelPrinterNotify();				
+    IF_DEBUG(Print(_L("<<<DpsEngine::CancelSearchPrinter")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CDpsEngine::ConnectStateNotify(TRequestStatus& aStatus)
+    {
+    IF_DEBUG(Print(_L(">>>DpsEngine::ConnectStateNotifyL")));
+    // SetPrintMode must be finished
+    if (!iUsbNotifier->IsSetPrintModeIssued())
+        {
+        TRequestStatus* status = &aStatus;
+        User::RequestComplete(status, KErrNotReady);
+        return;
+        }
+    
+    iPrinterConnectRequest = &aStatus;
+    *iPrinterConnectRequest = KRequestPending;		
+    iUsbNotifier->ConnectNotify();
+    IF_DEBUG(Print(_L("<<<DpsEngine::ConnecStatetNotifyL")));
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+EXPORT_C void CDpsEngine::DoDpsRequestL(TMDpsOperation* aRequest, 
+                                       TRequestStatus& aStatus)
+    {
+    IF_DEBUG(Print(_L(">>>DpsEngine::DoDpsRequestL")));
+    // the ptp printer must be connected and registered for the dps event
+    if (!iUsbNotifier->IsConfigured() || !iDpsEventRequest)
+        {
+        TRequestStatus* status = &aStatus;
+        User::RequestComplete(status, KErrNotReady);
+        return;
+        }
+        
+    // there is a request from the host received and the reply has been
+    // sending out, but the host has not received it yet. we can not send
+    // the device request now
+    IF_DEBUG(Print(_L("curState is %x, idleState is %x"), 
+        iDpsOperator->CurState(), iDpsOperator->IdleState()));    
+    if (iDpsOperator->CurState() != iDpsOperator->IdleState())
+        {
+        TRequestStatus* status = &aStatus;
+        User::RequestComplete(status, KErrInUse);        
+        return;
+        }
+    
+    iDpsOperator->StartTransactionL(aRequest);
+    iDpsOperationRequest = &aStatus;
+    *iDpsOperationRequest = KRequestPending;    
+    IF_DEBUG(Print(_L("<<<DpsEngine::DoDpsRequestL")));           
+	}
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//	
+EXPORT_C void CDpsEngine::CancelDpsRequest()
+    {
+    IF_DEBUG(Print(_L(">>>DpsEngine::CancelDpsOperation")));
+    if (iDpsOperationRequest)
+        {
+        iDpsOperator->ScriptSender()->Cancel();
+        User::RequestComplete(iDpsOperationRequest, KErrCancel);
+        }
+    iDpsOperator->Initialize();
+    IF_DEBUG(Print(_L("<<<DpsEngine::CancelDpsOperation")));
+    }
+ 
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//   
+EXPORT_C void CDpsEngine::DpsEventNotify(TDpsEvents& aParam,
+                                         TRequestStatus& aStatus)
+    {
+    IF_DEBUG(Print(_L(">>>DpsEngine::DpsEventNotify")));
+    // the PTP printer must be connected and registered for the disconnect
+    if (!iUsbNotifier->IsConfigured() || !iPrinterConnectRequest)
+        {
+        TRequestStatus* status = &aStatus;
+        User::RequestComplete(status, KErrNotReady);
+        return;
+        }
+    
+    iOutEvent = &aParam;
+    iDpsEventRequest = &aStatus;
+    *iDpsEventRequest = KRequestPending;
+    iDpsOperator->ScriptReceiver()->WaitForReceive();
+    IF_DEBUG(Print(_L("<<<DpsEngine::DpsEventNotify")));
+    }
+ 
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//       
+EXPORT_C void CDpsEngine::CancelDpsEventNotify()
+    {
+    IF_DEBUG(Print(_L("DpsEngine::CancelDpsEventNotify")));
+    if (iDpsEventRequest)
+        {
+        User::RequestComplete(iDpsEventRequest, KErrCancel);
+        iDpsOperator->ScriptReceiver()->Cancel();
+        }  
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//     
+EXPORT_C void CDpsEngine::GetDpsConfigL(TDpsConfigPrintReq& aConfig)
+    {
+    IF_DEBUG(Print(_L(">>>DpsEngine::GetDpsConfigL")));
+
+    RFs fs = iDpsOperator->Trader()->FileHandle()->FileSession();
+    RResourceFile resource;
+    
+    TBuf<KResource> resourceFile(PathInfo::RomRootPath());
+    TBuf<KResource> length(KDpsResource);    
+    resourceFile.SetLength(KDriver + length.Length());
+    resourceFile.Replace(KDriver, length.Length(), KDpsResource);
+    IF_DEBUG(Print(_L("file is %S"), &resourceFile));
+    resource.OpenL(fs, resourceFile);
+    CleanupClosePushL(resource);
+    resource.ConfirmSignatureL(KDpsResourceVersion);
+    HBufC8* id = resource.AllocReadLC(DPS_CONFIG);
+    TResourceReader reader;
+    reader.SetBuffer(id);
+    TInt count = static_cast<TInt>(reader.ReadUint8());
+    for (TInt i = 0; i < count; i++)
+        {
+        TDpsVersion version;
+        version.iMajor = static_cast<TInt>(reader.ReadUint8());
+        version.iMinor = static_cast<TInt>(reader.ReadUint8());
+        aConfig.iDpsVersions.Append(version); 
+        }
+    TPtrC vendorString = reader.ReadTPtrC(); 
+    aConfig.iVendorName.Copy(vendorString);
+    TDpsVersion vendorVersion;
+    vendorVersion.iMajor = static_cast<TInt>(reader.ReadUint8());
+    vendorVersion.iMinor = static_cast<TInt>(reader.ReadUint8());
+    aConfig.iVendorVersion = vendorVersion;
+    TPtrC productString = reader.ReadTPtrC();
+    aConfig.iProductName.Copy(productString);
+    TPtrC SerialNo = reader.ReadTPtrC();
+    aConfig.iSerialNo.Copy(SerialNo);
+    CleanupStack::PopAndDestroy(id); 
+    CleanupStack::PopAndDestroy(&resource);
+    IF_DEBUG(Print(_L("<<<DpsEngine::GetDpsConfigL")));
+    }
+   
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+EXPORT_C const TDesC& CDpsEngine::DpsFolder() const
+    {
+    return iDpsFolder;
+    }
+           
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TDpsEvents* CDpsEngine::Event() const
+    {
+    return iOutEvent;
+    }
+ 
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//         
+RPtp& CDpsEngine::Ptp()
+    {
+    return iPtp;
+    }
+  
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//         
+TDpsXmlString* CDpsEngine::DpsParameters() const
+    {
+    return iDpsParameters;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//    
+TRequestStatus*& CDpsEngine::EventRequest()
+    {
+    return iDpsEventRequest;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//            
+TRequestStatus*& CDpsEngine::OperationRequest()
+    {
+    return iDpsOperationRequest;
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//                
+TRequestStatus*& CDpsEngine::PrinterConnectRequest()
+    {
+    return iPrinterConnectRequest;
+    }
+    
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//               
+void CDpsEngine::SetDpsFolder(const TDesC& aFolder)
+    {
+    iDpsFolder.Copy(aFolder);
+    }
+
--- a/mtpfws/mtpfw/common/inc/mtpdatacapture.h	Thu May 27 13:42:43 2010 +0300
+++ b/mtpfws/mtpfw/common/inc/mtpdatacapture.h	Fri Jun 11 14:27:06 2010 +0300
@@ -23,13 +23,7 @@
 
 // MTP data caputre defines
 
-#if defined(__WINS__)
 _LIT(KRequestCaptureRootDir, "c:\\test\\data\\");
-#elif defined(__SERIES60_) 
-_LIT(KRequestCaptureRootDir, "c:\\test\\data\\");
-#else
-_LIT(KRequestCaptureRootDir, "e:\\test\\data\\");
-#endif
 
 _LIT(KRequestCaptureDirPrefix, "testcase");
 _LIT(KIToRDataPhaseOutputFile, "i_to_r_dataphase.dat");
--- a/mtpfws/mtpfw/common/inc/uiklafinternalcrkeys.h	Thu May 27 13:42:43 2010 +0300
+++ b/mtpfws/mtpfw/common/inc/uiklafinternalcrkeys.h	Fri Jun 11 14:27:06 2010 +0300
@@ -69,6 +69,25 @@
  */
 const TUint32 KUikOODDiskFreeSpaceWarningNoteLevelMassMemory = 0x00000007;
 
+#ifdef __MTP_NAVIENGINE_TEST
+//The free size of C-Drive of NaviEngine env is less than 21M,
+//it will block many ONB test cases
+const TInt KFreeSpaceThreshHoldDefaultValue(0);
+const TInt KFreeSpaceExtraReserved(0);
+
+#else
+//MTP should reserve some disk space to prevent OOD(Out of Disk) monitor 
+//popup 'Out of memory' note.When syncing music through ovi player,
+//sometimes device screen get freeze with this note
+//Be default, this value is read from Central Respository, if error while
+//reading, use this one
+const TInt KFreeSpaceThreshHoldDefaultValue(20*1024*1024);//20M bytes
+
+//Beside the OOD threshold value, we need to reserve extra disk space
+//for harvest server do the harvest, set this as 1M
+const TInt KFreeSpaceExtraReserved(1024*1024);//1M bytes
+
+#endif
 
 #endif __UIKLAF_INTERNAL_CR_KEYS_H__
 
--- a/mtpfws/mtpfw/daemon/client/src/rmtpclient.cpp	Thu May 27 13:42:43 2010 +0300
+++ b/mtpfws/mtpfw/daemon/client/src/rmtpclient.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -117,15 +117,6 @@
 		// Wait for the server start up to complete.
     	User::WaitForRequest(status);
     	ret = (server.ExitType() == EExitPanic) ? KErrGeneral : status.Int();
-#ifdef __WINSCW__
-    	if ( server.ExitType() == EExitPanic )
-    	    {
-            TExitCategoryName exitCategory = server.ExitCategory();
-            TInt exitReason = server.ExitReason();
-            RDebug::Print( _L("The exit category is \"%S\""), &exitCategory );
-            RDebug::Print( _L("The exit Reason is %d"), exitReason );
-    	    }
-#endif //__WINSCW__
     	server.Close();
 	    }
 	    
--- a/mtpfws/mtpfw/daemon/server/group/mtpserver.mmp	Thu May 27 13:42:43 2010 +0300
+++ b/mtpfws/mtpfw/daemon/server/group/mtpserver.mmp	Fri Jun 11 14:27:06 2010 +0300
@@ -22,12 +22,7 @@
 
 CAPABILITY			CommDD PowerMgmt ReadDeviceData WriteDeviceData TrustedUI ProtServ NetworkControl NetworkServices LocalServices ReadUserData WriteUserData
 
-#ifdef WINSCW
-//EPOCHEAPSIZE        0x1400000   0x1400000   // 20MB
 EPOCHEAPSIZE        0x80000   0x800000   // 8MB
-#else
-EPOCHEAPSIZE        0x80000   0x800000   // 8MB
-#endif
 
 EPOCSTACKSIZE       0x14000
 
--- a/mtpfws/mtpfw/dataproviders/devdp/group/bld.inf	Thu May 27 13:42:43 2010 +0300
+++ b/mtpfws/mtpfw/dataproviders/devdp/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -30,7 +30,6 @@
 #endif
 
 mtpdevice.ico /epoc32/data/z/private/102827a2/mtpdevice.ico
-mtpdevice.ico /epoc32/winscw/c/private/102827a2/mtpdevice.ico
 ../inc/mtpdevicedp_config.rh SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(mtp/mtpdevicedp_config.rh)
 
 mtp_devicedp.iby   /epoc32/rom/include/mtp_devicedp.iby
--- a/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpdevicedatastore.h	Thu May 27 13:42:43 2010 +0300
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpdevicedatastore.h	Fri Jun 11 14:27:06 2010 +0300
@@ -88,6 +88,9 @@
 
     TBool IsConnectMac();
     void SetConnectMac(TBool aConnectMac);	
+    
+    TBool Enumerated() const;
+    void RegisterPendingRequest();
 	
 private: // Form CActive
 
@@ -101,7 +104,6 @@
     CMTPDeviceDataStore();
     void ConstructL();
 
-    TBool Enumerated() const;
     void ExternalizeL(RWriteStream& aWriteStream) const;
     void InternalizeL(RReadStream& aReadStream);
     const TDesC& PropertyStoreName();
@@ -163,6 +165,7 @@
     CMTPTypeArray*                                   iSupportedDevProArray;
     TUint8			iFormatOreder; 
     
+    
 private: // Not owned.
 
     MMTPEnumerationCallback* 	    iCallback;
@@ -172,6 +175,7 @@
     MExtnDevicePropDp*              iExtnDevicePropDp;
 
     TBool                           iIsConnectMac; 
+    TBool                           iHasPendingRequest;    
     };
    
 #endif // CMTPDEVICEDATASTORE_H
--- a/mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevicedatastore.cpp	Thu May 27 13:42:43 2010 +0300
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevicedatastore.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -35,11 +35,7 @@
 // Class constants.
 __FLOG_STMT(_LIT8(KComponent,"DeviceDataStore");)
 
-#ifdef __WINS__
-_LIT( KFileName, "c:\\private\\102827a2\\mtpdevice.ico");
-#else
 _LIT( KFileName, "z:\\private\\102827a2\\mtpdevice.ico");
-#endif
 
 
 // Device property datastore constants.
@@ -438,6 +434,7 @@
     	if (isCompleted)
     		{
     		Schedule(EEnumerated);
+
     		}
     	else
     		{
@@ -453,12 +450,20 @@
         break;
 
     case EEnumerated:
+        {
+        if (iHasPendingRequest)
+            {
+            iHasPendingRequest = EFalse;
+            iSingletons.DpController().ExecutePendingRequestL();
+            }
+        
         if (iCallback)
             {
             iCallback->NotifyEnumerationCompleteL(iStorageId, KErrNone);
             iCallback = NULL;
             iStorageId = KMTPNotSpecified32;
             }
+        }
         break;
 
 case EEnumeratedBatteryLevel :
@@ -483,7 +488,8 @@
     CActive(EPriorityStandard),
 	iBatteryInfoV1Pckg(iBatteryInfoV1),
 	iPhoneIdV1Pckg(iPhoneIdV1),
-	iIsConnectMac(EFalse)
+	iIsConnectMac(EFalse),
+	iHasPendingRequest(EFalse)
     {
     CActiveScheduler::Add(this);
     }
@@ -1235,3 +1241,10 @@
     {
     iIsConnectMac = aConnectMac;
     }
+
+void CMTPDeviceDataStore::RegisterPendingRequest()
+    {
+    iHasPendingRequest = ETrue;
+    }
+
+
--- a/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetdeviceinfo.cpp	Thu May 27 13:42:43 2010 +0300
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetdeviceinfo.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -101,6 +101,15 @@
 void CMTPGetDeviceInfo::ServiceL()
     {
     __FLOG(_L8("ServiceL - Entry"));
+    
+    if (!iDpSingletons.DeviceDataStore().Enumerated())
+        {
+        __FLOG(_L8("MTPExtensionReady not ready, reschedule request")); 
+        iDpSingletons.DeviceDataStore().RegisterPendingRequest();
+        RegisterPendingRequest();
+        return;
+        }
+    
     BuildDeviceInfoL();
     SendDataL(*iDeviceInfo);
     __FLOG(_L8("ServiceL - Exit"));
--- a/mtpfws/mtpfw/dataproviders/dputility/src/cmtpfsenumerator.cpp	Thu May 27 13:42:43 2010 +0300
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpfsenumerator.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -455,7 +455,15 @@
     for (TInt i = (iFirstUnprocessed - count); i < iFirstUnprocessed; ++i)
         {
         const TEntry& entry = iEntries[i];
+        TInt len = entry.iName.Length();
+        if(iCurrentPath.Length()  + len > KMaxFileName)
+            {
+            __FLOG_VA(_L8("Full name exceeds KMaxFileName, ignored."));
+            continue;
+            }
+        
         iCurrentPath.Append(entry.iName);
+
         __FLOG_VA((_L("Process path %S name %S"), &iCurrentPath, &entry.iName));
 #ifdef __FLOG_ACTIVE    
         TBuf8<KMTPMaxFullFileName> tmp;
@@ -478,15 +486,6 @@
             }
 #endif // __FLOG_ACTIVE
 
-        TInt len = entry.iName.Length();
-        TInt totalLen = iCurrentPath.Length();
-        if(totalLen > KMaxFileName)
-            {
-            // Remove filename part
-            iCurrentPath.SetLength(totalLen - len);
-            __FLOG_VA(_L8("Full name exceeds KMaxFileName, ignored."));
-            continue;
-            }
         TUint32 handle = 0;
         TMTPFormatCode format;
         if(-- iObjectNeedToScan <=0 && iAllRootScaned)
--- a/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsendobjectinfo.cpp	Thu May 27 13:42:43 2010 +0300
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsendobjectinfo.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -717,7 +717,7 @@
             iFullPath.LowerCase();
             __FLOG_VA((_L8("File Name %S"), &iFullPath));
             TParsePtrC file( iFullPath );
-            if ( file.ExtPresent() && iExceptionList.Find(file.Ext()) != KErrNotFound)
+            if ( file.ExtPresent() && file.Ext().Length()<=KExtensionLength && iExceptionList.Find(file.Ext()) != KErrNotFound)
                 {
                 TUint32 DpId = iFramework.DataProviderId();
                 HBufC* mime = iDpSingletons.MTPUtility().ContainerMimeType(iFullPath);
--- a/mtpfws/mtpfw/datatypes/group/mtpdatatypes.mmp	Thu May 27 13:42:43 2010 +0300
+++ b/mtpfws/mtpfw/datatypes/group/mtpdatatypes.mmp	Fri Jun 11 14:27:06 2010 +0300
@@ -39,8 +39,7 @@
 USERINCLUDE     ../inc
 //For UiklafInternalCRKeys.h,should be removed, after we switched to DFs
 USERINCLUDE		../../common/inc
-//For mtpframeworkconst.h
-USERINCLUDE		../../inc
+
 
 SOURCEPATH      ../src
 SOURCE          cmtptypearray.cpp
--- a/mtpfws/mtpfw/datatypes/interface/cmtptypefile.h	Thu May 27 13:42:43 2010 +0300
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypefile.h	Fri Jun 11 14:27:06 2010 +0300
@@ -96,9 +96,9 @@
 	IMPORT_C TInt64 GetByteSent();
     
 private:
-    CMTPTypeFile();
-    void ConstructL(RFs& aFs, const TDesC& aName, TFileMode aMode);
-	void ConstructL(RFs& aFs, const TDesC& aName, TFileMode aMode, TInt64 aRequiredSize, TInt64 aOffSet);
+    CMTPTypeFile(RFs& aFs);
+    void ConstructL(const TDesC& aName, TFileMode aMode);
+	void ConstructL(const TDesC& aName, TFileMode aMode, TInt64 aRequiredSize, TInt64 aOffSet);
     void ToggleRdWrBuffer();
 
 protected: // From CActive
@@ -108,8 +108,10 @@
 	
     TInt RunError(TInt aError);
     void RunL();
+    
 private:
 
+    
     /**
     The read and write data stream states.
     */
@@ -213,6 +215,7 @@
      */
     CFileWriter    *iFileWriter2;
 
+    RFs&            iFs;
     };
     
 #endif // CMTPTYPEFILE_H
--- a/mtpfws/mtpfw/datatypes/src/cmtptypefile.cpp	Thu May 27 13:42:43 2010 +0300
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypefile.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -21,8 +21,6 @@
 #include <mtp/cmtptypefile.h>
 #include <mtp/mtpdatatypeconstants.h>
 
-#include "mtpframeworkconst.h"
-
 //This file is exported from s60 sdk, now just copy it
 //to make sure onb can run
 #include "UiklafInternalCRKeys.h"
@@ -141,9 +139,9 @@
  */
 EXPORT_C CMTPTypeFile* CMTPTypeFile::NewLC(RFs& aFs, const TDesC& aName, TFileMode aMode)
     {
-    CMTPTypeFile* self = new(ELeave) CMTPTypeFile;
+    CMTPTypeFile* self = new(ELeave) CMTPTypeFile(aFs);
     CleanupStack::PushL(self);
-    self->ConstructL(aFs, aName, aMode);
+    self->ConstructL(aName, aMode);
     return self;
     }
 
@@ -156,9 +154,9 @@
 
 EXPORT_C CMTPTypeFile* CMTPTypeFile::NewLC(RFs& aFs, const TDesC& aName, TFileMode aMode, TInt64 aRequiredSize, TInt64 aOffSet)
     {
-    CMTPTypeFile* self = new(ELeave) CMTPTypeFile;
+    CMTPTypeFile* self = new(ELeave) CMTPTypeFile(aFs);
     CleanupStack::PushL(self);
-    self->ConstructL(aFs, aName, aMode, aRequiredSize, aOffSet);
+    self->ConstructL(aName, aMode, aRequiredSize, aOffSet);
     return self;
     }
 
@@ -188,12 +186,10 @@
     //file syncing
     TInt driveNo;
     TDriveInfo driveInfo;
-    iFile.Drive(driveNo,driveInfo);
-    RFs fs;
+    User::LeaveIfError(iFile.Drive(driveNo,driveInfo));
+    
     TVolumeInfo volumeInfo;
-    fs.Connect();
-    fs.Volume(volumeInfo,driveNo);
-    fs.Close();
+    User::LeaveIfError(iFs.Volume(volumeInfo,driveNo));
     
     //Read the threshold value from Central Repository and check against it
     CRepository* repository(NULL);
@@ -571,28 +567,29 @@
     return iByteSent;
     }
 
-CMTPTypeFile::CMTPTypeFile() :
+CMTPTypeFile::CMTPTypeFile(RFs& aFs) :
     CActive(EPriorityUserInput), iBuffer1AvailForWrite(ETrue),
-        iFileRdWrError(EFalse), iCurrentCommitChunk(NULL, 0)
+        iFileRdWrError(EFalse), iCurrentCommitChunk(NULL, 0),
+        iFs(aFs)
     {
     CActiveScheduler::Add(this);
     }
 
-void CMTPTypeFile::ConstructL(RFs& aFs, const TDesC& aName, TFileMode aMode)
+void CMTPTypeFile::ConstructL(const TDesC& aName, TFileMode aMode)
     {
     if (aMode & EFileWrite)
         {
         iFileOpenForRead = EFalse;
-        TInt err = iFile.Create(aFs, aName, aMode|EFileWriteDirectIO);
+        TInt err = iFile.Create(iFs, aName, aMode|EFileWriteDirectIO);
         if (err != KErrNone)
             {
-            User::LeaveIfError(iFile.Replace(aFs, aName, aMode|EFileWriteDirectIO));
+            User::LeaveIfError(iFile.Replace(iFs, aName, aMode|EFileWriteDirectIO));
             }
         }
     else
         {
         iFileOpenForRead = ETrue;
-        User::LeaveIfError(iFile.Open(aFs, aName, aMode|EFileReadDirectIO|EFileShareReadersOnly));
+        User::LeaveIfError(iFile.Open(iFs, aName, aMode|EFileReadDirectIO|EFileShareReadersOnly));
 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
         TInt64 size = 0;
 #else
@@ -615,22 +612,22 @@
         }
     }
 
-void CMTPTypeFile::ConstructL(RFs& aFs, const TDesC& aName, TFileMode aMode, TInt64 aRequiredSize, TInt64 aOffSet)
+void CMTPTypeFile::ConstructL(const TDesC& aName, TFileMode aMode, TInt64 aRequiredSize, TInt64 aOffSet)
 	{
     if (aMode & EFileWrite)
         {
         iFileOpenForRead = EFalse;
-        TInt err = iFile.Create(aFs, aName, aMode|EFileWriteDirectIO);
+        TInt err = iFile.Create(iFs, aName, aMode|EFileWriteDirectIO);
         if (err != KErrNone)
             {
-            User::LeaveIfError(iFile.Replace(aFs, aName, aMode|EFileWriteDirectIO));
+            User::LeaveIfError(iFile.Replace(iFs, aName, aMode|EFileWriteDirectIO));
             }
         }
     else
         {
         iFileOpenForRead = ETrue;
         iOffSet = aOffSet;
-        User::LeaveIfError(iFile.Open(aFs, aName, aMode|EFileReadDirectIO|EFileShareReadersOnly));
+        User::LeaveIfError(iFile.Open(iFs, aName, aMode|EFileReadDirectIO|EFileShareReadersOnly));
 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
         TInt64 size = 0;
 #else
--- a/mtpfws/mtpfw/group/bld.inf	Thu May 27 13:42:43 2010 +0300
+++ b/mtpfws/mtpfw/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -31,11 +31,7 @@
 PRJ_EXPORTS
 // repositories exported for TechView and testing
 10282FCC_ARMV5.cre  /epoc32/data/z/private/10202be9/10282fcc.cre
-10282FCC_WINSCW.cre /epoc32/release/winscw/udeb/z/private/10202be9/10282fcc.cre
-10282FCC_WINSCW.cre /epoc32/release/winscw/urel/z/private/10202be9/10282fcc.cre
 backup_registration.xml  /epoc32/data/z/private/102827a2/backup_registration.xml
-backup_registration.xml /epoc32/release/winscw/udeb/z/private/102827a2/backup_registration.xml
-backup_registration.xml /epoc32/release/winscw/urel/z/private/102827a2/backup_registration.xml
 
 // ConfML Files
 ../conf/mtpframework.confml                 MW_LAYER_EXPORTS_CONFML(mtpframework.confml)
--- a/mtpfws/mtpfw/inc/cmtpconnectionmgr.h	Thu May 27 13:42:43 2010 +0300
+++ b/mtpfws/mtpfw/inc/cmtpconnectionmgr.h	Fri Jun 11 14:27:06 2010 +0300
@@ -111,6 +111,10 @@
     TMTPBTRemoteDevice iRemoteDevice;
     
     /**
+     * Set ETrue when Resumetransport need to be called.
+     */
+    TBool                           iResumeCalled;
+    /**
     FLOGGER debug trace member variable.
     */
     __FLOG_DECLARATION_MEMBER_MUTABLE;
--- a/mtpfws/mtpfw/inc/mtpframeworkconst.h	Thu May 27 13:42:43 2010 +0300
+++ b/mtpfws/mtpfw/inc/mtpframeworkconst.h	Fri Jun 11 14:27:06 2010 +0300
@@ -81,14 +81,5 @@
 */
 const TUint KMTPProxyDPID = 2; 
 
-//MTP should reserve some disk space to prevent OOD(Out of Disk) monitor 
-//popup 'Out of memory' note.When syncing music through ovi player,
-//sometimes device screen get freeze with this note
-//Be default, this value is read from Central Respository, if error while
-//reading, use this one
-const TInt KFreeSpaceThreshHoldDefaultValue(20*1024*1024);//20M bytes
 
-//Beside the OOD threshold value, we need to reserve extra disk space
-//for harvest server do the harvest, set this as 1M
-const TInt KFreeSpaceExtraReserved(1024*1024);//1M bytes
 #endif // MTPFRAMEWORKCONST_H
--- a/mtpfws/mtpfw/src/cmtpconnectionmgr.cpp	Thu May 27 13:42:43 2010 +0300
+++ b/mtpfws/mtpfw/src/cmtpconnectionmgr.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -24,6 +24,9 @@
 // Class constants.
 __FLOG_STMT(_LIT8(KComponent,"ConnectionMgr");)
 
+const TUint KMTPUsbTransportUid  = 0x102827B2;
+const TUint KMTPBTTransportUid  = 0x10286FCB;
+
 /**
 CMTPConnectionMgr factory method.
 @leave If a failure occurs, one of the system wide error codes.
@@ -97,17 +100,25 @@
 void CMTPConnectionMgr::ConnectionCloseComplete(const TUint& /*aConnUid*/)
     {
     __FLOG(_L8("ConnectionCloseComplete - Entry"));
-    ResumeSuspendedTransport();
+    if (iTransportUid.iUid != KMTPUsbTransportUid )
+        {
+        ResumeSuspendedTransport();
+        }
+    else
+        {
+        iResumeCalled = ETrue;
+        }
+    
     __FLOG(_L8("ConnectionCloseComplete - exit"));
     }
 
 EXPORT_C void CMTPConnectionMgr::StartTransportL(TUid aTransport)
     {
-    
-    TInt32 bluetoothUid = 0x10286FCB;
-    
+    __FLOG(_L8("StartTransportL - Entry"));
+  
     RUsb usb;
     User::LeaveIfError(usb.Connect());
+    __FLOG(_L8("after connect, and before call get currentpersonalityid"));
     TInt usbMode;
     TUsbServiceState usbStat;
     TInt err = usb.GetCurrentPersonalityId(usbMode);
@@ -133,7 +144,7 @@
     
     
     //When USB plug out, BT will start Master mode to reconnect remote device. Else BT will start slave mode to listen connection.
-    if(aTransport.iUid == bluetoothUid && iRemoteDevice.iDeviceAddr != 0 && aTransport != iTransportUid)
+    if(aTransport.iUid == KMTPBTTransportUid && iRemoteDevice.iDeviceAddr != 0 && aTransport != iTransportUid)
         {
         __FLOG(_L8("StartTransportL with parameter!"));
         TMTPBTRemoteDeviceBuf tmpdata(iRemoteDevice);
@@ -146,7 +157,7 @@
         __FLOG(_L8("StartTransportL without parameter!"));
         StartTransportL( aTransport, NULL );
         }
-    
+    __FLOG(_L8("StartTransportL - Exit"));
     }
 
 /**
@@ -163,8 +174,6 @@
     {
     __FLOG(_L8("StartTransportL - Entry"));
     
-    TInt32 bluetoothUid = 0x10286FCB;
-    
     if (iTransport)
         {
         __FLOG(_L8("The transport is not none."));
@@ -177,7 +186,7 @@
         else
             {
             __FLOG_1(_L8("Relaunch the transport 0x%X"), iTransportUid.iUid);
-            if(aTransport.iUid == bluetoothUid)
+            if(aTransport.iUid == KMTPBTTransportUid)
                 {
                 iTransport->Stop(*this);
                 delete iTransport;
@@ -217,7 +226,7 @@
         
         iTransportCount++;
         
-        if(iTransportUid.iUid != bluetoothUid)
+        if(iTransportUid.iUid != KMTPBTTransportUid)
             {
             UnsuspendTransport( iTransportUid );
             }
@@ -272,7 +281,9 @@
 	
 
     __FLOG_1(_L8("aTransport is 0x%X"), aTransport.iUid);
-    __FLOG_1(_L8("iTransportUid is 0x%X"), aTransport.iUid);
+    __FLOG_1(_L8("iTransportUid is 0x%X"), iTransportUid.iUid);
+    
+    TInt transportId = iTransportUid.iUid;
 
     if ( aByBearer )
         {
@@ -290,6 +301,13 @@
         iTransport = NULL;
         iTransportUid = KNullUid;
         iTransportCount--;
+        //To be sure Resume is done after StopTransport
+        if( transportId == KMTPUsbTransportUid && iResumeCalled)
+            {
+            ResumeSuspendedTransport();
+			iResumeCalled = EFalse;            
+            }
+
         }
     
 	__FLOG(_L8("StopTransport - Exit"));
@@ -390,6 +408,7 @@
     __FLOG_OPEN(KMTPSubsystem, KComponent);
     iRemoteDevice.iDeviceAddr = 0;
     iRemoteDevice.iDeviceServicePort = 0;
+    iResumeCalled = EFalse;
     }
 
 /**
@@ -471,21 +490,28 @@
     __FLOG_1(_L8("The count number is %d"), count);
     __FLOG_1(_L8("The transportport id is 0x%X"), iTransportUid.iUid);
     
-    TInt32 bluetoothUid = 0x10286FCB;
-    
     if ( ( count > 0 )
         // If the transport was just switched and suspended, it shouldn't be resumed.
-        && (( iTransportUid != iSuspendedTransports[count-1] ) || iTransportUid.iUid == bluetoothUid))
+        && (( iTransportUid != iSuspendedTransports[count-1] ) || iTransportUid.iUid == KMTPBTTransportUid))
         {
         __FLOG( _L8("Found suspended transport(s).") );
         if ( !iTransportTrigger )
             {
             iTransportTrigger = new( ELeave ) CAsyncCallBack( CActive::EPriorityStandard );
             }
-        __ASSERT_DEBUG( ( !iTransportTrigger->IsActive() ), User::Invariant() );
-        TCallBack callback( CMTPConnectionMgr::DoResumeSuspendedTransport, this );
-        iTransportTrigger->Set( callback );
-        iTransportTrigger->CallBack();
+       
+        if ( !iTransportTrigger->IsActive())
+            {
+            __FLOG( _L8("Set call back function!") );
+            TCallBack callback( CMTPConnectionMgr::DoResumeSuspendedTransport, this );
+            iTransportTrigger->Set( callback );
+            iTransportTrigger->CallBack();            
+            }
+        else
+            {
+            __FLOG( _L8("Call back has been set!") );
+            }
+
         }
     __FLOG( _L8("-ResumeSuspendedTransport") );
     }
--- a/mtpfws/mtpfw/src/cmtpdataprovider.cpp	Thu May 27 13:42:43 2010 +0300
+++ b/mtpfws/mtpfw/src/cmtpdataprovider.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -556,7 +556,10 @@
         }
     else
         {
-        iCurrentTransactionPhase = iCurrentConnection->TransactionPhaseL(iCurrentRequest->Uint32(TMTPTypeRequest::ERequestSessionID));        
+        if (iCurrentRequest != NULL)
+            {
+            iCurrentTransactionPhase = iCurrentConnection->TransactionPhaseL(iCurrentRequest->Uint32(TMTPTypeRequest::ERequestSessionID));
+            }
         }
     __FLOG_VA((_L8("Current transaction phase = 0x%08X"), iCurrentTransactionPhase));
     
@@ -616,7 +619,8 @@
 		else if (iSingletons.DpController().EnumerateState() < CMTPDataProviderController::EEnumeratingPhaseOneDone)
     	{
         __FLOG(_L8("DP Enumeration is not complete"));
-
+        if (iCurrentRequest != NULL)
+        {
         TUint16 opCode = iCurrentRequest->Uint16(TMTPTypeRequest::ERequestOperationCode);
 
         switch(opCode)
@@ -669,6 +673,7 @@
 	  default:
 		  break;
 		    }
+        }
 	    }
 		}
     else
@@ -678,16 +683,19 @@
         
         //Make ActiveRequest processor and CancelRequest processing to occur synchronously
         if( iCurrentTransactionPhase == ERequestPhase )
-        	{
-        	CMTPSession& session(static_cast<CMTPSession&>(iCurrentConnection->SessionWithMTPIdL(iCurrentRequest->Uint32(TMTPTypeRequest::ERequestSessionID))));
-        	MMTPConnectionProtocol& connection(static_cast<MMTPConnectionProtocol&>(*iCurrentConnection)); 
+            {
+                if( iCurrentRequest != NULL )
+                	{  
+        	        CMTPSession& session(static_cast<CMTPSession&>(iCurrentConnection->SessionWithMTPIdL(iCurrentRequest->Uint32(TMTPTypeRequest::ERequestSessionID))));
+        	        MMTPConnectionProtocol& connection(static_cast<MMTPConnectionProtocol&>(*iCurrentConnection)); 
         	
-        	// Pass transaction to session to check against any pending events
-           	if ( session.CheckPendingEvent(*iCurrentRequest) )
-            	{
-                //Current request matches a pending event, pass event to connection layer event processing
-                connection.ReceivedEventL(session.PendingEvent());
-                }
+        	        // Pass transaction to session to check against any pending events
+           	      if ( session.CheckPendingEvent(*iCurrentRequest) )
+            	    {
+                      //Current request matches a pending event, pass event to connection layer event processing
+                  connection.ReceivedEventL(session.PendingEvent());
+                  }
+                  }
         	}
         
         }
--- a/mtpfws/mtpfw/src/cmtpobjectstore.cpp	Thu May 27 13:42:43 2010 +0300
+++ b/mtpfws/mtpfw/src/cmtpobjectstore.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -497,9 +497,15 @@
 			else
 				{
 				aObject.SetUint(CMTPObjectMetaData::EHandle, handle);
-				needUpdateOwner = ETrue;
-				//while enumerating, we ignore the repeatedly INSERT operations.
-				//User::Leave(KErrAlreadyExists);
+				CMTPObjectMetaData* object(CMTPObjectMetaData::NewLC());
+				if(ObjectL(aObject.DesC(CMTPObjectMetaData::ESuid), *object))
+					{
+					if(object->Uint(CMTPObjectMetaData::EDataProviderId) != aObject.Uint(CMTPObjectMetaData::EDataProviderId))
+						{
+						needUpdateOwner = ETrue;
+						}
+					}
+				CleanupStack::PopAndDestroy(object);
 				}
 			__FLOG_VA(_L8("Not Found in Snapshot"));
 			}
--- a/mtpfws/mtpfw/src/cmtpstoragemgr.cpp	Thu May 27 13:42:43 2010 +0300
+++ b/mtpfws/mtpfw/src/cmtpstoragemgr.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -348,54 +348,8 @@
 EXPORT_C TUint32 CMTPStorageMgr::DefaultStorageId() const
     {
     __FLOG(_L8("DefaultStorageId - Entry"));
-    
-    TUint32 ret = iDefaultStorageId;
-    TBool check = EFalse;
-	TInt driveNo = DriveNumber(ret);
-	const TUint KMinFreeSpace(1024 * 512);  
-	if( (KErrNotFound == driveNo) || ( !IsReadWriteStorage(ret) ) )
-		{
-		check = ETrue;
-		}
-	else
-		{
-		TVolumeInfo volumeInfo;
-		if(iSingletons.Fs().Volume(volumeInfo, driveNo) != KErrNone)
-			{
-			check = ETrue;
-			}
-		else if (volumeInfo.iFree < KMinFreeSpace)
-			{
-			check = ETrue;
-			}
-		}
-    	
-    if(check)
-    	{ 
-		const TUint KCount(iMapDriveToStorage.Count());
-		for (TInt i = 0; i < KCount; i++)
-			{
-			if (iMapDriveToStorage[i] == KErrNotFound)
-				{
-				continue;
-				}
-			TVolumeInfo volume;
-			if( !IsReadWriteStorage(iMapDriveToStorage[i]) 
-					|| (iSingletons.Fs().Volume(volume, i) != KErrNone) )
-				{
-				continue;
-				}
-			
-			if (volume.iFree > KMinFreeSpace )
-				{
-				ret = iMapDriveToStorage[i];
-				break;
-				}
-			}
-    	}
-    
     __FLOG(_L8("DefaultStorageId - Exit"));
-    return ret;
+    return iDefaultStorageId;
     }
 
 EXPORT_C TInt CMTPStorageMgr::DriveNumber(TUint32 aStorageId) const
--- a/mtptransports/mtpcontroller/group/bld.inf	Thu May 27 13:42:43 2010 +0300
+++ b/mtptransports/mtpcontroller/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -22,7 +22,6 @@
 
 PRJ_PLATFORMS
 ARMV5
-WINSCW
 
 PRJ_EXPORTS
 mtp_controller.iby          /epoc32/rom/include/mtp_controller.iby
--- a/mtptransports/mtpptpiptransport/ptpipdatatypes/group/bld.inf	Thu May 27 13:42:43 2010 +0300
+++ b/mtptransports/mtpptpiptransport/ptpipdatatypes/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -21,7 +21,6 @@
 
 PRJ_PLATFORMS
 ARMV5
-winscw
 
 PRJ_EXPORTS
 
--- a/mtptransports/mtpptpiptransport/ptpipplugin/group/bld.inf	Thu May 27 13:42:43 2010 +0300
+++ b/mtptransports/mtpptpiptransport/ptpipplugin/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -21,7 +21,6 @@
 
 PRJ_PLATFORMS
 ARMV5
-winscw
 
 PRJ_EXPORTS
 
--- a/mtptransports/mtpusbtransport/usbsic_cc/group/bld.inf	Thu May 27 13:42:43 2010 +0300
+++ b/mtptransports/mtpusbtransport/usbsic_cc/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -25,6 +25,5 @@
 PRJ_EXPORTS
 
 PRJ_MMPFILES
-#ifndef WINSCW 
 mtpusbsiccc.mmp
-#endif
+
--- a/mtptransports/mtpusbtransport/usbsic_imp/group/bld.inf	Thu May 27 13:42:43 2010 +0300
+++ b/mtptransports/mtpusbtransport/usbsic_imp/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -25,6 +25,5 @@
 PRJ_EXPORTS
 
 PRJ_MMPFILES 
-#ifndef WINSCW
 mtpusbsicimp.mmp
-#endif
+
--- a/mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbconnection.cpp	Thu May 27 13:42:43 2010 +0300
+++ b/mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbconnection.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -131,7 +131,7 @@
     __FLOG(_L8("CloseConnection - Exit"));
     }
     
-void CMTPUsbConnection::ReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest)
+void CMTPUsbConnection::ReceiveDataL(MMTPType& aData, const TMTPTypeRequest& /*aRequest*/)
     {
     __FLOG(_L8("ReceiveDataL - Entry"));
     
@@ -521,7 +521,9 @@
                 static_cast<CMTPUsbEpBulkOut*>(iEndpoints[EMTPUsbEpBulkOut])->FlushRxDataL();
                 
             	// initiate bulk request sequence.
-            	InitiateBulkRequestSequenceL();                 
+            	InitiateBulkRequestSequenceL();   
+            	
+                SetDeviceStatus(EMTPUsbDeviceStatusOK);
             	}
             }
 
@@ -1039,10 +1041,7 @@
     CMTPUsbEpControl& ctrl(*static_cast<CMTPUsbEpControl*>(iEndpoints[EMTPUsbEpControl]));
     if (!ctrl.Stalled())
         {
-        // wait 100 miliseconds before issue control request.
-		// This line is to fix winlogo transport cancel test issue due to that ReadUntilShort never complete sometimes
-		// If USB team fixed the issue, this line could be removed.
-//        User::After(1000*100); // 100 Miliseconds 
+
         ctrl.ReceiveControlRequestSetupL(iUsbControlRequestSetup);
         }
     __FLOG(_L8("InitiateControlRequestSequenceL - Exit"));        
@@ -1255,7 +1254,7 @@
 @param aRequest The USB SIC class specific request setup data.
 @leave One of the system wide error codes, if a processing failure occurs.
 */ 
-void CMTPUsbConnection::ProcessControlRequestDeviceStatusL(const TMTPUsbControlRequestSetup& aRequest)
+void CMTPUsbConnection::ProcessControlRequestDeviceStatusL(const TMTPUsbControlRequestSetup& /*aRequest*/)
     {
     __FLOG(_L8("ProcessControlRequestDeviceStatusL - Entry"));
     iUsbControlRequestDeviceStatus.Reset();
--- a/mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepbase.cpp	Thu May 27 13:42:43 2010 +0300
+++ b/mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepbase.cpp	Fri Jun 11 14:27:06 2010 +0300
@@ -596,36 +596,19 @@
 	    // USB Header validation
 	    if (!ValidateUSBHeaderL())
 		    {
-			// If device has received trash data, flush the rest of the packet and try again.
-  	  	 	// This will occur when cancelling a transfer and the PC sends buffered data after 
-  	  	 	// the cancellation.
-		    TRequestStatus status;
-  	  		do
-				{
-  	  		    //trash data, continue to flush.
-                iReceiveData.Zero();
-                Connection().Ldd().ReadPacket(status, EndpointNumber(), iReceiveData, KUSBHeaderSize);
-                User::WaitForRequest(status);
-                
-                //check the first 12 bytes of next packet to see whether it's an expected USB header
-				iReceiveData.Zero();
-				Connection().Ldd().ReadOneOrMore(status, EndpointNumber(), iReceiveData, KUSBHeaderSize);
-				User::WaitForRequest(status);
+            //trash data, continue to flush.
+            TRequestStatus status;
+            RBuf8 readBuf;
+            readBuf.CreateL(KMaxPacketTypeBulkHS);
+            Connection().Ldd().ReadPacket(status, EndpointNumber(), readBuf, KMaxPacketTypeBulkHS);
+            User::WaitForRequest(status);    
+            RDebug::Print(_L("CMTPUsbEpBase::ProcessFirstReceivedChunkL(), trash data length = %d"), readBuf.Length());
+            readBuf.Close();
+            
+            InitiateFirstChunkReceiveL();  
+            return;
+            
 
-#ifdef __FLOG_ACTIVE				
-			    __FLOG_VA((_L8("Keep looking for headers, length = %d"), iReceiveData.Length()));
-		         for (int i=0; i<3&&(i*4+4)<=iReceiveData.Length(); i++)
-		             {
-		             __FLOG_VA((_L8("0x%x 0x%x 0x%x 0x%x"), iReceiveData[i*4], iReceiveData[i*4+1], iReceiveData[i*4+2], iReceiveData[i*4+3]));            
-		             }
-#endif
-				} while (iReceiveData.Length()==KUSBHeaderSize && !ValidateUSBHeaderL());
-
-			if(!ValidateUSBHeaderL())
-				{ 
-				InitiateFirstChunkReceiveL();  
-				return;
-				}
 			}
 			
 		if ((iDataLength - KUSBHeaderSize) == 0)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/dialup_connection_status_api/dialup_connection_status_api.metaxml	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<api id="9466701ce2cf18b6eb449314db5e9f97" dataversion="2.0">
+  <name>Dial-up Connection Status API</name>
+  <description>provides dial-up connection status info.</description>
+  <type>c++</type>
+  <collection>localconnectivityservice</collection>
+  <libs>
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/dialup_connection_status_api/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                Dial-up Connection Status API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/dundomainpskeys.h     MW_LAYER_PLATFORM_EXPORT_PATH(dundomainpskeys.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/dialup_connection_status_api/group/dialup_connection_status_api.mrp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+component	dialup_connection_status_api
+
+source \sf\mw\remoteconn\localconnectivityservice\dialup_connection_status_api
+
+notes_source	\component_defs\release.src
+
+ipr E 
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/dialup_connection_status_api/inc/dundomainpskeys.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*     DUN Server P&S key definitions
+*
+*/
+
+
+#ifndef DUN_DOMAIN_PS_KEYS_H
+#define DUN_DOMAIN_PS_KEYS_H
+
+/**
+* PubSub Uid of dialup connection status
+*/
+const TUid KPSUidDialupConnStatus = {0x0100387d};  // UID of DUN server
+
+/**
+* Dialup connection status
+*
+* Possible integer values:
+* 0 (EDunUndefined)  Value is not set
+* 1 (EDunInactive)   Dun is inactive  (no listening or active plugins)
+* 2 (EDunActive)     Dun is active    (at least one active plugin)
+*/
+
+const TUint KDialupConnStatus = 0x00000001;
+
+// Enumeration for DUN connection status
+enum TDialupConnStatus
+    {
+    EDialupUndefined,
+    EDialupInactive,
+    EDialupActive
+    };
+
+#endif // DUN_DOMAIN_PS_KEYS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/dun_secondary_display_notification_api/dun_secondary_display_notification_api.metaxml	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<api id="2706bef70ffa514ea5a95b206e904b05" dataversion="2.0">
+  <name>DUN Secondary Display Notification API</name>
+  <description>defines message IDs for showing message on secondary display</description>
+  <type>c++</type>
+  <collection>localconnectivityservice</collection>
+  <libs>
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/dun_secondary_display_notification_api/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to
+*                DUN Secondary Display Notification API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../inc/secondarydisplay/dunsecondarydisplayapi.h    MW_LAYER_PLATFORM_EXPORT_PATH(SecondaryDisplay/dunsecondarydisplayapi.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/dun_secondary_display_notification_api/group/dun_secondary_display_notification_api.mrp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+component	dun_secondary_display_notification_api
+
+source \sf\mw\remoteconn\localconnectivityservice\dun_secondary_display_notification_api
+
+notes_source	\component_defs\release.src
+
+ipr E 
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/dun_secondary_display_notification_api/inc/secondarydisplay/dunsecondarydisplayapi.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Contains dialog index for cover UI.
+*
+*/
+
+
+#ifndef DUNSECONDARYDISPLAYAPI_H
+#define DUNSECONDARYDISPLAYAPI_H
+
+#include <e32std.h>
+
+// Category (dunutils.dll)
+const TUid KDunNoteCategory = { 0x101F6E2A };
+
+enum TSecondaryDisplayDunDialogs
+    {
+    ECmdNone,
+    ECmdMaxNumber
+    };
+
+#endif  // DUNSECONDARYDISPLAYAPI_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/generic_hid_api/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                Generic HID API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/hidcollection.h      MW_LAYER_PLATFORM_EXPORT_PATH(hidcollection.h)
+../inc/hidfield.h           MW_LAYER_PLATFORM_EXPORT_PATH(hidfield.h)
+../inc/hidgeneric.h         MW_LAYER_PLATFORM_EXPORT_PATH(hidgeneric.h)
+../inc/hidinterfaces.h      MW_LAYER_PLATFORM_EXPORT_PATH(hidinterfaces.h)
+../inc/hidreportroot.h      MW_LAYER_PLATFORM_EXPORT_PATH(hidreportroot.h)
+../inc/hidtranslate.h       MW_LAYER_PLATFORM_EXPORT_PATH(hidtranslate.h)
+../inc/hidvalues.h          MW_LAYER_PLATFORM_EXPORT_PATH(hidvalues.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/generic_hid_api/group/generic_hid_api.mrp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+component	generic_hid_api
+
+source \sf\mw\remoteconn\localconnectivityservice\generic_hid_api
+
+notes_source	\component_defs\release.src
+
+ipr E 
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/generic_hid_api/inc/hidcollection.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,272 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declares main application class.
+*
+*/
+
+
+#ifndef C_COLLECTION_H
+#define C_COLLECTION_H
+
+#include <e32std.h>
+
+class CField;
+
+
+/**
+ *  Collection of HID report descriptor
+ *  A CCollection represents an individual collection within a HID
+ *  report descriptor. Each collection may have a number of associated
+ *  report fields (CField objects) and a number of child collection
+ *  objects. The collections within a HID report descriptor form a tree
+ *  structure, with a CReportRoot collection at the root.  The tree is
+ *  generated by CParser.
+ *
+ *
+ *  @lib generichid.lib
+ *  @since S60 v5.0
+ */
+class CCollection : public CBase
+    {
+
+public:
+
+   /**
+    *  An enumerations giving the possible types of collection, as
+    *  given in "USB Device Class Definition for Human Interface
+    *  Devices (HID)", Firmware Specification, Version 1.11, USB
+    *  Implementers' Forum, June 2001.
+    *
+    *  Note that a TUint32 is used for CCollection::iType, as it is
+    *  possible to have a vendor defined collection type that isn't
+    *  included in this list.
+    */
+    enum TType
+        {
+        EPhysical      = 0x00, //!< Physical (group of axes)
+        EApplication   = 0x01, //!< Application (mouse,keyboard)
+        ELogical       = 0x02, //!< Logical (interrelated data)
+        EReport        = 0x03, //!< Report
+        ENamedArray    = 0x04, //!< NamedArray
+        EUsageSwitch   = 0x05, //!< UsageSwitch
+        EUsageModifier = 0x06  //!< UsageModifier
+        };
+
+    static CCollection* NewL();
+    static CCollection* NewLC();
+
+    /**
+    * Destructor.
+    */
+    virtual ~CCollection();
+
+    /**
+     * Get collection type
+     *
+     * @since S60 v5.0
+     * @return The type for this collection item
+     */
+    IMPORT_C TUint32 Type() const;
+
+    /**
+     * Get usagepage
+     *
+     * @since S60 v5.0
+     * @return The usage page for this collection
+     */
+    IMPORT_C TInt UsagePage() const;
+
+    /**
+     * Get usagepage
+     *
+     * @since S60 v5.0
+     * @return The usage page for this collection
+     */
+    IMPORT_C TInt Usage() const;
+
+    /**
+     * Get number of collections
+     *
+     * @since S60 v5.0
+     * @return The number of collections that have been created so far
+     */
+    IMPORT_C TInt CollectionCount() const;
+
+    /**
+     * Gets numbers of field stored in collection
+     *
+     * @since S60 v5.0
+     * @return The number of fields stored in for the current collection
+     */
+    IMPORT_C TInt FieldCount() const;
+
+    /**
+     * Returns a pointer to a specific collection from the list of collections
+     *
+     * @since S60 v5.0
+     * @param aIndex The index of the required collection
+     * @return The number of fields stored in for the current collection.
+     *         NULL if there are no collection object at the secified index
+     */
+    IMPORT_C const CCollection* CollectionByIndex(TInt aIndex) const;
+
+    /**
+     * Returns a pointer to the field object at the given index within the field
+     * list
+     *
+     * @since S60 v5.0
+     * @param aIndex The offset within the current field list
+     * @return A pointer to the specified field object
+     *         NULL if there is no field object at the specified index
+     */
+    IMPORT_C const CField* FieldByIndex(TInt aIndex) const;
+
+    /**
+     * Check if collection type is physical
+     *
+     * @since S60 v5.0
+     * @return true if physical
+     */
+    IMPORT_C TBool IsPhysical() const;
+
+    /**
+     * Check if collection type is application
+     *
+     * @since S60 v5.0
+     * @return true if application
+     */
+    IMPORT_C TBool IsApplication() const;
+
+    /**
+     * Check if collection type is logical
+     *
+     * @since S60 v5.0
+     * @return true if logical
+     */
+    IMPORT_C TBool IsLogical() const;
+
+    /**
+     * Check if collection type is report
+     *
+     * @since S60 v5.0
+     * @return true if report
+     */
+    IMPORT_C TBool IsReport() const;
+
+    /**
+     * Check if collection type is name array
+     *
+     * @since S60 v5.0
+     * @return true if named array
+     */
+    IMPORT_C TBool IsNamedArray() const;
+
+    /**
+     * Check if collection type is usage switch
+     *
+     * @since S60 v5.0
+     * @return true if is usage switch
+     */
+    IMPORT_C TBool IsUsageSwitch() const;
+
+    /**
+     * Check if collection type is usage modifier
+     *
+     * @since S60 v5.0
+     * @return true if usage modifier
+     */
+    IMPORT_C TBool IsUsageModifier() const;
+
+public:
+
+    /**
+     * Set Collection type
+     *
+     * @since S60 v5.0
+     * @return None
+     */
+    void SetType(TUint32 aType);
+
+    /**
+     * Set usage page
+     *
+     * @since S60 v5.0
+     * @return None
+     */
+    void SetUsagePage(TInt aUsagePage);
+
+    /**
+     * Set usage
+     *
+     * @since S60 v5.0
+     * @return None
+     */
+    void SetUsage(TInt aUsage);
+
+    /**
+     * Called when a new collection object has been encountered in
+     * the report descriptor.  This creates a new CCollection object
+     * and adds it to the current list
+     *
+     * @since S60 v5.0
+     * @return None
+     */
+    CCollection* AddCollectionL();
+
+    /**
+     * Called when a new field object has been encountered in the
+     * report descriptor.  This creates a new field object and adds it
+     * the the current list
+     *
+     * @since S60 v5.0
+     * @return A pointer to the new field object
+     */
+    CField* AddFieldL();
+
+protected:
+
+    CCollection();
+    void ConstructL();
+
+private:
+
+    /**
+     * Collection type
+     */
+    TUint32 iType;
+
+    /**
+     * Usage page
+     */
+    TInt iUsagePage;
+
+    /**
+     * Usage
+     */
+    TInt iUsage;
+
+    /**
+     * List of collections for the report descriptor
+     */
+    RPointerArray<CCollection> iCollections;
+
+    /**
+     * List of fields in the current collection
+     */
+    RPointerArray<CField> iFields;
+
+    };
+
+#endif //  C_COLLECTION_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/generic_hid_api/inc/hidfield.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,732 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  HID field descriptor definition
+*
+*/
+
+#ifndef C_FIELD_H
+#define C_FIELD_H
+
+
+#include <e32base.h>
+
+
+const TInt   KFieldAttributeConstant      = 1<<0;  //!< Data (0) or Constant (1)
+const TInt   KFieldAttributeVariable      = 1<<1;  //!< Array (0) or Variable (1)
+const TInt   KFieldAttributeRelative      = 1<<2;  //!< Absolute (0) or Relative (1)
+const TInt   KFieldAttributeWrap          = 1<<3;  //!< No wrap (0) or Wrap (1)
+const TInt   KFieldAttributeNonLinear     = 1<<4;  //!< Linear (0) or Non-linear (1)
+const TInt   KFieldAttributeNoPreferred   = 1<<5;  //!< Preferred state (0) or not (1)
+const TInt   KFieldAttributeNullState     = 1<<6;  //!< No null position (0) or null state (1)
+const TInt   KFieldAttributeVolatile      = 1<<7;  //!< Non-volatile (0) or volatile (1)
+const TInt   KFieldAttributeBufferedBytes = 1<<8;  //!< Bit field (0) or buffered bytes (1)
+    
+const TInt KSizeOfByte      = 8;
+/**
+ *  HID report field presentation
+ *  Represents an individual field in a HID report, ie. the attributes
+ *  of an input, output or feature Main item defined in the HID report
+ *  descriptor.
+ *
+ *  The CField contains information such as the usage IDs sent in the
+ *  the report, the type of the report (input, output or feature) and
+ *  the logical range.
+ *
+ *
+ *  @lib generichid.lib
+ *  @since S60 v5.0
+ */
+class CField : public CBase
+  {
+public:
+    enum TType
+        {
+        EInput,    //!< Input report
+        EOutput,   //!< Output report
+        EFeature   //!< Feature report
+        };
+
+    
+
+public:
+  static CField* NewL();
+  static CField* NewLC();
+
+  /**
+   * Destructor.
+   */
+  virtual ~CField();
+
+public:
+  // Accessors:
+
+  /**
+   * Set Report root
+   *
+   * @since S60 v5.0
+   * @return None
+   */
+  IMPORT_C TInt UsagePage() const;
+
+  /**
+   * Return report id
+   *
+   * @since S60 v5.0
+   * @return report id
+   */
+  IMPORT_C TInt ReportId() const;
+
+  /**
+   * Return offset
+   *
+   * @since S60 v5.0
+   * @return offset
+   */
+  IMPORT_C TInt Offset() const;
+
+  /**
+   * Return size
+   *
+   * @since S60 v5.0   
+   * @return None
+   */
+  IMPORT_C TInt Size() const;
+
+  /**
+   * Return count
+   *
+   * @since S60 v5.0
+   * @return count
+   */
+  IMPORT_C TInt Count() const;
+
+  /**
+   * Return logical minimium
+   *
+   * @since S60 v5.0
+   * @return Logical minimium
+   */
+  IMPORT_C TInt LogicalMin() const;
+
+  /**
+   * Return logical maximum
+   *
+   * @since S60 v5.0   
+   * @return logical maximum
+   */
+  IMPORT_C TInt LogicalMax() const;
+
+  /**
+   * Return usage min
+   *
+   * @since S60 v5.0
+   * @return None
+   */
+  IMPORT_C TInt UsageMin() const;
+
+  /**
+   * Return usage max
+   *
+   * @since S60 v5.0   
+   * @return usage max
+   */
+  IMPORT_C TInt UsageMax() const;
+
+  /**
+   * Return Physical minimum
+   *
+   * @since S60 v5.0
+   * @return physical minimum
+   */
+  IMPORT_C TInt PhysicalMin() const;
+
+  /**
+   * Return Physical max
+   *
+   * @since S60 v5.0
+   * @return return physical max
+   */
+  IMPORT_C TInt PhysicalMax() const;
+
+  /**
+   * Return unit
+   *
+   * @since S60 v5.0
+   * @return Unit
+   */
+  IMPORT_C TInt Unit() const;
+
+  /**
+   * Return unit exponent
+   *
+   * @since S60 v5.0
+   * @return unit exponent
+   */
+  IMPORT_C TInt UnitExponent() const;
+
+  /**
+   * Return Designator index
+   *
+   * @since S60 v5.0
+   * @return Designator Index
+   */
+  IMPORT_C TInt DesignatorIndex() const;
+
+  /**
+   * Return designator minimium
+   *
+   * @since S60 v5.0
+   * @return return designator index minimium
+   */
+  IMPORT_C TInt DesignatorMin() const;
+
+  /**
+   * Return designator maximium
+   *
+   * @since S60 v5.0
+   * @return designator maximium
+   */
+  IMPORT_C TInt DesignatorMax() const;
+
+  /**
+   * Return string minimum
+   *
+   * @since S60 v5.0
+   * @return None
+   */
+  IMPORT_C TInt StringMin() const;
+
+  /**
+   * Return string maximum
+   *
+   * @since S60 v5.0
+   * @return string maximum
+   */
+  IMPORT_C TInt StringMax() const;
+
+  /**
+   * Return string index
+   *
+   * @since S60 v5.0
+   * @return string index
+   */
+  IMPORT_C TInt StringIndex() const;
+
+  /**
+   * Return attributes
+   *
+   * @since S60 v5.0
+   * @return attributes
+   */
+  IMPORT_C TUint32 Attributes() const;
+
+  /**
+   * Return type
+   *
+   * @since S60 v5.0
+   * @return type
+   */
+  IMPORT_C TType Type() const;
+
+  /**
+   * Return variable status
+   *
+   * @since S60 v5.0
+   * @return variable status
+   */
+  IMPORT_C TBool IsVariable() const;
+
+  /**
+   * Return array status
+   *
+   * @since S60 v5.0
+   * @return arrau status
+   */
+  IMPORT_C TBool IsArray() const;
+
+  /**
+   * Return data status
+   *
+   * @since S60 v5.0
+   * @return data status
+   */
+  IMPORT_C TBool IsData() const;
+
+  /**
+   * Return constant status
+   *
+   * @since S60 v5.0
+   * @return constant status
+   */
+  IMPORT_C TBool IsConstant() const;
+
+  /**
+   * Return input status
+   *
+   * @since S60 v5.0
+   * @return input status
+   */
+  IMPORT_C TBool IsInput() const;
+
+  /**
+   * Return output status
+   *
+   * @since S60 v5.0
+   * @return None
+   */
+  IMPORT_C TBool IsOutput() const;
+
+  /**
+   * Return feature status
+   *
+   * @since S60 v5.0
+   * @return feature status
+   */
+  IMPORT_C TBool IsFeature() const;
+
+  /**
+   * Check if reportid is in report
+   *
+   * @since S60 v5.0
+   * @param aReportId report id
+   * @return true if reportid is in report
+   */
+  IMPORT_C TBool IsInReport(TInt aReportId) const;
+
+  /**
+   * Check if usage exsist
+   *
+   * @since S60 v5.0
+   * @param aUsage Usage id
+   * @return None
+   */
+  IMPORT_C TBool HasUsage(TInt aUsage) const;
+
+  /**
+   * Return usage array
+   *
+   * @since S60 v5.0
+   * @return usage array
+   */
+  IMPORT_C TArray<TInt> UsageArray() const;
+
+  /**
+   * Return usage
+   *
+   * @since S60 v5.0
+   * @param aIndex usage array index
+   * @return usage
+   */
+  IMPORT_C TInt Usage(TInt aIndex) const;
+
+  /**
+   * Return usage count
+   *
+   * @since S60 v5.0
+   * @return usage count
+   */
+  IMPORT_C TInt UsageCount() const;
+
+  /**
+   * Return last usage
+   *
+   * @since S60 v5.0
+   * @return last usage
+   */
+  IMPORT_C TInt LastUsage() const;
+
+  /**
+   * Set type
+   *
+   * @since S60 v5.0
+   * @param aType type of field
+   * @return None
+   */
+  IMPORT_C void SetType(const TType& aType);
+
+  /**
+   * Add usage
+   *
+   * @since S60 v5.0
+   * @param aUsage usage to be added
+   * @return None
+   */
+  IMPORT_C void AddUsageL(TInt aUsage);
+
+  /**
+   * Clear usage list
+   *
+   * @since S60 v5.0
+   * @return None
+   */
+  IMPORT_C void ClearUsageList();
+
+  /**
+   * Set usage page
+   *
+   * @since S60 v5.0
+   * @param aUsagePage usagepage to be set
+   * @return None
+   */
+  IMPORT_C void SetUsagePage(TInt aUsagePage);
+
+  /**
+   * Set offset
+   *
+   * @since S60 v5.0
+   * @param aOffset offset to be set
+   * @return None
+   */
+  IMPORT_C void SetOffset(TInt aOffset);
+
+  /**
+   * Set size
+   *
+   * @since S60 v5.0
+   * @param aSize size to be set
+   * @return None
+   */
+  IMPORT_C void SetSize(TInt aSize);
+
+  /**
+   * Set count
+   *
+   * @since S60 v5.0
+   * @param aCount Count to be set
+   * @return None
+   */
+  IMPORT_C void SetCount(TInt aCount);
+
+  /**
+   * Set logical minimium
+   *
+   * @since S60 v5.0
+   * @param aMin Logical minimium to be set
+   * @return None
+   */
+  IMPORT_C void SetLogicalMin(TInt aMin);
+
+  /**
+   * Set logical maximum
+   *
+   * @since S60 v5.0
+   * @param aMax logical maximum to be used
+   * @return None
+   */
+  IMPORT_C void SetLogicalMax(TInt aMax);
+
+  /**
+   * Set usage min
+   *
+   * @since S60 v5.0
+   * @param aMin  usage minimium to be set.
+   * @return None
+   */
+  IMPORT_C void SetUsageMin(TInt aMin);
+
+  /**
+   * Set usage maximum
+   *
+   * @since S60 v5.0
+   * @param aMax usage max to be set
+   * @return None
+   */
+  IMPORT_C void SetUsageMax(TInt aMax);
+
+  /**
+   * Set Report ID
+   *
+   * @since S60 v5.0
+   * @param aReportId report id to be set
+   * @return None
+   */
+  IMPORT_C void SetReportId(TInt aReportId);
+
+  /**
+   * Set attributes
+   *
+   * @since S60 v5.0
+   * @param aAttributes attributes to be set
+   * @return None
+   */
+  IMPORT_C void SetAttributes(TUint32 aAttributes);
+
+  /**
+   * Set physical minimium
+   *
+   * @since S60 v5.0
+   * @param aValue physical minimium value
+   * @return None
+   */
+  IMPORT_C void SetPhysicalMin(TInt aValue);
+
+  /**
+   * Set Physical maximum
+   *
+   * @since S60 v5.0
+   * @param aValue physical maximum value
+   * @return None
+   */
+  IMPORT_C void SetPhysicalMax(TInt aValue);
+
+  /**
+   * Set unit value
+   *
+   * @since S60 v5.0
+   * @param aValue unit value
+   * @return None
+   */
+  IMPORT_C void SetUnit(TInt aValue);
+
+  /**
+   * Set unit exponent
+   *
+   * @since S60 v5.0
+   * @param aValue unit exponent valut to be set
+   * @return None
+   */
+  IMPORT_C void SetUnitExponent(TInt aValue);
+
+  /**
+   * Set Designator index
+   *
+   * @since S60 v5.0
+   * @param aValue Designator index value
+   * @return None
+   */
+  IMPORT_C void SetDesignatorIndex(TInt aValue);
+
+  /**
+   * Set designator minimium
+   *
+   * @since S60 v5.0
+   * @param aValue designator minimum value
+   * @return None
+   */
+  IMPORT_C void SetDesignatorMin(TInt aValue);
+
+  /**
+   * Set designator maximium value
+   *
+   * @since S60 v5.0
+   * @param aValue designator maximium value
+   * @return None
+   */
+  IMPORT_C void SetDesignatorMax(TInt aValue);
+
+  /**
+   * Set string minimium value
+   *
+   * @since S60 v5.0
+   * @param aValue string minimium value
+   * @return None
+   */
+  IMPORT_C void SetStringMin(TInt aValue);
+
+  /**
+   * Set string maximum value
+   *
+   * @since S60 v5.0
+   * @param aValue string maximum value to be set
+   * @return None
+   */
+  IMPORT_C void SetStringMax(TInt aValue);
+
+  /**
+   * Set string index
+   *
+   * @since S60 v5.0
+   * @param aValue string index
+   * @return None
+   */
+  IMPORT_C void SetStringIndex(TInt aValue);
+
+  /**
+   * Set Logical range
+   *
+   * @since S60 v5.0
+   * @param aMin logical range minimium value
+   * @param aMax logical range maximum value
+   * @return None
+   */
+  IMPORT_C void SetLogicalRange(TInt aMin, TInt aMax);
+
+  /**
+   * Set Usage range
+   *
+   * @since S60 v5.0
+   * @param aMin usage range minimium value
+   * @param aMax usage range maximum value
+   * @return None
+   */
+  IMPORT_C void SetUsageRange(TInt aMin, TInt aMax);
+
+  /**
+   * Set Physical range
+   *
+   * @since S60 v5.0
+   * @param aMin physical range minimium value
+   * @param aMax physical range maximum value
+   * @return None
+   */
+  IMPORT_C void SetPhysicalRange(TInt aMin, TInt aMax);
+
+  /**
+   * Set string range
+   *
+   * @since S60 v5.0
+   * @param aMin string range minimium value
+   * @param aMax string range maximum value
+   * @return None
+   */
+  IMPORT_C void SetStringRange(TInt aMin, TInt aMax);
+
+  /**
+   * Set designator range
+   *
+   * @since S60 v5.0
+   * @param aMin designator range minimium value
+   * @param aMax designator range maximum value
+   * @return None
+   */
+  IMPORT_C void SetDesignatorRange(TInt aMin, TInt aMax);
+
+private:
+  CField();
+
+  
+
+private:
+
+  /**
+   * Input, output or feature report
+   */
+  TType iType;
+
+  // For a detailed description of the use of the following members,
+  // see "USB Device Class Definition for Human Interface Devices
+  // (HID)", Firmware Specification, Version 1.11, USB Implementers'
+  // Forum, June 2001.
+
+  /**
+   * The usage page this field is associated with (G)
+   */
+  TInt iUsagePage;
+
+  /**
+   * ID for the HID report containing this field (G)
+   */
+  TInt iReportId;
+
+  /**
+   * Field offset (in bits) from start of report
+   */
+  TInt iPos;
+
+  /**
+   * Bit size of each item in the current field (G)
+   */
+  TInt iSize;
+
+  /**
+   * Number of items in the report field (G)
+   */
+  TInt iCount;
+
+  /**
+   * Minimum extent value in logical units (G)
+   */
+  TInt iLogicalMin;
+
+  /**
+   * Maximum extent value in logical units (G)
+   */
+  TInt iLogicalMax;
+
+  /**
+   * Starting usage associated with array / bitmap (L)
+   */
+  TInt iUsageMin;
+
+  /**
+   * Ending usage associated with array / bitmap (L)L)
+   */
+  TInt iUsageMax;
+
+  /**
+   * Unit value (G)
+   */
+  TInt iUnit;
+
+  /**
+   * Value of the unit exponent in base 10 (G)
+   */
+  TInt iUnitExponent;
+
+  /**
+   * Body part used for a control (L)
+   */
+  TInt iDesignatorIndex;
+
+  /**
+   * String associated with a control (L)
+   */
+  TInt iStringIndex;
+
+  /**
+   * Minimum physical extent for a variable item (G)
+   */
+  TInt iPhysicalMin;
+
+  /**
+   * Maximum physical extent for a variable item (G)
+   */
+  TInt iPhysicalMax;
+
+  /**
+   * First string index for a group of strings (L)
+   */
+  TInt iStringMin;
+
+  /**
+   * Last string index for a group of strings (L)
+   */
+  TInt iStringMax;
+
+  /**
+   * Starting designator index (L)
+   */
+  TInt iDesignatorMin;
+
+  /**
+   * Ending designator index (L)
+   */
+  TInt iDesignatorMax;
+
+  /**
+   * Flags associated with a main item (e.g. "array")
+   */
+  TUint32 iAttributes;
+
+  /**
+   * The usage indexes associated with this field (G)
+   */
+  RArray<TInt> iUsageList;
+
+  // (G) = Global item
+  // (L) = Local item
+  };
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/generic_hid_api/inc/hidgeneric.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,339 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declares main application class.
+*
+*/
+
+
+#ifndef C_GENERICHID_H
+#define C_GENERICHID_H
+
+#include <hidinterfaces.h>
+
+class CDriverListItem;
+class TElement;
+class CParser;
+class CReportRoot;
+class CConnectionInfo;
+
+/**
+ *
+ *  Generic HID main class
+ *  Generic HID layer, allowing the HID Transport layers and device drivers to
+ *  pass data to the Generic HID
+ *
+ *  @lib generichid.lib
+ *  @since S60 v5.0
+ */
+class CGenericHid : public CHidTransport, public MDriverAccess
+    {
+public:
+    virtual ~CGenericHid();
+
+    /**
+     * Constructs a generic HID layer with a reference to the owner so commands can
+     * be sent to connected devices
+     *
+     * @since S60 v5.0
+     * @param aTransportLayer The owning transport layer
+     * @return a Pointer to an instantiated Generic HID layer
+     */
+    IMPORT_C static CGenericHid* NewL(MTransportLayer* aTransportLayer);
+
+    /**
+     * Constructs a generic HID layer with a reference to the owner so commands can
+     * be sent to connected devices
+     *
+     * @since S60 v5.0
+     * @param aTransportLayer The owning transport layer
+     * @return a Pointer to an instantiated Generic HID layer
+     */
+    IMPORT_C static CGenericHid* NewLC(MTransportLayer* aTransportLayer);
+
+    /**
+     * Fromm class MDriverAccess
+     * Retrieves the country code for the HID device
+     *
+     * @since S60 v5.0
+     * @param aConnectionID The device identifier
+     * @return  a country code
+     */
+    TUint CountryCodeL(TInt aConnectionID);
+
+    /**
+     * Fromm class MDriverAccess
+     * Retrieves the country code for the HID device
+     *
+     * @since S60 v5.0
+     * @param aConnectionId The device identifier
+     * @return a vendor ir
+     */
+    TUint VendorIdL(TInt aConnectionId);
+
+    /**
+     * Fromm class MDriverAccess
+     * Retrieves the product identifier for the HID device
+     *
+     * @since S60 v5.0
+     * @param aConnectionId The device identifier
+     * @return  a prodcut id
+     */
+    TUint ProductIdL(TInt aConnectionId);
+
+
+    /**
+     * Fromm class MDriverAccess
+     * Sets the protocol to be used for reports. 
+     * Leaves KErrInUse The request was not successful because the
+     * transport layer is busy with a previous request,
+     * KErrNotReady The request failed because the device
+     * is currently unavailable and KErrNotFound The request
+     * was unsuccessful
+     *
+     * @since S60 v5.0
+     * @param aConnectionId The device identifier
+     * @param aInterface The device interface being used by the driver
+     * @param aProtocol The requested report protocol (boot or report)
+     * @parem aDriver Calling driver
+     * @return  None.
+     */
+    void SetProtocolL(TInt aConnectionId, TUint16 aInterface,
+        MDriverAccess::TProtocols aProtocol, CHidDriver* aDriver);
+
+
+    /**
+     * Fromm class MDriverAccess
+     * Requests the current protocol from the HID device.  This is an asynchronous
+     * request. The protocol value will come through at a later time
+     *
+     * @since S60 v5.0
+     * @param aConnectionId The device identifier
+     * @param aInterface The hid interface
+     * @return None. 
+     */
+    void GetProtocolL(TInt aConnectionId,  TUint16 aInterface);
+
+    /**
+     * Fromm class MDriverAccess
+     * A request for a report from the device.  This is an asynchronous request.
+     * The report will come through at a later time
+     *
+     * @since S60 v5.0
+     * @param aConnectionId The device identifier
+     * @param aReportId report id to be get
+     * @param aInterface The device interface being used by the driver
+     * @param aLength report lenght
+     * @return  None.
+     */
+    void GetReportL(TInt aConnectionId, TUint8 aReportId,
+        TUint16 aInterface, TUint16 aLength);
+
+    /**
+     * Fromm class MDriverAccess
+     * A request to send a report payload to the HID device
+     * Leaves whit KErrInUse The request was not successful because the transport 
+     * layer is busy with previous request and KErrNotReady The request failed 
+     * because the device is currently unavailable
+     *
+     * @since S60 v5.0
+     * @param aConnectionId The device ID
+     * @param aReportId The report id
+     * @param aReportType Type of report (input/output/feature)
+     * @param aPayload The report containing the device setup packet
+     * @param aInterface The device interface being used by the driver
+     * @parem aDriver Calling driver
+     * @return None.
+     */
+    void SetReportL(TInt aConnectionId,
+        TUint8 aReportId, MDriverAccess::TReportType aReportType,
+        const TDesC8& aPayload, TUint16 aInterface, CHidDriver* aDriver);
+
+    /**
+     * Fromm class MDriverAccess
+     * A request to send a report payload to the HID device in Interrupt Channel
+     * Leaves whit KErrInUse The request was not successful because the transport 
+     * layer is busy with previous request and KErrNotReady The request failed 
+     * because the device is currently unavailable
+     *
+     * @since S60 v5.0
+     * @param aConnectionId The device ID
+     * @param aReportId report id which payload to be send
+     * @param aPayload The report containing the device setup packet
+     * @param aInterface The device interface being used by the driver
+     * @return  None.
+     */
+    void DataOutL(TInt aConnectionId,  TUint8 aReportId,
+                              const TDesC8& aPayload, TUint16 aInterface);
+
+    /**
+     * Fromm class MDriverAccess
+     * Request for the current idle setting for the device
+     * This is an asynchronous request.  The idle value will come through at a
+     * later time. Leaves whit KErrInUse The request was not successful because the transport 
+     * layer is busy with previous request and KErrNotReady The request failed 
+     * because the device is currently unavailable
+     *
+     * @since S60 v5.0
+     * @param aConnectionId The device identifier
+     * @param aReportId The report ID for which we want the idle rate
+     * @param aInterface The device interface being used by the driver
+     * @return None.
+     */
+    void GetIdleL(TInt aConnectionId, TUint8 aReportId, TUint16 aInterface);
+
+    /**
+     * Fromm class MDriverAccess
+     * Request to the HID device to set the specified idle rate
+     * A request to send a report payload to the HID device
+     * Leaves whit KErrInUse The request was not successful because the transport 
+     * layer is busy with previous request and KErrNotReady The request failed 
+     * because the device is currently unavailable
+     *
+     * @since S60 v5.0
+     * @param aConnectionId The device ID
+     * @param aDuration The number of 0.04ms intervals to wait between reports
+     * @param aReportId The report for which the idle rate is being set
+     * @param aInterface The device interface being used by the driver
+     * @parem aDriver Calling driver
+     * @return None.
+     */
+    void SetIdleL(TInt aConnectionId, TUint8 aDuration,
+        TUint8 aReportId, TUint16 aInterface, CHidDriver* aDriver);
+
+    /**
+     * From class CHidTransport
+     * Called by the transport layers to inform the generic HID of the success of
+     * the last Set... command.
+     *
+     * @since S60 v5.0
+     * @param aConnectionId The device ID
+     * @param aCmdAck Status of the last Set... command
+     * @return None.
+     */
+    void CommandResult(TInt aConnectionId, TInt aCmdAck);
+
+    /**
+     * From class MDriverAccess
+     * Gives the device driver access to the results of the report
+     * descriptor parsing
+     *
+     * @since S60 v5.0
+     * @param aConnectionId The device ID
+     * @return A pointer to the parsed descriptor object.
+     */
+    CReportRoot* ReportDescriptor(TInt aConnectionId);
+
+    /**
+     * From class CHidTransport
+     * Called by a transport layer when a device has connected and the report
+     * descriptors have been obtained
+     *
+     * @since S60 v5.0
+     * @param aConnectionId The tansport-layer enumeration for the connection
+     * @param aDescriptor The report descriptor for the connected HID device
+     * @return KErrNone if a driver was found, otherwise an error code
+     */
+    TInt ConnectedL(TInt aConnectionId, const TDesC8& aDescriptor);
+
+    /**
+     * From class CHidTransport
+     * Called by a transport layer when a device has been disconnected
+     *
+     * @since S60 v5.0
+     * @param aConnectionId The tansport-layer enumeration for the connection
+     * @return KErrNone if a driver was found, otherwise an error code
+     */
+    TInt Disconnected(TInt aConnectionId);
+
+    /**
+     * From class CHidTransport
+     * Called by the transport layer when a device has sent a report on the
+     * interrupt or control channel
+     *
+     * @since S60 v5.0
+     * @param aConnectionId The tansport-layer enumeration for the connection
+     * @param aChannel Channel ID (Interrupt or Control)
+     * @param aPayload The complete report payload
+     * @return KErrNone if the data was handled by the driver, otherwise an error code
+     */
+    virtual TInt DataIn(TInt aConnectionId,
+        CHidTransport::THidChannelType aChannel, const TDesC8& aPayload);
+
+    /**
+     * From class CHidTransport
+     * Called by the transport layer to suspend or resume a driver
+     *
+     * @since S60 v5.0
+     * @param aConnectionId The tansport-layer enumeration for the connection
+     * @param aActive EActive to start the driver(s), ESuspend to suspend
+     * @return KErrNone if the driver was successfully activated, otherwise an error code
+     */
+    TInt DriverActive(TInt aConnectionId,
+        CHidTransport::TDriverState aActive);
+
+protected:
+    CGenericHid(MTransportLayer* aTransportLayer);
+    void ConstructL();
+
+private:
+
+    /**
+     * Remove drivers
+     *
+     * @since S60 v5.0
+     * @return None
+     */
+    void RemoveDrivers();
+              
+    /**
+     * Attempts to find a driver that is handling reports from the HID device
+     *
+     * @since S60 v5.0
+     * @return Connection information
+     */
+    CConnectionInfo* SeekConnectionInfo(TInt aConnectionId);
+
+private:
+
+    /**
+     * Instantiated driver list
+     */
+    TSglQue<CDriverListItem> iDriverList;
+
+    /**
+     * Parser
+     * Own.
+     */
+    CParser* iParser;
+
+    /**
+     * Parser
+     * Not own.
+     */
+    MTransportLayer* iTransportLayer;
+    
+    /**
+     * Connection information
+     */
+    RPointerArray<CConnectionInfo> iConnectionInfo;
+    
+    /**
+     * Input data handling registry 
+     * Own.
+     */
+    CHidInputDataHandlingReg* iInputHandlingReg;
+    
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/generic_hid_api/inc/hidinterfaces.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,704 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declares main application class.
+*
+*/
+
+
+
+#ifndef C_HIDDRIVER_H
+#define C_HIDDRIVER_H
+
+#include <ecom/ecom.h>
+
+
+class CReportRoot;
+class MDriverAccess;
+class MTransportLayer;
+class CHidDriver;
+// ----------------------------------------------------------------------
+
+// Return codes from the Generic HID to Transport layers
+//
+const TInt KErrHidBase = -8000;
+
+const TInt KErrHidNoDriver = KErrHidBase;           /*!< No driver could be found to handle the request */
+const TInt KErrHidSuspended = KErrHidBase - 1;      /*!< Command not handled - driver is suspended */
+const TInt KErrHidUnrecognised = KErrHidBase - 2;   /*!< Driver could not understand the data */
+const TInt KErrHidUnexpected = KErrHidBase - 3;     /*!< Unsolicited data from the device */
+const TInt KErrHidBadChannel = KErrHidBase - 4;     /*!< Channel was not Int or Ctrl type */
+const TInt KErrHidPartialSupported = KErrHidBase - 5;     /*!< Partil supported hid device */
+
+// Errors returned by the report translator / generator:
+//
+const TInt KErrUsageNotFound = KErrHidBase - 10;    //!< Usage page/ID wasn't found in the field
+const TInt KErrValueOutOfRange = KErrHidBase - 11;  //!< Value specified is outside the logical range
+const TInt KErrNoSpaceInArray = KErrHidBase - 12;   //!< Array field already contains the maximum number of values
+const TInt KErrBadControlIndex = KErrHidBase - 13;  //!< Control index exceeds the number of controls in the field
+
+// ACK codes returned by Set/Get requests to the devices
+//
+const TInt KErrCommandAckBase = -8100;
+
+const TInt KErrAckInvalidReportID = KErrCommandAckBase;         /*!< Invalid report ID */
+const TInt KErrAckInvalidParameter = KErrCommandAckBase - 1;    /*!< Invalid or out of range param */
+const TInt KErrAckUnknown = KErrCommandAckBase - 2;             /*!< Command failed, but the device can't determine why */
+const TInt KErrAckFatal = KErrCommandAckBase - 3;               /*!< The device is in an unrecoverable state and must be restarted */
+
+// Constant for plugin interface:
+const TUid KHidDriverPluginInterfaceUid        = { 0x10201d26 };
+
+
+class THidEvent
+    {
+    public:
+    /**
+     * Usage page
+     */
+    TInt iUsagePage;
+    
+    /**
+     * Keycode
+     */
+    TInt iKeyCode;
+    };
+
+class CHidInputDataHandlingReg: public CBase
+    {
+       
+public:
+    /**
+     * Two-phased constructor.     
+     */
+    static CHidInputDataHandlingReg* NewL();
+
+    /**
+     * Destructor
+     */
+     virtual ~CHidInputDataHandlingReg(); 
+
+public:        
+        
+    /**
+     * Check if key event is not allready processed
+     *
+     * @since S60 v5.0
+     * @param aUsagePage a usage page to be checked
+     * @param aUsage a usage code to be checked
+     * @return true if event is not allready handled
+     */
+    IMPORT_C TBool  AllowedToHandleEvent(TInt aUsagePage, TInt aUsage);
+    
+    
+    /**
+     * Add handled event
+     *
+     * @since S60 v5.0
+     * @param aUsagePage usage page to be handled
+     * @param aUsage Usage to be handled
+     * @return None.
+     */ 
+    IMPORT_C void  AddHandledEvent( TInt aUsagePage, TInt aUsage);
+    
+    /**
+     * Reset Array 
+     */
+    void  Reset();
+    
+private:
+    
+    CHidInputDataHandlingReg();
+    void ConstructL();
+
+private: 
+    
+    /**
+     * Event array
+     * Own.
+     */
+    CArrayFixFlat<THidEvent>* iEventArray;
+    
+    };
+
+/**
+ *
+ *  Transport layer interface class
+ *  Interface allowing the generic HID layer to pass data to a Transport layer
+ *  All commands are asynchronous.  The results are returned via the
+ *
+ *  @since S60 v5.0
+ */
+class MTransportLayer
+    {
+public:
+
+    /**
+     * Request for the country code of the given device.
+     *
+     * @since S60 v5.0
+     * @param aConnID The device identifier
+     * @return country code.
+     */
+    virtual TUint CountryCodeL(TInt aConnID) = 0;
+
+    /**
+     * Request for the vendor identifier for the given device.
+     *
+     * @since S60 v5.0
+     * @param aConnID The device identifier
+     * @return vendor id.
+     */
+    virtual TUint VendorIdL(TInt aConnID) = 0;
+
+    /**
+     * Request for the product identifier for the given device.
+     *
+     * @since S60 v5.0
+     * @param aConnID The device identifier
+     * @return product id.
+     */
+    virtual TUint ProductIdL(TInt aConnID) = 0;
+
+    /**
+     * Request for the current device report protocol. The protocol will be
+     * received as a control report via the CHidTransport::DataIn function
+     *
+     * @since S60 v5.0
+     * @param aConnID The device identifier
+     * @param aInterface The interface we want to get the protocol from
+     * @return None.
+     */
+    virtual void GetProtocolL(TInt aConnID,  TUint16 aInterface) = 0;
+
+    /**
+     * Request to put the device in the specified protocol
+     *
+     * @since S60 v5.0
+     * @param aConnID The device identifier
+     * @param aValue The requested protocol for the device (boot or report)
+     * @param aInterface The interface we want to set the protocol for
+     * @return None.
+     */
+    virtual void SetProtocolL(TInt aConnID, TUint16 aValue,
+        TUint16 aInterface) = 0;
+
+    /**
+     * Request for a device report. The data will be received as a control report
+     * via the CHidTransport::DataIn function
+     *
+     * @since S60 v5.0
+     * @param aConnID The device identifier
+     * @param aReportType The type of report (input/output/feature) requested
+     * @param aReportID The specific report required
+     * @param aInterface The interface we want the report from
+     * @param aLength The expected length of the report buffer
+     * @return None.
+     */
+    virtual void GetReportL(TInt aConnID, TUint8 aReportType,TUint8 aReportID,
+        TUint16 aInterface, TUint16 aLength) = 0;
+
+    /**
+     * Request to send a report to a device. The response will be reported via the
+     * CHidTransport::CommandResult function
+     *
+     * @since S60 v5.0
+     * @param aConnID The device identifier
+     * @param aReportType The type of report (input/output/feature) requested
+     * @param aReportID The specific report required to set
+     * @param aInterface The interface we want to send the report to
+     * @param aReport The report payload to be sent to the device
+     * @return None.
+     */
+    virtual void SetReportL(TInt aConnID, TUint8 aReportType,TUint8 aReportID,
+        TUint16 aInterface, const TDesC8& aReport) = 0;
+
+    /**
+     * Request to send data to a device. There are no responses to this report from device.
+     *
+     * @since S60 v5.0
+     * @param aConnID The device identifier
+     * @param aReportID The specific report required
+     * @param aInterface The interface we want to send the report to
+     * @param aReport The report payload to be sent to the device
+     * @return None.
+     */
+    virtual void DataOutL(TInt aConnID, TUint8 aReportID,
+        TUint16 aInterface, const TDesC8& aReport) = 0;
+
+    /**
+     * Request for the current idle rate of a report from the device. The response
+     * will be recevied via the CHidTransport::DataIn function
+     *
+     * @since S60 v5.0
+     * @param aConnID The device identifier
+     * @param aReportID The specific report to be queried
+     * @param aInterface The interface we want to query for idle rate
+     * @return None.
+     */
+    virtual void GetIdleL(TInt aConnID, TUint8 aReportID,
+        TUint16 aInterface) = 0;
+
+    /**
+     * Request to set the current idle rate for a report on the device.
+     * The response will be received via the CHidTransport::CommandResult function
+     *
+     * @since S60 v5.0
+     * @param aConnID The device identifier
+     * @param aReportID The specific report to be queried
+     * @param aDuration The time period between idle reports (4ms per bit. An
+     *        interval of 0 disables idle reports so that Interrupt reports are only ever
+     *        received when the reported data has changed
+     * @param aReportID The specific report to be queried
+     * @param aInterface The interface we want to query for idle rate
+     * @return None.
+     */
+    virtual void SetIdleL(TInt aConnID,  TUint8 aDuration, TUint8 aReportID,
+        TUint16 aInterface) = 0;
+    };
+
+/**
+ *
+ *  Driver access interface
+ *  Interface allowing drivers to request data from and send data to devices via
+ *  the Generic HID layer.
+ *
+ *  @since S60 v5.0
+ */
+class MDriverAccess
+    {
+public:
+
+    /**
+     * The type of report requested from the device
+     * Note: The enumeration values map directly to the HID equivalent values
+     * (Passed as TUint16 values to the transport layer)
+     */
+    enum TReportType
+        {
+        EInput=1,     /*!< Input report */
+        EOutput,      /*!< Output report */
+        EFeature      /*!< Feature report */
+        };
+
+    /** Return codes from the Generic HID to the device drivers
+     * Note: The enumeration values map directly to the HID equivalent values
+     *(Passed as TUint8 values to the transport layer)
+     */
+
+    enum TProtocols
+        {
+        EBoot=0,        /*!< Boot Protocol */
+        EReport=1       /*!< Report Protocol */
+        };
+
+public:
+
+    /**
+     * Retrieves the country code for the HID device
+     *
+     * @since S60 v5.0
+     * @param aConnID The device identifier
+     * @return contry code
+     */
+    virtual TUint CountryCodeL(TInt aConnID) = 0;
+
+    /**
+     * Retrieves the  for the HID device
+     *
+     * @since S60 v5.0
+     * @param aConnID The device identifier
+     * @return vendor id
+     */
+    virtual TUint VendorIdL(TInt aConnID) = 0;
+
+    /**
+     * Retrieves the product identifier for the HID device
+     *
+     * @since S60 v5.0
+     * @param aConnID The device identifier
+     * @return produrct id
+     */
+    virtual TUint ProductIdL(TInt aConnID) = 0;
+
+    /**
+     * Requests the current protocol for the device (boot or report)
+     * Leaves whit KErrInUse The request was not successful because the transport 
+     * layer is busy with previous request and KErrNotReady The request failed 
+     * because the device is currently unavaila
+     *
+     * @since S60 v5.0
+     * @param aConnectionID The connection id
+     * @param aInterface The current interface being used by the driver
+     * @return None.
+     */
+    virtual void GetProtocolL(TInt aConnectionID,
+        TUint16 aInterface) = 0;
+
+    /**
+     * Requests a report from the device
+     * Leaves whit KErrInUse The request was not successful because the transport 
+     * layer is busy with previous request and KErrNotReady The request failed 
+     * because the device is currently unavailable
+     *
+     * @since S60 v5.0
+     * @param aConnectionId The connection id
+     * @param aReportId The report required from the device
+     * @param aInterface The current interface being used by the driver
+     * @param aLength ** NOT USED **
+     * @return None
+     */
+    virtual void GetReportL(TInt aConnectionId, TUint8 aReportId,
+        TUint16 aInterface, TUint16 aLength) = 0;
+
+    /**
+     * Requests the current Idle setting for the device
+     * Leaves whit KErrInUse The request was not successful because the transport 
+     * layer is busy with previous request and KErrNotReady The request failed 
+     * because the device is currently unavailable
+     *
+     * @since S60 v5.0
+     * @param aConnectionId The device ID
+     * @param aReportId The report required from the device
+     * @param aInterface The current interface being used by the driver
+     * @return None.
+     */
+    virtual void GetIdleL(TInt aConnectionId, TUint8 aReportId,
+        TUint16 aInterface ) = 0;
+
+    /**
+     * Sets the protocol to be used for reports
+     * Leaves whit KErrInUse The request was not successful because the transport 
+     * layer is busy with previous request and KErrNotReady The request failed 
+     * because the device is currently unavailable
+     *
+     * @since S60 v5.0
+     * @param aConnectionId The device ID
+     * @param aInterface The current interface being used by the driver
+     * @param aProtocol The required protocol (boot or report)
+     * @parem aDriver Calling driver
+     * @return None.
+     */
+    virtual void SetProtocolL(TInt aConnectionId,
+        TUint16 aInterface, TProtocols aProtocol, CHidDriver* aDriver) = 0;
+
+    /**
+     * Sets the idle interval for interrupt data.
+     * Leaves whit KErrInUse The request was not successful because the transport 
+     * layer is busy with previous request and KErrNotReady The request failed 
+     * because the device is currently unavailable
+     *
+     * @since S60 v5.0
+     * @param aConnectionId The device ID
+     * @param aDuration The idle interval, in steps of 0.04ms intervals (where
+     *                  1 = 0.04ms, 2=0.08ms). 0 will disable idle so reports
+     *                   are only sent when the state of the device changes
+     * @param aInterface The current interface being used by the driver
+     * @param aReportId The report whose idle rate is being set
+     * @param aInterface The current interface being used by the driver
+     * @parem aDriver Calling driver
+     * @return None.
+     */
+    virtual void SetIdleL(TInt aConnectionId, TUint8 aDuration,
+        TUint8 aReportId, TUint16 aInterface, CHidDriver* aDriver) = 0;
+
+
+    /**
+     * Sends a report to the device
+     *
+     * @since S60 v5.0
+     * @param aConnectionId The device ID
+     * @param aReportId The report to receive the setup report
+     * @param aReportType The type of report being sent to the device (input, output
+     *                     or Feature)
+     * @param aPayload The report being sent to the device
+     * @parem aDriver Calling driver
+     * @param aInterface The current interface being used by the driver
+     * @return KErrNone The request was successful and the result of the command is
+     *         expected at a later time (as a CmdAck message), KErrInUse The request
+     *         was not successful because the transport layer is busy with a previous
+     *         request, KErrNotReady The request failed because the device is currently
+     *         unavailable and KErrNoMemory The request failed because not enough memory
+     *         available
+     */
+    virtual void SetReportL(TInt aConnectionId, TUint8 aReportId,
+        TReportType aReportType, const TDesC8& aPayload,
+        TUint16 aInterface, CHidDriver* aDriver) = 0;
+
+    /**
+     * Sends a report to the device (from host) using Interrupt Channel as DATA
+     *
+     * @since S60 v5.0
+     * @param aConnectionId The device ID
+     * @param aReportId The report to receive the setup report
+     * @param aPayload The report being sent to the device
+     * @param aInterface The current interface being used by the driver
+     * @return KErrNone The request was successful and the result of the
+     *         command is expected at a later time (as a CmdAck message),
+     *         KErrInUse The request was not successful because the transport layer is
+     *         busy with a previous request, KErrNotReady The request failed because the
+     *         device is currently unavailable and KErrNoMemory The request failed because
+     *         not enough memory available
+     */
+    virtual void DataOutL(TInt aConnectionId, TUint8 aReportId,
+        /*TReportType aReportType,*/ const TDesC8& aPayload,
+        TUint16 aInterface) = 0;
+
+    /**
+     * A request for the parsed descriptor container object so the driver can
+     * retrieve the report format(s)
+     *
+     * @since S60 v5.0
+     * @param aConnectionId The device ID
+     * @return A pointer to the parsed report descriptor container and
+     *        NULL if no parsed report descriptor container exists
+     */
+    virtual CReportRoot* ReportDescriptor(TInt aConnectionId) = 0;
+    };
+
+
+/**
+ *
+ *  Hid transport interface
+ *  Interface allowing the transport layer to pass data to the Generic HID
+ *
+ *  @since S60 v5.0
+ */
+class CHidTransport : public CBase
+    {
+public:
+    /**
+     * Defines the channel type for the DataIn function
+     */
+    enum THidChannelType
+        {
+        EHidChannelInt,     /*!< Interrupt channel */
+        EHidChannelCtrl     /*!< Control channel */
+        };
+
+    /**
+     *Driver state (active or suspended)
+     */
+    enum TDriverState
+        {
+        EActive,            /*!< Driver will handle interrupt data */
+        ESuspend            /*!< the driver will not handle interrupt data */
+        };
+
+public:
+
+    /**
+     * Called when a device has connected
+     *
+     * @since S60 v5.0
+     * @param aConnectionId The transport-layer enumeration for the connection
+     * @param aDescriptor The report descriptor for the device
+     * @return KErrNone The connection will be handled by one or more drivers,
+     *         KErrHidNoDriver No driver was found to handle the connected device
+     */
+    virtual TInt ConnectedL(TInt aConnectionId, const TDesC8& aDescriptor) = 0;
+
+    /**
+     * Called when a device has been disconnected
+     *
+     * @since S60 v5.0
+     * @param aConnectionId The transport-layer enumeration for the connection
+     * @param aDescriptor The report descriptor for the device
+     * @return KErrNone The device was recognised and its drivers were unloaded and
+     *         KErrHidNoDriver No driver was found to handle the connected device
+     */
+    virtual TInt Disconnected(TInt aConnectionId) = 0;
+
+    /**
+     * Called when a device has been disconnected
+     *
+     * @since S60 v5.0
+     * @param aConnectionId Transport layer connection enumeration
+     * @param aChannel Channel ID (Interrupt or Control)
+     * @param aPayload The complete report payload
+     * @return KErrNone The payload was handled by one or more drivers,
+     *         KErrHidNoDriver No driver is handling reports from the device
+     *         and KErrHidSuspended The report was not handled because all the drivers
+     *         handling the device are suspended
+     */
+    virtual TInt DataIn(TInt aConnectionId,
+        THidChannelType aChannel, const TDesC8& aPayload) = 0;
+
+    /**
+     * Suspends or Resumes the driver(s) handling the connection
+     *
+     * @since S60 v5.0
+     * @param aConnectionId Transport layer connection enumeration
+     * @param aActive The requested state of the driver (active or suspended)
+     * @return KErrNone The driver was successfully put into the requested state,
+     *         and KErrHidAlreadyInState All the drivers were already in the
+     *         requested state
+     */
+    virtual TInt DriverActive(TInt aConnectionId,
+        CHidTransport::TDriverState aActive) = 0;
+
+    /**
+     * Called by the transport layers to inform the generic HID of the
+     * success of the last Set... command.
+     *
+     * @since S60 v5.0
+     * @param aConnectionId Transport layer connection enumeration
+     * @param  aCmdAck Status of the last Set... command
+     * @return None.
+     */
+    virtual void CommandResult(TInt aConnectionId, TInt aCmdAck) = 0;
+    };
+
+/**
+ *
+ *  Driver plugin interface
+ *  Interface allowing drivers to request data from and send data to devices via
+ *  the Generic HID layer.
+ *
+ *  @lib generichid.lib 
+ *  @since S60 v5.0
+ */
+class CHidDriver : public CBase
+    {
+public:
+
+
+    /**
+     * Two-phased constructor.
+     * @param aImplementationUid Implementation UID of the plugin to be
+     *                           created.
+     * @param aHid               Driver acces interface
+     */
+    IMPORT_C static CHidDriver* NewL(
+	    const TUid aImplementationUid,
+    	MDriverAccess* aHid );
+
+    /**
+     * Destructor
+     */
+     IMPORT_C virtual ~CHidDriver();
+
+    /**
+     * Called by the Generic HID to see if the factory can use reports described by
+     * the parsed report descriptor
+     * NOTE: The current implementation supports just one driver and that driver
+     * that will either handle all the reports from the device or none at all.
+     * Report ID is not currently being taken into account.
+     *
+     * @since S60 v5.0
+     * @param aReportDescriptor Parsed HID report descriptor
+     * @return KErrNone The driver will handle reports from the report descriptor and
+     *         KErrHidUnrecognised The driver cannot handle reports from the device
+     */
+    virtual TInt CanHandleReportL(CReportRoot* aReportDescriptor) = 0;
+
+    /**
+     * Called by the Generic HID layer when a device has sent a report on the
+     * interrupt or control channel
+     *
+     * @since S60 v5.0
+     * @param aChannel Channel ID (Interrupt or Control)
+     * @param aPayload The complete report payload
+     * @return Error if data can't be handled.
+     */
+    virtual TInt DataIn(CHidTransport::THidChannelType aChannel,
+        const TDesC8& aPayload) = 0;
+
+    /**
+     * Called by the Generic HID layer when the handled device has been disconnected
+     * interrupt or control channel
+     *
+     * @since S60 v5.0
+     * @param aReason Disconnection code
+     * @return None.
+     */
+    virtual void Disconnected(TInt aReason) = 0;
+
+    /**
+     * Called after a driver is sucessfully created by the Generic HID,
+     * when a device is connected.
+     *
+     * @since S60 v5.0
+     * @param aConnectionId An number used to identify the device in
+     * subsequent calls from the driver to the generic HID, for example
+     * when sending data to the device.
+     * @return None.
+     */
+    virtual void InitialiseL(TInt aConnectionId) = 0;
+
+    /**
+     * Enables the driver so that it will configure the device and
+     * start handling interrupt reports from the device
+     *
+     * @since S60 v5.0
+     * @param aConnectionId A number used to identify the device in
+     * subsequent calls from the driver to the Generic HID, for example
+     * when sending data to the device.
+     * @return None.
+     */
+    virtual void StartL(TInt aConnectionId) = 0;
+
+    /**
+     * Disables the driver so that it will stop handling device
+     * interrupt reports
+     *
+     * @since S60 v5.0
+     * @return None.
+     */
+    virtual void Stop() = 0;
+
+    /**
+     * Called by the transport layers to inform the generic HID of
+     * the success of the last Set... command.
+     *
+     * @since S60 v5.0
+     * @param  aCmdAck Status of the last Set... command
+     * @return None.
+     */
+    virtual void CommandResult(TInt aCmdAck) = 0;
+    
+    /**
+     * Return count of supported fields
+     *
+     * @since S60 v5.0     
+     * @return Number of supported fields.
+     */
+    virtual TInt SupportedFieldCount()= 0;
+    
+    
+    /**
+     * Set input handling registy 
+     *
+     * @since S60 v5.0     
+     * @param aHandlingReg  a Input handling registry
+     * @return Number of supported fields.
+     */
+    virtual void SetInputHandlingReg(CHidInputDataHandlingReg* aHandlingReg) = 0;
+
+    protected:
+    /**
+     * C++ constructor.
+     */
+    IMPORT_C CHidDriver();
+
+    private: // Data
+
+    /**
+     * ECOM plugin instance UID.
+     */
+    TUid iDtor_ID_Key;
+    };
+    
+#endif
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/generic_hid_api/inc/hidreportroot.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,274 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declares hid report class
+*
+*/
+
+
+#ifndef C_HIDREPORTROOT_H
+#define C_HIDREPORTROOT_H
+
+#include <e32base.h>
+
+#include "hidfield.h"
+#include "hidcollection.h"
+
+#include "hidvalues.h"
+
+class CReportRoot;
+
+
+
+/**
+ * Hid field finder class
+ * The MHidFieldFinder class defines the call-back interface used by
+ * THidFieldSearch. A device driver uses THidFieldSearch::SearchL()
+ * along with a custom MHidFieldFinder object to determine whether it
+ * is compatible with a given report descriptor.
+ *
+ *  @lib generichid.lib
+ *  @since S60 v5.0
+ */
+class MHidFieldFinder
+    {
+public:
+
+    /**
+     * Called by THidFieldSearch::SearchL() during traversal of the
+     * report descriptor tree when a CCollection is encountered. It
+     * will be called once, and only once, for every CCollection in the
+     * descriptor. It is not called for the root collection
+     * (the CReportRoot).
+     *
+     * @since S60 v5.0
+     * @param aCollection A pointer to the collection object.
+     * @return ETrue if the contents of this collection (any child CField
+     * or CCollection objects) should be examined.  A driver would return
+     * EFalse if a collection was not of a compatible type, for
+     * example if the usage page was inappropriate.
+     */
+    virtual TBool BeginCollection(const CCollection *aCollection) = 0;
+
+    /**
+     * Called by THidFieldSearch::SearchL() during traversal of the
+     * report descriptor tree when all CFields and child CCollections
+     * of a CCollection have been examined.  It will be called once,
+     * and only once, for every CCollection in the descriptor. It is
+     * not called for the root collection (the CReportRoot).
+     *
+     * @since S60 v5.0
+     * @param aCollection A pointer to the collection object.
+     * @return ETrue if the search (tree traversal) should
+     * continue. A driver returns EFalse if it has finished examining
+     * the whole descriptor, in general this will be if it has
+     * established that it is compatible with the report descriptor.
+     */
+    virtual TBool EndCollection(const CCollection *aCollection) = 0;
+
+    /**
+     * Called once for each CField in a CCollection by
+     * THidFieldSearch::SearchL() during the traversal of a report
+     * descriptor tree.
+     *
+     * @since S60 v5.0
+     * @param aField The pointer to field
+     * @return None.
+     */
+    virtual void Field(const CField* aField) = 0;
+    };
+
+
+/**
+ *  Report Size
+ *
+ *  @lib generichid.lib
+ *  @since S60 v5.0
+ */
+class TReportSize
+    {
+public:
+
+    /**
+     * Constructor.
+     *
+     * @since S60 v5.0
+     * @param aReportId The report id
+     * @param aType Field type
+     * @return Pointer to report size object
+     */
+    TReportSize(TInt aReportId, CField::TType aType);
+
+
+    /**
+     * TReportSize comparision
+     *
+     * @since S60 v5.0
+     * @param aFirst first report size to be compared.
+     * @param aSecond second report size to be compared
+     * @return None
+     */
+    static TBool Match(const TReportSize& aFirst,
+        const TReportSize& aSecond);
+
+    /**
+     * Report id
+     */
+    TInt iReportId;
+
+    /**
+     * Fiel type
+     */
+    CField::TType iType;
+
+    /**
+     *  Report size
+     */
+    TInt iSize;
+    };
+
+
+/**
+ * Hid field search
+ * THidFieldSearch provides a mechanism for traversing a parsed report
+ * descriptor tree (a CReportRoot object). It is intended for a device
+ * driver to use when it is looking to see if it is compatible with a
+ * newly connected device, i.e. provides the appropriate types of
+ * report. The driver must provide an object of a class that implements
+ * the MHidFieldFinder interface.
+ *
+ * @since S60 v5.0
+ */
+class THidFieldSearch
+    {
+public:
+
+    /**
+     * Traverse a parsed report descriptor (a tree of CCollections
+     * and CFields) calling the MHidFieldFinder member functions as
+     * appropriate.
+     *
+     * @since S60 v5.0
+     * @param aReportRoot THe pointer to field
+     * @param aFinder An object that will establish if the report
+     *                descriptor is suitable.
+     * @return None.
+     */
+    IMPORT_C void SearchL(const CReportRoot* aReportRoot,
+        MHidFieldFinder* aFinder);
+
+private:
+
+    /**
+     * Traverse a parsed report descriptor (a tree of CCollections
+     * and CFields) calling the MHidFieldFinder member functions as
+     * appropriate.
+     *
+     * @since S60 v5.0
+     * @param aReportRoot THe pointer to field
+     * @return ETrue when search is done.
+     */
+    TBool DoSearchL(const CCollection* aCollection);
+
+private:
+    MHidFieldFinder* iFinder;
+    };
+
+/**
+ *  Root report
+ *  The top level of the tree of fields and collections in a HID
+ *  report descriptor.
+ *
+ *  @lib generichid.lib
+ *  @since S60 v5.0
+ */
+class CReportRoot : public CCollection
+    {
+public:
+    static CReportRoot* NewLC();
+    static CReportRoot* NewL();
+
+    /**
+     * Destructor
+     */
+    virtual ~CReportRoot();
+
+    /**
+     * Increase the size of a given report by a given number of bits
+     *
+     * @since S60 v5.0
+     * @param aReportId The report id, which size shoud be increased
+     * @param aType a Type of field
+     * @param aIncrement size of increase
+     * @return None
+     */
+    void IncrementReportSizeL(TInt aReportId,
+        CField::TType aType, TInt aIncrement);
+
+    /**
+     * Get the size of a given report in bits
+     *
+     * @since S60 v5.0
+     * @param aReportId The report id, which size shoud be increased
+     * @param aType a Type of field
+     * @return Size of report in bits
+     */
+    TInt ReportSize(TInt aReportId, CField::TType aType) const;
+
+    /**
+     * Get the size of a given report in bytes
+     *
+     * @since S60 v5.0
+     * @param aReportId The report id, which size shoud be increased
+     * @param aType a Type of field
+     * @return Size of report in bytys
+     */
+    IMPORT_C TInt ReportSizeBytes(TInt aReportId, CField::TType aType) const;
+
+    /**
+     * Get the number of reports
+     *
+     * @since S60 v5.0
+     * @return number of reports
+     */
+    TInt NumberOfReports() const;
+
+    /**
+     * Get the size of a given report by array index, rather than type & ID
+     *
+     * @since S60 v5.0
+     * @param aIndex report index
+     * @return report size
+     */
+    TInt ReportSize(TInt aIndex) const;
+
+private:
+    CReportRoot();
+
+    /**
+     * Find report index
+     *
+     * @since S60 v5.0
+     * @param aReportId The report id to be found
+     * @param aType a Type of field
+     * @return report size
+     */
+    TInt FindReportSizeIndex(TInt aReportId, CField::TType aType) const;
+
+    /**
+     * Array to store the size of each report
+     */
+    RArray<TReportSize> iSizes;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/generic_hid_api/inc/hidtranslate.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,191 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Report translator
+*
+*/
+
+#ifndef T_TRANSLATE_H
+#define T_TRANSLATE_H
+
+#include <e32std.h>
+
+class CField;
+
+/**
+ * HID report base object
+ *
+ * Base class for report translator and report generator.
+ * Contains only static functions.
+ *
+ * @lib  generichid.lib
+ * @since S60 v5.0
+ */
+class TReportUtils
+    {
+public:
+    /**
+     *  Find the index within the usages for a field of a given usage ID.
+     *
+     *  @since S60 v5.0
+     *  @param aField Pointer to the field.
+     *  @param aUsageId Usage ID to find.
+     *  @param aUsageIndex Reference to variable to receive the index.
+     *  @return True if the usage ID is found.
+     */
+    static TBool GetIndexOfUsage(const CField* aField,
+        TInt aUsageId, TInt& aUsageIndex);
+    /**
+     *  Find the usage ID at a given index within the usages for a field.
+     *
+     *  @since S60 v5.0
+     *  @param aField Pointer to the field.
+     *  @param aUsageIndex The index.
+     *  @return The usage ID at the given index.
+     */
+    static TInt UsageAtIndex(const CField* aField, TInt aUsageIndex);
+
+    /**
+     *  Write a value to a field at a given index.
+     *
+     *  @since S60 v5.0
+     *  @param aData Buffer containing the HID report.
+     *  @param aField The field in which to write.
+     *  @param aIndex Position in the field to write.
+     *  @param aValue Value to write to the field.
+     *  @return Error code indicating success or reason for failure.
+     */
+    static TInt WriteData(HBufC8& aData, const CField* aField,
+        TInt aIndex, TInt aValue);
+
+    /**
+     *  Read a value from a field at a given index.
+     *
+     *  @since S60 v5.0
+     *  @param aData Buffer containing the HID report.
+     *  @param aField The field from which to read.
+     *  @param aIndex Position in the field to read.
+     *  @param aValue Reference to variable to receive the value read
+     *                from the field.
+     *  @return Error code indicating success or reason for failure.
+     */
+    static TInt ReadData(const TDesC8& aData, const CField* aField,
+        TInt aIndex, TInt& aValue);
+    };
+
+/**
+ * HID report translator
+ *
+ * Allows a device driver to extract data items from a device report, based on
+ * the results of the report descriptor parser stage (at device connection)
+ *
+ * @lib  generichid.lib
+ * @since S60 v5.0
+ */
+class TReportTranslator
+    {
+public:
+
+    /**
+     * Constructor.
+     *
+     * @since S60 v5.0
+     * @param aData Data to be extracted
+     * @param aField  HID field
+     * @return return TReportTranslator
+     */
+    IMPORT_C TReportTranslator(const TDesC8& aData, const CField* aField);
+
+    /**
+     * For variable fields, reads the logical value of the control with the
+     * given usage ID.  For arrays, searches for the usage ID and gives the
+     * value as ETrue if found and EFalse if not.
+     *
+     * @since S60 v5.0
+     * @param aValue Reference to variable to receive the value read
+     *  from the field.
+     * @param aUsageId Usage ID of the control to read.
+     * @param aControlOffset Which control to read when more than one
+     *                       have the same usage ID.
+     * @return Error code indicating success or reason for failure.
+     */
+    IMPORT_C TInt GetValue(TInt& aValue, TInt aUsageId,
+        TInt aControlOffset = 0) const;
+
+    /**
+     * Alternate version of the above method for convenience.  Returns the
+     * value read directly and leaves if an error occurs.
+     *
+     * @since S60 v5.0
+     * @param aUsageId Usage ID of the control to read.
+     * @param aControlOffset Which control to read when more than one
+     *                       have the same usage ID.
+     * @return The logical value of a variable, or true/false for an array.
+     */
+    IMPORT_C TInt ValueL(TInt aUsageId, TInt aControlOffset = 0) const;
+
+    /**
+     * Gets the usage ID at a given index in an array field.  For variable
+     * fields, if the logical value of the control at the given index is non-
+     * zero, returns the usage ID of the control, otherwise returns zero.
+     *
+     * @since S60 v5.0
+     * @param aUsageId Reference to variable to receive the usage ID.
+     * @param aIndex Index in the array to read.
+     * @return Error code indicating success or reason for failure.
+     */
+    IMPORT_C TInt GetUsageId(TInt& aUsageId, TInt aIndex) const;
+
+    /**
+     * Alternate version of the above method for convenience.  Returns the
+     * usage ID directly and leaves if an error occurs.
+     *
+     * @since S60 v5.0
+     * @param aIndex Index in the array to read.
+     * @return The usage ID.
+     */
+    IMPORT_C TInt UsageIdL(TInt aIndex) const;
+
+    /**
+     * Gets the logical value at a given index in a field.  Leaves if an
+     * error occurs.
+     *
+     * @since S60 v5.0
+     * @param aIndex Index in the field to read.
+     * @return The logical value.
+     */
+    IMPORT_C TInt RawValueL(TInt aIndex) const;
+
+    /**
+     * Gets the number of controls in the field.
+     *
+     * @since S60 v5.0
+     * @return The number of controls.
+     */
+    IMPORT_C TInt Count() const;
+
+private:
+
+    /**
+     * Data to be extracted
+     */
+    const TDesC8& iData;
+
+    /**
+     * HID field
+     * Not own.
+     */
+    const CField* iField;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/generic_hid_api/inc/hidvalues.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,127 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  HID related enums
+*
+*/
+
+
+#ifndef HIDVALUES_H
+#define HIDVALUES_H
+
+#include <e32std.h>
+
+/**
+ * Constants as defined in "USB HID Usage Tables", Version 1.11, USB
+ * Implementers' Forum, June 2001.  Used throughout for parsing report
+ * descriptors and interpreting reports.
+ */
+
+/**
+ * HID usage page ID values, as given in the document "USB HID Usage
+ * Tables", Version 1.11, USB Implementers' Forum, June 2001
+ */
+enum THidUsagePages
+    {
+    EUsagePageUndefined             = 0x00,
+    EUsagePageGenericDesktop        = 0x01,
+    EUsagePageSimulationControls    = 0x02,
+    EUsagePageVRControls            = 0x03,
+    EUsagePageSportControls         = 0x04,
+    EUsagePageGameControls          = 0x05,
+    EUsagePageGenericDeviceControls = 0x06,
+    EUsagePageKeyboard              = 0x07,
+    EUsagePageLEDs                  = 0x08,
+    EUsagePageButton                = 0x09,
+    EUsagePageOrdinal               = 0x0A,
+    EUsagePageTelephony             = 0x0B,
+    EUsagePageConsumer              = 0x0C,
+    EUsagePageDigitizer             = 0x0D,
+    EUsagePagePIDPage               = 0x0F,
+    EUsagePageUnicode               = 0x10,
+    EUsagePageAlphanumericDisplay   = 0x14,
+    EUsagePageMedicalInstruments    = 0x40,
+    EUsagePageMonitorMin            = 0x80,
+    EUsagePageMonitorMax            = 0x83,
+    EUsagePagePowerMin              = 0x84,
+    EUsagePagePowerMax              = 0x87,
+    EUsagePageBarCodeScanner        = 0x8C,
+    EUsagePageScale                 = 0x8D,
+    EUsagePageMagStripe             = 0x8E,
+    EUsagePagePOS                   = 0x8F,
+    EUsagePageCameraControl         = 0x90,
+    EUsagePageArcade                = 0x91,
+    EUsagePageVendorSpecific		= 0xFF01
+    };
+
+/**
+ * HID usage ID values for the Generic Desktop usage page, as given in
+ * the document "USB HID Usage Tables", Version 1.11, USB Implementers'
+ * Forum, June 2001
+ */
+enum THidGenericDesktopUsages
+    {
+    EGenericDesktopUsagePointer       = 0x01,
+    EGenericDesktopUsageMouse         = 0x02,
+    EGenericDesktopUsageJoystick      = 0x04,
+    EGenericDesktopUsagePad           = 0x05,
+    EGenericDesktopUsageKeyboard      = 0x06,
+    EGenericDesktopUsageKeypad        = 0x07,
+    EGenericDesktopUsageMultiAxisCtrl = 0x08,
+    EGenericDesktopUsageX             = 0x30,
+    EGenericDesktopUsageY             = 0x31,
+    EGenericDesktopUsageZ             = 0x32,
+    EGenericDesktopUsageRx            = 0x33,
+    EGenericDesktopUsageRy            = 0x34,
+    EGenericDesktopUsageRz            = 0x35,
+    EGenericDesktopUsageSlider        = 0x36,
+    EGenericDesktopUsageDial          = 0x37,
+    EGenericDesktopUsageWheel         = 0x38,
+    EGenericDesktopUsageHatSwitch     = 0x39,
+    EGenericDesktopUsageCountedBuffer = 0x3A,
+    EGenericDesktopUsageByteCount     = 0x3B,
+    EGenericDesktopUsageMotionWakeup  = 0x3C,
+    EGenericDesktopUsageStart         = 0x3D,
+    EGenericDesktopUsageSelect        = 0x3E
+    };
+
+enum THidTelephonyUsages
+	{
+	ETelephonyUsageHookSwitch       = 0x20,
+	ETelephonyUsagePhoneMute		= 0x2F,
+	ETelephonyUsagePoC              = 0x33
+	};
+
+enum THidConsumerUsages
+	{
+	EConsumerUsagePlay              = 0xB0,
+	EConsumerUsageFastForward       = 0xB3,
+	EConsumerUsageRewind            = 0xB4,
+	EConsumerUsageScanNext          = 0xB5,
+	EConsumerUsageScanPrev          = 0xB6,
+	EConsumerUsageStop              = 0xB7,
+	EConsumerUsageRandomPlay        = 0xB9,
+	EConsumerUsagePlayPause         = 0xCD,
+	EConsumerUsageVolumeInc         = 0xE9,
+	EConsumerUsageVolumeDec         = 0xEA,
+	EConsumerUsageMute              = 0xE2
+	};
+
+enum THidVendorSpecificUsages
+	{
+	EVendorSpecificUsagePoC = 0x01,
+	EVendorSpecificUsageHeadplugDetection = 0x02
+	};
+// ----------------------------------------------------------------------
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Includes all the Domain API specific bld.inf files, which 
+*                export files.
+*
+*/
+
+
+
+#include "../dialup_connection_status_api/group/bld.inf"
+#include "../dun_secondary_display_notification_api/group/bld.inf"
+#include "../generic_hid_api/group/bld.inf"
+#include "../locod_bearer_plugin_api/group/bld.inf"
+#include "../locod_service_plugin_api/group/bld.inf"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/locod_bearer_plugin_api/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                Locod bearer API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/locodplugin.hrh                  MW_LAYER_PLATFORM_EXPORT_PATH(locodplugin.hrh)
+../inc/locodbearer.h                    MW_LAYER_PLATFORM_EXPORT_PATH(locodbearer.h)
+../inc/locodbearerplugin.h              MW_LAYER_PLATFORM_EXPORT_PATH(locodbearerplugin.h)
+../inc/locodbearerplugin.inl            MW_LAYER_PLATFORM_EXPORT_PATH(locodbearerplugin.inl)
+../inc/locodbearerpluginobserver.h      MW_LAYER_PLATFORM_EXPORT_PATH(locodbearerpluginobserver.h)
+../inc/locodbearerpluginparams.h        MW_LAYER_PLATFORM_EXPORT_PATH(locodbearerpluginparams.h)
+../inc/locodbearerpluginparams.inl      MW_LAYER_PLATFORM_EXPORT_PATH(locodbearerpluginparams.inl)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/locod_bearer_plugin_api/group/locod_bearer_plugin_api.mrp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+component	locod_bearer_plugin_api
+
+source \sf\mw\remoteconn\localconnectivityservice\locod_bearer_plugin_api
+
+notes_source	\component_defs\release.src
+
+ipr E 
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/locod_bearer_plugin_api/inc/locodbearer.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Defines the LCD Bearer Plugin identifier.
+*
+*/
+
+
+#ifndef T_LOCODBEARER_H
+#define T_LOCODBEARER_H
+
+#include <e32base.h>
+
+/**  bearer value in LC */
+enum TLocodBearer
+    {
+    ELocodBearerBT =  0x0001,
+	ELocodBearerIR =  0x0010,
+	ELocodBearerUSB = 0x0100,
+    };
+
+#endif // T_LOCODBEARER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/locod_bearer_plugin_api/inc/locodbearerplugin.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,87 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Bearer Plugin base class declaration.
+*
+*/
+
+
+#ifndef C_LOCODBEARERPLUGIN_H
+#define C_LOCODBEARERPLUGIN_H
+
+#include <e32base.h>
+#include "locodbearerpluginparams.h"
+
+/**
+ *  Bearer Plugin base class
+ *
+ *  This is the base class from which bearer plugins inherit.
+ *
+ * See locodplugin.hrh for the resource registration definitions.
+ * 
+ *  @lib euser.lib
+ *  @since S60 v3.2
+ */
+class CLocodBearerPlugin : public CBase
+    {
+public:
+
+    static CLocodBearerPlugin* NewL(TLocodBearerPluginParams& aParams);
+
+    virtual ~CLocodBearerPlugin();
+
+    /**
+     * Gets the implementation uid of this plugin
+     *
+     * @since S60 v3.2
+     * @return The implementation uid
+     */
+    TUid ImplementationUid() const;
+    
+protected:
+
+    CLocodBearerPlugin(TLocodBearerPluginParams& aParams);
+
+    /**
+     * Gets the observer interface object associated with this plugin
+     *
+     * @since S60 v3.2
+     * @return The observer object
+     */
+    MLocodBearerPluginObserver& Observer() const;
+
+private: // data
+
+    /**
+     * UID set by ECOM when the instance is created.  Used when the instance
+     * is destroyed.
+     */
+    TUid iInstanceUid;
+
+    /**
+     * Implementation UID of the concrete instance.
+     */
+    TUid iImplementationUid;
+
+    /**
+     * Holds the observer object which will be notified when the operations
+     * complete
+     * Not own.
+     */
+    MLocodBearerPluginObserver& iObserver;
+
+    };
+
+#include "locodbearerplugin.inl"
+
+#endif // C_LOCODBEARERPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/locod_bearer_plugin_api/inc/locodbearerplugin.inl	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Bearer Plugin construction parameters
+*                declaration
+*
+*/
+
+
+#include <ecom.h>
+
+// -----------------------------------------------------------------------------
+// Creates the bearer plug ins and return it to caller
+// -----------------------------------------------------------------------------
+//
+inline CLocodBearerPlugin* CLocodBearerPlugin::NewL(TLocodBearerPluginParams& aParams)
+    {
+	CLocodBearerPlugin* self = reinterpret_cast<CLocodBearerPlugin*>(
+		REComSession::CreateImplementationL(
+			aParams.ImplementationUid(),
+			_FOFF(CLocodBearerPlugin, iInstanceUid),
+			(TAny*)&aParams)
+		);
+
+	return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+//
+inline CLocodBearerPlugin::~CLocodBearerPlugin()
+    {
+    REComSession::DestroyedImplementation(iInstanceUid);
+    }
+
+// -----------------------------------------------------------------------------
+// Return the implemtation uid
+// -----------------------------------------------------------------------------
+//
+inline TUid CLocodBearerPlugin::ImplementationUid() const
+    {
+    return iImplementationUid;
+    }
+
+// -----------------------------------------------------------------------------
+// Constructor method, just saves the arguments into member variables
+// -----------------------------------------------------------------------------
+//
+inline CLocodBearerPlugin::CLocodBearerPlugin(TLocodBearerPluginParams& aParams)
+    : iImplementationUid(aParams.ImplementationUid()),
+      iObserver(aParams.Observer())
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Return the observer class
+// -----------------------------------------------------------------------------
+//
+inline MLocodBearerPluginObserver& CLocodBearerPlugin::Observer() const
+    {
+    return iObserver;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/locod_bearer_plugin_api/inc/locodbearerpluginobserver.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Bearer Plugin observer interface definition.
+*
+*/
+
+
+#ifndef M_LOCODBEARERPLUGINOBSERVER_H
+#define M_LOCODBEARERPLUGINOBSERVER_H
+
+#include "locodbearer.h"
+
+/**
+ *  LCD Bearer Plugin Observer interface class
+ *
+ *  This is the bearer plugin observer interface definition used by LCD
+ *  Bearer Plugins to inform the daemon about the plugin's event.
+ *
+ *  @euser.lib
+ *  @since S60 v3.2
+ */
+class MLocodBearerPluginObserver
+    {
+public:
+
+    /**
+     * This is a callback function used by the plugins to inform when the
+     * bearer's availability changes.
+     *
+     * @since S60 v3.2
+     * @param  aBearer the bearer which calls this nothification
+     * @param  aStatus the status of this bearer, ETrue if it is available;
+     *                 EFalse otherwise.
+     */
+    virtual void NotifyBearerStatus(TLocodBearer aBearer, TBool aStatus) = 0;
+    };
+
+#endif // M_LOCODBEARERPLUGINOBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/locod_bearer_plugin_api/inc/locodbearerpluginparams.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Bearer Plugin construction parameters
+*                declaration
+*
+*/
+
+
+#ifndef T_LOCODBEARERPLUGINPARAMS_H
+#define T_LOCODBEARERPLUGINPARAMS_H
+
+class MLocodBearerPluginObserver;
+
+/**
+ *  LCD Bearer Plugin Callback construction parameters
+ *
+ *  This interface class is used to pass construction parameters to the
+ *  plugins.  These parameters include the callback interface and the ECOM 
+ *  plugin implementation UID 
+ *
+ *  @euser.lib
+ *  @since S60 v3.2
+ */
+class TLocodBearerPluginParams
+    {
+public:
+
+    /**
+     * Constructor.
+     *
+     * @since S60 v3.2
+     * @param  aUid      Implementation UID of the plugin being constructed
+     * @param  aObserver Callback interface object
+     */
+    TLocodBearerPluginParams(const TUid aUid, MLocodBearerPluginObserver& aObserver);
+
+    /**
+     * Gets the implementation UID of the plugin
+     *
+     * @since S60 v3.2
+     * @return Implementaion UID
+     */
+    TUid ImplementationUid() const;
+
+    /**
+     * Gets the observer interface object
+     *
+     * @since S60 v3.2
+     * @return The observer object
+     */
+    MLocodBearerPluginObserver& Observer() const;    
+
+private: // data
+
+    /**
+     * The implementation UID
+     */
+    const TUid iImplementationUid;
+
+    /**
+     * Reference to the observer object
+     */
+    MLocodBearerPluginObserver& iObserver;
+
+    };
+
+#include "locodbearerpluginparams.inl"
+
+#endif // T_LOCODBEARERPLUGINPARAMS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/locod_bearer_plugin_api/inc/locodbearerpluginparams.inl	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Bearer Plugin construction parameters
+*                declaration
+*
+*/
+
+
+// -----------------------------------------------------------------------------
+// Constructor method, just saves the arguments into member variables
+// -----------------------------------------------------------------------------
+//
+inline TLocodBearerPluginParams::TLocodBearerPluginParams(const TUid aUid, MLocodBearerPluginObserver& aObserver)
+    : iImplementationUid(aUid),
+      iObserver(aObserver)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// returns the implementation UID
+// -----------------------------------------------------------------------------
+//
+inline TUid TLocodBearerPluginParams::ImplementationUid() const
+    {
+    return iImplementationUid;
+    }
+
+// -----------------------------------------------------------------------------
+// returns the  observer class
+// -----------------------------------------------------------------------------
+//
+inline MLocodBearerPluginObserver& TLocodBearerPluginParams::Observer() const
+    {
+    return iObserver;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/locod_bearer_plugin_api/inc/locodplugin.hrh	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definitions for plugin resource registration.
+*
+*/
+
+
+#ifndef LOCODPLUGIN_HRH
+#define LOCODPLUGIN_HRH
+
+/**
+ * This file contains the defintions for plugin resource registration.
+ *
+ * All plugins should use version 2 registration resource file and set the
+ * rom_only field to 1 to prevent it from being overridden by RAM-based plugins.
+ *
+ * All bearer plugins should use KLOCODBEARERINTERFACEUID as the interface UID.
+ *
+ * A bearer plugin should use its corresponding feature ID (from features.hrh) as the
+ * implementation UID,  that is, 
+ *  Implementation UID of IR bearer is KFeatureIdIrda,
+ *  Implementation UID of BT bearer is KFeatureIdBt,
+ *  Implementation UID of USB bearer is KFeatureIdUsb.
+ *
+ * All service plugins should use KLOCODSERVICEINTERFACEUID as the interface UID.
+ *
+ * A service plugin should use its corresponding feature ID (from features.hrh) as the
+ * implementation UID,  that is, 
+ *  Implementation UID of Dun is KFeatureIdDun, (not exist yet, CR created)
+ *  Implementation UID of Obex is KFeatureIdSrcs,
+ * 
+ */
+
+// Interface UID of bearer plugins
+#define  KLOCODBEARERINTERFACEUID 0x20002771
+
+// Interface UID of service plugins
+#define  KLOCODSERVICEINTERFACEUID 0x20002772
+
+#endif // LOCODPLUGIN_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/locod_service_plugin_api/group/bld.inf	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                Locod bearer API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/locodserviceplugin.h             MW_LAYER_PLATFORM_EXPORT_PATH(locodserviceplugin.h)
+../inc/locodserviceplugin.inl           MW_LAYER_PLATFORM_EXPORT_PATH(locodserviceplugin.inl)
+../inc/locodservicepluginobserver.h     MW_LAYER_PLATFORM_EXPORT_PATH(locodservicepluginobserver.h)
+../inc/locodservicepluginparams.h       MW_LAYER_PLATFORM_EXPORT_PATH(locodservicepluginparams.h)
+../inc/locodservicepluginparams.inl      MW_LAYER_PLATFORM_EXPORT_PATH(locodservicepluginparams.inl)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/locod_service_plugin_api/group/locod_service_plugin_api.mrp	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+component	locod_service_plugin_api
+
+source \sf\mw\remoteconn\localconnectivityservice\locod_service_plugin_api
+
+notes_source	\component_defs\release.src
+
+ipr E 
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/locod_service_plugin_api/inc/locodserviceplugin.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,98 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Service Plugin base class declaration.
+*
+*/
+
+
+#ifndef C_LOCODSERVICEPLUGIN_H
+#define C_LOCODSERVICEPLUGIN_H
+
+#include <e32base.h>
+
+#include "locodservicepluginparams.h"
+#include "locodbearer.h"
+    
+/**
+ *  Service Plugin base class
+ *
+ *  This is the base class from which service plugins inherit.
+ *
+ * When a service plugin is constructed, it should not start any service by default.
+ * A service is started on demand when the bearer is available.
+ *
+ *  @euser.lib
+ *  @since S60 v3.2
+ */
+class CLocodServicePlugin : public CBase
+    {
+public:
+
+    static CLocodServicePlugin* NewL(TLocodServicePluginParams& aParams);
+
+    virtual ~CLocodServicePlugin();
+
+    /**
+     * Tell service plugin which service should be enabled or disabled according to
+     * specified bearer and its status.
+     * 
+     * On completion, the plugin should call 
+     * MLocodServicePluginObserver::ManageServiceCompleted() to inform the result.
+     *
+     * @since S60 v3.2
+     * @param  aBearer the bearer identification 
+     * @param  aStatus the status of this bearer, ETrue if it is available;
+     *                 EFalse otherwise.
+     */
+    virtual void ManageService(TLocodBearer aBearer, TBool aStatus) = 0;
+
+    TUid ImplementationUid() const;
+    
+protected:
+
+    CLocodServicePlugin(TLocodServicePluginParams& aParams);
+
+    /**
+     * Gets the observer interface object associated with this plugin
+     *
+     * @since S60 v3.2
+     * @return The observer object
+     */
+    MLocodServicePluginObserver& Observer() const;
+
+private: // data
+
+    /**
+     * UID set by ECOM when the instance is created.  Used when the instance
+     * is destroyed.
+     */
+    TUid iInstanceUid;
+
+    /**
+     * Implementation UID of the concrete instance.
+     */
+    const TUid iImplementationUid;
+
+    /**
+     * Holds the observer object which will be notified when the operations
+     * complete
+     * Not own.
+     */
+    MLocodServicePluginObserver& iObserver;
+
+    };
+
+#include <locodserviceplugin.inl>
+
+#endif // C_LOCODSERVICEPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/locod_service_plugin_api/inc/locodserviceplugin.inl	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Service Plugin construction parameters
+*                declaration
+*
+*/
+
+
+#include <ecom.h>
+
+// -----------------------------------------------------------------------------
+// Constructor method, just saves the arguments into member variables
+// -----------------------------------------------------------------------------
+//
+inline CLocodServicePlugin* CLocodServicePlugin::NewL(TLocodServicePluginParams& aParams)
+    {
+	CLocodServicePlugin* self = reinterpret_cast<CLocodServicePlugin*>(
+		REComSession::CreateImplementationL(
+			aParams.ImplementationUid(),
+			_FOFF(CLocodServicePlugin, iInstanceUid),
+			(TAny*)&aParams)
+		);
+
+	return self;
+    }
+    
+
+// -----------------------------------------------------------------------------
+// Service plug ins destructor
+// -----------------------------------------------------------------------------
+//
+inline CLocodServicePlugin::~CLocodServicePlugin()
+    {
+    REComSession::DestroyedImplementation(iInstanceUid);
+    }
+    
+// -----------------------------------------------------------------------------
+// returns the implementation UID
+// -----------------------------------------------------------------------------
+//
+inline TUid CLocodServicePlugin::ImplementationUid() const
+    {
+    return iImplementationUid;
+    }
+
+// -----------------------------------------------------------------------------
+// CLocodServicePlugin C++ constructor
+// -----------------------------------------------------------------------------
+//
+inline CLocodServicePlugin::CLocodServicePlugin(TLocodServicePluginParams& aParams)
+    : iImplementationUid(aParams.ImplementationUid()),
+      iObserver(aParams.Observer())
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// return the observer class
+// -----------------------------------------------------------------------------
+//
+inline MLocodServicePluginObserver& CLocodServicePlugin::Observer() const
+    {
+    return iObserver;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/locod_service_plugin_api/inc/locodservicepluginobserver.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Service Plugin observer interface definition.
+*
+*/
+
+
+#ifndef M_LOCODSERVICEPLUGINOBSERVER_H
+#define M_LOCODSERVICEPLUGINOBSERVER_H
+
+#include "locodbearer.h"
+
+/**
+ *  LCD Service Plugin Observer interface class
+ *
+ *  This is the service plugin observer interface definition used by LCD
+ *  Service Plugins to inform the daemon when an action is complete.
+ *
+ *  @lib 
+ *  @since S60 v3.2
+ */
+class MLocodServicePluginObserver
+    {
+public:
+
+    /**
+     * This is a callback function used by the plugins to inform when
+     * managing the service have completed.  The parameters passed should be
+     * identical to the ones used when the plugin's ManageService() was called,
+     * plus this service plugin's implemnetation UID and the completion status.
+     *
+     * @since S60 v3.2
+     * @param  aBearer the bearer identification passed in ManageService()
+     * @param  aStatus the status of this bearer passed in ManageService()
+     * @param  aServiceImplUid, the implementation UID of this service plugin.
+     * @param  err     KErrNone if the operation succeeded; otherwise a Symbian
+     *                 error code.
+     */
+    virtual void ManageServiceCompleted(
+        TLocodBearer aBearer,
+        TBool aStatus,
+        TUid aServiceImplUid,
+        TInt err) = 0;
+    };
+
+#endif // M_LOCODSERVICEPLUGINOBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/locod_service_plugin_api/inc/locodservicepluginparams.h	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Service Plugin construction parameters
+*                declaration
+*
+*/
+
+
+#ifndef T_LOCODSERVICEPLUGINPARAMS_H
+#define T_LOCODSERVICEPLUGINPARAMS_H
+
+class MLocodServicePluginObserver;
+
+/**
+ *  LCD Service Plugin Callback construction parameters
+ *
+ *  This interface class is used to pass construction parameters to the
+ *  plugins.  These parameters include the callback interface (usually
+ *  implemented by the LCD) and the ECOM plugin implementation UID 
+ *
+ *  @lib ?library
+ *  @since S60 v3.2
+ */
+class TLocodServicePluginParams
+    {
+public:
+    /**
+     * Constructor.
+     *
+     * @since S60 v3.2
+     * @param  aUid      Implementation UID of the plugin being constructed
+     * @param  aObserver Callback interface object
+     */
+    TLocodServicePluginParams(TUid aUid, MLocodServicePluginObserver& aObserver);
+
+    /**
+     * Gets the implementation UID of the plugin
+     *
+     * @since S60 v3.2
+     * @return Implementaion UID
+     */
+    TUid ImplementationUid() const;
+
+    /**
+     * Gets the observer interface object
+     *
+     * @since S60 v3.2
+     * @return The observer object
+     */
+    MLocodServicePluginObserver& Observer() const;    
+
+private: // data
+
+    /**
+     * The implementation UID
+     */
+    const TUid iImplementationUid;
+
+    /**
+     * Reference to the observer object
+     */
+    MLocodServicePluginObserver& iObserver;
+
+    };
+
+#include "locodservicepluginparams.inl"
+
+#endif // T_LOCODSERVICEPLUGINPARAMS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteconn_plat/locod_service_plugin_api/inc/locodservicepluginparams.inl	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the LCD Service Plugin construction parameters
+*                declaration
+*
+*/
+
+
+// -----------------------------------------------------------------------------
+// Constructor method, just saves the arguments into member variables
+// -----------------------------------------------------------------------------
+//
+inline TLocodServicePluginParams::TLocodServicePluginParams(TUid aUid, MLocodServicePluginObserver& aObserver)
+    : iImplementationUid(aUid),
+      iObserver(aObserver)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Returns the implementation UID
+// -----------------------------------------------------------------------------
+//
+inline TUid TLocodServicePluginParams::ImplementationUid() const
+    {
+    return iImplementationUid;
+    }
+
+// -----------------------------------------------------------------------------
+// return the observer class
+// -----------------------------------------------------------------------------
+//
+inline MLocodServicePluginObserver& TLocodServicePluginParams::Observer() const
+    {
+    return iObserver;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysdef_1_5_1.dtd	Fri Jun 11 14:27:06 2010 +0300
@@ -0,0 +1,88 @@
+ <!ELEMENT SystemDefinition (systemModel?, build?)>
+ <!ATTLIST SystemDefinition
+  name CDATA #REQUIRED
+  schema CDATA #REQUIRED>
+ <!ELEMENT systemModel (layer+)>
+ <!ELEMENT layer (logicalset* | module*)*>
+ <!ATTLIST layer
+  name CDATA #REQUIRED
+  levels CDATA #IMPLIED
+  span CDATA #IMPLIED>
+ <!ELEMENT logicalset (logicalsubset* | module* | unit* | package* | prebuilt*)*>
+ <!ATTLIST logicalset name CDATA #REQUIRED>
+ <!ELEMENT logicalsubset (module* | unit* | package* | prebuilt*)*>
+ <!ATTLIST logicalsubset name CDATA #REQUIRED>
+ <!ELEMENT module (component* | unit* | package* | prebuilt*)*>
+ <!ATTLIST module
+  name CDATA #REQUIRED
+  level CDATA #IMPLIED>
+ <!ELEMENT component (unit* | package* | prebuilt*)*>
+ <!ATTLIST component name CDATA #REQUIRED>
+ <!ELEMENT unit EMPTY>
+ <!ATTLIST unit
+  unitID ID #REQUIRED
+  name CDATA #REQUIRED
+  mrp CDATA #REQUIRED
+  filter CDATA #IMPLIED
+  bldFile CDATA #REQUIRED
+  priority CDATA #IMPLIED
+  contract CDATA #IMPLIED
+  proFile CDATA #IMPLIED
+  qmakeArgs CDATA #IMPLIED>
+ <!ELEMENT package EMPTY>
+ <!ATTLIST package
+  name CDATA #REQUIRED
+  mrp CDATA #REQUIRED
+  filter CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT prebuilt EMPTY>
+ <!ATTLIST prebuilt
+  name CDATA #REQUIRED
+  version CDATA #REQUIRED
+  late (Y|N) #IMPLIED
+  filter CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT build (option* | target+ | targetList+ | unitList+ | configuration+)*>
+ <!ELEMENT unitList (unitRef+)>
+ <!ATTLIST unitList
+  name ID #REQUIRED
+  description CDATA #REQUIRED>
+ <!ELEMENT unitRef EMPTY>
+ <!ATTLIST unitRef unit IDREF #REQUIRED>
+ <!ELEMENT targetList EMPTY>
+ <!ATTLIST targetList
+  name ID #REQUIRED
+  description CDATA #REQUIRED
+  target IDREFS #REQUIRED>
+ <!ELEMENT target EMPTY>
+ <!ATTLIST target
+  name ID #REQUIRED
+  abldTarget CDATA #REQUIRED
+  description CDATA #REQUIRED>
+ <!ELEMENT option EMPTY>
+ <!ATTLIST option
+  name ID #REQUIRED
+  abldOption CDATA #REQUIRED
+  description CDATA #REQUIRED
+  enable (Y | N | y | n) #REQUIRED>
+ <!ELEMENT configuration (unitListRef+ | layerRef+ | task+)*>
+ <!ATTLIST configuration
+  name ID #REQUIRED
+  description CDATA #REQUIRED
+  filter CDATA #REQUIRED>
+ <!ELEMENT task ( unitListRef* , (buildLayer | specialInstructions))>
+ <!ELEMENT unitListRef EMPTY>
+ <!ATTLIST unitListRef unitList IDREF #REQUIRED>
+ <!ELEMENT layerRef EMPTY>
+ <!ATTLIST layerRef layerName CDATA #REQUIRED>
+ <!ELEMENT buildLayer EMPTY>
+ <!ATTLIST buildLayer
+  command CDATA #REQUIRED
+  targetList IDREFS #IMPLIED
+  unitParallel (Y | N | y | n) #REQUIRED
+  targetParallel (Y | N | y | n) #IMPLIED>
+ <!ELEMENT specialInstructions EMPTY>
+ <!ATTLIST specialInstructions
+  name CDATA #REQUIRED
+  cwd CDATA #REQUIRED
+  command CDATA #REQUIRED>